@synopackageland/cli 0.4.0 → 0.4.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 (438) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +37 -0
  3. package/dist/build-spk/generator.js +3 -0
  4. package/dist/build-spk/notices.d.ts +5 -0
  5. package/dist/build-spk/notices.js +60 -0
  6. package/dist/cli.js +9 -2
  7. package/dist/error-registry.js +20 -0
  8. package/dist/init.d.ts +4 -0
  9. package/dist/init.js +20 -12
  10. package/dist/standalone/build.js +3 -1
  11. package/dist/standalone/daemon.d.ts +23 -0
  12. package/dist/standalone/daemon.js +114 -0
  13. package/dist/standalone/dsm-window.d.ts +1 -1
  14. package/dist/standalone/dsm-window.js +50 -10
  15. package/dist/standalone/helper-inventory.d.ts +16 -0
  16. package/dist/standalone/helper-inventory.js +2 -0
  17. package/dist/standalone/helper.d.ts +2 -12
  18. package/dist/standalone/helper.js +8 -7
  19. package/dist/standalone/host-adapter.d.ts +5 -0
  20. package/dist/standalone/host-adapter.js +148 -0
  21. package/dist/standalone/host-platform.d.ts +13 -0
  22. package/dist/standalone/host-platform.js +42 -0
  23. package/dist/standalone/host-types.d.ts +49 -0
  24. package/dist/standalone/host-types.js +1 -0
  25. package/dist/standalone/inspect-helper.d.ts +6 -0
  26. package/dist/standalone/inspect-helper.js +88 -0
  27. package/dist/standalone/inspect-spk.d.ts +2 -0
  28. package/dist/standalone/inspect-spk.js +49 -0
  29. package/dist/standalone/lifecycle-helper.d.ts +2 -0
  30. package/dist/standalone/lifecycle-helper.js +12 -0
  31. package/dist/standalone/lifecycle.d.ts +3 -0
  32. package/dist/standalone/lifecycle.js +53 -0
  33. package/dist/standalone/manifest.d.ts +2 -0
  34. package/dist/standalone/manifest.js +4 -1
  35. package/dist/standalone/reopen-events.d.ts +2 -0
  36. package/dist/standalone/reopen-events.js +28 -0
  37. package/dist/standalone/root-messages.js +9 -0
  38. package/dist/standalone/root-window.d.ts +4 -3
  39. package/dist/standalone/root-window.js +17 -5
  40. package/dist/standalone/spk.d.ts +4 -3
  41. package/dist/standalone/spk.js +20 -33
  42. package/dist/template-paths.d.ts +2 -0
  43. package/dist/template-paths.js +9 -0
  44. package/dist/templates/_daemon/fixture_linux_test.go +15 -0
  45. package/dist/templates/_daemon/fixture_other_test.go +7 -0
  46. package/dist/templates/_daemon/go.mod +3 -0
  47. package/dist/templates/_daemon/main.go +608 -0
  48. package/dist/templates/_daemon/main_test.go +242 -0
  49. package/dist/templates/_daemon/process_linux.go +55 -0
  50. package/dist/templates/_daemon/process_linux_test.go +161 -0
  51. package/dist/templates/_daemon/process_other.go +14 -0
  52. package/dist/templates/_daemon/testdata/child.go +41 -0
  53. package/dist/templates/_shared/GO-LICENSE +27 -0
  54. package/dist/templates/_shared/GO-PATENTS +22 -0
  55. package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
  56. package/dist/templates/_shared/notice-overrides/index.json +14 -0
  57. package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
  58. package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
  59. package/dist/templates/_shared/third-party-notices.mjs +51 -0
  60. package/dist/templates/native-go/README.md +57 -1
  61. package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
  62. package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
  63. package/dist/templates/native-go/backend/go.mod +4 -0
  64. package/dist/templates/native-go/backend/go.sum +4 -0
  65. package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
  66. package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
  67. package/dist/templates/native-go/backend/internal/api/registry.go +14 -4
  68. package/dist/templates/native-go/backend/internal/api/server.go +4 -0
  69. package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
  70. package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
  71. package/dist/templates/native-go/backend/internal/app/routes.go +11 -0
  72. package/dist/templates/native-go/backend/internal/app/routes_test.go +10 -5
  73. package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
  74. package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
  75. package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
  76. package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
  77. package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
  78. package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
  79. package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
  80. package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
  81. package/dist/templates/native-go/backend/internal/helper/control.go +226 -21
  82. package/dist/templates/native-go/backend/internal/helper/control_test.go +10 -2
  83. package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
  84. package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
  85. package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
  86. package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
  87. package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
  88. package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
  89. package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
  90. package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
  91. package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
  92. package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
  93. package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
  94. package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
  95. package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
  96. package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
  97. package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
  98. package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
  99. package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
  100. package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
  101. package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
  102. package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
  103. package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
  104. package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
  105. package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
  106. package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
  107. package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
  108. package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
  109. package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
  110. package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
  111. package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
  112. package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
  113. package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
  114. package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
  115. package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
  116. package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
  117. package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
  118. package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
  119. package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
  120. package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
  121. package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
  122. package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
  123. package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
  124. package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
  125. package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
  126. package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
  127. package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
  128. package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
  129. package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
  130. package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
  131. package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
  132. package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
  133. package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
  134. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
  135. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
  136. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
  137. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
  138. package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
  139. package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
  140. package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
  141. package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
  142. package/dist/templates/native-go/backend/internal/helper/process_linux.go +11 -1
  143. package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
  144. package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
  145. package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
  146. package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
  147. package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
  148. package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
  149. package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
  150. package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
  151. package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
  152. package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
  153. package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
  154. package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
  155. package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
  156. package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
  157. package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
  158. package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
  159. package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
  160. package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
  161. package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
  162. package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
  163. package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
  164. package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
  165. package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
  166. package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
  167. package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
  168. package/dist/templates/native-go/backend/internal/helper/server_linux.go +44 -3
  169. package/dist/templates/native-go/backend/internal/helper/status.go +74 -11
  170. package/dist/templates/native-go/backend/internal/helper/status_test.go +83 -0
  171. package/dist/templates/native-go/backend/internal/helper/supervision.go +28 -5
  172. package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
  173. package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
  174. package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
  175. package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
  176. package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
  177. package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
  178. package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
  179. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
  180. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
  181. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
  182. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
  183. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
  184. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
  185. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
  186. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
  187. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
  188. package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
  189. package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
  190. package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
  191. package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
  192. package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
  193. package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
  194. package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
  195. package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
  196. package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
  197. package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
  198. package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
  199. package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
  200. package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
  201. package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
  202. package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
  203. package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
  204. package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
  205. package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
  206. package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
  207. package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
  208. package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
  209. package/dist/templates/native-go/ui/app.js +8 -1
  210. package/dist/templates/native-go-better-auth/node/build.mjs +2 -0
  211. package/dist/templates/native-go-vue/README.md +115 -1
  212. package/dist/templates/native-go-vue/frontend/DESIGN.md +1 -1
  213. package/dist/templates/native-go-vue/frontend/package-lock.json +132 -229
  214. package/dist/templates/native-go-vue/frontend/package.json +1 -1
  215. package/dist/templates/native-go-vue/frontend/src/App.vue +33 -6
  216. package/dist/templates/native-go-vue/frontend/src/context.ts +41 -2
  217. package/dist/templates/native-go-vue/frontend/src/main.ts +4 -1
  218. package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
  219. package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
  220. package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
  221. package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
  222. package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
  223. package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
  224. package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
  225. package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
  226. package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
  227. package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
  228. package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
  229. package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
  230. package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
  231. package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
  232. package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
  233. package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
  234. package/dist/templates/native-go-vue/frontend/src/style.css +17 -0
  235. package/dist/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
  236. package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
  237. package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
  238. package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
  239. package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -1
  240. package/dist/templates/native-go-vue/frontend/vite.config.ts +6 -4
  241. package/package.json +3 -2
  242. package/templates/_daemon/fixture_linux_test.go +15 -0
  243. package/templates/_daemon/fixture_other_test.go +7 -0
  244. package/templates/_daemon/go.mod +3 -0
  245. package/templates/_daemon/main.go +608 -0
  246. package/templates/_daemon/main_test.go +242 -0
  247. package/templates/_daemon/process_linux.go +55 -0
  248. package/templates/_daemon/process_linux_test.go +161 -0
  249. package/templates/_daemon/process_other.go +14 -0
  250. package/templates/_daemon/testdata/child.go +41 -0
  251. package/templates/_shared/GO-LICENSE +27 -0
  252. package/templates/_shared/GO-PATENTS +22 -0
  253. package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
  254. package/templates/_shared/notice-overrides/index.json +14 -0
  255. package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
  256. package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
  257. package/templates/_shared/third-party-notices.mjs +51 -0
  258. package/templates/native-go/README.md +57 -1
  259. package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
  260. package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
  261. package/templates/native-go/backend/go.mod +4 -0
  262. package/templates/native-go/backend/go.sum +4 -0
  263. package/templates/native-go/backend/internal/api/binary.go +154 -0
  264. package/templates/native-go/backend/internal/api/binary_test.go +165 -0
  265. package/templates/native-go/backend/internal/api/registry.go +14 -4
  266. package/templates/native-go/backend/internal/api/server.go +4 -0
  267. package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
  268. package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
  269. package/templates/native-go/backend/internal/app/routes.go +11 -0
  270. package/templates/native-go/backend/internal/app/routes_test.go +10 -5
  271. package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
  272. package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
  273. package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
  274. package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
  275. package/templates/native-go/backend/internal/helper/cohort.go +393 -0
  276. package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
  277. package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
  278. package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
  279. package/templates/native-go/backend/internal/helper/control.go +226 -21
  280. package/templates/native-go/backend/internal/helper/control_test.go +10 -2
  281. package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
  282. package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
  283. package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
  284. package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
  285. package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
  286. package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
  287. package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
  288. package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
  289. package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
  290. package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
  291. package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
  292. package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
  293. package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
  294. package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
  295. package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
  296. package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
  297. package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
  298. package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
  299. package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
  300. package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
  301. package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
  302. package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
  303. package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
  304. package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
  305. package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
  306. package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
  307. package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
  308. package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
  309. package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
  310. package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
  311. package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
  312. package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
  313. package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
  314. package/templates/native-go/backend/internal/helper/lease.go +112 -0
  315. package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
  316. package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
  317. package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
  318. package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
  319. package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
  320. package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
  321. package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
  322. package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
  323. package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
  324. package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
  325. package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
  326. package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
  327. package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
  328. package/templates/native-go/backend/internal/helper/observation.go +204 -0
  329. package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
  330. package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
  331. package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
  332. package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
  333. package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
  334. package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
  335. package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
  336. package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
  337. package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
  338. package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
  339. package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
  340. package/templates/native-go/backend/internal/helper/process_linux.go +11 -1
  341. package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
  342. package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
  343. package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
  344. package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
  345. package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
  346. package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
  347. package/templates/native-go/backend/internal/helper/readonly.go +105 -0
  348. package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
  349. package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
  350. package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
  351. package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
  352. package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
  353. package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
  354. package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
  355. package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
  356. package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
  357. package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
  358. package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
  359. package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
  360. package/templates/native-go/backend/internal/helper/repair.go +132 -0
  361. package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
  362. package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
  363. package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
  364. package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
  365. package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
  366. package/templates/native-go/backend/internal/helper/server_linux.go +44 -3
  367. package/templates/native-go/backend/internal/helper/status.go +74 -11
  368. package/templates/native-go/backend/internal/helper/status_test.go +83 -0
  369. package/templates/native-go/backend/internal/helper/supervision.go +28 -5
  370. package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
  371. package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
  372. package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
  373. package/templates/native-go/backend/internal/helper/supervisor_linux.go +187 -16
  374. package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +618 -7
  375. package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
  376. package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
  377. package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
  378. package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
  379. package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
  380. package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
  381. package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
  382. package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
  383. package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
  384. package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
  385. package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
  386. package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
  387. package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
  388. package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
  389. package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
  390. package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
  391. package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
  392. package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
  393. package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
  394. package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
  395. package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
  396. package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
  397. package/templates/native-go/backend/internal/helper/write.go +77 -0
  398. package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
  399. package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
  400. package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
  401. package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
  402. package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
  403. package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
  404. package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
  405. package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
  406. package/templates/native-go/backend/internal/helper/write_test.go +53 -0
  407. package/templates/native-go/ui/app.js +8 -1
  408. package/templates/native-go-better-auth/node/build.mjs +2 -0
  409. package/templates/native-go-vue/README.md +115 -1
  410. package/templates/native-go-vue/frontend/DESIGN.md +1 -1
  411. package/templates/native-go-vue/frontend/package-lock.json +132 -229
  412. package/templates/native-go-vue/frontend/package.json +1 -1
  413. package/templates/native-go-vue/frontend/src/App.vue +33 -6
  414. package/templates/native-go-vue/frontend/src/context.ts +41 -2
  415. package/templates/native-go-vue/frontend/src/main.ts +4 -1
  416. package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
  417. package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
  418. package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
  419. package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
  420. package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
  421. package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
  422. package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
  423. package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
  424. package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
  425. package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
  426. package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
  427. package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
  428. package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
  429. package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
  430. package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
  431. package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
  432. package/templates/native-go-vue/frontend/src/style.css +17 -0
  433. package/templates/native-go-vue/frontend/test/apps.test.ts +44 -2
  434. package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
  435. package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
  436. package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
  437. package/templates/native-go-vue/frontend/tsconfig.json +1 -1
  438. package/templates/native-go-vue/frontend/vite.config.ts +6 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 synopkgland
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -17,8 +17,45 @@ synopkgland --project ./my-app deploy --host my-nas --arch x86_64
17
17
 
