@nimiplatform/app-tools 0.7.5 → 0.12.0

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.
Files changed (97) hide show
  1. package/README.md +59 -5
  2. package/bin/nimi-app.mjs +11 -3
  3. package/lib/app-access-declaration.mjs +1 -0
  4. package/lib/app-dependency-combinations.mjs +16 -28
  5. package/lib/app-doctor-update.mjs +66 -7
  6. package/lib/app-info.mjs +8 -1
  7. package/lib/app-project-lifecycle.mjs +82 -9
  8. package/lib/app-scaffold-capabilities.mjs +3 -3
  9. package/lib/app-scaffold-profiles.mjs +96 -26
  10. package/lib/app-scaffold.mjs +54 -7
  11. package/lib/canonical-capability-ids.generated.mjs +4 -0
  12. package/package.json +26 -25
  13. package/scripts/dev-shell.mjs +61 -17
  14. package/skills/nimi-app-lifecycle/references/acceptance.md +1 -1
  15. package/skills/nimi-app-lifecycle/references/adapt.md +2 -2
  16. package/skills/nimi-app-lifecycle/references/release.md +1 -1
  17. package/skills/nimi-app-lifecycle/references/upgrade-platform.md +14 -0
  18. package/templates/app-source/src/ai-studio-core/ai-config.ts +17 -3
  19. package/templates/app-source/src/ai-studio-core/ai-studio-core.css +40 -3
  20. package/templates/app-source/src/ai-studio-core/audio-separation-request.ts +24 -0
  21. package/templates/app-source/src/ai-studio-core/contexts.tsx +4 -0
  22. package/templates/app-source/src/ai-studio-core/history-policy.ts +395 -41
  23. package/templates/app-source/src/ai-studio-core/history.ts +262 -10
  24. package/templates/app-source/src/ai-studio-core/host-context.tsx +15 -2
  25. package/templates/app-source/src/ai-studio-core/index.ts +15 -4
  26. package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +105 -0
  27. package/templates/app-source/src/ai-studio-core/job-recovery.ts +224 -0
  28. package/templates/app-source/src/ai-studio-core/managed-result-references.ts +79 -0
  29. package/templates/app-source/src/ai-studio-core/messages/en.json +185 -10
  30. package/templates/app-source/src/ai-studio-core/messages/zh.json +185 -10
  31. package/templates/app-source/src/ai-studio-core/module-registration.ts +9 -1
  32. package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +81 -2
  33. package/templates/app-source/src/ai-studio-core/parameters.ts +34 -1
  34. package/templates/app-source/src/ai-studio-core/runtime-types.ts +124 -8
  35. package/templates/app-source/src/ai-studio-core/runtime.ts +218 -20
  36. package/templates/app-source/src/ai-studio-core/section-ai-testing-annotation-result.tsx +123 -0
  37. package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +3 -0
  38. package/templates/app-source/src/ai-studio-core/section-ai-testing-audio-separation-result.tsx +26 -0
  39. package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +14 -7
  40. package/templates/app-source/src/ai-studio-core/section-ai-testing-decision-result.tsx +76 -0
  41. package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +71 -0
  42. package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +20 -4
  43. package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +29 -0
  44. package/templates/app-source/src/ai-studio-core/section-ai-testing-music-result.tsx +45 -0
  45. package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +132 -10
  46. package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +122 -38
  47. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +4 -3
  48. package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +66 -0
  49. package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +100 -22
  50. package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +6 -0
  51. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcript-result.tsx +45 -0
  52. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +106 -0
  53. package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +23 -4
  54. package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-asset-actions.tsx +40 -0
  55. package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-conversion-result.tsx +20 -0
  56. package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +219 -35
  57. package/templates/app-source/src/ai-studio-core/text-annotation-document.ts +50 -0
  58. package/templates/app-source/src/ai-studio-core/text-media-replay.ts +51 -0
  59. package/templates/app-source/src/ai-studio-core/voice-assets.ts +17 -0
  60. package/templates/app-source/src/ai-studio-core/workspace.tsx +48 -6
  61. package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +1 -1
  62. package/templates/app-source/src/studio-modules/studio-create/messages/en.json +13 -1
  63. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +13 -1
  64. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
  65. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -2
  66. package/templates/app-source/src/studio-modules/studio-create/registration.ts +2 -2
  67. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +121 -3
  68. package/templates/app-source/src/studio-modules/studio-media/audio-separate-parameters.tsx +72 -0
  69. package/templates/app-source/src/studio-modules/studio-media/audio-separate-runtime.ts +90 -0
  70. package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +16 -1
  71. package/templates/app-source/src/studio-modules/studio-media/index.ts +2 -0
  72. package/templates/app-source/src/studio-modules/studio-media/messages/en.json +225 -7
  73. package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +225 -7
  74. package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +85 -0
  75. package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx +85 -0
  76. package/templates/app-source/src/studio-modules/studio-media/music-transcription-runtime.ts +64 -0
  77. package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +9 -26
  78. package/templates/app-source/src/studio-modules/studio-media/parameters.ts +170 -6
  79. package/templates/app-source/src/studio-modules/studio-media/registration.ts +29 -1
  80. package/templates/app-source/src/studio-modules/studio-media/runtime.ts +90 -6
  81. package/templates/app-source/src/studio-modules/studio-media/vision-parameters.tsx +1 -0
  82. package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +23 -5
  83. package/templates/app-source/src/studio-modules/studio-media/voice-convert-parameters.tsx +132 -0
  84. package/templates/app-source/src/studio-modules/studio-media/voice-convert-runtime.ts +120 -0
  85. package/templates/app-source/src/studio-modules/studio-voice/audio-url.ts +25 -0
  86. package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +4 -4
  87. package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +4 -4
  88. package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +28 -0
  89. package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +66 -30
  90. package/templates/app-source/src/workbench-core/index.ts +2 -0
  91. package/templates/app-source/src/workbench-core/runtime-gate.tsx +102 -6
  92. package/templates/app-source/src/workbench-core/workbench-core.css +42 -0
  93. package/templates/app-source/src/workbench-core/workbench-core.tsx +69 -18
  94. package/templates/app-source.manifest.json +100 -0
  95. package/templates/default-starter/README.md +2 -1
  96. package/templates/default-starter/src/shell/workbench-target-adapter.ts +102 -12
  97. package/templates/default-starter.manifest.json +0 -4
