@nimiplatform/app-tools 0.14.0 → 0.16.0-rc.12

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 (99) hide show
  1. package/README.md +112 -24
  2. package/bin/nimi-app.mjs +35 -15
  3. package/lib/app-access-declaration.mjs +3 -0
  4. package/lib/app-dependency-combinations.mjs +70 -24
  5. package/lib/app-doctor-update.mjs +97 -39
  6. package/lib/app-host-support.mjs +6 -0
  7. package/lib/app-identifiers.mjs +27 -0
  8. package/lib/app-info.mjs +292 -1
  9. package/lib/app-lifecycle-guidance.mjs +1 -1
  10. package/lib/app-pack.mjs +65 -39
  11. package/lib/app-project-lifecycle.mjs +149 -244
  12. package/lib/app-scaffold-capabilities.mjs +13 -109
  13. package/lib/app-scaffold-profiles.mjs +81 -115
  14. package/lib/app-scaffold.mjs +74 -166
  15. package/lib/app-toolchain-updates.mjs +45 -0
  16. package/lib/canonical-capability-ids.generated.mjs +2 -0
  17. package/lib/development-environment.d.mts +10 -0
  18. package/lib/development-environment.mjs +39 -0
  19. package/lib/hosted-web-release.mjs +98 -0
  20. package/lib/index.mjs +43 -3
  21. package/lib/mobile-development.mjs +19 -0
  22. package/lib/realm-environments.generated.mjs +5 -0
  23. package/lib/storefront-media.mjs +154 -0
  24. package/lib/web-coordination.mjs +59 -0
  25. package/lib/web-development.d.mts +23 -0
  26. package/lib/web-development.mjs +118 -0
  27. package/lib/web-scaffold.mjs +125 -0
  28. package/package.json +33 -21
  29. package/scripts/dev-shell.mjs +4 -1
  30. package/scripts/sync-scaffold-versions.mjs +0 -2
  31. package/skills/nimi-app-lifecycle/SKILL.md +3 -1
  32. package/skills/nimi-app-lifecycle/references/acceptance.md +6 -2
  33. package/skills/nimi-app-lifecycle/references/adapt.md +5 -3
  34. package/skills/nimi-app-lifecycle/references/audit.md +3 -2
  35. package/skills/nimi-app-lifecycle/references/create.md +6 -2
  36. package/skills/nimi-app-lifecycle/references/release.md +10 -0
  37. package/skills/nimi-app-lifecycle/references/upgrade-platform.md +12 -7
  38. package/templates/app-source/src/ai-studio-core/ai-studio-core.css +87 -52
  39. package/templates/app-source/src/ai-studio-core/history-policy.ts +45 -11
  40. package/templates/app-source/src/ai-studio-core/history.ts +22 -11
  41. package/templates/app-source/src/ai-studio-core/host-context.tsx +9 -4
  42. package/templates/app-source/src/ai-studio-core/index.ts +2 -0
  43. package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +15 -5
  44. package/templates/app-source/src/ai-studio-core/job-recovery.ts +2 -2
  45. package/templates/app-source/src/ai-studio-core/messages/en.json +73 -19
  46. package/templates/app-source/src/ai-studio-core/messages/zh.json +73 -19
  47. package/templates/app-source/src/ai-studio-core/module-registration.ts +1 -0
  48. package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +30 -5
  49. package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +12 -6
  50. package/templates/app-source/src/ai-studio-core/parameters.ts +4 -0
  51. package/templates/app-source/src/ai-studio-core/prompt-drafts.ts +42 -0
  52. package/templates/app-source/src/ai-studio-core/runtime-types.ts +9 -2
  53. package/templates/app-source/src/ai-studio-core/runtime.ts +8 -4
  54. package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +98 -90
  55. package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +1 -1
  56. package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +205 -48
  57. package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +1 -0
  58. package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +36 -14
  59. package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +96 -75
  60. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +59 -16
  61. package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +2 -0
  62. package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +12 -21
  63. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +2 -2
  64. package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +3 -3
  65. package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +158 -76
  66. package/templates/app-source/src/ai-studio-core/workspace.tsx +49 -22
  67. package/templates/app-source/src/product-modules/agent-center/index.tsx +2 -3
  68. package/templates/app-source/src/product-modules/agent-conversation/index.tsx +2 -3
  69. package/templates/app-source/src/studio-modules/studio-create/messages/en.json +12 -3
  70. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +12 -3
  71. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
  72. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -1
  73. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +47 -5
  74. package/templates/app-source/src/studio-modules/studio-media/messages/en.json +59 -8
  75. package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +68 -8
  76. package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +2 -1
  77. package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +271 -83
  78. package/templates/app-source/src/studio-modules/studio-media/parameters.ts +120 -2
  79. package/templates/app-source/src/studio-modules/studio-media/registration.ts +1 -0
  80. package/templates/app-source/src/studio-modules/studio-media/runtime.ts +24 -14
  81. package/templates/app-source/src/studio-modules/studio-voice/descriptors.ts +1 -1
  82. package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +3 -2
  83. package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +3 -2
  84. package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +46 -23
  85. package/templates/app-source/src/studio-modules/studio-voice/registration.ts +2 -1
  86. package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +2 -2
  87. package/templates/app-source/src/workbench-core/workbench-core.tsx +27 -3
  88. package/templates/default-starter/AGENTS.md +3 -3
  89. package/templates/default-starter/README.md +1 -1
  90. package/templates/default-starter/src/shell/App.tsx +6 -18
  91. package/templates/default-starter/src/shell/auth/local-app-client.ts +6 -15
  92. package/templates/default-starter/src/shell/auth/runtime-platform.ts +7 -107
  93. package/templates/default-starter/src/shell/workbench-target-adapter.ts +9 -126
  94. package/templates/default-starter.manifest.json +0 -16
  95. package/templates/hosted-web-release.yml +98 -0
  96. package/templates/default-starter/src-tauri/Cargo.toml +0 -17
  97. package/templates/default-starter/src-tauri/build.rs +0 -32
  98. package/templates/default-starter/src-tauri/capabilities/default.json +0 -7
  99. package/templates/default-starter/src-tauri/tauri.conf.json +0 -26
