@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
@@ -41,6 +41,10 @@
41
41
  "path": "src/ai-studio-core/ai-studio-core.css",
42
42
  "class": "app-owned product code"
43
43
  },
44
+ {
45
+ "path": "src/ai-studio-core/audio-separation-request.ts",
46
+ "class": "app-owned product code"
47
+ },
44
48
  {
45
49
  "path": "src/ai-studio-core/contexts.tsx",
46
50
  "class": "app-owned product code"
@@ -61,6 +65,18 @@
61
65
  "path": "src/ai-studio-core/index.ts",
62
66
  "class": "app-owned product code"
63
67
  },
68
+ {
69
+ "path": "src/ai-studio-core/job-recovery-panel.tsx",
70
+ "class": "app-owned product code"
71
+ },
72
+ {
73
+ "path": "src/ai-studio-core/job-recovery.ts",
74
+ "class": "app-owned product code"
75
+ },
76
+ {
77
+ "path": "src/ai-studio-core/managed-result-references.ts",
78
+ "class": "app-owned product code"
79
+ },
64
80
  {
65
81
  "path": "src/ai-studio-core/messages/en.json",
66
82
  "class": "app-owned product code"
@@ -117,14 +133,30 @@
117
133
  "path": "src/ai-studio-core/section-ai-testing-ai-config.tsx",
118
134
  "class": "app-owned product code"
119
135
  },
136
+ {
137
+ "path": "src/ai-studio-core/section-ai-testing-annotation-result.tsx",
138
+ "class": "app-owned product code"
139
+ },
120
140
  {
121
141
  "path": "src/ai-studio-core/section-ai-testing-artifact-preview.ts",
122
142
  "class": "app-owned product code"
123
143
  },
144
+ {
145
+ "path": "src/ai-studio-core/section-ai-testing-audio-separation-result.tsx",
146
+ "class": "app-owned product code"
147
+ },
124
148
  {
125
149
  "path": "src/ai-studio-core/section-ai-testing-composer.tsx",
126
150
  "class": "app-owned product code"
127
151
  },
152
+ {
153
+ "path": "src/ai-studio-core/section-ai-testing-decision-result.tsx",
154
+ "class": "app-owned product code"
155
+ },
156
+ {
157
+ "path": "src/ai-studio-core/section-ai-testing-exchange-result.tsx",
158
+ "class": "app-owned product code"
159
+ },
128
160
  {
129
161
  "path": "src/ai-studio-core/section-ai-testing-history.tsx",
130
162
  "class": "app-owned product code"
@@ -133,6 +165,10 @@
133
165
  "path": "src/ai-studio-core/section-ai-testing-input.ts",
134
166
  "class": "app-owned product code"
135
167
  },
168
+ {
169
+ "path": "src/ai-studio-core/section-ai-testing-music-result.tsx",
170
+ "class": "app-owned product code"
171
+ },
136
172
  {
137
173
  "path": "src/ai-studio-core/section-ai-testing-output.tsx",
138
174
  "class": "app-owned product code"
@@ -145,6 +181,10 @@
145
181
  "path": "src/ai-studio-core/section-ai-testing-run.ts",
146
182
  "class": "app-owned product code"
147
183
  },
184
+ {
185
+ "path": "src/ai-studio-core/section-ai-testing-session-result.tsx",
186
+ "class": "app-owned product code"
187
+ },
148
188
  {
149
189
  "path": "src/ai-studio-core/section-ai-testing-studio-result.tsx",
150
190
  "class": "app-owned product code"
@@ -153,6 +193,14 @@
153
193
  "path": "src/ai-studio-core/section-ai-testing-surface.tsx",
154
194
  "class": "app-owned product code"
155
195
  },
196
+ {
197
+ "path": "src/ai-studio-core/section-ai-testing-transcript-result.tsx",
198
+ "class": "app-owned product code"
199
+ },
200
+ {
201
+ "path": "src/ai-studio-core/section-ai-testing-transcription-result.tsx",
202
+ "class": "app-owned product code"
203
+ },
156
204
  {
157
205
  "path": "src/ai-studio-core/section-ai-testing-vision-input.tsx",
158
206
  "class": "app-owned product code"
@@ -161,6 +209,14 @@
161
209
  "path": "src/ai-studio-core/section-ai-testing-vision-result.tsx",
162
210
  "class": "app-owned product code"
163
211
  },
