@nimiplatform/app-tools 0.1.3 → 0.2.1

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 (121) hide show
  1. package/LICENSE +198 -6
  2. package/README.md +83 -27
  3. package/bin/nimi-app.mjs +328 -45
  4. package/lib/app-access-declaration.mjs +49 -0
  5. package/lib/app-doctor-update.mjs +411 -149
  6. package/lib/app-pack.mjs +402 -0
  7. package/lib/app-project-lifecycle.mjs +1141 -0
  8. package/lib/app-scaffold-capabilities.mjs +769 -0
  9. package/lib/app-scaffold-default-source.mjs +21 -0
  10. package/lib/app-scaffold-profiles.mjs +1093 -0
  11. package/lib/app-scaffold.mjs +1266 -813
  12. package/lib/index.mjs +195 -42
  13. package/lib/simulator-conformance-ast.mjs +498 -0
  14. package/lib/simulator-conformance-css.mjs +116 -0
  15. package/lib/simulator-conformance-graph.mjs +757 -0
  16. package/lib/simulator-conformance.d.mts +14 -0
  17. package/lib/simulator-conformance.mjs +203 -0
  18. package/lib/simulator-css-profile.d.mts +27 -0
  19. package/lib/simulator-css-profile.mjs +531 -0
  20. package/lib/simulator-kit-export-resolution.mjs +70 -0
  21. package/lib/simulator-manifest.mjs +334 -0
  22. package/lib/windows-powershell.mjs +7 -0
  23. package/package.json +66 -3
  24. package/scripts/dev-shell.mjs +465 -0
  25. package/scripts/sync-app-source.mjs +300 -0
  26. package/scripts/sync-scaffold-versions.mjs +91 -0
  27. package/templates/app-source/LICENSE +21 -0
  28. package/templates/app-source/src/ai-studio-core/ai-config.ts +100 -0
  29. package/templates/app-source/src/ai-studio-core/ai-studio-core.css +338 -0
  30. package/templates/app-source/src/ai-studio-core/contexts.tsx +61 -0
  31. package/templates/app-source/src/ai-studio-core/history-policy.ts +447 -0
  32. package/templates/app-source/src/ai-studio-core/history.ts +824 -0
  33. package/templates/app-source/src/ai-studio-core/host-context.tsx +79 -0
  34. package/templates/app-source/src/ai-studio-core/index.ts +214 -0
  35. package/templates/app-source/src/ai-studio-core/messages/en.json +310 -0
  36. package/templates/app-source/src/ai-studio-core/messages/index.ts +47 -0
  37. package/templates/app-source/src/ai-studio-core/messages/zh.json +310 -0
  38. package/templates/app-source/src/ai-studio-core/module-registration.ts +109 -0
  39. package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +65 -0
  40. package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +247 -0
  41. package/templates/app-source/src/ai-studio-core/parameters.ts +110 -0
  42. package/templates/app-source/src/ai-studio-core/prompt-drafts.ts +69 -0
  43. package/templates/app-source/src/ai-studio-core/run-target.ts +123 -0
  44. package/templates/app-source/src/ai-studio-core/runtime-dispatcher.ts +35 -0
  45. package/templates/app-source/src/ai-studio-core/runtime-types.ts +86 -0
  46. package/templates/app-source/src/ai-studio-core/runtime.ts +306 -0
  47. package/templates/app-source/src/ai-studio-core/section-ai-testing-admission.ts +38 -0
  48. package/templates/app-source/src/ai-studio-core/section-ai-testing-ai-config.tsx +30 -0
  49. package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +40 -0
  50. package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +257 -0
  51. package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +676 -0
  52. package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +19 -0
  53. package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +291 -0
  54. package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +413 -0
  55. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +174 -0
  56. package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +449 -0
  57. package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +45 -0
  58. package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +494 -0
  59. package/templates/app-source/src/ai-studio-core/studio-directives.ts +33 -0
  60. package/templates/app-source/src/ai-studio-core/workspace.tsx +381 -0
  61. package/templates/app-source/src/product-modules/agent-center/index.tsx +27 -0
  62. package/templates/app-source/src/product-modules/agent-conversation/index.tsx +19 -0
  63. package/templates/app-source/src/product-modules/agent-realtime/index.tsx +29 -0
  64. package/templates/app-source/src/product-modules/kit-recipes/gallery.tsx +142 -0
  65. package/templates/app-source/src/product-modules/kit-recipes/index.tsx +19 -0
  66. package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-data-recipes.tsx +336 -0
  67. package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-demos.tsx +165 -0
  68. package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-recipes.tsx +682 -0
  69. package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-surface.tsx +341 -0
  70. package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +26 -0
  71. package/templates/app-source/src/studio-modules/studio-create/index.ts +14 -0
  72. package/templates/app-source/src/studio-modules/studio-create/messages/en.json +67 -0
  73. package/templates/app-source/src/studio-modules/studio-create/messages/index.ts +5 -0
  74. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +67 -0
  75. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +153 -0
  76. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +70 -0
  77. package/templates/app-source/src/studio-modules/studio-create/registration.ts +46 -0
  78. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +339 -0
  79. package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +22 -0
  80. package/templates/app-source/src/studio-modules/studio-media/index.ts +12 -0
  81. package/templates/app-source/src/studio-modules/studio-media/messages/en.json +82 -0
  82. package/templates/app-source/src/studio-modules/studio-media/messages/index.ts +5 -0
  83. package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +82 -0
  84. package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +283 -0
  85. package/templates/app-source/src/studio-modules/studio-media/parameters.ts +94 -0
  86. package/templates/app-source/src/studio-modules/studio-media/registration.ts +44 -0
  87. package/templates/app-source/src/studio-modules/studio-media/runtime.ts +113 -0
  88. package/templates/app-source/src/studio-modules/studio-voice/descriptors.ts +28 -0
  89. package/templates/app-source/src/studio-modules/studio-voice/index.ts +16 -0
  90. package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +99 -0
  91. package/templates/app-source/src/studio-modules/studio-voice/messages/index.ts +5 -0
  92. package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +99 -0
  93. package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +284 -0
  94. package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +116 -0
  95. package/templates/app-source/src/studio-modules/studio-voice/registration.ts +59 -0
  96. package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +347 -0
  97. package/templates/app-source/src/workbench-core/empty-state.tsx +31 -0
  98. package/templates/app-source/src/workbench-core/index.ts +17 -0
  99. package/templates/app-source/src/workbench-core/runtime-gate.tsx +131 -0
  100. package/templates/app-source/src/workbench-core/workbench-core.css +255 -0
  101. package/templates/app-source/src/workbench-core/workbench-core.tsx +140 -0
  102. package/templates/app-source.manifest.json +333 -0
  103. package/templates/default-starter/AGENTS.md +33 -0
  104. package/templates/default-starter/LICENSE +21 -0
  105. package/templates/default-starter/README.md +41 -0
  106. package/templates/default-starter/SECURITY.md +5 -0
  107. package/templates/default-starter/index.html +12 -0
  108. package/templates/default-starter/scripts/validate.mjs +26 -0
  109. package/templates/default-starter/src/shell/App.tsx +27 -0
  110. package/templates/default-starter/src/shell/auth/app-identity.ts +3 -0
  111. package/templates/default-starter/src/shell/auth/local-app-client.ts +18 -0
  112. package/templates/default-starter/src/shell/auth/runtime-platform.ts +110 -0
  113. package/templates/default-starter/src/shell/authenticated-shell.tsx +20 -0
  114. package/templates/default-starter/src/shell/workbench-target-adapter.ts +40 -0
  115. package/templates/default-starter/src/styles.css +26 -0
  116. package/templates/default-starter/src-tauri/Cargo.toml +17 -0
  117. package/templates/default-starter/src-tauri/build.rs +5 -0
  118. package/templates/default-starter/src-tauri/capabilities/default.json +7 -0
  119. package/templates/default-starter/src-tauri/tauri.conf.json +26 -0
  120. package/templates/default-starter/tsconfig.json +18 -0
  121. package/templates/default-starter.manifest.json +99 -0
