@native-sdk/cli 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/build/app.zig +331 -24
  2. package/build.zig +179 -11
  3. package/native-sdk.d.ts +8 -0
  4. package/package.json +10 -10
  5. package/packages/core/compile-surface/core.ts +70 -1
  6. package/packages/core/package-lock.json +11 -11
  7. package/packages/core/package.json +2 -2
  8. package/packages/core/scripts/merge_static_archives.mjs +78 -0
  9. package/packages/core/scripts/run_external_core_compiler.mjs +52 -7
  10. package/packages/core/scripts/run_external_service_compiler.mjs +53 -13
  11. package/packages/core/scripts/stage_external_services.mjs +1 -1
  12. package/packages/core/sdk/core.d.ts +75 -0
  13. package/packages/core/sdk/core.ts +167 -12
  14. package/packages/core/sdk/events.d.ts +53 -0
  15. package/packages/core/sdk/events.ts +78 -7
  16. package/packages/core/src/checker.ts +470 -2
  17. package/packages/core/src/cli.ts +13 -0
  18. package/packages/core/src/contract.ts +3 -1
  19. package/packages/core/src/devhost.ts +30 -1
  20. package/packages/core/src/devhost_journal.mjs +10 -8
  21. package/packages/core/src/diagnostics.ts +99 -8
  22. package/packages/core/src/frontend.ts +6 -0
  23. package/packages/core/src/infer.ts +24 -0
  24. package/skill-data/automation/SKILL.md +1 -1
  25. package/skill-data/native-ui/SKILL.md +11 -5
  26. package/skill-data/ts-core/SKILL.md +53 -20
  27. package/skill-data/ts-services/SKILL.md +4 -4
  28. package/skill-data/ts-services/references/service-surface.md +2 -1
  29. package/skill-data/zig/SKILL.md +1 -1
  30. package/src/app_runner/root.zig +29 -0
  31. package/src/app_runner/ts_core_main.zig +5 -0
  32. package/src/app_runner/ts_core_mobile.zig +241 -0
  33. package/src/automation/protocol.zig +5 -1
  34. package/src/automation/snapshot.zig +8 -6
  35. package/src/embed/app_exports.zig +1 -0
  36. package/src/embed/root.zig +1 -0
  37. package/src/embed/tests.zig +28 -0
  38. package/src/embed/ui_host.zig +68 -2
  39. package/src/platform/linux/cef_host.cpp +7 -1
  40. package/src/platform/linux/gtk_host.c +200 -5
  41. package/src/platform/linux/gtk_host.h +2 -1
  42. package/src/platform/linux/root.zig +69 -4
  43. package/src/platform/macos/appkit_host.h +11 -7
  44. package/src/platform/macos/appkit_host.m +210 -88
  45. package/src/platform/macos/cef_host.mm +210 -88
  46. package/src/platform/macos/root.zig +77 -30
  47. package/src/platform/null_platform.zig +234 -51
  48. package/src/platform/null_platform_tests.zig +39 -0
  49. package/src/platform/root.zig +10 -0
  50. package/src/platform/types.zig +105 -16
  51. package/src/platform/windows/root.zig +20 -6
  52. package/src/platform/windows/webview2_host.cpp +41 -5
  53. package/src/root.zig +7 -0
  54. package/src/runtime/api.zig +8 -0
  55. package/src/runtime/automation_commands.zig +35 -2
  56. package/src/runtime/automation_snapshot.zig +32 -24
  57. package/src/runtime/bridge_permission_tests.zig +35 -1
  58. package/src/runtime/bridge_responses.zig +1 -1
  59. package/src/runtime/builtin_bridge.zig +11 -1
  60. package/src/runtime/core.zig +12 -6
  61. package/src/runtime/effects.zig +1323 -35
  62. package/src/runtime/effects_file_tests.zig +587 -0
  63. package/src/runtime/effects_notification_tests.zig +11 -0
  64. package/src/runtime/file_access.zig +400 -0
  65. package/src/runtime/file_effect_crash_helper.zig +28 -0
  66. package/src/runtime/file_effect_crash_tests.zig +37 -0
  67. package/src/runtime/flow.zig +21 -9
  68. package/src/runtime/native_command_event_tests.zig +44 -2
  69. package/src/runtime/pty.zig +5 -2
  70. package/src/runtime/root.zig +5 -0
  71. package/src/runtime/session_blobs.zig +4 -1
  72. package/src/runtime/session_journal.zig +56 -5
  73. package/src/runtime/session_record.zig +38 -0
  74. package/src/runtime/session_replay.zig +97 -7
  75. package/src/runtime/session_tests.zig +81 -0
  76. package/src/runtime/state.zig +10 -0
  77. package/src/runtime/system_services.zig +129 -36
  78. package/src/runtime/ts_core_host.zig +281 -11
  79. package/src/runtime/ts_core_host_tests.zig +95 -1
  80. package/src/runtime/ts_ui_app.zig +461 -8
  81. package/src/runtime/ui_app.zig +321 -109
  82. package/src/runtime/ui_app_tests.zig +132 -6
  83. package/src/runtime/ui_app_window_tests.zig +61 -7
  84. package/src/runtime/validation.zig +20 -0
  85. package/src/tooling/templates.zig +28 -0
  86. package/src/tooling/ts_core.zig +83 -0
  87. package/tools/corewire/emit.zig +3 -3
  88. package/tools/corewire/emit_facade.zig +65 -5
  89. package/tools/corewire/emit_profile.zig +2 -2
  90. package/tools/corewire/emit_service.zig +2 -2
  91. package/tools/corewire/service_contract.zig +4 -4
  92. package/tools/corewire/sidecar.zig +4 -4
