@nimiplatform/app-tools 0.2.9 → 0.4.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.
- package/README.md +89 -4
- package/lib/app-doctor-update.mjs +12 -3
- package/lib/app-info.mjs +142 -0
- package/lib/app-pack.mjs +53 -16
- package/lib/app-project-lifecycle.mjs +10 -15
- package/lib/app-scaffold-profiles.mjs +28 -13
- package/lib/app-scaffold.mjs +31 -3
- package/lib/macos-native.mjs +96 -0
- package/lib/payload-links.mjs +41 -0
- package/package.json +8 -7
- package/scripts/sync-scaffold-versions.mjs +3 -16
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +31 -0
- package/templates/app-source/src/ai-studio-core/history-policy.ts +23 -1
- package/templates/app-source/src/ai-studio-core/history.ts +7 -1
- package/templates/app-source/src/ai-studio-core/host-context.tsx +5 -3
- package/templates/app-source/src/ai-studio-core/messages/en.json +1 -0
- package/templates/app-source/src/ai-studio-core/messages/zh.json +1 -0
- package/templates/app-source/src/ai-studio-core/module-registration.ts +2 -2
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +6 -2
- package/templates/app-source/src/ai-studio-core/run-target.ts +1 -1
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +4 -0
- package/templates/app-source/src/ai-studio-core/runtime.ts +13 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-admission.ts +3 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +41 -13
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +1 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +1 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +26 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +14 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +3 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +12 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-input.tsx +56 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +22 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +54 -29
- package/templates/app-source/src/product-modules/agent-realtime/index.tsx +2 -2
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +1 -0
- package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +6 -1
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +19 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +19 -0
- package/templates/app-source/src/studio-modules/studio-media/registration.ts +10 -1
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +2 -0
- package/templates/app-source/src/studio-modules/studio-media/vision-parameters.tsx +18 -0
- package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +58 -0
- package/templates/app-source/src/workbench-core/workbench-core.css +5 -0
- package/templates/app-source.manifest.json +16 -0
|
@@ -136,18 +136,21 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
136
136
|
`const APP_EXECUTABLE_NAME = ${JSON.stringify(identity.cargoPackageName)};`,
|
|
137
137
|
`const APP_PRODUCT_NAME = ${JSON.stringify(identity.appTitle)};`,
|
|
138
138
|
resolveWindowsResourceVersion.toString(),
|
|
139
|
-
"const
|
|
139
|
+
"const MACOS_BUILD = process.platform === 'darwin' && process.arch === 'arm64';",
|
|
140
|
+
"const NATIVE_PLATFORM = MACOS_BUILD ? 'darwin' : 'win32';",
|
|
141
|
+
"const NATIVE_ARCH = MACOS_BUILD ? 'arm64' : 'x64';",
|
|
142
|
+
"const NATIVE_BINDING_PACKAGE = MACOS_BUILD ? '@nimiplatform/kit-protected-local-darwin-arm64' : '@nimiplatform/kit-protected-local-win32-x64';",
|
|
140
143
|
"const appRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');",
|
|
141
144
|
"const outputRoot = path.join(appRoot, 'dist-electron-package');",
|
|
142
145
|
"const requireFromApp = createRequire(path.join(appRoot, 'package.json'));",
|
|
143
146
|
'',
|
|
144
|
-
"if (process.platform !== 'win32' || process.arch !== 'x64') {",
|
|
145
|
-
" throw new Error('
|
|
147
|
+
"if (!MACOS_BUILD && (process.platform !== 'win32' || process.arch !== 'x64')) {",
|
|
148
|
+
" throw new Error('Electron production packaging requires a windows-x86_64 or macos-aarch64 build host.');",
|
|
146
149
|
'}',
|
|
147
150
|
'',
|
|
148
151
|
"const appPackage = JSON.parse(await readFile(path.join(appRoot, 'package.json'), 'utf8'));",
|
|
149
152
|
'const APP_VERSION = appPackage.version;',
|
|
150
|
-
'const
|
|
153
|
+
'const RESOURCE_VERSION = MACOS_BUILD ? APP_VERSION : resolveWindowsResourceVersion(APP_VERSION);',
|
|
151
154
|
"for (const sectionName of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) {",
|
|
152
155
|
' if (Object.hasOwn(appPackage[sectionName] || {}, NATIVE_BINDING_PACKAGE)) {',
|
|
153
156
|
" throw new Error('The protected native binding must arrive through the Kit optional dependency.');",
|
|
@@ -158,7 +161,7 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
158
161
|
"const kitRoot = await findPackageRoot(kitEntry, '@nimiplatform/kit');",
|
|
159
162
|
"const kitPackage = JSON.parse(await readFile(path.join(kitRoot, 'package.json'), 'utf8'));",
|
|
160
163
|
'if (!Object.hasOwn(kitPackage.optionalDependencies || {}, NATIVE_BINDING_PACKAGE)) {',
|
|
161
|
-
" throw new Error('Kit does not declare the
|
|
164
|
+
" throw new Error('Kit does not declare the current-platform protected native binding as optional.');",
|
|
162
165
|
'}',
|
|
163
166
|
"const requireFromKit = createRequire(path.join(kitRoot, 'package.json'));",
|
|
164
167
|
'const nativeEntry = requireFromKit.resolve(NATIVE_BINDING_PACKAGE);',
|
|
@@ -209,12 +212,13 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
209
212
|
'',
|
|
210
213
|
' const packagePaths = await packager({',
|
|
211
214
|
' dir: productionSourceRoot,',
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
' platform: NATIVE_PLATFORM,',
|
|
216
|
+
' arch: NATIVE_ARCH,',
|
|
217
|
+
` appBundleId: ${JSON.stringify(identity.tauriIdentifier)},`,
|
|
214
218
|
' name: APP_EXECUTABLE_NAME,',
|
|
215
219
|
' executableName: APP_EXECUTABLE_NAME,',
|
|
216
|
-
' appVersion:
|
|
217
|
-
' buildVersion:
|
|
220
|
+
' appVersion: RESOURCE_VERSION,',
|
|
221
|
+
' buildVersion: RESOURCE_VERSION,',
|
|
218
222
|
' electronVersion: electronPackage.version,',
|
|
219
223
|
' out: outputRoot,',
|
|
220
224
|
' tmpdir: packagerTempRoot,',
|
|
@@ -223,6 +227,13 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
223
227
|
' prune: false,',
|
|
224
228
|
' quiet: true,',
|
|
225
229
|
' derefSymlinks: true,',
|
|
230
|
+
' // Publisher-side ad-hoc sealing supplies no Developer ID or notarization.',
|
|
231
|
+
' // Runtime preserves these bytes; Nimi never signs installed third-party code.',
|
|
232
|
+
' ...(MACOS_BUILD ? { osxSign: {',
|
|
233
|
+
" identity: '-', identityValidation: false, preAutoEntitlements: false,",
|
|
234
|
+
' preEmbedProvisioningProfile: false, strictVerify: true,',
|
|
235
|
+
" optionsForFile: () => ({ entitlements: [], hardenedRuntime: false, timestamp: 'none' }),",
|
|
236
|
+
' } } : {}),',
|
|
226
237
|
' afterInitialize: [async ({ buildPath }) => {',
|
|
227
238
|
" const packagedManifestPath = path.join(buildPath, 'package.json');",
|
|
228
239
|
" const packagedManifest = JSON.parse(await readFile(packagedManifestPath, 'utf8'));",
|
|
@@ -238,11 +249,13 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
238
249
|
' },',
|
|
239
250
|
' });',
|
|
240
251
|
" if (!Array.isArray(packagePaths) || packagePaths.length !== 1) throw new Error('Electron packager returned an ambiguous production package.');",
|
|
241
|
-
' const expectedPackageRoot = path.join(outputRoot, `${APP_EXECUTABLE_NAME}
|
|
252
|
+
' const expectedPackageRoot = path.join(outputRoot, `${APP_EXECUTABLE_NAME}-${NATIVE_PLATFORM}-${NATIVE_ARCH}`);',
|
|
242
253
|
' if (path.resolve(packagePaths[0]).toLowerCase() !== path.resolve(expectedPackageRoot).toLowerCase()) {',
|
|
243
254
|
" throw new Error('Electron packager returned an unexpected production package path.');",
|
|
244
255
|
' }',
|
|
245
|
-
' await realpath(
|
|
256
|
+
' await realpath(MACOS_BUILD',
|
|
257
|
+
" ? path.join(expectedPackageRoot, `${APP_EXECUTABLE_NAME}.app`, 'Contents', 'MacOS', APP_EXECUTABLE_NAME)",
|
|
258
|
+
' : path.join(expectedPackageRoot, `${APP_EXECUTABLE_NAME}.exe`));',
|
|
246
259
|
' packageCompleted = true;',
|
|
247
260
|
' process.stdout.write(`[nimi-app] Electron production package: ${expectedPackageRoot}\\n`);',
|
|
248
261
|
'} finally {',
|
|
@@ -253,9 +266,10 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
253
266
|
'',
|
|
254
267
|
'async function installProductionDependencies(projectRoot) {',
|
|
255
268
|
" const command = 'pnpm install --prod --frozen-lockfile --ignore-scripts --node-linker=hoisted';",
|
|
256
|
-
" const commandShell = process.env.ComSpec || 'cmd.exe';",
|
|
269
|
+
" const commandShell = MACOS_BUILD ? 'pnpm' : process.env.ComSpec || 'cmd.exe';",
|
|
270
|
+
" const commandArguments = MACOS_BUILD ? ['install', '--prod', '--frozen-lockfile', '--ignore-scripts', '--node-linker=hoisted'] : ['/d', '/s', '/c', command];",
|
|
257
271
|
' await new Promise((resolve, reject) => {',
|
|
258
|
-
|
|
272
|
+
' const child = spawn(commandShell, commandArguments, {',
|
|
259
273
|
' cwd: projectRoot,',
|
|
260
274
|
" stdio: 'inherit',",
|
|
261
275
|
' windowsHide: true,',
|
|
@@ -1000,6 +1014,7 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1000
1014
|
' appId,',
|
|
1001
1015
|
" surfaceId: 'ai-capabilities',",
|
|
1002
1016
|
" abortReason: 'studio-user-canceled',",
|
|
1017
|
+
' translate,',
|
|
1003
1018
|
' handlers: generatedStudioRuntimeHandlers,',
|
|
1004
1019
|
' resolveCapability: (capabilityId) => generatedAIStudioComposition.getCapability(capabilityId).descriptor,',
|
|
1005
1020
|
' inspectRuntime: inspectTargetRuntime,',
|
package/lib/app-scaffold.mjs
CHANGED
|
@@ -145,7 +145,7 @@ const APP_RELEASE_WORKFLOW = [
|
|
|
145
145
|
' id: matrix',
|
|
146
146
|
' shell: bash',
|
|
147
147
|
' run: |',
|
|
148
|
-
" matrix=$(jq -c '{include: [.targets[] | {target: ., runner: (if . == \"windows-x86_64\" then \"windows-latest\" else error(\"unsupported target\") end)}]}' .nimi-targets.json)",
|
|
148
|
+
" matrix=$(jq -c '{include: [.targets[] | {target: ., runner: (if . == \"windows-x86_64\" then \"windows-latest\" elif . == \"macos-aarch64\" then \"macos-15\" else error(\"unsupported target\") end)}]}' .nimi-targets.json)",
|
|
149
149
|
' test "$(jq \'.include | length\' <<<"$matrix")" -gt 0',
|
|
150
150
|
' echo "matrix=$matrix" >> "$GITHUB_OUTPUT"',
|
|
151
151
|
' build-target:',
|
|
@@ -202,6 +202,7 @@ const APP_RELEASE_WORKFLOW = [
|
|
|
202
202
|
' path: |',
|
|
203
203
|
' dist/nimi-app/*.nimiapp',
|
|
204
204
|
' dist/nimi-app/*.target.json',
|
|
205
|
+
' dist/nimi-app/*.app-info.json',
|
|
205
206
|
' if-no-files-found: error',
|
|
206
207
|
' attest-target:',
|
|
207
208
|
" if: github.event_name == 'push' && github.ref_type == 'tag'",
|
|
@@ -248,6 +249,7 @@ const APP_RELEASE_WORKFLOW = [
|
|
|
248
249
|
' path: |',
|
|
249
250
|
' dist/nimi-app/*.nimiapp',
|
|
250
251
|
' dist/nimi-app/*.target.json',
|
|
252
|
+
' dist/nimi-app/*.app-info.json',
|
|
251
253
|
' dist/nimi-app/*.candidate.json',
|
|
252
254
|
' if-no-files-found: error',
|
|
253
255
|
' release:',
|
|
@@ -287,7 +289,7 @@ const APP_RELEASE_WORKFLOW = [
|
|
|
287
289
|
" sleep 10",
|
|
288
290
|
" done",
|
|
289
291
|
" }",
|
|
290
|
-
' assets=(release-assets/*.nimiapp release-assets/*.candidate.json)',
|
|
292
|
+
' assets=(release-assets/*.nimiapp release-assets/*.app-info.json release-assets/*.candidate.json)',
|
|
291
293
|
' test "${#assets[@]}" -gt 0',
|
|
292
294
|
" expected=$(printf '%s\\n' \"${assets[@]##*/}\" | jq -R -s -c 'split(\"\\n\")[:-1] | sort')",
|
|
293
295
|
' if release_id=$(gh release view "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --json databaseId --jq .databaseId 2>/dev/null); then',
|
|
@@ -864,6 +866,15 @@ function buildNimiAppManifest(identity) {
|
|
|
864
866
|
profile: identity.profile,
|
|
865
867
|
manifest_role: 'submitted-input',
|
|
866
868
|
app_access: identity.appAccessItems,
|
|
869
|
+
capability_contract_refs: identity.capabilityResolution.capabilityContractRefs,
|
|
870
|
+
required_standardized_feature_refs: identity.capabilityResolution.requiredStandardizedFeatureRefs,
|
|
871
|
+
storage_policy: { kind: 'nimi-mediated-default' },
|
|
872
|
+
metadata: {
|
|
873
|
+
summary: '',
|
|
874
|
+
icon: 'assets/app-icon.png',
|
|
875
|
+
readme: 'README.md',
|
|
876
|
+
release_notes: 'RELEASE_NOTES.md',
|
|
877
|
+
},
|
|
867
878
|
local_development: {
|
|
868
879
|
electron: {
|
|
869
880
|
renderer_origin: `http://127.0.0.1:${identity.devPort}`,
|
|
@@ -1027,6 +1038,13 @@ export function renderAppBuildProfile(options = {}) {
|
|
|
1027
1038
|
payload_path: `dist-electron-package/${identity.cargoPackageName}-win32-x64`,
|
|
1028
1039
|
runtime_entry: `payload/${identity.cargoPackageName}.exe`,
|
|
1029
1040
|
},
|
|
1041
|
+
'macos-aarch64': {
|
|
1042
|
+
os: 'macos',
|
|
1043
|
+
arch: 'arm64',
|
|
1044
|
+
build_command: 'pnpm run build:electron:production',
|
|
1045
|
+
payload_path: `dist-electron-package/${identity.cargoPackageName}-darwin-arm64`,
|
|
1046
|
+
runtime_entry: `payload/${identity.cargoPackageName}.app/Contents/MacOS/${identity.cargoPackageName}`,
|
|
1047
|
+
},
|
|
1030
1048
|
} : undefined);
|
|
1031
1049
|
return YAML.stringify({
|
|
1032
1050
|
build_profile_ref: 'electron-packager-pnpm-vite',
|
|
@@ -1329,7 +1347,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
|
|
|
1329
1347
|
for (const file of files) {
|
|
1330
1348
|
const mutationClass = file.mutationClass;
|
|
1331
1349
|
taxonomy[mutationClass].push(file.path);
|
|
1332
|
-
const digest =
|
|
1350
|
+
const digest = hashScaffoldManagedContent(file.path, file.content);
|
|
1333
1351
|
if (mutationClass === 'app-owned product code') {
|
|
1334
1352
|
appOwnedInitialHashes[file.path] = {
|
|
1335
1353
|
class: mutationClass,
|
|
@@ -1564,3 +1582,13 @@ export function createAppScaffoldCandidate(input) {
|
|
|
1564
1582
|
const plan = input.plan || buildAppScaffoldCandidateCreatePlan(input);
|
|
1565
1583
|
return createAppScaffold({ ...input, plan });
|
|
1566
1584
|
}
|
|
1585
|
+
|
|
1586
|
+
export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['metadata', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy']);
|
|
1587
|
+
|
|
1588
|
+
// Source configuration is editable; existing scaffold checks still cover identity and carrier fields.
|
|
1589
|
+
export function hashScaffoldManagedContent(relativePath, content) {
|
|
1590
|
+
if (relativePath !== 'nimi.app.yaml') return hashScaffoldContent(content);
|
|
1591
|
+
const manifest = YAML.parse(content.toString());
|
|
1592
|
+
for (const field of APP_AUTHOR_DECLARATION_FIELDS) delete manifest[field];
|
|
1593
|
+
return hashScaffoldContent(YAML.stringify(manifest, { lineWidth: 0 }));
|
|
1594
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-024a
|
|
2
|
+
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-024b
|
|
3
|
+
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-034a
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { spawnSync } from 'node:child_process';
|
|
7
|
+
|
|
8
|
+
function command(binary, args) {
|
|
9
|
+
const result = spawnSync(binary, args, { encoding: 'utf8', timeout: 60000, maxBuffer: 4 * 1024 * 1024 });
|
|
10
|
+
if (result.error) throw result.error;
|
|
11
|
+
return { status: result.status, text: `${result.stdout || ''}\n${result.stderr || ''}`, stdout: result.stdout || '' };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function requireCommand(binary, args) {
|
|
15
|
+
const result = command(binary, args);
|
|
16
|
+
if (result.status !== 0) throw new Error(`${path.basename(binary)} native verification failed: ${result.text.trim()}`);
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function inspectMacOSMachO(bytes) {
|
|
21
|
+
if (bytes.length < 32 || bytes.readUInt32LE(0) !== 0xfeedfacf || bytes.readUInt32LE(4) !== 0x0100000c || bytes.readUInt32LE(12) !== 2) {
|
|
22
|
+
throw new Error('macOS Runtime entry must be a native arm64 Mach-O executable');
|
|
23
|
+
}
|
|
24
|
+
const count = bytes.readUInt32LE(16);
|
|
25
|
+
const end = 32 + bytes.readUInt32LE(20);
|
|
26
|
+
if (end > bytes.length) throw new Error('Invalid Mach-O load-command extent');
|
|
27
|
+
let cursor = 32;
|
|
28
|
+
let signaturePresent = false;
|
|
29
|
+
for (let index = 0; index < count; index += 1) {
|
|
30
|
+
if (cursor + 8 > end) throw new Error('Invalid Mach-O load command');
|
|
31
|
+
const size = bytes.readUInt32LE(cursor + 4);
|
|
32
|
+
if (size < 8 || cursor + size > end) throw new Error('Invalid Mach-O load-command size');
|
|
33
|
+
if (bytes.readUInt32LE(cursor) === 0x1d) {
|
|
34
|
+
if (signaturePresent || size !== 16) throw new Error('Invalid Mach-O signature command');
|
|
35
|
+
const offset = bytes.readUInt32LE(cursor + 8);
|
|
36
|
+
const signatureSize = bytes.readUInt32LE(cursor + 12);
|
|
37
|
+
if (!signatureSize || offset < end || offset + signatureSize > bytes.length) throw new Error('Invalid Mach-O signature extent');
|
|
38
|
+
signaturePresent = true;
|
|
39
|
+
}
|
|
40
|
+
cursor += size;
|
|
41
|
+
}
|
|
42
|
+
if (cursor !== end) throw new Error('Invalid Mach-O load-command count');
|
|
43
|
+
return { signaturePresent };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function macOSBundleForRuntimeEntry(runtimePath) {
|
|
47
|
+
const executableRoot = path.dirname(runtimePath);
|
|
48
|
+
const contentsRoot = path.dirname(executableRoot);
|
|
49
|
+
const bundleRoot = path.dirname(contentsRoot);
|
|
50
|
+
if (path.basename(executableRoot) !== 'MacOS' || path.basename(contentsRoot) !== 'Contents' || !bundleRoot.endsWith('.app')) {
|
|
51
|
+
throw new Error('macOS Runtime entry must be a direct bundle Contents/MacOS executable');
|
|
52
|
+
}
|
|
53
|
+
return bundleRoot;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function classifyMacOSNativeTrustObservation(observation) {
|
|
57
|
+
if (observation.signature === 'absent' || observation.signature === 'ad-hoc') {
|
|
58
|
+
if (observation.certificateSubject !== null || observation.notarization !== 'absent') throw new Error('macOS absent publisher identity has contradictory native metadata');
|
|
59
|
+
return { posture: 'production-unsigned', macos_developer_id: 'absent', macos_notarization: 'absent', certificate_subject: null };
|
|
60
|
+
}
|
|
61
|
+
if (observation.signature === 'developer-id-valid' && typeof observation.certificateSubject === 'string' && observation.certificateSubject.trim() === observation.certificateSubject && observation.certificateSubject && ['absent', 'notarized'].includes(observation.notarization)) {
|
|
62
|
+
return { posture: 'observed-valid-native-signature', macos_developer_id: 'valid', macos_notarization: observation.notarization, certificate_subject: observation.certificateSubject };
|
|
63
|
+
}
|
|
64
|
+
throw new Error('macOS native signature or notarization is invalid or unresolved');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function observeMacOSExecutableFacts(runtimePath) {
|
|
68
|
+
if (process.platform !== 'darwin' || process.arch !== 'arm64') throw new Error('Production macOS pack must run on macos-aarch64');
|
|
69
|
+
const bundleRoot = macOSBundleForRuntimeEntry(runtimePath);
|
|
70
|
+
const bytes = readFileSync(runtimePath);
|
|
71
|
+
const { signaturePresent } = inspectMacOSMachO(bytes);
|
|
72
|
+
const info = JSON.parse(requireCommand('/usr/bin/plutil', ['-convert', 'json', '-o', '-', path.join(bundleRoot, 'Contents', 'Info.plist')]).stdout);
|
|
73
|
+
if (info.CFBundleExecutable !== path.basename(runtimePath) || Object.hasOwn(info, 'SMPrivilegedExecutables') || existsSync(path.join(bundleRoot, 'Contents', 'Library', 'LaunchDaemons'))) {
|
|
74
|
+
throw new Error('macOS bundle does not satisfy the ordinary current-user execution profile');
|
|
75
|
+
}
|
|
76
|
+
const detail = command('/usr/bin/codesign', ['--display', '--verbose=4', bundleRoot]);
|
|
77
|
+
let observation;
|
|
78
|
+
if (!signaturePresent) {
|
|
79
|
+
if (detail.status === 0 || !/code object is not signed at all/u.test(detail.text)) throw new Error('macOS unsigned observation is unresolved');
|
|
80
|
+
observation = { signature: 'absent', certificateSubject: null, notarization: 'absent' };
|
|
81
|
+
} else {
|
|
82
|
+
if (detail.status !== 0) throw new Error(`macOS code signature is unreadable: ${detail.text.trim()}`);
|
|
83
|
+
requireCommand('/usr/bin/codesign', ['--verify', '--deep', '--strict', bundleRoot]);
|
|
84
|
+
if (/^Signature=adhoc$/mu.test(detail.text)) {
|
|
85
|
+
observation = { signature: 'ad-hoc', certificateSubject: null, notarization: 'absent' };
|
|
86
|
+
} else {
|
|
87
|
+
requireCommand('/usr/bin/codesign', ['--verify', '--strict', '-R=anchor apple generic and certificate leaf[field.1.2.840.113635.100.6.1.13] exists', bundleRoot]);
|
|
88
|
+
const subject = detail.text.match(/^Authority=(Developer ID Application: .+)$/mu)?.[1];
|
|
89
|
+
if (!subject) throw new Error('macOS publisher signature is not a verified Developer ID identity');
|
|
90
|
+
const ticket = command('/usr/bin/xcrun', ['stapler', 'validate', bundleRoot]);
|
|
91
|
+
if (ticket.status !== 0 && !/does not have a ticket stapled to it/u.test(ticket.text)) throw new Error(`macOS notarization is unresolved: ${ticket.text.trim()}`);
|
|
92
|
+
observation = { signature: 'developer-id-valid', certificateSubject: subject, notarization: ticket.status === 0 ? 'notarized' : 'absent' };
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return { nativeTrust: classifyMacOSNativeTrustObservation(observation), executionProfile: { launch_mode: 'current-user' } };
|
|
96
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-014a
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
export const SYMBOLIC_LINK_MODE = 0o120777;
|
|
5
|
+
|
|
6
|
+
// Electron frameworks contain relative links such as Versions/Current -> A.
|
|
7
|
+
// Resolve against the archive tree, never against the publisher's filesystem.
|
|
8
|
+
export function validatePayloadLinks(entries, os) {
|
|
9
|
+
const directories = new Set();
|
|
10
|
+
for (const name of entries.keys()) {
|
|
11
|
+
for (let parent = path.posix.dirname(name); parent !== '.'; parent = path.posix.dirname(parent)) {
|
|
12
|
+
directories.add(parent);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
for (const name of directories) {
|
|
16
|
+
if (entries.has(name)) throw new Error(`nimiapp file/directory collision: ${name}`);
|
|
17
|
+
}
|
|
18
|
+
const resolve = (name, visited = new Set()) => {
|
|
19
|
+
const parts = name.split('/');
|
|
20
|
+
for (let length = 1; length <= parts.length; length += 1) {
|
|
21
|
+
const prefix = parts.slice(0, length).join('/');
|
|
22
|
+
const entry = entries.get(prefix);
|
|
23
|
+
if (entry?.mode !== SYMBOLIC_LINK_MODE) continue;
|
|
24
|
+
if (visited.has(prefix)) throw new Error(`Cyclic payload symbolic link: ${prefix}`);
|
|
25
|
+
const target = entry.bytes.toString('utf8');
|
|
26
|
+
if (!target || target.includes('\\') || target.includes('\0') || path.posix.isAbsolute(target)) {
|
|
27
|
+
throw new Error(`Invalid payload symbolic link: ${prefix}`);
|
|
28
|
+
}
|
|
29
|
+
const destination = path.posix.normalize(path.posix.join(path.posix.dirname(prefix), target, ...parts.slice(length)));
|
|
30
|
+
if (!destination.startsWith('payload/')) throw new Error(`Payload symbolic link escapes its root: ${prefix}`);
|
|
31
|
+
return resolve(destination, new Set([...visited, prefix]));
|
|
32
|
+
}
|
|
33
|
+
if (!entries.has(name) && !directories.has(name)) throw new Error(`Missing payload symbolic link destination: ${name}`);
|
|
34
|
+
return name;
|
|
35
|
+
};
|
|
36
|
+
for (const [name, entry] of entries) {
|
|
37
|
+
if (entry.mode !== SYMBOLIC_LINK_MODE) continue;
|
|
38
|
+
if (os !== 'macos' || !name.startsWith('payload/')) throw new Error(`Symbolic link is not admitted for this target: ${name}`);
|
|
39
|
+
resolve(name);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimiplatform/app-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Public app-authoring CLI for Nimi App projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"provenance": true
|
|
19
19
|
},
|
|
20
20
|
"nimiScaffoldVersions": {
|
|
21
|
-
"sdkVersion": "^0.
|
|
22
|
-
"appToolsVersion": "^0.
|
|
23
|
-
"nimicodingVersion": "0.6.
|
|
21
|
+
"sdkVersion": "^0.10.0",
|
|
22
|
+
"appToolsVersion": "^0.4.0",
|
|
23
|
+
"nimicodingVersion": "0.6.2",
|
|
24
24
|
"aiSdkVersion": "^6.0.85",
|
|
25
|
-
"kitVersion": "^0.
|
|
25
|
+
"kitVersion": "^0.6.0",
|
|
26
26
|
"reactVersion": "^19.2.8",
|
|
27
27
|
"reactDomVersion": "^19.2.8",
|
|
28
28
|
"i18nextVersion": "^25.10.10",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"sync:app-source": "node scripts/sync-app-source.mjs --apply",
|
|
58
58
|
"prepack": "pnpm run build",
|
|
59
59
|
"prepublishOnly": "pnpm run build",
|
|
60
|
-
"test": "node
|
|
61
|
-
"test:
|
|
60
|
+
"test": "node ../scripts/with-workspace-surfaces.mjs -- pnpm run test:prepared",
|
|
61
|
+
"test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/simulator-conformance.test.mjs test/dev-shell.test.mjs && node --test test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-scaffold.test.mjs"
|
|
62
62
|
},
|
|
63
63
|
"files": [
|
|
64
64
|
"bin",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"README.md"
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
+
"pngjs": "7.0.0",
|
|
71
72
|
"postcss": "^8.5.26",
|
|
72
73
|
"postcss-selector-parser": "^7.1.5",
|
|
73
74
|
"semver": "^7.8.5",
|
|
@@ -26,36 +26,23 @@ function publicPackageRange(manifest, label) {
|
|
|
26
26
|
return `^${requiredString(manifest.version, `${label}.version`)}`;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!/^name\s*=\s*"nimi-shell-tauri"\s*$/mu.test(cargo)) {
|
|
32
|
-
throw new Error('Scaffold version source is invalid: kit/shell/tauri package name');
|
|
33
|
-
}
|
|
34
|
-
const match = cargo.match(/^version\s*=\s*"([^"]+)"\s*$/mu);
|
|
35
|
-
const version = requiredString(match?.[1], 'kit/shell/tauri.version');
|
|
36
|
-
validateAppScaffoldCargoDependencyValue(version, 'kit/shell/tauri.version');
|
|
37
|
-
return version;
|
|
38
|
-
}
|
|
39
|
-
|
|
29
|
+
// @nimi-authority: rule.nimi.platform.governance-release.p-gov-027-component-release-identity
|
|
30
|
+
// The manifest owns tested public dependency versions independently of workspace development versions.
|
|
40
31
|
export function buildScaffoldVersionProjection() {
|
|
41
32
|
const rootManifest = readJson('package.json');
|
|
42
33
|
const appToolsManifest = readJson('app-tools/package.json');
|
|
43
|
-
const sdkManifest = readJson('sdks/typescript/package.json');
|
|
44
|
-
const kitManifest = readJson('kit/package.json');
|
|
45
34
|
const current = appToolsManifest.nimiScaffoldVersions;
|
|
46
35
|
if (!current || typeof current !== 'object' || Array.isArray(current)) {
|
|
47
36
|
throw new Error('app-tools package manifest is missing nimiScaffoldVersions');
|
|
48
37
|
}
|
|
38
|
+
validateAppScaffoldCargoDependencyValue(current.nimiShellTauriVersion, 'nimiScaffoldVersions.nimiShellTauriVersion');
|
|
49
39
|
return Object.freeze({
|
|
50
40
|
...current,
|
|
51
|
-
sdkVersion: publicPackageRange(sdkManifest, '@nimiplatform/sdk'),
|
|
52
41
|
appToolsVersion: publicPackageRange(appToolsManifest, '@nimiplatform/app-tools'),
|
|
53
42
|
nimicodingVersion: requiredString(
|
|
54
43
|
rootManifest.devDependencies?.['@nimiplatform/nimi-coding'],
|
|
55
44
|
'root.devDependencies.@nimiplatform/nimi-coding',
|
|
56
45
|
),
|
|
57
|
-
kitVersion: publicPackageRange(kitManifest, '@nimiplatform/kit'),
|
|
58
|
-
nimiShellTauriVersion: nimiShellTauriVersion(),
|
|
59
46
|
packageManager: requiredString(rootManifest.packageManager, 'root.packageManager'),
|
|
60
47
|
});
|
|
61
48
|
}
|
|
@@ -37,6 +37,37 @@
|
|
|
37
37
|
.studio-parameters-drawer{ display: none;}
|
|
38
38
|
.studio-parameters-drawer--open{ display: block; max-height: min(420px, 52cqh); overflow: auto; border-top: 1px solid var(--nimi-border-subtle); padding: 12px 6px 2px 0;}
|
|
39
39
|
.studio-parameters{ display: grid; gap: 12px;}
|
|
40
|
+
.studio-start--vision{ overflow-y: auto; align-items: start; padding-bottom: 32px;}
|
|
41
|
+
.studio-start--vision .studio-start__center{ gap: 24px;}
|
|
42
|
+
.studio-composer--vision{ gap: 16px;}
|
|
43
|
+
.studio-locate-input{ min-width: 0; overflow: hidden; border-radius: var(--nimi-radius-lg); background: var(--nimi-surface-card);}
|
|
44
|
+
.studio-locate-input__empty{ display: grid; justify-items: center; align-content: center; gap: 12px; min-height: 156px; padding: 24px;}
|
|
45
|
+
.studio-locate-input__empty p{ margin: 0; color: var(--nimi-text-secondary); font-size: 13px; line-height: 1.5; text-align: center;}
|
|
46
|
+
.studio-locate-input__preview{ display: block; width: 100%; height: 220px; object-fit: contain; image-orientation: from-image;}
|
|
47
|
+
.studio-locate-input__file{ display: flex; align-items: center; gap: 8px; padding: 8px 12px;}
|
|
48
|
+
.studio-locate-input__file > span{ flex: 1; min-width: 0; overflow: hidden; color: var(--nimi-text-secondary); font-size: 13px; text-overflow: ellipsis; white-space: nowrap;}
|
|
49
|
+
.studio-locate-input__label{ color: var(--nimi-text-primary); font-size: 13px; font-weight: var(--nimi-type-label-weight);}
|
|
50
|
+
.studio-locate-parameters{ padding: 12px 0;}
|
|
51
|
+
.studio-locate-parameters p{ margin: 0; color: var(--nimi-text-secondary); font-size: 12px; line-height: 1.5;}
|
|
52
|
+
.studio-composer--vision .studio-composer__bar{ flex-wrap: wrap; justify-content: flex-end;}
|
|
53
|
+
.studio-composer--vision .studio-composer__controls{ display: none;}
|
|
54
|
+
.studio-composer--vision .studio-composer__actions{ justify-content: flex-end;}
|
|
55
|
+
.studio-composer--vision.studio-composer--compact{ gap: 10px;}
|
|
56
|
+
.studio-composer--vision.studio-composer--compact .studio-locate-input{ display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center;}
|
|
57
|
+
.studio-composer--vision.studio-composer--compact .studio-locate-input__preview{ height: 64px;}
|
|
58
|
+
.studio-composer--vision.studio-composer--compact .studio-locate-input__empty{ grid-column: 1 / -1; min-height: 80px; padding: 12px;}
|
|
59
|
+
.studio-composer--vision.studio-composer--compact .studio-locate-parameters{ padding: 8px 0;}
|
|
60
|
+
.studio-composer--vision.studio-composer--compact .studio-locate-parameters p{ display: none;}
|
|
61
|
+
.studio-composer--vision.studio-composer--compact .studio-input{ padding-bottom: 16px;}
|
|
62
|
+
.studio-locate-result{margin:0;display:grid;gap:12px;min-width:0;}
|
|
63
|
+
.studio-locate-result__image{position:relative;width:100%;overflow:hidden;background:var(--nimi-surface-card);border-radius:var(--nimi-radius-md);}
|
|
64
|
+
.studio-locate-result__image img{display:block;width:100%;height:100%;object-fit:contain;image-orientation:from-image;}
|
|
65
|
+
.studio-locate-result__image svg{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;}
|
|
66
|
+
.studio-locate-result__image rect{fill:transparent;stroke:var(--nimi-accent);stroke-width:3;filter:drop-shadow(0 1px 1px white);}
|
|
67
|
+
.studio-locate-result__image circle{fill:var(--nimi-accent);stroke:white;stroke-width:2;}
|
|
68
|
+
.studio-locate-result details{font-size:13px;}
|
|
69
|
+
.studio-locate-result summary{cursor:pointer;color:var(--nimi-text-secondary);}
|
|
70
|
+
.studio-locate-result pre{max-height:320px;overflow:auto;font-size:12px;}
|
|
40
71
|
.studio-parameters__head{ display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--nimi-text-muted); font-size: 12px;}
|
|
41
72
|
.studio-parameters__grid{ display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;}
|
|
42
73
|
.studio-parameters__stack{ display: grid; gap: 9px;}
|
|
@@ -85,6 +85,20 @@ function validateHistoryResult(value: unknown, path: string): void {
|
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
optionalString(value.traceId, `${path}.traceId`);
|
|
88
|
+
if (kind === 'vision-locate') {
|
|
89
|
+
requiredString(value.jobId, `${path}.jobId`);
|
|
90
|
+
const result = value.result;
|
|
91
|
+
if (result === undefined) return;
|
|
92
|
+
if (!isJsonObject(result) || typeof result.imageArtifactId !== 'string' || !result.imageArtifactId || !Number.isInteger(result.width) || (result.width as number) <= 0 || !Number.isInteger(result.height) || (result.height as number) <= 0 || !Array.isArray(result.locations)) historyError(path, 'requires a typed Locate result');
|
|
93
|
+
for (const location of result.locations) {
|
|
94
|
+
if (!isJsonObject(location)) historyError(path, 'requires a typed location');
|
|
95
|
+
const axes = location.type === 'box' ? ['x1','y1','x2','y2'] : location.type === 'point' ? ['x','y'] : [];
|
|
96
|
+
if (!axes.length || axes.some(axis => typeof location[axis] !== 'number' || !Number.isFinite(location[axis]) || (location[axis] as number) < 0 || (location[axis] as number) > 1)) historyError(path, 'has invalid Locate coordinates');
|
|
97
|
+
if (location.type === 'box' && !((location.x1 as number) < (location.x2 as number) && (location.y1 as number) < (location.y2 as number))) historyError(path, 'has invalid Locate box ordering');
|
|
98
|
+
optionalString(location.label, `${path}.result.locations.label`);
|
|
99
|
+
}
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
88
102
|
if (kind === 'text') {
|
|
89
103
|
requiredString(value.body, `${path}.body`);
|
|
90
104
|
nonNegativeNumber(value.charCount, `${path}.charCount`);
|
|
@@ -213,8 +227,16 @@ export function studioHistoryFromRecords(records: readonly StudioRunHistoryRecor
|
|
|
213
227
|
}
|
|
214
228
|
|
|
215
229
|
export function boundStudioRunHistoryWithRecord(history: StudioRunHistory, record: StudioRunHistoryRecord): StudioRunHistory {
|
|
230
|
+
// History has a smaller JSON budget than a complete Runtime Locate result.
|
|
231
|
+
// Preserve the summary/Job reference without mutating the current full result.
|
|
232
|
+
let storedRecord = record;
|
|
233
|
+
if (record.result?.ok && record.result.kind === 'vision-locate' && record.result.result
|
|
234
|
+
&& new TextEncoder().encode(JSON.stringify(studioHistoryFromRecords([record]))).byteLength > STUDIO_HISTORY_LIMIT_BYTES) {
|
|
235
|
+
const { result: _locations, ...reference } = record.result;
|
|
236
|
+
storedRecord = { ...record, result: reference };
|
|
237
|
+
}
|
|
216
238
|
const counts = new Map<string, number>();
|
|
217
|
-
const retained = [
|
|
239
|
+
const retained = [storedRecord, ...flattenStudioHistoryRecords(history).filter((existing) => existing.id !== record.id)]
|
|
218
240
|
.sort((left, right) => right.createdAt.localeCompare(left.createdAt))
|
|
219
241
|
.filter((candidate) => {
|
|
220
242
|
const count = counts.get(candidate.capabilityId) ?? 0;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isJsonObject } from '@nimiplatform/sdk/types';
|
|
2
|
+
import type { NimiLocalAppVisionLocateResult } from '@nimiplatform/sdk/app';
|
|
2
3
|
import type {
|
|
3
4
|
StudioCapabilityRunResult,
|
|
4
5
|
StudioManagedArtifact,
|
|
@@ -29,7 +30,7 @@ export type StudioRunTargetStatus =
|
|
|
29
30
|
| 'checking'
|
|
30
31
|
| 'configured'
|
|
31
32
|
| 'blocked'
|
|
32
|
-
| '
|
|
33
|
+
| 'viewer-only'
|
|
33
34
|
| 'sdk-gap'
|
|
34
35
|
| 'not-admitted';
|
|
35
36
|
|
|
@@ -50,6 +51,7 @@ export type StudioRunConfigSnapshot = {
|
|
|
50
51
|
};
|
|
51
52
|
|
|
52
53
|
export type StudioRunHistoryResultSnapshot =
|
|
54
|
+
| { ok: true; kind: 'vision-locate'; summary: string; jobId: string; result?: NimiLocalAppVisionLocateResult; traceId?: string }
|
|
53
55
|
| {
|
|
54
56
|
ok: true;
|
|
55
57
|
kind: 'text';
|
|
@@ -456,6 +458,7 @@ export function createStudioRunHistoryResultSnapshot(result: StudioCapabilityRun
|
|
|
456
458
|
|
|
457
459
|
const trace = traceFields(result);
|
|
458
460
|
const output = result.output;
|
|
461
|
+
if (output.kind === 'vision-locate') return { ok: true, kind: 'vision-locate', summary: result.message, jobId: output.jobId, result: output.result, ...trace };
|
|
459
462
|
if (output.kind === 'text') {
|
|
460
463
|
return {
|
|
461
464
|
ok: true,
|
|
@@ -569,6 +572,7 @@ export function restoreStudioCapabilityRunResult(
|
|
|
569
572
|
message: record.message,
|
|
570
573
|
...(trace ? { trace } : {}),
|
|
571
574
|
};
|
|
575
|
+
if (snapshot.kind === 'vision-locate') return snapshot.result ? { ...common, output: { kind: 'vision-locate', jobId: snapshot.jobId, result: snapshot.result } } : null;
|
|
572
576
|
if (snapshot.kind === 'text') {
|
|
573
577
|
return {
|
|
574
578
|
...common,
|
|
@@ -802,6 +806,7 @@ export function getStudioRunMetricSummary(record: StudioRunHistoryRecord): strin
|
|
|
802
806
|
if (result.kind === 'artifacts') return `${result.jobState || 'unknown'} / ${result.artifactCount} artifact${result.artifactCount === 1 ? '' : 's'}`;
|
|
803
807
|
if (result.kind === 'transcript') return `${result.jobState || 'unknown'} / ${result.charCount} chars / ${result.artifactCount} artifact${result.artifactCount === 1 ? '' : 's'}`;
|
|
804
808
|
if (result.kind === 'voice-asset') return `${result.jobState || 'unknown'} / ${result.creationSource} / ${result.assetStatus}`;
|
|
809
|
+
if (result.kind === 'vision-locate') return result.summary;
|
|
805
810
|
return `${result.voiceCount} voice${result.voiceCount === 1 ? '' : 's'}`;
|
|
806
811
|
}
|
|
807
812
|
|
|
@@ -820,5 +825,6 @@ export function getStudioRunResultTags(record: StudioRunHistoryRecord): string[]
|
|
|
820
825
|
if (result.kind === 'artifacts') return ['Ready'];
|
|
821
826
|
if (result.kind === 'transcript') return ['Ready'];
|
|
822
827
|
if (result.kind === 'voice-asset') return ['VoiceAsset ready', result.creationSource];
|
|
828
|
+
if (result.kind === 'vision-locate') return result.result ? ['Locate', String(result.result.locations.length)] : ['Locate'];
|
|
823
829
|
return [`${result.voiceCount} voices`];
|
|
824
830
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import type { NimiLocalAppClient } from '@nimiplatform/sdk/app';
|
|
1
2
|
import { createContext, useContext, type ReactNode } from 'react';
|
|
2
3
|
import type { NimiPortableAppAIConfig } from '@nimiplatform/sdk/ai';
|
|
3
|
-
import type { NimiLocalAppArtifactImageMime } from '@nimiplatform/sdk/app';
|
|
4
4
|
import type { StudioCapabilityRunInput, StudioCapabilityRunResult } from './runtime-types.js';
|
|
5
5
|
import type { StudioCapabilityDescriptor } from './module-registration.js';
|
|
6
6
|
import type { StudioRunTargetSummary } from './history.js';
|
|
7
7
|
import type { StudioPromptDraftKey } from './prompt-drafts.js';
|
|
8
8
|
|
|
9
|
+
type NimiLocalAppArtifactUploadMime = Parameters<NimiLocalAppClient['ai']['artifacts']['upload']>[0]['mimeType'];
|
|
10
|
+
|
|
9
11
|
export type StudioHostCommandResult<TValue extends object = Record<string, never>> =
|
|
10
12
|
| { readonly ok: true; readonly value?: TValue }
|
|
11
13
|
| { readonly ok: false; readonly error?: unknown };
|
|
@@ -47,11 +49,11 @@ export type AIStudioHostPort = {
|
|
|
47
49
|
}[]>;
|
|
48
50
|
readonly uploadLocalAppArtifact: (input: {
|
|
49
51
|
readonly bytes: Uint8Array;
|
|
50
|
-
readonly mimeType:
|
|
52
|
+
readonly mimeType: NimiLocalAppArtifactUploadMime;
|
|
51
53
|
}) => Promise<{
|
|
52
54
|
readonly artifactId: string;
|
|
53
55
|
readonly sizeBytes: number;
|
|
54
|
-
readonly mimeType:
|
|
56
|
+
readonly mimeType: NimiLocalAppArtifactUploadMime;
|
|
55
57
|
}>;
|
|
56
58
|
readonly aiConfig: {
|
|
57
59
|
readonly get: () => Promise<NimiPortableAppAIConfig | null>;
|
|
@@ -165,6 +165,7 @@
|
|
|
165
165
|
"expandImage": "Expand image",
|
|
166
166
|
"expandGeneratedImage": "Expand generated image",
|
|
167
167
|
"imagePreview": "Image preview",
|
|
168
|
+
"imagePreviewFailed": "The image preview could not be opened. Please try again.",
|
|
168
169
|
"closeImagePreview": "Close image preview",
|
|
169
170
|
"emptyBody": "(empty body)",
|
|
170
171
|
"emptyTranscript": "(empty transcript)",
|
|
@@ -7,7 +7,7 @@ import type { StudioParameterPanelProps } from './parameter-fields.js';
|
|
|
7
7
|
|
|
8
8
|
export type StudioControlId = 'tone' | 'length';
|
|
9
9
|
export type StudioInputKind = 'prompt' | 'url' | 'none';
|
|
10
|
-
export type StudioResultKind = 'text' | 'transcript' | 'embedding' | 'artifacts' | 'voice-asset' | 'voice-catalog';
|
|
10
|
+
export type StudioResultKind = 'text' | 'transcript' | 'embedding' | 'artifacts' | 'voice-asset' | 'voice-catalog' | 'vision-locate';
|
|
11
11
|
|
|
12
12
|
export type CapabilityStudioProfile = {
|
|
13
13
|
readonly studioTag: string;
|
|
@@ -43,7 +43,7 @@ export type StudioCapabilityDescriptor<TCapabilityId extends string = string> =
|
|
|
43
43
|
readonly summary: string;
|
|
44
44
|
readonly summaryKey: string;
|
|
45
45
|
readonly surface: string;
|
|
46
|
-
readonly execution: 'runtime-sdk' | 'standalone-
|
|
46
|
+
readonly execution: 'runtime-sdk' | 'standalone-electron' | 'typed-unavailable';
|
|
47
47
|
readonly capabilityContract?: string;
|
|
48
48
|
readonly missingSurface?: string;
|
|
49
49
|
};
|
|
@@ -29,12 +29,16 @@ export function studioNonSuccessReasonTitle(reason: StudioNonSuccessReason, tran
|
|
|
29
29
|
return translate(`NonSuccess.title.${reasonKeySegment(reason)}`);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function studioNonSuccessReasonUserMessage(reason: string, translate: StudioTranslate): string {
|
|
32
|
+
export function studioNonSuccessReasonUserMessage(reason: string, translate: StudioTranslate, capabilityId?: string, diagnostics?: StudioNonSuccessDiagnostics): string {
|
|
33
|
+
if (capabilityId === 'vision.locate' && diagnostics?.reasonCode === 'AI_LOCAL_SELECTION_NOT_FOUND') return translate('VisionLocate.modelSelectionRequired');
|
|
34
|
+
if (reason === 'input-invalid' && capabilityId === 'vision.locate') return translate('VisionLocate.invalidInput');
|
|
33
35
|
const segment = reasonKeySegment(reason);
|
|
34
36
|
return translate(segment ? `NonSuccess.message.${segment}` : 'NonSuccess.message.fallback');
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
export function studioNonSuccessReasonUserAction(reason: string, translate: StudioTranslate): string {
|
|
39
|
+
export function studioNonSuccessReasonUserAction(reason: string, translate: StudioTranslate, capabilityId?: string, diagnostics?: StudioNonSuccessDiagnostics): string {
|
|
40
|
+
if (capabilityId === 'vision.locate' && diagnostics?.reasonCode === 'AI_LOCAL_SELECTION_NOT_FOUND') return translate('VisionLocate.selectModelAction');
|
|
41
|
+
if (reason === 'input-invalid' && capabilityId === 'vision.locate') return translate('VisionLocate.correctInput');
|
|
38
42
|
const segment = reasonKeySegment(reason);
|
|
39
43
|
return translate(segment ? `NonSuccess.action.${segment}` : 'NonSuccess.action.fallback');
|
|
40
44
|
}
|