@patodo/localapp 0.1.0

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 (527) hide show
  1. package/.localapp-artifact.json +2731 -0
  2. package/LICENSE +21 -0
  3. package/README.md +288 -0
  4. package/bin/localapp.mjs +34182 -0
  5. package/package.json +21 -0
  6. package/runtime/bootstrap/localapp-daemon-bootstrap.mjs +150 -0
  7. package/runtime/native/adapter-manifest.json +85 -0
  8. package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/Info.plist +21 -0
  9. package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
  10. package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +940 -0
  11. package/runtime/native/darwin-arm64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +128 -0
  12. package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/Info.plist +21 -0
  13. package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/MacOS/LocalAppBridge +0 -0
  14. package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/Resources/localapp-native-ipc-client.mjs +940 -0
  15. package/runtime/native/darwin-x64/LocalAppBridge.app/Contents/_CodeSignature/CodeResources +128 -0
  16. package/runtime/native/linux-x64/localapp-native-ipc-client.mjs +940 -0
  17. package/runtime/native/linux-x64/localapp-notifications +0 -0
  18. package/runtime/native/win32-x64/localapp-native-ipc-client.mjs +940 -0
  19. package/runtime/native/win32-x64/localapp-native.exe +0 -0
  20. package/runtime/server/.localapp-server-runtime.json +133 -0
  21. package/runtime/server/bin/server-cli.cjs +8343 -0
  22. package/runtime/server/bin/server.mjs +8 -0
  23. package/runtime/server/bin/worker.cjs +144339 -0
  24. package/runtime/server/node_modules/sql.js/dist/sql-wasm.js +185 -0
  25. package/runtime/server/node_modules/sql.js/dist/sql-wasm.wasm +0 -0
  26. package/runtime/server/node_modules/sql.js/package.json +58 -0
  27. package/runtime/server/package.json +11 -0
  28. package/runtime/server/runner/localapp-runner.mjs +324 -0
  29. package/runtime/server/web/404.html +1 -0
  30. package/runtime/server/web/_next/static/CqtRUQyhpQ2FmEc3vaVz3/_buildManifest.js +1 -0
  31. package/runtime/server/web/_next/static/CqtRUQyhpQ2FmEc3vaVz3/_ssgManifest.js +1 -0
  32. package/runtime/server/web/_next/static/chunks/184-184da63eba05808f.js +1 -0
  33. package/runtime/server/web/_next/static/chunks/265-a58973dbf631dc41.js +1 -0
  34. package/runtime/server/web/_next/static/chunks/308-d74213c6f5179bf0.js +1 -0
  35. package/runtime/server/web/_next/static/chunks/416-53d48ad9442eb7b2.js +1 -0
  36. package/runtime/server/web/_next/static/chunks/448-280e06e915001cb5.js +1 -0
  37. package/runtime/server/web/_next/static/chunks/66-6f6658280a10fbca.js +1 -0
  38. package/runtime/server/web/_next/static/chunks/740d80ee-6c0a9504f1fd46f8.js +1 -0
  39. package/runtime/server/web/_next/static/chunks/86-7105ac54171494a1.js +1 -0
  40. package/runtime/server/web/_next/static/chunks/900-743e38de13217291.js +1 -0
  41. package/runtime/server/web/_next/static/chunks/app/(dashboard)/inbox/page-32b885c019043e48.js +1 -0
  42. package/runtime/server/web/_next/static/chunks/app/(dashboard)/layout-4b3a212263712a5c.js +1 -0
  43. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/analytics/page-6af9adc14ccfa925.js +1 -0
  44. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/apps/[name]/settings/page-8b6f809eeccdbd22.js +1 -0
  45. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/apps/page-7f1ddf07889da248.js +1 -0
  46. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/dashboard/page-a25eb621fb18491d.js +1 -0
  47. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/device-actions/page-e6045823829567f7.js +1 -0
  48. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/device-notifications/page-377ed49cf55da81d.js +1 -0
  49. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/favorites/page-82f292daebf98a2f.js +1 -0
  50. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/groups/page-fe4ed80c7b11920f.js +1 -0
  51. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/info/page-d5d5075eec069ce3.js +1 -0
  52. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/keys/page-35ed01bf39a163b6.js +1 -0
  53. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/layout-5481d53aae3a0ce1.js +1 -0
  54. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/orgs/page-44c606ff2233f1a8.js +1 -0
  55. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/page-f2331bbbe09541aa.js +1 -0
  56. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/pages/page-6bf4e160a99411ce.js +1 -0
  57. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/peers/page-27041dd149601002.js +1 -0
  58. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/recent/page-f321688d374a8ff3.js +1 -0
  59. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/settings/page-64e724318dc3a584.js +1 -0
  60. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/studio/page-a2c0c34538ac62b3.js +1 -0
  61. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/subscriptions/page-57cdaafe12347e32.js +1 -0
  62. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/system/page-96d2e1f8c2fb22b0.js +1 -0
  63. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/tasks/page-bf16b78ed6749d78.js +1 -0
  64. package/runtime/server/web/_next/static/chunks/app/(dashboard)/my/users/page-c47d4524d2a156b8.js +1 -0
  65. package/runtime/server/web/_next/static/chunks/app/(dashboard)/page-f4641be7b88818a2.js +1 -0
  66. package/runtime/server/web/_next/static/chunks/app/_not-found/page-f4902e6b69eebd4c.js +1 -0
  67. package/runtime/server/web/_next/static/chunks/app/layout-5557bc90d966fded.js +1 -0
  68. package/runtime/server/web/_next/static/chunks/app/platform-shell/[userId]/[name]/page-da0d5e71857f33d1.js +1 -0
  69. package/runtime/server/web/_next/static/chunks/app/platform-shell-preview/page-52fa7e8c8b480934.js +1 -0
  70. package/runtime/server/web/_next/static/chunks/app/setup/page-9e29d6f66825a8f8.js +1 -0
  71. package/runtime/server/web/_next/static/chunks/framework-1c02a2e60068b586.js +1 -0
  72. package/runtime/server/web/_next/static/chunks/main-21ea4d4d10f4a256.js +1 -0
  73. package/runtime/server/web/_next/static/chunks/main-app-5b3c67453d8c5b99.js +1 -0
  74. package/runtime/server/web/_next/static/chunks/pages/_app-649f81c9fedecf29.js +1 -0
  75. package/runtime/server/web/_next/static/chunks/pages/_error-64e3bd84e2ecae08.js +1 -0
  76. package/runtime/server/web/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  77. package/runtime/server/web/_next/static/chunks/webpack-0bed2fdf6baa566e.js +1 -0
  78. package/runtime/server/web/_next/static/css/afdc0938fca59693.css +3 -0
  79. package/runtime/server/web/_next/static/media/013b72fa676f92e0-s.woff2 +0 -0
  80. package/runtime/server/web/_next/static/media/22a5144ee8d83bca-s.p.woff2 +0 -0
  81. package/runtime/server/web/_next/static/media/2b5b02fc7e511755-s.woff2 +0 -0
  82. package/runtime/server/web/_next/static/media/65f03d54ccadf4a8-s.woff2 +0 -0
  83. package/runtime/server/web/_next/static/media/7d4881bb7e1bf84d-s.p.woff2 +0 -0
  84. package/runtime/server/web/_next/static/media/9766a7e9e2e0ad5a-s.woff2 +0 -0
  85. package/runtime/server/web/_next/static/media/aa016aab0e6d1295-s.woff2 +0 -0
  86. package/runtime/server/web/_next/static/media/b66cf8e69499582a-s.woff2 +0 -0
  87. package/runtime/server/web/_next/static/media/b9408752a0c24fb9-s.woff2 +0 -0
  88. package/runtime/server/web/_next/static/media/e038a29029a234f2-s.woff2 +0 -0
  89. package/runtime/server/web/_next/static/media/f639721981034f88-s.woff2 +0 -0
  90. package/runtime/server/web/home/redline-launch-hero.png +0 -0
  91. package/runtime/server/web/inbox.html +1 -0
  92. package/runtime/server/web/inbox.txt +27 -0
  93. package/runtime/server/web/index.html +1 -0
  94. package/runtime/server/web/index.txt +27 -0
  95. package/runtime/server/web/my/analytics.html +1 -0
  96. package/runtime/server/web/my/analytics.txt +27 -0
  97. package/runtime/server/web/my/apps/placeholder/settings.html +1 -0
  98. package/runtime/server/web/my/apps/placeholder/settings.txt +24 -0
  99. package/runtime/server/web/my/apps.html +1 -0
  100. package/runtime/server/web/my/apps.txt +27 -0
  101. package/runtime/server/web/my/dashboard.html +1 -0
  102. package/runtime/server/web/my/dashboard.txt +27 -0
  103. package/runtime/server/web/my/device-actions.html +1 -0
  104. package/runtime/server/web/my/device-actions.txt +24 -0
  105. package/runtime/server/web/my/device-notifications.html +1 -0
  106. package/runtime/server/web/my/device-notifications.txt +24 -0
  107. package/runtime/server/web/my/favorites.html +1 -0
  108. package/runtime/server/web/my/favorites.txt +27 -0
  109. package/runtime/server/web/my/groups.html +1 -0
  110. package/runtime/server/web/my/groups.txt +27 -0
  111. package/runtime/server/web/my/info.html +1 -0
  112. package/runtime/server/web/my/info.txt +27 -0
  113. package/runtime/server/web/my/keys.html +1 -0
  114. package/runtime/server/web/my/keys.txt +27 -0
  115. package/runtime/server/web/my/orgs.html +1 -0
  116. package/runtime/server/web/my/orgs.txt +27 -0
  117. package/runtime/server/web/my/pages.html +1 -0
  118. package/runtime/server/web/my/pages.txt +27 -0
  119. package/runtime/server/web/my/peers.html +1 -0
  120. package/runtime/server/web/my/peers.txt +24 -0
  121. package/runtime/server/web/my/recent.html +1 -0
  122. package/runtime/server/web/my/recent.txt +27 -0
  123. package/runtime/server/web/my/settings.html +1 -0
  124. package/runtime/server/web/my/settings.txt +27 -0
  125. package/runtime/server/web/my/studio.html +1 -0
  126. package/runtime/server/web/my/studio.txt +24 -0
  127. package/runtime/server/web/my/subscriptions.html +1 -0
  128. package/runtime/server/web/my/subscriptions.txt +27 -0
  129. package/runtime/server/web/my/system.html +1 -0
  130. package/runtime/server/web/my/system.txt +24 -0
  131. package/runtime/server/web/my/tasks.html +1 -0
  132. package/runtime/server/web/my/tasks.txt +24 -0
  133. package/runtime/server/web/my/users.html +1 -0
  134. package/runtime/server/web/my/users.txt +27 -0
  135. package/runtime/server/web/my.html +1 -0
  136. package/runtime/server/web/my.txt +27 -0
  137. package/runtime/server/web/platform-shell/placeholder/placeholder.html +1 -0
  138. package/runtime/server/web/platform-shell/placeholder/placeholder.txt +23 -0
  139. package/runtime/server/web/platform-shell-preview.html +1 -0
  140. package/runtime/server/web/platform-shell-preview.txt +23 -0
  141. package/runtime/server/web/setup.html +1 -0
  142. package/runtime/server/web/setup.txt +23 -0
  143. package/template/.claude/skills/agent-tool-patterns/SKILL.md +195 -0
  144. package/template/.claude/skills/localapp/SKILL.md +80 -0
  145. package/template/.claude/skills/localapp-auth/SKILL.md +299 -0
  146. package/template/.claude/skills/localapp-business/SKILL.md +325 -0
  147. package/template/.claude/skills/localapp-data/SKILL.md +381 -0
  148. package/template/.claude/skills/localapp-device-actions/SKILL.md +60 -0
  149. package/template/.claude/skills/localapp-notify/SKILL.md +118 -0
  150. package/template/.claude/skills/localapp-transitions/SKILL.md +238 -0
  151. package/template/.claude/skills/localapp-ui/SKILL.md +67 -0
  152. package/template/.claude/skills/localapp-upload/SKILL.md +172 -0
  153. package/template/AGENTS.md +33 -0
  154. package/template/CLAUDE.md +117 -0
  155. package/template/ISSUES.md +32 -0
  156. package/template/backend/resources/work_items/mutations.json +83 -0
  157. package/template/backend/resources/work_items/queries.json +83 -0
  158. package/template/backend/resources/work_items/schema.json +31 -0
  159. package/template/backend/schemas/mutations.schema.json +15 -0
  160. package/template/backend/schemas/queries.schema.json +36 -0
  161. package/template/backend/schemas/resource-schema.schema.json +25 -0
  162. package/template/components.json +25 -0
  163. package/template/index.html +12 -0
  164. package/template/migrations/001_work_items.sql +6 -0
  165. package/template/package.json +70 -0
  166. package/template/postcss.config.js +5 -0
  167. package/template/runtime/dev-shell.tsx +6398 -0
  168. package/template/runtime/hooks/use-mobile.ts +19 -0
  169. package/template/runtime/issue-reference.ts +44 -0
  170. package/template/runtime/lib/utils.ts +6 -0
  171. package/template/runtime/package.json +14 -0
  172. package/template/runtime/platform-capabilities.json +109 -0
  173. package/template/runtime/sdk/agent/package.json +51 -0
  174. package/template/runtime/sdk/agent/src/agent-chat.tsx +188 -0
  175. package/template/runtime/sdk/agent/src/assistant-ui-adapter.ts +87 -0
  176. package/template/runtime/sdk/agent/src/context.ts +56 -0
  177. package/template/runtime/sdk/agent/src/dev-bridge.ts +21 -0
  178. package/template/runtime/sdk/agent/src/index.ts +19 -0
  179. package/template/runtime/sdk/agent/src/llm-adapter.ts +263 -0
  180. package/template/runtime/sdk/agent/src/native-registry.ts +61 -0
  181. package/template/runtime/sdk/agent/src/platform-runtime.ts +164 -0
  182. package/template/runtime/sdk/agent/src/postmessage-bridge.ts +60 -0
  183. package/template/runtime/sdk/agent/src/postmessage-types.ts +150 -0
  184. package/template/runtime/sdk/agent/src/tools.ts +70 -0
  185. package/template/runtime/sdk/agent/src/types.ts +27 -0
  186. package/template/runtime/sdk/agent/src/use-agent.ts +139 -0
  187. package/template/runtime/sdk/agent/src/use-register-edit-session.ts +54 -0
  188. package/template/runtime/sdk/agent/src/use-register-tools.ts +92 -0
  189. package/template/runtime/sdk/agent/tests/platform-runtime.test.ts +154 -0
  190. package/template/runtime/sdk/agent/tests/postmessage-bridge.test.ts +119 -0
  191. package/template/runtime/sdk/agent/tests/shell-integration.test.ts +71 -0
  192. package/template/runtime/sdk/agent/tests/use-register-edit-session.test.tsx +125 -0
  193. package/template/runtime/sdk/agent/tests/use-register-tools.test.ts +208 -0
  194. package/template/runtime/sdk/agent/tsconfig.json +18 -0
  195. package/template/runtime/sdk/agent/vitest.config.ts +8 -0
  196. package/template/runtime/sdk/backend/package.json +15 -0
  197. package/template/runtime/sdk/backend/src/index.ts +92 -0
  198. package/template/runtime/sdk/backend/tsconfig.json +8 -0
  199. package/template/runtime/sdk/core/package.json +15 -0
  200. package/template/runtime/sdk/core/src/client.ts +317 -0
  201. package/template/runtime/sdk/core/src/collaboration.ts +66 -0
  202. package/template/runtime/sdk/core/src/desktop.ts +469 -0
  203. package/template/runtime/sdk/core/src/device.ts +112 -0
  204. package/template/runtime/sdk/core/src/index.ts +6 -0
  205. package/template/runtime/sdk/core/src/invalidate.ts +40 -0
  206. package/template/runtime/sdk/core/src/types.ts +108 -0
  207. package/template/runtime/sdk/core/tests/capabilities.test.ts +64 -0
  208. package/template/runtime/sdk/core/tests/client.test.ts +424 -0
  209. package/template/runtime/sdk/core/tests/collaboration.test.ts +92 -0
  210. package/template/runtime/sdk/core/tests/desktop.test.ts +310 -0
  211. package/template/runtime/sdk/core/tests/device.test.ts +69 -0
  212. package/template/runtime/sdk/core/tsconfig.json +17 -0
  213. package/template/runtime/sdk/react/package.json +34 -0
  214. package/template/runtime/sdk/react/src/client.ts +7 -0
  215. package/template/runtime/sdk/react/src/components/can.tsx +24 -0
  216. package/template/runtime/sdk/react/src/hooks/use-action.ts +34 -0
  217. package/template/runtime/sdk/react/src/hooks/use-capabilities.ts +35 -0
  218. package/template/runtime/sdk/react/src/hooks/use-count.ts +37 -0
  219. package/template/runtime/sdk/react/src/hooks/use-create.ts +37 -0
  220. package/template/runtime/sdk/react/src/hooks/use-delete.ts +36 -0
  221. package/template/runtime/sdk/react/src/hooks/use-desktop-action.ts +94 -0
  222. package/template/runtime/sdk/react/src/hooks/use-device-action.ts +62 -0
  223. package/template/runtime/sdk/react/src/hooks/use-get.ts +37 -0
  224. package/template/runtime/sdk/react/src/hooks/use-group-members.ts +31 -0
  225. package/template/runtime/sdk/react/src/hooks/use-groups.ts +31 -0
  226. package/template/runtime/sdk/react/src/hooks/use-list.ts +53 -0
  227. package/template/runtime/sdk/react/src/hooks/use-me.ts +35 -0
  228. package/template/runtime/sdk/react/src/hooks/use-mutation.ts +30 -0
  229. package/template/runtime/sdk/react/src/hooks/use-permissions.ts +37 -0
  230. package/template/runtime/sdk/react/src/hooks/use-platform-data.ts +94 -0
  231. package/template/runtime/sdk/react/src/hooks/use-query.ts +30 -0
  232. package/template/runtime/sdk/react/src/hooks/use-time.ts +36 -0
  233. package/template/runtime/sdk/react/src/hooks/use-transaction.ts +30 -0
  234. package/template/runtime/sdk/react/src/hooks/use-transitions.ts +82 -0
  235. package/template/runtime/sdk/react/src/hooks/use-update.ts +37 -0
  236. package/template/runtime/sdk/react/src/hooks/use-upload.ts +30 -0
  237. package/template/runtime/sdk/react/src/hooks/use-users.ts +31 -0
  238. package/template/runtime/sdk/react/src/index.ts +40 -0
  239. package/template/runtime/sdk/react/src/permissions.ts +94 -0
  240. package/template/runtime/sdk/react/tests/permissions.test.ts +176 -0
  241. package/template/runtime/sdk/react/tests/use-action.test.tsx +64 -0
  242. package/template/runtime/sdk/react/tests/use-capabilities.test.tsx +48 -0
  243. package/template/runtime/sdk/react/tests/use-desktop-action.test.tsx +144 -0
  244. package/template/runtime/sdk/react/tests/use-permissions.test.tsx +162 -0
  245. package/template/runtime/sdk/react/tests/use-platform-data.test.tsx +89 -0
  246. package/template/runtime/sdk/react/tests/use-transaction.test.tsx +65 -0
  247. package/template/runtime/sdk/react/tests/use-transitions.test.ts +149 -0
  248. package/template/runtime/sdk/react/tsconfig.json +18 -0
  249. package/template/runtime/sdk/react/vitest.config.ts +9 -0
  250. package/template/runtime/sdk/react/vitest.setup.ts +6 -0
  251. package/template/runtime/server-core/dist/generated/platform-capabilities.d.ts +84 -0
  252. package/template/runtime/server-core/dist/generated/platform-capabilities.d.ts.map +1 -0
  253. package/template/runtime/server-core/dist/generated/platform-capabilities.js +115 -0
  254. package/template/runtime/server-core/dist/generated/platform-capabilities.js.map +1 -0
  255. package/template/runtime/server-core/dist/index.d.ts +19 -0
  256. package/template/runtime/server-core/dist/index.d.ts.map +1 -0
  257. package/template/runtime/server-core/dist/index.js +35 -0
  258. package/template/runtime/server-core/dist/index.js.map +1 -0
  259. package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.d.ts +2 -0
  260. package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.d.ts.map +1 -0
  261. package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.js +475 -0
  262. package/template/runtime/server-core/dist/lib/__tests__/action-runtime-hardening.test.js.map +1 -0
  263. package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.d.ts +2 -0
  264. package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.d.ts.map +1 -0
  265. package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.js +65 -0
  266. package/template/runtime/server-core/dist/lib/__tests__/app-api-contract.test.js.map +1 -0
  267. package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.d.ts +2 -0
  268. package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.d.ts.map +1 -0
  269. package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.js +103 -0
  270. package/template/runtime/server-core/dist/lib/__tests__/app-runtime.test.js.map +1 -0
  271. package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.d.ts +2 -0
  272. package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.d.ts.map +1 -0
  273. package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.js +358 -0
  274. package/template/runtime/server-core/dist/lib/__tests__/backend-actions.test.js.map +1 -0
  275. package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.d.ts +2 -0
  276. package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.d.ts.map +1 -0
  277. package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.js +786 -0
  278. package/template/runtime/server-core/dist/lib/__tests__/backend-contract.test.js.map +1 -0
  279. package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.d.ts +2 -0
  280. package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.d.ts.map +1 -0
  281. package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.js +82 -0
  282. package/template/runtime/server-core/dist/lib/__tests__/content-capabilities.test.js.map +1 -0
  283. package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.d.ts +2 -0
  284. package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.d.ts.map +1 -0
  285. package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.js +42 -0
  286. package/template/runtime/server-core/dist/lib/__tests__/database-write-guard.test.js.map +1 -0
  287. package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.d.ts +2 -0
  288. package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.d.ts.map +1 -0
  289. package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.js +144 -0
  290. package/template/runtime/server-core/dist/lib/__tests__/issue-collaboration.test.js.map +1 -0
  291. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.d.ts +2 -0
  292. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.d.ts.map +1 -0
  293. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.js +75 -0
  294. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-minimization.test.js.map +1 -0
  295. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.d.ts +2 -0
  296. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.d.ts.map +1 -0
  297. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.js +85 -0
  298. package/template/runtime/server-core/dist/lib/__tests__/issue-comment-pins.test.js.map +1 -0
  299. package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.d.ts +2 -0
  300. package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.d.ts.map +1 -0
  301. package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.js +75 -0
  302. package/template/runtime/server-core/dist/lib/__tests__/issue-cross-references.test.js.map +1 -0
  303. package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.d.ts +2 -0
  304. package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.d.ts.map +1 -0
  305. package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.js +78 -0
  306. package/template/runtime/server-core/dist/lib/__tests__/issue-dependencies.test.js.map +1 -0
  307. package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.d.ts +2 -0
  308. package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.d.ts.map +1 -0
  309. package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.js +66 -0
  310. package/template/runtime/server-core/dist/lib/__tests__/issue-duplicates.test.js.map +1 -0
  311. package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.d.ts +2 -0
  312. package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.d.ts.map +1 -0
  313. package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.js +322 -0
  314. package/template/runtime/server-core/dist/lib/__tests__/issue-list.test.js.map +1 -0
  315. package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.d.ts +2 -0
  316. package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.d.ts.map +1 -0
  317. package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.js +49 -0
  318. package/template/runtime/server-core/dist/lib/__tests__/issue-potential-duplicates.test.js.map +1 -0
  319. package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.d.ts +2 -0
  320. package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.d.ts.map +1 -0
  321. package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.js +67 -0
  322. package/template/runtime/server-core/dist/lib/__tests__/issue-reactions.test.js.map +1 -0
  323. package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.d.ts +2 -0
  324. package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.d.ts.map +1 -0
  325. package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.js +91 -0
  326. package/template/runtime/server-core/dist/lib/__tests__/issue-revisions.test.js.map +1 -0
  327. package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.d.ts +2 -0
  328. package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.d.ts.map +1 -0
  329. package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.js +69 -0
  330. package/template/runtime/server-core/dist/lib/__tests__/issue-saved-views.test.js.map +1 -0
  331. package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.d.ts +2 -0
  332. package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.d.ts.map +1 -0
  333. package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.js +159 -0
  334. package/template/runtime/server-core/dist/lib/__tests__/issue-sub-issues.test.js.map +1 -0
  335. package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.d.ts +2 -0
  336. package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.d.ts.map +1 -0
  337. package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.js +102 -0
  338. package/template/runtime/server-core/dist/lib/__tests__/issue-task-conversion.test.js.map +1 -0
  339. package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.d.ts +2 -0
  340. package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.d.ts.map +1 -0
  341. package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.js +65 -0
  342. package/template/runtime/server-core/dist/lib/__tests__/issue-templates.test.js.map +1 -0
  343. package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.d.ts +2 -0
  344. package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.d.ts.map +1 -0
  345. package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.js +226 -0
  346. package/template/runtime/server-core/dist/lib/__tests__/issue-timeline.test.js.map +1 -0
  347. package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.d.ts +2 -0
  348. package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.d.ts.map +1 -0
  349. package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.js +64 -0
  350. package/template/runtime/server-core/dist/lib/__tests__/issue-types.test.js.map +1 -0
  351. package/template/runtime/server-core/dist/lib/__tests__/migrations.test.d.ts +2 -0
  352. package/template/runtime/server-core/dist/lib/__tests__/migrations.test.d.ts.map +1 -0
  353. package/template/runtime/server-core/dist/lib/__tests__/migrations.test.js +101 -0
  354. package/template/runtime/server-core/dist/lib/__tests__/migrations.test.js.map +1 -0
  355. package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.d.ts +2 -0
  356. package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.d.ts.map +1 -0
  357. package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.js +69 -0
  358. package/template/runtime/server-core/dist/lib/__tests__/platform-capabilities.test.js.map +1 -0
  359. package/template/runtime/server-core/dist/lib/__tests__/transitions.test.d.ts +2 -0
  360. package/template/runtime/server-core/dist/lib/__tests__/transitions.test.d.ts.map +1 -0
  361. package/template/runtime/server-core/dist/lib/__tests__/transitions.test.js +32 -0
  362. package/template/runtime/server-core/dist/lib/__tests__/transitions.test.js.map +1 -0
  363. package/template/runtime/server-core/dist/lib/access-control.d.ts +34 -0
  364. package/template/runtime/server-core/dist/lib/access-control.d.ts.map +1 -0
  365. package/template/runtime/server-core/dist/lib/access-control.js +138 -0
  366. package/template/runtime/server-core/dist/lib/access-control.js.map +1 -0
  367. package/template/runtime/server-core/dist/lib/app-api-contract.d.ts +69 -0
  368. package/template/runtime/server-core/dist/lib/app-api-contract.d.ts.map +1 -0
  369. package/template/runtime/server-core/dist/lib/app-api-contract.js +57 -0
  370. package/template/runtime/server-core/dist/lib/app-api-contract.js.map +1 -0
  371. package/template/runtime/server-core/dist/lib/app-db.d.ts +486 -0
  372. package/template/runtime/server-core/dist/lib/app-db.d.ts.map +1 -0
  373. package/template/runtime/server-core/dist/lib/app-db.js +2581 -0
  374. package/template/runtime/server-core/dist/lib/app-db.js.map +1 -0
  375. package/template/runtime/server-core/dist/lib/app-runtime.d.ts +28 -0
  376. package/template/runtime/server-core/dist/lib/app-runtime.d.ts.map +1 -0
  377. package/template/runtime/server-core/dist/lib/app-runtime.js +56 -0
  378. package/template/runtime/server-core/dist/lib/app-runtime.js.map +1 -0
  379. package/template/runtime/server-core/dist/lib/backend-actions.d.ts +149 -0
  380. package/template/runtime/server-core/dist/lib/backend-actions.d.ts.map +1 -0
  381. package/template/runtime/server-core/dist/lib/backend-actions.js +926 -0
  382. package/template/runtime/server-core/dist/lib/backend-actions.js.map +1 -0
  383. package/template/runtime/server-core/dist/lib/backend-contract.d.ts +399 -0
  384. package/template/runtime/server-core/dist/lib/backend-contract.d.ts.map +1 -0
  385. package/template/runtime/server-core/dist/lib/backend-contract.js +1148 -0
  386. package/template/runtime/server-core/dist/lib/backend-contract.js.map +1 -0
  387. package/template/runtime/server-core/dist/lib/content-capabilities.d.ts +30 -0
  388. package/template/runtime/server-core/dist/lib/content-capabilities.d.ts.map +1 -0
  389. package/template/runtime/server-core/dist/lib/content-capabilities.js +133 -0
  390. package/template/runtime/server-core/dist/lib/content-capabilities.js.map +1 -0
  391. package/template/runtime/server-core/dist/lib/issue-saved-replies.d.ts +7 -0
  392. package/template/runtime/server-core/dist/lib/issue-saved-replies.d.ts.map +1 -0
  393. package/template/runtime/server-core/dist/lib/issue-saved-replies.js +22 -0
  394. package/template/runtime/server-core/dist/lib/issue-saved-replies.js.map +1 -0
  395. package/template/runtime/server-core/dist/lib/issue-saved-views.d.ts +43 -0
  396. package/template/runtime/server-core/dist/lib/issue-saved-views.d.ts.map +1 -0
  397. package/template/runtime/server-core/dist/lib/issue-saved-views.js +201 -0
  398. package/template/runtime/server-core/dist/lib/issue-saved-views.js.map +1 -0
  399. package/template/runtime/server-core/dist/lib/issue-task-conversion.d.ts +11 -0
  400. package/template/runtime/server-core/dist/lib/issue-task-conversion.d.ts.map +1 -0
  401. package/template/runtime/server-core/dist/lib/issue-task-conversion.js +66 -0
  402. package/template/runtime/server-core/dist/lib/issue-task-conversion.js.map +1 -0
  403. package/template/runtime/server-core/dist/lib/issue-templates.d.ts +16 -0
  404. package/template/runtime/server-core/dist/lib/issue-templates.d.ts.map +1 -0
  405. package/template/runtime/server-core/dist/lib/issue-templates.js +89 -0
  406. package/template/runtime/server-core/dist/lib/issue-templates.js.map +1 -0
  407. package/template/runtime/server-core/dist/lib/migrations.d.ts +31 -0
  408. package/template/runtime/server-core/dist/lib/migrations.d.ts.map +1 -0
  409. package/template/runtime/server-core/dist/lib/migrations.js +180 -0
  410. package/template/runtime/server-core/dist/lib/migrations.js.map +1 -0
  411. package/template/runtime/server-core/dist/lib/notify-permission-sql.d.ts +21 -0
  412. package/template/runtime/server-core/dist/lib/notify-permission-sql.d.ts.map +1 -0
  413. package/template/runtime/server-core/dist/lib/notify-permission-sql.js +71 -0
  414. package/template/runtime/server-core/dist/lib/notify-permission-sql.js.map +1 -0
  415. package/template/runtime/server-core/dist/lib/record-access.d.ts +34 -0
  416. package/template/runtime/server-core/dist/lib/record-access.d.ts.map +1 -0
  417. package/template/runtime/server-core/dist/lib/record-access.js +81 -0
  418. package/template/runtime/server-core/dist/lib/record-access.js.map +1 -0
  419. package/template/runtime/server-core/dist/lib/runtime-errors.d.ts +28 -0
  420. package/template/runtime/server-core/dist/lib/runtime-errors.d.ts.map +1 -0
  421. package/template/runtime/server-core/dist/lib/runtime-errors.js +67 -0
  422. package/template/runtime/server-core/dist/lib/runtime-errors.js.map +1 -0
  423. package/template/runtime/server-core/dist/lib/transitions.d.ts +55 -0
  424. package/template/runtime/server-core/dist/lib/transitions.d.ts.map +1 -0
  425. package/template/runtime/server-core/dist/lib/transitions.js +142 -0
  426. package/template/runtime/server-core/dist/lib/transitions.js.map +1 -0
  427. package/template/runtime/server-core/dist/types/models.d.ts +163 -0
  428. package/template/runtime/server-core/dist/types/models.d.ts.map +1 -0
  429. package/template/runtime/server-core/dist/types/models.js +3 -0
  430. package/template/runtime/server-core/dist/types/models.js.map +1 -0
  431. package/template/runtime/server-core/package.json +24 -0
  432. package/template/runtime/styles/preset.css +282 -0
  433. package/template/runtime/sync-template-command.cjs +19 -0
  434. package/template/runtime/sync-template.cjs +71 -0
  435. package/template/runtime/tsconfig.base.json +20 -0
  436. package/template/runtime/version.json +3 -0
  437. package/template/runtime/vite-plugin.mjs +309 -0
  438. package/template/src/App.tsx +273 -0
  439. package/template/src/components/ui/accordion.tsx +79 -0
  440. package/template/src/components/ui/alert-dialog.tsx +197 -0
  441. package/template/src/components/ui/alert.tsx +76 -0
  442. package/template/src/components/ui/aspect-ratio.tsx +11 -0
  443. package/template/src/components/ui/avatar.tsx +110 -0
  444. package/template/src/components/ui/badge.tsx +49 -0
  445. package/template/src/components/ui/breadcrumb.tsx +122 -0
  446. package/template/src/components/ui/button-group.tsx +83 -0
  447. package/template/src/components/ui/button.tsx +67 -0
  448. package/template/src/components/ui/calendar.tsx +221 -0
  449. package/template/src/components/ui/card.tsx +103 -0
  450. package/template/src/components/ui/carousel.tsx +240 -0
  451. package/template/src/components/ui/chart.tsx +373 -0
  452. package/template/src/components/ui/checkbox.tsx +31 -0
  453. package/template/src/components/ui/collapsible.tsx +33 -0
  454. package/template/src/components/ui/combobox.tsx +299 -0
  455. package/template/src/components/ui/command.tsx +193 -0
  456. package/template/src/components/ui/context-menu.tsx +261 -0
  457. package/template/src/components/ui/dialog.tsx +168 -0
  458. package/template/src/components/ui/direction.tsx +22 -0
  459. package/template/src/components/ui/drawer.tsx +132 -0
  460. package/template/src/components/ui/dropdown-menu.tsx +269 -0
  461. package/template/src/components/ui/empty.tsx +104 -0
  462. package/template/src/components/ui/field.tsx +238 -0
  463. package/template/src/components/ui/hover-card.tsx +42 -0
  464. package/template/src/components/ui/input-group.tsx +154 -0
  465. package/template/src/components/ui/input-otp.tsx +87 -0
  466. package/template/src/components/ui/input.tsx +19 -0
  467. package/template/src/components/ui/item.tsx +196 -0
  468. package/template/src/components/ui/kbd.tsx +26 -0
  469. package/template/src/components/ui/label.tsx +22 -0
  470. package/template/src/components/ui/menubar.tsx +280 -0
  471. package/template/src/components/ui/native-select.tsx +61 -0
  472. package/template/src/components/ui/navigation-menu.tsx +164 -0
  473. package/template/src/components/ui/pagination.tsx +129 -0
  474. package/template/src/components/ui/popover.tsx +87 -0
  475. package/template/src/components/ui/progress.tsx +31 -0
  476. package/template/src/components/ui/radio-group.tsx +42 -0
  477. package/template/src/components/ui/resizable.tsx +50 -0
  478. package/template/src/components/ui/scroll-area.tsx +53 -0
  479. package/template/src/components/ui/select.tsx +192 -0
  480. package/template/src/components/ui/separator.tsx +26 -0
  481. package/template/src/components/ui/sheet.tsx +145 -0
  482. package/template/src/components/ui/sidebar.tsx +700 -0
  483. package/template/src/components/ui/skeleton.tsx +13 -0
  484. package/template/src/components/ui/slider.tsx +59 -0
  485. package/template/src/components/ui/sonner.tsx +47 -0
  486. package/template/src/components/ui/spinner.tsx +10 -0
  487. package/template/src/components/ui/switch.tsx +33 -0
  488. package/template/src/components/ui/table.tsx +114 -0
  489. package/template/src/components/ui/tabs.tsx +90 -0
  490. package/template/src/components/ui/textarea.tsx +18 -0
  491. package/template/src/components/ui/toggle-group.tsx +89 -0
  492. package/template/src/components/ui/toggle.tsx +45 -0
  493. package/template/src/components/ui/tooltip.tsx +57 -0
  494. package/template/src/hooks/use-mobile.ts +3 -0
  495. package/template/src/index.css +4 -0
  496. package/template/src/lib/utils.ts +3 -0
  497. package/template/src/main.tsx +10 -0
  498. package/template/src/vite-env.d.ts +1 -0
  499. package/template/template.gitignore +10 -0
  500. package/template/template.npmrc +1 -0
  501. package/template/tests/agent-context.test.ts +69 -0
  502. package/template/tests/agent-guidance-template.test.ts +49 -0
  503. package/template/tests/agent-runtime.test.ts +198 -0
  504. package/template/tests/agent-tools.test.ts +150 -0
  505. package/template/tests/agent-use-agent.test.ts +86 -0
  506. package/template/tests/assistant-ui-adapter.test.ts +211 -0
  507. package/template/tests/business-modeling-template.test.ts +71 -0
  508. package/template/tests/client.test.ts +382 -0
  509. package/template/tests/dev-issue-search-suggestions.test.ts +36 -0
  510. package/template/tests/dev-shell-context.test.tsx +40 -0
  511. package/template/tests/dev-shell-template.test.ts +2593 -0
  512. package/template/tests/invalidation.test.ts +126 -0
  513. package/template/tests/main-tsx.test.ts +28 -0
  514. package/template/tests/media-preview-template.test.ts +21 -0
  515. package/template/tests/mutations.test.ts +224 -0
  516. package/template/tests/react.test.ts +302 -0
  517. package/template/tests/redirect.test.ts +51 -0
  518. package/template/tests/skill-docs.test.ts +76 -0
  519. package/template/tests/state-transitions-template.test.ts +61 -0
  520. package/template/tests/template-ui.test.ts +145 -0
  521. package/template/tests/upload.test.ts +143 -0
  522. package/template/tests/vite-plugin.test.ts +426 -0
  523. package/template/tests/vite-proxy-security.test.ts +153 -0
  524. package/template/tsconfig.json +11 -0
  525. package/template/vite.config.ts +7 -0
  526. package/template/vitest.config.ts +16 -0
  527. package/template/vitest.setup.ts +1 -0