package/build.zig CHANGED
@@ -198,11 +198,42 @@ pub fn build(b: *std.Build) void {
198
198
  desktop_mod.addIncludePath(b.path("third_party/sqlite"));
199
199
  desktop_mod.addCSourceFile(.{
200
200
  .file = b.path("third_party/sqlite/sqlite3.c"),
201
- .flags = sqliteCompileFlags(),
201
+ // Mobile -Dtargets (the mobile e2e battery) compile the
202
+ // amalgamation against the platform SDK/NDK sysroot; desktop
203
+ // targets keep Zig's ordinary libc discovery.
204
+ .flags = if (target.result.os.tag == .ios or target.result.abi.isAndroid())
205
+ @import("build/app.zig").sqliteCFlags(b, target)
206
+ else
207
+ sqliteCompileFlags(),
202
208
  });
203
209
  desktop_mod.link_libc = true;
204
210
  const desktop_tests = testArtifact(b, desktop_mod);
205
211
  const desktop_test_shards = desktopTestShardArtifacts(b, desktop_mod);
212
+ // Tier-5 crash battery: a child uses the public streamed sink, signals
213
+ // after a chunk is durable only in the atomic temporary, then the parent
214
+ // kills it and verifies the destination still names the old generation.
215
+ const file_crash_helper_mod = module(b, target, optimize, "src/runtime/file_effect_crash_helper.zig");
216
+ file_crash_helper_mod.addImport("native_sdk", desktop_mod);
217
+ const file_crash_helper = b.addExecutable(.{ .name = "file-effect-crash-helper", .root_module = file_crash_helper_mod });
218
+ const file_crash_tests_mod = module(b, target, optimize, "src/runtime/file_effect_crash_tests.zig");
219
+ file_crash_tests_mod.addImport("native_sdk", desktop_mod);
220
+ const file_crash_options = b.addOptions();
221
+ file_crash_options.addOptionPath("helper_executable", file_crash_helper.getEmittedBin());
222
+ file_crash_tests_mod.addOptions("file_crash_options", file_crash_options);
223
+ const file_crash_tests = testArtifact(b, file_crash_tests_mod);
224
+ const file_crash_run = b.addRunArtifact(file_crash_tests);
225
+ const file_crash_step = b.step("test-file-effect-crash", "Kill a streamed writer before close and verify atomic destination visibility");
226
+ file_crash_step.dependOn(&file_crash_run.step);
227
+ const tier5_tests = filteredTestArtifact(b, desktop_mod, "storage-tier-5-tests", &.{
228
+ "runtime.effects_file_tests.test",
229
+ "runtime.file_access.test",
230
+ "runtime.session_record.test.recorder moves streamed file chunks",
231
+ "runtime.session_tests.test.a multi-megabyte file stream",
232
+ });
233
+ const tier5_run = b.addRunArtifact(tier5_tests);
234
+ const tier5_step = b.step("test-storage-tier-5", "Run file streaming, bounds, replay/blob, gating, and crash-atomicity batteries");
235
+ tier5_step.dependOn(&tier5_run.step);
236
+ tier5_step.dependOn(&file_crash_run.step);
206
237
 
207
238
  // SQLite is capability-shed from ordinary app artifacts. Its focused
208
239
  // engine/store suite gets a dedicated module that explicitly compiles the
@@ -564,6 +595,7 @@ pub fn build(b: *std.Build) void {
564
595
  test_step.dependOn(&b.addRunArtifact(app_runner_assets_tests).step);
565
596
  test_step.dependOn(&b.addRunArtifact(canvas_tests).step);
566
597
  test_step.dependOn(&b.addRunArtifact(record_store_tests).step);
598
+ test_step.dependOn(&file_crash_run.step);
567
599
  for (desktop_test_shards) |shard_tests| {
568
600
  test_step.dependOn(&b.addRunArtifact(shard_tests).step);
569
601
  }
@@ -591,7 +623,9 @@ pub fn build(b: *std.Build) void {
591
623
  // no build inputs/outputs to hash, so always run it.
592
624
  scaffold_ide_e2e_run.has_side_effects = true;
593
625
  const ai_chat_e2e_run = b.addRunArtifact(ts_core_artifacts.ai_chat);
626
+ const feed_reader_e2e_run = b.addRunArtifact(ts_core_artifacts.feed_reader);
594
627
  const services_e2e_run = b.addRunArtifact(ts_core_artifacts.services);
628
+ ts_services_e2e_step.dependOn(&feed_reader_e2e_run.step);
595
629
  ts_services_e2e_step.dependOn(&services_e2e_run.step);
596
630
  // The same fixture through the in-process carrier (ServicePool over
597
631
  // the linked service archive): parallel keys, per-key FIFO,
@@ -618,13 +652,15 @@ pub fn build(b: *std.Build) void {
618
652
  const sidecar_conformance_run = b.addRunArtifact(ts_core_artifacts.sidecar_conformance);
619
653
  const sidecar_conformance_step = b.step("sidecar-conformance", "Validate corewire-generated mirrors over every fixture's frontend-emitted contract (requires node)");
620
654
  sidecar_conformance_step.dependOn(&sidecar_conformance_run.step);
621
- // ABI-law suite over a real compiled core: the markup fixture's
622
- // archive driven directly through the C ABI (collect invariant,
623
- // deterministic re-init, channel envelopes, integer classes).
655
+ // ABI-law suites over real compiled cores: the broad markup fixture
656
+ // plus the focused mixed bare-Model/[Model, Cmd] return regression.
624
657
  const abi_laws_run = b.addRunArtifact(ts_core_artifacts.external_core_abi_laws);
625
- const abi_laws_step = b.step("test-external-core-abi", "Run the compiled-core ABI-law suite over the markup fixture's archive (requires node and `npm ci` in packages/core)");
658
+ const mixed_return_abi_run = b.addRunArtifact(ts_core_artifacts.mixed_return_abi_laws);
659
+ const abi_laws_step = b.step("test-external-core-abi", "Run the compiled-core ABI-law suites, including mixed update returns (requires node and `npm ci` in packages/core)");
626
660
  abi_laws_step.dependOn(&abi_laws_run.step);
661
+ abi_laws_step.dependOn(&mixed_return_abi_run.step);
627
662
  test_step.dependOn(&abi_laws_run.step);
663
+ test_step.dependOn(&mixed_return_abi_run.step);
628
664
  // The cross-execution battery staging: the host-fixture and
629
665
  // markup batteries (update/snapshot/effects and the markup view
630
666
  // over genuinely compiled cores) plus, where the target admits
@@ -638,6 +674,14 @@ pub fn build(b: *std.Build) void {
638
674
  if (ts_core_artifacts.services_pool) |pool_tests| {
639
675
  cross_e2e_step.dependOn(&b.addInstallArtifact(pool_tests, .{ .dest_dir = e2e_dir }).step);
640
676
  }
677
+ // The mobile execution battery staging: one static library the
678
+ // platform toolchain (xcrun clang / NDK clang) links around a tiny
679
+ // harness for execution on the simulator or emulator. Registered
680
+ // only for a mobile -Dtarget; scripts/mobile-e2e.sh is the driver.
681
+ if (ts_core_artifacts.mobile_battery) |battery| {
682
+ const mobile_e2e_step = b.step("stage-mobile-e2e", "Install the TS mobile e2e battery archive under <prefix>/e2e (pair with -Dtarget=aarch64-ios-simulator or aarch64-linux-android and -p; see scripts/mobile-e2e.sh)");
683
+ mobile_e2e_step.dependOn(&b.addInstallFileWithDir(battery, .{ .custom = "e2e" }, "libts-mobile-e2e.a").step);
684
+ }
641
685
  // The corpus contract artifacts an external core toolchain
642
686
  // consumes: per fixture, the frontend-emitted contract sidecar
643
687
  // (after projection), the generated entry module, and the
@@ -657,6 +701,7 @@ pub fn build(b: *std.Build) void {
657
701
  ts_core_e2e_step.dependOn(&monitor_e2e_run.step);
658
702
  ts_core_e2e_step.dependOn(&scaffold_ide_e2e_run.step);
659
703
  ts_core_e2e_step.dependOn(&ai_chat_e2e_run.step);
704
+ ts_core_e2e_step.dependOn(&feed_reader_e2e_run.step);
660
705
  ts_core_e2e_step.dependOn(&services_e2e_run.step);
661
706
  if (services_pool_e2e_run) |run| ts_core_e2e_step.dependOn(&run.step);
662
707
  test_step.dependOn(&host_e2e_run.step);
@@ -667,6 +712,7 @@ pub fn build(b: *std.Build) void {
667
712
  test_step.dependOn(&monitor_e2e_run.step);
668
713
  test_step.dependOn(&scaffold_ide_e2e_run.step);
669
714
  test_step.dependOn(&ai_chat_e2e_run.step);
715
+ test_step.dependOn(&feed_reader_e2e_run.step);
670
716
  test_step.dependOn(&services_e2e_run.step);
671
717
  if (services_pool_e2e_run) |run| test_step.dependOn(&run.step);
672
718
  test_step.dependOn(&sidecar_conformance_run.step);
@@ -761,10 +807,16 @@ pub fn build(b: *std.Build) void {
761
807
  .{ .path = "build.zig", .pattern = "if (!app_build.linuxGlibcSpellingHitsDefaultFloor(target)) return;" },
762
808
  .{ .path = "build/app.zig", .pattern = "scriptcPlatformTriple(b, target),\n // Keep the core and service archives on the same cross compiler" },
763
809
  .{ .path = "build.zig", .pattern = "app_build.scriptcPlatformTriple(b, target),\n \"--zig-exe\",\n b.graph.zig_exe," },
764
- .{ .path = "build.zig", .pattern = "compile.addArgs(&.{ \"--host-platform\", host_platform, \"--target-platform\", app_build.scriptcPlatformTriple(b, target), \"--zig-exe\", b.graph.zig_exe });\n addScriptcGlibcFloorTeaching(b, target, &compile.step);" },
765
- .{ .path = "build.zig", .pattern = "app_build.scriptcPlatformTriple(b, target),\n \"--zig-exe\",\n b.graph.zig_exe,\n });\n addScriptcGlibcFloorTeaching(b, target, &compile.step);" },
810
+ .{ .path = "build.zig", .pattern = "compile.addArgs(&.{ \"--host-platform\", host_platform, \"--target-platform\", app_build.scriptcPlatformTriple(b, target), \"--zig-exe\", b.graph.zig_exe });\n app_build.addScriptcAndroidNdk(b, compile, target);\n addScriptcGlibcFloorTeaching(b, target, &compile.step);" },
811
+ .{ .path = "build.zig", .pattern = "app_build.scriptcPlatformTriple(b, target),\n \"--zig-exe\",\n b.graph.zig_exe,\n });\n app_build.addScriptcAndroidNdk(b, compile, target);\n addScriptcGlibcFloorTeaching(b, target, &compile.step);" },
766
812
  .{ .path = "build.zig", .pattern = "abi_laws_mod.addObjectFile(markup_fixture.archive);\n addScriptcArchiveSystemLibs(abi_laws_mod, target);" },
767
- .{ .path = "packages/core/scripts/run_external_core_compiler.mjs", .pattern = "SCRIPTC_TARGET: args[\"target-platform\"]" },
813
+ // Both drivers map the build graph's Zig triple onto the compiler's
814
+ // own mobile spellings and thread the NDK like --zig-exe.
815
+ .{ .path = "packages/core/scripts/run_external_core_compiler.mjs", .pattern = "SCRIPTC_TARGET: scriptcTarget" },
816
+ .{ .path = "packages/core/scripts/run_external_service_compiler.mjs", .pattern = "SCRIPTC_TARGET: scriptcTarget" },
817
+ .{ .path = "packages/core/scripts/run_external_core_compiler.mjs", .pattern = "ANDROID_NDK_ROOT: args[\"android-ndk\"]" },
818
+ .{ .path = "packages/core/scripts/run_external_service_compiler.mjs", .pattern = "ANDROID_NDK_ROOT: args[\"android-ndk\"]" },
819
+ .{ .path = "build/app.zig", .pattern = ".ios => host.os.tag == .macos and target.result.cpu.arch == .aarch64" },
768
820
  });
769
821
  addFileContainsCheckStep(b, file_contains_checker, test_step, "test-app-test-entry-analysis", "Verify the managed app test step force-analyzes the entry point (UiApp.create's Model-defaults rule must teach at `native test`, not ambush at `native build`)", &.{
770
822
  .{ .path = "build/app.zig", .pattern = "app_analysis.zig" },
@@ -2992,6 +3044,10 @@ const TsCoreE2eArtifacts = struct {
2992
3044
  /// paths, and builds keep working with node_modules deleted.
2993
3045
  scaffold_ide: *std.Build.Step.Compile,
2994
3046
  ai_chat: *std.Build.Step.Compile,
3047
+ /// The complete services loop over examples/service-feed-reader: a real
3048
+ /// loopback Cmd.fetch, the generated typed client into a real service
3049
+ /// child, the shipping markup, and record→replay without either.
3050
+ feed_reader: *std.Build.Step.Compile,
2995
3051
  /// The phase-1 service seam: a real compiled core plus a real plain-scriptc
2996
3052
  /// service executable driven through the out-of-process carrier.
2997
3053
  services: *std.Build.Step.Compile,
@@ -3001,6 +3057,13 @@ const TsCoreE2eArtifacts = struct {
3001
3057
  /// cancellation/deadlines, trap isolation, streaming, replay). Null when
3002
3058
  /// the target cannot carry the archive (cross or non-desktop builds).
3003
3059
  services_pool: ?*std.Build.Step.Compile,
3060
+ /// The mobile execution battery: the pool fixture's core and service
3061
+ /// archives linked into one static library exporting `nsme_run`, so
3062
+ /// the platform toolchain links a runnable harness for the simulator
3063
+ /// or emulator (scripts/mobile-e2e.sh). Present only for a mobile
3064
+ /// -Dtarget; the Android archive is flattened to plain objects (Zig's
3065
+ /// ELF static-library emission nests archive inputs).
3066
+ mobile_battery: ?std.Build.LazyPath,
3004
3067
  /// The service-host carrier benchmark: a bytes-echo service compiled
3005
3068
  /// through the same lane, driven directly through the production
3006
3069
  /// carrier bindings of BOTH carriers (cold start, round-trip latency,
@@ -3016,6 +3079,9 @@ const TsCoreE2eArtifacts = struct {
3016
3079
  /// (boot fence, collect invariant, deterministic re-init, channel
3017
3080
  /// envelopes, integer classes).
3018
3081
  external_core_abi_laws: *std.Build.Step.Compile,
3082
+ /// The mixed-return ABI regression: a real compiled core whose update
3083
+ /// returns both bare Model and [Model, Cmd] through the generated facade.
3084
+ mixed_return_abi_laws: *std.Build.Step.Compile,
3019
3085
  /// Per-fixture contract artifacts for an external core toolchain:
3020
3086
  /// the effective contract sidecar and its TypeScript facade/profile
3021
3087
  /// projections, installed by the stage-core-contracts step.
@@ -3110,6 +3176,13 @@ fn tsCoreE2eArtifact(
3110
3176
  .name = "markup_core",
3111
3177
  });
3112
3178
  const markup_fixture_mod = markup_fixture.module;
3179
+ const mixed_return_src = b.addWriteFiles();
3180
+ _ = mixed_return_src.addCopyFile(b.path("tests/ts-core/mixed_return_fixture.ts"), "mixed_return_fixture.ts");
3181
+ const mixed_return_fixture = externalCoreFixtureModule(b, target, optimize, node, corewire_exe, .{
3182
+ .entry = "tests/ts-core/mixed_return_fixture.ts",
3183
+ .src_dir = mixed_return_src.getDirectory(),
3184
+ .name = "mixed_return_core",
3185
+ });
3113
3186
 
3114
3187
  const e2e_mod = module(b, target, optimize, "tests/ts-core/host_e2e_tests.zig");
3115
3188
  e2e_mod.addImport("native_sdk", desktop_mod);
@@ -3174,6 +3247,8 @@ fn tsCoreE2eArtifact(
3174
3247
  const monitor_stage = b.addWriteFiles();
3175
3248
  const monitor_root = monitor_stage.addCopyFile(b.path("tests/ts-core/system_monitor_e2e_tests.zig"), "system_monitor_e2e_tests.zig");
3176
3249
  _ = monitor_stage.addCopyFile(b.path("examples/system-monitor-ts/src/app.native"), "app.native");
3250
+ _ = monitor_stage.addCopyFile(b.path("examples/system-monitor-ts/src/windows/settings.native"), "settings.native");
3251
+ _ = monitor_stage.addCopyFile(b.path("examples/system-monitor-ts/src/windows/components/sampling.native"), "components/sampling.native");
3177
3252
  _ = monitor_stage.addCopyFile(b.path("examples/system-monitor/src/fixtures/sysctl.txt"), "fixtures/sysctl.txt");
3178
3253
  _ = monitor_stage.addCopyFile(b.path("examples/system-monitor/src/fixtures/ps.txt"), "fixtures/ps.txt");
3179
3254
  _ = monitor_stage.addCopyFile(b.path("examples/system-monitor/src/fixtures/vm_stat.txt"), "fixtures/vm_stat.txt");
@@ -3211,6 +3286,42 @@ fn tsCoreE2eArtifact(
3211
3286
  ai_chat_mod.addImport("native_sdk", desktop_mod);
3212
3287
  ai_chat_mod.addImport("ts_ai_chat_core", ai_chat_core_mod);
3213
3288
 
3289
+ // The service-feed-reader example's core, service child, and shipping
3290
+ // markup, tested as one app: a real buffered Cmd.fetch against a
3291
+ // loopback fixture, the generated typed client into the real child,
3292
+ // and record→replay with neither the service nor the network present.
3293
+ const feed_reader_fixture = externalCoreFixtureModule(b, target, optimize, node, corewire_exe, .{
3294
+ .entry = "examples/service-feed-reader/src/core.ts",
3295
+ .src_dir = b.path("examples/service-feed-reader/src"),
3296
+ .name = "feed_reader_core",
3297
+ .emit_services = true,
3298
+ });
3299
+ const feed_reader_service = externalServiceFixture(
3300
+ b,
3301
+ target,
3302
+ optimize,
3303
+ node,
3304
+ corewire_exe,
3305
+ b.path("examples/service-feed-reader/src"),
3306
+ feed_reader_fixture.services_contract.?,
3307
+ "feed_reader_services",
3308
+ );
3309
+ const feed_reader_stage = b.addWriteFiles();
3310
+ const feed_reader_root = feed_reader_stage.addCopyFile(b.path("tests/ts-services/feed_reader_e2e_tests.zig"), "feed_reader_e2e_tests.zig");
3311
+ _ = feed_reader_stage.addCopyFile(b.path("examples/service-feed-reader/src/app.native"), "app.native");
3312
+ _ = feed_reader_stage.addCopyFile(b.path("examples/service-feed-reader/fixtures/feed.xml"), "fixture_feed.xml");
3313
+ const feed_reader_mod = b.createModule(.{
3314
+ .root_source_file = feed_reader_root,
3315
+ .target = target,
3316
+ .optimize = optimize,
3317
+ });
3318
+ feed_reader_mod.addImport("native_sdk", desktop_mod);
3319
+ feed_reader_mod.addImport("ts_feed_reader_core", feed_reader_fixture.module);
3320
+ feed_reader_mod.addImport("ts_feed_reader_registry", feed_reader_service.registry);
3321
+ const feed_reader_options = b.addOptions();
3322
+ feed_reader_options.addOptionPath("service_executable", feed_reader_service.executable);
3323
+ feed_reader_mod.addOptions("ts_feed_reader_options", feed_reader_options);
3324
+
3214
3325
  // Phase-1 TypeScript services, end to end: the frontend emits BOTH
3215
3326
  // sidecars from one checked two-class program; corewire derives the
3216
3327
  // registry/host only from the service sidecar; plain scriptc compiles the
@@ -3257,6 +3368,46 @@ fn tsCoreE2eArtifact(
3257
3368
  break :pool pool_mod;
3258
3369
  } else null;
3259
3370
 
3371
+ // The mobile execution battery: a static library over the same pool
3372
+ // fixture, linked into a runnable harness by the platform toolchain —
3373
+ // the same link pattern embedding apps use for the embed library. The
3374
+ // Android objects are PIC like the embed library's (the harness there
3375
+ // is a bionic executable; a future .so embedding needs it regardless).
3376
+ const battery_target_is_mobile = target.result.os.tag == .ios or target.result.abi.isAndroid();
3377
+ const mobile_battery: ?std.Build.LazyPath = if (battery_target_is_mobile and service_host_fixture.archive != null) battery: {
3378
+ const battery_mod = b.createModule(.{
3379
+ .root_source_file = b.path("tests/ts-services/mobile_e2e_battery.zig"),
3380
+ .target = target,
3381
+ .optimize = optimize,
3382
+ .pic = if (target.result.abi.isAndroid()) true else null,
3383
+ });
3384
+ battery_mod.addImport("native_sdk", desktop_mod);
3385
+ battery_mod.addImport("ts_services_core", services_fixture.module);
3386
+ battery_mod.addImport("ts_services_registry", service_host_fixture.registry);
3387
+ battery_mod.link_libc = true;
3388
+ battery_mod.addObjectFile(service_host_fixture.archive.?);
3389
+ const battery_lib = b.addLibrary(.{
3390
+ .linkage = .static,
3391
+ .name = "ts-mobile-e2e",
3392
+ .root_module = battery_mod,
3393
+ .use_llvm = @import("build/app.zig").useLlvmWorkaround(target),
3394
+ });
3395
+ if (target.result.abi.isAndroid()) {
3396
+ // Flatten the nested TypeScript archives (Zig's ELF static-lib
3397
+ // emission stores .a inputs as members) so the NDK link consumes
3398
+ // plain objects — the same normalization the app lane applies.
3399
+ const merge = b.addSystemCommand(&.{node});
3400
+ merge.addFileArg(b.path("packages/core/scripts/merge_static_archives.mjs"));
3401
+ merge.addArgs(&.{ "--zig", b.graph.zig_exe, "--format", "gnu" });
3402
+ merge.addArg("--out");
3403
+ const merged = merge.addOutputFileArg("libts-mobile-e2e.a");
3404
+ merge.addArg("--in");
3405
+ merge.addFileArg(battery_lib.getEmittedBin());
3406
+ break :battery merged;
3407
+ }
3408
+ break :battery battery_lib.getEmittedBin();
3409
+ } else null;
3410
+
3260
3411
  // Service-host carrier benchmark: the same production service lane
3261
3412
  // (frontend contract -> corewire host/registry -> exact-pinned
3262
3413
  // plain-scriptc executable) over a bytes-echo operation that returns
@@ -3369,6 +3520,9 @@ fn tsCoreE2eArtifact(
3369
3520
  abi_laws_mod.addObjectFile(markup_fixture.archive);
3370
3521
  addScriptcArchiveSystemLibs(abi_laws_mod, target);
3371
3522
 
3523
+ const mixed_return_abi_mod = module(b, target, optimize, "tests/sidecar/mixed_return_abi_tests.zig");
3524
+ mixed_return_abi_mod.addImport("mixed_return_core", mixed_return_fixture.module);
3525
+
3372
3526
  return .{
3373
3527
  .host = filteredTestArtifact(b, e2e_mod, "ts-core-e2e-tests", &.{}),
3374
3528
  .persist = filteredTestArtifact(b, persist_mod, "ts-persist-e2e-tests", &.{}),
@@ -3378,11 +3532,14 @@ fn tsCoreE2eArtifact(
3378
3532
  .system_monitor = filteredTestArtifact(b, monitor_mod, "ts-system-monitor-e2e-tests", &.{}),
3379
3533
  .scaffold_ide = filteredTestArtifact(b, scaffold_ide_mod, "ts-scaffold-ide-e2e-tests", &.{}),
3380
3534
  .ai_chat = filteredTestArtifact(b, ai_chat_mod, "ts-ai-chat-e2e-tests", &.{}),
3535
+ .feed_reader = filteredTestArtifact(b, feed_reader_mod, "ts-feed-reader-e2e-tests", &.{}),
3381
3536
  .services = filteredTestArtifact(b, services_e2e_mod, "ts-services-e2e-tests", &.{}),
3382
3537
  .services_pool = if (services_pool_mod) |pool_mod| filteredTestArtifact(b, pool_mod, "ts-services-pool-e2e-tests", &.{}) else null,
3538
+ .mobile_battery = mobile_battery,
3383
3539
  .service_host_bench = service_bench_exe,
3384
3540
  .sidecar_conformance = filteredTestArtifact(b, conformance_mod, "sidecar-conformance-tests", &.{}),
3385
3541
  .external_core_abi_laws = filteredTestArtifact(b, abi_laws_mod, "external-core-abi-tests", &.{}),
3542
+ .mixed_return_abi_laws = filteredTestArtifact(b, mixed_return_abi_mod, "mixed-return-abi-tests", &.{}),
3386
3543
  .core_contracts = core_contracts.toOwnedSlice(b.allocator) catch @panic("OOM"),
3387
3544
  };
3388
3545
  }
@@ -3485,15 +3642,24 @@ fn externalServiceFixture(
3485
3642
  compile.addFileArg(b.path("packages/core/package.json"));
3486
3643
  compile.addArg("--contract");
3487
3644
  compile.addFileArg(contract);
3488
- compile.addArg("--out-exe");
3489
- const suffix = if (target.result.os.tag == .windows) ".exe" else "";
3490
- const executable = compile.addOutputFileArg(b.fmt("{s}{s}", .{ name, suffix }));
3645
+ // Mobile targets are archive-only (no child process exists there): the
3646
+ // driver refuses --out-exe, so the child-carrier batteries get a stub
3647
+ // path they never execute for those targets.
3648
+ const mobile_target = target.result.os.tag == .ios or target.result.abi.isAndroid();
3649
+ const executable: std.Build.LazyPath = if (mobile_target)
3650
+ b.addWriteFiles().add(b.fmt("{s}-unavailable-on-mobile", .{name}), "")
3651
+ else exe: {
3652
+ compile.addArg("--out-exe");
3653
+ const suffix = if (target.result.os.tag == .windows) ".exe" else "";
3654
+ break :exe compile.addOutputFileArg(b.fmt("{s}{s}", .{ name, suffix }));
3655
+ };
3491
3656
  const archive: ?std.Build.LazyPath = if (emit_archive) archive: {
3492
3657
  compile.addArg("--out-archive");
3493
3658
  break :archive compile.addOutputFileArg(b.fmt("lib{s}.a", .{name}));
3494
3659
  } else null;
3495
3660
  const host_platform = b.fmt("{t}-{t}-{t}", .{ b.graph.host.result.cpu.arch, b.graph.host.result.os.tag, b.graph.host.result.abi });
3496
3661
  compile.addArgs(&.{ "--host-platform", host_platform, "--target-platform", app_build.scriptcPlatformTriple(b, target), "--zig-exe", b.graph.zig_exe });
3662
+ app_build.addScriptcAndroidNdk(b, compile, target);
3497
3663
  addScriptcGlibcFloorTeaching(b, target, &compile.step);
3498
3664
  if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER")) |override| {
3499
3665
  compile.addArgs(&.{ "--compiler", override });
@@ -3665,6 +3831,7 @@ fn externalCoreFixtureModule(
3665
3831
  if (spec.store_capability) check.addArgs(&.{ "--capability", "store" });
3666
3832
  if (spec.relational_capability) check.addArgs(&.{ "--capability", "sqlite" });
3667
3833
  if (spec.credentials_capability) check.addArgs(&.{ "--capability", "credentials", "--permission", "credentials" });
3834
+ if (std.mem.eql(u8, spec.entry, "tests/ts-core/fixture.ts")) check.addArgs(&.{ "--permission", "filesystem" });
3668
3835
  tsCoreAddDirInputs(b, check, "packages/core/sdk");
3669
3836
  tsCoreAddDirInputs(b, check, std.fs.path.dirname(spec.entry) orelse ".");
3670
3837
  const frontend_sources = [_][]const u8{
@@ -3737,6 +3904,7 @@ fn externalCoreFixtureModule(
3737
3904
  "--zig-exe",
3738
3905
  b.graph.zig_exe,
3739
3906
  });
3907
+ app_build.addScriptcAndroidNdk(b, compile, target);
3740
3908
  addScriptcGlibcFloorTeaching(b, target, &compile.step);
3741
3909
  if (b.graph.environ_map.get("NATIVE_SDK_CORE_COMPILER")) |override| {
3742
3910
  // The development override: point at any toolchain command; the
package/native-sdk.d.ts CHANGED
@@ -473,6 +473,8 @@ export interface NativeSdkCommandEvent {
473
473
  source: NativeSdkCommandSource;
474
474
  windowId: number;
475
475
  viewLabel: string;
476
+ /** Native status-item id for tray-sourced commands, otherwise 0. */
477
+ statusItemId: number;
476
478
  /** Native tray item id for tray-sourced commands, otherwise 0. */
477
479
  trayItemId: number;
478
480
  }
@@ -549,9 +551,15 @@ export interface NativeSdkRecentDocumentOptions {
549
551
  }
550
552
 
551
553
  export interface NativeSdkNotificationOptions {
554
+ /** Stable replacement/deduplication identifier. */
555
+ id?: string;
552
556
  title: string;
553
557
  subtitle?: string;
554
558
  body?: string;
559
+ /** Paired with actionCommand; both must be present or both omitted. */
560
+ actionLabel?: string;
561
+ /** Normal application command dispatched when the user activates the action. */
562
+ actionCommand?: string;
555
563
  }
556
564
 
557
565
  export interface NativeSdkClipboardReadOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/cli",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "The Native SDK: the complete toolkit for building native desktop applications — declarative markup, native rendering, WebView surfaces, and OS capabilities",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,17 +32,17 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@typescript/old": "npm:typescript@6.0.3",
35
- "scriptc": "0.0.28"
35
+ "scriptc": "0.0.31"
36
36
  },
37
37
  "optionalDependencies": {
38
- "@native-sdk/cli-darwin-arm64": "0.9.0",
39
- "@native-sdk/cli-darwin-x64": "0.9.0",
40
- "@native-sdk/cli-linux-arm64-gnu": "0.9.0",
41
- "@native-sdk/cli-linux-arm64-musl": "0.9.0",
42
- "@native-sdk/cli-linux-x64-gnu": "0.9.0",
43
- "@native-sdk/cli-linux-x64-musl": "0.9.0",
44
- "@native-sdk/cli-win32-arm64": "0.9.0",
45
- "@native-sdk/cli-win32-x64": "0.9.0"
38
+ "@native-sdk/cli-darwin-arm64": "0.9.1",
39
+ "@native-sdk/cli-darwin-x64": "0.9.1",
40
+ "@native-sdk/cli-linux-arm64-gnu": "0.9.1",
41
+ "@native-sdk/cli-linux-arm64-musl": "0.9.1",
42
+ "@native-sdk/cli-linux-x64-gnu": "0.9.1",
43
+ "@native-sdk/cli-linux-x64-musl": "0.9.1",
44
+ "@native-sdk/cli-win32-arm64": "0.9.1",
45
+ "@native-sdk/cli-win32-x64": "0.9.1"
46
46
  },
47
47
  "repository": {
48
48
  "type": "git",
@@ -84,6 +84,31 @@ export function utf8Bytes(s: string): Uint8Array {
84
84
 
85
85
  export type Msgish = { readonly kind: string };
86
86
 
87
+ import { type WindowDescriptor, type WindowDescriptorSpec } from "./events.ts";
88
+
89
+ export function windowDescriptor(spec: WindowDescriptorSpec): WindowDescriptor {
90
+ return {
91
+ label: spec.label,
92
+ canvasLabel: spec.canvasLabel,
93
+ title: spec.title ?? new Uint8Array(0),
94
+ width: spec.width ?? 480,
95
+ height: spec.height ?? 360,
96
+ x: spec.x ?? null,
97
+ y: spec.y ?? null,
98
+ resizable: spec.resizable ?? true,
99
+ minWidth: spec.minWidth ?? 0,
100
+ minHeight: spec.minHeight ?? 0,
101
+ titlebar: spec.titlebar ?? "standard",
102
+ transparent: spec.transparent ?? false,
103
+ alwaysOnTop: spec.alwaysOnTop ?? false,
104
+ clickThrough: spec.clickThrough ?? false,
105
+ activateOnShow: spec.activateOnShow ?? true,
106
+ allowsFullscreen: spec.allowsFullscreen ?? true,
107
+ closePolicy: spec.closePolicy ?? "quit",
108
+ onCloseCommand: spec.onCloseCommand ?? new Uint8Array(0),
109
+ };
110
+ }
111
+
87
112
  /** Cooperative cancellation capability supplied by generated service hosts. */
88
113
  export interface ServiceCancellation {
89
114
  readonly cancelled: () => boolean;
@@ -143,6 +168,16 @@ export interface WriteRoute<M extends Msgish> {
143
168
  readonly err: M["kind"];
144
169
  }
145
170
 
171
+ export interface FileReadStreamRoute<M extends Msgish> {
172
+ readonly key?: string;
173
+ readonly chunk: M["kind"];
174
+ readonly done: M["kind"];
175
+ readonly err: M["kind"];
176
+ }
177
+
178
+ export interface FileStatArm { readonly exists: boolean; readonly size: number; readonly mtimeMs: number; }
179
+ export interface FileStatRoute<M extends Msgish> { readonly key?: string; readonly ok: M["kind"]; readonly err: M["kind"]; }
180
+
146
181
  export interface StoreScanOptions {
147
182
  readonly limit?: number;
148
183
  readonly after?: string | Uint8Array;
@@ -302,9 +337,12 @@ export interface FetchStreamSpec extends FetchSpec {
302
337
  }
303
338
 
304
339
  export interface NotificationSpec {
340
+ readonly id?: Uint8Array;
305
341
  readonly title: Uint8Array;
306
342
  readonly subtitle?: Uint8Array;
307
343
  readonly body?: Uint8Array;
344
+ readonly actionLabel?: Uint8Array;
345
+ readonly actionCommand?: Uint8Array;
308
346
  }
309
347
 
310
348
  export type LocalTimeStyle = "date" | "time" | "datetime";
@@ -355,6 +393,13 @@ export type CmdData =
355
393
  readonly path: Uint8Array;
356
394
  readonly bytes: Uint8Array;
357
395
  }
396
+ | { readonly op: "append_file"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array; readonly bytes: Uint8Array }
397
+ | { readonly op: "stat_file"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array }
398
+ | { readonly op: "delete_file"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array }
399
+ | { readonly op: "read_file_stream"; readonly key: string; readonly chunkKind: string; readonly doneKind: string; readonly errKind: string; readonly path: Uint8Array }
400
+ | { readonly op: "write_file_stream"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly path: Uint8Array }
401
+ | { readonly op: "write_file_chunk"; readonly key: string; readonly okKind: string; readonly errKind: string; readonly bytes: Uint8Array }
402
+ | { readonly op: "write_file_close"; readonly key: string; readonly okKind: string; readonly errKind: string }
358
403
  | {
359
404
  readonly op: "store_set";
360
405
  readonly key: string;
@@ -428,7 +473,7 @@ export type CmdData =
428
473
  }
429
474
  | { readonly op: "clip_write"; readonly bytes: Uint8Array }
430
475
  | { readonly op: "clip_read"; readonly key: string; readonly okKind: string; readonly errKind: string }
431
- | { readonly op: "show_notification"; readonly title: Uint8Array; readonly subtitle: Uint8Array; readonly body: Uint8Array }
476
+ | { readonly op: "show_notification"; readonly id: Uint8Array; readonly title: Uint8Array; readonly subtitle: Uint8Array; readonly body: Uint8Array; readonly actionLabel: Uint8Array; readonly actionCommand: Uint8Array }
432
477
  | { readonly op: "delay"; readonly key: string; readonly afterMs: number; readonly msgKind: string }
433
478
  | {
434
479
  readonly op: "spawn";
@@ -700,6 +745,27 @@ export const Cmd = {
700
745
  writeFile(path: Uint8Array, bytes: Uint8Array, route: { readonly key?: string; readonly ok: string; readonly err: string }): CmdData {
701
746
  return { op: "write_file", key: route.key ?? "", okKind: route.ok, errKind: route.err, path, bytes };
702
747
  },
748
+ appendFile(path: Uint8Array, bytes: Uint8Array, route: { readonly key?: string; readonly ok: string; readonly err: string }): CmdData {
749
+ return { op: "append_file", key: route.key ?? "", okKind: route.ok, errKind: route.err, path, bytes };
750
+ },
751
+ statFile(path: Uint8Array, route: { readonly key?: string; readonly ok: string; readonly err: string }): CmdData {
752
+ return { op: "stat_file", key: route.key ?? "", okKind: route.ok, errKind: route.err, path };
753
+ },
754
+ deleteFile(path: Uint8Array, route: { readonly key?: string; readonly ok: string; readonly err: string }): CmdData {
755
+ return { op: "delete_file", key: route.key ?? "", okKind: route.ok, errKind: route.err, path };
756
+ },
757
+ readFileStream(path: Uint8Array, route: { readonly key?: string; readonly chunk: string; readonly done: string; readonly err: string }): CmdData {
758
+ return { op: "read_file_stream", key: route.key ?? "", chunkKind: route.chunk, doneKind: route.done, errKind: route.err, path };
759
+ },
760
+ writeFileStream(key: string, path: Uint8Array, route: { readonly key?: string; readonly ok: string; readonly err: string }): CmdData {
761
+ return { op: "write_file_stream", key, okKind: route.ok, errKind: route.err, path };
762
+ },
763
+ writeFileChunk(key: string, bytes: Uint8Array, route: { readonly key?: string; readonly ok: string; readonly err: string }): CmdData {
764
+ return { op: "write_file_chunk", key, okKind: route.ok, errKind: route.err, bytes };
765
+ },
766
+ writeFileClose(key: string, route: { readonly key?: string; readonly ok: string; readonly err: string }): CmdData {
767
+ return { op: "write_file_close", key, okKind: route.ok, errKind: route.err };
768
+ },
703
769
 
704
770
  store: {
705
771
  set(storeKey: string, bytes: Uint8Array, route: { readonly key?: string; readonly ok: string; readonly err: string }): CmdData {
@@ -790,9 +856,12 @@ export const Cmd = {
790
856
  showNotification(spec: NotificationSpec): CmdData {
791
857
  return {
792
858
  op: "show_notification",
859
+ id: spec.id ?? new Uint8Array(0),
793
860
  title: spec.title,
794
861
  subtitle: spec.subtitle ?? new Uint8Array(0),
795
862
  body: spec.body ?? new Uint8Array(0),
863
+ actionLabel: spec.actionLabel ?? new Uint8Array(0),
864
+ actionCommand: spec.actionCommand ?? new Uint8Array(0),
796
865
  };
797
866
  },
798
867
 
@@ -1,32 +1,32 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@native-sdk/core",
9
- "version": "0.9.0",
9
+ "version": "0.9.1",
10
10
  "dependencies": {
11
- "scriptc": "0.0.28"
11
+ "scriptc": "0.0.31"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@typescript/old": "npm:typescript@6.0.3"
15
15
  }
16
16
  },
17
17
  "node_modules/@scriptc/compiler": {
18
- "version": "0.0.28",
19
- "integrity": "sha512-zq41x81F209cPrW4T+qMGlcIu8joveB2S26vYePIktbmpCVe+ZwdLnDvAY6aTuktoqTVjXXcsR3ebxGyuGh7rQ==",
18
+ "version": "0.0.31",
19
+ "integrity": "sha512-mx0GZXQdYR19jwahXQeo8dgZffi38v2F43n2zvofRsNozjPkh4cJ8qM7ir5xgc1otEfXKHIVMTBh0x/uKq6gbQ==",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@scriptc/runtime": "0.0.28",
22
+ "@scriptc/runtime": "0.0.31",
23
23
  "typescript": "7.0.2",
24
24
  "typescript5": "npm:typescript@5.9.3"
25
25
  }
26
26
  },
27
27
  "node_modules/@scriptc/runtime": {
28
- "version": "0.0.28",
29
- "integrity": "sha512-x7wO/i75fW4sJ8wY16Tr8ImX1SBROy3BIDZK2H4fafAC0rBI1LsYnxJogHqdeahkxUPDkWwuXZPoPC1vxAljGg==",
28
+ "version": "0.0.31",
29
+ "integrity": "sha512-NS37+H6blyQGmv24BN11vXmqOZ9igudWOqlkcL1MWvslOemy4vLWqxAe77Ca/51DJCfAu1xui2a3MPq8rQLfcQ==",
30
30
  "license": "Apache-2.0"
31
31
  },
32
32
  "node_modules/@typescript/old": {
@@ -344,11 +344,11 @@
344
344
  }
345
345
  },
346
346
  "node_modules/scriptc": {
347
- "version": "0.0.28",
348
- "integrity": "sha512-adYCjzHtD7XJyJg3g+gtkrTvONRqiRHsp8ZjkH2ot4FNCHPeix6ebqi88pyP9ZFHMh2bNZe2z3M3/2yHZFwOTg==",
347
+ "version": "0.0.31",
348
+ "integrity": "sha512-V7cR6080/mqm1PlHeIIlGDHID4aL/Poq+w4U/03935nK0stIJkHaKGtmKZEk5GrOXrejqVEtMNCGjZvYk/ClUQ==",
349
349
  "license": "Apache-2.0",
350
350
  "dependencies": {
351
- "@scriptc/compiler": "0.0.28"
351
+ "@scriptc/compiler": "0.0.31"
352
352
  },
353
353
  "bin": {
354
354
  "scriptc": "dist/main.js"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@native-sdk/core",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "The TypeScript authoring tier: the app-core subset, its checker and contract frontend, the exact-pinned core compiler dependency, and the SDK module cores import",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,6 +36,6 @@
36
36
  "@typescript/old": "npm:typescript@6.0.3"
37
37
  },
38
38
  "dependencies": {
39
- "scriptc": "0.0.28"
39
+ "scriptc": "0.0.31"
40
40
  }
41
41
  }