@@ -0,0 +1,310 @@
1
+ {
2
+ "Common": {
3
+ "retry": "重试",
4
+ "close": "关闭",
5
+ "copy": "复制",
6
+ "copied": "已复制",
7
+ "copyFailed": "复制失败"
8
+ },
9
+ "History": {
10
+ "title": "历史",
11
+ "panelAriaLabel": "Runtime 测试历史",
12
+ "filterAriaLabel": "筛选历史",
13
+ "filtersAriaLabel": "历史筛选",
14
+ "menus": {
15
+ "status": "状态",
16
+ "capability": "能力",
17
+ "environment": "环境",
18
+ "activity": "最近活动",
19
+ "group": "分组方式",
20
+ "sort": "排序方式"
21
+ },
22
+ "filters": {
23
+ "status": {
24
+ "all": "全部状态",
25
+ "ready": "Runtime 就绪",
26
+ "failed": "失败",
27
+ "canceled": "已取消",
28
+ "timedOut": "已超时",
29
+ "unavailable": "SDK 不可用"
30
+ },
31
+ "environment": {
32
+ "all": "全部",
33
+ "local": "本地",
34
+ "cloud": "云端",
35
+ "remoteControl": "远程控制"
36
+ },
37
+ "activity": {
38
+ "all": "全部",
39
+ "today": "今天",
40
+ "last7Days": "最近 7 天",
41
+ "last30Days": "最近 30 天"
42
+ },
43
+ "group": {
44
+ "none": "无",
45
+ "date": "日期",
46
+ "capability": "能力"
47
+ },
48
+ "sort": {
49
+ "recency": "最近优先",
50
+ "oldest": "最早优先"
51
+ },
52
+ "capability": {
53
+ "all": "全部",
54
+ "allCapabilities": "全部能力"
55
+ }
56
+ },
57
+ "clearFilters": "清除全部筛选",
58
+ "scopeAriaLabel": "历史范围",
59
+ "scope": {
60
+ "capability": "本能力",
61
+ "all": "全部",
62
+ "media": "媒体"
63
+ },
64
+ "hideFailures": "隐藏失败",
65
+ "showFailures": "显示失败",
66
+ "unsupportedCapability": "这条记录的能力无法在此打开",
67
+ "searchPlaceholder": "搜索提示词或结果",
68
+ "deleteRun": "删除这条记录",
69
+ "deleteRecordOnly": "删除记录并保留托管资产",
70
+ "deleteRecordAndAsset": "删除记录和托管资产",
71
+ "deletedRecordOnly": "记录已删除,托管资产已保留",
72
+ "deletedRecordAndAsset": "记录和托管资产已删除",
73
+ "deleteAssetFailed": "托管资产删除失败,历史记录已保留",
74
+ "deleteFailed": "删除失败,请重试",
75
+ "clearScope": "清空当前范围",
76
+ "clearScopeConfirm": "再次点击确认清空",
77
+ "cleared": "历史已清空",
78
+ "clearChoiceAriaLabel": "选择清空历史时是否同时删除托管资产",
79
+ "clearRecordsOnly": "仅记录",
80
+ "clearRecordsAndAssets": "记录和资产",
81
+ "clearedRecordsOnly": "历史已清空,托管资产已保留",
82
+ "clearOutcome": "清理结果:完成 {{completed}};跳过 {{skipped}};失败 {{failed}}",
83
+ "clearFailed": "清空失败,请重试",
84
+ "linkedRunMissing": "关联的运行记录已被淘汰",
85
+ "emptyMedia": "还没有媒体记录",
86
+ "source": {
87
+ "local": "本地",
88
+ "cloud": "云端",
89
+ "unknown": "未知"
90
+ },
91
+ "canceled": "已取消",
92
+ "stoppedWaiting": "取消结果待确认",
93
+ "timedOut": "已超时",
94
+ "failed": "失败",
95
+ "today": "今天",
96
+ "yesterday": "昨天",
97
+ "unknownDate": "未知日期",
98
+ "runAriaIntent": "{{source}}意图:{{intent}}",
99
+ "runAriaPrompt": "提示词:{{prompt}}",
100
+ "groupRunsAriaLabel": "{{group}}的运行",
101
+ "recentRuns": "最近运行",
102
+ "emptyNone": "还没有运行记录",
103
+ "emptyFiltered": "没有符合这些筛选条件的运行",
104
+ "loadFailedTitle": "历史加载失败",
105
+ "saveFailedTitle": "历史保存失败"
106
+ },
107
+ "NonSuccess": {
108
+ "title": {
109
+ "runtimeUnavailable": "本地 AI 暂时不可用",
110
+ "inputInvalid": "请检查输入",
111
+ "sdkMethodUnavailable": "当前版本暂不支持",
112
+ "principalUnauthorized": "需要重新连接",
113
+ "operationAborted": "取消结果待确认",
114
+ "runtimeCanceled": "任务已取消",
115
+ "runtimeTimeout": "任务已超时",
116
+ "streamInterrupted": "结果流已中断",
117
+ "runtimeCallFailed": "生成失败"
118
+ },
119
+ "message": {
120
+ "runtimeUnavailable": "本次请求中 Runtime 不可用。",
121
+ "inputInvalid": "请求需要提供有效的提示词或必填输入后才能运行。",
122
+ "sdkMethodUnavailable": "当前 App 构建中此能力不可用。",
123
+ "principalUnauthorized": "Runtime 拒绝了本次请求的受保护所有者。",
124
+ "operationAborted": "已请求取消,但 Runtime 尚未确认任务的最终状态。",
125
+ "runtimeCanceled": "这次任务已取消。",
126
+ "runtimeTimeout": "这次任务已超时。",
127
+ "streamInterrupted": "实时结果连接已结束,但 Runtime 尚未确认最终状态。",
128
+ "runtimeCallFailed": "这次生成未能完成。",
129
+ "fallback": "本次生成未完成。"
130
+ },
131
+ "action": {
132
+ "runtimeUnavailable": "返回 Desktop 确认本地 AI 已连接,然后重试。",
133
+ "inputInvalid": "检查提示词与必填字段后重新运行。",
134
+ "sdkMethodUnavailable": "更新 App 后重试。",
135
+ "principalUnauthorized": "返回 Desktop 重新打开此 App,然后重试。",
136
+ "operationAborted": "请先检查任务状态,再决定是否重新运行。",
137
+ "runtimeCanceled": "准备好后可重新运行此请求。",
138
+ "runtimeTimeout": "稍后重试;如果仍然超时,再展开 Runtime 详情查看原因。",
139
+ "streamInterrupted": "请先检查任务状态;确认任务未完成后再重试。",
140
+ "runtimeCallFailed": "先重试一次;如果仍然失败,再展开 Runtime 详情查看原因。",
141
+ "fallback": "请重试;如果仍然失败,再展开 Runtime 详情查看原因。"
142
+ },
143
+ "hint": {
144
+ "runtimeUnavailable": "恢复受保护的 Runtime 连接后重试同一请求。",
145
+ "inputInvalid": "为此能力提供有效的请求体后重试。",
146
+ "sdkMethodUnavailable": "添加一个已准入的 SDK Nimi App 执行方法。不要用 App 本地 REST 绕过 Runtime。",
147
+ "principalUnauthorized": "Runtime 拒绝了受保护的所有者身份。请先恢复已准入的 App 会话再重试。",
148
+ "operationAborted": "SDK 已请求取消,但 Runtime 在一次有界后续查询中仍未返回终态。",
149
+ "runtimeCanceled": "Runtime 已持久化取消此 ScenarioJob。仅在确实需要再次运行时提交新请求。",
150
+ "runtimeTimeout": "Runtime 已将此 ScenarioJob 记录为超时终态。重试前请检查带类型的原因与追踪信息。",
151
+ "streamInterrupted": "事件流未携带终态便已结束,且一次有界 Runtime Job 查询仍为非终态或不可用。",
152
+ "runtimeCallFailed": "Runtime 返回了带类型的契约失败。请查看原始 Runtime 错误,不要推断为成功。"
153
+ }
154
+ },
155
+ "StudioShell": {
156
+ "showHistory": "显示历史",
157
+ "hideHistory": "隐藏历史",
158
+ "statusConfigured": "已配置",
159
+ "statusBlocked": "受阻",
160
+ "statusNotAdmitted": "未准入",
161
+ "statusSdkGap": "SDK 缺口",
162
+ "statusChecking": "检查中",
163
+ "copyRuntimeDetails": "复制 Runtime 详情",
164
+ "downloadRuntimeDetails": "下载 Runtime 详情",
165
+ "expandImage": "展开图片",
166
+ "expandGeneratedImage": "展开生成的图片",
167
+ "imagePreview": "图片预览",
168
+ "closeImagePreview": "关闭图片预览",
169
+ "emptyBody": "(空内容)",
170
+ "emptyTranscript": "(空转写)",
171
+ "contextLabel": "上下文",
172
+ "requestSettings": "请求设置",
173
+ "showRequestSettings": "显示请求设置",
174
+ "hideRequestSettings": "隐藏请求设置",
175
+ "legacyRecordHint": "这条较早的历史记录仅包含状态元数据。重新运行一次即可保存类型化的结果快照。",
176
+ "generationFailed": "生成未能完成",
177
+ "generationCanceled": "生成已取消",
178
+ "cancelGeneration": "取消任务",
179
+ "cancelRequested": "正在请求取消…",
180
+ "runtimeDetails": "Runtime 详情",
181
+ "runLabel": "运行",
182
+ "download": "下载",
183
+ "copyGeneration": "复制生成结果",
184
+ "downloadGeneration": "下载生成结果",
185
+ "revealAsset": "在文件夹中显示",
186
+ "revealGeneration": "在文件夹中显示生成文件",
187
+ "regenerate": "重新生成",
188
+ "newRun": "新建运行",
189
+ "useAsDraft": "用作草稿",
190
+ "intentLabel": "意图",
191
+ "embeddingSuccess": "向量嵌入生成成功。",
192
+ "voiceAssetSuccess": "新语音已创建,可以在语音合成中使用。",
193
+ "mediaSuccess": "媒体生成成功。",
194
+ "mediaPreviewMetadataOnly": "媒体已生成,但 Runtime 仅返回元数据,没有可用的预览字节。",
195
+ "mediaPreviewUnsupported": "媒体已生成,但此产物类型无法在此处预览。",
196
+ "mediaMetadataDownloadHint": "可使用下载按钮保存生成的产物;没有可用字节时则保存其详情。",
197
+ "noVoices": "未返回任何语音。",
198
+ "runStoppedEarly": "运行在返回类型化的 Runtime 结果前已停止。",
199
+ "noResultProduced": "未产生任何结果。请先解决类型化的 Runtime 失败,再重试。",
200
+ "resultAriaLabel": "{{capability}}结果",
201
+ "promptLabel": "提示词",
202
+ "generationLabel": "生成结果",
203
+ "runStatusReady": "Runtime 就绪",
204
+ "runStatusUnavailable": "SDK 不可用",
205
+ "runStatusFailed": "失败",
206
+ "runStatusCanceled": "已取消",
207
+ "runStatusTimedOut": "已超时"
208
+ },
209
+ "StudioModelConfig": {
210
+ "drawerTitle": "App AI 配置",
211
+ "drawerDescription": "配置 {{appTitle}} AI 能力"
212
+ },
213
+ "Studio": {
214
+ "admission": {
215
+ "sdkGapDetail": "该能力没有可用的已准入类型化 SDK 方法。"
216
+ },
217
+ "composer": {
218
+ "runtimeOwnedIntent": "由 Runtime 拥有的能力意图",
219
+ "openIntentConfig": "打开 AI 意图配置",
220
+ "configureIntent": "配置能力意图",
221
+ "context": "上下文",
222
+ "contextAttached": "已附加上下文",
223
+ "attachContext": "附加上下文",
224
+ "removeAttachment": "移除 {{name}}",
225
+ "requestAriaLabel": "{{capability}}请求",
226
+ "startAriaLabel": "{{capability}}起始页",
227
+ "contextPlaceholder": "可选的上下文、受众、来源笔记或约束",
228
+ "intentSummary": "意图:{{intent}}"
229
+ },
230
+ "parameters": {
231
+ "title": "参数",
232
+ "reset": "重置",
233
+ "presenceHint": "未触碰的控件不会进入请求。",
234
+ "runtimeDefault": "Runtime 默认值",
235
+ "cloudOnlyGroup": "仅 Cloud 参数",
236
+ "localOnlyGroup": "仅 Local 参数",
237
+ "switchToCloudHint": "切换 Cloud 意图后可用。",
238
+ "switchToLocalHint": "切换 Local 意图后可用。",
239
+ "localAppUnavailableGroup": "本地应用不可用参数",
240
+ "localAppUnavailableHint": "受保护的应用入口不会携带这些私有调度字段。",
241
+ "fixedValue": "固定 {{value}}",
242
+ "fields": {
243
+ "seed": "种子"
244
+ }
245
+ },
246
+ "run": {
247
+ "aiConfigLoadFailed": "App AIConfig 加载失败。"
248
+ },
249
+ "drawerError": {
250
+ "title": "模型配置不可用",
251
+ "fallback": "共享模型配置界面加载失败。"
252
+ },
253
+ "result": {
254
+ "methodLabel": "方法",
255
+ "admissionLabel": "准入",
256
+ "reasonLabel": "原因",
257
+ "traceLabel": "追踪",
258
+ "verboseConsoleNote": "详细控制台:能力 {{capability}};{{state}}。",
259
+ "verboseTypedSuccess": "类型化成功",
260
+ "verboseFailClosed": "失败关闭:{{reason}}",
261
+ "verboseNoResult": "当前会话无结果",
262
+ "sdkUnavailable": "SDK 不可用",
263
+ "statRunning": "运行中",
264
+ "statStopping": "正在请求取消",
265
+ "notRecorded": "未记录",
266
+ "status": {
267
+ "stopping": "正在请求取消",
268
+ "runtimeRunning": "正在生成",
269
+ "operationAborted": "取消结果待确认",
270
+ "runtimeCanceled": "任务已取消",
271
+ "runtimeTimedOut": "任务已超时",
272
+ "runtimeBlocked": "生成受阻",
273
+ "runtimeResult": "已完成",
274
+ "runtimeWaiting": "等待开始"
275
+ },
276
+ "tokensNotCaptured": "未捕获",
277
+ "statStatus": "状态",
278
+ "statWaiting": "等待中",
279
+ "statBlocked": "受阻",
280
+ "statStopped": "取消结果待确认",
281
+ "statCanceled": "已取消",
282
+ "statTimedOut": "已超时",
283
+ "statTokens": "Token",
284
+ "statCharacters": "字符",
285
+ "statArtifacts": "产物",
286
+ "statResult": "结果",
287
+ "statCreated": "已创建",
288
+ "statCompleted": "已完成",
289
+ "statAvailable": "可使用",
290
+ "statState": "状态",
291
+ "stateUnknown": "未知",
292
+ "statVoices": "语音",
293
+ "metricWords_one": "{{count}} 个词",
294
+ "metricWords_other": "{{count}} 个词",
295
+ "metricArtifacts_one": "{{count}} 个产物",
296
+ "metricArtifacts_other": "{{count}} 个产物",
297
+ "metricCreated": "已创建",
298
+ "metricVoices_one": "{{count}} 个语音",
299
+ "metricVoices_other": "{{count}} 个语音",
300
+ "pendingStreaming": "正在生成回复……",
301
+ "pendingRuntime": "正在准备并生成……",
302
+ "pendingCancel": "正在向 Runtime 请求取消……",
303
+ "runTimeLabel": "运行 / {{time}}",
304
+ "runtimeChip": "AI 生成",
305
+ "createdFromDescription": "文字描述",
306
+ "createdFromAudio": "参考音频",
307
+ "generationMetrics": "生成指标"
308
+ }
309
+ }
310
+ }
@@ -0,0 +1,109 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { LucideIcon } from 'lucide-react';
3
+ import type { StudioParameterContract } from './parameters.js';
4
+ import type { StudioParameterPanelProps } from './parameter-fields.js';
5
+
6
+ // @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-019c
7
+
8
+ export type StudioControlId = 'tone' | 'length';
9
+ export type StudioInputKind = 'prompt' | 'url' | 'none';
10
+ export type StudioResultKind = 'text' | 'transcript' | 'embedding' | 'artifacts' | 'voice-asset' | 'voice-catalog';
11
+
12
+ export type CapabilityStudioProfile = {
13
+ readonly studioTag: string;
14
+ readonly inputTitleKey: string;
15
+ readonly inputPlaceholderKey: string;
16
+ readonly inputKind: StudioInputKind;
17
+ readonly inputNoteKey?: string;
18
+ readonly supportsAttachments: boolean;
19
+ readonly controls: readonly StudioControlId[];
20
+ readonly primaryLabelKey: string;
21
+ readonly primaryRunningLabelKey: string;
22
+ readonly resultTitle: string;
23
+ readonly emptyTitleKey: string;
24
+ readonly emptyHintKey: string;
25
+ readonly resultKind: StudioResultKind;
26
+ readonly footnoteKey: string;
27
+ readonly statusLabelKey?: string;
28
+ readonly pendingLabelKey?: string;
29
+ };
30
+
31
+ export type ScenarioPreset = {
32
+ readonly id: string;
33
+ readonly label: string;
34
+ readonly prompt: string;
35
+ };
36
+
37
+ export type StudioCapabilityDescriptor<TCapabilityId extends string = string> = {
38
+ readonly id: TCapabilityId;
39
+ readonly label: string;
40
+ readonly labelKey: string;
41
+ readonly group: 'text' | 'media' | 'audio' | 'world';
42
+ readonly section: 'chat' | 'embed' | 'image' | 'video' | 'music' | 'tts' | 'stt' | 'voice' | 'world';
43
+ readonly summary: string;
44
+ readonly summaryKey: string;
45
+ readonly surface: string;
46
+ readonly execution: 'runtime-sdk' | 'standalone-tauri' | 'typed-unavailable';
47
+ readonly capabilityContract?: string;
48
+ readonly missingSurface?: string;
49
+ };
50
+
51
+ export type StudioCapabilityRegistration<TCapabilityId extends string = string> = {
52
+ readonly descriptor: StudioCapabilityDescriptor<TCapabilityId>;
53
+ readonly icon: LucideIcon;
54
+ readonly profile: CapabilityStudioProfile;
55
+ readonly preset: ScenarioPreset;
56
+ readonly runtimeMethod: string;
57
+ readonly parameters: StudioParameterContract;
58
+ readonly parameterPanel?: ComponentType<StudioParameterPanelProps>;
59
+ };
60
+
61
+ export type AIStudioModuleRegistration<
62
+ TModuleId extends string = string,
63
+ TCapabilityId extends string = string,
64
+ > = {
65
+ readonly id: TModuleId;
66
+ readonly navigationLabel: string;
67
+ readonly order: number;
68
+ readonly capabilities: readonly StudioCapabilityRegistration<TCapabilityId>[];
69
+ };
70
+
71
+ export function composeAIStudioModules(
72
+ registrations: readonly AIStudioModuleRegistration[],
73
+ ) {
74
+ const ordered = [...registrations].sort((left, right) => left.order - right.order);
75
+ const moduleIds: string[] = [];
76
+ const capabilityIds: string[] = [];
77
+ const capabilities: StudioCapabilityRegistration[] = [];
78
+ for (const registration of ordered) {
79
+ if (!registration.id || moduleIds.includes(registration.id)) {
80
+ throw new Error(`Duplicate or empty AI studio module id: ${registration.id || 'missing'}`);
81
+ }
82
+ moduleIds.push(registration.id);
83
+ if (registration.capabilities.length === 0) {
84
+ throw new Error(`AI studio module has no capabilities: ${registration.id}`);
85
+ }
86
+ for (const capability of registration.capabilities) {
87
+ const id = capability.descriptor.id;
88
+ if (!id || capabilityIds.includes(id)) {
89
+ throw new Error(`Duplicate or empty AI studio capability id: ${id || 'missing'}`);
90
+ }
91
+ capabilityIds.push(id);
92
+ capabilities.push(capability);
93
+ }
94
+ }
95
+ return Object.freeze({
96
+ modules: Object.freeze(ordered),
97
+ capabilities: Object.freeze(capabilities),
98
+ getCapability(id: string) {
99
+ const capability = capabilities.find((candidate) => candidate.descriptor.id === id);
100
+ if (!capability) throw new Error(`Unknown AI studio capability: ${id}`);
101
+ return capability;
102
+ },
103
+ createInitialParameterState() {
104
+ return Object.freeze(Object.fromEntries(
105
+ capabilities.map((capability) => [capability.descriptor.id, capability.parameters.initial()]),
106
+ ));
107
+ },
108
+ });
109
+ }
@@ -0,0 +1,65 @@
1
+ import type {
2
+ StudioNonSuccess,
3
+ StudioNonSuccessDiagnostics,
4
+ StudioNonSuccessReason,
5
+ StudioRuntimeCapabilityDescriptor,
6
+ } from './runtime-types.js';
7
+
8
+ export type StudioTranslate = (
9
+ key: string,
10
+ values?: Readonly<Record<string, unknown>>,
11
+ ) => string;
12
+
13
+ function reasonKeySegment(reason: string): string {
14
+ switch (reason) {
15
+ case 'runtime-unavailable': return 'runtimeUnavailable';
16
+ case 'input-invalid': return 'inputInvalid';
17
+ case 'sdk-method-unavailable': return 'sdkMethodUnavailable';
18
+ case 'principal-unauthorized': return 'principalUnauthorized';
19
+ case 'operation-aborted': return 'operationAborted';
20
+ case 'runtime-canceled': return 'runtimeCanceled';
21
+ case 'runtime-timeout': return 'runtimeTimeout';
22
+ case 'stream-interrupted': return 'streamInterrupted';
23
+ case 'runtime-call-failed': return 'runtimeCallFailed';
24
+ default: return '';
25
+ }
26
+ }
27
+
28
+ export function studioNonSuccessReasonTitle(reason: StudioNonSuccessReason, translate: StudioTranslate): string {
29
+ return translate(`NonSuccess.title.${reasonKeySegment(reason)}`);
30
+ }
31
+
32
+ export function studioNonSuccessReasonUserMessage(reason: string, translate: StudioTranslate): string {
33
+ const segment = reasonKeySegment(reason);
34
+ return translate(segment ? `NonSuccess.message.${segment}` : 'NonSuccess.message.fallback');
35
+ }
36
+
37
+ export function studioNonSuccessReasonUserAction(reason: string, translate: StudioTranslate): string {
38
+ const segment = reasonKeySegment(reason);
39
+ return translate(segment ? `NonSuccess.action.${segment}` : 'NonSuccess.action.fallback');
40
+ }
41
+
42
+ export function studioNonSuccessActionHint(
43
+ reason: StudioNonSuccessReason,
44
+ translate: StudioTranslate,
45
+ ): string {
46
+ return translate(`NonSuccess.hint.${reasonKeySegment(reason)}`);
47
+ }
48
+
49
+ export function createStudioNonSuccess(
50
+ capability: StudioRuntimeCapabilityDescriptor,
51
+ reason: StudioNonSuccessReason,
52
+ message: string,
53
+ translate: StudioTranslate,
54
+ diagnostics?: StudioNonSuccessDiagnostics,
55
+ ): StudioNonSuccess {
56
+ return {
57
+ ok: false,
58
+ capabilityId: capability.id,
59
+ reason,
60
+ message,
61
+ actionHint: studioNonSuccessActionHint(reason, translate),
62
+ missingSurface: capability.missingSurface,
63
+ ...(diagnostics ? { diagnostics } : {}),
64
+ };
65
+ }