@rsconcept/rstool 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/index-uhkmwruf.d.ts +46 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +2 -2
- package/dist/mappers/model-adapter.d.ts +1 -1
- package/dist/mappers/schema-adapter.d.ts +1 -1
- package/dist/models/index.d.ts +5 -4
- package/dist/models/index.js +2 -2
- package/dist/models/rstool-agent.d.ts +1 -1
- package/dist/models/rstool-agent.js +1 -92
- 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/rstool-agent-BZi5jO1y.js +158 -0
- package/dist/rstool-agent-BZi5jO1y.js.map +1 -0
- package/dist/{rstool-agent-DkeH5Qml.d.ts → rstool-agent-pRaPnZay.d.ts} +6 -4
- package/dist/session/session-store.d.ts +2 -1
- package/dist/session/session-store.js +3 -0
- package/dist/session/session-store.js.map +1 -1
- package/dist/{session-BHGCCLfQ.d.ts → session-BPgsE80c.d.ts} +12 -1
- package/dist/{tool-contract-CsGqg_0P.d.ts → tool-contract-n1ghUOrK.d.ts} +5 -3
- package/dist/wrapper/stdio-wrapper.js +13 -1
- package/dist/wrapper/stdio-wrapper.js.map +1 -1
- package/docs/CONCEPTUAL-SCHEMA.md +50 -140
- package/docs/CONSTITUENTA.md +37 -62
- package/docs/DIAGNOSTICS.md +85 -130
- package/docs/DOMAIN.md +68 -91
- package/docs/GRAMMAR-REF.md +35 -86
- package/docs/MODEL-TESTING.md +57 -0
- package/docs/PORTAL-API.md +22 -36
- package/docs/README.md +14 -13
- package/docs/SYNTAX.md +49 -104
- package/docs/TYPIFICATION.md +41 -60
- package/package.json +1 -1
- package/skills/README.md +6 -8
- package/skills/rstool-helper/EXAMPLES.md +91 -105
- package/skills/rstool-helper/GUIDE.md +67 -114
- package/skills/rstool-helper/REFERENCE.md +43 -11
- package/skills/rstool-helper/SKILL.md +5 -8
- package/src/index.ts +6 -0
- package/src/models/index.ts +8 -0
- package/src/models/portal-json.ts +45 -0
- package/src/models/rstool-agent.test.ts +98 -0
- package/src/models/rstool-agent.ts +72 -4
- package/src/models/session.ts +11 -0
- package/src/models/tool-contract.ts +3 -1
- package/src/session/session-store.ts +3 -0
- package/src/wrapper/stdio-wrapper.ts +14 -0
- package/dist/models/rstool-agent.js.map +0 -1
package/README.md
CHANGED
|
@@ -85,6 +85,8 @@ Supported methods (current contract version: see [`CONTRACT_VERSION`](src/models
|
|
|
85
85
|
- `listDiagnostics`
|
|
86
86
|
- `commitStep`
|
|
87
87
|
- `exportSession`
|
|
88
|
+
- `exportPortalSchema`
|
|
89
|
+
- `exportPortalModel`
|
|
88
90
|
- `importSession`
|
|
89
91
|
- `setConstituentaValue`
|
|
90
92
|
- `setConstituentaValues`
|
|
@@ -103,7 +105,7 @@ Example request:
|
|
|
103
105
|
Example response:
|
|
104
106
|
|
|
105
107
|
```json
|
|
106
|
-
{ "id": "1", "ok": true, "result": { "sessionId": "...", "contractVersion": "1.
|
|
108
|
+
{ "id": "1", "ok": true, "result": { "sessionId": "...", "contractVersion": "1.4.0" } }
|
|
107
109
|
```
|
|
108
110
|
|
|
109
111
|
## Typed client example
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { o as RSToolValue, t as BasicBinding } from "./common-DxLg3eXX.js";
|
|
2
|
+
//#region src/models/portal-json.d.ts
|
|
3
|
+
/** Portal JSON import/export format version (schema and model files). */
|
|
4
|
+
declare const PORTAL_JSON_CONTRACT_VERSION = "1.0.0";
|
|
5
|
+
interface PortalImportMetadata {
|
|
6
|
+
contract_version: string;
|
|
7
|
+
title: string;
|
|
8
|
+
alias: string;
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
interface PortalTermForm {
|
|
12
|
+
text: string;
|
|
13
|
+
tags: string;
|
|
14
|
+
}
|
|
15
|
+
interface PortalSchemaConstituenta {
|
|
16
|
+
id: number;
|
|
17
|
+
alias: string;
|
|
18
|
+
convention: string;
|
|
19
|
+
crucial: boolean;
|
|
20
|
+
cst_type: string;
|
|
21
|
+
definition_formal: string;
|
|
22
|
+
typification_manual: string;
|
|
23
|
+
value_is_property: boolean;
|
|
24
|
+
definition_raw: string;
|
|
25
|
+
definition_resolved: string;
|
|
26
|
+
term_raw: string;
|
|
27
|
+
term_resolved: string;
|
|
28
|
+
term_forms: PortalTermForm[];
|
|
29
|
+
}
|
|
30
|
+
interface PortalSchemaImportData extends PortalImportMetadata {
|
|
31
|
+
items: PortalSchemaConstituenta[];
|
|
32
|
+
attribution: Array<{
|
|
33
|
+
container: number;
|
|
34
|
+
attribute: number;
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
interface PortalModelImportData extends PortalImportMetadata {
|
|
38
|
+
items: Array<{
|
|
39
|
+
id: number;
|
|
40
|
+
type: string;
|
|
41
|
+
value: RSToolValue | BasicBinding;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { PortalSchemaImportData as a, PortalSchemaConstituenta as i, PortalImportMetadata as n, PortalTermForm as o, PortalModelImportData as r, PORTAL_JSON_CONTRACT_VERSION as t };
|
|
46
|
+
//# sourceMappingURL=index-uhkmwruf.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -4,9 +4,10 @@ import { n as ListDiagnosticsFilters, t as DiagnosticRecord } from "./diagnostic
|
|
|
4
4
|
import { i as ConstituentaState, n as AddOrUpdateConstituentaResult, r as ConstituentaDraft, t as AddOrUpdateConstituentaInput } from "./constituenta-Dnd6iToB.js";
|
|
5
5
|
import { n as EvaluateExpressionInput, r as EvaluationResult, t as EvaluateConstituentaInput } from "./evaluation-CCVYH0wA.js";
|
|
6
6
|
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, o as SetConstituentaValuesInput, r as RecalculateModelResult, t as ClearConstituentaValuesInput } from "./model-value-SFAVj0dw.js";
|
|
7
|
-
import { n as
|
|
8
|
-
import { n as
|
|
9
|
-
import { t as
|
|
7
|
+
import { a as PortalSchemaImportData, i as PortalSchemaConstituenta, n as PortalImportMetadata, o as PortalTermForm, r as PortalModelImportData, t as PORTAL_JSON_CONTRACT_VERSION } from "./index-uhkmwruf.js";
|
|
8
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-BPgsE80c.js";
|
|
9
|
+
import { n as RSToolAgentContract, t as CONTRACT_VERSION } from "./tool-contract-n1ghUOrK.js";
|
|
10
|
+
import { t as RSToolAgent } from "./rstool-agent-pRaPnZay.js";
|
|
10
11
|
import { DomainAnalysisLike, DomainErrorLike, toPublicAnalysis, toPublicError } from "./mappers/types.js";
|
|
11
12
|
import { RSToolWrapperClient, RSToolWrapperClientOptions, WrapperResponse } from "./wrapper/client.js";
|
|
12
|
-
export { type AddOrUpdateConstituentaInput, type AddOrUpdateConstituentaResult, type AnalysisResult, type AnalyzeExpressionInput, type BasicBinding, CONTRACT_VERSION, type ClearConstituentaValuesInput, type ConstituentaDraft, type ConstituentaState, CstType, type DiagnosticRecord, type DomainAnalysisLike, type DomainErrorLike, EvalStatus, type EvaluateConstituentaInput, type EvaluateExpressionInput, type EvaluationResult, type ListDiagnosticsFilters, type ModelValueState, RSErrorCode, RSToolAgent, type RSToolAgentContract, type RSToolErrorDescription, type RSToolValue, RSToolWrapperClient, type RSToolWrapperClientOptions, type RecalculateModelResult, type SessionHandle, type SessionModelState, type SessionRevision, type SessionState, type SetConstituentaValueInput, type SetConstituentaValuesInput, ValueClass, type WrapperResponse, toPublicAnalysis, toPublicError };
|
|
13
|
+
export { type AddOrUpdateConstituentaInput, type AddOrUpdateConstituentaResult, type AnalysisResult, type AnalyzeExpressionInput, type BasicBinding, CONTRACT_VERSION, type ClearConstituentaValuesInput, type ConstituentaDraft, type ConstituentaState, CstType, type DiagnosticRecord, type DomainAnalysisLike, type DomainErrorLike, EvalStatus, type EvaluateConstituentaInput, type EvaluateExpressionInput, type EvaluationResult, type ListDiagnosticsFilters, type ModelValueState, PORTAL_JSON_CONTRACT_VERSION, type PortalImportMetadata, type PortalModelImportData, type PortalSchemaConstituenta, type PortalSchemaImportData, type PortalTermForm, RSErrorCode, RSToolAgent, type RSToolAgentContract, type RSToolErrorDescription, type RSToolValue, RSToolWrapperClient, type RSToolWrapperClientOptions, type RecalculateModelResult, type SessionHandle, type SessionModelState, type SessionRevision, type SessionState, type SetConstituentaValueInput, type SetConstituentaValuesInput, ValueClass, type WrapperResponse, toPublicAnalysis, toPublicError };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toPublicAnalysis, toPublicError } from "./mappers/types.js";
|
|
2
2
|
import { CstType, EvalStatus, RSErrorCode, ValueClass } from "./models/common.js";
|
|
3
|
+
import { n as PORTAL_JSON_CONTRACT_VERSION, t as RSToolAgent } from "./rstool-agent-BZi5jO1y.js";
|
|
3
4
|
import { CONTRACT_VERSION } from "./models/tool-contract.js";
|
|
4
|
-
import { RSToolAgent } from "./models/rstool-agent.js";
|
|
5
5
|
import "./models/index.js";
|
|
6
6
|
import { RSToolWrapperClient } from "./wrapper/client.js";
|
|
7
|
-
export { CONTRACT_VERSION, CstType, EvalStatus, RSErrorCode, RSToolAgent, RSToolWrapperClient, ValueClass, toPublicAnalysis, toPublicError };
|
|
7
|
+
export { CONTRACT_VERSION, CstType, EvalStatus, PORTAL_JSON_CONTRACT_VERSION, RSErrorCode, RSToolAgent, RSToolWrapperClient, ValueClass, toPublicAnalysis, toPublicError };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as EvaluationResult } from "../evaluation-CCVYH0wA.js";
|
|
2
2
|
import { a as SetConstituentaValueInput, i as SessionModelState, r as RecalculateModelResult } from "../model-value-SFAVj0dw.js";
|
|
3
|
-
import { r as SessionState } from "../session-
|
|
3
|
+
import { r as SessionState } from "../session-BPgsE80c.js";
|
|
4
4
|
import { CstType } from "@rsconcept/domain/library/rsform";
|
|
5
5
|
import { RSEngine } from "@rsconcept/domain/library/rsengine";
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as AnalysisResult } from "../analysis-JiwOYDKx.js";
|
|
2
2
|
import { t as DiagnosticRecord } from "../diagnostic-BMYvciz8.js";
|
|
3
3
|
import { i as ConstituentaState, r as ConstituentaDraft } from "../constituenta-Dnd6iToB.js";
|
|
4
|
-
import { r as SessionState } from "../session-
|
|
4
|
+
import { r as SessionState } from "../session-BPgsE80c.js";
|
|
5
5
|
import { RSForm } from "@rsconcept/domain/library/rsform";
|
|
6
6
|
import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
|
|
7
7
|
|
package/dist/models/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { n as ListDiagnosticsFilters, t as DiagnosticRecord } from "../diagnosti
|
|
|
4
4
|
import { i as ConstituentaState, n as AddOrUpdateConstituentaResult, r as ConstituentaDraft, t as AddOrUpdateConstituentaInput } from "../constituenta-Dnd6iToB.js";
|
|
5
5
|
import { n as EvaluateExpressionInput, r as EvaluationResult, t as EvaluateConstituentaInput } from "../evaluation-CCVYH0wA.js";
|
|
6
6
|
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, o as SetConstituentaValuesInput, r as RecalculateModelResult, t as ClearConstituentaValuesInput } from "../model-value-SFAVj0dw.js";
|
|
7
|
-
import { n as
|
|
8
|
-
import { n as
|
|
9
|
-
import { t as
|
|
10
|
-
|
|
7
|
+
import { a as PortalSchemaImportData, i as PortalSchemaConstituenta, n as PortalImportMetadata, o as PortalTermForm, r as PortalModelImportData, t as PORTAL_JSON_CONTRACT_VERSION } from "../index-uhkmwruf.js";
|
|
8
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "../session-BPgsE80c.js";
|
|
9
|
+
import { n as RSToolAgentContract, t as CONTRACT_VERSION } from "../tool-contract-n1ghUOrK.js";
|
|
10
|
+
import { t as RSToolAgent } from "../rstool-agent-pRaPnZay.js";
|
|
11
|
+
export { type AddOrUpdateConstituentaInput, type AddOrUpdateConstituentaResult, type AnalysisResult, type AnalyzeExpressionInput, type BasicBinding, CONTRACT_VERSION, type ClearConstituentaValuesInput, type ConstituentaDraft, type ConstituentaState, CstType, type DiagnosticRecord, EvalStatus, type EvaluateConstituentaInput, type EvaluateExpressionInput, type EvaluationResult, type ListDiagnosticsFilters, type ModelValueState, PORTAL_JSON_CONTRACT_VERSION, type PortalImportMetadata, type PortalModelImportData, type PortalSchemaConstituenta, type PortalSchemaImportData, type PortalTermForm, RSErrorCode, RSToolAgent, type RSToolAgentContract, type RSToolErrorDescription, type RSToolValue, type RecalculateModelResult, type SessionHandle, type SessionModelState, type SessionRevision, type SessionState, type SetConstituentaValueInput, type SetConstituentaValuesInput, ValueClass };
|
package/dist/models/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CstType, EvalStatus, RSErrorCode, ValueClass } from "./common.js";
|
|
2
|
+
import { n as PORTAL_JSON_CONTRACT_VERSION, t as RSToolAgent } from "../rstool-agent-BZi5jO1y.js";
|
|
2
3
|
import { CONTRACT_VERSION } from "./tool-contract.js";
|
|
3
|
-
|
|
4
|
-
export { CONTRACT_VERSION, CstType, EvalStatus, RSErrorCode, RSToolAgent, ValueClass };
|
|
4
|
+
export { CONTRACT_VERSION, CstType, EvalStatus, PORTAL_JSON_CONTRACT_VERSION, RSErrorCode, RSToolAgent, ValueClass };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as RSToolAgent } from "../rstool-agent-
|
|
1
|
+
import { t as RSToolAgent } from "../rstool-agent-pRaPnZay.js";
|
|
2
2
|
export { RSToolAgent };
|
|
@@ -1,93 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SchemaAdapter } from "../mappers/schema-adapter.js";
|
|
3
|
-
import { SessionStore } from "../session/session-store.js";
|
|
4
|
-
import { CONTRACT_VERSION } from "./tool-contract.js";
|
|
5
|
-
//#region src/models/rstool-agent.ts
|
|
6
|
-
var RSToolAgent = class {
|
|
7
|
-
contractVersion = CONTRACT_VERSION;
|
|
8
|
-
sessions = new SessionStore();
|
|
9
|
-
adapter = new SchemaAdapter();
|
|
10
|
-
evaluation = new ModelAdapter();
|
|
11
|
-
createSession(initial) {
|
|
12
|
-
return this.sessions.create(initial, this.contractVersion);
|
|
13
|
-
}
|
|
14
|
-
addOrUpdateConstituenta(sessionId, input) {
|
|
15
|
-
const envelope = this.sessions.get(sessionId);
|
|
16
|
-
const { result, diagnostics } = this.adapter.analyzeAgainstSession(envelope.state, input.draft);
|
|
17
|
-
const state = this.adapter.mergeStateWithDraft(envelope.state, input.draft, result);
|
|
18
|
-
this.sessions.appendDiagnostics(sessionId, diagnostics);
|
|
19
|
-
return {
|
|
20
|
-
state,
|
|
21
|
-
diagnostics
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
analyzeExpression(sessionId, input) {
|
|
25
|
-
const envelope = this.sessions.get(sessionId);
|
|
26
|
-
const { result, diagnostics } = this.adapter.analyzeAgainstSession(envelope.state, {
|
|
27
|
-
id: -1,
|
|
28
|
-
alias: "_analysis",
|
|
29
|
-
cstType: input.cstType,
|
|
30
|
-
definitionFormal: input.expression
|
|
31
|
-
});
|
|
32
|
-
this.sessions.appendDiagnostics(sessionId, diagnostics.map((item) => ({
|
|
33
|
-
...item,
|
|
34
|
-
constituentId: void 0
|
|
35
|
-
})));
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
getFormState(sessionId) {
|
|
39
|
-
const envelope = this.sessions.get(sessionId);
|
|
40
|
-
return structuredClone(envelope.state);
|
|
41
|
-
}
|
|
42
|
-
listDiagnostics(sessionId, filters) {
|
|
43
|
-
return this.sessions.listDiagnostics(sessionId, filters);
|
|
44
|
-
}
|
|
45
|
-
commitStep(sessionId, message) {
|
|
46
|
-
return this.sessions.addRevision(sessionId, message);
|
|
47
|
-
}
|
|
48
|
-
exportSession(sessionId) {
|
|
49
|
-
const envelope = this.sessions.get(sessionId);
|
|
50
|
-
return JSON.stringify({
|
|
51
|
-
contractVersion: this.contractVersion,
|
|
52
|
-
state: envelope.state,
|
|
53
|
-
diagnostics: envelope.diagnostics
|
|
54
|
-
}, null, 2);
|
|
55
|
-
}
|
|
56
|
-
importSession(payload) {
|
|
57
|
-
const parsed = JSON.parse(payload);
|
|
58
|
-
if (!parsed.state.model) parsed.state.model = { items: [] };
|
|
59
|
-
return this.sessions.create(parsed.state, this.contractVersion);
|
|
60
|
-
}
|
|
61
|
-
async setConstituentaValue(sessionId, input) {
|
|
62
|
-
const envelope = this.sessions.get(sessionId);
|
|
63
|
-
return this.evaluation.setConstituentaValue(envelope.state, input);
|
|
64
|
-
}
|
|
65
|
-
async setConstituentaValues(sessionId, input) {
|
|
66
|
-
const envelope = this.sessions.get(sessionId);
|
|
67
|
-
return this.evaluation.setConstituentaValues(envelope.state, input);
|
|
68
|
-
}
|
|
69
|
-
async clearConstituentaValues(sessionId, input) {
|
|
70
|
-
const envelope = this.sessions.get(sessionId);
|
|
71
|
-
return this.evaluation.clearConstituentaValues(envelope.state, input.items);
|
|
72
|
-
}
|
|
73
|
-
getModelState(sessionId) {
|
|
74
|
-
const envelope = this.sessions.get(sessionId);
|
|
75
|
-
return structuredClone(envelope.state.model);
|
|
76
|
-
}
|
|
77
|
-
evaluateExpression(sessionId, input) {
|
|
78
|
-
const envelope = this.sessions.get(sessionId);
|
|
79
|
-
return this.evaluation.evaluateExpression(envelope.state, input.expression, input.cstType);
|
|
80
|
-
}
|
|
81
|
-
evaluateConstituenta(sessionId, input) {
|
|
82
|
-
const envelope = this.sessions.get(sessionId);
|
|
83
|
-
return this.evaluation.evaluateConstituenta(envelope.state, input.constituentId);
|
|
84
|
-
}
|
|
85
|
-
recalculateModel(sessionId) {
|
|
86
|
-
const envelope = this.sessions.get(sessionId);
|
|
87
|
-
return this.evaluation.recalculateModel(envelope.state);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
//#endregion
|
|
1
|
+
import { t as RSToolAgent } from "../rstool-agent-BZi5jO1y.js";
|
|
91
2
|
export { RSToolAgent };
|
|
92
|
-
|
|
93
|
-
//# sourceMappingURL=rstool-agent.js.map
|
package/dist/models/session.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "../session-
|
|
1
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "../session-BPgsE80c.js";
|
|
2
2
|
export { SessionHandle, SessionRevision, SessionState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RSToolAgentContract, t as CONTRACT_VERSION } from "../tool-contract-
|
|
1
|
+
import { n as RSToolAgentContract, t as CONTRACT_VERSION } from "../tool-contract-n1ghUOrK.js";
|
|
2
2
|
export { CONTRACT_VERSION, RSToolAgentContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-contract.js","names":[],"sources":["../../src/models/tool-contract.ts"],"sourcesContent":["import { type AnalysisResult, type AnalyzeExpressionInput } from './analysis';\nimport {\n type AddOrUpdateConstituentaInput,\n type AddOrUpdateConstituentaResult\n} from './constituenta';\nimport {\n type DiagnosticRecord,\n type ListDiagnosticsFilters\n} from './diagnostic';\nimport {\n type EvaluateConstituentaInput,\n type EvaluateExpressionInput,\n type EvaluationResult\n} from './evaluation';\nimport {\n type ClearConstituentaValuesInput,\n type RecalculateModelResult,\n type SessionModelState,\n type SetConstituentaValueInput,\n type SetConstituentaValuesInput\n} from './model-value';\nimport {\n type SessionHandle,\n type SessionRevision,\n type SessionState\n} from './session';\n\nexport const CONTRACT_VERSION = '1.
|
|
1
|
+
{"version":3,"file":"tool-contract.js","names":[],"sources":["../../src/models/tool-contract.ts"],"sourcesContent":["import { type AnalysisResult, type AnalyzeExpressionInput } from './analysis';\nimport {\n type AddOrUpdateConstituentaInput,\n type AddOrUpdateConstituentaResult\n} from './constituenta';\nimport {\n type DiagnosticRecord,\n type ListDiagnosticsFilters\n} from './diagnostic';\nimport {\n type EvaluateConstituentaInput,\n type EvaluateExpressionInput,\n type EvaluationResult\n} from './evaluation';\nimport {\n type ClearConstituentaValuesInput,\n type RecalculateModelResult,\n type SessionModelState,\n type SetConstituentaValueInput,\n type SetConstituentaValuesInput\n} from './model-value';\nimport {\n type SessionHandle,\n type SessionRevision,\n type SessionState\n} from './session';\n\nexport const CONTRACT_VERSION = '1.4.0';\n\nexport interface RSToolAgentContract {\n readonly contractVersion: string;\n createSession(initial?: Partial<SessionState>): SessionHandle;\n addOrUpdateConstituenta(sessionId: string, input: AddOrUpdateConstituentaInput): AddOrUpdateConstituentaResult;\n analyzeExpression(sessionId: string, input: AnalyzeExpressionInput): AnalysisResult;\n getFormState(sessionId: string): SessionState;\n listDiagnostics(sessionId: string, filters?: ListDiagnosticsFilters): DiagnosticRecord[];\n commitStep(sessionId: string, message?: string): SessionRevision;\n exportSession(sessionId: string): string;\n exportPortalSchema(sessionId: string): string;\n exportPortalModel(sessionId: string): string;\n importSession(payload: string): SessionHandle;\n setConstituentaValue(sessionId: string, input: SetConstituentaValueInput): Promise<SessionModelState>;\n setConstituentaValues(sessionId: string, input: SetConstituentaValuesInput): Promise<SessionModelState>;\n clearConstituentaValues(sessionId: string, input: ClearConstituentaValuesInput): Promise<SessionModelState>;\n getModelState(sessionId: string): SessionModelState;\n evaluateExpression(sessionId: string, input: EvaluateExpressionInput): EvaluationResult;\n evaluateConstituenta(sessionId: string, input: EvaluateConstituentaInput): EvaluationResult;\n recalculateModel(sessionId: string): RecalculateModelResult;\n}\n"],"mappings":";AA2BA,MAAa,mBAAmB"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { ModelAdapter } from "./mappers/model-adapter.js";
|
|
2
|
+
import { SchemaAdapter } from "./mappers/schema-adapter.js";
|
|
3
|
+
import { SessionStore } from "./session/session-store.js";
|
|
4
|
+
import { CONTRACT_VERSION } from "./models/tool-contract.js";
|
|
5
|
+
//#region src/models/portal-json.ts
|
|
6
|
+
/** Portal JSON import/export format version (schema and model files). */
|
|
7
|
+
const PORTAL_JSON_CONTRACT_VERSION = "1.0.0";
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/models/rstool-agent.ts
|
|
10
|
+
function normalizeImportedState(state) {
|
|
11
|
+
return {
|
|
12
|
+
...state,
|
|
13
|
+
alias: state.alias ?? "",
|
|
14
|
+
title: state.title ?? "",
|
|
15
|
+
comment: state.comment ?? "",
|
|
16
|
+
model: state.model ?? { items: [] }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function portalImportMetadata(session, kind) {
|
|
20
|
+
const defaults = kind === "schema" ? {
|
|
21
|
+
title: "Conceptual schema",
|
|
22
|
+
alias: "SCHEMA"
|
|
23
|
+
} : {
|
|
24
|
+
title: "Conceptual model",
|
|
25
|
+
alias: "MODEL"
|
|
26
|
+
};
|
|
27
|
+
const title = session.title.trim();
|
|
28
|
+
const alias = session.alias.trim();
|
|
29
|
+
return {
|
|
30
|
+
title: title.length > 0 ? title : defaults.title,
|
|
31
|
+
alias: alias.length > 0 ? alias : defaults.alias,
|
|
32
|
+
description: session.comment.trim()
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var RSToolAgent = class {
|
|
36
|
+
contractVersion = CONTRACT_VERSION;
|
|
37
|
+
sessions = new SessionStore();
|
|
38
|
+
adapter = new SchemaAdapter();
|
|
39
|
+
evaluation = new ModelAdapter();
|
|
40
|
+
createSession(initial) {
|
|
41
|
+
return this.sessions.create(initial, this.contractVersion);
|
|
42
|
+
}
|
|
43
|
+
addOrUpdateConstituenta(sessionId, input) {
|
|
44
|
+
const envelope = this.sessions.get(sessionId);
|
|
45
|
+
const { result, diagnostics } = this.adapter.analyzeAgainstSession(envelope.state, input.draft);
|
|
46
|
+
const state = this.adapter.mergeStateWithDraft(envelope.state, input.draft, result);
|
|
47
|
+
this.sessions.appendDiagnostics(sessionId, diagnostics);
|
|
48
|
+
return {
|
|
49
|
+
state,
|
|
50
|
+
diagnostics
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
analyzeExpression(sessionId, input) {
|
|
54
|
+
const envelope = this.sessions.get(sessionId);
|
|
55
|
+
const { result, diagnostics } = this.adapter.analyzeAgainstSession(envelope.state, {
|
|
56
|
+
id: -1,
|
|
57
|
+
alias: "_analysis",
|
|
58
|
+
cstType: input.cstType,
|
|
59
|
+
definitionFormal: input.expression
|
|
60
|
+
});
|
|
61
|
+
this.sessions.appendDiagnostics(sessionId, diagnostics.map((item) => ({
|
|
62
|
+
...item,
|
|
63
|
+
constituentId: void 0
|
|
64
|
+
})));
|
|
65
|
+
return result;
|
|
66
|
+
}
|
|
67
|
+
getFormState(sessionId) {
|
|
68
|
+
const envelope = this.sessions.get(sessionId);
|
|
69
|
+
return structuredClone(envelope.state);
|
|
70
|
+
}
|
|
71
|
+
listDiagnostics(sessionId, filters) {
|
|
72
|
+
return this.sessions.listDiagnostics(sessionId, filters);
|
|
73
|
+
}
|
|
74
|
+
commitStep(sessionId, message) {
|
|
75
|
+
return this.sessions.addRevision(sessionId, message);
|
|
76
|
+
}
|
|
77
|
+
exportSession(sessionId) {
|
|
78
|
+
const envelope = this.sessions.get(sessionId);
|
|
79
|
+
return JSON.stringify({
|
|
80
|
+
contractVersion: this.contractVersion,
|
|
81
|
+
state: envelope.state,
|
|
82
|
+
diagnostics: envelope.diagnostics
|
|
83
|
+
}, null, 2);
|
|
84
|
+
}
|
|
85
|
+
exportPortalSchema(sessionId) {
|
|
86
|
+
const envelope = this.sessions.get(sessionId);
|
|
87
|
+
const payload = {
|
|
88
|
+
contract_version: PORTAL_JSON_CONTRACT_VERSION,
|
|
89
|
+
...portalImportMetadata(envelope.state, "schema"),
|
|
90
|
+
items: envelope.state.items.map((item) => ({
|
|
91
|
+
id: item.id,
|
|
92
|
+
alias: item.alias,
|
|
93
|
+
convention: item.convention,
|
|
94
|
+
crucial: false,
|
|
95
|
+
cst_type: item.cstType,
|
|
96
|
+
definition_formal: item.definitionFormal,
|
|
97
|
+
typification_manual: "",
|
|
98
|
+
value_is_property: false,
|
|
99
|
+
definition_raw: item.definitionText,
|
|
100
|
+
definition_resolved: item.definitionText,
|
|
101
|
+
term_raw: item.term,
|
|
102
|
+
term_resolved: item.term,
|
|
103
|
+
term_forms: []
|
|
104
|
+
})),
|
|
105
|
+
attribution: []
|
|
106
|
+
};
|
|
107
|
+
return JSON.stringify(payload, null, 2);
|
|
108
|
+
}
|
|
109
|
+
exportPortalModel(sessionId) {
|
|
110
|
+
const envelope = this.sessions.get(sessionId);
|
|
111
|
+
const payload = {
|
|
112
|
+
contract_version: PORTAL_JSON_CONTRACT_VERSION,
|
|
113
|
+
...portalImportMetadata(envelope.state, "model"),
|
|
114
|
+
items: envelope.state.model.items.map((item) => ({
|
|
115
|
+
id: item.id,
|
|
116
|
+
type: item.type,
|
|
117
|
+
value: item.value
|
|
118
|
+
}))
|
|
119
|
+
};
|
|
120
|
+
return JSON.stringify(payload, null, 2);
|
|
121
|
+
}
|
|
122
|
+
importSession(payload) {
|
|
123
|
+
const parsed = JSON.parse(payload);
|
|
124
|
+
return this.sessions.create(normalizeImportedState(parsed.state), this.contractVersion);
|
|
125
|
+
}
|
|
126
|
+
async setConstituentaValue(sessionId, input) {
|
|
127
|
+
const envelope = this.sessions.get(sessionId);
|
|
128
|
+
return this.evaluation.setConstituentaValue(envelope.state, input);
|
|
129
|
+
}
|
|
130
|
+
async setConstituentaValues(sessionId, input) {
|
|
131
|
+
const envelope = this.sessions.get(sessionId);
|
|
132
|
+
return this.evaluation.setConstituentaValues(envelope.state, input);
|
|
133
|
+
}
|
|
134
|
+
async clearConstituentaValues(sessionId, input) {
|
|
135
|
+
const envelope = this.sessions.get(sessionId);
|
|
136
|
+
return this.evaluation.clearConstituentaValues(envelope.state, input.items);
|
|
137
|
+
}
|
|
138
|
+
getModelState(sessionId) {
|
|
139
|
+
const envelope = this.sessions.get(sessionId);
|
|
140
|
+
return structuredClone(envelope.state.model);
|
|
141
|
+
}
|
|
142
|
+
evaluateExpression(sessionId, input) {
|
|
143
|
+
const envelope = this.sessions.get(sessionId);
|
|
144
|
+
return this.evaluation.evaluateExpression(envelope.state, input.expression, input.cstType);
|
|
145
|
+
}
|
|
146
|
+
evaluateConstituenta(sessionId, input) {
|
|
147
|
+
const envelope = this.sessions.get(sessionId);
|
|
148
|
+
return this.evaluation.evaluateConstituenta(envelope.state, input.constituentId);
|
|
149
|
+
}
|
|
150
|
+
recalculateModel(sessionId) {
|
|
151
|
+
const envelope = this.sessions.get(sessionId);
|
|
152
|
+
return this.evaluation.recalculateModel(envelope.state);
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
//#endregion
|
|
156
|
+
export { PORTAL_JSON_CONTRACT_VERSION as n, RSToolAgent as t };
|
|
157
|
+
|
|
158
|
+
//# sourceMappingURL=rstool-agent-BZi5jO1y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rstool-agent-BZi5jO1y.js","names":[],"sources":["../src/models/portal-json.ts","../src/models/rstool-agent.ts"],"sourcesContent":["import { type BasicBinding, type RSToolValue } from './common';\n\n/** Portal JSON import/export format version (schema and model files). */\nexport const PORTAL_JSON_CONTRACT_VERSION = '1.0.0';\n\nexport interface PortalImportMetadata {\n contract_version: string;\n title: string;\n alias: string;\n description: string;\n}\n\nexport interface PortalTermForm {\n text: string;\n tags: string;\n}\n\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\nexport interface PortalSchemaImportData extends PortalImportMetadata {\n items: PortalSchemaConstituenta[];\n attribution: Array<{ container: number; attribute: number }>;\n}\n\nexport interface PortalModelImportData extends PortalImportMetadata {\n items: Array<{\n id: number;\n type: string;\n value: RSToolValue | BasicBinding;\n }>;\n}\n","import { ModelAdapter } from '../mappers/model-adapter';\nimport { SchemaAdapter } from '../mappers/schema-adapter';\nimport { SessionStore } from '../session/session-store';\nimport { type AnalysisResult, type AnalyzeExpressionInput } from './analysis';\nimport {\n type AddOrUpdateConstituentaInput,\n type AddOrUpdateConstituentaResult\n} from './constituenta';\nimport { type ListDiagnosticsFilters } from './diagnostic';\nimport {\n type EvaluateConstituentaInput,\n type EvaluateExpressionInput,\n type EvaluationResult\n} from './evaluation';\nimport {\n type ClearConstituentaValuesInput,\n type RecalculateModelResult,\n type SessionModelState,\n type SetConstituentaValueInput,\n type SetConstituentaValuesInput\n} from './model-value';\nimport {\n PORTAL_JSON_CONTRACT_VERSION,\n type PortalModelImportData,\n type PortalSchemaImportData\n} from './portal-json';\nimport { type SessionHandle, type SessionRevision, type SessionState } from './session';\nimport { CONTRACT_VERSION, type RSToolAgentContract } 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'\n ? { title: 'Conceptual schema', alias: 'SCHEMA' }\n : { 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\nexport class RSToolAgent implements RSToolAgentContract {\n public readonly contractVersion = CONTRACT_VERSION;\n private readonly sessions = new SessionStore();\n private readonly adapter = new SchemaAdapter();\n private readonly evaluation = new ModelAdapter();\n\n public createSession(initial?: Partial<SessionState>): SessionHandle {\n return this.sessions.create(initial, this.contractVersion);\n }\n\n public addOrUpdateConstituenta(\n sessionId: string,\n input: AddOrUpdateConstituentaInput\n ): AddOrUpdateConstituentaResult {\n const envelope = this.sessions.get(sessionId);\n const { result, diagnostics } = this.adapter.analyzeAgainstSession(envelope.state, input.draft);\n const state = this.adapter.mergeStateWithDraft(envelope.state, input.draft, result);\n this.sessions.appendDiagnostics(sessionId, diagnostics);\n return {\n state,\n diagnostics\n };\n }\n\n public analyzeExpression(sessionId: string, input: AnalyzeExpressionInput): AnalysisResult {\n const envelope = this.sessions.get(sessionId);\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 this.sessions.appendDiagnostics(\n sessionId,\n diagnostics.map(item => ({ ...item, constituentId: undefined }))\n );\n return result;\n }\n\n public getFormState(sessionId: string): SessionState {\n const envelope = this.sessions.get(sessionId);\n return structuredClone(envelope.state);\n }\n\n public listDiagnostics(sessionId: string, filters?: ListDiagnosticsFilters) {\n return this.sessions.listDiagnostics(sessionId, filters);\n }\n\n public commitStep(sessionId: string, message?: string): SessionRevision {\n return this.sessions.addRevision(sessionId, message);\n }\n\n public exportSession(sessionId: string): string {\n const envelope = this.sessions.get(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 public exportPortalSchema(sessionId: string): string {\n const envelope = this.sessions.get(sessionId);\n const payload: PortalSchemaImportData = {\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 return JSON.stringify(payload, null, 2);\n }\n\n public exportPortalModel(sessionId: string): string {\n const envelope = this.sessions.get(sessionId);\n const payload: PortalModelImportData = {\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 return JSON.stringify(payload, null, 2);\n }\n\n public importSession(payload: string): SessionHandle {\n const parsed = JSON.parse(payload) as {\n state: SessionState;\n };\n return this.sessions.create(normalizeImportedState(parsed.state), this.contractVersion);\n }\n\n public async setConstituentaValue(\n sessionId: string,\n input: SetConstituentaValueInput\n ): Promise<SessionModelState> {\n const envelope = this.sessions.get(sessionId);\n return this.evaluation.setConstituentaValue(envelope.state, input);\n }\n\n public async setConstituentaValues(\n sessionId: string,\n input: SetConstituentaValuesInput\n ): Promise<SessionModelState> {\n const envelope = this.sessions.get(sessionId);\n return this.evaluation.setConstituentaValues(envelope.state, input);\n }\n\n public async clearConstituentaValues(\n sessionId: string,\n input: ClearConstituentaValuesInput\n ): Promise<SessionModelState> {\n const envelope = this.sessions.get(sessionId);\n return this.evaluation.clearConstituentaValues(envelope.state, input.items);\n }\n\n public getModelState(sessionId: string): SessionModelState {\n const envelope = this.sessions.get(sessionId);\n return structuredClone(envelope.state.model);\n }\n\n public evaluateExpression(sessionId: string, input: EvaluateExpressionInput): EvaluationResult {\n const envelope = this.sessions.get(sessionId);\n return this.evaluation.evaluateExpression(envelope.state, input.expression, input.cstType);\n }\n\n public evaluateConstituenta(sessionId: string, input: EvaluateConstituentaInput): EvaluationResult {\n const envelope = this.sessions.get(sessionId);\n return this.evaluation.evaluateConstituenta(envelope.state, input.constituentId);\n }\n\n public recalculateModel(sessionId: string): RecalculateModelResult {\n const envelope = this.sessions.get(sessionId);\n return this.evaluation.recalculateModel(envelope.state);\n }\n}\n"],"mappings":"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"}
|
|
@@ -3,12 +3,12 @@ import { n as ListDiagnosticsFilters, t as DiagnosticRecord } from "./diagnostic
|
|
|
3
3
|
import { n as AddOrUpdateConstituentaResult, t as AddOrUpdateConstituentaInput } from "./constituenta-Dnd6iToB.js";
|
|
4
4
|
import { n as EvaluateExpressionInput, r as EvaluationResult, t as EvaluateConstituentaInput } from "./evaluation-CCVYH0wA.js";
|
|
5
5
|
import { a as SetConstituentaValueInput, i as SessionModelState, o as SetConstituentaValuesInput, r as RecalculateModelResult, t as ClearConstituentaValuesInput } from "./model-value-SFAVj0dw.js";
|
|
6
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-
|
|
7
|
-
import { n as RSToolAgentContract } from "./tool-contract-
|
|
6
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-BPgsE80c.js";
|
|
7
|
+
import { n as RSToolAgentContract } from "./tool-contract-n1ghUOrK.js";
|
|
8
8
|
|
|
9
9
|
//#region src/models/rstool-agent.d.ts
|
|
10
10
|
declare class RSToolAgent implements RSToolAgentContract {
|
|
11
|
-
readonly contractVersion = "1.
|
|
11
|
+
readonly contractVersion = "1.4.0";
|
|
12
12
|
private readonly sessions;
|
|
13
13
|
private readonly adapter;
|
|
14
14
|
private readonly evaluation;
|
|
@@ -19,6 +19,8 @@ declare class RSToolAgent implements RSToolAgentContract {
|
|
|
19
19
|
listDiagnostics(sessionId: string, filters?: ListDiagnosticsFilters): DiagnosticRecord[];
|
|
20
20
|
commitStep(sessionId: string, message?: string): SessionRevision;
|
|
21
21
|
exportSession(sessionId: string): string;
|
|
22
|
+
exportPortalSchema(sessionId: string): string;
|
|
23
|
+
exportPortalModel(sessionId: string): string;
|
|
22
24
|
importSession(payload: string): SessionHandle;
|
|
23
25
|
setConstituentaValue(sessionId: string, input: SetConstituentaValueInput): Promise<SessionModelState>;
|
|
24
26
|
setConstituentaValues(sessionId: string, input: SetConstituentaValuesInput): Promise<SessionModelState>;
|
|
@@ -30,4 +32,4 @@ declare class RSToolAgent implements RSToolAgentContract {
|
|
|
30
32
|
}
|
|
31
33
|
//#endregion
|
|
32
34
|
export { RSToolAgent as t };
|
|
33
|
-
//# sourceMappingURL=rstool-agent-
|
|
35
|
+
//# sourceMappingURL=rstool-agent-pRaPnZay.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { n as ListDiagnosticsFilters, t as DiagnosticRecord } from "../diagnostic-BMYvciz8.js";
|
|
2
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "../session-
|
|
2
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "../session-BPgsE80c.js";
|
|
3
|
+
|
|
3
4
|
//#region src/session/session-store.d.ts
|
|
4
5
|
interface SessionEnvelope {
|
|
5
6
|
state: SessionState;
|
|
@@ -7,6 +7,9 @@ var SessionStore = class {
|
|
|
7
7
|
const sessionId = initial?.sessionId ?? randomUUID();
|
|
8
8
|
const state = {
|
|
9
9
|
sessionId,
|
|
10
|
+
alias: initial?.alias ?? "",
|
|
11
|
+
title: initial?.title ?? "",
|
|
12
|
+
comment: initial?.comment ?? "",
|
|
10
13
|
createdAt: initial?.createdAt ?? now,
|
|
11
14
|
updatedAt: now,
|
|
12
15
|
revisions: initial?.revisions ?? [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-store.js","names":[],"sources":["../../src/session/session-store.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nimport {\n type DiagnosticRecord,\n type ListDiagnosticsFilters,\n type SessionHandle,\n type SessionRevision,\n type SessionState\n} from '../models';\n\ninterface SessionEnvelope {\n state: SessionState;\n diagnostics: DiagnosticRecord[];\n}\n\nexport class SessionStore {\n private sessions = new Map<string, SessionEnvelope>();\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 createdAt: initial?.createdAt ?? now,\n updatedAt: now,\n revisions: initial?.revisions ?? [],\n items: initial?.items ?? [],\n model: initial?.model ?? { items: [] }\n };\n this.sessions.set(sessionId, {\n state,\n diagnostics: []\n });\n return {\n sessionId,\n contractVersion: contractVersion ?? '1.0.0'\n };\n }\n\n public get(sessionId: string): SessionEnvelope {\n const found = this.sessions.get(sessionId);\n if (!found) {\n throw new Error(`Unknown session: ${sessionId}`);\n }\n return found;\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 }\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 return revision;\n }\n\n public appendDiagnostics(sessionId: string, records: DiagnosticRecord[]): void {\n const found = this.get(sessionId);\n found.diagnostics.push(...records);\n found.state.updatedAt = new Date().toISOString();\n }\n\n public listDiagnostics(sessionId: string, filters?: ListDiagnosticsFilters): DiagnosticRecord[] {\n const found = this.get(sessionId);\n if (!filters?.constituentId) {\n return [...found.diagnostics];\n }\n return found.diagnostics.filter(record => record.constituentId === filters.constituentId);\n }\n}\n"],"mappings":";;AAeA,IAAa,eAAb,MAA0B;CACxB,2BAAmB,IAAI,IAA6B;CAEpD,OAAc,SAAiC,iBAAyC;EACtF,MAAM,uBAAM,IAAI,KAAK,GAAE,YAAY;EACnC,MAAM,YAAY,SAAS,aAAa,WAAW;EACnD,MAAM,QAAsB;GAC1B;GACA,WAAW,SAAS,aAAa;GACjC,WAAW;GACX,WAAW,SAAS,aAAa,CAAC;GAClC,OAAO,SAAS,SAAS,CAAC;GAC1B,OAAO,SAAS,SAAS,EAAE,OAAO,CAAC,EAAE;EACvC;EACA,KAAK,SAAS,IAAI,WAAW;GAC3B;GACA,aAAa,CAAC;EAChB,CAAC;EACD,OAAO;GACL;GACA,iBAAiB,mBAAmB;EACtC;CACF;CAEA,IAAW,WAAoC;EAC7C,MAAM,QAAQ,KAAK,SAAS,IAAI,SAAS;EACzC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,oBAAoB,WAAW;EAEjD,OAAO;CACT;CAEA,aAAoB,WAAmB,WAA+B;EACpE,MAAM,QAAQ,KAAK,IAAI,SAAS;EAChC,MAAM,QAAQ;GACZ,GAAG;GACH,4BAAW,IAAI,KAAK,GAAE,YAAY;EACpC;CACF;CAEA,YAAmB,WAAmB,SAAmC;EACvE,MAAM,QAAQ,KAAK,IAAI,SAAS;EAChC,MAAM,WAA4B;GAChC,YAAY,WAAW;GACvB,qBAAI,IAAI,KAAK,GAAE,YAAY;GAC3B;EACF;EACA,MAAM,MAAM,UAAU,KAAK,QAAQ;EACnC,MAAM,MAAM,YAAY,SAAS;EACjC,OAAO;CACT;CAEA,kBAAyB,WAAmB,SAAmC;EAC7E,MAAM,QAAQ,KAAK,IAAI,SAAS;EAChC,MAAM,YAAY,KAAK,GAAG,OAAO;EACjC,MAAM,MAAM,6BAAY,IAAI,KAAK,GAAE,YAAY;CACjD;CAEA,gBAAuB,WAAmB,SAAsD;EAC9F,MAAM,QAAQ,KAAK,IAAI,SAAS;EAChC,IAAI,CAAC,SAAS,eACZ,OAAO,CAAC,GAAG,MAAM,WAAW;EAE9B,OAAO,MAAM,YAAY,QAAO,WAAU,OAAO,kBAAkB,QAAQ,aAAa;CAC1F;AACF"}
|
|
1
|
+
{"version":3,"file":"session-store.js","names":[],"sources":["../../src/session/session-store.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\n\nimport {\n type DiagnosticRecord,\n type ListDiagnosticsFilters,\n type SessionHandle,\n type SessionRevision,\n type SessionState\n} from '../models';\n\ninterface SessionEnvelope {\n state: SessionState;\n diagnostics: DiagnosticRecord[];\n}\n\nexport class SessionStore {\n private sessions = new Map<string, SessionEnvelope>();\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 this.sessions.set(sessionId, {\n state,\n diagnostics: []\n });\n return {\n sessionId,\n contractVersion: contractVersion ?? '1.0.0'\n };\n }\n\n public get(sessionId: string): SessionEnvelope {\n const found = this.sessions.get(sessionId);\n if (!found) {\n throw new Error(`Unknown session: ${sessionId}`);\n }\n return found;\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 }\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 return revision;\n }\n\n public appendDiagnostics(sessionId: string, records: DiagnosticRecord[]): void {\n const found = this.get(sessionId);\n found.diagnostics.push(...records);\n found.state.updatedAt = new Date().toISOString();\n }\n\n public listDiagnostics(sessionId: string, filters?: ListDiagnosticsFilters): DiagnosticRecord[] {\n const found = this.get(sessionId);\n if (!filters?.constituentId) {\n return [...found.diagnostics];\n }\n return found.diagnostics.filter(record => record.constituentId === filters.constituentId);\n }\n}\n"],"mappings":";;AAeA,IAAa,eAAb,MAA0B;CACxB,2BAAmB,IAAI,IAA6B;CAEpD,OAAc,SAAiC,iBAAyC;EACtF,MAAM,uBAAM,IAAI,KAAK,GAAE,YAAY;EACnC,MAAM,YAAY,SAAS,aAAa,WAAW;EACnD,MAAM,QAAsB;GAC1B;GACA,OAAO,SAAS,SAAS;GACzB,OAAO,SAAS,SAAS;GACzB,SAAS,SAAS,WAAW;GAC7B,WAAW,SAAS,aAAa;GACjC,WAAW;GACX,WAAW,SAAS,aAAa,CAAC;GAClC,OAAO,SAAS,SAAS,CAAC;GAC1B,OAAO,SAAS,SAAS,EAAE,OAAO,CAAC,EAAE;EACvC;EACA,KAAK,SAAS,IAAI,WAAW;GAC3B;GACA,aAAa,CAAC;EAChB,CAAC;EACD,OAAO;GACL;GACA,iBAAiB,mBAAmB;EACtC;CACF;CAEA,IAAW,WAAoC;EAC7C,MAAM,QAAQ,KAAK,SAAS,IAAI,SAAS;EACzC,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,oBAAoB,WAAW;EAEjD,OAAO;CACT;CAEA,aAAoB,WAAmB,WAA+B;EACpE,MAAM,QAAQ,KAAK,IAAI,SAAS;EAChC,MAAM,QAAQ;GACZ,GAAG;GACH,4BAAW,IAAI,KAAK,GAAE,YAAY;EACpC;CACF;CAEA,YAAmB,WAAmB,SAAmC;EACvE,MAAM,QAAQ,KAAK,IAAI,SAAS;EAChC,MAAM,WAA4B;GAChC,YAAY,WAAW;GACvB,qBAAI,IAAI,KAAK,GAAE,YAAY;GAC3B;EACF;EACA,MAAM,MAAM,UAAU,KAAK,QAAQ;EACnC,MAAM,MAAM,YAAY,SAAS;EACjC,OAAO;CACT;CAEA,kBAAyB,WAAmB,SAAmC;EAC7E,MAAM,QAAQ,KAAK,IAAI,SAAS;EAChC,MAAM,YAAY,KAAK,GAAG,OAAO;EACjC,MAAM,MAAM,6BAAY,IAAI,KAAK,GAAE,YAAY;CACjD;CAEA,gBAAuB,WAAmB,SAAsD;EAC9F,MAAM,QAAQ,KAAK,IAAI,SAAS;EAChC,IAAI,CAAC,SAAS,eACZ,OAAO,CAAC,GAAG,MAAM,WAAW;EAE9B,OAAO,MAAM,YAAY,QAAO,WAAU,OAAO,kBAAkB,QAAQ,aAAa;CAC1F;AACF"}
|
|
@@ -13,12 +13,23 @@ interface SessionRevision {
|
|
|
13
13
|
}
|
|
14
14
|
interface SessionState {
|
|
15
15
|
sessionId: string;
|
|
16
|
+
/** Library item alias for the conceptual schema or model. */
|
|
17
|
+
alias: string;
|
|
18
|
+
/** Human-readable title. */
|
|
19
|
+
title: string;
|
|
20
|
+
/** Developer comment (Portal JSON `description` on export). */
|
|
21
|
+
comment: string;
|
|
22
|
+
/** Date of creation. */
|
|
16
23
|
createdAt: string;
|
|
24
|
+
/** Date of last update. */
|
|
17
25
|
updatedAt: string;
|
|
26
|
+
/** List of revisions. */
|
|
18
27
|
revisions: SessionRevision[];
|
|
28
|
+
/** List of constituents in the session. */
|
|
19
29
|
items: ConstituentaState[];
|
|
30
|
+
/** Model state. */
|
|
20
31
|
model: SessionModelState;
|
|
21
32
|
}
|
|
22
33
|
//#endregion
|
|
23
34
|
export { SessionRevision as n, SessionState as r, SessionHandle as t };
|
|
24
|
-
//# sourceMappingURL=session-
|
|
35
|
+
//# sourceMappingURL=session-BPgsE80c.d.ts.map
|
|
@@ -3,10 +3,10 @@ import { n as ListDiagnosticsFilters, t as DiagnosticRecord } from "./diagnostic
|
|
|
3
3
|
import { n as AddOrUpdateConstituentaResult, t as AddOrUpdateConstituentaInput } from "./constituenta-Dnd6iToB.js";
|
|
4
4
|
import { n as EvaluateExpressionInput, r as EvaluationResult, t as EvaluateConstituentaInput } from "./evaluation-CCVYH0wA.js";
|
|
5
5
|
import { a as SetConstituentaValueInput, i as SessionModelState, o as SetConstituentaValuesInput, r as RecalculateModelResult, t as ClearConstituentaValuesInput } from "./model-value-SFAVj0dw.js";
|
|
6
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-
|
|
6
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-BPgsE80c.js";
|
|
7
7
|
|
|
8
8
|
//#region src/models/tool-contract.d.ts
|
|
9
|
-
declare const CONTRACT_VERSION = "1.
|
|
9
|
+
declare const CONTRACT_VERSION = "1.4.0";
|
|
10
10
|
interface RSToolAgentContract {
|
|
11
11
|
readonly contractVersion: string;
|
|
12
12
|
createSession(initial?: Partial<SessionState>): SessionHandle;
|
|
@@ -16,6 +16,8 @@ interface RSToolAgentContract {
|
|
|
16
16
|
listDiagnostics(sessionId: string, filters?: ListDiagnosticsFilters): DiagnosticRecord[];
|
|
17
17
|
commitStep(sessionId: string, message?: string): SessionRevision;
|
|
18
18
|
exportSession(sessionId: string): string;
|
|
19
|
+
exportPortalSchema(sessionId: string): string;
|
|
20
|
+
exportPortalModel(sessionId: string): string;
|
|
19
21
|
importSession(payload: string): SessionHandle;
|
|
20
22
|
setConstituentaValue(sessionId: string, input: SetConstituentaValueInput): Promise<SessionModelState>;
|
|
21
23
|
setConstituentaValues(sessionId: string, input: SetConstituentaValuesInput): Promise<SessionModelState>;
|
|
@@ -27,4 +29,4 @@ interface RSToolAgentContract {
|
|
|
27
29
|
}
|
|
28
30
|
//#endregion
|
|
29
31
|
export { RSToolAgentContract as n, CONTRACT_VERSION as t };
|
|
30
|
-
//# sourceMappingURL=tool-contract-
|
|
32
|
+
//# sourceMappingURL=tool-contract-n1ghUOrK.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { RSToolAgent } from "../
|
|
2
|
+
import { t as RSToolAgent } from "../rstool-agent-BZi5jO1y.js";
|
|
3
3
|
import readline from "node:readline";
|
|
4
4
|
//#region src/wrapper/stdio-wrapper.ts
|
|
5
5
|
const tool = new RSToolAgent();
|
|
@@ -11,6 +11,8 @@ const METHODS = [
|
|
|
11
11
|
"listDiagnostics",
|
|
12
12
|
"commitStep",
|
|
13
13
|
"exportSession",
|
|
14
|
+
"exportPortalSchema",
|
|
15
|
+
"exportPortalModel",
|
|
14
16
|
"importSession",
|
|
15
17
|
"setConstituentaValue",
|
|
16
18
|
"setConstituentaValues",
|
|
@@ -84,6 +86,16 @@ async function handleRequest(request) {
|
|
|
84
86
|
ok: true,
|
|
85
87
|
result: tool.exportSession(requiredString(params, "sessionId"))
|
|
86
88
|
};
|
|
89
|
+
case "exportPortalSchema": return {
|
|
90
|
+
id: request.id,
|
|
91
|
+
ok: true,
|
|
92
|
+
result: tool.exportPortalSchema(requiredString(params, "sessionId"))
|
|
93
|
+
};
|
|
94
|
+
case "exportPortalModel": return {
|
|
95
|
+
id: request.id,
|
|
96
|
+
ok: true,
|
|
97
|
+
result: tool.exportPortalModel(requiredString(params, "sessionId"))
|
|
98
|
+
};
|
|
87
99
|
case "importSession": return {
|
|
88
100
|
id: request.id,
|
|
89
101
|
ok: true,
|