@synopackageland/cli 0.3.10 → 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 (641) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -9
  3. package/dist/bin.js +1 -2
  4. package/dist/build-spk/generator.d.ts +0 -3
  5. package/dist/build-spk/generator.js +138 -287
  6. package/dist/build-spk/native-lifecycle.js +0 -3
  7. package/dist/build-spk/native-payload.js +0 -1
  8. package/dist/build-spk/notices.d.ts +5 -0
  9. package/dist/build-spk/notices.js +60 -0
  10. package/dist/cli.js +178 -151
  11. package/dist/compose/analyze.d.ts +1 -2
  12. package/dist/compose/analyze.js +5 -48
  13. package/dist/contract/unsupported-types.d.ts +10 -0
  14. package/dist/contract/unsupported-types.js +49 -0
  15. package/dist/contract/validate.js +25 -2
  16. package/dist/contract/web-launch.js +0 -2
  17. package/dist/deploy/deploy.d.ts +1 -4
  18. package/dist/deploy/deploy.js +45 -156
  19. package/dist/deploy/homes-values.js +1 -1
  20. package/dist/deploy/plan.d.ts +18 -0
  21. package/dist/deploy/plan.js +54 -0
  22. package/dist/deploy/spk-version.d.ts +2 -14
  23. package/dist/deploy/spk-version.js +25 -111
  24. package/dist/dev.d.ts +1 -3
  25. package/dist/dev.js +14 -28
  26. package/dist/error-registry.js +830 -862
  27. package/dist/host/dsm-client.js +12 -272
  28. package/dist/host/dsm-port-profile.d.ts +0 -1
  29. package/dist/host/dsm-port-profile.js +0 -2
  30. package/dist/host/types.d.ts +1 -83
  31. package/dist/index.d.ts +0 -9
  32. package/dist/index.js +0 -6
  33. package/dist/info.d.ts +0 -1
  34. package/dist/info.js +3 -10
  35. package/dist/init.d.ts +15 -1
  36. package/dist/init.js +128 -12
  37. package/dist/log.js +2 -3
  38. package/dist/native/validate.js +0 -1
  39. package/dist/standalone/binary.d.ts +9 -0
  40. package/dist/standalone/binary.js +67 -0
  41. package/dist/standalone/build.d.ts +25 -0
  42. package/dist/standalone/build.js +110 -0
  43. package/dist/standalone/daemon.d.ts +23 -0
  44. package/dist/standalone/daemon.js +114 -0
  45. package/dist/standalone/dsm-window.d.ts +26 -0
  46. package/dist/standalone/dsm-window.js +291 -0
  47. package/dist/standalone/helper-inventory.d.ts +16 -0
  48. package/dist/standalone/helper-inventory.js +2 -0
  49. package/dist/standalone/helper.d.ts +21 -0
  50. package/dist/standalone/helper.js +105 -0
  51. package/dist/standalone/host-adapter.d.ts +5 -0
  52. package/dist/standalone/host-adapter.js +148 -0
  53. package/dist/standalone/host-platform.d.ts +13 -0
  54. package/dist/standalone/host-platform.js +42 -0
  55. package/dist/standalone/host-types.d.ts +49 -0
  56. package/dist/standalone/host-types.js +1 -0
  57. package/dist/standalone/i18n.d.ts +28 -0
  58. package/dist/standalone/i18n.js +161 -0
  59. package/dist/standalone/inspect-helper.d.ts +6 -0
  60. package/dist/standalone/inspect-helper.js +88 -0
  61. package/dist/standalone/inspect-spk.d.ts +23 -0
  62. package/dist/standalone/inspect-spk.js +209 -0
  63. package/dist/standalone/lifecycle-helper.d.ts +2 -0
  64. package/dist/standalone/lifecycle-helper.js +12 -0
  65. package/dist/standalone/lifecycle.d.ts +3 -0
  66. package/dist/standalone/lifecycle.js +53 -0
  67. package/dist/standalone/manifest.d.ts +73 -0
  68. package/dist/standalone/manifest.js +279 -0
  69. package/dist/standalone/reopen-events.d.ts +2 -0
  70. package/dist/standalone/reopen-events.js +28 -0
  71. package/dist/standalone/root-messages.d.ts +7 -0
  72. package/dist/standalone/root-messages.js +259 -0
  73. package/dist/standalone/root-ops.d.ts +42 -0
  74. package/dist/standalone/root-ops.js +101 -0
  75. package/dist/standalone/root-window.d.ts +36 -0
  76. package/dist/standalone/root-window.js +302 -0
  77. package/dist/standalone/spk.d.ts +23 -0
  78. package/dist/standalone/spk.js +192 -0
  79. package/dist/template-paths.d.ts +2 -0
  80. package/dist/template-paths.js +9 -0
  81. package/dist/templates/_daemon/fixture_linux_test.go +15 -0
  82. package/dist/templates/_daemon/fixture_other_test.go +7 -0
  83. package/dist/templates/_daemon/go.mod +3 -0
  84. package/dist/templates/_daemon/main.go +608 -0
  85. package/dist/templates/_daemon/main_test.go +242 -0
  86. package/dist/templates/_daemon/process_linux.go +55 -0
  87. package/dist/templates/_daemon/process_linux_test.go +161 -0
  88. package/dist/templates/_daemon/process_other.go +14 -0
  89. package/dist/templates/_daemon/testdata/child.go +41 -0
  90. package/dist/templates/_shared/GO-LICENSE +27 -0
  91. package/dist/templates/_shared/GO-PATENTS +22 -0
  92. package/dist/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
  93. package/dist/templates/_shared/notice-overrides/index.json +14 -0
  94. package/dist/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
  95. package/dist/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
  96. package/dist/templates/_shared/third-party-notices.mjs +51 -0
  97. package/dist/templates/binary/synology-app.yaml +7 -0
  98. package/dist/templates/hello-files/compose.yaml +0 -1
  99. package/dist/templates/hello-web/compose.yaml +13 -10
  100. package/dist/templates/hello-web/html/app.js +1 -23
  101. package/dist/templates/hello-web/html/index.html +1 -3
  102. package/dist/templates/hello-web-page/compose.yaml +13 -10
  103. package/dist/templates/hello-web-page/html/app.js +1 -23
  104. package/dist/templates/hello-web-page/html/index.html +1 -3
  105. package/dist/templates/native-go/README.md +324 -0
  106. package/dist/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
  107. package/dist/templates/native-go/backend/cmd/app/main.go +49 -0
  108. package/dist/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
  109. package/dist/templates/native-go/backend/cmd/helper/main.go +38 -0
  110. package/dist/templates/native-go/backend/go.mod +7 -0
  111. package/dist/templates/native-go/backend/go.sum +4 -0
  112. package/dist/templates/native-go/backend/internal/api/binary.go +154 -0
  113. package/dist/templates/native-go/backend/internal/api/binary_test.go +165 -0
  114. package/dist/templates/native-go/backend/internal/api/errors.go +33 -0
  115. package/dist/templates/native-go/backend/internal/api/registry.go +104 -0
  116. package/dist/templates/native-go/backend/internal/api/registry_test.go +329 -0
  117. package/dist/templates/native-go/backend/internal/api/server.go +159 -0
  118. package/dist/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
  119. package/dist/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
  120. package/dist/templates/native-go/backend/internal/app/root_none.go +9 -0
  121. package/dist/templates/native-go/backend/internal/app/routes.go +138 -0
  122. package/dist/templates/native-go/backend/internal/app/routes_test.go +172 -0
  123. package/dist/templates/native-go/backend/internal/dsm/auth.go +118 -0
  124. package/dist/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
  125. package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
  126. package/dist/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
  127. package/dist/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
  128. package/dist/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
  129. package/dist/templates/native-go/backend/internal/helper/cohort.go +393 -0
  130. package/dist/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
  131. package/dist/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
  132. package/dist/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
  133. package/dist/templates/native-go/backend/internal/helper/control.go +424 -0
  134. package/dist/templates/native-go/backend/internal/helper/control_test.go +250 -0
  135. package/dist/templates/native-go/backend/internal/helper/data_contract.go +242 -0
  136. package/dist/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
  137. package/dist/templates/native-go/backend/internal/helper/data_decode.go +184 -0
  138. package/dist/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
  139. package/dist/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
  140. package/dist/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
  141. package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
  142. package/dist/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
  143. package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
  144. package/dist/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
  145. package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
  146. package/dist/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
  147. package/dist/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
  148. package/dist/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
  149. package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
  150. package/dist/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
  151. package/dist/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
  152. package/dist/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
  153. package/dist/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
  154. package/dist/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
  155. package/dist/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
  156. package/dist/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
  157. package/dist/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
  158. package/dist/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
  159. package/dist/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
  160. package/dist/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
  161. package/dist/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
  162. package/dist/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
  163. package/dist/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
  164. package/dist/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
  165. package/dist/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
  166. package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
  167. package/dist/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
  168. package/dist/templates/native-go/backend/internal/helper/lease.go +112 -0
  169. package/dist/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
  170. package/dist/templates/native-go/backend/internal/helper/lease_other.go +8 -0
  171. package/dist/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
  172. package/dist/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
  173. package/dist/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
  174. package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
  175. package/dist/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
  176. package/dist/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
  177. package/dist/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
  178. package/dist/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
  179. package/dist/templates/native-go/backend/internal/helper/native_identity.go +89 -0
  180. package/dist/templates/native-go/backend/internal/helper/native_provider.go +159 -0
  181. package/dist/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
  182. package/dist/templates/native-go/backend/internal/helper/observation.go +204 -0
  183. package/dist/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
  184. package/dist/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
  185. package/dist/templates/native-go/backend/internal/helper/observation_test.go +196 -0
  186. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
  187. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
  188. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
  189. package/dist/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
  190. package/dist/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
  191. package/dist/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
  192. package/dist/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
  193. package/dist/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
  194. package/dist/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
  195. package/dist/templates/native-go/backend/internal/helper/peer_other.go +7 -0
  196. package/dist/templates/native-go/backend/internal/helper/process_linux.go +177 -0
  197. package/dist/templates/native-go/backend/internal/helper/process_other.go +5 -0
  198. package/dist/templates/native-go/backend/internal/helper/publication_test.go +178 -0
  199. package/dist/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
  200. package/dist/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
  201. package/dist/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
  202. package/dist/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
  203. package/dist/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
  204. package/dist/templates/native-go/backend/internal/helper/readonly.go +105 -0
  205. package/dist/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
  206. package/dist/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
  207. package/dist/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
  208. package/dist/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
  209. package/dist/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
  210. package/dist/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
  211. package/dist/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
  212. package/dist/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
  213. package/dist/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
  214. package/dist/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
  215. package/dist/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
  216. package/dist/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
  217. package/dist/templates/native-go/backend/internal/helper/repair.go +132 -0
  218. package/dist/templates/native-go/backend/internal/helper/repair_test.go +271 -0
  219. package/dist/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
  220. package/dist/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
  221. package/dist/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
  222. package/dist/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
  223. package/dist/templates/native-go/backend/internal/helper/server_linux.go +124 -0
  224. package/dist/templates/native-go/backend/internal/helper/status.go +334 -0
  225. package/dist/templates/native-go/backend/internal/helper/status_test.go +288 -0
  226. package/dist/templates/native-go/backend/internal/helper/supervision.go +107 -0
  227. package/dist/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
  228. package/dist/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
  229. package/dist/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
  230. package/dist/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
  231. package/dist/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
  232. package/dist/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
  233. package/dist/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
  234. package/dist/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
  235. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
  236. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
  237. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
  238. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
  239. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
  240. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
  241. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
  242. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
  243. package/dist/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
  244. package/dist/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
  245. package/dist/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
  246. package/dist/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
  247. package/dist/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
  248. package/dist/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
  249. package/dist/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
  250. package/dist/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
  251. package/dist/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
  252. package/dist/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
  253. package/dist/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
  254. package/dist/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
  255. package/dist/templates/native-go/backend/internal/helper/write.go +77 -0
  256. package/dist/templates/native-go/backend/internal/helper/write_admission.go +260 -0
  257. package/dist/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
  258. package/dist/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
  259. package/dist/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
  260. package/dist/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
  261. package/dist/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
  262. package/dist/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
  263. package/dist/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
  264. package/dist/templates/native-go/backend/internal/helper/write_test.go +53 -0
  265. package/dist/templates/native-go/dsm-package.yaml +58 -0
  266. package/dist/templates/native-go/gitignore +1 -0
  267. package/dist/templates/native-go/i18n/glossary.json +662 -0
  268. package/dist/templates/native-go/i18n/messages/de.json +28 -0
  269. package/dist/templates/native-go/i18n/messages/en.json +28 -0
  270. package/dist/templates/native-go/i18n/messages/es.json +28 -0
  271. package/dist/templates/native-go/i18n/messages/fr.json +28 -0
  272. package/dist/templates/native-go/i18n/messages/it.json +28 -0
  273. package/dist/templates/native-go/i18n/messages/ja.json +28 -0
  274. package/dist/templates/native-go/i18n/messages/ko.json +28 -0
  275. package/dist/templates/native-go/i18n/messages/zh-CN.json +28 -0
  276. package/dist/templates/native-go/i18n/messages/zh-TW.json +28 -0
  277. package/dist/templates/native-go/ui/app.css +35 -0
  278. package/dist/templates/native-go/ui/app.js +101 -0
  279. package/dist/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
  280. package/dist/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
  281. package/dist/templates/native-go-better-auth/node/app.mjs +72 -0
  282. package/dist/templates/native-go-better-auth/node/build.mjs +4 -0
  283. package/dist/templates/native-go-better-auth/node/package-lock.json +862 -0
  284. package/dist/templates/native-go-better-auth/node/package.json +1 -0
  285. package/dist/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
  286. package/dist/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
  287. package/dist/templates/native-go-integration/backend/internal/app/personal.go +203 -0
  288. package/dist/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
  289. package/dist/templates/native-go-root/backend/internal/app/root.go +107 -0
  290. package/dist/templates/native-go-root/backend/internal/app/root_test.go +124 -0
  291. package/dist/templates/native-go-root/root/whoami.sh +6 -0
  292. package/dist/templates/native-go-vue/README.md +224 -0
  293. package/dist/templates/native-go-vue/frontend/DESIGN.md +78 -0
  294. package/dist/templates/native-go-vue/frontend/package-lock.json +2410 -0
  295. package/dist/templates/native-go-vue/frontend/package.json +6 -0
  296. package/dist/templates/native-go-vue/frontend/src/App.vue +159 -0
  297. package/dist/templates/native-go-vue/frontend/src/context.ts +56 -0
  298. package/dist/templates/native-go-vue/frontend/src/main.ts +29 -0
  299. package/dist/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
  300. package/dist/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
  301. package/dist/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
  302. package/dist/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
  303. package/dist/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
  304. package/dist/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
  305. package/dist/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
  306. package/dist/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
  307. package/dist/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
  308. package/dist/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
  309. package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
  310. package/dist/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
  311. package/dist/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
  312. package/dist/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
  313. package/dist/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
  314. package/dist/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
  315. package/dist/templates/native-go-vue/frontend/src/style.css +31 -0
  316. package/dist/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
  317. package/dist/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
  318. package/dist/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
  319. package/dist/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
  320. package/dist/templates/native-go-vue/frontend/tsconfig.json +1 -0
  321. package/dist/templates/native-go-vue/frontend/vite.config.ts +10 -0
  322. package/dist/templates/native-go-vue/gitignore +2 -0
  323. package/dist/types.d.ts +1 -1
  324. package/dist/validate.js +11 -7
  325. package/package.json +5 -8
  326. package/schema/synology-app.schema.json +36 -37
  327. package/skills/SKILL.md +4 -48
  328. package/skills/reference/create.md +11 -83
  329. package/skills/reference/deploy.md +7 -78
  330. package/skills/reference/diagnose.md +4 -101
  331. package/skills/reference/files.md +5 -41
  332. package/skills/reference/identity.md +3 -29
  333. package/skills/reference/wrap.md +0 -2
  334. package/templates/_daemon/fixture_linux_test.go +15 -0
  335. package/templates/_daemon/fixture_other_test.go +7 -0
  336. package/templates/_daemon/go.mod +3 -0
  337. package/templates/_daemon/main.go +608 -0
  338. package/templates/_daemon/main_test.go +242 -0
  339. package/templates/_daemon/process_linux.go +55 -0
  340. package/templates/_daemon/process_linux_test.go +161 -0
  341. package/templates/_daemon/process_other.go +14 -0
  342. package/templates/_daemon/testdata/child.go +41 -0
  343. package/templates/_shared/GO-LICENSE +27 -0
  344. package/templates/_shared/GO-PATENTS +22 -0
  345. package/templates/_shared/LICENSES/TEMPLATE.txt +21 -0
  346. package/templates/_shared/notice-overrides/index.json +14 -0
  347. package/templates/_shared/notice-overrides/utils-0.4.2-LICENSE +21 -0
  348. package/templates/_shared/notice-overrides/utils-0.5.0-LICENSE +21 -0
  349. package/templates/_shared/third-party-notices.mjs +51 -0
  350. package/templates/binary/synology-app.yaml +7 -0
  351. package/templates/hello-files/compose.yaml +0 -1
  352. package/templates/hello-web/compose.yaml +13 -10
  353. package/templates/hello-web/html/app.js +1 -23
  354. package/templates/hello-web/html/index.html +1 -3
  355. package/templates/hello-web-page/compose.yaml +13 -10
  356. package/templates/hello-web-page/html/app.js +1 -23
  357. package/templates/hello-web-page/html/index.html +1 -3
  358. package/templates/native-go/README.md +324 -0
  359. package/templates/native-go/backend/THIRD_PARTY_NOTICES.txt +59 -0
  360. package/templates/native-go/backend/cmd/app/main.go +49 -0
  361. package/templates/native-go/backend/cmd/dsm-readonly-probe/main_linux.go +46 -0
  362. package/templates/native-go/backend/cmd/helper/main.go +38 -0
  363. package/templates/native-go/backend/go.mod +7 -0
  364. package/templates/native-go/backend/go.sum +4 -0
  365. package/templates/native-go/backend/internal/api/binary.go +154 -0
  366. package/templates/native-go/backend/internal/api/binary_test.go +165 -0
  367. package/templates/native-go/backend/internal/api/errors.go +33 -0
  368. package/templates/native-go/backend/internal/api/registry.go +104 -0
  369. package/templates/native-go/backend/internal/api/registry_test.go +329 -0
  370. package/templates/native-go/backend/internal/api/server.go +159 -0
  371. package/templates/native-go/backend/internal/app/nas_cgi_artifact_test.go +121 -0
  372. package/templates/native-go/backend/internal/app/nas_refusal_test.go +46 -0
  373. package/templates/native-go/backend/internal/app/root_none.go +9 -0
  374. package/templates/native-go/backend/internal/app/routes.go +138 -0
  375. package/templates/native-go/backend/internal/app/routes_test.go +172 -0
  376. package/templates/native-go/backend/internal/dsm/auth.go +118 -0
  377. package/templates/native-go/backend/internal/dsm/auth_test.go +139 -0
  378. package/templates/native-go/backend/internal/dsmprobe/collector_linux.go +335 -0
  379. package/templates/native-go/backend/internal/dsmprobe/collector_linux_test.go +41 -0
  380. package/templates/native-go/backend/internal/dsmprobe/protocol.go +179 -0
  381. package/templates/native-go/backend/internal/dsmprobe/protocol_test.go +29 -0
  382. package/templates/native-go/backend/internal/helper/cohort.go +393 -0
  383. package/templates/native-go/backend/internal/helper/cohort_publication.go +18 -0
  384. package/templates/native-go/backend/internal/helper/cohort_publication_test.go +105 -0
  385. package/templates/native-go/backend/internal/helper/cohort_test.go +372 -0
  386. package/templates/native-go/backend/internal/helper/control.go +424 -0
  387. package/templates/native-go/backend/internal/helper/control_test.go +250 -0
  388. package/templates/native-go/backend/internal/helper/data_contract.go +242 -0
  389. package/templates/native-go/backend/internal/helper/data_contract_test.go +51 -0
  390. package/templates/native-go/backend/internal/helper/data_decode.go +184 -0
  391. package/templates/native-go/backend/internal/helper/data_decode_pointer_test.go +30 -0
  392. package/templates/native-go/backend/internal/helper/data_protocol.go +416 -0
  393. package/templates/native-go/backend/internal/helper/data_protocol_test.go +449 -0
  394. package/templates/native-go/backend/internal/helper/dsm_acl_linux.go +139 -0
  395. package/templates/native-go/backend/internal/helper/dsm_acl_linux_test.go +121 -0
  396. package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux.go +95 -0
  397. package/templates/native-go/backend/internal/helper/dsm_acl_syscall_linux_test.go +56 -0
  398. package/templates/native-go/backend/internal/helper/dsm_bridge_linux.go +144 -0
  399. package/templates/native-go/backend/internal/helper/dsm_bridge_linux_test.go +89 -0
  400. package/templates/native-go/backend/internal/helper/dsm_home_linux.go +107 -0
  401. package/templates/native-go/backend/internal/helper/dsm_home_linux_test.go +82 -0
  402. package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux.go +151 -0
  403. package/templates/native-go/backend/internal/helper/dsm_probe_transport_linux_test.go +66 -0
  404. package/templates/native-go/backend/internal/helper/grant_authority.go +516 -0
  405. package/templates/native-go/backend/internal/helper/grant_authority_contract.go +88 -0
  406. package/templates/native-go/backend/internal/helper/grant_authority_test.go +510 -0
  407. package/templates/native-go/backend/internal/helper/grant_cohort.go +389 -0
  408. package/templates/native-go/backend/internal/helper/grant_cohort_test.go +239 -0
  409. package/templates/native-go/backend/internal/helper/grant_delivery.go +49 -0
  410. package/templates/native-go/backend/internal/helper/grant_delivery_methods.go +273 -0
  411. package/templates/native-go/backend/internal/helper/grant_delivery_test.go +322 -0
  412. package/templates/native-go/backend/internal/helper/grant_operation_contract.go +47 -0
  413. package/templates/native-go/backend/internal/helper/grant_readonly_test.go +180 -0
  414. package/templates/native-go/backend/internal/helper/grant_repository_linux.go +415 -0
  415. package/templates/native-go/backend/internal/helper/grant_repository_linux_test.go +468 -0
  416. package/templates/native-go/backend/internal/helper/grant_rpc.go +147 -0
  417. package/templates/native-go/backend/internal/helper/grant_rpc_test.go +51 -0
  418. package/templates/native-go/backend/internal/helper/grant_snapshot.go +75 -0
  419. package/templates/native-go/backend/internal/helper/grant_supervisor_linux.go +134 -0
  420. package/templates/native-go/backend/internal/helper/grant_supervisor_linux_test.go +254 -0
  421. package/templates/native-go/backend/internal/helper/lease.go +112 -0
  422. package/templates/native-go/backend/internal/helper/lease_linux.go +44 -0
  423. package/templates/native-go/backend/internal/helper/lease_other.go +8 -0
  424. package/templates/native-go/backend/internal/helper/lifecycle.go +234 -0
  425. package/templates/native-go/backend/internal/helper/lifecycle_test.go +473 -0
  426. package/templates/native-go/backend/internal/helper/managed_pilot.go +284 -0
  427. package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux.go +74 -0
  428. package/templates/native-go/backend/internal/helper/managed_pilot_repository_linux_test.go +40 -0
  429. package/templates/native-go/backend/internal/helper/managed_pilot_test.go +210 -0
  430. package/templates/native-go/backend/internal/helper/nas_shipped_refusal_linux_test.go +97 -0
  431. package/templates/native-go/backend/internal/helper/native_discovery.go +79 -0
  432. package/templates/native-go/backend/internal/helper/native_identity.go +89 -0
  433. package/templates/native-go/backend/internal/helper/native_provider.go +159 -0
  434. package/templates/native-go/backend/internal/helper/native_provider_test.go +421 -0
  435. package/templates/native-go/backend/internal/helper/observation.go +204 -0
  436. package/templates/native-go/backend/internal/helper/observation_health_test.go +115 -0
  437. package/templates/native-go/backend/internal/helper/observation_reload_budget_test.go +117 -0
  438. package/templates/native-go/backend/internal/helper/observation_test.go +196 -0
  439. package/templates/native-go/backend/internal/helper/observer_diagnostic.go +109 -0
  440. package/templates/native-go/backend/internal/helper/observer_diagnostic_linux.go +76 -0
  441. package/templates/native-go/backend/internal/helper/observer_diagnostic_linux_test.go +124 -0
  442. package/templates/native-go/backend/internal/helper/observer_diagnostic_test.go +98 -0
  443. package/templates/native-go/backend/internal/helper/operation_bootstrap_linux.go +193 -0
  444. package/templates/native-go/backend/internal/helper/operation_credentials_linux.go +56 -0
  445. package/templates/native-go/backend/internal/helper/operation_linux.go +480 -0
  446. package/templates/native-go/backend/internal/helper/operation_linux_test.go +528 -0
  447. package/templates/native-go/backend/internal/helper/peer_linux.go +44 -0
  448. package/templates/native-go/backend/internal/helper/peer_other.go +7 -0
  449. package/templates/native-go/backend/internal/helper/process_linux.go +177 -0
  450. package/templates/native-go/backend/internal/helper/process_other.go +5 -0
  451. package/templates/native-go/backend/internal/helper/publication_test.go +178 -0
  452. package/templates/native-go/backend/internal/helper/read_stream_cohort_linux_test.go +156 -0
  453. package/templates/native-go/backend/internal/helper/read_transfer.go +40 -0
  454. package/templates/native-go/backend/internal/helper/read_transfer_linux.go +109 -0
  455. package/templates/native-go/backend/internal/helper/read_transfer_linux_test.go +118 -0
  456. package/templates/native-go/backend/internal/helper/read_transfer_test.go +177 -0
  457. package/templates/native-go/backend/internal/helper/readonly.go +105 -0
  458. package/templates/native-go/backend/internal/helper/readonly_admission.go +85 -0
  459. package/templates/native-go/backend/internal/helper/readonly_cohort_linux_test.go +253 -0
  460. package/templates/native-go/backend/internal/helper/readonly_linux_test.go +378 -0
  461. package/templates/native-go/backend/internal/helper/readonly_mount_linux.go +65 -0
  462. package/templates/native-go/backend/internal/helper/readonly_mount_proxy_linux.go +113 -0
  463. package/templates/native-go/backend/internal/helper/readonly_operations_linux.go +168 -0
  464. package/templates/native-go/backend/internal/helper/readonly_resolver_linux.go +241 -0
  465. package/templates/native-go/backend/internal/helper/readonly_test.go +40 -0
  466. package/templates/native-go/backend/internal/helper/relaxed_identity.go +252 -0
  467. package/templates/native-go/backend/internal/helper/relaxed_identity_contract.go +105 -0
  468. package/templates/native-go/backend/internal/helper/relaxed_identity_test.go +406 -0
  469. package/templates/native-go/backend/internal/helper/relaxed_invalidation.go +200 -0
  470. package/templates/native-go/backend/internal/helper/repair.go +132 -0
  471. package/templates/native-go/backend/internal/helper/repair_test.go +271 -0
  472. package/templates/native-go/backend/internal/helper/s1r_actor_acl_linux_test.go +303 -0
  473. package/templates/native-go/backend/internal/helper/s1r_actor_fixture_linux_test.go +184 -0
  474. package/templates/native-go/backend/internal/helper/s1r_actor_races_linux_test.go +231 -0
  475. package/templates/native-go/backend/internal/helper/s1r_fixture_contract_linux_test.go +18 -0
  476. package/templates/native-go/backend/internal/helper/server_linux.go +124 -0
  477. package/templates/native-go/backend/internal/helper/status.go +334 -0
  478. package/templates/native-go/backend/internal/helper/status_test.go +288 -0
  479. package/templates/native-go/backend/internal/helper/supervision.go +107 -0
  480. package/templates/native-go/backend/internal/helper/supervision_test.go +124 -0
  481. package/templates/native-go/backend/internal/helper/supervisor_frame.go +76 -0
  482. package/templates/native-go/backend/internal/helper/supervisor_frame_linux_test.go +69 -0
  483. package/templates/native-go/backend/internal/helper/supervisor_frame_test.go +107 -0
  484. package/templates/native-go/backend/internal/helper/supervisor_linux.go +363 -0
  485. package/templates/native-go/backend/internal/helper/supervisor_linux_test.go +913 -0
  486. package/templates/native-go/backend/internal/helper/supervisor_socket_eof_test.go +74 -0
  487. package/templates/native-go/backend/internal/helper/supervisor_socket_test.go +45 -0
  488. package/templates/native-go/backend/internal/helper/testdata/protocol2/create.json +23 -0
  489. package/templates/native-go/backend/internal/helper/testdata/protocol2/frames.json +67 -0
  490. package/templates/native-go/backend/internal/helper/testdata/protocol2/grant-store.json +52 -0
  491. package/templates/native-go/backend/internal/helper/testdata/protocol2/intent.json +20 -0
  492. package/templates/native-go/backend/internal/helper/testdata/protocol2/list.json +20 -0
  493. package/templates/native-go/backend/internal/helper/testdata/protocol2/publish.json +20 -0
  494. package/templates/native-go/backend/internal/helper/testdata/protocol2/read.json +22 -0
  495. package/templates/native-go/backend/internal/helper/testdata/protocol2/stat.json +22 -0
  496. package/templates/native-go/backend/internal/helper/testdata/protocol2/write-stream.json +22 -0
  497. package/templates/native-go/backend/internal/helper/unit_connection.go +75 -0
  498. package/templates/native-go/backend/internal/helper/unit_connection_linux_test.go +135 -0
  499. package/templates/native-go/backend/internal/helper/unit_connection_test.go +133 -0
  500. package/templates/native-go/backend/internal/helper/unit_frame_test.go +32 -0
  501. package/templates/native-go/backend/internal/helper/unit_linux.go +364 -0
  502. package/templates/native-go/backend/internal/helper/unit_linux_test.go +46 -0
  503. package/templates/native-go/backend/internal/helper/unit_mechanisms_linux_test.go +217 -0
  504. package/templates/native-go/backend/internal/helper/unit_padding_linux_test.go +178 -0
  505. package/templates/native-go/backend/internal/helper/unit_query_linux.go +111 -0
  506. package/templates/native-go/backend/internal/helper/unit_reload_linux_test.go +372 -0
  507. package/templates/native-go/backend/internal/helper/unit_reload_sequence_linux_test.go +232 -0
  508. package/templates/native-go/backend/internal/helper/write.go +77 -0
  509. package/templates/native-go/backend/internal/helper/write_admission.go +260 -0
  510. package/templates/native-go/backend/internal/helper/write_admission_test.go +135 -0
  511. package/templates/native-go/backend/internal/helper/write_cohort_linux_test.go +218 -0
  512. package/templates/native-go/backend/internal/helper/write_files_linux.go +202 -0
  513. package/templates/native-go/backend/internal/helper/write_files_linux_test.go +199 -0
  514. package/templates/native-go/backend/internal/helper/write_intent_linux.go +116 -0
  515. package/templates/native-go/backend/internal/helper/write_intent_linux_test.go +74 -0
  516. package/templates/native-go/backend/internal/helper/write_operation_linux.go +245 -0
  517. package/templates/native-go/backend/internal/helper/write_test.go +53 -0
  518. package/templates/native-go/dsm-package.yaml +58 -0
  519. package/templates/native-go/gitignore +1 -0
  520. package/templates/native-go/i18n/glossary.json +662 -0
  521. package/templates/native-go/i18n/messages/de.json +28 -0
  522. package/templates/native-go/i18n/messages/en.json +28 -0
  523. package/templates/native-go/i18n/messages/es.json +28 -0
  524. package/templates/native-go/i18n/messages/fr.json +28 -0
  525. package/templates/native-go/i18n/messages/it.json +28 -0
  526. package/templates/native-go/i18n/messages/ja.json +28 -0
  527. package/templates/native-go/i18n/messages/ko.json +28 -0
  528. package/templates/native-go/i18n/messages/zh-CN.json +28 -0
  529. package/templates/native-go/i18n/messages/zh-TW.json +28 -0
  530. package/templates/native-go/ui/app.css +35 -0
  531. package/templates/native-go/ui/app.js +101 -0
  532. package/templates/native-go-better-auth/backend/internal/app/identity.go +208 -0
  533. package/templates/native-go-better-auth/backend/internal/app/identity_test.go +113 -0
  534. package/templates/native-go-better-auth/node/app.mjs +72 -0
  535. package/templates/native-go-better-auth/node/build.mjs +4 -0
  536. package/templates/native-go-better-auth/node/package-lock.json +862 -0
  537. package/templates/native-go-better-auth/node/package.json +1 -0
  538. package/templates/native-go-better-auth/node/test/auth.test.mjs +31 -0
  539. package/templates/native-go-integration/backend/internal/app/identity_none.go +6 -0
  540. package/templates/native-go-integration/backend/internal/app/personal.go +203 -0
  541. package/templates/native-go-integration/backend/internal/app/personal_test.go +119 -0
  542. package/templates/native-go-root/backend/internal/app/root.go +107 -0
  543. package/templates/native-go-root/backend/internal/app/root_test.go +124 -0
  544. package/templates/native-go-root/root/whoami.sh +6 -0
  545. package/templates/native-go-vue/README.md +224 -0
  546. package/templates/native-go-vue/frontend/DESIGN.md +78 -0
  547. package/templates/native-go-vue/frontend/package-lock.json +2410 -0
  548. package/templates/native-go-vue/frontend/package.json +6 -0
  549. package/templates/native-go-vue/frontend/src/App.vue +159 -0
  550. package/templates/native-go-vue/frontend/src/context.ts +56 -0
  551. package/templates/native-go-vue/frontend/src/main.ts +29 -0
  552. package/templates/native-go-vue/frontend/src/nas/NasGrantSettings.vue +74 -0
  553. package/templates/native-go-vue/frontend/src/nas/NasPathPicker.vue +106 -0
  554. package/templates/native-go-vue/frontend/src/nas/NasUnavailable.vue +20 -0
  555. package/templates/native-go-vue/frontend/src/nas/i18n/de.json +74 -0
  556. package/templates/native-go-vue/frontend/src/nas/i18n/en.json +74 -0
  557. package/templates/native-go-vue/frontend/src/nas/i18n/es.json +74 -0
  558. package/templates/native-go-vue/frontend/src/nas/i18n/fr.json +74 -0
  559. package/templates/native-go-vue/frontend/src/nas/i18n/it.json +74 -0
  560. package/templates/native-go-vue/frontend/src/nas/i18n/ja.json +74 -0
  561. package/templates/native-go-vue/frontend/src/nas/i18n/ko.json +74 -0
  562. package/templates/native-go-vue/frontend/src/nas/i18n/zh-CN.json +74 -0
  563. package/templates/native-go-vue/frontend/src/nas/i18n/zh-TW.json +74 -0
  564. package/templates/native-go-vue/frontend/src/nas/i18n.ts +38 -0
  565. package/templates/native-go-vue/frontend/src/nas/mock-provider.ts +119 -0
  566. package/templates/native-go-vue/frontend/src/nas/provider.ts +59 -0
  567. package/templates/native-go-vue/frontend/src/nas/use-request.ts +27 -0
  568. package/templates/native-go-vue/frontend/src/style.css +31 -0
  569. package/templates/native-go-vue/frontend/test/apps.test.ts +190 -0
  570. package/templates/native-go-vue/frontend/test/nas-provider.test.ts +81 -0
  571. package/templates/native-go-vue/frontend/test/nas-request.test.ts +21 -0
  572. package/templates/native-go-vue/frontend/test/nas-ui.test.ts +261 -0
  573. package/templates/native-go-vue/frontend/tsconfig.json +1 -0
  574. package/templates/native-go-vue/frontend/vite.config.ts +10 -0
  575. package/templates/native-go-vue/gitignore +2 -0
  576. package/dist/attestation/app-package.d.ts +0 -86
  577. package/dist/attestation/app-package.js +0 -206
  578. package/dist/attestation/install-on-host.d.ts +0 -14
  579. package/dist/attestation/install-on-host.js +0 -52
  580. package/dist/attestation/keyring.d.ts +0 -21
  581. package/dist/attestation/keyring.js +0 -168
  582. package/dist/attestation/platform-service.d.ts +0 -70
  583. package/dist/attestation/platform-service.js +0 -250
  584. package/dist/build-spk/broker-glue.d.ts +0 -16
  585. package/dist/build-spk/broker-glue.js +0 -40
  586. package/dist/deploy/catalog-publish.d.ts +0 -3
  587. package/dist/deploy/catalog-publish.js +0 -7
  588. package/dist/doctor.d.ts +0 -22
  589. package/dist/doctor.js +0 -822
  590. package/dist/error-collector.d.ts +0 -2
  591. package/dist/error-collector.js +0 -46
  592. package/dist/host/broker-paths.d.ts +0 -1
  593. package/dist/host/broker-paths.js +0 -1
  594. package/dist/host/broker-upgrade-preflight.d.ts +0 -61
  595. package/dist/host/broker-upgrade-preflight.js +0 -156
  596. package/dist/host/digests.d.ts +0 -5
  597. package/dist/host/digests.js +0 -63
  598. package/dist/host/fake-nas.d.ts +0 -49
  599. package/dist/host/fake-nas.js +0 -193
  600. package/dist/mock-broker/bootstrap.d.ts +0 -2
  601. package/dist/mock-broker/bootstrap.js +0 -8
  602. package/dist/mock-broker/files.d.ts +0 -60
  603. package/dist/mock-broker/files.js +0 -408
  604. package/dist/mock-broker/oidc.d.ts +0 -31
  605. package/dist/mock-broker/oidc.js +0 -161
  606. package/dist/mock-broker/path.d.ts +0 -9
  607. package/dist/mock-broker/path.js +0 -50
  608. package/dist/mock-broker/server.d.ts +0 -19
  609. package/dist/mock-broker/server.js +0 -350
  610. package/dist/publish/build-ledger.d.ts +0 -22
  611. package/dist/publish/build-ledger.js +0 -26
  612. package/dist/publish/community-path.d.ts +0 -6
  613. package/dist/publish/community-path.js +0 -41
  614. package/dist/publish/curated-release.d.ts +0 -78
  615. package/dist/publish/curated-release.js +0 -883
  616. package/dist/publish/file-build-ledger.d.ts +0 -18
  617. package/dist/publish/file-build-ledger.js +0 -268
  618. package/dist/publish/github-pr.d.ts +0 -25
  619. package/dist/publish/github-pr.js +0 -85
  620. package/dist/publish/github-repo.d.ts +0 -8
  621. package/dist/publish/github-repo.js +0 -21
  622. package/dist/publish/platform-service-release.d.ts +0 -60
  623. package/dist/publish/platform-service-release.js +0 -333
  624. package/dist/publish/preflight.d.ts +0 -24
  625. package/dist/publish/preflight.js +0 -138
  626. package/dist/publish/publish.d.ts +0 -27
  627. package/dist/publish/publish.js +0 -136
  628. package/dist/publish/sync-definition.d.ts +0 -4
  629. package/dist/publish/sync-definition.js +0 -48
  630. package/dist/release-bin.d.ts +0 -2
  631. package/dist/release-bin.js +0 -23
  632. package/dist/templates/hello-web/html/sdk.js +0 -68
  633. package/dist/templates/hello-web-page/html/sdk.js +0 -68
  634. package/dist/templates/native/synology-app.yaml +0 -7
  635. package/dist/test-host.d.ts +0 -15
  636. package/dist/test-host.js +0 -37
  637. package/templates/hello-web/html/sdk.js +0 -68
  638. package/templates/hello-web-page/html/sdk.js +0 -68
  639. package/templates/native/synology-app.yaml +0 -7
  640. /package/dist/templates/{native → binary}/native.yaml +0 -0
  641. /package/templates/{native → binary}/native.yaml +0 -0