@@ -1,12 +1,23 @@
1
+ import { VoiceAssetActions } from './section-ai-testing-voice-asset-actions.js';
2
+ import { MusicGenerationNotice } from './section-ai-testing-music-result.js';
3
+ import { MusicTranscriptionNotice } from './section-ai-testing-transcription-result.js';
4
+ import { VoiceConversionNotice } from './section-ai-testing-voice-conversion-result.js';
5
+ import { AudioSeparationNotice } from './section-ai-testing-audio-separation-result.js';
6
+ import { TextAnnotationResultView } from './section-ai-testing-annotation-result.js';
7
+ import { SpeechTranscriptResultView } from './section-ai-testing-transcript-result.js';
8
+ import { TextExchangeResultView } from './section-ai-testing-exchange-result.js';
9
+ import { TextDecisionResultView } from './section-ai-testing-decision-result.js';
10
+ import { FaceSwapNotice, SessionSummaryView } from './section-ai-testing-session-result.js';
1
11
  import { useState, type ReactNode } from 'react';
2
12
  import { IconButton, nimiToast, StatusBadge, Tooltip } from '@nimiplatform/kit/ui';
3
13
  import { AlertTriangle, ChevronRight, Copy as CopyIcon, Download as DownloadIcon, FileText, FolderOpen, MessageSquare, RefreshCw, SlidersHorizontal, SquarePen } from 'lucide-react';
4
14
  import { useAIStudioHost } from './host-context.js';
5
15
  import { VisionLocateResultView } from './section-ai-testing-vision-result.js';
6
16
  import type { StudioCapabilityRegistration } from './module-registration.js';
7
- import { formatStudioRunTimestamp, getStudioRunConfigParamRows, getStudioRunIntentLabel, getStudioRunPromptControlFacts, getStudioRunResultTags, getStudioRunStatusTone, type StudioRunConfigParamRow, type StudioRunHistoryRecord, type StudioRunHistoryResultSnapshot, type StudioRunPromptControlFact } from './history.js';
17
+ import { getStudioRunHistoryExportText, formatStudioRunTimestamp, getStudioRunConfigParamRows, getStudioRunIntentLabel, getStudioRunPromptControlFacts, getStudioRunResultTags, getStudioRunStatusTone, type StudioRunConfigParamRow, type StudioRunHistoryRecord, type StudioRunHistoryResultSnapshot, type StudioRunPromptControlFact } from './history.js';
8
18
  import { studioNonSuccessReasonTitle, studioNonSuccessReasonUserAction, studioNonSuccessReasonUserMessage } from './non-success-presentation.js';
