alchemylab-opencode 1.0.26 → 2.0.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 (123) hide show
  1. package/NODE_COMPAT.md +23 -174
  2. package/dist/20260127222353_familiar_lady_ursula-KV747FJX.js +14 -0
  3. package/dist/{chunk-LTCXIXYM.js → 20260211171708_add_project_commands-GDOHPDPF.js} +3 -1
  4. package/dist/20260213144116_wakeful_the_professor-ZVDD54AK.js +14 -0
  5. package/dist/20260225215848_workspace-ZMSOZSPA.js +14 -0
  6. package/dist/20260227213759_add_session_workspace_id-ROENWPKA.js +14 -0
  7. package/dist/20260228203230_blue_harpoon-IW3Z4TQZ.js +14 -0
  8. package/dist/20260303231226_add_workspace_fields-OUVZMNAG.js +14 -0
  9. package/dist/20260309230000_move_org_to_state-NOXAPU5V.js +14 -0
  10. package/dist/20260312043431_session_message_cursor-DJ4T3T4R.js +14 -0
  11. package/dist/20260323234822_events-72GIKJ2A.js +14 -0
  12. package/dist/20260410174513_workspace-name-JXSWFBJN.js +14 -0
  13. package/dist/20260413175956_chief_energizer-4HEWZ6U3.js +14 -0
  14. package/dist/20260423070820_add_icon_url_override-X5SHFGTI.js +14 -0
  15. package/dist/20260427172553_slow_nightmare-PS5T2AH2.js +14 -0
  16. package/dist/{chunk-PWFRMDDF.js → 20260428004200_add_session_path-LGW75WYA.js} +3 -0
  17. package/dist/{valibot--1zFm7rT-FSYJNYJ6.js → 20260501142318_next_venus-J3TLVXZ6.js} +3 -1
  18. package/dist/20260504145000_add_sync_owner-3R52GB4C.js +14 -0
  19. package/dist/20260507164347_add_workspace_time-JHDRCZAR.js +14 -0
  20. package/dist/20260510033149_session_usage-UGBVOXZB.js +53 -0
  21. package/dist/20260511000411_data_migration_state-FB4LBFSE.js +14 -0
  22. package/dist/20260511173437_session-metadata-T2XHGWHS.js +14 -0
  23. package/dist/20260601010001_normalize_storage_paths-5MAY5GT3.js +14 -0
  24. package/dist/{chunk-YRY5Y3QL.js → 20260601202201_amazing_prowler-PET224YG.js} +3 -1
  25. package/dist/20260602002951_lowly_union_jack-PG6XDMGL.js +14 -0
  26. package/dist/20260602182828_add_project_directories-ZCH2ACGG.js +14 -0
  27. package/dist/20260603001617_session_message_projection_indexes-XVLJTUF2.js +14 -0
  28. package/dist/20260603040000_session_message_projection_order-XG6RACZQ.js +14 -0
  29. package/dist/20260603141458_session_input_inbox-K2VQ7V6E.js +14 -0
  30. package/dist/20260603160727_jittery_ezekiel_stane-WKJLRDO7.js +14 -0
  31. package/dist/20260604172448_event_sourced_session_input-NTXOECR7.js +14 -0
  32. package/dist/20260605003541_add_session_context_snapshot-DXMQEXMT.js +14 -0
  33. package/dist/{zod-Bwrt9trS-HVDOFWRP.js → 20260605042240_add_context_epoch_agent-W6IQYZXE.js} +3 -1
  34. package/dist/20260611035744_credential-XTMSYTJD.js +14 -0
  35. package/dist/20260611192811_lush_chimera-XPLIQMJD.js +14 -0
  36. package/dist/20260612174303_project_dir_strategy-FR2NGQKK.js +14 -0
  37. package/dist/20260622142730_simplify_session_context_epoch-NTQZR3RE.js +14 -0
  38. package/dist/20260622170816_reset_v2_session_state-5JPHJTZG.js +14 -0
  39. package/dist/20260622202450_simplify_session_input-2EXF2HMV.js +14 -0
  40. package/dist/app-runtime-6NGO2HRS.js +14 -0
  41. package/dist/chunk-4K2RXRZL.js +14 -0
  42. package/dist/chunk-BM2C7NHL.js +41 -0
  43. package/dist/chunk-E47SMIVL.js +186 -0
  44. package/dist/chunk-OMDJ6ZZ2.js +684 -0
  45. package/dist/chunk-PLQOF3WF.js +393 -0
  46. package/dist/chunk-QRABYJKL.js +14 -0
  47. package/dist/chunk-RHIWAYN5.js +14 -0
  48. package/dist/{arktype-aI7TBD0R-TFNARRIP.js → chunk-VURLSDCB.js} +3 -1
  49. package/dist/chunk-Z5TLIUAI.js +28 -0
  50. package/dist/chunk-ZMHNE2MU.js +865 -0
  51. package/dist/chunk-ZWLTE2TM.js +1455 -0
  52. package/dist/code-mode-YFX4N2VN.js +40 -0
  53. package/dist/copilot-provider-TX4YFKJZ.js +14 -0
  54. package/dist/photon-VQS5F5BI.js +14 -0
  55. package/dist/pty.node-Y3N2XKYG.js +14 -0
  56. package/dist/run.js +3 -1
  57. package/dist/serve.js +3 -1
  58. package/dist/server-TI57TGPO.js +17 -0
  59. package/dist/session-6RNXZNG6.js +14 -0
  60. package/dist/{chunk-2ANK3QEN.js → worktree-3RZQEGVC.js} +3 -1
  61. package/package.json +83 -50
  62. package/patches/@ai-sdk%2Famazon-bedrock@4.0.166.patch +164 -0
  63. package/patches/@ai-sdk%2Fanthropic@3.0.111.patch +528 -0
  64. package/patches/@ai-sdk%2Fgoogle@3.0.73.patch +69 -0
  65. package/patches/@ai-sdk%2Fgroq@3.0.31.patch +79 -0
  66. package/patches/@ai-sdk%2Fmistral@3.0.51.patch +714 -0
  67. package/patches/@ai-sdk%2Fopenai-compatible@2.0.41.patch +39 -0
  68. package/patches/@ai-sdk%2Fopenai@3.0.88.patch +280 -0
  69. package/patches/@ai-sdk%2Fxai@3.0.139.patch +296 -0
  70. package/patches/@modelcontextprotocol%2Fsdk@1.29.0.patch +647 -0
  71. package/patches/@npmcli%2Fagent@4.0.2.patch +13 -0
  72. package/patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch +285 -0
  73. package/patches/effect@4.0.0-beta.83.patch +57 -0
  74. package/patches/gcp-metadata@8.1.2.patch +14 -0
  75. package/patches/pacote@21.5.0.patch +18 -0
  76. package/postinstall.cjs +146 -0
  77. package/dist/chunk-5P5WLADX.js +0 -18
  78. package/dist/chunk-7KKA6WBY.js +0 -12
  79. package/dist/chunk-A7EXZZPC.js +0 -12
  80. package/dist/chunk-CZVKIDQZ.js +0 -12
  81. package/dist/chunk-FXLFZ5DL.js +0 -12
  82. package/dist/chunk-G752V4OP.js +0 -2187
  83. package/dist/chunk-GBXMNWYD.js +0 -18
  84. package/dist/chunk-IR6PDN4W.js +0 -13
  85. package/dist/chunk-M4CB72HE.js +0 -13
  86. package/dist/chunk-MBZTOEAD.js +0 -12
  87. package/dist/default-u_dwuiYb-652AQZKX.js +0 -12
  88. package/dist/effect-QlVUlMFu-JVYEXAZL.js +0 -12
  89. package/dist/log-MVJ7H4K5.js +0 -12
  90. package/dist/pty.node-X2EITEZ4.js +0 -12
  91. package/dist/registry-ISXIFNPG.js +0 -12
  92. package/dist/run-AUCA7EKA.js +0 -20
  93. package/dist/run-service-MT3LOWLS.js +0 -12
  94. package/dist/schema-YWIVP7UR.js +0 -12
  95. package/dist/server-PIYRZLBG.js +0 -12
  96. package/dist/session-ACBIJ2VE.js +0 -12
  97. package/dist/share-next-MPGA7EO4.js +0 -12
  98. package/dist/sury-CWZTCd75-3YHH6KVI.js +0 -12
  99. package/dist/typebox-Dei93FPO-GLI7OCTY.js +0 -12
  100. package/dist/valibot-D_HTw1Gn-E5NKVIOV.js +0 -12
  101. package/dist/worktree-E4DGSBLJ.js +0 -12
  102. package/dist/zod-DSgpEGAE-DSH6V7MG.js +0 -12
  103. package/packages/opencode/migration/20260127222353_familiar_lady_ursula/migration.sql +0 -90
  104. package/packages/opencode/migration/20260127222353_familiar_lady_ursula/snapshot.json +0 -796
  105. package/packages/opencode/migration/20260211171708_add_project_commands/migration.sql +0 -1
  106. package/packages/opencode/migration/20260211171708_add_project_commands/snapshot.json +0 -806
  107. package/packages/opencode/migration/20260213144116_wakeful_the_professor/migration.sql +0 -11
  108. package/packages/opencode/migration/20260213144116_wakeful_the_professor/snapshot.json +0 -897
  109. package/packages/opencode/migration/20260225215848_workspace/migration.sql +0 -7
  110. package/packages/opencode/migration/20260225215848_workspace/snapshot.json +0 -959
  111. package/packages/opencode/migration/20260227213759_add_session_workspace_id/migration.sql +0 -2
  112. package/packages/opencode/migration/20260227213759_add_session_workspace_id/snapshot.json +0 -983
  113. package/packages/opencode/migration/20260228203230_blue_harpoon/migration.sql +0 -17
  114. package/packages/opencode/migration/20260228203230_blue_harpoon/snapshot.json +0 -1102
  115. package/packages/opencode/migration/20260303231226_add_workspace_fields/migration.sql +0 -5
  116. package/packages/opencode/migration/20260303231226_add_workspace_fields/snapshot.json +0 -1013
  117. package/packages/opencode/migration/20260309230000_move_org_to_state/migration.sql +0 -3
  118. package/packages/opencode/migration/20260309230000_move_org_to_state/snapshot.json +0 -1156
  119. package/packages/opencode/migration/20260312043431_session_message_cursor/migration.sql +0 -4
  120. package/packages/opencode/migration/20260312043431_session_message_cursor/snapshot.json +0 -1168
  121. package/packages/opencode/migration/20260323234822_events/migration.sql +0 -13
  122. package/packages/opencode/migration/20260323234822_events/snapshot.json +0 -1271
  123. package/packages/opencode/migration/20260409000000_add_session_metadata/migration.sql +0 -1
