ugly-app 0.1.120 → 0.1.122

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.
@@ -1,2 +1,2 @@
1
- export declare const CLI_VERSION = "0.1.120";
1
+ export declare const CLI_VERSION = "0.1.122";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Auto-generated by prebuild — do not edit manually
2
- export const CLI_VERSION = "0.1.120";
2
+ export const CLI_VERSION = "0.1.122";
3
3
  //# sourceMappingURL=version.js.map
@@ -1,5 +1,5 @@
1
1
  import type { ImageGenInput, JsonGenInput, TextGenInput } from '../shared/index.js';
2
- export declare const callTextGen: (input: TextGenInput) => Promise<string>;
3
- export declare const callJsonGen: <T = unknown>(input: JsonGenInput) => Promise<T>;
4
- export declare const callImageGen: (input: ImageGenInput) => Promise<string>;
2
+ export declare function callTextGen(input: TextGenInput): Promise<string>;
3
+ export declare function callJsonGen<T = unknown>(input: JsonGenInput): Promise<T>;
4
+ export declare function callImageGen(input: ImageGenInput): Promise<string>;
5
5
  //# sourceMappingURL=callAI.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"callAI.d.ts","sourceRoot":"","sources":["../../src/client/callAI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACb,MAAM,oBAAoB,CAAC;AA0B5B,eAAO,MAAM,WAAW,GAAI,OAAO,YAAY,KAAG,OAAO,CAAC,MAAM,CACd,CAAC;AAEnD,eAAO,MAAM,WAAW,GAAI,CAAC,GAAG,OAAO,EAAE,OAAO,YAAY,KAAG,OAAO,CAAC,CAAC,CAC3B,CAAC;AAE9C,eAAO,MAAM,YAAY,GAAI,OAAO,aAAa,KAAG,OAAO,CAAC,MAAM,CACf,CAAC"}
1
+ {"version":3,"file":"callAI.d.ts","sourceRoot":"","sources":["../../src/client/callAI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACb,MAAM,oBAAoB,CAAC;AAsB5B,wBAAsB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAOtE;AAED,wBAAsB,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAO9E;AAED,wBAAsB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAUxE"}
@@ -14,13 +14,28 @@ async function callUglyBot(op, input) {
14
14
  throw new Error(`${res.status}: ${body}`);
15
15
  }
16
16
  const json = (await res.json());
17
- if (json.error)
18
- throw new Error(json.error);
19
- if (json.result === undefined)
20
- throw new Error(`AI request returned no result — response: ${JSON.stringify(json)}`);
21
- return json.result;
17
+ if (json['error'])
18
+ throw new Error(json['error']);
19
+ return json;
20
+ }
21
+ export async function callTextGen(input) {
22
+ const res = (await callUglyBot('textGen', input));
23
+ if (!res.message?.content)
24
+ throw new Error(`textGen returned no content — response: ${JSON.stringify(res)}`);
25
+ return res.message.content;
26
+ }
27
+ export async function callJsonGen(input) {
28
+ const res = (await callUglyBot('jsonGen', input));
29
+ if (!res.message?.content)
30
+ throw new Error(`jsonGen returned no content — response: ${JSON.stringify(res)}`);
31
+ return JSON.parse(res.message.content);
32
+ }
33
+ export async function callImageGen(input) {
34
+ const res = (await callUglyBot('imageGen', input));
35
+ if (res.url)
36
+ return res.url;
37
+ if (res.base64)
38
+ return `data:${res.mime ?? 'image/png'};base64,${res.base64}`;
39
+ throw new Error(`imageGen returned no image — response: ${JSON.stringify(res)}`);
22
40
  }