212
+ {
213
+ "path": "src/ai-studio-core/section-ai-testing-voice-asset-actions.tsx",
214
+ "class": "app-owned product code"
215
+ },
216
+ {
217
+ "path": "src/ai-studio-core/section-ai-testing-voice-conversion-result.tsx",
218
+ "class": "app-owned product code"
219
+ },
164
220
  {
165
221
  "path": "src/ai-studio-core/section-ai-testing.tsx",
166
222
  "class": "app-owned product code"
@@ -169,6 +225,18 @@
169
225
  "path": "src/ai-studio-core/studio-directives.ts",
170
226
  "class": "app-owned product code"
171
227
  },
228
+ {
229
+ "path": "src/ai-studio-core/text-annotation-document.ts",
230
+ "class": "app-owned product code"
231
+ },
232
+ {
233
+ "path": "src/ai-studio-core/text-media-replay.ts",
234
+ "class": "app-owned product code"
235
+ },
236
+ {
237
+ "path": "src/ai-studio-core/voice-assets.ts",
238
+ "class": "app-owned product code"
239
+ },
172
240
  {
173
241
  "path": "src/ai-studio-core/workspace.tsx",
174
242
  "class": "app-owned product code"
@@ -245,6 +313,14 @@
245
313
  "path": "src/studio-modules/studio-create/runtime.ts",
246
314
  "class": "app-owned product code"
247
315
  },
316
+ {
317
+ "path": "src/studio-modules/studio-media/audio-separate-parameters.tsx",
318
+ "class": "app-owned product code"
319
+ },
320
+ {
321
+ "path": "src/studio-modules/studio-media/audio-separate-runtime.ts",
322
+ "class": "app-owned product code"
323
+ },
248
324
  {
249
325
  "path": "src/studio-modules/studio-media/descriptors.ts",
250
326
  "class": "app-owned product code"
@@ -265,6 +341,18 @@
265
341
  "path": "src/studio-modules/studio-media/messages/zh.json",
266
342
  "class": "app-owned product code"
267
343
  },
344
+ {
345
+ "path": "src/studio-modules/studio-media/music-parameters.tsx",
346
+ "class": "app-owned product code"
347
+ },
348
+ {
349
+ "path": "src/studio-modules/studio-media/music-transcription-parameters.tsx",
350
+ "class": "app-owned product code"
351
+ },
352
+ {
353
+ "path": "src/studio-modules/studio-media/music-transcription-runtime.ts",
354
+ "class": "app-owned product code"
355
+ },
268
356
  {
269
357
  "path": "src/studio-modules/studio-media/parameter-panel.tsx",
270
358
  "class": "app-owned product code"
@@ -289,6 +377,18 @@
289
377
  "path": "src/studio-modules/studio-media/vision-runtime.ts",
290
378
  "class": "app-owned product code"
291
379
  },
