@nimiplatform/app-tools 0.16.0-rc.12 → 0.16.0-rc.13

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.
@@ -1,6 +1,6 @@
1
1
  import { isAppId } from './app-identifiers.mjs';
2
2
  import { WEB_BASE_TEMPLATE_PATHS, webDevelopmentInput, webBuildProfile, webPackage, webDependencyMatrix } from './web-scaffold.mjs';
3
- import { resolveWebAppScaffoldFeatures } from './app-scaffold-capabilities.mjs';
3
+ import { resolveDesktopAppScaffoldFeatures, resolveWebAppScaffoldFeatures } from './app-scaffold-capabilities.mjs';
4
4
  import path from 'node:path';
5
5
  import { createHash } from 'node:crypto';
6
6
  import YAML from 'yaml';
@@ -29,7 +29,7 @@ export { SUPPORTED_APP_SCAFFOLD_PROFILES };
29
29
  const DEFAULT_APP_ID = 'my.nimi-app';
30
30
  const DEFAULT_APP_TITLE = 'My Nimi App';
31
31
  const DEFAULT_APP_VERSION = '0.1.0';
32
- 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;
32
+ const SEMVER_PATTERN = /^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u;
33
33
  export const SCAFFOLD_INTENT_VERSION = 4;
34
34
  export const SCAFFOLD_LOCK_VERSION = 4;
35
35
  export const SCAFFOLD_VERSION = '2026-10-13.standard-app-navigation-v1';