@@ -0,0 +1,469 @@
1
+ import { detectBasePath } from "./client.js";
2
+
3
+ export const DESKTOP_ACTION_PROTOCOL_VERSION = 1;
4
+
5
+ export type DesktopActionStatus =
6
+ | "pending"
7
+ | "claimed"
8
+ | "awaiting_trust"
9
+ | "preparing"
10
+ | "running"
11
+ | "succeeded"
12
+ | "failed"
13
+ | "cancelled"
14
+ | "expired"
15
+ | "interrupted";
16
+
17
+ export type DesktopActionTerminalStatus = Extract<
18
+ DesktopActionStatus,
19
+ "succeeded" | "failed" | "cancelled" | "expired" | "interrupted"
20
+ >;
21
+
22
+ export interface DesktopActionRequest {
23
+ title: string;
24
+ description?: string;
25
+ script: string;
26
+ dependencies?: Record<string, string>;
27
+ input?: unknown;
28
+ timeoutSeconds?: number;
29
+ }
30
+
31
+ export interface DesktopActionResultError {
32
+ message: string;
33
+ code?: string;
34
+ }
35
+
36
+ export interface DesktopActionSnapshot<TResult = unknown> {
37
+ requestId: string;
38
+ status: DesktopActionStatus;
39
+ result: TResult | null;
40
+ error: DesktopActionResultError | null;
41
+ title?: string;
42
+ description?: string | null;
43
+ appOwner?: string;
44
+ appName?: string;
45
+ appVersion?: string | null;
46
+ publisherUserId?: string;
47
+ publisherDisplayName?: string | null;
48
+ createdAt?: string;
49
+ updatedAt?: string;
50
+ expiresAt?: string;
51
+ claimedAt?: string | null;
52
+ completedAt?: string | null;
53
+ }
54
+
55
+ export type DesktopActionErrorCode =
56
+ | "unsupported"
57
+ | "offline"
58
+ | "protocol_mismatch"
59
+ | "aborted"
60
+ | "observation_timeout"
61
+ | "request_failed"
62
+ | "invalid_response";
63
+
64
+ export class DesktopActionError extends Error {
65
+ readonly code: DesktopActionErrorCode;
66
+ readonly status: number;
67
+ readonly requestId?: string;
68
+
69
+ constructor(code: DesktopActionErrorCode, message: string, options: { status?: number; requestId?: string } = {}) {
70
+ super(message);
71
+ this.name = "DesktopActionError";
72
+ this.code = code;
73
+ this.status = options.status ?? 0;
74
+ this.requestId = options.requestId;
75
+ }
76
+ }
77
+
78
+ export interface DesktopActionRunOptions<TResult = unknown> {
79
+ signal?: AbortSignal;
80
+ observationTimeoutMs?: number;
81
+ onRequestId?: (requestId: string) => void;
82
+ onStatus?: (snapshot: DesktopActionSnapshot<TResult>) => void;
83
+ }
84
+
85
+ export interface DesktopApi {
86
+ run<TResult = unknown>(request: DesktopActionRequest, options?: DesktopActionRunOptions<TResult>): Promise<DesktopActionSnapshot<TResult>>;
87
+ get<TResult = unknown>(requestId: string): Promise<DesktopActionSnapshot<TResult>>;
88
+ }
89
+
90
+ interface EventSourceLike {
91
+ onmessage: ((event: MessageEvent<string>) => void) | null;
92
+ onerror: ((event: Event) => unknown) | null;
93
+ addEventListener?(type: string, listener: (event: MessageEvent<string>) => void): void;
94
+ close(): void;
95
+ }
96
+
97
+ interface EventSourceConstructor {
98
+ new(url: string): EventSourceLike;
99
+ }
100
+
101
+ export interface DesktopApiEnvironment {
102
+ fetch?: typeof fetch;
103
+ EventSource?: EventSourceConstructor;
104
+ activate?: (url: string) => void;
105
+ pollIntervalMs?: number;
106
+ }
107
+
108
+ interface CapabilityResponse {
109
+ supported: boolean;
110
+ online: boolean;
111
+ protocolVersion: number;
112
+ }
113
+
114
+ interface CreateResponse {
115
+ requestId: string;
116
+ activationUrl: string;
117
+ status?: DesktopActionStatus;
118
+ }
119
+
120
+ const TERMINAL_STATUSES = new Set<DesktopActionStatus>([
121
+ "succeeded",
122
+ "failed",
123
+ "cancelled",
124
+ "expired",
125
+ "interrupted",
126
+ ]);
127
+ const DEFAULT_OBSERVATION_TIMEOUT_MS = 10 * 60 * 1000;
128
+ const DEFAULT_POLL_INTERVAL_MS = 1000;
129
+
130
+ export function createDesktopApi(environment: DesktopApiEnvironment = {}): DesktopApi {
131
+ const getFetch = (): typeof fetch | undefined => environment.fetch ?? globalThis.fetch?.bind(globalThis);
132
+ const getEventSource = (): EventSourceConstructor | undefined => environment.EventSource ?? globalThis.EventSource;
133
+ const activate = environment.activate ?? activateCustomProtocol;
134
+ const pollIntervalMs = environment.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS;
135
+
136
+ async function get<TResult = unknown>(requestId: string): Promise<DesktopActionSnapshot<TResult>> {
137
+ const raw = await requestJson(
138
+ getFetch(),
139
+ `/api/desktop-actions/${encodeURIComponent(requestId)}`,
140
+ { method: "GET" },
141
+ );
142
+ return toSnapshot<TResult>(unwrapData(raw), requestId);
143
+ }
144
+
145
+ async function run<TResult = unknown>(
146
+ request: DesktopActionRequest,
147
+ options: DesktopActionRunOptions<TResult> = {},
148
+ ): Promise<DesktopActionSnapshot<TResult>> {
149
+ throwIfAborted(options.signal);
150
+ await negotiate(getFetch(), options.signal);
151
+ throwIfAborted(options.signal);
152
+ const raw = await requestJson(getFetch(), `${detectBasePath()}/desktop-actions`, {
153
+ method: "POST",
154
+ headers: { "Content-Type": "application/json" },
155
+ body: JSON.stringify({ ...request, protocolVersion: DESKTOP_ACTION_PROTOCOL_VERSION }),
156
+ ...(options.signal ? { signal: options.signal } : {}),
157
+ });
158
+ const created = toCreateResponse(unwrapData(raw));
159
+ options.onRequestId?.(created.requestId);
160
+ options.onStatus?.({
161
+ requestId: created.requestId,
162
+ status: created.status ?? "pending",
163
+ result: null,
164
+ error: null,
165
+ });
166
+ activate(created.activationUrl);
167
+ return observe<TResult>(created.requestId, options);
168
+ }
169
+
170
+ function observe<TResult>(
171
+ requestId: string,
172
+ options: DesktopActionRunOptions<TResult>,
173
+ ): Promise<DesktopActionSnapshot<TResult>> {
174
+ return new Promise((resolve, reject) => {
175
+ let source: EventSourceLike | null = null;
176
+ let settled = false;
177
+ let polling = false;
178
+ const timeoutMs = options.observationTimeoutMs ?? DEFAULT_OBSERVATION_TIMEOUT_MS;
179
+ const EventSourceImpl = getEventSource();
180
+
181
+ const finish = (callback: () => void): void => {
182
+ if (settled) return;
183
+ settled = true;
184
+ source?.close();
185
+ clearTimeout(timeout);
186
+ options.signal?.removeEventListener("abort", abort);
187
+ callback();
188
+ };
189
+ const fail = (code: DesktopActionErrorCode, message: string): void => {
190
+ finish(() => reject(new DesktopActionError(code, message, { requestId })));
191
+ };
192
+ const accept = (snapshot: DesktopActionSnapshot<TResult>): void => {
193
+ if (settled) return;
194
+ options.onStatus?.(snapshot);
195
+ if (TERMINAL_STATUSES.has(snapshot.status)) finish(() => resolve(snapshot));
196
+ };
197
+ const abort = (): void => fail("aborted", "Desktop action observation was aborted");
198
+ const timeout = setTimeout(
199
+ () => fail("observation_timeout", "Desktop action observation timed out"),
200
+ Math.max(0, timeoutMs),
201
+ );
202
+
203
+ if (options.signal?.aborted) {
204
+ abort();
205
+ return;
206
+ }
207
+ options.signal?.addEventListener("abort", abort, { once: true });
208
+
209
+ const poll = async (): Promise<void> => {
210
+ if (polling || settled) return;
211
+ polling = true;
212
+ while (!settled) {
213
+ try {
214
+ accept(await get<TResult>(requestId));
215
+ } catch (error) {
216
+ if (error instanceof DesktopActionError && error.status >= 400 && error.status < 500) {
217
+ finish(() => reject(error));
218
+ return;
219
+ }
220
+ }
221
+ if (!settled) await delay(pollIntervalMs, options.signal);
222
+ }
223
+ };
224
+
225
+ if (!EventSourceImpl) {
226
+ void poll();
227
+ return;
228
+ }
229
+
230
+ source = new EventSourceImpl(`/api/desktop-actions/${encodeURIComponent(requestId)}/events`);
231
+ const receive = (event: MessageEvent<string>): void => {
232
+ try {
233
+ accept(toSnapshot<TResult>(unwrapData(parseJson(event.data)), requestId));
234
+ } catch {
235
+ // Ignore malformed event frames; the stream or timeout remains authoritative.
236
+ }
237
+ };
238
+ source.onmessage = receive;
239
+ source.addEventListener?.("desktop:action-updated", receive);
240
+ source.onerror = () => {
241
+ source?.close();
242
+ source = null;
243
+ void poll();
244
+ };
245
+ });
246
+ }
247
+
248
+ return { run, get };
249
+ }
250
+
251
+ async function negotiate(fetchRequest: typeof fetch | undefined, signal?: AbortSignal): Promise<void> {
252
+ let raw: unknown;
253
+ try {
254
+ raw = await requestJson(fetchRequest, "/api/desktop-actions/capabilities", {
255
+ method: "GET",
256
+ ...(signal ? { signal } : {}),
257
+ });
258
+ } catch (error) {
259
+ if (error instanceof DesktopActionError && error.code === "aborted") throw error;
260
+ if (error instanceof DesktopActionError && error.status === 404) {
261
+ throw new DesktopActionError("unsupported", "Desktop actions are not supported by this server", { status: 404 });
262
+ }
263
+ if (error instanceof DesktopActionError && error.status > 0) throw error;
264
+ throw new DesktopActionError("offline", "Desktop action capability could not be reached");
265
+ }
266
+ const capability = toCapability(unwrapData(raw));
267
+ if (!capability.supported) throw new DesktopActionError("unsupported", "Desktop actions are not supported by this server");
268
+ if (capability.protocolVersion !== DESKTOP_ACTION_PROTOCOL_VERSION) {
269
+ throw new DesktopActionError("protocol_mismatch", "Desktop action protocol version is incompatible");
270
+ }
271
+ if (!capability.online) throw new DesktopActionError("offline", "No compatible LocalApp Desktop client is online");
272
+ }
273
+
274
+ async function requestJson(fetchRequest: typeof fetch | undefined, url: string, init: RequestInit): Promise<unknown> {
275
+ if (!fetchRequest) throw new DesktopActionError("offline", "Fetch is not available in this environment");
276
+ let response: Response;
277
+ try {
278
+ response = await fetchRequest(url, init);
279
+ } catch (error) {
280
+ if (isAbortError(error)) {
281
+ throw new DesktopActionError("aborted", "Desktop action request was aborted");
282
+ }
283
+ throw new DesktopActionError("offline", `Could not reach ${url}`);
284
+ }
285
+ let text: string;
286
+ try {
287
+ text = await response.text();
288
+ } catch (error) {
289
+ if (isAbortError(error)) {
290
+ throw new DesktopActionError("aborted", "Desktop action request was aborted");
291
+ }
292
+ throw error;
293
+ }
294
+ let body: unknown;
295
+ try {
296
+ body = text ? parseJson(text) : null;
297
+ } catch {
298
+ body = null;
299
+ }
300
+ if (!response.ok || isFailedEnvelope(body)) {
301
+ throw new DesktopActionError(
302
+ "request_failed",
303
+ readErrorMessage(body) ?? `Desktop action request failed with HTTP ${response.status}`,
304
+ { status: response.status },
305
+ );
306
+ }
307
+ if (body === null) {
308
+ throw new DesktopActionError("invalid_response", `Desktop action endpoint returned a non-JSON response (HTTP ${response.status})`, {
309
+ status: response.status,
310
+ });
311
+ }
312
+ return body;
313
+ }
314
+
315
+ function parseJson(value: string): unknown {
316
+ return JSON.parse(value) as unknown;
317
+ }
318
+
319
+ function unwrapData(value: unknown): unknown {
320
+ if (isRecord(value) && "data" in value && (value.success === true || "success" in value)) return value.data;
321
+ return value;
322
+ }
323
+
324
+ function isFailedEnvelope(value: unknown): boolean {
325
+ return isRecord(value) && value.success === false;
326
+ }
327
+
328
+ function readErrorMessage(value: unknown): string | undefined {
329
+ if (!isRecord(value)) return undefined;
330
+ if (typeof value.error === "string") return value.error;
331
+ if (isRecord(value.error) && typeof value.error.message === "string") return value.error.message;
332
+ return undefined;
333
+ }
334
+
335
+ function toCapability(value: unknown): CapabilityResponse {
336
+ if (!isRecord(value)
337
+ || typeof value.supported !== "boolean"
338
+ || typeof value.online !== "boolean"
339
+ || typeof value.protocolVersion !== "number") {
340
+ throw new DesktopActionError("invalid_response", "Desktop capability response is invalid");
341
+ }
342
+ return value as unknown as CapabilityResponse;
343
+ }
344
+
345
+ function toCreateResponse(value: unknown): CreateResponse {
346
+ if (!isRecord(value)
347
+ || typeof value.requestId !== "string"
348
+ || typeof value.activationUrl !== "string"
349
+ || (!value.activationUrl.startsWith("localapp://") && !isLocalConfirmationUrl(value.activationUrl, value.requestId))) {
350
+ throw new DesktopActionError("invalid_response", "Desktop action creation response is invalid");
351
+ }
352
+ return value as unknown as CreateResponse;
353
+ }
354
+
355
+ function isLocalConfirmationUrl(value: string, requestId: string): boolean {
356
+ if (typeof window === "undefined" || typeof window.location?.origin !== "string") return false;
357
+ return value === `${window.location.origin}/my/device-actions/?requestId=${encodeURIComponent(requestId)}`;
358
+ }
359
+
360
+ function toSnapshot<TResult>(value: unknown, fallbackRequestId?: string): DesktopActionSnapshot<TResult> {
361
+ if (!isRecord(value)) throw new DesktopActionError("invalid_response", "Desktop action status response is invalid");
362
+ const requestId = typeof value.requestId === "string"
363
+ ? value.requestId
364
+ : typeof value.id === "string"
365
+ ? value.id
366
+ : fallbackRequestId;
367
+ if (!requestId || !isDesktopActionStatus(value.status)) {
368
+ throw new DesktopActionError("invalid_response", "Desktop action status response is invalid", { requestId: fallbackRequestId });
369
+ }
370
+ const snapshot: DesktopActionSnapshot<TResult> = {
371
+ requestId,
372
+ status: value.status,
373
+ result: (value.result ?? null) as TResult | null,
374
+ error: toResultError(value.error),
375
+ };
376
+ copyString(value, snapshot, "title");
377
+ copyNullableString(value, snapshot, "description");
378
+ copyString(value, snapshot, "appOwner");
379
+ copyString(value, snapshot, "appName");
380
+ copyNullableString(value, snapshot, "appVersion");
381
+ copyString(value, snapshot, "publisherUserId");
382
+ copyNullableString(value, snapshot, "publisherDisplayName");
383
+ copyString(value, snapshot, "createdAt");
384
+ copyString(value, snapshot, "updatedAt");
385
+ copyString(value, snapshot, "expiresAt");
386
+ copyNullableString(value, snapshot, "claimedAt");
387
+ copyNullableString(value, snapshot, "completedAt");
388
+ return snapshot;
389
+ }
390
+
391
+ function toResultError(value: unknown): DesktopActionResultError | null {
392
+ if (!isRecord(value) || typeof value.message !== "string") return null;
393
+ return typeof value.code === "string" ? { message: value.message, code: value.code } : { message: value.message };
394
+ }
395
+
396
+ function copyString(source: Record<string, unknown>, target: object, key: string): void {
397
+ if (typeof source[key] === "string") Object.assign(target, { [key]: source[key] });
398
+ }
399
+
400
+ function copyNullableString(source: Record<string, unknown>, target: object, key: string): void {
401
+ if (typeof source[key] === "string" || source[key] === null) Object.assign(target, { [key]: source[key] });
402
+ }
403
+
404
+ function isDesktopActionStatus(value: unknown): value is DesktopActionStatus {
405
+ return typeof value === "string" && (
406
+ value === "pending"
407
+ || value === "claimed"
408
+ || value === "awaiting_trust"
409
+ || value === "preparing"
410
+ || value === "running"
411
+ || value === "succeeded"
412
+ || value === "failed"
413
+ || value === "cancelled"
414
+ || value === "expired"
415
+ || value === "interrupted"
416
+ );
417
+ }
418
+
419
+ function isRecord(value: unknown): value is Record<string, unknown> {
420
+ return typeof value === "object" && value !== null;
421
+ }
422
+
423
+ function isAbortError(error: unknown): boolean {
424
+ return isRecord(error) && error.name === "AbortError";
425
+ }
426
+
427
+ function throwIfAborted(signal?: AbortSignal): void {
428
+ if (signal?.aborted) throw new DesktopActionError("aborted", "Desktop action request was aborted");
429
+ }
430
+
431
+ function activateCustomProtocol(url: string): void {
432
+ if (url.startsWith("http://") || url.startsWith("https://")) {
433
+ const target = new URL(url);
434
+ const event = new CustomEvent("localapp:platform_request", {
435
+ cancelable: true,
436
+ detail: {
437
+ type: "localapp:platform_request",
438
+ id: `device-action-${Date.now()}-${Math.random().toString(36).slice(2)}`,
439
+ capability: "openRoute",
440
+ payload: { href: `${target.pathname}${target.search}${target.hash}` },
441
+ },
442
+ });
443
+ if (!window.dispatchEvent(event)) return;
444
+ window.location.href = url;
445
+ return;
446
+ }
447
+ if (typeof document === "undefined") return;
448
+ const anchor = document.createElement("a");
449
+ anchor.href = url;
450
+ anchor.style.display = "none";
451
+ document.body?.appendChild(anchor);
452
+ anchor.click();
453
+ anchor.remove();
454
+ }
455
+
456
+ function delay(ms: number, signal?: AbortSignal): Promise<void> {
457
+ if (signal?.aborted) return Promise.resolve();
458
+ return new Promise((resolve) => {
459
+ const finish = (): void => {
460
+ clearTimeout(timeout);
461
+ signal?.removeEventListener("abort", finish);
462
+ resolve();
463
+ };
464
+ const timeout = setTimeout(finish, Math.max(0, ms));
465
+ signal?.addEventListener("abort", finish, { once: true });
466
+ });
467
+ }
468
+
469
+ export const desktop = createDesktopApi();
@@ -0,0 +1,112 @@
1
+ import {
2
+ createDesktopApi,
3
+ DesktopActionError,
4
+ type DesktopApiEnvironment,
5
+ type DesktopActionRequest,
6
+ type DesktopActionResultError,
7
+ type DesktopActionRunOptions,
8
+ type DesktopActionSnapshot,
9
+ type DesktopActionStatus,
10
+ type DesktopActionTerminalStatus,
11
+ } from "./desktop.js";
12
+
13
+ export const DEVICE_ACTION_PROTOCOL_VERSION = 2;
14
+
15
+ export type DeviceActionStatus = DesktopActionStatus;
16
+ export type DeviceActionTerminalStatus = DesktopActionTerminalStatus;
17
+ export type DeviceActionResultError = DesktopActionResultError;
18
+ export type DeviceActionSnapshot<TResult = unknown> = DesktopActionSnapshot<TResult> & {
19
+ permissions?: { filesystemRead?: string[]; filesystemWrite?: string[]; network?: boolean; childProcess?: boolean };
20
+ permissionsDigest?: string;
21
+ };
22
+ export type DeviceActionErrorCode = "unsupported" | "offline" | "protocol_mismatch" | "aborted" | "observation_timeout" | "request_failed" | "invalid_response";
23
+ export const DeviceActionError = DesktopActionError;
24
+ export type DeviceActionError = DesktopActionError;
25
+ export type DeviceActionRequest = Omit<DesktopActionRequest, "permissions"> & {
26
+ permissions: { filesystemRead?: string[]; filesystemWrite?: string[]; network?: boolean; childProcess?: boolean };
27
+ };
28
+ export type DeviceActionRunOptions<TResult = unknown> = Omit<DesktopActionRunOptions<TResult>, "onStatus"> & {
29
+ onStatus?: (snapshot: DeviceActionSnapshot<TResult>) => void;
30
+ };
31
+
32
+ export interface DeviceApi {
33
+ run<TResult = unknown>(request: DeviceActionRequest, options?: DeviceActionRunOptions<TResult>): Promise<DeviceActionSnapshot<TResult>>;
34
+ get<TResult = unknown>(requestId: string): Promise<DeviceActionSnapshot<TResult>>;
35
+ }
36
+
37
+ export interface DeviceApiEnvironment extends DesktopApiEnvironment {}
38
+
39
+ /**
40
+ * Generic device actions use the same observation implementation as the
41
+ * legacy client, but all requests are routed to the canonical Server Device
42
+ * Action endpoints. No application-specific installer contract is present.
43
+ */
44
+ export function createDeviceApi(environment: DeviceApiEnvironment = {}): DeviceApi {
45
+ const baseFetch = environment.fetch ?? globalThis.fetch?.bind(globalThis);
46
+ const fetcher: typeof fetch | undefined = baseFetch
47
+ ? async (input, init) => {
48
+ const original = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
49
+ const rewritten = rewriteDevicePath(original);
50
+ let actualInit = init;
51
+ if (init?.body && typeof init.body === "string" && init.method === "POST" && original.includes("/desktop-actions")) {
52
+ try {
53
+ const body = JSON.parse(init.body) as Record<string, unknown>;
54
+ actualInit = { ...init, body: JSON.stringify({ ...body, protocolVersion: DEVICE_ACTION_PROTOCOL_VERSION }) };
55
+ } catch {
56
+ // The canonical endpoint will return its normal invalid-payload response.
57
+ }
58
+ }
59
+ const response = await baseFetch(rewritten, actualInit);
60
+ if (!original.endsWith("/api/desktop-actions/capabilities") && !original.endsWith("/api/device-actions/capabilities")) return response;
61
+ const body = await response.text();
62
+ try {
63
+ const parsed = JSON.parse(body) as { success?: boolean; data?: Record<string, unknown> };
64
+ const capability = parsed.data ?? {};
65
+ return new Response(JSON.stringify({
66
+ success: parsed.success !== false,
67
+ data: {
68
+ supported: capability.supported !== false,
69
+ online: true,
70
+ protocolVersion: 1,
71
+ },
72
+ }), { status: response.status, headers: { "content-type": "application/json" } });
73
+ } catch {
74
+ return response;
75
+ }
76
+ }
77
+ : undefined;
78
+ const eventSource = environment.EventSource
79
+ ? class DeviceEventSource {
80
+ private readonly inner: EventSourceLike;
81
+ onmessage: ((event: MessageEvent<string>) => void) | null = null;
82
+ onerror: ((event: Event) => unknown) | null = null;
83
+
84
+ constructor(url: string) {
85
+ this.inner = new environment.EventSource!(rewriteDevicePath(url));
86
+ this.inner.onmessage = (event) => this.onmessage?.(event);
87
+ this.inner.onerror = (event) => this.onerror?.(event);
88
+ }
89
+
90
+ addEventListener(type: string, listener: (event: MessageEvent<string>) => void): void {
91
+ this.inner.addEventListener?.(type === "desktop:action-updated" ? "device:action-updated" : type, listener);
92
+ }
93
+
94
+ close(): void { this.inner.close(); }
95
+ }
96
+ : undefined;
97
+ const api = createDesktopApi({ ...environment, fetch: fetcher, ...(eventSource ? { EventSource: eventSource as never } : {}) });
98
+ return api as unknown as DeviceApi;
99
+ }
100
+
101
+ export const device = createDeviceApi();
102
+
103
+ function rewriteDevicePath(value: string): string {
104
+ return value.split("/api/desktop-actions").join("/api/device-actions");
105
+ }
106
+
107
+ interface EventSourceLike {
108
+ onmessage: ((event: MessageEvent<string>) => void) | null;
109
+ onerror: ((event: Event) => unknown) | null;
110
+ addEventListener?(type: string, listener: (event: MessageEvent<string>) => void): void;
111
+ close(): void;
112
+ }
@@ -0,0 +1,6 @@
1
+ export { createClient, detectBasePath, availableTransitions, transactionResult, type AvailableTransitionsOptions, type LocalAppClient, LocalAppError, redirectToLogin, type ExecResult, type NamedMutationResultRef, type NamedMutationStep, type NamedQueryResult, type TransitionInfo } from "./client.js";
2
+ export { subscribeCollaborationEvents, applyCommittedEventToDraftState, type CollaborationCommittedEvent, type SubscribeCollaborationEventsOptions, type DraftState } from "./collaboration.js";
3
+ export { desktop, createDesktopApi, DESKTOP_ACTION_PROTOCOL_VERSION, DesktopActionError, type DesktopActionErrorCode, type DesktopActionRequest, type DesktopActionResultError, type DesktopActionRunOptions, type DesktopActionSnapshot, type DesktopActionStatus, type DesktopActionTerminalStatus, type DesktopApi, type DesktopApiEnvironment } from "./desktop.js";
4
+ export { device, createDeviceApi, DEVICE_ACTION_PROTOCOL_VERSION, DeviceActionError, type DeviceActionErrorCode, type DeviceActionRequest, type DeviceActionResultError, type DeviceActionRunOptions, type DeviceActionSnapshot, type DeviceActionStatus, type DeviceActionTerminalStatus, type DeviceApi, type DeviceApiEnvironment } from "./device.js";
5
+ export type { User, UserBasic, GroupBasic, Pagination, ListOptions, ListResult, UploadResult, ServerTime, PlatformCapabilities } from "./types.js";
6
+ export { subscribe, invalidate } from "./invalidate.js";
@@ -0,0 +1,40 @@
1
+ type Listener = () => void;
2
+ const listeners = new Map<string, Set<Listener>>();
3
+ let devContextListenerTarget: Window | null = null;
4
+
5
+ export function subscribe(resource: string, fn: Listener): () => void {
6
+ installDevContextInvalidation();
7
+ if (!listeners.has(resource)) {
8
+ listeners.set(resource, new Set());
9
+ }
10
+ listeners.get(resource)!.add(fn);
11
+ return () => {
12
+ const set = listeners.get(resource);
13
+ if (set) {
14
+ set.delete(fn);
15
+ if (set.size === 0) listeners.delete(resource);
16
+ }
17
+ };
18
+ }
19
+
20
+ export function invalidate(resource: string): void {
21
+ const set = listeners.get(resource);
22
+ if (set) {
23
+ for (const fn of set) fn();
24
+ }
25
+ }
26
+
27
+ function invalidateAll(): void {
28
+ for (const set of listeners.values()) {
29
+ for (const fn of set) fn();
30
+ }
31
+ }
32
+
33
+ function installDevContextInvalidation(): void {
34
+ if (typeof window === "undefined" || typeof window.addEventListener !== "function") return;
35
+ const eventName = ["localapp", "dev-context-changed"].join(":");
36
+ if (devContextListenerTarget === window) return;
37
+ devContextListenerTarget?.removeEventListener(eventName, invalidateAll);
38
+ devContextListenerTarget = window;
39
+ window.addEventListener(eventName, invalidateAll);
40
+ }