18
18
  Native-go requires Go 1.24+; binary consumes checked prebuilt archives; container SPKs use DSM resource workers. Root operations require per-operation DSM approval. Remove root tasks before uninstall; changed task text needs fresh approval.
19
19
 
20
+ For native-go integration, `--ui vue --integration go --integration-protocol 2
21
+ --data-access relaxed` selects the S1R build policy (`integration.dataAccess`).
22
+ Default data access remains unavailable. Mode is pinned in helper/CGI inventory
23
+ and requires rebuild and new root approval when changed. Missing certified DSM
24
+ adapters still refuse NAS access; this setting does not open write gates.
25
+ Recreated accounts with the same UID and username may retain grants; a change to
26
+ either invalidates all grants for that identity and requires new authorization.
27
+
20
28
  For containers, `--share MEDIA_SHARE=photos`, `--run-as RUN_AS=alice` and `--param APP_MODE=prod` supply declared values. Keep upstream target paths. Fixed service credentials govern mount access, while each upstream app owns user login and authorization.
21
29
 
22
30
  `dev` and `test` run local Compose. `info` and `log` read DSM package state/status; status output is not application log streaming. `skill path/list/show` exposes the bundled authoring guidance. `--dev` is available for container/binary development package identities. There is no release or public-submit command; deploy never publishes.
