@rsconcept/rstool 1.7.0 → 1.9.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 +5 -5
- package/dist/{agent-workflow-DY-hfAap.d.ts → agent-workflow-BqEC_Foh.d.ts} +5 -6
- package/dist/{analysis-ktWFu4BY.d.ts → analysis-C7GrmB17.d.ts} +3 -4
- package/dist/{common-D6TFl6l_.d.ts → common-oafVB-wX.d.ts} +1 -2
- package/dist/{constituenta-HTnFtmxt.d.ts → constituenta-CwJogNKY.d.ts} +4 -5
- package/dist/{diagnostic-CODFUU-Q.d.ts → diagnostic-CtxXifJY.d.ts} +4 -3
- 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-6A7rK4t7.d.ts → evaluation-BHv2xNwf.d.ts} +3 -4
- package/dist/index.d.ts +11 -10
- package/dist/index.js +1 -1
- package/dist/mappers/model-adapter.d.ts +9 -4
- package/dist/mappers/model-adapter.js +29 -4
- package/dist/mappers/model-adapter.js.map +1 -1
- package/dist/mappers/schema-adapter.d.ts +5 -5
- package/dist/mappers/schema-adapter.js +1 -1
- 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 +1 -1
- 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 +10 -10
- 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-BKmWx92e.js → models-D06g8LId.js} +8 -7
- package/dist/{models-BKmWx92e.js.map → models-D06g8LId.js.map} +1 -1
- package/dist/{rsform-builder-DKwZfJvN.js → rsform-builder-BlXEe5Ow.js} +2 -2
- package/dist/{rsform-builder-DKwZfJvN.js.map → rsform-builder-BlXEe5Ow.js.map} +1 -1
- package/dist/{rstool-agent-D-w4DlEo.d.ts → rstool-agent-DLq0mtym.d.ts} +9 -10
- package/dist/session/session-store.d.ts +3 -2
- package/dist/session/session-store.js +1 -1
- package/dist/{session-Uc_vHrq9.d.ts → session-OaLqLq0H.d.ts} +3 -4
- package/dist/{tool-contract-i0v2gbWs.d.ts → tool-contract-ZVyh7hhp.d.ts} +10 -11
- package/dist/wrapper/client.d.ts +12 -5
- package/dist/wrapper/client.js +79 -12
- package/dist/wrapper/client.js.map +1 -1
- package/dist/wrapper/stdio-wrapper.d.ts +1 -1
- package/dist/wrapper/stdio-wrapper.js +18 -10
- package/dist/wrapper/stdio-wrapper.js.map +1 -1
- package/docs/CONCEPTUAL-SCHEMA.md +1 -1
- package/docs/CONSTRUCTIONS.md +372 -0
- package/docs/DIAGNOSTICS.md +70 -28
- package/docs/DOMAIN.md +7 -2
- package/docs/MODEL-TESTING.md +48 -0
- package/docs/README.md +1 -0
- package/docs/SYNTAX.md +1 -1
- package/docs/TYPIFICATION.md +11 -2
- package/examples/diagnostics-utils.ts +3 -4
- package/package.json +20 -19
- package/skills/README.md +1 -1
- package/skills/rstool-helper/EXAMPLES.md +24 -0
- package/skills/rstool-helper/GUIDE.md +49 -22
- package/skills/rstool-helper/REFERENCE.md +24 -5
- package/skills/rstool-helper/SKILL.md +7 -4
- package/src/mappers/diagnostic-assembly.ts +5 -2
- package/src/mappers/model-adapter.ts +34 -1
- package/src/mappers/types.ts +1 -0
- package/src/models/rstool-agent.test.ts +95 -0
- package/src/models/tool-contract.ts +1 -1
- package/src/wrapper/client.test.ts +43 -4
- package/src/wrapper/client.ts +95 -16
- package/src/wrapper/stdio-handler.test.ts +43 -0
- package/src/wrapper/stdio-handler.ts +19 -5
- package/dist/diagnostic-assembly-B-6vIA5I.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Agent-facing library for **incremental RSForm construction**, **RSLang expression analysis**, **diagnostics**, **modeling**, and **evaluation**. It wraps [`@rsconcept/domain`](https://www.npmjs.com/package/@rsconcept/domain) with a deterministic session contract and a stdio JSON wrapper for LLM agents. MCP hosts can use it through [`@rsconcept/rstool-mcp`](https://www.npmjs.com/package/@rsconcept/rstool-mcp).
|
|
4
4
|
|
|
5
|
-
**Contract version:** `3.
|
|
5
|
+
**Contract version:** `3.3.0` — see [skills/rstool-helper/REFERENCE.md](./skills/rstool-helper/REFERENCE.md) for the full v3 API.
|
|
6
6
|
|
|
7
7
|
## Agent skill
|
|
8
8
|
|
|
@@ -77,7 +77,7 @@ Maintainers: see [PUBLISHING.md](./PUBLISHING.md) for npm release steps.
|
|
|
77
77
|
- If a session method is called without an active session, rstool creates one lazily.
|
|
78
78
|
- On startup, a ready handshake is printed.
|
|
79
79
|
|
|
80
|
-
Supported methods (contract `3.
|
|
80
|
+
Supported methods (contract `3.3.0`):
|
|
81
81
|
|
|
82
82
|
- `ping`
|
|
83
83
|
- `methods`
|
|
@@ -100,7 +100,7 @@ Supported methods (contract `3.2.0`):
|
|
|
100
100
|
- `restoreOrder`
|
|
101
101
|
- `synthesize`
|
|
102
102
|
|
|
103
|
-
Params are **flat** at the top level (no `params.input` wrapper). Optional `sessionId` sits alongside method fields.
|
|
103
|
+
Params are **flat** at the top level (no `params.input` wrapper). Optional `sessionId` sits alongside method fields. `listDiagnostics` takes flat `constituentId` / `kind` / `severity` filters (a legacy nested `filters` object is still accepted).
|
|
104
104
|
|
|
105
105
|
Example `createSession`:
|
|
106
106
|
|
|
@@ -113,7 +113,7 @@ Request:
|
|
|
113
113
|
Response:
|
|
114
114
|
|
|
115
115
|
```json
|
|
116
|
-
{ "id": "1", "ok": true, "result": { "sessionId": "...", "contractVersion": "3.
|
|
116
|
+
{ "id": "1", "ok": true, "result": { "sessionId": "...", "contractVersion": "3.3.0" } }
|
|
117
117
|
```
|
|
118
118
|
|
|
119
119
|
Example `applySchemaPatch`:
|
|
@@ -142,7 +142,7 @@ Response:
|
|
|
142
142
|
"ok": true,
|
|
143
143
|
"result": {
|
|
144
144
|
"success": true,
|
|
145
|
-
"session": { "sessionId": "...", "contractVersion": "3.
|
|
145
|
+
"session": { "sessionId": "...", "contractVersion": "3.3.0" },
|
|
146
146
|
"summary": { "itemCount": 3 }
|
|
147
147
|
}
|
|
148
148
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { a as Diagnostic } from "./diagnostic-
|
|
2
|
-
import { n as CstType } from "./common-
|
|
3
|
-
import { a as ApplyConstituentsResult, i as ApplyConstituentsMode, o as ConstituentaDraft } from "./constituenta-
|
|
4
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-
|
|
5
|
-
|
|
1
|
+
import { a as Diagnostic } from "./diagnostic-CtxXifJY.js";
|
|
2
|
+
import { n as CstType } from "./common-oafVB-wX.js";
|
|
3
|
+
import { a as ApplyConstituentsResult, i as ApplyConstituentsMode, o as ConstituentaDraft } from "./constituenta-CwJogNKY.js";
|
|
4
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-OaLqLq0H.js";
|
|
6
5
|
//#region src/models/agent-workflow.d.ts
|
|
7
6
|
/** Level of detail returned by {@link RSToolAgent.getSessionState}. */
|
|
8
7
|
type SessionStateDetail = 'summary' | 'full';
|
|
@@ -113,4 +112,4 @@ interface ApplySchemaPatchResult extends ApplyConstituentsResult {
|
|
|
113
112
|
}
|
|
114
113
|
//#endregion
|
|
115
114
|
export { SessionStateDetail as a, SessionSummaryItem as c, SynthesizeResult as d, RestoreOrderResult as i, SynthesisSubstitution as l, ApplySchemaPatchInput as n, SessionStateResult as o, ApplySchemaPatchResult as r, SessionSummary as s, AgentConstituentaPatch as t, SynthesizeInput as u };
|
|
116
|
-
//# sourceMappingURL=agent-workflow-
|
|
115
|
+
//# sourceMappingURL=agent-workflow-BqEC_Foh.d.ts.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as Diagnostic } from "./diagnostic-
|
|
2
|
-
import { n as CstType, o as ValueClass } from "./common-
|
|
3
|
-
|
|
1
|
+
import { a as Diagnostic } from "./diagnostic-CtxXifJY.js";
|
|
2
|
+
import { n as CstType, o as ValueClass } from "./common-oafVB-wX.js";
|
|
4
3
|
//#region src/models/analysis.d.ts
|
|
5
4
|
/** Input for {@link RSToolAgent.analyzeExpression}. */
|
|
6
5
|
interface AnalyzeExpressionInput {
|
|
@@ -21,4 +20,4 @@ interface AnalysisResult {
|
|
|
21
20
|
}
|
|
22
21
|
//#endregion
|
|
23
22
|
export { AnalyzeExpressionInput as n, AnalysisResult as t };
|
|
24
|
-
//# sourceMappingURL=analysis-
|
|
23
|
+
//# sourceMappingURL=analysis-C7GrmB17.d.ts.map
|
|
@@ -2,10 +2,9 @@ import { RSErrorCode as RSErrorCode$1 } from "@rsconcept/domain/rslang/error";
|
|
|
2
2
|
import { CstType as CstType$1 } from "@rsconcept/domain/library/rsform";
|
|
3
3
|
import { BasicBinding, EvalStatus as EvalStatus$1 } from "@rsconcept/domain/library/rsmodel";
|
|
4
4
|
import { ValueClass as ValueClass$1 } from "@rsconcept/domain/rslang";
|
|
5
|
-
|
|
6
5
|
//#region src/models/common.d.ts
|
|
7
6
|
/** Runtime evaluation value: number, nested array (set/tuple), or boolean 0/1. */
|
|
8
7
|
type RSToolValue = number | RSToolValue[];
|
|
9
8
|
//#endregion
|
|
10
9
|
export { RSToolValue as a, RSErrorCode$1 as i, CstType$1 as n, ValueClass$1 as o, EvalStatus$1 as r, BasicBinding as t };
|
|
11
|
-
//# sourceMappingURL=common-
|
|
10
|
+
//# sourceMappingURL=common-oafVB-wX.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { a as Diagnostic } from "./diagnostic-
|
|
2
|
-
import { n as CstType } from "./common-
|
|
3
|
-
import { t as AnalysisResult } from "./analysis-
|
|
4
|
-
|
|
1
|
+
import { a as Diagnostic } from "./diagnostic-CtxXifJY.js";
|
|
2
|
+
import { n as CstType } from "./common-oafVB-wX.js";
|
|
3
|
+
import { t as AnalysisResult } from "./analysis-C7GrmB17.js";
|
|
5
4
|
//#region src/models/constituenta.d.ts
|
|
6
5
|
/** Constituent payload before analysis and merge into session state. */
|
|
7
6
|
interface ConstituentaDraft {
|
|
@@ -51,4 +50,4 @@ interface ApplyConstituentsResult {
|
|
|
51
50
|
}
|
|
52
51
|
//#endregion
|
|
53
52
|
export { ApplyConstituentsResult as a, ApplyConstituentsMode as i, AddOrUpdateConstituentaResult as n, ConstituentaDraft as o, ApplyConstituentsInput as r, ConstituentaState as s, AddOrUpdateConstituentaInput as t };
|
|
54
|
-
//# sourceMappingURL=constituenta-
|
|
53
|
+
//# sourceMappingURL=constituenta-CwJogNKY.d.ts.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CstDiagnostic, CstDiagnostic as CstDiagnostic$1, DiagnosticKind, DiagnosticKind as DiagnosticKind$1, RSDiagnosticCode, RSDiagnosticCode as RSDiagnosticCode$1 } from "@rsconcept/domain/library";
|
|
2
|
-
import { RSErrorDescription } from "@rsconcept/domain/rslang/error";
|
|
2
|
+
import { EvalStackFrame, RSErrorDescription } from "@rsconcept/domain/rslang/error";
|
|
3
3
|
import { EvalStatus } from "@rsconcept/domain/library/rsmodel";
|
|
4
4
|
import { DiagnosticSourceFields } from "@rsconcept/domain/library/rsform-api";
|
|
5
|
-
|
|
6
5
|
//#region src/mappers/diagnostic-assembly.d.ts
|
|
7
6
|
/** Severity of a {@link Diagnostic}. */
|
|
8
7
|
type DiagnosticSeverity = 'error' | 'warning';
|
|
@@ -15,6 +14,8 @@ interface Diagnostic extends CstDiagnostic {
|
|
|
15
14
|
expression: string;
|
|
16
15
|
from: number;
|
|
17
16
|
to: number;
|
|
17
|
+
/** Evaluation call chain when the fault is inside a called `F#`/`P#` body. */
|
|
18
|
+
stack?: readonly EvalStackFrame[];
|
|
18
19
|
}
|
|
19
20
|
/** Context for attributing a {@link Diagnostic} to a constituent. */
|
|
20
21
|
interface DiagnosticTarget {
|
|
@@ -36,4 +37,4 @@ interface ListDiagnosticsFilters {
|
|
|
36
37
|
}
|
|
37
38
|
//#endregion
|
|
38
39
|
export { Diagnostic as a, expandCstDiagnostic as c, getDiagnosticSeverity as d, modelStatusDiagnostic as f, RSDiagnosticCode as i, expressionDiagnostic as l, DiagnosticKind as n, DiagnosticSeverity as o, ListDiagnosticsFilters as r, DiagnosticTarget as s, CstDiagnostic$1 as t, getDiagnosticName as u };
|
|
39
|
-
//# sourceMappingURL=diagnostic-
|
|
40
|
+
//# sourceMappingURL=diagnostic-CtxXifJY.d.ts.map
|
|
@@ -32,7 +32,8 @@ function expressionDiagnostic(error, expression, target) {
|
|
|
32
32
|
expression,
|
|
33
33
|
from: error.from,
|
|
34
34
|
to: error.to,
|
|
35
|
-
...error.params ? { params: error.params } : {}
|
|
35
|
+
...error.params ? { params: error.params } : {},
|
|
36
|
+
...error.stack ? { stack: error.stack } : {}
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
function modelStatusDiagnostic(status, cst) {
|
|
@@ -53,4 +54,4 @@ function expressionForCstDiagnostic(cst, diagnostic) {
|
|
|
53
54
|
//#endregion
|
|
54
55
|
export { getDiagnosticSeverity as a, getDiagnosticName as i, expandCstDiagnostic as n, modelStatusDiagnostic as o, expressionDiagnostic as r, DiagnosticKind as t };
|
|
55
56
|
|
|
56
|
-
//# sourceMappingURL=diagnostic-assembly-B-
|
|
57
|
+
//# sourceMappingURL=diagnostic-assembly-B-r0NyHL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostic-assembly-B-r0NyHL.js","names":[],"sources":["../src/mappers/diagnostic-assembly.ts"],"sourcesContent":["import {\n type CstDiagnostic,\n DiagnosticKind,\n modelStatusCstDiagnostic,\n RSDiagnosticCode\n} from '@rsconcept/domain/library';\nimport { type DiagnosticSourceFields } from '@rsconcept/domain/library/rsform-api';\nimport { EvalStatus } from '@rsconcept/domain/library/rsmodel';\nimport { isCritical, RSErrorCode, type EvalStackFrame, 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 /** Evaluation call chain when the fault is inside a called `F#`/`P#` body. */\n stack?: readonly EvalStackFrame[];\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: DiagnosticSourceFields, 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 ...(error.stack ? { stack: error.stack } : {})\n };\n}\n\nexport function modelStatusDiagnostic(status: EvalStatus, cst: DiagnosticSourceFields): Diagnostic | null {\n const base = modelStatusCstDiagnostic(status, cst.cst_type);\n return base ? expandCstDiagnostic(cst, base) : null;\n}\n\nfunction expressionForCstDiagnostic(cst: DiagnosticSourceFields, 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":";;;AAkCA,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,KAA6B,YAAuC;CACtG,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;EAC/C,GAAI,MAAM,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;CAC9C;AACF;AAEA,SAAgB,sBAAsB,QAAoB,KAAgD;CACxG,MAAM,OAAO,yBAAyB,QAAQ,IAAI,QAAQ;CAC1D,OAAO,OAAO,oBAAoB,KAAK,IAAI,IAAI;AACjD;AAEA,SAAS,2BAA2B,KAA6B,YAAmC;CAClG,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,6 +1,5 @@
|
|
|
1
|
-
import { a as Diagnostic } from "./diagnostic-
|
|
2
|
-
import { a as RSToolValue, n as CstType, r as EvalStatus, t as BasicBinding } from "./common-
|
|
3
|
-
|
|
1
|
+
import { a as Diagnostic } from "./diagnostic-CtxXifJY.js";
|
|
2
|
+
import { a as RSToolValue, n as CstType, r as EvalStatus, t as BasicBinding } from "./common-oafVB-wX.js";
|
|
4
3
|
//#region src/models/evaluation.d.ts
|
|
5
4
|
interface EvaluateExpressionInput {
|
|
6
5
|
expression: string;
|
|
@@ -29,4 +28,4 @@ interface EvaluationResult {
|
|
|
29
28
|
}
|
|
30
29
|
//#endregion
|
|
31
30
|
export { EvaluationResult as i, EvaluateExpressionInput as n, EvaluateInput as r, EvaluateConstituentaInput as t };
|
|
32
|
-
//# sourceMappingURL=evaluation-
|
|
31
|
+
//# sourceMappingURL=evaluation-BHv2xNwf.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { a as Diagnostic, i as RSDiagnosticCode, n as DiagnosticKind, o as DiagnosticSeverity, r as ListDiagnosticsFilters, t as CstDiagnostic } from "./diagnostic-
|
|
2
|
-
import { a as RSToolValue, i as RSErrorCode, n as CstType, o as ValueClass, r as EvalStatus, t as BasicBinding } from "./common-
|
|
3
|
-
import { n as AnalyzeExpressionInput, t as AnalysisResult } from "./analysis-
|
|
4
|
-
import { o as ConstituentaDraft, s as ConstituentaState } from "./constituenta-
|
|
5
|
-
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, r as RecalculateModelResult, s as SetModelValuesInput } from "./model-value-
|
|
6
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-
|
|
7
|
-
import { a as SessionStateDetail, c as SessionSummaryItem, d as SynthesizeResult, l as SynthesisSubstitution, n as ApplySchemaPatchInput, o as SessionStateResult, r as ApplySchemaPatchResult, s as SessionSummary, t as AgentConstituentaPatch, u as SynthesizeInput } from "./agent-workflow-
|
|
8
|
-
import { i as EvaluationResult, r as EvaluateInput } from "./evaluation-
|
|
9
|
-
import { a as ExportPortalInput, c as PortalExportKind, d as PortalModelImportData, f as PortalRsformDetails, h as PortalTermForm, i as ExportFormat, l as PORTAL_JSON_CONTRACT_VERSION, m as PortalSchemaImportData, n as RSToolAgentContract, o as ExportPortalResult, p as PortalSchemaConstituenta, r as RSToolAgentOptions, s as ImportDataKind, t as CONTRACT_VERSION, u as PortalImportMetadata } from "./tool-contract-
|
|
10
|
-
import { t as RSToolAgent } from "./rstool-agent-
|
|
1
|
+
import { a as Diagnostic, i as RSDiagnosticCode, n as DiagnosticKind, o as DiagnosticSeverity, r as ListDiagnosticsFilters, t as CstDiagnostic } from "./diagnostic-CtxXifJY.js";
|
|
2
|
+
import { a as RSToolValue, i as RSErrorCode, n as CstType, o as ValueClass, r as EvalStatus, t as BasicBinding } from "./common-oafVB-wX.js";
|
|
3
|
+
import { n as AnalyzeExpressionInput, t as AnalysisResult } from "./analysis-C7GrmB17.js";
|
|
4
|
+
import { o as ConstituentaDraft, s as ConstituentaState } from "./constituenta-CwJogNKY.js";
|
|
5
|
+
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, r as RecalculateModelResult, s as SetModelValuesInput } from "./model-value-C0QA-ji2.js";
|
|
6
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "./session-OaLqLq0H.js";
|
|
7
|
+
import { a as SessionStateDetail, c as SessionSummaryItem, d as SynthesizeResult, l as SynthesisSubstitution, n as ApplySchemaPatchInput, o as SessionStateResult, r as ApplySchemaPatchResult, s as SessionSummary, t as AgentConstituentaPatch, u as SynthesizeInput } from "./agent-workflow-BqEC_Foh.js";
|
|
8
|
+
import { i as EvaluationResult, r as EvaluateInput } from "./evaluation-BHv2xNwf.js";
|
|
9
|
+
import { a as ExportPortalInput, c as PortalExportKind, d as PortalModelImportData, f as PortalRsformDetails, h as PortalTermForm, i as ExportFormat, l as PORTAL_JSON_CONTRACT_VERSION, m as PortalSchemaImportData, n as RSToolAgentContract, o as ExportPortalResult, p as PortalSchemaConstituenta, r as RSToolAgentOptions, s as ImportDataKind, t as CONTRACT_VERSION, u as PortalImportMetadata } from "./tool-contract-ZVyh7hhp.js";
|
|
10
|
+
import { t as RSToolAgent } from "./rstool-agent-DLq0mtym.js";
|
|
11
|
+
import "./models/index.js";
|
|
11
12
|
import { DomainAnalysisLike, DomainErrorLike, toDiagnostic, toPublicAnalysis } from "./mappers/types.js";
|
|
12
13
|
import { RSToolWrapperClient, RSToolWrapperClientOptions, WrapperResponse } from "./wrapper/client.js";
|
|
13
14
|
export { type AgentConstituentaPatch, type AnalysisResult, type AnalyzeExpressionInput, type ApplySchemaPatchInput, type ApplySchemaPatchResult, type BasicBinding, CONTRACT_VERSION, type ConstituentaDraft, type ConstituentaState, type CstDiagnostic, CstType, type Diagnostic, DiagnosticKind, type DiagnosticSeverity, type DomainAnalysisLike, type DomainErrorLike, EvalStatus, type EvaluateInput, type EvaluationResult, type ExportFormat, type ExportPortalInput, type ExportPortalResult, type ImportDataKind, type ListDiagnosticsFilters, type ModelValueState, PORTAL_JSON_CONTRACT_VERSION, type PortalExportKind, type PortalImportMetadata, type PortalModelImportData, type PortalRsformDetails, type PortalSchemaConstituenta, type PortalSchemaImportData, type PortalTermForm, RSDiagnosticCode, RSErrorCode, RSToolAgent, type RSToolAgentContract, type RSToolAgentOptions, type RSToolValue, RSToolWrapperClient, type RSToolWrapperClientOptions, type RecalculateModelResult, type SessionHandle, type SessionModelState, type SessionRevision, type SessionState, type SessionStateDetail, type SessionStateResult, type SessionSummary, type SessionSummaryItem, type SetConstituentaValueInput, type SetModelValuesInput, type SynthesisSubstitution, type SynthesizeInput, type SynthesizeResult, ValueClass, type WrapperResponse, toDiagnostic, toPublicAnalysis };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { toDiagnostic, toPublicAnalysis } from "./mappers/types.js";
|
|
2
2
|
import { CstType, EvalStatus, RSErrorCode, ValueClass } from "./models/common.js";
|
|
3
3
|
import { DiagnosticKind, RSDiagnosticCode } from "./models/diagnostic.js";
|
|
4
|
-
import { r as PORTAL_JSON_CONTRACT_VERSION, t as RSToolAgent } from "./models-
|
|
4
|
+
import { r as PORTAL_JSON_CONTRACT_VERSION, t as RSToolAgent } from "./models-D06g8LId.js";
|
|
5
5
|
import { CONTRACT_VERSION } from "./models/tool-contract.js";
|
|
6
6
|
import { RSToolWrapperClient } from "./wrapper/client.js";
|
|
7
7
|
export { CONTRACT_VERSION, CstType, DiagnosticKind, EvalStatus, PORTAL_JSON_CONTRACT_VERSION, RSDiagnosticCode, RSErrorCode, RSToolAgent, RSToolWrapperClient, ValueClass, toDiagnostic, toPublicAnalysis };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as SetConstituentaValueInput, i as SessionModelState, r as RecalculateModelResult } from "../model-value-
|
|
2
|
-
import { r as SessionState } from "../session-
|
|
3
|
-
import { i as EvaluationResult } from "../evaluation-
|
|
1
|
+
import { a as SetConstituentaValueInput, i as SessionModelState, r as RecalculateModelResult } from "../model-value-C0QA-ji2.js";
|
|
2
|
+
import { r as SessionState } from "../session-OaLqLq0H.js";
|
|
3
|
+
import { i as EvaluationResult } from "../evaluation-BHv2xNwf.js";
|
|
4
|
+
import "../models/index.js";
|
|
4
5
|
import { CstType } from "@rsconcept/domain/library/rsform";
|
|
5
6
|
import { RSEngine } from "@rsconcept/domain/library/rsengine";
|
|
6
|
-
|
|
7
7
|
//#region src/mappers/model-adapter.d.ts
|
|
8
8
|
declare class ModelAdapter {
|
|
9
9
|
setConstituentaValue(session: SessionState, input: SetConstituentaValueInput): Promise<SessionModelState>;
|
|
@@ -15,6 +15,11 @@ declare class ModelAdapter {
|
|
|
15
15
|
evaluateConstituenta(session: SessionState, constituentId: number): EvaluationResult;
|
|
16
16
|
recalculateModel(session: SessionState): RecalculateModelResult;
|
|
17
17
|
createEngine(session: SessionState): RSEngine;
|
|
18
|
+
/**
|
|
19
|
+
* Computes values of inferrable constituents referenced by a scratch expression (directly or
|
|
20
|
+
* through `F#` / `P#` bodies). A fresh engine only holds interpreted `X#` / `C#` / `S#` values.
|
|
21
|
+
*/
|
|
22
|
+
private prepareReferencedValues;
|
|
18
23
|
private validateSetInput;
|
|
19
24
|
}
|
|
20
25
|
//#endregion
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { r as expressionDiagnostic, t as DiagnosticKind } from "../diagnostic-assembly-B-
|
|
2
|
-
import { t as buildRSFormFromSession } from "../rsform-builder-
|
|
1
|
+
import { r as expressionDiagnostic, t as DiagnosticKind } from "../diagnostic-assembly-B-r0NyHL.js";
|
|
2
|
+
import { t as buildRSFormFromSession } from "../rsform-builder-BlXEe5Ow.js";
|
|
3
3
|
import { EvalStatus } from "@rsconcept/domain/library/rsmodel";
|
|
4
4
|
import { isBaseSet } from "@rsconcept/domain/library/rsform-api";
|
|
5
5
|
import { isInferrable, isInterpretable, toBasicBinding, validateBasicBindingData, validateValueData } from "@rsconcept/domain/library/rsmodel-api";
|
|
6
|
+
import { extractGlobals } from "@rsconcept/domain/rslang/api";
|
|
7
|
+
import { normalizeValue } from "@rsconcept/domain/rslang/eval/value-api";
|
|
6
8
|
import { RSEngine } from "@rsconcept/domain/library/rsengine";
|
|
7
9
|
//#region src/mappers/model-adapter.ts
|
|
8
10
|
const SESSION_MODEL_ID = 0;
|
|
@@ -14,7 +16,11 @@ var ModelAdapter = class {
|
|
|
14
16
|
if (isBaseSet(frontendType)) {
|
|
15
17
|
const binding = toBasicBinding(input.value);
|
|
16
18
|
await engine.setBasicValue(input.target, binding);
|
|
17
|
-
} else
|
|
19
|
+
} else {
|
|
20
|
+
const value = structuredClone(input.value);
|
|
21
|
+
normalizeValue(value);
|
|
22
|
+
await engine.setStructureValue(input.target, value);
|
|
23
|
+
}
|
|
18
24
|
session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
19
25
|
return structuredClone(session.model);
|
|
20
26
|
}
|
|
@@ -31,7 +37,9 @@ var ModelAdapter = class {
|
|
|
31
37
|
return structuredClone(session.model);
|
|
32
38
|
}
|
|
33
39
|
evaluateExpression(session, expression, cstType) {
|
|
34
|
-
const
|
|
40
|
+
const engine = this.createEngine(session);
|
|
41
|
+
this.prepareReferencedValues(engine, session, expression);
|
|
42
|
+
const result = engine.evaluateExpression(expression, cstType);
|
|
35
43
|
const status = result.value === null ? result.errors.length > 0 ? EvalStatus.EVAL_FAIL : EvalStatus.EMPTY : EvalStatus.HAS_DATA;
|
|
36
44
|
return toPublicEvaluationResult(result.value, result.errors, result.iterations, result.cacheHits, status, expression);
|
|
37
45
|
}
|
|
@@ -63,6 +71,23 @@ var ModelAdapter = class {
|
|
|
63
71
|
engine.loadData(schema, model);
|
|
64
72
|
return engine;
|
|
65
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Computes values of inferrable constituents referenced by a scratch expression (directly or
|
|
76
|
+
* through `F#` / `P#` bodies). A fresh engine only holds interpreted `X#` / `C#` / `S#` values.
|
|
77
|
+
*/
|
|
78
|
+
prepareReferencedValues(engine, session, expression) {
|
|
79
|
+
const schema = engine.schema;
|
|
80
|
+
if (!schema) return;
|
|
81
|
+
const globals = extractGlobals(expression);
|
|
82
|
+
const referenced = session.items.filter((item) => globals.has(item.alias)).map((item) => item.id);
|
|
83
|
+
if (referenced.length === 0) return;
|
|
84
|
+
const required = /* @__PURE__ */ new Set([...referenced, ...schema.graph.expandAllInputs(referenced)]);
|
|
85
|
+
for (const cstID of schema.graph.topologicalOrder()) {
|
|
86
|
+
if (!required.has(cstID)) continue;
|
|
87
|
+
const cst = schema.cstByID.get(cstID);
|
|
88
|
+
if (cst && isInferrable(cst.cst_type)) engine.calculateCst(cstID);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
66
91
|
validateSetInput(session, input) {
|
|
67
92
|
const cst = session.items.find((item) => item.id === input.target);
|
|
68
93
|
if (!cst) throw new Error(`Unknown constituent: ${input.target}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-adapter.js","names":[],"sources":["../../src/mappers/model-adapter.ts"],"sourcesContent":["import { DiagnosticKind, expressionDiagnostic } from './diagnostic-assembly';\nimport { type RSErrorDescription, type Value } from '@rsconcept/domain/rslang';\nimport { isBaseSet } from '@rsconcept/domain/library/rsform-api';\nimport { CstType, type RSForm } from '@rsconcept/domain/library/rsform';\nimport { RSEngine, type RSEngineServices } from '@rsconcept/domain/library/rsengine';\nimport { type BasicBinding, EvalStatus, type RSModel } from '@rsconcept/domain/library/rsmodel';\nimport {\n isInferrable,\n isInterpretable,\n toBasicBinding,\n validateBasicBindingData,\n validateValueData\n} from '@rsconcept/domain/library/rsmodel-api';\n\nimport {\n type EvaluationResult,\n type RecalculateModelResult,\n type SessionModelState,\n type SessionState,\n type SetConstituentaValueInput\n} from '../models';\nimport { buildRSFormFromSession } from './rsform-builder';\n\nconst SESSION_MODEL_ID = 0;\n\nexport class ModelAdapter {\n public async setConstituentaValue(\n session: SessionState,\n input: SetConstituentaValueInput\n ): Promise<SessionModelState> {\n this.validateSetInput(session, input);\n const engine = this.createEngine(session);\n const cst = session.items.find(item => item.id === input.target)!;\n const frontendType = cst.cstType;\n\n if (isBaseSet(frontendType)) {\n const binding = toBasicBinding(input.value as Record<string | number, string>);\n await engine.setBasicValue(input.target, binding);\n } else {\n await engine.setStructureValue(input.target, input.value as Value);\n }\n session.updatedAt = new Date().toISOString();\n return structuredClone(session.model);\n }\n\n public async setConstituentaValues(\n session: SessionState,\n input: { items: SetConstituentaValueInput[] }\n ): Promise<SessionModelState> {\n for (const item of input.items) {\n await this.setConstituentaValue(session, item);\n }\n return structuredClone(session.model);\n }\n\n public async clearConstituentaValues(session: SessionState, ids: number[]): Promise<SessionModelState> {\n const engine = this.createEngine(session);\n for (const id of ids) {\n await engine.resetValue(id);\n session.updatedAt = new Date().toISOString();\n }\n return structuredClone(session.model);\n }\n\n public evaluateExpression(session: SessionState, expression: string, cstType: CstType): EvaluationResult {\n const engine = this.createEngine(session);\n const result = engine.evaluateExpression(expression, cstType);\n const status =\n result.value === null\n ? result.errors.length > 0\n ? EvalStatus.EVAL_FAIL\n : EvalStatus.EMPTY\n : EvalStatus.HAS_DATA;\n return toPublicEvaluationResult(\n result.value,\n result.errors,\n result.iterations,\n result.cacheHits,\n status,\n expression\n );\n }\n\n public evaluateConstituenta(session: SessionState, constituentId: number): EvaluationResult {\n const cst = session.items.find(item => item.id === constituentId);\n if (!cst) {\n throw new Error(`Unknown constituent: ${constituentId}`);\n }\n const engine = this.createEngine(session);\n const result = engine.calculateCst(constituentId);\n const status = engine.getCstStatus(constituentId);\n return toPublicEvaluationResult(\n result.value,\n result.errors,\n result.iterations,\n result.cacheHits,\n status,\n cst.definitionFormal,\n { constituentId: cst.id, alias: cst.alias }\n );\n }\n\n public recalculateModel(session: SessionState): RecalculateModelResult {\n const engine = this.createEngine(session);\n engine.recalculateAll();\n const items = session.items.map(item => ({\n id: item.id,\n alias: item.alias,\n value: engine.getCstValue(item.id) as number | number[] | null,\n status: engine.getCstStatus(item.id)\n }));\n return { items };\n }\n\n public createEngine(session: SessionState): RSEngine {\n const schema = buildRSFormFromSession(session);\n const model = buildRSModelFromSession(session);\n const engine = new RSEngine(SESSION_MODEL_ID, createInMemoryServices(session));\n engine.loadData(schema, model);\n return engine;\n }\n\n private validateSetInput(session: SessionState, input: SetConstituentaValueInput): void {\n const cst = session.items.find(item => item.id === input.target);\n if (!cst) {\n throw new Error(`Unknown constituent: ${input.target}`);\n }\n const frontendType = cst.cstType;\n if (!isInterpretable(frontendType)) {\n throw new Error(`Constituent ${cst.alias} is not interpretable`);\n }\n if (isInferrable(frontendType)) {\n throw new Error(`Constituent ${cst.alias} is inferrable and cannot be set directly`);\n }\n if (isBaseSet(frontendType)) {\n if (!validateBasicBindingData(input.value)) {\n throw new Error(`Invalid basic binding for ${cst.alias}`);\n }\n return;\n }\n if (!validateValueData(input.value)) {\n throw new Error(`Invalid structured value for ${cst.alias}`);\n }\n }\n}\n\nfunction createInMemoryServices(session: SessionState): RSEngineServices {\n return {\n setCstValue: async ({ data }) => {\n for (const item of data) {\n const entry = {\n id: item.target,\n type: item.type,\n value: item.data as Value | BasicBinding\n };\n const index = session.model.items.findIndex(existing => existing.id === item.target);\n if (index === -1) {\n session.model.items.push(entry);\n } else {\n session.model.items[index] = entry;\n }\n }\n },\n clearValues: async ({ data }) => {\n const ids = new Set(data.items);\n session.model.items = session.model.items.filter(item => !ids.has(item.id));\n }\n };\n}\n\nfunction buildRSModelFromSession(session: SessionState): RSModel {\n return {\n id: SESSION_MODEL_ID,\n schema: 0,\n editors: [],\n items: session.model.items.map(item => ({\n id: item.id,\n type: item.type,\n value: item.value as Value | BasicBinding\n }))\n } as unknown as RSModel;\n}\n\nfunction toPublicEvaluationResult(\n value: Value | null,\n errors: RSErrorDescription[],\n iterations: number,\n cacheHits: number,\n status: EvalStatus,\n expression: string,\n target?: { constituentId?: number; alias?: string }\n): EvaluationResult {\n const diagnostics = errors.map(error => ({\n ...expressionDiagnostic(error, expression, target),\n kind: DiagnosticKind.MODEL\n }));\n return {\n success: diagnostics.length === 0 && value !== null,\n value: value as EvaluationResult['value'],\n status,\n iterations,\n cacheHits,\n diagnostics\n };\n}\n"],"mappings":";;;;;;;AAuBA,MAAM,mBAAmB;AAEzB,IAAa,eAAb,MAA0B;CACxB,MAAa,qBACX,SACA,OAC4B;EAC5B,KAAK,iBAAiB,SAAS,KAAK;EACpC,MAAM,SAAS,KAAK,aAAa,OAAO;EAExC,MAAM,eADM,QAAQ,MAAM,MAAK,SAAQ,KAAK,OAAO,MAAM,MACpC,CAAA,CAAI;EAEzB,IAAI,UAAU,YAAY,GAAG;GAC3B,MAAM,UAAU,eAAe,MAAM,KAAwC;GAC7E,MAAM,OAAO,cAAc,MAAM,QAAQ,OAAO;EAClD,OACE,MAAM,OAAO,kBAAkB,MAAM,QAAQ,MAAM,KAAc;EAEnE,QAAQ,6BAAY,IAAI,KAAK,EAAC,CAAC,YAAY;EAC3C,OAAO,gBAAgB,QAAQ,KAAK;CACtC;CAEA,MAAa,sBACX,SACA,OAC4B;EAC5B,KAAK,MAAM,QAAQ,MAAM,OACvB,MAA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AC,IAAI,IAAI,KAAK,EAAE,CAAC;EAC5E;CACF;AACF;AAEA,SAAS,wBAAwB,SAAgC;CAC/D,OAAO;EACL,IAAI;EACJ,QAAQ;EACR,SAAS,CAAC;EACV,OAAO,QAAQ,MAAM,MAAM,KAAI,UAAS;GACtC,IAAI,KAAK;GACT,MAAM,KAAK;GACX,OAAO,KAAK;EACd,EAAE;CACJ;AACF;AAEA,SAAS,yBACP,OACA,QACA,YACA,WACA,QACA,YACA,QACkB;CAClB,MAAM,cAAc,OAAO,KAAI,WAAU;EACvC,GAAG,qBAAqB,OAAO,YAAY,MAAM;EACjD,MAAM,eAAe;CACvB,EAAE;CACF,OAAO;EACL,SAAS,YAAY,WAAW,KAAK,UAAU;EACxC;EACP;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"model-adapter.js","names":[],"sources":["../../src/mappers/model-adapter.ts"],"sourcesContent":["import { DiagnosticKind, expressionDiagnostic } from './diagnostic-assembly';\nimport { type RSErrorDescription, type Value } from '@rsconcept/domain/rslang';\nimport { extractGlobals } from '@rsconcept/domain/rslang/api';\nimport { normalizeValue } from '@rsconcept/domain/rslang/eval/value-api';\nimport { isBaseSet } from '@rsconcept/domain/library/rsform-api';\nimport { CstType, type RSForm } from '@rsconcept/domain/library/rsform';\nimport { RSEngine, type RSEngineServices } from '@rsconcept/domain/library/rsengine';\nimport { type BasicBinding, EvalStatus, type RSModel } from '@rsconcept/domain/library/rsmodel';\nimport {\n isInferrable,\n isInterpretable,\n toBasicBinding,\n validateBasicBindingData,\n validateValueData\n} from '@rsconcept/domain/library/rsmodel-api';\n\nimport {\n type EvaluationResult,\n type RecalculateModelResult,\n type SessionModelState,\n type SessionState,\n type SetConstituentaValueInput\n} from '../models';\nimport { buildRSFormFromSession } from './rsform-builder';\n\nconst SESSION_MODEL_ID = 0;\n\nexport class ModelAdapter {\n public async setConstituentaValue(\n session: SessionState,\n input: SetConstituentaValueInput\n ): Promise<SessionModelState> {\n this.validateSetInput(session, input);\n const engine = this.createEngine(session);\n const cst = session.items.find(item => item.id === input.target)!;\n const frontendType = cst.cstType;\n\n if (isBaseSet(frontendType)) {\n const binding = toBasicBinding(input.value as Record<string | number, string>);\n await engine.setBasicValue(input.target, binding);\n } else {\n // Set operations in the evaluator assume canonical form (sorted, deduplicated);\n // agents may pass elements in arbitrary order.\n const value = structuredClone(input.value) as Value;\n normalizeValue(value);\n await engine.setStructureValue(input.target, value);\n }\n session.updatedAt = new Date().toISOString();\n return structuredClone(session.model);\n }\n\n public async setConstituentaValues(\n session: SessionState,\n input: { items: SetConstituentaValueInput[] }\n ): Promise<SessionModelState> {\n for (const item of input.items) {\n await this.setConstituentaValue(session, item);\n }\n return structuredClone(session.model);\n }\n\n public async clearConstituentaValues(session: SessionState, ids: number[]): Promise<SessionModelState> {\n const engine = this.createEngine(session);\n for (const id of ids) {\n await engine.resetValue(id);\n session.updatedAt = new Date().toISOString();\n }\n return structuredClone(session.model);\n }\n\n public evaluateExpression(session: SessionState, expression: string, cstType: CstType): EvaluationResult {\n const engine = this.createEngine(session);\n this.prepareReferencedValues(engine, session, expression);\n const result = engine.evaluateExpression(expression, cstType);\n const status =\n result.value === null\n ? result.errors.length > 0\n ? EvalStatus.EVAL_FAIL\n : EvalStatus.EMPTY\n : EvalStatus.HAS_DATA;\n return toPublicEvaluationResult(\n result.value,\n result.errors,\n result.iterations,\n result.cacheHits,\n status,\n expression\n );\n }\n\n public evaluateConstituenta(session: SessionState, constituentId: number): EvaluationResult {\n const cst = session.items.find(item => item.id === constituentId);\n if (!cst) {\n throw new Error(`Unknown constituent: ${constituentId}`);\n }\n const engine = this.createEngine(session);\n const result = engine.calculateCst(constituentId);\n const status = engine.getCstStatus(constituentId);\n return toPublicEvaluationResult(\n result.value,\n result.errors,\n result.iterations,\n result.cacheHits,\n status,\n cst.definitionFormal,\n { constituentId: cst.id, alias: cst.alias }\n );\n }\n\n public recalculateModel(session: SessionState): RecalculateModelResult {\n const engine = this.createEngine(session);\n engine.recalculateAll();\n const items = session.items.map(item => ({\n id: item.id,\n alias: item.alias,\n value: engine.getCstValue(item.id) as number | number[] | null,\n status: engine.getCstStatus(item.id)\n }));\n return { items };\n }\n\n public createEngine(session: SessionState): RSEngine {\n const schema = buildRSFormFromSession(session);\n const model = buildRSModelFromSession(session);\n const engine = new RSEngine(SESSION_MODEL_ID, createInMemoryServices(session));\n engine.loadData(schema, model);\n return engine;\n }\n\n /**\n * Computes values of inferrable constituents referenced by a scratch expression (directly or\n * through `F#` / `P#` bodies). A fresh engine only holds interpreted `X#` / `C#` / `S#` values.\n */\n private prepareReferencedValues(engine: RSEngine, session: SessionState, expression: string): void {\n const schema = engine.schema;\n if (!schema) {\n return;\n }\n const globals = extractGlobals(expression);\n const referenced = session.items.filter(item => globals.has(item.alias)).map(item => item.id);\n if (referenced.length === 0) {\n return;\n }\n const required = new Set([...referenced, ...schema.graph.expandAllInputs(referenced)]);\n for (const cstID of schema.graph.topologicalOrder()) {\n if (!required.has(cstID)) {\n continue;\n }\n const cst = schema.cstByID.get(cstID);\n if (cst && isInferrable(cst.cst_type)) {\n engine.calculateCst(cstID);\n }\n }\n }\n\n private validateSetInput(session: SessionState, input: SetConstituentaValueInput): void {\n const cst = session.items.find(item => item.id === input.target);\n if (!cst) {\n throw new Error(`Unknown constituent: ${input.target}`);\n }\n const frontendType = cst.cstType;\n if (!isInterpretable(frontendType)) {\n throw new Error(`Constituent ${cst.alias} is not interpretable`);\n }\n if (isInferrable(frontendType)) {\n throw new Error(`Constituent ${cst.alias} is inferrable and cannot be set directly`);\n }\n if (isBaseSet(frontendType)) {\n if (!validateBasicBindingData(input.value)) {\n throw new Error(`Invalid basic binding for ${cst.alias}`);\n }\n return;\n }\n if (!validateValueData(input.value)) {\n throw new Error(`Invalid structured value for ${cst.alias}`);\n }\n }\n}\n\nfunction createInMemoryServices(session: SessionState): RSEngineServices {\n return {\n setCstValue: async ({ data }) => {\n for (const item of data) {\n const entry = {\n id: item.target,\n type: item.type,\n value: item.data as Value | BasicBinding\n };\n const index = session.model.items.findIndex(existing => existing.id === item.target);\n if (index === -1) {\n session.model.items.push(entry);\n } else {\n session.model.items[index] = entry;\n }\n }\n },\n clearValues: async ({ data }) => {\n const ids = new Set(data.items);\n session.model.items = session.model.items.filter(item => !ids.has(item.id));\n }\n };\n}\n\nfunction buildRSModelFromSession(session: SessionState): RSModel {\n return {\n id: SESSION_MODEL_ID,\n schema: 0,\n editors: [],\n items: session.model.items.map(item => ({\n id: item.id,\n type: item.type,\n value: item.value as Value | BasicBinding\n }))\n } as unknown as RSModel;\n}\n\nfunction toPublicEvaluationResult(\n value: Value | null,\n errors: RSErrorDescription[],\n iterations: number,\n cacheHits: number,\n status: EvalStatus,\n expression: string,\n target?: { constituentId?: number; alias?: string }\n): EvaluationResult {\n const diagnostics = errors.map(error => ({\n ...expressionDiagnostic(error, expression, target),\n kind: DiagnosticKind.MODEL\n }));\n return {\n success: diagnostics.length === 0 && value !== null,\n value: value as EvaluationResult['value'],\n status,\n iterations,\n cacheHits,\n diagnostics\n };\n}\n"],"mappings":";;;;;;;;;AAyBA,MAAM,mBAAmB;AAEzB,IAAa,eAAb,MAA0B;CACxB,MAAa,qBACX,SACA,OAC4B;EAC5B,KAAK,iBAAiB,SAAS,KAAK;EACpC,MAAM,SAAS,KAAK,aAAa,OAAO;EAExC,MAAM,eADM,QAAQ,MAAM,MAAK,SAAQ,KAAK,OAAO,MAAM,MACpC,CAAA,CAAI;EAEzB,IAAI,UAAU,YAAY,GAAG;GAC3B,MAAM,UAAU,eAAe,MAAM,KAAwC;GAC7E,MAAM,OAAO,cAAc,MAAM,QAAQ,OAAO;EAClD,OAAO;GAGL,MAAM,QAAQ,gBAAgB,MAAM,KAAK;GACzC,eAAe,KAAK;GACpB,MAAM,OAAO,kBAAkB,MAAM,QAAQ,KAAK;EACpD;EACA,QAAQ,6BAAY,IAAI,KAAK,EAAC,CAAC,YAAY;EAC3C,OAAO,gBAAgB,QAAQ,KAAK;CACtC;CA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agnostic-
|
|
2
|
-
import { t as AnalysisResult } from "../analysis-
|
|
3
|
-
import { o as ConstituentaDraft, s as ConstituentaState } from "../constituenta-
|
|
4
|
-
import { r as SessionState } from "../session-
|
|
1
|
+
import { a as Diagnostic } from "../diagnostic-CtxXifJY.js";
|
|
2
|
+
import { t as AnalysisResult } from "../analysis-C7GrmB17.js";
|
|
3
|
+
import { o as ConstituentaDraft, s as ConstituentaState } from "../constituenta-CwJogNKY.js";
|
|
4
|
+
import { r as SessionState } from "../session-OaLqLq0H.js";
|
|
5
|
+
import "../models/index.js";
|
|
5
6
|
import { RSForm } from "@rsconcept/domain/library/rsform";
|
|
6
7
|
import { RSLangAnalyzer } from "@rsconcept/domain/rslang";
|
|
7
|
-
|
|
8
8
|
//#region src/mappers/schema-adapter.d.ts
|
|
9
9
|
declare class SchemaAdapter {
|
|
10
10
|
analyzeAgainstSession(session: SessionState, draft: ConstituentaDraft): {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toPublicAnalysis } from "./types.js";
|
|
2
|
-
import { t as buildRSFormFromSession } from "../rsform-builder-
|
|
2
|
+
import { t as buildRSFormFromSession } from "../rsform-builder-BlXEe5Ow.js";
|
|
3
3
|
import { getAnalysisFor } from "@rsconcept/domain/library/rsform-api";
|
|
4
4
|
//#region src/mappers/schema-adapter.ts
|
|
5
5
|
var SchemaAdapter = class {
|
package/dist/mappers/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as Diagnostic, s as DiagnosticTarget } from "../diagnostic-
|
|
2
|
-
import { t as AnalysisResult } from "../analysis-
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { a as Diagnostic, s as DiagnosticTarget } from "../diagnostic-CtxXifJY.js";
|
|
2
|
+
import { t as AnalysisResult } from "../analysis-C7GrmB17.js";
|
|
3
|
+
import "../models/index.js";
|
|
4
|
+
import { RSErrorDescription, ValueClass } from "@rsconcept/domain/rslang";
|
|
5
5
|
//#region src/mappers/types.d.ts
|
|
6
6
|
/** Minimal domain error shape before mapping to {@link Diagnostic}. */
|
|
7
7
|
interface DomainErrorLike {
|
|
@@ -9,6 +9,7 @@ interface DomainErrorLike {
|
|
|
9
9
|
from: number;
|
|
10
10
|
to: number;
|
|
11
11
|
params?: readonly string[];
|
|
12
|
+
stack?: RSErrorDescription['stack'];
|
|
12
13
|
}
|
|
13
14
|
/** Minimal domain analysis shape before mapping to {@link AnalysisResult}. */
|
|
14
15
|
interface DomainAnalysisLike {
|
package/dist/mappers/types.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as expressionDiagnostic } from "../diagnostic-assembly-B-
|
|
1
|
+
import { r as expressionDiagnostic } from "../diagnostic-assembly-B-r0NyHL.js";
|
|
2
2
|
//#region src/mappers/types.ts
|
|
3
3
|
/** Map a domain parser/semantic error to the public diagnostic shape. */
|
|
4
4
|
function toDiagnostic(error, expression, target) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/mappers/types.ts"],"sourcesContent":["import { DiagnosticKind, type DiagnosticTarget, expressionDiagnostic } from './diagnostic-assembly';\nimport { type RSErrorDescription, type ValueClass } from '@rsconcept/domain/rslang';\n\nimport { type AnalysisResult, type Diagnostic } from '../models';\n\n/** Minimal domain error shape before mapping to {@link Diagnostic}. */\nexport interface DomainErrorLike {\n code: number;\n from: number;\n to: number;\n params?: readonly string[];\n}\n\n/** Minimal domain analysis shape before mapping to {@link AnalysisResult}. */\nexport interface DomainAnalysisLike {\n success: boolean;\n type: Record<string, unknown> | null;\n valueClass: ValueClass | null;\n errors: DomainErrorLike[];\n}\n\n/** Map a domain parser/semantic error to the public diagnostic shape. */\nexport function toDiagnostic(error: DomainErrorLike, expression: string, target?: DiagnosticTarget): Diagnostic {\n return expressionDiagnostic(error as RSErrorDescription, expression, target);\n}\n\n/** Map a domain analysis result to the public {@link AnalysisResult} shape. */\nexport function toPublicAnalysis(\n analysis: DomainAnalysisLike,\n expression: string,\n target?: DiagnosticTarget\n): AnalysisResult {\n return {\n success: analysis.success,\n type: analysis.type,\n valueClass: analysis.valueClass,\n diagnostics: analysis.errors.map(error => expressionDiagnostic(error as RSErrorDescription, expression, target))\n };\n}\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/mappers/types.ts"],"sourcesContent":["import { DiagnosticKind, type DiagnosticTarget, expressionDiagnostic } from './diagnostic-assembly';\nimport { type RSErrorDescription, type ValueClass } from '@rsconcept/domain/rslang';\n\nimport { type AnalysisResult, type Diagnostic } from '../models';\n\n/** Minimal domain error shape before mapping to {@link Diagnostic}. */\nexport interface DomainErrorLike {\n code: number;\n from: number;\n to: number;\n params?: readonly string[];\n stack?: RSErrorDescription['stack'];\n}\n\n/** Minimal domain analysis shape before mapping to {@link AnalysisResult}. */\nexport interface DomainAnalysisLike {\n success: boolean;\n type: Record<string, unknown> | null;\n valueClass: ValueClass | null;\n errors: DomainErrorLike[];\n}\n\n/** Map a domain parser/semantic error to the public diagnostic shape. */\nexport function toDiagnostic(error: DomainErrorLike, expression: string, target?: DiagnosticTarget): Diagnostic {\n return expressionDiagnostic(error as RSErrorDescription, expression, target);\n}\n\n/** Map a domain analysis result to the public {@link AnalysisResult} shape. */\nexport function toPublicAnalysis(\n analysis: DomainAnalysisLike,\n expression: string,\n target?: DiagnosticTarget\n): AnalysisResult {\n return {\n success: analysis.success,\n type: analysis.type,\n valueClass: analysis.valueClass,\n diagnostics: analysis.errors.map(error => expressionDiagnostic(error as RSErrorDescription, expression, target))\n };\n}\n"],"mappings":";;;AAuBA,SAAgB,aAAa,OAAwB,YAAoB,QAAuC;CAC9G,OAAO,qBAAqB,OAA6B,YAAY,MAAM;AAC7E;;AAGA,SAAgB,iBACd,UACA,YACA,QACgB;CAChB,OAAO;EACL,SAAS,SAAS;EAClB,MAAM,SAAS;EACf,YAAY,SAAS;EACrB,aAAa,SAAS,OAAO,KAAI,UAAS,qBAAqB,OAA6B,YAAY,MAAM,CAAC;CACjH;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { a as RSToolValue, r as EvalStatus, t as BasicBinding } from "./common-
|
|
2
|
-
|
|
1
|
+
import { a as RSToolValue, r as EvalStatus, t as BasicBinding } from "./common-oafVB-wX.js";
|
|
3
2
|
//#region src/models/model-value.d.ts
|
|
4
3
|
/** Model value for one constituent. */
|
|
5
4
|
interface ModelValueState {
|
|
@@ -43,4 +42,4 @@ interface RecalculateModelResult {
|
|
|
43
42
|
}
|
|
44
43
|
//#endregion
|
|
45
44
|
export { SetConstituentaValueInput as a, SessionModelState as i, ModelValueState as n, SetConstituentaValuesInput as o, RecalculateModelResult as r, SetModelValuesInput as s, ClearConstituentaValuesInput as t };
|
|
46
|
-
//# sourceMappingURL=model-value-
|
|
45
|
+
//# sourceMappingURL=model-value-C0QA-ji2.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SessionStateDetail, c as SessionSummaryItem, d as SynthesizeResult, i as RestoreOrderResult, l as SynthesisSubstitution, n as ApplySchemaPatchInput, o as SessionStateResult, r as ApplySchemaPatchResult, s as SessionSummary, t as AgentConstituentaPatch, u as SynthesizeInput } from "../agent-workflow-
|
|
1
|
+
import { a as SessionStateDetail, c as SessionSummaryItem, d as SynthesizeResult, i as RestoreOrderResult, l as SynthesisSubstitution, n as ApplySchemaPatchInput, o as SessionStateResult, r as ApplySchemaPatchResult, s as SessionSummary, t as AgentConstituentaPatch, u as SynthesizeInput } from "../agent-workflow-BqEC_Foh.js";
|
|
2
2
|
export { AgentConstituentaPatch, ApplySchemaPatchInput, ApplySchemaPatchResult, RestoreOrderResult, SessionStateDetail, SessionStateResult, SessionSummary, SessionSummaryItem, SynthesisSubstitution, SynthesizeInput, SynthesizeResult };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as AnalyzeExpressionInput, t as AnalysisResult } from "../analysis-
|
|
1
|
+
import { n as AnalyzeExpressionInput, t as AnalysisResult } from "../analysis-C7GrmB17.js";
|
|
2
2
|
export { AnalysisResult, AnalyzeExpressionInput };
|
package/dist/models/common.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RSToolValue, i as RSErrorCode, n as CstType, o as ValueClass, r as EvalStatus, t as BasicBinding } from "../common-
|
|
1
|
+
import { a as RSToolValue, i as RSErrorCode, n as CstType, o as ValueClass, r as EvalStatus, t as BasicBinding } from "../common-oafVB-wX.js";
|
|
2
2
|
export { type BasicBinding, CstType, EvalStatus, RSErrorCode, RSToolValue, ValueClass };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as ApplyConstituentsResult, i as ApplyConstituentsMode, n as AddOrUpdateConstituentaResult, o as ConstituentaDraft, r as ApplyConstituentsInput, s as ConstituentaState, t as AddOrUpdateConstituentaInput } from "../constituenta-
|
|
1
|
+
import { a as ApplyConstituentsResult, i as ApplyConstituentsMode, n as AddOrUpdateConstituentaResult, o as ConstituentaDraft, r as ApplyConstituentsInput, s as ConstituentaState, t as AddOrUpdateConstituentaInput } from "../constituenta-CwJogNKY.js";
|
|
2
2
|
export { AddOrUpdateConstituentaInput, AddOrUpdateConstituentaResult, ApplyConstituentsInput, ApplyConstituentsMode, ApplyConstituentsResult, ConstituentaDraft, ConstituentaState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Diagnostic, c as expandCstDiagnostic, d as getDiagnosticSeverity, f as modelStatusDiagnostic, i as RSDiagnosticCode, l as expressionDiagnostic, n as DiagnosticKind, o as DiagnosticSeverity, r as ListDiagnosticsFilters, s as DiagnosticTarget, t as CstDiagnostic, u as getDiagnosticName } from "../diagnostic-
|
|
1
|
+
import { a as Diagnostic, c as expandCstDiagnostic, d as getDiagnosticSeverity, f as modelStatusDiagnostic, i as RSDiagnosticCode, l as expressionDiagnostic, n as DiagnosticKind, o as DiagnosticSeverity, r as ListDiagnosticsFilters, s as DiagnosticTarget, t as CstDiagnostic, u as getDiagnosticName } from "../diagnostic-CtxXifJY.js";
|
|
2
2
|
export { type CstDiagnostic, type Diagnostic, DiagnosticKind, type DiagnosticSeverity, type DiagnosticTarget, ListDiagnosticsFilters, RSDiagnosticCode, expandCstDiagnostic, expressionDiagnostic, getDiagnosticName, getDiagnosticSeverity, modelStatusDiagnostic };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as getDiagnosticSeverity, i as getDiagnosticName, n as expandCstDiagnostic, o as modelStatusDiagnostic, r as expressionDiagnostic } from "../diagnostic-assembly-B-
|
|
1
|
+
import { a as getDiagnosticSeverity, i as getDiagnosticName, n as expandCstDiagnostic, o as modelStatusDiagnostic, r as expressionDiagnostic } from "../diagnostic-assembly-B-r0NyHL.js";
|
|
2
2
|
import { DiagnosticKind, RSDiagnosticCode } from "@rsconcept/domain/library";
|
|
3
3
|
export { DiagnosticKind, RSDiagnosticCode, expandCstDiagnostic, expressionDiagnostic, getDiagnosticName, getDiagnosticSeverity, modelStatusDiagnostic };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as EvaluationResult, n as EvaluateExpressionInput, r as EvaluateInput, t as EvaluateConstituentaInput } from "../evaluation-
|
|
1
|
+
import { i as EvaluationResult, n as EvaluateExpressionInput, r as EvaluateInput, t as EvaluateConstituentaInput } from "../evaluation-BHv2xNwf.js";
|
|
2
2
|
export { EvaluateConstituentaInput, EvaluateExpressionInput, EvaluateInput, EvaluationResult };
|
package/dist/models/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as Diagnostic, i as RSDiagnosticCode, n as DiagnosticKind, o as DiagnosticSeverity, r as ListDiagnosticsFilters, t as CstDiagnostic } from "../diagnostic-
|
|
2
|
-
import { a as RSToolValue, i as RSErrorCode, n as CstType, o as ValueClass, r as EvalStatus, t as BasicBinding } from "../common-
|
|
3
|
-
import { n as AnalyzeExpressionInput, t as AnalysisResult } from "../analysis-
|
|
4
|
-
import { i as ApplyConstituentsMode, o as ConstituentaDraft, s as ConstituentaState } from "../constituenta-
|
|
5
|
-
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, r as RecalculateModelResult, s as SetModelValuesInput } from "../model-value-
|
|
6
|
-
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "../session-
|
|
7
|
-
import { a as SessionStateDetail, c as SessionSummaryItem, d as SynthesizeResult, i as RestoreOrderResult, l as SynthesisSubstitution, n as ApplySchemaPatchInput, o as SessionStateResult, r as ApplySchemaPatchResult, s as SessionSummary, t as AgentConstituentaPatch, u as SynthesizeInput } from "../agent-workflow-
|
|
8
|
-
import { i as EvaluationResult, r as EvaluateInput } from "../evaluation-
|
|
9
|
-
import { a as ExportPortalInput, c as PortalExportKind, d as PortalModelImportData, f as PortalRsformDetails, g as portalItemToDraft, h as PortalTermForm, i as ExportFormat, l as PORTAL_JSON_CONTRACT_VERSION, m as PortalSchemaImportData, n as RSToolAgentContract, o as ExportPortalResult, p as PortalSchemaConstituenta, r as RSToolAgentOptions, s as ImportDataKind, t as CONTRACT_VERSION, u as PortalImportMetadata } from "../tool-contract-
|
|
10
|
-
import { t as RSToolAgent } from "../rstool-agent-
|
|
1
|
+
import { a as Diagnostic, i as RSDiagnosticCode, n as DiagnosticKind, o as DiagnosticSeverity, r as ListDiagnosticsFilters, t as CstDiagnostic } from "../diagnostic-CtxXifJY.js";
|
|
2
|
+
import { a as RSToolValue, i as RSErrorCode, n as CstType, o as ValueClass, r as EvalStatus, t as BasicBinding } from "../common-oafVB-wX.js";
|
|
3
|
+
import { n as AnalyzeExpressionInput, t as AnalysisResult } from "../analysis-C7GrmB17.js";
|
|
4
|
+
import { i as ApplyConstituentsMode, o as ConstituentaDraft, s as ConstituentaState } from "../constituenta-CwJogNKY.js";
|
|
5
|
+
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, r as RecalculateModelResult, s as SetModelValuesInput } from "../model-value-C0QA-ji2.js";
|
|
6
|
+
import { n as SessionRevision, r as SessionState, t as SessionHandle } from "../session-OaLqLq0H.js";
|
|
7
|
+
import { a as SessionStateDetail, c as SessionSummaryItem, d as SynthesizeResult, i as RestoreOrderResult, l as SynthesisSubstitution, n as ApplySchemaPatchInput, o as SessionStateResult, r as ApplySchemaPatchResult, s as SessionSummary, t as AgentConstituentaPatch, u as SynthesizeInput } from "../agent-workflow-BqEC_Foh.js";
|
|
8
|
+
import { i as EvaluationResult, r as EvaluateInput } from "../evaluation-BHv2xNwf.js";
|
|
9
|
+
import { a as ExportPortalInput, c as PortalExportKind, d as PortalModelImportData, f as PortalRsformDetails, g as portalItemToDraft, h as PortalTermForm, i as ExportFormat, l as PORTAL_JSON_CONTRACT_VERSION, m as PortalSchemaImportData, n as RSToolAgentContract, o as ExportPortalResult, p as PortalSchemaConstituenta, r as RSToolAgentOptions, s as ImportDataKind, t as CONTRACT_VERSION, u as PortalImportMetadata } from "../tool-contract-ZVyh7hhp.js";
|
|
10
|
+
import { t as RSToolAgent } from "../rstool-agent-DLq0mtym.js";
|
|
11
11
|
export { type AgentConstituentaPatch, type AnalysisResult, type AnalyzeExpressionInput, type ApplyConstituentsMode, type ApplySchemaPatchInput, type ApplySchemaPatchResult, type BasicBinding, CONTRACT_VERSION, type ConstituentaDraft, type ConstituentaState, type CstDiagnostic, CstType, type Diagnostic, DiagnosticKind, type DiagnosticSeverity, EvalStatus, type EvaluateInput, type EvaluationResult, type ExportFormat, type ExportPortalInput, type ExportPortalResult, type ImportDataKind, type ListDiagnosticsFilters, type ModelValueState, PORTAL_JSON_CONTRACT_VERSION, type PortalExportKind, type PortalImportMetadata, type PortalModelImportData, type PortalRsformDetails, type PortalSchemaConstituenta, type PortalSchemaImportData, type PortalTermForm, RSDiagnosticCode, RSErrorCode, RSToolAgent, type RSToolAgentContract, type RSToolAgentOptions, type RSToolValue, type RecalculateModelResult, type RestoreOrderResult, type SessionHandle, type SessionModelState, type SessionRevision, type SessionState, type SessionStateDetail, type SessionStateResult, type SessionSummary, type SessionSummaryItem, type SetConstituentaValueInput, type SetModelValuesInput, type SynthesisSubstitution, type SynthesizeInput, type SynthesizeResult, ValueClass, portalItemToDraft };
|
package/dist/models/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CstType, EvalStatus, RSErrorCode, ValueClass } from "./common.js";
|
|
2
2
|
import { DiagnosticKind, RSDiagnosticCode } from "./diagnostic.js";
|
|
3
|
-
import { i as portalItemToDraft, r as PORTAL_JSON_CONTRACT_VERSION, t as RSToolAgent } from "../models-
|
|
3
|
+
import { i as portalItemToDraft, r as PORTAL_JSON_CONTRACT_VERSION, t as RSToolAgent } from "../models-D06g8LId.js";
|
|
4
4
|
import { CONTRACT_VERSION } from "./tool-contract.js";
|
|
5
5
|
export { CONTRACT_VERSION, CstType, DiagnosticKind, EvalStatus, PORTAL_JSON_CONTRACT_VERSION, RSDiagnosticCode, RSErrorCode, RSToolAgent, ValueClass, portalItemToDraft };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, o as SetConstituentaValuesInput, r as RecalculateModelResult, s as SetModelValuesInput, t as ClearConstituentaValuesInput } from "../model-value-
|
|
1
|
+
import { a as SetConstituentaValueInput, i as SessionModelState, n as ModelValueState, o as SetConstituentaValuesInput, r as RecalculateModelResult, s as SetModelValuesInput, t as ClearConstituentaValuesInput } from "../model-value-C0QA-ji2.js";
|
|
2
2
|
export { ClearConstituentaValuesInput, ModelValueState, RecalculateModelResult, SessionModelState, SetConstituentaValueInput, SetConstituentaValuesInput, SetModelValuesInput };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as RSToolAgent } from "../rstool-agent-
|
|
1
|
+
import { t as RSToolAgent } from "../rstool-agent-DLq0mtym.js";
|
|
2
2
|
export { RSToolAgent };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as RSToolAgent } from "../models-
|
|
1
|
+
import { t as RSToolAgent } from "../models-D06g8LId.js";
|
|
2
2
|
export { RSToolAgent };
|
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-OaLqLq0H.js";
|
|
2
2
|
export { SessionHandle, SessionRevision, SessionState };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as RSToolAgentContract, r as RSToolAgentOptions, t as CONTRACT_VERSION } from "../tool-contract-
|
|
1
|
+
import { n as RSToolAgentContract, r as RSToolAgentOptions, t as CONTRACT_VERSION } from "../tool-contract-ZVyh7hhp.js";
|
|
2
2
|
export { CONTRACT_VERSION, RSToolAgentContract, RSToolAgentOptions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-contract.js","names":[],"sources":["../../src/models/tool-contract.ts"],"sourcesContent":["import {\n type ApplySchemaPatchInput,\n type ApplySchemaPatchResult,\n type RestoreOrderResult,\n type SessionStateDetail,\n type SessionStateResult,\n type SynthesizeInput,\n type SynthesizeResult\n} from './agent-workflow';\nimport { type AnalysisResult, type AnalyzeExpressionInput } from './analysis';\nimport { type Diagnostic, type ListDiagnosticsFilters } from './diagnostic';\nimport { type EvaluateInput, type EvaluationResult } from './evaluation';\nimport { type ExportPortalInput, type ExportPortalResult, type ImportDataKind } from './import-export';\nimport { type RecalculateModelResult, type SessionModelState, type SetModelValuesInput } from './model-value';\nimport { type SessionHandle, type SessionRevision, type SessionState } from './session';\n\n/** Agent-visible contract version; bump on breaking API changes. */\nexport const CONTRACT_VERSION = '3.
|
|
1
|
+
{"version":3,"file":"tool-contract.js","names":[],"sources":["../../src/models/tool-contract.ts"],"sourcesContent":["import {\n type ApplySchemaPatchInput,\n type ApplySchemaPatchResult,\n type RestoreOrderResult,\n type SessionStateDetail,\n type SessionStateResult,\n type SynthesizeInput,\n type SynthesizeResult\n} from './agent-workflow';\nimport { type AnalysisResult, type AnalyzeExpressionInput } from './analysis';\nimport { type Diagnostic, type ListDiagnosticsFilters } from './diagnostic';\nimport { type EvaluateInput, type EvaluationResult } from './evaluation';\nimport { type ExportPortalInput, type ExportPortalResult, type ImportDataKind } from './import-export';\nimport { type RecalculateModelResult, type SessionModelState, type SetModelValuesInput } from './model-value';\nimport { type SessionHandle, type SessionRevision, type SessionState } from './session';\n\n/** Agent-visible contract version; bump on breaking API changes. */\nexport const CONTRACT_VERSION = '3.3.0';\n\n/** Options for constructing an {@link RSToolAgent}. */\nexport interface RSToolAgentOptions {\n /** When set, sessions are persisted to this directory and survive process restarts. */\n persistenceDir?: string;\n}\n\n/**\n * Public method surface of {@link RSToolAgent}.\n *\n * Each method accepts an optional `sessionId`; when omitted, the current session is used\n * (or a new one is created where noted).\n */\nexport interface RSToolAgentContract {\n /** Current contract version string (same as {@link CONTRACT_VERSION}). */\n readonly contractVersion: string;\n\n /** Return the current session, or create one with optional `initial` metadata. */\n ensureSession(initial?: Partial<SessionState>): SessionHandle;\n\n /** Create a new session and make it current. */\n createSession(initial?: Partial<SessionState>): SessionHandle;\n\n /** Return the current session handle, or `null` when none is active. */\n getCurrentSession(): SessionHandle | null;\n\n /** Switch the active session; throws when `sessionId` is unknown. */\n setCurrentSession(sessionId: string): SessionHandle;\n\n /** Apply constituent patches to the schema (analyze, merge, optionally commit). */\n applySchemaPatch(input: ApplySchemaPatchInput, sessionId?: string): ApplySchemaPatchResult;\n\n /** Return session summary (default) or full cloned state when `detail` is `'full'`. */\n getSessionState(detail?: SessionStateDetail, sessionId?: string): SessionStateResult;\n\n /** List diagnostics for the session, optionally filtered by constituent or kind. */\n listDiagnostics(filters?: ListDiagnosticsFilters, sessionId?: string): Diagnostic[];\n\n /** Parse and type-check an RSLang expression against the current schema context. */\n analyzeExpression(input: AnalyzeExpressionInput, sessionId?: string): AnalysisResult;\n\n /** Record a revision checkpoint with an optional message. */\n commitStep(message?: string, sessionId?: string): SessionRevision;\n\n /** Export the session as a JSON string (state + diagnostics). */\n exportSession(sessionId?: string): string;\n\n /** Export schema or model payload in Portal JSON format. */\n exportPortal(input: ExportPortalInput, sessionId?: string): ExportPortalResult;\n\n /**\n * Import a session export or Portal JSON payload and make the new session current.\n *\n * When `kind` is `'auto'`, the payload shape is detected automatically.\n */\n importData(payload: string | object, kind?: ImportDataKind): SessionHandle;\n\n /** Set or clear model values for constituents; returns the updated model state. */\n setModelValues(input: SetModelValuesInput, sessionId?: string): Promise<SessionModelState>;\n\n /** Return a deep clone of the session model state. */\n getModelState(sessionId?: string): SessionModelState;\n\n /**\n * Evaluate a stored constituent or a scratch expression.\n *\n * Provide `constituentId`, or both `expression` and `cstType`.\n */\n evaluate(input: EvaluateInput, sessionId?: string): EvaluationResult;\n\n /** Recompute derived model values for all constituents. */\n recalculateModel(sessionId?: string): RecalculateModelResult;\n\n /**\n * Restore declaration order: formal topology, semantic clusters when ready,\n * otherwise stable against type/kernel preferred ranks.\n */\n restoreOrder(sessionId?: string): RestoreOrderResult;\n\n /**\n * Synthesis by embedding: merge constituents from another session into the receiver,\n * then apply an identification table.\n */\n synthesize(input: SynthesizeInput, sessionId?: string): SynthesizeResult;\n}\n"],"mappings":";;AAiBA,MAAa,mBAAmB"}
|