@rslsp1/fa-app-tools 9.0.0 → 9.4.4

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
@@ -9,9 +9,19 @@ import {
9
9
  ELEMENT_VERSION_SCHEMA_FILE,
10
10
  FLOW_EXECUTION_PATH,
11
11
  GENERAL_POLICY_SUBTYPE,
12
+ KEINE_BILDER,
13
+ LOAD_MORE_PAGE_SIZE,
14
+ MANUAL_MODEL_ID,
15
+ MANUAL_NODE_STATE,
16
+ MANUAL_PROVIDER,
17
+ MANUAL_VISIBILITY_BASIS,
12
18
  MAX_PROPOSAL_TITLE_LENGTH,
19
+ PAUSE_SEKUNDEN_OPTIONEN,
20
+ PAUSE_SEKUNDEN_VORGABE,
13
21
  PROBE_VERSION_ID,
22
+ PROMPT_AUSZUG_ZEICHEN,
14
23
  PROMPT_RULE_EFFECT,
24
+ PROMPT_RUN_DETAIL_FIELDS,
15
25
  REFERENCE_FIELD,
16
26
  RULES_WITHOUT_CAPABILITY_EFFECT,
17
27
  RULE_SCOPES,
@@ -30,10 +40,14 @@ import {
30
40
  UPLOAD_MAX_BYTES,
31
41
  UnsupportedSchemaError,
32
42
  acceptProposalTitle,
43
+ annotateElementsFromEvents,
44
+ annotateRunsFromEvents,
45
+ areaForFokus,
33
46
  areasFor,
34
47
  assessDerivationResponse,
35
48
  batchesForPromptRun,
36
49
  bildPfad,
50
+ buildManualPromptRunRecord,
37
51
  buildSystemInstruction,
38
52
  buildSystemInstruction2,
39
53
  buildSzenenSnapshot,
@@ -68,6 +82,7 @@ import {
68
82
  collectImageBatches,
69
83
  collectImageGenerationOrders,
70
84
  collectImageJobs,
85
+ collectPromptRunTags,
71
86
  collectPromptRuns,
72
87
  collectSceneDerivationRecoveries,
73
88
  collectSceneDerivations,
@@ -98,6 +113,7 @@ import {
98
113
  deriveLineage,
99
114
  describableContent,
100
115
  describeTargetModelFailure,
116
+ detailFehlt,
101
117
  diagnosticOfFinding,
102
118
  diagnosticOfSchemaError,
103
119
  draftRevisionOf,
@@ -114,6 +130,7 @@ import {
114
130
  formatSeedListe,
115
131
  freezeDraftChain,
116
132
  freezeSceneWorkingState,
133
+ fuehreQueueAus,
117
134
  generationBatchIdOf,
118
135
  gesamtHerkunft,
119
136
  getSzenenSchemas,
@@ -125,17 +142,24 @@ import {
125
142
  isOk,
126
143
  isProjectionCurrent,
127
144
  isSzenenItemId,
145
+ istGueltigePause,
146
+ istOffen,
128
147
  istSzenenSnapshotDatei,
129
148
  istZipDatei,
130
149
  itemIdForRun,
131
150
  itemsAusBestand,
132
151
  jobsForPromptRun,
152
+ labelsOf,
133
153
  ladeVorschauen,
134
154
  leseBilderAusZip,
155
+ letztesErzeugtesBild,
135
156
  linkFor,
157
+ listElementsPageOver,
136
158
  locatorAus,
137
159
  locatorTeile,
138
160
  logRevisionOf,
161
+ manualEntryOf,
162
+ mergeRunTags,
139
163
  mergeSnapshotAndPending,
140
164
  mergeSzenenBatchOrigin,
141
165
  mimeTypAus,
@@ -144,12 +168,18 @@ import {
144
168
  noticeFor,
145
169
  ordersForPromptRun,
146
170
  ordneSeedsZu,
171
+ pageOf,
172
+ pagePromptRuns,
173
+ pageRequestFrom,
147
174
  parseDerivationResponse,
148
175
  parseRunResponse,
149
176
  parseSeedListe,
150
177
  parseSzenenSnapshot,
151
178
  preferredHeadRevisionOf,
152
179
  promptDiagnosticsOf,
180
+ promptRunPageForTransport,
181
+ promptRunPageFromTransport,
182
+ promptRunTagsOf,
153
183
  publishedHeadsOf,
154
184
  recoveriesForRun,
155
185
  recoveryStatusOf,
@@ -162,6 +192,7 @@ import {
162
192
  resolveTargetModelOver,
163
193
  resolverFromQueries,
164
194
  roundOfRun,
195
+ roundsOf,
165
196
  rulesWithoutPromptEffect,
166
197
  runPromptDerivation,
167
198
  runPublishChecks,
@@ -170,6 +201,7 @@ import {
170
201
  scenePolicyFingerprint,
171
202
  scopeOfPath,
172
203
  seedFehlerText,
204
+ selectImageJobs,
173
205
  selectPromptRuns,
174
206
  selectableTargetModels,
175
207
  showChain,
@@ -178,6 +210,7 @@ import {
178
210
  sortScenePolicies,
179
211
  sourceOf,
180
212
  szenenSnapshotFilename,
213
+ tagRefsAus,
181
214
  typAusBytes,
182
215
  unclassifiedPublishRules,
183
216
  unsupportedReason,
@@ -186,7 +219,7 @@ import {
186
219
  validateElementVersion,
187
220
  validatePayload,
188
221
  withReference
189
- } from "./chunk-2ADFDRFX.mjs";
222
+ } from "./chunk-KF5ZVSKJ.mjs";
190
223
  import {
191
224
  ContractViolation,
192
225
  STYLE_PAYLOAD,
@@ -520,6 +553,14 @@ function createMemoryViewPort(options = {}) {
520
553
  const ids = options.ids ?? defaultIds;
521
554
  const elements = createHfElementStore({ channel: createInMemoryEventChannel() });
522
555
  const laeufe = [...options.runs ?? []];
556
+ const laufTags = new Map(
557
+ Object.entries(options.runTags ?? {}).map(
558
+ ([runId, labels]) => [runId, labels.map((l) => ({ l, v: l, cat: null }))]
559
+ )
560
+ );
561
+ const annotationen = new Map(
562
+ Object.entries(options.runAnnotations ?? {})
563
+ );
523
564
  const items = /* @__PURE__ */ new Map();
524
565
  const versionMedien = /* @__PURE__ */ new Map();
525
566
  const itemMedien = /* @__PURE__ */ new Map();
@@ -605,6 +646,34 @@ function createMemoryViewPort(options = {}) {
605
646
  laeufe.push(lauf);
606
647
  return done(lauf);
607
648
  },
649
+ // ── Der manuell erfasste Lauf derselben Szene (Schritt 01) ────────────
650
+ //
651
+ // Auch hier nur die **Form**, und zwar ueber `buildManualPromptRunRecord()`
652
+ // — dieselbe Funktion, die der echte Port benutzt. Ein hier nachgebauter
653
+ // Datensatz waere die zweite Wahrheit, an der eine Ansicht gruen testete
654
+ // und im Host scheiterte. Was der Speicherport nicht abbildet, ist das
655
+ // Einfrieren: Es braucht einen echten Bestand.
656
+ async addManualSceneRun(input) {
657
+ const gebaut = buildManualPromptRunRecord({
658
+ runId: ids(),
659
+ scene: {
660
+ element_id: input.sceneElementId,
661
+ draft_id: `draft-${input.sceneElementId}`,
662
+ revision: 1,
663
+ version_id: null
664
+ },
665
+ input: {
666
+ scene: { nodes: [] }
667
+ },
668
+ promptText: input.promptText,
669
+ note: input.note ?? null,
670
+ derivedFromRunId: input.derivedFromRunId ?? null,
671
+ enteredBy: input.enteredBy
672
+ });
673
+ if (gebaut.kind !== "ok") return { kind: "rejected", message: gebaut.message };
674
+ laeufe.push(gebaut.record);
675
+ return done(gebaut.record);
676
+ },
608
677
  async listRunsForScene(sceneElementId) {
609
678
  return ok(laeufe.filter(
610
679
  (r) => r.source?.kind === "scene_direct" && r.source.scene.element_id === sceneElementId
@@ -615,6 +684,38 @@ function createMemoryViewPort(options = {}) {
615
684
  // Server. Ein eigener Filter waere eine zweite Wahrheit.
616
685
  async listAllRuns(filter) {
617
686
  return ok(selectPromptRuns(laeufe, filter));
687
+ },
688
+ /**
689
+ * Die direkten Tags eines Laufs setzen — der vollstaendige Satz.
690
+ *
691
+ * Ohne Vokabelpruefung, und das ist hier richtig: Der Speicherhost hat
692
+ * keine Vokabel. Die Regel „nur bestehende Tags" gehoert dorthin, wo die
693
+ * Tabelle steht (`libraryService.resolveTagLabels`), nicht in eine zweite
694
+ * Fassung davon.
695
+ */
696
+ async setRunTags(runId, labels) {
697
+ if (!laeufe.some((l) => l.run_id === runId)) {
698
+ return { kind: "error", message: `Lauf ${runId} ist unbekannt.`, retryable: false };
699
+ }
700
+ const satz = labels.map((l) => ({ l, v: l, cat: null }));
701
+ laufTags.set(runId, satz);
702
+ return done(satz);
703
+ },
704
+ // Der Seitenschnitt — dieselbe reine Funktion wie im Client und im Server.
705
+ async listRunsPage(input) {
706
+ try {
707
+ return ok(pagePromptRuns(laeufe, {
708
+ ...input,
709
+ tags: input.tags ?? laufTags,
710
+ ...annotationen.size > 0 && !input.annotations ? { annotations: annotationen } : {}
711
+ }));
712
+ } catch (error) {
713
+ return {
714
+ kind: "error",
715
+ message: error instanceof Error ? error.message : String(error),
716
+ retryable: false
717
+ };
718
+ }
618
719
  }
619
720
  };
620
721
  const itemPort = {
@@ -1015,8 +1116,21 @@ function createMemoryViewPort(options = {}) {
1015
1116
  return done(null);
1016
1117
  }
1017
1118
  };
1119
+ const elementeMitAnnotationen = options.elementAnnotations ? {
1120
+ ...elements,
1121
+ async listElementsPage(filter, page) {
1122
+ const seite = await listElementsPageOver((f) => elements.listElements(f), filter, page);
1123
+ if (seite.kind !== "ok") return seite;
1124
+ const annotations = {};
1125
+ for (const element of seite.value.items) {
1126
+ const annotation = options.elementAnnotations[element.element_id];
1127
+ if (annotation) annotations[element.element_id] = annotation;
1128
+ }
1129
+ return ok({ ...seite.value, annotations });
1130
+ }
1131
+ } : elements;
1018
1132
  const port = {
1019
- elements,
1133
+ elements: elementeMitAnnotationen,
1020
1134
  context: {
1021
1135
  // Ein Host ohne Kontextgraph liefert `[eigener, null]` — das ist dort
1022
1136
  // nicht die verkürzte Vererbung, sondern die vollständige.
@@ -1024,7 +1138,17 @@ function createMemoryViewPort(options = {}) {
1024
1138
  return ok(contextId === null ? [null] : [contextId, null]);
1025
1139
  }
1026
1140
  },
1027
- runs
1141
+ runs,
1142
+ // Die Vorschlagsliste des Tag-Editors — nur, wenn der Test eine Vokabel
1143
+ // vorgibt. Weglassen statt leere Liste: `tagVocabulary: false` ist eine
1144
+ // andere Aussage als „die Vokabel ist leer".
1145
+ ...options.tagVocabulary ? {
1146
+ tags: {
1147
+ async listTags() {
1148
+ return ok(options.tagVocabulary.map((l) => ({ l, v: l, cat: null })));
1149
+ }
1150
+ }
1151
+ } : {}
1028
1152
  };
1029
1153
  if (options.items !== false) port.items = itemPort;
1030
1154
  if (options.media !== false) port.media = mediaPort;
@@ -1271,6 +1395,47 @@ function pruefeLaufherkunft(quelle) {
1271
1395
  }
1272
1396
  return { ok: true };
1273
1397
  }
1398
+ function pruefeHandeingabe(record) {
1399
+ const block = record.manual_entry;
1400
+ if (block === void 0) return { ok: true };
1401
+ if (!isObject(block)) {
1402
+ return { ok: false, message: '"manual_entry" muss ein Objekt sein.' };
1403
+ }
1404
+ if (block.entered_manually !== true) {
1405
+ return {
1406
+ ok: false,
1407
+ message: '"manual_entry.entered_manually" muss true sein. Ein Block, der das nicht sagt, ist kein Nachweis einer Handeingabe.'
1408
+ };
1409
+ }
1410
+ if (!istText(block.entered_by)) {
1411
+ return { ok: false, message: '"manual_entry.entered_by" fehlt oder ist leer.' };
1412
+ }
1413
+ if (block.note !== null && typeof block.note !== "string") {
1414
+ return {
1415
+ ok: false,
1416
+ message: '"manual_entry.note" muss eine Zeichenkette oder null sein \u2014 ohne Notiz gehoert null hin, kein fehlendes Feld.'
1417
+ };
1418
+ }
1419
+ if (block.derived_from_run_id !== null && !istText(block.derived_from_run_id)) {
1420
+ return {
1421
+ ok: false,
1422
+ message: '"manual_entry.derived_from_run_id" muss eine run_id oder null sein. Eine leere Kennung belegt keinen Ursprung.'
1423
+ };
1424
+ }
1425
+ if (record.status !== "succeeded") {
1426
+ return {
1427
+ ok: false,
1428
+ message: `Ein manuell erfasster Lauf hat den Status "succeeded" \u2014 er traegt einen vorgegebenen Prompttext. Angekommen ist ${JSON.stringify(record.status)}.`
1429
+ };
1430
+ }
1431
+ if (record.provider !== MANUAL_PROVIDER || record.model_id !== MANUAL_MODEL_ID) {
1432
+ return {
1433
+ ok: false,
1434
+ message: `Ein manuell erfasster Lauf traegt provider "${MANUAL_PROVIDER}" und model_id "${MANUAL_MODEL_ID}"; angekommen sind ${JSON.stringify(record.provider)} und ${JSON.stringify(record.model_id)}. Formuliert hat ein Mensch \u2014 ein Modell als Urheber waere eine Falschaussage.`
1435
+ };
1436
+ }
1437
+ return { ok: true };
1438
+ }
1274
1439
  function checkPromptRunRecord(candidate) {
1275
1440
  if (candidate === null || typeof candidate !== "object" || Array.isArray(candidate)) {
1276
1441
  return {
@@ -1320,6 +1485,8 @@ function checkPromptRunRecord(candidate) {
1320
1485
  message: `"status" muss succeeded oder failed sein, angekommen ist ${JSON.stringify(record.status)}.`
1321
1486
  };
1322
1487
  }
1488
+ const handeingabe = pruefeHandeingabe(record);
1489
+ if (!handeingabe.ok) return handeingabe;
1323
1490
  const eingabe = record.input_payload;
1324
1491
  if (eingabe === null || typeof eingabe !== "object") {
1325
1492
  return { ok: false, message: '"input_payload" fehlt \u2014 ohne sie ist der Lauf nicht pruefbar.' };
@@ -1702,7 +1869,8 @@ async function preparePromptOperation(input) {
1702
1869
  store: input.store,
1703
1870
  resolver: input.resolver,
1704
1871
  contextChain: input.contextChain,
1705
- userInstruction: input.userInstruction ?? null
1872
+ userInstruction: input.userInstruction ?? null,
1873
+ targetModelElementId: input.targetModelElementId ?? null
1706
1874
  });
1707
1875
  if (eingefroren.kind !== "ok") return eingefroren;
1708
1876
  const rendererInput = eingefroren.input;
@@ -1802,9 +1970,19 @@ export {
1802
1970
  ELEMENT_VERSION_SCHEMA_FILE,
1803
1971
  FLOW_EXECUTION_PATH,
1804
1972
  GENERAL_POLICY_SUBTYPE,
1973
+ KEINE_BILDER,
1974
+ LOAD_MORE_PAGE_SIZE,
1975
+ MANUAL_MODEL_ID,
1976
+ MANUAL_NODE_STATE,
1977
+ MANUAL_PROVIDER,
1978
+ MANUAL_VISIBILITY_BASIS,
1805
1979
  MCP_CLIENT_PROVIDER,
1980
+ PAUSE_SEKUNDEN_OPTIONEN,
1981
+ PAUSE_SEKUNDEN_VORGABE,
1806
1982
  PROBE_VERSION_ID,
1983
+ PROMPT_AUSZUG_ZEICHEN,
1807
1984
  PROMPT_RULE_EFFECT,
1985
+ PROMPT_RUN_DETAIL_FIELDS,
1808
1986
  REFERENCE_FIELD,
1809
1987
  RULES_WITHOUT_CAPABILITY_EFFECT,
1810
1988
  RULE_SCOPES,
@@ -1826,12 +2004,16 @@ export {
1826
2004
  UPLOAD_MAX_BYTES,
1827
2005
  UnsupportedSchemaError,
1828
2006
  VersionDagError,
2007
+ annotateElementsFromEvents,
2008
+ annotateRunsFromEvents,
2009
+ areaForFokus,
1829
2010
  areasFor,
1830
2011
  assessDerivationResponse,
1831
2012
  batchesForPromptRun,
1832
2013
  bildPfad,
1833
2014
  buildSystemInstruction as buildDerivationSystemInstruction,
1834
2015
  buildUserPrompt as buildDerivationUserPrompt,
2016
+ buildManualPromptRunRecord,
1835
2017
  buildSystemInstruction2 as buildSystemInstruction,
1836
2018
  buildSzenenSnapshot,
1837
2019
  buildUserPrompt2 as buildUserPrompt,
@@ -1869,6 +2051,7 @@ export {
1869
2051
  collectImageGenerationOrders,
1870
2052
  collectImageJobs,
1871
2053
  collectPromptOperations,
2054
+ collectPromptRunTags,
1872
2055
  collectPromptRuns,
1873
2056
  collectProviderChecks,
1874
2057
  collectSceneDerivationRecoveries,
@@ -1904,6 +2087,7 @@ export {
1904
2087
  deriveLineage,
1905
2088
  describableContent,
1906
2089
  describeTargetModelFailure,
2090
+ detailFehlt,
1907
2091
  diagnosticOfFinding,
1908
2092
  diagnosticOfSchemaError,
1909
2093
  differentialSteps,
@@ -1924,6 +2108,7 @@ export {
1924
2108
  formatSeedListe,
1925
2109
  freezeDraftChain,
1926
2110
  freezeSceneWorkingState,
2111
+ fuehreQueueAus,
1927
2112
  generationBatchIdOf,
1928
2113
  gesamtHerkunft,
1929
2114
  getSzenenSchemas,
@@ -1935,17 +2120,24 @@ export {
1935
2120
  isOk,
1936
2121
  isProjectionCurrent,
1937
2122
  isSzenenItemId,
2123
+ istGueltigePause,
2124
+ istOffen,
1938
2125
  istSzenenSnapshotDatei,
1939
2126
  istZipDatei,
1940
2127
  itemIdForRun,
1941
2128
  itemsAusBestand,
1942
2129
  jobsForPromptRun,
2130
+ labelsOf,
1943
2131
  ladeVorschauen,
1944
2132
  leseBilderAusZip,
2133
+ letztesErzeugtesBild,
1945
2134
  linkFor,
2135
+ listElementsPageOver,
1946
2136
  locatorAus,
1947
2137
  locatorTeile,
1948
2138
  logRevisionOf,
2139
+ manualEntryOf,
2140
+ mergeRunTags,
1949
2141
  mergeSnapshotAndPending,
1950
2142
  mergeSzenenBatchOrigin,
1951
2143
  mimeTypAus,
@@ -1954,6 +2146,9 @@ export {
1954
2146
  noticeFor,
1955
2147
  ordersForPromptRun,
1956
2148
  ordneSeedsZu,
2149
+ pageOf,
2150
+ pagePromptRuns,
2151
+ pageRequestFrom,
1957
2152
  parseDerivationResponse,
1958
2153
  parseRunResponse,
1959
2154
  parseSeedListe,
@@ -1962,6 +2157,9 @@ export {
1962
2157
  preferredVersionId,
1963
2158
  preparePromptOperation,
1964
2159
  promptDiagnosticsOf,
2160
+ promptRunPageForTransport,
2161
+ promptRunPageFromTransport,
2162
+ promptRunTagsOf,
1965
2163
  publishedHeadsOf,
1966
2164
  recoveriesForRun,
1967
2165
  recoveryStatusOf,
@@ -1976,6 +2174,7 @@ export {
1976
2174
  resolverFromQueries,
1977
2175
  responseContractOf,
1978
2176
  roundOfRun,
2177
+ roundsOf,
1979
2178
  rulesWithoutPromptEffect,
1980
2179
  runElementStoreContract,
1981
2180
  runOfOperation,
@@ -1988,6 +2187,7 @@ export {
1988
2187
  scenePolicyFingerprint,
1989
2188
  scopeOfPath,
1990
2189
  seedFehlerText,
2190
+ selectImageJobs,
1991
2191
  selectPromptRuns,
1992
2192
  selectableTargetModels,
1993
2193
  showChain,
@@ -1996,6 +2196,7 @@ export {
1996
2196
  sortScenePolicies,
1997
2197
  sourceOf,
1998
2198
  szenenSnapshotFilename,
2199
+ tagRefsAus,
1999
2200
  totalModelCalls,
2000
2201
  typAusBytes,
2001
2202
  unclassifiedPublishRules,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslsp1/fa-app-tools",
3
- "version": "9.0.0",
3
+ "version": "9.4.4",
4
4
  "description": "Shared tools and hooks for Fine Art flow apps",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -29,7 +29,8 @@
29
29
  "build": "node scripts/sync-szenen-styles.js && tsup",
30
30
  "prepublishOnly": "npm run build",
31
31
  "test": "vitest run",
32
- "mutation:szenen": "stryker run stryker.szenen.conf.mjs"
32
+ "mutation:szenen": "stryker run stryker.szenen.conf.mjs",
33
+ "mutation:runintegrity": "stryker run stryker.runintegrity.conf.mjs"
33
34
  },
34
35
  "peerDependencies": {
35
36
  "react": ">=18"