@aippy/runtime 0.2.7-dev.6 → 0.2.7-dev.8
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.
- package/dist/ai/config/index.d.ts +1 -1
- package/dist/ai/config/parser.d.ts +5 -12
- package/dist/ai/errors.d.ts +1 -0
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.js +15 -16
- package/dist/{app-version-checker-GLONqMxq.js → app-version-checker-Bz7FrEZz.js} +70 -52
- package/dist/{bridge-BKcAlLAd.js → bridge-CqV1iP30.js} +51 -51
- package/dist/{container-message-WJolNXso.js → container-message-C14NWxTG.js} +2 -2
- package/dist/core/errors.d.ts +22 -3
- package/dist/core/index.js +14 -12
- package/dist/device/index.js +194 -194
- package/dist/errors-B3bDbQbD.js +40 -0
- package/dist/{helper-yKJ_6uB-.js → helper-CCP_kta2.js} +63 -65
- package/dist/{hooks-DgadJdiM.js → hooks-Dmr_Dcnz.js} +1 -1
- package/dist/index/index.js +82 -81
- package/dist/pwa-C5nXU0DN.js +250 -0
- package/dist/tweaks/index.js +1 -1
- package/dist/{useTweaks-QxMRmg7i.js → useTweaks-B7Muzo78.js} +10 -9
- package/dist/user/index.js +3 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/ui.d.ts +3 -1
- package/package.json +1 -1
- package/dist/errors-CDEBaBxB.js +0 -26
- package/dist/pwa-CilSlaik.js +0 -249
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var _ = Object.defineProperty;
|
|
2
|
+
var s = (E, R, O) => R in E ? _(E, R, { enumerable: !0, configurable: !0, writable: !0, value: O }) : E[R] = O;
|
|
3
|
+
var r = (E, R, O) => s(E, typeof R != "symbol" ? R + "" : R, O);
|
|
4
|
+
const N = {
|
|
5
|
+
RUNTIME: "[Aippy Runtime]",
|
|
6
|
+
// 运行时错误,不上报 LLM
|
|
7
|
+
CODE: "[Aippy Error]"
|
|
8
|
+
// 代码相关错误,上报 LLM
|
|
9
|
+
};
|
|
10
|
+
class t extends Error {
|
|
11
|
+
constructor(O, n = "AIPPY_ERROR", o, I = N.RUNTIME) {
|
|
12
|
+
super(`${I} ${O}`);
|
|
13
|
+
r(this, "code");
|
|
14
|
+
r(this, "context");
|
|
15
|
+
r(this, "prefix");
|
|
16
|
+
this.name = "AippyRuntimeError", this.code = n, this.context = o, this.prefix = I;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const e = {
|
|
20
|
+
NOT_SUPPORTED: "NOT_SUPPORTED",
|
|
21
|
+
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
22
|
+
INVALID_CONFIG: "INVALID_CONFIG",
|
|
23
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
24
|
+
TIMEOUT: "TIMEOUT",
|
|
25
|
+
OPERATION_FAILED: "OPERATION_FAILED",
|
|
26
|
+
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
27
|
+
};
|
|
28
|
+
function c(E, R = "UNKNOWN_ERROR", O) {
|
|
29
|
+
return new t(E, e[R], O, N.RUNTIME);
|
|
30
|
+
}
|
|
31
|
+
function i(E, R = "INVALID_CONFIG", O) {
|
|
32
|
+
return new t(E, e[R], O, N.CODE);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
t as A,
|
|
36
|
+
N as E,
|
|
37
|
+
e as a,
|
|
38
|
+
i as b,
|
|
39
|
+
c
|
|
40
|
+
};
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { createOpenAICompatible as
|
|
2
|
-
import { s as
|
|
3
|
-
import { AISDKError as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { createOpenAICompatible as d } from "@ai-sdk/openai-compatible";
|
|
2
|
+
import { s as f, a as b } from "./container-message-C14NWxTG.js";
|
|
3
|
+
import { AISDKError as c, DefaultChatTransport as h } from "ai";
|
|
4
|
+
import { E as m, b as p, a as u } from "./errors-B3bDbQbD.js";
|
|
5
|
+
import { j as A } from "./url-c26cuIpu.js";
|
|
6
|
+
const g = "https://api.aippy.dev", I = `${g}/aisdk/v1/`, w = `${g}/aisdk/v1/ui/`, v = "gpt-5-nano", C = "";
|
|
7
|
+
function O(n = {}) {
|
|
7
8
|
return {
|
|
8
|
-
baseUrl: n.baseUrl ??
|
|
9
|
+
baseUrl: n.baseUrl ?? I
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function _(n = {}) {
|
|
12
13
|
return {
|
|
13
|
-
baseUrl: n.baseUrl ??
|
|
14
|
+
baseUrl: n.baseUrl ?? w
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
function E(n, e) {
|
|
17
18
|
const r = n.status;
|
|
18
19
|
if (e && typeof e == "object" && "error" in e) {
|
|
19
20
|
const t = e, o = t.error.code, s = o != null ? `AippyAIError_${o}` : `AippyAIError_${r}`, a = e;
|
|
20
|
-
return "appMessage" in a && a.appMessage !== void 0 &&
|
|
21
|
+
return "appMessage" in a && a.appMessage !== void 0 && f(a.appMessage), new c({
|
|
21
22
|
name: s,
|
|
22
|
-
message: t.error.message
|
|
23
|
+
message: `${m.RUNTIME} ${t.error.message}`,
|
|
23
24
|
cause: {
|
|
24
25
|
type: t.error.type ?? void 0,
|
|
25
26
|
param: t.error.param ?? void 0,
|
|
@@ -29,17 +30,17 @@ function E(n, e) {
|
|
|
29
30
|
}
|
|
30
31
|
if (e && typeof e == "object" && e !== null) {
|
|
31
32
|
const t = e;
|
|
32
|
-
"appMessage" in t && t.appMessage !== void 0 &&
|
|
33
|
+
"appMessage" in t && t.appMessage !== void 0 && f(t.appMessage);
|
|
33
34
|
}
|
|
34
|
-
return new
|
|
35
|
+
return new c({
|
|
35
36
|
name: `AippyAIError_${r}`,
|
|
36
|
-
message:
|
|
37
|
+
message: `${m.RUNTIME} Request failed with status ${r}`,
|
|
37
38
|
cause: { status: r }
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
|
-
function
|
|
41
|
+
function l() {
|
|
41
42
|
return async (n, e) => {
|
|
42
|
-
const r = await
|
|
43
|
+
const r = await b(e?.headers), t = await globalThis.fetch(n, { ...e, headers: r });
|
|
43
44
|
if (!t.ok) {
|
|
44
45
|
const o = await t.text().catch(() => null);
|
|
45
46
|
let s = null;
|
|
@@ -59,7 +60,7 @@ const S = [
|
|
|
59
60
|
"gpt-image-1-mini",
|
|
60
61
|
"gpt-image-1.5"
|
|
61
62
|
];
|
|
62
|
-
function
|
|
63
|
+
function U(n) {
|
|
63
64
|
try {
|
|
64
65
|
const e = JSON.parse(n);
|
|
65
66
|
if (e.model && S.some((r) => e.model.startsWith(r))) {
|
|
@@ -70,25 +71,25 @@ function O(n) {
|
|
|
70
71
|
}
|
|
71
72
|
return n;
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
-
const { baseUrl: e } =
|
|
75
|
-
return
|
|
74
|
+
function x(n = {}) {
|
|
75
|
+
const { baseUrl: e } = O(n), r = l();
|
|
76
|
+
return d({
|
|
76
77
|
name: "aippy",
|
|
77
78
|
baseURL: e,
|
|
78
79
|
fetch: async (o, s) => o.toString().includes("/images/generations") && s?.method?.toUpperCase() === "POST" && s?.body ? r(o, {
|
|
79
80
|
...s,
|
|
80
|
-
body:
|
|
81
|
+
body: U(s.body)
|
|
81
82
|
}) : r(o, s),
|
|
82
83
|
// Enable structured outputs support (json_schema response format)
|
|
83
84
|
// This is required for Output.object() and Output.array() to work properly
|
|
84
85
|
supportsStructuredOutputs: !0
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
|
-
const
|
|
88
|
-
function
|
|
89
|
-
const { baseUrl: e } =
|
|
88
|
+
const N = "/chat";
|
|
89
|
+
function J(n = {}) {
|
|
90
|
+
const { baseUrl: e } = _(n), r = n.model ?? v, t = n.system ?? C, o = n.api ?? A(e, N), s = { model: r, system: t }, a = l();
|
|
90
91
|
return {
|
|
91
|
-
transport: new
|
|
92
|
+
transport: new h({
|
|
92
93
|
api: o,
|
|
93
94
|
body: s,
|
|
94
95
|
// Ensure token is fetched fresh for every request
|
|
@@ -96,15 +97,10 @@ function N(n = {}) {
|
|
|
96
97
|
})
|
|
97
98
|
};
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
-
constructor(e, r) {
|
|
101
|
-
super(e), this.errors = r, this.name = "AIConfigValidationError";
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function g(n) {
|
|
100
|
+
function y(n) {
|
|
105
101
|
const e = [];
|
|
106
102
|
if (!n || typeof n != "object")
|
|
107
|
-
throw
|
|
103
|
+
throw p("AIConfig must be an object", u.INVALID_CONFIG);
|
|
108
104
|
const r = n;
|
|
109
105
|
for (const [t, o] of Object.entries(r)) {
|
|
110
106
|
if (!o || typeof o != "object") {
|
|
@@ -146,35 +142,38 @@ function g(n) {
|
|
|
146
142
|
s.group !== void 0 && typeof s.group != "string" && e.push({ key: t, message: "group must be a string" });
|
|
147
143
|
}
|
|
148
144
|
if (e.length > 0)
|
|
149
|
-
throw
|
|
145
|
+
throw p(
|
|
150
146
|
`AIConfig validation failed with ${e.length} error(s)`,
|
|
151
|
-
|
|
147
|
+
u.INVALID_CONFIG,
|
|
148
|
+
{ errors: e }
|
|
152
149
|
);
|
|
153
150
|
}
|
|
154
|
-
function
|
|
151
|
+
function P(n) {
|
|
155
152
|
let e;
|
|
156
153
|
try {
|
|
157
154
|
e = JSON.parse(n);
|
|
158
155
|
} catch (r) {
|
|
159
|
-
throw
|
|
160
|
-
{
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
164
|
-
]);
|
|
156
|
+
throw p(
|
|
157
|
+
`Invalid JSON: ${r instanceof Error ? r.message : String(r)}`,
|
|
158
|
+
u.INVALID_CONFIG
|
|
159
|
+
);
|
|
165
160
|
}
|
|
166
|
-
return
|
|
161
|
+
return y(e), e;
|
|
167
162
|
}
|
|
168
|
-
function
|
|
169
|
-
return
|
|
163
|
+
function T(n) {
|
|
164
|
+
return y(n), n;
|
|
170
165
|
}
|
|
171
|
-
function
|
|
166
|
+
function F(n, e) {
|
|
172
167
|
const r = n[e];
|
|
173
168
|
if (!r)
|
|
174
|
-
throw
|
|
169
|
+
throw p(
|
|
170
|
+
`AIConfig key "${e}" not found`,
|
|
171
|
+
u.INVALID_CONFIG,
|
|
172
|
+
{ key: e }
|
|
173
|
+
);
|
|
175
174
|
return r.value;
|
|
176
175
|
}
|
|
177
|
-
function
|
|
176
|
+
function R(n) {
|
|
178
177
|
if (!(typeof window > "u"))
|
|
179
178
|
try {
|
|
180
179
|
const e = window.webkit?.messageHandlers?.aippyListener;
|
|
@@ -202,13 +201,13 @@ function x(n) {
|
|
|
202
201
|
console.warn("⚠️ [Aippy AI Config] Failed to send config:", e);
|
|
203
202
|
}
|
|
204
203
|
}
|
|
205
|
-
function
|
|
206
|
-
const e =
|
|
207
|
-
return
|
|
204
|
+
function B(n) {
|
|
205
|
+
const e = T(n);
|
|
206
|
+
return R(e), new Proxy({}, {
|
|
208
207
|
get(r, t) {
|
|
209
208
|
if (typeof t == "string")
|
|
210
209
|
try {
|
|
211
|
-
return
|
|
210
|
+
return F(e, t);
|
|
212
211
|
} catch {
|
|
213
212
|
return;
|
|
214
213
|
}
|
|
@@ -222,19 +221,18 @@ function J(n) {
|
|
|
222
221
|
});
|
|
223
222
|
}
|
|
224
223
|
export {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
T as
|
|
235
|
-
U as l,
|
|
224
|
+
I as D,
|
|
225
|
+
N as U,
|
|
226
|
+
x as a,
|
|
227
|
+
J as b,
|
|
228
|
+
w as c,
|
|
229
|
+
v as d,
|
|
230
|
+
C as e,
|
|
231
|
+
B as f,
|
|
232
|
+
F as g,
|
|
233
|
+
T as l,
|
|
236
234
|
E as n,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
235
|
+
P as p,
|
|
236
|
+
R as s,
|
|
237
|
+
y as v
|
|
240
238
|
};
|
|
@@ -15,7 +15,7 @@ async function v() {
|
|
|
15
15
|
console.log("🔍 [useUserInfo] fetchUserInfoFromBridge started");
|
|
16
16
|
const n = A();
|
|
17
17
|
try {
|
|
18
|
-
const { getUserInfoAsync: o, getUserInfoFromParent: c, isInIframe: t } = await import("./bridge-
|
|
18
|
+
const { getUserInfoAsync: o, getUserInfoFromParent: c, isInIframe: t } = await import("./bridge-CqV1iP30.js"), { hasNativeBridge: f } = await import("./native-bridge-BnvipFJc.js"), i = f(), l = t();
|
|
19
19
|
console.log("🔍 [useUserInfo] Environment check:", {
|
|
20
20
|
hasNativeBridge: i,
|
|
21
21
|
isInIframe: l,
|
package/dist/index/index.js
CHANGED
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
import { D as
|
|
2
|
-
import { A as i,
|
|
3
|
-
import { S as
|
|
4
|
-
import { A as
|
|
5
|
-
import { CameraAPI as D, FileSystemAPI as U, GeolocationAPI as
|
|
6
|
-
import { P as
|
|
7
|
-
import { a as
|
|
8
|
-
import { j as
|
|
9
|
-
import { a as
|
|
10
|
-
import { c as
|
|
11
|
-
import { reportScore as
|
|
12
|
-
import {
|
|
13
|
-
import { c as
|
|
14
|
-
import { getAuthTokenAsync as
|
|
15
|
-
import { hasNativeBridge as
|
|
1
|
+
import { D as r, g as o, m as s } from "../config-B0A7gHQM.js";
|
|
2
|
+
import { A as i, a as n, E as p, b as m, c as A } from "../errors-B3bDbQbD.js";
|
|
3
|
+
import { S as f, V as u, c as C, a as E, g, s as I } from "../container-message-C14NWxTG.js";
|
|
4
|
+
import { A as l, C as S, R as x, a as R, p as T } from "../runtime-CmoG3v2m.js";
|
|
5
|
+
import { CameraAPI as D, FileSystemAPI as U, GeolocationAPI as y, SensorsAPI as F, camera as P, fileSystem as M, geolocation as h, isMotionSupported as v, isOrientationSupported as O, requestMotionPermission as b, sensors as L, vibrate as w, watchMotion as H, watchOrientation as N } from "../device/index.js";
|
|
6
|
+
import { P as k, a as q, c as B, b as j, g as G, i as z, p as K, r as W, s as X } from "../app-version-checker-Bz7FrEZz.js";
|
|
7
|
+
import { a as J, P as Q, p as Z, b as $ } from "../pwa-C5nXU0DN.js";
|
|
8
|
+
import { j as ae } from "../url-c26cuIpu.js";
|
|
9
|
+
import { a as oe, b as se } from "../useTweaks-B7Muzo78.js";
|
|
10
|
+
import { c as ie, a as ne, i as pe, p as me, u as Ae } from "../useAudioContext-D9F3x80Y.js";
|
|
11
|
+
import { reportScore as fe, sendEvent as ue, updateScore as Ce } from "../leaderboard/index.js";
|
|
12
|
+
import { D as ge, d as Ie, e as de, c as le, U as Se, a as xe, b as Re, f as Te, g as _e, l as De, n as Ue, p as ye, s as Fe, v as Pe } from "../helper-CCP_kta2.js";
|
|
13
|
+
import { c as he, u as ve } from "../hooks-Dmr_Dcnz.js";
|
|
14
|
+
import { getAuthTokenAsync as be } from "../bridge-CqV1iP30.js";
|
|
15
|
+
import { hasNativeBridge as we } from "../native-bridge-BnvipFJc.js";
|
|
16
16
|
export {
|
|
17
|
-
|
|
18
|
-
I as AippyRuntime,
|
|
17
|
+
l as AippyRuntime,
|
|
19
18
|
i as AippyRuntimeError,
|
|
20
19
|
D as CameraAPI,
|
|
21
|
-
|
|
20
|
+
S as Cancellable,
|
|
22
21
|
ge as DEFAULT_BASE_URL,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
Ie as DEFAULT_CHAT_MODEL,
|
|
23
|
+
de as DEFAULT_CHAT_SYSTEM,
|
|
24
|
+
r as DEFAULT_CONFIG,
|
|
25
|
+
le as DEFAULT_UI_BASE_URL,
|
|
27
26
|
n as ERROR_CODES,
|
|
27
|
+
p as ERROR_PREFIX,
|
|
28
28
|
U as FileSystemAPI,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
y as GeolocationAPI,
|
|
30
|
+
J as PWAUtils,
|
|
31
|
+
Q as PerformanceMonitor,
|
|
32
|
+
k as PlatformDetector,
|
|
33
|
+
x as ReceiveChannel,
|
|
34
|
+
f as SDK_NAME,
|
|
35
|
+
F as SensorsAPI,
|
|
36
|
+
Se as UI_CHAT_ENDPOINT,
|
|
37
|
+
u as VERSION,
|
|
38
|
+
xe as aippyAIProvider,
|
|
39
|
+
Re as aippyChatConfig,
|
|
40
|
+
R as aippyRuntime,
|
|
41
|
+
oe as aippyTweaks,
|
|
42
|
+
se as aippyTweaksRuntime,
|
|
43
|
+
P as camera,
|
|
44
|
+
q as checkFeatureSupport,
|
|
45
|
+
he as clearUserInfoCache,
|
|
46
|
+
B as compareVersions,
|
|
47
47
|
Te as createAIConfig,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
M as
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
C as createAippyHeaders,
|
|
49
|
+
E as createAippyHeadersAsync,
|
|
50
|
+
m as createCodeError,
|
|
51
|
+
A as createError,
|
|
52
|
+
ie as createHiddenMediaElement,
|
|
53
|
+
M as fileSystem,
|
|
54
|
+
h as geolocation,
|
|
55
|
+
_e as getAIConfigValue,
|
|
56
|
+
be as getAuthTokenAsync,
|
|
57
|
+
j as getAvailableFeatures,
|
|
58
|
+
o as getConfigFromEnv,
|
|
59
|
+
G as getFeatureVersionRequirements,
|
|
60
|
+
g as getVersionInfo,
|
|
61
|
+
we as hasNativeBridge,
|
|
62
|
+
ne as isIOSDevice,
|
|
63
|
+
z as isInIframe,
|
|
64
|
+
pe as isMediaStreamAudioSupported,
|
|
65
|
+
v as isMotionSupported,
|
|
66
|
+
O as isOrientationSupported,
|
|
67
|
+
ae as joinUrl,
|
|
68
|
+
De as loadAIConfig,
|
|
68
69
|
s as mergeConfig,
|
|
69
|
-
|
|
70
|
+
Ue as normalizeError,
|
|
70
71
|
ye as parseAIConfig,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
me as patchAudioContext,
|
|
73
|
+
Z as performanceMonitor,
|
|
74
|
+
K as platform,
|
|
75
|
+
T as processMotionData,
|
|
76
|
+
$ as pwa,
|
|
77
|
+
fe as reportScore,
|
|
78
|
+
b as requestMotionPermission,
|
|
79
|
+
W as requireFeatureSupport,
|
|
80
|
+
Fe as sendAIConfigToContainer,
|
|
81
|
+
ue as sendEvent,
|
|
82
|
+
I as sendMessageToContainer,
|
|
83
|
+
L as sensors,
|
|
84
|
+
X as showAlert,
|
|
85
|
+
Ce as updateScore,
|
|
86
|
+
Ae as useAudioContext,
|
|
87
|
+
ve as useUserInfo,
|
|
88
|
+
Pe as validateAIConfig,
|
|
89
|
+
w as vibrate,
|
|
90
|
+
H as watchMotion,
|
|
91
|
+
N as watchOrientation
|
|
91
92
|
};
|