@aippy/runtime 0.4.1-dev.1 → 0.4.2-beta.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 (45) hide show
  1. package/README.md +35 -6
  2. package/dist/ai/errors.d.ts +1 -0
  3. package/dist/ai/index.d.ts +2 -0
  4. package/dist/ai/index.js +22 -17
  5. package/dist/ai/viggle/generate.d.ts +67 -0
  6. package/dist/ai/viggle/models.d.ts +46 -0
  7. package/dist/ai/viggle/recovery.d.ts +12 -0
  8. package/dist/{app-version-checker-Bz7FrEZz.js → app-version-checker-YVIFbytA.js} +18 -17
  9. package/dist/bridge-K3HqQwdj.js +311 -0
  10. package/dist/container-message-gRiGPin4.js +56 -0
  11. package/dist/core/env.d.ts +2 -0
  12. package/dist/core/index.js +2 -2
  13. package/dist/core/parent-message.d.ts +5 -0
  14. package/dist/core/wallet-recharge.d.ts +16 -0
  15. package/dist/helper-CJ3YV3nf.js +748 -0
  16. package/dist/{hooks-D5lkty5r.js → hooks-CMKwSLcQ.js} +1 -1
  17. package/dist/index/index.js +66 -56
  18. package/dist/index.d.ts +1 -0
  19. package/dist/ministore/app-authorization.d.ts +9 -0
  20. package/dist/ministore/authorization.d.ts +6 -0
  21. package/dist/ministore/consume.d.ts +3 -0
  22. package/dist/ministore/errors.d.ts +18 -0
  23. package/dist/ministore/index.d.ts +19 -0
  24. package/dist/ministore/index.js +99 -0
  25. package/dist/ministore/order.d.ts +1 -0
  26. package/dist/ministore/purchase.d.ts +5 -0
  27. package/dist/ministore/queries.d.ts +14 -0
  28. package/dist/ministore/recharge.d.ts +12 -0
  29. package/dist/ministore/transport.d.ts +14 -0
  30. package/dist/ministore/types.d.ts +177 -0
  31. package/dist/ministore/update-item.d.ts +3 -0
  32. package/dist/ministore/validation.d.ts +19 -0
  33. package/dist/ministore.d.ts +2 -0
  34. package/dist/recharge-o5P-y8eV.js +1036 -0
  35. package/dist/tweaks/index.js +1 -1
  36. package/dist/{useTweaks-v5wEZGGm.js → useTweaks-C7BEMpV3.js} +21 -27
  37. package/dist/user/bridge.d.ts +3 -8
  38. package/dist/user/config.d.ts +2 -0
  39. package/dist/user/index.js +3 -3
  40. package/dist/utils/app-version-requirements.json.d.ts +4 -0
  41. package/dist/utils/index.js +1 -1
  42. package/package.json +15 -3
  43. package/dist/bridge-CtB9L5kL.js +0 -259
  44. package/dist/container-message-KgL1paGV.js +0 -56
  45. package/dist/helper-CZqFi-QF.js +0 -241
