@rslsp1/fa-app-tools 10.1.3 → 10.3.2

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
@@ -16,6 +16,7 @@ import {
16
16
  MANUAL_PROVIDER,
17
17
  MANUAL_VISIBILITY_BASIS,
18
18
  MAX_PROPOSAL_TITLE_LENGTH,
19
+ MCP_CLIENT_PROVIDER,
19
20
  PAUSE_SEKUNDEN_OPTIONEN,
20
21
  PAUSE_SEKUNDEN_VORGABE,
21
22
  PROBE_VERSION_ID,
@@ -37,17 +38,20 @@ import {
37
38
  SZENEN_SNAPSHOT_SCHEMA_VERSION,
38
39
  SzenenView,
39
40
  UNCHECKED_PUBLISH_RULES,
41
+ UNVERIFIED_MODEL_ID,
40
42
  UPLOAD_MAX_BYTES,
41
43
  UnsupportedSchemaError,
42
44
  acceptProposalTitle,
43
45
  annotateElementsFromEvents,
44
46
  annotateRunsFromEvents,
47
+ annotatedElementsPageOver,
45
48
  areaForFokus,
46
49
  areasFor,
47
50
  assessDerivationResponse,
48
51
  batchesForPromptRun,
49
52
  bildPfad,
50
53
  bilderDesLaufs,
54
+ buildCameraPreviewContext,
51
55
  buildManualPromptRunRecord,
52
56
  buildSystemInstruction,
53
57
  buildSystemInstruction2,
@@ -83,12 +87,14 @@ import {
83
87
  collectImageBatches,
84
88
  collectImageGenerationOrders,
85
89
  collectImageJobs,
90
+ collectPromptOperations,
86
91
  collectPromptRunTags,
87
92
  collectPromptRuns,
88
93
  collectSceneDerivationRecoveries,
89
94
  collectSceneDerivations,
90
95
  collectVersionRefs,
91
96
  compileSchemas,
97
+ completePromptOperation,
92
98
  contextOfRun,
93
99
  createClientDerivationPort,
94
100
  createClientRunPort,
@@ -118,11 +124,14 @@ import {
118
124
  diagnosticOfFinding,
119
125
  diagnosticOfSchemaError,
120
126
  draftRevisionOf,
127
+ effectivePromptVocabulary,
128
+ elementsByActivity,
121
129
  executableImageModels,
122
130
  findExecutableImageModel,
123
131
  findImageBatch,
124
132
  findImageGenerationOrder,
125
133
  findImageJob,
134
+ findPromptOperation,
126
135
  findPromptRun,
127
136
  findSceneDerivation,
128
137
  findSceneDerivationRecovery,
@@ -177,29 +186,37 @@ import {
177
186
  parseSeedListe,
178
187
  parseSzenenSnapshot,
179
188
  preferredHeadRevisionOf,
189
+ preparePromptDerivation,
190
+ preparePromptOperation,
180
191
  promptDiagnosticsOf,
181
192
  promptRunPageForTransport,
182
193
  promptRunPageFromTransport,
183
194
  promptRunTagsOf,
195
+ promptTagGroup,
184
196
  publishedHeadsOf,
185
197
  recoveriesForRun,
186
198
  recoveryStatusOf,
187
199
  reduceElementEvents,
188
200
  resolveArea,
189
201
  resolveGeneralScenePolicies,
202
+ resolvePromptConstructionTags,
190
203
  resolveScenePayload,
191
204
  resolveShot,
192
205
  resolveShotPayload,
193
206
  resolveTargetModelOver,
194
207
  resolverFromQueries,
208
+ responseContractOf,
195
209
  roundOfRun,
196
210
  roundsOf,
197
211
  rulesWithoutPromptEffect,
212
+ runOfOperation,
198
213
  runPromptDerivation,
199
214
  runPublishChecks,
200
215
  runSceneDerivation,
216
+ sameResponseAs,
201
217
  sceneOnlyCapabilities,
202
218
  scenePolicyFingerprint,
219
+ sceneVersionElementsOf,
203
220
  scopeOfPath,
204
221
  seedFehlerText,
205
222
  selectImageJobs,
@@ -210,6 +227,7 @@ import {
210
227
  simulatedAnswerFor,
211
228
  sortScenePolicies,
212
229
  sourceOf,
230
+ supportsCompositionReference,
213
231
  szenenSnapshotFilename,
214
232
  tagRefsAus,
215
233
  typAusBytes,
@@ -220,20 +238,31 @@ import {
220
238
  validateElementVersion,
221
239
  validatePayload,
222
240
  withReference
223
- } from "./chunk-5SYVLULG.mjs";
241
+ } from "./chunk-JP7LIWDR.mjs";
224
242
  import {
225
243
  ContractViolation,
226
244
  STYLE_PAYLOAD,
227
245
  STYLE_PAYLOAD_V2,
228
246
  elementStoreContractChecks,
229
247
  runElementStoreContract
230
- } from "./chunk-C5CGSPP3.mjs";
248
+ } from "./chunk-RFTANBQ5.mjs";
231
249
  import {
232
250
  VersionDagError,
233
251
  buildVersionDag,
234
252
  preferredVersionId,
235
253
  resolvePreferredHead
236
254
  } from "./chunk-FUY2OCVC.mjs";
255
+ import {
256
+ CAMERA_ASPECT_RATIOS,
257
+ STAGE_CATALOGUE,
258
+ cameraAspectRatioValue,
259
+ cameraPerspective,
260
+ checkCameraAspectRatioChanges,
261
+ dragPosition,
262
+ frozenCameraAspectRatio,
263
+ stageFrame,
264
+ stageNode
265
+ } from "./chunk-TFWIMFNF.mjs";
237
266
 
238
267
  // src/lib/szenen/providerCheckStore.ts
239
268
  function collectProviderChecks(events) {
@@ -552,7 +581,8 @@ function simulierteRekonstruktion(input, runId) {
552
581
  }
553
582
  function createMemoryViewPort(options = {}) {
554
583
  const ids = options.ids ?? defaultIds;
555
- const elements = createHfElementStore({ channel: createInMemoryEventChannel() });
584
+ const elementChannel = createInMemoryEventChannel();
585
+ const elements = createHfElementStore({ channel: elementChannel });
556
586
  const laeufe = [...options.runs ?? []];
557
587
  const laufTags = new Map(
558
588
  Object.entries(options.runTags ?? {}).map(
@@ -629,6 +659,7 @@ function createMemoryViewPort(options = {}) {
629
659
  );
630
660
  const lauf = {
631
661
  ...basis,
662
+ input_payload: { ...basis.input_payload, scene: { ...basis.input_payload.scene, element_id: input.sceneElementId, version_id: "" } },
632
663
  shot_version_id: "",
633
664
  shot_element_id: "",
634
665
  scene_setup_version_id: "",
@@ -664,7 +695,7 @@ function createMemoryViewPort(options = {}) {
664
695
  version_id: null
665
696
  },
666
697
  input: {
667
- scene: { nodes: [] }
698
+ scene: { element_id: input.sceneElementId, version_id: "", nodes: [] }
668
699
  },
669
700
  promptText: input.promptText,
670
701
  note: input.note ?? null,
@@ -707,6 +738,7 @@ function createMemoryViewPort(options = {}) {
707
738
  try {
708
739
  return ok(pagePromptRuns(laeufe, {
709
740
  ...input,
741
+ sceneVersionElements: sceneVersionElementsOf(reduceElementEvents(await elementChannel.readEvents())),
710
742
  tags: input.tags ?? laufTags,
711
743
  ...annotationen.size > 0 && !input.annotations ? { annotations: annotationen } : {}
712
744
  }));
@@ -773,6 +805,16 @@ function createMemoryViewPort(options = {}) {
773
805
  return done({ removed: rest.length !== vorhanden.length });
774
806
  }
775
807
  };
808
+ const assetVorschauen = options.assetPreviews;
809
+ if (assetVorschauen) {
810
+ mediaPort.loadAssetPreview = async (assetId) => {
811
+ const quelle = assetVorschauen[assetId];
812
+ if (quelle === void 0) {
813
+ return { kind: "error", message: `Medien-Asset ${assetId} ist unbekannt.`, retryable: false };
814
+ }
815
+ return ok(quelle);
816
+ };
817
+ }
776
818
  const rekonstruktionen = [];
777
819
  const fassungen = [];
778
820
  const uebernommen = /* @__PURE__ */ new Map();
@@ -1120,14 +1162,25 @@ function createMemoryViewPort(options = {}) {
1120
1162
  const elementeMitAnnotationen = options.elementAnnotations ? {
1121
1163
  ...elements,
1122
1164
  async listElementsPage(filter, page) {
1123
- const seite = await listElementsPageOver((f) => elements.listElements(f), filter, page);
1124
- if (seite.kind !== "ok") return seite;
1165
+ const vorbelegt = options.elementAnnotations;
1166
+ const alle = await elements.listElements(filter);
1167
+ if (alle.kind !== "ok") return alle;
1168
+ let seite;
1169
+ try {
1170
+ seite = pageOf(
1171
+ elementsByActivity(alle.value, (e) => vorbelegt[e.element_id]?.lastActivityAt ?? null),
1172
+ (e) => e.element_id,
1173
+ page ?? null
1174
+ );
1175
+ } catch (error) {
1176
+ return { kind: "error", message: error.message, retryable: false };
1177
+ }
1125
1178
  const annotations = {};
1126
- for (const element of seite.value.items) {
1127
- const annotation = options.elementAnnotations[element.element_id];
1179
+ for (const element of seite.items) {
1180
+ const annotation = vorbelegt[element.element_id];
1128
1181
  if (annotation) annotations[element.element_id] = annotation;
1129
1182
  }
1130
- return ok({ ...seite.value, annotations });
1183
+ return ok({ ...seite, annotations });
1131
1184
  }
1132
1185
  } : elements;
1133
1186
  const port = {
@@ -1492,6 +1545,17 @@ function checkPromptRunRecord(candidate) {
1492
1545
  if (eingabe === null || typeof eingabe !== "object") {
1493
1546
  return { ok: false, message: '"input_payload" fehlt \u2014 ohne sie ist der Lauf nicht pruefbar.' };
1494
1547
  }
1548
+ if (record.camera_preview !== void 0) {
1549
+ const preview = record.camera_preview;
1550
+ const camera = eingabe.camera;
1551
+ if (!preview || preview.mime_type !== "image/png" || !/^[a-f0-9]{64}$/.test(preview.sha256) || !Number.isInteger(preview.width) || !Number.isInteger(preview.height) || preview.width <= 0 || preview.height <= 0 || preview.width > 2048 || preview.height > 2048 || !camera?.aspect_ratio || preview.camera_id !== camera.camera_id) {
1552
+ return { ok: false, message: "Das Kamera-Preview hat keinen g\xFCltigen Bezug zum eingefrorenen Kamerastand." };
1553
+ }
1554
+ const [width, height] = camera.aspect_ratio.split(":").map(Number);
1555
+ if (!Number.isFinite(width / height) || Math.abs(preview.width / preview.height - width / height) > 1e-9) {
1556
+ return { ok: false, message: "Preview-Abmessungen und eingefrorenes Kameraformat widersprechen sich." };
1557
+ }
1558
+ }
1495
1559
  if (record.status === "failed") {
1496
1560
  if (record.output !== null && record.output !== void 0) {
1497
1561
  return {
@@ -1844,123 +1908,9 @@ function checkSceneDerivationRecoveryRecord(candidate) {
1844
1908
  }
1845
1909
  return { ok: true };
1846
1910
  }
1847
-
1848
- // src/lib/szenen/scenePromptOperation.ts
1849
- var MCP_CLIENT_PROVIDER = "mcp_client";
1850
- var UNVERIFIED_MODEL_ID = "mcp-client-unspecified";
1851
- var istText2 = (wert) => typeof wert === "string" && wert.trim().length > 0;
1852
- function collectPromptOperations(events) {
1853
- const nachId = /* @__PURE__ */ new Map();
1854
- for (const event of events) {
1855
- if (event.type !== SZENEN_EVENT_TYPES.promptOperationPrepared) continue;
1856
- const payload = event.payload;
1857
- if (!payload || !istText2(payload.operation_id)) continue;
1858
- if (nachId.has(payload.operation_id)) continue;
1859
- nachId.set(payload.operation_id, payload);
1860
- }
1861
- return [...nachId.values()];
1862
- }
1863
- function findPromptOperation(events, operationId) {
1864
- return collectPromptOperations(events).find((v) => v.operation_id === operationId) ?? null;
1865
- }
1866
- async function preparePromptOperation(input) {
1867
- const now = input.now ?? (() => /* @__PURE__ */ new Date());
1868
- const eingefroren = await freezeSceneWorkingState({
1869
- sceneElementId: input.sceneElementId,
1870
- store: input.store,
1871
- resolver: input.resolver,
1872
- contextChain: input.contextChain,
1873
- userInstruction: input.userInstruction ?? null,
1874
- targetModelElementId: input.targetModelElementId ?? null
1875
- });
1876
- if (eingefroren.kind !== "ok") return eingefroren;
1877
- const rendererInput = eingefroren.input;
1878
- return {
1879
- kind: "ok",
1880
- operation: {
1881
- operation_id: input.operationId,
1882
- scene: eingefroren.scene,
1883
- context_id: input.contextId,
1884
- user_instruction: input.userInstruction ?? null,
1885
- renderer_input: rendererInput,
1886
- renderer_instruction: buildSystemInstruction2(rendererInput),
1887
- renderer_payload: buildUserPrompt2(rendererInput),
1888
- response_contract: responseContractOf(rendererInput),
1889
- prepared_by: input.preparedBy,
1890
- created_at: now().toISOString()
1891
- }
1892
- };
1893
- }
1894
- function responseContractOf(input) {
1895
- const model = input.target_model ?? {};
1896
- return {
1897
- format: "json",
1898
- required_fields: ["positive", "negative", "feedback", "visibility", "notes"],
1899
- negative_prompt_allowed: model.supports_negative_prompt === true,
1900
- node_ids: input.scene.nodes.map((node) => node.node_id),
1901
- prompt_language: typeof model.prompt_language === "string" ? model.prompt_language : "en"
1902
- };
1903
- }
1904
- function completePromptOperation(input) {
1905
- const now = input.now ?? (() => /* @__PURE__ */ new Date());
1906
- const { operation } = input;
1907
- const geparst = parseRunResponse(input.response);
1908
- if (!geparst.ok) {
1909
- return {
1910
- kind: "rejected",
1911
- message: `Die Antwort zu Vorgang ${operation.operation_id} ist nicht verwertbar: ${geparst.message}`
1912
- };
1913
- }
1914
- const geprueft = checkRunResponse(geparst.value, operation.renderer_input);
1915
- if (!geprueft.ok) {
1916
- return {
1917
- kind: "rejected",
1918
- message: `Die Antwort zu Vorgang ${operation.operation_id} passt nicht zur eingefrorenen Eingabe: ${geprueft.message}`
1919
- };
1920
- }
1921
- const origin = {
1922
- host: "mcp",
1923
- ...istText2(input.declaredModelId) ? { declared_model_id: input.declaredModelId } : {},
1924
- renderer_instruction_was_system_prompt: false
1925
- };
1926
- return {
1927
- kind: "ok",
1928
- record: {
1929
- run_id: input.runId,
1930
- // Keine fingierten Kennungen (D-98/D-75) — genau wie beim
1931
- // Szene-Direktlauf des bestehenden Pfads.
1932
- shot_version_id: "",
1933
- shot_element_id: "",
1934
- scene_setup_version_id: "",
1935
- camera_id: "",
1936
- target_model_version_id: operation.renderer_input.target_model_resolution?.version_id ?? "",
1937
- provider: MCP_CLIENT_PROVIDER,
1938
- model_id: UNVERIFIED_MODEL_ID,
1939
- // Die Renderer-Anweisung, wie sie der Vorgang eingefroren hat — nicht
1940
- // eine zweite, jetzt neu gebaute Fassung.
1941
- system_prompt: operation.renderer_instruction,
1942
- input_payload: operation.renderer_input,
1943
- status: "succeeded",
1944
- failure: null,
1945
- output: geprueft.output,
1946
- raw_output: input.response,
1947
- source: { kind: "scene_direct", scene: operation.scene },
1948
- operation_id: operation.operation_id,
1949
- execution_origin: origin,
1950
- created_at: now().toISOString()
1951
- }
1952
- };
1953
- }
1954
- function runOfOperation(runs, operationId) {
1955
- return runs.find(
1956
- (run) => run.operation_id === operationId
1957
- ) ?? null;
1958
- }
1959
- function sameResponseAs(run, response) {
1960
- return (run.raw_output ?? "") === response;
1961
- }
1962
1911
  export {
1963
1912
  ALL_PUBLISH_RULES,
1913
+ CAMERA_ASPECT_RATIOS,
1964
1914
  CATALOGUE_TYPES,
1965
1915
  CHAIN_EDGES,
1966
1916
  CHAIN_LINK_FIELDS,
@@ -1989,6 +1939,7 @@ export {
1989
1939
  RULE_SCOPES,
1990
1940
  ResolveTechnicalError,
1991
1941
  SIMULATION_PROVIDER,
1942
+ STAGE_CATALOGUE,
1992
1943
  STYLE_PAYLOAD,
1993
1944
  STYLE_PAYLOAD_V2,
1994
1945
  SZENEN_ELEMENT_TYPES,
@@ -2007,24 +1958,29 @@ export {
2007
1958
  VersionDagError,
2008
1959
  annotateElementsFromEvents,
2009
1960
  annotateRunsFromEvents,
1961
+ annotatedElementsPageOver,
2010
1962
  areaForFokus,
2011
1963
  areasFor,
2012
1964
  assessDerivationResponse,
2013
1965
  batchesForPromptRun,
2014
1966
  bildPfad,
2015
1967
  bilderDesLaufs,
2016
- buildSystemInstruction as buildDerivationSystemInstruction,
2017
- buildUserPrompt as buildDerivationUserPrompt,
1968
+ buildCameraPreviewContext,
1969
+ buildSystemInstruction2 as buildDerivationSystemInstruction,
1970
+ buildUserPrompt2 as buildDerivationUserPrompt,
2018
1971
  buildManualPromptRunRecord,
2019
- buildSystemInstruction2 as buildSystemInstruction,
1972
+ buildSystemInstruction,
2020
1973
  buildSzenenSnapshot,
2021
- buildUserPrompt2 as buildUserPrompt,
1974
+ buildUserPrompt,
2022
1975
  buildVersionDag,
2023
1976
  callOptional,
1977
+ cameraAspectRatioValue,
1978
+ cameraPerspective,
2024
1979
  capabilitiesOf,
2025
1980
  capabilityGate,
2026
1981
  capabilityReport,
2027
1982
  catalogueFor,
1983
+ checkCameraAspectRatioChanges,
2028
1984
  checkChainTargets,
2029
1985
  checkCreateElementInput,
2030
1986
  checkDerivationResponse,
@@ -2094,7 +2050,10 @@ export {
2094
2050
  diagnosticOfSchemaError,
2095
2051
  differentialSteps,
2096
2052
  draftRevisionOf,
2053
+ dragPosition,
2054
+ effectivePromptVocabulary,
2097
2055
  elementStoreContractChecks,
2056
+ elementsByActivity,
2098
2057
  executableImageModels,
2099
2058
  findExecutableImageModel,
2100
2059
  findImageBatch,
@@ -2110,6 +2069,7 @@ export {
2110
2069
  formatSeedListe,
2111
2070
  freezeDraftChain,
2112
2071
  freezeSceneWorkingState,
2072
+ frozenCameraAspectRatio,
2113
2073
  fuehreQueueAus,
2114
2074
  generationBatchIdOf,
2115
2075
  gesamtHerkunft,
@@ -2157,11 +2117,13 @@ export {
2157
2117
  parseSzenenSnapshot,
2158
2118
  preferredHeadRevisionOf,
2159
2119
  preferredVersionId,
2120
+ preparePromptDerivation,
2160
2121
  preparePromptOperation,
2161
2122
  promptDiagnosticsOf,
2162
2123
  promptRunPageForTransport,
2163
2124
  promptRunPageFromTransport,
2164
2125
  promptRunTagsOf,
2126
+ promptTagGroup,
2165
2127
  publishedHeadsOf,
2166
2128
  recoveriesForRun,
2167
2129
  recoveryStatusOf,
@@ -2169,6 +2131,7 @@ export {
2169
2131
  resolveArea,
2170
2132
  resolveGeneralScenePolicies,
2171
2133
  resolvePreferredHead,
2134
+ resolvePromptConstructionTags,
2172
2135
  resolveScenePayload,
2173
2136
  resolveShot,
2174
2137
  resolveShotPayload,
@@ -2187,6 +2150,7 @@ export {
2187
2150
  sameResponseAs,
2188
2151
  sceneOnlyCapabilities,
2189
2152
  scenePolicyFingerprint,
2153
+ sceneVersionElementsOf,
2190
2154
  scopeOfPath,
2191
2155
  seedFehlerText,
2192
2156
  selectImageJobs,
@@ -2197,6 +2161,9 @@ export {
2197
2161
  simulatedAnswerFor,
2198
2162
  sortScenePolicies,
2199
2163
  sourceOf,
2164
+ stageFrame,
2165
+ stageNode,
2166
+ supportsCompositionReference,
2200
2167
  szenenSnapshotFilename,
2201
2168
  tagRefsAus,
2202
2169
  totalModelCalls,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslsp1/fa-app-tools",
3
- "version": "10.1.3",
3
+ "version": "10.3.2",
4
4
  "description": "Shared tools and hooks for Fine Art flow apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -33,11 +33,12 @@
33
33
  "mutation:runintegrity": "stryker run stryker.runintegrity.conf.mjs"
34
34
  },
35
35
  "peerDependencies": {
36
- "react": ">=18"
36
+ "react": "^18.2.0 || ^19.0.0"
37
37
  },
38
38
  "dependencies": {
39
39
  "@huggingface/hub": "^2.13.0",
40
40
  "jszip": "^3.10.1",
41
+ "three": "^0.186.1",
41
42
  "zustand": "^5.0.14"
42
43
  },
43
44
  "devDependencies": {
@@ -46,6 +47,7 @@
46
47
  "@testing-library/dom": "^10.4.1",
47
48
  "@testing-library/react": "^16.3.2",
48
49
  "@types/react": "^19.0.0",
50
+ "@types/three": "^0.186.0",
49
51
  "@vitest/coverage-v8": "2.1.9",
50
52
  "@xyflow/react": "^12.10.2",
51
53
  "jsdom": "^29.1.1",