@rslsp1/fa-app-tools 1.0.3 → 1.0.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/index.d.mts CHANGED
@@ -93,6 +93,34 @@ declare function parsePromptResponse(raw: string): {
93
93
  prompt: string;
94
94
  feedback: string | null;
95
95
  };
96
+ interface FlowSdk {
97
+ generate: {
98
+ image: (options: Record<string, any>) => Promise<{
99
+ base64: string;
100
+ mediaId: string;
101
+ }>;
102
+ text: (prompt: string, options?: Record<string, any>) => Promise<{
103
+ text: string;
104
+ }>;
105
+ };
106
+ download: (args: {
107
+ base64: string;
108
+ mimeType: string;
109
+ filename: string;
110
+ }) => Promise<void>;
111
+ media: {
112
+ selectMultiple: (args: {
113
+ filter: string;
114
+ }) => Promise<any[]>;
115
+ };
116
+ }
117
+ declare function createFlowServices(Flow: FlowSdk): {
118
+ generateImage: (options: Record<string, any>) => Promise<{
119
+ base64: string;
120
+ mediaId: string;
121
+ }>;
122
+ generateText: (hierarchyText: string, mode?: "literal" | "creative") => Promise<string>;
123
+ };
96
124
  declare function interpretSdkError(err: any): Error;
97
125
 
98
126
  interface ExtractedCharacter {
@@ -269,4 +297,4 @@ interface ProjectSyncTabProps {
269
297
  }
270
298
  declare const ProjectSyncTab: React.FC<ProjectSyncTabProps>;
271
299
 
272
- export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type ExtractedCharacter, FaToolsBadge, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectMeta, type ProjectSettings, ProjectSyncTab, PromptTab, SectionLabel, type SelectedTag, SetupPanel, type SyncDiff, type TagOption, type WorkspaceTags, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, buildPromptTabPayload, cleanAiResponse, exportProjectToZip, formatTreeToMarkdown, getFormattedTimestamp, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, parsePromptResponse, useKeyboardNavigation, useOnClickOutside };
300
+ export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type ExtractedCharacter, FaToolsBadge, type FlowSdk, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectMeta, type ProjectSettings, ProjectSyncTab, PromptTab, SectionLabel, type SelectedTag, SetupPanel, type SyncDiff, type TagOption, type WorkspaceTags, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, buildPromptTabPayload, cleanAiResponse, createFlowServices, exportProjectToZip, formatTreeToMarkdown, getFormattedTimestamp, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, parsePromptResponse, useKeyboardNavigation, useOnClickOutside };
package/dist/index.d.ts CHANGED
@@ -93,6 +93,34 @@ declare function parsePromptResponse(raw: string): {
93
93
  prompt: string;
94
94
  feedback: string | null;
95
95
  };
96
+ interface FlowSdk {
97
+ generate: {
98
+ image: (options: Record<string, any>) => Promise<{
99
+ base64: string;
100
+ mediaId: string;
101
+ }>;
102
+ text: (prompt: string, options?: Record<string, any>) => Promise<{
103
+ text: string;
104
+ }>;
105
+ };
106
+ download: (args: {
107
+ base64: string;
108
+ mimeType: string;
109
+ filename: string;
110
+ }) => Promise<void>;
111
+ media: {
112
+ selectMultiple: (args: {
113
+ filter: string;
114
+ }) => Promise<any[]>;
115
+ };
116
+ }
117
+ declare function createFlowServices(Flow: FlowSdk): {
118
+ generateImage: (options: Record<string, any>) => Promise<{
119
+ base64: string;
120
+ mediaId: string;
121
+ }>;
122
+ generateText: (hierarchyText: string, mode?: "literal" | "creative") => Promise<string>;
123
+ };
96
124
  declare function interpretSdkError(err: any): Error;
97
125
 
