@nimiplatform/app-tools 0.6.3 → 0.11.4

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 (115) hide show
  1. package/README.md +153 -12
  2. package/bin/nimi-app.mjs +16 -14
  3. package/lib/app-access-declaration.mjs +1 -0
  4. package/lib/app-dependency-combinations.mjs +49 -0
  5. package/lib/app-doctor-update.mjs +84 -23
  6. package/lib/app-info.mjs +33 -3
  7. package/lib/app-lifecycle-guidance.mjs +4 -2
  8. package/lib/app-pack.mjs +5 -2
  9. package/lib/app-project-lifecycle.mjs +284 -53
  10. package/lib/app-safety-profile.mjs +204 -0
  11. package/lib/app-scaffold-capabilities.mjs +11 -3
  12. package/lib/app-scaffold-profiles.mjs +136 -27
  13. package/lib/app-scaffold.mjs +55 -7
  14. package/lib/canonical-capability-ids.generated.mjs +25 -0
  15. package/lib/index.mjs +0 -4
  16. package/package.json +27 -31
  17. package/scripts/dev-shell.mjs +80 -18
  18. package/skills/nimi-app-lifecycle/SKILL.md +7 -3
  19. package/skills/nimi-app-lifecycle/references/acceptance.md +7 -1
  20. package/skills/nimi-app-lifecycle/references/adapt.md +46 -1
  21. package/skills/nimi-app-lifecycle/references/audit.md +55 -0
  22. package/skills/nimi-app-lifecycle/references/platform-gaps.md +15 -0
  23. package/skills/nimi-app-lifecycle/references/release.md +2 -2
  24. package/skills/nimi-app-lifecycle/references/safety-declaration.md +37 -0
  25. package/skills/nimi-app-lifecycle/references/upgrade-platform.md +16 -2
  26. package/templates/app-source/src/ai-studio-core/ai-config.ts +17 -3
  27. package/templates/app-source/src/ai-studio-core/ai-studio-core.css +40 -3
  28. package/templates/app-source/src/ai-studio-core/audio-separation-request.ts +24 -0
  29. package/templates/app-source/src/ai-studio-core/contexts.tsx +4 -0
  30. package/templates/app-source/src/ai-studio-core/history-policy.ts +395 -41
  31. package/templates/app-source/src/ai-studio-core/history.ts +262 -10
  32. package/templates/app-source/src/ai-studio-core/host-context.tsx +15 -2
  33. package/templates/app-source/src/ai-studio-core/index.ts +15 -4
  34. package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +105 -0
  35. package/templates/app-source/src/ai-studio-core/job-recovery.ts +224 -0
  36. package/templates/app-source/src/ai-studio-core/managed-result-references.ts +79 -0
  37. package/templates/app-source/src/ai-studio-core/messages/en.json +185 -10
  38. package/templates/app-source/src/ai-studio-core/messages/zh.json +185 -10
  39. package/templates/app-source/src/ai-studio-core/module-registration.ts +9 -1
  40. package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +81 -2
  41. package/templates/app-source/src/ai-studio-core/parameters.ts +34 -1
  42. package/templates/app-source/src/ai-studio-core/runtime-types.ts +124 -8
  43. package/templates/app-source/src/ai-studio-core/runtime.ts +218 -20
  44. package/templates/app-source/src/ai-studio-core/section-ai-testing-annotation-result.tsx +123 -0
  45. package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +3 -0
  46. package/templates/app-source/src/ai-studio-core/section-ai-testing-audio-separation-result.tsx +26 -0
  47. package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +14 -7
  48. package/templates/app-source/src/ai-studio-core/section-ai-testing-decision-result.tsx +76 -0
  49. package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +71 -0
  50. package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +20 -4
  51. package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +29 -0
  52. package/templates/app-source/src/ai-studio-core/section-ai-testing-music-result.tsx +45 -0
  53. package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +132 -10
  54. package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +122 -38
  55. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +4 -3
  56. package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +66 -0
  57. package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +100 -22
  58. package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +6 -0
  59. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcript-result.tsx +45 -0
  60. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +106 -0
  61. package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +23 -4
  62. package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-asset-actions.tsx +40 -0
  63. package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-conversion-result.tsx +20 -0
  64. package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +219 -35
  65. package/templates/app-source/src/ai-studio-core/text-annotation-document.ts +50 -0
  66. package/templates/app-source/src/ai-studio-core/text-media-replay.ts +51 -0
  67. package/templates/app-source/src/ai-studio-core/voice-assets.ts +17 -0
  68. package/templates/app-source/src/ai-studio-core/workspace.tsx +48 -6
  69. package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +1 -1
  70. package/templates/app-source/src/studio-modules/studio-create/messages/en.json +13 -1
  71. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +13 -1
  72. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
  73. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -2
  74. package/templates/app-source/src/studio-modules/studio-create/registration.ts +2 -2
  75. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +121 -3
  76. package/templates/app-source/src/studio-modules/studio-media/audio-separate-parameters.tsx +72 -0
  77. package/templates/app-source/src/studio-modules/studio-media/audio-separate-runtime.ts +90 -0
  78. package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +16 -1
  79. package/templates/app-source/src/studio-modules/studio-media/index.ts +2 -0
  80. package/templates/app-source/src/studio-modules/studio-media/messages/en.json +225 -7
  81. package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +225 -7
  82. package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +85 -0
  83. package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx +85 -0
  84. package/templates/app-source/src/studio-modules/studio-media/music-transcription-runtime.ts +64 -0
  85. package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +9 -26
  86. package/templates/app-source/src/studio-modules/studio-media/parameters.ts +170 -6
  87. package/templates/app-source/src/studio-modules/studio-media/registration.ts +29 -1
  88. package/templates/app-source/src/studio-modules/studio-media/runtime.ts +90 -6
  89. package/templates/app-source/src/studio-modules/studio-media/vision-parameters.tsx +1 -0
  90. package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +23 -5
  91. package/templates/app-source/src/studio-modules/studio-media/voice-convert-parameters.tsx +132 -0
  92. package/templates/app-source/src/studio-modules/studio-media/voice-convert-runtime.ts +120 -0
  93. package/templates/app-source/src/studio-modules/studio-voice/audio-url.ts +25 -0
  94. package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +4 -4
  95. package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +4 -4
  96. package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +36 -10
  97. package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +66 -30
  98. package/templates/app-source/src/workbench-core/index.ts +2 -0
  99. package/templates/app-source/src/workbench-core/runtime-gate.tsx +102 -6
  100. package/templates/app-source/src/workbench-core/workbench-core.css +42 -0
  101. package/templates/app-source/src/workbench-core/workbench-core.tsx +69 -18
  102. package/templates/app-source.manifest.json +100 -0
  103. package/templates/default-starter/AGENTS.md +4 -2
  104. package/templates/default-starter/README.md +2 -1
  105. package/templates/default-starter/src/shell/workbench-target-adapter.ts +102 -12
  106. package/templates/default-starter.manifest.json +0 -4
  107. package/lib/simulator-conformance-ast.mjs +0 -498
  108. package/lib/simulator-conformance-css.mjs +0 -116
  109. package/lib/simulator-conformance-graph.mjs +0 -757
  110. package/lib/simulator-conformance.d.mts +0 -14
  111. package/lib/simulator-conformance.mjs +0 -203
  112. package/lib/simulator-css-profile.d.mts +0 -27
  113. package/lib/simulator-css-profile.mjs +0 -531
  114. package/lib/simulator-kit-export-resolution.mjs +0 -70
  115. package/lib/simulator-manifest.mjs +0 -334
