peachsim 0.1.2406 → 0.1.2408

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 (96) hide show
  1. package/cli/agent-note.ts +231 -0
  2. package/cli/cloud-dispatch.ts +1 -1
  3. package/cli/commands/agent.ts +29 -26
  4. package/cli/commands/stream.ts +11 -7
  5. package/cli/main.ts +16 -2
  6. package/cli/outbound-endpoints.ts +15 -0
  7. package/dist-lib/agent-daemon-client.cjs +23 -3
  8. package/dist-lib/agent-events.cjs +1 -1
  9. package/dist-lib/attached-projects.cjs +1 -1
  10. package/dist-lib/auth/shared-session.cjs +1 -1
  11. package/dist-lib/backend-origin.cjs +1 -1
  12. package/dist-lib/beta.cjs +1 -1
  13. package/dist-lib/beta.mjs +1 -1
  14. package/dist-lib/bridge-constants.cjs +1 -1
  15. package/dist-lib/bridge-contract-input.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.mjs +1 -1
  17. package/dist-lib/bridge-contract.cjs +1 -1
  18. package/dist-lib/bridge-contract.mjs +1 -1
  19. package/dist-lib/bundle-channel.cjs +201 -60
  20. package/dist-lib/capture-contract.cjs +1 -1
  21. package/dist-lib/capture-contract.mjs +1 -1
  22. package/dist-lib/cloud-contract.cjs +1 -1
  23. package/dist-lib/cloud-contract.mjs +1 -1
  24. package/dist-lib/cloud-test-args.cjs +1 -1
  25. package/dist-lib/cloud-test-args.mjs +1 -1
  26. package/dist-lib/cloud.cjs +1 -1
  27. package/dist-lib/cloud.mjs +1 -1
  28. package/dist-lib/config.cjs +1 -1
  29. package/dist-lib/config.mjs +1 -1
  30. package/dist-lib/detox/index.cjs +1 -1
  31. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  32. package/dist-lib/expo-swift-bundle.cjs +200 -59
  33. package/dist-lib/expo-swift-metadata.cjs +1 -1
  34. package/dist-lib/expo-swift-metadata.mjs +1 -1
  35. package/dist-lib/home-paths.cjs +1 -1
  36. package/dist-lib/host/bridge-host.cjs +356 -100
  37. package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
  38. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  39. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  40. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  41. package/dist-lib/host/websocket-proxy.cjs +1 -1
  42. package/dist-lib/index.cjs +4 -4
  43. package/dist-lib/jump-to-source-babel.cjs +1 -1
  44. package/dist-lib/jump-to-source-native.cjs +1 -1
  45. package/dist-lib/kotlin-host.cjs +1 -1
  46. package/dist-lib/menu.cjs +1 -1
  47. package/dist-lib/menu.mjs +1 -1
  48. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  49. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  50. package/dist-lib/metro-production-bundle.cjs +1 -1
  51. package/dist-lib/metro-production-bundle.mjs +1 -1
  52. package/dist-lib/metro.cjs +4 -4
  53. package/dist-lib/native-app-identity-project.cjs +3 -3
  54. package/dist-lib/native-app-identity-project.mjs +3 -3
  55. package/dist-lib/native-app-identity.cjs +1 -1
  56. package/dist-lib/native-app-identity.mjs +1 -1
  57. package/dist-lib/native-firebase-metadata.cjs +1 -1
  58. package/dist-lib/native-firebase-metadata.mjs +1 -1
  59. package/dist-lib/pdfium-raster.cjs +1 -1
  60. package/dist-lib/pdfium-raster.mjs +1 -1
  61. package/dist-lib/plist.cjs +1 -1
  62. package/dist-lib/plist.mjs +1 -1
  63. package/dist-lib/profiles.cjs +1 -1
  64. package/dist-lib/public-brand.cjs +1 -1
  65. package/dist-lib/public-origins-lib-esm.json +24 -24
  66. package/dist-lib/public-origins-lib.json +56 -55
  67. package/dist-lib/react-native-host-modules.cjs +1 -1
  68. package/dist-lib/react-native-host-modules.mjs +1 -1
  69. package/dist-lib/reap-browser.cjs +1 -1
  70. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  71. package/dist-lib/sdk.cjs +1 -1
  72. package/dist-lib/sdk.mjs +1 -1
  73. package/dist-lib/skills.cjs +367 -106
  74. package/dist-lib/swift-compile.cjs +195 -54
  75. package/dist-lib/swift-compile.mjs +195 -54
  76. package/dist-lib/swift-package.cjs +1 -1
  77. package/dist-lib/swift-package.mjs +1 -1
  78. package/dist-lib/swift-submit.cjs +1 -1
  79. package/dist-lib/swift-submit.mjs +1 -1
  80. package/dist-lib/swift-toolchain.cjs +1 -1
  81. package/dist-lib/swift.cjs +1 -1
  82. package/dist-lib/vite-swift.cjs +198 -57
  83. package/dist-lib/vite.cjs +4 -4
  84. package/dist-lib/worklet-executable.cjs +1 -1
  85. package/dist-lib/worklet-executable.mjs +1 -1
  86. package/kotlin/sdk.tar.gz +0 -0
  87. package/package.json +1 -1
  88. package/skills/peach-setup/SKILL.md +8 -3
  89. package/src/agent-daemon-client.ts +35 -2
  90. package/src/agent-prompt.ts +68 -0
  91. package/src/canvas-agent-note-delivery.ts +83 -0
  92. package/src/host/agent-host.ts +128 -18
  93. package/src/swift-compile.ts +124 -66
  94. package/src/swift-host.ts +2 -1
  95. package/src/swift-objc-import.ts +99 -0
  96. package/src/xcode-header-search.ts +33 -0
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2406 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2408 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -40519,7 +40519,7 @@ var swiftCoverageProvenance;
40519
40519
  var init_provenance = __esm({
40520
40520
  "src/swift-coverage/provenance.ts"() {
40521
40521
  "use strict";
40522
- swiftCoverageProvenance = true ? JSON.parse('{"swift-coverage/indexdump.ts":"0d82d8eeb96bf377f409ea7e33274c341a710c0e071f6b6e17571a23d8d92412","swift-coverage/indexing.ts":"633ccf19eec1f382a8847d0ee1dca42a2792a3c60aafd43622ed5152b09b8272","swift-coverage/types.ts":"bd8fae54ea6c53e110cd8a5d7b57c1d532dd0166e09fdaea63c4f270c3780dd1","swift-coverage/source.ts":"c151758a9f67631bc61473c375df0dc017da6902a34533b2cf4fc4fd7d19b6ee","swift-coverage/package.ts":"1f0068be7461fa7c5a7a891faf318f305cbed2e94c19667ba76627f7e5be260b","swift-coverage/xcode.ts":"65a500b806ce1c3a496de27f2e0ad77287c0f6795c618342c08af647f92af1fa","swift-coverage/xcode-assets.ts":"d98d6294b359528f7733b26db6f80f554782354faa235605f9562be4ad98b8a3","swift-coverage/xcode-asset-symbols.ts":"1b2a67733bc9d139b351466270205452a6172140bc25080d72619e2952c44671","swift-coverage/xcode-bridging.ts":"33184be8c5daf6646aa5a1276a4e15531f1be27b7c26f56550e0fbb1fc678a11","swift-coverage/xcode-packages.ts":"5c83f56357d880243ab485b260d23abd0094583ffa2287dac6e9e7eb18c3673d","swift-coverage/xcode-strings.ts":"f2dd4c7cd8ef77035184b0132909c2fa09fd20ed06b7757c2f1f960bfdde031c","swift-coverage/reader.ts":"da559b67ecd1161dea70c980b5f98f2c55af3550f0714479100fa5e9e813625c","swift-coverage/provenance.ts":"f5039c16e63c6129e22b71203f58982c68cef6e282a4f236b93da28edd39c108","swift-package-manifest.ts":"a19fe4c5e2efe18bbc3ece544ff2c8be660170d63274cccb0ab58e53083050e4","swift-package.ts":"851417572ca9aff699ad368bdc3ff05309b0256e483d40812b9c0beb869d0a5b","swift-source-file.ts":"8becce5e73b76a61d9d202c1ecfb39b1238e9bbf0e77841f1c51c98fa9ac7bd3","swift-toolchain.ts":"dec93d0206df8efbd9f538d1f3e3f6173f6eb022cb9ad6b02271481db7578d77","home-paths.ts":"d1606390f0e8e50f0ff72544eadb3d49dfabf08e004c1218f2998c36fb8995dd","xcode-header-search.ts":"d61be5d97c018bef4cf2a423f3625bac9757ab2c8e8541a00a4f29ebf048640f","xcode-project.ts":"092e07d3f9154f5aaf9f7c668f16c933c3ac5d8c57e5c32df0222ae6f785eaf7","xcode-target-members.ts":"2f25aaf5a3aa34395983c75935491c06bd68554c47ff1cb06b49c79499c03db0","xcode-json-project.ts":"41990ebbe4b488eef34e74c4608b4b48e5a5b299ba98ca7fbcfdfa0e77be63b6","openstep-plist.ts":"74e6ce1dac80c9c318e0e9f5e3e8cd19a898a8820c36fc160609695bcb59dcd3"}') : swiftCoverageSourceDigests((0, import_node_path.join)(__sootsim_import_meta_dirname, ".."));
40522
+ swiftCoverageProvenance = true ? JSON.parse('{"swift-coverage/indexdump.ts":"0d82d8eeb96bf377f409ea7e33274c341a710c0e071f6b6e17571a23d8d92412","swift-coverage/indexing.ts":"633ccf19eec1f382a8847d0ee1dca42a2792a3c60aafd43622ed5152b09b8272","swift-coverage/types.ts":"bd8fae54ea6c53e110cd8a5d7b57c1d532dd0166e09fdaea63c4f270c3780dd1","swift-coverage/source.ts":"c151758a9f67631bc61473c375df0dc017da6902a34533b2cf4fc4fd7d19b6ee","swift-coverage/package.ts":"1f0068be7461fa7c5a7a891faf318f305cbed2e94c19667ba76627f7e5be260b","swift-coverage/xcode.ts":"65a500b806ce1c3a496de27f2e0ad77287c0f6795c618342c08af647f92af1fa","swift-coverage/xcode-assets.ts":"d98d6294b359528f7733b26db6f80f554782354faa235605f9562be4ad98b8a3","swift-coverage/xcode-asset-symbols.ts":"1b2a67733bc9d139b351466270205452a6172140bc25080d72619e2952c44671","swift-coverage/xcode-bridging.ts":"33184be8c5daf6646aa5a1276a4e15531f1be27b7c26f56550e0fbb1fc678a11","swift-coverage/xcode-packages.ts":"5c83f56357d880243ab485b260d23abd0094583ffa2287dac6e9e7eb18c3673d","swift-coverage/xcode-strings.ts":"f2dd4c7cd8ef77035184b0132909c2fa09fd20ed06b7757c2f1f960bfdde031c","swift-coverage/reader.ts":"da559b67ecd1161dea70c980b5f98f2c55af3550f0714479100fa5e9e813625c","swift-coverage/provenance.ts":"f5039c16e63c6129e22b71203f58982c68cef6e282a4f236b93da28edd39c108","swift-package-manifest.ts":"a19fe4c5e2efe18bbc3ece544ff2c8be660170d63274cccb0ab58e53083050e4","swift-package.ts":"851417572ca9aff699ad368bdc3ff05309b0256e483d40812b9c0beb869d0a5b","swift-source-file.ts":"8becce5e73b76a61d9d202c1ecfb39b1238e9bbf0e77841f1c51c98fa9ac7bd3","swift-toolchain.ts":"dec93d0206df8efbd9f538d1f3e3f6173f6eb022cb9ad6b02271481db7578d77","home-paths.ts":"d1606390f0e8e50f0ff72544eadb3d49dfabf08e004c1218f2998c36fb8995dd","xcode-header-search.ts":"4a775ba92c7b23ce71dd6bb08c188c4bccd6e1ed500cc9fc7850030b945fc8d4","xcode-project.ts":"092e07d3f9154f5aaf9f7c668f16c933c3ac5d8c57e5c32df0222ae6f785eaf7","xcode-target-members.ts":"2f25aaf5a3aa34395983c75935491c06bd68554c47ff1cb06b49c79499c03db0","xcode-json-project.ts":"41990ebbe4b488eef34e74c4608b4b48e5a5b299ba98ca7fbcfdfa0e77be63b6","openstep-plist.ts":"74e6ce1dac80c9c318e0e9f5e3e8cd19a898a8820c36fc160609695bcb59dcd3"}') : swiftCoverageSourceDigests((0, import_node_path.join)(__sootsim_import_meta_dirname, ".."));
40523
40523
  }
40524
40524
  });