23
31
 
24
32
  See the repository's docs/independent-packages.md for supported parameters, lifecycle and limitations.
33
+ ## Licensing
34
+
35
+ The CLI and original templates are MIT licensed, Copyright (c) 2026 synopkgland.
36
+ Third-party components retain their own terms.
37
+ Generated projects keep these template terms in `LICENSES/TEMPLATE.txt`.
38
+ `init` does not create an app-level `LICENSE` or select a license for your work:
39
+ choose your own terms and copyright holder in the project root `LICENSE`.
40
+ Retain the template and dependency notices when distributing derived code.
41
+
42
+ SPKs place legal material under the installed payload's `LICENSES/` directory:
43
+ `TEMPLATE.txt`, optional developer `APP.txt`, Go's `GO-LICENSE`/`GO-PATENTS`,
44
+ `GO-THIRD_PARTY_NOTICES.txt`, optional `HELPER-THIRD_PARTY_NOTICES.txt`, and
45
+ `ui/` or `better-auth/` notice trees. The helper also retains its existing
46
+ `integration/THIRD_PARTY_NOTICES.txt` location for compatibility.
47
+
48
+ Vue and Better Auth builds generate full notices plus `inventory.json` from
49
+ the installed, locked production dependency tree (a conservative superset of
50
+ bundled code). Missing text or a version mismatch fails the build. Run `npm ci`
51
+ in the generated frontend/Node directories before building. For
52
+ `@better-auth/utils` 0.4.2 and 0.5.0, which omit license text in their npm
53
+ archives, the tool retains the upstream project's subsequently added MIT
54
+ license, with its pinned source commit and exact npm integrity recorded in
55
+ `notice-overrides/index.json`. Unknown missing licenses require a new review;
56
+ the tool never manufactures a license from a package's SPDX field.
57
+
58
+ Keep `backend/THIRD_PARTY_NOTICES.txt` current if you change Go modules.
59
+ The supplied notice inventory covers the pinned template dependencies and Go
60
+ runtime; arbitrary developer binaries, Go module additions, container images,
61
+ custom UI bundles and upstream applications need their own notice inventory.
@@ -12,6 +12,7 @@ import { validateProject } from "../validate.js";
12
12
  import { writeDsmWindowIcons, writePackageCenterIcons } from "./dsm-icons.js";
13
13
  import { infoArchValue } from "./dsm-arch.js";
14
14
  import { createReproducibleTar } from "./reproducible-archive.js";
15
+ import { copyProjectNotices } from "./notices.js";
15
16
  import { renderDeleteAppDataBlock } from "./delete-app-data.js";
16
17
  import { loadNative } from "../native/load.js";
17
18
  import { materializeNativePayload } from "./native-payload.js";
@@ -115,6 +116,7 @@ export async function buildSpk(options) {
115
116
  chmodSync(join(packageDir, "native.yaml"), FILE_MODE);
116
117
  const outputPath = options.outputPath ??
117
118
  join(options.project.root, `${String(contract.package)}-${options.archFamily}.spk`);
119
+ copyProjectNotices(options.project.root, packageDir);
118
120
  await createDeterministicSpk(staging, outputPath);
119
121
  return { ok: true, outputPath, errors: [] };
120
122
  }
@@ -224,6 +226,7 @@ export async function buildSpk(options) {
224
226
  chmodSync(join(staging, "package", "ui", "config"), FILE_MODE);
225
227
  }
226
228
  const outputPath = options.outputPath ?? join(options.project.root, `${String(contract.package)}.spk`);
229
+ copyProjectNotices(options.project.root, join(staging, 'package'));
227
230
  await createDeterministicSpk(staging, outputPath);
228
231
  return { ok: true, outputPath, errors: [] };
229
232
  }
