@goah/cli 0.13.0 → 0.13.2

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 (236) hide show
  1. package/dist/LICENSE +201 -0
  2. package/dist/THIRD-PARTY-NOTICES.md +2319 -0
  3. package/dist/anthropic-messages-WBFOHES5.js +7214 -0
  4. package/dist/azure-openai-responses-NZFH3PO6.js +253 -0
  5. package/dist/chunk-25XSBFX6.js +639 -0
  6. package/dist/chunk-2QBQZGXF.js +110 -0
  7. package/dist/chunk-2ZP2NBW3.js +345 -0
  8. package/dist/chunk-4KA63VNZ.js +2 -0
  9. package/dist/chunk-4M6TXTT5.js +86 -0
  10. package/dist/chunk-4US7ZHT3.js +20 -0
  11. package/dist/chunk-6M3OOCKO.js +11809 -0
  12. package/dist/chunk-7AXAFDPG.js +17 -0
  13. package/dist/chunk-7E7V6OIU.js +920 -0
  14. package/dist/chunk-BXA47DTF.js +548 -0
  15. package/dist/chunk-D2DVAH37.js +25 -0
  16. package/dist/chunk-FSBUS2BI.js +26 -0
  17. package/dist/chunk-GKDRAHLI.js +4787 -0
  18. package/dist/chunk-H462EFJP.js +89 -0
  19. package/dist/chunk-IIJQ3DW4.js +35 -0
  20. package/dist/chunk-JQD5EWJY.js +34 -0
  21. package/dist/chunk-K26BVR6O.js +61 -0
  22. package/dist/chunk-KAO7WIXG.js +31 -0
  23. package/dist/chunk-KJ4HJCTK.js +1178 -0
  24. package/dist/chunk-LBKI23CC.js +9810 -0
  25. package/dist/chunk-LKBKZEHT.js +41 -0
  26. package/dist/chunk-MD7TLTXZ.js +18 -0
  27. package/dist/chunk-MPXK7QBL.js +868 -0
  28. package/dist/chunk-NRLGWZJC.js +11 -0
  29. package/dist/chunk-QBD6EJ2Z.js +1746 -0
  30. package/dist/chunk-R6I3VKME.js +132 -0
  31. package/dist/chunk-TJON22J4.js +87 -0
  32. package/dist/chunk-ULY36ME4.js +33097 -0
  33. package/dist/chunk-XALZLRYK.js +9221 -0
  34. package/dist/chunk-XPQKM3L7.js +57 -0
  35. package/dist/chunk-YH6YJ2IB.js +1773 -0
  36. package/dist/cli.d.ts +0 -2
  37. package/dist/cli.js +13716 -580
  38. package/dist/console/assets/{index-Rtc_B7cs.js → index-B1vGMXKr.js} +11 -11
  39. package/dist/console/assets/{index-Rtc_B7cs.js.map → index-B1vGMXKr.js.map} +1 -1
  40. package/dist/console/index.html +1 -1
  41. package/dist/dist-65MDQA4Q.js +1126 -0
  42. package/dist/dist-KNR2XL6J.js +39 -0
  43. package/dist/execution.d.ts +557 -2
  44. package/dist/execution.js +37 -2
  45. package/dist/faux-runner-worker.js +128 -0
  46. package/dist/google-generative-ai-YMHXZSFE.js +422 -0
  47. package/dist/google-vertex-X6DB3ZQ6.js +471 -0
  48. package/dist/index.d.ts +853 -25
  49. package/dist/index.js +84 -385
  50. package/dist/kernel.d.ts +39 -2
  51. package/dist/kernel.js +21 -2
  52. package/dist/mistral-conversations-TY3MMD6G.js +718 -0
  53. package/dist/multipart-parser-F6M4NJZU.js +373 -0
  54. package/dist/openai-codex-responses-BRDUMLN5.js +1374 -0
  55. package/dist/openai-completions-CX634XN3.js +1139 -0
  56. package/dist/openai-responses-HMCXJIHT.js +300 -0
  57. package/dist/openrouter-images-KTWET2H2.js +148 -0
  58. package/dist/pi-messages-XL5OEC4K.js +307 -0
  59. package/dist/pi-worker.js +671 -0
  60. package/dist/runner-pi.d.ts +342 -2
  61. package/dist/runner-pi.js +46 -2
  62. package/dist/runner-registry-GD4BYCQC.js +22 -0
  63. package/dist/sqlite.d.ts +446 -2
  64. package/dist/sqlite.js +15 -2
  65. package/dist/src-F2KBSV4T.js +1398 -0
  66. package/dist/supervisor.d.ts +625 -2
  67. package/dist/supervisor.js +39 -2
  68. package/dist/testkit.d.ts +564 -2
  69. package/dist/testkit.js +127 -2
  70. package/dist/transcript.d.ts +84 -2
  71. package/dist/transcript.js +25 -2
  72. package/dist/verification-worker.js +72 -0
  73. package/package.json +2 -26
  74. package/dist/cli.d.ts.map +0 -1
  75. package/dist/cli.js.map +0 -1
  76. package/dist/control.d.ts +0 -106
  77. package/dist/control.d.ts.map +0 -1
  78. package/dist/control.js +0 -242
  79. package/dist/control.js.map +0 -1
  80. package/dist/execution.d.ts.map +0 -1
  81. package/dist/execution.js.map +0 -1
  82. package/dist/index.d.ts.map +0 -1
  83. package/dist/index.js.map +0 -1
  84. package/dist/kernel.d.ts.map +0 -1
  85. package/dist/kernel.js.map +0 -1
  86. package/dist/live-config.d.ts +0 -10
  87. package/dist/live-config.d.ts.map +0 -1
  88. package/dist/live-config.js +0 -44
  89. package/dist/live-config.js.map +0 -1
  90. package/dist/prompt-queue.d.ts +0 -13
  91. package/dist/prompt-queue.d.ts.map +0 -1
  92. package/dist/prompt-queue.js +0 -35
  93. package/dist/prompt-queue.js.map +0 -1
  94. package/dist/runner-pi.d.ts.map +0 -1
  95. package/dist/runner-pi.js.map +0 -1
  96. package/dist/runner-registry.d.ts +0 -8
  97. package/dist/runner-registry.d.ts.map +0 -1
  98. package/dist/runner-registry.js +0 -12
  99. package/dist/runner-registry.js.map +0 -1
  100. package/dist/searchable-select.d.ts +0 -24
  101. package/dist/searchable-select.d.ts.map +0 -1
  102. package/dist/searchable-select.js +0 -61
  103. package/dist/searchable-select.js.map +0 -1
  104. package/dist/secret-input.d.ts +0 -8
  105. package/dist/secret-input.d.ts.map +0 -1
  106. package/dist/secret-input.js +0 -14
  107. package/dist/secret-input.js.map +0 -1
  108. package/dist/setup-wizard.d.ts +0 -22
  109. package/dist/setup-wizard.d.ts.map +0 -1
  110. package/dist/setup-wizard.js +0 -154
  111. package/dist/setup-wizard.js.map +0 -1
  112. package/dist/sqlite.d.ts.map +0 -1
  113. package/dist/sqlite.js.map +0 -1
  114. package/dist/supervisor.d.ts.map +0 -1
  115. package/dist/supervisor.js.map +0 -1
  116. package/dist/testkit.d.ts.map +0 -1
  117. package/dist/testkit.js.map +0 -1
  118. package/dist/thread-inspect.d.ts +0 -47
  119. package/dist/thread-inspect.d.ts.map +0 -1
  120. package/dist/thread-inspect.js +0 -78
  121. package/dist/thread-inspect.js.map +0 -1
  122. package/dist/transcript.d.ts.map +0 -1
  123. package/dist/transcript.js.map +0 -1
  124. package/dist/tui-theme.d.ts +0 -17
  125. package/dist/tui-theme.d.ts.map +0 -1
  126. package/dist/tui-theme.js +0 -19
  127. package/dist/tui-theme.js.map +0 -1
  128. package/dist/tui.d.ts +0 -24
  129. package/dist/tui.d.ts.map +0 -1
  130. package/dist/tui.js +0 -784
  131. package/dist/tui.js.map +0 -1
  132. package/dist/update.d.ts +0 -16
  133. package/dist/update.d.ts.map +0 -1
  134. package/dist/update.js +0 -67
  135. package/dist/update.js.map +0 -1
  136. package/dist/web-console.d.ts +0 -33
  137. package/dist/web-console.d.ts.map +0 -1
  138. package/dist/web-console.js +0 -242
  139. package/dist/web-console.js.map +0 -1
  140. package/dist/welcome.d.ts +0 -30
  141. package/dist/welcome.d.ts.map +0 -1
  142. package/dist/welcome.js +0 -69
  143. package/dist/welcome.js.map +0 -1
  144. package/node_modules/goah-ledger-contract/dist/execution.d.ts +0 -544
  145. package/node_modules/goah-ledger-contract/dist/execution.d.ts.map +0 -1
  146. package/node_modules/goah-ledger-contract/dist/execution.js +0 -52
  147. package/node_modules/goah-ledger-contract/dist/execution.js.map +0 -1
  148. package/node_modules/goah-ledger-contract/dist/index.d.ts +0 -4
  149. package/node_modules/goah-ledger-contract/dist/index.d.ts.map +0 -1
  150. package/node_modules/goah-ledger-contract/dist/index.js +0 -4
  151. package/node_modules/goah-ledger-contract/dist/index.js.map +0 -1
  152. package/node_modules/goah-ledger-contract/dist/kernel.d.ts +0 -37
  153. package/node_modules/goah-ledger-contract/dist/kernel.d.ts.map +0 -1
  154. package/node_modules/goah-ledger-contract/dist/kernel.js +0 -8
  155. package/node_modules/goah-ledger-contract/dist/kernel.js.map +0 -1
  156. package/node_modules/goah-ledger-contract/dist/transcript.d.ts +0 -63
  157. package/node_modules/goah-ledger-contract/dist/transcript.d.ts.map +0 -1
  158. package/node_modules/goah-ledger-contract/dist/transcript.js +0 -115
  159. package/node_modules/goah-ledger-contract/dist/transcript.js.map +0 -1
  160. package/node_modules/goah-ledger-contract/package.json +0 -28
  161. package/node_modules/goah-ledger-sqlite/dist/index.d.ts +0 -86
  162. package/node_modules/goah-ledger-sqlite/dist/index.d.ts.map +0 -1
  163. package/node_modules/goah-ledger-sqlite/dist/index.js +0 -1254
  164. package/node_modules/goah-ledger-sqlite/dist/index.js.map +0 -1
  165. package/node_modules/goah-ledger-sqlite/package.json +0 -26
  166. package/node_modules/goah-runner-pi/dist/configurator.d.ts +0 -20
  167. package/node_modules/goah-runner-pi/dist/configurator.d.ts.map +0 -1
  168. package/node_modules/goah-runner-pi/dist/configurator.js +0 -423
  169. package/node_modules/goah-runner-pi/dist/configurator.js.map +0 -1
  170. package/node_modules/goah-runner-pi/dist/credential-store.d.ts +0 -14
  171. package/node_modules/goah-runner-pi/dist/credential-store.d.ts.map +0 -1
  172. package/node_modules/goah-runner-pi/dist/credential-store.js +0 -163
  173. package/node_modules/goah-runner-pi/dist/credential-store.js.map +0 -1
  174. package/node_modules/goah-runner-pi/dist/env-spec.d.ts +0 -17
  175. package/node_modules/goah-runner-pi/dist/env-spec.d.ts.map +0 -1
  176. package/node_modules/goah-runner-pi/dist/env-spec.js +0 -95
  177. package/node_modules/goah-runner-pi/dist/env-spec.js.map +0 -1
  178. package/node_modules/goah-runner-pi/dist/index.d.ts +0 -76
  179. package/node_modules/goah-runner-pi/dist/index.d.ts.map +0 -1
  180. package/node_modules/goah-runner-pi/dist/index.js +0 -326
  181. package/node_modules/goah-runner-pi/dist/index.js.map +0 -1
  182. package/node_modules/goah-runner-pi/dist/model-provider.d.ts +0 -30
  183. package/node_modules/goah-runner-pi/dist/model-provider.d.ts.map +0 -1
  184. package/node_modules/goah-runner-pi/dist/model-provider.js +0 -96
  185. package/node_modules/goah-runner-pi/dist/model-provider.js.map +0 -1
  186. package/node_modules/goah-runner-pi/dist/pi-worker.d.ts +0 -31
  187. package/node_modules/goah-runner-pi/dist/pi-worker.d.ts.map +0 -1
  188. package/node_modules/goah-runner-pi/dist/pi-worker.js +0 -579
  189. package/node_modules/goah-runner-pi/dist/pi-worker.js.map +0 -1
  190. package/node_modules/goah-runner-pi/dist/steering-no-ack.test-fixture.d.ts +0 -2
  191. package/node_modules/goah-runner-pi/dist/steering-no-ack.test-fixture.d.ts.map +0 -1
  192. package/node_modules/goah-runner-pi/dist/steering-no-ack.test-fixture.js +0 -3
  193. package/node_modules/goah-runner-pi/dist/steering-no-ack.test-fixture.js.map +0 -1
  194. package/node_modules/goah-runner-pi/dist/steering-reject.test-fixture.d.ts +0 -2
  195. package/node_modules/goah-runner-pi/dist/steering-reject.test-fixture.d.ts.map +0 -1
  196. package/node_modules/goah-runner-pi/dist/steering-reject.test-fixture.js +0 -5
  197. package/node_modules/goah-runner-pi/dist/steering-reject.test-fixture.js.map +0 -1
  198. package/node_modules/goah-runner-pi/dist/steering-worker.test-fixture.d.ts +0 -2
  199. package/node_modules/goah-runner-pi/dist/steering-worker.test-fixture.d.ts.map +0 -1
  200. package/node_modules/goah-runner-pi/dist/steering-worker.test-fixture.js +0 -5
  201. package/node_modules/goah-runner-pi/dist/steering-worker.test-fixture.js.map +0 -1
  202. package/node_modules/goah-runner-pi/dist/test-helpers.d.ts +0 -4
  203. package/node_modules/goah-runner-pi/dist/test-helpers.d.ts.map +0 -1
  204. package/node_modules/goah-runner-pi/dist/test-helpers.js +0 -13
  205. package/node_modules/goah-runner-pi/dist/test-helpers.js.map +0 -1
  206. package/node_modules/goah-runner-pi/dist/verification-worker.d.ts +0 -2
  207. package/node_modules/goah-runner-pi/dist/verification-worker.d.ts.map +0 -1
  208. package/node_modules/goah-runner-pi/dist/verification-worker.js +0 -46
  209. package/node_modules/goah-runner-pi/dist/verification-worker.js.map +0 -1
  210. package/node_modules/goah-runner-pi/package.json +0 -28
  211. package/node_modules/goah-supervisor/dist/context-view.d.ts +0 -30
  212. package/node_modules/goah-supervisor/dist/context-view.d.ts.map +0 -1
  213. package/node_modules/goah-supervisor/dist/context-view.js +0 -58
  214. package/node_modules/goah-supervisor/dist/context-view.js.map +0 -1
  215. package/node_modules/goah-supervisor/dist/index.d.ts +0 -96
  216. package/node_modules/goah-supervisor/dist/index.d.ts.map +0 -1
  217. package/node_modules/goah-supervisor/dist/index.js +0 -1075
  218. package/node_modules/goah-supervisor/dist/index.js.map +0 -1
  219. package/node_modules/goah-supervisor/dist/roles.d.ts +0 -4
  220. package/node_modules/goah-supervisor/dist/roles.d.ts.map +0 -1
  221. package/node_modules/goah-supervisor/dist/roles.js +0 -29
  222. package/node_modules/goah-supervisor/dist/roles.js.map +0 -1
  223. package/node_modules/goah-supervisor/dist/verification.d.ts +0 -61
  224. package/node_modules/goah-supervisor/dist/verification.d.ts.map +0 -1
  225. package/node_modules/goah-supervisor/dist/verification.js +0 -135
  226. package/node_modules/goah-supervisor/dist/verification.js.map +0 -1
  227. package/node_modules/goah-supervisor/package.json +0 -26
  228. package/node_modules/goah-testkit/dist/faux-runner-worker.d.ts +0 -2
  229. package/node_modules/goah-testkit/dist/faux-runner-worker.d.ts.map +0 -1
  230. package/node_modules/goah-testkit/dist/faux-runner-worker.js +0 -82
  231. package/node_modules/goah-testkit/dist/faux-runner-worker.js.map +0 -1
  232. package/node_modules/goah-testkit/dist/index.d.ts +0 -49
  233. package/node_modules/goah-testkit/dist/index.d.ts.map +0 -1
  234. package/node_modules/goah-testkit/dist/index.js +0 -96
  235. package/node_modules/goah-testkit/dist/index.js.map +0 -1
  236. package/node_modules/goah-testkit/package.json +0 -29
