@rslsp1/fa-app-tools 7.2.0 → 7.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/dist/szenen.mjs CHANGED
@@ -63,8 +63,10 @@ import {
63
63
  checkSzenenBatchOrigin,
64
64
  checkTitle,
65
65
  checkWriteDraftInput,
66
+ claimWon,
66
67
  collectImageBatches,
67
68
  collectImageGenerationOrders,
69
+ collectImageJobs,
68
70
  collectPromptRuns,
69
71
  collectSceneDerivationRecoveries,
70
72
  collectSceneDerivations,
@@ -86,6 +88,7 @@ import {
86
88
  createHfImageLibrary,
87
89
  createHfImageStore,
88
90
  createImageGenerationPort,
91
+ createImageJobPort,
89
92
  createSimulationSceneDerivationPort,
90
93
  createSimulationTextGenerationPort,
91
94
  derivationPoliciesOf,
@@ -100,6 +103,7 @@ import {
100
103
  findExecutableImageModel,
101
104
  findImageBatch,
102
105
  findImageGenerationOrder,
106
+ findImageJob,
103
107
  findPromptRun,
104
108
  findSceneDerivation,
105
109
  findSceneDerivationRecovery,
@@ -108,6 +112,7 @@ import {
108
112
  formatSeedListe,
109
113
  freezeDraftChain,
110
114
  freezeSceneWorkingState,
115
+ generationBatchIdOf,
111
116
  gesamtHerkunft,
112
117
  getSzenenSchemas,
113
118
  gruppiereZuItems,
@@ -119,13 +124,17 @@ import {
119
124
  istSzenenSnapshotDatei,
120
125
  istZipDatei,
121
126
  itemIdForRun,
127
+ itemsAusBestand,
128
+ jobsForPromptRun,
122
129
  ladeVorschauen,
123
130
  leseBilderAusZip,
124
131
  linkFor,
132
+ locatorAus,
125
133
  locatorTeile,
126
134
  logRevisionOf,
127
135
  mergeSnapshotAndPending,
128
136
  mergeSzenenBatchOrigin,
137
+ mimeTypAus,
129
138
  mitDefaultVorlage,
130
139
  noticeFor,
131
140
  ordersForPromptRun,
@@ -166,7 +175,7 @@ import {
166
175
  validateElementVersion,
167
176
  validatePayload,
168
177
  withReference
169
- } from "./chunk-5QA6DTJ6.mjs";
178
+ } from "./chunk-HUGUH4VB.mjs";
170
179
  import {
171
180
  ContractViolation,
172
181
  STYLE_PAYLOAD,
@@ -1650,6 +1659,120 @@ function checkSceneDerivationRecoveryRecord(candidate) {
1650
1659
  }
1651
1660
  return { ok: true };
1652
1661
  }
1662
+
1663
+ // src/lib/szenen/scenePromptOperation.ts
1664
+ var MCP_CLIENT_PROVIDER = "mcp_client";
1665
+ var UNVERIFIED_MODEL_ID = "mcp-client-unspecified";
1666
+ var istText2 = (wert) => typeof wert === "string" && wert.trim().length > 0;
1667
+ function collectPromptOperations(events) {
1668
+ const nachId = /* @__PURE__ */ new Map();
1669
+ for (const event of events) {
1670
+ if (event.type !== SZENEN_EVENT_TYPES.promptOperationPrepared) continue;
1671
+ const payload = event.payload;
1672
+ if (!payload || !istText2(payload.operation_id)) continue;
1673
+ if (nachId.has(payload.operation_id)) continue;
1674
+ nachId.set(payload.operation_id, payload);
1675
+ }
1676
+ return [...nachId.values()];
1677
+ }
1678
+ function findPromptOperation(events, operationId) {
1679
+ return collectPromptOperations(events).find((v) => v.operation_id === operationId) ?? null;
1680
+ }
1681
+ async function preparePromptOperation(input) {
1682
+ const now = input.now ?? (() => /* @__PURE__ */ new Date());
1683
+ const eingefroren = await freezeSceneWorkingState({
1684
+ sceneElementId: input.sceneElementId,
1685
+ store: input.store,
1686
+ resolver: input.resolver,
1687
+ contextChain: input.contextChain,
1688
+ userInstruction: input.userInstruction ?? null
1689
+ });
1690
+ if (eingefroren.kind !== "ok") return eingefroren;
1691
+ const rendererInput = eingefroren.input;
1692
+ return {
1693
+ kind: "ok",
1694
+ operation: {
1695
+ operation_id: input.operationId,
1696
+ scene: eingefroren.scene,
1697
+ context_id: input.contextId,
1698
+ user_instruction: input.userInstruction ?? null,
1699
+ renderer_input: rendererInput,
1700
+ renderer_instruction: buildSystemInstruction2(rendererInput),
1701
+ renderer_payload: buildUserPrompt2(rendererInput),
1702
+ response_contract: responseContractOf(rendererInput),
1703
+ prepared_by: input.preparedBy,
1704
+ created_at: now().toISOString()
1705
+ }
1706
+ };
1707
+ }
1708
+ function responseContractOf(input) {
1709
+ const model = input.target_model ?? {};
1710
+ return {
1711
+ format: "json",
1712
+ required_fields: ["positive", "negative", "feedback", "visibility", "notes"],
1713
+ negative_prompt_allowed: model.supports_negative_prompt === true,
1714
+ node_ids: input.scene.nodes.map((node) => node.node_id),
1715
+ prompt_language: typeof model.prompt_language === "string" ? model.prompt_language : "en"
1716
+ };
1717
+ }
1718
+ function completePromptOperation(input) {
1719
+ const now = input.now ?? (() => /* @__PURE__ */ new Date());
1720
+ const { operation } = input;
1721
+ const geparst = parseRunResponse(input.response);
1722
+ if (!geparst.ok) {
1723
+ return {
1724
+ kind: "rejected",
1725
+ message: `Die Antwort zu Vorgang ${operation.operation_id} ist nicht verwertbar: ${geparst.message}`
1726
+ };
1727
+ }
1728
+ const geprueft = checkRunResponse(geparst.value, operation.renderer_input);
1729
+ if (!geprueft.ok) {
1730
+ return {
1731
+ kind: "rejected",
1732
+ message: `Die Antwort zu Vorgang ${operation.operation_id} passt nicht zur eingefrorenen Eingabe: ${geprueft.message}`
1733
+ };
1734
+ }
1735
+ const origin = {
1736
+ host: "mcp",
1737
+ ...istText2(input.declaredModelId) ? { declared_model_id: input.declaredModelId } : {},
1738
+ renderer_instruction_was_system_prompt: false
1739
+ };
1740
+ return {
1741
+ kind: "ok",
1742
+ record: {
1743
+ run_id: input.runId,
1744
+ // Keine fingierten Kennungen (D-98/D-75) — genau wie beim
1745
+ // Szene-Direktlauf des bestehenden Pfads.
1746
+ shot_version_id: "",
1747
+ shot_element_id: "",
1748
+ scene_setup_version_id: "",
1749
+ camera_id: "",
1750
+ target_model_version_id: operation.renderer_input.target_model_resolution?.version_id ?? "",
1751
+ provider: MCP_CLIENT_PROVIDER,
1752
+ model_id: UNVERIFIED_MODEL_ID,
1753
+ // Die Renderer-Anweisung, wie sie der Vorgang eingefroren hat — nicht
1754
+ // eine zweite, jetzt neu gebaute Fassung.
1755
+ system_prompt: operation.renderer_instruction,
1756
+ input_payload: operation.renderer_input,
1757
+ status: "succeeded",
1758
+ failure: null,
1759
+ output: geprueft.output,
1760
+ raw_output: input.response,
1761
+ source: { kind: "scene_direct", scene: operation.scene },
1762
+ operation_id: operation.operation_id,
1763
+ execution_origin: origin,
1764
+ created_at: now().toISOString()
1765
+ }
1766
+ };
1767
+ }
1768
+ function runOfOperation(runs, operationId) {
1769
+ return runs.find(
1770
+ (run) => run.operation_id === operationId
1771
+ ) ?? null;
1772
+ }
1773
+ function sameResponseAs(run, response) {
1774
+ return (run.raw_output ?? "") === response;
1775
+ }
1653
1776
  export {
1654
1777
  ALL_PUBLISH_RULES,
1655
1778
  CATALOGUE_TYPES,
@@ -1661,6 +1784,7 @@ export {
1661
1784
  DERIVABLE_TYPES,
1662
1785
  ELEMENT_VERSION_SCHEMA_FILE,
1663
1786
  FLOW_EXECUTION_PATH,
1787
+ MCP_CLIENT_PROVIDER,
1664
1788
  PROBE_VERSION_ID,
1665
1789
  PROMPT_RULE_EFFECT,
1666
1790
  REFERENCE_FIELD,
@@ -1680,6 +1804,7 @@ export {
1680
1804
  SZENEN_SNAPSHOT_SCHEMA_VERSION,
1681
1805
  SzenenView,
1682
1806
  UNCHECKED_PUBLISH_RULES,
1807
+ UNVERIFIED_MODEL_ID,
1683
1808
  UPLOAD_MAX_BYTES,
1684
1809
  UnsupportedSchemaError,
1685
1810
  VersionDagError,
@@ -1721,14 +1846,18 @@ export {
1721
1846
  checkSzenenBatchOrigin,
1722
1847
  checkTitle,
1723
1848
  checkWriteDraftInput,
1849
+ claimWon,
1724
1850
  collectImageBatches,
1725
1851
  collectImageGenerationOrders,
1852
+ collectImageJobs,
1853
+ collectPromptOperations,
1726
1854
  collectPromptRuns,
1727
1855
  collectProviderChecks,
1728
1856
  collectSceneDerivationRecoveries,
1729
1857
  collectSceneDerivations,
1730
1858
  collectVersionRefs,
1731
1859
  compileSchemas,
1860
+ completePromptOperation,
1732
1861
  createBrowserTextGenerationPort,
1733
1862
  createClientDerivationPort,
1734
1863
  createClientRunPort,
@@ -1746,6 +1875,7 @@ export {
1746
1875
  createHfImageLibrary,
1747
1876
  createHfImageStore,
1748
1877
  createImageGenerationPort,
1878
+ createImageJobPort,
1749
1879
  createInMemoryEventChannel,
1750
1880
  createMemoryViewPort,
1751
1881
  createSimulationSceneDerivationPort,
@@ -1764,6 +1894,8 @@ export {
1764
1894
  findExecutableImageModel,
1765
1895
  findImageBatch,
1766
1896
  findImageGenerationOrder,
1897
+ findImageJob,
1898
+ findPromptOperation,
1767
1899
  findPromptRun,
1768
1900
  findProviderCheck,
1769
1901
  findSceneDerivation,
@@ -1773,6 +1905,7 @@ export {
1773
1905
  formatSeedListe,
1774
1906
  freezeDraftChain,
1775
1907
  freezeSceneWorkingState,
1908
+ generationBatchIdOf,
1776
1909
  gesamtHerkunft,
1777
1910
  getSzenenSchemas,
1778
1911
  gruppiereZuItems,
@@ -1784,13 +1917,17 @@ export {
1784
1917
  istSzenenSnapshotDatei,
1785
1918
  istZipDatei,
1786
1919
  itemIdForRun,
1920
+ itemsAusBestand,
1921
+ jobsForPromptRun,
1787
1922
  ladeVorschauen,
1788
1923
  leseBilderAusZip,
1789
1924
  linkFor,
1925
+ locatorAus,
1790
1926
  locatorTeile,
1791
1927
  logRevisionOf,
1792
1928
  mergeSnapshotAndPending,
1793
1929
  mergeSzenenBatchOrigin,
1930
+ mimeTypAus,
1794
1931
  mitDefaultVorlage,
1795
1932
  noticeFor,
1796
1933
  ordersForPromptRun,
@@ -1801,6 +1938,7 @@ export {
1801
1938
  parseSzenenSnapshot,
1802
1939
  preferredHeadRevisionOf,
1803
1940
  preferredVersionId,
1941
+ preparePromptOperation,
1804
1942
  promptDiagnosticsOf,
1805
1943
  publishedHeadsOf,
1806
1944
  recoveriesForRun,
@@ -1813,13 +1951,16 @@ export {
1813
1951
  resolveShotPayload,
1814
1952
  resolveTargetModelOver,
1815
1953
  resolverFromQueries,
1954
+ responseContractOf,
1816
1955
  roundOfRun,
1817
1956
  rulesWithoutPromptEffect,
1818
1957
  runElementStoreContract,
1958
+ runOfOperation,
1819
1959
  runPromptDerivation,
1820
1960
  runPublishChecks,
1821
1961
  runSceneDerivation,
1822
1962
  runStoreDifferential,
1963
+ sameResponseAs,
1823
1964
  sceneOnlyCapabilities,
1824
1965
  scopeOfPath,
1825
1966
  seedFehlerText,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslsp1/fa-app-tools",
3
- "version": "7.2.0",
3
+ "version": "7.4.0",
4
4
  "description": "Shared tools and hooks for Fine Art flow apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -28,7 +28,8 @@
28
28
  "scripts": {
29
29
  "build": "node scripts/sync-szenen-styles.js && tsup",
30
30
  "prepublishOnly": "npm run build",
31
- "test": "vitest run"
31
+ "test": "vitest run",
32
+ "mutation:szenen": "stryker run stryker.szenen.conf.mjs"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "react": ">=18"
@@ -39,9 +40,12 @@
39
40
  "zustand": "^5.0.14"
40
41
  },
41
42
  "devDependencies": {
43
+ "@stryker-mutator/core": "9.6.1",
44
+ "@stryker-mutator/vitest-runner": "9.6.1",
42
45
  "@testing-library/dom": "^10.4.1",
43
46
  "@testing-library/react": "^16.3.2",
44
47
  "@types/react": "^19.0.0",
48
+ "@vitest/coverage-v8": "2.1.9",
45
49
  "@xyflow/react": "^12.10.2",
46
50
  "jsdom": "^29.1.1",
47
51
  "motion": "^12.40.0",