@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.
@@ -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 l } from "@ai-sdk/openai-compatible";
2
- import { s as u, a as y } from "./container-message-WJolNXso.js";
3
- import { AISDKError as f, DefaultChatTransport as d } from "ai";
4
- import { j as h } from "./url-c26cuIpu.js";
5
- const c = "https://api.aippy.dev", b = `${c}/aisdk/v1/`, A = `${c}/aisdk/v1/ui/`, w = "gpt-5-nano", v = "";
6
- function I(n = {}) {
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 ?? b
9
+ baseUrl: n.baseUrl ?? I
9
10
  };
10
11
  }
11
- function C(n = {}) {
12
+ function _(n = {}) {
12
13
  return {
13
- baseUrl: n.baseUrl ?? A
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 && u(a.appMessage), new f({
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 && u(t.appMessage);
33
+ "appMessage" in t && t.appMessage !== void 0 && f(t.appMessage);
33
34
  }
34
- return new f({
35
+ return new c({
35
36
  name: `AippyAIError_${r}`,
36
- message: `Request failed with status ${r}`,
37
+ message: `${m.RUNTIME} Request failed with status ${r}`,
37
38
  cause: { status: r }
38
39
  });
39
40
  }
40
- function m() {
41
+ function l() {
41
42
  return async (n, e) => {
42
- const r = await y(e?.headers), t = await globalThis.fetch(n, { ...e, headers: r });
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 O(n) {
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 L(n = {}) {
74
- const { baseUrl: e } = I(n), r = m();
75
- return l({
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: O(s.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 _ = "/chat";
88
- function N(n = {}) {
89
- const { baseUrl: e } = C(n), r = n.model ?? w, t = n.system ?? v, o = n.api ?? h(e, _), s = { model: r, system: t }, a = m();
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 d({
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
- class p extends Error {
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 new p("AIConfig must be an object", []);
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 new p(
145
+ throw p(
150
146
  `AIConfig validation failed with ${e.length} error(s)`,
151
- e
147
+ u.INVALID_CONFIG,
148
+ { errors: e }
152
149
  );
153
150
  }
154
- function D(n) {
151
+ function P(n) {
155
152
  let e;
156
153
  try {
157
154
  e = JSON.parse(n);
158
155
  } catch (r) {
159
- throw new p("Invalid JSON", [
160
- {
161
- key: "",
162
- message: `JSON parse error: ${r instanceof Error ? r.message : String(r)}`
163
- }
164
- ]);
156
+ throw p(
157
+ `Invalid JSON: ${r instanceof Error ? r.message : String(r)}`,
158
+ u.INVALID_CONFIG
159
+ );
165
160
  }
166
- return g(e), e;
161
+ return y(e), e;
167
162
  }
168
- function U(n) {
169
- return g(n), n;
163
+ function T(n) {
164
+ return y(n), n;
170
165
  }
171
- function T(n, e) {
166
+ function F(n, e) {
172
167
  const r = n[e];
173
168
  if (!r)
174
- throw new Error(`AIConfig key "${e}" not found`);
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 x(n) {
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 J(n) {
206
- const e = U(n);
207
- return x(e), new Proxy({}, {
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 T(e, t);
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
- p as A,
226
- b as D,
227
- _ as U,
228
- L as a,
229
- N as b,
230
- A as c,
231
- w as d,
232
- v as e,
233
- J as f,
234
- T as g,
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
- D as p,
238
- x as s,
239
- g as v
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-BKcAlLAd.js"), { hasNativeBridge: f } = await import("./native-bridge-BnvipFJc.js"), i = f(), l = t();
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,
@@ -1,91 +1,92 @@
1
- import { D as o, g as r, m as s } from "../config-B0A7gHQM.js";
2
- import { A as i, E as n, c as p } from "../errors-CDEBaBxB.js";
3
- import { S as m, V as f, c, a as u, g as C, s as g } from "../container-message-WJolNXso.js";
4
- import { A as I, C as d, R as E, a as S, p as x } from "../runtime-CmoG3v2m.js";
5
- import { CameraAPI as D, FileSystemAPI as U, GeolocationAPI as _, SensorsAPI as y, camera as R, fileSystem as F, geolocation as M, isMotionSupported as P, isOrientationSupported as h, requestMotionPermission as v, sensors as O, vibrate as L, watchMotion as b, watchOrientation as V } from "../device/index.js";
6
- import { P as H, a as N, c as k, b as q, g as B, i as j, p as G, r as z, s as K } from "../app-version-checker-GLONqMxq.js";
7
- import { a as Y, P as J, p as Q, b as X } from "../pwa-CilSlaik.js";
8
- import { j as $ } from "../url-c26cuIpu.js";
9
- import { a as ae, b as oe } from "../useTweaks-QxMRmg7i.js";
10
- import { c as se, a as te, i as ie, p as ne, u as pe } from "../useAudioContext-D9F3x80Y.js";
11
- import { reportScore as me, sendEvent as fe, updateScore as ce } from "../leaderboard/index.js";
12
- import { A as Ce, D as ge, d as le, e as Ie, c as de, U as Ee, a as Se, b as xe, f as Te, g as De, l as Ue, n as _e, p as ye, s as Re, v as Fe } from "../helper-yKJ_6uB-.js";
13
- import { c as Pe, u as he } from "../hooks-DgadJdiM.js";
14
- import { getAuthTokenAsync as Oe } from "../bridge-BKcAlLAd.js";
15
- import { hasNativeBridge as be } from "../native-bridge-BnvipFJc.js";
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
- Ce as AIConfigValidationError,
18
- I as AippyRuntime,
17
+ l as AippyRuntime,
19
18
  i as AippyRuntimeError,
20
19
  D as CameraAPI,
21
- d as Cancellable,
20
+ S as Cancellable,
22
21
  ge as DEFAULT_BASE_URL,
23
- le as DEFAULT_CHAT_MODEL,
24
- Ie as DEFAULT_CHAT_SYSTEM,
25
- o as DEFAULT_CONFIG,
26
- de as DEFAULT_UI_BASE_URL,
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
- _ as GeolocationAPI,
30
- Y as PWAUtils,
31
- J as PerformanceMonitor,
32
- H as PlatformDetector,
33
- E as ReceiveChannel,
34
- m as SDK_NAME,
35
- y as SensorsAPI,
36
- Ee as UI_CHAT_ENDPOINT,
37
- f as VERSION,
38
- Se as aippyAIProvider,
39
- xe as aippyChatConfig,
40
- S as aippyRuntime,
41
- ae as aippyTweaks,
42
- oe as aippyTweaksRuntime,
43
- R as camera,
44
- N as checkFeatureSupport,
45
- Pe as clearUserInfoCache,
46
- k as compareVersions,
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
- c as createAippyHeaders,
49
- u as createAippyHeadersAsync,
50
- p as createError,
51
- se as createHiddenMediaElement,
52
- F as fileSystem,
53
- M as geolocation,
54
- De as getAIConfigValue,
55
- Oe as getAuthTokenAsync,
56
- q as getAvailableFeatures,
57
- r as getConfigFromEnv,
58
- B as getFeatureVersionRequirements,
59
- C as getVersionInfo,
60
- be as hasNativeBridge,
61
- te as isIOSDevice,
62
- j as isInIframe,
63
- ie as isMediaStreamAudioSupported,
64
- P as isMotionSupported,
65
- h as isOrientationSupported,
66
- $ as joinUrl,
67
- Ue as loadAIConfig,
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
- _e as normalizeError,
70
+ Ue as normalizeError,
70
71
  ye as parseAIConfig,
71
- ne as patchAudioContext,
72
- Q as performanceMonitor,
73
- G as platform,
74
- x as processMotionData,
75
- X as pwa,
76
- me as reportScore,
77
- v as requestMotionPermission,
78
- z as requireFeatureSupport,
79
- Re as sendAIConfigToContainer,
80
- fe as sendEvent,
81
- g as sendMessageToContainer,
82
- O as sensors,
83
- K as showAlert,
84
- ce as updateScore,
85
- pe as useAudioContext,
86
- he as useUserInfo,
87
- Fe as validateAIConfig,
88
- L as vibrate,
89
- b as watchMotion,
90
- V as watchOrientation
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
  };