@rsconcept/rstool 1.6.0 → 1.7.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/README.md +5 -4
- package/dist/{agent-workflow-BTwrxOoX.d.ts → agent-workflow-BqEC_Foh.d.ts} +51 -7
- package/dist/{analysis-DA44pfgA.d.ts → analysis-C7GrmB17.d.ts} +3 -4
- package/dist/{common-D6TFl6l_.d.ts → common-oafVB-wX.d.ts} +1 -2
- package/dist/{constituenta-QY5w1x91.d.ts → constituenta-CwJogNKY.d.ts} +4 -5
- package/dist/{diagnostic-C6TRoBgt.d.ts → diagnostic-CtxXifJY.d.ts} +8 -6
- package/dist/{diagnostic-assembly-B-6vIA5I.js → diagnostic-assembly-B-r0NyHL.js} +3 -2
- package/dist/diagnostic-assembly-B-r0NyHL.js.map +1 -0
- package/dist/{evaluation-Cd4S7-3t.d.ts → evaluation-BHv2xNwf.d.ts} +3 -4
- package/dist/index.d.ts +12 -11
- package/dist/index.js +1 -1
- package/dist/mappers/model-adapter.d.ts +4 -4
- package/dist/mappers/model-adapter.js +1 -1
- package/dist/mappers/schema-adapter.d.ts +5 -5
- package/dist/mappers/types.d.ts +5 -4
- package/dist/mappers/types.js +1 -1
- package/dist/mappers/types.js.map +1 -1
- package/dist/{model-value-BUhr2IjA.d.ts → model-value-C0QA-ji2.d.ts} +2 -3
- package/dist/models/agent-workflow.d.ts +2 -2
- package/dist/models/analysis.d.ts +1 -1
- package/dist/models/common.d.ts +1 -1
- package/dist/models/constituenta.d.ts +1 -1
- package/dist/models/diagnostic.d.ts +1 -1
- package/dist/models/diagnostic.js +1 -1
- package/dist/models/evaluation.d.ts +1 -1
- package/dist/models/index.d.ts +11 -11
- package/dist/models/index.js +1 -1
- package/dist/models/model-value.d.ts +1 -1
- package/dist/models/rstool-agent.d.ts +1 -1
- package/dist/models/rstool-agent.js +1 -1
- package/dist/models/session.d.ts +1 -1
- package/dist/models/tool-contract.d.ts +1 -1
- package/dist/models/tool-contract.js +1 -1
- package/dist/models/tool-contract.js.map +1 -1
- package/dist/{models-LMyDB0md.js → models-DG2uTaV_.js} +117 -4
- package/dist/models-DG2uTaV_.js.map +1 -0
- package/dist/{rstool-agent-BrAFJcoE.d.ts → rstool-agent-DLq0mtym.d.ts} +13 -10
- package/dist/session/session-store.d.ts +3 -2
- package/dist/session/session-store.js +1 -1
- package/dist/{session-CI4rLYby.d.ts → session-OaLqLq0H.d.ts} +3 -4
- package/dist/{tool-contract-BUaDRHoO.d.ts → tool-contract-ZVyh7hhp.d.ts} +15 -11
- package/dist/wrapper/stdio-wrapper.js +8 -2
- package/dist/wrapper/stdio-wrapper.js.map +1 -1
- package/docs/DIAGNOSTICS.md +64 -22
- package/docs/DOMAIN.md +16 -4
- package/docs/README.md +1 -1
- package/examples/diagnostics-utils.ts +3 -4
- package/package.json +6 -6
- package/skills/rstool-helper/EXAMPLES.md +25 -0
- package/skills/rstool-helper/GUIDE.md +5 -4
- package/skills/rstool-helper/REFERENCE.md +52 -21
- package/skills/rstool-helper/SKILL.md +1 -1
- package/src/index.ts +4 -1
- package/src/mappers/diagnostic-assembly.ts +9 -6
- package/src/mappers/types.ts +1 -0
- package/src/models/agent-workflow.ts +45 -0
- package/src/models/index.ts +5 -9
- package/src/models/rstool-agent.test.ts +62 -0
- package/src/models/rstool-agent.ts +160 -2
- package/src/models/tool-contract.ts +10 -2
- package/src/wrapper/stdio-handler.ts +8 -1
- package/dist/diagnostic-assembly-B-6vIA5I.js.map +0 -1
- package/dist/models-LMyDB0md.js.map +0 -1
|
@@ -1055,4 +1055,66 @@ describe('RSToolAgent modeling semantics', () => {
|
|
|
1055
1055
|
tool.setModelValues({ set: [{ target: 1, value: [1, 2, 3] as never }] }, session.sessionId)
|
|
1056
1056
|
).rejects.toThrow(/Invalid basic binding/);
|
|
1057
1057
|
});
|
|
1058
|
+
|
|
1059
|
+
it('synthesize merges source session and remaps aliases', () => {
|
|
1060
|
+
const tool = new RSToolAgent();
|
|
1061
|
+
const receiver = tool.createSession({ title: 'Receiver' });
|
|
1062
|
+
tool.applySchemaPatch({ items: [{ alias: 'X1' }] }, receiver.sessionId);
|
|
1063
|
+
|
|
1064
|
+
const source = tool.createSession({ title: 'Source' });
|
|
1065
|
+
tool.applySchemaPatch(
|
|
1066
|
+
{
|
|
1067
|
+
items: [
|
|
1068
|
+
{ alias: 'X1', term: 'person' },
|
|
1069
|
+
{ alias: 'S1', definitionFormal: 'ℬ(X1)' }
|
|
1070
|
+
]
|
|
1071
|
+
},
|
|
1072
|
+
source.sessionId
|
|
1073
|
+
);
|
|
1074
|
+
|
|
1075
|
+
tool.setCurrentSession(receiver.sessionId);
|
|
1076
|
+
const result = tool.synthesize({
|
|
1077
|
+
sourceSessionId: source.sessionId,
|
|
1078
|
+
commitMessage: 'merge source'
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
expect(result.summary.itemCount).toBe(3);
|
|
1082
|
+
expect(result.success).toBe(true);
|
|
1083
|
+
expect(result.failed).toEqual([]);
|
|
1084
|
+
expect(result.aliasMapping).toEqual({ X1: 'X2', S1: 'S1' });
|
|
1085
|
+
const state = tool.getSessionState('full', receiver.sessionId) as {
|
|
1086
|
+
items: Array<{ alias: string; definitionFormal: string }>;
|
|
1087
|
+
};
|
|
1088
|
+
expect(state.items.map(item => item.alias)).toEqual(['X1', 'X2', 'S1']);
|
|
1089
|
+
expect(state.items.find(item => item.alias === 'S1')?.definitionFormal).toBe('ℬ(X2)');
|
|
1090
|
+
expect(result.revision?.message).toBe('merge source');
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
it('synthesize applies identification table', () => {
|
|
1094
|
+
const tool = new RSToolAgent();
|
|
1095
|
+
const receiver = tool.createSession();
|
|
1096
|
+
tool.applySchemaPatch({ items: [{ alias: 'X1', term: 'keep' }] }, receiver.sessionId);
|
|
1097
|
+
|
|
1098
|
+
const source = tool.createSession();
|
|
1099
|
+
tool.applySchemaPatch({ items: [{ alias: 'X1', term: 'drop' }] }, source.sessionId);
|
|
1100
|
+
|
|
1101
|
+
tool.setCurrentSession(receiver.sessionId);
|
|
1102
|
+
const result = tool.synthesize({
|
|
1103
|
+
sourceSessionId: source.sessionId,
|
|
1104
|
+
substitutions: [{ original: 'X1', substitution: 'X1' }]
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
expect(result.summary.itemCount).toBe(1);
|
|
1108
|
+
expect(result.success).toBe(true);
|
|
1109
|
+
expect(result.deletedIds).toHaveLength(1);
|
|
1110
|
+
const state = tool.getSessionState('full', receiver.sessionId) as { items: Array<{ alias: string; term: string }> };
|
|
1111
|
+
expect(state.items[0].alias).toBe('X1');
|
|
1112
|
+
expect(state.items[0].term).toBe('keep');
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
it('synthesize rejects same source and receiver session', () => {
|
|
1116
|
+
const tool = new RSToolAgent();
|
|
1117
|
+
const session = tool.createSession();
|
|
1118
|
+
expect(() => tool.synthesize({ sourceSessionId: session.sessionId }, session.sessionId)).toThrow(/must differ/);
|
|
1119
|
+
});
|
|
1058
1120
|
});
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
inlineSynthesis,
|
|
3
|
+
restoreConstituentOrder,
|
|
4
|
+
type SynthesizableFields
|
|
5
|
+
} from '@rsconcept/domain/library/rsform-api';
|
|
6
|
+
import { type Substitution } from '@rsconcept/domain/library/rsform';
|
|
2
7
|
import {
|
|
3
8
|
portalDetailsToDrafts,
|
|
4
9
|
portalDetailsToSessionSeed,
|
|
@@ -17,7 +22,9 @@ import {
|
|
|
17
22
|
type RestoreOrderResult,
|
|
18
23
|
type SessionStateDetail,
|
|
19
24
|
type SessionStateResult,
|
|
20
|
-
type SessionSummary
|
|
25
|
+
type SessionSummary,
|
|
26
|
+
type SynthesizeInput,
|
|
27
|
+
type SynthesizeResult
|
|
21
28
|
} from './agent-workflow';
|
|
22
29
|
import { type AnalysisResult, type AnalyzeExpressionInput } from './analysis';
|
|
23
30
|
import { CstType } from './common';
|
|
@@ -326,6 +333,141 @@ export class RSToolAgent implements RSToolAgentContract {
|
|
|
326
333
|
};
|
|
327
334
|
}
|
|
328
335
|
|
|
336
|
+
/** @inheritdoc */
|
|
337
|
+
public synthesize(input: SynthesizeInput, sessionId?: string): SynthesizeResult {
|
|
338
|
+
const receiverHandle = sessionId
|
|
339
|
+
? { sessionId: this.resolveSessionId(sessionId), contractVersion: this.contractVersion }
|
|
340
|
+
: this.ensureSession();
|
|
341
|
+
const receiverId = receiverHandle.sessionId;
|
|
342
|
+
const sourceId = this.resolveSessionId(input.sourceSessionId);
|
|
343
|
+
|
|
344
|
+
if (sourceId === receiverId) {
|
|
345
|
+
throw new Error('synthesize: sourceSessionId must differ from the receiver session');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const receiverEnvelope = this.sessions.get(receiverId);
|
|
349
|
+
const sourceEnvelope = this.sessions.get(sourceId);
|
|
350
|
+
const snapshot = this.sessions.snapshot(receiverId);
|
|
351
|
+
|
|
352
|
+
try {
|
|
353
|
+
const sourceItems = this.selectSourceItems(sourceEnvelope.state.items, input.items);
|
|
354
|
+
const substitutions = this.resolveSynthesisSubstitutions(
|
|
355
|
+
receiverEnvelope.state.items,
|
|
356
|
+
sourceItems,
|
|
357
|
+
input.substitutions ?? []
|
|
358
|
+
);
|
|
359
|
+
|
|
360
|
+
const nextId = receiverEnvelope.state.items.reduce((max, item) => Math.max(max, item.id), 0) + 1;
|
|
361
|
+
const result = inlineSynthesis({
|
|
362
|
+
receiverItems: receiverEnvelope.state.items.map(toSynthesizableSessionItem),
|
|
363
|
+
sourceItems: sourceItems.map(toSynthesizableSessionItem),
|
|
364
|
+
substitutions,
|
|
365
|
+
nextId
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
const drafts: ConstituentaDraft[] = result.items.map(item => ({
|
|
369
|
+
id: item.id,
|
|
370
|
+
alias: item.alias,
|
|
371
|
+
cstType: item.cst_type,
|
|
372
|
+
definitionFormal: item.definition_formal,
|
|
373
|
+
term: item.term_resolved || item.term_raw,
|
|
374
|
+
definitionText: item.definition_resolved || item.definition_raw,
|
|
375
|
+
convention: item.convention
|
|
376
|
+
}));
|
|
377
|
+
|
|
378
|
+
receiverEnvelope.state.items = [];
|
|
379
|
+
receiverEnvelope.state.model = {
|
|
380
|
+
items: receiverEnvelope.state.model.items.filter(value => !result.deletedIds.has(value.id))
|
|
381
|
+
};
|
|
382
|
+
this.sessions.replaceState(receiverId, receiverEnvelope.state);
|
|
383
|
+
|
|
384
|
+
const applied = this.applyConstituents({ drafts, mode: 'best_effort' }, receiverId);
|
|
385
|
+
|
|
386
|
+
const revision = input.commitMessage ? this.commitStep(input.commitMessage, receiverId) : undefined;
|
|
387
|
+
return {
|
|
388
|
+
session: receiverHandle,
|
|
389
|
+
summary: this.buildSessionSummary(receiverId),
|
|
390
|
+
success: applied.success,
|
|
391
|
+
failed: applied.failed,
|
|
392
|
+
idMap: result.idMap,
|
|
393
|
+
aliasMapping: result.aliasMapping,
|
|
394
|
+
deletedIds: [...result.deletedIds],
|
|
395
|
+
insertedIds: result.insertedIds,
|
|
396
|
+
revision
|
|
397
|
+
};
|
|
398
|
+
} catch (error) {
|
|
399
|
+
this.sessions.restore(receiverId, snapshot);
|
|
400
|
+
throw error;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
private selectSourceItems(sourceItems: ConstituentaState[], aliases?: string[]): ConstituentaState[] {
|
|
405
|
+
if (!aliases || aliases.length === 0) {
|
|
406
|
+
return [...sourceItems];
|
|
407
|
+
}
|
|
408
|
+
const byAlias = new Map(sourceItems.map(item => [item.alias, item]));
|
|
409
|
+
const selected: ConstituentaState[] = [];
|
|
410
|
+
for (const alias of aliases) {
|
|
411
|
+
const item = byAlias.get(alias);
|
|
412
|
+
if (!item) {
|
|
413
|
+
throw new Error(`synthesize: unknown source alias "${alias}"`);
|
|
414
|
+
}
|
|
415
|
+
selected.push(item);
|
|
416
|
+
}
|
|
417
|
+
return selected;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
private resolveSynthesisSubstitutions(
|
|
421
|
+
receiverItems: ConstituentaState[],
|
|
422
|
+
sourceItems: ConstituentaState[],
|
|
423
|
+
substitutions: SynthesizeInput['substitutions']
|
|
424
|
+
): Substitution[] {
|
|
425
|
+
if (!substitutions || substitutions.length === 0) {
|
|
426
|
+
return [];
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
const receiverByAlias = new Map(receiverItems.map(item => [item.alias, item]));
|
|
430
|
+
const sourceByAlias = new Map(sourceItems.map(item => [item.alias, item]));
|
|
431
|
+
const deletedKeys = new Set<string>();
|
|
432
|
+
const resolved: Substitution[] = [];
|
|
433
|
+
|
|
434
|
+
for (const row of substitutions) {
|
|
435
|
+
const originalSource = sourceByAlias.get(row.original);
|
|
436
|
+
const originalReceiver = receiverByAlias.get(row.original);
|
|
437
|
+
const substitutionSource = sourceByAlias.get(row.substitution);
|
|
438
|
+
const substitutionReceiver = receiverByAlias.get(row.substitution);
|
|
439
|
+
|
|
440
|
+
let originalId: number;
|
|
441
|
+
let substitutionId: number;
|
|
442
|
+
let originalKey: string;
|
|
443
|
+
|
|
444
|
+
// Prefer source→receiver when both sides share the same alias (typical base identification).
|
|
445
|
+
// Session ids are independent, so do not compare numeric ids across sessions.
|
|
446
|
+
if (originalSource && substitutionReceiver) {
|
|
447
|
+
originalId = originalSource.id;
|
|
448
|
+
substitutionId = substitutionReceiver.id;
|
|
449
|
+
originalKey = `s:${originalId}`;
|
|
450
|
+
} else if (originalReceiver && substitutionSource) {
|
|
451
|
+
originalId = originalReceiver.id;
|
|
452
|
+
substitutionId = substitutionSource.id;
|
|
453
|
+
originalKey = `r:${originalId}`;
|
|
454
|
+
} else {
|
|
455
|
+
throw new Error(
|
|
456
|
+
`synthesize: substitution "${row.original}" → "${row.substitution}" must pair one source alias with one receiver alias`
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if (deletedKeys.has(originalKey)) {
|
|
461
|
+
throw new Error(`synthesize: constituenta "${row.original}" is substituted more than once`);
|
|
462
|
+
}
|
|
463
|
+
deletedKeys.add(originalKey);
|
|
464
|
+
|
|
465
|
+
resolved.push({ original: originalId, substitution: substitutionId });
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return resolved;
|
|
469
|
+
}
|
|
470
|
+
|
|
329
471
|
private addOrUpdateConstituenta(
|
|
330
472
|
input: AddOrUpdateConstituentaInput,
|
|
331
473
|
sessionId?: string
|
|
@@ -551,3 +693,19 @@ export class RSToolAgent implements RSToolAgentContract {
|
|
|
551
693
|
]);
|
|
552
694
|
}
|
|
553
695
|
}
|
|
696
|
+
|
|
697
|
+
function toSynthesizableSessionItem(item: ConstituentaState): SynthesizableFields & { convention: string } {
|
|
698
|
+
return {
|
|
699
|
+
id: item.id,
|
|
700
|
+
alias: item.alias,
|
|
701
|
+
cst_type: item.cstType,
|
|
702
|
+
definition_formal: item.definitionFormal,
|
|
703
|
+
typification_manual: '',
|
|
704
|
+
term_raw: item.term,
|
|
705
|
+
term_resolved: item.term,
|
|
706
|
+
term_forms: [],
|
|
707
|
+
definition_raw: item.definitionText,
|
|
708
|
+
definition_resolved: item.definitionText,
|
|
709
|
+
convention: item.convention
|
|
710
|
+
};
|
|
711
|
+
}
|
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
type ApplySchemaPatchResult,
|
|
4
4
|
type RestoreOrderResult,
|
|
5
5
|
type SessionStateDetail,
|
|
6
|
-
type SessionStateResult
|
|
6
|
+
type SessionStateResult,
|
|
7
|
+
type SynthesizeInput,
|
|
8
|
+
type SynthesizeResult
|
|
7
9
|
} from './agent-workflow';
|
|
8
10
|
import { type AnalysisResult, type AnalyzeExpressionInput } from './analysis';
|
|
9
11
|
import { type Diagnostic, type ListDiagnosticsFilters } from './diagnostic';
|
|
@@ -13,7 +15,7 @@ import { type RecalculateModelResult, type SessionModelState, type SetModelValue
|
|
|
13
15
|
import { type SessionHandle, type SessionRevision, type SessionState } from './session';
|
|
14
16
|
|
|
15
17
|
/** Agent-visible contract version; bump on breaking API changes. */
|
|
16
|
-
export const CONTRACT_VERSION = '3.
|
|
18
|
+
export const CONTRACT_VERSION = '3.3.0';
|
|
17
19
|
|
|
18
20
|
/** Options for constructing an {@link RSToolAgent}. */
|
|
19
21
|
export interface RSToolAgentOptions {
|
|
@@ -92,4 +94,10 @@ export interface RSToolAgentContract {
|
|
|
92
94
|
* otherwise stable against type/kernel preferred ranks.
|
|
93
95
|
*/
|
|
94
96
|
restoreOrder(sessionId?: string): RestoreOrderResult;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Synthesis by embedding: merge constituents from another session into the receiver,
|
|
100
|
+
* then apply an identification table.
|
|
101
|
+
*/
|
|
102
|
+
synthesize(input: SynthesizeInput, sessionId?: string): SynthesizeResult;
|
|
95
103
|
}
|
|
@@ -34,7 +34,8 @@ export const STDIO_METHODS = [
|
|
|
34
34
|
'getModelState',
|
|
35
35
|
'evaluate',
|
|
36
36
|
'recalculateModel',
|
|
37
|
-
'restoreOrder'
|
|
37
|
+
'restoreOrder',
|
|
38
|
+
'synthesize'
|
|
38
39
|
] as const;
|
|
39
40
|
|
|
40
41
|
function asObject(value: unknown): Record<string, unknown> {
|
|
@@ -178,6 +179,12 @@ export async function handleStdioRequest(tool: RSToolAgent, request: StdioReques
|
|
|
178
179
|
ok: true,
|
|
179
180
|
result: tool.restoreOrder(optionalSessionId(params))
|
|
180
181
|
};
|
|
182
|
+
case 'synthesize':
|
|
183
|
+
return {
|
|
184
|
+
id: request.id,
|
|
185
|
+
ok: true,
|
|
186
|
+
result: tool.synthesize(omitSessionId(params) as never, optionalSessionId(params))
|
|
187
|
+
};
|
|
181
188
|
default:
|
|
182
189
|
return {
|
|
183
190
|
id: request.id ?? null,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-assembly-B-6vIA5I.js","names":[],"sources":["../src/mappers/diagnostic-assembly.ts"],"sourcesContent":["import {\n type Constituenta,\n type CstDiagnostic,\n DiagnosticKind,\n modelStatusCstDiagnostic,\n RSDiagnosticCode\n} from '@rsconcept/domain/library';\nimport { EvalStatus } from '@rsconcept/domain/library/rsmodel';\nimport { isCritical, RSErrorCode, type RSErrorDescription } from '@rsconcept/domain/rslang/error';\n\nexport { DiagnosticKind, RSDiagnosticCode };\n\n/** Severity of a {@link Diagnostic}. */\nexport type DiagnosticSeverity = 'error' | 'warning';\n\n/** Agent-facing diagnostic with redundant fields for autonomous repair. */\nexport interface Diagnostic extends CstDiagnostic {\n name: string;\n severity: DiagnosticSeverity;\n constituentId?: number;\n alias?: string;\n expression: string;\n from: number;\n to: number;\n}\n\n/** Context for attributing a {@link Diagnostic} to a constituent. */\nexport interface DiagnosticTarget {\n constituentId?: number;\n alias?: string;\n}\n\nconst DIAGNOSTIC_NAMES: ReadonlyMap<number, string> = new Map([\n ...Object.entries(RSErrorCode).map(([name, code]) => [code, name] as const),\n ...Object.entries(RSDiagnosticCode).map(([name, code]) => [code, name] as const)\n]);\n\nexport function getDiagnosticName(code: number): string {\n return DIAGNOSTIC_NAMES.get(code) ?? `0x${code.toString(16).toUpperCase()}`;\n}\n\nexport function getDiagnosticSeverity(code: number): DiagnosticSeverity {\n return isCritical(code as RSErrorCode) ? 'error' : 'warning';\n}\n\nexport function expandCstDiagnostic(cst: Constituenta, diagnostic: CstDiagnostic): Diagnostic {\n const expression = expressionForCstDiagnostic(cst, diagnostic);\n return {\n ...diagnostic,\n name: getDiagnosticName(diagnostic.code),\n severity: getDiagnosticSeverity(diagnostic.code),\n constituentId: cst.id,\n alias: cst.alias,\n expression,\n from: 0,\n to: diagnostic.kind === DiagnosticKind.MODEL ? 0 : Math.max(expression.length, 1)\n };\n}\n\nexport function expressionDiagnostic(\n error: RSErrorDescription,\n expression: string,\n target?: DiagnosticTarget\n): Diagnostic {\n return {\n kind: DiagnosticKind.EXPRESSION,\n code: error.code,\n name: getDiagnosticName(error.code),\n severity: getDiagnosticSeverity(error.code),\n constituentId: target?.constituentId,\n alias: target?.alias,\n expression,\n from: error.from,\n to: error.to,\n ...(error.params ? { params: error.params } : {})\n };\n}\n\nexport function modelStatusDiagnostic(status: EvalStatus, cst: Constituenta): Diagnostic | null {\n const base = modelStatusCstDiagnostic(status, cst.cst_type);\n return base ? expandCstDiagnostic(cst, base) : null;\n}\n\nfunction expressionForCstDiagnostic(cst: Constituenta, diagnostic: CstDiagnostic): string {\n switch (diagnostic.code) {\n case RSDiagnosticCode.schemaHomonym:\n case RSDiagnosticCode.schemaMissingTerm:\n return cst.term_resolved;\n case RSDiagnosticCode.schemaMissingConvention:\n return cst.convention;\n case RSDiagnosticCode.schemaTypeMismatch:\n return cst.typification_manual;\n case RSDiagnosticCode.schemaDependencyCycle:\n case RSDiagnosticCode.schemaFormalDuplicate:\n return cst.definition_formal;\n default:\n return cst.definition_formal;\n }\n}\n"],"mappings":";;;AAgCA,MAAM,mBAAgD,IAAI,IAAI,CAC5D,GAAG,OAAO,QAAQ,WAAW,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,IAAI,CAAU,GAC1E,GAAG,OAAO,QAAQ,gBAAgB,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,IAAI,CAAU,CACjF,CAAC;AAED,SAAgB,kBAAkB,MAAsB;CACtD,OAAO,iBAAiB,IAAI,IAAI,KAAK,KAAK,KAAK,SAAS,EAAE,CAAC,CAAC,YAAY;AAC1E;AAEA,SAAgB,sBAAsB,MAAkC;CACtE,OAAO,WAAW,IAAmB,IAAI,UAAU;AACrD;AAEA,SAAgB,oBAAoB,KAAmB,YAAuC;CAC5F,MAAM,aAAa,2BAA2B,KAAK,UAAU;CAC7D,OAAO;EACL,GAAG;EACH,MAAM,kBAAkB,WAAW,IAAI;EACvC,UAAU,sBAAsB,WAAW,IAAI;EAC/C,eAAe,IAAI;EACnB,OAAO,IAAI;EACX;EACA,MAAM;EACN,IAAI,WAAW,SAAS,eAAe,QAAQ,IAAI,KAAK,IAAI,WAAW,QAAQ,CAAC;CAClF;AACF;AAEA,SAAgB,qBACd,OACA,YACA,QACY;CACZ,OAAO;EACL,MAAM,eAAe;EACrB,MAAM,MAAM;EACZ,MAAM,kBAAkB,MAAM,IAAI;EAClC,UAAU,sBAAsB,MAAM,IAAI;EAC1C,eAAe,QAAQ;EACvB,OAAO,QAAQ;EACf;EACA,MAAM,MAAM;EACZ,IAAI,MAAM;EACV,GAAI,MAAM,SAAS,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;CACjD;AACF;AAEA,SAAgB,sBAAsB,QAAoB,KAAsC;CAC9F,MAAM,OAAO,yBAAyB,QAAQ,IAAI,QAAQ;CAC1D,OAAO,OAAO,oBAAoB,KAAK,IAAI,IAAI;AACjD;AAEA,SAAS,2BAA2B,KAAmB,YAAmC;CACxF,QAAQ,WAAW,MAAnB;EACE,KAAK,iBAAiB;EACtB,KAAK,iBAAiB,mBACpB,OAAO,IAAI;EACb,KAAK,iBAAiB,yBACpB,OAAO,IAAI;EACb,KAAK,iBAAiB,oBACpB,OAAO,IAAI;EACb,KAAK,iBAAiB;EACtB,KAAK,iBAAiB,uBACpB,OAAO,IAAI;EACb,SACE,OAAO,IAAI;CACf;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"models-LMyDB0md.js","names":[],"sources":["../src/models/portal-json.ts","../src/mappers/portal-adapter.ts","../src/mappers/diagnostics-collector.ts","../src/session/batch-apply.ts","../src/session/persistence.ts","../src/session/session-store.ts","../src/models/import-detect.ts","../src/models/rstool-agent.ts"],"sourcesContent":["import { CstType, type BasicBinding, type RSToolValue } from './common';\nimport { type ConstituentaDraft } from './constituenta';\n\nconst CST_TYPE_VALUES = new Set<string>(Object.values(CstType));\n\nfunction parsePortalCstType(value: string, alias: string): ConstituentaDraft['cstType'] {\n if (!CST_TYPE_VALUES.has(value)) {\n throw new Error(`Invalid cst_type \"${value}\" for constituent \"${alias}\"`);\n }\n return value as ConstituentaDraft['cstType'];\n}\n\n/** Portal JSON import/export format version (schema and model files). */\nexport const PORTAL_JSON_CONTRACT_VERSION = '1.0.0';\n\n/** Shared metadata block in Portal schema and model JSON files. */\nexport interface PortalImportMetadata {\n contract_version: string;\n title: string;\n alias: string;\n description: string;\n}\n\n/** Inflected or tagged surface form of a term. */\nexport interface PortalTermForm {\n text: string;\n tags: string;\n}\n\n/** One constituent in Portal schema JSON (`cst_type`, snake_case fields). */\nexport interface PortalSchemaConstituenta {\n id: number;\n alias: string;\n convention: string;\n crucial: boolean;\n cst_type: string;\n definition_formal: string;\n typification_manual: string;\n value_is_property: boolean;\n definition_raw: string;\n definition_resolved: string;\n term_raw: string;\n term_resolved: string;\n term_forms: PortalTermForm[];\n}\n\n/** Full Portal conceptual schema import/export document. */\nexport interface PortalSchemaImportData extends PortalImportMetadata {\n items: PortalSchemaConstituenta[];\n attribution: Array<{ container: number; attribute: number }>;\n}\n\n/** `GET /api/rsforms/:id/details` response (schema payload only). */\nexport interface PortalRsformDetails {\n id?: number;\n title?: string;\n alias?: string;\n description?: string;\n items: Array<{\n id: number;\n alias: string;\n cst_type: string;\n definition_formal?: string;\n term_raw?: string;\n definition_raw?: string;\n convention?: string;\n }>;\n}\n\n/** Full Portal conceptual model import/export document. */\nexport interface PortalModelImportData extends PortalImportMetadata {\n items: Array<{\n id: number;\n type: string;\n value: RSToolValue | BasicBinding;\n }>;\n}\n\n/** Map a Portal API or JSON schema item to an agent {@link ConstituentaDraft}. */\nexport function portalItemToDraft(item: {\n id: number;\n alias: string;\n cst_type: string;\n definition_formal?: string;\n term_raw?: string;\n definition_raw?: string;\n convention?: string;\n}): ConstituentaDraft {\n return {\n id: item.id,\n alias: item.alias,\n cstType: parsePortalCstType(item.cst_type, item.alias),\n definitionFormal: item.definition_formal ?? '',\n term: item.term_raw ?? '',\n definitionText: item.definition_raw ?? '',\n convention: item.convention ?? ''\n };\n}\n","import { type ConstituentaDraft } from '../models/constituenta';\nimport {\n type PortalImportMetadata,\n type PortalRsformDetails,\n type PortalSchemaImportData,\n portalItemToDraft\n} from '../models/portal-json';\nimport { type SessionState } from '../models/session';\n\ntype PortalSessionSeedInput = Partial<Pick<PortalImportMetadata, 'alias' | 'title' | 'description'>>;\n\nfunction portalMetadataToSessionSeed(data: PortalSessionSeedInput): Partial<SessionState> {\n return {\n alias: data.alias ?? '',\n title: data.title ?? '',\n comment: data.description ?? '',\n items: []\n };\n}\n\nexport function portalSchemaToSessionSeed(data: PortalSchemaImportData): Partial<SessionState> {\n return portalMetadataToSessionSeed(data);\n}\n\nexport function portalDetailsToSessionSeed(data: PortalRsformDetails): Partial<SessionState> {\n return portalMetadataToSessionSeed(data);\n}\n\nexport function portalItemsToDrafts(\n items: Array<{\n id: number;\n alias: string;\n cst_type: string;\n definition_formal?: string;\n term_raw?: string;\n definition_raw?: string;\n convention?: string;\n }>\n): ConstituentaDraft[] {\n return items.map(item => portalItemToDraft(item));\n}\n\nexport function portalSchemaToDrafts(data: PortalSchemaImportData): ConstituentaDraft[] {\n return portalItemsToDrafts(data.items);\n}\n\nexport function portalDetailsToDrafts(data: PortalRsformDetails): ConstituentaDraft[] {\n return portalItemsToDrafts(data.items);\n}\n","import { isModelIssue } from '@rsconcept/domain/library/rsmodel-api';\n\nimport { type SessionState } from '../models';\nimport {\n DiagnosticKind,\n expandCstDiagnostic,\n modelStatusDiagnostic,\n type Diagnostic\n} from './diagnostic-assembly';\nimport { ModelAdapter } from './model-adapter';\nimport { enrichSessionConstituents } from './rsform-builder';\nimport { toDiagnostic } from './types';\n\nconst modelAdapter = new ModelAdapter();\n\n/** Collect expression and schema diagnostics for a session. */\nexport function collectSchemaDiagnostics(session: SessionState): Diagnostic[] {\n const records: Diagnostic[] = [];\n\n for (const item of session.items) {\n for (const diagnostic of item.analysis.diagnostics) {\n const base = diagnostic.name\n ? diagnostic\n : toDiagnostic(diagnostic, item.definitionFormal, {\n constituentId: item.id,\n alias: item.alias\n });\n records.push({\n ...base,\n kind: DiagnosticKind.EXPRESSION,\n constituentId: base.constituentId ?? item.id,\n alias: base.alias ?? item.alias\n });\n }\n }\n\n const enriched = enrichSessionConstituents(session);\n for (const { cst } of enriched) {\n for (const diagnostic of cst.diagnostics) {\n if (diagnostic.kind !== DiagnosticKind.SCHEMA) {\n continue;\n }\n records.push(expandCstDiagnostic(cst, diagnostic));\n }\n }\n\n return records;\n}\n\n/** Collect model diagnostics for a session (requires schema items). */\nexport function collectModelDiagnostics(session: SessionState): Diagnostic[] {\n if (session.items.length === 0) {\n return [];\n }\n\n const records: Diagnostic[] = [];\n const enriched = enrichSessionConstituents(session);\n const schema = enriched.map(entry => entry.cst);\n const engine = modelAdapter.createEngine(session);\n engine.recalculateAll();\n for (const cst of schema) {\n if (!isModelIssue(engine, cst)) {\n continue;\n }\n const diagnostic = modelStatusDiagnostic(engine.getCstStatus(cst.id), cst);\n if (diagnostic) {\n records.push(diagnostic);\n }\n }\n\n return records;\n}\n\n/** Collect expression, schema, and model diagnostics for a session. */\nexport function collectSessionDiagnostics(session: SessionState): Diagnostic[] {\n return [...collectSchemaDiagnostics(session), ...collectModelDiagnostics(session)];\n}\n","import { Graph } from '@rsconcept/domain/graph/graph';\nimport { extractGlobals } from '@rsconcept/domain/rslang/api';\n\nimport { type ConstituentaDraft, type ConstituentaState } from '../models';\n\n/** Order drafts so suppliers are applied before dependents. */\nexport function orderDrafts(sessionItems: ConstituentaState[], drafts: ConstituentaDraft[]): ConstituentaDraft[] {\n const merged = new Map<number, ConstituentaDraft>();\n for (const item of sessionItems) {\n merged.set(item.id, {\n id: item.id,\n alias: item.alias,\n cstType: item.cstType,\n definitionFormal: item.definitionFormal\n });\n }\n for (const draft of drafts) {\n merged.set(draft.id, draft);\n }\n\n const graph = new Graph<number>();\n const aliasToId = new Map<string, number>();\n for (const [id, draft] of merged) {\n graph.addNode(id);\n aliasToId.set(draft.alias, id);\n }\n\n for (const [id, draft] of merged) {\n if (!draft.definitionFormal) {\n continue;\n }\n for (const alias of extractGlobals(draft.definitionFormal)) {\n const depId = aliasToId.get(alias);\n if (depId !== undefined && depId !== id) {\n graph.addEdge(depId, id);\n }\n }\n }\n\n const draftIds = new Set(drafts.map(draft => draft.id));\n const topoIds = graph.topologicalOrder().filter(id => draftIds.has(id));\n const seen = new Set(topoIds);\n const missing = drafts.filter(draft => !seen.has(draft.id)).map(draft => draft.id);\n\n const orderedIds = [...topoIds, ...missing];\n return orderedIds.map(id => drafts.find(draft => draft.id === id)!).filter(Boolean);\n}\n\n/**\n * Restore declaration order in session items after a batch apply.\n * Topological apply order is only needed for analysis; Portal JSON uses array order.\n */\nexport function reorderSessionItemsByDrafts(\n items: ConstituentaState[],\n drafts: ConstituentaDraft[],\n preBatchItemIds: ReadonlySet<number>\n): void {\n if (drafts.length === 0 || items.length === 0) {\n return;\n }\n\n const draftIds = drafts.map(draft => draft.id);\n const draftIdSet = new Set(draftIds);\n const mentioned = items.filter(item => draftIdSet.has(item.id));\n if (mentioned.length === 0) {\n return;\n }\n\n const unmentioned = items.filter(item => !draftIdSet.has(item.id));\n if (unmentioned.length === 0) {\n const byId = new Map(items.map(item => [item.id, item]));\n items.splice(0, items.length, ...draftIds.map(id => byId.get(id)!));\n return;\n }\n\n const newDrafts = drafts.filter(draft => !preBatchItemIds.has(draft.id));\n if (newDrafts.length === 0) {\n return;\n }\n\n const newIds = new Set(newDrafts.map(draft => draft.id));\n const kept = items.filter(item => !newIds.has(item.id));\n const byId = new Map(items.map(item => [item.id, item]));\n items.splice(0, items.length, ...kept, ...newDrafts.map(draft => byId.get(draft.id)!));\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { type Diagnostic, type SessionState } from '../models';\n\nexport interface PersistedSessionEnvelope {\n state: SessionState;\n diagnostics: Diagnostic[];\n}\n\nconst CURRENT_SESSION_FILE = '_current.json';\nconst UNSAFE_SESSION_ID = /[/\\\\]|\\.\\./;\n\nfunction assertSafeSessionId(sessionId: string): void {\n if (!sessionId || UNSAFE_SESSION_ID.test(sessionId)) {\n throw new Error(`Invalid session ID: ${sessionId}`);\n }\n}\n\nexport class SessionPersistence {\n private readonly dir: string;\n\n public constructor(dir: string) {\n this.dir = dir;\n fs.mkdirSync(dir, { recursive: true });\n }\n\n public save(sessionId: string, envelope: PersistedSessionEnvelope): void {\n fs.writeFileSync(this.filePath(sessionId), JSON.stringify(envelope, null, 2), 'utf-8');\n }\n\n public load(sessionId: string): PersistedSessionEnvelope | null {\n const file = this.filePath(sessionId);\n if (!fs.existsSync(file)) {\n return null;\n }\n return JSON.parse(fs.readFileSync(file, 'utf-8')) as PersistedSessionEnvelope;\n }\n\n public delete(sessionId: string): void {\n const file = this.filePath(sessionId);\n if (fs.existsSync(file)) {\n fs.unlinkSync(file);\n }\n }\n\n public saveCurrentSessionId(sessionId: string | null): void {\n fs.writeFileSync(path.join(this.dir, CURRENT_SESSION_FILE), JSON.stringify({ sessionId }, null, 2), 'utf-8');\n }\n\n public loadCurrentSessionId(): string | null {\n const file = path.join(this.dir, CURRENT_SESSION_FILE);\n if (!fs.existsSync(file)) {\n return null;\n }\n const parsed = JSON.parse(fs.readFileSync(file, 'utf-8')) as { sessionId?: string | null };\n return parsed.sessionId ?? null;\n }\n\n private filePath(sessionId: string): string {\n assertSafeSessionId(sessionId);\n const file = path.resolve(this.dir, `${sessionId}.json`);\n const relative = path.relative(path.resolve(this.dir), file);\n if (relative.startsWith('..') || path.isAbsolute(relative)) {\n throw new Error(`Invalid session ID: ${sessionId}`);\n }\n return file;\n }\n}\n","import { randomUUID } from 'node:crypto';\n\nimport {\n CONTRACT_VERSION,\n type Diagnostic,\n type ListDiagnosticsFilters,\n type SessionHandle,\n type SessionRevision,\n type SessionState\n} from '../models';\nimport { SessionPersistence, type PersistedSessionEnvelope } from './persistence';\n\nexport interface SessionStoreOptions {\n persistenceDir?: string;\n}\n\ninterface SessionEnvelope {\n state: SessionState;\n diagnostics: Diagnostic[];\n}\n\nexport class SessionStore {\n private sessions = new Map<string, SessionEnvelope>();\n private readonly persistence: SessionPersistence | null;\n\n public constructor(options: SessionStoreOptions = {}) {\n this.persistence = options.persistenceDir ? new SessionPersistence(options.persistenceDir) : null;\n }\n\n public create(initial?: Partial<SessionState>, contractVersion?: string): SessionHandle {\n const now = new Date().toISOString();\n const sessionId = initial?.sessionId ?? randomUUID();\n const state: SessionState = {\n sessionId,\n alias: initial?.alias ?? '',\n title: initial?.title ?? '',\n comment: initial?.comment ?? '',\n createdAt: initial?.createdAt ?? now,\n updatedAt: now,\n revisions: initial?.revisions ?? [],\n items: initial?.items ?? [],\n model: initial?.model ?? { items: [] }\n };\n const envelope: SessionEnvelope = {\n state,\n diagnostics: []\n };\n this.sessions.set(sessionId, envelope);\n this.persist(sessionId, envelope);\n return {\n sessionId,\n contractVersion: contractVersion ?? CONTRACT_VERSION\n };\n }\n\n public get(sessionId: string): SessionEnvelope {\n const found = this.sessions.get(sessionId) ?? this.loadFromDisk(sessionId);\n if (!found) {\n throw new Error(`Unknown session: ${sessionId}`);\n }\n return found;\n }\n\n public has(sessionId: string): boolean {\n if (this.sessions.has(sessionId)) {\n return true;\n }\n if (!this.persistence) {\n return false;\n }\n return this.persistence.load(sessionId) !== null;\n }\n\n public replaceState(sessionId: string, nextState: SessionState): void {\n const found = this.get(sessionId);\n found.state = {\n ...nextState,\n updatedAt: new Date().toISOString()\n };\n this.persist(sessionId, found);\n }\n\n public addRevision(sessionId: string, message?: string): SessionRevision {\n const found = this.get(sessionId);\n const revision: SessionRevision = {\n revisionId: randomUUID(),\n at: new Date().toISOString(),\n message\n };\n found.state.revisions.push(revision);\n found.state.updatedAt = revision.at;\n this.persist(sessionId, found);\n return revision;\n }\n\n /** Replace active diagnostics for one constituent (or scratch when constituentId is undefined). */\n public replaceDiagnosticsForConstituent(\n sessionId: string,\n constituentId: number | undefined,\n records: Diagnostic[]\n ): void {\n const found = this.get(sessionId);\n found.diagnostics = found.diagnostics.filter(record => record.constituentId !== constituentId);\n found.diagnostics.push(...records);\n found.state.updatedAt = new Date().toISOString();\n this.persist(sessionId, found);\n }\n\n public setDiagnostics(sessionId: string, records: Diagnostic[]): void {\n const found = this.get(sessionId);\n found.diagnostics = [...records];\n found.state.updatedAt = new Date().toISOString();\n this.persist(sessionId, found);\n }\n\n public listDiagnostics(sessionId: string, filters?: ListDiagnosticsFilters): Diagnostic[] {\n const found = this.get(sessionId);\n let records = found.diagnostics;\n if (filters?.kind !== undefined) {\n records = records.filter(record => record.kind === filters.kind);\n }\n if (filters?.severity !== undefined) {\n records = records.filter(record => record.severity === filters.severity);\n }\n if (filters?.constituentId === undefined) {\n return [...records];\n }\n return records.filter(record => record.constituentId === filters.constituentId);\n }\n\n public snapshot(sessionId: string): SessionEnvelope {\n const found = this.get(sessionId);\n return structuredClone(found);\n }\n\n public restore(sessionId: string, snapshot: SessionEnvelope): void {\n this.sessions.set(sessionId, structuredClone(snapshot));\n this.persist(sessionId, this.sessions.get(sessionId)!);\n }\n\n public saveCurrentSessionId(sessionId: string | null): void {\n this.persistence?.saveCurrentSessionId(sessionId);\n }\n\n public loadCurrentSessionId(): string | null {\n return this.persistence?.loadCurrentSessionId() ?? null;\n }\n\n private loadFromDisk(sessionId: string): SessionEnvelope | null {\n const loaded = this.persistence?.load(sessionId);\n if (!loaded) {\n return null;\n }\n this.sessions.set(sessionId, loaded);\n return loaded;\n }\n\n private persist(sessionId: string, envelope: SessionEnvelope): void {\n this.persistence?.save(sessionId, envelope as PersistedSessionEnvelope);\n }\n}\n","import { type ImportDataKind } from './import-export';\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nexport function parseImportPayload(payload: string | object): unknown {\n if (typeof payload === 'string') {\n return JSON.parse(payload) as unknown;\n }\n return payload;\n}\n\nexport function detectImportKind(data: unknown): Exclude<ImportDataKind, 'auto'> {\n if (!isRecord(data)) {\n throw new Error('Invalid import payload');\n }\n\n if ('contractVersion' in data && 'state' in data) {\n return 'session';\n }\n\n if ('contract_version' in data && Array.isArray(data.items)) {\n const items = data.items as unknown[];\n if (items.length > 0) {\n const first = items[0];\n if (isRecord(first) && 'cst_type' in first) {\n return 'portal-schema';\n }\n throw new Error('Portal model JSON cannot be imported as a schema session');\n }\n }\n\n if (Array.isArray(data.items) && data.items.length > 0) {\n const first = data.items[0];\n if (isRecord(first) && 'cst_type' in first) {\n return 'portal-details';\n }\n }\n\n throw new Error('Cannot detect import kind; pass kind explicitly');\n}\n","import { restoreConstituentOrder } from '@rsconcept/domain/library/rsform-api';\nimport {\n portalDetailsToDrafts,\n portalDetailsToSessionSeed,\n portalSchemaToDrafts,\n portalSchemaToSessionSeed\n} from '../mappers/portal-adapter';\nimport { collectModelDiagnostics, collectSchemaDiagnostics } from '../mappers/diagnostics-collector';\nimport { ModelAdapter } from '../mappers/model-adapter';\nimport { SchemaAdapter } from '../mappers/schema-adapter';\nimport { orderDrafts, reorderSessionItemsByDrafts } from '../session/batch-apply';\nimport { SessionStore } from '../session/session-store';\nimport {\n type AgentConstituentaPatch,\n type ApplySchemaPatchInput,\n type ApplySchemaPatchResult,\n type RestoreOrderResult,\n type SessionStateDetail,\n type SessionStateResult,\n type SessionSummary\n} from './agent-workflow';\nimport { type AnalysisResult, type AnalyzeExpressionInput } from './analysis';\nimport { CstType } from './common';\nimport {\n type AddOrUpdateConstituentaInput,\n type AddOrUpdateConstituentaResult,\n type ApplyConstituentsInput,\n type ApplyConstituentsResult,\n type ConstituentaDraft,\n type ConstituentaState\n} from './constituenta';\nimport { type Diagnostic, type ListDiagnosticsFilters } from './diagnostic';\nimport { type EvaluateInput, type EvaluationResult } from './evaluation';\nimport { detectImportKind, parseImportPayload } from './import-detect';\nimport { type ExportPortalInput, type ExportPortalResult, type ImportDataKind } from './import-export';\nimport { type RecalculateModelResult, type SessionModelState, type SetModelValuesInput } from './model-value';\nimport {\n PORTAL_JSON_CONTRACT_VERSION,\n type PortalModelImportData,\n type PortalRsformDetails,\n type PortalSchemaImportData\n} from './portal-json';\nimport { type SessionHandle, type SessionRevision, type SessionState } from './session';\nimport { CONTRACT_VERSION, type RSToolAgentContract, type RSToolAgentOptions } from './tool-contract';\n\nfunction normalizeImportedState(state: SessionState): SessionState {\n return {\n ...state,\n alias: state.alias ?? '',\n title: state.title ?? '',\n comment: state.comment ?? '',\n model: state.model ?? { items: [] }\n };\n}\n\nfunction portalImportMetadata(\n session: SessionState,\n kind: 'schema' | 'model'\n): Pick<PortalSchemaImportData, 'title' | 'alias' | 'description'> {\n const defaults =\n kind === 'schema' ? { title: 'Conceptual schema', alias: 'SCHEMA' } : { title: 'Conceptual model', alias: 'MODEL' };\n const title = session.title.trim();\n const alias = session.alias.trim();\n return {\n title: title.length > 0 ? title : defaults.title,\n alias: alias.length > 0 ? alias : defaults.alias,\n description: session.comment.trim()\n };\n}\n\nfunction inferCstType(alias: string): CstType {\n const prefix = alias.trim().charAt(0).toUpperCase();\n switch (prefix) {\n case 'X':\n return CstType.BASE;\n case 'C':\n return CstType.CONSTANT;\n case 'S':\n return CstType.STRUCTURED;\n case 'D':\n return CstType.TERM;\n case 'A':\n return CstType.AXIOM;\n case 'F':\n return CstType.FUNCTION;\n case 'P':\n return CstType.PREDICATE;\n case 'N':\n return CstType.NOMINAL;\n case 'T':\n return CstType.STATEMENT;\n default:\n throw new Error(`Cannot infer cstType from alias \"${alias}\"; pass cstType explicitly`);\n }\n}\n\n/**\n * Agent-facing entry point for incremental RSForm editing, analysis, diagnostics,\n * modeling, and evaluation.\n *\n * Holds in-memory (optionally persisted) sessions and delegates language work\n * to internal schema and model adapters.\n */\nexport class RSToolAgent implements RSToolAgentContract {\n public readonly contractVersion = CONTRACT_VERSION;\n private readonly sessions: SessionStore;\n private readonly adapter = new SchemaAdapter();\n private readonly evaluation = new ModelAdapter();\n private currentSessionId: string | null;\n\n /** @param options - Optional persistence directory for session storage. */\n public constructor(options: RSToolAgentOptions = {}) {\n this.sessions = new SessionStore({ persistenceDir: options.persistenceDir });\n this.currentSessionId = this.sessions.loadCurrentSessionId();\n }\n\n /** @inheritdoc */\n public ensureSession(initial?: Partial<SessionState>): SessionHandle {\n const current = this.getCurrentSession();\n return current ?? this.createSession(initial);\n }\n\n /** @inheritdoc */\n public createSession(initial?: Partial<SessionState>): SessionHandle {\n return this.trackSession(this.sessions.create(initial, this.contractVersion));\n }\n\n /** @inheritdoc */\n public getCurrentSession(): SessionHandle | null {\n if (!this.currentSessionId) {\n return null;\n }\n if (!this.sessions.has(this.currentSessionId)) {\n this.currentSessionId = null;\n this.sessions.saveCurrentSessionId(null);\n return null;\n }\n return { sessionId: this.currentSessionId, contractVersion: this.contractVersion };\n }\n\n /** @inheritdoc */\n public setCurrentSession(sessionId: string): SessionHandle {\n if (!this.sessions.has(sessionId)) {\n throw new Error(`Unknown session: ${sessionId}`);\n }\n return this.trackSession({ sessionId, contractVersion: this.contractVersion });\n }\n\n /** @inheritdoc */\n public applySchemaPatch(input: ApplySchemaPatchInput, sessionId?: string): ApplySchemaPatchResult {\n const session = sessionId\n ? { sessionId: this.resolveSessionId(sessionId), contractVersion: this.contractVersion }\n : this.ensureSession(input.initial);\n const drafts = this.resolveAgentPatches(session.sessionId, input.items);\n const result = this.applyConstituents(\n {\n drafts,\n mode: input.mode\n },\n session.sessionId\n );\n const revision =\n result.success && input.commitMessage ? this.commitStep(input.commitMessage, session.sessionId) : undefined;\n return {\n ...result,\n session,\n summary: this.buildSessionSummary(session.sessionId),\n revision\n };\n }\n\n /** @inheritdoc */\n public getSessionState(detail: SessionStateDetail = 'summary', sessionId?: string): SessionStateResult {\n if (detail === 'full') {\n const envelope = this.sessions.get(this.resolveSessionId(sessionId));\n return structuredClone(envelope.state);\n }\n return this.buildSessionSummary(sessionId);\n }\n\n /** @inheritdoc */\n public listDiagnostics(filters?: ListDiagnosticsFilters, sessionId?: string) {\n return this.sessions.listDiagnostics(this.resolveSessionId(sessionId), filters);\n }\n\n /** @inheritdoc */\n public analyzeExpression(input: AnalyzeExpressionInput, sessionId?: string): AnalysisResult {\n const id = this.resolveSessionId(sessionId);\n const envelope = this.sessions.get(id);\n const { result, diagnostics } = this.adapter.analyzeAgainstSession(envelope.state, {\n id: -1,\n alias: '_analysis',\n cstType: input.cstType,\n definitionFormal: input.expression\n });\n const sanitizedDiagnostics = diagnostics.map(item => ({ ...item, constituentId: undefined }));\n if (input.recordDiagnostics) {\n this.sessions.setDiagnostics(id, [...collectSchemaDiagnostics(envelope.state), ...sanitizedDiagnostics]);\n }\n return { ...result, diagnostics: sanitizedDiagnostics };\n }\n\n /** @inheritdoc */\n public commitStep(message?: string, sessionId?: string): SessionRevision {\n return this.sessions.addRevision(this.resolveSessionId(sessionId), message);\n }\n\n /** @inheritdoc */\n public exportSession(sessionId?: string): string {\n const envelope = this.sessions.get(this.resolveSessionId(sessionId));\n return JSON.stringify(\n {\n contractVersion: this.contractVersion,\n state: envelope.state,\n diagnostics: envelope.diagnostics\n },\n null,\n 2\n );\n }\n\n /** @inheritdoc */\n public exportPortal(input: ExportPortalInput, sessionId?: string): ExportPortalResult {\n const format = input.format ?? 'json';\n const object =\n input.kind === 'schema' ? this.buildPortalSchemaObject(sessionId) : this.buildPortalModelObject(sessionId);\n return format === 'object' ? object : JSON.stringify(object, null, 2);\n }\n\n /** @inheritdoc */\n public importData(payload: string | object, kind: ImportDataKind = 'auto'): SessionHandle {\n const parsed = parseImportPayload(payload);\n const resolvedKind = kind === 'auto' ? detectImportKind(parsed) : kind;\n\n switch (resolvedKind) {\n case 'session':\n return this.importSessionExport(parsed);\n case 'portal-schema':\n return this.importPortalSchemaData(parsed as PortalSchemaImportData);\n case 'portal-details':\n return this.importPortalDetailsData(parsed as PortalRsformDetails);\n default:\n throw new Error(`Unsupported import kind: ${resolvedKind as string}`);\n }\n }\n\n /** @inheritdoc */\n public async setModelValues(input: SetModelValuesInput, sessionId?: string): Promise<SessionModelState> {\n const id = this.resolveSessionId(sessionId);\n const snapshot = this.sessions.snapshot(id);\n\n try {\n let state = this.sessions.get(id).state;\n\n if (input.clear?.length) {\n const model = await this.evaluation.clearConstituentaValues(state, input.clear);\n state = { ...state, model };\n this.sessions.replaceState(id, state);\n }\n\n if (input.set?.length) {\n state = this.sessions.get(id).state;\n const model = await this.evaluation.setConstituentaValues(state, { items: input.set });\n state = { ...state, model };\n this.sessions.replaceState(id, state);\n this.refreshModelDiagnostics(id);\n return model;\n }\n\n this.refreshModelDiagnostics(id);\n return structuredClone(this.sessions.get(id).state.model);\n } catch (error) {\n this.sessions.restore(id, snapshot);\n throw error;\n }\n }\n\n /** @inheritdoc */\n public getModelState(sessionId?: string): SessionModelState {\n const envelope = this.sessions.get(this.resolveSessionId(sessionId));\n return structuredClone(envelope.state.model);\n }\n\n /** @inheritdoc */\n public evaluate(input: EvaluateInput, sessionId?: string): EvaluationResult {\n const envelope = this.sessions.get(this.resolveSessionId(sessionId));\n\n if (input.constituentId !== undefined) {\n return this.evaluation.evaluateConstituenta(envelope.state, input.constituentId);\n }\n\n if (input.expression !== undefined && input.cstType !== undefined) {\n return this.evaluation.evaluateExpression(envelope.state, input.expression, input.cstType);\n }\n\n throw new Error('evaluate requires constituentId or expression with cstType');\n }\n\n /** @inheritdoc */\n public recalculateModel(sessionId?: string): RecalculateModelResult {\n const id = this.resolveSessionId(sessionId);\n const envelope = this.sessions.get(id);\n const result = this.evaluation.recalculateModel(envelope.state);\n this.refreshModelDiagnostics(id);\n return result;\n }\n\n /** @inheritdoc */\n public restoreOrder(sessionId?: string): RestoreOrderResult {\n const id = this.resolveSessionId(sessionId);\n const envelope = this.sessions.get(id);\n const orderable = envelope.state.items.map(item => ({\n id: item.id,\n alias: item.alias,\n cst_type: item.cstType,\n definition_formal: item.definitionFormal\n }));\n const ordered = restoreConstituentOrder(orderable);\n const byId = new Map(envelope.state.items.map(item => [item.id, item]));\n envelope.state.items = ordered.map(item => byId.get(item.id)!);\n envelope.state.updatedAt = new Date().toISOString();\n this.sessions.replaceState(id, envelope.state);\n return {\n orderedIds: ordered.map(item => item.id),\n orderedAliases: ordered.map(item => item.alias)\n };\n }\n\n private addOrUpdateConstituenta(\n input: AddOrUpdateConstituentaInput,\n sessionId?: string\n ): AddOrUpdateConstituentaResult {\n const id = this.resolveSessionId(sessionId);\n const envelope = this.sessions.get(id);\n const { result, diagnostics } = this.adapter.analyzeAgainstSession(envelope.state, input.draft);\n const state = this.adapter.mergeStateWithDraft(envelope.state, input.draft, result);\n return { state, diagnostics };\n }\n\n private applyConstituents(input: ApplyConstituentsInput, sessionId?: string): ApplyConstituentsResult {\n const id = this.resolveSessionId(sessionId);\n const mode = input.mode ?? 'atomic';\n const ordered = orderDrafts(this.sessions.get(id).state.items, input.drafts);\n const preBatchItemIds = new Set(this.sessions.get(id).state.items.map(item => item.id));\n const snapshot = this.sessions.snapshot(id);\n const applied: ConstituentaState[] = [];\n const failed: ApplyConstituentsResult['failed'] = [];\n\n for (const draft of ordered) {\n const result = this.addOrUpdateConstituenta({ draft }, id);\n if (result.state.analysis.success) {\n applied.push(result.state);\n continue;\n }\n failed.push({ draft, diagnostics: result.diagnostics });\n if (mode === 'atomic') {\n this.sessions.restore(id, snapshot);\n return {\n success: false,\n applied: [],\n failed,\n diagnostics: this.sessions.listDiagnostics(id)\n };\n }\n }\n\n const envelope = this.sessions.get(id);\n reorderSessionItemsByDrafts(envelope.state.items, input.drafts, preBatchItemIds);\n this.sessions.replaceState(id, envelope.state);\n this.refreshDiagnostics(id);\n\n return {\n success: failed.length === 0,\n applied,\n failed,\n diagnostics: this.sessions.listDiagnostics(id)\n };\n }\n\n private buildSessionSummary(sessionId?: string): SessionSummary {\n const id = this.resolveSessionId(sessionId);\n const envelope = this.sessions.get(id);\n const diagnostics = this.sessions.listDiagnostics(id);\n return {\n sessionId: id,\n contractVersion: this.contractVersion,\n alias: envelope.state.alias,\n title: envelope.state.title,\n comment: envelope.state.comment,\n itemCount: envelope.state.items.length,\n modelItemCount: envelope.state.model.items.length,\n diagnosticsCount: diagnostics.length,\n items: envelope.state.items.map(item => ({\n id: item.id,\n alias: item.alias,\n cstType: item.cstType,\n analysisSuccess: item.analysis.success\n })),\n diagnostics,\n lastRevision: envelope.state.revisions.at(-1)\n };\n }\n\n private buildPortalSchemaObject(sessionId?: string): PortalSchemaImportData {\n const envelope = this.sessions.get(this.resolveSessionId(sessionId));\n return {\n contract_version: PORTAL_JSON_CONTRACT_VERSION,\n ...portalImportMetadata(envelope.state, 'schema'),\n items: envelope.state.items.map(item => ({\n id: item.id,\n alias: item.alias,\n convention: item.convention,\n crucial: false,\n cst_type: item.cstType,\n definition_formal: item.definitionFormal,\n typification_manual: '',\n value_is_property: false,\n definition_raw: item.definitionText,\n definition_resolved: item.definitionText,\n term_raw: item.term,\n term_resolved: item.term,\n term_forms: []\n })),\n attribution: []\n };\n }\n\n private buildPortalModelObject(sessionId?: string): PortalModelImportData {\n const envelope = this.sessions.get(this.resolveSessionId(sessionId));\n return {\n contract_version: PORTAL_JSON_CONTRACT_VERSION,\n ...portalImportMetadata(envelope.state, 'model'),\n items: envelope.state.model.items.map(item => ({\n id: item.id,\n type: item.type,\n value: item.value\n }))\n };\n }\n\n private importSessionExport(parsed: unknown): SessionHandle {\n if (!parsed || typeof parsed !== 'object' || !('state' in parsed)) {\n throw new Error('Invalid session export payload');\n }\n const data = parsed as {\n state: SessionState;\n diagnostics?: Diagnostic[];\n };\n const handle = this.sessions.create(normalizeImportedState(data.state), this.contractVersion);\n if (data.diagnostics?.length) {\n this.sessions.setDiagnostics(handle.sessionId, data.diagnostics);\n } else {\n this.refreshDiagnostics(handle.sessionId);\n }\n return this.trackSession(handle);\n }\n\n private importPortalSchemaData(data: PortalSchemaImportData): SessionHandle {\n const handle = this.createSession(portalSchemaToSessionSeed(data));\n this.applyConstituents({ drafts: portalSchemaToDrafts(data), mode: 'best_effort' }, handle.sessionId);\n return handle;\n }\n\n private importPortalDetailsData(data: PortalRsformDetails): SessionHandle {\n const handle = this.createSession(portalDetailsToSessionSeed(data));\n this.applyConstituents({ drafts: portalDetailsToDrafts(data), mode: 'best_effort' }, handle.sessionId);\n return handle;\n }\n\n private resolveAgentPatches(sessionId: string, patches: AgentConstituentaPatch[]): ConstituentaDraft[] {\n const items = this.sessions.get(sessionId).state.items;\n const existingByAlias = new Map(items.map(item => [item.alias, item]));\n const usedIds = new Set(items.map(item => item.id));\n let nextId = items.reduce((max, item) => Math.max(max, item.id), 0) + 1;\n\n const reserveId = (id: number): void => {\n usedIds.add(id);\n if (id >= nextId) {\n nextId = id + 1;\n }\n };\n\n const allocateId = (): number => {\n while (usedIds.has(nextId)) {\n nextId += 1;\n }\n const id = nextId;\n nextId += 1;\n usedIds.add(id);\n return id;\n };\n\n return patches.map(patch => {\n const existing = existingByAlias.get(patch.alias);\n let id: number;\n if (patch.id !== undefined) {\n id = patch.id;\n reserveId(id);\n } else if (existing !== undefined) {\n id = existing.id;\n } else {\n id = allocateId();\n }\n const draft = {\n id,\n alias: patch.alias,\n cstType: patch.cstType ?? existing?.cstType ?? inferCstType(patch.alias),\n definitionFormal: patch.definitionFormal ?? existing?.definitionFormal ?? '',\n term: patch.term ?? existing?.term ?? '',\n definitionText: patch.definitionText ?? existing?.definitionText ?? '',\n convention: patch.convention ?? existing?.convention ?? ''\n };\n existingByAlias.set(patch.alias, {\n ...draft,\n analysis: existing?.analysis ?? { success: true, type: null, valueClass: 'value', diagnostics: [] }\n });\n return draft;\n });\n }\n\n private resolveSessionId(sessionId?: string): string {\n const id = sessionId ?? this.currentSessionId;\n if (!id) {\n return this.createSession().sessionId;\n }\n if (!this.sessions.has(id)) {\n if (sessionId) {\n throw new Error(`Unknown session: ${sessionId}`);\n }\n return this.createSession().sessionId;\n }\n return id;\n }\n\n private trackSession(handle: SessionHandle): SessionHandle {\n this.currentSessionId = handle.sessionId;\n this.sessions.saveCurrentSessionId(handle.sessionId);\n return handle;\n }\n\n private refreshDiagnostics(sessionId: string): void {\n const envelope = this.sessions.get(sessionId);\n this.sessions.setDiagnostics(sessionId, collectSchemaDiagnostics(envelope.state));\n }\n\n private refreshModelDiagnostics(sessionId: string): void {\n const envelope = this.sessions.get(sessionId);\n this.sessions.setDiagnostics(sessionId, [\n ...collectSchemaDiagnostics(envelope.state),\n ...collectModelDiagnostics(envelope.state)\n ]);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAGA,MAAM,kBAAkB,IAAI,IAAY,OAAO,OAAO,OAAO,CAAC;AAE9D,SAAS,mBAAmB,OAAe,OAA6C;CACtF,IAAI,CAAC,gBAAgB,IAAI,KAAK,GAC5B,MAAM,IAAI,MAAM,qBAAqB,MAAM,qBAAqB,MAAM,EAAE;CAE1E,OAAO;AACT;;AAGA,MAAa,+BAA+B;;AAkE5C,SAAgB,kBAAkB,MAQZ;CACpB,OAAO;EACL,IAAI,KAAK;EACT,OAAO,KAAK;EACZ,SAAS,mBAAmB,KAAK,UAAU,KAAK,KAAK;EACrD,kBAAkB,KAAK,qBAAqB;EAC5C,MAAM,KAAK,YAAY;EACvB,gBAAgB,KAAK,kBAAkB;EACvC,YAAY,KAAK,cAAc;CACjC;AACF;;;ACtFA,SAAS,4BAA4B,MAAqD;CACxF,OAAO;EACL,OAAO,KAAK,SAAS;EACrB,OAAO,KAAK,SAAS;EACrB,SAAS,KAAK,eAAe;EAC7B,OAAO,CAAC;CACV;AACF;AAEA,SAAgB,0BAA0B,MAAqD;CAC7F,OAAO,4BAA4B,IAAI;AACzC;AAEA,SAAgB,2BAA2B,MAAkD;CAC3F,OAAO,4BAA4B,IAAI;AACzC;AAEA,SAAgB,oBACd,OASqB;CACrB,OAAO,MAAM,KAAI,SAAQ,kBAAkB,IAAI,CAAC;AAClD;AAEA,SAAgB,qBAAqB,MAAmD;CACtF,OAAO,oBAAoB,KAAK,KAAK;AACvC;AAEA,SAAgB,sBAAsB,MAAgD;CACpF,OAAO,oBAAoB,KAAK,KAAK;AACvC;;;ACnCA,MAAM,eAAe,IAAI,aAAa;;AAGtC,SAAgB,yBAAyB,SAAqC;CAC5E,MAAM,UAAwB,CAAC;CAE/B,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