@@ -172,7 +172,7 @@ const APP_RELEASE_WORKFLOW = [
172
172
  ' id: matrix',
173
173
  ' shell: bash',
174
174
  ' run: |',
175
- " 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)",
175
+ " matrix=$(jq -c '{include: [.targets[] | {target: ., runner: (if . == \"desktop-universal\" then \"ubuntu-latest\" elif . == \"windows-x86_64\" then \"windows-latest\" elif . == \"macos-aarch64\" then \"macos-15\" else error(\"unsupported target\") end)}]}' .nimi-targets.json)",
176
176
  ' test "$(jq \'.include | length\' <<<"$matrix")" -gt 0',
177
177
  ' echo "matrix=$matrix" >> "$GITHUB_OUTPUT"',
178
178
  ' build-target:',
@@ -521,6 +521,23 @@ function deriveScaffoldDevPort(appId) {
521
521
  return 1430 + hash;
522
522
  }
523
523
 
524
+ export const SUPPORTED_DESKTOP_CARRIERS = Object.freeze(['managed-web', 'native']);
525
+
526
+ function resolveDesktopCarrier(platform, carrier) {
527
+ const normalized = String(carrier || '').trim();
528
+ if (platform === 'web') {
529
+ if (normalized) {
530
+ throw new Error('--carrier is available only for desktop Apps');
531
+ }
532
+ return undefined;
533
+ }
534
+ const selected = normalized || 'managed-web';
535
+ if (!SUPPORTED_DESKTOP_CARRIERS.includes(selected)) {
536
+ throw new Error(`Unsupported desktop App carrier: ${selected} (expected managed-web or native)`);
537
+ }
538
+ return selected;
539
+ }
540
+
524
541
  function buildAppIdentity(
525
542
  profile,
526
543
  appId,
@@ -532,14 +549,19 @@ function buildAppIdentity(
532
549
  features = undefined,
533
550
  featureResolver = resolveAppScaffoldFeatures,
534
551
  platform = 'desktop',
552
+ carrier = undefined,
535
553
  ) {
536
554
  const resolvedPackageName = packageName || packageSafeName(appId);
537
555
  if (!['desktop', 'web'].includes(platform)) throw new Error(`Unsupported App platform: ${platform}`);
538
- const capabilityResolution = platform === 'web' ? resolveWebAppScaffoldFeatures(features, featureResolver) : featureResolver(features);
556
+ const desktopCarrier = resolveDesktopCarrier(platform, carrier);
557
+ const capabilityResolution = platform === 'web'
558
+ ? resolveWebAppScaffoldFeatures(features, featureResolver)
559
+ : resolveDesktopAppScaffoldFeatures(features, desktopCarrier, featureResolver);
539
560
  const identity = {
540
561
  appId,
541
562
  appTitle,
542
563
  platform,
564
+ ...(desktopCarrier ? { carrier: desktopCarrier } : {}),
543
565
  version: normalizeAppVersion(version),
544
566
  profile,
545
567
  packageName: resolvedPackageName,
@@ -573,6 +595,8 @@ function resolveAppScaffoldCreateInputWithResolver(
573
595
  featureResolver,
574
596
  ) {
575
597
  const profile = resolveProfile(options);
598
+ const platform = options.platform || 'desktop';
599
+ const carrier = resolveDesktopCarrier(platform, options.carrier);
576
600
  const appId = resolveAppId(options);
577
601
  const appTitle = normalizeDisplayName(options.title || options.name || DEFAULT_APP_TITLE);
578
602
  const version = normalizeAppVersion(options.version);
@@ -589,10 +613,12 @@ function resolveAppScaffoldCreateInputWithResolver(
589
613
  options.accentPack,
590
614
  options.features,
591
615
  featureResolver,
592
- options.platform || 'desktop',
616
+ platform,
617
+ carrier,
593
618
  );
594
619
  return Object.freeze({
595
620
  ...(identity.platform === 'web' ? { platform: 'web' } : {}),
621
+ ...(identity.carrier ? { carrier: identity.carrier } : {}),
596
622
  profile,
597
623
  appId,
598
624
  appTitle,
@@ -672,7 +698,31 @@ function buildPackageJson(profile, versions, identity) {
672
698
  if (identity.author) {
673
699
  packageJson.author = identity.author;
674
700
  }
675
- return identity.platform === 'web' ? webPackage(packageJson) : packageJson;
701
+ if (identity.platform === 'web') return webPackage(packageJson);
702
+ if (identity.carrier === 'managed-web') {
703
+ const { main: _main, ...managedPkg } = packageJson;
704
+ for (const name of ['@electron/packager', 'electron', 'esbuild', 'pngjs']) {
705
+ delete managedPkg.devDependencies[name];
706
+ }
707
+ managedPkg.pnpm = { onlyBuiltDependencies: ['esbuild', 'protobufjs'] };
708
+ managedPkg.scripts = {
709
+ dev: 'nimi-app dev --shell electron',
710
+ 'dev:renderer': `vite --host 127.0.0.1 --port ${identity.devPort} --strictPort`,
711
+ 'dev:shell': 'nimi-app dev',
712
+ init: 'nimi-app init',
713
+ sync: 'nimi-app sync',
714
+ check: 'nimi-app check',
715
+ test: 'nimi-app test',
716
+ 'test:app': 'node --test test/*.test.mjs',
717
+ 'app:build': 'nimi-app build',
718
+ pack: 'nimi-app pack',
719
+ typecheck: 'tsc --noEmit',
720
+ build: 'tsc --noEmit && vite build',
721
+ validate: 'node scripts/validate.mjs',
722
+ };
723
+ return managedPkg;
724
+ }
725
+ return packageJson;
676
726
  }
677
727
 
678
728
  function buildRuntimeDependencies(profile, versions, capabilityResolution) {
@@ -813,6 +863,13 @@ function buildNimiAppManifest(identity) {
813
863
  capability_contract_refs: identity.capabilityResolution.capabilityContractRefs,
814
864
  required_standardized_feature_refs: identity.capabilityResolution.requiredStandardizedFeatureRefs,
815
865
  storage_policy: { kind: 'nimi-mediated-default' },
866
+ ...(identity.platform !== 'web' && identity.carrier === 'managed-web' ? {
867
+ desktop: {
868
+ window: {
869
+ title_bar_style: 'hidden',
870
+ },
871
+ },
872
+ } : {}),
816
873
  metadata: {
817
874
  summary: '',
818
875
  icon: 'assets/app-icon.png',
@@ -858,7 +915,187 @@ function applyProfileSeam(relativePath, content, profile, identity) {
858
915
  return buildNimiAppManifest(identity);
859
916
  }
860
917
  if (relativePath === 'README.md') {
861
- return content.replace(/Profile: `standalone`/, `Profile: \`${profile}\``);
918
+ return content
919
+ .replace(/Profile: `standalone`/, `Profile: \`${profile}\``)
920
+ .replace(/<!-- carrier: (native|managed-web) -->\r?\n([\s\S]*?)<!-- end carrier -->\r?\n/gu,
921
+ (_, carrier, section) => carrier === identity.carrier ? section : '');
922
+ }
923
+ if (identity.carrier === 'managed-web' && relativePath === 'src/capabilities/agent-center/index.tsx') {
924
+ return [
925
+ "import type { ComponentProps } from 'react';",
926
+ "import { AppAgentCenterEntry } from '@nimiplatform/kit/features/agent-center';",
927
+ '',
928
+ '// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-019c',
929
+ '// @nimi-authority: rule.nimi.platform.app-ecosystem.p-agid-014a',
930
+ "export function AgentCenterCapability(props: { readonly client: ComponentProps<typeof AppAgentCenterEntry>['client'] }) {",
931
+ ' return (',
932
+ ' <AppAgentCenterEntry',
933
+ ' client={props.client}',
934
+ ' hostMechanics={null}',
935
+ " language={globalThis.document?.documentElement.lang || 'en'}",
936
+ ' />',
937
+ ' );',
938
+ '}',
939
+ '',
940
+ ].join('\n');
941
+ }
942
+ if (identity.carrier === 'managed-web' && relativePath === 'src/capabilities/agent-conversation/index.tsx') {
943
+ return [
944
+ "import { useEffect, useMemo, useRef, useState } from 'react';",
945
+ "import { ArrowLeft, ChevronRight, MessagesSquare } from 'lucide-react';",
946
+ "import { Avatar, Button, InlineAlert, LoadingSkeleton, Surface } from '@nimiplatform/kit/ui';",
947
+ 'import {',
948
+ ' APP_CONVERSATION_ENTRY_COPY,',
949
+ ' CanonicalComposer,',
950
+ ' CanonicalTranscriptView,',
951
+ ' createAppConversationEntrySession,',
952
+ ' createBrowserAppConversationHostPort,',
953
+ ' type AppConversationEntryClient,',
954
+ ' type AppConversationEntrySession,',
955
+ ' type AppConversationEntryState,',
956
+ "} from '@nimiplatform/kit/features/chat';",
957
+ '',
958
+ '// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-019c',
959
+ '// @nimi-authority: rule.nimi.runtime.agent-participation.r093',
960
+ '// Managed-web carrier keeps text conversation and omits microphone recording.',
961
+ 'export function AgentConversationCapability(props: { readonly client: AppConversationEntryClient }) {',
962
+ " const language = globalThis.document?.documentElement.lang || 'en';",
963
+ " const copy = useMemo(() => (language.trim().toLowerCase().startsWith('zh') ? APP_CONVERSATION_ENTRY_COPY.zh : APP_CONVERSATION_ENTRY_COPY.en), [language]);",
964
+ ' const hostPort = useMemo(() => createBrowserAppConversationHostPort(), []);',
965
+ ' const sessionRef = useRef<AppConversationEntrySession | null>(null);',
966
+ ' const [state, setState] = useState<AppConversationEntryState | null>(null);',
967
+ " const [composerText, setComposerText] = useState('');",
968
+ '',
969
+ ' useEffect(() => {',
970
+ ' const session = createAppConversationEntrySession({ client: props.client, hostPort });',
971
+ ' sessionRef.current = session;',
972
+ ' const unobserve = session.observe(setState);',
973
+ ' void session.loadReferences();',
974
+ ' return () => {',
975
+ ' unobserve();',
976
+ ' if (sessionRef.current === session) sessionRef.current = null;',
977
+ ' void session.dispose();',
978
+ ' };',
979
+ ' }, [props.client, hostPort]);',
980
+ '',
981
+ ' useEffect(() => {',
982
+ " setComposerText('');",
983
+ ' }, [state?.conversationAnchorId]);',
984
+ '',
985
+ ' const composerAdapter = useMemo(() => ({',
986
+ ' submit: async ({ text }: { text: string; attachments: readonly never[] }) => {',
987
+ ' const session = sessionRef.current;',
988
+ ' if (!session || !text.trim()) return;',
989
+ ' const requestId = `send_${globalThis.crypto?.randomUUID?.() ?? Date.now()}`;',
990
+ " await session.send({ requestId, parts: [{ kind: 'text', text }] });",
991
+ ' if (sessionRef.current !== session) return;',
992
+ " setComposerText((current) => (current === text ? '' : current));",
993
+ ' },',
994
+ ' }), []);',
995
+ '',
996
+ " if (!state || state.status === 'idle' || state.status === 'loading-references' || state.status === 'opening' || state.status === 'failed' || state.status === 'stale') {",
997
+ " const opening = state?.status === 'opening';",
998
+ ' return (',
999
+ ' <Surface tone="panel" className="space-y-3 p-4" data-nimi-app-conversation-entry="true">',
1000
+ ' <h1 className="m-0 text-2xl font-semibold tracking-tight">{copy.title}</h1>',
1001
+ " {!state || state.status === 'idle' || state.status === 'loading-references' || opening ? (",
1002
+ ' <LoadingSkeleton lines={2} label={opening ? copy.opening : copy.loadingReferences} />',
1003
+ ' ) : null}',
1004
+ ' {state?.error ? <InlineAlert tone="warning">{state.error}</InlineAlert> : null}',
1005
+ " {state && (state.status === 'failed' || state.status === 'stale') ? (",
1006
+ ' <Button size="sm" tone="secondary" onClick={() => { void sessionRef.current?.loadReferences(); }}>',
1007
+ ' {state.selectedReference ? copy.reload : copy.retry}',
1008
+ ' </Button>',
1009
+ ' ) : null}',
1010
+ ' </Surface>',
1011
+ ' );',
1012
+ ' }',
1013
+ '',
1014
+ " if (state.status === 'select-reference') {",
1015
+ ' return (',
1016
+ ' <Surface tone="panel" className="space-y-4 p-4" data-nimi-app-conversation-entry="true">',
1017
+ ' <header className="flex items-start gap-3">',
1018
+ ' <span className="grid size-10 shrink-0 place-items-center rounded-xl bg-[var(--nimi-surface-active)] text-[var(--nimi-action-primary-bg)]">',
1019
+ ' <MessagesSquare className="size-5" aria-hidden="true" />',
1020
+ ' </span>',
1021
+ ' <div className="min-w-0">',
1022
+ ' <h1 className="m-0 text-2xl font-semibold tracking-tight">{copy.title}</h1>',
1023
+ ' <p className="m-0 mt-1 text-sm text-[var(--nimi-text-secondary)]">{copy.description}</p>',
1024
+ ' </div>',
1025
+ ' </header>',
1026
+ ' {state.references.length === 0 ? (',
1027
+ ' <InlineAlert tone="warning">{copy.empty}</InlineAlert>',
1028
+ ' ) : (',
1029
+ ' <div className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,13rem),1fr))] gap-2" data-nimi-app-conversation-selector="true">',
1030
+ ' {state.references.map((reference) => (',
1031
+ ' <Button',
1032
+ ' key={reference.agentHandle}',
1033
+ ' tone="secondary"',
1034
+ ' aria-label={`${reference.displayName} · ${copy.select}`}',
1035
+ ' className="min-h-14 min-w-0 justify-start px-3 text-left [&>span]:w-full [&>span]:justify-start"',
1036
+ ' onClick={() => { void sessionRef.current?.selectReference(reference.agentHandle); }}',
1037
+ ' >',
1038
+ ' <Avatar size="md" src={reference.avatarUrl || undefined} alt="" fallback={reference.displayName.slice(0, 1)} />',
1039
+ ' <span className="min-w-0 flex-1 truncate">{reference.displayName}</span>',
1040
+ ' <ChevronRight className="size-4 shrink-0 opacity-60" aria-hidden="true" />',
1041
+ ' </Button>',
1042
+ ' ))}',
1043
+ ' </div>',
1044
+ ' )}',
1045
+ ' </Surface>',
1046
+ ' );',
1047
+ ' }',
1048
+ '',
1049
+ " if (state.status !== 'ready' || !state.selectedReference || !state.conversationAnchorId) {",
1050
+ ' return null;',
1051
+ ' }',
1052
+ '',
1053
+ ' const reference = state.selectedReference;',
1054
+ ' return (',
1055
+ ' <div className="h-full min-h-[28rem]" data-nimi-app-conversation-entry="true">',
1056
+ ' <Surface tone="panel" className="flex h-full min-h-[inherit] min-w-0 flex-col overflow-hidden">',
1057
+ ' <header className="flex shrink-0 items-center justify-between gap-3 border-b border-[var(--nimi-border-subtle)] px-4 py-3">',
1058
+ ' <div className="flex min-w-0 items-center gap-3">',
1059
+ ' <Button size="sm" tone="ghost" onClick={() => { void sessionRef.current?.clearSelection(); }}>',
1060
+ ' <ArrowLeft className="size-4" aria-hidden="true" />{copy.back}',
1061
+ ' </Button>',
1062
+ ' <Avatar size="md" src={reference.avatarUrl || undefined} alt="" fallback={reference.displayName.slice(0, 1)} />',
1063
+ ' <h1 className="m-0 min-w-0 text-base font-semibold break-words">{reference.displayName}</h1>',
1064
+ ' </div>',
1065
+ ' </header>',
1066
+ ' {state.actionError ? <div className="px-4 py-2"><InlineAlert tone="warning">{state.actionError}</InlineAlert></div> : null}',
1067
+ ' <CanonicalTranscriptView',
1068
+ ' messages={state.messages}',
1069
+ ' copy={copy.chatCopy}',
1070
+ ' activeConversationId={state.conversationAnchorId}',
1071
+ ' agentAvatarUrl={reference.avatarUrl}',
1072
+ ' agentName={reference.displayName}',
1073
+ ' pendingFirstBeat={state.activeTurnId !== null}',
1074
+ ' emptyEyebrow={copy.transcriptEmptyEyebrow}',
1075
+ ' emptyTitle={copy.transcriptEmptyTitle}',
1076
+ ' emptyDescription={copy.transcriptEmptyDescription}',
1077
+ ' pendingStopLabel={copy.stopTurn}',
1078
+ ' onStopGenerating={() => { void sessionRef.current?.interrupt().catch(() => {}); }}',
1079
+ ' widthClassName="w-full max-w-[52rem]"',
1080
+ ' contentPaddingBottomClassName="pb-4"',
1081
+ ' />',
1082
+ ' <div className="shrink-0 border-t border-[var(--nimi-border-subtle)]">',
1083
+ ' <CanonicalComposer',
1084
+ ' adapter={composerAdapter}',
1085
+ ' text={composerText}',
1086
+ ' onTextChange={setComposerText}',
1087
+ ' placeholder={copy.composerPlaceholder}',
1088
+ ' sendLabel={copy.send}',
1089
+ ' widthClassName="w-full max-w-[52rem]"',
1090
+ ' layout="stacked"',
1091
+ ' />',
1092
+ ' </div>',
1093
+ ' </Surface>',
1094
+ ' </div>',
1095
+ ' );',
1096
+ '}',
1097
+ '',
1098
+ ].join('\n');
862
1099
  }
863
1100
  return content;
864
1101
  }
@@ -951,6 +1188,28 @@ export function renderAppIdentityInput(identity) {
951
1188
  export function renderAppBuildProfile(options = {}) {
952
1189
  const identity = options.identity || null;
953
1190
  if (identity?.platform === 'web') return YAML.stringify(webBuildProfile(), { lineWidth: 0 });
1191
+ if (identity?.carrier === 'managed-web') {
1192
+ const targets = options.targets || {
1193
+ 'desktop-universal': {
1194
+ os: 'any',
1195
+ arch: 'any',
1196
+ build_command: 'pnpm run build',
1197
+ payload_path: 'dist/renderer',
1198
+ runtime_entry: 'payload/index.html',
1199
+ },
1200
+ };
1201
+ return YAML.stringify({
1202
+ build_profile_ref: 'managed-web-pnpm-vite',
1203
+ test_command: options.testCommand || 'pnpm run test:app',
1204
+ build_command: options.buildCommand || 'pnpm run build',
1205
+ output_path: 'dist/renderer',
1206
+ lockfile_path: 'pnpm-lock.yaml',
1207
+ lockfile_policy: LOCKFILE_POLICY,
1208
+ ci_install_command: 'pnpm install --frozen-lockfile',
1209
+ targets,
1210
+ profile_role: 'developer-workflow-input',
1211
+ }, { lineWidth: 0 });
1212
+ }
954
1213
  const targets = options.targets || (identity ? {
955
1214
  'windows-x86_64': {
956
1215
  os: 'windows',
@@ -1141,6 +1400,7 @@ function buildScaffoldIntent(identity, versions, targetDir = '') {
1141
1400
  initOrder: ['nimi-app create', 'pnpm install', 'pnpm exec nimi-app init'],
1142
1401
  profile: identity.profile,
1143
1402
  ...(identity.platform === 'web' ? { platform: 'web' } : {}),
1403
+ ...(identity.carrier === 'managed-web' ? { carrier: 'managed-web' } : {}),
1144
1404
  appId: identity.appId,
1145
1405
  appTitle: identity.appTitle,
1146
1406
  version: identity.version,
@@ -1162,7 +1422,7 @@ function buildScaffoldIntent(identity, versions, targetDir = '') {
1162
1422
  requiredStandardizedFeatureRefs: identity.capabilityResolution.requiredStandardizedFeatureRefs,
1163
1423
  devPort: identity.devPort,
1164
1424
  appIdentity: buildIdentityMapping(identity, targetDir),
1165
- dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution, identity.platform),
1425
+ dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution, identity.platform, identity.carrier),
1166
1426
  semantics: {
1167
1427
  role: 'app-scaffold-init-input',
1168
1428
  authority: 'app-tools-orchestration-input-not-platform-admission',
@@ -1258,7 +1518,7 @@ export function hashScaffoldContent(content) {
1258
1518
  return createHash('sha256').update(content).digest('hex');
1259
1519
  }
1260
1520
 
1261
- function buildDependencyMatrix(profile, versions, capabilityResolution, platform = 'desktop') {
1521
+ function buildDependencyMatrix(profile, versions, capabilityResolution, platform = 'desktop', carrier = 'native') {
1262
1522
  const matrix = {
1263
1523
  npm: {
1264
1524
  '@nimiplatform/app-tools': versions.appToolsVersion,
@@ -1280,7 +1540,13 @@ function buildDependencyMatrix(profile, versions, capabilityResolution, platform
1280
1540
  pnpm: versions.packageManager.replace(/^pnpm@/u, ''),
1281
1541
  },
1282
1542
  };
1283
- return platform === 'web' ? webDependencyMatrix(matrix) : matrix;
1543
+ if (platform === 'web') return webDependencyMatrix(matrix);
1544
+ if (carrier === 'managed-web') {
1545
+ for (const name of ['@electron/packager', 'electron', 'esbuild', 'pngjs']) {
1546
+ delete matrix.npm[name];
1547
+ }
1548
+ }
1549
+ return matrix;
1284
1550
  }
1285
1551
 
1286
1552
  function buildScaffoldLock(identity, versions, files, targetDir = '') {
@@ -1314,6 +1580,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
1314
1580
  scaffoldVersion: SCAFFOLD_VERSION,
1315
1581
  profile: identity.profile,
1316
1582
  ...(identity.platform === 'web' ? { platform: 'web' } : {}),
1583
+ ...(identity.carrier === 'managed-web' ? { carrier: 'managed-web' } : {}),
1317
1584
  appId: identity.appId,
1318
1585
  appTitle: identity.appTitle,
1319
1586
  version: identity.version,
@@ -1341,7 +1608,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
1341
1608
  },
1342
1609
  managedFileHashes,
1343
1610
  appOwnedInitialHashes,
1344
- dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution, identity.platform),
1611
+ dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution, identity.platform, identity.carrier),
1345
1612
  semantics: {
1346
1613
  initRole: 'developer-scaffold-initialization-after-install',
1347
1614
  nimicodingProjectionOwner: '@nimiplatform/nimi-coding',
@@ -1356,7 +1623,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
1356
1623
  }
1357
1624
 
1358
1625
  function buildAppScaffoldSnapshotWithResolver(
1359
- { profile, platform = 'desktop', versions, appId, appTitle, version = DEFAULT_APP_VERSION, packageName, author, accentPack, features, targetDir = '' },
1626
+ { profile, platform = 'desktop', carrier = undefined, versions, appId, appTitle, version = DEFAULT_APP_VERSION, packageName, author, accentPack, features, targetDir = '' },
1360
1627
  featureResolver,
1361
1628
  ) {
1362
1629
  const identity = buildAppIdentity(
@@ -1370,6 +1637,7 @@ function buildAppScaffoldSnapshotWithResolver(
1370
1637
  features,
1371
1638
  featureResolver,
1372
1639
  platform,
1640
+ carrier,
1373
1641
  );
1374
1642
  const createFiles = [
1375
1643
  ...buildScaffoldFiles(identity, versions),
@@ -1400,6 +1668,7 @@ function buildAppScaffoldSnapshotWithResolver(
1400
1668
  version: identity.version,
1401
1669
  profile: identity.profile,
1402
1670
  ...(identity.platform === 'web' ? { platform: 'web' } : {}),
1671
+ ...(identity.carrier ? { carrier: identity.carrier } : {}),
1403
1672
  packageName: identity.packageName,
1404
1673
  packageAuthor: identity.author || null,
1405
1674
  cargoPackageName: identity.cargoPackageName,
@@ -1433,9 +1702,12 @@ export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir
1433
1702
  throw new Error(`Unsupported scaffold profile: ${String(intent?.profile || 'missing')}`);
1434
1703
  }
1435
1704
  const canonicalTargetDir = targetDir || intent?.appIdentity?.targetDir || '';
1705
+ const platform = intent.platform || 'desktop';
1706
+ const carrier = platform === 'web' ? undefined : (intent.carrier || 'native');
1436
1707
  const snapshot = buildAppScaffoldSnapshotWithResolver({
1437
1708
  profile: intent.profile,
1438
- platform: intent.platform || 'desktop',
1709
+ platform,
1710
+ carrier,
1439
1711
  versions,
1440
1712
  appId: intent.appId,
1441
1713
  appTitle: intent.appTitle,
@@ -1448,7 +1720,7 @@ export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir
1448
1720
  }, resolveAppScaffoldIntentFeatures);
1449
1721
  const expectedIntent = JSON.parse(snapshot.filesByPath.get(SCAFFOLD_INTENT_PATH).content);
1450
1722
  // @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-018c
1451
- const immutableInputs = new Set(['intentVersion', 'scaffoldVersion', 'initRequired', 'initCommand', 'initOrder', 'profile', 'platform', 'appId', 'appTitle', 'version', 'packageName', 'packageAuthor', 'cargoPackageName', 'tauriIdentifier', 'accentPack', 'directFeatures', 'devPort', 'semantics']);
1723
+ const immutableInputs = new Set(['intentVersion', 'scaffoldVersion', 'initRequired', 'initCommand', 'initOrder', 'profile', 'platform', 'carrier', 'appId', 'appTitle', 'version', 'packageName', 'packageAuthor', 'cargoPackageName', 'tauriIdentifier', 'accentPack', 'directFeatures', 'devPort', 'semantics']);
1452
1724
  if (canonicalJson(Object.keys(intent).sort()) !== canonicalJson(Object.keys(expectedIntent).sort())) {
1453
1725
  throw new Error('Scaffold intent fields do not match the current canonical resolved intent');
1454
1726
  }
@@ -1482,6 +1754,7 @@ function buildAppScaffoldCreatePlanWithResolver(
1482
1754
  const snapshot = buildAppScaffoldSnapshotWithResolver({
1483
1755
  profile: resolvedInput.profile,
1484
1756
  platform: resolvedInput.platform || 'desktop',
1757
+ carrier: resolvedInput.carrier,
1485
1758
  versions,
1486
1759
  appId: resolvedInput.appId,
1487
1760
  appTitle: resolvedInput.appTitle,
@@ -1498,6 +1771,7 @@ function buildAppScaffoldCreatePlanWithResolver(
1498
1771
  preview: Object.freeze({
1499
1772
  targetDir: resolvedInput.targetDir,
1500
1773
  profile: resolvedInput.profile,
1774
+ ...(resolvedInput.carrier ? { carrier: resolvedInput.carrier } : {}),
1501
1775
  identity: snapshot.lock.appIdentity,
1502
1776
  directFeatures: snapshot.lock.directFeatures,
1503
1777
  resolvedModules: snapshot.lock.resolvedModules,
@@ -1558,7 +1832,7 @@ export function createAppScaffoldCandidate(input) {
1558
1832
  return createAppScaffold({ ...input, plan });
1559
1833
  }
1560
1834
 
1561
- export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['metadata', 'app_access', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', 'safety_profile', 'public_slug']);
1835
+ export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['desktop', 'metadata', 'app_access', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', 'safety_profile', 'public_slug']);
1562
1836
 
1563
1837
  // Source configuration is editable; existing scaffold checks still cover identity and carrier fields.
1564
1838
  export function hashScaffoldManagedContent(relativePath, content) {
@@ -0,0 +1,106 @@
1
+ import { parseDocument as parseYamlDocument, isMap, isScalar } from 'yaml';
2
+
3
+ // @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-014a
4
+
5
+ export const DESKTOP_WINDOW_DEFAULTS = Object.freeze({
6
+ width: 1280,
7
+ height: 840,
8
+ min_width: 480,
9
+ min_height: 420,
10
+ title_bar_style: 'native',
11
+ });
12
+
13
+ const DESKTOP_WINDOW_BOUNDS = Object.freeze({
14
+ width: Object.freeze([400, 2560]),
15
+ height: Object.freeze([360, 1600]),
16
+ min_width: Object.freeze([320, 1280]),
17
+ min_height: Object.freeze([320, 960]),
18
+ });
19
+
20
+ const ALLOWED_DESKTOP_KEYS = new Set(['window']);
21
+ const ALLOWED_WINDOW_KEYS = new Set(['width', 'height', 'min_width', 'min_height', 'title_bar_style']);
22
+ const ALLOWED_TITLE_BAR_STYLES = new Set(['native', 'hidden']);
23
+
24
+ function isPlainObject(value) {
25
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
26
+ }
27
+
28
+ function assertDesktopWindowYamlIntegerNodes(yamlText, label) {
29
+ const doc = parseYamlDocument(yamlText, { keepSourceTokens: true });
30
+ if (!isMap(doc.contents)) return;
31
+ const desktopNode = doc.contents.get('desktop', true);
32
+ if (!isMap(desktopNode)) return;
33
+ const windowNode = desktopNode.get('window', true);
34
+ if (!isMap(windowNode)) return;
35
+ for (const pair of windowNode.items) {
36
+ const key = isScalar(pair.key) ? String(pair.key.value) : '';
37
+ if (!['width', 'height', 'min_width', 'min_height'].includes(key)) continue;
38
+ if (!isScalar(pair.value) || typeof pair.value.value !== 'number') {
39
+ throw new Error(`${label}.window.${key} must be a base-10 YAML integer`);
40
+ }
41
+ const rawSource = typeof pair.value.srcToken?.source === 'string'
42
+ ? pair.value.srcToken.source.trim()
43
+ : String(pair.value.value);
44
+ if (!/^[0-9]+$/u.test(rawSource)) {
45
+ throw new Error(`${label}.window.${key} must be a base-10 YAML integer`);
46
+ }
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Validates optional `desktop` declaration (`desktop.window`) with closed keys
52
+ * and exact geometry bounds matching Runtime (`managed_web.go`) and Desktop
53
+ * (`managed-web-snapshot.ts`). Returns `undefined` when omitted, or a clean
54
+ * normalized object preserving only declared keys.
55
+ */
56
+ export function validateManifestDesktop(desktop, label = 'nimi.app.yaml desktop', yamlText = null) {
57
+ if (desktop === undefined) return undefined;
58
+ if (typeof yamlText === 'string') {
59
+ assertDesktopWindowYamlIntegerNodes(yamlText, label);
60
+ }
61
+ if (!isPlainObject(desktop)) {
62
+ throw new Error(`${label} must be a mapping`);
63
+ }
64
+ for (const key of Object.keys(desktop)) {
65
+ if (!ALLOWED_DESKTOP_KEYS.has(key)) {
66
+ throw new Error(`${label} contains unsupported field: ${key}`);
67
+ }
68
+ }
69
+ if (desktop.window === undefined) {
70
+ return {};
71
+ }
72
+ const rawWindow = desktop.window;
73
+ if (!isPlainObject(rawWindow)) {
74
+ throw new Error(`${label}.window must be a mapping`);
75
+ }
76
+ const normalizedWindow = {};
77
+ for (const key of Object.keys(rawWindow)) {
78
+ if (!ALLOWED_WINDOW_KEYS.has(key)) {
79
+ throw new Error(`${label}.window contains unsupported field: ${key}`);
80
+ }
81
+ const value = rawWindow[key];
82
+ if (key === 'title_bar_style') {
83
+ if (typeof value !== 'string' || !ALLOWED_TITLE_BAR_STYLES.has(value)) {
84
+ throw new Error(`${label}.window.title_bar_style must be "native" or "hidden"`);
85
+ }
86
+ normalizedWindow.title_bar_style = value;
87
+ continue;
88
+ }
89
+ const [min, max] = DESKTOP_WINDOW_BOUNDS[key];
90
+ if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < min || value > max) {
91
+ throw new Error(`${label}.window.${key} must be an integer between ${min} and ${max}`);
92
+ }
93
+ normalizedWindow[key] = value;
94
+ }
95
+ const effectiveWidth = normalizedWindow.width ?? DESKTOP_WINDOW_DEFAULTS.width;
96
+ const effectiveHeight = normalizedWindow.height ?? DESKTOP_WINDOW_DEFAULTS.height;
97
+ const effectiveMinWidth = normalizedWindow.min_width ?? DESKTOP_WINDOW_DEFAULTS.min_width;
98
+ const effectiveMinHeight = normalizedWindow.min_height ?? DESKTOP_WINDOW_DEFAULTS.min_height;
99
+ if (effectiveMinWidth > effectiveWidth) {
100
+ throw new Error(`${label}.window.min_width (${effectiveMinWidth}) must not exceed width (${effectiveWidth})`);
101
+ }
102
+ if (effectiveMinHeight > effectiveHeight) {
103
+ throw new Error(`${label}.window.min_height (${effectiveMinHeight}) must not exceed height (${effectiveHeight})`);
104
+ }
105
+ return { window: normalizedWindow };
106
+ }
package/lib/index.mjs CHANGED
@@ -133,6 +133,7 @@ export function createApp(cwd, options = {}) {
133
133
  dir: options.dir,
134
134
  profile: options.profile,
135
135
  platform: options.platform,
136
+ carrier: options.carrier,
136
137
  appId: options.appId,
137
138
  name: options.name,
138
139
  title: options.title,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimiplatform/app-tools",
3
- "version": "0.16.0-rc.12",
3
+ "version": "0.16.0-rc.13",
4
4
  "description": "Public app-authoring CLI for Nimi App projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "nimiScaffoldVersions": {
21
21
  "sdkVersion": "^0.24.0-rc.10",
22
- "appToolsVersion": "^0.16.0-rc.12",
22
+ "appToolsVersion": "^0.16.0-rc.13",
23
23
  "nimicodingVersion": "0.7.0",
24
24
  "aiSdkVersion": "^7.0.171",
25
25
  "kitVersion": "^0.24.0-rc.16",
@@ -68,7 +68,7 @@
68
68
  "prepublishOnly": "pnpm run build",
69
69
  "test": "node ../scripts/with-workspace-surfaces.mjs -- pnpm run test:prepared",
70
70
  "test:large-archive": "node --test test/app-pack-large.test.mjs",
71
- "test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-icons.test.mjs test/app-storefront.test.mjs test/app-dependency-combinations.test.mjs test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-pack-large.test.mjs test/app-scaffold.test.mjs test/web-carrier.test.mjs test/hosted-web-release.test.mjs test/mobile-development.test.mjs"
71
+ "test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-icons.test.mjs test/app-storefront.test.mjs test/app-dependency-combinations.test.mjs test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-pack-large.test.mjs test/app-scaffold.test.mjs test/managed-web-carrier.test.mjs test/web-carrier.test.mjs test/hosted-web-release.test.mjs test/mobile-development.test.mjs"
72
72
  },
73
73
  "files": [
74
74
  "bin",
@@ -46,7 +46,9 @@ export async function runDevShell(cwd, options = {}) {
46
46
  if (typeof fetchImpl !== 'function') {
47
47
  throw new DevShellError('local-development-launcher-unavailable', 'This Node.js runtime does not provide fetch.');
48
48
  }
49
- if (!options.listRegistrations) await assertProjectElectronRuntime(projectRoot);
49
+ if (!options.listRegistrations && !(await isManagedWebProject(projectRoot))) {
50
+ await assertProjectElectronRuntime(projectRoot);
51
+ }
50
52
  let registrationSelector = options.resume;
51
53
  if (options.listRegistrations || (!options.resume && !options.newRegistration)) {
52
54
  const listed = await postJson(fetchImpl, descriptor, '/v1/registrations', {
@@ -207,6 +209,16 @@ export async function assertProjectElectronRuntime(projectRoot, platform = proce
207
209
  }
208
210
  }
209
211
 
212
+ export async function isManagedWebProject(projectRoot) {
213
+ try {
214
+ const raw = await readFile(path.join(projectRoot, '.nimi', 'config', 'build-profile.yaml'), 'utf8');
215
+ const parsed = parseYaml(raw);
216
+ return parsed?.build_profile_ref === 'managed-web-pnpm-vite';
217
+ } catch {
218
+ return false;
219
+ }
220
+ }
221
+
210
222
  export class DevShellError extends Error {
211
223
  constructor(reasonCode, message) {
212
224
  super(message);