40525
40525
 
@@ -57460,6 +57460,61 @@ function swiftClangImporterFlags(flags) {
57460
57460
  (flag) => flag !== "-fobjc-arc" && flag !== "-fno-objc-arc" && !/^-std=(?:c(?!\+\+)|gnu(?!\+\+)|iso9899:)/.test(flag)
57461
57461
  );
57462
57462
  }
57463
+ function compactSwiftClangDefines(flags) {
57464
+ const definitions = /* @__PURE__ */ new Map();
57465
+ const macros = [];
57466
+ for (let index = 0; index < flags.length; index++) {
57467
+ if (flags[index].startsWith("@")) return flags;
57468
+ if (flags[index] !== "-Xcc") continue;
57469
+ const flag = flags[++index];
57470
+ if (flag === void 0 || flags[index - 2] === "-Xfrontend" || flag === "-Xclang" || flag === "-Xpreprocessor" || flag.startsWith("-Wp,") || flag.startsWith("--config") || flag.startsWith("@"))
57471
+ return flags;
57472
+ if (CLANG_PATH_OPTIONS.has(flag) && flags[index + 1] === "-Xcc") {
57473
+ index += 2;
57474
+ continue;
57475
+ }
57476
+ if (!flag.startsWith("-D") && !flag.startsWith("-U")) continue;
57477
+ const name3 = /^-[DU]([A-Za-z_$][\w$]*)(?=[(=]|$)/.exec(flag)?.[1];
57478
+ if (!name3) return flags;
57479
+ const previous = definitions.get(name3);
57480
+ definitions.set(name3, previous === void 0 || previous === flag ? flag : null);
57481
+ macros.push({ index, name: name3, flag });
57482
+ }
57483
+ const seen = /* @__PURE__ */ new Set();
57484
+ const duplicates = /* @__PURE__ */ new Set();
57485
+ for (const { index, name: name3, flag } of macros) {
57486
+ if (definitions.get(name3) !== flag) continue;
57487
+ if (seen.has(name3)) {
57488
+ duplicates.add(index - 1);
57489
+ duplicates.add(index);
57490
+ }
57491
+ seen.add(name3);
57492
+ }
57493
+ return duplicates.size === 0 ? flags : flags.filter((_, index) => !duplicates.has(index));
57494
+ }
57495
+ function compactSwiftClangOverlays(flags, generated) {
57496
+ if (generated.size === 0) return flags;
57497
+ const overlays = /* @__PURE__ */ new Map();
57498
+ const duplicates = /* @__PURE__ */ new Set();
57499
+ for (let index = 0; index < flags.length; index++) {
57500
+ const flag = flags[index];
57501
+ if (flag.startsWith("@")) return flags;
57502
+ if (flag === "-Xcc" && flags[index - 1] === "-Xfrontend") return flags;
57503
+ if (flags[index - 1] === "-Xcc" && (flag.startsWith("--config") || flag === "-Xclang"))
57504
+ return flags;
57505
+ if (!flag.startsWith("-ivfsoverlay") && !flag.startsWith("-vfsoverlay")) continue;
57506
+ if (flag !== "-ivfsoverlay" || flags[index - 1] !== "-Xcc" || flags[index + 1] !== "-Xcc")
57507
+ return flags;
57508
+ const file = flags[index + 2];
57509
+ if (file === void 0 || !generated.has(file)) return flags;
57510
+ const previous = overlays.get(file);
57511
+ if (previous !== void 0)
57512
+ for (let offset = -1; offset < 3; offset++) duplicates.add(previous + offset);
57513
+ overlays.set(file, index);
57514
+ index += 2;
57515
+ }
57516
+ return duplicates.size === 0 ? flags : flags.filter((_, index) => !duplicates.has(index));
57517
+ }
57463
57518
  function swiftSubmoduleImports(sources) {
57464
57519
  const imports2 = /* @__PURE__ */ new Map();
57465
57520
  for (const source of sources)
@@ -57484,7 +57539,7 @@ function swiftObjCModuleMap(module2, headers, submodules = /* @__PURE__ */ new S
57484
57539
  ""
57485
57540
  ].join("\n");
57486
57541
  }
57487
- var SWIFT_OBJC_INTEROP_FLAGS, SWIFT_SUBMODULE_IMPORT;
57542
+ var SWIFT_OBJC_INTEROP_FLAGS, CLANG_PATH_OPTIONS, SWIFT_SUBMODULE_IMPORT;
57488
57543
  var init_swift_objc_import = __esm({
57489
57544
  "src/swift-objc-import.ts"() {
57490
57545
  "use strict";
@@ -57498,6 +57553,23 @@ var init_swift_objc_import = __esm({
57498
57553
  "-Xcc",
57499
57554
  "-fblocks"
57500
57555
  ];
57556
+ CLANG_PATH_OPTIONS = /* @__PURE__ */ new Set([
57557
+ "-I",
57558
+ "-F",
57559
+ "-idirafter",
57560
+ "-iframework",
57561
+ "-iframeworkwithsysroot",
57562
+ "-imacros",
57563
+ "-include",
57564
+ "-iprefix",
57565
+ "-iquote",
57566
+ "-isystem",
57567
+ "-isysroot",
57568
+ "-ivfsoverlay",
57569
+ "-iwithprefix",
57570
+ "-iwithprefixbefore",
57571
+ "--sysroot"
57572
+ ]);
57501
57573
  SWIFT_SUBMODULE_IMPORT = /^[ \t]*(?:@\w+(?:\([^)]*\))?[ \t]+)*import[ \t]+([A-Za-z_]\w*)\.([A-Za-z_]\w*)[ \t]*(?:\/\/.*)?$/gm;
57502
57574
  }
57503
57575
  });
@@ -57867,6 +57939,30 @@ var init_swift_uniform_type_constants = __esm({
57867
57939
  });
57868
57940
 
57869
57941
  // src/xcode-header-search.ts
57942
+ function coalescibleHeaderOverlays(files2) {
57943
+ const aliases = /* @__PURE__ */ new Map();
57944
+ const key2 = (file) => file.replace(/[A-Z]/g, (letter) => letter.toLowerCase());
57945
+ const index = (directory2, entry) => {
57946
+ const name3 = import_node_path56.default.resolve(directory2, entry.name);
57947
+ if (entry.type === "directory")
57948
+ return entry.contents.every((child) => index(name3, child));
57949
+ const source = entry["external-contents"];
57950
+ const previous = aliases.get(key2(name3));
57951
+ if (previous !== void 0 && previous !== source) return false;
57952
+ aliases.set(key2(name3), source);
57953
+ return true;
57954
+ };
57955
+ for (const file of files2) {
57956
+ const overlay = JSON.parse(import_node_fs59.default.readFileSync(file, "utf8"));
57957
+ if (!overlay.roots.every((entry) => index(import_node_path56.default.dirname(file), entry)))
57958
+ return /* @__PURE__ */ new Set();
57959
+ }
57960
+ for (const file of [...files2, ...aliases.values()]) {
57961
+ const source = aliases.get(key2(import_node_path56.default.normalize(file)));
57962
+ if (source !== void 0 && source !== file) return /* @__PURE__ */ new Set();
57963
+ }
57964
+ return files2;
57965
+ }
57870
57966
  function headerMap(entries) {
57871
57967
  const unique = /* @__PURE__ */ new Map();
57872
57968
  for (const entry of entries)
@@ -58791,6 +58887,15 @@ function swiftTargetDependencies(files2, targets, frameworks = OPTIONAL_FRAMEWOR
58791
58887
  )
58792
58888
  );
58793
58889
  const names = /* @__PURE__ */ new Set([...frameworks, ...targets.map((target) => target.name)]);
58890
+ const entriesByPrefix = new Map(
58891
+ targets.map(({ path: path148 }) => [path148 === "." ? "" : `${path148}/`, []])
58892
+ );
58893
+ for (const entry of Object.entries(files2)) {
58894
+ const [file] = entry;
58895
+ entriesByPrefix.get("")?.push(entry);
58896
+ for (let end = file.indexOf("/"); end !== -1; end = file.indexOf("/", end + 1))
58897
+ entriesByPrefix.get(file.slice(0, end + 1))?.push(entry);
58898
+ }
58794
58899
  const siblings = /* @__PURE__ */ new Map();
58795
58900
  for (const target of targets) {
58796
58901
  const prefix = target.path === "." ? "" : `${target.path}/`;
@@ -58804,8 +58909,11 @@ function swiftTargetDependencies(files2, targets, frameworks = OPTIONAL_FRAMEWOR
58804
58909
  (dependency) => dependency.kind === "target" && dependency.name !== target.name && names.has(dependency.name) || dependency.kind === "product" && dependency.package === "sootsim-swift" && OPTIONAL_FRAMEWORKS.has(dependency.name) ? [dependency.name] : []
58805
58910
  )
58806
58911
  );
58807
- for (const [file, contents2] of Object.entries(files2)) {
58808
- if (file === "Package.swift" || !file.startsWith(prefix)) continue;
58912
+ const nested = target.sources === void 0 ? targets.flatMap(
58913
+ (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) ? [`${candidate.path}/`] : []
58914
+ ) : [];
58915
+ for (const [file, contents2] of entriesByPrefix.get(prefix) ?? []) {
58916
+ if (file === "Package.swift") continue;
58809
58917
  const relative6 = file.slice(prefix.length);
58810
58918
  if (target.sources !== void 0 && !target.sources.some(
58811
58919
  (source) => source === "." || relative6 === source || relative6.startsWith(`${source}/`)
@@ -58815,10 +58923,7 @@ function swiftTargetDependencies(files2, targets, frameworks = OPTIONAL_FRAMEWOR
58815
58923
  (excluded) => relative6 === excluded || relative6.startsWith(`${excluded}/`)
58816
58924
  ))
58817
58925
  continue;
58818
- if (target.sources === void 0 && targets.some(
58819
- (candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
58820
- ))
58821
- continue;
58926
+ if (nested.some((path148) => file.startsWith(path148))) continue;
58822
58927
  const imports2 = file.endsWith(".swift") ? swiftImportNames(contents2) : SWIFT_NATIVE_SOURCE_EXTENSIONS.some((extension) => file.endsWith(extension)) ? clangImportNames(contents2, ownsHeader) : [];
58823
58928
  for (const name3 of imports2) {
58824
58929
  if (names.has(name3) && name3 !== target.name && !(target.dependencies !== void 0 && localNames.has(name3)))
@@ -59063,7 +59168,9 @@ function emitSwiftPackageManifest(args) {
59063
59168
  const flags = JSON.parse(literal6.replace(/,\s*]$/, "]")).filter(
59064
59169
  (flag, index, all) => !mapsPackageModule(flag) && !(flag === "-Xcc" && mapsPackageModule(all[index + 1] ?? ""))
59065
59170
  );
59066
- const content = flags.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
59171
+ const macros = compactSwiftClangDefines(flags);
59172
+ const compact = args.coalescibleOverlays ? compactSwiftClangOverlays(macros, args.coalescibleOverlays) : macros;
59173
+ const content = compact.map((flag) => JSON.stringify(flag)).join("\n") + "\n";
59067
59174
  const digest3 = (0, import_node_crypto28.createHash)("sha256").update(content).digest("hex");
59068
59175
  const file = import_node_path57.default.join(args.root, ".peach-swift-arguments", `${digest3}.rsp`);
59069
59176
  args.files.set(file, content);
@@ -59154,7 +59261,7 @@ function emitSwiftPackageManifest(args) {
59154
59261
  ].map((flag) => `, ${JSON.stringify(flag)}`).join("");
59155
59262
  const header = args.headerDirectory && (args.nativeHeaderDeclarations?.[target.name] || [...args.native?.values() ?? []].some(
59156
59263
  (value) => value.late?.producers.includes(target.name)
59157
- )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path57.default.join(args.headerDirectory, `${target.name}-Swift${args.nativeHeaderDeclarations?.[target.name] ? ".original" : ""}.h`))}` : "";
59264
+ )) ? `, "-emit-objc-header-path", ${JSON.stringify(import_node_path57.default.join(args.headerDirectory, `${target.name}-Swift.original.h`))}` : "";
59158
59265
  const clangMode = target.cxxInterop ? "" : ', "-Xcc", "-fno-cxx-modules"';
59159
59266
  const deployment = `, "-Xfrontend", "-peach-ios-deployment-target", "-Xfrontend", ${JSON.stringify(target.iosDeploymentTarget ?? SWIFTPM_DEFAULT_IOS_DEPLOYMENT_TARGET)}`;
59160
59267
  const swiftSettings = `swiftSettings: [.swiftLanguageMode(.v${target.languageMode}),${isolation}${interoperability}${defines}${features}${upcoming} .unsafeFlags(${swiftFlagArray(`["-Osize", "-Xfrontend", "-enable-cross-import-overlays"${overlayFlags}${FOUNDATION_IMPLICIT_FLAGS}${oneModule ? ONE_IMPLICIT_FLAGS : ""}${imports2}${nativeImportFlags}${objcFlags}${header}${clangMode}${deployment}${upstream}]`)})]`;
@@ -61245,6 +61352,9 @@ module ${moduleName2}.Swift {
61245
61352
  nativeHeaderDeclarations[module2] = [...declared];
61246
61353
  }
61247
61354
  const nativeFlags = native.size > 0 ? /* @__PURE__ */ new Map() : void 0;
61355
+ const generatedOverlays = new Set(
61356
+ headerSearch.files.filter((file) => file.endsWith(".yaml"))
61357
+ );
61248
61358
  if (nativeFlags) {
61249
61359
  const toolchainBin = nativeToolchain();
61250
61360
  const headers = import_node_path57.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "darwin");
@@ -61265,8 +61375,11 @@ module ${moduleName2}.Swift {
61265
61375
  throw new Error(
61266
61376
  target.name + ": missing or unsupported declared iOS deployment target " + JSON.stringify(version2)
61267
61377
  );
61378
+ const sdkIntake = objcSdkIntakeFlags(headers, toolchainBin, minimum);
61379
+ const sdkOverlay = sdkIntake.indexOf("-ivfsoverlay");
61380
+ if (sdkOverlay >= 0) generatedOverlays.add(sdkIntake[sdkOverlay + 1]);
61268
61381
  const intake = [
61269
- ...objcSdkIntakeFlags(headers, toolchainBin, minimum),
61382
+ ...sdkIntake,
61270
61383
  "-ivfsoverlay",
61271
61384
  headerSearch.files[0],
61272
61385
  "-I",
@@ -61435,6 +61548,7 @@ module ${moduleName2}.Swift {
61435
61548
  sourceSwiftTargets: swiftTargets,
61436
61549
  nativeFlags,
61437
61550
  nativeImportFlags,
61551
+ coalescibleOverlays: nativeFlags ? coalescibleHeaderOverlays(generatedOverlays) : void 0,
61438
61552
  nativeHeaderFlags,
61439
61553
  nativeSwiftHeaderMaps,
61440
61554
  nativeHeaderDeclarations,
@@ -62733,6 +62847,7 @@ function compileSwiftProjectOnce(input, options) {
62733
62847
  report("compiling and linking Swift modules");
62734
62848
  const frameworkInterfaces = /* @__PURE__ */ new Map();
62735
62849
  const nativeDeclarations = /* @__PURE__ */ new Map();
62850
+ const nativeHeaders = Object.entries(input.files).filter(([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")).map(([, source]) => source);
62736
62851
  for (const [file, contents2] of Object.entries(input.files)) {
62737
62852
  if (!file.endsWith(".modulemap")) continue;
62738
62853
  const name3 = moduleMapName(contents2);
@@ -62820,54 +62935,83 @@ function compileSwiftProjectOnce(input, options) {
62820
62935
  );
62821
62936
  return value;
62822
62937
  };
62823
- try {
62824
- for (const build2 of preparation.headerBuilds) {
62825
- await runCompiler(
62826
- swift,
62827
- [...buildArgs, "--target", build2.target],
62828
- appOptions,
62829
- SWIFTPM_PROGRESS,
62830
- SWIFTPM_NOISE
62938
+ const compileApp = async () => {
62939
+ const stages = [
62940
+ ...preparation.headerBuilds,
62941
+ ...preparation.nativeProductTarget ? [{ target: preparation.nativeProductTarget, producers: [] }] : []
62942
+ ];
62943
+ const checkpoints = import_node_path57.default.join(root, ".build", "peach-product-checkpoints");
62944
+ const recipe2 = (0, import_node_crypto28.createHash)("sha256").update(hash).update((0, import_node_fs60.readFileSync)(import_node_path57.default.join(root, "Package.swift"))).update(JSON.stringify(buildArgs)).digest("hex");
62945
+ for (const { target, producers } of stages) {
62946
+ const receipt = import_node_path57.default.join(
62947
+ checkpoints,
62948
+ (0, import_node_crypto28.createHash)("sha256").update(target).digest("hex")
62831
62949
  );
62832
- for (const producer of build2.producers) {
62833
- const emitted = import_node_path57.default.join(
62950
+ const headers = producers.map((producer) => {
62951
+ const stem = import_node_path57.default.join(
62834
62952
  root,
62835
62953
  ".build",
62836
62954
  "peach-cxx-headers",
62837
- `${producer}-Swift.h`
62955
+ `${producer}-Swift`
62838
62956
  );
62839
- const original = preparation.nativeHeaderDeclarations[producer] ? emitted.replace(/-Swift\.h$/, "-Swift.original.h") : emitted;
62840
- if ((0, import_node_fs60.existsSync)(original)) {
62841
- const generated = clangInterfaceHeader(
62842
- (0, import_node_fs60.readFileSync)(original, "utf8")
62843
- );
62844
- writeBuildFile(
62845
- emitted,
62846
- withoutSwiftDeclarations(
62847
- swiftHeaderWithSuperclassImports(generated, frameworkInterface),
62848
- /* @__PURE__ */ new Set([
62849
- ...preparation.nativeHeaderDeclarations[producer] ?? [],
62850
- ...nativelyDeclaredFunctions(
62851
- generated,
62852
- Object.entries(input.files).filter(
62853
- ([name3]) => name3.endsWith(".h") && !name3.endsWith("-Swift.h")
62854
- ).map(([, source]) => source)
62855
- )
62856
- ]),
62857
- `#import <${producer}/${producer}.h>`
62858
- )
62957
+ return {
62958
+ producer,
62959
+ original: `${stem}.original.h`,
62960
+ emitted: `${stem}.h`
62961
+ };
62962
+ });
62963
+ const fingerprint = () => {
62964
+ const digest3 = (0, import_node_crypto28.createHash)("sha256").update(recipe2);
62965
+ for (const { emitted } of headers) {
62966
+ if (!(0, import_node_fs60.existsSync)(emitted)) return;
62967
+ digest3.update(
62968
+ (0, import_node_crypto28.createHash)("sha256").update((0, import_node_fs60.readFileSync)(emitted)).digest()
62859
62969
  );
62860
62970
  }
62861
- }
62862
- }
62863
- if (preparation.nativeProductTarget) {
62971
+ return digest3.digest("hex");
62972
+ };
62973
+ if (!options.project && (0, import_node_fs60.existsSync)(receipt) && (0, import_node_fs60.readFileSync)(receipt, "utf8") === fingerprint())
62974
+ continue;
62975
+ if (!options.project) (0, import_node_fs60.rmSync)(receipt, { force: true });
62976
+ for (const { producer, original } of headers)
62977
+ if (!(0, import_node_fs60.existsSync)(original))
62978
+ (0, import_node_fs60.rmSync)(
62979
+ import_node_path57.default.join(
62980
+ root,
62981
+ ".build",
62982
+ WASM_TRIPLE,
62983
+ "release",
62984
+ "Modules",
62985
+ `${swiftTargetModuleName(producer)}.swiftmodule`
62986
+ ),
62987
+ { force: true }
62988
+ );
62864
62989
  await runCompiler(
62865
62990
  swift,
62866
- [...buildArgs, "--target", preparation.nativeProductTarget],
62991
+ [...buildArgs, "--target", target],
62867
62992
  appOptions,
62868
62993
  SWIFTPM_PROGRESS,
62869
62994
  SWIFTPM_NOISE
62870
62995
  );
62996
+ for (const { producer, original, emitted } of headers) {
62997
+ const generated = clangInterfaceHeader((0, import_node_fs60.readFileSync)(original, "utf8"));
62998
+ writeBuildFile(
62999
+ emitted,
63000
+ withoutSwiftDeclarations(
63001
+ swiftHeaderWithSuperclassImports(generated, frameworkInterface),
63002
+ /* @__PURE__ */ new Set([
63003
+ ...preparation.nativeHeaderDeclarations[producer] ?? [],
63004
+ ...nativelyDeclaredFunctions(generated, nativeHeaders)
63005
+ ]),
63006
+ `#import <${producer}/${producer}.h>`
63007
+ )
63008
+ );
63009
+ }
63010
+ if (!options.project) {
63011
+ (0, import_node_fs60.mkdirSync)(checkpoints, { recursive: true });
63012
+ (0, import_node_fs60.writeFileSync)(`${receipt}.partial`, fingerprint());
63013
+ (0, import_node_fs60.renameSync)(`${receipt}.partial`, receipt);
63014
+ }
62871
63015
  }