@@ -1,241 +0,0 @@
1
- import { createOpenAICompatible as d } from "@ai-sdk/openai-compatible";
2
- import { r as f } from "./bridge-CtB9L5kL.js";
3
- import { s as m, a as b } from "./container-message-KgL1paGV.js";
4
- import { AISDKError as c, DefaultChatTransport as h } from "ai";
5
- import { E as g, b as p, a as u } from "./errors-B3bDbQbD.js";
6
- import { j as A } from "./url-c26cuIpu.js";
7
- const j = `${f()}/aisdk/v1/`, x = `${f()}/aisdk/v1/ui/`, I = "gpt-5-nano", v = "";
8
- function w(o = {}) {
9
- return {
10
- baseUrl: o.baseUrl ?? `${f()}/aisdk/v1/`
11
- };
12
- }
13
- function C(o = {}) {
14
- return {
15
- baseUrl: o.baseUrl ?? `${f()}/aisdk/v1/ui/`
16
- };
17
- }
18
- function O(o, e) {
19
- const r = o.status;
20
- if (e && typeof e == "object" && "error" in e) {
21
- const t = e, n = t.error.code, s = n != null ? `AippyAIError_${n}` : `AippyAIError_${r}`, a = e;
22
- return "appMessage" in a && a.appMessage !== void 0 && m(a.appMessage), new c({
23
- name: s,
24
- message: `${g.RUNTIME} ${t.error.message}`,
25
- cause: {
26
- type: t.error.type ?? void 0,
27
- param: t.error.param ?? void 0,
28
- status: r
29
- }
30
- });
31
- }
32
- if (e && typeof e == "object" && e !== null) {
33
- const t = e;
34
- "appMessage" in t && t.appMessage !== void 0 && m(t.appMessage);
35
- }
36
- return new c({
37
- name: `AippyAIError_${r}`,
38
- message: `${g.RUNTIME} Request failed with status ${r}`,
39
- cause: { status: r }
40
- });
41
- }
42
- function l() {
43
- return async (o, e) => {
44
- const r = await b(e?.headers), t = await globalThis.fetch(o, { ...e, headers: r });
45
- if (!t.ok) {
46
- const n = await t.text().catch(() => null);
47
- let s = null;
48
- if (n)
49
- try {
50
- s = JSON.parse(n);
51
- } catch {
52
- s = { message: n };
53
- }
54
- throw O(t, s);
55
- }
56
- return t;
57
- };
58
- }
59
- const E = [
60
- "gpt-image-1",
61
- "gpt-image-1-mini",
62
- "gpt-image-1.5"
63
- ];
64
- function _(o) {
65
- try {
66
- const e = JSON.parse(o);
67
- if (e.model && E.some((r) => e.model.startsWith(r))) {
68
- const { response_format: r, ...t } = e;
69
- return JSON.stringify(t);
70
- }
71
- } catch {
72
- }
73
- return o;
74
- }
75
- function J(o = {}) {
76
- const { baseUrl: e } = w(o), r = l();
77
- return d({
78
- name: "aippy",
79
- baseURL: e,
80
- fetch: async (n, s) => n.toString().includes("/images/generations") && s?.method?.toUpperCase() === "POST" && s?.body ? r(n, {
81
- ...s,
82
- body: _(s.body)
83
- }) : r(n, s),
84
- // Enable structured outputs support (json_schema response format)
85
- // This is required for Output.object() and Output.array() to work properly
86
- supportsStructuredOutputs: !0
87
- });
88
- }
89
- const S = "/chat";
90
- function B(o = {}) {
91
- const { baseUrl: e } = C(o), r = o.model ?? I, t = o.system ?? v, n = o.api ?? A(e, S), s = { model: r, system: t }, a = l();
92
- return {
93
- transport: new h({
94
- api: n,
95
- body: s,
96
- // Ensure token is fetched fresh for every request
97
- fetch: a
98
- })
99
- };
100
- }
101
- function y(o) {
102
- const e = [];
103
- if (!o || typeof o != "object")
104
- throw p("AIConfig must be an object", u.INVALID_CONFIG);
105
- const r = o;
106
- for (const [t, n] of Object.entries(r)) {
107
- if (!n || typeof n != "object") {
108
- e.push({ key: t, message: "Item must be an object" });
109
- continue;
110
- }
111
- const s = n;
112
- typeof s.index != "number" && e.push({ key: t, message: "index must be a number" }), typeof s.name != "string" && e.push({ key: t, message: "name must be a string" }), typeof s.description != "string" && e.push({ key: t, message: "description must be a string" });
113
- const a = s.type;
114
- if (!["number", "boolean", "text", "enum"].includes(a)) {
115
- e.push({
116
- key: t,
117
- message: `type must be one of: number, boolean, text, enum (got: ${a})`
118
- });
119
- continue;
120
- }
121
- if (a === "number")
122
- typeof s.value != "number" && e.push({ key: t, message: 'value must be a number for type "number"' }), s.min !== void 0 && typeof s.min != "number" && e.push({ key: t, message: "min must be a number" }), s.max !== void 0 && typeof s.max != "number" && e.push({ key: t, message: "max must be a number" }), s.step !== void 0 && typeof s.step != "number" && e.push({ key: t, message: "step must be a number" });
123
- else if (a === "boolean")
124
- typeof s.value != "boolean" && e.push({ key: t, message: 'value must be a boolean for type "boolean"' });
125
- else if (a === "text")
126
- typeof s.value != "string" && e.push({ key: t, message: 'value must be a string for type "text"' });
127
- else if (a === "enum") {
128
- if (!Array.isArray(s.options))
129
- e.push({ key: t, message: 'options must be an array for type "enum"' });
130
- else if (s.options.length === 0)
131
- e.push({ key: t, message: 'options array cannot be empty for type "enum"' });
132
- else
133
- for (let i = 0; i < s.options.length; i++)
134
- typeof s.options[i] != "string" && e.push({
135
- key: t,
136
- message: `options[${i}] must be a string`
137
- });
138
- typeof s.value != "string" ? e.push({ key: t, message: 'value must be a string for type "enum"' }) : Array.isArray(s.options) && !s.options.includes(s.value) && e.push({
139
- key: t,
140
- message: `value "${s.value}" is not in options: [${s.options.join(", ")}]`
141
- });
142
- }
143
- s.group !== void 0 && typeof s.group != "string" && e.push({ key: t, message: "group must be a string" });
144
- }
145
- if (e.length > 0)
146
- throw p(
147
- `AIConfig validation failed with ${e.length} error(s)`,
148
- u.INVALID_CONFIG,
149
- { errors: e }
150
- );
151
- }
152
- function H(o) {
153
- let e;
154
- try {
155
- e = JSON.parse(o);
156
- } catch (r) {
157
- throw p(
158
- `Invalid JSON: ${r instanceof Error ? r.message : String(r)}`,
159
- u.INVALID_CONFIG
160
- );
161
- }
162
- return y(e), e;
163
- }
164
- function U(o) {
165
- return y(o), o;
166
- }
167
- function N(o, e) {
168
- const r = o[e];
169
- if (!r)
170
- throw p(
171
- `AIConfig key "${e}" not found`,
172
- u.INVALID_CONFIG,
173
- { key: e }
174
- );
175
- return r.value;
176
- }
177
- function T(o) {
178
- if (!(typeof window > "u"))
179
- try {
180
- const e = window.webkit?.messageHandlers?.aippyListener;
181
- if (e)
182
- try {
183
- const r = {
184
- command: "ai.initialize",
185
- parameters: JSON.stringify(o)
186
- };
187
- e.postMessage(r);
188
- } catch (r) {
189
- console.warn("❌ [Aippy AI Config] Failed to send config to iOS app:", r);
190
- }
191
- if (window.parent && window.parent !== window)
192
- try {
193
- const r = {
194
- type: "ai.initialize",
195
- config: JSON.stringify(o)
196
- };
197
- window.parent.postMessage(r, "*");
198
- } catch (r) {
199
- console.warn("❌ [Aippy AI Config] Failed to send config to parent window:", r);
200
- }
201
- } catch (e) {
202
- console.warn("⚠️ [Aippy AI Config] Failed to send config:", e);
203
- }
204
- }
205
- function P(o) {
206
- const e = U(o);
207
- return T(e), new Proxy({}, {
208
- get(r, t) {
209
- if (typeof t == "string")
210
- try {
211
- return N(e, t);
212
- } catch {
213
- return;
214
- }
215
- },
216
- has(r, t) {
217
- return typeof t != "string" ? !1 : t in e;
218
- },
219
- ownKeys(r) {
220
- return Object.keys(e);
221
- }
222
- });
223
- }
224
- export {
225
- j as D,
226
- S as U,
227
- J as a,
228
- B as b,
229
- x as c,
230
- I as d,
231
- v as e,
232
- C as f,
233
- N as g,
234
- P as h,
235
- U as l,
236
- O as n,
237
- H as p,
238
- w as r,
239
- T as s,
240
- y as v
241
- };