@goah/cli 0.13.0 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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-BXA47DTF.js +548 -0
  14. package/dist/chunk-FSBUS2BI.js +26 -0
  15. package/dist/chunk-GKDRAHLI.js +4787 -0
  16. package/dist/chunk-H462EFJP.js +89 -0
  17. package/dist/chunk-IIJQ3DW4.js +35 -0
  18. package/dist/chunk-JQD5EWJY.js +34 -0
  19. package/dist/chunk-K26BVR6O.js +61 -0
  20. package/dist/chunk-KAO7WIXG.js +31 -0
  21. package/dist/chunk-LBKI23CC.js +9810 -0
  22. package/dist/chunk-LKBKZEHT.js +41 -0
  23. package/dist/chunk-MD7TLTXZ.js +18 -0
  24. package/dist/chunk-MPXK7QBL.js +868 -0
  25. package/dist/chunk-NRLGWZJC.js +11 -0
  26. package/dist/chunk-PFEV3HWI.js +1178 -0
  27. package/dist/chunk-QBD6EJ2Z.js +1746 -0
  28. package/dist/chunk-R6I3VKME.js +132 -0
  29. package/dist/chunk-TJON22J4.js +87 -0
  30. package/dist/chunk-ULY36ME4.js +33097 -0
  31. package/dist/chunk-VWEV4LTH.js +25 -0
  32. package/dist/chunk-X7UWW2PN.js +883 -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 +13123 -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-M776E3SE.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,110 @@