9
- import { ArtifactMediaResult, RuntimeDiagnosticsActions, StudioResult, TextStudioOutputBody, downloadTextFile, statusForCapability } from './section-ai-testing-surface.js';
19
+ import { ArtifactMediaPreview, ArtifactMediaResult, RuntimeDiagnosticsActions, StudioResult, TextStudioOutputBody, downloadTextFile, statusForCapability } from './section-ai-testing-surface.js';
20
+ import { EmbeddingResultBody, SpeakerEmbeddingResultBody, KnownJobNotice, revealStudioAsset } from './section-ai-testing-output.js';
10
21
  import type { TextStudioActiveRun } from './section-ai-testing-run.js';
11
22
 
12
23
  function TextStudioPromptControlFacts({ facts }: { facts: readonly StudioRunPromptControlFact[] }) {
@@ -98,17 +109,10 @@ function hasTextStudioRequestSettings(record: StudioRunHistoryRecord): boolean {
98
109
  return getStudioRunConfigParamRows(runConfig).length > 0 || Boolean(runConfig.target.paramsSummary.join(' / '));
99
110
  }
100
111
 
101
- function historyRecordPlainText(record: StudioRunHistoryRecord): string {
102
- const snapshot = record.result;
103
- if (!snapshot) return record.message;
104
- if (!snapshot.ok) return snapshot.message;
105
- if (snapshot.kind === 'text' || snapshot.kind === 'transcript') return snapshot.body;
106
- return snapshot.summary;
107
- }
108
-
109
112
  function historyNonSuccessDiagnosticsText(snapshot: Extract<StudioRunHistoryResultSnapshot, { ok: false }>): string {
110
113
  return [
111
114
  `Reason: ${snapshot.reason}`,
115
+ snapshot.jobId ? `Job: ${snapshot.jobId}` : '',
112
116
  snapshot.missingSurface ? `Missing surface: ${snapshot.missingSurface}` : '',
113
117
  '',
114
118
  'Message:',
@@ -131,11 +135,13 @@ function historyResultToneClass(record: StudioRunHistoryRecord): string {
131
135
  }
132
136
 
133
137
  function TextStudioHistoryRecordResult({
138
+ registration,
134
139
  record,
135
140
  canRegenerate,
136
141
  onRegenerate,
137
142
  onUseAsDraft,
138
143
  }: {
144
+ registration: StudioCapabilityRegistration;
139
145
  record: StudioRunHistoryRecord;
140
146
  canRegenerate: boolean;
141
147
  onRegenerate: () => void;
@@ -144,14 +150,31 @@ function TextStudioHistoryRecordResult({
144
150
  const rendererHost = useAIStudioHost();
145
151
  const { translate: t } = useAIStudioHost();
146
152
  const snapshot = record.result;
153
+ const HistoryActions = registration.historyActions;
147
154
  const blocked = snapshot && !snapshot.ok ? snapshot : null;
148
- const tags = blocked ? [studioNonSuccessReasonTitle(blocked.reason, t)] : getStudioRunResultTags(record);
155
+ const jobState = snapshot?.ok && 'jobState' in snapshot ? snapshot.jobState : undefined;
156
+ const statusLabel = record.status === 'ready' && snapshot?.ok && (snapshot.kind === 'speaker-embedding' || (snapshot.kind === 'vision-locate' && snapshot.result))
157
+ ? t('Studio.result.statCompleted')
158
+ : jobState === undefined
159
+ ? rendererHost.app.projection.runStatusLabel(record.status)
160
+ : jobState.toUpperCase() === 'COMPLETED' ? t('Studio.result.statCompleted')
161
+ : jobState || t('Studio.result.stateUnknown');
162
+ const tags = blocked ? [studioNonSuccessReasonTitle(blocked.reason, t, record.capabilityId)] : getStudioRunResultTags(record);
149
163
  const intentLabel = getStudioRunIntentLabel(record);
150
164
  const toneClass = historyResultToneClass(record);
151
- const exportText = historyRecordPlainText(record);
165
+ const exportText = getStudioRunHistoryExportText(record);
152
166
  const managedArtifact = snapshot?.ok && snapshot.kind === 'artifacts'
153
167
  ? snapshot.artifacts?.[0] ?? snapshot.firstArtifact
154
- : undefined;
168
+ : snapshot?.ok && snapshot.kind === 'text-annotation' ? snapshot.document : undefined;
169
+ // Session state and selected media are not retained by history. A truncated
170
+ // prompt or omitted extra annotation documents would replay different input.
171
+ const sessionOnly = snapshot?.ok && snapshot.kind === 'session';
172
+ const faceSwapNeedsMedia = snapshot?.ok && snapshot.kind === 'artifacts' && Boolean(snapshot.faceSwap);
173
+ const speakerNeedsMedia = snapshot?.ok && snapshot.kind === 'speaker-embedding';
174
+ const additionalDocumentsNotRetained = snapshot?.ok && snapshot.kind === 'text-annotation'
175
+ && Number(record.runConfig?.target.params.additionalDocuments ?? 0) > 0;
176
+ const canUseAsDraft = !sessionOnly && !faceSwapNeedsMedia && !speakerNeedsMedia && !record.inputTruncated;
177
+ const canReplay = canUseAsDraft && !additionalDocumentsNotRetained;
155
178
  const revealsManagedAsset = Boolean(managedArtifact?.relativePath);
156
179
  const canExport = !blocked && (revealsManagedAsset || Boolean(exportText.trim()));
157
180
  const hasRequestSettings = hasTextStudioRequestSettings(record);
@@ -172,12 +195,12 @@ function TextStudioHistoryRecordResult({
172
195
  }
173
196
  function handleDownload() {
174
197
  if (managedArtifact?.relativePath) {
175
- void rendererHost.sdk.revealLocalAppAsset(managedArtifact.relativePath);
198
+ void revealStudioAsset(rendererHost, managedArtifact.relativePath);
176
199
  return;
177
200
  }
178
201
  const stamp = record.createdAt.replace(/[:.]/g, '-');
179
202
  if (!exportText.trim()) return;
180
- void downloadTextFile(rendererHost.app.commands, `${record.capabilityId}-${stamp}.txt`, exportText);
203
+ void downloadTextFile(rendererHost, `${record.capabilityId}-${stamp}.txt`, exportText);
181
204
  }
182
205
  let body: ReactNode;
183
206
  if (!snapshot) {
@@ -195,10 +218,11 @@ function TextStudioHistoryRecordResult({
195
218
  <div className="studio-result__blocked">
196
219
  <div className="studio-result__blocked-line">
197
220
  <AlertTriangle size={15} aria-hidden="true" />
198
- <span>{studioNonSuccessReasonTitle(snapshot.reason, t)}</span>
221
+ <span>{studioNonSuccessReasonTitle(snapshot.reason, t, record.capabilityId)}</span>
199
222
  </div>
200
223
  <p>{studioNonSuccessReasonUserMessage(snapshot.reason, t, record.capabilityId, snapshot.diagnostics)}</p>
201
224
  <p className="studio-result__hint">{studioNonSuccessReasonUserAction(snapshot.reason, t, record.capabilityId, snapshot.diagnostics)}</p>
225
+ <KnownJobNotice jobId={snapshot.jobId} />
202
226
  <details className="studio-diag">
203
227
  <summary>{t('StudioShell.runtimeDetails')}</summary>
204
228
  <RuntimeDiagnosticsActions text={diagnosticsText} filenameBase={record.capabilityId} />
@@ -207,14 +231,15 @@ function TextStudioHistoryRecordResult({
207
231
  </div>
208
232
  );
209
233
  } else {
210
- body = <TextStudioHistorySnapshotBody snapshot={snapshot} />;
234
+ body = <TextStudioHistorySnapshotBody snapshot={snapshot} recordId={record.id}
235
+ submittedParameters={record.capabilityId === 'audio.separate' ? record.runConfig?.target.params : undefined} />;
211
236
  }
212
237
  return (
213
238
  <div className="studio-history-result" role="status">
214
239
  <div className="studio-history-result__head">
215
240
  <div className="studio-history-result__line">
216
241
  <StatusBadge tone={getStudioRunStatusTone(record.status)} shape="dot">
217
- {blocked ? studioNonSuccessReasonTitle(blocked.reason, t) : rendererHost.app.projection.runStatusLabel(record.status)}
242
+ {blocked ? studioNonSuccessReasonTitle(blocked.reason, t) : statusLabel}
218
243
  </StatusBadge>
219
244
  <span className="studio-history-result__title-stack">
220
245
  <time dateTime={record.createdAt}>{t('StudioShell.runLabel')} / {formatStudioRunTimestamp(record.createdAt, new Date(rendererHost.clock.now()))}</time>
@@ -231,12 +256,16 @@ function TextStudioHistoryRecordResult({
231
256
  </Tooltip>
232
257
  </>
233
258
  ) : null}
234
- <Tooltip content={t('StudioShell.useAsDraft')} placement="top">
235
- <IconButton type="button" className="studio-result__action" onClick={() => onUseAsDraft(record)} aria-label={t('StudioShell.useAsDraft')} icon={<SquarePen size={16} aria-hidden="true" />} />
236
- </Tooltip>
237
- <Tooltip content={t('StudioShell.regenerate')} placement="top">
238
- <IconButton type="button" className="studio-result__action" onClick={onRegenerate} disabled={!canRegenerate} aria-label={t('StudioShell.regenerate')} icon={<RefreshCw size={16} aria-hidden="true" />} />
239
- </Tooltip>
259
+ {canUseAsDraft ? (
260
+ <Tooltip content={t('StudioShell.useAsDraft')} placement="top">
261
+ <IconButton type="button" className="studio-result__action" onClick={() => onUseAsDraft(record)} aria-label={t('StudioShell.useAsDraft')} icon={<SquarePen size={16} aria-hidden="true" />} />
262
+ </Tooltip>
263
+ ) : null}
264
+ {canReplay ? (
265
+ <Tooltip content={t('StudioShell.regenerate')} placement="top">
266
+ <IconButton type="button" className="studio-result__action" onClick={onRegenerate} disabled={!canRegenerate} aria-label={t('StudioShell.regenerate')} icon={<RefreshCw size={16} aria-hidden="true" />} />
267
+ </Tooltip>
268
+ ) : null}
240
269
  </div>
241
270
  </div>
242
271
  <div className="studio-history-result__meta">
@@ -265,31 +294,67 @@ function TextStudioHistoryRecordResult({
265
294
  </div>
266
295
  </div>
267
296
  {requestSettingsOpen && hasRequestSettings ? <TextStudioRequestSettings record={record} /> : null}
297
+ {HistoryActions ? <HistoryActions key={record.id} record={record} /> : null}
268
298
  {body}
299
+ {additionalDocumentsNotRetained ? <p className="studio-result__hint">{t('StudioShell.historyAdditionalDocumentsNotRetained')}</p> : null}
269
300
  </div>
270
301
  );
271
302
  }
272
303
 
273
- function TextStudioHistorySnapshotBody({ snapshot }: { snapshot: Extract<StudioRunHistoryResultSnapshot, { ok: true }> }) {
304
+ function TextStudioHistorySnapshotBody({ snapshot, recordId, submittedParameters }: {
305
+ snapshot: Extract<StudioRunHistoryResultSnapshot, { ok: true }>; recordId: string;
306
+ submittedParameters?: Readonly<Record<string, unknown>>;
307
+ }) {
274
308
  const { translate: t } = useAIStudioHost();
275
309
  if (snapshot.kind === 'vision-locate') return snapshot.result
276
- ? <VisionLocateResultView output={{kind:'vision-locate', jobId:snapshot.jobId, result:snapshot.result}} />
310
+ ? <VisionLocateResultView output={{kind:'vision-locate', jobId:snapshot.jobId, result:snapshot.result, sourceImage:snapshot.sourceImage}} />
277
311
  : <><p>{snapshot.summary}</p><p className="studio-result__hint">{t('VisionLocate.historySummaryOnly')}</p><pre>{JSON.stringify({ jobId: snapshot.jobId }, null, 2)}</pre></>;
278
- if (snapshot.kind === 'text' || snapshot.kind === 'transcript') {
279
- return <TextStudioOutputBody text={snapshot.body} />;
312
+ if (snapshot.kind === 'text') {
313
+ return <div className="studio-result__rich">
314
+ {snapshot.sourceImage ? <ArtifactMediaPreview artifact={snapshot.sourceImage} fallbackLabel={snapshot.sourceImage.displayName || snapshot.sourceImage.relativePath} /> : null}
315
+ <TextStudioOutputBody text={snapshot.body} />
316
+ </div>;
280
317
  }
318
+ if (snapshot.kind === 'transcript') {
319
+ return <SpeechTranscriptResultView text={snapshot.body} transcription={snapshot.transcription} />;
320
+ }
321
+ if (snapshot.kind === 'speaker-embedding') return <SpeakerEmbeddingResultBody spaceId={snapshot.spaceId} vector={snapshot.vector} />;
281
322
  if (snapshot.kind === 'embedding') {
282
- return (
283
- <div className="studio-result__rich">
284
- <p className="studio-result__plain">{t('StudioShell.embeddingSuccess')}</p>
285
- </div>
286
- );
323
+ return <EmbeddingResultBody spaceId={snapshot.spaceId} />;
324
+ }
325
+ if (snapshot.kind === 'text-annotation') {
326
+ return <TextAnnotationResultView output={{
327
+ kind: 'text-annotation', jobId: snapshot.jobId, jobState: snapshot.jobState, language: snapshot.language,
328
+ documentCount: snapshot.documentCount, tokenCount: snapshot.tokenCount, sentenceCount: snapshot.sentenceCount, document: snapshot.document,
329
+ }} />;
330
+ }
331
+ if (snapshot.kind === 'text-exchange') {
332
+ return <TextExchangeResultView output={{
333
+ kind: 'text-exchange', scenario: snapshot.scenario, steps: snapshot.steps, text: snapshot.text,
334
+ ...(snapshot.structured !== undefined ? { structured: snapshot.structured } : {}),
335
+ }} />;
336
+ }
337
+ if (snapshot.kind === 'text-decision') {
338
+ return snapshot.answers
339
+ ? <TextDecisionResultView output={{ kind: 'text-decision', answers: snapshot.answers }} traceId={snapshot.traceId} />
340
+ : <><p>{snapshot.summary}</p><p className="studio-result__hint">{t('StudioResults.decision.summaryOnly')}</p></>;
341
+ }
342
+ if (snapshot.kind === 'session') {
343
+ return <SessionSummaryView output={{
344
+ kind: 'session', capabilityContract: snapshot.capabilityContract, startedAt: snapshot.startedAt, endedAt: snapshot.endedAt,
345
+ ending: snapshot.ending, terminalReason: snapshot.terminalReason, observed: snapshot.observed,
346
+ }} />;
287
347
  }
288
348
  if (snapshot.kind === 'artifacts') {
289
349
  const artifacts = snapshot.artifacts ?? (snapshot.firstArtifact ? [snapshot.firstArtifact] : []);
290
350
  return (
291
351
  <div className="studio-result__rich">
292
- {artifacts.map((artifact, index) => (
352
+ <MusicGenerationNotice value={snapshot.musicGeneration} />
353
+ <MusicTranscriptionNotice value={snapshot.musicTranscription} recordId={recordId} />
354
+ <VoiceConversionNotice value={snapshot.voiceConversion} />
355
+ <AudioSeparationNotice value={snapshot.audioSeparation} submittedParameters={submittedParameters} />
356
+ <FaceSwapNotice value={snapshot.faceSwap} />
357
+ {artifacts.filter((artifact) => !snapshot.musicTranscription && !snapshot.voiceConversion && !snapshot.audioSeparation && artifact.relativePath !== snapshot.musicGeneration?.generatedScore?.relativePath).map((artifact, index) => (
293
358
  <ArtifactMediaResult
294
359
  key={artifact.relativePath}
295
360
  artifact={artifact}
@@ -303,6 +368,9 @@ function TextStudioHistorySnapshotBody({ snapshot }: { snapshot: Extract<StudioR
303
368
  return (
304
369
  <div className="studio-result__rich">
305
370
  <p className="studio-result__plain">{t('StudioShell.voiceAssetSuccess')}</p>
371
+ {snapshot.preview ? <ArtifactMediaResult artifact={snapshot.preview} fallbackLabel={snapshot.jobId} /> : null}
372
+ {snapshot.expiresAt ? <p>{t('StudioShell.voiceExpiry', { date: new Date(snapshot.expiresAt).toLocaleString() })}</p> : null}
373
+ <VoiceAssetActions key={snapshot.voiceAssetId} voiceAssetId={snapshot.voiceAssetId} />
306
374
  </div>
307
375
  );
308
376
  }
@@ -345,6 +413,7 @@ export function TextStudioResultState({
345
413
  intentLabel,
346
414
  running,
347
415
  canRegenerate,
416
+ regenerateHint,
348
417
  cancelRequested,
349
418
  streamingText,
350
419
  verboseConsole,
@@ -354,6 +423,7 @@ export function TextStudioResultState({
354
423
  onRegenerate,
355
424
  onCancel,
356
425
  onUseAsDraft,
426
+ onOpenIntentConfig,
357
427
  }: {
358
428
  registration: StudioCapabilityRegistration;
359
429
  activeRun: TextStudioActiveRun;
@@ -361,6 +431,7 @@ export function TextStudioResultState({
361
431
  intentLabel: string;
362
432
  running: boolean;
363
433
  canRegenerate: boolean;
434
+ regenerateHint?: string;
364
435
  cancelRequested: boolean;
365
436
  streamingText: string | null;
366
437
  verboseConsole: boolean;
@@ -370,24 +441,36 @@ export function TextStudioResultState({
370
441
  onRegenerate: () => void;
371
442
  onCancel?: () => void;
372
443
  onUseAsDraft: (record: StudioRunHistoryRecord) => void;
444
+ onOpenIntentConfig?: () => void;
373
445
  }) {
374
446
  const { translate: t } = useAIStudioHost();
375
447
  const capability = registration.descriptor;
376
448
  return (
377
449
  <section className="studio-thread" aria-label={t('StudioShell.resultAriaLabel', { capability: t(capability.labelKey) })}>
378
450
  <div className="studio-thread__scroll">
379
- <article className="studio-turn studio-turn--user">
451
+ {regenerateHint ? <p className="studio-result__hint" role="status">{regenerateHint}</p> : null}
452
+ {registration.parameters.recordedInput ? (
453
+ // A parameter-owned input is shown as the complete request it recorded.
454
+ <article className="studio-turn studio-turn--user">
455
+ <details className="studio-diag studio-turn__request">
456
+ <summary>{t('StudioShell.requestLabel')}</summary>
457
+ <pre className="studio-diag__json">{activeRun.prompt}</pre>
458
+ </details>
459
+ {activeRun.record?.inputTruncated ? <p className="studio-result__hint">{t('StudioShell.historyInputTruncated')}</p> : null}
460
+ </article>
461
+ ) : registration.profile.inputKind !== 'none' && activeRun.prompt ? <article className="studio-turn studio-turn--user">
380
462
  <div className="studio-turn__label">
381
463
  <MessageSquare size={14} aria-hidden="true" />
382
464
  <span>{t('StudioShell.promptLabel')}</span>
383
465
  </div>
384
466
  <p>{activeRun.prompt}</p>
467
+ {activeRun.record?.inputTruncated ? <p className="studio-result__hint">{t('StudioShell.historyInputTruncated')}</p> : null}
385
468
  <TextStudioPromptSettings activeRun={activeRun} />
386
- </article>
469
+ </article> : null}
387
470
  <article className="studio-turn studio-turn--assistant">
388
471
  <div className="studio-turn__label">
389
472
  <FileText size={14} aria-hidden="true" />
390
- <span>{t('StudioShell.generationLabel')}</span>
473
+ <span>{t(capability.id === 'music.transcribe' ? 'Transcription.result' : capability.id === 'audio.voice.convert' ? 'VoiceConvert.result' : capability.id === 'audio.separate' ? 'AudioSeparate.result' : 'StudioShell.generationLabel')}</span>
391
474
  </div>
392
475
  {activeRun.error ? (
393
476
  <TextStudioRunError message={activeRun.error} />
@@ -410,10 +493,11 @@ export function TextStudioResultState({
410
493
  onDownload={onDownload}
411
494
  onRegenerate={onRegenerate}
412
495
  onCancel={onCancel}
496
+ onOpenIntentConfig={onOpenIntentConfig}
413
497
  />
414
498
  </>
415
499
  ) : activeRun.record ? (
416
- <TextStudioHistoryRecordResult record={activeRun.record} canRegenerate={canRegenerate} onRegenerate={onRegenerate} onUseAsDraft={onUseAsDraft} />
500
+ <TextStudioHistoryRecordResult registration={registration} record={activeRun.record} canRegenerate={canRegenerate} onRegenerate={onRegenerate} onUseAsDraft={onUseAsDraft} />
417
501
  ) : null}
418
502
  </article>
419
503
  </div>
@@ -3,7 +3,7 @@ import type { NimiPortableAppAIConfig } from '@nimiplatform/sdk/ai';
3
3
 
4
4
  import { useAIStudioHost } from './host-context.js';
5
5
  import type { StudioCapabilityRegistration, CapabilityStudioProfile } from './module-registration.js';
6
- import type { StudioCapabilityRunResult, StudioRuntimeInspection } from './runtime-types.js';
6
+ import type { StudioCapabilityRunResult, StudioManagedArtifact, StudioRuntimeInspection } from './runtime-types.js';
7
7
  import {
8
8
  getStudioRunIntentLabel,
9
9
  type StudioRunConfigSnapshot,
@@ -20,6 +20,8 @@ import {
20
20
  import type { StudioTranslate } from './non-success-presentation.js';
21
21
 
22
22
  export type TextStudioActiveRun = {
23
+ attachmentCount?: number;
24
+ replayMedia?: StudioManagedArtifact;
23
25
  jobStatus?: 'queued' | 'running';
24
26
  id: string;
25
27
  prompt: string;
@@ -63,7 +65,6 @@ export function canConfigureRunTarget(runTarget: StudioRunTargetSummary): boolea
63
65
  export function useStudioRunTargetSummary(
64
66
  registration: StudioCapabilityRegistration,
65
67
  runtime: StudioRuntimeInspection | null,
66
- configOpen = false,
67
68
  ): StudioRunTargetSummary {
68
69
  const host = useAIStudioHost();
69
70
  const [configProjection, setConfigProjection] = useState<{
@@ -101,7 +102,7 @@ export function useStudioRunTargetSummary(
101
102
  requestGeneration += 1;
102
103
  unsubscribe();
103
104
  };
104
- }, [host, configOpen]);
105
+ }, [host]);
105
106
 
106
107
  return useMemo(() => host.app.projection.projectRunTarget({
107
108
  capability: registration.descriptor,
@@ -0,0 +1,66 @@
1
+ import { useAIStudioHost } from './host-context.js';
2
+ import type { StudioFaceSwap, StudioTypedOutput } from './runtime-types.js';
3
+
4
+ type SessionOutput = Extract<StudioTypedOutput, { kind: 'session' }>;
5
+
6
+ // A Session summary records what was observed while it was open. It cannot
7
+ // restore the Session; running it again opens a new one.
8
+ export function SessionSummaryView({ output }: { readonly output: SessionOutput }) {
9
+ const { translate: t } = useAIStudioHost();
10
+ const started = new Date(output.startedAt);
11
+ const ended = new Date(output.endedAt);
12
+ const seconds = Math.max(0, (ended.valueOf() - started.valueOf()) / 1000);
13
+ const counters = Object.entries(output.observed).filter(([, count]) => count > 0);
14
+ return (
15
+ <section className="studio-result__rich" aria-label={t('StudioResults.session.title')}>
16
+ <p className="studio-result__plain">
17
+ {t(output.ending === 'closed' ? 'StudioResults.session.closed' : 'StudioResults.session.terminated', {
18
+ contract: output.capabilityContract,
19
+ reason: output.terminalReason,
20
+ })}
21
+ </p>
22
+ <dl className="studio-diag__grid">
23
+ <div><dt>{t('StudioResults.session.started')}</dt><dd><time dateTime={output.startedAt}>{output.startedAt}</time></dd></div>
24
+ <div><dt>{t('StudioResults.session.duration')}</dt><dd>{t('StudioResults.session.seconds', { seconds: seconds.toFixed(1) })}</dd></div>
25
+ <div><dt>{t('StudioResults.session.terminalReason')}</dt><dd><code>{output.terminalReason}</code></dd></div>
26
+ </dl>
27
+ {counters.length > 0 ? (
28
+ <ul className="studio-voice-list">
29
+ {counters.map(([name, count]) => (
30
+ <li key={name}><strong>{name}</strong><span>{count}</span></li>
31
+ ))}
32
+ </ul>
33
+ ) : <p className="studio-result__hint">{t('StudioResults.session.nothingObserved')}</p>}
34
+ <p className="studio-result__hint">{t('StudioResults.session.notRestorable')}</p>
35
+ </section>
36
+ );
37
+ }
38
+
39
+ export function FaceSwapNotice({ value }: { readonly value?: StudioFaceSwap }) {
40
+ const { translate: t } = useAIStudioHost();
41
+ if (!value) return null;
42
+ return (
43
+ <section className="space-y-2 text-sm" aria-label={t('StudioResults.faceSwap.inputs')}>
44
+ <ul className="studio-voice-list">
45
+ {value.inputs.map((input) => (
46
+ <li key={input.role}>
47
+ <strong>{t(`StudioResults.faceSwap.role.${input.role}`)}</strong>
48
+ <span>{`${input.name} · ${input.mediaType} · ${input.sizeBytes} B · ${input.sha256.slice(0, 19)}…`}</span>
49
+ </li>
50
+ ))}
51
+ </ul>
52
+ {value.noFacePolicy ? <p>{t('StudioResults.faceSwap.policy', { policy: t(`StudioResults.faceSwap.policies.${value.noFacePolicy}`) })}</p> : null}
53
+ {value.video ? (
54
+ <p>{t('StudioResults.faceSwap.videoSummary', {
55
+ total: value.video.totalFrames,
56
+ transformed: value.video.transformedFrames,
57
+ preserved: value.video.preservedFrames,
58
+ seconds: (value.video.durationUs / 1_000_000).toFixed(2),
59
+ fps: value.video.frameRate,
60
+ audio: t(value.video.audioPreserved ? 'StudioResults.faceSwap.audioPreserved' : 'StudioResults.faceSwap.noAudio'),
61
+ })}</p>
62
+ ) : null}
63
+ <p className="studio-result__hint">{t('StudioResults.faceSwap.rerunHint')}</p>
64
+ </section>
65
+ );
66
+ }