@openapi-flow/langchain 0.4.0 → 0.4.1
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/analyze-api-input-answers.js +31 -6
- package/dist/arguments/assert-api-argument-generation-source.d.ts +4 -0
- package/dist/arguments/assert-api-argument-generation-source.js +16 -0
- package/dist/arguments/attribute-api-literal-generation-sources.d.ts +4 -0
- package/dist/arguments/attribute-api-literal-generation-sources.js +16 -0
- package/dist/arguments/create-api-argument-rejection.js +9 -2
- package/dist/arguments/fingerprint-api-argument-source.d.ts +2 -2
- package/dist/arguments/fingerprint-api-argument-source.js +2 -1
- package/dist/arguments/generate-api-arguments.js +36 -14
- package/dist/bindings/plan-api-call-bindings.js +30 -9
- package/dist/bindings/select-api-binding-sources.js +32 -8
- package/dist/prompts/api-arguments-prompt.d.ts +2 -2
- package/dist/prompts/api-arguments-prompt.js +11 -2
- package/dist/prompts/api-input-answers-prompt.d.ts +1 -1
- package/dist/prompts/api-input-answers-prompt.js +8 -7
- package/dist/prompts/api-material-repair-prompt.d.ts +1 -0
- package/dist/prompts/api-material-repair-prompt.js +1 -0
- package/dist/prompts/native-instance-selection-review-prompt.d.ts +1 -1
- package/dist/prompts/native-instance-selection-review-prompt.js +1 -0
- package/dist/prompts/native-node-planning-prompt.d.ts +1 -1
- package/dist/prompts/native-node-planning-prompt.js +1 -0
- package/dist/prompts/workflow-connection-native-repair-prompt.d.ts +1 -0
- package/dist/prompts/workflow-connection-native-repair-prompt.js +1 -0
- package/dist/public-api.d.ts +8 -0
- package/dist/public-api.js +6 -0
- package/dist/schemas/api-input-answer-source-schema.d.ts +5 -5
- package/dist/schemas/api-input-answer-source-schema.js +14 -6
- package/dist/schemas/api-literal-generation-output-schema.d.ts +9 -30
- package/dist/schemas/api-literal-generation-output-schema.js +22 -12
- package/dist/schemas/create-connection-material-repair-choice-schema.js +3 -1
- package/dist/schemas/native-planning-rejection-schema.d.ts +11 -0
- package/dist/schemas/native-planning-rejection-schema.js +8 -0
- package/dist/types/api-call-binding-planning.d.ts +2 -1
- package/dist/types/api-input-answers.d.ts +2 -6
- package/dist/types/argument-generation.d.ts +8 -3
- package/dist/types/native-instance-selection-review.d.ts +3 -0
- package/dist/types/native-node-planning.d.ts +4 -0
- package/dist/types/native-planning-rejection.d.ts +21 -0
- package/dist/types/native-planning-rejection.js +1 -0
- package/dist/types/workflow-connection-native-repair.d.ts +16 -0
- package/dist/types/workflow-connection-native-repair.js +1 -0
- package/dist/workflow/connections/generate-workflow-connection-native-parameters.d.ts +4 -0
- package/dist/workflow/connections/generate-workflow-connection-native-parameters.js +80 -0
- package/dist/workflow/connections/plan-workflow-connection-native-dependencies.d.ts +4 -0
- package/dist/workflow/connections/plan-workflow-connection-native-dependencies.js +73 -0
- package/dist/workflow/connections/workflow-connection-native-repair-error.d.ts +6 -0
- package/dist/workflow/connections/workflow-connection-native-repair-error.js +18 -0
- package/dist/workflow/native-selection/create-native-planning-rejection.d.ts +4 -0
- package/dist/workflow/native-selection/create-native-planning-rejection.js +45 -0
- package/dist/workflow/native-selection/describe-native-planning-request.d.ts +5 -0
- package/dist/workflow/native-selection/describe-native-planning-request.js +26 -0
- package/dist/workflow/native-selection/review-native-instance-selection.js +19 -3
- package/dist/workflow/native-selection/validate-native-planning-rejections.d.ts +2 -0
- package/dist/workflow/native-selection/validate-native-planning-rejections.js +14 -0
- package/dist/workflow/select-native-node-instances.js +40 -22
- package/package.json +2 -2
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
3
|
+
import { describeWorkflowConnectionNativeDependencies, createWorkflowConnectionNativeDependenciesSchema, resolveWorkflowConnectionNativeDependencies, runOpenApiFlowOperation, } from '@openapi-flow/core';
|
|
4
|
+
import { invokeStructuredModel } from '../../model/invoke-structured-model.js';
|
|
5
|
+
import { workflowConnectionNativeRepairPrompt } from '../../prompts/workflow-connection-native-repair-prompt.js';
|
|
6
|
+
import { modelSignalSchema } from '../../schemas/model-signal-schema.js';
|
|
7
|
+
import { WorkflowConnectionNativeRepairError } from './workflow-connection-native-repair-error.js';
|
|
8
|
+
/** Zero or one scoped decision. No retries or mutation of the original source. */
|
|
9
|
+
export async function planWorkflowConnectionNativeDependencies(input) {
|
|
10
|
+
const context = runOpenApiFlowOperation({
|
|
11
|
+
owner: 'langchain',
|
|
12
|
+
operation: 'planWorkflowConnectionNativeDependencies',
|
|
13
|
+
stage: 'input-validation',
|
|
14
|
+
code: 'PLANNING_INPUT_INVALID',
|
|
15
|
+
}, () => {
|
|
16
|
+
modelSignalSchema.parse(input.signal);
|
|
17
|
+
if (input.model !== undefined &&
|
|
18
|
+
(!input.model || typeof input.model.withStructuredOutput !== 'function'))
|
|
19
|
+
throw new Error('planWorkflowConnectionNativeDependencies.model must support structured output when supplied');
|
|
20
|
+
return describeWorkflowConnectionNativeDependencies(input);
|
|
21
|
+
});
|
|
22
|
+
input.signal?.throwIfAborted();
|
|
23
|
+
if (context.targets.every((target) => target.sourceNodeIds.length === 0))
|
|
24
|
+
return resolveWorkflowConnectionNativeDependencies({
|
|
25
|
+
...input,
|
|
26
|
+
proposal: {
|
|
27
|
+
sourcesByNodeId: Object.fromEntries(context.targets.map((target) => [
|
|
28
|
+
target.nodeId,
|
|
29
|
+
{ sourceNodeIds: [] },
|
|
30
|
+
])),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
if (!input.model)
|
|
34
|
+
throw new Error('planWorkflowConnectionNativeDependencies.model is required for producer choices');
|
|
35
|
+
const output = await invokeStructuredModel({
|
|
36
|
+
model: input.model,
|
|
37
|
+
schema: createWorkflowConnectionNativeDependenciesSchema(input),
|
|
38
|
+
operation: 'planWorkflowConnectionNativeDependencies',
|
|
39
|
+
name: 'repair_native_dependencies',
|
|
40
|
+
method: 'functionCalling',
|
|
41
|
+
strict: true,
|
|
42
|
+
signal: input.signal,
|
|
43
|
+
messages: [
|
|
44
|
+
new SystemMessage(workflowConnectionNativeRepairPrompt),
|
|
45
|
+
new HumanMessage(JSON.stringify(context)),
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
input.signal?.throwIfAborted();
|
|
49
|
+
return runOpenApiFlowOperation({
|
|
50
|
+
owner: 'langchain',
|
|
51
|
+
operation: 'planWorkflowConnectionNativeDependencies',
|
|
52
|
+
stage: 'contract-validation',
|
|
53
|
+
code: 'NATIVE_NODE_PLANNING_FAILED',
|
|
54
|
+
}, () => {
|
|
55
|
+
try {
|
|
56
|
+
if (!isDeepStrictEqual(context, describeWorkflowConnectionNativeDependencies(input)))
|
|
57
|
+
throw new Error('Native repair source changed during dependency planning');
|
|
58
|
+
return resolveWorkflowConnectionNativeDependencies({
|
|
59
|
+
...input,
|
|
60
|
+
proposal: output,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
if (!(cause instanceof Error))
|
|
65
|
+
throw cause;
|
|
66
|
+
throw new WorkflowConnectionNativeRepairError({
|
|
67
|
+
operation: 'planWorkflowConnectionNativeDependencies',
|
|
68
|
+
fingerprint: context.fingerprint,
|
|
69
|
+
output,
|
|
70
|
+
}, cause);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { OpenApiFlowError } from '@openapi-flow/core';
|
|
2
|
+
import type { WorkflowConnectionNativeRepairFailure } from '../../types/workflow-connection-native-repair.js';
|
|
3
|
+
export declare class WorkflowConnectionNativeRepairError extends OpenApiFlowError {
|
|
4
|
+
readonly failure: WorkflowConnectionNativeRepairFailure;
|
|
5
|
+
constructor(failure: WorkflowConnectionNativeRepairFailure, cause: Error);
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OpenApiFlowError } from '@openapi-flow/core';
|
|
2
|
+
export class WorkflowConnectionNativeRepairError extends OpenApiFlowError {
|
|
3
|
+
failure;
|
|
4
|
+
constructor(failure, cause) {
|
|
5
|
+
super({
|
|
6
|
+
message: cause.message,
|
|
7
|
+
diagnostic: {
|
|
8
|
+
owner: 'langchain',
|
|
9
|
+
operation: failure.operation,
|
|
10
|
+
stage: 'contract-validation',
|
|
11
|
+
code: 'NATIVE_NODE_PLANNING_FAILED',
|
|
12
|
+
},
|
|
13
|
+
cause,
|
|
14
|
+
});
|
|
15
|
+
this.name = 'WorkflowConnectionNativeRepairError';
|
|
16
|
+
this.failure = failure;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CreateNativeSelectionRejectionInput, CreateNativeSelectionReviewRejectionInput, NativePlanningRejectedProposal } from '../../types/native-planning-rejection.js';
|
|
2
|
+
/** Only unchanged, source-bound output failures are eligible; transport/configuration failures are not proposals. */
|
|
3
|
+
export declare function createNativeSelectionRejection(input: CreateNativeSelectionRejectionInput): NativePlanningRejectedProposal | undefined;
|
|
4
|
+
export declare function createNativeSelectionReviewRejection(input: CreateNativeSelectionReviewRejectionInput): NativePlanningRejectedProposal | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { nativePlanningRejectionSchema } from '../../schemas/native-planning-rejection-schema.js';
|
|
3
|
+
import { NativeNodePlanningError } from '../native-node-planning-error.js';
|
|
4
|
+
import { NativeInstanceSelectionReviewError } from './native-instance-selection-review-error.js';
|
|
5
|
+
import { describeNativeSelectionRequest, fingerprintNativeSelectionReviewRequest, } from './describe-native-planning-request.js';
|
|
6
|
+
/** Only unchanged, source-bound output failures are eligible; transport/configuration failures are not proposals. */
|
|
7
|
+
export function createNativeSelectionRejection(input) {
|
|
8
|
+
const error = input.error;
|
|
9
|
+
if (!(error instanceof NativeNodePlanningError) ||
|
|
10
|
+
error.failure.stage !== 'instance-selection' ||
|
|
11
|
+
error.failure.requestFingerprint === undefined)
|
|
12
|
+
return undefined;
|
|
13
|
+
const current = describeNativeSelectionRequest(input);
|
|
14
|
+
if (current.requestFingerprint !== error.failure.requestFingerprint)
|
|
15
|
+
return undefined;
|
|
16
|
+
const parsed = nativePlanningRejectionSchema.safeParse({
|
|
17
|
+
stage: 'instance-selection',
|
|
18
|
+
requestFingerprint: current.requestFingerprint,
|
|
19
|
+
output: error.failure.output,
|
|
20
|
+
reason: error.message,
|
|
21
|
+
});
|
|
22
|
+
if (!parsed.success ||
|
|
23
|
+
!isDeepStrictEqual(parsed.data.output, error.failure.output))
|
|
24
|
+
return undefined;
|
|
25
|
+
return structuredClone(parsed.data);
|
|
26
|
+
}
|
|
27
|
+
export function createNativeSelectionReviewRejection(input) {
|
|
28
|
+
const error = input.error;
|
|
29
|
+
if (!(error instanceof NativeInstanceSelectionReviewError) ||
|
|
30
|
+
error.failure.requestFingerprint === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
const requestFingerprint = fingerprintNativeSelectionReviewRequest(input);
|
|
33
|
+
if (requestFingerprint !== error.failure.requestFingerprint)
|
|
34
|
+
return undefined;
|
|
35
|
+
const parsed = nativePlanningRejectionSchema.safeParse({
|
|
36
|
+
stage: 'selection-review',
|
|
37
|
+
requestFingerprint,
|
|
38
|
+
output: error.failure.output,
|
|
39
|
+
reason: error.message,
|
|
40
|
+
});
|
|
41
|
+
if (!parsed.success ||
|
|
42
|
+
!isDeepStrictEqual(parsed.data.output, error.failure.output))
|
|
43
|
+
return undefined;
|
|
44
|
+
return structuredClone(parsed.data);
|
|
45
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SelectNativeNodeInstancesInput } from '../../types/native-node-planning.js';
|
|
2
|
+
import type { ReviewNativeInstanceSelectionInput } from '../../types/native-instance-selection-review.js';
|
|
3
|
+
import type { NativeSelectionRequestDescription } from '../../types/native-planning-rejection.js';
|
|
4
|
+
export declare function describeNativeSelectionRequest(input: SelectNativeNodeInstancesInput): NativeSelectionRequestDescription;
|
|
5
|
+
export declare function fingerprintNativeSelectionReviewRequest(input: ReviewNativeInstanceSelectionInput): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { describeNativeInstanceSelection, describeNativeInstanceSelectionFeedback, describeNativeInstanceSelectionReview, } from '@openapi-flow/core';
|
|
3
|
+
export function describeNativeSelectionRequest(input) {
|
|
4
|
+
const { context } = describeNativeInstanceSelection(input);
|
|
5
|
+
const feedback = input.feedback === undefined
|
|
6
|
+
? undefined
|
|
7
|
+
: describeNativeInstanceSelectionFeedback(input, input.feedback);
|
|
8
|
+
return {
|
|
9
|
+
context,
|
|
10
|
+
...(feedback === undefined ? {} : { feedback }),
|
|
11
|
+
requestFingerprint: createHash('sha256')
|
|
12
|
+
.update(JSON.stringify([
|
|
13
|
+
input.planId,
|
|
14
|
+
input.allowRuntimeParameters,
|
|
15
|
+
input.includeExplanations,
|
|
16
|
+
context,
|
|
17
|
+
feedback,
|
|
18
|
+
]))
|
|
19
|
+
.digest('hex'),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function fingerprintNativeSelectionReviewRequest(input) {
|
|
23
|
+
return createHash('sha256')
|
|
24
|
+
.update(JSON.stringify(describeNativeInstanceSelectionReview(input)))
|
|
25
|
+
.digest('hex');
|
|
26
|
+
}
|
|
@@ -6,6 +6,8 @@ import { serializeStructuredOutputSchema } from '../../schemas/serialize-structu
|
|
|
6
6
|
import { modelSignalSchema } from '../../schemas/model-signal-schema.js';
|
|
7
7
|
import { nativeInstanceSelectionReviewPrompt } from '../../prompts/native-instance-selection-review-prompt.js';
|
|
8
8
|
import { NativeInstanceSelectionReviewError } from './native-instance-selection-review-error.js';
|
|
9
|
+
import { fingerprintNativeSelectionReviewRequest } from './describe-native-planning-request.js';
|
|
10
|
+
import { validateNativePlanningRejections } from './validate-native-planning-rejections.js';
|
|
9
11
|
/** One review call only. The host owns replanning, user questions, budgets and persistence. */
|
|
10
12
|
export async function reviewNativeInstanceSelection(input) {
|
|
11
13
|
const operation = 'reviewNativeInstanceSelection';
|
|
@@ -19,6 +21,12 @@ export async function reviewNativeInstanceSelection(input) {
|
|
|
19
21
|
return describeNativeInstanceSelectionReview(input);
|
|
20
22
|
});
|
|
21
23
|
input.signal?.throwIfAborted();
|
|
24
|
+
const requestFingerprint = fingerprintNativeSelectionReviewRequest(input);
|
|
25
|
+
const rejectedProposals = validateNativePlanningRejections({
|
|
26
|
+
stage: 'selection-review',
|
|
27
|
+
requestFingerprint,
|
|
28
|
+
rejectedProposals: input.rejectedProposals,
|
|
29
|
+
});
|
|
22
30
|
if (!description.gaps.length)
|
|
23
31
|
return createNativeInstanceSelectionReview({
|
|
24
32
|
...input,
|
|
@@ -43,7 +51,12 @@ export async function reviewNativeInstanceSelection(input) {
|
|
|
43
51
|
code: 'PLANNING_INPUT_INVALID',
|
|
44
52
|
}, () => {
|
|
45
53
|
try {
|
|
46
|
-
if (!isDeepStrictEqual(description, describeNativeInstanceSelectionReview(input))
|
|
54
|
+
if (!isDeepStrictEqual(description, describeNativeInstanceSelectionReview(input)) ||
|
|
55
|
+
!isDeepStrictEqual(rejectedProposals, validateNativePlanningRejections({
|
|
56
|
+
stage: 'selection-review',
|
|
57
|
+
requestFingerprint,
|
|
58
|
+
rejectedProposals: input.rejectedProposals,
|
|
59
|
+
})))
|
|
47
60
|
throw new Error('Native selection review source changed during model invocation');
|
|
48
61
|
}
|
|
49
62
|
catch (error) {
|
|
@@ -62,7 +75,10 @@ export async function reviewNativeInstanceSelection(input) {
|
|
|
62
75
|
strict: true,
|
|
63
76
|
messages: [
|
|
64
77
|
new SystemMessage(nativeInstanceSelectionReviewPrompt),
|
|
65
|
-
new HumanMessage(JSON.stringify(
|
|
78
|
+
new HumanMessage(JSON.stringify({
|
|
79
|
+
...description,
|
|
80
|
+
...(rejectedProposals.length === 0 ? {} : { rejectedProposals }),
|
|
81
|
+
})),
|
|
66
82
|
],
|
|
67
83
|
...(input.signal === undefined ? {} : { signal: input.signal }),
|
|
68
84
|
}).catch((error) => {
|
|
@@ -76,6 +92,6 @@ export async function reviewNativeInstanceSelection(input) {
|
|
|
76
92
|
catch (cause) {
|
|
77
93
|
if (!(cause instanceof Error))
|
|
78
94
|
throw cause;
|
|
79
|
-
throw new NativeInstanceSelectionReviewError({ output }, cause);
|
|
95
|
+
throw new NativeInstanceSelectionReviewError({ output, requestFingerprint }, cause);
|
|
80
96
|
}
|
|
81
97
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { nativePlanningRejectionSchema } from '../../schemas/native-planning-rejection-schema.js';
|
|
3
|
+
export function validateNativePlanningRejections(input) {
|
|
4
|
+
if (input.rejectedProposals === undefined)
|
|
5
|
+
return [];
|
|
6
|
+
const parsed = nativePlanningRejectionSchema
|
|
7
|
+
.array()
|
|
8
|
+
.parse(input.rejectedProposals);
|
|
9
|
+
if (!isDeepStrictEqual(parsed, input.rejectedProposals) ||
|
|
10
|
+
parsed.some((entry) => entry.stage !== input.stage ||
|
|
11
|
+
entry.requestFingerprint !== input.requestFingerprint))
|
|
12
|
+
throw new Error('Native rejectedProposals belong to a changed source or different planning stage');
|
|
13
|
+
return structuredClone(parsed);
|
|
14
|
+
}
|
|
@@ -1,24 +1,40 @@
|
|
|
1
1
|
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
2
2
|
import { isDeepStrictEqual } from 'node:util';
|
|
3
|
-
import { createNativeInstanceSelectionSchema,
|
|
3
|
+
import { createNativeInstanceSelectionSchema, resolveNativeInstanceSelection, } from '@openapi-flow/core';
|
|
4
4
|
import { serializeStructuredOutputSchema } from '../schemas/serialize-structured-output-schema.js';
|
|
5
5
|
import { nativeInstanceSelectionPrompt } from '../prompts/native-node-planning-prompt.js';
|
|
6
6
|
import { NativeNodePlanningError } from './native-node-planning-error.js';
|
|
7
|
+
import { describeNativeSelectionRequest } from './native-selection/describe-native-planning-request.js';
|
|
8
|
+
import { validateNativePlanningRejections } from './native-selection/validate-native-planning-rejections.js';
|
|
7
9
|
/** One checkpointable role/ownership selection; parameter values are a separate public stage. */
|
|
8
10
|
export async function selectNativeNodeInstances(input) {
|
|
9
11
|
input.signal?.throwIfAborted();
|
|
10
12
|
if (input.model !== undefined &&
|
|
11
13
|
(!input.model || typeof input.model.withStructuredOutput !== 'function'))
|
|
12
14
|
throw new Error('selectNativeNodeInstances.model must support structured output when supplied');
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
:
|
|
17
|
-
|
|
18
|
-
input.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const request = describeNativeSelectionRequest(input);
|
|
16
|
+
const { context, feedback, requestFingerprint } = request;
|
|
17
|
+
const rejectedProposals = validateNativePlanningRejections({
|
|
18
|
+
stage: 'instance-selection',
|
|
19
|
+
requestFingerprint,
|
|
20
|
+
rejectedProposals: input.rejectedProposals,
|
|
21
|
+
});
|
|
22
|
+
const checkCurrent = (failure) => {
|
|
23
|
+
try {
|
|
24
|
+
if (!isDeepStrictEqual(request, describeNativeSelectionRequest(input)) ||
|
|
25
|
+
!isDeepStrictEqual(rejectedProposals, validateNativePlanningRejections({
|
|
26
|
+
stage: 'instance-selection',
|
|
27
|
+
requestFingerprint,
|
|
28
|
+
rejectedProposals: input.rejectedProposals,
|
|
29
|
+
})))
|
|
30
|
+
throw new Error('Native instance source contracts changed during selection; no automatic rebase');
|
|
31
|
+
}
|
|
32
|
+
catch (cause) {
|
|
33
|
+
if (failure !== undefined)
|
|
34
|
+
throw new AggregateError([failure, cause], 'Native selection input changed while a failed model call was received', { cause });
|
|
35
|
+
throw cause;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
22
38
|
const schema = createNativeInstanceSelectionSchema(input);
|
|
23
39
|
if (!context.capabilities.length)
|
|
24
40
|
return resolveNativeInstanceSelection({
|
|
@@ -44,25 +60,27 @@ export async function selectNativeNodeInstances(input) {
|
|
|
44
60
|
new HumanMessage(JSON.stringify({
|
|
45
61
|
...context,
|
|
46
62
|
...(feedback === undefined ? {} : { selectionFeedback: feedback }),
|
|
63
|
+
...(rejectedProposals.length === 0 ? {} : { rejectedProposals }),
|
|
47
64
|
})),
|
|
48
|
-
], input.signal === undefined ? undefined : { signal: input.signal })
|
|
65
|
+
], input.signal === undefined ? undefined : { signal: input.signal })
|
|
66
|
+
.catch((error) => {
|
|
67
|
+
checkCurrent(error);
|
|
68
|
+
throw error;
|
|
69
|
+
});
|
|
49
70
|
input.signal?.throwIfAborted();
|
|
71
|
+
let unchanged = false;
|
|
50
72
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
? undefined
|
|
54
|
-
: describeNativeInstanceSelectionFeedback(input, input.feedback)) ||
|
|
55
|
-
JSON.stringify([
|
|
56
|
-
input.planId,
|
|
57
|
-
input.allowRuntimeParameters,
|
|
58
|
-
input.includeExplanations,
|
|
59
|
-
]) !== originalOptions)
|
|
60
|
-
throw new Error('Native instance source contracts changed during selection; no automatic rebase');
|
|
73
|
+
checkCurrent();
|
|
74
|
+
unchanged = true;
|
|
61
75
|
return resolveNativeInstanceSelection({ ...input, proposal: output });
|
|
62
76
|
}
|
|
63
77
|
catch (cause) {
|
|
64
78
|
if (!(cause instanceof Error))
|
|
65
79
|
throw cause;
|
|
66
|
-
throw new NativeNodePlanningError({
|
|
80
|
+
throw new NativeNodePlanningError({
|
|
81
|
+
stage: 'instance-selection',
|
|
82
|
+
output,
|
|
83
|
+
...(unchanged ? { requestFingerprint } : {}),
|
|
84
|
+
}, cause);
|
|
67
85
|
}
|
|
68
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-flow/langchain",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Composable LangChain planning for OpenAPI workflows",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@openapi-flow/core": "0.4.
|
|
31
|
+
"@openapi-flow/core": "0.4.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"@langchain/core": "^1.0.0",
|