@indexnetwork/protocol 6.11.0-rc.401.1 → 6.11.1-rc.402.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/intent/intent.graph.d.ts +33 -2
- package/dist/intent/intent.graph.d.ts.map +1 -1
- package/dist/intent/intent.graph.js +98 -16
- package/dist/intent/intent.graph.js.map +1 -1
- package/dist/intent/intent.state.d.ts +11 -0
- package/dist/intent/intent.state.d.ts.map +1 -1
- package/dist/intent/intent.state.js +10 -0
- package/dist/intent/intent.state.js.map +1 -1
- package/dist/intent/intent.tools.d.ts +16 -0
- package/dist/intent/intent.tools.d.ts.map +1 -1
- package/dist/intent/intent.tools.js +30 -4
- package/dist/intent/intent.tools.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { VerifiedIntent, ExecutionResult } from "./intent.state.js";
|
|
1
|
+
import { VerifiedIntent, ExecutionResult, type IntentValidationFailure } from "./intent.state.js";
|
|
2
|
+
import { ExplicitIntentInferrer } from "./intent.inferrer.js";
|
|
3
|
+
import { SemanticVerifier } from "./intent.verifier.js";
|
|
4
|
+
import { IntentReconciler } from "./intent.reconciler.js";
|
|
2
5
|
import type { NormalizedIntentAction } from "./intent.reconciler.js";
|
|
3
6
|
import { IntentGraphDatabase } from "../shared/interfaces/database.interface.js";
|
|
4
7
|
import type { EmbeddingGenerator } from "../shared/interfaces/embedder.interface.js";
|
|
@@ -11,6 +14,15 @@ import type { QuestionerEnqueueFn } from "../questioner/questioner.types.js";
|
|
|
11
14
|
* whose id is one of the caller-provided targets survive.
|
|
12
15
|
*/
|
|
13
16
|
export declare function enforceIntentActionBoundary(operationMode: 'create' | 'update' | 'delete' | 'read' | 'propose', targetIntentIds: string[] | undefined, actions: NormalizedIntentAction[]): NormalizedIntentAction[];
|
|
17
|
+
/**
|
|
18
|
+
* Build the only action permitted for an explicit update. This path is
|
|
19
|
+
* intentionally deterministic: semantic reconciliation may shape create
|
|
20
|
+
* operations, but it may not redirect an update away from its supplied target.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildExplicitUpdateActions(targetIntentIds: string[] | undefined, activeIntentIds: string[], candidates: VerifiedIntent[]): {
|
|
23
|
+
actions: NormalizedIntentAction[];
|
|
24
|
+
failure?: IntentValidationFailure;
|
|
25
|
+
};
|
|
14
26
|
/**
|
|
15
27
|
* Factory class to build and compile the Intent Processing Graph.
|
|
16
28
|
*/
|
|
@@ -19,7 +31,12 @@ export declare class IntentGraphFactory {
|
|
|
19
31
|
private embedder?;
|
|
20
32
|
private intentQueue?;
|
|
21
33
|
private questionerEnqueue?;
|
|
22
|
-
|
|
34
|
+
private agents?;
|
|
35
|
+
constructor(database: IntentGraphDatabase, embedder?: EmbeddingGenerator | undefined, intentQueue?: IntentGraphQueue | undefined, questionerEnqueue?: QuestionerEnqueueFn | undefined, agents?: {
|
|
36
|
+
inferrer?: Pick<ExplicitIntentInferrer, "invoke">;
|
|
37
|
+
verifier?: Pick<SemanticVerifier, "invoke">;
|
|
38
|
+
reconciler?: Pick<IntentReconciler, "invoke">;
|
|
39
|
+
} | undefined);
|
|
23
40
|
createGraph(): import("@langchain/langgraph").CompiledStateGraph<{
|
|
24
41
|
userId: string;
|
|
25
42
|
userProfile: string;
|
|
@@ -32,6 +49,7 @@ export declare class IntentGraphFactory {
|
|
|
32
49
|
scopeType: import("../index.js").ToolScopeType | undefined;
|
|
33
50
|
scopeId: string | undefined;
|
|
34
51
|
activeIntents: string;
|
|
52
|
+
activeIntentIds: string[];
|
|
35
53
|
inferredIntents: {
|
|
36
54
|
reasoning: string;
|
|
37
55
|
type: "goal" | "tombstone";
|
|
@@ -39,6 +57,7 @@ export declare class IntentGraphFactory {
|
|
|
39
57
|
description: string;
|
|
40
58
|
}[];
|
|
41
59
|
verifiedIntents: VerifiedIntent[];
|
|
60
|
+
validationFailures: IntentValidationFailure[];
|
|
42
61
|
actions: NormalizedIntentAction[];
|
|
43
62
|
executionResults: ExecutionResult[];
|
|
44
63
|
error: string | undefined;
|
|
@@ -76,6 +95,7 @@ export declare class IntentGraphFactory {
|
|
|
76
95
|
scopeType?: import("../index.js").ToolScopeType | import("@langchain/langgraph").OverwriteValue<import("../index.js").ToolScopeType | undefined> | undefined;
|
|
77
96
|
scopeId?: string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined;
|
|
78
97
|
activeIntents?: string | import("@langchain/langgraph").OverwriteValue<string> | undefined;
|
|
98
|
+
activeIntentIds?: string[] | import("@langchain/langgraph").OverwriteValue<string[]> | undefined;
|
|
79
99
|
inferredIntents?: {
|
|
80
100
|
reasoning: string;
|
|
81
101
|
type: "goal" | "tombstone";
|
|
@@ -88,6 +108,7 @@ export declare class IntentGraphFactory {
|
|
|
88
108
|
description: string;
|
|
89
109
|
}[]> | undefined;
|
|
90
110
|
verifiedIntents?: VerifiedIntent[] | import("@langchain/langgraph").OverwriteValue<VerifiedIntent[]> | undefined;
|
|
111
|
+
validationFailures?: IntentValidationFailure[] | import("@langchain/langgraph").OverwriteValue<IntentValidationFailure[]> | undefined;
|
|
91
112
|
actions?: NormalizedIntentAction[] | import("@langchain/langgraph").OverwriteValue<NormalizedIntentAction[]> | undefined;
|
|
92
113
|
executionResults?: ExecutionResult[] | import("@langchain/langgraph").OverwriteValue<ExecutionResult[]> | undefined;
|
|
93
114
|
error?: string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined;
|
|
@@ -153,6 +174,7 @@ export declare class IntentGraphFactory {
|
|
|
153
174
|
scopeType: import("@langchain/langgraph").BaseChannel<import("../index.js").ToolScopeType | undefined, import("../index.js").ToolScopeType | import("@langchain/langgraph").OverwriteValue<import("../index.js").ToolScopeType | undefined> | undefined, unknown>;
|
|
154
175
|
scopeId: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
155
176
|
activeIntents: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
177
|
+
activeIntentIds: import("@langchain/langgraph").BaseChannel<string[], string[] | import("@langchain/langgraph").OverwriteValue<string[]>, unknown>;
|
|
156
178
|
inferredIntents: import("@langchain/langgraph").BaseChannel<{
|
|
157
179
|
reasoning: string;
|
|
158
180
|
type: "goal" | "tombstone";
|
|
@@ -170,6 +192,7 @@ export declare class IntentGraphFactory {
|
|
|
170
192
|
description: string;
|
|
171
193
|
}[]>, unknown>;
|
|
172
194
|
verifiedIntents: import("@langchain/langgraph").BaseChannel<VerifiedIntent[], VerifiedIntent[] | import("@langchain/langgraph").OverwriteValue<VerifiedIntent[]>, unknown>;
|
|
195
|
+
validationFailures: import("@langchain/langgraph").BaseChannel<IntentValidationFailure[], IntentValidationFailure[] | import("@langchain/langgraph").OverwriteValue<IntentValidationFailure[]>, unknown>;
|
|
173
196
|
actions: import("@langchain/langgraph").BaseChannel<NormalizedIntentAction[], NormalizedIntentAction[] | import("@langchain/langgraph").OverwriteValue<NormalizedIntentAction[]>, unknown>;
|
|
174
197
|
executionResults: import("@langchain/langgraph").BaseChannel<ExecutionResult[], ExecutionResult[] | import("@langchain/langgraph").OverwriteValue<ExecutionResult[]>, unknown>;
|
|
175
198
|
error: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
@@ -251,6 +274,7 @@ export declare class IntentGraphFactory {
|
|
|
251
274
|
scopeType: import("@langchain/langgraph").BaseChannel<import("../index.js").ToolScopeType | undefined, import("../index.js").ToolScopeType | import("@langchain/langgraph").OverwriteValue<import("../index.js").ToolScopeType | undefined> | undefined, unknown>;
|
|
252
275
|
scopeId: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
253
276
|
activeIntents: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
277
|
+
activeIntentIds: import("@langchain/langgraph").BaseChannel<string[], string[] | import("@langchain/langgraph").OverwriteValue<string[]>, unknown>;
|
|
254
278
|
inferredIntents: import("@langchain/langgraph").BaseChannel<{
|
|
255
279
|
reasoning: string;
|
|
256
280
|
type: "goal" | "tombstone";
|
|
@@ -268,6 +292,7 @@ export declare class IntentGraphFactory {
|
|
|
268
292
|
description: string;
|
|
269
293
|
}[]>, unknown>;
|
|
270
294
|
verifiedIntents: import("@langchain/langgraph").BaseChannel<VerifiedIntent[], VerifiedIntent[] | import("@langchain/langgraph").OverwriteValue<VerifiedIntent[]>, unknown>;
|
|
295
|
+
validationFailures: import("@langchain/langgraph").BaseChannel<IntentValidationFailure[], IntentValidationFailure[] | import("@langchain/langgraph").OverwriteValue<IntentValidationFailure[]>, unknown>;
|
|
271
296
|
actions: import("@langchain/langgraph").BaseChannel<NormalizedIntentAction[], NormalizedIntentAction[] | import("@langchain/langgraph").OverwriteValue<NormalizedIntentAction[]>, unknown>;
|
|
272
297
|
executionResults: import("@langchain/langgraph").BaseChannel<ExecutionResult[], ExecutionResult[] | import("@langchain/langgraph").OverwriteValue<ExecutionResult[]>, unknown>;
|
|
273
298
|
error: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
@@ -329,9 +354,11 @@ export declare class IntentGraphFactory {
|
|
|
329
354
|
prep: {
|
|
330
355
|
error: string;
|
|
331
356
|
activeIntents?: undefined;
|
|
357
|
+
activeIntentIds?: undefined;
|
|
332
358
|
trace?: undefined;
|
|
333
359
|
} | {
|
|
334
360
|
activeIntents: string;
|
|
361
|
+
activeIntentIds: string[];
|
|
335
362
|
trace: {
|
|
336
363
|
node: string;
|
|
337
364
|
detail: string;
|
|
@@ -395,9 +422,11 @@ export declare class IntentGraphFactory {
|
|
|
395
422
|
verification: {
|
|
396
423
|
verifiedIntents: never[];
|
|
397
424
|
agentTimings: never[];
|
|
425
|
+
validationFailures?: undefined;
|
|
398
426
|
trace?: undefined;
|
|
399
427
|
} | {
|
|
400
428
|
verifiedIntents: VerifiedIntent[];
|
|
429
|
+
validationFailures: IntentValidationFailure[];
|
|
401
430
|
agentTimings: DebugMetaAgent[];
|
|
402
431
|
trace: {
|
|
403
432
|
node: string;
|
|
@@ -439,6 +468,7 @@ export declare class IntentGraphFactory {
|
|
|
439
468
|
scopeType: import("@langchain/langgraph").BaseChannel<import("../index.js").ToolScopeType | undefined, import("../index.js").ToolScopeType | import("@langchain/langgraph").OverwriteValue<import("../index.js").ToolScopeType | undefined> | undefined, unknown>;
|
|
440
469
|
scopeId: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
441
470
|
activeIntents: import("@langchain/langgraph").BaseChannel<string, string | import("@langchain/langgraph").OverwriteValue<string>, unknown>;
|
|
471
|
+
activeIntentIds: import("@langchain/langgraph").BaseChannel<string[], string[] | import("@langchain/langgraph").OverwriteValue<string[]>, unknown>;
|
|
442
472
|
inferredIntents: import("@langchain/langgraph").BaseChannel<{
|
|
443
473
|
reasoning: string;
|
|
444
474
|
type: "goal" | "tombstone";
|
|
@@ -456,6 +486,7 @@ export declare class IntentGraphFactory {
|
|
|
456
486
|
description: string;
|
|
457
487
|
}[]>, unknown>;
|
|
458
488
|
verifiedIntents: import("@langchain/langgraph").BaseChannel<VerifiedIntent[], VerifiedIntent[] | import("@langchain/langgraph").OverwriteValue<VerifiedIntent[]>, unknown>;
|
|
489
|
+
validationFailures: import("@langchain/langgraph").BaseChannel<IntentValidationFailure[], IntentValidationFailure[] | import("@langchain/langgraph").OverwriteValue<IntentValidationFailure[]>, unknown>;
|
|
459
490
|
actions: import("@langchain/langgraph").BaseChannel<NormalizedIntentAction[], NormalizedIntentAction[] | import("@langchain/langgraph").OverwriteValue<NormalizedIntentAction[]>, unknown>;
|
|
460
491
|
executionResults: import("@langchain/langgraph").BaseChannel<ExecutionResult[], ExecutionResult[] | import("@langchain/langgraph").OverwriteValue<ExecutionResult[]>, unknown>;
|
|
461
492
|
error: import("@langchain/langgraph").BaseChannel<string | undefined, string | import("@langchain/langgraph").OverwriteValue<string | undefined> | undefined, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent.graph.d.ts","sourceRoot":"/","sources":["intent/intent.graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"intent.graph.d.ts","sourceRoot":"/","sources":["intent/intent.graph.ts"],"names":[],"mappings":"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"}
|
|
@@ -20,6 +20,42 @@ export function enforceIntentActionBoundary(operationMode, targetIntentIds, acti
|
|
|
20
20
|
const targets = new Set(targetIntentIds ?? []);
|
|
21
21
|
return actions.filter((action) => action.type === 'update' && targets.has(action.id));
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Build the only action permitted for an explicit update. This path is
|
|
25
|
+
* intentionally deterministic: semantic reconciliation may shape create
|
|
26
|
+
* operations, but it may not redirect an update away from its supplied target.
|
|
27
|
+
*/
|
|
28
|
+
export function buildExplicitUpdateActions(targetIntentIds, activeIntentIds, candidates) {
|
|
29
|
+
if (targetIntentIds?.length !== 1 || !activeIntentIds.includes(targetIntentIds[0])) {
|
|
30
|
+
return {
|
|
31
|
+
actions: [],
|
|
32
|
+
failure: {
|
|
33
|
+
category: 'update_target_boundary',
|
|
34
|
+
message: 'Explicit update requires exactly one active intent owned by the caller.',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (candidates.length !== 1) {
|
|
39
|
+
return {
|
|
40
|
+
actions: [],
|
|
41
|
+
failure: {
|
|
42
|
+
category: 'reconciliation_boundary',
|
|
43
|
+
message: 'Explicit update must resolve to exactly one verified intent.',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const candidate = candidates[0];
|
|
48
|
+
return {
|
|
49
|
+
actions: [{
|
|
50
|
+
type: 'update',
|
|
51
|
+
id: targetIntentIds[0],
|
|
52
|
+
payload: candidate.description,
|
|
53
|
+
score: candidate.score ?? null,
|
|
54
|
+
reasoning: candidate.reasoning ?? 'Explicit user-confirmed update',
|
|
55
|
+
intentMode: candidate.verification?.referential_anchor ? 'REFERENTIAL' : 'ATTRIBUTIVE',
|
|
56
|
+
}],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
23
59
|
const MAX_PERMISSIBLE_ENTROPY = 0.75;
|
|
24
60
|
const MIN_CLEAR_INTENT_SCORE = 40;
|
|
25
61
|
const GENERIC_JOB_PHRASE = /\b(?:a|any|some)\s+job\b/i;
|
|
@@ -89,17 +125,18 @@ const toSpeechActType = (classification) => {
|
|
|
89
125
|
* Factory class to build and compile the Intent Processing Graph.
|
|
90
126
|
*/
|
|
91
127
|
export class IntentGraphFactory {
|
|
92
|
-
constructor(database, embedder, intentQueue, questionerEnqueue) {
|
|
128
|
+
constructor(database, embedder, intentQueue, questionerEnqueue, agents) {
|
|
93
129
|
this.database = database;
|
|
94
130
|
this.embedder = embedder;
|
|
95
131
|
this.intentQueue = intentQueue;
|
|
96
132
|
this.questionerEnqueue = questionerEnqueue;
|
|
133
|
+
this.agents = agents;
|
|
97
134
|
}
|
|
98
135
|
createGraph() {
|
|
99
136
|
// Instantiate Agents (Nodes)
|
|
100
|
-
const inferrer = new ExplicitIntentInferrer();
|
|
101
|
-
const verifier = new SemanticVerifier();
|
|
102
|
-
const reconciler = new IntentReconciler();
|
|
137
|
+
const inferrer = this.agents?.inferrer ?? new ExplicitIntentInferrer();
|
|
138
|
+
const verifier = this.agents?.verifier ?? new SemanticVerifier();
|
|
139
|
+
const reconciler = this.agents?.reconciler ?? new IntentReconciler();
|
|
103
140
|
// --- NODE DEFINITIONS ---
|
|
104
141
|
/**
|
|
105
142
|
* Node 0: Prep
|
|
@@ -134,6 +171,7 @@ export class IntentGraphFactory {
|
|
|
134
171
|
});
|
|
135
172
|
return {
|
|
136
173
|
activeIntents: formattedActiveIntents,
|
|
174
|
+
activeIntentIds: activeIntents.map((intent) => intent.id),
|
|
137
175
|
trace: [{
|
|
138
176
|
node: "prep",
|
|
139
177
|
detail: `Fetched ${activeIntents.length} active intent(s)`,
|
|
@@ -247,7 +285,14 @@ export class IntentGraphFactory {
|
|
|
247
285
|
const VALID_TYPES = ['COMMISSIVE', 'DIRECTIVE', 'DECLARATION'];
|
|
248
286
|
if (!VALID_TYPES.includes(verdict.classification)) {
|
|
249
287
|
logger.warn('Dropping intent', { description, classification: verdict.classification });
|
|
250
|
-
return
|
|
288
|
+
return {
|
|
289
|
+
failure: {
|
|
290
|
+
category: 'non_actionable',
|
|
291
|
+
classification: verdict.classification,
|
|
292
|
+
referentialBreadth: verdict.referential_breadth,
|
|
293
|
+
message: `Description was classified as ${verdict.classification}, not an actionable goal.`,
|
|
294
|
+
},
|
|
295
|
+
};
|
|
251
296
|
}
|
|
252
297
|
if (isVague(description, verdict.semantic_entropy, verdict.felicity_scores.clarity)) {
|
|
253
298
|
logger.warn('Dropping vague intent after verification', {
|
|
@@ -255,34 +300,55 @@ export class IntentGraphFactory {
|
|
|
255
300
|
entropy: verdict.semantic_entropy,
|
|
256
301
|
clarity: verdict.felicity_scores.clarity,
|
|
257
302
|
});
|
|
258
|
-
return
|
|
303
|
+
return {
|
|
304
|
+
failure: {
|
|
305
|
+
category: 'vague_or_invalid',
|
|
306
|
+
classification: verdict.classification,
|
|
307
|
+
referentialBreadth: verdict.referential_breadth,
|
|
308
|
+
message: 'Description failed clarity or semantic-entropy requirements.',
|
|
309
|
+
},
|
|
310
|
+
};
|
|
259
311
|
}
|
|
260
|
-
if (state.operationMode
|
|
312
|
+
if (state.operationMode === 'create' && verdict.referential_breadth === 'broad') {
|
|
261
313
|
logger.warn('Dropping broad attributive intent before persistence', {
|
|
262
314
|
description,
|
|
263
315
|
referentialBreadth: verdict.referential_breadth,
|
|
264
316
|
missingSelectionalConstraints: verdict.missing_selectional_constraints,
|
|
265
317
|
warning: getSpecificityWarning(verdict),
|
|
266
318
|
});
|
|
267
|
-
return
|
|
319
|
+
return {
|
|
320
|
+
failure: {
|
|
321
|
+
category: 'vague_or_invalid',
|
|
322
|
+
classification: verdict.classification,
|
|
323
|
+
referentialBreadth: verdict.referential_breadth,
|
|
324
|
+
message: getSpecificityWarning(verdict),
|
|
325
|
+
},
|
|
326
|
+
};
|
|
268
327
|
}
|
|
269
328
|
// Calculate Score
|
|
270
329
|
const score = Math.min(verdict.felicity_scores.authority, verdict.felicity_scores.sincerity, verdict.felicity_scores.clarity);
|
|
271
330
|
// Return enriched intent
|
|
272
331
|
return {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
332
|
+
intent: {
|
|
333
|
+
...intent,
|
|
334
|
+
description,
|
|
335
|
+
verification: verdict,
|
|
336
|
+
score,
|
|
337
|
+
},
|
|
277
338
|
};
|
|
278
339
|
}
|
|
279
340
|
catch (e) {
|
|
280
341
|
logger.error('Error verifying intent', { description: intent.description, error: e });
|
|
281
|
-
return
|
|
342
|
+
return {
|
|
343
|
+
failure: {
|
|
344
|
+
category: 'verification_failure',
|
|
345
|
+
message: e instanceof Error ? e.message : 'Intent verification failed unexpectedly.',
|
|
346
|
+
},
|
|
347
|
+
};
|
|
282
348
|
}
|
|
283
349
|
}));
|
|
284
|
-
|
|
285
|
-
const
|
|
350
|
+
const verified = verificationResults.flatMap((result) => 'intent' in result ? [result.intent] : []);
|
|
351
|
+
const validationFailures = verificationResults.flatMap((result) => 'failure' in result ? [result.failure] : []);
|
|
286
352
|
logger.verbose(`Verification complete`, {
|
|
287
353
|
passed: verified.length,
|
|
288
354
|
total: intents.length,
|
|
@@ -326,7 +392,7 @@ export class IntentGraphFactory {
|
|
|
326
392
|
data: undefined,
|
|
327
393
|
});
|
|
328
394
|
}
|
|
329
|
-
return { verifiedIntents: verified, agentTimings: agentTimingsAccum, trace: traceEntries };
|
|
395
|
+
return { verifiedIntents: verified, validationFailures, agentTimings: agentTimingsAccum, trace: traceEntries };
|
|
330
396
|
});
|
|
331
397
|
};
|
|
332
398
|
/**
|
|
@@ -379,6 +445,22 @@ export class IntentGraphFactory {
|
|
|
379
445
|
trace: [{ node: "reconciler", detail: "No intents to reconcile" }],
|
|
380
446
|
};
|
|
381
447
|
}
|
|
448
|
+
if (state.operationMode === 'update') {
|
|
449
|
+
const explicitUpdate = buildExplicitUpdateActions(state.targetIntentIds, state.activeIntentIds, candidates);
|
|
450
|
+
return {
|
|
451
|
+
actions: explicitUpdate.actions,
|
|
452
|
+
validationFailures: explicitUpdate.failure
|
|
453
|
+
? [...state.validationFailures, explicitUpdate.failure]
|
|
454
|
+
: state.validationFailures,
|
|
455
|
+
agentTimings: agentTimingsAccum,
|
|
456
|
+
trace: [{
|
|
457
|
+
node: 'reconciler',
|
|
458
|
+
detail: explicitUpdate.failure
|
|
459
|
+
? `Explicit update rejected: ${explicitUpdate.failure.category}`
|
|
460
|
+
: `Explicit update bound to target ${state.targetIntentIds?.[0]}`,
|
|
461
|
+
}],
|
|
462
|
+
};
|
|
463
|
+
}
|
|
382
464
|
// Format candidates for the Reconciler Prompt
|
|
383
465
|
const formattedCandidates = candidates.map(c => `- [${c.type.toUpperCase()}] "${c.description}" (Confidence: ${c.confidence}, Score: ${c.score})\n` +
|
|
384
466
|
` Reasoning: ${c.reasoning}\n` +
|