@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
|
@@ -1,18 +1,34 @@
|
|
|
1
|
-
import { useMemo, type ComponentProps } from 'react';
|
|
1
|
+
import { useEffect, useMemo, useState, type ComponentProps } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
AppConversationEntry,
|
|
4
4
|
createBrowserAppConversationHostPort,
|
|
5
5
|
} from '@nimiplatform/kit/features/chat';
|
|
6
6
|
|
|
7
|
+
function useDocumentLanguage(explicit?: string): string {
|
|
8
|
+
const [docLang, setDocLang] = useState(() => globalThis.document?.documentElement.lang || 'en');
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (explicit) return undefined;
|
|
11
|
+
const root = globalThis.document?.documentElement;
|
|
12
|
+
if (!root || typeof MutationObserver === 'undefined') return undefined;
|
|
13
|
+
const sync = () => setDocLang(root.lang || 'en');
|
|
14
|
+
sync();
|
|
15
|
+
const observer = new MutationObserver(sync);
|
|
16
|
+
observer.observe(root, { attributes: true, attributeFilter: ['lang'] });
|
|
17
|
+
return () => observer.disconnect();
|
|
18
|
+
}, [explicit]);
|
|
19
|
+
return explicit || docLang;
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-019c
|
|
8
23
|
// @nimi-authority: rule.nimi.runtime.agent-participation.r093
|
|
9
|
-
export function AgentConversationCapability(props: { readonly client: ComponentProps<typeof AppConversationEntry>['client'] }) {
|
|
24
|
+
export function AgentConversationCapability(props: { readonly client: ComponentProps<typeof AppConversationEntry>['client']; readonly language?: string }) {
|
|
25
|
+
const language = useDocumentLanguage(props.language);
|
|
10
26
|
const hostPort = useMemo(() => createBrowserAppConversationHostPort(), []);
|
|
11
27
|
return (
|
|
12
28
|
<AppConversationEntry
|
|
13
29
|
client={props.client}
|
|
14
30
|
hostPort={hostPort}
|
|
15
|
-
language={
|
|
31
|
+
language={language}
|
|
16
32
|
/>
|
|
17
33
|
);
|
|
18
34
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import type { NimiLocalAppClient } from '@nimiplatform/sdk/app';
|
|
3
3
|
import {
|
|
4
4
|
AgentRealtimeEntry,
|
|
@@ -13,9 +13,25 @@ const INPUT_AUDIO = Object.freeze({
|
|
|
13
13
|
maximumFrameBytes: 640,
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
+
function useDocumentLocale(explicit?: string): string {
|
|
17
|
+
const [docLang, setDocLang] = useState(() => globalThis.document?.documentElement.lang || 'en');
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (explicit) return undefined;
|
|
20
|
+
const root = globalThis.document?.documentElement;
|
|
21
|
+
if (!root || typeof MutationObserver === 'undefined') return undefined;
|
|
22
|
+
const sync = () => setDocLang(root.lang || 'en');
|
|
23
|
+
sync();
|
|
24
|
+
const observer = new MutationObserver(sync);
|
|
25
|
+
observer.observe(root, { attributes: true, attributeFilter: ['lang'] });
|
|
26
|
+
return () => observer.disconnect();
|
|
27
|
+
}, [explicit]);
|
|
28
|
+
return explicit || docLang;
|
|
29
|
+
}
|
|
30
|
+
|
|
16
31
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-017
|
|
17
32
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-019c
|
|
18
|
-
export function AgentRealtimeCapability(props: { readonly client: NimiLocalAppClient }) {
|
|
33
|
+
export function AgentRealtimeCapability(props: { readonly client: NimiLocalAppClient; readonly locale?: string }) {
|
|
34
|
+
const locale = useDocumentLocale(props.locale);
|
|
19
35
|
const host = useMemo(() => createBrowserAgentRealtimeHostMediaPort(), []);
|
|
20
36
|
return (
|
|
21
37
|
<AgentRealtimeEntry
|
|
@@ -23,7 +39,7 @@ export function AgentRealtimeCapability(props: { readonly client: NimiLocalAppCl
|
|
|
23
39
|
inputAudio={INPUT_AUDIO}
|
|
24
40
|
turnDetection="server-vad"
|
|
25
41
|
host={host}
|
|
26
|
-
locale={
|
|
42
|
+
locale={locale}
|
|
27
43
|
/>
|
|
28
44
|
);
|
|
29
45
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo, useState } from 'react';
|
|
2
|
-
import { Button, IconButton, Surface } from '@nimiplatform/kit/ui';
|
|
2
|
+
import { Button, IconButton, nimiToast, Surface } from '@nimiplatform/kit/ui';
|
|
3
3
|
import {
|
|
4
4
|
CheckSquare,
|
|
5
5
|
Copy,
|
|
@@ -67,8 +67,13 @@ export function KitRecipesGallery({
|
|
|
67
67
|
setCategory(nextCategory);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
function copyImport() {
|
|
71
|
-
|
|
70
|
+
async function copyImport() {
|
|
71
|
+
try {
|
|
72
|
+
await copyText(categoryCopyText);
|
|
73
|
+
nimiToast.success('Copied');
|
|
74
|
+
} catch {
|
|
75
|
+
nimiToast.danger('Copy failed');
|
|
76
|
+
}
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
return (
|
|
@@ -80,7 +85,7 @@ export function KitRecipesGallery({
|
|
|
80
85
|
<h1 className="m-0 text-2xl font-bold tracking-tight">UI Recipes</h1>
|
|
81
86
|
</div>
|
|
82
87
|
<div className="flex min-h-0 flex-1 flex-col gap-2 max-[880px]:flex-none">
|
|
83
|
-
<p className="kit-doc__browse-label px-1 text-[
|
|
88
|
+
<p className="kit-doc__browse-label px-1 text-[length:var(--nimi-type-overline-size)] font-bold uppercase tracking-wider text-[var(--nimi-text-muted)]">Browse</p>
|
|
84
89
|
<nav className="kit-doc__taxonomy grid min-h-0 flex-1 content-start gap-1.5 overflow-auto max-[880px]:flex-none" aria-label="Recipe categories">
|
|
85
90
|
{CATEGORIES.map((entry) => {
|
|
86
91
|
const isActive = entry.id === category;
|
|
@@ -90,7 +95,7 @@ export function KitRecipesGallery({
|
|
|
90
95
|
type="button"
|
|
91
96
|
tone="ghost"
|
|
92
97
|
size="sm"
|
|
93
|
-
className={`kit-tax grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 rounded-2xl border p-2 text-left
|
|
98
|
+
className={`kit-tax grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-3 rounded-2xl border p-2 text-left [&>span]:contents ${isActive ? 'kit-tax--active border-transparent bg-[var(--nimi-sidebar-item-active)] text-[var(--nimi-text-primary)] shadow-[var(--nimi-elevation-base)]' : 'border-transparent bg-transparent text-[var(--nimi-text-secondary)] hover:bg-[var(--nimi-sidebar-item-hover)] hover:text-[var(--nimi-text-primary)]'}`}
|
|
94
99
|
onClick={() => selectCategory(entry.id)}
|
|
95
100
|
aria-current={isActive ? 'page' : undefined}
|
|
96
101
|
>
|
|
@@ -115,7 +120,7 @@ export function KitRecipesGallery({
|
|
|
115
120
|
<section className="kit-doc__main grid min-w-0 content-start gap-4">
|
|
116
121
|
<div className="kit-doc__header flex min-w-0 items-center justify-between gap-4 px-1 py-1 max-[720px]:flex-col max-[720px]:items-stretch">
|
|
117
122
|
<div className="grid min-w-0 gap-2">
|
|
118
|
-
<h2 className="m-0 truncate text-
|
|
123
|
+
<h2 className="m-0 truncate text-xl font-bold tracking-tight">{activeCategory.label}</h2>
|
|
119
124
|
</div>
|
|
120
125
|
<div className="kit-doc__header-actions flex min-w-0 shrink-0 flex-wrap items-center gap-2">
|
|
121
126
|
<IconButton
|
|
@@ -124,7 +129,7 @@ export function KitRecipesGallery({
|
|
|
124
129
|
aria-label={category === 'foundations' ? 'Copy CSS setup' : 'Copy imports'}
|
|
125
130
|
className="kit-doc__copy-action bg-[color-mix(in_srgb,var(--nimi-surface-card)_32%,transparent)] border-[color-mix(in_srgb,var(--nimi-border-subtle)_45%,transparent)] shadow-none hover:bg-[var(--nimi-action-primary-bg)] hover:border-[var(--nimi-action-primary-bg)] hover:text-[var(--nimi-action-primary-text)] hover:shadow-none"
|
|
126
131
|
icon={<Copy size={14} aria-hidden="true" />}
|
|
127
|
-
onClick={copyImport}
|
|
132
|
+
onClick={() => void copyImport()}
|
|
128
133
|
/>
|
|
129
134
|
</div>
|
|
130
135
|
</div>
|
package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-surface.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useRef, useState, type RefObject } from 'react';
|
|
2
|
-
import { AppCardSurface, Button, IconButton, NimiText, ScrollShell, StatusBadge, Surface } from '@nimiplatform/kit/ui';
|
|
1
|
+
import { useEffect, useRef, useState, type MouseEvent, type RefObject } from 'react';
|
|
2
|
+
import { AppCardSurface, Button, IconButton, NimiText, nimiToast, ScrollShell, StatusBadge, Surface } from '@nimiplatform/kit/ui';
|
|
3
3
|
import {
|
|
4
4
|
Check,
|
|
5
5
|
Code2,
|
|
@@ -83,7 +83,7 @@ function RecipeTile({
|
|
|
83
83
|
recipe: Recipe;
|
|
84
84
|
context: KitRecipeExampleContext;
|
|
85
85
|
active: boolean;
|
|
86
|
-
onInspect: () => void;
|
|
86
|
+
onInspect: (trigger: HTMLButtonElement) => void;
|
|
87
87
|
}) {
|
|
88
88
|
return (
|
|
89
89
|
<AppCardSurface
|
|
@@ -102,8 +102,8 @@ function RecipeTile({
|
|
|
102
102
|
aria-pressed={active}
|
|
103
103
|
leadingIcon={<Code2 size={14} strokeWidth={2.2} aria-hidden="true" />}
|
|
104
104
|
aria-label={`Inspect ${recipe.name}`}
|
|
105
|
-
className="kit-recipe-inspect-action min-h-10 rounded-full border-[color-mix(in_srgb,var(--nimi-action-primary-bg)_44%,var(--nimi-border-strong))] bg-[var(--nimi-surface-card)] px-4 text-[var(--nimi-text-primary)] shadow-[var(--nimi-elevation-raised)] hover:border-[var(--nimi-action-primary-bg)] hover:bg-[color-mix(in_srgb,var(--nimi-action-primary-bg)_10%,var(--nimi-surface-card))] hover:shadow-[
|
|
106
|
-
onClick={onInspect}
|
|
105
|
+
className="kit-recipe-inspect-action min-h-10 rounded-full border-[color-mix(in_srgb,var(--nimi-action-primary-bg)_44%,var(--nimi-border-strong))] bg-[var(--nimi-surface-card)] px-4 text-[var(--nimi-text-primary)] shadow-[var(--nimi-elevation-raised)] hover:border-[var(--nimi-action-primary-bg)] hover:bg-[color-mix(in_srgb,var(--nimi-action-primary-bg)_10%,var(--nimi-surface-card))] hover:shadow-[var(--nimi-elevation-floating)] data-[active]:border-[var(--nimi-action-primary-bg)] data-[active]:bg-[color-mix(in_srgb,var(--nimi-action-primary-bg)_16%,var(--nimi-surface-card))] data-[active]:text-[var(--nimi-text-primary)]"
|
|
106
|
+
onClick={(event: MouseEvent<HTMLButtonElement>) => onInspect(event.currentTarget)}
|
|
107
107
|
>
|
|
108
108
|
Inspect
|
|
109
109
|
</Button>
|
|
@@ -130,6 +130,16 @@ function RecipeInspector({
|
|
|
130
130
|
const importBlock = recipeImportBlock(recipe);
|
|
131
131
|
const checks = recipeAccessChecks(recipe);
|
|
132
132
|
const tokenFootprint = recipeTokenFootprint(recipe);
|
|
133
|
+
|
|
134
|
+
async function handleCopy(value: string) {
|
|
135
|
+
try {
|
|
136
|
+
await copyText(value);
|
|
137
|
+
nimiToast.success('Copied');
|
|
138
|
+
} catch {
|
|
139
|
+
nimiToast.danger('Copy failed');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
133
143
|
return (
|
|
134
144
|
<div ref={panelRef} className="min-w-0">
|
|
135
145
|
<Surface
|
|
@@ -138,12 +148,12 @@ function RecipeInspector({
|
|
|
138
148
|
tone="panel"
|
|
139
149
|
elevation="floating"
|
|
140
150
|
padding="none"
|
|
141
|
-
className="kit-doc__inspector sticky top-0 grid max-h-[calc(100cqh-2rem)] min-w-0 content-start gap-5 overflow-y-auto rounded-
|
|
151
|
+
className="kit-doc__inspector sticky top-0 grid max-h-[calc(100cqh-2rem)] min-w-0 content-start gap-5 overflow-y-auto rounded-[var(--nimi-radius-lg)] p-5"
|
|
142
152
|
aria-label={`${recipe.name} Recipe Inspector`}
|
|
143
153
|
>
|
|
144
154
|
<div className="flex min-w-0 items-start justify-between gap-3">
|
|
145
155
|
<div className="grid min-w-0 gap-1">
|
|
146
|
-
<p className="m-0 text-[
|
|
156
|
+
<p className="m-0 text-[length:var(--nimi-type-overline-size)] font-bold uppercase tracking-wider text-[var(--nimi-text-muted)]">Recipe Inspector</p>
|
|
147
157
|
<h3 className="m-0 truncate text-xl font-bold">{recipe.name}</h3>
|
|
148
158
|
</div>
|
|
149
159
|
<IconButton
|
|
@@ -165,11 +175,11 @@ function RecipeInspector({
|
|
|
165
175
|
size="sm"
|
|
166
176
|
aria-label="Copy recipe imports"
|
|
167
177
|
icon={<Copy size={14} aria-hidden="true" />}
|
|
168
|
-
onClick={() => void
|
|
178
|
+
onClick={() => void handleCopy(importBlock)}
|
|
169
179
|
/>
|
|
170
180
|
</div>
|
|
171
181
|
<ScrollShell className="max-h-44 rounded-2xl border border-[var(--nimi-border-subtle)] bg-[var(--nimi-surface-canvas)] p-3">
|
|
172
|
-
<pre className="m-0 whitespace-pre-wrap text-[
|
|
182
|
+
<pre className="m-0 whitespace-pre-wrap text-[length:var(--nimi-type-mono-size)] leading-5 text-[var(--nimi-text-secondary)]">{importBlock}</pre>
|
|
173
183
|
</ScrollShell>
|
|
174
184
|
</section>
|
|
175
185
|
|
|
@@ -180,8 +190,8 @@ function RecipeInspector({
|
|
|
180
190
|
<div className="overflow-hidden rounded-2xl border border-[var(--nimi-border-subtle)]">
|
|
181
191
|
{recipe.props.map((row) => (
|
|
182
192
|
<div key={row.name} className="grid grid-cols-[112px_minmax(0,1fr)] border-b border-[color-mix(in_srgb,var(--nimi-text-primary)_7%,transparent)] last:border-b-0">
|
|
183
|
-
<b className="bg-[color-mix(in_srgb,var(--nimi-surface-card)_70%,transparent)] p-3 text-[
|
|
184
|
-
<span className="p-3 text-[
|
|
193
|
+
<b className="bg-[color-mix(in_srgb,var(--nimi-surface-card)_70%,transparent)] p-3 text-[length:var(--nimi-type-caption-size)]">{row.name}</b>
|
|
194
|
+
<span className="p-3 text-[length:var(--nimi-type-caption-size)] leading-5 text-[var(--nimi-text-secondary)]">{row.desc}</span>
|
|
185
195
|
</div>
|
|
186
196
|
))}
|
|
187
197
|
</div>
|
|
@@ -209,14 +219,14 @@ function RecipeInspector({
|
|
|
209
219
|
<h4 className="m-0 text-sm font-bold">Design tokens</h4>
|
|
210
220
|
<div className="flex min-w-0 flex-wrap gap-2">
|
|
211
221
|
{tokenFootprint.map((row) => (
|
|
212
|
-
<code key={`${row.token}-${row.role}`} className="rounded-full bg-[color-mix(in_srgb,var(--nimi-status-info-soft-bg)_72%,var(--nimi-surface-card))] px-3 py-2 text-[
|
|
222
|
+
<code key={`${row.token}-${row.role}`} className="rounded-full bg-[color-mix(in_srgb,var(--nimi-status-info-soft-bg)_72%,var(--nimi-surface-card))] px-3 py-2 text-[length:var(--nimi-type-mono-size)] text-[var(--nimi-text-secondary)]">
|
|
213
223
|
{row.token}
|
|
214
224
|
</code>
|
|
215
225
|
))}
|
|
216
226
|
</div>
|
|
217
227
|
</section>
|
|
218
228
|
|
|
219
|
-
<Button tone="primary" fullWidth leadingIcon={<Copy size={15} aria-hidden="true" />} onClick={() => void
|
|
229
|
+
<Button tone="primary" fullWidth leadingIcon={<Copy size={15} aria-hidden="true" />} onClick={() => void handleCopy(recipeCopyText(recipe, context))}>
|
|
220
230
|
Copy selected recipe
|
|
221
231
|
</Button>
|
|
222
232
|
</Surface>
|
|
@@ -228,15 +238,37 @@ export function RecipeWorkspace({ recipes, copyText, exampleAppId }: { recipes:
|
|
|
228
238
|
const [selectedRecipeId, setSelectedRecipeId] = useState(recipes[0]?.id ?? '');
|
|
229
239
|
const [inspectorOpen, setInspectorOpen] = useState(false);
|
|
230
240
|
const inspectorPanelRef = useRef<HTMLDivElement | null>(null);
|
|
241
|
+
const inspectTriggerRef = useRef<HTMLButtonElement | null>(null);
|
|
231
242
|
const selectedRecipe = recipes.find((recipe) => recipe.id === selectedRecipeId) ?? recipes[0];
|
|
232
243
|
|
|
244
|
+
useEffect(() => {
|
|
245
|
+
if (!inspectorOpen) return undefined;
|
|
246
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
247
|
+
if (event.key !== 'Escape' || event.defaultPrevented) return;
|
|
248
|
+
setInspectorOpen(false);
|
|
249
|
+
if (inspectTriggerRef.current?.isConnected) {
|
|
250
|
+
inspectTriggerRef.current.focus();
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
window.addEventListener('keydown', onKeyDown);
|
|
254
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
255
|
+
}, [inspectorOpen]);
|
|
256
|
+
|
|
233
257
|
if (!selectedRecipe) return null;
|
|
234
258
|
|
|
235
259
|
function closeInspector() {
|
|
236
260
|
setInspectorOpen(false);
|
|
261
|
+
if (inspectTriggerRef.current?.isConnected) {
|
|
262
|
+
inspectTriggerRef.current.focus();
|
|
263
|
+
}
|
|
237
264
|
}
|
|
238
265
|
|
|
239
|
-
function inspectRecipe(recipe: Recipe) {
|
|
266
|
+
function inspectRecipe(recipe: Recipe, trigger: HTMLButtonElement) {
|
|
267
|
+
inspectTriggerRef.current = trigger;
|
|
268
|
+
if (inspectorOpen && selectedRecipe.id === recipe.id) {
|
|
269
|
+
closeInspector();
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
240
272
|
setSelectedRecipeId(recipe.id);
|
|
241
273
|
setInspectorOpen(true);
|
|
242
274
|
}
|
|
@@ -244,10 +276,6 @@ export function RecipeWorkspace({ recipes, copyText, exampleAppId }: { recipes:
|
|
|
244
276
|
return (
|
|
245
277
|
<div
|
|
246
278
|
className={inspectorOpen ? 'kit-recipe-workspace grid min-w-0 gap-5 lg:grid-cols-[minmax(0,1fr)_340px]' : 'kit-recipe-workspace grid min-w-0 gap-5'}
|
|
247
|
-
onBlur={(event) => {
|
|
248
|
-
if (!inspectorOpen || event.currentTarget.contains(event.relatedTarget)) return;
|
|
249
|
-
closeInspector();
|
|
250
|
-
}}
|
|
251
279
|
>
|
|
252
280
|
<div className="grid min-w-0 content-start gap-4">
|
|
253
281
|
<div className={inspectorOpen ? 'grid min-w-0 items-stretch gap-4 2xl:grid-cols-2' : 'grid min-w-0 items-stretch gap-4 lg:grid-cols-2'}>
|
|
@@ -256,8 +284,8 @@ export function RecipeWorkspace({ recipes, copyText, exampleAppId }: { recipes:
|
|
|
256
284
|
key={recipe.id}
|
|
257
285
|
recipe={recipe}
|
|
258
286
|
context={{ appId: exampleAppId }}
|
|
259
|
-
active={recipe.id === selectedRecipe.id}
|
|
260
|
-
onInspect={() => inspectRecipe(recipe)}
|
|
287
|
+
active={inspectorOpen && recipe.id === selectedRecipe.id}
|
|
288
|
+
onInspect={(trigger) => inspectRecipe(recipe, trigger)}
|
|
261
289
|
/>
|
|
262
290
|
))}
|
|
263
291
|
</div>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"emptyTitle": "Waiting for generation",
|
|
24
24
|
"emptyHint": "Your generated text will appear here.",
|
|
25
25
|
"footnote": "Your request will be sent to the runtime to generate content.",
|
|
26
|
-
"imageInvalid": "Attach one JPEG image, WAV or MP3 recording, or MP4 video for this request.",
|
|
26
|
+
"imageInvalid": "Attach one JPEG, PNG, WebP, or GIF image, one WAV or MP3 recording, or one MP4 video for this request.",
|
|
27
27
|
"imageTargetChecking": "Checking whether the selected model accepts this media. The attachment is kept while checking.",
|
|
28
28
|
"imageTargetUnknown": "Media support could not be confirmed. The attachment is kept; reopen model settings or retry later.",
|
|
29
29
|
"imageTargetUnsupported": "The selected model does not accept this media. Remove the attachment or choose a model that supports its format.",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"addInput": "Add input",
|
|
69
69
|
"removeInput": "Remove input {{index}}",
|
|
70
70
|
"fields": {
|
|
71
|
-
"inputs": "
|
|
71
|
+
"inputs": "Additional texts to embed after the prompt",
|
|
72
72
|
"dimensions": "Requested output dimensions",
|
|
73
73
|
"embeddingPurpose": "Retrieval purpose",
|
|
74
74
|
"temperature": "Temperature",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"emptyTitle": "等待生成",
|
|
24
24
|
"emptyHint": "生成的文本会显示在这里。",
|
|
25
25
|
"footnote": "你的请求会发送到 Runtime 以生成内容。",
|
|
26
|
-
"imageInvalid": "请为这次请求附上一张 JPEG 图片、一段 WAV 或 MP3 录音,或一个 MP4 视频。",
|
|
26
|
+
"imageInvalid": "请为这次请求附上一张 JPEG、PNG、WebP 或 GIF 图片、一段 WAV 或 MP3 录音,或一个 MP4 视频。",
|
|
27
27
|
"imageTargetChecking": "正在检查所选模型是否接受这份媒体。检查期间会保留附件。",
|
|
28
28
|
"imageTargetUnknown": "无法确认所选模型是否支持这份媒体。附件会保留;请重新打开模型设置或稍后重试。",
|
|
29
29
|
"imageTargetUnsupported": "所选模型不接受这份媒体。请移除附件,或选择支持其格式的模型。",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"addInput": "添加输入",
|
|
69
69
|
"removeInput": "移除输入 {{index}}",
|
|
70
70
|
"fields": {
|
|
71
|
-
"inputs": "
|
|
71
|
+
"inputs": "追加在提示词之后的嵌入文本",
|
|
72
72
|
"dimensions": "请求输出维度",
|
|
73
73
|
"embeddingPurpose": "检索用途",
|
|
74
74
|
"temperature": "Temperature",
|
|
@@ -16,7 +16,7 @@ export const studioCreateModule = Object.freeze({
|
|
|
16
16
|
studioTag: 'Text', inputTitleKey: 'Studio.profiles.textGenerate.inputTitle', inputPlaceholderKey: 'Studio.profiles.textGenerate.inputPlaceholder', inputKind: 'prompt', supportsAttachments: true, controls: ['tone', 'length'], primaryLabelKey: 'Studio.profiles.textGenerate.primaryLabel', primaryRunningLabelKey: 'Studio.profiles.textGenerate.primaryRunningLabel', resultTitle: 'Generated result', emptyTitleKey: 'Studio.profiles.textGenerate.emptyTitle', emptyHintKey: 'Studio.profiles.textGenerate.emptyHint', resultKind: 'text', footnoteKey: 'Studio.profiles.textGenerate.footnote',
|
|
17
17
|
},
|
|
18
18
|
preset: { id: 'acceptance-note', label: 'Acceptance note', prompt: 'Write a concise acceptance note for a Runtime-backed Nimi App that can generate helpful content.' },
|
|
19
|
-
runtimeMethod: 'sdk.localApp.ai.text.generateCandidate / scenario.execute:text-generate
|
|
19
|
+
runtimeMethod: 'sdk.localApp.ai.text.generateCandidate / scenario.execute:text-generate',
|
|
20
20
|
parameters: studioTextGenerateParameters,
|
|
21
21
|
parameterPanel: StudioCreateParameterPanel,
|
|
22
22
|
},
|
|
@@ -3,6 +3,10 @@ import type { NimiRuntimeAIScenarioClient } from '@nimiplatform/sdk/ai';
|
|
|
3
3
|
import type { NimiLocalAppTextTurnEvent } from '@nimiplatform/sdk/app';
|
|
4
4
|
import { ExecutionMode, FinishReason, ScenarioType } from '@nimiplatform/sdk/runtime/generated';
|
|
5
5
|
import type { StudioCapabilityRuntimeHandlers } from '../../ai-studio-core/runtime-dispatcher.js';
|
|
6
|
+
import {
|
|
7
|
+
isSupportedStudioTextMediaMime,
|
|
8
|
+
studioTextMediaExtension,
|
|
9
|
+
} from '../../ai-studio-core/section-ai-testing-input.js';
|
|
6
10
|
import type { StudioEmbeddingRetrieval } from '../../ai-studio-core/runtime-types.js';
|
|
7
11
|
import {
|
|
8
12
|
projectStudioRunnerNonSuccess,
|
|
@@ -34,10 +38,11 @@ async function runTextGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
34
38
|
const attachments = context.input.attachments ?? [];
|
|
35
39
|
if (attachments.length > 0) {
|
|
36
40
|
const image = attachments[0];
|
|
37
|
-
if (attachments.length !== 1 || !image || !
|
|
41
|
+
if (attachments.length !== 1 || !image || !isSupportedStudioTextMediaMime(image.mimeType)) {
|
|
38
42
|
return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Studio.profiles.textGenerate.imageInvalid'));
|
|
39
43
|
}
|
|
40
|
-
const
|
|
44
|
+
const mediaType = image.mimeType;
|
|
45
|
+
const prefix = `data:${mediaType};base64,`;
|
|
41
46
|
if (!image.dataUrl.startsWith(prefix) || image.dataUrl.length > prefix.length + 4 * Math.ceil(32 * 1024 * 1024 / 3)) {
|
|
42
47
|
return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Studio.profiles.textGenerate.imageTooLarge'));
|
|
43
48
|
}
|
|
@@ -55,7 +60,7 @@ async function runTextGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
55
60
|
}
|
|
56
61
|
const upload = await context.host.client.ai.artifacts.upload({
|
|
57
62
|
bytes,
|
|
58
|
-
mimeType:
|
|
63
|
+
mimeType: mediaType,
|
|
59
64
|
});
|
|
60
65
|
if (studioRequestSignal(context)?.aborted) {
|
|
61
66
|
return context.host.nonSuccess(context.capability, 'operation-aborted', context.host.translate('Studio.profiles.textGenerate.imageStopped'));
|
|
@@ -67,7 +72,7 @@ async function runTextGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
67
72
|
text: '',
|
|
68
73
|
parts: [
|
|
69
74
|
{ type: 'text', text: context.prompt },
|
|
70
|
-
{ type: 'artifact-ref', artifactId: upload.artifactId, mediaType
|
|
75
|
+
{ type: 'artifact-ref', artifactId: upload.artifactId, mediaType, displayName: image.name },
|
|
71
76
|
],
|
|
72
77
|
}],
|
|
73
78
|
...textCandidateParameters(parameters),
|
|
@@ -82,7 +87,7 @@ async function runTextGenerate(context: StudioCapabilityRuntimeContext) {
|
|
|
82
87
|
if (response.output.type !== 'text-generate' || response.output.finishReason !== 'stop' || !answer.trim()) {
|
|
83
88
|
return context.host.nonSuccess(context.capability, 'runtime-call-failed', context.host.translate('Studio.profiles.textGenerate.imageOutputInvalid'));
|
|
84
89
|
}
|
|
85
|
-
const extension =
|
|
90
|
+
const extension = studioTextMediaExtension(mediaType);
|
|
86
91
|
const relativePath = `studio/text-generate-inputs/${crypto.randomUUID()}.${extension}`;
|
|
87
92
|
let sourceImage;
|
|
88
93
|
let message = context.host.translate('Studio.profiles.textGenerate.imageCompleted');
|
|
@@ -192,7 +197,7 @@ async function runTextEmbed(context: StudioCapabilityRuntimeContext) {
|
|
|
192
197
|
parameters,
|
|
193
198
|
);
|
|
194
199
|
if (!context.prompt && embeddingInputs.length === 0) return inputRequired(context);
|
|
195
|
-
const documents =
|
|
200
|
+
const documents = context.prompt ? [context.prompt, ...embeddingInputs] : embeddingInputs;
|
|
196
201
|
const query = parameters?.retrievalQuery?.trim();
|
|
197
202
|
const signal = studioRequestSignal(context);
|
|
198
203
|
if (signal?.aborted) throw studioAbortError();
|
|
@@ -350,7 +355,6 @@ async function* streamLocalAppTextEvents(
|
|
|
350
355
|
signal?.addEventListener('abort', cancel, { once: true });
|
|
351
356
|
try {
|
|
352
357
|
if (signal?.aborted) throw studioAbortError();
|
|
353
|
-
let started = false;
|
|
354
358
|
let textItemOpened = false;
|
|
355
359
|
for await (const event of subscription) {
|
|
356
360
|
if (signal?.aborted) throw studioAbortError();
|
|
@@ -359,18 +363,6 @@ async function* streamLocalAppTextEvents(
|
|
|
359
363
|
if (event.type === 'reasoning-summary') {
|
|
360
364
|
throw Object.assign(new Error('The text-only Studio request received an unrequested reasoning summary.'), { reasonCode: 'SDK_AI_RUNTIME_OUTPUT_INVALID' });
|
|
361
365
|
}
|
|
362
|
-
if (!started) {
|
|
363
|
-
started = true;
|
|
364
|
-
yield {
|
|
365
|
-
eventType: 1,
|
|
366
|
-
sequence: event.sequence,
|
|
367
|
-
traceId: event.traceId,
|
|
368
|
-
payload: {
|
|
369
|
-
oneofKind: 'started',
|
|
370
|
-
started: { modelResolved: '', routeDecision: 0, voiceOutputMode: 0 },
|
|
371
|
-
},
|
|
372
|
-
};
|
|
373
|
-
}
|
|
374
366
|
if (event.type === 'delta') {
|
|
375
367
|
textItemOpened = true;
|
|
376
368
|
yield localTextDeltaEvent(event);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Button } from '@nimiplatform/kit/ui';
|
|
3
3
|
import { useAIStudioHost } from '../../ai-studio-core/host-context.js';
|
|
4
|
-
import { StudioBooleanParameter, StudioNumberParameter,
|
|
4
|
+
import { StudioBooleanParameter, StudioNumberParameter, type StudioParameterPanelProps } from '../../ai-studio-core/parameter-fields.js';
|
|
5
5
|
import type { StudioAudioSeparateParameters } from './parameters.js';
|
|
6
6
|
|
|
7
7
|
export function AudioSeparateFields(props: StudioParameterPanelProps) {
|
|
@@ -52,13 +52,16 @@ export function AudioSeparateFields(props: StudioParameterPanelProps) {
|
|
|
52
52
|
}
|
|
53
53
|
return <div className="space-y-4">
|
|
54
54
|
{!ready ? <p>{t('AudioSeparate.configureInputs')}</p> : <p>{t('AudioSeparate.inputHint')}</p>}
|
|
55
|
-
<
|
|
55
|
+
<fieldset className="studio-parameters__field">
|
|
56
|
+
<legend className="studio-parameters__label">{t('AudioSeparate.source')}</legend>
|
|
56
57
|
<input ref={sourceInput} hidden type="file" accept=".mp3,.wav,.flac" onChange={event => {
|
|
57
58
|
const file = event.currentTarget.files?.[0]; event.currentTarget.value = ''; if (file) void importAudio(file);
|
|
58
59
|
}} />
|
|
59
|
-
<
|
|
60
|
+
<div>
|
|
61
|
+
<Button size="sm" tone="secondary" disabled={disabled || !ready} onClick={() => sourceInput.current?.click()}>{t(busy ? 'Music.importing' : 'AudioSeparate.chooseSource')}</Button>
|
|
62
|
+
</div>
|
|
60
63
|
{parameters.sourceRelativePath ? <p>{parameters.sourceName}</p> : null}
|
|
61
|
-
</
|
|
64
|
+
</fieldset>
|
|
62
65
|
{ready ? <>
|
|
63
66
|
<StudioNumberParameter current={parameters} field="startSeconds" label={t('AudioSeparate.start')} onChange={update} disabled={disabled} />
|
|
64
67
|
<StudioNumberParameter current={parameters} field="endSeconds" label={t('AudioSeparate.end')} onChange={update} disabled={disabled} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NimiLocalAppAudioInfo } from '@nimiplatform/sdk/app';
|
|
2
2
|
import type { NimiRuntimeScenarioJob } from '@nimiplatform/sdk/runtime';
|
|
3
|
-
import { beginStudioJobRecovery,
|
|
3
|
+
import { beginStudioJobRecovery, StudioRecoveryWriteUnconfirmed, cleanupRejectedStudioRecoveryEntry, createRecordedStudioScenarioJobSession, isDefiniteUninvokedRunnerRejection, recoverStudioJobId, readStudioJobRecovery, restoreSavedStudioJobResult, saveStudioJobRecoveryResult, studioJobRecoverySignal } from '../../ai-studio-core/job-recovery.js';
|
|
4
4
|
import { createStudioScenarioJobClient, projectStudioArtifactRunnerResult, type StudioCapabilityRuntimeContext } from '../../ai-studio-core/runtime.js';
|
|
5
5
|
import type { StudioManagedArtifact } from '../../ai-studio-core/runtime-types.js';
|
|
6
6
|
import type { StudioAudioSeparateParameters } from './parameters.js';
|
|
@@ -10,7 +10,7 @@ export async function runAudioSeparate(context: StudioCapabilityRuntimeContext)
|
|
|
10
10
|
const parameters = context.input.parameters as StudioAudioSeparateParameters | undefined;
|
|
11
11
|
const client = context.host.client; const signal = context.input.signal;
|
|
12
12
|
if (parameters?.recoverySubmissionId) {
|
|
13
|
-
const entry = (await readStudioJobRecovery(client.storage, 'audio.separate')).find(item => item.clientSubmissionId === parameters.recoverySubmissionId);
|
|
13
|
+
const entry = (await readStudioJobRecovery(client.storage.assets, 'audio.separate')).find(item => item.clientSubmissionId === parameters.recoverySubmissionId);
|
|
14
14
|
if (!entry?.sourceAudio) throw new Error(context.host.translate('Music.recoveryMissing'));
|
|
15
15
|
const saved = await restoreSavedStudioJobResult(entry, context.capability.label, 'audio.separate', client.storage.assets, studioJobRecoverySignal(context.input));
|
|
16
16
|
if (saved) return saved;
|
|
@@ -19,8 +19,7 @@ export async function runAudioSeparate(context: StudioCapabilityRuntimeContext)
|
|
|
19
19
|
jobId: recoveredJobId, signal: context.input.observationSignal, cancelSignal: signal, onObservation: context.input.onObservation, abortReason: context.host.abortReason, onJobUpdate: context.input.onJobUpdate });
|
|
20
20
|
const projected = await projectStudioArtifactRunnerResult({ ...context, separationSourceAudio: entry.sourceAudio,
|
|
21
21
|
separationRequest: entry.separationRequest }, result);
|
|
22
|
-
|
|
23
|
-
return projected;
|
|
22
|
+
return saveStudioJobRecoveryResult(client.storage.assets, entry.clientSubmissionId, projected, 'audio.separate');
|
|
24
23
|
}
|
|
25
24
|
const invalid = () => context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('AudioSeparate.configureInputs'));
|
|
26
25
|
if (!parameters?.sourceRelativePath || !parameters.sourceMimeType) return invalid();
|
|
@@ -65,20 +64,25 @@ export async function runAudioSeparate(context: StudioCapabilityRuntimeContext)
|
|
|
65
64
|
try {
|
|
66
65
|
signal?.throwIfAborted();
|
|
67
66
|
if (adopted.sizeBytes !== separationInput.sizeBytes || adopted.mediaType !== separationInput.mimeType) throw new Error('Canonical source adoption changed metadata');
|
|
68
|
-
clientSubmissionId = await beginStudioJobRecovery(client.storage, 'audio.separate', sourceAudio, undefined,
|
|
67
|
+
clientSubmissionId = await beginStudioJobRecovery(client.storage.assets, 'audio.separate', sourceAudio, undefined,
|
|
69
68
|
separationRequest, context.input.recordedRunConfig, context.input.prompt);
|
|
70
|
-
} catch (cause) {
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
} catch (cause) {
|
|
70
|
+
if (!(cause instanceof StudioRecoveryWriteUnconfirmed)) await client.storage.assets.remove(adopted.relativePath);
|
|
71
|
+
throw cause;
|
|
72
|
+
}
|
|
73
|
+
const session = createRecordedStudioScenarioJobSession(context, clientSubmissionId, 'audio.separate');
|
|
74
|
+
const result = await context.host.runners.audioSeparate({ runtime: { ai: session.client }, appId: context.host.appId,
|
|
73
75
|
mimeType: separationInput.mimeType,
|
|
74
76
|
sourceAudio: { artifactId: separationInput.artifactId, ...(sourceRange ? { range: sourceRange } : {}) },
|
|
75
77
|
...(parameters.includeInstrumentParts ? { includeInstrumentParts: true } : {}),
|
|
76
78
|
scenarioId: context.scenarioId, surfaceId: context.host.surfaceId,
|
|
77
79
|
signal, observationSignal: context.input.observationSignal, onObservation: context.input.onObservation, abortReason: context.host.abortReason,
|
|
78
80
|
onJobUpdate: context.input.onJobUpdate });
|
|
81
|
+
if (result.ok === false && !session.wasSubmitInvoked() && isDefiniteUninvokedRunnerRejection(result.error)) {
|
|
82
|
+
await cleanupRejectedStudioRecoveryEntry(client.storage.assets, 'audio.separate', clientSubmissionId);
|
|
83
|
+
}
|
|
79
84
|
const projected = await projectStudioArtifactRunnerResult({ ...context, separationSourceAudio: sourceAudio, separationRequest }, result);
|
|
80
|
-
|
|
81
|
-
return projected;
|
|
85
|
+
return saveStudioJobRecoveryResult(client.storage.assets, clientSubmissionId, projected, 'audio.separate');
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
function resolveRange(startSeconds: number | undefined, endSeconds: number | undefined, info: NimiLocalAppAudioInfo) {
|
|
@@ -319,7 +319,9 @@
|
|
|
319
319
|
"markupFileHint": "A separate transparent PNG annotation layer matching the source image. Do not combine with a mask.",
|
|
320
320
|
"layerPngRequired": "Choose a PNG file up to 32 MiB.",
|
|
321
321
|
"clearLayer": "Clear layer",
|
|
322
|
-
"imageFormatHint": "Use a format supported by the selected model. SVG and GIF are generation-only; SVG can incur separate provider authoring charges. GIF timing rounds to 10 ms."
|
|
322
|
+
"imageFormatHint": "Use a format supported by the selected model. SVG and GIF are generation-only; SVG can incur separate provider authoring charges. GIF timing rounds to 10 ms.",
|
|
323
|
+
"imageInputSlotMissingHint": "This local implementation supports image input (such as ControlNet or image-guided generation), but the optional companion slot is not bound in the current Loadout. Bind it in Nimi Home to use image input; submitting one now will be rejected by Runtime.",
|
|
324
|
+
"imageInputUnsupportedHint": "The selected configuration does not declare image input support (text-to-image only). Submitting reference, control, or mask images will be rejected by Runtime."
|
|
323
325
|
}
|
|
324
326
|
},
|
|
325
327
|
"Music": {
|
|
@@ -328,7 +328,9 @@
|
|
|
328
328
|
"markupFileHint": "与参考图尺寸一致的独立透明 PNG 标注图层,不能与蒙版同时使用。",
|
|
329
329
|
"layerPngRequired": "请选择不超过 32 MiB 的 PNG 文件。",
|
|
330
330
|
"clearLayer": "清除图层",
|
|
331
|
-
"imageFormatHint": "请选择模型支持的格式。SVG 和 GIF 仅用于生成;SVG 可能产生供方额外绘制费用,GIF 每帧时间按 10 毫秒取整。"
|
|
331
|
+
"imageFormatHint": "请选择模型支持的格式。SVG 和 GIF 仅用于生成;SVG 可能产生供方额外绘制费用,GIF 每帧时间按 10 毫秒取整。",
|
|
332
|
+
"imageInputSlotMissingHint": "当前本机实现支持图像输入(如 ControlNet 或图生图),但所选 Loadout 尚未绑定对应的可选伴生模型槽位。请在 Nimi Home 绑定后再使用;现在提交图像输入会被 Runtime 明确拒绝。",
|
|
333
|
+
"imageInputUnsupportedHint": "当前配置未声明支持图像输入(仅文生图)。提交参考图、控制图或蒙版会被 Runtime 明确拒绝。"
|
|
332
334
|
}
|
|
333
335
|
},
|
|
334
336
|
"Music": {
|
|
@@ -65,21 +65,22 @@ export function MusicFields(props: StudioParameterPanelProps) {
|
|
|
65
65
|
? t('Music.fixedClipDuration', { seconds: profile.defaultDurationSeconds }) : t('Music.durationHint')}</p>
|
|
66
66
|
{profile?.supportsSeed ? <StudioNumberParameter current={parameters} field="seed" label={t('Music.seed')} onChange={update} disabled={disabled} /> : null}
|
|
67
67
|
{profile?.supportsInstrumental ? <StudioBooleanParameter current={parameters} field="instrumental" label={t('Music.instrumental')} onChange={(next) => update({ ...next, ...(next.instrumental ? { lyrics: '' } : {}) })} disabled={disabled} /> : null}
|
|
68
|
-
{scoreProfile ? <
|
|
68
|
+
{scoreProfile ? <fieldset className="studio-parameters__field">
|
|
69
|
+
<legend className="studio-parameters__label">{t('Music.score')}</legend>
|
|
69
70
|
<input ref={input} type="file" accept=".abc,text/vnd.abc" hidden onChange={(event) => {
|
|
70
71
|
const file = event.currentTarget.files?.[0]; event.currentTarget.value = ''; if (file) void importScore(file);
|
|
71
72
|
}} />
|
|
72
73
|
<div className="flex flex-wrap items-center gap-2">
|
|
73
|
-
<Button disabled={props.disabled || importing} onClick={() => input.current?.click()}>{t(importing ? 'Music.importing' : 'Music.importScore')}</Button>
|
|
74
|
-
{parameters.scoreRelativePath ? <><span>{parameters.scoreName || t('Music.importedScore')}</span><Button disabled={props.disabled} onClick={() => {
|
|
74
|
+
<Button size="sm" tone="secondary" disabled={props.disabled || importing} onClick={() => input.current?.click()}>{t(importing ? 'Music.importing' : 'Music.importScore')}</Button>
|
|
75
|
+
{parameters.scoreRelativePath ? <><span>{parameters.scoreName || t('Music.importedScore')}</span><Button size="sm" tone="ghost" disabled={props.disabled} onClick={() => {
|
|
75
76
|
const { scoreRelativePath, scoreName, scoreConditioning, ...rest } = parameters; update(rest);
|
|
76
77
|
}}>{t('Music.clearScore')}</Button></> : null}
|
|
77
78
|
</div>
|
|
78
79
|
{parameters.scoreRelativePath ? <SelectField value={parameters.scoreConditioning ?? 'melody-and-harmony'} disabled={disabled}
|
|
79
80
|
onChange={(event) => update({ ...parameters, scoreConditioning: event.currentTarget.value as 'melody-only' | 'melody-and-harmony' })}
|
|
80
81
|
options={scoreProfile.scoreConditioning.map((value) => ({ value, label: t(value === 'melody-only' ? 'Music.melodyOnly' : 'Music.melodyHarmony') }))} /> : null}
|
|
81
|
-
<p className="text-sm
|
|
82
|
-
</
|
|
82
|
+
<p className="text-sm text-[var(--nimi-text-muted)]">{t('Music.scoreHint')}</p>
|
|
83
|
+
</fieldset> : null}
|
|
83
84
|
{profile?.supportsGeneratedScore ? <StudioBooleanParameter current={parameters} field="returnGeneratedScore" label={t('Music.returnScore')} onChange={update} disabled={disabled} /> : null}
|
|
84
85
|
{error ? <p role="alert">{error}</p> : null}
|
|
85
86
|
</div>;
|