98
126
  interface ExtractedCharacter {
@@ -269,4 +297,4 @@ interface ProjectSyncTabProps {
269
297
  }
270
298
  declare const ProjectSyncTab: React.FC<ProjectSyncTabProps>;
271
299
 
272
- export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type ExtractedCharacter, FaToolsBadge, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectMeta, type ProjectSettings, ProjectSyncTab, PromptTab, SectionLabel, type SelectedTag, SetupPanel, type SyncDiff, type TagOption, type WorkspaceTags, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, buildPromptTabPayload, cleanAiResponse, exportProjectToZip, formatTreeToMarkdown, getFormattedTimestamp, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, parsePromptResponse, useKeyboardNavigation, useOnClickOutside };
300
+ export { AvatarArchitectApp, type AvatarArchitectAppProps, CollapsibleCard, CompactDropdown, type ExtractedCharacter, FaToolsBadge, type FlowSdk, GLOBAL_STYLES, type Generation, HistoryPanel, InspectPanel, ListView, type MediaItem, MediaLibrary, PillButton, type ProjectMeta, type ProjectSettings, ProjectSyncTab, PromptTab, SectionLabel, type SelectedTag, SetupPanel, type SyncDiff, type TagOption, type WorkspaceTags, buildFallbackPrompt, buildGenerationPrompt, buildImageGenerationOptions, buildPromptTabPayload, cleanAiResponse, createFlowServices, exportProjectToZip, formatTreeToMarkdown, getFormattedTimestamp, importProjectFromZip, injectXMPMetadata, interpretSdkError, parsePromptFile, parsePromptResponse, useKeyboardNavigation, useOnClickOutside };
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ __export(index_exports, {
49
49
  buildImageGenerationOptions: () => buildImageGenerationOptions,
50
50
  buildPromptTabPayload: () => buildPromptTabPayload,
51
51
  cleanAiResponse: () => cleanAiResponse,
52
+ createFlowServices: () => createFlowServices,
52
53
  exportProjectToZip: () => exportProjectToZip,
53
54
  formatTreeToMarkdown: () => formatTreeToMarkdown,
54
55
  getFormattedTimestamp: () => getFormattedTimestamp,
@@ -415,6 +416,33 @@ function parsePromptResponse(raw) {
415
416
  }
416
417
  return { prompt: cleaned, feedback: null };
417
418
  }
419
+ function createFlowServices(Flow) {
420
+ return {
421
+ generateImage: async (options) => {
422
+ try {
423
+ const result = await Flow.generate.image(options);
424
+ if (!result?.base64) throw new Error("Keine Bilddaten vom SDK erhalten.");
425
+ return { base64: result.base64, mediaId: result.mediaId };
426
+ } catch (err) {
427
+ throw interpretSdkError(err);
428
+ }
429
+ },
430
+ generateText: async (hierarchyText, mode = "creative") => {
431
+ const prompt = buildGenerationPrompt(hierarchyText, mode);
432
+ try {
433
+ const response = await Flow.generate.text(prompt, {
434
+ thinkingLevel: "low",
435
+ systemInstruction: "You are an expert prompt engineer. Always return ONLY the generated prompt text, no headers, no quotes, no conversational filler."
436
+ });
437
+ const result = response?.text?.trim() || "";
438
+ if (!result) throw new Error("Empty AI response");
439
+ return cleanAiResponse(result);
440
+ } catch {
441
+ return buildFallbackPrompt(hierarchyText);
442
+ }
443
+ }
444
+ };
445
+ }
418
446
  function interpretSdkError(err) {
419
447
  const msg = err?.message || "Generierung fehlgeschlagen";
420
448
  if (msg.includes("PUBLIC_ERROR_SOMETHING_WENT_WRONG")) {
@@ -2645,6 +2673,7 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
2645
2673
  buildImageGenerationOptions,
2646
2674
  buildPromptTabPayload,
2647
2675
  cleanAiResponse,
2676
+ createFlowServices,
2648
2677
  exportProjectToZip,
2649
2678
  formatTreeToMarkdown,
2650
2679
  getFormattedTimestamp,
package/dist/index.mjs CHANGED
@@ -351,6 +351,33 @@ function parsePromptResponse(raw) {
351
351
  }
352
352
  return { prompt: cleaned, feedback: null };
353
353
  }
354
+ function createFlowServices(Flow) {
355
+ return {
356
+ generateImage: async (options) => {
357
+ try {
358
+ const result = await Flow.generate.image(options);
359
+ if (!result?.base64) throw new Error("Keine Bilddaten vom SDK erhalten.");
360
+ return { base64: result.base64, mediaId: result.mediaId };
361
+ } catch (err) {
362
+ throw interpretSdkError(err);
363
+ }
364
+ },
365
+ generateText: async (hierarchyText, mode = "creative") => {
366
+ const prompt = buildGenerationPrompt(hierarchyText, mode);
367
+ try {
368
+ const response = await Flow.generate.text(prompt, {
369
+ thinkingLevel: "low",
370
+ systemInstruction: "You are an expert prompt engineer. Always return ONLY the generated prompt text, no headers, no quotes, no conversational filler."
371
+ });
372
+ const result = response?.text?.trim() || "";
373
+ if (!result) throw new Error("Empty AI response");
374
+ return cleanAiResponse(result);
375
+ } catch {
376
+ return buildFallbackPrompt(hierarchyText);
377
+ }
378
+ }
379
+ };
380
+ }
354
381
  function interpretSdkError(err) {
355
382
  const msg = err?.message || "Generierung fehlgeschlagen";
356
383
  if (msg.includes("PUBLIC_ERROR_SOMETHING_WENT_WRONG")) {
@@ -2580,6 +2607,7 @@ export {
2580
2607
  buildImageGenerationOptions,
2581
2608
  buildPromptTabPayload,
2582
2609
  cleanAiResponse,
2610
+ createFlowServices,
2583
2611
  exportProjectToZip,
2584
2612
  formatTreeToMarkdown,
2585
2613
  getFormattedTimestamp,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslsp1/fa-app-tools",
3
- "version": "1.0.3",
3
+ "version": "1.0.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",