@nimiplatform/app-tools 0.16.0-rc.14 → 0.16.0-rc.18
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 -42
- package/bin/nimi-app.mjs +25 -6
- package/lib/app-dependency-combinations.mjs +1 -0
- package/lib/app-doctor-update.mjs +8 -6
- package/lib/app-info.mjs +39 -19
- package/lib/app-lifecycle-guidance.mjs +1 -1
- package/lib/app-pack.mjs +31 -13
- package/lib/app-project-lifecycle.mjs +32 -12
- package/lib/app-resources.mjs +36 -0
- package/lib/app-scaffold-profiles.mjs +72 -2
- package/lib/app-scaffold.mjs +11 -13
- package/lib/index.mjs +7 -0
- package/lib/public-storefront.mjs +327 -0
- package/lib/storefront-media.mjs +8 -4
- package/lib/storefront-pack.mjs +152 -0
- package/lib/storefront-release-verification.mjs +31 -0
- package/lib/storefront-source.mjs +161 -0
- package/lib/web-coordination.mjs +4 -1
- package/lib/web-scaffold.mjs +3 -3
- package/package.json +9 -6
- package/scripts/sync-app-source.mjs +5 -12
- package/skills/nimi-app-lifecycle/SKILL.md +1 -0
- package/skills/nimi-app-lifecycle/references/storefront.md +28 -0
- package/templates/app-source/src/ai-studio-core/ai-config.ts +12 -0
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +138 -117
- package/templates/app-source/src/ai-studio-core/history.ts +10 -8
- package/templates/app-source/src/ai-studio-core/host-context.tsx +1 -0
- package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +15 -10
- package/templates/app-source/src/ai-studio-core/job-recovery.ts +505 -115
- package/templates/app-source/src/ai-studio-core/messages/en.json +55 -9
- package/templates/app-source/src/ai-studio-core/messages/zh.json +55 -9
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +8 -2
- package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +2 -0
- package/templates/app-source/src/ai-studio-core/parameters.ts +5 -4
- package/templates/app-source/src/ai-studio-core/run-target.ts +12 -1
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +3 -0
- package/templates/app-source/src/ai-studio-core/runtime.ts +50 -12
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +6 -7
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +88 -27
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +33 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-music-result.tsx +2 -2
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +10 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +6 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +121 -40
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +34 -8
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcript-result.tsx +16 -2
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +18 -7
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +1 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +78 -9
- package/templates/app-source/src/ai-studio-core/text-media-replay.ts +2 -1
- package/templates/app-source/src/ai-studio-core/workspace.tsx +138 -3
- package/templates/app-source/src/product-modules/agent-center/index.tsx +19 -3
- package/templates/app-source/src/product-modules/agent-conversation/index.tsx +19 -3
- package/templates/app-source/src/product-modules/agent-realtime/index.tsx +19 -3
- package/templates/app-source/src/product-modules/kit-recipes/gallery.tsx +12 -7
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-surface.tsx +48 -20
- package/templates/app-source/src/studio-modules/studio-create/messages/en.json +2 -2
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +2 -2
- package/templates/app-source/src/studio-modules/studio-create/registration.ts +1 -1
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +11 -19
- package/templates/app-source/src/studio-modules/studio-media/audio-separate-parameters.tsx +7 -4
- package/templates/app-source/src/studio-modules/studio-media/audio-separate-runtime.ts +14 -10
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +3 -1
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +3 -1
- package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +6 -5
- package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx +19 -11
- package/templates/app-source/src/studio-modules/studio-media/music-transcription-runtime.ts +14 -10
- package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +54 -16
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +22 -9
- package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +19 -10
- package/templates/app-source/src/studio-modules/studio-media/voice-convert-parameters.tsx +12 -6
- package/templates/app-source/src/studio-modules/studio-media/voice-convert-runtime.ts +11 -9
- package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +5 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +5 -0
- package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +18 -7
- package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +28 -4
- package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +12 -8
- package/templates/app-source/src/workbench-core/runtime-gate.tsx +171 -44
- package/templates/app-source/src/workbench-core/workbench-core.css +226 -23
- package/templates/app-source/src/workbench-core/workbench-core.tsx +5 -5
- package/templates/app-source.manifest.json +2 -2
- package/templates/default-starter/NIMI_APP.md +11 -3
- package/templates/default-starter.manifest.json +2 -2
- package/templates/storefront-release.yml +97 -0
|
@@ -110,15 +110,15 @@ export function TextStudioComposer({
|
|
|
110
110
|
&& (!profile.requiresParameterInput || hasAlternativeInput)
|
|
111
111
|
&& (!isVisionLocate || (attachments.length === 1 && attachments[0]?.kind === 'image'));
|
|
112
112
|
const intentConfigAction = Boolean(onOpenIntentConfig) && !canDispatch && canConfigureIntent;
|
|
113
|
-
const generateDisabled =
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
const generateDisabled = running || (!intentConfigAction && (
|
|
114
|
+
!promptReady || !canDispatch || (!isVisionLocate && Boolean(attachmentWarning))
|
|
115
|
+
));
|
|
116
116
|
const generateLabel = running
|
|
117
117
|
? t(profile.primaryRunningLabelKey)
|
|
118
118
|
: intentConfigAction
|
|
119
119
|
? t('Studio.composer.configureIntent')
|
|
120
120
|
: t(profile.primaryLabelKey);
|
|
121
|
-
const visibleInputIssue = running ? undefined : inputIssue ?? (!promptReady ? t('Studio.composer.inputRequired') : undefined);
|
|
121
|
+
const visibleInputIssue = running || intentConfigAction ? undefined : inputIssue ?? (!promptReady ? t('Studio.composer.inputRequired') : undefined);
|
|
122
122
|
const hasPromptField = !isReadOnlyComposer && promptEnabled;
|
|
123
123
|
const hasAttachmentControls = profile.supportsAttachments && !isVisionLocate;
|
|
124
124
|
const canRunFromPrompt = hasPromptField && !intentConfigAction && !generateDisabled;
|
|
@@ -213,7 +213,7 @@ export function TextStudioComposer({
|
|
|
213
213
|
id={queryInputId}
|
|
214
214
|
tone="quiet"
|
|
215
215
|
className="rounded-none focus-within:border-transparent focus-within:ring-0"
|
|
216
|
-
textareaClassName="resize-none px-0 py-0 text-[
|
|
216
|
+
textareaClassName="resize-none px-0 py-0 text-[length:var(--nimi-type-body-size)] font-normal leading-relaxed"
|
|
217
217
|
rows={compact ? 2 : 3}
|
|
218
218
|
wrap="soft"
|
|
219
219
|
maxLength={2000}
|
|
@@ -253,8 +253,7 @@ export function TextStudioComposer({
|
|
|
253
253
|
<div className={contextOpen ? 'studio-context studio-context--open' : 'studio-context'}>
|
|
254
254
|
<TextareaField
|
|
255
255
|
tone="quiet"
|
|
256
|
-
|
|
257
|
-
textareaClassName="min-h-[56px] resize-none px-0 py-0 text-[15px] leading-[1.55]"
|
|
256
|
+
textareaClassName="min-h-[56px] resize-none px-2 py-1 text-[length:var(--nimi-type-body-size)] leading-[1.55]"
|
|
258
257
|
rows={compact ? 2 : 3}
|
|
259
258
|
wrap="soft"
|
|
260
259
|
maxLength={1600}
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
AnimatePresence,
|
|
4
|
+
Button,
|
|
5
|
+
Checkbox,
|
|
6
|
+
ConfirmDialog,
|
|
7
|
+
IconButton,
|
|
8
|
+
InlineAlert,
|
|
9
|
+
motion,
|
|
10
|
+
nimiOverlayPanelMotion,
|
|
11
|
+
nimiToast,
|
|
12
|
+
OverlayShell,
|
|
13
|
+
Popover,
|
|
14
|
+
PopoverContent,
|
|
15
|
+
PopoverTrigger,
|
|
16
|
+
useNimiReducedMotion,
|
|
17
|
+
} from '@nimiplatform/kit/ui';
|
|
3
18
|
import { Check, ChevronRight, Ellipsis, FileX, Funnel, GitCompareArrows, RefreshCw, Search, Sparkles, Trash2, X } from 'lucide-react';
|
|
4
19
|
import { useAIStudioHost } from './host-context.js';
|
|
5
20
|
import type { StudioCapabilityRegistration } from './module-registration.js';
|
|
@@ -221,6 +236,13 @@ export function CapabilityRunHistory({
|
|
|
221
236
|
const [comparing, setComparing] = useState(false);
|
|
222
237
|
const [comparisonIds, setComparisonIds] = useState<readonly string[]>([]);
|
|
223
238
|
const [comparisonOpen, setComparisonOpen] = useState(false);
|
|
239
|
+
const [pendingDelete, setPendingDelete] = useState<
|
|
240
|
+
| { kind: 'media'; record: StudioMediaHistoryRecord }
|
|
241
|
+
| { kind: 'document'; record: StudioRunHistoryRecord }
|
|
242
|
+
| null
|
|
243
|
+
>(null);
|
|
244
|
+
const reducedMotion = useNimiReducedMotion();
|
|
245
|
+
const drawerMotion = nimiOverlayPanelMotion({ kind: 'drawer', side: 'right', reducedMotion });
|
|
224
246
|
const scope: StudioHistoryPanelScope = historyPanel?.scope ?? 'capability';
|
|
225
247
|
const hideFailures = historyPanel?.hideFailures ?? false;
|
|
226
248
|
const setScope = (next: StudioHistoryPanelScope) => {
|
|
@@ -274,6 +296,7 @@ export function CapabilityRunHistory({
|
|
|
274
296
|
}
|
|
275
297
|
|
|
276
298
|
function handleRemoveRecord(record: StudioRunHistoryRecord, deleteDocument = false) {
|
|
299
|
+
setComparisonIds((ids) => ids.filter((id) => id !== record.id));
|
|
277
300
|
void historyActions?.removeRecord(record.id, deleteDocument);
|
|
278
301
|
}
|
|
279
302
|
|
|
@@ -291,6 +314,7 @@ export function CapabilityRunHistory({
|
|
|
291
314
|
const source = getStudioRunIntentSource(record);
|
|
292
315
|
if (source === 'local') return t('History.source.local');
|
|
293
316
|
if (source === 'cloud') return t('History.source.cloud');
|
|
317
|
+
if (source === 'external') return t('History.source.external');
|
|
294
318
|
return t('History.source.unknown');
|
|
295
319
|
}
|
|
296
320
|
|
|
@@ -427,15 +451,31 @@ export function CapabilityRunHistory({
|
|
|
427
451
|
setActiveMenu(null);
|
|
428
452
|
}
|
|
429
453
|
|
|
430
|
-
|
|
454
|
+
function handleConfirmPendingDelete() {
|
|
455
|
+
if (!pendingDelete) return;
|
|
456
|
+
const target = pendingDelete;
|
|
457
|
+
setPendingDelete(null);
|
|
458
|
+
if (target.kind === 'media') {
|
|
459
|
+
handleRemoveMediaRecord(target.record);
|
|
460
|
+
} else {
|
|
461
|
+
handleRemoveRecord(target.record, true);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
431
464
|
|
|
432
465
|
return (
|
|
433
|
-
|
|
434
|
-
<
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
466
|
+
<>
|
|
467
|
+
<AnimatePresence initial={false}>
|
|
468
|
+
{!collapsed ? (
|
|
469
|
+
<motion.div
|
|
470
|
+
key="studio-history-panel"
|
|
471
|
+
className="studio-history-shell"
|
|
472
|
+
{...drawerMotion}
|
|
473
|
+
>
|
|
474
|
+
<aside
|
|
475
|
+
className="studio-history"
|
|
476
|
+
aria-label={t('History.panelAriaLabel')}
|
|
477
|
+
onKeyDown={onClose ? (event) => { if (event.key === 'Escape' && !filterOpen && !historyActionsOpen && !pendingDelete) onClose(); } : undefined}
|
|
478
|
+
>
|
|
439
479
|
<div className="studio-recent__head">
|
|
440
480
|
<div className="studio-history__title">
|
|
441
481
|
<strong>{t('History.title')}</strong>
|
|
@@ -681,6 +721,7 @@ export function CapabilityRunHistory({
|
|
|
681
721
|
</span>
|
|
682
722
|
</Button>
|
|
683
723
|
{historyActions ? (
|
|
724
|
+
<div className="studio-recent__row-actions">
|
|
684
725
|
<IconButton
|
|
685
726
|
type="button"
|
|
686
727
|
tone="ghost"
|
|
@@ -688,9 +729,10 @@ export function CapabilityRunHistory({
|
|
|
688
729
|
className="studio-recent__row-delete"
|
|
689
730
|
aria-label={t('History.deleteRecordAndAsset')}
|
|
690
731
|
title={t('History.deleteRecordAndAsset')}
|
|
691
|
-
onClick={() =>
|
|
732
|
+
onClick={() => setPendingDelete({ kind: 'media', record })}
|
|
692
733
|
icon={<Trash2 size={13} strokeWidth={1.9} aria-hidden="true" />}
|
|
693
734
|
/>
|
|
735
|
+
</div>
|
|
694
736
|
) : null}
|
|
695
737
|
</li>
|
|
696
738
|
))}
|
|
@@ -713,8 +755,8 @@ export function CapabilityRunHistory({
|
|
|
713
755
|
return (
|
|
714
756
|
<li key={record.id} className={comparing ? 'studio-recent__compare-row' : undefined}>
|
|
715
757
|
{comparing ? (
|
|
716
|
-
<
|
|
717
|
-
|
|
758
|
+
<Checkbox
|
|
759
|
+
className="studio-recent__compare-checkbox"
|
|
718
760
|
checked={selected}
|
|
719
761
|
disabled={!selected && !selectable}
|
|
720
762
|
aria-label={t('History.selectComparisonRun', { run: historyLabelForRun(record) })}
|
|
@@ -753,6 +795,19 @@ export function CapabilityRunHistory({
|
|
|
753
795
|
</span>
|
|
754
796
|
</Button>
|
|
755
797
|
{historyActions ? (
|
|
798
|
+
<div className="studio-recent__row-actions">
|
|
799
|
+
{studioHistoryDocumentPaths(record).length > 0 ? (
|
|
800
|
+
<IconButton
|
|
801
|
+
type="button"
|
|
802
|
+
tone="ghost"
|
|
803
|
+
size="sm"
|
|
804
|
+
className="studio-recent__row-delete studio-recent__row-delete--document"
|
|
805
|
+
aria-label={t('History.deleteRecordAndDocument')}
|
|
806
|
+
title={t('History.deleteRecordAndDocument')}
|
|
807
|
+
onClick={() => setPendingDelete({ kind: 'document', record })}
|
|
808
|
+
icon={<FileX size={13} strokeWidth={1.9} aria-hidden="true" />}
|
|
809
|
+
/>
|
|
810
|
+
) : null}
|
|
756
811
|
<IconButton
|
|
757
812
|
type="button"
|
|
758
813
|
tone="ghost"
|
|
@@ -763,18 +818,7 @@ export function CapabilityRunHistory({
|
|
|
763
818
|
onClick={() => handleRemoveRecord(record)}
|
|
764
819
|
icon={<Trash2 size={13} strokeWidth={1.9} aria-hidden="true" />}
|
|
765
820
|
/>
|
|
766
|
-
|
|
767
|
-
{historyActions && studioHistoryDocumentPaths(record).length > 0 ? (
|
|
768
|
-
<IconButton
|
|
769
|
-
type="button"
|
|
770
|
-
tone="ghost"
|
|
771
|
-
size="sm"
|
|
772
|
-
className="studio-recent__row-delete studio-recent__row-delete--document"
|
|
773
|
-
aria-label={t('History.deleteRecordAndDocument')}
|
|
774
|
-
title={t('History.deleteRecordAndDocument')}
|
|
775
|
-
onClick={() => handleRemoveRecord(record, true)}
|
|
776
|
-
icon={<FileX size={13} strokeWidth={1.9} aria-hidden="true" />}
|
|
777
|
-
/>
|
|
821
|
+
</div>
|
|
778
822
|
) : null}
|
|
779
823
|
</li>
|
|
780
824
|
);
|
|
@@ -791,7 +835,10 @@ export function CapabilityRunHistory({
|
|
|
791
835
|
</Button>
|
|
792
836
|
) : null}
|
|
793
837
|
</div>
|
|
794
|
-
|
|
838
|
+
</aside>
|
|
839
|
+
</motion.div>
|
|
840
|
+
) : null}
|
|
841
|
+
</AnimatePresence>
|
|
795
842
|
<OverlayShell
|
|
796
843
|
open={comparisonOpen && comparisonRecords.length === 2}
|
|
797
844
|
kind="dialog"
|
|
@@ -804,9 +851,9 @@ export function CapabilityRunHistory({
|
|
|
804
851
|
<div className="grid min-w-0 gap-4 sm:grid-cols-2">
|
|
805
852
|
{comparisonRecords.map(record => {
|
|
806
853
|
const snapshot = record.result;
|
|
807
|
-
const params = record.runConfig ? getStudioRunConfigParamRows(record.runConfig) : [];
|
|
854
|
+
const params = record.runConfig ? getStudioRunConfigParamRows(record.runConfig, undefined, t) : [];
|
|
808
855
|
const defaults = record.runConfig?.target.configuredDefaults
|
|
809
|
-
? getStudioRunConfigParamRows(record.runConfig, record.runConfig.target.configuredDefaults) : [];
|
|
856
|
+
? getStudioRunConfigParamRows(record.runConfig, record.runConfig.target.configuredDefaults, t) : [];
|
|
810
857
|
const jobId = snapshot && 'jobId' in snapshot ? snapshot.jobId : undefined;
|
|
811
858
|
const traceId = record.runConfig?.traceId ?? (snapshot?.ok ? snapshot.traceId : snapshot?.diagnostics?.traceId);
|
|
812
859
|
const output = snapshot?.ok && (snapshot.kind === 'text' || snapshot.kind === 'transcript')
|
|
@@ -844,6 +891,20 @@ export function CapabilityRunHistory({
|
|
|
844
891
|
})}
|
|
845
892
|
</div>
|
|
846
893
|
</OverlayShell>
|
|
847
|
-
|
|
894
|
+
<ConfirmDialog
|
|
895
|
+
open={pendingDelete !== null}
|
|
896
|
+
title={pendingDelete?.kind === 'media'
|
|
897
|
+
? t('History.confirmDeleteAssetTitle')
|
|
898
|
+
: t('History.confirmDeleteDocumentTitle')}
|
|
899
|
+
message={pendingDelete?.kind === 'media'
|
|
900
|
+
? t('History.confirmDeleteAssetMessage')
|
|
901
|
+
: t('History.confirmDeleteDocumentMessage')}
|
|
902
|
+
confirmLabel={t('History.confirmDeleteAction')}
|
|
903
|
+
cancelLabel={t('History.cancelDeleteAction')}
|
|
904
|
+
confirmTone="danger"
|
|
905
|
+
onConfirm={handleConfirmPendingDelete}
|
|
906
|
+
onClose={() => setPendingDelete(null)}
|
|
907
|
+
/>
|
|
908
|
+
</>
|
|
848
909
|
);
|
|
849
910
|
}
|
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
import type { StudioResultKind } from './module-registration.js';
|
|
2
2
|
import type { NimiAIConfigSnapshot } from '@nimiplatform/sdk/ai';
|
|
3
3
|
|
|
4
|
+
export const STUDIO_TEXT_MEDIA_MIMES = [
|
|
5
|
+
'image/jpeg',
|
|
6
|
+
'image/png',
|
|
7
|
+
'image/webp',
|
|
8
|
+
'image/gif',
|
|
9
|
+
'audio/wav',
|
|
10
|
+
'audio/mpeg',
|
|
11
|
+
'video/mp4',
|
|
12
|
+
] as const;
|
|
13
|
+
|
|
14
|
+
export type StudioTextMediaMime = (typeof STUDIO_TEXT_MEDIA_MIMES)[number];
|
|
15
|
+
|
|
16
|
+
const STUDIO_TEXT_MEDIA_EXTENSIONS: Readonly<Record<StudioTextMediaMime, string>> = {
|
|
17
|
+
'image/jpeg': 'jpg',
|
|
18
|
+
'image/png': 'png',
|
|
19
|
+
'image/webp': 'webp',
|
|
20
|
+
'image/gif': 'gif',
|
|
21
|
+
'audio/wav': 'wav',
|
|
22
|
+
'audio/mpeg': 'mp3',
|
|
23
|
+
'video/mp4': 'mp4',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function isSupportedStudioTextMediaMime(value: string): value is StudioTextMediaMime {
|
|
27
|
+
return (STUDIO_TEXT_MEDIA_MIMES as readonly string[]).includes(value);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function studioTextMediaExtension(mimeType: StudioTextMediaMime): string {
|
|
31
|
+
return STUDIO_TEXT_MEDIA_EXTENSIONS[mimeType];
|
|
32
|
+
}
|
|
33
|
+
|
|
4
34
|
export function textStudioMediaInputAvailable(snapshot: NimiAIConfigSnapshot, mediaType?: string): boolean {
|
|
5
35
|
const required = mediaType ? mediaType.startsWith('image/') ? 'input.image' : mediaType.startsWith('audio/') ? 'input.audio' : mediaType.startsWith('video/') ? 'input.video' : '' : undefined;
|
|
6
36
|
if (required === '') return false;
|
|
@@ -13,6 +43,9 @@ export function textStudioMediaInputAvailable(snapshot: NimiAIConfigSnapshot, me
|
|
|
13
43
|
if (resource?.oneofKind === 'local') {
|
|
14
44
|
return resource.local.state === 'ready' && (required ? resource.local.configuredFeatures.includes(required) && resource.local.implementationSupportedFeatures.includes(required) : ['input.image', 'input.audio', 'input.video'].some((feature) => resource.local.configuredFeatures.includes(feature) && resource.local.implementationSupportedFeatures.includes(feature)));
|
|
15
45
|
}
|
|
46
|
+
if (resource?.oneofKind === 'external') {
|
|
47
|
+
return resource.external.target.state === 'ready' && (required ? resource.external.target.supportedFeatures.includes(required) : ['input.image', 'input.audio', 'input.video'].some((feature) => resource.external.target.supportedFeatures.includes(feature)));
|
|
48
|
+
}
|
|
16
49
|
return false;
|
|
17
50
|
}
|
|
18
51
|
|
|
@@ -34,10 +34,10 @@ export function MusicGenerationNotice({ value }: { readonly value?: StudioMusicG
|
|
|
34
34
|
<p>{t(value.termination === 'model-end' ? 'Music.terminationModelEnd' : value.termination === 'budget-limit' ? 'Music.terminationBudget' : 'Music.terminationUnknown')}</p>
|
|
35
35
|
{value.generatedScore?.truncated ? <p>{t('Music.scoreTruncated')}</p> : null}
|
|
36
36
|
{scorePath ? <div className="space-y-2">
|
|
37
|
-
<Button onClick={() => setExpanded((current) => !current)}>{t(expanded ? 'Music.hideScore' : 'Music.viewScore')}</Button>
|
|
37
|
+
<Button size="sm" tone="secondary" onClick={() => setExpanded((current) => !current)}>{t(expanded ? 'Music.hideScore' : 'Music.viewScore')}</Button>
|
|
38
38
|
{expanded && score ? <>
|
|
39
39
|
<TextareaField value={score} readOnly textareaClassName="min-h-40 font-mono" aria-label={t('Music.generatedPlan')} />
|
|
40
|
-
<Button onClick={() => void downloadTextFile(host, 'generated-score.abc', score)}>{t('Music.exportScore')}</Button>
|
|
40
|
+
<Button size="sm" tone="secondary" onClick={() => void downloadTextFile(host, 'generated-score.abc', score)}>{t('Music.exportScore')}</Button>
|
|
41
41
|
</> : null}
|
|
42
42
|
{error ? <p role="alert">{error}</p> : null}
|
|
43
43
|
</div> : null}
|
|
@@ -105,10 +105,16 @@ export function formatTypedOutput(
|
|
|
105
105
|
|
|
106
106
|
// A Job the owner already issued stays locatable after a non-success, but
|
|
107
107
|
// Runtime retains it only for its own retention period.
|
|
108
|
-
export function KnownJobNotice({ jobId }: {
|
|
108
|
+
export function KnownJobNotice({ jobId, recoveryCleanupUnconfirmed }: {
|
|
109
|
+
readonly jobId?: string;
|
|
110
|
+
readonly recoveryCleanupUnconfirmed?: true;
|
|
111
|
+
}) {
|
|
109
112
|
const { translate: t } = useAIStudioHost();
|
|
110
113
|
if (!jobId) return null;
|
|
111
|
-
return
|
|
114
|
+
return <>
|
|
115
|
+
<p className="studio-result__hint">{t('StudioResults.job.known', { jobId })}</p>
|
|
116
|
+
{recoveryCleanupUnconfirmed ? <p className="studio-result__hint" role="status">{t('StudioResults.job.recoveryCleanupUnconfirmed')}</p> : null}
|
|
117
|
+
</>;
|
|
112
118
|
}
|
|
113
119
|
|
|
114
120
|
export function EmbeddingResultBody({ spaceId, retrieval }: { readonly spaceId?: string; readonly retrieval?: StudioEmbeddingRetrieval }) {
|
|
@@ -398,8 +404,9 @@ function splitSubjectLine(text: string): { subject: string; body: string } | nul
|
|
|
398
404
|
};
|
|
399
405
|
}
|
|
400
406
|
|
|
401
|
-
export function TextStudioOutputBody({ text }: { text: string }) {
|
|
407
|
+
export function TextStudioOutputBody({ text, finishReason }: { text: string; finishReason?: string }) {
|
|
402
408
|
const { translate: t } = useAIStudioHost();
|
|
409
|
+
if (!text.trim() && finishReason?.toLowerCase() === 'length') return <p className="studio-result__hint">{t('StudioShell.outputLimitReached')}</p>;
|
|
403
410
|
const emptyBody = t('StudioShell.emptyBody');
|
|
404
411
|
const value = text || emptyBody;
|
|
405
412
|
const subject = splitSubjectLine(value);
|
|
@@ -37,7 +37,7 @@ function TextStudioPromptControlFacts({ facts }: { facts: readonly StudioRunProm
|
|
|
37
37
|
function TextStudioPromptSettings({ activeRun }: { activeRun: TextStudioActiveRun }) {
|
|
38
38
|
const { translate: t } = useAIStudioHost();
|
|
39
39
|
const runConfig = activeRun.record?.runConfig;
|
|
40
|
-
const facts = runConfig ? getStudioRunPromptControlFacts(runConfig) : [];
|
|
40
|
+
const facts = runConfig ? getStudioRunPromptControlFacts(runConfig, t) : [];
|
|
41
41
|
const context = (runConfig?.promptControls.context ?? activeRun.context).trim();
|
|
42
42
|
if (facts.length === 0 && !context) return null;
|
|
43
43
|
return (
|
|
@@ -70,9 +70,9 @@ function TextStudioRequestSettings({ record }: { record: StudioRunHistoryRecord
|
|
|
70
70
|
const { translate: t } = useAIStudioHost();
|
|
71
71
|
const runConfig = record.runConfig;
|
|
72
72
|
const target = runConfig?.target;
|
|
73
|
-
const paramGroups = runConfig ? groupParamRows(getStudioRunConfigParamRows(runConfig)) : [];
|
|
73
|
+
const paramGroups = runConfig ? groupParamRows(getStudioRunConfigParamRows(runConfig, undefined, t)) : [];
|
|
74
74
|
const defaults = runConfig && target?.configuredDefaults
|
|
75
|
-
? getStudioRunConfigParamRows(runConfig, target.configuredDefaults) : [];
|
|
75
|
+
? getStudioRunConfigParamRows(runConfig, target.configuredDefaults, t) : [];
|
|
76
76
|
const snapshot = record.result;
|
|
77
77
|
const jobId = snapshot && 'jobId' in snapshot ? snapshot.jobId : undefined;
|
|
78
78
|
const traceId = runConfig?.traceId ?? (snapshot?.ok ? snapshot.traceId : snapshot?.diagnostics?.traceId);
|
|
@@ -314,7 +314,7 @@ function TextStudioHistorySnapshotBody({ snapshot, recordId, submittedParameters
|
|
|
314
314
|
if (snapshot.kind === 'text') {
|
|
315
315
|
return <div className="studio-result__rich">
|
|
316
316
|
{snapshot.sourceImage ? <ArtifactMediaPreview artifact={snapshot.sourceImage} fallbackLabel={snapshot.sourceImage.displayName || snapshot.sourceImage.relativePath} /> : null}
|
|
317
|
-
<TextStudioOutputBody text={snapshot.body} />
|
|
317
|
+
<TextStudioOutputBody text={snapshot.body} finishReason={snapshot.finishReason} />
|
|
318
318
|
</div>;
|
|
319
319
|
}
|
|
320
320
|
if (snapshot.kind === 'transcript') {
|
|
@@ -485,7 +485,9 @@ export function TextStudioResultState({
|
|
|
485
485
|
createdAt={activeRun.createdAt}
|
|
486
486
|
intentLabel={intentLabel}
|
|
487
487
|
streamingText={streamingText}
|
|
488
|
+
jobId={activeRun.jobId}
|
|
488
489
|
jobStatus={activeRun.jobStatus}
|
|
490
|
+
jobProgress={activeRun.jobProgress}
|
|
489
491
|
verboseConsole={verboseConsole}
|
|
490
492
|
onCopy={onCopy}
|
|
491
493
|
onDownload={onDownload}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
runtimeAIConfigStructToJson,
|
|
4
|
+
type NimiAIConfigEffectiveSelection,
|
|
5
|
+
type NimiAIConfigSnapshot,
|
|
6
|
+
} from '@nimiplatform/sdk/ai';
|
|
3
7
|
|
|
4
8
|
import { findStudioCapabilityIntent } from './ai-config.js';
|
|
5
9
|
import { useAIStudioHost } from './host-context.js';
|
|
@@ -21,12 +25,20 @@ import {
|
|
|
21
25
|
import type { StudioTranslate } from './non-success-presentation.js';
|
|
22
26
|
import type { StudioParameterValue } from './parameters.js';
|
|
23
27
|
|
|
28
|
+
export type StudioJobProgress = {
|
|
29
|
+
readonly percent: number;
|
|
30
|
+
readonly currentStep: number;
|
|
31
|
+
readonly totalSteps: number;
|
|
32
|
+
};
|
|
33
|
+
|
|
24
34
|
export type TextStudioActiveRun = {
|
|
25
35
|
attachmentCount?: number;
|
|
26
36
|
replayMedia?: StudioManagedArtifact;
|
|
27
37
|
// Latest submission's session-only input; history never stores these bytes.
|
|
28
38
|
submittedParameters?: StudioParameterValue;
|
|
39
|
+
jobId?: string;
|
|
29
40
|
jobStatus?: 'queued' | 'running';
|
|
41
|
+
jobProgress?: StudioJobProgress;
|
|
30
42
|
id: string;
|
|
31
43
|
prompt: string;
|
|
32
44
|
context: string;
|
|
@@ -64,12 +76,14 @@ export function textStudioRunTargetIntentSummary(
|
|
|
64
76
|
}
|
|
65
77
|
|
|
66
78
|
export function studioConfiguredTargetLabel(
|
|
67
|
-
target: Pick<StudioRunTargetSummary, 'source' | 'targetLabel'> | undefined,
|
|
79
|
+
target: (Pick<StudioRunTargetSummary, 'source' | 'targetLabel'> & Partial<Pick<StudioRunTargetSummary, 'status'>>) | undefined,
|
|
68
80
|
translate: StudioTranslate,
|
|
69
81
|
): string {
|
|
82
|
+
if (target?.status === 'checking') return translate('Studio.composer.checkingTarget');
|
|
70
83
|
const route = target?.source === 'local' ? translate('Studio.composer.routeLocal')
|
|
71
84
|
: target?.source === 'cloud' ? translate('Studio.composer.routeCloud')
|
|
72
|
-
: translate('Studio.composer.
|
|
85
|
+
: target?.source === 'external' ? translate('Studio.composer.routeExternal')
|
|
86
|
+
: translate('Studio.composer.routeUnknown');
|
|
73
87
|
return target?.targetLabel ? `${route} · ${target.targetLabel}` : route;
|
|
74
88
|
}
|
|
75
89
|
|
|
@@ -77,72 +91,139 @@ export function canConfigureRunTarget(runTarget: StudioRunTargetSummary): boolea
|
|
|
77
91
|
return !runTarget.canDispatch && runTarget.status === 'blocked' && Boolean(runTarget.capabilityContract);
|
|
78
92
|
}
|
|
79
93
|
|
|
94
|
+
let fallbackScopeSeq = 1;
|
|
95
|
+
const fallbackScopeIds = new WeakMap<object, string>();
|
|
96
|
+
|
|
97
|
+
function resolveRunTargetScopeKey(host: ReturnType<typeof useAIStudioHost>): string {
|
|
98
|
+
if (host.sessionScopeKey) return host.sessionScopeKey;
|
|
99
|
+
const existing = fallbackScopeIds.get(host.sdk.aiConfig);
|
|
100
|
+
if (existing) return existing;
|
|
101
|
+
const assigned = `studio-ai-config-${fallbackScopeSeq++}`;
|
|
102
|
+
fallbackScopeIds.set(host.sdk.aiConfig, assigned);
|
|
103
|
+
return assigned;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export type StudioTargetRefreshWaitResult =
|
|
107
|
+
| { readonly waited: false }
|
|
108
|
+
| { readonly waited: true; readonly snapshot: NimiAIConfigSnapshot | null };
|
|
109
|
+
|
|
80
110
|
export function useStudioRunTargetSummary(
|
|
81
111
|
registration: StudioCapabilityRegistration,
|
|
82
112
|
runtime: StudioRuntimeInspection | null,
|
|
83
|
-
): StudioRunTargetSummary & {
|
|
113
|
+
): StudioRunTargetSummary & {
|
|
114
|
+
readonly snapshot: NimiAIConfigSnapshot | null;
|
|
115
|
+
readonly effectiveSelection: NimiAIConfigEffectiveSelection | undefined;
|
|
116
|
+
readonly configReadFailed: boolean;
|
|
117
|
+
readonly waitForTargetRefresh: (verifyLocalSelection: boolean) => Promise<StudioTargetRefreshWaitResult>;
|
|
118
|
+
} {
|
|
84
119
|
const host = useAIStudioHost();
|
|
120
|
+
const hostRef = useRef(host);
|
|
121
|
+
hostRef.current = host;
|
|
122
|
+
const scopeKey = resolveRunTargetScopeKey(host);
|
|
123
|
+
const inFlightRefreshRef = useRef<{ settled: Promise<void>; release: () => void } | null>(null);
|
|
124
|
+
const lastRefresh = useRef<{ scopeKey: string; snapshot: NimiAIConfigSnapshot | null } | null>(null);
|
|
85
125
|
const [configProjection, setConfigProjection] = useState<{
|
|
126
|
+
scopeKey: string;
|
|
86
127
|
state: 'loading' | 'loaded' | 'failed';
|
|
87
128
|
snapshot: NimiAIConfigSnapshot | null;
|
|
88
129
|
error: string | null;
|
|
89
|
-
}>({ state: 'loading', snapshot: null, error: null });
|
|
130
|
+
}>({ scopeKey, state: 'loading', snapshot: null, error: null });
|
|
90
131
|
|
|
91
|
-
|
|
92
|
-
let
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
132
|
+
const refresh = useCallback((preserveSnapshot: boolean) => {
|
|
133
|
+
let release!: () => void;
|
|
134
|
+
const settled = new Promise<void>(resolve => { release = resolve; });
|
|
135
|
+
const pending = { settled, release };
|
|
136
|
+
const previous = inFlightRefreshRef.current;
|
|
137
|
+
inFlightRefreshRef.current = pending;
|
|
138
|
+
// A submission waiting on a superseded refresh can now await the latest one.
|
|
139
|
+
previous?.release();
|
|
140
|
+
if (!preserveSnapshot) {
|
|
141
|
+
setConfigProjection({ scopeKey, state: 'loading', snapshot: null, error: null });
|
|
142
|
+
}
|
|
143
|
+
void hostRef.current.sdk.aiConfig.getSnapshot()
|
|
144
|
+
.then((next) => {
|
|
145
|
+
if (inFlightRefreshRef.current !== pending) return;
|
|
146
|
+
lastRefresh.current = { scopeKey, snapshot: next };
|
|
147
|
+
setConfigProjection({ scopeKey, state: 'loaded', snapshot: next, error: null });
|
|
148
|
+
})
|
|
149
|
+
.catch((cause) => {
|
|
150
|
+
if (inFlightRefreshRef.current !== pending) return;
|
|
151
|
+
lastRefresh.current = { scopeKey, snapshot: null };
|
|
152
|
+
setConfigProjection({
|
|
153
|
+
scopeKey,
|
|
154
|
+
state: 'failed',
|
|
155
|
+
snapshot: null,
|
|
156
|
+
error: cause instanceof Error ? cause.message : String(cause || hostRef.current.translate('Studio.run.aiConfigLoadFailed')),
|
|
111
157
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
158
|
+
})
|
|
159
|
+
.finally(() => {
|
|
160
|
+
if (inFlightRefreshRef.current === pending) {
|
|
161
|
+
inFlightRefreshRef.current = null;
|
|
162
|
+
}
|
|
163
|
+
pending.release();
|
|
164
|
+
});
|
|
165
|
+
}, [scopeKey]);
|
|
166
|
+
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
refresh(lastRefresh.current?.scopeKey === scopeKey);
|
|
169
|
+
const unsubscribe = hostRef.current.app.events.subscribeAIConfigRefresh(() => refresh(true));
|
|
115
170
|
return () => {
|
|
116
|
-
|
|
117
|
-
|
|
171
|
+
inFlightRefreshRef.current?.release();
|
|
172
|
+
inFlightRefreshRef.current = null;
|
|
118
173
|
unsubscribe();
|
|
119
174
|
};
|
|
120
|
-
}, [
|
|
175
|
+
}, [scopeKey, refresh, registration.descriptor.id]);
|
|
176
|
+
|
|
177
|
+
const waitForTargetRefresh = useCallback(async (verifyLocalSelection: boolean): Promise<StudioTargetRefreshWaitResult> => {
|
|
178
|
+
// A machine selection can change without this App receiving a window-focus event.
|
|
179
|
+
if (verifyLocalSelection && !inFlightRefreshRef.current) refresh(true);
|
|
180
|
+
if (!inFlightRefreshRef.current) return { waited: false };
|
|
181
|
+
while (inFlightRefreshRef.current) {
|
|
182
|
+
await inFlightRefreshRef.current.settled;
|
|
183
|
+
}
|
|
184
|
+
return { waited: true, snapshot: lastRefresh.current?.scopeKey === scopeKey ? lastRefresh.current.snapshot : null };
|
|
185
|
+
}, [scopeKey, refresh]);
|
|
121
186
|
|
|
122
187
|
return useMemo(() => {
|
|
123
|
-
const
|
|
188
|
+
const scopeMatches = configProjection.scopeKey === scopeKey;
|
|
189
|
+
const projectionState = scopeMatches ? configProjection.state : 'loading';
|
|
190
|
+
const snapshot = scopeMatches ? configProjection.snapshot : null;
|
|
191
|
+
const projectionError = scopeMatches ? configProjection.error : null;
|
|
124
192
|
const config = snapshot?.config ?? null;
|
|
125
193
|
const target = host.app.projection.projectRunTarget({
|
|
126
194
|
capability: registration.descriptor,
|
|
127
195
|
runtime,
|
|
128
196
|
config,
|
|
129
|
-
configState:
|
|
130
|
-
configError:
|
|
197
|
+
configState: projectionState,
|
|
198
|
+
configError: projectionError,
|
|
131
199
|
});
|
|
132
|
-
const
|
|
200
|
+
const effectiveSelection = target.capabilityContract
|
|
201
|
+
? snapshot?.effectiveSelections.find((item) => item.capabilityContract === target.capabilityContract)
|
|
202
|
+
: undefined;
|
|
203
|
+
const readState = {
|
|
204
|
+
snapshot,
|
|
205
|
+
effectiveSelection,
|
|
206
|
+
configReadFailed: projectionState === 'failed',
|
|
207
|
+
waitForTargetRefresh,
|
|
208
|
+
};
|
|
133
209
|
if (!target.capabilityContract || !target.canDispatch) return { ...target, ...readState };
|
|
134
|
-
const selection =
|
|
210
|
+
const selection = effectiveSelection;
|
|
135
211
|
const resource = selection?.resource;
|
|
136
212
|
const intent = findStudioCapabilityIntent(config, target.capabilityContract);
|
|
137
213
|
const configuredCloudModel = intent?.route.oneofKind === 'cloud'
|
|
138
214
|
? runtimeAIConfigStructToJson(intent.route.cloud.providerModelTarget).providerModelId
|
|
139
215
|
: undefined;
|
|
216
|
+
const configuredExternalTarget = intent?.route.oneofKind === 'external'
|
|
217
|
+
? intent.route.external.targetRef
|
|
218
|
+
: undefined;
|
|
140
219
|
const label = resource?.oneofKind === 'local' ? resource.local.label
|
|
141
220
|
: resource?.oneofKind === 'cloud' ? resource.cloud.target.label
|
|
142
|
-
:
|
|
221
|
+
: resource?.oneofKind === 'external' ? resource.external.target.displayName
|
|
222
|
+
: configuredCloudModel ?? configuredExternalTarget;
|
|
143
223
|
const targetLabel = typeof label === 'string' && label.trim() ? label : undefined;
|
|
144
224
|
const targetRef = resource?.oneofKind === 'local' ? resource.local.loadoutRef
|
|
145
|
-
:
|
|
225
|
+
: resource?.oneofKind === 'external' ? `${resource.external.executor.executorRef}:${resource.external.target.targetRef}`
|
|
226
|
+
: typeof configuredCloudModel === 'string' ? configuredCloudModel : configuredExternalTarget;
|
|
146
227
|
const recordedConfig = {
|
|
147
228
|
targetLabel,
|
|
148
229
|
targetRef,
|
|
@@ -153,7 +234,7 @@ export function useStudioRunTargetSummary(
|
|
|
153
234
|
detail: host.translate('Studio.run.effectiveTargetUnavailable') };
|
|
154
235
|
}
|
|
155
236
|
return { ...target, ...readState, ...recordedConfig };
|
|
156
|
-
}, [configProjection, host, registration.descriptor, runtime]);
|
|
237
|
+
}, [configProjection, host, registration.descriptor, runtime, scopeKey, waitForTargetRefresh]);
|
|
157
238
|
}
|
|
158
239
|
|
|
159
240
|
export type TextStudioPromptStyle = { tone: string; length: string };
|