@@ -0,0 +1,5 @@
1
+ /** Copy legal text only; never follow a project-supplied symlink. */
2
+ export declare function copyNoticeTree(source: string, target: string): void;
3
+ /** Fixed payload location, independent of app code/binary paths. */
4
+ export declare function copyProjectNotices(root: string, payload: string): void;
5
+ export declare function copyStandaloneNotices(root: string, uiDir: string, payload: string, go: boolean, helper: boolean, identity: boolean, goDir?: string): void;
@@ -0,0 +1,60 @@
1
+ import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync } from 'node:fs';
2
+ import { dirname, join } from 'node:path';
3
+ /** Copy legal text only; never follow a project-supplied symlink. */
4
+ export function copyNoticeTree(source, target) {
5
+ const stat = lstatSync(source);
6
+ if (stat.isSymbolicLink())
7
+ throw new Error(`[NOTICE_UNSAFE] Symlink in notice tree: ${source}`);
8
+ if (stat.isDirectory()) {
9
+ mkdirSync(target, { recursive: true });
10
+ for (const name of readdirSync(source).sort())
11
+ copyNoticeTree(join(source, name), join(target, name));
12
+ }
13
+ else if (stat.isFile() && stat.size <= 8 * 1024 * 1024) {
14
+ mkdirSync(dirname(target), { recursive: true });
15
+ copyFileSync(source, target);
16
+ }
17
+ else
18
+ throw new Error(`[NOTICE_UNSAFE] Notice must be a bounded regular file: ${source}`);
19
+ }
20
+ /** Fixed payload location, independent of app code/binary paths. */
21
+ export function copyProjectNotices(root, payload) {
22
+ const dest = join(payload, 'LICENSES');
23
+ if (existsSync(join(root, 'LICENSES')))
24
+ copyNoticeTree(join(root, 'LICENSES'), dest);
25
+ if (existsSync(join(root, 'LICENSE')))
26
+ copyNoticeTree(join(root, 'LICENSE'), join(dest, 'APP.txt'));
27
+ }
28
+ export function copyStandaloneNotices(root, uiDir, payload, go, helper, identity, goDir = join(root, 'backend')) {
29
+ copyProjectNotices(root, payload);
30
+ const dest = join(payload, 'LICENSES');
31
+ const shared = new URL('../../templates/_shared/', import.meta.url);
32
+ if (go || helper) {
33
+ mkdirSync(dest, { recursive: true });
34
+ for (const name of ['GO-LICENSE', 'GO-PATENTS'])
35
+ copyFileSync(new URL(name, shared), join(dest, name));
36
+ if (existsSync(join(goDir, 'THIRD_PARTY_NOTICES.txt')))
37
+ copyNoticeTree(join(goDir, 'THIRD_PARTY_NOTICES.txt'), join(dest, 'GO-THIRD_PARTY_NOTICES.txt'));
38
+ }
39
+ if (helper)
40
+ copyFileSync(new URL('../../templates/native-go/backend/THIRD_PARTY_NOTICES.txt', import.meta.url), join(dest, 'HELPER-THIRD_PARTY_NOTICES.txt'));
41
+ const frontend = join(root, 'frontend/package.json');
42
+ const usesUi = existsSync(frontend) && Boolean(JSON.parse(readFileSync(frontend, 'utf8')).dependencies?.['@synopackageland/ui']);
43
+ if (usesUi) {
44
+ for (const name of ['UI-LICENSE', 'UI-THIRD_PARTY.md', 'THIRD_PARTY_NOTICES.txt', 'inventory.json']) {
45
+ const source = join(uiDir, 'LICENSES', name);
46
+ if (!existsSync(source))
47
+ throw new Error(`[NOTICE_MISSING] UI notice missing: ${source}; rebuild frontend`);
48
+ }
49
+ }
50
+ if (existsSync(join(uiDir, 'LICENSES')))
51
+ copyNoticeTree(join(uiDir, 'LICENSES'), join(dest, 'ui'));
52
+ if (identity) {
53
+ const source = join(root, 'node/dist/LICENSES');
54
+ for (const name of ['THIRD_PARTY_NOTICES.txt', 'inventory.json']) {
55
+ if (!existsSync(join(source, name)))
56
+ throw new Error(`[NOTICE_MISSING] Better Auth notice missing: ${name}; rebuild node bundle`);
57
+ }
58
+ copyNoticeTree(source, join(dest, 'better-auth'));
59
+ }
60
+ }
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { planDeployment, deployStandalone } from "./deploy/plan.js";
2
2
  import { Command } from "commander";
3
- import { renameSync } from "node:fs";
3
+ import { readFileSync, renameSync } from "node:fs";
4
4
  import { resolve, dirname } from "node:path";
5
5
  import { findProjectRoot } from "./discovery.js";
6
6
  import { loadContract } from "./contract/load.js";
@@ -21,6 +21,8 @@ import { resolveInstallParameterExtraValues } from "./deploy/param-values.js";
21
21
  import { findStandaloneRoot, loadStandaloneManifest } from "./standalone/manifest.js";
22
22
  import { buildStandalone } from "./standalone/build.js";
23
23
  import { inspectSpk } from "./standalone/inspect-spk.js";