package/dist/init.js CHANGED
@@ -1,12 +1,13 @@
1
- import { mkdirSync, cpSync, existsSync } from "node:fs";
2
- import { dirname, join } from "node:path";
3
- import { fileURLToPath } from "node:url";
1
+ import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
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",
7
7
  "hello-files",
8
8
  "compose-import",
9
- "native",
9
+ "binary",
10
+ "native-go",
10
11
  ];
11
12
  export function isTemplateName(value) {
12
13
  return TEMPLATE_NAMES.includes(value);
@@ -14,19 +15,134 @@ export function isTemplateName(value) {
14
15
  export function listTemplates() {
15
16
  return [...TEMPLATE_NAMES];
16
17
  }
17
- function templatesRoot() {
18
- const moduleDir = dirname(fileURLToPath(import.meta.url));
19
- const distTemplates = join(moduleDir, "templates");
20
- if (existsSync(distTemplates)) {
21
- return distTemplates;
22
- }
23
- return join(moduleDir, "..", "templates");
18
+ /**
19
+ * native-go --privilege root: files laid over the native-go template, and the
20
+ * files they replace.
21
+ */
22
+ const ROOT_OVERLAY = "native-go-root";
23
+ const ROOT_REPLACED = ["backend/internal/app/root_none.go"];
24
+ /** Templates whose identity is filled in at init (placeholders in these files). */
25
+ const SUBSTITUTED = {
26
+ "native-go": ["dsm-package.yaml", "README.md"],
27
+ };
28
+ const PACKAGE_ID = /^[A-Za-z][A-Za-z0-9]{1,63}$/;
29
+ /** npm never publishes files named .gitignore, so templates ship them as `gitignore`. */
30
+ const RENAMED = { gitignore: ".gitignore" };
31
+ function words(dir) {
32
+ return basename(dir).split(/[^A-Za-z0-9]+/).filter(Boolean);
33
+ }
34
+ function defaultPackageId(dir) {
35
+ const id = words(dir).map((w) => w[0].toUpperCase() + w.slice(1)).join("");
36
+ return PACKAGE_ID.test(id) ? id : "MyPackage";
37
+ }
38
+ function defaultDisplayName(dir) {
39
+ const name = words(dir).map((w) => w[0].toUpperCase() + w.slice(1)).join(" ");
40
+ return name || "My Package";
41
+ }
42
+ function templateFiles(root, dir = root) {
43
+ return readdirSync(dir).flatMap((name) => {
44
+ const path = join(dir, name);
45
+ return statSync(path).isDirectory() ? templateFiles(root, path) : [relative(root, path)];
46
+ });
47
+ }
48
+ function targetName(file) {
49
+ return RENAMED[file] ?? file;
24
50
  }
25
- export function initFromTemplate(template, targetDir) {
51
+ export function initFromTemplate(template, targetDir, options = {}) {
26
52
  const source = join(templatesRoot(), template);
27
53
  if (!existsSync(source)) {
28
54
  throw new Error(`找不到模板:${template}`);
29
55
  }
56
+ const substitutions = substitutionsFor(template, targetDir, options);
57
+ const privilege = options.privilege ?? (options.integration ? "root" : "none");
58
+ const overlays = [
59
+ ...(privilege === "root" ? [ROOT_OVERLAY] : []),
60
+ ...(options.ui === "vue" ? ["native-go-vue"] : []),
61
+ ...(options.integration ? ["native-go-integration"] : []),
62
+ ...(options.integration === "better-auth" ? ["native-go-better-auth"] : []),
63
+ ].map(name => join(templatesRoot(), name));
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}`)] : [])];
70
+ const collisions = files.map(targetName).filter((file) => existsSync(join(targetDir, file)));
71
+ if (collisions.length > 0) {
72
+ throw new Error(`[INIT_TARGET_NOT_EMPTY] ${targetDir} 已有 ${collisions.join(", ")};init 不會覆蓋既有檔案。請改用空目錄。`);
73
+ }
30
74
  mkdirSync(targetDir, { recursive: true });
31
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"));
78
+ for (const overlay of overlays)
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 });
85
+ if (privilege === "root")
86
+ ROOT_REPLACED.forEach(file => rmSync(join(targetDir, file)));
87
+ for (const [from, to] of Object.entries(RENAMED)) {
88
+ if (files.includes(from)) {
89
+ renameSync(join(targetDir, from), join(targetDir, to));
90
+ }
91
+ }
92
+ for (const file of new Set([...(SUBSTITUTED[template] ?? []), ...overlays.flatMap(root => templateFiles(root))])) {
93
+ const path = join(targetDir, targetName(file));
94
+ let text = readFileSync(path, "utf8");
95
+ for (const [token, value] of Object.entries(substitutions)) {
96
+ text = text.replaceAll(token, value);
97
+ }
98
+ writeFileSync(path, text);
99
+ }
100
+ if (options.ui === "vue") {
101
+ const manifest = join(targetDir, "dsm-package.yaml");
102
+ writeFileSync(manifest, readFileSync(manifest, "utf8").replace(" dir: ui", " dir: frontend/dist\n build: {cwd: frontend, command: [npm, run, build]}"));
103
+ rmSync(join(targetDir, "ui"), { recursive: true });
104
+ }
105
+ if (options.integration === "better-auth")
106
+ rmSync(join(targetDir, "backend/internal/app/identity_none.go"));
107
+ if (options.integration) {
108
+ const mod = join(targetDir, "backend/go.mod");
109
+ writeFileSync(mod, readFileSync(mod, "utf8").replace("go 1.24", "go 1.25"));
110
+ const manifest = join(targetDir, "dsm-package.yaml");
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` : ""));
112
+ const routes = join(targetDir, "backend/internal/app/routes.go");
113
+ writeFileSync(routes, readFileSync(routes, "utf8").replace("return append(routes, cfg.rootRoutes()...)", "routes = append(routes, cfg.integrationRoutes()...)\n\treturn append(routes, cfg.rootRoutes()...)"));
114
+ }
115
+ }
116
+ function substitutionsFor(template, targetDir, options) {
117
+ if (options.privilege !== undefined && template !== "native-go") {
118
+ throw new Error("[INIT_PRIVILEGE_UNSUPPORTED] --privilege 只適用於 -t native-go。");
119
+ }
120
+ if ((options.ui !== undefined || options.integration !== undefined) && template !== "native-go")
121
+ throw new Error("[INIT_OPTIONS_UNSUPPORTED] --ui/--integration 只適用於 native-go。");
122
+ if (options.ui !== undefined && !["plain", "vue"].includes(options.ui))
123
+ throw new Error("[INIT_UI_INVALID] --ui 只接受 plain 或 vue。");
124
+ if (options.integration !== undefined && !["go", "better-auth"].includes(options.integration))
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。");
130
+ if (options.integration && (options.ui !== "vue" || options.privilege === "none"))
131
+ throw new Error("[INIT_INTEGRATION_OPTIONS] integration 需要 --ui vue 與 root privilege(自動選用)。");
132
+ const privilege = options.privilege ?? (options.integration ? "root" : "none");
133
+ if (privilege !== "none" && privilege !== "root") {
134
+ throw new Error(`[INIT_PRIVILEGE_INVALID] --privilege 只接受 none 或 root,收到「${String(privilege)}」。`);
135
+ }
136
+ if (!SUBSTITUTED[template]) {
137
+ return {};
138
+ }
139
+ const packageId = options.packageId ?? defaultPackageId(targetDir);
140
+ if (!PACKAGE_ID.test(packageId)) {
141
+ throw new Error(`[INIT_PACKAGE_INVALID] package「${packageId}」必須以英文字母開頭,只含英數字(2–64 字),例如 PhotoTagger。`);
142
+ }
143
+ const displayName = options.displayName ?? defaultDisplayName(targetDir);
144
+ if (displayName.trim() === "" || /[\r\n"\\]/.test(displayName)) {
145
+ throw new Error("[INIT_DISPLAY_NAME_INVALID] 顯示名稱必須是單行,且不含 \" 或 \\。");
146
+ }
147
+ return { __PACKAGE__: packageId, __DISPLAY_NAME__: displayName, __PRIVILEGE__: privilege };
32
148
  }
package/dist/log.js CHANGED
@@ -6,14 +6,13 @@ export async function followProjectLogs(options) {
6
6
  return { ok: false, lines: [], diagnostics: { code: "NOT_INSTALLED" } };
7
7
  }
8
8
  const lines = await options.host.fetchContainerLogs(identity.packageId);
9
- const info = await options.host.getAttestationInfo(identity.packageId);
9
+ const info = await options.host.getInstalledPackageState?.(identity.packageId);
10
10
  return {
11
11
  ok: true,
12
12
  lines,
13
13
  diagnostics: {
14
14
  packageIdentity: identity.packageId,
15
- attestationKind: info.attestationKind,
16
- readiness: info.readiness,
15
+ readiness: info?.status,
17
16
  redacted: true,
18
17
  },
19
18
  };
@@ -11,7 +11,6 @@ function nativeSpan(file, doc, pathSegments, pathString) {
11
11
  return { file, line: pos.line, column: pos.column, path: dotPath };
12
12
  }
13
13
  const HEX64_REGEX = /^[0-9a-fA-F]{64}$/;
14
- const FORBIDDEN_SERVICE_FIELDS = ["user", "command", "pre_start", "post_start", "shell"];
15
14
  export function validateNative(parsed, nativeFile, options = {}) {
16
15
  const errors = [];
17
16
  const profile = options.profile ?? "personal";
@@ -0,0 +1,9 @@
1
+ import type { NativeArchFamily } from "../build-spk/dsm-arch.js";
2
+ import type { StandaloneError } from "./manifest.js";
3
+ /**
4
+ * Checks a prebuilt CGI before it is packaged: a regular file inside the
5
+ * project, a 64-bit little-endian ELF for `arch`, and statically linked
6
+ * (no PT_INTERP), because DSM models ship different libc versions.
7
+ * Returns undefined when the file is acceptable.
8
+ */
9
+ export declare function checkCgiBinary(projectRoot: string, file: string, arch: NativeArchFamily): StandaloneError | undefined;
@@ -0,0 +1,67 @@
1
+ import { closeSync, lstatSync, openSync, readSync, realpathSync } from "node:fs";
2
+ import { relative } from "node:path";
3
+ const ELF_MACHINE = { x86_64: 62, aarch64: 183 };
4
+ const PT_INTERP = 3;
5
+ const MAX_BINARY_BYTES = 256 * 1024 * 1024;
6
+ const HEADER_BYTES = 64 * 1024;
7
+ function fail(code, message) {
8
+ return { code, message };
9
+ }
10
+ /**
11
+ * Checks a prebuilt CGI before it is packaged: a regular file inside the
12
+ * project, a 64-bit little-endian ELF for `arch`, and statically linked
13
+ * (no PT_INTERP), because DSM models ship different libc versions.
14
+ * Returns undefined when the file is acceptable.
15
+ */
16
+ export function checkCgiBinary(projectRoot, file, arch) {
17
+ let stat;
18
+ try {
19
+ stat = lstatSync(file);
20
+ }
21
+ catch {
22
+ return fail("STANDALONE_BINARY_MISSING", `找不到 ${arch} 的 backend 執行檔:${file}`);
23
+ }
24
+ if (!stat.isFile()) {
25
+ return fail("STANDALONE_BINARY_NOT_REGULAR", `${file} 必須是一般檔案(不可是 symlink 或目錄)。`);
26
+ }
27
+ const rel = relative(realpathSync(projectRoot), realpathSync(file));
28
+ if (rel.startsWith("..")) {
29
+ return fail("STANDALONE_PATH_OUTSIDE_PROJECT", `${file} 實際位於專案目錄之外。`);
30
+ }
31
+ if (stat.size > MAX_BINARY_BYTES) {
32
+ return fail("STANDALONE_BINARY_TOO_LARGE", `${file} 超過 256 MiB。`);
33
+ }
34
+ return checkElf(readHeader(file), file, arch);
35
+ }
36
+ function readHeader(file) {
37
+ const fd = openSync(file, "r");
38
+ try {
39
+ const buf = Buffer.alloc(HEADER_BYTES);
40
+ return buf.subarray(0, readSync(fd, buf, 0, HEADER_BYTES, 0));
41
+ }
42
+ finally {
43
+ closeSync(fd);
44
+ }
45
+ }
46
+ function checkElf(buf, file, arch) {
47
+ const notElf = fail("STANDALONE_BINARY_NOT_ELF", `${file} 不是 64-bit little-endian Linux ELF 執行檔。`);
48
+ if (buf.length < 64 || buf.toString("latin1", 0, 4) !== "\x7fELF" || buf[4] !== 2 || buf[5] !== 1) {
49
+ return notElf;
50
+ }
51
+ const machine = buf.readUInt16LE(18);
52
+ if (machine !== ELF_MACHINE[arch]) {
53
+ return fail("STANDALONE_BINARY_ARCH_MISMATCH", `${file} 的 ELF machine 是 ${machine},不是 ${arch}。`);
54
+ }
55
+ const phoff = Number(buf.readBigUInt64LE(32));
56
+ const phentsize = buf.readUInt16LE(54);
57
+ const phnum = buf.readUInt16LE(56);
58
+ if (phentsize < 4 || phoff + phentsize * phnum > buf.length) {
59
+ return notElf;
60
+ }
61
+ for (let i = 0; i < phnum; i++) {
62
+ if (buf.readUInt32LE(phoff + i * phentsize) === PT_INTERP) {
63
+ return fail("STANDALONE_BINARY_DYNAMIC", `${file} 是動態連結執行檔。請改用靜態連結(Go:CGO_ENABLED=0;Rust:*-unknown-linux-musl)。`);
64
+ }
65
+ }
66
+ return undefined;
67
+ }
@@ -0,0 +1,25 @@
1
+ import type { NativeArchFamily } from "../build-spk/dsm-arch.js";
2
+ export interface CommandResult {
3
+ status: number | null;
4
+ stderr: string;
5
+ /** The program itself was not found. */
6
+ missing?: boolean;
7
+ }
8
+ export type CommandRunner = (command: string, args: string[], options: {
9
+ cwd: string;
10
+ env: Record<string, string | undefined>;
11
+ }) => CommandResult;
12
+ export interface StandaloneBuildOptions {
13
+ root: string;
14
+ /** Defaults to every arch in the manifest. */
15
+ arches?: NativeArchFamily[];
16
+ /** Defaults to `<root>/dist`. */
17
+ outDir?: string;
18
+ run?: CommandRunner;
19
+ }
20
+ /** Argv only, never a shell; output streams to the terminal except stderr, which is also kept. */
21
+ export declare const runCommand: CommandRunner;
22
+ /** `build-spk` for a Standalone Package: build the UI, compile the CGI, pack one SPK per arch. */
23
+ export declare function buildStandalone(options: StandaloneBuildOptions): Promise<{
24
+ outputs: string[];
25
+ }>;
@@ -0,0 +1,110 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { mkdtempSync, rmSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { checkCgiBinary } from "./binary.js";
6
+ import { loadStandaloneManifest } from "./manifest.js";
7
+ import { assembleStandaloneSpk, StandaloneBuildError } from "./spk.js";
8
+ import { buildHelper } from "./helper.js";
9
+ import { buildDaemonControl } from "./daemon.js";
10
+ const GOARCH = { x86_64: "amd64", aarch64: "arm64" };
11
+ /** Argv only, never a shell; output streams to the terminal except stderr, which is also kept. */
12
+ export const runCommand = (command, args, options) => {
13
+ const result = spawnSync(command, args, {
14
+ cwd: options.cwd,
15
+ env: options.env,
16
+ stdio: ["ignore", "inherit", "pipe"],
17
+ encoding: "utf8",
18
+ });
19
+ if (result.stderr) {
20
+ process.stderr.write(result.stderr);
21
+ }
22
+ const missing = result.error?.code === "ENOENT";
23
+ return { status: result.status, stderr: result.stderr ?? "", missing };
24
+ };
25
+ /** `build-spk` for a Standalone Package: build the UI, compile the CGI, pack one SPK per arch. */
26
+ export async function buildStandalone(options) {
27
+ const loaded = loadStandaloneManifest(options.root);
28
+ if (!loaded.ok) {
29
+ const [first] = loaded.errors;
30
+ throw new StandaloneBuildError(first.code, loaded.errors.map((e) => `[${e.code}] ${e.message}`).join("\n"));
31
+ }
32
+ const manifest = loaded.manifest;
33
+ const run = options.run ?? runCommand;
34
+ const arches = options.arches ?? manifest.arches;
35
+ for (const arch of arches) {
36
+ if (!manifest.arches.includes(arch)) {
37
+ throw new StandaloneBuildError("STANDALONE_ARCH_NOT_DECLARED", `${arch} 不在 dsm-package.yaml 的 arches 內。`);
38
+ }
39
+ }
40
+ buildUi(manifest, run);
41
+ if (manifest.integration?.identity === "better-auth") {
42
+ const result = run("npm", ["run", "build"], { cwd: join(manifest.root, "node"), env: { ...process.env } });
43
+ if (result.missing || result.status !== 0)
44
+ throw new StandaloneBuildError("STANDALONE_IDENTITY_BUILD_FAILED", `Optional Better Auth build failed.\n${result.stderr}`);
45
+ }
46
+ const outDir = options.outDir ?? join(options.root, "dist");
47
+ const work = mkdtempSync(join(tmpdir(), "syno-standalone-build-"));
48
+ try {
49
+ const outputs = [];
50
+ for (const arch of arches) {
51
+ const helper = buildHelper(manifest, arch, work, run);
52
+ if (helper) {
53
+ const problem = checkCgiBinary(work, helper.binary, arch);
54
+ if (problem)
55
+ throw new StandaloneBuildError(problem.code, problem.message);
56
+ }
57
+ const cgiPath = backendFor(manifest, arch, work, run, helper);
58
+ const problem = checkCgiBinary(manifest.backend.kind === "go" ? work : manifest.root, cgiPath, arch);
59
+ if (problem) {
60
+ throw new StandaloneBuildError(problem.code, problem.message);
61
+ }
62
+ const outputPath = join(outDir, `${manifest.package}-${manifest.spkVersion}-${arch}.spk`);
63
+ const daemonControl = buildDaemonControl(manifest, arch, work, run);
64
+ const builtManifest = helper ? { ...manifest, rootOps: [...(manifest.rootOps ?? []), ...helper.ops] } : manifest;
65
+ await assembleStandaloneSpk({ manifest: builtManifest, arch, cgiPath, outputPath, helper, daemonControl });
66
+ outputs.push(outputPath);
67
+ }
68
+ return { outputs };
69
+ }
70
+ finally {
71
+ rmSync(work, { recursive: true, force: true });
72
+ }
73
+ }
74
+ function buildUi(manifest, run) {
75
+ const build = manifest.ui.build;
76
+ if (!build) {
77
+ return;
78
+ }
79
+ const [command, ...args] = build.command;
80
+ const result = run(command, args, { cwd: build.cwd, env: { ...process.env } });
81
+ if (result.missing || result.status !== 0) {
82
+ throw new StandaloneBuildError("STANDALONE_UI_BUILD_FAILED", `UI build(${build.command.join(" ")})失敗。\n${result.stderr}`);
83
+ }
84
+ }
85
+ function backendFor(manifest, arch, work, run, helper) {
86
+ const backend = manifest.backend;
87
+ if (backend.kind === "binary") {
88
+ return backend.files[arch];
89
+ }
90
+ const out = join(work, `api-${arch}.cgi`);
91
+ const ldflags = [
92
+ "-s",
93
+ "-w",
94
+ "-buildid=",
95
+ `-X main.packageID=${manifest.package}`,
96
+ `-X main.version=${manifest.spkVersion}`,
97
+ ...(helper ? [`-X 'main.helperInventory=${JSON.stringify(helper.inventory)}'`] : []),
98
+ ].join(" ");
99
+ const result = run("go", ["build", "-trimpath", "-buildvcs=false", "-ldflags", ldflags, "-o", out, backend.main], {
100
+ cwd: backend.dir,
101
+ env: { ...process.env, CGO_ENABLED: "0", GOOS: "linux", GOARCH: GOARCH[arch] },
102
+ });
103
+ if (result.missing) {
104
+ throw new StandaloneBuildError("STANDALONE_GO_MISSING", "找不到 go 指令。請安裝 Go 1.24 以上版本(https://go.dev/dl/),或改用 backend.binary 打包既有執行檔。");
105
+ }
106
+ if (result.status !== 0) {
107
+ throw new StandaloneBuildError("STANDALONE_GO_BUILD_FAILED", `go build(${arch})失敗。\n${result.stderr}`);
108
+ }
109
+ return out;
110
+ }
@@ -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
+ }
@@ -0,0 +1,26 @@
1
+ import type { StandaloneManifest } from "./manifest.js";
2
+ /** Same path the generated wrapper POSTs to, and the payload location of the CGI. */
3
+ export declare const CGI_PAYLOAD_PATH = "ui/cgi/api.cgi";
4
+ export declare function cgiUrl(packageId: string): string;
5
+ /**
6
+ * `createI18n(dsmLang, catalogs)` → `{ locale, t }`, plain ES5 so it runs in
7
+ * DSM's desktop as is. The DSM language picks a shipped catalog (else
8
+ * English); missing keys fall back to English, then to the key itself.
9
+ * `t(key, { count })` looks up `key.one` / `key.other` via Intl.PluralRules.
10
+ */
11
+ export declare const I18N_RUNTIME: string;
12
+ /**
13
+ * The wrapper file name carries the build so DSM never serves a wrapper
14
+ * cached from the previous version after an upgrade.
15
+ */
16
+ export declare function windowScriptName(manifest: Pick<StandaloneManifest, "build">): string;
17
+ /** `ui/config`: registers the DSM main-menu app and its window class. */
18
+ export declare function renderUiConfig(manifest: StandaloneManifest): string;
19
+ /**
20
+ * The DSM AppWindow that hosts the project's UI. It loads app/app.js and
21
+ * app/app.css once, then calls the app's mount(root, ctx). `ctx.call` is the
22
+ * only transport: same-origin POST with DSM's session cookie and SynoToken.
23
+ * `ctx.t` / `ctx.locale` translate with the catalogs embedded at build time.
24
+ * `assetVersion` busts browser caches when the UI changes.
25
+ */
26
+ export declare function renderWindowScript(manifest: StandaloneManifest, assetVersion: string): string;