1
+ import { createRequire as __goahCreateRequire } from "node:module";
2
+ const require = __goahCreateRequire(import.meta.url);
3
+
4
+ // ../../node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js
5
+ var EventStream = class {
6
+ queue = [];
7
+ waiting = [];
8
+ done = false;
9
+ finalResultPromise;
10
+ resolveFinalResult;
11
+ isComplete;
12
+ extractResult;
13
+ constructor(isComplete, extractResult) {
14
+ this.isComplete = isComplete;
15
+ this.extractResult = extractResult;
16
+ this.finalResultPromise = new Promise((resolve) => {
17
+ this.resolveFinalResult = resolve;
18
+ });
19
+ }
20
+ push(event) {
21
+ if (this.done)
22
+ return;
23
+ if (this.isComplete(event)) {
24
+ this.done = true;
25
+ this.resolveFinalResult(this.extractResult(event));
26
+ }
27
+ const waiter = this.waiting.shift();
28
+ if (waiter) {
29
+ waiter({ value: event, done: false });
30
+ } else {
31
+ this.queue.push(event);
32
+ }
33
+ }
34
+ end(result) {
35
+ this.done = true;
36
+ if (result !== void 0) {
37
+ this.resolveFinalResult(result);
38
+ }
39
+ while (this.waiting.length > 0) {
40
+ const waiter = this.waiting.shift();
41
+ waiter({ value: void 0, done: true });
42
+ }
43
+ }
44
+ async *[Symbol.asyncIterator]() {
45
+ while (true) {
46
+ if (this.queue.length > 0) {
47
+ yield this.queue.shift();
48
+ } else if (this.done) {
49
+ return;
50
+ } else {
51
+ const result = await new Promise((resolve) => this.waiting.push(resolve));
52
+ if (result.done)
53
+ return;
54
+ yield result.value;
55
+ }
56
+ }
57
+ }
58
+ result() {
59
+ return this.finalResultPromise;
60
+ }
61
+ };
62
+ var AssistantMessageEventStream = class extends EventStream {
63
+ constructor() {
64
+ super((event) => event.type === "done" || event.type === "error", (event) => {
65
+ if (event.type === "done") {
66
+ return event.message;
67
+ } else if (event.type === "error") {
68
+ return event.error;
69
+ }
70
+ throw new Error("Unexpected event type for final result");
71
+ });
72
+ }
73
+ };
74
+ function createAssistantMessageEventStream() {
75
+ return new AssistantMessageEventStream();
76
+ }
77
+
78
+ // ../../node_modules/@earendil-works/pi-ai/dist/utils/diagnostics.js
79
+ function formatThrownValue(value) {
80
+ if (value instanceof Error)
81
+ return value.message || value.name;
82
+ if (typeof value === "string")
83
+ return value;
84
+ return String(value);
85
+ }
86
+ function extractDiagnosticError(error) {
87
+ if (!(error instanceof Error))
88
+ return { name: "ThrownValue", message: formatThrownValue(error) };
89
+ const code = error.code;
90
+ return {
91
+ name: error.name || void 0,
92
+ message: error.message || error.name,
93
+ stack: error.stack,
94
+ code: typeof code === "string" || typeof code === "number" ? code : void 0
95
+ };
96
+ }
97
+ function createAssistantMessageDiagnostic(type, error, details) {
98
+ return { type, timestamp: Date.now(), error: extractDiagnosticError(error), details };
99
+ }
100
+ function appendAssistantMessageDiagnostic(message, diagnostic) {
101
+ message.diagnostics = [...message.diagnostics ?? [], diagnostic];
102
+ }
103
+
104
+ export {
105
+ AssistantMessageEventStream,
106
+ createAssistantMessageEventStream,
107
+ formatThrownValue,
108
+ createAssistantMessageDiagnostic,
109
+ appendAssistantMessageDiagnostic
110
+ };
@@ -0,0 +1,345 @@
1
+ import { createRequire as __goahCreateRequire } from "node:module";
2
+ const require = __goahCreateRequire(import.meta.url);
3
+ import {
4
+ __commonJS,
5
+ __toESM
6
+ } from "./chunk-XPQKM3L7.js";
7
+
8
+ // ../../node_modules/partial-json/dist/options.js
9
+ var require_options = __commonJS({
10
+ "../../node_modules/partial-json/dist/options.js"(exports) {
11
+ "use strict";
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Allow = exports.ALL = exports.COLLECTION = exports.ATOM = exports.SPECIAL = exports.INF = exports._INFINITY = exports.INFINITY = exports.NAN = exports.BOOL = exports.NULL = exports.OBJ = exports.ARR = exports.NUM = exports.STR = void 0;
14
+ exports.STR = 1;
15
+ exports.NUM = 2;
16
+ exports.ARR = 4;
17
+ exports.OBJ = 8;
18
+ exports.NULL = 16;
19
+ exports.BOOL = 32;
20
+ exports.NAN = 64;
21
+ exports.INFINITY = 128;
22
+ exports._INFINITY = 256;
23
+ exports.INF = exports.INFINITY | exports._INFINITY;
24
+ exports.SPECIAL = exports.NULL | exports.BOOL | exports.INF | exports.NAN;
25
+ exports.ATOM = exports.STR | exports.NUM | exports.SPECIAL;
26
+ exports.COLLECTION = exports.ARR | exports.OBJ;
27
+ exports.ALL = exports.ATOM | exports.COLLECTION;
28
+ exports.Allow = { STR: exports.STR, NUM: exports.NUM, ARR: exports.ARR, OBJ: exports.OBJ, NULL: exports.NULL, BOOL: exports.BOOL, NAN: exports.NAN, INFINITY: exports.INFINITY, _INFINITY: exports._INFINITY, INF: exports.INF, SPECIAL: exports.SPECIAL, ATOM: exports.ATOM, COLLECTION: exports.COLLECTION, ALL: exports.ALL };
29
+ exports.default = exports.Allow;
30
+ }
31
+ });
32
+
33
+ // ../../node_modules/partial-json/dist/index.js
34
+ var require_dist = __commonJS({
35
+ "../../node_modules/partial-json/dist/index.js"(exports) {
36
+ "use strict";
37
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
38
+ if (k2 === void 0) k2 = k;
39
+ var desc = Object.getOwnPropertyDescriptor(m, k);
40
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
41
+ desc = { enumerable: true, get: function() {
42
+ return m[k];
43
+ } };
44
+ }
45
+ Object.defineProperty(o, k2, desc);
46
+ }) : (function(o, m, k, k2) {
47
+ if (k2 === void 0) k2 = k;
48
+ o[k2] = m[k];
49
+ }));
50
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
51
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.Allow = exports.MalformedJSON = exports.PartialJSON = exports.parseJSON = exports.parse = void 0;
55
+ var options_1 = require_options();
56
+ Object.defineProperty(exports, "Allow", { enumerable: true, get: function() {
57
+ return options_1.Allow;
58
+ } });
59
+ __exportStar(require_options(), exports);
60
+ var PartialJSON = class extends Error {
61
+ };
62
+ exports.PartialJSON = PartialJSON;
63
+ var MalformedJSON = class extends Error {
64
+ };
65
+ exports.MalformedJSON = MalformedJSON;
66
+ function parseJSON(jsonString, allowPartial = options_1.Allow.ALL) {
67
+ if (typeof jsonString !== "string") {
68
+ throw new TypeError(`expecting str, got ${typeof jsonString}`);
69
+ }
70
+ if (!jsonString.trim()) {
71
+ throw new Error(`${jsonString} is empty`);
72
+ }
73
+ return _parseJSON(jsonString.trim(), allowPartial);
74
+ }
75
+ exports.parseJSON = parseJSON;
76
+ var _parseJSON = (jsonString, allow) => {
77
+ const length = jsonString.length;
78
+ let index = 0;
79
+ const markPartialJSON = (msg) => {
80
+ throw new PartialJSON(`${msg} at position ${index}`);
81
+ };
82
+ const throwMalformedError = (msg) => {
83
+ throw new MalformedJSON(`${msg} at position ${index}`);
84
+ };
85
+ const parseAny = () => {
86
+ skipBlank();
87
+ if (index >= length)
88
+ markPartialJSON("Unexpected end of input");
89
+ if (jsonString[index] === '"')
90
+ return parseStr();
91
+ if (jsonString[index] === "{")
92
+ return parseObj();
93
+ if (jsonString[index] === "[")
94
+ return parseArr();
95
+ if (jsonString.substring(index, index + 4) === "null" || options_1.Allow.NULL & allow && length - index < 4 && "null".startsWith(jsonString.substring(index))) {
96
+ index += 4;
97
+ return null;
98
+ }
99
+ if (jsonString.substring(index, index + 4) === "true" || options_1.Allow.BOOL & allow && length - index < 4 && "true".startsWith(jsonString.substring(index))) {
100
+ index += 4;
101
+ return true;
102
+ }
103
+ if (jsonString.substring(index, index + 5) === "false" || options_1.Allow.BOOL & allow && length - index < 5 && "false".startsWith(jsonString.substring(index))) {
104
+ index += 5;
105
+ return false;
106
+ }
107
+ if (jsonString.substring(index, index + 8) === "Infinity" || options_1.Allow.INFINITY & allow && length - index < 8 && "Infinity".startsWith(jsonString.substring(index))) {
108
+ index += 8;
109
+ return Infinity;
110
+ }
111
+ if (jsonString.substring(index, index + 9) === "-Infinity" || options_1.Allow._INFINITY & allow && 1 < length - index && length - index < 9 && "-Infinity".startsWith(jsonString.substring(index))) {
112
+ index += 9;
113
+ return -Infinity;
114
+ }
115
+ if (jsonString.substring(index, index + 3) === "NaN" || options_1.Allow.NAN & allow && length - index < 3 && "NaN".startsWith(jsonString.substring(index))) {
116
+ index += 3;
117
+ return NaN;
118
+ }
119
+ return parseNum();
120
+ };
121
+ const parseStr = () => {
122
+ const start = index;
123
+ let escape = false;
124
+ index++;
125
+ while (index < length && (jsonString[index] !== '"' || escape && jsonString[index - 1] === "\\")) {
126
+ escape = jsonString[index] === "\\" ? !escape : false;
127
+ index++;
128
+ }
129
+ if (jsonString.charAt(index) == '"') {
130
+ try {
131
+ return JSON.parse(jsonString.substring(start, ++index - Number(escape)));
132
+ } catch (e) {
133
+ throwMalformedError(String(e));
134
+ }
135
+ } else if (options_1.Allow.STR & allow) {
136
+ try {
137
+ return JSON.parse(jsonString.substring(start, index - Number(escape)) + '"');
138
+ } catch (e) {
139
+ return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("\\")) + '"');
140
+ }
141
+ }
142
+ markPartialJSON("Unterminated string literal");
143
+ };
144
+ const parseObj = () => {
145
+ index++;
146
+ skipBlank();
147
+ const obj = {};
148
+ try {
149
+ while (jsonString[index] !== "}") {
150
+ skipBlank();
151
+ if (index >= length && options_1.Allow.OBJ & allow)
152
+ return obj;
153
+ const key = parseStr();
154
+ skipBlank();
155
+ index++;
156
+ try {
157
+ const value = parseAny();
158
+ obj[key] = value;
159
+ } catch (e) {
160
+ if (options_1.Allow.OBJ & allow)
161
+ return obj;
162
+ else
163
+ throw e;
164
+ }
165
+ skipBlank();
166
+ if (jsonString[index] === ",")
167
+ index++;
168
+ }
169
+ } catch (e) {
170
+ if (options_1.Allow.OBJ & allow)
171
+ return obj;
172
+ else
173
+ markPartialJSON("Expected '}' at end of object");
174
+ }
175
+ index++;
176
+ return obj;
177
+ };
178
+ const parseArr = () => {
179
+ index++;
180
+ const arr = [];
181
+ try {
182
+ while (jsonString[index] !== "]") {
183
+ arr.push(parseAny());
184
+ skipBlank();
185
+ if (jsonString[index] === ",") {
186
+ index++;
187
+ }
188
+ }
189
+ } catch (e) {
190
+ if (options_1.Allow.ARR & allow) {
191
+ return arr;
192
+ }
193
+ markPartialJSON("Expected ']' at end of array");
194
+ }
195
+ index++;
196
+ return arr;
197
+ };
198
+ const parseNum = () => {
199
+ if (index === 0) {
200
+ if (jsonString === "-")
201
+ throwMalformedError("Not sure what '-' is");
202
+ try {
203
+ return JSON.parse(jsonString);
204
+ } catch (e) {
205
+ if (options_1.Allow.NUM & allow)
206
+ try {
207
+ return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf("e")));
208
+ } catch (e2) {
209
+ }
210
+ throwMalformedError(String(e));
211
+ }
212
+ }
213
+ const start = index;
214
+ if (jsonString[index] === "-")
215
+ index++;
216
+ while (jsonString[index] && ",]}".indexOf(jsonString[index]) === -1)
217
+ index++;
218
+ if (index == length && !(options_1.Allow.NUM & allow))
219
+ markPartialJSON("Unterminated number literal");
220
+ try {
221
+ return JSON.parse(jsonString.substring(start, index));
222
+ } catch (e) {
223
+ if (jsonString.substring(start, index) === "-")
224
+ markPartialJSON("Not sure what '-' is");
225
+ try {
226
+ return JSON.parse(jsonString.substring(start, jsonString.lastIndexOf("e")));
227
+ } catch (e2) {
228
+ throwMalformedError(String(e2));
229
+ }
230
+ }
231
+ };
232
+ const skipBlank = () => {
233
+ while (index < length && " \n\r ".includes(jsonString[index])) {
234
+ index++;
235
+ }
236
+ };
237
+ return parseAny();
238
+ };
239
+ var parse = parseJSON;
240
+ exports.parse = parse;
241
+ }
242
+ });
243
+
244
+ // ../../node_modules/@earendil-works/pi-ai/dist/utils/json-parse.js
245
+ var import_partial_json = __toESM(require_dist(), 1);
246
+ var VALID_JSON_ESCAPES = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t", "u"]);
247
+ function isControlCharacter(char) {
248
+ const codePoint = char.codePointAt(0);
249
+ return codePoint !== void 0 && codePoint >= 0 && codePoint <= 31;
250
+ }
251
+ function escapeControlCharacter(char) {
252
+ switch (char) {
253
+ case "\b":
254
+ return "\\b";
255
+ case "\f":
256
+ return "\\f";
257
+ case "\n":
258
+ return "\\n";
259
+ case "\r":
260
+ return "\\r";
261
+ case " ":
262
+ return "\\t";
263
+ default:
264
+ return `\\u${char.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
265
+ }
266
+ }
267
+ function repairJson(json) {
268
+ let repaired = "";
269
+ let inString = false;
270
+ for (let index = 0; index < json.length; index++) {
271
+ const char = json[index];
272
+ if (!inString) {
273
+ repaired += char;
274
+ if (char === '"') {
275
+ inString = true;
276
+ }
277
+ continue;
278
+ }
279
+ if (char === '"') {
280
+ repaired += char;
281
+ inString = false;
282
+ continue;
283
+ }
284
+ if (char === "\\") {
285
+ const nextChar = json[index + 1];
286
+ if (nextChar === void 0) {
287
+ repaired += "\\\\";
288
+ continue;
289
+ }
290
+ if (nextChar === "u") {
291
+ const unicodeDigits = json.slice(index + 2, index + 6);
292
+ if (/^[0-9a-fA-F]{4}$/.test(unicodeDigits)) {
293
+ repaired += `\\u${unicodeDigits}`;
294
+ index += 5;
295
+ continue;
296
+ }
297
+ }
298
+ if (VALID_JSON_ESCAPES.has(nextChar)) {
299
+ repaired += `\\${nextChar}`;
300
+ index += 1;
301
+ continue;
302
+ }
303
+ repaired += "\\\\";
304
+ continue;
305
+ }
306
+ repaired += isControlCharacter(char) ? escapeControlCharacter(char) : char;
307
+ }
308
+ return repaired;
309
+ }
310
+ function parseJsonWithRepair(json) {
311
+ try {
312
+ return JSON.parse(json);
313
+ } catch (error) {
314
+ const repairedJson = repairJson(json);
315
+ if (repairedJson !== json) {
316
+ return JSON.parse(repairedJson);
317
+ }
318
+ throw error;
319
+ }
320
+ }
321
+ function parseStreamingJson(partialJson) {
322
+ if (!partialJson || partialJson.trim() === "") {
323
+ return {};
324
+ }
325
+ try {
326
+ return parseJsonWithRepair(partialJson);
327
+ } catch {
328
+ try {
329
+ const result = (0, import_partial_json.parse)(partialJson);
330
+ return result ?? {};
331
+ } catch {
332
+ try {
333
+ const result = (0, import_partial_json.parse)(repairJson(partialJson));
334
+ return result ?? {};
335
+ } catch {
336
+ return {};
337
+ }
338
+ }
339
+ }
340
+ }
341
+
342
+ export {
343
+ parseJsonWithRepair,
344
+ parseStreamingJson
345
+ };
@@ -0,0 +1,2 @@
1
+ import { createRequire as __goahCreateRequire } from "node:module";
2
+ const require = __goahCreateRequire(import.meta.url);
@@ -0,0 +1,86 @@
1
+ import { createRequire as __goahCreateRequire } from "node:module";
2
+ const require = __goahCreateRequire(import.meta.url);
3
+
4
+ // ../../node_modules/@earendil-works/pi-ai/dist/utils/provider-retry.js
5
+ var DEFAULT_MAX_RETRY_DELAY_MS = 6e4;
6
+ function isProviderError(error) {
7
+ if (!(error instanceof Error) || !("status" in error) || !("headers" in error))
8
+ return false;
9
+ return (error.status === void 0 || typeof error.status === "number") && (error.headers === void 0 || error.headers instanceof Headers);
10
+ }
11
+ function isRetryableProviderError(error) {
12
+ const shouldRetry = error.headers?.get("x-should-retry");
13
+ if (shouldRetry === "true")
14
+ return true;
15
+ if (shouldRetry === "false")
16
+ return false;
17
+ if (error.status === void 0)
18
+ return true;
19
+ return error.status === 408 || error.status === 409 || error.status === 429 || typeof error.status === "number" && error.status >= 500;
20
+ }
21
+ function validateServerRetryDelayMs(delayMs, maxRetryDelayMs, providerErrorMessage) {
22
+ const maxDelayMs = maxRetryDelayMs ?? DEFAULT_MAX_RETRY_DELAY_MS;
23
+ if (maxDelayMs > 0 && delayMs > maxDelayMs) {
24
+ throw new Error(`Server requested ${Math.ceil(delayMs / 1e3)}s retry delay (max: ${Math.ceil(maxDelayMs / 1e3)}s). ${providerErrorMessage}`);
25
+ }
26
+ return delayMs;
27
+ }
28
+ function getRetryDelayMs(error, retryIndex, maxRetryDelayMs) {
29
+ const retryAfterMs = error.headers?.get("retry-after-ms");
30
+ if (retryAfterMs) {
31
+ const value = Number.parseFloat(retryAfterMs);
32
+ if (!Number.isNaN(value))
33
+ return validateServerRetryDelayMs(value, maxRetryDelayMs, error.message);
34
+ }
35
+ const retryAfter = error.headers?.get("retry-after");
36
+ if (retryAfter) {
37
+ const seconds = Number.parseFloat(retryAfter);
38
+ const delayMs = Number.isNaN(seconds) ? Date.parse(retryAfter) - Date.now() : seconds * 1e3;
39
+ return validateServerRetryDelayMs(delayMs, maxRetryDelayMs, error.message);
40
+ }
41
+ const exponentialDelay = Math.min(0.5 * 2 ** retryIndex, 8) * 1e3;
42
+ return exponentialDelay * (1 - Math.random() * 0.25);
43
+ }
44
+ function createAbortError() {
45
+ const error = new Error("Request aborted");
46
+ error.name = "AbortError";
47
+ return error;
48
+ }
49
+ function abortableSleep(ms, signal) {
50
+ return new Promise((resolve, reject) => {
51
+ if (signal?.aborted) {
52
+ reject(createAbortError());
53
+ return;
54
+ }
55
+ const onAbort = () => {
56
+ clearTimeout(timeout);
57
+ reject(createAbortError());
58
+ };
59
+ const timeout = setTimeout(() => {
60
+ signal?.removeEventListener("abort", onAbort);
61
+ resolve();
62
+ }, Math.max(0, ms));
63
+ signal?.addEventListener("abort", onAbort, { once: true });
64
+ });
65
+ }
66
+ async function retryProviderRequest(request, options = {}) {
67
+ const maxRetries = options.maxRetries ?? 0;
68
+ let retriesRemaining = maxRetries;
69
+ for (; ; ) {
70
+ try {
71
+ return await request();
72
+ } catch (error) {
73
+ if (options.signal?.aborted)
74
+ throw createAbortError();
75
+ if (retriesRemaining <= 0 || !isProviderError(error) || !isRetryableProviderError(error))
76
+ throw error;
77
+ const retryIndex = maxRetries - retriesRemaining;
78
+ retriesRemaining--;
79
+ await abortableSleep(getRetryDelayMs(error, retryIndex, options.maxRetryDelayMs), options.signal);
80
+ }
81
+ }
82
+ }
83
+
84
+ export {
85
+ retryProviderRequest
86
+ };
@@ -0,0 +1,20 @@
1
+ import { createRequire as __goahCreateRequire } from "node:module";
2
+ const require = __goahCreateRequire(import.meta.url);
3
+
4
+ // ../../node_modules/@earendil-works/pi-ai/dist/utils/hash.js
5
+ function shortHash(str) {
6
+ let h1 = 3735928559;
7
+ let h2 = 1103547991;
8
+ for (let i = 0; i < str.length; i++) {
9
+ const ch = str.charCodeAt(i);
10
+ h1 = Math.imul(h1 ^ ch, 2654435761);
11
+ h2 = Math.imul(h2 ^ ch, 1597334677);
12
+ }
13
+ h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
14
+ h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
15
+ return (h2 >>> 0).toString(36) + (h1 >>> 0).toString(36);
16
+ }
17
+
18
+ export {
19
+ shortHash
20
+ };