24
+ import { templatesRoot } from "./template-paths.js";
25
+ import { join } from "node:path";
24
26
  function collectKvOption(value, previous, flag, example) {
25
27
  const separator = value.indexOf("=");
26
28
  if (separator <= 0) {
@@ -54,6 +56,7 @@ function formatSpkInspection(spk, report) {
54
56
  `arch:${report.arch ?? "?"} runtime:${report.kind ?? "?"}`,
55
57
  `簽署:${report.signed ? "有 Synology 簽章" : "未簽署(Package Center 需允許任何發行者)"}`,
56
58
  `CGI:${report.cgi ?? "無"}`,
59
+ ...(report.integration ? [`integration protocol:${report.integration.protocol};NAS data mode:${report.integration.dataAccess};policy:${report.integration.dataAccess === "relaxed" ? "UID + username" : "unavailable"};inspect 只核對產物,不證明 runtime adapters/DSM 認證`] : []),
57
60
  "payload:",
58
61
  ...report.payload.map((entry) => ` ${entry.mode} ${entry.path}`),
59
62
  ];
@@ -163,8 +166,10 @@ export async function runCli(argv) {
163
166
  .option("--package <id>", "native-go:INFO.package(預設由目錄名產生,例如 photo-tagger → PhotoTagger)")
164
167
  .option("--name <display>", "native-go:顯示名稱(預設由目錄名產生)")
165
168
  .option("--privilege <none|root>", "native-go:root 另加由 DSM 管理員在套件視窗核准的 root 操作(預設 none)")
166
- .option("--ui <plain|vue>", "native-go:沿用 UI 0.3.1 的 Vue 介面(預設 plain)")
169
+ .option("--ui <plain|vue>", `native-go:沿用 UI ${JSON.parse(readFileSync(join(templatesRoot(), "native-go-vue/frontend/package.json"), "utf8")).dependencies["@synopackageland/ui"]} 的 Vue 介面(預設 plain)`)
167
170
  .option("--integration <go|better-auth>", "native-go --ui vue:每包 helper 與私有範例;better-auth 才加入 Node")
171
+ .option("--integration-protocol <1|2>", "helper inventory protocol(預設 1);2 可選 NAS data policy,缺已認證 adapters 仍拒絕")
172
+ .option("--data-access <unavailable|relaxed>", "protocol 2 build-time 身分模式(預設 unavailable);relaxed 不繞過 DSM/App/lifecycle gates")
168
173
  .argument("[dir]", "目標目錄", ".")
169
174
  .addHelpText("after", `
170
175
  模板分兩類:
@@ -208,6 +213,8 @@ export async function runCli(argv) {
208
213
  privilege: options.privilege,
209
214
  ui: options.ui,
210
215
  integration: options.integration,
216
+ integrationProtocol: options.integrationProtocol === undefined ? undefined : (["1", "2"].includes(options.integrationProtocol) ? Number(options.integrationProtocol) : NaN),
217
+ dataAccess: options.dataAccess,
211
218
  });
212
219
  }
213
220
  catch (error) {
@@ -579,6 +579,26 @@ export const ERROR_REGISTRY = {
579
579
  "description": "每包 helper 的 integration 宣告不合法。",
580
580
  "suggestion": "使用 native-go、privilege: root、protocol: 1 和 workers map;不要自訂 helper_ 操作。"
581
581
  },
582
+ "STANDALONE_DAEMON_INVALID": {
583
+ "code": "STANDALONE_DAEMON_INVALID",
584
+ "description": "套件 daemon 的宣告不符合固定 argv、環境與生命週期契約。",
585
+ "suggestion": "核對 daemon.exec、各架構 targets、args、env、uninstall_args 與整數秒 timeouts;移除 shell、user 與自訂 conf。"
586
+ },
587
+ "STANDALONE_DAEMON_BUILD_FAILED": {
588
+ "code": "STANDALONE_DAEMON_BUILD_FAILED",
589
+ "description": "無法建置套件 daemon 的 Go supervisor。",
590
+ "suggestion": "安裝 Go 1.24 以上並檢查 compiler stderr;NAS 不需要 Go toolchain。"
591
+ },
592
+ "STANDALONE_DAEMON_PAYLOAD_INVALID": {
593
+ "code": "STANDALONE_DAEMON_PAYLOAD_INVALID",
594
+ "description": "daemon payload 不是專案內的有界、無連結目錄。",
595
+ "suggestion": "重建各架構 bundle;移除 symlink、特殊檔與 setid,並將大小限制在 512 MiB。"
596
+ },
597
+ "STANDALONE_DAEMON_ARTIFACT_REQUIRED": {
598
+ "code": "STANDALONE_DAEMON_ARTIFACT_REQUIRED",
599
+ "description": "組裝 daemon SPK 時缺少已建置的 supervisor。",
600
+ "suggestion": "透過 synopkgland build-spk 建置完整產物,不直接呼叫缺少 controller 的 assembler。"
601
+ },
582
602
  "HELPER_WORKER_UNSAFE": {
583
603
  "code": "HELPER_WORKER_UNSAFE",
584
604
  "description": "worker inventory 檔案不在專案內或不是一般檔案。",
package/dist/init.d.ts CHANGED
@@ -10,5 +10,9 @@ export interface InitOptions {
10
10
  privilege?: "none" | "root";
11
11
  ui?: "plain" | "vue";
12
12
  integration?: "go" | "better-auth";
13
+ /** Pin the helper inventory protocol; protocol 2 still refuses NAS data. */
14
+ integrationProtocol?: 1 | 2;
15
+ /** Protocol 2 policy only; unavailable adapters still refuse data. */
16
+ dataAccess?: "unavailable" | "relaxed";
13
17
  }
14
18
  export declare function initFromTemplate(template: TemplateName, targetDir: string, options?: InitOptions): void;
package/dist/init.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
2
- import { basename, dirname, join, relative } from "node:path";
3
- import { fileURLToPath } from "node:url";
2
+ import { basename, join, relative } from "node:path";
3
+ import { templatesRoot } from "./template-paths.js";
4
4
  const TEMPLATE_NAMES = [
5
5
  "hello-web",
6
6
  "hello-web-page",
@@ -15,14 +15,6 @@ export function isTemplateName(value) {
15
15
  export function listTemplates() {
16
16
  return [...TEMPLATE_NAMES];
17
17
  }
18
- function templatesRoot() {
19
- const moduleDir = dirname(fileURLToPath(import.meta.url));
20
- const distTemplates = join(moduleDir, "templates");
21
- if (existsSync(distTemplates)) {
22
- return distTemplates;
23
- }
24
- return join(moduleDir, "..", "templates");
25
- }
26
18
  /**
27
19
  * native-go --privilege root: files laid over the native-go template, and the
28
20
  * files they replace.
@@ -69,15 +61,27 @@ export function initFromTemplate(template, targetDir, options = {}) {
69
61
  ...(options.integration ? ["native-go-integration"] : []),
70
62
  ...(options.integration === "better-auth" ? ["native-go-better-auth"] : []),
71
63
  ].map(name => join(templatesRoot(), name));
72
- const files = [...templateFiles(source), ...overlays.flatMap(root => templateFiles(root))];
64
+ // Shared legal resources also live in the CLI package; only the template
65
+ // terms are an unconditional part of a generated project.
66
+ const shared = join(templatesRoot(), "_shared");
67
+ const files = [...templateFiles(source), "LICENSES/TEMPLATE.txt", ...overlays.flatMap(root => templateFiles(root)),
68
+ ...(options.ui === "vue" ? ["frontend/third-party-notices.mjs"] : []),
69
+ ...(options.integration === "better-auth" ? ["node/third-party-notices.mjs", ...templateFiles(join(shared, 'notice-overrides')).map(file => `node/notice-overrides/${file}`)] : [])];
73
70
  const collisions = files.map(targetName).filter((file) => existsSync(join(targetDir, file)));
74
71
  if (collisions.length > 0) {
75
72
  throw new Error(`[INIT_TARGET_NOT_EMPTY] ${targetDir} 已有 ${collisions.join(", ")};init 不會覆蓋既有檔案。請改用空目錄。`);
76
73
  }
77
74
  mkdirSync(targetDir, { recursive: true });
78
75
  cpSync(source, targetDir, { recursive: true });
76
+ mkdirSync(join(targetDir, "LICENSES"), { recursive: true });
77
+ cpSync(join(shared, "LICENSES/TEMPLATE.txt"), join(targetDir, "LICENSES/TEMPLATE.txt"));
79
78
  for (const overlay of overlays)
80
79
  cpSync(overlay, targetDir, { recursive: true });
80
+ for (const dir of [...(options.ui === "vue" ? ["frontend"] : []), ...(options.integration === "better-auth" ? ["node"] : [])]) {
81
+ cpSync(join(shared, "third-party-notices.mjs"), join(targetDir, dir, "third-party-notices.mjs"));
82
+ }
83
+ if (options.integration === "better-auth")
84
+ cpSync(join(shared, 'notice-overrides'), join(targetDir, 'node/notice-overrides'), { recursive: true });
81
85
  if (privilege === "root")
82
86
  ROOT_REPLACED.forEach(file => rmSync(join(targetDir, file)));
83
87
  for (const [from, to] of Object.entries(RENAMED)) {
@@ -104,7 +108,7 @@ export function initFromTemplate(template, targetDir, options = {}) {
104
108
  const mod = join(targetDir, "backend/go.mod");
105
109
  writeFileSync(mod, readFileSync(mod, "utf8").replace("go 1.24", "go 1.25"));
106
110
  const manifest = join(targetDir, "dsm-package.yaml");
107
- writeFileSync(manifest, readFileSync(manifest, "utf8") + "\nintegration:\n protocol: 1\n workers: {}\n" + (options.integration === "better-auth" ? " identity: better-auth\n" : ""));
111
+ writeFileSync(manifest, readFileSync(manifest, "utf8") + `\nintegration:\n protocol: ${options.integrationProtocol ?? 1}\n workers: {}\n` + (options.integration === "better-auth" ? " identity: better-auth\n" : "") + (options.dataAccess ? ` dataAccess: ${options.dataAccess}\n` : ""));
108
112
  const routes = join(targetDir, "backend/internal/app/routes.go");
109
113
  writeFileSync(routes, readFileSync(routes, "utf8").replace("return append(routes, cfg.rootRoutes()...)", "routes = append(routes, cfg.integrationRoutes()...)\n\treturn append(routes, cfg.rootRoutes()...)"));
110
114
  }
@@ -119,6 +123,10 @@ function substitutionsFor(template, targetDir, options) {
119
123
  throw new Error("[INIT_UI_INVALID] --ui 只接受 plain 或 vue。");
120
124
  if (options.integration !== undefined && !["go", "better-auth"].includes(options.integration))
121
125
  throw new Error("[INIT_INTEGRATION_INVALID] --integration 只接受 go 或 better-auth。");
126
+ if (options.dataAccess !== undefined && (!options.integration || options.integrationProtocol !== 2 || !["unavailable", "relaxed"].includes(options.dataAccess)))
127
+ throw new Error("[INIT_DATA_ACCESS_INVALID] --data-access 只接受 unavailable 或 relaxed,且需要 --integration 與 --integration-protocol 2;缺少已認證 adapter 仍拒絕 NAS 操作。");
128
+ if (options.integrationProtocol !== undefined && (!options.integration || ![1, 2].includes(options.integrationProtocol)))
129
+ throw new Error("[INIT_INTEGRATION_PROTOCOL_INVALID] --integration-protocol 只接受 1 或 2,且需要 --integration;protocol 2 不啟用 NAS data path。");
122
130
  if (options.integration && (options.ui !== "vue" || options.privilege === "none"))
123
131
  throw new Error("[INIT_INTEGRATION_OPTIONS] integration 需要 --ui vue 與 root privilege(自動選用)。");
124
132
  const privilege = options.privilege ?? (options.integration ? "root" : "none");
@@ -6,6 +6,7 @@ import { checkCgiBinary } from "./binary.js";
6
6
  import { loadStandaloneManifest } from "./manifest.js";
7
7
  import { assembleStandaloneSpk, StandaloneBuildError } from "./spk.js";
8
8
  import { buildHelper } from "./helper.js";
9
+ import { buildDaemonControl } from "./daemon.js";
9
10
  const GOARCH = { x86_64: "amd64", aarch64: "arm64" };
10
11
  /** Argv only, never a shell; output streams to the terminal except stderr, which is also kept. */
11
12
  export const runCommand = (command, args, options) => {
@@ -59,8 +60,9 @@ export async function buildStandalone(options) {
59
60
  throw new StandaloneBuildError(problem.code, problem.message);
60
61
  }
61
62
  const outputPath = join(outDir, `${manifest.package}-${manifest.spkVersion}-${arch}.spk`);
63
+ const daemonControl = buildDaemonControl(manifest, arch, work, run);
62
64
  const builtManifest = helper ? { ...manifest, rootOps: [...(manifest.rootOps ?? []), ...helper.ops] } : manifest;
63
- await assembleStandaloneSpk({ manifest: builtManifest, arch, cgiPath, outputPath, helper });
65
+ await assembleStandaloneSpk({ manifest: builtManifest, arch, cgiPath, outputPath, helper, daemonControl });
64
66
  outputs.push(outputPath);
65
67
  }
66
68
  return { outputs };
@@ -0,0 +1,23 @@
1
+ import type { NativeArchFamily } from "../build-spk/dsm-arch.js";
2
+ import type { CommandRunner } from "./build.js";
3
+ import type { StandaloneError, StandaloneManifest } from "./manifest.js";
4
+ export interface Daemon {
5
+ /** Fixed foreground executable relative to daemon/payload. */
6
+ exec: string;
7
+ /** Architecture-specific project directories, copied without links. */
8
+ targets: Partial<Record<NativeArchFamily, string>>;
9
+ args: string[];
10
+ /** Optional fixed executable argv, after stop, only on uninstall. */
11
+ uninstall_args?: string[];
12
+ /** The only application environment inherited beyond PATH/HOME/TMPDIR. */
13
+ env: Record<string, string>;
14
+ timeouts: {
15
+ start: number;
16
+ stop: number;
17
+ status: number;
18
+ };
19
+ }
20
+ export declare function readDaemon(value: unknown, root: string, arches: NativeArchFamily[], fail: (error: StandaloneError) => void): Daemon | undefined;
21
+ export declare function daemonConfig(manifest: StandaloneManifest): string;
22
+ export declare function buildDaemonControl(manifest: StandaloneManifest, arch: NativeArchFamily, work: string, run: CommandRunner): string | undefined;
23
+ export declare function copyDaemonPayload(manifest: StandaloneManifest, arch: NativeArchFamily, target: string, controller: string): void;
@@ -0,0 +1,114 @@
1
+ import { chmodSync, copyFileSync, lstatSync, mkdirSync, readdirSync, realpathSync, writeFileSync } from "node:fs";
2
+ import { isAbsolute, join, relative, resolve } from "node:path";
3
+ import { templatesRoot } from "../template-paths.js";
4
+ import { checkCgiBinary } from "./binary.js";
5
+ import { StandaloneBuildError } from "./spk.js";
6
+ const fields = new Set(["exec", "targets", "args", "env", "timeouts", "uninstall_args"]);
7
+ const record = (v) => Boolean(v) && typeof v === "object" && !Array.isArray(v);
8
+ const token = (v) => typeof v === "string" && Buffer.byteLength(v) <= 4096 && !v.includes("\0")
9
+ && !v.replaceAll("${SYNOPKG_PKGDEST}", "").replaceAll("${SYNOPKG_PKGVAR}", "").includes("${");
10
+ const envKey = (k) => /^[A-Z][A-Z0-9_]{0,63}$/.test(k)
11
+ && !/^(PATH|HOME|TMPDIR|ENV|BASH_ENV|SHELLOPTS|BASHOPTS|GODEBUG|GOTRACEBACK|LD_.*|DYLD_.*|SYNOPKG_.*)$/.test(k);
12
+ export function readDaemon(value, root, arches, fail) {
13
+ if (value === undefined)
14
+ return undefined;
15
+ const invalid = () => { fail({ code: "STANDALONE_DAEMON_INVALID", message: "daemon 只接受固定 exec、targets、args、env 與 timeouts;路徑須在專案內,環境不接受 loader/shell/system 變數。" }); return undefined; };
16
+ if (!record(value) || Object.keys(value).some(k => !fields.has(k)))
17
+ return invalid();
18
+ if (typeof value.exec !== "string" || !/^[A-Za-z0-9_-]+(?:\/[A-Za-z0-9_.-]+)*$/.test(value.exec)
19
+ || value.exec.split("/").some(p => p === "." || p === "..") || value.exec.length > 200)
20
+ return invalid();
21
+ if (!record(value.targets) || Object.keys(value.targets).length !== arches.length)
22
+ return invalid();
23
+ const targets = {};
24
+ for (const arch of arches) {
25
+ const path = value.targets[arch];
26
+ if (typeof path !== "string" || !path.trim() || path.includes("\0") || isAbsolute(path) || path.split(/[\\/]/).includes(".."))
27
+ return invalid();
28
+ const resolved = resolve(root, path), rel = relative(root, resolved);
29
+ if (!rel || rel.startsWith("..") || isAbsolute(rel))
30
+ return invalid();
31
+ targets[arch] = resolved;
32
+ }
33
+ const args = value.args ?? [];
34
+ if (!Array.isArray(args) || args.length > 64 || !args.every(token))
35
+ return invalid();
36
+ const uninstall = value.uninstall_args;
37
+ if (uninstall !== undefined && (!Array.isArray(uninstall) || !uninstall.length || uninstall.length > 64 || !uninstall.every(token)))
38
+ return invalid();
39
+ const env = value.env ?? {};
40
+ if (!record(env) || Object.keys(env).length > 64 || Object.entries(env).some(([k, v]) => !envKey(k) || !token(v)))
41
+ return invalid();
42
+ const limits = value.timeouts ?? {};
43
+ if (!record(limits) || Object.keys(limits).some(k => !["start", "stop", "status"].includes(k)))
44
+ return invalid();
45
+ const timeouts = { start: limits.start ?? 5, stop: limits.stop ?? 10, status: limits.status ?? 2 };
46
+ for (const [key, v] of Object.entries(timeouts)) {
47
+ if (!Number.isInteger(v) || v < (key === "start" ? 2 : key === "stop" ? 2 : 1) || v > (key === "status" ? 10 : 120))
48
+ return invalid();
49
+ }
50
+ return { exec: value.exec, targets, args, ...(uninstall ? { uninstall_args: uninstall } : {}), env: Object.fromEntries(Object.keys(env).sort().map(key => [key, env[key]])), timeouts: timeouts };
51
+ }
52
+ export function daemonConfig(manifest) {
53
+ const { exec, args, uninstall_args, env, timeouts } = manifest.daemon;
54
+ return JSON.stringify({ package: manifest.package, exec, args, ...(uninstall_args ? { uninstall_args } : {}), env, timeouts }) + "\n";
55
+ }
56
+ export function buildDaemonControl(manifest, arch, work, run) {
57
+ if (!manifest.daemon)
58
+ return undefined;
59
+ const out = join(work, `daemon-control-${arch}`);
60
+ const result = run("go", ["build", "-trimpath", "-buildvcs=false", "-ldflags", "-s -w -buildid=", "-o", out, "."], {
61
+ cwd: join(templatesRoot(), "_daemon"), env: { ...process.env, CGO_ENABLED: "0", GOOS: "linux", GOARCH: arch === "x86_64" ? "amd64" : "arm64" },
62
+ });
63
+ if (result.missing || result.status !== 0)
64
+ throw new StandaloneBuildError("STANDALONE_DAEMON_BUILD_FAILED", `daemon controller build 需要 Go 1.24 以上。\n${result.stderr}`);
65
+ const problem = checkCgiBinary(work, out, arch);
66
+ if (problem)
67
+ throw new StandaloneBuildError(problem.code, problem.message);
68
+ return out;
69
+ }
70
+ export function copyDaemonPayload(manifest, arch, target, controller) {
71
+ const daemon = manifest.daemon;
72
+ const source = daemon.targets[arch];
73
+ const invalid = (message) => { throw new StandaloneBuildError("STANDALONE_DAEMON_PAYLOAD_INVALID", message); };
74
+ let total = 0;
75
+ const walk = (from, to) => {
76
+ const stat = lstatSync(from);
77
+ const rel = relative(realpathSync(manifest.root), realpathSync(from));
78
+ if (rel.startsWith("..") || isAbsolute(rel) || stat.isSymbolicLink())
79
+ invalid(`daemon payload 路徑不可含 symlink 或跳出專案:${from}`);
80
+ if (stat.isDirectory()) {
81
+ mkdirSync(to, { recursive: true });
82
+ chmodSync(to, 0o755);
83
+ for (const name of readdirSync(from).sort())
84
+ walk(join(from, name), join(to, name));
85
+ }
86
+ else if (stat.isFile()) {
87
+ total += stat.size;
88
+ if (total > 512 * 1024 * 1024 || (stat.mode & 0o6000))
89
+ invalid(`daemon payload 不接受 setid 或超過 512 MiB:${from}`);
90
+ copyFileSync(from, to);
91
+ chmodSync(to, stat.mode & 0o111 ? 0o755 : 0o644);
92
+ }
93
+ else
94
+ invalid(`daemon payload 只接受一般檔案及目錄:${from}`);
95
+ };
96
+ try {
97
+ if (!lstatSync(source).isDirectory())
98
+ invalid("daemon.targets 必須指向目錄。");
99
+ walk(source, join(target, "payload"));
100
+ }
101
+ catch (error) {
102
+ if (error instanceof StandaloneBuildError)
103
+ throw error;
104
+ invalid(`無法讀取 daemon payload:${String(error)}`);
105
+ }
106
+ const exec = join(source, daemon.exec);
107
+ const problem = checkCgiBinary(manifest.root, exec, arch);
108
+ if (problem)
109
+ throw new StandaloneBuildError(problem.code, problem.message);
110
+ chmodSync(join(target, "payload", daemon.exec), 0o755);
111
+ copyFileSync(controller, join(target, "control"));
112
+ chmodSync(join(target, "control"), 0o755);
113
+ writeFileSync(join(target, "config.json"), daemonConfig(manifest), { mode: 0o644 });
114
+ }
@@ -13,7 +13,7 @@ export declare const I18N_RUNTIME: string;
13
13
  * The wrapper file name carries the build so DSM never serves a wrapper
14
14
  * cached from the previous version after an upgrade.
15
15
  */
16
- export declare function windowScriptName(manifest: StandaloneManifest): string;
16
+ export declare function windowScriptName(manifest: Pick<StandaloneManifest, "build">): string;
17
17
  /** `ui/config`: registers the DSM main-menu app and its window class. */
18
18
  export declare function renderUiConfig(manifest: StandaloneManifest): string;
19
19
  /**
@@ -1,6 +1,8 @@
1
+ import { REOPEN_EVENTS_RUNTIME } from "./reopen-events.js";
1
2
  import { DSM_LANGS } from "./i18n.js";
2
3
  import { ROOT_MESSAGES } from "./root-messages.js";
3
4
  import { ROOT_PANEL, ROOT_RUNTIME, rootTasks } from "./root-window.js";
5
+ import { HOST_ADAPTER_RUNTIME } from "./host-adapter.js";
4
6
  /** Same path the generated wrapper POSTs to, and the payload location of the CGI. */
5
7
  export const CGI_PAYLOAD_PATH = "ui/cgi/api.cgi";
6
8
  export function cgiUrl(packageId) {
@@ -115,6 +117,16 @@ ${I18N_RUNTIME}
115
117
  return createI18n;
116
118
  })();
117
119
 
120
+ ${ns}.createReopenEvents = (function () {
121
+ ${REOPEN_EVENTS_RUNTIME}
122
+ return createReopenEvents;
123
+ })();
124
+
125
+ ${ns}.createHost = (function () {
126
+ ${HOST_ADAPTER_RUNTIME}
127
+ return createHostAdapter;
128
+ })();
129
+
118
130
  ${root ? root.definitions : ""}${ns}.loadApp = function (done) {
119
131
  var apps = window.DsmPackageApps || {};
120
132
  if (apps[${p}]) {
@@ -150,33 +162,61 @@ Ext.define(${JSON.stringify(`${ns}.MainWindow`)}, {
150
162
  this.callParent(arguments);
151
163
  var me = this;
152
164
  if (me.mounted) {
153
- me.reopenHandlers.forEach(function (fn) { fn(); });
165
+ me.reopenEvents.emit();
154
166
  return;
155
167
  }
156
- me.reopenHandlers = [];
157
- var lang = typeof _S === "function" ? _S("lang") : "enu";
168
+ if (me.mountPending) return;
169
+ me.mountPending = true;
170
+ var mountToken = me.mountToken = {};
171
+ me.reopenEvents = ${ns}.createReopenEvents();
172
+ me.reopenHandlers = me.reopenEvents.handlers;
173
+ var lang = "enu";
174
+ try { if (typeof _S === "function") lang = _S("lang"); } catch (error) {}
158
175
  ${root ? root.mount : ""} ${ns}.loadApp(function (app) {
176
+ if (me.mountToken !== mountToken) return;
177
+ me.mountPending = false;
159
178
  var root = me.body && me.body.dom.querySelector(".dsmapp-root");
160
179
  if (app && root && !me.mounted) {
161
180
  var i18n = ${ns}.createI18n(lang, ${ns}.messages);
181
+ me.hostAccess = ${ns}.createHost({ appWindow: me, locale: i18n.locale });
162
182
  root.lang = i18n.locale;
163
- me.mounted = app.mount(root, {
183
+ try {
184
+ me.mounted = app.mount(root, {
164
185
  call: ${ns}.call,
165
- reopen: function (fn) { me.reopenHandlers.push(fn); },
186
+ reopen: me.reopenEvents.subscribe,
187
+ host: me.hostAccess,
166
188
  appWindow: me,
167
189
  lang: lang,
168
190
  locale: i18n.locale,
169
191
  t: i18n.t${root ? ",\n root: access" : ""}
170
- }) || {};
192
+ }) || {};
193
+ } catch (error) {
194
+ me.hostAccess.dispose();
195
+ me.hostAccess = null;
196
+ me.mountToken = null;
197
+ me.reopenEvents.dispose();
198
+ me.reopenEvents = null;
199
+ me.reopenHandlers = [];
200
+ throw error;
201
+ }
171
202
  }
172
203
  });
173
204
  },
174
205
  onDestroy: function () {
175
- if (this.mounted && this.mounted.unmount) {
176
- this.mounted.unmount();
177
- }
206
+ this.mountToken = null;
207
+ this.mountPending = false;
208
+ if (this.reopenEvents) this.reopenEvents.dispose();
209
+ this.reopenEvents = null;
210
+ this.reopenHandlers = [];
211
+ if (this.hostAccess) this.hostAccess.dispose();
212
+ this.hostAccess = null;
213
+ var mounted = this.mounted;
178
214
  this.mounted = null;
179
- this.callParent(arguments);
215
+ try {
216
+ if (mounted && mounted.unmount) mounted.unmount();
217
+ } finally {
218
+ this.callParent(arguments);
219
+ }
180
220
  }
181
221
  });
182
222
  `;
@@ -0,0 +1,16 @@
1
+ export type DataAccessMode = "unavailable" | "relaxed";
2
+ export interface Integration {
3
+ protocol: 1 | 2;
4
+ workers: Record<string, string>;
5
+ identity?: "better-auth";
6
+ dataAccess?: DataAccessMode;
7
+ }
8
+ export interface HelperInventory {
9
+ package: string;
10
+ version: string;
11
+ protocol: number;
12
+ payloadDigest: string;
13
+ registryDigest: string;
14
+ dataAccess?: DataAccessMode;
15
+ }
16
+ export declare const sha256: (b: string | Buffer) => string;
@@ -0,0 +1,2 @@
1
+ import { createHash } from "node:crypto";
2
+ export const sha256 = (b) => createHash("sha256").update(b).digest("hex");
@@ -2,18 +2,8 @@ import type { NativeArchFamily } from "../build-spk/dsm-arch.js";
2
2
  import type { CommandRunner } from "./build.js";
3
3
  import type { StandaloneError, StandaloneManifest } from "./manifest.js";
4
4
  import { type RootOp } from "./root-ops.js";
5
- export interface Integration {
6
- protocol: number;
7
- workers: Record<string, string>;
8
- identity?: "better-auth";
9
- }
10
- export interface HelperInventory {
11
- package: string;
12
- version: string;
13
- protocol: number;
14
- payloadDigest: string;
15
- registryDigest: string;
16
- }
5
+ export type { Integration, HelperInventory } from "./helper-inventory.js";
6
+ import { type Integration, type HelperInventory } from "./helper-inventory.js";
17
7
  export interface WorkerPayload {
18
8
  id: string;
19
9
  digest: string;