@openapi-flow/core 0.3.10 → 0.3.12
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/dist/arguments/clarification/api-input-requirement-dialect.d.ts +4 -0
- package/dist/arguments/clarification/api-input-requirement-dialect.js +8 -0
- package/dist/arguments/clarification/extraction/capture-api-input-answer-context.js +2 -3
- package/dist/arguments/clarification/extraction/create-api-input-answer-extraction-record.js +9 -2
- package/dist/arguments/clarification/extraction/resolve-api-input-answer-interpretations.d.ts +3 -0
- package/dist/arguments/clarification/extraction/resolve-api-input-answer-interpretations.js +52 -0
- package/dist/arguments/clarification/extraction/resolve-api-input-answer-sources.js +3 -3
- package/dist/arguments/clarification/extraction/resolve-api-input-source-selections.js +1 -0
- package/dist/arguments/clarification/extraction/validate-api-input-answer-analysis.d.ts +3 -0
- package/dist/arguments/clarification/extraction/validate-api-input-answer-analysis.js +56 -0
- package/dist/arguments/clarification/extraction/validate-api-input-answer-extraction-record.js +4 -0
- package/dist/arguments/enum/describe-api-argument-enum-context.d.ts +4 -0
- package/dist/arguments/enum/describe-api-argument-enum-context.js +41 -0
- package/dist/arguments/enum/describe-api-input-enum-answer-choices.d.ts +4 -0
- package/dist/arguments/enum/describe-api-input-enum-answer-choices.js +23 -0
- package/dist/arguments/enum/expand-requested-enum-requirements.d.ts +4 -0
- package/dist/arguments/enum/expand-requested-enum-requirements.js +45 -0
- package/dist/arguments/enum/list-api-input-enum-candidates.d.ts +3 -0
- package/dist/arguments/enum/list-api-input-enum-candidates.js +73 -0
- package/dist/arguments/enum/resolve-api-argument-enum-interpretation.d.ts +3 -0
- package/dist/arguments/enum/resolve-api-argument-enum-interpretation.js +26 -0
- package/dist/arguments/sources/resolve-api-literal-proposal-sources.d.ts +3 -0
- package/dist/arguments/sources/resolve-api-literal-proposal-sources.js +58 -0
- package/dist/draft/edits/api/describe-workflow-draft-api-enum-choices.d.ts +3 -0
- package/dist/draft/edits/api/describe-workflow-draft-api-enum-choices.js +70 -0
- package/dist/draft/edits/api/resolve-workflow-draft-api-call-arguments.js +9 -5
- package/dist/draft/edits/api/resolve-workflow-draft-api-enum-selections.d.ts +4 -0
- package/dist/draft/edits/api/resolve-workflow-draft-api-enum-selections.js +38 -0
- package/dist/draft/edits/api/resolve-workflow-draft-api-literal-sources.js +9 -56
- package/dist/draft/edits/enum/verify-workflow-draft-api-enum-selection.d.ts +3 -0
- package/dist/draft/edits/enum/verify-workflow-draft-api-enum-selection.js +23 -0
- package/dist/draft/edits/inputs/describe-workflow-draft-api-input-edit-answer-requirements.d.ts +4 -0
- package/dist/draft/edits/inputs/describe-workflow-draft-api-input-edit-answer-requirements.js +30 -0
- package/dist/draft/edits/inputs/describe-workflow-draft-api-input-edit-enum-choices.d.ts +4 -0
- package/dist/draft/edits/inputs/describe-workflow-draft-api-input-edit-enum-choices.js +42 -0
- package/dist/draft/edits/inputs/resolve-workflow-draft-api-input-edit-reply.d.ts +3 -0
- package/dist/draft/edits/inputs/resolve-workflow-draft-api-input-edit-reply.js +24 -0
- package/dist/draft/edits/inputs/resolve-workflow-draft-api-input-edits.js +20 -0
- package/dist/public-api.d.ts +18 -0
- package/dist/public-api.js +13 -0
- package/dist/schemas/api-input-answer-extraction-schema.d.ts +16 -0
- package/dist/schemas/api-input-answer-extraction-schema.js +9 -0
- package/dist/schemas/api-input-enum-answer-selection-schema.d.ts +25 -0
- package/dist/schemas/api-input-enum-answer-selection-schema.js +11 -0
- package/dist/schemas/create-workflow-draft-api-input-edit-values-schema.js +11 -2
- package/dist/schemas/workflow-draft-api-enum-choice-schema.d.ts +5 -0
- package/dist/schemas/workflow-draft-api-enum-choice-schema.js +25 -0
- package/dist/schemas/workflow-draft-api-enum-selection-schema.d.ts +4 -0
- package/dist/schemas/workflow-draft-api-enum-selection-schema.js +14 -0
- package/dist/schemas/workflow-draft-api-input-edit-proposal-schema.js +3 -1
- package/dist/types/api-argument-enum.d.ts +23 -0
- package/dist/types/api-argument-enum.js +1 -0
- package/dist/types/api-arguments.d.ts +6 -0
- package/dist/types/api-clarification.d.ts +2 -0
- package/dist/types/api-input-answer-extraction.d.ts +11 -2
- package/dist/types/api-input-enum-answers.d.ts +25 -0
- package/dist/types/api-input-enum-answers.js +1 -0
- package/dist/types/api-input-enum.d.ts +26 -0
- package/dist/types/api-input-enum.js +1 -0
- package/dist/types/api-input-literal-source.d.ts +15 -0
- package/dist/types/workflow-draft-api-call-planning.d.ts +4 -0
- package/dist/types/workflow-draft-api-enum-selection.d.ts +39 -0
- package/dist/types/workflow-draft-api-enum-selection.js +1 -0
- package/dist/types/workflow-draft-api-input-edit.d.ts +15 -2
- package/dist/types/workflow-draft-api-literal-sources.d.ts +3 -9
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { inspectApiArgumentRequirements } from '../../../arguments/clarification
|
|
|
5
5
|
import { resolveWorkflowDraftSourceEvidence } from '../references/resolve-workflow-draft-source-evidence.js';
|
|
6
6
|
import { jsonValuesEqual } from '../../../utils/json-values-equal.js';
|
|
7
7
|
import { resolveWorkflowDraftApiLiteralSources } from './resolve-workflow-draft-api-literal-sources.js';
|
|
8
|
+
import { resolveWorkflowDraftApiEnumSelections } from './resolve-workflow-draft-api-enum-selections.js';
|
|
8
9
|
/** Resolve one actual request; partial values become typed questions/slots, never dummy data. */
|
|
9
10
|
export function resolveWorkflowDraftApiCallArguments(input) {
|
|
10
11
|
const { description, fingerprint } = resolveApiCallArgumentsContext(input);
|
|
@@ -13,13 +14,18 @@ export function resolveWorkflowDraftApiCallArguments(input) {
|
|
|
13
14
|
const proposal = createWorkflowDraftApiCallArgumentsSchema(input).parse(input.proposal);
|
|
14
15
|
if (!jsonValuesEqual(proposal, input.proposal))
|
|
15
16
|
throw new Error('API call arguments must validate without defaults, coercion or transformation');
|
|
17
|
+
const literalSources = resolveWorkflowDraftApiLiteralSources({
|
|
18
|
+
description,
|
|
19
|
+
proposal,
|
|
20
|
+
});
|
|
21
|
+
const enums = resolveWorkflowDraftApiEnumSelections({ ...input, proposal });
|
|
16
22
|
const values = applyConfirmedApiInputs({
|
|
17
23
|
callId: description.nodeId,
|
|
18
24
|
operation: description.operation,
|
|
19
25
|
requestMediaType: description.requestMediaType,
|
|
20
26
|
bindings: input.bindingPlan.bindings,
|
|
21
27
|
confirmedInputs: input.confirmedInputs,
|
|
22
|
-
values:
|
|
28
|
+
values: enums.values,
|
|
23
29
|
});
|
|
24
30
|
const inspected = inspectApiArgumentRequirements({
|
|
25
31
|
callId: description.nodeId,
|
|
@@ -32,10 +38,8 @@ export function resolveWorkflowDraftApiCallArguments(input) {
|
|
|
32
38
|
const fields = {
|
|
33
39
|
fingerprint,
|
|
34
40
|
proposal,
|
|
35
|
-
literalSources
|
|
36
|
-
|
|
37
|
-
proposal,
|
|
38
|
-
}),
|
|
41
|
+
literalSources,
|
|
42
|
+
...(enums.selections.length ? { enumSelections: enums.selections } : {}),
|
|
39
43
|
...resolveWorkflowDraftSourceEvidence({
|
|
40
44
|
description,
|
|
41
45
|
decision: proposal,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResolveWorkflowDraftApiCallArgumentsInput } from '../../../types/workflow-draft-api-call-planning.js';
|
|
2
|
+
import type { WorkflowDraftApiEnumResolution } from '../../../types/workflow-draft-api-enum-selection.js';
|
|
3
|
+
/** Copy from the current OAS, never from model-supplied values or same-name fields. */
|
|
4
|
+
export declare function resolveWorkflowDraftApiEnumSelections(input: ResolveWorkflowDraftApiCallArgumentsInput): WorkflowDraftApiEnumResolution;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describeWorkflowDraftApiEnumChoices } from './describe-workflow-draft-api-enum-choices.js';
|
|
2
|
+
import { createWorkflowDraftApiEnumSelectionSchema } from '../../../schemas/workflow-draft-api-enum-selection-schema.js';
|
|
3
|
+
import { assignApiInputValue } from '../../../arguments/clarification/assign-api-input-value.js';
|
|
4
|
+
import { resolveApiCallArgumentsContext } from './resolve-api-call-arguments-context.js';
|
|
5
|
+
import { verifyWorkflowDraftApiEnumSelection } from '../enum/verify-workflow-draft-api-enum-selection.js';
|
|
6
|
+
/** Copy from the current OAS, never from model-supplied values or same-name fields. */
|
|
7
|
+
export function resolveWorkflowDraftApiEnumSelections(input) {
|
|
8
|
+
const values = structuredClone(input.proposal.values);
|
|
9
|
+
const verified = [];
|
|
10
|
+
if (input.enumSelections === undefined)
|
|
11
|
+
return { values, selections: verified };
|
|
12
|
+
const { candidates } = describeWorkflowDraftApiEnumChoices(input);
|
|
13
|
+
const proposal = createWorkflowDraftApiEnumSelectionSchema(input).parse({
|
|
14
|
+
selections: input.enumSelections,
|
|
15
|
+
});
|
|
16
|
+
const { description } = resolveApiCallArgumentsContext(input);
|
|
17
|
+
for (const selection of proposal.selections) {
|
|
18
|
+
const candidate = candidates.find((item) => item.id === selection.candidateId);
|
|
19
|
+
if (!candidate)
|
|
20
|
+
throw new Error(`API enum selection ${selection.candidateId} is absent from the current OAS choices`);
|
|
21
|
+
if (verified.some((item) => item.targetPointer === candidate.targetPointer ||
|
|
22
|
+
item.targetPointer.startsWith(candidate.targetPointer + '/') ||
|
|
23
|
+
candidate.targetPointer.startsWith(item.targetPointer + '/')))
|
|
24
|
+
throw new Error(`API enum selections overlap at ${candidate.targetPointer}`);
|
|
25
|
+
const receipt = verifyWorkflowDraftApiEnumSelection({
|
|
26
|
+
selection,
|
|
27
|
+
candidates,
|
|
28
|
+
messages: [...description.messages, ...description.backgroundMessages],
|
|
29
|
+
});
|
|
30
|
+
assignApiInputValue(values, candidate.targetPointer, structuredClone(candidate.value), {
|
|
31
|
+
operation: description.operation,
|
|
32
|
+
requestMediaType: description.requestMediaType,
|
|
33
|
+
callId: description.nodeId,
|
|
34
|
+
});
|
|
35
|
+
verified.push(receipt);
|
|
36
|
+
}
|
|
37
|
+
return { values, selections: verified };
|
|
38
|
+
}
|
|
@@ -1,60 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { verifyApiInputLiteralSource } from '../../../arguments/sources/verify-api-input-literal-source.js';
|
|
1
|
+
import { resolveApiLiteralProposalSources } from '../../../arguments/sources/resolve-api-literal-proposal-sources.js';
|
|
3
2
|
/** OAS validation and message existence alone do not establish a literal's origin. */
|
|
4
3
|
export function resolveWorkflowDraftApiLiteralSources(input) {
|
|
5
4
|
const { description, proposal } = input;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const message = messages.find((entry) => entry.id === selection.messageId);
|
|
15
|
-
if (!message)
|
|
16
|
-
throw new Error(`${label} cites unavailable user message ${selection.messageId}`);
|
|
17
|
-
const proposed = pointerValue(proposal.values, selection.targetPointer);
|
|
18
|
-
if (proposed === undefined)
|
|
19
|
-
throw new Error(`${label} source targets an absent proposed value`);
|
|
20
|
-
const parsed = verifyApiInputLiteralSource({
|
|
21
|
-
...selection,
|
|
22
|
-
text: message.text,
|
|
23
|
-
label,
|
|
24
|
-
value: proposed,
|
|
25
|
-
});
|
|
26
|
-
sources.push({ ...selection, occurrences: parsed.occurrences });
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
function check(value, pointer) {
|
|
30
|
-
if (sources.some((source) => isAncestor(source.targetPointer, pointer)))
|
|
31
|
-
return;
|
|
32
|
-
if (value !== null &&
|
|
33
|
-
typeof value === 'object' &&
|
|
34
|
-
Object.keys(value).length) {
|
|
35
|
-
for (const [key, child] of Object.entries(value))
|
|
36
|
-
check(child, `${pointer}/${key.replaceAll('~', '~0').replaceAll('/', '~1')}`);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
throw new Error(`API ${description.nodeId} literal ${pointer} requires an exact user source in literalSources`);
|
|
40
|
-
}
|
|
41
|
-
for (const [root, value] of Object.entries(proposal.values)) {
|
|
42
|
-
// Empty parameter-location objects contain no request values. Empty body
|
|
43
|
-
// objects/arrays are actual data and still require their own source.
|
|
44
|
-
if (root !== 'body' &&
|
|
45
|
-
value !== null &&
|
|
46
|
-
typeof value === 'object' &&
|
|
47
|
-
!Object.keys(value).length)
|
|
48
|
-
continue;
|
|
49
|
-
check(value, `/${root}`);
|
|
50
|
-
}
|
|
51
|
-
return sources;
|
|
52
|
-
}
|
|
53
|
-
function isAncestor(ancestor, pointer) {
|
|
54
|
-
return (ancestor === '' ||
|
|
55
|
-
pointer === ancestor ||
|
|
56
|
-
pointer.startsWith(`${ancestor}/`));
|
|
57
|
-
}
|
|
58
|
-
function overlaps(left, right) {
|
|
59
|
-
return isAncestor(left, right) || isAncestor(right, left);
|
|
5
|
+
// Empty parameter-location objects contain no request values. Empty body
|
|
6
|
+
// objects/arrays are actual data and still require their own source.
|
|
7
|
+
return resolveApiLiteralProposalSources({
|
|
8
|
+
callId: description.nodeId,
|
|
9
|
+
values: proposal.values,
|
|
10
|
+
sources: proposal.literalSources === undefined ? [] : proposal.literalSources,
|
|
11
|
+
messages: [...description.messages, ...description.backgroundMessages],
|
|
12
|
+
});
|
|
60
13
|
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { VerifyWorkflowDraftApiEnumSelectionInput, VerifiedWorkflowDraftApiEnumSelection } from '../../../types/workflow-draft-api-enum-selection.js';
|
|
2
|
+
/** Human intent is a separate receipt; the selected request value comes only from the OAS. */
|
|
3
|
+
export declare function verifyWorkflowDraftApiEnumSelection(input: VerifyWorkflowDraftApiEnumSelectionInput): VerifiedWorkflowDraftApiEnumSelection;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createWorkflowDraftApiEnumChoiceSchema } from '../../../schemas/workflow-draft-api-enum-choice-schema.js';
|
|
2
|
+
import { readApiInputLiteralSource } from '../../../arguments/sources/read-api-input-literal-source.js';
|
|
3
|
+
/** Human intent is a separate receipt; the selected request value comes only from the OAS. */
|
|
4
|
+
export function verifyWorkflowDraftApiEnumSelection(input) {
|
|
5
|
+
const selection = createWorkflowDraftApiEnumChoiceSchema(input.candidates, input.messages.map((message) => message.id)).parse(input.selection);
|
|
6
|
+
const candidate = input.candidates.find((item) => item.id === selection.candidateId);
|
|
7
|
+
if (!candidate)
|
|
8
|
+
throw new Error(`API enum selection ${selection.candidateId} is absent from the current OAS choices`);
|
|
9
|
+
const message = input.messages.find((item) => item.id === selection.messageId);
|
|
10
|
+
if (!message)
|
|
11
|
+
throw new Error(`API enum selection cites unavailable message ${selection.messageId}`);
|
|
12
|
+
const source = readApiInputLiteralSource({
|
|
13
|
+
sourceFormat: 'text',
|
|
14
|
+
sourceText: selection.sourceText,
|
|
15
|
+
text: message.text,
|
|
16
|
+
label: `API enum ${candidate.targetPointer}`,
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
...structuredClone(candidate),
|
|
20
|
+
...selection,
|
|
21
|
+
occurrences: source.occurrences,
|
|
22
|
+
};
|
|
23
|
+
}
|
package/dist/draft/edits/inputs/describe-workflow-draft-api-input-edit-answer-requirements.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ResolveWorkflowDraftApiInputEditsInput } from '../../../types/workflow-draft-api-input-edit.js';
|
|
2
|
+
import type { ApiInputRequirement } from '../../../types/api-clarification.js';
|
|
3
|
+
/** Questions for actual pending set-targets, retaining references and declaring the compiled dialect. */
|
|
4
|
+
export declare function describeWorkflowDraftApiInputEditAnswerRequirements(input: ResolveWorkflowDraftApiInputEditsInput): ApiInputRequirement[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describeWorkflowDraftApiInputEdit } from './describe-workflow-draft-api-input-edit.js';
|
|
2
|
+
import { resolveWorkflowDraftApiInputEdits } from './resolve-workflow-draft-api-input-edits.js';
|
|
3
|
+
import { createSchemaResourceContext } from '../../../bindings/resources/create-schema-resource-context.js';
|
|
4
|
+
/** Questions for actual pending set-targets, retaining references and declaring the compiled dialect. */
|
|
5
|
+
export function describeWorkflowDraftApiInputEditAnswerRequirements(input) {
|
|
6
|
+
const result = resolveWorkflowDraftApiInputEdits(input);
|
|
7
|
+
if (result.status === 'ready')
|
|
8
|
+
return [];
|
|
9
|
+
const described = describeWorkflowDraftApiInputEdit(input);
|
|
10
|
+
const resources = createSchemaResourceContext(input.contract.schemaResource);
|
|
11
|
+
return result.pendingTargets.map((target) => {
|
|
12
|
+
if (target.kind !== 'set')
|
|
13
|
+
throw new Error(`Pending API edit ${input.contract.id}:${target.id} is not a set-target`);
|
|
14
|
+
return {
|
|
15
|
+
kind: 'requested-input',
|
|
16
|
+
id: `${input.contract.id}:${target.id}`,
|
|
17
|
+
callId: described.call.id,
|
|
18
|
+
operation: structuredClone(described.operation.key),
|
|
19
|
+
targetPointer: target.pointer,
|
|
20
|
+
schema: resources.bundle(target.schema),
|
|
21
|
+
openapiVersion: described.operation.openapiVersion,
|
|
22
|
+
schemaDialect: 'draft-2020-12',
|
|
23
|
+
requestedInputs: [target.pointer],
|
|
24
|
+
...(typeof described.operation.operation.summary === 'string'
|
|
25
|
+
? { operationSummary: described.operation.operation.summary }
|
|
26
|
+
: {}),
|
|
27
|
+
message: `Provide the new explicitly requested value at ${target.pointer}. The existing value is not an answer to this edit.`,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WorkflowDraftApiInputEditContractInput } from '../../../types/workflow-draft-api-input-edit.js';
|
|
2
|
+
import type { WorkflowDraftApiEnumChoicesDescription } from '../../../types/workflow-draft-api-enum-selection.js';
|
|
3
|
+
/** Only previously validated set-targets; never advertise remove targets, bindings or unrelated fields. */
|
|
4
|
+
export declare function describeWorkflowDraftApiInputEditEnumChoices(input: WorkflowDraftApiInputEditContractInput): WorkflowDraftApiEnumChoicesDescription;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { validateWorkflowDraftApiInputEditContract } from './validate-workflow-draft-api-input-edit-contract.js';
|
|
2
|
+
import { describeWorkflowDraftApiInputEdit } from './describe-workflow-draft-api-input-edit.js';
|
|
3
|
+
import { createSchemaResourceContext } from '../../../bindings/resources/create-schema-resource-context.js';
|
|
4
|
+
import { listApiInputEnumCandidates } from '../../../arguments/enum/list-api-input-enum-candidates.js';
|
|
5
|
+
/** Only previously validated set-targets; never advertise remove targets, bindings or unrelated fields. */
|
|
6
|
+
export function describeWorkflowDraftApiInputEditEnumChoices(input) {
|
|
7
|
+
validateWorkflowDraftApiInputEditContract(input);
|
|
8
|
+
if (input.selectOasEnums !== undefined &&
|
|
9
|
+
typeof input.selectOasEnums !== 'boolean')
|
|
10
|
+
throw new Error('API input edit selectOasEnums must be a boolean');
|
|
11
|
+
const result = {
|
|
12
|
+
candidates: [],
|
|
13
|
+
targets: [],
|
|
14
|
+
};
|
|
15
|
+
if (input.selectOasEnums !== true)
|
|
16
|
+
return result;
|
|
17
|
+
const description = describeWorkflowDraftApiInputEdit(input);
|
|
18
|
+
const resources = createSchemaResourceContext(input.contract.schemaResource);
|
|
19
|
+
for (const target of input.contract.targets) {
|
|
20
|
+
if (target.kind !== 'set')
|
|
21
|
+
continue;
|
|
22
|
+
const candidates = listApiInputEnumCandidates({
|
|
23
|
+
source: {
|
|
24
|
+
kind: 'operation',
|
|
25
|
+
callId: description.call.id,
|
|
26
|
+
operation: description.operation,
|
|
27
|
+
requestMediaType: description.call.requestMediaType,
|
|
28
|
+
targetPointer: target.pointer,
|
|
29
|
+
},
|
|
30
|
+
schemas: [target.schema],
|
|
31
|
+
resources,
|
|
32
|
+
});
|
|
33
|
+
if (candidates.length) {
|
|
34
|
+
result.candidates.push(...candidates);
|
|
35
|
+
result.targets.push({
|
|
36
|
+
targetPointer: target.pointer,
|
|
37
|
+
schema: resources.bundle(target.schema),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ResolveWorkflowDraftApiInputEditReplyInput, WorkflowDraftApiInputEditAnswers } from '../../../types/workflow-draft-api-input-edit.js';
|
|
2
|
+
/** Interpretations become validated answer values, never a replacement model proposal. */
|
|
3
|
+
export declare function resolveWorkflowDraftApiInputEditReply(input: ResolveWorkflowDraftApiInputEditReplyInput): WorkflowDraftApiInputEditAnswers;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describeWorkflowDraftApiInputEditAnswerRequirements } from './describe-workflow-draft-api-input-edit-answer-requirements.js';
|
|
2
|
+
import { validateApiInputAnswerAnalysis } from '../../../arguments/clarification/extraction/validate-api-input-answer-analysis.js';
|
|
3
|
+
import { createWorkflowDraftApiInputEditAnswersSchema } from '../../../schemas/create-workflow-draft-api-input-edit-answers-schema.js';
|
|
4
|
+
/** Interpretations become validated answer values, never a replacement model proposal. */
|
|
5
|
+
export function resolveWorkflowDraftApiInputEditReply(input) {
|
|
6
|
+
const requirements = describeWorkflowDraftApiInputEditAnswerRequirements(input);
|
|
7
|
+
validateApiInputAnswerAnalysis({
|
|
8
|
+
reply: input.reply,
|
|
9
|
+
requirements,
|
|
10
|
+
...(input.selectOasEnums === undefined
|
|
11
|
+
? {}
|
|
12
|
+
: { selectOasEnums: input.selectOasEnums }),
|
|
13
|
+
analysis: input.analysis,
|
|
14
|
+
});
|
|
15
|
+
return createWorkflowDraftApiInputEditAnswersSchema(input).parse({
|
|
16
|
+
contractId: input.contract.id,
|
|
17
|
+
answers: input.analysis.answers.map((answer) => {
|
|
18
|
+
const target = input.contract.targets.find((target) => `${input.contract.id}:${target.id}` === answer.requirementId);
|
|
19
|
+
if (!target)
|
|
20
|
+
throw new Error(`API edit reply references an unavailable target ${answer.requirementId}`);
|
|
21
|
+
return { targetId: target.id, value: structuredClone(answer.value) };
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -6,6 +6,8 @@ import { applyWorkflowDraftApiInputEdits } from '../values/apply-workflow-draft-
|
|
|
6
6
|
import { validateApiArguments } from '../../../arguments/validate-api-arguments.js';
|
|
7
7
|
import { orderWorkflowDraftValueEdits } from '../values/order-workflow-draft-value-edits.js';
|
|
8
8
|
import { verifyApiInputLiteralSource } from '../../../arguments/sources/verify-api-input-literal-source.js';
|
|
9
|
+
import { describeWorkflowDraftApiInputEditEnumChoices } from './describe-workflow-draft-api-input-edit-enum-choices.js';
|
|
10
|
+
import { verifyWorkflowDraftApiEnumSelection } from '../enum/verify-workflow-draft-api-enum-selection.js';
|
|
9
11
|
/** Exact-source validation is deterministic; it is not semantic entailment proof. */
|
|
10
12
|
export function resolveWorkflowDraftApiInputEdits(input) {
|
|
11
13
|
const output = createWorkflowDraftApiInputEditValuesSchema(input).parse(input.output);
|
|
@@ -19,12 +21,28 @@ export function resolveWorkflowDraftApiInputEdits(input) {
|
|
|
19
21
|
const sets = [];
|
|
20
22
|
const removals = [];
|
|
21
23
|
const pendingTargets = [];
|
|
24
|
+
const enumSelections = [];
|
|
25
|
+
const { candidates } = describeWorkflowDraftApiInputEditEnumChoices(input);
|
|
22
26
|
for (const target of input.contract.targets) {
|
|
23
27
|
if (target.kind === 'remove') {
|
|
24
28
|
removals.push({ kind: 'remove', pointer: target.pointer });
|
|
25
29
|
continue;
|
|
26
30
|
}
|
|
27
31
|
const answer = output.values[target.id];
|
|
32
|
+
if (answer.status === 'oas-enum') {
|
|
33
|
+
const selection = verifyWorkflowDraftApiEnumSelection({
|
|
34
|
+
selection: answer.selection,
|
|
35
|
+
candidates: candidates.filter((candidate) => candidate.targetPointer === target.pointer),
|
|
36
|
+
messages: described.messages,
|
|
37
|
+
});
|
|
38
|
+
sets.push({
|
|
39
|
+
kind: 'set',
|
|
40
|
+
pointer: target.pointer,
|
|
41
|
+
value: structuredClone(selection.value),
|
|
42
|
+
});
|
|
43
|
+
enumSelections.push(selection);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
28
46
|
if (answer.explanation)
|
|
29
47
|
validateWorkflowPlanningEvidence({
|
|
30
48
|
context: { messages: described.messages },
|
|
@@ -60,6 +78,7 @@ export function resolveWorkflowDraftApiInputEdits(input) {
|
|
|
60
78
|
values: output,
|
|
61
79
|
pendingTargets,
|
|
62
80
|
...human,
|
|
81
|
+
...(enumSelections.length ? { enumSelections } : {}),
|
|
63
82
|
};
|
|
64
83
|
// Targets address the original value. Set before deletion; remove higher array
|
|
65
84
|
// indices first so one deletion does not retarget another original index.
|
|
@@ -80,6 +99,7 @@ export function resolveWorkflowDraftApiInputEdits(input) {
|
|
|
80
99
|
contractId: input.contract.id,
|
|
81
100
|
values: output,
|
|
82
101
|
...human,
|
|
102
|
+
...(enumSelections.length ? { enumSelections } : {}),
|
|
83
103
|
resolution: {
|
|
84
104
|
stepId: input.stepId,
|
|
85
105
|
kind: 'api-inputs',
|
package/dist/public-api.d.ts
CHANGED
|
@@ -14,6 +14,13 @@ export type * from './types/api-operation.js';
|
|
|
14
14
|
export { createApiArgumentsSchema } from './schemas/create-api-arguments-schema.js';
|
|
15
15
|
export { createApiArgumentGenerationContract } from './schemas/create-api-argument-generation-contract.js';
|
|
16
16
|
export type * from './types/api-argument-generation.js';
|
|
17
|
+
export type * from './types/api-argument-enum.js';
|
|
18
|
+
export type * from './types/api-input-literal-source.js';
|
|
19
|
+
export { apiInputLiteralSourceSchema } from './schemas/api-input-literal-source-schema.js';
|
|
20
|
+
export { resolveApiLiteralProposalSources } from './arguments/sources/resolve-api-literal-proposal-sources.js';
|
|
21
|
+
export { createApiRequestInputPointerSchema } from './schemas/create-api-request-input-pointer-schema.js';
|
|
22
|
+
export { describeApiArgumentEnumContext } from './arguments/enum/describe-api-argument-enum-context.js';
|
|
23
|
+
export { resolveApiArgumentEnumInterpretation } from './arguments/enum/resolve-api-argument-enum-interpretation.js';
|
|
17
24
|
export type * from './types/api-literal-generation.js';
|
|
18
25
|
export { describeApiLiteralGeneration } from './arguments/generation/describe-api-literal-generation.js';
|
|
19
26
|
export { createApiLiteralGenerationRecord } from './arguments/generation/create-api-literal-generation-record.js';
|
|
@@ -32,8 +39,14 @@ export { resolveApiInputSourceSelections } from './arguments/clarification/extra
|
|
|
32
39
|
export { createApiInputSourceSelectionSchema } from './schemas/api-input-source-selection-schema.js';
|
|
33
40
|
export { captureApiInputAnswerContext } from './arguments/clarification/extraction/capture-api-input-answer-context.js';
|
|
34
41
|
export { resolveApiInputAnswerSources } from './arguments/clarification/extraction/resolve-api-input-answer-sources.js';
|
|
42
|
+
export { resolveApiInputAnswerInterpretations } from './arguments/clarification/extraction/resolve-api-input-answer-interpretations.js';
|
|
43
|
+
export { describeApiInputEnumAnswerChoices } from './arguments/enum/describe-api-input-enum-answer-choices.js';
|
|
44
|
+
export type * from './types/api-input-enum-answers.js';
|
|
35
45
|
export { createApiInputAnswerExtractionRecord } from './arguments/clarification/extraction/create-api-input-answer-extraction-record.js';
|
|
36
46
|
export { validateApiInputAnswerExtractionRecord } from './arguments/clarification/extraction/validate-api-input-answer-extraction-record.js';
|
|
47
|
+
export { validateApiInputAnswerAnalysis } from './arguments/clarification/extraction/validate-api-input-answer-analysis.js';
|
|
48
|
+
export { describeWorkflowDraftApiInputEditAnswerRequirements } from './draft/edits/inputs/describe-workflow-draft-api-input-edit-answer-requirements.js';
|
|
49
|
+
export { resolveWorkflowDraftApiInputEditReply } from './draft/edits/inputs/resolve-workflow-draft-api-input-edit-reply.js';
|
|
37
50
|
export { applyConfirmedApiInputs } from './arguments/clarification/apply-confirmed-api-inputs.js';
|
|
38
51
|
export { inspectApiArgumentRequirements } from './arguments/clarification/inspect-api-argument-requirements.js';
|
|
39
52
|
export { validateApiInputAnswers } from './arguments/clarification/validate-api-input-answers.js';
|
|
@@ -166,6 +179,11 @@ export type * from './types/workflow-draft-native-dependencies.js';
|
|
|
166
179
|
export { createWorkflowDraftNativeDependenciesSchema } from './schemas/workflow-draft-native-dependencies-schema.js';
|
|
167
180
|
export { describeWorkflowDraftNativeDependencies, resolveWorkflowDraftNativeDependencies, validateWorkflowDraftNativeDependencies, validateWorkflowDraftNativeDependencyResolutions, } from './draft/edits/native/additions/resolve-workflow-draft-native-dependencies.js';
|
|
168
181
|
export type * from './types/workflow-draft-api-call-planning.js';
|
|
182
|
+
export type * from './types/workflow-draft-api-enum-selection.js';
|
|
183
|
+
export type { ApiInputEnumCandidate } from './types/api-input-enum.js';
|
|
184
|
+
export { describeWorkflowDraftApiEnumChoices } from './draft/edits/api/describe-workflow-draft-api-enum-choices.js';
|
|
185
|
+
export { createWorkflowDraftApiEnumSelectionSchema } from './schemas/workflow-draft-api-enum-selection-schema.js';
|
|
186
|
+
export { describeWorkflowDraftApiInputEditEnumChoices } from './draft/edits/inputs/describe-workflow-draft-api-input-edit-enum-choices.js';
|
|
169
187
|
export type * from './types/workflow-draft-api-binding-intent.js';
|
|
170
188
|
export { describeWorkflowDraftApiBindingIntent } from './draft/edits/api/describe-workflow-draft-api-binding-intent.js';
|
|
171
189
|
export { createWorkflowDraftApiBindingIntentSchema } from './schemas/workflow-draft-api-binding-intent-schema.js';
|
package/dist/public-api.js
CHANGED
|
@@ -10,6 +10,11 @@ export { createApiSelectionExplanation } from './openapi/selection/evidence/crea
|
|
|
10
10
|
export { validateApiSelectionExplanation } from './openapi/selection/evidence/validate-api-selection-explanation.js';
|
|
11
11
|
export { createApiArgumentsSchema } from './schemas/create-api-arguments-schema.js';
|
|
12
12
|
export { createApiArgumentGenerationContract } from './schemas/create-api-argument-generation-contract.js';
|
|
13
|
+
export { apiInputLiteralSourceSchema } from './schemas/api-input-literal-source-schema.js';
|
|
14
|
+
export { resolveApiLiteralProposalSources } from './arguments/sources/resolve-api-literal-proposal-sources.js';
|
|
15
|
+
export { createApiRequestInputPointerSchema } from './schemas/create-api-request-input-pointer-schema.js';
|
|
16
|
+
export { describeApiArgumentEnumContext } from './arguments/enum/describe-api-argument-enum-context.js';
|
|
17
|
+
export { resolveApiArgumentEnumInterpretation } from './arguments/enum/resolve-api-argument-enum-interpretation.js';
|
|
13
18
|
export { describeApiLiteralGeneration } from './arguments/generation/describe-api-literal-generation.js';
|
|
14
19
|
export { createApiLiteralGenerationRecord } from './arguments/generation/create-api-literal-generation-record.js';
|
|
15
20
|
export { validateApiLiteralGenerationRecord } from './arguments/generation/validate-api-literal-generation-record.js';
|
|
@@ -22,8 +27,13 @@ export { resolveApiInputSourceSelections } from './arguments/clarification/extra
|
|
|
22
27
|
export { createApiInputSourceSelectionSchema } from './schemas/api-input-source-selection-schema.js';
|
|
23
28
|
export { captureApiInputAnswerContext } from './arguments/clarification/extraction/capture-api-input-answer-context.js';
|
|
24
29
|
export { resolveApiInputAnswerSources } from './arguments/clarification/extraction/resolve-api-input-answer-sources.js';
|
|
30
|
+
export { resolveApiInputAnswerInterpretations } from './arguments/clarification/extraction/resolve-api-input-answer-interpretations.js';
|
|
31
|
+
export { describeApiInputEnumAnswerChoices } from './arguments/enum/describe-api-input-enum-answer-choices.js';
|
|
25
32
|
export { createApiInputAnswerExtractionRecord } from './arguments/clarification/extraction/create-api-input-answer-extraction-record.js';
|
|
26
33
|
export { validateApiInputAnswerExtractionRecord } from './arguments/clarification/extraction/validate-api-input-answer-extraction-record.js';
|
|
34
|
+
export { validateApiInputAnswerAnalysis } from './arguments/clarification/extraction/validate-api-input-answer-analysis.js';
|
|
35
|
+
export { describeWorkflowDraftApiInputEditAnswerRequirements } from './draft/edits/inputs/describe-workflow-draft-api-input-edit-answer-requirements.js';
|
|
36
|
+
export { resolveWorkflowDraftApiInputEditReply } from './draft/edits/inputs/resolve-workflow-draft-api-input-edit-reply.js';
|
|
27
37
|
export { applyConfirmedApiInputs } from './arguments/clarification/apply-confirmed-api-inputs.js';
|
|
28
38
|
export { inspectApiArgumentRequirements } from './arguments/clarification/inspect-api-argument-requirements.js';
|
|
29
39
|
export { validateApiInputAnswers } from './arguments/clarification/validate-api-input-answers.js';
|
|
@@ -124,6 +134,9 @@ export { resolveWorkflowDraftNativeNodeParameterOwnership, validateWorkflowDraft
|
|
|
124
134
|
export { resolveWorkflowDraftNativeNodeAddition } from './draft/edits/native/additions/resolve-workflow-draft-native-node-addition.js';
|
|
125
135
|
export { createWorkflowDraftNativeDependenciesSchema } from './schemas/workflow-draft-native-dependencies-schema.js';
|
|
126
136
|
export { describeWorkflowDraftNativeDependencies, resolveWorkflowDraftNativeDependencies, validateWorkflowDraftNativeDependencies, validateWorkflowDraftNativeDependencyResolutions, } from './draft/edits/native/additions/resolve-workflow-draft-native-dependencies.js';
|
|
137
|
+
export { describeWorkflowDraftApiEnumChoices } from './draft/edits/api/describe-workflow-draft-api-enum-choices.js';
|
|
138
|
+
export { createWorkflowDraftApiEnumSelectionSchema } from './schemas/workflow-draft-api-enum-selection-schema.js';
|
|
139
|
+
export { describeWorkflowDraftApiInputEditEnumChoices } from './draft/edits/inputs/describe-workflow-draft-api-input-edit-enum-choices.js';
|
|
127
140
|
export { describeWorkflowDraftApiBindingIntent } from './draft/edits/api/describe-workflow-draft-api-binding-intent.js';
|
|
128
141
|
export { createWorkflowDraftApiBindingIntentSchema } from './schemas/workflow-draft-api-binding-intent-schema.js';
|
|
129
142
|
export { resolveWorkflowDraftApiBindingIntent } from './draft/edits/api/resolve-workflow-draft-api-binding-intent.js';
|
|
@@ -15,6 +15,7 @@ export declare const apiInputRequirementSchema: z.ZodObject<{
|
|
|
15
15
|
targetPointer: z.ZodString;
|
|
16
16
|
schema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
|
|
17
17
|
openapiVersion: z.ZodString;
|
|
18
|
+
schemaDialect: z.ZodOptional<z.ZodLiteral<"draft-2020-12">>;
|
|
18
19
|
operationSummary: z.ZodOptional<z.ZodString>;
|
|
19
20
|
parameterDescription: z.ZodOptional<z.ZodString>;
|
|
20
21
|
message: z.ZodString;
|
|
@@ -37,10 +38,13 @@ export declare const apiInputAnswerContextSchema: z.ZodObject<{
|
|
|
37
38
|
targetPointer: z.ZodString;
|
|
38
39
|
schema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodRecord<z.ZodString, z.ZodJSONSchema>]>;
|
|
39
40
|
openapiVersion: z.ZodString;
|
|
41
|
+
schemaDialect: z.ZodOptional<z.ZodLiteral<"draft-2020-12">>;
|
|
40
42
|
operationSummary: z.ZodOptional<z.ZodString>;
|
|
41
43
|
parameterDescription: z.ZodOptional<z.ZodString>;
|
|
42
44
|
message: z.ZodString;
|
|
43
45
|
}, z.core.$strict>>;
|
|
46
|
+
purpose: z.ZodOptional<z.ZodString>;
|
|
47
|
+
selectOasEnums: z.ZodOptional<z.ZodBoolean>;
|
|
44
48
|
}, z.core.$strict>;
|
|
45
49
|
export declare const apiInputAnswerSourceSchema: z.ZodObject<{
|
|
46
50
|
sourceFormat: z.ZodEnum<{
|
|
@@ -69,4 +73,16 @@ export declare const apiInputAnswerExtractionDecisionSchema: z.ZodObject<{
|
|
|
69
73
|
requirementId: z.ZodString;
|
|
70
74
|
reason: z.ZodString;
|
|
71
75
|
}, z.core.$strict>>;
|
|
76
|
+
enumSelections: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
77
|
+
requirementId: z.ZodString;
|
|
78
|
+
candidateId: z.ZodString;
|
|
79
|
+
intent: z.ZodObject<{
|
|
80
|
+
sourceFormat: z.ZodEnum<{
|
|
81
|
+
text: "text";
|
|
82
|
+
json: "json";
|
|
83
|
+
}>;
|
|
84
|
+
sourceText: z.ZodString;
|
|
85
|
+
}, z.core.$strict>;
|
|
86
|
+
reason: z.ZodString;
|
|
87
|
+
}, z.core.$strict>>>;
|
|
72
88
|
}, z.core.$strict>;
|
|
@@ -2,6 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { apiOperationKeySchema } from './api-operation-key-schema.js';
|
|
3
3
|
import { apiInputLiteralSourceSchema } from './api-input-literal-source-schema.js';
|
|
4
4
|
import { requestedApiInputsSchema } from './requested-api-inputs-schema.js';
|
|
5
|
+
import { apiInputEnumAnswerSelectionsSchema } from './api-input-enum-answer-selection-schema.js';
|
|
5
6
|
export const apiInputRequirementSchema = z.strictObject({
|
|
6
7
|
kind: z.enum(['missing-input', 'requested-input']),
|
|
7
8
|
requestedInputs: requestedApiInputsSchema.optional(),
|
|
@@ -11,6 +12,7 @@ export const apiInputRequirementSchema = z.strictObject({
|
|
|
11
12
|
targetPointer: z.string().min(1),
|
|
12
13
|
schema: z.union([z.boolean(), z.record(z.string(), z.json())]),
|
|
13
14
|
openapiVersion: z.string().min(1),
|
|
15
|
+
schemaDialect: z.literal('draft-2020-12').optional(),
|
|
14
16
|
operationSummary: z.string().optional(),
|
|
15
17
|
parameterDescription: z.string().optional(),
|
|
16
18
|
message: z.string().min(1),
|
|
@@ -18,6 +20,12 @@ export const apiInputRequirementSchema = z.strictObject({
|
|
|
18
20
|
export const apiInputAnswerContextSchema = z.strictObject({
|
|
19
21
|
reply: z.string(),
|
|
20
22
|
requirements: z.array(apiInputRequirementSchema),
|
|
23
|
+
purpose: z
|
|
24
|
+
.string()
|
|
25
|
+
.min(1)
|
|
26
|
+
.refine((value) => value.trim().length > 0)
|
|
27
|
+
.optional(),
|
|
28
|
+
selectOasEnums: z.boolean().optional(),
|
|
21
29
|
});
|
|
22
30
|
export const apiInputAnswerSourceSchema = apiInputLiteralSourceSchema.extend({
|
|
23
31
|
requirementId: z.string().min(1),
|
|
@@ -26,4 +34,5 @@ export const apiInputAnswerSourcesSchema = z.array(apiInputAnswerSourceSchema);
|
|
|
26
34
|
export const apiInputAnswerExtractionDecisionSchema = z.strictObject({
|
|
27
35
|
reason: z.string().min(1),
|
|
28
36
|
answers: z.array(apiInputAnswerSourceSchema.extend({ reason: z.string().min(1) })),
|
|
37
|
+
enumSelections: apiInputEnumAnswerSelectionsSchema.optional(),
|
|
29
38
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const apiInputEnumAnswerSelectionSchema: z.ZodObject<{
|
|
3
|
+
requirementId: z.ZodString;
|
|
4
|
+
candidateId: z.ZodString;
|
|
5
|
+
intent: z.ZodObject<{
|
|
6
|
+
sourceFormat: z.ZodEnum<{
|
|
7
|
+
text: "text";
|
|
8
|
+
json: "json";
|
|
9
|
+
}>;
|
|
10
|
+
sourceText: z.ZodString;
|
|
11
|
+
}, z.core.$strict>;
|
|
12
|
+
reason: z.ZodString;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const apiInputEnumAnswerSelectionsSchema: z.ZodArray<z.ZodObject<{
|
|
15
|
+
requirementId: z.ZodString;
|
|
16
|
+
candidateId: z.ZodString;
|
|
17
|
+
intent: z.ZodObject<{
|
|
18
|
+
sourceFormat: z.ZodEnum<{
|
|
19
|
+
text: "text";
|
|
20
|
+
json: "json";
|
|
21
|
+
}>;
|
|
22
|
+
sourceText: z.ZodString;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
reason: z.ZodString;
|
|
25
|
+
}, z.core.$strict>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { apiInputLiteralSourceSchema } from './api-input-literal-source-schema.js';
|
|
3
|
+
export const apiInputEnumAnswerSelectionSchema = z.strictObject({
|
|
4
|
+
requirementId: z.string().min(1),
|
|
5
|
+
candidateId: z.string().min(1),
|
|
6
|
+
intent: apiInputLiteralSourceSchema,
|
|
7
|
+
reason: z
|
|
8
|
+
.string()
|
|
9
|
+
.refine((value) => value.trim().length > 0, 'An enum choice requires a reason'),
|
|
10
|
+
});
|
|
11
|
+
export const apiInputEnumAnswerSelectionsSchema = z.array(apiInputEnumAnswerSelectionSchema);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { validateWorkflowDraftApiInputEditContract } from '../draft/edits/inputs/validate-workflow-draft-api-input-edit-contract.js';
|
|
3
2
|
import { createWorkflowDraftEditMessageFields } from './workflow-draft-edit-message-fields.js';
|
|
4
3
|
import { createWorkflowDraftApiInputEditTargetValueSchema } from './create-workflow-draft-api-input-edit-target-value-schema.js';
|
|
5
4
|
import { createSchemaResourceContext } from '../bindings/resources/create-schema-resource-context.js';
|
|
6
5
|
import { apiInputLiteralSourceSchema } from './api-input-literal-source-schema.js';
|
|
6
|
+
import { describeWorkflowDraftApiInputEditEnumChoices } from '../draft/edits/inputs/describe-workflow-draft-api-input-edit-enum-choices.js';
|
|
7
|
+
import { createWorkflowDraftApiEnumChoiceSchema } from './workflow-draft-api-enum-choice-schema.js';
|
|
7
8
|
/** Only selected set-values are model-owned; per-field OAS assertions stay intact. */
|
|
8
9
|
export function createWorkflowDraftApiInputEditValuesSchema(input, messageSchema) {
|
|
9
|
-
|
|
10
|
+
const { candidates } = describeWorkflowDraftApiInputEditEnumChoices(input);
|
|
10
11
|
const evidence = createWorkflowDraftEditMessageFields(input.requestMessageIds, input.plan.options.includeExplanations, messageSchema);
|
|
11
12
|
const resources = createSchemaResourceContext(input.contract.schemaResource);
|
|
12
13
|
const wire = resources.bundleStaticProjections(Object.fromEntries(input.contract.targets
|
|
@@ -31,6 +32,14 @@ export function createWorkflowDraftApiInputEditValuesSchema(input, messageSchema
|
|
|
31
32
|
status: z.literal('needs-input'),
|
|
32
33
|
...evidence.fields,
|
|
33
34
|
}),
|
|
35
|
+
...(candidates.some((candidate) => candidate.targetPointer === target.pointer)
|
|
36
|
+
? [
|
|
37
|
+
z.strictObject({
|
|
38
|
+
status: z.literal('oas-enum'),
|
|
39
|
+
selection: createWorkflowDraftApiEnumChoiceSchema(candidates.filter((candidate) => candidate.targetPointer === target.pointer), input.requestMessageIds),
|
|
40
|
+
}),
|
|
41
|
+
]
|
|
42
|
+
: []),
|
|
34
43
|
]),
|
|
35
44
|
]))),
|
|
36
45
|
})
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { WorkflowDraftApiEnumSelection } from '../types/workflow-draft-api-enum-selection.js';
|
|
3
|
+
import type { ApiInputEnumCandidate } from '../types/api-input-enum.js';
|
|
4
|
+
/** No generated value or schema field exists in a semantic enum choice. */
|
|
5
|
+
export declare function createWorkflowDraftApiEnumChoiceSchema(candidates: ApiInputEnumCandidate[], messageIds: string[]): z.ZodType<WorkflowDraftApiEnumSelection>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** No generated value or schema field exists in a semantic enum choice. */
|
|
3
|
+
export function createWorkflowDraftApiEnumChoiceSchema(candidates, messageIds) {
|
|
4
|
+
if (!messageIds.length)
|
|
5
|
+
throw new Error('API enum choice requires original human message IDs');
|
|
6
|
+
if (!candidates.length)
|
|
7
|
+
return z.never();
|
|
8
|
+
return z.strictObject({
|
|
9
|
+
candidateId: z
|
|
10
|
+
.enum(candidates.map((candidate) => candidate.id))
|
|
11
|
+
.describe('Choose an offered original-OAS enum candidate ID. Code copies its original value; never generate a request value.'),
|
|
12
|
+
messageId: z
|
|
13
|
+
.enum(messageIds)
|
|
14
|
+
.describe('Actual supplied human message expressing this enum intent, not an OAS quotation.'),
|
|
15
|
+
sourceText: z
|
|
16
|
+
.string()
|
|
17
|
+
.min(1)
|
|
18
|
+
.describe('Exact original human text expressing the intended meaning; it need not contain the enum literal.'),
|
|
19
|
+
reason: z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.refine((value) => value.trim().length > 0)
|
|
23
|
+
.describe('Brief user-facing reason why this OAS choice matches the cited request. Not private chain-of-thought.'),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { WorkflowDraftApiEnumChoicesInput, WorkflowDraftApiEnumSelectionProposal } from '../types/workflow-draft-api-enum-selection.js';
|
|
3
|
+
/** The model selects IDs and explains intent; there is deliberately no value field. */
|
|
4
|
+
export declare function createWorkflowDraftApiEnumSelectionSchema(input: WorkflowDraftApiEnumChoicesInput): z.ZodType<WorkflowDraftApiEnumSelectionProposal>;
|