@@ -0,0 +1,285 @@
1
+ diff --git a/photon_rs.js b/photon_rs.js
2
+ index 8f4144d..29a964a 100644
3
+ --- a/photon_rs.js
4
+ +++ b/photon_rs.js
5
+ @@ -1,6 +1,7 @@
6
+
7
+ let imports = {};
8
+ -imports['__wbindgen_placeholder__'] = module.exports;
9
+ +const __wbindgen_placeholder__ = {};
10
+ +imports['__wbindgen_placeholder__'] = __wbindgen_placeholder__;
11
+ let wasm;
12
+ const { TextEncoder, TextDecoder } = require(`util`);
13
+
14
+ @@ -4272,12 +4273,12 @@ class Rgba {
15
+ }
16
+ module.exports.Rgba = Rgba;
17
+
18
+ -module.exports.__wbg_new_abda76e883ba8a5f = function() {
19
+ +__wbindgen_placeholder__.__wbg_new_abda76e883ba8a5f = function() {
20
+ const ret = new Error();
21
+ return ret;
22
+ };
23
+
24
+ -module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
25
+ +__wbindgen_placeholder__.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
26
+ const ret = arg1.stack;
27
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
28
+ const len1 = WASM_VECTOR_LEN;
29
+ @@ -4285,7 +4286,7 @@ module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
30
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
31
+ };
32
+
33
+ -module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
34
+ +__wbindgen_placeholder__.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
35
+ let deferred0_0;
36
+ let deferred0_1;
37
+ try {
38
+ @@ -4297,7 +4298,7 @@ module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
39
+ }
40
+ };
41
+
42
+ -module.exports.__wbg_instanceof_Window_c4b70662a0d2c5ec = function(arg0) {
43
+ +__wbindgen_placeholder__.__wbg_instanceof_Window_c4b70662a0d2c5ec = function(arg0) {
44
+ let result;
45
+ try {
46
+ result = arg0 instanceof Window;
47
+ @@ -4308,42 +4309,42 @@ module.exports.__wbg_instanceof_Window_c4b70662a0d2c5ec = function(arg0) {
48
+ return ret;
49
+ };
50
+
51
+ -module.exports.__wbg_document_e5c1786dea6542e4 = function(arg0) {
52
+ +__wbindgen_placeholder__.__wbg_document_e5c1786dea6542e4 = function(arg0) {
53
+ const ret = arg0.document;
54
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
55
+ };
56
+
57
+ -module.exports.__wbg_body_e70ae6abd01ae584 = function(arg0) {
58
+ +__wbindgen_placeholder__.__wbg_body_e70ae6abd01ae584 = function(arg0) {
59
+ const ret = arg0.body;
60
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
61
+ };
62
+
63
+ -module.exports.__wbg_createElement_5d4c76f218b78145 = function() { return handleError(function (arg0, arg1, arg2) {
64
+ +__wbindgen_placeholder__.__wbg_createElement_5d4c76f218b78145 = function() { return handleError(function (arg0, arg1, arg2) {
65
+ const ret = arg0.createElement(getStringFromWasm0(arg1, arg2));
66
+ return ret;
67
+ }, arguments) };
68
+
69
+ -module.exports.__wbg_width_4c6f0048d64cf86b = function(arg0) {
70
+ +__wbindgen_placeholder__.__wbg_width_4c6f0048d64cf86b = function(arg0) {
71
+ const ret = arg0.width;
72
+ return ret;
73
+ };
74
+
75
+ -module.exports.__wbg_height_21f0d3fd8f753394 = function(arg0) {
76
+ +__wbindgen_placeholder__.__wbg_height_21f0d3fd8f753394 = function(arg0) {
77
+ const ret = arg0.height;
78
+ return ret;
79
+ };
80
+
81
+ -module.exports.__wbg_width_79e0847ed5883b03 = function(arg0) {
82
+ +__wbindgen_placeholder__.__wbg_width_79e0847ed5883b03 = function(arg0) {
83
+ const ret = arg0.width;
84
+ return ret;
85
+ };
86
+
87
+ -module.exports.__wbg_height_e4e4e4779f8feac0 = function(arg0) {
88
+ +__wbindgen_placeholder__.__wbg_height_e4e4e4779f8feac0 = function(arg0) {
89
+ const ret = arg0.height;
90
+ return ret;
91
+ };
92
+
93
+ -module.exports.__wbg_data_fda507064d127f5b = function(arg0, arg1) {
94
+ +__wbindgen_placeholder__.__wbg_data_fda507064d127f5b = function(arg0, arg1) {
95
+ const ret = arg1.data;
96
+ const ptr1 = passArray8ToWasm0(ret, wasm.__wbindgen_malloc);
97
+ const len1 = WASM_VECTOR_LEN;
98
+ @@ -4351,12 +4352,12 @@ module.exports.__wbg_data_fda507064d127f5b = function(arg0, arg1) {
99
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
100
+ };
101
+
102
+ -module.exports.__wbg_newwithu8clampedarrayandsh_1fddccb3a94a5e05 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
103
+ +__wbindgen_placeholder__.__wbg_newwithu8clampedarrayandsh_1fddccb3a94a5e05 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
104
+ const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
105
+ return ret;
106
+ }, arguments) };
107
+
108
+ -module.exports.__wbg_instanceof_CanvasRenderingContext2d_3abbe7ec7af32cae = function(arg0) {
109
+ +__wbindgen_placeholder__.__wbg_instanceof_CanvasRenderingContext2d_3abbe7ec7af32cae = function(arg0) {
110
+ let result;
111
+ try {
112
+ result = arg0 instanceof CanvasRenderingContext2D;
113
+ @@ -4367,24 +4368,24 @@ module.exports.__wbg_instanceof_CanvasRenderingContext2d_3abbe7ec7af32cae = fun
114
+ return ret;
115
+ };
116
+
117
+ -module.exports.__wbg_drawImage_fede06db74e39a60 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
118
+ +__wbindgen_placeholder__.__wbg_drawImage_fede06db74e39a60 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
119
+ arg0.drawImage(arg1, arg2, arg3);
120
+ }, arguments) };
121
+
122
+ -module.exports.__wbg_drawImage_f395c8e43c79a909 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
123
+ +__wbindgen_placeholder__.__wbg_drawImage_f395c8e43c79a909 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
124
+ arg0.drawImage(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
125
+ }, arguments) };
126
+
127
+ -module.exports.__wbg_getImageData_5e1c242046e6b59e = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
128
+ +__wbindgen_placeholder__.__wbg_getImageData_5e1c242046e6b59e = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
129
+ const ret = arg0.getImageData(arg1, arg2, arg3, arg4);
130
+ return ret;
131
+ }, arguments) };
132
+
133
+ -module.exports.__wbg_putImageData_a8b3e177ee06d521 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
134
+ +__wbindgen_placeholder__.__wbg_putImageData_a8b3e177ee06d521 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
135
+ arg0.putImageData(arg1, arg2, arg3);
136
+ }, arguments) };
137
+
138
+ -module.exports.__wbg_instanceof_HtmlCanvasElement_25d964a0dde6717e = function(arg0) {
139
+ +__wbindgen_placeholder__.__wbg_instanceof_HtmlCanvasElement_25d964a0dde6717e = function(arg0) {
140
+ let result;
141
+ try {
142
+ result = arg0 instanceof HTMLCanvasElement;
143
+ @@ -4395,93 +4396,93 @@ module.exports.__wbg_instanceof_HtmlCanvasElement_25d964a0dde6717e = function(a
144
+ return ret;
145
+ };
146
+
147
+ -module.exports.__wbg_width_dc225e55343b745e = function(arg0) {
148
+ +__wbindgen_placeholder__.__wbg_width_dc225e55343b745e = function(arg0) {
149
+ const ret = arg0.width;
150
+ return ret;
151
+ };
152
+
153
+ -module.exports.__wbg_setwidth_488780db69b08846 = function(arg0, arg1) {
154
+ +__wbindgen_placeholder__.__wbg_setwidth_488780db69b08846 = function(arg0, arg1) {
155
+ arg0.width = arg1 >>> 0;
156
+ };
157
+
158
+ -module.exports.__wbg_height_3a8bec2f3fe71b26 = function(arg0) {
159
+ +__wbindgen_placeholder__.__wbg_height_3a8bec2f3fe71b26 = function(arg0) {
160
+ const ret = arg0.height;
161
+ return ret;
162
+ };
163
+
164
+ -module.exports.__wbg_setheight_1761808c18403921 = function(arg0, arg1) {
165
+ +__wbindgen_placeholder__.__wbg_setheight_1761808c18403921 = function(arg0, arg1) {
166
+ arg0.height = arg1 >>> 0;
167
+ };
168
+
169
+ -module.exports.__wbg_getContext_fc99dbd3a9a7e318 = function() { return handleError(function (arg0, arg1, arg2) {
170
+ +__wbindgen_placeholder__.__wbg_getContext_fc99dbd3a9a7e318 = function() { return handleError(function (arg0, arg1, arg2) {
171
+ const ret = arg0.getContext(getStringFromWasm0(arg1, arg2));
172
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
173
+ }, arguments) };
174
+
175
+ -module.exports.__wbg_settextContent_f82a86a8df347e1c = function(arg0, arg1, arg2) {
176
+ +__wbindgen_placeholder__.__wbg_settextContent_f82a86a8df347e1c = function(arg0, arg1, arg2) {
177
+ arg0.textContent = arg1 === 0 ? undefined : getStringFromWasm0(arg1, arg2);
178
+ };
179
+
180
+ -module.exports.__wbg_appendChild_fa3b00dade9fc4cf = function() { return handleError(function (arg0, arg1) {
181
+ +__wbindgen_placeholder__.__wbg_appendChild_fa3b00dade9fc4cf = function() { return handleError(function (arg0, arg1) {
182
+ const ret = arg0.appendChild(arg1);
183
+ return ret;
184
+ }, arguments) };
185
+
186
+ -module.exports.__wbg_newnoargs_e643855c6572a4a8 = function(arg0, arg1) {
187
+ +__wbindgen_placeholder__.__wbg_newnoargs_e643855c6572a4a8 = function(arg0, arg1) {
188
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
189
+ return ret;
190
+ };
191
+
192
+ -module.exports.__wbg_call_f96b398515635514 = function() { return handleError(function (arg0, arg1) {
193
+ +__wbindgen_placeholder__.__wbg_call_f96b398515635514 = function() { return handleError(function (arg0, arg1) {
194
+ const ret = arg0.call(arg1);
195
+ return ret;
196
+ }, arguments) };
197
+
198
+ -module.exports.__wbg_self_b9aad7f1c618bfaf = function() { return handleError(function () {
199
+ +__wbindgen_placeholder__.__wbg_self_b9aad7f1c618bfaf = function() { return handleError(function () {
200
+ const ret = self.self;
201
+ return ret;
202
+ }, arguments) };
203
+
204
+ -module.exports.__wbg_window_55e469842c98b086 = function() { return handleError(function () {
205
+ +__wbindgen_placeholder__.__wbg_window_55e469842c98b086 = function() { return handleError(function () {
206
+ const ret = window.window;
207
+ return ret;
208
+ }, arguments) };
209
+
210
+ -module.exports.__wbg_globalThis_d0957e302752547e = function() { return handleError(function () {
211
+ +__wbindgen_placeholder__.__wbg_globalThis_d0957e302752547e = function() { return handleError(function () {
212
+ const ret = globalThis.globalThis;
213
+ return ret;
214
+ }, arguments) };
215
+
216
+ -module.exports.__wbg_global_ae2f87312b8987fb = function() { return handleError(function () {
217
+ +__wbindgen_placeholder__.__wbg_global_ae2f87312b8987fb = function() { return handleError(function () {
218
+ const ret = global.global;
219
+ return ret;
220
+ }, arguments) };
221
+
222
+ -module.exports.__wbindgen_is_undefined = function(arg0) {
223
+ +__wbindgen_placeholder__.__wbindgen_is_undefined = function(arg0) {
224
+ const ret = arg0 === undefined;
225
+ return ret;
226
+ };
227
+
228
+ -module.exports.__wbg_buffer_fcbfb6d88b2732e9 = function(arg0) {
229
+ +__wbindgen_placeholder__.__wbg_buffer_fcbfb6d88b2732e9 = function(arg0) {
230
+ const ret = arg0.buffer;
231
+ return ret;
232
+ };
233
+
234
+ -module.exports.__wbg_new_bc5d9aad3f9ac80e = function(arg0) {
235
+ +__wbindgen_placeholder__.__wbg_new_bc5d9aad3f9ac80e = function(arg0) {
236
+ const ret = new Uint8Array(arg0);
237
+ return ret;
238
+ };
239
+
240
+ -module.exports.__wbg_set_4b3aa8445ac1e91c = function(arg0, arg1, arg2) {
241
+ +__wbindgen_placeholder__.__wbg_set_4b3aa8445ac1e91c = function(arg0, arg1, arg2) {
242
+ arg0.set(arg1, arg2 >>> 0);
243
+ };
244
+
245
+ -module.exports.__wbg_length_d9c4ded7e708c6a1 = function(arg0) {
246
+ +__wbindgen_placeholder__.__wbg_length_d9c4ded7e708c6a1 = function(arg0) {
247
+ const ret = arg0.length;
248
+ return ret;
249
+ };
250
+
251
+ -module.exports.__wbindgen_debug_string = function(arg0, arg1) {
252
+ +__wbindgen_placeholder__.__wbindgen_debug_string = function(arg0, arg1) {
253
+ const ret = debugString(arg1);
254
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
255
+ const len1 = WASM_VECTOR_LEN;
256
+ @@ -4489,16 +4490,16 @@ module.exports.__wbindgen_debug_string = function(arg0, arg1) {
257
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
258
+ };
259
+
260
+ -module.exports.__wbindgen_throw = function(arg0, arg1) {
261
+ +__wbindgen_placeholder__.__wbindgen_throw = function(arg0, arg1) {
262
+ throw new Error(getStringFromWasm0(arg0, arg1));
263
+ };
264
+
265
+ -module.exports.__wbindgen_memory = function() {
266
+ +__wbindgen_placeholder__.__wbindgen_memory = function() {
267
+ const ret = wasm.memory;
268
+ return ret;
269
+ };
270
+
271
+ -module.exports.__wbindgen_init_externref_table = function() {
272
+ +__wbindgen_placeholder__.__wbindgen_init_externref_table = function() {
273
+ const table = wasm.__wbindgen_export_2;
274
+ const offset = table.grow(4);
275
+ table.set(0, undefined);
276
+ @@ -4509,7 +4510,8 @@ module.exports.__wbindgen_init_externref_table = function() {
277
+ ;
278
+ };
279
+
280
+ -const path = require('path').join(__dirname, 'photon_rs_bg.wasm');
281
+ +// Allow opencode's Bun compiled binary to point photon-node at its embedded wasm asset.
282
+ +const path = globalThis.__OPENCODE_PHOTON_WASM_PATH || require('path').join(__dirname, 'photon_rs_bg.wasm');
283
+ const bytes = require('fs').readFileSync(path);
284
+
285
+ const wasmModule = new WebAssembly.Module(bytes);
@@ -0,0 +1,57 @@
1
+ diff --git a/dist/unstable/httpapi/HttpApiSchema.js b/dist/unstable/httpapi/HttpApiSchema.js
2
+ index ecb6603d1ee4e89e92174b3a1100e8c9c720b3f3..08b832b6b3e9e4d10df156eca36b16f571f67f6e 100644
3
+ --- a/dist/unstable/httpapi/HttpApiSchema.js
4
+ +++ b/dist/unstable/httpapi/HttpApiSchema.js
5
+ @@ -151,7 +151,7 @@ export const StreamSse = options => {
6
+ const events = options.events ?? (options.data === undefined ? undefined : Schema.Struct({
7
+ id: Schema.UndefinedOr(Schema.String),
8
+ event: Schema.String,
9
+ - data: Schema.fromJsonString(options.data)
10
+ + data: sseDataJsonSchema(options.data)
11
+ }));
12
+ if (events === undefined) {
13
+ throw new Error("StreamSse requires either an events schema or a data schema");
14
+ @@ -166,6 +166,14 @@ export const StreamSse = options => {
15
+ error: options.error ?? Schema.Never
16
+ });
17
+ };
18
+ +const sseDataJsonSchema = data => {
19
+ + const identifier = SchemaAST.resolveIdentifier(data.ast);
20
+ + return identifier === undefined ? Schema.fromJsonString(data) : Schema.fromJsonString(data).annotate({
21
+ + // The SSE transport field is a JSON string. Give that wrapper its own
22
+ + // OpenAPI identifier so it does not claim the decoded data schema's name.
23
+ + identifier: `${identifier}Stream`
24
+ + });
25
+ +};
26
+ /**
27
+ * Creates a streaming `Uint8Array` success response schema.
28
+ *
29
+ diff --git a/src/unstable/httpapi/HttpApiSchema.ts b/src/unstable/httpapi/HttpApiSchema.ts
30
+ index f2920365cf0328146523ce2e2dba04d6a8809a4a..5482d635cdf01a72063ff683d244fab891910211 100644
31
+ --- a/src/unstable/httpapi/HttpApiSchema.ts
32
+ +++ b/src/unstable/httpapi/HttpApiSchema.ts
33
+ @@ -433,7 +433,7 @@ export const StreamSse: {
34
+ const events = options.events ?? (options.data === undefined ? undefined : Schema.Struct({
35
+ id: Schema.UndefinedOr(Schema.String),
36
+ event: Schema.String,
37
+ - data: Schema.fromJsonString(options.data)
38
+ + data: sseDataJsonSchema(options.data)
39
+ }))
40
+ if (events === undefined) {
41
+ throw new Error("StreamSse requires either an events schema or a data schema")
42
+ @@ -449,6 +449,15 @@ export const StreamSse: {
43
+ })
44
+ }
45
+
46
+ +const sseDataJsonSchema = (data: Schema.Constraint) => {
47
+ + const identifier = SchemaAST.resolveIdentifier(data.ast)
48
+ + return identifier === undefined ? Schema.fromJsonString(data) : Schema.fromJsonString(data).annotate({
49
+ + // The SSE transport field is a JSON string. Give that wrapper its own
50
+ + // OpenAPI identifier so it does not claim the decoded data schema's name.
51
+ + identifier: `${identifier}Stream`
52
+ + })
53
+ +}
54
+ +
55
+ /**
56
+ * Creates a streaming `Uint8Array` success response schema.
57
+ *
@@ -0,0 +1,14 @@
1
+ diff --git a/build/src/index.js b/build/src/index.js
2
+ --- a/build/src/index.js
3
+ +++ b/build/src/index.js
4
+ @@ -323,6 +323,10 @@ async function isAvailable() {
5
+ if (process.env.DEBUG_AUTH) {
6
+ console.info(err);
7
+ }
8
+ + // Promise.any() rejects with AggregateError when neither metadata host
9
+ + // is available. This is expected outside GCP, not a warning condition.
10
+ + if (err instanceof AggregateError)
11
+ + return false;
12
+ if (err.type === 'request-timeout') {
13
+ // If running in a GCP environment, metadata endpoint should return
14
+ // within ms.
@@ -0,0 +1,18 @@
1
+ diff --git a/lib/git.js b/lib/git.js
2
+ index 000ee9fc..a2a6cbb7 100644
3
+ --- a/lib/git.js
4
+ +++ b/lib/git.js
5
+ @@ -254,8 +254,11 @@ class GitFetcher extends Fetcher {
6
+ resolved: this.resolved,
7
+ integrity: null, // it'll always be different, if we have one
8
+ }).extract(tmp).then(() => handler(`${tmp}${this.spec.gitSubdir || ''}`), er => {
9
+ - // fall back to ssh download if tarball fails
10
+ - if (er.constructor.name.match(/^Http/)) {
11
+ + // fall back to clone if the tarball download fails due to an
12
+ + // HTTP error or if the response is not a valid tarball (e.g.
13
+ + // a hosted provider returning an HTML sign-in page with 200)
14
+ + if ((typeof er.statusCode === 'number' && er.statusCode >= 400) ||
15
+ + /^TAR_/.test(er.code)) {
16
+ return this.#clone(handler, false)
17
+ } else {
18
+ throw er
@@ -0,0 +1,146 @@
1
+ #!/usr/bin/env node
2
+ // Runs after npm install, in development and where the package is installed.
3
+ //
4
+ // 1. Dependency patches (alchemy fork, since 1.18). Upstream OpenCode patches
5
+ // several dependencies through bun's patchedDependencies (patches/*.patch,
6
+ // git diffs relative to the package root: the AI SDK providers, the MCP SDK,
7
+ // effect, gcp-metadata, pacote, @npmcli/agent, photon-node). The bundle keeps
8
+ // those packages external, so the same patches are applied here, with the
9
+ // `diff` package's applyPatch, to every installed copy of the package under
10
+ // the install's node_modules (a user's install has no lock, so a provider
11
+ // can carry its own nested copy, at another version). A copy at another
12
+ // version than the patch's gets the patch when it applies cleanly, or counts
13
+ // as patched when it already has the change (the patch undoes cleanly); when
14
+ // neither, one line on stderr says so and the copy is left as it is (the
15
+ // install never fails over a patch). A patched copy keeps a stamp file, so
16
+ // a second run changes nothing.
17
+ // 2. @opencode-ai/* symlinks to packages/*, so bun tests and the TypeScript
18
+ // sources resolve the workspace packages (only when packages/ has them).
19
+
20
+ const fs = require('fs');
21
+ const path = require('path');
22
+
23
+ const root = __dirname;
24
+
25
+ // Where this install's packages live: the node_modules this package sits in
26
+ // (installed as a dependency), else its own (development).
27
+ function installNodeModules() {
28
+ const parent = path.dirname(root);
29
+ return path.basename(parent) === 'node_modules' ? parent : path.join(root, 'node_modules');
30
+ }
31
+
32
+ // Every installed copy of the named packages: { name: [dir, ...] }. Walks
33
+ // node_modules folders and the nested node_modules inside packages; symlinks
34
+ // (workspace links) are not followed.
35
+ function findCopies(nodeModules, names) {
36
+ const found = {};
37
+ const walk = (dir) => {
38
+ let entries;
39
+ try {
40
+ entries = fs.readdirSync(dir, { withFileTypes: true });
41
+ } catch {
42
+ return;
43
+ }
44
+ for (const entry of entries) {
45
+ if (!entry.isDirectory() || entry.name.startsWith('.')) continue;
46
+ const scoped = entry.name.startsWith('@');
47
+ const dirs = scoped
48
+ ? fs.readdirSync(path.join(dir, entry.name), { withFileTypes: true })
49
+ .filter((e) => e.isDirectory())
50
+ .map((e) => [`${entry.name}/${e.name}`, path.join(dir, entry.name, e.name)])
51
+ : [[entry.name, path.join(dir, entry.name)]];
52
+ for (const [name, pkgDir] of dirs) {
53
+ if (names.has(name) && fs.existsSync(path.join(pkgDir, 'package.json'))) (found[name] ||= []).push(pkgDir);
54
+ walk(path.join(pkgDir, 'node_modules'));
55
+ }
56
+ }
57
+ };
58
+ walk(nodeModules);
59
+ return found;
60
+ }
61
+
62
+ function applyPatches() {
63
+ const dir = path.join(root, 'patches');
64
+ if (!fs.existsSync(dir)) return;
65
+ let Diff;
66
+ try {
67
+ Diff = require('diff');
68
+ } catch {
69
+ process.stderr.write('alchemylab-opencode postinstall: the diff package is missing, dependency patches not applied\n');
70
+ return;
71
+ }
72
+ const patchFiles = fs.readdirSync(dir).filter((f) => f.endsWith('.patch')).sort();
73
+ const nameOf = (file) => {
74
+ const spec = decodeURIComponent(file.slice(0, -'.patch'.length));
75
+ return spec.slice(0, spec.lastIndexOf('@'));
76
+ };
77
+ const nodeModules = installNodeModules();
78
+ const copies = findCopies(nodeModules, new Set(patchFiles.map(nameOf)));
79
+ let patched = 0;
80
+ let skipped = 0;
81
+ for (const file of patchFiles) {
82
+ const patches = Diff.parsePatch(fs.readFileSync(path.join(dir, file), 'utf8'));
83
+ for (const pkgDir of copies[nameOf(file)] || []) {
84
+ const stamp = path.join(pkgDir, '.alchemylab-patched');
85
+ if (fs.existsSync(stamp) && fs.readFileSync(stamp, 'utf8') === file) {
86
+ patched++;
87
+ continue;
88
+ }
89
+ const version = JSON.parse(fs.readFileSync(path.join(pkgDir, 'package.json'), 'utf8')).version;
90
+ // Every file first, then write: a copy is patched whole or not at all.
91
+ const writes = [];
92
+ let miss = '';
93
+ for (const p of patches) {
94
+ const rel = (p.newFileName || p.oldFileName || '').replace(/^[ab]\//, '');
95
+ if (!rel || rel === '/dev/null') continue;
96
+ const target = path.join(pkgDir, rel);
97
+ const before = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : '';
98
+ const after = Diff.applyPatch(before, p);
99
+ if (after !== false) writes.push([target, after]);
100
+ // A newer version can already carry the change (the patch undoes cleanly).
101
+ else if (Diff.applyPatch(before, Diff.reversePatch(p)) === false) {
102
+ miss = rel;
103
+ break;
104
+ }
105
+ }
106
+ const where = path.relative(nodeModules, pkgDir);
107
+ if (miss) {
108
+ skipped++;
109
+ process.stderr.write(`alchemylab-opencode postinstall: ${file} does not apply to ${where} (version ${version}, ${miss}); left unpatched\n`);
110
+ continue;
111
+ }
112
+ for (const [target, after] of writes) {
113
+ fs.mkdirSync(path.dirname(target), { recursive: true });
114
+ fs.writeFileSync(target, after);
115
+ }
116
+ fs.writeFileSync(stamp, file);
117
+ patched++;
118
+ }
119
+ }
120
+ if (patched || skipped) {
121
+ process.stderr.write(`alchemylab-opencode postinstall: ${patched} package copies patched${skipped ? `, ${skipped} left unpatched` : ''}\n`);
122
+ }
123
+ }
124
+
125
+ function linkWorkspacePackages() {
126
+ const packages = path.join(root, 'packages');
127
+ if (!fs.existsSync(packages)) return;
128
+ const scopeDir = path.join(root, 'node_modules', '@opencode-ai');
129
+ fs.mkdirSync(scopeDir, { recursive: true });
130
+ for (const name of fs.readdirSync(packages)) {
131
+ const target = path.join(packages, name);
132
+ if (!fs.existsSync(path.join(target, 'package.json'))) continue;
133
+ const linkPath = path.join(scopeDir, name);
134
+ try {
135
+ const stat = fs.lstatSync(linkPath);
136
+ if (stat.isSymbolicLink() || stat.isFile()) fs.unlinkSync(linkPath);
137
+ else if (stat.isDirectory()) fs.rmSync(linkPath, { recursive: true });
138
+ } catch {
139
+ // Not there yet.
140
+ }
141
+ fs.symlinkSync(path.relative(scopeDir, target), linkPath);
142
+ }
143
+ }
144
+
145
+ applyPatches();
146
+ linkWorkspacePackages();
@@ -1,18 +0,0 @@
1
- // Built by esbuild from opencode-server source
2
- if (typeof globalThis.Bun === 'undefined') {
3
- globalThis.Bun = {
4
- version: '0.0.0-node-compat',
5
- stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
- which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
- };
8
- }
9
- if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
- if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
-
12
- import{a as Me}from"./chunk-A7EXZZPC.js";import{E as Ge,F as Z,G as Le,L as le,P as Ue,S as ze,e as fe,h as V,l as pe,n as O,o as De,p as Be}from"./chunk-G752V4OP.js";import{A as Y,a as Q,d as D,h as S,j as Ce,k as ae,m as de,s as q,u as Re,v as A,w as Pe,x as T,y as g}from"./chunk-IR6PDN4W.js";import{d as je,e as z}from"./chunk-M4CB72HE.js";import{a as m}from"./chunk-MBZTOEAD.js";import p from"zod";import{Effect as h,Layer as ee,ServiceMap as Ke,Stream as Ae}from"effect";import Qe from"path";import $ from"zod";var ue;(P=>{let E=z.create({service:"vcs"}),G=m(d=>d?d.endsWith(`
13
- `)?d.slice(0,-1).split(`
14
- `).length:d.split(`
15
- `).length:0,"count"),te=h.fnUntraced(function*(d,s,u){let r=Qe.join(s,u);if(!(yield*d.exists(r).pipe(h.orDie)))return"";let i=yield*d.readFile(r).pipe(h.catch(()=>h.succeed(new Uint8Array)));return Buffer.from(i).includes(0)?"":Buffer.from(i).toString("utf8")}),re=m(d=>new Map(d.map(s=>[s.file,{additions:s.additions,deletions:s.deletions}])),"nums"),me=m((...d)=>{let s=new Map;return d.flat().forEach(u=>{s.has(u.file)||s.set(u.file,u)}),[...s.values()]},"merge"),J=h.fnUntraced(function*(d,s,u,r,i,a){let w=r?yield*s.prefix(u):"";return(yield*h.forEach(i,y=>h.gen(function*(){let x=y.status==="added"||!r?"":yield*s.show(u,r,y.file,w),j=y.status==="deleted"?"":yield*te(d,u,y.file),K=a.get(y.file);return{file:y.file,before:x,after:j,additions:K?.additions??(y.status==="added"?G(j):0),deletions:K?.deletions??(y.status==="deleted"?G(x):0),status:y.status}}),{concurrency:8})).toSorted((y,x)=>y.file.localeCompare(x.file))}),W=h.fnUntraced(function*(d,s,u,r){if(!r)return yield*J(d,s,u,r,yield*s.status(u),new Map);let[i,a]=yield*h.all([s.status(u),s.stats(u,r)],{concurrency:2});return yield*J(d,s,u,r,i,re(a))}),ne=h.fnUntraced(function*(d,s,u,r){let[i,a,w]=yield*h.all([s.diff(u,r),s.stats(u,r),s.status(u)],{concurrency:3});return yield*J(d,s,u,r,me(i,w.filter(F=>F.code==="??")),re(a))});P.Mode=$.enum(["git","branch"]),P.Event={BranchUpdated:q.define("vcs.branch.updated",$.object({branch:$.string().optional()}))},P.Info=$.object({branch:$.string().optional(),default_branch:$.string().optional()}).meta({ref:"VcsInfo"});class I extends Ke.Service()("@opencode/Vcs"){static{m(this,"Service")}}P.Service=I,P.layer=ee.effect(I,h.gen(function*(){let d=yield*A.Service,s=yield*O.Service,u=yield*V.Service,r=yield*S.make(h.fn("Vcs.state")(i=>h.gen(function*(){if(i.project.vcs!=="git")return{current:void 0,root:void 0};let a=h.fnUntraced(function*(){return yield*s.branch(i.directory)}),[w,F]=yield*h.all([s.branch(i.directory),s.defaultBranch(i.directory)],{concurrency:2}),y={current:w,root:F};return E.info("initialized",{branch:y.current,default_branch:y.root?.name}),yield*u.subscribe(Z.Event.Updated).pipe(Ae.filter(x=>x.properties.file.endsWith("HEAD")),Ae.runForEach(x=>h.gen(function*(){let j=yield*a();j!==y.current&&(E.info("branch changed",{from:y.current,to:j}),y.current=j,yield*u.publish(P.Event.BranchUpdated,{branch:j}))})),h.forkScoped),y})));return I.of({init:h.fn("Vcs.init")(function*(){yield*S.get(r)}),branch:h.fn("Vcs.branch")(function*(){return yield*S.use(r,i=>i.current)}),defaultBranch:h.fn("Vcs.defaultBranch")(function*(){return yield*S.use(r,i=>i.root?.name)}),diff:h.fn("Vcs.diff")(function*(i){let a=yield*S.get(r);if(g.project.vcs!=="git")return[];if(i==="git")return yield*W(d,s,g.directory,(yield*s.hasHead(g.directory))?"HEAD":void 0);if(!a.root)return[];if(a.current&&a.current===a.root.name)return[];let w=yield*s.mergeBase(g.directory,a.root.ref);return w?yield*ne(d,s,g.directory,w):[]})})}));let ie=P.layer.pipe(ee.provide(O.defaultLayer),ee.provide(A.defaultLayer),ee.provide(V.layer)),{runPromise:C}=Y(I,ie);async function he(){return C(d=>d.init())}P.init=he,m(he,"init");async function we(){return C(d=>d.branch())}P.branch=we,m(we,"branch");async function U(){return C(d=>d.defaultBranch())}P.defaultBranch=U,m(U,"defaultBranch");async function Ne(d){return C(s=>s.diff(d))}P.diff=Ne,m(Ne,"diff")})(ue||={});async function Te(){z.Default.info("bootstrapping",{directory:g.directory}),await ze.init(),Me.init(),Le.init(),await De.init(),Ge.init(),Z.init(),ue.init(),Be.init(),V.subscribe(le.Event.Executed,async E=>{E.properties.name===le.Default.INIT&&T.setInitialized(g.project.id)})}m(Te,"InstanceBootstrap");import{Effect as o,Layer as X,Path as Ye,Scope as Ze,ServiceMap as et,Stream as B}from"effect";import{ChildProcess as $e,ChildProcessSpawner as tt}from"effect/unstable/process";import{NodePath as rt}from"@effect/platform-node";var nt;(r=>{let E=z.create({service:"worktree"});r.Event={Ready:q.define("worktree.ready",p.object({name:p.string(),branch:p.string()})),Failed:q.define("worktree.failed",p.object({message:p.string()}))},r.Info=p.object({name:p.string(),branch:p.string(),directory:p.string()}).meta({ref:"Worktree"}),r.CreateInput=p.object({name:p.string().optional(),startCommand:p.string().optional().describe("Additional startup script to run after the project's start command")}).meta({ref:"WorktreeCreateInput"}),r.RemoveInput=p.object({directory:p.string()}).meta({ref:"WorktreeRemoveInput"}),r.ResetInput=p.object({directory:p.string()}).meta({ref:"WorktreeResetInput"}),r.NotGitError=D.create("WorktreeNotGitError",p.object({message:p.string()})),r.NameGenerationFailedError=D.create("WorktreeNameGenerationFailedError",p.object({message:p.string()})),r.CreateFailedError=D.create("WorktreeCreateFailedError",p.object({message:p.string()})),r.StartCommandFailedError=D.create("WorktreeStartCommandFailedError",p.object({message:p.string()})),r.RemoveFailedError=D.create("WorktreeRemoveFailedError",p.object({message:p.string()})),r.ResetFailedError=D.create("WorktreeResetFailedError",p.object({message:p.string()}));function oe(i){return i.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}m(oe,"slugify");function ie(...i){return i.filter(Boolean).flatMap(a=>a.split(`
16
- `).map(w=>w.trim()).flatMap(w=>{let F=w.match(/^warning:\s+failed to remove\s+(.+):\s+/i);if(!F)return[];let y=F[1]?.trim().replace(/^['"]|['"]$/g,"");return y?[y]:[]}))}m(ie,"failedRemoves");class C extends et.Service()("@opencode/Worktree"){static{m(this,"Service")}}r.Service=C,r.layer=X.effect(C,o.gen(function*(){let i=yield*Ze.Scope,a=yield*A.Service,w=yield*Ye.Path,F=yield*tt.ChildProcessSpawner,y=yield*T.Service,x=o.fnUntraced(function*(t,e){let n=yield*F.spawn($e.make("git",t,{cwd:e?.cwd,extendEnv:!0,stdin:"ignore"})),[c,f]=yield*o.all([B.mkString(B.decodeText(n.stdout)),B.mkString(B.decodeText(n.stderr))],{concurrency:2});return{code:yield*n.exitCode,text:c,stderr:f}},o.scoped,o.catch(t=>o.succeed({code:1,text:"",stderr:t instanceof Error?t.message:String(t)}))),j=26,K=o.fn("Worktree.candidate")(function*(t,e){let n=yield*S.context;for(let c of Array.from({length:j},(f,l)=>l)){let f=e?c===0?e:`${e}-${pe.create()}`:pe.create(),l=`opencode/${f}`,b=w.join(t,f);if(yield*a.exists(b).pipe(o.orDie))continue;let v=`refs/heads/${l}`;if((yield*x(["show-ref","--verify","--quiet",v],{cwd:n.worktree})).code!==0)return r.Info.parse({name:f,branch:l,directory:b})}throw new r.NameGenerationFailedError({message:"Failed to generate a unique worktree name"})}),xe=o.fn("Worktree.makeWorktreeInfo")(function*(t){let e=yield*S.context;if(e.project.vcs!=="git")throw new r.NotGitError({message:"Worktrees are only supported for git projects"});let n=w.join(je.Path.data,"worktree",e.project.id);yield*a.makeDirectory(n,{recursive:!0}).pipe(o.orDie);let c=t?oe(t):"";return yield*K(n,c||void 0)}),ve=o.fnUntraced(function*(t){let e=yield*S.context,n=yield*x(["worktree","add","--no-checkout","-b",t.branch,t.directory],{cwd:e.worktree});if(n.code!==0)throw new r.CreateFailedError({message:n.stderr||n.text||"Failed to create git worktree"});yield*y.addSandbox(e.project.id,t.directory).pipe(o.catch(()=>o.void))}),be=o.fnUntraced(function*(t,e){let c=(yield*S.context).project.id,f=e?.trim(),l=yield*x(["reset","--hard"],{cwd:t.directory});if(l.code!==0){let v=l.stderr||l.text||"Failed to populate worktree";E.error("worktree checkout failed",{directory:t.directory,message:v}),Q.emit("event",{directory:t.directory,payload:{type:r.Event.Failed.type,properties:{message:v}}});return}(yield*o.promise(()=>g.provide({directory:t.directory,init:Te,fn:m(()=>{},"fn")}).then(()=>!0).catch(v=>{let R=fe(v);return E.error("worktree bootstrap failed",{directory:t.directory,message:R}),Q.emit("event",{directory:t.directory,payload:{type:r.Event.Failed.type,properties:{message:R}}}),!1})))&&(Q.emit("event",{directory:t.directory,payload:{type:r.Event.Ready.type,properties:{name:t.name,branch:t.branch}}}),yield*Ee(t.directory,{projectID:c,extra:f}))}),We=o.fn("Worktree.createFromInfo")(function*(t,e){yield*ve(t),yield*be(t,e)}),_e=o.fn("Worktree.create")(function*(t){let e=yield*xe(t?.name);return yield*ve(e),yield*be(e,t?.startCommand).pipe(o.catchCause(n=>o.sync(()=>E.error("worktree bootstrap failed",{cause:n}))),o.forkIn(i)),e}),M=o.fnUntraced(function*(t){let e=w.resolve(t),n=yield*a.realPath(e).pipe(o.catch(()=>o.succeed(e))),c=w.normalize(n);return process.platform==="win32"?c.toLowerCase():c});function se(t){return t.split(`
17
- `).map(e=>e.trim()).reduce((e,n)=>{if(!n)return e;if(n.startsWith("worktree "))return e.push({path:n.slice(9).trim()}),e;let c=e[e.length-1];return c&&n.startsWith("branch ")&&(c.branch=n.slice(7).trim()),e},[])}m(se,"parseWorktreeList");let ce=o.fnUntraced(function*(t,e){for(let n of t){if(!n.path)continue;if((yield*M(n.path))===e)return n}});function Ie(t){return a.exists(t).pipe(o.orDie,o.flatMap(e=>e?x(["fsmonitor--daemon","stop"],{cwd:t}):o.void))}m(Ie,"stopFsmonitor");function ke(t){return o.promise(()=>import("fs/promises").then(e=>e.rm(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:100})).catch(e=>{let n=fe(e);throw new r.RemoveFailedError({message:n||"Failed to remove git worktree directory"})}))}m(ke,"cleanDirectory");let He=o.fn("Worktree.remove")(function*(t){if(g.project.vcs!=="git")throw new r.NotGitError({message:"Worktrees are only supported for git projects"});let e=yield*M(t.directory),n=yield*x(["worktree","list","--porcelain"],{cwd:g.worktree});if(n.code!==0)throw new r.RemoveFailedError({message:n.stderr||n.text||"Failed to read git worktrees"});let c=se(n.text),f=yield*ce(c,e);if(!f?.path)return(yield*a.exists(e).pipe(o.orDie))&&(yield*Ie(e),yield*ke(e)),!0;yield*Ie(f.path);let l=yield*x(["worktree","remove","--force",f.path],{cwd:g.worktree});if(l.code!==0){let v=yield*x(["worktree","list","--porcelain"],{cwd:g.worktree});if(v.code!==0)throw new r.RemoveFailedError({message:l.stderr||l.text||v.stderr||v.text||"Failed to remove git worktree"});if((yield*ce(se(v.text),e))?.path)throw new r.RemoveFailedError({message:l.stderr||l.text||"Failed to remove git worktree"})}yield*ke(f.path);let b=f.branch?.replace(/^refs\/heads\//,"");if(b){let v=yield*x(["branch","-D",b],{cwd:g.worktree});if(v.code!==0)throw new r.RemoveFailedError({message:v.stderr||v.text||"Failed to delete worktree branch"})}return!0}),_=o.fnUntraced(function*(t,e,n){let c=yield*x(t,e);if(c.code!==0)throw n(c);return c}),qe=o.fnUntraced(function*(t,e){let[n,c]=process.platform==="win32"?["cmd",["/c",e]]:["bash",["-lc",e]],f=yield*F.spawn($e.make(n,c,{cwd:t,extendEnv:!0,stdin:"ignore"})),[,l]=yield*o.all([B.runDrain(f.stdout),B.mkString(B.decodeText(f.stderr))],{concurrency:2}).pipe(o.orDie);return{code:yield*f.exitCode,stderr:l}},o.scoped,o.catch(()=>o.succeed({code:1,stderr:""}))),Se=o.fnUntraced(function*(t,e,n){let c=e.trim();if(!c)return!0;let f=yield*qe(t,c);return f.code===0?!0:(E.error("worktree start command failed",{kind:n,directory:t,message:f.stderr}),!1)}),Ee=o.fnUntraced(function*(t,e){let n=yield*o.sync(()=>Ce.use(b=>b.select().from(de).where((0,ae.eq)(de.id,e.projectID)).get())),f=(n?T.fromRow(n):void 0)?.commands?.start?.trim()??"";return(yield*Se(t,f,"project"))?(yield*Se(t,e.extra??"","worktree"),!0):!1}),Ve=o.fnUntraced(function*(t,e){let n=yield*M(t);yield*o.forEach(e,c=>o.gen(function*(){let f=yield*M(w.resolve(t,c));f!==n&&f.startsWith(`${n}${w.sep}`)&&(yield*a.remove(f,{recursive:!0}).pipe(o.ignore))}),{concurrency:"unbounded"})}),Oe=o.fnUntraced(function*(t){let e=yield*x(["clean","-ffdx"],{cwd:t});if(e.code===0)return e;let n=ie(e.stderr,e.text);return n.length?(yield*Ve(t,n),yield*x(["clean","-ffdx"],{cwd:t})):e}),Xe=o.fn("Worktree.reset")(function*(t){if(g.project.vcs!=="git")throw new r.NotGitError({message:"Worktrees are only supported for git projects"});let e=yield*M(t.directory),n=yield*M(g.worktree);if(e===n)throw new r.ResetFailedError({message:"Cannot reset the primary workspace"});let c=yield*x(["worktree","list","--porcelain"],{cwd:g.worktree});if(c.code!==0)throw new r.ResetFailedError({message:c.stderr||c.text||"Failed to read git worktrees"});let f=yield*ce(se(c.text),e);if(!f?.path)throw new r.ResetFailedError({message:"Worktree not found"});let l=f.path,b=yield*o.promise(()=>O.defaultBranch(g.worktree));if(!b)throw new r.ResetFailedError({message:"Default branch not found"});let v=b.ref.indexOf("/");if(b.ref!==b.name&&v>0){let k=b.ref.slice(0,v),Je=b.ref.slice(v+1);yield*_(["fetch",k,Je],{cwd:g.worktree},Fe=>new r.ResetFailedError({message:Fe.stderr||Fe.text||`Failed to fetch ${b.ref}`}))}yield*_(["reset","--hard",b.ref],{cwd:l},k=>new r.ResetFailedError({message:k.stderr||k.text||"Failed to reset worktree to target"}));let R=yield*Oe(l);if(R.code!==0)throw new r.ResetFailedError({message:R.stderr||R.text||"Failed to clean worktree"});yield*_(["submodule","update","--init","--recursive","--force"],{cwd:l},k=>new r.ResetFailedError({message:k.stderr||k.text||"Failed to update submodules"})),yield*_(["submodule","foreach","--recursive","git","reset","--hard"],{cwd:l},k=>new r.ResetFailedError({message:k.stderr||k.text||"Failed to reset submodules"})),yield*_(["submodule","foreach","--recursive","git","clean","-fdx"],{cwd:l},k=>new r.ResetFailedError({message:k.stderr||k.text||"Failed to clean submodules"}));let H=yield*x(["-c","core.fsmonitor=false","status","--porcelain=v1"],{cwd:l});if(H.code!==0)throw new r.ResetFailedError({message:H.stderr||H.text||"Failed to read git status"});if(H.text.trim())throw new r.ResetFailedError({message:`Worktree reset left local changes:
18
- ${H.text.trim()}`});return yield*Ee(l,{projectID:g.project.id}).pipe(o.catchCause(k=>o.sync(()=>E.error("worktree start task failed",{cause:k}))),o.forkIn(i)),!0});return C.of({makeWorktreeInfo:xe,createFromInfo:We,create:_e,remove:He,reset:Xe})}));let we=r.layer.pipe(X.provide(Pe),X.provide(T.defaultLayer),X.provide(A.defaultLayer),X.provide(rt.layer)),{runPromise:U}=Y(C,we);async function Ne(i){return U(a=>a.makeWorktreeInfo(i))}r.makeWorktreeInfo=Ne,m(Ne,"makeWorktreeInfo");async function P(i,a){return U(w=>w.createFromInfo(i,a))}r.createFromInfo=P,m(P,"createFromInfo");async function d(i){return U(a=>a.create(i))}r.create=d,m(d,"create");async function s(i){return U(a=>a.remove(i))}r.remove=s,m(s,"remove");async function u(i){return U(a=>a.reset(i))}r.reset=u,m(u,"reset")})(nt||={});import N from"zod";var ir=N.object({id:Ue.zod,type:N.string(),branch:N.string().nullable(),name:N.string().nullable(),directory:N.string().nullable(),extra:N.unknown().nullable(),projectID:Re.zod});export{ue as a,Te as b,nt as c,ir as d};
@@ -1,12 +0,0 @@
1
- // Built by esbuild from opencode-server source
2
- if (typeof globalThis.Bun === 'undefined') {
3
- globalThis.Bun = {
4
- version: '0.0.0-node-compat',
5
- stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
- which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
- };
8
- }
9
- if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
- if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
-
12
- import{a as g}from"./chunk-LTCXIXYM.js";import{a as n}from"./chunk-MBZTOEAD.js";import{Schema as m}from"effect";import y from"zod";import l from"zod";import{randomBytes as k}from"crypto";var c;(w=>{let r={event:"evt",session:"ses",message:"msg",permission:"per",question:"que",user:"usr",part:"prt",pty:"pty",tool:"tool",workspace:"wrk"};function o(e){return l.string().startsWith(r[e])}w.schema=o,n(o,"schema");let h=26,x=0,u=0;function D(e,t){return d(e,!1,t)}w.ascending=D,n(D,"ascending");function B(e,t){return d(e,!0,t)}w.descending=B,n(B,"descending");function d(e,t,s){if(!s)return S(e,t);if(!s.startsWith(r[e]))throw new Error(`ID ${s} does not start with ${r[e]}`);return s}n(d,"generateID");function I(e){let t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",s="",a=k(e);for(let i=0;i<e;i++)s+=t[a[i]%62];return s}n(I,"randomBase62");function S(e,t,s){let a=s??Date.now();a!==x&&(x=a,u=0),u++;let i=BigInt(a)*BigInt(4096)+BigInt(u);i=t?~i:i;let f=Buffer.alloc(6);for(let p=0;p<6;p++)f[p]=Number(i>>BigInt(40-8*p)&BigInt(255));return r[e]+"_"+f.toString("hex")+I(h-12)}w.create=S,n(S,"create");function b(e,t){if(e===t)return 0;try{let s=BigInt("0x"+e.slice(e.indexOf("_")+1,e.indexOf("_")+13)),a=BigInt("0x"+t.slice(t.indexOf("_")+1,t.indexOf("_")+13));if(s!==a){let i=1n<<48n,f=1n<<47n,p=(s-a)%i;return p<0n&&(p+=i),p<f?1:-1}}catch{}return e<t?-1:1}w.compareAscending=b,n(b,"compareAscending");function T(e){let t=e.split("_")[0],s=e.slice(t.length+1,t.length+13),a=BigInt("0x"+s);return Number(a/BigInt(4096))}w.timestamp=T,n(T,"timestamp")})(c||={});var A=m.String.pipe(m.brand("SessionID"),g(r=>({make:n(o=>r.makeUnsafe(o),"make"),descending:n(o=>r.makeUnsafe(c.descending("session",o)),"descending"),zod:c.schema("session").pipe(y.custom())}))),E=m.String.pipe(m.brand("MessageID"),g(r=>({make:n(o=>r.makeUnsafe(o),"make"),ascending:n(o=>r.makeUnsafe(c.ascending("message",o)),"ascending"),zod:c.schema("message").pipe(y.custom())}))),H=m.String.pipe(m.brand("PartID"),g(r=>({make:n(o=>r.makeUnsafe(o),"make"),ascending:n(o=>r.makeUnsafe(c.ascending("part",o)),"ascending"),zod:c.schema("part").pipe(y.custom())})));export{c as a,A as b,E as c,H as d};
@@ -1,12 +0,0 @@
1
- // Built by esbuild from opencode-server source
2
- if (typeof globalThis.Bun === 'undefined') {
3
- globalThis.Bun = {
4
- version: '0.0.0-node-compat',
5
- stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
- which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
- };
8
- }
9
- if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
- if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
-
12
- import{Q as D,R as N,c as z,d as V,h as w,k as A,q,t as C}from"./chunk-G752V4OP.js";import{A as J,h as S,j as O,k as b,l as B,n as F}from"./chunk-IR6PDN4W.js";import{e as K}from"./chunk-M4CB72HE.js";import{a as c}from"./chunk-MBZTOEAD.js";import{Effect as t,Exit as de,Layer as u,Option as j,Schema as k,Scope as G,ServiceMap as pe,Stream as fe}from"effect";import{FetchHttpClient as le,HttpClient as Q,HttpClientRequest as p,HttpClientResponse as ue}from"effect/unstable/http";import{sqliteTable as ce,text as I}from"drizzle-orm/sqlite-core";var l=ce("session_share",{session_id:I().primaryKey().references(()=>F.id,{onDelete:"cascade"}),id:I().notNull(),secret:I().notNull(),url:I().notNull(),...B});var ye;(x=>{let f=K.create({service:"share-next"}),y=process.env.OPENCODE_DISABLE_SHARE==="true"||process.env.OPENCODE_DISABLE_SHARE==="1",W=k.Struct({id:k.String,url:k.String,secret:k.String});class _ extends pe.Service()("@opencode/ShareNext"){static{c(this,"Service")}}x.Service=_;let $=c(i=>t.sync(()=>O.use(i)),"db");function U(i){return{create:`/api/${i}`,sync:c(d=>`/api/${i}/${d}/sync`,"sync"),remove:c(d=>`/api/${i}/${d}`,"remove"),data:c(d=>`/api/${i}/${d}/data`,"data")}}c(U,"api");let X=U("share"),Y=U("shares");function R(i){switch(i.type){case"session":return"session";case"message":return`message/${i.data.id}`;case"part":return`part/${i.data.messageID}/${i.data.id}`;case"session_diff":return"session_diff";case"model":return"model"}}c(R,"key"),x.layer=u.effect(_,t.gen(function*(){let i=yield*A.Service,d=yield*w.Service,te=yield*N.Service,H=yield*Q.HttpClient,L=Q.filterStatusOk(H),P=yield*C.Service,M=yield*D.Service;function m(e,s){return t.gen(function*(){if(y)return;let n=yield*S.get(E),r=n.queue.get(e);if(r){for(let a of s)r.data.set(R(a),a);return}let o=new Map(s.map(a=>[R(a),a]));n.queue.set(e,{data:o}),yield*re(e).pipe(t.delay(1e3),t.catchCause(a=>t.sync(()=>{f.error("share flush failed",{sessionID:e,cause:a})})),t.forkIn(n.scope))})}c(m,"sync");let E=yield*S.make(t.fn("ShareNext.state")(function*(e){let s={queue:new Map,scope:yield*G.make()};if(yield*t.addFinalizer(()=>G.close(s.scope,de.void).pipe(t.andThen(t.sync(()=>{s.queue.clear()})))),y)return s;let n=c((r,o)=>d.subscribe(r).pipe(fe.runForEach(a=>o(a).pipe(t.catchCause(v=>t.sync(()=>{f.error("share subscriber failed",{type:r.type,cause:v})})))),t.forkScoped),"watch");return yield*n(D.Event.Updated,r=>t.gen(function*(){let o=yield*M.get(r.properties.sessionID);yield*m(o.id,[{type:"session",data:o}])})),yield*n(q.Event.Updated,r=>t.gen(function*(){let o=r.properties.info;if(yield*m(o.sessionID,[{type:"message",data:o}]),o.role!=="user")return;let a=yield*P.getModel(o.model.providerID,o.model.modelID);yield*m(o.sessionID,[{type:"model",data:[a]}])})),yield*n(q.Event.PartUpdated,r=>m(r.properties.part.sessionID,[{type:"part",data:r.properties.part}])),yield*n(D.Event.Diff,r=>m(r.properties.sessionID,[{type:"session_diff",data:r.properties.diff}])),s})),h=t.fn("ShareNext.request")(function*(){let e={},s=yield*i.active();if(j.isNone(s)||!s.value.active_org_id){let r=(yield*te.get()).enterprise?.url??"https://opncd.ai";return{headers:e,api:X,baseUrl:r}}let n=yield*i.token(s.value.id);if(j.isNone(n))throw new Error("No active account token available for sharing");return e.authorization=`Bearer ${n.value}`,e["x-org-id"]=s.value.active_org_id,{headers:e,api:Y,baseUrl:s.value.url}}),T=t.fnUntraced(function*(e){let s=yield*$(n=>n.select().from(l).where((0,b.eq)(l.session_id,e)).get());if(s)return{id:s.id,secret:s.secret,url:s.url}}),re=t.fn("ShareNext.flush")(function*(e){if(y)return;let s=yield*S.get(E),n=s.queue.get(e);if(!n)return;s.queue.delete(e);let r=yield*T(e);if(!r)return;let o=yield*h(),a=yield*p.post(`${o.baseUrl}${o.api.sync(r.id)}`).pipe(p.setHeaders(o.headers),p.bodyJson({secret:r.secret,data:Array.from(n.data.values())}),t.flatMap(v=>H.execute(v)));a.status>=400&&f.warn("failed to sync share",{sessionID:e,shareID:r.id,status:a.status})}),se=t.fn("ShareNext.full")(function*(e){f.info("full sync",{sessionID:e});let s=yield*M.get(e),n=yield*M.diff(e),r=yield*t.sync(()=>Array.from(q.stream(e))),o=yield*t.forEach(Array.from(new Map(r.filter(a=>a.info.role==="user").map(a=>a.info.model).map(a=>[`${a.providerID}/${a.modelID}`,a])).values()),a=>P.getModel(z.make(a.providerID),V.make(a.modelID)),{concurrency:8});yield*m(e,[{type:"session",data:s},...r.map(a=>({type:"message",data:a.info})),...r.flatMap(a=>a.parts.map(v=>({type:"part",data:v}))),{type:"session_diff",data:n},{type:"model",data:o}])}),ne=t.fn("ShareNext.init")(function*(){y||(yield*S.get(E))}),ae=t.fn("ShareNext.url")(function*(){return(yield*h()).baseUrl}),ie=t.fn("ShareNext.create")(function*(e){if(y)return{id:"",url:"",secret:""};f.info("creating share",{sessionID:e});let s=yield*h(),n=yield*p.post(`${s.baseUrl}${s.api.create}`).pipe(p.setHeaders(s.headers),p.bodyJson({sessionID:e}),t.flatMap(o=>L.execute(o)),t.flatMap(ue.schemaBodyJson(W)));yield*$(o=>o.insert(l).values({session_id:e,id:n.id,secret:n.secret,url:n.url}).onConflictDoUpdate({target:l.session_id,set:{id:n.id,secret:n.secret,url:n.url}}).run());let r=yield*S.get(E);return yield*se(e).pipe(t.catchCause(o=>t.sync(()=>{f.error("share full sync failed",{sessionID:e,cause:o})})),t.forkIn(r.scope)),n}),oe=t.fn("ShareNext.remove")(function*(e){if(y)return;f.info("removing share",{sessionID:e});let s=yield*T(e);if(!s)return;let n=yield*h();yield*p.delete(`${n.baseUrl}${n.api.remove(s.id)}`).pipe(p.setHeaders(n.headers),p.bodyJson({secret:s.secret}),t.flatMap(r=>L.execute(r))),yield*$(r=>r.delete(l).where((0,b.eq)(l.session_id,e)).run())});return _.of({init:ne,url:ae,request:h,create:ie,remove:oe})})),x.defaultLayer=x.layer.pipe(u.provide(w.layer),u.provide(A.defaultLayer),u.provide(N.defaultLayer),u.provide(le.layer),u.provide(C.defaultLayer),u.provide(D.defaultLayer));let{runPromise:g}=J(_,x.defaultLayer);async function me(){return g(i=>i.init())}x.init=me,c(me,"init");async function Se(){return g(i=>i.url())}x.url=Se,c(Se,"url");async function ge(){return g(i=>i.request())}x.request=ge,c(ge,"request");async function he(i){return g(d=>d.create(i))}x.create=he,c(he,"create");async function ve(i){return g(d=>d.remove(i))}x.remove=ve,c(ve,"remove")})(ye||={});export{ye as a};
@@ -1,12 +0,0 @@
1
- // Built by esbuild from opencode-server source
2
- if (typeof globalThis.Bun === 'undefined') {
3
- globalThis.Bun = {
4
- version: '0.0.0-node-compat',
5
- stdin: { async text() { const chunks = []; for await (const c of process.stdin) chunks.push(c); return Buffer.concat(chunks).toString(); } },
6
- which(cmd) { try { return require('child_process').execFileSync('which', [cmd], { encoding: 'utf8' }).trim(); } catch { return null; } },
7
- };
8
- }
9
- if (typeof globalThis.__name === 'undefined') { globalThis.__name = (t, n) => { Object.defineProperty(t, 'name', { value: n, configurable: true }); return t; }; }
10
- if (typeof globalThis.__export === 'undefined') { globalThis.__export = (t, a) => { for (const k in a) Object.defineProperty(t, k, { get: a[k], enumerable: true }); }; }
11
-
12
- import{a as e}from"./chunk-MBZTOEAD.js";var u=Symbol.for("quansync.getIsAsync"),f=class extends Error{static{e(this,"QuansyncError")}constructor(n="Unexpected promise in sync context"){super(n),this.name="QuansyncError"}};function y(n){return n&&typeof n=="object"&&typeof n.then=="function"}e(y,"isThenable");function x(n){return n&&typeof n=="object"&&typeof n[Symbol.iterator]=="function"&&"__quansync"in n}e(x,"isQuansyncGenerator");function d(n){let r=e(function*(...a){return(yield u)?yield n.async.apply(this,a):n.sync.apply(this,a)},"generator");function t(...a){let o=r.apply(this,a);return o.then=(...b)=>n.async.apply(this,a).then(...b),o.__quansync=!0,o}return e(t,"fn"),t.sync=n.sync,t.async=n.async,t}e(d,"fromObject");function _(n){return d({async:e(()=>Promise.resolve(n),"async"),sync:e(()=>{if(y(n))throw new f;return n},"sync")})}e(_,"fromPromise");function i(n,r){if(n===u)return r;if(x(n))return r?w(n):h(n);if(!r&&y(n))throw new f;return n}e(i,"unwrapYield");var p=e(n=>n,"DEFAULT_ON_YIELD");function h(n,r=p){let t=n.next();for(;!t.done;)try{t=n.next(i(r(t.value,!1)))}catch(a){t=n.throw(a)}return i(t.value)}e(h,"iterateSync");async function w(n,r=p){let t=n.next();for(;!t.done;)try{t=n.next(await i(r(t.value,!0),!0))}catch(a){t=n.throw(a)}return t.value}e(w,"iterateAsync");function S(n,r){return d({name:n.name,async(...t){return w(n.apply(this,t),r?.onYield)},sync(...t){return h(n.apply(this,t),r?.onYield)}})}e(S,"fromGeneratorFn");function s(n,r){return y(n)?_(n):typeof n=="function"?S(n,r):d(n)}e(s,"quansync");var E=s({async:e(()=>Promise.resolve(!0),"async"),sync:e(()=>!1,"sync")});var l=new Map,c=class extends Error{static{e(this,"UnsupportedVendorError")}constructor(r){super(`standard-json: Unsupported schema vendor "${r}".`)}},m=class extends Error{static{e(this,"MissingDependencyError")}constructor(r){super(`standard-json: Missing dependencies "${r}".`)}},k=e(async n=>{let r=l.get(n);if(r)return r;let t;switch(n){case"arktype":t=(await import("./arktype-aI7TBD0R-TFNARRIP.js")).default();break;case"effect":t=(await import("./effect-QlVUlMFu-JVYEXAZL.js")).default();break;case"sury":t=(await import("./sury-CWZTCd75-3YHH6KVI.js")).default();break;case"typebox":t=(await import("./typebox-Dei93FPO-GLI7OCTY.js")).default();break;case"valibot":t=(await import("./valibot--1zFm7rT-FSYJNYJ6.js")).default();break;case"zod":t=(await import("./zod-Bwrt9trS-HVDOFWRP.js")).default();break;default:throw new c(n)}let a=await t;return l.set(n,a),a},"getToJsonSchemaFn"),P=s({sync:e((n,r)=>{let t=n["~standard"].vendor,a=l.get(t);if(!a)throw new c(t);return a(n,r)},"sync"),async:e(async(n,r)=>(await k(n["~standard"].vendor))(n,r),"async")});export{m as a,P as b};