@nimiplatform/app-tools 0.2.9 → 0.3.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 +24 -4
- package/lib/app-pack.mjs +33 -11
- package/lib/app-project-lifecycle.mjs +1 -0
- package/lib/app-scaffold-profiles.mjs +28 -13
- package/lib/app-scaffold.mjs +8 -1
- package/lib/macos-native.mjs +96 -0
- package/lib/payload-links.mjs +41 -0
- package/package.json +7 -7
- 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/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
package/README.md
CHANGED
|
@@ -79,13 +79,31 @@ The list shows the current project's registrations and creation times. Copy the
|
|
|
79
79
|
|
|
80
80
|
The default `windows-x86_64` build profile runs `build:electron:production`. It rebuilds the renderer and Electron main/preload, then creates a fresh, non-installer `dist-electron-package/<app>-shell-win32-x64/` directory with `asar` disabled and an App-specific `<app>-shell.exe`. The production main bundle has a compile-time production marker and rejects every `--nimi-dev-renderer-url` argument; packaged renderer assets stay relative under `dist/`. The protected native binding is resolved from Kit's optional dependency and is never declared directly by the App.
|
|
81
81
|
|
|
82
|
+
App Tools 0.3 also prepares the `macos-aarch64` target on an Apple Silicon Mac.
|
|
83
|
+
The same owner command produces `dist-electron-package/<app>-shell-darwin-arm64/`
|
|
84
|
+
with a native `.app` bundle and a direct `Contents/MacOS` entry. The publisher's
|
|
85
|
+
build applies an ad-hoc integrity seal without a Developer ID identity or Apple
|
|
86
|
+
notarization; production pack observes that absence and rejects invalid seals.
|
|
87
|
+
Relative framework links are preserved inside the immutable payload. The App
|
|
88
|
+
continues to consume the macOS native binding through Kit's optional dependency.
|
|
89
|
+
Nimi installation never signs or repairs the publisher's code.
|
|
90
|
+
|
|
91
|
+
Existing `.nimi/config/build-profile.yaml` target choices are App-owned and are
|
|
92
|
+
preserved by sync. To add macOS, declare `macos-aarch64` with `os: macos`,
|
|
93
|
+
`arch: arm64`, the same production build command, the Darwin output directory
|
|
94
|
+
above as `payload_path`, and
|
|
95
|
+
`payload/<app>-shell.app/Contents/MacOS/<app>-shell` as `runtime_entry`.
|
|
96
|
+
The managed workflow resolves that declared target to `macos-15`; Windows keeps
|
|
97
|
+
its existing runner and profile. These authoring/build capabilities do not by
|
|
98
|
+
themselves establish Registry admission or a completed Desktop lifecycle.
|
|
99
|
+
|
|
82
100
|
Tauri remains an explicit alternative through `pnpm run build:tauri:production`; selecting it requires an explicit Tauri build profile rather than changing the default Electron carrier.
|
|
83
101
|
|
|
84
102
|
## Canonical release boundary
|
|
85
103
|
|
|
86
|
-
The
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
The Registry publication chain uses the stages below. Publisher GitHub Release
|
|
105
|
+
is available for configured pilot repositories; protected Registry admission and
|
|
106
|
+
verified installation, update, launch and uninstall are available on Windows x86_64:
|
|
89
107
|
|
|
90
108
|
```text
|
|
91
109
|
public App repository
|
|
@@ -101,7 +119,9 @@ public App repository
|
|
|
101
119
|
|
|
102
120
|
The registry references publisher Release assets and never mirrors bytes. GitHub Release is not catalog admission; catalog admission is not installed; installed is not running; running is not Nimi Access ready.
|
|
103
121
|
|
|
104
|
-
Repository administration must enable a protected `v*` tag ruleset and GitHub immutable releases before production. The managed tag workflow fetches the repository's canonical default branch and rejects a tag commit outside that history before production preflight, build, attestation, or Release. A fine-grained `NIMI_REPOSITORY_ADMIN_TOKEN` secret with repository Administration read permission lets the workflow verify protected-tag and immutable-release settings; it cannot enable or change them. Manual workflow dispatch runs only the non-production build/package path. On Windows, the tag-only production build invokes the App-declared production build with no certificate-secret mapping or app-tools-owned signing step. Optional native signing remains publisher-owned and must already be reflected in the final exact Runtime entry before production pack observes and records its native-trust posture; a present invalid or unresolved signature still fails closed. A successful tag workflow creates the immutable publisher GitHub Release and no registry, installed, running, or Nimi Access truth.
|
|
122
|
+
Repository administration must enable a protected `v*` tag ruleset and GitHub immutable releases before production. The managed tag workflow fetches the repository's canonical default branch and rejects a tag commit outside that history before production preflight, build, attestation, or Release. A fine-grained `NIMI_REPOSITORY_ADMIN_TOKEN` secret with repository Administration read permission lets the workflow verify protected-tag and immutable-release settings; it cannot enable or change them. Manual workflow dispatch runs only the non-production build/package path. On Windows, the tag-only production build invokes the App-declared production build with no certificate-secret mapping or app-tools-owned signing step. Optional native signing remains publisher-owned and must already be reflected in the final exact Runtime entry before production pack observes and records its native-trust posture; a present invalid or unresolved signature still fails closed. A successful tag workflow creates the immutable publisher GitHub Release and no registry, installed, running, or Nimi Access truth. Protected Registry submission and approved Windows x86_64 installation, update, launch/focus/stop, current-session Nimi Access and uninstall are available through their Platform, Runtime and Desktop owners. Other-platform installed lifecycle and ordinary repair remain unavailable. Explicit immutable local-package import remains a separate product path whose entry is not yet implemented.
|
|
123
|
+
|
|
124
|
+
Registry projects must be open source with an explicit license and reviewable release source. Consistently observed unsigned packages are eligible; invalid signatures cannot be downgraded to unsigned. These Registry admission requirements do not apply to user-imported packages or Developer Mode projects. Registry approval is not a guarantee that third-party code is harmless.
|
|
105
125
|
|
|
106
126
|
## Publishing on GitHub
|
|
107
127
|
|
package/lib/app-pack.mjs
CHANGED
|
@@ -12,11 +12,14 @@ import {
|
|
|
12
12
|
mkdirSync,
|
|
13
13
|
readFileSync,
|
|
14
14
|
readdirSync,
|
|
15
|
+
readlinkSync,
|
|
15
16
|
writeFileSync,
|
|
16
17
|
} from 'node:fs';
|
|
17
18
|
import path from 'node:path';
|
|
18
19
|
import { parse as parseYaml } from 'yaml';
|
|
19
20
|
import { observeWindowsExecutableFacts } from './windows-powershell.mjs';
|
|
21
|
+
import { SYMBOLIC_LINK_MODE, validatePayloadLinks } from './payload-links.mjs';
|
|
22
|
+
import { observeMacOSExecutableFacts } from './macos-native.mjs';
|
|
20
23
|
|
|
21
24
|
const PACKAGE_FORMAT = 'nimi.app-package/v1';
|
|
22
25
|
const TARGET_METADATA_FORMAT = 'nimi.app-target-candidate/v1';
|
|
@@ -28,6 +31,7 @@ const OUTPUT_DIR = 'dist/nimi-app';
|
|
|
28
31
|
const SEMVER_PATTERN = /^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/u;
|
|
29
32
|
const TARGETS = Object.freeze({
|
|
30
33
|
'windows-x86_64': Object.freeze({ os: 'windows', arch: 'x86_64' }),
|
|
34
|
+
'macos-aarch64': Object.freeze({ os: 'macos', arch: 'arm64' }),
|
|
31
35
|
});
|
|
32
36
|
|
|
33
37
|
function compareText(left, right) {
|
|
@@ -103,7 +107,7 @@ function readCargoPackageVersion(source) {
|
|
|
103
107
|
throw new Error('src-tauri/Cargo.toml [package] version is missing');
|
|
104
108
|
}
|
|
105
109
|
|
|
106
|
-
function collectPayload(payloadPath) {
|
|
110
|
+
function collectPayload(payloadPath, os) {
|
|
107
111
|
const stat = lstatSync(payloadPath);
|
|
108
112
|
if (stat.isSymbolicLink()) throw new Error('Pack payload must not contain symbolic links');
|
|
109
113
|
if (stat.isFile()) {
|
|
@@ -116,8 +120,10 @@ function collectPayload(payloadPath) {
|
|
|
116
120
|
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
117
121
|
const absolute = path.join(current, entry.name);
|
|
118
122
|
const entryStat = lstatSync(absolute);
|
|
119
|
-
if (entryStat.isSymbolicLink())
|
|
120
|
-
|
|
123
|
+
if (entryStat.isSymbolicLink()) {
|
|
124
|
+
if (os !== 'macos') throw new Error(`Pack payload must not contain symbolic links: ${relative}`);
|
|
125
|
+
entries.push({ relative, bytes: Buffer.from(readlinkSync(absolute)), mode: SYMBOLIC_LINK_MODE });
|
|
126
|
+
} else if (entryStat.isDirectory()) {
|
|
121
127
|
walk(absolute, relative);
|
|
122
128
|
} else if (entryStat.isFile()) {
|
|
123
129
|
entries.push({ relative, bytes: readFileSync(absolute), mode: entryStat.mode & 0o111 ? 0o755 : 0o644 });
|
|
@@ -157,7 +163,7 @@ export function writeNimiAppArchive(entries) {
|
|
|
157
163
|
const normalized = entries.map((entry) => ({
|
|
158
164
|
name: zipEntryName(entry.name),
|
|
159
165
|
bytes: Buffer.isBuffer(entry.bytes) ? entry.bytes : Buffer.from(entry.bytes),
|
|
160
|
-
mode: entry.mode === 0o755 ? 0o755 : 0o644,
|
|
166
|
+
mode: entry.mode === SYMBOLIC_LINK_MODE ? SYMBOLIC_LINK_MODE : entry.mode === 0o755 ? 0o755 : 0o644,
|
|
161
167
|
})).sort((left, right) => compareText(left.name, right.name));
|
|
162
168
|
if (normalized.length === 0) throw new Error('nimiapp archive requires at least one file');
|
|
163
169
|
if (new Set(normalized.map((entry) => entry.name)).size !== normalized.length) throw new Error('nimiapp archive entries must be unique');
|
|
@@ -199,7 +205,7 @@ export function writeNimiAppArchive(entries) {
|
|
|
199
205
|
central.writeUInt16LE(0, 32);
|
|
200
206
|
central.writeUInt16LE(0, 34);
|
|
201
207
|
central.writeUInt16LE(0, 36);
|
|
202
|
-
central.writeUInt32LE(((0o100000 | entry.mode) << 16) >>> 0, 38);
|
|
208
|
+
central.writeUInt32LE(((entry.mode === SYMBOLIC_LINK_MODE ? entry.mode : 0o100000 | entry.mode) << 16) >>> 0, 38);
|
|
203
209
|
central.writeUInt32LE(offset, 42);
|
|
204
210
|
centralParts.push(central, name);
|
|
205
211
|
offset += local.length + name.length + entry.bytes.length;
|
|
@@ -236,9 +242,10 @@ export function readNimiAppArchive(bytes) {
|
|
|
236
242
|
const extraLength = archive.readUInt16LE(cursor + 30);
|
|
237
243
|
const commentLength = archive.readUInt16LE(cursor + 32);
|
|
238
244
|
const localOffset = archive.readUInt32LE(cursor + 42);
|
|
239
|
-
const
|
|
245
|
+
const unixMode = archive.readUInt32LE(cursor + 38) >>> 16;
|
|
246
|
+
const mode = (unixMode & 0o170000) === 0o120000 ? unixMode : unixMode & 0o777;
|
|
240
247
|
if (method !== 0 || extraLength !== 0 || commentLength !== 0) throw new Error('Unsupported nimiapp ZIP entry encoding');
|
|
241
|
-
if (mode !== 0o644 && mode !== 0o755) throw new Error('Unsupported nimiapp ZIP entry mode');
|
|
248
|
+
if (mode !== 0o644 && mode !== 0o755 && mode !== SYMBOLIC_LINK_MODE) throw new Error('Unsupported nimiapp ZIP entry mode');
|
|
242
249
|
const name = zipEntryName(archive.subarray(cursor + 46, cursor + 46 + nameLength).toString('utf8'));
|
|
243
250
|
if (entries.has(name) || archive.readUInt32LE(localOffset) !== 0x04034b50) throw new Error('Invalid or duplicate nimiapp ZIP entry');
|
|
244
251
|
const localNameLength = archive.readUInt16LE(localOffset + 26);
|
|
@@ -358,10 +365,15 @@ function resolveTargetFacts(input, production, archivedRuntimeEntryBytes) {
|
|
|
358
365
|
executionProfile: null,
|
|
359
366
|
};
|
|
360
367
|
}
|
|
368
|
+
if (input.target.os === 'macos') {
|
|
369
|
+
const facts = observeMacOSExecutableFacts(input.runtimeHostPath);
|
|
370
|
+
if (!archivedRuntimeEntryBytes.equals(readFileSync(input.runtimeHostPath))) throw new Error('Production Runtime entry changed during macOS native observation');
|
|
371
|
+
return facts;
|
|
372
|
+
}
|
|
361
373
|
return observeProductionWindowsFacts(input, archivedRuntimeEntryBytes);
|
|
362
374
|
}
|
|
363
375
|
|
|
364
|
-
function validateNativeExecutionFacts(nativeTrust, executionProfile, label) {
|
|
376
|
+
function validateNativeExecutionFacts(nativeTrust, executionProfile, label, os) {
|
|
365
377
|
if (!nativeTrust || typeof nativeTrust !== 'object' || Array.isArray(nativeTrust)) {
|
|
366
378
|
throw new Error(`${label} native_trust must be an object`);
|
|
367
379
|
}
|
|
@@ -371,6 +383,13 @@ function validateNativeExecutionFacts(nativeTrust, executionProfile, label) {
|
|
|
371
383
|
}
|
|
372
384
|
return;
|
|
373
385
|
}
|
|
386
|
+
if (os === 'macos') {
|
|
387
|
+
if (!executionProfile || Object.keys(executionProfile).join(',') !== 'launch_mode' || executionProfile.launch_mode !== 'current-user') throw new Error(`${label} macOS execution_profile must use current-user launch`);
|
|
388
|
+
if (Object.keys(nativeTrust).sort().join(',') !== 'certificate_subject,macos_developer_id,macos_notarization,posture') throw new Error(`${label} macOS native_trust is inconsistent`);
|
|
389
|
+
if (nativeTrust.posture === 'production-unsigned' && nativeTrust.macos_developer_id === 'absent' && nativeTrust.macos_notarization === 'absent' && nativeTrust.certificate_subject === null) return;
|
|
390
|
+
if (nativeTrust.posture === 'observed-valid-native-signature' && nativeTrust.macos_developer_id === 'valid' && ['absent', 'notarized'].includes(nativeTrust.macos_notarization) && typeof nativeTrust.certificate_subject === 'string' && nativeTrust.certificate_subject.trim() === nativeTrust.certificate_subject && nativeTrust.certificate_subject) return;
|
|
391
|
+
throw new Error(`${label} macOS native_trust posture is inconsistent`);
|
|
392
|
+
}
|
|
374
393
|
if (
|
|
375
394
|
!executionProfile
|
|
376
395
|
|| typeof executionProfile !== 'object'
|
|
@@ -423,10 +442,12 @@ export function packAppTarget(cwd, options = {}) {
|
|
|
423
442
|
const targetId = String(options.target || '').trim();
|
|
424
443
|
if (!targetId) throw new Error('nimi-app pack requires --target');
|
|
425
444
|
const input = readPackInputs(targetDir, targetId);
|
|
426
|
-
const payloadEntries = collectPayload(input.payloadPath).map((entry) => {
|
|
445
|
+
const payloadEntries = collectPayload(input.payloadPath, input.target.os).map((entry) => {
|
|
427
446
|
const name = `payload/${entry.relative.replaceAll('\\', '/')}`;
|
|
447
|
+
if (name === input.runtimeEntry && entry.mode === SYMBOLIC_LINK_MODE) throw new Error('Runtime entry must be a direct regular file');
|
|
428
448
|
return { name, bytes: entry.bytes, mode: name === input.runtimeEntry ? 0o755 : entry.mode };
|
|
429
449
|
});
|
|
450
|
+
validatePayloadLinks(new Map(payloadEntries.map((entry) => [entry.name, entry])), input.target.os);
|
|
430
451
|
const runtimeEntry = payloadEntries.find((entry) => entry.name === input.runtimeEntry);
|
|
431
452
|
if (!runtimeEntry) throw new Error(`runtime_entry is missing from target payload: ${input.runtimeEntry}`);
|
|
432
453
|
const { nativeTrust, executionProfile } = resolveTargetFacts(input, options.production === true, runtimeEntry.bytes);
|
|
@@ -498,12 +519,13 @@ export function aggregateAppTargetCandidates(cwd, options = {}) {
|
|
|
498
519
|
}
|
|
499
520
|
const runtimeEntry = canonicalRelative(target.runtime_entry, `${metadataLabel}.runtime_entry`);
|
|
500
521
|
if (!runtimeEntry.startsWith('payload/')) throw new Error(`Target runtime_entry must resolve inside payload: ${runtimeEntry}`);
|
|
501
|
-
validateNativeExecutionFacts(target.native_trust, target.execution_profile, metadataLabel);
|
|
522
|
+
validateNativeExecutionFacts(target.native_trust, target.execution_profile, metadataLabel, target.os);
|
|
502
523
|
const artifactPath = path.join(outputDir, assetName);
|
|
503
524
|
if (!existsSync(artifactPath)) throw new Error(`Target artifact is missing: ${target.asset_name}`);
|
|
504
525
|
const bytes = readFileSync(artifactPath);
|
|
505
526
|
if (bytes.length !== target.size || createHash('sha256').update(bytes).digest('hex') !== target.sha256) throw new Error(`Target artifact changed after pack: ${target.asset_name}`);
|
|
506
527
|
const entries = readNimiAppArchive(bytes);
|
|
528
|
+
validatePayloadLinks(entries, target.os);
|
|
507
529
|
const manifest = readPackageManifestFromArchive(entries, metadataLabel);
|
|
508
530
|
if (manifest.format !== PACKAGE_FORMAT) throw new Error(`Target archive manifest format is invalid: ${target.asset_name}`);
|
|
509
531
|
for (const field of ['app_id', 'version', 'target_id', 'os', 'arch', 'runtime_entry', 'native_trust', 'execution_profile']) {
|
|
@@ -511,7 +533,7 @@ export function aggregateAppTargetCandidates(cwd, options = {}) {
|
|
|
511
533
|
throw new Error(`Target metadata does not match archive manifest ${field}: ${target.asset_name}`);
|
|
512
534
|
}
|
|
513
535
|
}
|
|
514
|
-
validateNativeExecutionFacts(manifest.native_trust, manifest.execution_profile, `${target.asset_name} archive manifest
|
|
536
|
+
validateNativeExecutionFacts(manifest.native_trust, manifest.execution_profile, `${target.asset_name} archive manifest`, target.os);
|
|
515
537
|
const runtimeEntryArchive = entries.get(runtimeEntry);
|
|
516
538
|
if (!runtimeEntryArchive || runtimeEntryArchive.mode !== 0o755) {
|
|
517
539
|
throw new Error(`Target archive runtime_entry is missing or non-executable: ${runtimeEntry}`);
|
|
@@ -46,6 +46,7 @@ const SUBMISSION_PATH = '.nimi/admission/submission.yaml';
|
|
|
46
46
|
const SEMVER_PATTERN = /^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/u;
|
|
47
47
|
const CURRENT_APP_TARGETS = Object.freeze({
|
|
48
48
|
'windows-x86_64': Object.freeze({ os: 'windows', arch: 'x86_64' }),
|
|
49
|
+
'macos-aarch64': Object.freeze({ os: 'macos', arch: 'arm64' }),
|
|
49
50
|
});
|
|
50
51
|
|
|
51
52
|
function resolveTargetDir(cwd, options = {}) {
|
|
@@ -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:',
|
|
@@ -1027,6 +1027,13 @@ export function renderAppBuildProfile(options = {}) {
|
|
|
1027
1027
|
payload_path: `dist-electron-package/${identity.cargoPackageName}-win32-x64`,
|
|
1028
1028
|
runtime_entry: `payload/${identity.cargoPackageName}.exe`,
|
|
1029
1029
|
},
|
|
1030
|
+
'macos-aarch64': {
|
|
1031
|
+
os: 'macos',
|
|
1032
|
+
arch: 'arm64',
|
|
1033
|
+
build_command: 'pnpm run build:electron:production',
|
|
1034
|
+
payload_path: `dist-electron-package/${identity.cargoPackageName}-darwin-arm64`,
|
|
1035
|
+
runtime_entry: `payload/${identity.cargoPackageName}.app/Contents/MacOS/${identity.cargoPackageName}`,
|
|
1036
|
+
},
|
|
1030
1037
|
} : undefined);
|
|
1031
1038
|
return YAML.stringify({
|
|
1032
1039
|
build_profile_ref: 'electron-packager-pnpm-vite',
|
|
@@ -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.3.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.3.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",
|
|
@@ -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;
|