@@ -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"
@@ -11,19 +11,21 @@
11
11
 
12
12
  ## Hard Boundaries
13
13
  - Follow `Runtime / Realm truth -> @nimiplatform/sdk interface -> app consumer`.
14
- - Runtime owns local execution, capability, readiness, routing, model, and memory truth; Realm owns canonical cloud identity, relationships, entities, and shared persistence.
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.
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.
18
18
  - Keep Lab-only Settings/account, App Access diagnostics, Realm/Agent probes, World Tour, and native or diagnostic surfaces outside generated product composition.
19
19
  - Preserve ownership: `sync` may refresh scaffold-managed files but must not overwrite app-owned workbench or module code; `check` is non-mutating. Identity and direct feature selection are immutable; create a fresh scaffold to change them.
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
- - This third-party scaffold uses public registry versions only; do not substitute workspace paths, local overrides, tarballs, or downgrades. A private workspace-validation result is not standalone evidence.
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
+ - 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.
22
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
24
  - Do not add provider/model hardcoding, compatibility dual-writes, pseudo-success, Runtime internals, generated private clients, or Desktop product source.
24
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.
25
26
 
26
27
  ## Retrieval Defaults
28
+ - Feasibility, capability-fit and cost requests use the lifecycle skill's audit guide before implementation setup. When following an audit, preserve confirmed user decisions and verify consequential assumptions against current owner contracts rather than treating the report as authority.
27
29
  - Start with the requested product route, its direct SDK/Kit surface, and the relevant scaffold-managed glue.
28
30
  - Read platform authority only when ownership or semantics remain ambiguous; skip unrelated platform packages and generated files.
29
31
 
@@ -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"