62872
63016
  await runCompiler(
62873
63017
  swift,
@@ -62876,6 +63020,9 @@ function compileSwiftProjectOnce(input, options) {
62876
63020
  SWIFTPM_PROGRESS,
62877
63021
  SWIFTPM_NOISE
62878
63022
  );
63023
+ };
63024
+ try {
63025
+ await compileApp();
62879
63026
  } catch (error) {
62880
63027
  const output3 = outputOf(error);
62881
63028
  const moduleCache = import_node_path57.default.join(
@@ -62888,13 +63035,7 @@ function compileSwiftProjectOnce(input, options) {
62888
63035
  if (output3.includes("was compiled with module cache path") && (0, import_node_fs60.existsSync)(moduleCache)) {
62889
63036
  (0, import_node_fs60.rmSync)(moduleCache, { recursive: true, force: true });
62890
63037
  try {
62891
- await runCompiler(
62892
- swift,
62893
- buildArgs,
62894
- appOptions,
62895
- SWIFTPM_PROGRESS,
62896
- SWIFTPM_NOISE
62897
- );
63038
+ await compileApp();
62898
63039
  } catch (retryError) {
62899
63040
  throw new Error(
62900
63041
  [
@@ -63225,9 +63366,9 @@ int EXUpdatesApplyBSDiffPatch(const char * _Nonnull oldFilePath,
63225
63366
  `;
63226
63367
  darwinRecordsRegion = (quoted2) => quoted2.length ? ["-Wl,--start-lib", ...quoted2, "-Wl,--end-lib"] : [];
63227
63368
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
63228
- MULTI_MANIFEST_VERSION = 69;
63369
+ MULTI_MANIFEST_VERSION = 71;
63229
63370
  SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
63230
- compilerSourceDigest = true ? "5f7b13ec00e56a1f8e36b1e4f1688c4eb10836e9afffb80f5e63e4fbf23e9070" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
63371
+ compilerSourceDigest = true ? "36b1496faf39a688e5ab3ee63bdab89a3afde2b9c6355443c3162f4b1e3b9144" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
63231
63372
  nativeCxxCompilerFlags = ["-fno-cxx-modules"];
63232
63373
  cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
63233
63374
  cxxFlagArray = (flags) => JSON.stringify([...nativeCxxCompilerFlags, ...withoutGlogModuleMap(flags)]);
@@ -69958,7 +70099,7 @@ var init_swift_standin_digest = __esm({
69958
70099
  STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
69959
70100
  SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
69960
70101
  standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
69961
- STANDIN_SOURCE_DIGEST = true ? "2e7f1f173feffee6e539b11d8cd6fa9540f7418a23e3563c8b2d9aa747495bd6" : standinSourceDigest();
70102
+ STANDIN_SOURCE_DIGEST = true ? "80b89d414ee068d747a0859811608daad7d3c46ca66f7bf589cc5c82b820de93" : standinSourceDigest();
69962
70103
  }
69963
70104
  });
69964
70105
 
@@ -70453,7 +70594,7 @@ __export(expo_native_prebuilt_exports, {
70453
70594
  servedExpoSwift: () => servedExpoSwift
70454
70595
  });
70455
70596
  function expoNativeCompilerDigestValue() {
70456
- return true ? "a21e70334c74419c8ca0427886adcfb457911bc210711ce2210c3f98b2dabf6b" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
70597
+ return true ? "3860d02e968c4e679b7669066efdc2302ff559ff6014934ad88d4fad7996909d" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
70457
70598
  }
70458
70599
  function readSources(value) {
70459
70600
  const sources = isRecord(value) ? value.sources : null;
@@ -80808,7 +80949,7 @@ async function swiftPackages(entry, app) {
80808
80949
  ] : []
80809
80950
  );
80810
80951
  let reached = [...cached4.binaries.filter((binary2) => binary2.reached), ...vendored];
80811
- const standinArtifact = (binary2) => binary2.publicHeaders === void 0 || binary2.unloweredSources !== void 0;
80952
+ const standinArtifact = (binary2) => !binary2.rustCrate && (binary2.publicHeaders === void 0 || binary2.unloweredSources !== void 0);
80812
80953
  const artifacts = reached.filter(standinArtifact);
80813
80954
  if (entry.moduleRoot && entry.provided && artifacts.length > 0) {
80814
80955
  const { provided } = entry;
@@ -93422,7 +93563,7 @@ var init_nitro_superset = __esm({
93422
93563
  init_nitroContract();
93423
93564
  init_swift_standin_digest();
93424
93565
  NITRO_SUPERSET_ENTRY_NAME = "superset";
93425
- NITRO_COMPILER_DIGEST = true ? "2e5b44e9dc857aa080b0fdbc25e3098d25f9ca1deb9250bdd5e7c10f2f96bffc" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
93566
+ NITRO_COMPILER_DIGEST = true ? "46fa7b8faaa964fe0011aec30ae6215d5249f6c1668cc19a35082c35738917cb" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
93426
93567
  nitroSupersetLock = parseLock(nitro_superset_lock_default);
93427
93568
  nitroSupersetKey = (inputs) => nativeEntryKey({ ...inputs, compiler: NITRO_COMPILER_DIGEST });
93428
93569
  published2 = /* @__PURE__ */ new Map();
@@ -96715,29 +96856,31 @@ var init_dev_server_scanner = __esm({
96715
96856
  }
96716
96857
  });
96717
96858
 
96718
- // src/agent-events.ts
96719
- function isAgentEvent(value) {
96720
- if (!value || typeof value !== "object") return false;
96721
- const v7 = value;
96722
- return typeof v7.type === "string" && typeof v7.ts === "number";
96859
+ // src/agent-prompt.ts
96860
+ function readCanvasAgentId(value) {
96861
+ return typeof value === "string" && value.length <= CANVAS_AGENT_ID_MAX_CHARS ? value.trim() || void 0 : void 0;
96723
96862
  }
96724
- function parseAgentEventLine(line) {
96725
- const trimmed = line.trim();
96726
- if (!trimmed) return null;
96727
- try {
96728
- const parsed = JSON.parse(trimmed);
96729
- return isAgentEvent(parsed) ? parsed : null;
96730
- } catch {
96863
+ function readCanvasAgentNote(value) {
96864
+ if (!value || typeof value !== "object") return null;
96865
+ const agentId = readCanvasAgentId(Reflect.get(value, "agentId"));
96866
+ const text6 = Reflect.get(value, "text");
96867
+ const inspectSummary = Reflect.get(value, "inspectSummary");
96868
+ const inspectTrace = Reflect.get(value, "inspectTrace");
96869
+ const crop = Reflect.get(value, "crop");
96870
+ if (!agentId || typeof text6 !== "string" || !text6.trim() || text6.length > 8192 || typeof inspectSummary !== "string" || !inspectSummary.trim() || inspectSummary.length > 8192 || inspectTrace !== void 0 && (typeof inspectTrace !== "string" || inspectTrace.length > 32768) || typeof crop !== "string" || crop.length > MAX_NOTE_CROP_LENGTH || !/^data:image\/(?:webp|png);base64,[A-Za-z0-9+/]+={0,2}$/.test(crop))
96731
96871
  return null;
96732
- }
96872
+ return { agentId, text: text6.trim(), inspectSummary, inspectTrace, crop };
96873
+ }
96874
+ function createCanvasAgentInspectMessage(simId, { agentId, text: text6, inspectSummary, inspectTrace, crop }) {
96875
+ return {
96876
+ id: `inspect-${globalThis.crypto.randomUUID()}`,
96877
+ simId,
96878
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
96879
+ recipientId: agentId,
96880
+ prompt: { text: text6, inspectSummary, inspectTrace },
96881
+ crop
96882
+ };
96733
96883
  }
96734
- var init_agent_events = __esm({
96735
- "src/agent-events.ts"() {
96736
- "use strict";
96737
- }
96738
- });
96739
-
96740
- // src/agent-prompt.ts
96741
96884
  function cleanPromptText(value) {
96742
96885
  return typeof value === "string" ? value.trim() : "";
96743
96886
  }
@@ -96757,14 +96900,41 @@ function encodeAgentPromptEnvelope(input) {
96757
96900
  inspectTrace
96758
96901
  });
96759
96902
  }
96760
- var ENVELOPE_MARKER;
96903
+ var MAX_NOTE_CROP_LENGTH, CANVAS_AGENT_ID_MAX_CHARS, MAX_CANVAS_AGENT_NOTE_BODY_BYTES, AGENT_NOTE_TTL_MS, AGENT_NOTE_QUEUE_LIMIT, ENVELOPE_MARKER;
96761
96904
  var init_agent_prompt = __esm({
96762
96905
  "src/agent-prompt.ts"() {
96763
96906
  "use strict";
96907
+ MAX_NOTE_CROP_LENGTH = 2 * 1024 * 1024;
96908
+ CANVAS_AGENT_ID_MAX_CHARS = 200;
96909
+ MAX_CANVAS_AGENT_NOTE_BODY_BYTES = MAX_NOTE_CROP_LENGTH + 256 * 1024;
96910
+ AGENT_NOTE_TTL_MS = 24 * 60 * 60 * 1e3;
96911
+ AGENT_NOTE_QUEUE_LIMIT = 16;
96764
96912
  ENVELOPE_MARKER = "sootsim-agent-prompt-v1";
96765
96913
  }
96766
96914
  });
96767
96915
 
96916
+ // src/agent-events.ts
96917
+ function isAgentEvent(value) {
96918
+ if (!value || typeof value !== "object") return false;
96919
+ const v7 = value;
96920
+ return typeof v7.type === "string" && typeof v7.ts === "number";
96921
+ }
96922
+ function parseAgentEventLine(line) {
96923
+ const trimmed = line.trim();
96924
+ if (!trimmed) return null;
96925
+ try {
96926
+ const parsed = JSON.parse(trimmed);
96927
+ return isAgentEvent(parsed) ? parsed : null;
96928
+ } catch {
96929
+ return null;
96930
+ }
96931
+ }
96932
+ var init_agent_events = __esm({
96933
+ "src/agent-events.ts"() {
96934
+ "use strict";
96935
+ }
96936
+ });
96937
+
96768
96938
  // src/attached-projects.ts
96769
96939
  function userDataDir() {
96770
96940
  if (overrideDir) return overrideDir;
@@ -97507,6 +97677,7 @@ var init_agent_host = __esm({
97507
97677
  import_node_fs115 = __toESM(require("node:fs"), 1);
97508
97678
  import_node_path116 = __toESM(require("node:path"), 1);
97509
97679
  init_dev_server_scanner();
97680
+ init_agent_prompt();
97510
97681
  init_agent_sessions();
97511
97682
  init_attached_projects();
97512
97683
  WS_OPEN = 1;
@@ -97524,6 +97695,7 @@ var init_agent_host = __esm({
97524
97695
  allSockets = /* @__PURE__ */ new Set();
97525
97696
  inspectQueues = /* @__PURE__ */ new Map();
97526
97697
  inspectListeners = /* @__PURE__ */ new Map();
97698
+ takenNotes = /* @__PURE__ */ new Map();
97527
97699
  // agent wrappers also emit prompt-received from the FIFO reader, but the
97528
97700
  // shell/daemon already knows the user-facing display text when send-prompt
97529
97701
  // is accepted. emit the friendly prompt immediately and suppress the raw
@@ -97622,6 +97794,7 @@ var init_agent_host = __esm({
97622
97794
  }
97623
97795
  this.inspectListeners.clear();
97624
97796
  this.inspectQueues.clear();
97797
+ this.takenNotes.clear();
97625
97798
  this.allSockets.clear();
97626
97799
  }
97627
97800
  // --- dispatch ---
@@ -97641,7 +97814,49 @@ var init_agent_host = __esm({
97641
97814
  case "agent:start-session":
97642
97815
  return this.doStartSession(msg.input ?? {});
97643
97816
  case "agent:listen-inspect":
97644
- return this.listenForInspect(ws, this.requireSimId(msg, type));
97817
+ return this.listenForInspect(
97818
+ ws,
97819
+ this.requireSimId(msg, type),
97820
+ readCanvasAgentId(msg.recipientId)
97821
+ );
97822
+ case "agent:cancel-listen-inspect": {
97823
+ const simId = this.requireSimId(msg, type);
97824
+ const listeners = this.inspectListeners.get(simId) ?? [];
97825
+ const index = listeners.findIndex((listener2) => listener2.socket === ws);
97826
+ if (index < 0) return false;
97827
+ const [listener] = listeners.splice(index, 1);
97828
+ if (!listeners.length) this.inspectListeners.delete(simId);
97829
+ listener?.reject(new AgentSessionError("CANCELED", "inspect listener canceled"));
97830
+ return true;
97831
+ }
97832
+ case "agent:take-inspect-message": {
97833
+ const recipientId = readCanvasAgentId(msg.recipientId);
97834
+ return recipientId ? this.takeInspectMessage(this.requireSimId(msg, type), recipientId, true) : null;
97835
+ }
97836
+ case "agent:send-canvas-note": {
97837
+ const simId = this.requireSimId(msg, type);
97838
+ const note = readCanvasAgentNote(msg.note);
97839
+ if (!note) throw new AgentSessionError("INVALID_NOTE", "invalid canvas note");
97840
+ if (this.inspectQueue(simId).filter((message2) => message2.recipientId).length >= AGENT_NOTE_QUEUE_LIMIT) {
97841
+ throw new AgentSessionError(
97842
+ "INBOX_FULL",
97843
+ "the simulator has too many pending notes"
97844
+ );
97845
+ }
97846
+ const message = createCanvasAgentInspectMessage(simId, note);
97847
+ this.enqueueInspectMessage(message);
97848
+ return { id: message.id };
97849
+ }
97850
+ case "agent:canvas-note-status": {
97851
+ const simId = this.requireSimId(msg, type);
97852
+ this.pruneTakenNotes();
97853
+ const pending2 = this.inspectQueue(simId).some(
97854
+ (message) => message.id === msg.messageId
97855
+ );
97856
+ return {
97857
+ status: pending2 ? "pending" : this.takenNotes.get(msg.messageId)?.simId === simId ? "taken" : "missing"
97858
+ };
97859
+ }
97645
97860
  case "agent:get-inspect-listener-status": {
97646
97861
  const simId = this.requireSimId(msg, type);
97647
97862
  return { simId, listening: (this.inspectListeners.get(simId)?.length ?? 0) > 0 };
@@ -97687,19 +97902,52 @@ var init_agent_host = __esm({
97687
97902
  if (!simId) throw new AgentSessionError("NO_SIM", `${type} requires simId`);
97688
97903
  return simId;
97689
97904
  }
97690
- listenForInspect(socket, simId) {
97691
- const queue2 = this.inspectQueues.get(simId);
97692
- const queued = queue2?.shift();
97693
- if (queued && queue2) {
97694
- if (queue2.length === 0) this.inspectQueues.delete(simId);
97695
- return Promise.resolve(queued);
97696
- }
97905
+ listenForInspect(socket, simId, recipientId) {
97906
+ const queued = this.takeInspectMessage(simId, recipientId, false);
97907
+ if (queued) return Promise.resolve(queued);
97697
97908
  return new Promise((resolve14, reject) => {
97698
97909
  const listeners = this.inspectListeners.get(simId) ?? [];
97699
- listeners.push({ socket, resolve: resolve14, reject });
97910
+ listeners.push({ socket, recipientId, resolve: resolve14, reject });
97700
97911
  this.inspectListeners.set(simId, listeners);
97701
97912
  });
97702
97913
  }
97914
+ pruneTakenNotes() {
97915
+ const now = Date.now();
97916
+ for (const [id, receipt] of this.takenNotes) {
97917
+ if (receipt.expiresAt <= now) this.takenNotes.delete(id);
97918
+ }
97919
+ }
97920
+ markInspectMessageTaken(message) {
97921
+ if (!message.recipientId) return;
97922
+ this.pruneTakenNotes();
97923
+ this.takenNotes.set(message.id, {
97924
+ simId: message.simId,
97925
+ expiresAt: Date.now() + AGENT_NOTE_TTL_MS
97926
+ });
97927
+ }
97928
+ inspectQueue(simId) {
97929
+ const queue2 = this.inspectQueues.get(simId);
97930
+ if (!queue2) return [];
97931
+ const cutoff = Date.now() - AGENT_NOTE_TTL_MS;
97932
+ const pending2 = queue2.filter(
97933
+ (message) => !message.recipientId || Date.parse(message.createdAt) > cutoff
97934
+ );
97935
+ if (pending2.length) this.inspectQueues.set(simId, pending2);
97936
+ else this.inspectQueues.delete(simId);
97937
+ return pending2;
97938
+ }
97939
+ takeInspectMessage(simId, recipientId, notesOnly = false) {
97940
+ const queue2 = this.inspectQueue(simId);
97941
+ const index = queue2.findIndex(
97942
+ (message2) => message2.recipientId ? message2.recipientId === recipientId : !notesOnly
97943
+ );
97944
+ if (index < 0) return null;
97945
+ const [message] = queue2.splice(index, 1);
97946
+ if (!queue2.length) this.inspectQueues.delete(simId);
97947
+ if (!message) return null;
97948
+ this.markInspectMessageTaken(message);
97949
+ return message;
97950
+ }
97703
97951
  sendInspectMessage(simId, prompt) {
97704
97952
  if (!prompt.text.trim()) {
97705
97953
  throw new AgentSessionError("EMPTY_PROMPT", "inspect message cannot be empty");
@@ -97710,17 +97958,26 @@ var init_agent_host = __esm({
97710
97958
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
97711
97959
  prompt
97712
97960
  };
97713
- const listeners = this.inspectListeners.get(simId);
97714
- const listener = listeners?.shift();
97715
- if (listener && listeners) {
97716
- if (listeners.length === 0) this.inspectListeners.delete(simId);
97717
- listener.resolve(message);
97718
- return { ok: true, queued: false, messageId: message.id };
97719
- }
97720
- const queue2 = this.inspectQueues.get(simId) ?? [];
97961
+ const queued = this.enqueueInspectMessage(message);
97962
+ return { ok: true, queued, messageId: message.id };
97963
+ }
97964
+ enqueueInspectMessage(message) {
97965
+ const { simId, recipientId } = message;
97966
+ const listeners = this.inspectListeners.get(simId) ?? [];
97967
+ const index = listeners.findIndex(
97968
+ (listener) => !recipientId || listener.recipientId === recipientId
97969
+ );
97970
+ if (index >= 0) {
97971
+ const [listener] = listeners.splice(index, 1);
97972
+ if (!listeners.length) this.inspectListeners.delete(simId);
97973
+ this.markInspectMessageTaken(message);
97974
+ listener?.resolve(message);
97975
+ return false;
97976
+ }
97977
+ const queue2 = this.inspectQueue(simId);
97721
97978
  queue2.push(message);
97722
97979
  this.inspectQueues.set(simId, queue2);
97723
- return { ok: true, queued: true, messageId: message.id };
97980
+ return true;
97724
97981
  }
97725
97982
  async doStartSession(input) {
97726
97983
  const project2 = findProjectById(input.projectId);
@@ -124162,8 +124419,18 @@ var init_metro_bundle_assets = __esm({
124162
124419
  var stream_exports = {};
124163
124420
  __export(stream_exports, {
124164
124421
  STREAM_FLAG: () => STREAM_FLAG,
124422
+ readLocalStreamRecord: () => readLocalStreamRecord,
124165
124423
  runStreamCommand: () => runStreamCommand
124166
124424
  });
124425
+ function readLocalStreamRecord(simId) {
124426
+ const file = (0, import_node_path151.join)(rnxHomeDir(), "streams", `${encodeURIComponent(simId)}.json`);
124427
+ try {
124428
+ return recordSchema.parse(JSON.parse((0, import_node_fs148.readFileSync)(file, "utf8")));
124429
+ } catch (error) {
124430
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
124431
+ throw error;
124432
+ }
124433
+ }
124167
124434
  async function runStreamCommand(args, opts = {}) {
124168
124435
  const parsed = parseBridgeCliArgs(args, { port: opts.port });
124169
124436
  const action = parsed.positional[0] ?? "status";
@@ -124204,13 +124471,7 @@ async function runStreamCommand(args, opts = {}) {
124204
124471
  };
124205
124472
  if (action === "stop") {
124206
124473
  await callInBridge(bridge, "SootSim.bridges.videoStream.stop");
124207
- let record6 = null;
124208
- try {
124209
- record6 = recordSchema.parse(JSON.parse((0, import_node_fs148.readFileSync)(file, "utf8")));
124210
- } catch (error) {
124211
- if (!(error instanceof Error && "code" in error && error.code === "ENOENT"))
124212
- throw error;
124213
- }
124474
+ const record6 = readLocalStreamRecord(simId);
124214
124475
  if (record6) await stopSession(record6);
124215
124476
  (0, import_node_fs148.rmSync)(file, { force: true });
124216
124477
  console.log(" stream: off");