@@ -0,0 +1,373 @@
1
+ import { createRequire as __goahCreateRequire } from "node:module";
2
+ const require = __goahCreateRequire(import.meta.url);
3
+ import {
4
+ FormData,
5
+ file_default,
6
+ init_esm_min,
7
+ init_from
8
+ } from "./chunk-GKDRAHLI.js";
9
+ import {
10
+ __esm
11
+ } from "./chunk-XPQKM3L7.js";
12
+
13
+ // ../../node_modules/node-fetch/src/utils/multipart-parser.js
14
+ function _fileName(headerValue) {
15
+ const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
16
+ if (!m) {
17
+ return;
18
+ }
19
+ const match = m[2] || m[3] || "";
20
+ let filename = match.slice(match.lastIndexOf("\\") + 1);
21
+ filename = filename.replace(/%22/g, '"');
22
+ filename = filename.replace(/&#(\d{4});/g, (m2, code) => {
23
+ return String.fromCharCode(code);
24
+ });
25
+ return filename;
26
+ }
27
+ async function toFormData(Body, ct) {
28
+ if (!/multipart/i.test(ct)) {
29
+ throw new TypeError("Failed to fetch");
30
+ }
31
+ const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
32
+ if (!m) {
33
+ throw new TypeError("no or bad content-type header, no multipart boundary");
34
+ }
35
+ const parser = new MultipartParser(m[1] || m[2]);
36
+ let headerField;
37
+ let headerValue;
38
+ let entryValue;
39
+ let entryName;
40
+ let contentType;
41
+ let filename;
42
+ const entryChunks = [];
43
+ const formData = new FormData();
44
+ const onPartData = (ui8a) => {
45
+ entryValue += decoder.decode(ui8a, { stream: true });
46
+ };
47
+ const appendToFile = (ui8a) => {
48
+ entryChunks.push(ui8a);
49
+ };
50
+ const appendFileToFormData = () => {
51
+ const file = new file_default(entryChunks, filename, { type: contentType });
52
+ formData.append(entryName, file);
53
+ };
54
+ const appendEntryToFormData = () => {
55
+ formData.append(entryName, entryValue);
56
+ };
57
+ const decoder = new TextDecoder("utf-8");
58
+ decoder.decode();
59
+ parser.onPartBegin = function() {
60
+ parser.onPartData = onPartData;
61
+ parser.onPartEnd = appendEntryToFormData;
62
+ headerField = "";
63
+ headerValue = "";
64
+ entryValue = "";
65
+ entryName = "";
66
+ contentType = "";
67
+ filename = null;
68
+ entryChunks.length = 0;
69
+ };
70
+ parser.onHeaderField = function(ui8a) {
71
+ headerField += decoder.decode(ui8a, { stream: true });
72
+ };
73
+ parser.onHeaderValue = function(ui8a) {
74
+ headerValue += decoder.decode(ui8a, { stream: true });
75
+ };
76
+ parser.onHeaderEnd = function() {
77
+ headerValue += decoder.decode();
78
+ headerField = headerField.toLowerCase();
79
+ if (headerField === "content-disposition") {
80
+ const m2 = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
81
+ if (m2) {
82
+ entryName = m2[2] || m2[3] || "";
83
+ }
84
+ filename = _fileName(headerValue);
85
+ if (filename) {
86
+ parser.onPartData = appendToFile;
87
+ parser.onPartEnd = appendFileToFormData;
88
+ }
89
+ } else if (headerField === "content-type") {
90
+ contentType = headerValue;
91
+ }
92
+ headerValue = "";
93
+ headerField = "";
94
+ };
95
+ for await (const chunk of Body) {
96
+ parser.write(chunk);
97
+ }
98
+ parser.end();
99
+ return formData;
100
+ }
101
+ var s, S, f, F, LF, CR, SPACE, HYPHEN, COLON, A, Z, lower, noop, MultipartParser;
102
+ var init_multipart_parser = __esm({
103
+ "../../node_modules/node-fetch/src/utils/multipart-parser.js"() {
104
+ init_from();
105
+ init_esm_min();
106
+ s = 0;
107
+ S = {
108
+ START_BOUNDARY: s++,
109
+ HEADER_FIELD_START: s++,
110
+ HEADER_FIELD: s++,
111
+ HEADER_VALUE_START: s++,
112
+ HEADER_VALUE: s++,
113
+ HEADER_VALUE_ALMOST_DONE: s++,
114
+ HEADERS_ALMOST_DONE: s++,
115
+ PART_DATA_START: s++,
116
+ PART_DATA: s++,
117
+ END: s++
118
+ };
119
+ f = 1;
120
+ F = {
121
+ PART_BOUNDARY: f,
122
+ LAST_BOUNDARY: f *= 2
123
+ };
124
+ LF = 10;
125
+ CR = 13;
126
+ SPACE = 32;
127
+ HYPHEN = 45;
128
+ COLON = 58;
129
+ A = 97;
130
+ Z = 122;
131
+ lower = (c) => c | 32;
132
+ noop = () => {
133
+ };
134
+ MultipartParser = class {
135
+ /**
136
+ * @param {string} boundary
137
+ */
138
+ constructor(boundary) {
139
+ this.index = 0;
140
+ this.flags = 0;
141
+ this.onHeaderEnd = noop;
142
+ this.onHeaderField = noop;
143
+ this.onHeadersEnd = noop;
144
+ this.onHeaderValue = noop;
145
+ this.onPartBegin = noop;
146
+ this.onPartData = noop;
147
+ this.onPartEnd = noop;
148
+ this.boundaryChars = {};
149
+ boundary = "\r\n--" + boundary;
150
+ const ui8a = new Uint8Array(boundary.length);
151
+ for (let i = 0; i < boundary.length; i++) {
152
+ ui8a[i] = boundary.charCodeAt(i);
153
+ this.boundaryChars[ui8a[i]] = true;
154
+ }
155
+ this.boundary = ui8a;
156
+ this.lookbehind = new Uint8Array(this.boundary.length + 8);
157
+ this.state = S.START_BOUNDARY;
158
+ }
159
+ /**
160
+ * @param {Uint8Array} data
161
+ */
162
+ write(data) {
163
+ let i = 0;
164
+ const length_ = data.length;
165
+ let previousIndex = this.index;
166
+ let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
167
+ const boundaryLength = this.boundary.length;
168
+ const boundaryEnd = boundaryLength - 1;
169
+ const bufferLength = data.length;
170
+ let c;
171
+ let cl;
172
+ const mark = (name) => {
173
+ this[name + "Mark"] = i;
174
+ };
175
+ const clear = (name) => {
176
+ delete this[name + "Mark"];
177
+ };
178
+ const callback = (callbackSymbol, start, end, ui8a) => {
179
+ if (start === void 0 || start !== end) {
180
+ this[callbackSymbol](ui8a && ui8a.subarray(start, end));
181
+ }
182
+ };
183
+ const dataCallback = (name, clear2) => {
184
+ const markSymbol = name + "Mark";
185
+ if (!(markSymbol in this)) {
186
+ return;
187
+ }
188
+ if (clear2) {
189
+ callback(name, this[markSymbol], i, data);
190
+ delete this[markSymbol];
191
+ } else {
192
+ callback(name, this[markSymbol], data.length, data);
193
+ this[markSymbol] = 0;
194
+ }
195
+ };
196
+ for (i = 0; i < length_; i++) {
197
+ c = data[i];
198
+ switch (state) {
199
+ case S.START_BOUNDARY:
200
+ if (index === boundary.length - 2) {
201
+ if (c === HYPHEN) {
202
+ flags |= F.LAST_BOUNDARY;
203
+ } else if (c !== CR) {
204
+ return;
205
+ }
206
+ index++;
207
+ break;
208
+ } else if (index - 1 === boundary.length - 2) {
209
+ if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
210
+ state = S.END;
211
+ flags = 0;
212
+ } else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
213
+ index = 0;
214
+ callback("onPartBegin");
215
+ state = S.HEADER_FIELD_START;
216
+ } else {
217
+ return;
218
+ }
219
+ break;
220
+ }
221
+ if (c !== boundary[index + 2]) {
222
+ index = -2;
223
+ }
224
+ if (c === boundary[index + 2]) {
225
+ index++;
226
+ }
227
+ break;
228
+ case S.HEADER_FIELD_START:
229
+ state = S.HEADER_FIELD;
230
+ mark("onHeaderField");
231
+ index = 0;
232
+ // falls through
233
+ case S.HEADER_FIELD:
234
+ if (c === CR) {
235
+ clear("onHeaderField");
236
+ state = S.HEADERS_ALMOST_DONE;
237
+ break;
238
+ }
239
+ index++;
240
+ if (c === HYPHEN) {
241
+ break;
242
+ }
243
+ if (c === COLON) {
244
+ if (index === 1) {
245
+ return;
246
+ }
247
+ dataCallback("onHeaderField", true);
248
+ state = S.HEADER_VALUE_START;
249
+ break;
250
+ }
251
+ cl = lower(c);
252
+ if (cl < A || cl > Z) {
253
+ return;
254
+ }
255
+ break;
256
+ case S.HEADER_VALUE_START:
257
+ if (c === SPACE) {
258
+ break;
259
+ }
260
+ mark("onHeaderValue");
261
+ state = S.HEADER_VALUE;
262
+ // falls through
263
+ case S.HEADER_VALUE:
264
+ if (c === CR) {
265
+ dataCallback("onHeaderValue", true);
266
+ callback("onHeaderEnd");
267
+ state = S.HEADER_VALUE_ALMOST_DONE;
268
+ }
269
+ break;
270
+ case S.HEADER_VALUE_ALMOST_DONE:
271
+ if (c !== LF) {
272
+ return;
273
+ }
274
+ state = S.HEADER_FIELD_START;
275
+ break;
276
+ case S.HEADERS_ALMOST_DONE:
277
+ if (c !== LF) {
278
+ return;
279
+ }
280
+ callback("onHeadersEnd");
281
+ state = S.PART_DATA_START;
282
+ break;
283
+ case S.PART_DATA_START:
284
+ state = S.PART_DATA;
285
+ mark("onPartData");
286
+ // falls through
287
+ case S.PART_DATA:
288
+ previousIndex = index;
289
+ if (index === 0) {
290
+ i += boundaryEnd;
291
+ while (i < bufferLength && !(data[i] in boundaryChars)) {
292
+ i += boundaryLength;
293
+ }
294
+ i -= boundaryEnd;
295
+ c = data[i];
296
+ }
297
+ if (index < boundary.length) {
298
+ if (boundary[index] === c) {
299
+ if (index === 0) {
300
+ dataCallback("onPartData", true);
301
+ }
302
+ index++;
303
+ } else {
304
+ index = 0;
305
+ }
306
+ } else if (index === boundary.length) {
307
+ index++;
308
+ if (c === CR) {
309
+ flags |= F.PART_BOUNDARY;
310
+ } else if (c === HYPHEN) {
311
+ flags |= F.LAST_BOUNDARY;
312
+ } else {
313
+ index = 0;
314
+ }
315
+ } else if (index - 1 === boundary.length) {
316
+ if (flags & F.PART_BOUNDARY) {
317
+ index = 0;
318
+ if (c === LF) {
319
+ flags &= ~F.PART_BOUNDARY;
320
+ callback("onPartEnd");
321
+ callback("onPartBegin");
322
+ state = S.HEADER_FIELD_START;
323
+ break;
324
+ }
325
+ } else if (flags & F.LAST_BOUNDARY) {
326
+ if (c === HYPHEN) {
327
+ callback("onPartEnd");
328
+ state = S.END;
329
+ flags = 0;
330
+ } else {
331
+ index = 0;
332
+ }
333
+ } else {
334
+ index = 0;
335
+ }
336
+ }
337
+ if (index > 0) {
338
+ lookbehind[index - 1] = c;
339
+ } else if (previousIndex > 0) {
340
+ const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
341
+ callback("onPartData", 0, previousIndex, _lookbehind);
342
+ previousIndex = 0;
343
+ mark("onPartData");
344
+ i--;
345
+ }
346
+ break;
347
+ case S.END:
348
+ break;
349
+ default:
350
+ throw new Error(`Unexpected state entered: ${state}`);
351
+ }
352
+ }
353
+ dataCallback("onHeaderField");
354
+ dataCallback("onHeaderValue");
355
+ dataCallback("onPartData");
356
+ this.index = index;
357
+ this.state = state;
358
+ this.flags = flags;
359
+ }
360
+ end() {
361
+ if (this.state === S.HEADER_FIELD_START && this.index === 0 || this.state === S.PART_DATA && this.index === this.boundary.length) {
362
+ this.onPartEnd();
363
+ } else if (this.state !== S.END) {
364
+ throw new Error("MultipartParser.end(): stream ended unexpectedly");
365
+ }
366
+ }
367
+ };
368
+ }
369
+ });
370
+ init_multipart_parser();
371
+ export {
372
+ toFormData
373
+ };