23
- export const callTextGen = (input) => callUglyBot('textGen', input);
24
- export const callJsonGen = (input) => callUglyBot('jsonGen', input);
25
- export const callImageGen = (input) => callUglyBot('imageGen', input);
26
41
  //# sourceMappingURL=callAI.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"callAI.js","sourceRoot":"","sources":["../../src/client/callAI.ts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vB,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpF,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;AAC7B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAAc,KAAmB;IAChE,MAAM,GAAG,GAAG,CAAC,MAAM,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAE/C,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO;QACvB,MAAM,IAAI,KAAK,CAAC,2CAA2C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACpF,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAM,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAoB;IACrD,MAAM,GAAG,GAAG,CAAC,MAAM,WAAW,CAAC,UAAU,EAAE,KAAK,CAAC,CAIhD,CAAC;IACF,IAAI,GAAG,CAAC,GAAG;QAAE,OAAO,GAAG,CAAC,GAAG,CAAC;IAC5B,IAAI,GAAG,CAAC,MAAM;QACZ,OAAO,QAAQ,GAAG,CAAC,IAAI,IAAI,WAAW,WAAW,GAAG,CAAC,MAAM,EAAE,CAAC;IAChE,MAAM,IAAI,KAAK,CAAC,0CAA0C,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACnF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ugly-app",
3
- "version": "0.1.120",
3
+ "version": "0.1.122",
4
4
  "type": "module",
5
5
  "main": "./dist/server/index.js",
6
6
  "exports": {
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by prebuild — do not edit manually
2
- export const CLI_VERSION = "0.1.120";
2
+ export const CLI_VERSION = "0.1.122";
@@ -19,20 +19,37 @@ async function callUglyBot(op: string, input: unknown): Promise<unknown> {
19
19
  const body = await res.text().catch(() => '');
20
20
  throw new Error(`${res.status}: ${body}`);
21
21
  }
22
- const json = (await res.json()) as { result?: unknown; error?: string };
23
- if (json.error) throw new Error(json.error);
24
- if (json.result === undefined)
25
- throw new Error(
26
- `AI request returned no result — response: ${JSON.stringify(json)}`,
27
- );
28
- return json.result;
22
+ const json = (await res.json()) as Record<string, unknown>;
23
+ if (json['error']) throw new Error(json['error'] as string);
24
+ return json;
29
25
  }
30
26
 
31
- export const callTextGen = (input: TextGenInput): Promise<string> =>
32
- callUglyBot('textGen', input) as Promise<string>;
27
+ export async function callTextGen(input: TextGenInput): Promise<string> {
28
+ const res = (await callUglyBot('textGen', input)) as {
29
+ message?: { role: string; content: string };
30
+ };
31
+ if (!res.message?.content)
32
+ throw new Error(`textGen returned no content — response: ${JSON.stringify(res)}`);
33
+ return res.message.content;
34
+ }
33
35
 
34
- export const callJsonGen = <T = unknown>(input: JsonGenInput): Promise<T> =>
35
- callUglyBot('jsonGen', input) as Promise<T>;
36
+ export async function callJsonGen<T = unknown>(input: JsonGenInput): Promise<T> {
37
+ const res = (await callUglyBot('jsonGen', input)) as {
38
+ message?: { role: string; content: string };
39
+ };
40
+ if (!res.message?.content)
41
+ throw new Error(`jsonGen returned no content — response: ${JSON.stringify(res)}`);
42
+ return JSON.parse(res.message.content) as T;
43
+ }
36
44
 
37
- export const callImageGen = (input: ImageGenInput): Promise<string> =>
38
- callUglyBot('imageGen', input) as Promise<string>;
45
+ export async function callImageGen(input: ImageGenInput): Promise<string> {
46
+ const res = (await callUglyBot('imageGen', input)) as {
47
+ url?: string;
48
+ base64?: string;
49
+ mime?: string;
50
+ };
51
+ if (res.url) return res.url;
52
+ if (res.base64)
53
+ return `data:${res.mime ?? 'image/png'};base64,${res.base64}`;
54
+ throw new Error(`imageGen returned no image — response: ${JSON.stringify(res)}`);
55
+ }