@@ -1,3 +1,4 @@
1
+ import type { NimiRuntimeVideoContentPart } from '@nimiplatform/sdk/features/generation';
1
2
  import {
2
3
  CLOUD_ONLY_STUDIO_PARAMETER,
3
4
  LOCAL_AND_CLOUD_STUDIO_PARAMETER,
@@ -49,6 +50,9 @@ function recordedRangeValid(restored: Record<string, unknown>, start: string, en
49
50
  }
50
51
 
51
52
  export type StudioImageGenerationParameters = {
53
+ controlImageArtifactId?: string;
54
+ controlType?: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
55
+ controlStrength?: number;
52
56
  negativePrompt?: string;
53
57
  count?: number;
54
58
  size?: string;
@@ -59,12 +63,27 @@ export type StudioImageGenerationParameters = {
59
63
  referenceImage?: string;
60
64
  referenceImageArtifactId?: string;
61
65
  mask?: string;
66
+ maskArtifactId?: string;
67
+ complexity?: '' | 'low' | 'medium' | 'high';
68
+ outputFormat?: '' | 'png' | 'jpeg' | 'webp' | 'gif' | 'svg';
69
+ markup?: string;
70
+ markupArtifactId?: string;
71
+ frameCount?: number;
72
+ frameDurationMs?: number;
62
73
  };
63
74
 
64
75
  export type StudioVideoGenerationParameters = {
65
- mode?: 't2v' | 'i2v-first-frame' | 'i2v-reference';
76
+ mode?: 't2v' | 'i2v-first-frame' | 'i2v-first-last' | 'i2v-reference';
66
77
  firstFrameImageUrl?: string;
78
+ firstFrameArtifactId?: string;
79
+ lastFrameImageUrl?: string;
80
+ lastFrameArtifactId?: string;
67
81
  referenceArtifactId?: string;
82
+ additionalReferenceArtifactIds?: string[];
83
+ referenceVideoUrls?: string[];
84
+ referenceAudioUrls?: string[];
85
+ referenceAudioArtifactIds?: string[];
86
+ referenceVideoArtifactIds?: string[];
68
87
  negativePrompt?: string;
69
88
  resolution?: string;
70
89
  frames?: number;
@@ -210,6 +229,18 @@ export const MAX_STUDIO_ARTIFACT_UPLOAD_BYTES = 32 * 1024 * 1024;
210
229
 
211
230
  export const studioImageGenerateParameters = defineStudioParameters<StudioImageGenerationParameters>({
212
231
  initial: () => ({}),
232
+ restoreRecordedParameters: (snapshot) => {
233
+ if (!snapshot) return null;
234
+ const strings = new Set(['negativePrompt', 'size', 'aspectRatio', 'quality', 'style', 'referenceImage', 'referenceImageArtifactId', 'mask', 'maskArtifactId', 'complexity', 'outputFormat', 'markup', 'markupArtifactId', 'controlImageArtifactId']);
235
+ const numbers = new Set(['count', 'seed', 'frameCount', 'frameDurationMs', 'controlType', 'controlStrength']);
236
+ const restored: Record<string, unknown> = {};
237
+ for (const [key,value] of Object.entries(snapshot)) {
238
+ if (value === undefined) continue;
239
+ if (strings.has(key) ? typeof value !== 'string' : numbers.has(key) ? typeof value !== 'number' || !Number.isFinite(value) : true) return null;
240
+ restored[key] = value;
241
+ }
242
+ return restored as StudioImageGenerationParameters;
243
+ },
213
244
  routeMatrix: {
214
245
  negativePrompt: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
215
246
  count: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
@@ -221,15 +252,102 @@ export const studioImageGenerateParameters = defineStudioParameters<StudioImageG
221
252
  referenceImage: CLOUD_ONLY_STUDIO_PARAMETER,
222
253
  referenceImageArtifactId: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
223
254
  mask: CLOUD_ONLY_STUDIO_PARAMETER,
255
+ maskArtifactId: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
256
+ complexity: CLOUD_ONLY_STUDIO_PARAMETER,
257
+ outputFormat: CLOUD_ONLY_STUDIO_PARAMETER,
258
+ markup: CLOUD_ONLY_STUDIO_PARAMETER,
259
+ markupArtifactId: CLOUD_ONLY_STUDIO_PARAMETER,
260
+ frameCount: CLOUD_ONLY_STUDIO_PARAMETER,
261
+ frameDurationMs: CLOUD_ONLY_STUDIO_PARAMETER,
262
+ controlImageArtifactId: LOCAL_ONLY_STUDIO_PARAMETER,
263
+ controlType: LOCAL_ONLY_STUDIO_PARAMETER,
264
+ controlStrength: LOCAL_ONLY_STUDIO_PARAMETER,
224
265
  },
225
266
  });
226
267
 
268
+ export function studioVideoInput(parameters: StudioVideoGenerationParameters = {}):
269
+ | { ok: true; content: readonly NimiRuntimeVideoContentPart[] }
270
+ | { ok: false; issue: string } {
271
+ const content: NimiRuntimeVideoContentPart[] = [];
272
+ if (parameters.mode === 'i2v-first-frame' || parameters.mode === 'i2v-first-last') {
273
+ const frames = [
274
+ { role: 'first-frame' as const, artifactId: parameters.firstFrameArtifactId, url: parameters.firstFrameImageUrl, issue: 'Studio.parameters.videoFirstFrameRequired' },
275
+ ...(parameters.mode === 'i2v-first-last'
276
+ ? [{ role: 'last-frame' as const, artifactId: parameters.lastFrameArtifactId, url: parameters.lastFrameImageUrl, issue: 'Studio.parameters.videoLastFrameRequired' }]
277
+ : []),
278
+ ];
279
+ for (const frame of frames) {
280
+ const artifactId = frame.artifactId?.trim();
281
+ const url = frame.url?.trim();
282
+ if (Boolean(artifactId) === Boolean(url)) return { ok: false, issue: frame.issue };
283
+ content.push(artifactId ? { type: 'artifact-ref', role: frame.role, artifactId } : { type: 'image-url', role: frame.role, url: url! });
284
+ }
285
+ } else if (parameters.mode === 'i2v-reference') {
286
+ const imageIds = [
287
+ ...(parameters.referenceArtifactId?.trim() ? [parameters.referenceArtifactId] : []),
288
+ ...(parameters.additionalReferenceArtifactIds ?? []),
289
+ ];
290
+ content.push(
291
+ ...imageIds.map((artifactId) => ({ type: 'artifact-ref' as const, role: 'reference-image' as const, artifactId })),
292
+ ...(parameters.referenceVideoArtifactIds ?? []).map((artifactId) => ({ type: 'artifact-ref' as const, role: 'reference-video' as const, artifactId })),
293
+ ...(parameters.referenceVideoUrls ?? []).map((url) => ({ type: 'video-url' as const, role: 'reference-video' as const, url })),
294
+ ...(parameters.referenceAudioArtifactIds ?? []).map((artifactId) => ({ type: 'artifact-ref' as const, role: 'reference-audio' as const, artifactId })),
295
+ ...(parameters.referenceAudioUrls ?? []).map((url) => ({ type: 'audio-url' as const, role: 'reference-audio' as const, url })),
296
+ );
297
+ if (!content.length || content.some((part) => {
298
+ const value = 'artifactId' in part ? part.artifactId : 'url' in part ? part.url : '';
299
+ return typeof value !== 'string' || !value.trim();
300
+ })) return { ok: false, issue: 'Studio.parameters.videoReferencesRequired' };
301
+ }
302
+ return { ok: true, content };
303
+ }
304
+
227
305
  export const studioVideoGenerateParameters = defineStudioParameters<StudioVideoGenerationParameters>({
228
306
  initial: () => ({ mode: 't2v' }),
307
+ hasAlternativeInput: (value) => {
308
+ const input = studioVideoInput(value);
309
+ return input.ok && input.content.length > 0;
310
+ },
311
+ requiredInputIssue: (value) => {
312
+ const input = studioVideoInput(value);
313
+ return input.ok ? undefined : input.issue;
314
+ },
315
+ restoreRecordedParameters: (snapshot) => {
316
+ if (!snapshot) return null;
317
+ const strings = new Set(['mode', 'firstFrameImageUrl', 'firstFrameArtifactId', 'lastFrameImageUrl', 'lastFrameArtifactId', 'referenceArtifactId', 'negativePrompt', 'resolution', 'ratio', 'serviceTier']);
318
+ const numbers = new Set(['frames', 'seed', 'durationSec', 'fps', 'executionExpiresAfterSec']);
319
+ const booleans = new Set(['generateAudio', 'cameraFixed', 'watermark', 'draft', 'returnLastFrame']);
320
+ const restored: Record<string, unknown> = {};
321
+ for (const [key, value] of Object.entries(snapshot)) {
322
+ if (value === undefined) continue;
323
+ if (strings.has(key)) {
324
+ if (typeof value !== 'string') return null;
325
+ } else if (numbers.has(key)) {
326
+ if (typeof value !== 'number' || !Number.isFinite(value)) return null;
327
+ } else if (booleans.has(key)) {
328
+ if (typeof value !== 'boolean') return null;
329
+ } else if (['additionalReferenceArtifactIds', 'referenceVideoUrls', 'referenceAudioUrls', 'referenceAudioArtifactIds', 'referenceVideoArtifactIds'].includes(key)) {
330
+ if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) return null;
331
+ restored[key] = [...value];
332
+ continue;
333
+ } else return null;
334
+ restored[key] = value;
335
+ }
336
+ if (restored.mode !== undefined && !['t2v', 'i2v-first-frame', 'i2v-first-last', 'i2v-reference'].includes(String(restored.mode))) return null;
337
+ return restored as StudioVideoGenerationParameters;
338
+ },
229
339
  routeMatrix: {
230
340
  mode: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
231
- referenceArtifactId: LOCAL_ONLY_STUDIO_PARAMETER,
341
+ referenceArtifactId: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
342
+ additionalReferenceArtifactIds: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
343
+ referenceVideoUrls: CLOUD_ONLY_STUDIO_PARAMETER,
344
+ referenceAudioUrls: CLOUD_ONLY_STUDIO_PARAMETER,
345
+ referenceAudioArtifactIds: CLOUD_ONLY_STUDIO_PARAMETER,
346
+ referenceVideoArtifactIds: CLOUD_ONLY_STUDIO_PARAMETER,
232
347
  firstFrameImageUrl: CLOUD_ONLY_STUDIO_PARAMETER,
348
+ firstFrameArtifactId: CLOUD_ONLY_STUDIO_PARAMETER,
349
+ lastFrameImageUrl: CLOUD_ONLY_STUDIO_PARAMETER,
350
+ lastFrameArtifactId: CLOUD_ONLY_STUDIO_PARAMETER,
233
351
  negativePrompt: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
234
352
  resolution: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
235
353
  frames: LOCAL_AND_CLOUD_STUDIO_PARAMETER,
@@ -59,6 +59,7 @@ export const studioMediaModule = Object.freeze({
59
59
  descriptor: studioMediaDescriptors[1],
60
60
  icon: Video,
61
61
  profile: {
62
+ primaryParameters: 'partial',
62
63
  studioTag: 'Video', inputTitleKey: 'Studio.profiles.videoGenerate.inputTitle', inputPlaceholderKey: 'Studio.profiles.videoGenerate.inputPlaceholder', inputKind: 'prompt', supportsAttachments: false, controls: [], primaryLabelKey: 'Studio.profiles.videoGenerate.primaryLabel', primaryRunningLabelKey: 'Studio.profiles.videoGenerate.primaryRunningLabel', resultTitle: 'Generated clip', emptyTitleKey: 'Studio.profiles.videoGenerate.emptyTitle', emptyHintKey: 'Studio.profiles.videoGenerate.emptyHint', resultKind: 'artifacts', footnoteKey: 'Studio.profiles.videoGenerate.footnote',
63
64
  },
64
65
  preset: { id: 'clip-sample', label: 'Clip sample', prompt: 'Create a short inspection clip for a Nimi App glass UI workflow.' },
@@ -11,10 +11,11 @@ import {
11
11
  projectStudioArtifactRunnerResult,
12
12
  type StudioCapabilityRuntimeContext,
13
13
  } from '../../ai-studio-core/runtime.js';
14
- import type {
15
- StudioImageGenerationParameters,
16
- StudioMusicGenerationParameters,
17
- StudioVideoGenerationParameters,
14
+ import {
15
+ studioVideoInput,
16
+ type StudioImageGenerationParameters,
17
+ type StudioMusicGenerationParameters,
18
+ type StudioVideoGenerationParameters,
18
19
  } from './parameters.js';
19
20
 
20
21
  // @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-019c
@@ -43,6 +44,9 @@ async function runImageGenerate(context: StudioCapabilityRuntimeContext) {
43
44
  if (parameters?.referenceImage?.trim() && parameters.referenceImageArtifactId?.trim()) {
44
45
  return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Studio.parameters.imageReferenceExclusive'));
45
46
  }
47
+ if ((parameters?.controlImageArtifactId || parameters?.controlType !== undefined || parameters?.controlStrength !== undefined) && (!parameters?.controlImageArtifactId || !parameters?.controlType)) {
48
+ return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Studio.parameters.controlImageRequired'));
49
+ }
46
50
  const result = await context.host.runners.imageGenerate({
47
51
  runtime: { ai: createStudioScenarioJobClient(context) },
48
52
  appId: context.host.appId,
@@ -57,6 +61,16 @@ async function runImageGenerate(context: StudioCapabilityRuntimeContext) {
57
61
  ...(parameters?.referenceImage !== undefined ? { referenceImages: [parameters.referenceImage] } : {}),
58
62
  ...(parameters?.referenceImageArtifactId !== undefined ? { referenceImageArtifactId: parameters.referenceImageArtifactId } : {}),
59
63
  ...(parameters?.mask !== undefined ? { mask: parameters.mask } : {}),
64
+ ...(parameters?.maskArtifactId !== undefined ? { maskArtifactId: parameters.maskArtifactId } : {}),
65
+ ...(parameters?.complexity !== undefined ? { complexity: parameters.complexity } : {}),
66
+ ...(parameters?.outputFormat !== undefined ? { outputFormat: parameters.outputFormat } : {}),
67
+ ...(parameters?.markup !== undefined ? { markup: parameters.markup } : {}),
68
+ ...(parameters?.markupArtifactId !== undefined ? { markupArtifactId: parameters.markupArtifactId } : {}),
69
+ ...(parameters?.frameCount !== undefined ? { frameCount: parameters.frameCount } : {}),
70
+ ...(parameters?.frameDurationMs !== undefined ? { frameDurationMs: parameters.frameDurationMs } : {}),
71
+ ...(parameters?.controlImageArtifactId && parameters.controlType ? {
72
+ controlImage: { imageArtifactId: parameters.controlImageArtifactId, type: parameters.controlType, ...(parameters.controlStrength === undefined ? {} : { strength: parameters.controlStrength }) },
73
+ } : {}),
60
74
  scenarioId: context.scenarioId,
61
75
  surfaceId: context.host.surfaceId,
62
76
  observationSignal: context.input.observationSignal,
@@ -91,6 +105,8 @@ async function runMusicGenerate(context: StudioCapabilityRuntimeContext) {
91
105
  const capabilities = resource?.oneofKind === 'local' ? resource.local.musicInput : resource?.oneofKind === 'cloud' ? resource.cloud.target?.musicInput : undefined;
92
106
  const profile = capabilities?.generation.find((item) => item.scoreMode === (parameters?.scoreRelativePath ? 'required' : 'unsupported'));
93
107
  if (selected?.state !== 'ready' || !profile) return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Music.configureInputs'));
108
+ if (profile.lyricsMode === 'required' && !lyrics.trim()) return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Music.lyricsRequired'));
109
+ if (profile.lyricsMode === 'unsupported' && lyrics.trim()) return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Music.lyricsUnsupported'));
94
110
  let score: { artifactId: string; format: 'abc' } | undefined;
95
111
  if (parameters?.scoreRelativePath) {
96
112
  const input = await context.host.client.storage.assets.read({ relativePath: parameters.scoreRelativePath });
@@ -140,24 +156,18 @@ async function runVideoGenerate(context: StudioCapabilityRuntimeContext) {
140
156
  onJobUpdate: context.input.onJobUpdate, onObservation: context.input.onObservation });
141
157
  return projectStudioArtifactRunnerResult(context, result);
142
158
  }
143
- if (!context.prompt) return inputRequired(context);
144
159
  const parameters = context.input.parameters as StudioVideoGenerationParameters | undefined;
145
160
  const mode = parameters?.mode ?? 't2v';
146
- if (mode === 'i2v-first-frame' && !parameters?.firstFrameImageUrl?.trim()) {
147
- return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate('Studio.parameters.videoFirstFrameRequired'));
148
- }
161
+ if (!context.prompt && mode === 't2v') return inputRequired(context);
162
+ const input = studioVideoInput(parameters);
163
+ if (!input.ok) return context.host.nonSuccess(context.capability, 'input-invalid', context.host.translate(input.issue));
149
164
  const result = await context.host.runners.videoGenerate({
150
165
  runtime: { ai: createStudioScenarioJobClient(context) },
151
166
  appId: context.host.appId,
152
167
  mode,
153
168
  prompt: context.prompt,
154
169
  ...(parameters?.negativePrompt !== undefined ? { negativePrompt: parameters.negativePrompt } : {}),
155
- ...(mode === 'i2v-first-frame' && parameters?.firstFrameImageUrl ? {
156
- content: [{ type: 'image-url', role: 'first-frame', url: parameters.firstFrameImageUrl }],
157
- } : {}),
158
- ...(mode === 'i2v-reference' && parameters?.referenceArtifactId ? {
159
- content: [{ type: 'artifact-ref', role: 'reference-image', artifactId: parameters.referenceArtifactId }],
160
- } : {}),
170
+ ...(input.content.length > 0 ? { content: input.content } : {}),
161
171
  options: videoGenerationOptions(parameters),
162
172
  scenarioId: context.scenarioId,
163
173
  surfaceId: context.host.surfaceId,
@@ -10,7 +10,7 @@ export const studioVoiceDescriptors = Object.freeze([
10
10
  {
11
11
  id: 'audio.transcribe', label: 'Speech Transcribe', labelKey: 'Capabilities.audioTranscribe.label', group: 'audio',
12
12
  section: 'stt',
13
- summary: 'Audio URL → audio.transcribe Scenario Job → typed transcript result.', summaryKey: 'Capabilities.audioTranscribe.summary',
13
+ summary: 'Audio file or HTTPS URL → audio.transcribe Scenario Job → typed transcript result.', summaryKey: 'Capabilities.audioTranscribe.summary',
14
14
  surface: 'kit.runRuntimeSpeechTranscribe → sdk.localApp.ai.scenarioJobs + artifacts', execution: 'runtime-sdk', capabilityContract: 'audio.transcribe',
15
15
  },
16
16
  {
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "audioTranscribe": {
8
8
  "label": "Speech Transcribe",
9
- "summary": "Audio URL → audio.transcribe Scenario Job → typed transcript result."
9
+ "summary": "Audio file or HTTPS URL → audio.transcribe Scenario Job → typed transcript result."
10
10
  },
11
11
  "voiceCreate": {
12
12
  "label": "Voice Create",
@@ -64,7 +64,8 @@
64
64
  "noVoiceAssets": "No created voices",
65
65
  "chooseAudioFile": "Choose audio file",
66
66
  "removeFile": "Remove",
67
- "audioFileTooLarge": "Audio files must not exceed 32 MiB.",
67
+ "transcriptionAudioFileSize": "Choose a non-empty audio file up to 32 MiB.",
68
+ "transcriptionAudioFileUnreadable": "Could not read the selected audio file. Choose it again or use another file.",
68
69
  "voiceReferenceFileTooLarge": "Reference audio must be non-empty and not exceed 20 MiB.",
69
70
  "voiceReferenceMimeUnsupported": "Choose a file with an audio MIME type.",
70
71
  "voiceSourceReferenceAudio": "Reference audio",
@@ -6,7 +6,7 @@
6
6
  },
7
7
  "audioTranscribe": {
8
8
  "label": "语音转写",
9
- "summary": "音频 URL → audio.transcribe 场景任务 → 类型化转写结果。"
9
+ "summary": "音频文件或 HTTPS 链接 → audio.transcribe 场景任务 → 类型化转写结果。"
10
10
  },
11
11
  "voiceCreate": {
12
12
  "label": "创建语音",
@@ -64,7 +64,8 @@
64
64
  "noVoiceAssets": "暂无已创建音色",
65
65
  "chooseAudioFile": "选择音频文件",
66
66
  "removeFile": "移除",
67
- "audioFileTooLarge": "音频文件不得超过 32 MiB。",
67
+ "transcriptionAudioFileSize": "请选择不超过 32 MiB 的非空音频文件。",
68
+ "transcriptionAudioFileUnreadable": "无法读取所选音频,请重新选择或换一个文件。",
68
69
  "voiceReferenceFileTooLarge": "参考音频必须非空且不得超过 20 MiB。",
69
70
  "voiceReferenceMimeUnsupported": "请选择具有音频 MIME 类型的文件。",
70
71
  "voiceSourceReferenceAudio": "参考音频",
@@ -122,19 +122,37 @@ function SpeechTranscribeFields(props: StudioParameterPanelProps) {
122
122
  const parameters = props.parameters as StudioSpeechTranscribeParameters;
123
123
  const update = props.onChange as (next: StudioSpeechTranscribeParameters) => void;
124
124
  const inputRef = useRef<HTMLInputElement>(null);
125
+ const fileSelection = useRef(0);
126
+ const latestParameters = useRef(parameters);
127
+ latestParameters.current = parameters;
125
128
  const [fileError, setFileError] = useState('');
129
+ useEffect(() => () => { fileSelection.current += 1; }, []);
130
+
126
131
  async function selectFile(event: ChangeEvent<HTMLInputElement>) {
127
132
  const file = event.currentTarget.files?.[0];
128
133
  event.currentTarget.value = '';
129
134
  if (!file) return;
130
- if (file.size > MAX_STUDIO_AUDIO_UPLOAD_BYTES) {
131
- setFileError(t('Studio.parameters.audioFileTooLarge'));
135
+ const selection = ++fileSelection.current;
136
+ if (file.size === 0 || file.size > MAX_STUDIO_AUDIO_UPLOAD_BYTES) {
137
+ setFileError(t('Studio.parameters.transcriptionAudioFileSize'));
132
138
  return;
133
139
  }
134
140
  const mimeType = file.type || 'application/octet-stream';
135
- const bytes = new Uint8Array(await file.arrayBuffer());
136
141
  setFileError('');
137
- update({ ...parameters, audioFile: { name: file.name, mimeType, sizeBytes: file.size, bytes }, mimeType });
142
+ try {
143
+ const bytes = new Uint8Array(await file.arrayBuffer());
144
+ if (selection !== fileSelection.current) return;
145
+ update({ ...latestParameters.current, audioFile: { name: file.name, mimeType, sizeBytes: file.size, bytes }, mimeType });
146
+ } catch {
147
+ if (selection === fileSelection.current) setFileError(t('Studio.parameters.transcriptionAudioFileUnreadable'));
148
+ }
149
+ }
150
+ function removeFile() {
151
+ fileSelection.current += 1;
152
+ const next = { ...parameters };
153
+ delete next.audioFile;
154
+ update(next);
155
+ setFileError('');
138
156
  }
139
157
  const textField = (field: keyof StudioSpeechTranscribeParameters, label: string): StudioParameterFieldDefinition => ({
140
158
  field,
@@ -148,23 +166,6 @@ function SpeechTranscribeFields(props: StudioParameterPanelProps) {
148
166
  });
149
167
  const audioFileLabel = t('Studio.parameters.fields.audioFile');
150
168
  const fields: StudioParameterFieldDefinition[] = [
151
- {
152
- field: 'audioFile',
153
- label: audioFileLabel,
154
- render: (routeDisabled) => (
155
- <StudioParameterField label={audioFileLabel}>
156
- <input ref={inputRef} className="studio-parameters__file-input" type="file" accept="audio/*,.wav,.mp3,.m4a,.ogg,.webm,.flac" disabled={props.disabled || routeDisabled} onChange={(event) => void selectFile(event)} />
157
- <div className="studio-parameters__file-row">
158
- <Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled} leadingIcon={<Upload size={14} aria-hidden="true" />} onClick={() => inputRef.current?.click()}>
159
- {t('Studio.parameters.chooseAudioFile')}
160
- </Button>
161
- {parameters.audioFile ? <span>{parameters.audioFile.name}</span> : null}
162
- {parameters.audioFile ? <Button type="button" tone="ghost" size="sm" disabled={props.disabled || routeDisabled} onClick={() => { const next = { ...parameters }; delete next.audioFile; update(next); }}>{t('Studio.parameters.removeFile')}</Button> : null}
163
- </div>
164
- {fileError ? <small>{fileError}</small> : null}
165
- </StudioParameterField>
166
- ),
167
- },
168
169
  textField('mimeType', t('Studio.parameters.fields.mimeType')),
169
170
  textField('language', t('Studio.parameters.fields.language')),
170
171
  booleanField('timestamps', t('Studio.parameters.fields.timestamps')),
@@ -177,7 +178,29 @@ function SpeechTranscribeFields(props: StudioParameterPanelProps) {
177
178
  textField('prompt', t('Studio.parameters.fields.transcriptionPrompt')),
178
179
  textField('responseFormat', t('Studio.parameters.fields.responseFormat')),
179
180
  ];
180
- return <StudioRouteAwareParameterFields contract={props.contract} source={props.source} fields={fields} translate={translate} />;
181
+ return (
182
+ <StudioParameterPanelFrame
183
+ translate={translate}
184
+ disabled={props.disabled}
185
+ onReset={() => update(parameters.audioFile ? { audioFile: parameters.audioFile, mimeType: parameters.audioFile.mimeType } : {})}
186
+ primary={(
187
+ <fieldset className="studio-parameters__field">
188
+ <legend className="studio-parameters__label">{audioFileLabel}</legend>
189
+ <input ref={inputRef} className="studio-parameters__file-input" type="file" accept="audio/*,.wav,.mp3,.m4a,.ogg,.webm,.flac" disabled={props.disabled} onChange={(event) => void selectFile(event)} />
190
+ <div className="studio-parameters__file-row">
191
+ <Button type="button" tone="secondary" size="sm" disabled={props.disabled} leadingIcon={<Upload size={14} aria-hidden="true" />} onClick={() => inputRef.current?.click()}>
192
+ {t('Studio.parameters.chooseAudioFile')}
193
+ </Button>
194
+ {parameters.audioFile ? <span>{parameters.audioFile.name}</span> : null}
195
+ {parameters.audioFile ? <Button type="button" tone="ghost" size="sm" disabled={props.disabled} onClick={removeFile}>{t('Studio.parameters.removeFile')}</Button> : null}
196
+ </div>
197
+ {fileError ? <small role="alert">{fileError}</small> : null}
198
+ </fieldset>
199
+ )}
200
+ >
201
+ <StudioRouteAwareParameterFields contract={props.contract} source={props.source} fields={fields} translate={translate} />
202
+ </StudioParameterPanelFrame>
203
+ );
181
204
  }
182
205
 
183
206
  function VoiceCreateFields(props: StudioParameterPanelProps) {
@@ -267,9 +290,9 @@ function VoiceCreateFields(props: StudioParameterPanelProps) {
267
290
  export function StudioVoiceParameterPanel(props: StudioParameterPanelProps) {
268
291
  const { translate: t } = useAIStudioHost();
269
292
  const translate: StudioParameterTranslate = (key, values) => t(key, values);
293
+ if (props.capabilityId === 'audio.transcribe') return <SpeechTranscribeFields {...props} />;
270
294
  let fields = null;
271
295
  if (props.capabilityId === 'audio.synthesize') fields = <SpeechSynthesizeFields {...props} />;
272
- else if (props.capabilityId === 'audio.transcribe') fields = <SpeechTranscribeFields {...props} />;
273
296
  else if (props.capabilityId === 'voice.create') fields = <VoiceCreateFields {...props} />;
274
297
  if (!fields) return null;
275
298
  return (
@@ -27,9 +27,10 @@ export const studioVoiceModule = Object.freeze({
27
27
  descriptor: studioVoiceDescriptors[1],
28
28
  icon: Captions,
29
29
  profile: {
30
+ primaryParameters: 'partial',
30
31
  studioTag: 'Transcribe', inputTitleKey: 'Studio.profiles.audioTranscribe.inputTitle', inputPlaceholderKey: 'Studio.profiles.audioTranscribe.inputPlaceholder', inputKind: 'url', supportsAttachments: false, controls: [], primaryLabelKey: 'Studio.profiles.audioTranscribe.primaryLabel', primaryRunningLabelKey: 'Studio.profiles.audioTranscribe.primaryRunningLabel', resultTitle: 'Transcript', emptyTitleKey: 'Studio.profiles.audioTranscribe.emptyTitle', emptyHintKey: 'Studio.profiles.audioTranscribe.emptyHint', resultKind: 'transcript', footnoteKey: 'Studio.profiles.audioTranscribe.footnote',
31
32
  },
32
- preset: { id: 'audio-url', label: 'Audio URL', prompt: 'https://example.test/sample.wav' },
33
+ preset: { id: 'audio-url', label: 'Audio input', prompt: '' },
33
34
  runtimeMethod: 'kit.generation.runRuntimeSpeechTranscribe',
34
35
  parameters: studioSpeechTranscribeParameters,
35
36
  parameterPanel: StudioVoiceParameterPanel,
@@ -89,11 +89,11 @@ async function runSpeechTranscribe(context: StudioCapabilityRuntimeContext) {
89
89
  }
90
90
  const parameters = context.input.parameters as StudioSpeechTranscribeParameters | undefined;
91
91
  if (!context.prompt && !parameters?.audioFile) return inputRequired(context);
92
- if (parameters?.audioFile && parameters.audioFile.sizeBytes > MAX_STUDIO_AUDIO_UPLOAD_BYTES) {
92
+ if (parameters?.audioFile && (parameters.audioFile.bytes.byteLength === 0 || parameters.audioFile.bytes.byteLength > MAX_STUDIO_AUDIO_UPLOAD_BYTES)) {
93
93
  return context.host.nonSuccess(
94
94
  context.capability,
95
95
  'input-invalid',
96
- 'Speech transcription audio files must not exceed 32 MiB.',
96
+ 'Speech transcription requires a non-empty audio file up to 32 MiB.',
97
97
  );
98
98
  }
99
99
  const inferredMimeType = context.prompt ? audioMimeTypeFromUrl(context.prompt) : null;
@@ -21,6 +21,8 @@ export type WorkbenchNavigationGroup<TViewId extends string> = {
21
21
  readonly id: string;
22
22
  readonly label?: string;
23
23
  readonly items: readonly WorkbenchNavigationItem<TViewId>[];
24
+ readonly collapsed?: boolean;
25
+ readonly onToggle?: () => void;
24
26
  };
25
27
 
26
28
  export type WorkbenchCoreProps<TViewId extends string> = {
@@ -30,6 +32,8 @@ export type WorkbenchCoreProps<TViewId extends string> = {
30
32
  readonly navigationPresentation?: 'rail' | 'catalog';
31
33
  readonly navigationTitle?: string;
32
34
  readonly navigationDescription?: string;
35
+ readonly navigationToolbar?: ReactNode;
36
+ readonly navigationEmpty?: ReactNode;
33
37
  readonly navigationGroups: readonly WorkbenchNavigationGroup<TViewId>[];
34
38
  readonly bottomNavigationItems?: readonly WorkbenchNavigationItem<TViewId>[];
35
39
  readonly bottomNavigationLabel?: string;
@@ -46,6 +50,8 @@ export function WorkbenchCore<TViewId extends string>({
46
50
  navigationPresentation = 'rail',
47
51
  navigationTitle,
48
52
  navigationDescription,
53
+ navigationToolbar,
54
+ navigationEmpty,
49
55
  navigationGroups,
50
56
  bottomNavigationItems = [],
51
57
  bottomNavigationLabel,
@@ -62,6 +68,7 @@ export function WorkbenchCore<TViewId extends string>({
62
68
  <div className="workbench-side-nav__heading">
63
69
  <h1>{navigationTitle}</h1>
64
70
  {navigationDescription ? <p>{navigationDescription}</p> : null}
71
+ {navigationToolbar}
65
72
  </div>
66
73
  ) : null}
67
74
  <nav className="workbench-side-nav__groups" aria-label={navigationLabel}>
@@ -71,10 +78,13 @@ export function WorkbenchCore<TViewId extends string>({
71
78
  activeViewId={activeViewId}
72
79
  items={group.items}
73
80
  label={group.label}
81
+ collapsed={group.collapsed}
82
+ onToggle={group.onToggle}
74
83
  onSelectView={onSelectView}
75
84
  presentation={navigationPresentation}
76
85
  />
77
86
  ))}
87
+ {navigationGroups.length === 0 ? navigationEmpty : null}
78
88
  {navigationPresentation === 'rail' && (bottomNavigationItems.length > 0 || accountSlot) ? (
79
89
  <div className="workbench-side-nav__group" data-nav-placement="bottom">
80
90
  <ul>
@@ -123,17 +133,30 @@ function WorkbenchNavigationList<TViewId extends string>({
123
133
  label,
124
134
  onSelectView,
125
135
  presentation,
136
+ collapsed = false,
137
+ onToggle,
126
138
  }: {
127
139
  readonly activeViewId: TViewId | null;
128
140
  readonly items: readonly WorkbenchNavigationItem<TViewId>[];
129
141
  readonly label?: string;
130
142
  readonly onSelectView: (viewId: TViewId) => void;
131
143
  readonly presentation: 'rail' | 'catalog';
144
+ readonly collapsed?: boolean;
145
+ readonly onToggle?: () => void;
132
146
  }) {
133
147
  return (
134
148
  <div className="workbench-side-nav__group">
135
- {presentation === 'catalog' && label ? <h2 className="workbench-side-nav__group-label">{label}</h2> : null}
136
- <ul>
149
+ {presentation === 'catalog' && label ? (
150
+ <h2 className="workbench-side-nav__group-label">
151
+ {onToggle ? (
152
+ <Button type="button" tone="ghost" size="sm" className="workbench-side-nav__group-toggle" onClick={onToggle} aria-expanded={!collapsed}
153
+ leadingIcon={<span className="workbench-side-nav__group-chevron" aria-hidden="true" />}>
154
+ {label}
155
+ </Button>
156
+ ) : label}
157
+ </h2>
158
+ ) : null}
159
+ {!collapsed ? <ul>
137
160
  {items.map((item) => (
138
161
  <WorkbenchNavigationListItem
139
162
  key={item.id}
@@ -143,7 +166,7 @@ function WorkbenchNavigationList<TViewId extends string>({
143
166
  presentation={presentation}
144
167
  />
145
168
  ))}
146
- </ul>
169
+ </ul> : null}
147
170
  </div>
148
171
  );
149
172
  }
@@ -170,6 +193,7 @@ function WorkbenchNavigationListItem<TViewId extends string>({
170
193
  className={active ? 'workbench-side-nav__item workbench-side-nav__item--active' : 'workbench-side-nav__item'}
171
194
  onClick={() => onSelectView(item.id)}
172
195
  aria-label={item.label}
196
+ aria-description={item.detail}
173
197
  aria-current={active ? 'page' : undefined}
174
198
  >
175
199
  <Icon size={18} strokeWidth={1.9} aria-hidden="true" />
@@ -3,7 +3,7 @@
3
3
  ## Scope
4
4
  - Treat `.nimi/app-scaffold/{intent,lock}.json` as app-scaffold intent and lock state.
5
5
  - App Tools maintains its identity/contract projections and the declared engineering fields in `.nimi/config` and `.nimi/admission`; the build profile and product declarations retain their App-owned inputs. Nimi-coding maintains its own methodology and AGENTS block through its declared sync command.
6
- - Keep auth, Runtime, App Access declaration, manifest, and Tauri shell glue in scaffold-managed files.
6
+ - Keep auth, Runtime and native shell wiring in the managed files. The App author maintains its App Access, capability requirements, storage policy and metadata in nimi.app.yaml.
7
7
  - App-owned product code is `src/workbench-core/**`, selected `src/capabilities/**`, `src/shell/routes/product-area.tsx`, `src/shell/routes/app-navigation.tsx`, and App-authored product screens, state, tests, styles, and bounded native helpers.
8
8
  - Scaffold-managed code is the carrier/auth wiring, identity, manifests, project tooling, bounded native integration, and `src/scaffold/generated/**` composition glue.
9
9
  - Treat this template as the identity-neutral, Lab-derived base. The generator composes it positively with only the dependency closure of explicitly selected admitted features under `src/capabilities/**`.
@@ -11,7 +11,7 @@
11
11
 
12
12
  ## Hard Boundaries
13
13
  - Follow `Runtime / Realm truth -> @nimiplatform/sdk interface -> app consumer`.
14
- - Runtime owns AI execution and its exact configuration/admission; Cognition owns canonical long-term Memory and Knowledge. Realm owns ecosystem identity, relationships and shared entities; App business state follows its declared storage boundary.
14
+ - Runtime owns AI execution and its exact configuration/admission; Cognition V1 owns canonical long-term Memory and bounded Agent Source custody. The App owns its document workflows and retrieval data. Realm owns ecosystem identity, relationships and shared entities; App business state follows its declared storage boundary.
15
15
  - Use SDK typed projections for Runtime and Realm; do not call private endpoints or mirror their canonical truth locally.
16
16
  - Use `@nimiplatform/kit` for reusable controls, layout, accessibility, tokens, and interaction patterns; keep app CSS and composition product-specific.
17
17
  - Keep the base free of Lab-only product behavior. Feature implementations enter generated output only through the app-tools module registry and public admitted `--features` selection. Internal modules such as `ai-studio-core` enter only through dependency closure and are never selected directly.
@@ -20,7 +20,7 @@
20
20
  - Preserve lifecycle order: `create -> dependency install -> init -> sync -> check -> dev/test/build -> pack`. Never run lifecycle commands after `create` before dependencies are installed. Local publish remains unavailable; production publication is owned by the managed protected-tag GitHub workflow, while registry admission and installation remain separate later owners.
21
21
  - Keep public dependency version declarations and the selected package matrix. Development may resolve complete local npm tarballs through the explicit overrides supported by the selected app-tools README; source-workspace and directory links remain invalid. Public-release preflight requires registry resolutions. A private workspace-validation result is not standalone evidence.
22
22
  - Use generated Host, preload, renderer and SDK/Kit wiring as the foundation for session, App Access, AIConfig and AI calls. An existing App adaptation starts with a same-package generated reference and preserves the original product's workflows and business settings; do not substitute a reference workbench for the complete App.
23
- - Use the scaffold-managed Kit Electron app-host bridge for supervised local development. Treat `nimi-shell-tauri` glue, where present, as bounded independent OS integration only, never a second local-development carrier, authority, App registration, admission, model-routing, or token-custody surface.
23
+ - Use the scaffold-managed Kit Electron app-host bridge for supervised local development on Windows x64 and macOS arm64. The App owns any additional native helpers and their build inputs.
24
24
  - Do not add provider/model hardcoding, compatibility dual-writes, pseudo-success, Runtime internals, generated private clients, or Desktop product source.
25
25
  - Before durable storage, native commands, private calls, or registries, inspect the nearest contract and current consumer; ask only if multiple semantic owners remain plausible.
26
26
 
@@ -43,7 +43,7 @@ The default `windows-x86_64` build outputs a fresh non-installer Electron direct
43
43
 
44
44
  The production bundle rejects `--nimi-dev-renderer-url`. The protected native binding arrives only through Kit's optional dependency—do not add it directly to this App.
45
45
 
46
- `pnpm run build:tauri:production` remains an explicit alternative when a Tauri build profile is deliberately selected; it is not the default production carrier.
46
+ Electron packages target Windows x64 and macOS arm64. Standard builds use Node, pnpm and the prebuilt native Kit package for the target.
47
47
 
48
48
  ### Packaging & Release Boundaries
49
49
 
@@ -1,20 +1,15 @@
1
- import { WorkbenchRuntimeGate } from '../workbench-core/index.js';
1
+ import { NimiAppSessionProvider, NimiAppAccessGate } from '@nimiplatform/kit/auth/app';
2
2
  import { NimiToaster } from '@nimiplatform/kit/ui';
3
3
  import { NimiAppChrome } from '@nimiplatform/kit/ui/app-chrome';
4
4
  import appPackage from '../../package.json';
5
5
  import { hasGeneratedViews } from '../scaffold/generated/navigation.js';
6
6
  import { AppNavigationProvider, useAppNavigation } from './routes/app-navigation.js';
7
7
  import { AuthenticatedShell } from './authenticated-shell.js';
8
- import {
9
- appTitle,
10
- clearTargetRuntimeGate,
11
- resolveTargetRuntimeGate,
12
- targetRuntimeGateCopy,
13
- targetRuntimeGateErrorMessage,
14
- } from './workbench-target-adapter.js';
8
+ import { appTitle } from './auth/app-identity.js';
9
+ import { getTargetAppSession } from './workbench-target-adapter.js';
15
10
 
16
11
  export function App() {
17
- return <AppNavigationProvider><AppFrame /></AppNavigationProvider>;
12
+ return <NimiAppSessionProvider session={getTargetAppSession()}><AppNavigationProvider><AppFrame /></AppNavigationProvider></NimiAppSessionProvider>;
18
13
  }
19
14
  function AppFrame() {
20
15
  const owner = useAppNavigation();
@@ -25,17 +20,10 @@ function AppFrame() {
25
20
  return (
26
21
  <div className="flex h-full min-h-0 flex-col overflow-hidden">
27
22
  <NimiAppChrome metadata={{ name: appTitle, version: appPackage.version, license: 'license' in appPackage && typeof appPackage.license === 'string' ? appPackage.license : undefined }} locale={locale} navigation={owner.navigation} navigationEnabled={owner.ready}
23
+ commands={[{ id: 'app.nimi-account', label: locale === 'zh' ? 'Nimi 账号' : 'Nimi account', menu: 'file', state: () => ({ visible: true, enabled: true }), execute: async () => { const account = getTargetAppSession().account; if (account.kind === 'home-managed') await account.openAccountOwner(); } }]}
28
24
  sidebar={sidebarAvailable && owner.ready ? { visible: owner.sidebarVisible, onVisibleChange: owner.setSidebarVisible } : undefined} />
29
25
  <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
30
- <WorkbenchRuntimeGate
31
- appTitle={appTitle}
32
- copy={targetRuntimeGateCopy}
33
- resolve={resolveTargetRuntimeGate}
34
- clear={clearTargetRuntimeGate}
35
- toErrorMessage={targetRuntimeGateErrorMessage}
36
- >
37
- <AuthenticatedShell />
38
- </WorkbenchRuntimeGate>
26
+ <NimiAppAccessGate title={appTitle} language={locale}>{() => <AuthenticatedShell />}</NimiAppAccessGate>
39
27
  </div>
40
28
  <NimiToaster />
41
29
  </div>