380
+ {
381
+ "path": "src/studio-modules/studio-media/voice-convert-parameters.tsx",
382
+ "class": "app-owned product code"
383
+ },
384
+ {
385
+ "path": "src/studio-modules/studio-media/voice-convert-runtime.ts",
386
+ "class": "app-owned product code"
387
+ },
388
+ {
389
+ "path": "src/studio-modules/studio-voice/audio-url.ts",
390
+ "class": "app-owned product code"
391
+ },
292
392
  {
293
393
  "path": "src/studio-modules/studio-voice/descriptors.ts",
294
394
  "class": "app-owned product code"
@@ -5,7 +5,8 @@ This standalone App was generated as an identity-neutral base plus the explicitl
5
5
  Profile: `standalone`.
6
6
 
7
7
  - App-owned product code: `src/workbench-core/**`, selected `src/capabilities/**`, and subsequent product edits.
8
- - Scaffold-managed code: carrier/auth wiring, identity, manifests, build/release inputs, managed workflow and generated composition glue.
8
+ - App-owned license: `LICENSE` starts as an MIT license naming the package author, or the App title when no author was given. Replace it with the App's own terms as needed and declare the matching `license` identifier in `package.json` before packaging; `sync` never rewrites it.
9
+ - Scaffold-managed code: carrier/auth wiring, identity, manifests, build/release inputs, managed workflow, generated composition glue, and the template's own license notice in `licenses/nimi-app-template.txt`.
9
10
  - Package-owned projections: `.nimi/{config,contracts,methodology}/**`, materialized by the pinned local `nimicoding` package during `init`.
10
11
 
11
12
  `sync` refreshes scaffold-managed files without overwriting App-owned code. `check` is non-mutating. Changing identity, profile or direct feature selection requires a fresh scaffold.
@@ -1,33 +1,64 @@
1
+ import { openDesktopIntent } from '@nimiplatform/kit/shell/renderer/bridge';
1
2
  import type {
2
3
  WorkbenchRuntimeGateCopy,
3
4
  WorkbenchRuntimeGateProjection,
4
5
  } from '../workbench-core/index.js';
5
6
  import {
7
+ appId,
6
8
  appTitle,
7
9
  clearRuntimePlatformProjection,
8
10
  getRuntimePlatformProjection,
11
+ type RuntimePlatformUnavailableProjection,
9
12
  } from './auth/runtime-platform.js';
10
13
 
11
14
  export { appTitle };
12
15
 
16
+ // Plain copy for people using the App. Reason codes and Runtime hints stay in
17
+ // the gate's folded technical details.
13
18
  export const targetRuntimeGateCopy: WorkbenchRuntimeGateCopy = Object.freeze({
14
- checking: 'App-host check',
15
- setupRequired: 'Action required',
16
- signInRequired: 'Sign in to Nimi',
17
- connectionRequired: 'Runtime session unavailable',
18
- retry: 'Retry Runtime check',
19
+ checking: 'Connecting to Nimi…',
20
+ setupRequired: 'Not connected',
21
+ signInRequired: 'Sign in to Nimi to continue',
22
+ connectionRequired: 'This App needs Nimi',
23
+ retry: 'Try again',
19
24
  offlineTier: (tier) => `Offline tier: ${tier}`,
20
- nextAction: (action) => `Next action: ${action}`,
25
+ nextAction: (step) => step,
26
+ technicalDetails: 'Technical details',
21
27
  });
22
28
 
23
- export async function resolveTargetRuntimeGate(): Promise<WorkbenchRuntimeGateProjection> {
29
+ // A gate that renders recovery actions and technical details receives them;
30
+ // an App-owned gate from an earlier scaffold still type-checks and shows the
31
+ // plain copy without them.
32
+ type TargetRuntimeGateRecovery = {
33
+ readonly recoveryAction?: { readonly label: string; readonly run: () => Promise<string> };
34
+ readonly technicalDetails?: readonly { readonly label: string; readonly value: string }[];
35
+ };
36
+
37
+ export type TargetRuntimeGateProjection =
38
+ | Extract<WorkbenchRuntimeGateProjection, { readonly status: 'ready' }>
39
+ | (Extract<WorkbenchRuntimeGateProjection, { readonly status: 'unavailable' }> & TargetRuntimeGateRecovery);
40
+
41
+ type TargetRuntimeGateGuidance = {
42
+ readonly signInRequired: boolean;
43
+ readonly body: string;
44
+ readonly nextStep: string;
45
+ };
46
+
47
+ export async function resolveTargetRuntimeGate(): Promise<TargetRuntimeGateProjection> {
24
48
  const projection = await getRuntimePlatformProjection();
25
49
  if (projection.status === 'ready') return { status: 'ready' };
50
+ const guidance = targetRuntimeGateGuidance(projection);
26
51
  return {
27
52
  status: 'unavailable',
28
- body: projection.message || 'Runtime session projection is not ready.',
29
- signInRequired: projection.reasonCode === 'runtime-unauthenticated',
30
- nextAction: projection.actionHint,
53
+ body: guidance.body,
54
+ signInRequired: guidance.signInRequired,
55
+ nextAction: guidance.nextStep,
56
+ recoveryAction: { label: 'Open Nimi', run: openNimi },
57
+ technicalDetails: [
58
+ { label: 'Reason', value: projection.reasonCode },
59
+ ...(projection.actionHint ? [{ label: 'Suggested action', value: projection.actionHint }] : []),
60
+ { label: 'Details', value: projection.message },
61
+ ],
31
62
  };
32
63
  }
33
64
 
@@ -35,6 +66,65 @@ export function clearTargetRuntimeGate(): void {
35
66
  clearRuntimePlatformProjection();
36
67
  }
37
68
 
38
- export function targetRuntimeGateErrorMessage(error: unknown): string {
39
- return error instanceof Error ? error.message : String(error || 'App-host check failed');
69
+ // The Runtime projection already carries failures as data; this covers only an
70
+ // unexpected rejection of the check itself.
71
+ export function targetRuntimeGateErrorMessage(): string {
72
+ return "This App couldn't check its connection to Nimi.";
73
+ }
74
+
75
+ function targetRuntimeGateGuidance(projection: RuntimePlatformUnavailableProjection): TargetRuntimeGateGuidance {
76
+ if (projection.reasonCode === 'runtime-unauthenticated') {
77
+ return {
78
+ signInRequired: true,
79
+ body: "You aren't signed in to Nimi on this computer.",
80
+ nextStep: 'Open Nimi and sign in, then select Try again.',
81
+ };
82
+ }
83
+ switch (projection.actionHint) {
84
+ case 'establish_fresh_app_access_session':
85
+ case 'wait_for_app_access_admission':
86
+ return {
87
+ signInRequired: false,
88
+ body: "Nimi hasn't finished giving this App access.",
89
+ nextStep: 'Wait a moment, then select Try again. If this keeps happening, open the App again from Nimi.',
90
+ };
91
+ case 'reopen_local_app_session':
92
+ case 'establish_session_for_current_account':
93
+ case 'restart_through_verified_desktop_supervisor':
94
+ case 'retry_when_nimi_access_is_available':
95
+ return {
96
+ signInRequired: false,
97
+ body: "This App's connection to Nimi ended, for example because Nimi restarted or the account changed.",
98
+ nextStep: 'Close this App and open it again from Nimi.',
99
+ };
100
+ case 'register_local_development_project':
101
+ case 'restart_official_nimi_app_dev_command':
102
+ case 'restore_registered_project_identity':
103
+ return {
104
+ signInRequired: false,
105
+ body: "Nimi doesn't recognize this development project as it is now.",
106
+ nextStep: 'Stop the App and start it again with pnpm dev.',
107
+ };
108
+ default:
109
+ return {
110
+ signInRequired: false,
111
+ body: "Nimi isn't running, or this App can't reach it right now.",
112
+ nextStep: 'Make sure Nimi is open, then select Try again.',
113
+ };
114
+ }
115
+ }
116
+
117
+ // Brings a running Nimi forward on this App's page. Nimi is never started from
118
+ // here, so a closed Nimi gets a plain instruction instead.
119
+ async function openNimi(): Promise<string> {
120
+ try {
121
+ const result = await openDesktopIntent({ intent: { kind: 'open-apps', appId } });
122
+ if (result.status === 'accepted') return "Nimi is open. When you're done there, select Try again.";
123
+ if (result.reasonCode === 'desktop-open-desktop-not-running') return "Nimi isn't running. Start Nimi, then select Try again.";
124
+ if (result.reasonCode === 'desktop-open-desktop-not-ready') return 'Nimi is still starting. Wait a moment, then select Try again.';
125
+ } catch {
126
+ // Without the verified Host bridge, for example in a plain browser tab,
127
+ // this App cannot ask Nimi to open.
128
+ }
129
+ return "This App couldn't open Nimi. Open Nimi yourself, then select Try again.";
40
130
  }
@@ -35,10 +35,6 @@
35
35
  "path": "index.html",
36
36
  "class": "scaffold-managed glue"
37
37
  },
38
- {
39
- "path": "LICENSE",
40
- "class": "scaffold-managed glue"
41
- },
42
38
  {
43
39
  "path": "README.md",
44
40
  "class": "scaffold-managed glue"