qarpeo 0.1.12 → 0.1.14
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/README.md +7 -13
- package/dist/chunks/auth-schema.mjs +119 -147
- package/dist/chunks/wrangler.mjs +1 -1
- package/dist/cli/index.mjs +2 -2
- package/dist/module.mjs +146 -38
- package/dist/runtime/ai.d.ts +4 -2
- package/dist/runtime/ai.mjs +8 -2
- package/dist/runtime/app/components/FileUpload.vue +5 -5
- package/dist/runtime/app/composables/ai.d.ts +74 -0
- package/dist/runtime/app/composables/ai.mjs +148 -0
- package/dist/runtime/app/composables/auth.d.ts +16 -1
- package/dist/runtime/app/composables/auth.mjs +23 -34
- package/dist/runtime/app/composables/storage.d.ts +47 -2
- package/dist/runtime/app/composables/storage.mjs +204 -1
- package/dist/runtime/app/composables/void-client.d.ts +3 -0
- package/dist/runtime/app/composables/void-client.mjs +4 -0
- package/dist/runtime/blob.mjs +1 -1
- package/dist/runtime/db.mjs +1 -1
- package/dist/runtime/server/routes/agents/[agent]/history.get.d.ts +1 -1
- package/dist/runtime/server/routes/auth/handler.d.ts +2 -0
- package/dist/runtime/server/routes/auth/handler.mjs +11 -0
- package/dist/runtime/server/utils/auth.d.ts +66 -0
- package/dist/runtime/server/utils/auth.mjs +58 -0
- package/dist/runtime/server/utils/realtime.mjs +1 -1
- package/dist/runtime/server/utils/storage.d.ts +29 -0
- package/dist/runtime/server/utils/storage.mjs +79 -0
- package/dist/runtime/server/utils/void-ai.d.ts +7 -0
- package/dist/runtime/server/utils/void-ai.mjs +47 -0
- package/dist/runtime/server/utils/void-auth.d.ts +2 -0
- package/dist/runtime/server/utils/void-auth.mjs +9 -0
- package/dist/runtime/server/utils/void-db.d.ts +8 -0
- package/dist/runtime/server/utils/void-db.mjs +38 -0
- package/dist/runtime/server/utils/void-seed.d.ts +11 -0
- package/dist/runtime/server/utils/void-seed.mjs +3 -0
- package/dist/runtime/types/ai.d.ts +2 -0
- package/dist/runtime/types/imports.d.ts +65 -6
- package/dist/types.d.ts +1 -1
- package/dist/utils/auth-schema.d.ts +3 -5
- package/package.json +3 -2
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import { defineNuxtModule, useLogger, createResolver, addTemplate, addComponent, hasNuxtModule, installModule, addNitroPlugin, addImports, addServerImports, addTypeTemplate, updateTemplates, addServerImportsDir, addServerHandler, addRouteMiddleware, addPlugin, extendPages } from '@nuxt/kit';
|
|
5
5
|
import { defu } from 'defu';
|
|
6
6
|
import { join, resolve, extname, basename, dirname, normalize, relative } from 'pathe';
|
|
7
|
-
import { c as createWranglerConfig, r as
|
|
7
|
+
import { c as createWranglerConfig, r as resolveProjectName, a as resolveBindingName, b as checkDrizzleVersion, s as scanSchemaExports, f as findQueueFiles, d as findJobFiles, g as generateDevWranglerConfig, e as applyD1Migrations, h as findSchemaFiles } from './chunks/wrangler.mjs';
|
|
8
8
|
import { generateAuthSchema } from './chunks/auth-schema.mjs';
|
|
9
9
|
export { getActiveAuthTableNames } from './chunks/auth-schema.mjs';
|
|
10
10
|
import { createHash } from 'node:crypto';
|
|
@@ -19,7 +19,7 @@ import 'drizzle-orm/node-sqlite';
|
|
|
19
19
|
import 'node:process';
|
|
20
20
|
import 'node:readline/promises';
|
|
21
21
|
|
|
22
|
-
const version = "0.1.
|
|
22
|
+
const version = "0.1.14";
|
|
23
23
|
|
|
24
24
|
function ensureDevEnv(rootDir) {
|
|
25
25
|
const envPath = join(rootDir, ".env");
|
|
@@ -1226,6 +1226,12 @@ ${extraSources}
|
|
|
1226
1226
|
nuxt.options.alias["#qarpeo/notifications"] = resolver.resolve("./runtime/server/utils/notifications");
|
|
1227
1227
|
nuxt.options.alias["qarpeo/vapid"] = resolver.resolve("./runtime/server/utils/vapid");
|
|
1228
1228
|
nuxt.options.alias["#qarpeo/vapid"] = resolver.resolve("./runtime/server/utils/vapid");
|
|
1229
|
+
nuxt.options.alias["void/db"] = resolver.resolve("./runtime/server/utils/void-db");
|
|
1230
|
+
nuxt.options.alias["void/seed"] = resolver.resolve("./runtime/server/utils/void-seed");
|
|
1231
|
+
nuxt.options.alias["void/auth"] = resolver.resolve("./runtime/server/utils/void-auth");
|
|
1232
|
+
nuxt.options.alias["void/ai"] = resolver.resolve("./runtime/server/utils/void-ai");
|
|
1233
|
+
nuxt.options.alias["void/client/vue"] = resolver.resolve("./runtime/app/composables/void-client");
|
|
1234
|
+
nuxt.options.alias["void/client"] = resolver.resolve("./runtime/app/composables/void-client");
|
|
1229
1235
|
const emptyAgentsTemplate = addTemplate({
|
|
1230
1236
|
filename: "qarpeo/agents-empty.mjs",
|
|
1231
1237
|
write: true,
|
|
@@ -1271,9 +1277,12 @@ ${extraSources}
|
|
|
1271
1277
|
const drizzleSeedDir = resolvePkgDir("drizzle-seed");
|
|
1272
1278
|
nuxt.options.alias["drizzle-seed"] = drizzleSeedDir;
|
|
1273
1279
|
nuxt.options.alias["drizzle-seed/"] = `${drizzleSeedDir}/`;
|
|
1274
|
-
const
|
|
1275
|
-
nuxt.options.alias["
|
|
1276
|
-
nuxt.options.alias["
|
|
1280
|
+
const betterAuthDir = resolvePkgDir("better-auth");
|
|
1281
|
+
nuxt.options.alias["better-auth/vue"] = resolve(betterAuthDir, "dist/client/vue/index.mjs");
|
|
1282
|
+
nuxt.options.alias["better-auth/client"] = resolve(betterAuthDir, "dist/client/index.mjs");
|
|
1283
|
+
nuxt.options.alias["better-auth"] = resolve(betterAuthDir, "dist/index.mjs");
|
|
1284
|
+
const betterAuthAdapterDir = resolvePkgDir("@better-auth/drizzle-adapter");
|
|
1285
|
+
nuxt.options.alias["@better-auth/drizzle-adapter"] = resolve(betterAuthAdapterDir, "dist/index.mjs");
|
|
1277
1286
|
const comarkNuxtDir = resolvePkgDir("@comark/nuxt");
|
|
1278
1287
|
nuxt.options.alias["@comark/nuxt/utils"] = resolve(comarkNuxtDir, "dist/utils/index.js");
|
|
1279
1288
|
nuxt.options.alias["@comark/nuxt/render"] = resolve(comarkNuxtDir, "dist/render.js");
|
|
@@ -1367,7 +1376,9 @@ ${extraSources}
|
|
|
1367
1376
|
"@shikijs/engine-javascript",
|
|
1368
1377
|
"@shikijs/langs",
|
|
1369
1378
|
"@shikijs/themes",
|
|
1370
|
-
"@shikijs/vscode-textmate"
|
|
1379
|
+
"@shikijs/vscode-textmate",
|
|
1380
|
+
"better-auth",
|
|
1381
|
+
"@better-auth/drizzle-adapter"
|
|
1371
1382
|
);
|
|
1372
1383
|
nuxt.options.vite = nuxt.options.vite || {};
|
|
1373
1384
|
nuxt.options.vite.optimizeDeps = nuxt.options.vite.optimizeDeps || {};
|
|
@@ -1423,15 +1434,6 @@ ${extraSources}
|
|
|
1423
1434
|
if (webAuthnEnabled) {
|
|
1424
1435
|
nuxt.options.auth = defu(nuxt.options.auth || {}, { webAuthn: true });
|
|
1425
1436
|
}
|
|
1426
|
-
if (!hasNuxtModule("nuxt-auth-utils")) {
|
|
1427
|
-
const authModuleOptions = webAuthnEnabled ? { webAuthn: true } : {};
|
|
1428
|
-
try {
|
|
1429
|
-
const authModulePath = fileURLToPath(import.meta.resolve("nuxt-auth-utils"));
|
|
1430
|
-
await installModule(authModulePath, authModuleOptions);
|
|
1431
|
-
} catch {
|
|
1432
|
-
await installModule("nuxt-auth-utils", authModuleOptions);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
1437
|
}
|
|
1436
1438
|
if (options.cms && !hasNuxtModule("@comark/nuxt")) {
|
|
1437
1439
|
try {
|
|
@@ -1486,6 +1488,51 @@ ${extraSources}
|
|
|
1486
1488
|
const configPath = resolve(nuxt.options.buildDir, "wrangler.json");
|
|
1487
1489
|
process.env.QARPEO_WRANGLER_CONFIG = configPath;
|
|
1488
1490
|
process.env.QARPEO_PERSIST_PATH = resolve(nuxt.options.rootDir, ".wrangler/state/v3");
|
|
1491
|
+
nuxt.hook("ready", async () => {
|
|
1492
|
+
try {
|
|
1493
|
+
const { existsSync: existsSync2, mkdirSync, writeFileSync } = await import('node:fs');
|
|
1494
|
+
const voidDir = resolve(nuxt.options.rootDir, ".void");
|
|
1495
|
+
if (!existsSync2(voidDir)) {
|
|
1496
|
+
mkdirSync(voidDir, { recursive: true });
|
|
1497
|
+
}
|
|
1498
|
+
const inferenceImports = [
|
|
1499
|
+
"// Auto-generated by Qarpeo for Void Resource Inference",
|
|
1500
|
+
"// Triggers Void (void.cloud) to provision Cloudflare bindings automatically"
|
|
1501
|
+
];
|
|
1502
|
+
if (options.db) inferenceImports.push('import { db } from "void/db"');
|
|
1503
|
+
if (options.kv) inferenceImports.push('import { kv } from "void/kv"');
|
|
1504
|
+
if (options.blob) inferenceImports.push('import { storage } from "void/storage"');
|
|
1505
|
+
if (options.ai) inferenceImports.push('import { ai } from "void/ai"');
|
|
1506
|
+
if (options.realtime) inferenceImports.push('import { defineLiveStream } from "void/live"');
|
|
1507
|
+
if (options.queue) inferenceImports.push('import { queues } from "void/queues"');
|
|
1508
|
+
writeFileSync(resolve(voidDir, "inference.ts"), inferenceImports.join("\n") + "\n", "utf-8");
|
|
1509
|
+
if (options.auth) {
|
|
1510
|
+
writeFileSync(
|
|
1511
|
+
resolve(voidDir, "better-auth-schema.ts"),
|
|
1512
|
+
generateAuthSchema(options.auth),
|
|
1513
|
+
"utf-8"
|
|
1514
|
+
);
|
|
1515
|
+
}
|
|
1516
|
+
const voidConfigPath = resolve(nuxt.options.rootDir, "void.config.ts");
|
|
1517
|
+
if (!existsSync2(voidConfigPath)) {
|
|
1518
|
+
const projectName = resolveProjectName(nuxt, options);
|
|
1519
|
+
const voidConfigContent = [
|
|
1520
|
+
'import { defineConfig } from "void/config"',
|
|
1521
|
+
"",
|
|
1522
|
+
"export default defineConfig({",
|
|
1523
|
+
" cloudflare: {",
|
|
1524
|
+
` name: "${projectName}",`,
|
|
1525
|
+
' compatibility_date: "2026-02-24",',
|
|
1526
|
+
' compatibility_flags: ["nodejs_compat", "nodejs_als"],',
|
|
1527
|
+
" },",
|
|
1528
|
+
"})",
|
|
1529
|
+
""
|
|
1530
|
+
].join("\n");
|
|
1531
|
+
writeFileSync(voidConfigPath, voidConfigContent, "utf-8");
|
|
1532
|
+
}
|
|
1533
|
+
} catch {
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1489
1536
|
if (options.remote) {
|
|
1490
1537
|
process.env.QARPEO_CF_REMOTE = "1";
|
|
1491
1538
|
const hasAccountId = process.env.CLOUDFLARE_ACCOUNT_ID || process.env.CF_ACCOUNT_ID;
|
|
@@ -1765,6 +1812,7 @@ export default queueHandler;
|
|
|
1765
1812
|
});
|
|
1766
1813
|
schemaTemplateDst = template.dst;
|
|
1767
1814
|
nuxt.options.alias["#qarpeo/schema"] = schemaTemplateDst;
|
|
1815
|
+
nuxt.options.alias["@schema"] = schemaTemplateDst;
|
|
1768
1816
|
const typesTemplate = addTemplate({
|
|
1769
1817
|
filename: "qarpeo/db-types.ts",
|
|
1770
1818
|
write: true,
|
|
@@ -1895,12 +1943,19 @@ export default queueHandler;
|
|
|
1895
1943
|
const drizzleSeedDir = resolvePkgDir("drizzle-seed");
|
|
1896
1944
|
nitroConfig.alias["drizzle-seed"] = drizzleSeedDir;
|
|
1897
1945
|
nitroConfig.alias["drizzle-seed/"] = `${drizzleSeedDir}/`;
|
|
1898
|
-
const authUtilsDir = resolvePkgDir("nuxt-auth-utils");
|
|
1899
|
-
nitroConfig.alias["nuxt-auth-utils"] = authUtilsDir;
|
|
1900
|
-
nitroConfig.alias["nuxt-auth-utils/"] = `${authUtilsDir}/`;
|
|
1901
1946
|
const wranglerDir = resolvePkgDir("wrangler");
|
|
1902
1947
|
nitroConfig.alias["wrangler"] = wranglerDir;
|
|
1903
1948
|
nitroConfig.alias["wrangler/"] = `${wranglerDir}/`;
|
|
1949
|
+
const betterAuthDir = resolvePkgDir("better-auth");
|
|
1950
|
+
nitroConfig.alias["better-auth/vue"] = resolve(betterAuthDir, "dist/client/vue/index.mjs");
|
|
1951
|
+
nitroConfig.alias["better-auth/client"] = resolve(betterAuthDir, "dist/client/index.mjs");
|
|
1952
|
+
nitroConfig.alias["better-auth"] = resolve(betterAuthDir, "dist/index.mjs");
|
|
1953
|
+
const betterAuthAdapterDir = resolvePkgDir("@better-auth/drizzle-adapter");
|
|
1954
|
+
nitroConfig.alias["@better-auth/drizzle-adapter"] = resolve(betterAuthAdapterDir, "dist/index.mjs");
|
|
1955
|
+
nitroConfig.alias["void/db"] = resolver.resolve("./runtime/server/utils/void-db");
|
|
1956
|
+
nitroConfig.alias["void/seed"] = resolver.resolve("./runtime/server/utils/void-seed");
|
|
1957
|
+
nitroConfig.alias["void/auth"] = resolver.resolve("./runtime/server/utils/void-auth");
|
|
1958
|
+
nitroConfig.alias["void/ai"] = resolver.resolve("./runtime/server/utils/void-ai");
|
|
1904
1959
|
const comarkNuxtDir = resolvePkgDir("@comark/nuxt");
|
|
1905
1960
|
nitroConfig.alias["@comark/nuxt/utils"] = resolve(comarkNuxtDir, "dist/utils/index.js");
|
|
1906
1961
|
nitroConfig.alias["@comark/nuxt/render"] = resolve(comarkNuxtDir, "dist/render.js");
|
|
@@ -2085,6 +2140,7 @@ export default queueHandler;
|
|
|
2085
2140
|
if (isDrizzle && schemaTemplateDst) {
|
|
2086
2141
|
nitroConfig.alias = nitroConfig.alias || {};
|
|
2087
2142
|
nitroConfig.alias["#qarpeo/schema"] = schemaTemplateDst;
|
|
2143
|
+
nitroConfig.alias["@schema"] = schemaTemplateDst;
|
|
2088
2144
|
const typesAlias = nuxt.options.alias["#qarpeo/db/types"];
|
|
2089
2145
|
const zodAlias = nuxt.options.alias["#qarpeo/db/zod"];
|
|
2090
2146
|
if (typesAlias) {
|
|
@@ -2422,6 +2478,14 @@ export default queueHandler;
|
|
|
2422
2478
|
name: "schema",
|
|
2423
2479
|
from: resolver.resolve("./runtime/server/utils/drizzle")
|
|
2424
2480
|
},
|
|
2481
|
+
{
|
|
2482
|
+
name: "createDb",
|
|
2483
|
+
from: resolver.resolve("./runtime/server/utils/void-db")
|
|
2484
|
+
},
|
|
2485
|
+
{
|
|
2486
|
+
name: "defineSeed",
|
|
2487
|
+
from: resolver.resolve("./runtime/server/utils/void-seed")
|
|
2488
|
+
},
|
|
2425
2489
|
{
|
|
2426
2490
|
name: "useDB",
|
|
2427
2491
|
from: "qarpeo/runtime"
|
|
@@ -2505,6 +2569,16 @@ export default queueHandler;
|
|
|
2505
2569
|
]);
|
|
2506
2570
|
}
|
|
2507
2571
|
if (options.ai) {
|
|
2572
|
+
addImports([
|
|
2573
|
+
{
|
|
2574
|
+
name: "useAIStream",
|
|
2575
|
+
from: resolver.resolve("./runtime/app/composables/ai")
|
|
2576
|
+
},
|
|
2577
|
+
{
|
|
2578
|
+
name: "useVectorSearch",
|
|
2579
|
+
from: resolver.resolve("./runtime/app/composables/ai")
|
|
2580
|
+
}
|
|
2581
|
+
]);
|
|
2508
2582
|
addServerImports([
|
|
2509
2583
|
{
|
|
2510
2584
|
name: "ai",
|
|
@@ -2716,6 +2790,24 @@ export default queueHandler;
|
|
|
2716
2790
|
}
|
|
2717
2791
|
]);
|
|
2718
2792
|
}
|
|
2793
|
+
addImports([
|
|
2794
|
+
{
|
|
2795
|
+
name: "useUserSession",
|
|
2796
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2797
|
+
},
|
|
2798
|
+
{
|
|
2799
|
+
name: "useAuth",
|
|
2800
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2801
|
+
},
|
|
2802
|
+
{
|
|
2803
|
+
name: "useSession",
|
|
2804
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2805
|
+
},
|
|
2806
|
+
{
|
|
2807
|
+
name: "authClient",
|
|
2808
|
+
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2809
|
+
}
|
|
2810
|
+
]);
|
|
2719
2811
|
if (options.auth) {
|
|
2720
2812
|
const authConfig = typeof options.auth === "object" ? options.auth : {};
|
|
2721
2813
|
const authPrefix = authConfig.prefix || "/api/auth";
|
|
@@ -2753,6 +2845,10 @@ export default queueHandler;
|
|
|
2753
2845
|
path: resolver.resolve("./runtime/app/middleware/auth.global"),
|
|
2754
2846
|
global: true
|
|
2755
2847
|
});
|
|
2848
|
+
addServerHandler({
|
|
2849
|
+
route: `${authPrefix}/**`,
|
|
2850
|
+
handler: resolver.resolve("./runtime/server/routes/auth/handler")
|
|
2851
|
+
});
|
|
2756
2852
|
addServerHandler({
|
|
2757
2853
|
route: `${authPrefix}/user`,
|
|
2758
2854
|
handler: resolver.resolve("./runtime/server/routes/auth/user.get")
|
|
@@ -2923,10 +3019,6 @@ export default queueHandler;
|
|
|
2923
3019
|
handler: resolver.resolve("./runtime/server/routes/auth/organization/mfa.post")
|
|
2924
3020
|
});
|
|
2925
3021
|
addImports([
|
|
2926
|
-
{
|
|
2927
|
-
name: "useAuth",
|
|
2928
|
-
from: resolver.resolve("./runtime/app/composables/auth")
|
|
2929
|
-
},
|
|
2930
3022
|
{
|
|
2931
3023
|
name: "useOrganization",
|
|
2932
3024
|
from: resolver.resolve("./runtime/app/composables/organization")
|
|
@@ -2957,6 +3049,26 @@ export default queueHandler;
|
|
|
2957
3049
|
}
|
|
2958
3050
|
]);
|
|
2959
3051
|
addServerImports([
|
|
3052
|
+
{
|
|
3053
|
+
name: "serverAuth",
|
|
3054
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3055
|
+
},
|
|
3056
|
+
{
|
|
3057
|
+
name: "createAuth",
|
|
3058
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3059
|
+
},
|
|
3060
|
+
{
|
|
3061
|
+
name: "useServerAuth",
|
|
3062
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3063
|
+
},
|
|
3064
|
+
{
|
|
3065
|
+
name: "getServerSession",
|
|
3066
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3067
|
+
},
|
|
3068
|
+
{
|
|
3069
|
+
name: "requireServerSession",
|
|
3070
|
+
from: resolver.resolve("./runtime/server/utils/auth")
|
|
3071
|
+
},
|
|
2960
3072
|
{
|
|
2961
3073
|
name: "handleOAuthSuccess",
|
|
2962
3074
|
from: resolver.resolve("./runtime/server/utils/auth")
|
|
@@ -3195,14 +3307,6 @@ export default queueHandler;
|
|
|
3195
3307
|
images: blobConfig.images
|
|
3196
3308
|
};
|
|
3197
3309
|
publicConfig.qarpeo.storage = publicConfig.qarpeo.blob;
|
|
3198
|
-
addServerHandler({
|
|
3199
|
-
route: `${storagePrefix}/upload`,
|
|
3200
|
-
handler: resolver.resolve("./runtime/server/routes/storage/upload.post")
|
|
3201
|
-
});
|
|
3202
|
-
addServerHandler({
|
|
3203
|
-
route: `${storagePrefix}/presigned`,
|
|
3204
|
-
handler: resolver.resolve("./runtime/server/routes/storage/presigned.post")
|
|
3205
|
-
});
|
|
3206
3310
|
addServerHandler({
|
|
3207
3311
|
route: `${storagePrefix}/files`,
|
|
3208
3312
|
handler: resolver.resolve("./runtime/server/routes/storage/files.get")
|
|
@@ -3220,14 +3324,6 @@ export default queueHandler;
|
|
|
3220
3324
|
handler: resolver.resolve("./runtime/server/routes/storage/file/[...key].delete")
|
|
3221
3325
|
});
|
|
3222
3326
|
if (storagePrefix !== "/api/blob") {
|
|
3223
|
-
addServerHandler({
|
|
3224
|
-
route: "/api/blob/upload",
|
|
3225
|
-
handler: resolver.resolve("./runtime/server/routes/storage/upload.post")
|
|
3226
|
-
});
|
|
3227
|
-
addServerHandler({
|
|
3228
|
-
route: "/api/blob/presigned",
|
|
3229
|
-
handler: resolver.resolve("./runtime/server/routes/storage/presigned.post")
|
|
3230
|
-
});
|
|
3231
3327
|
addServerHandler({
|
|
3232
3328
|
route: "/api/blob/files",
|
|
3233
3329
|
handler: resolver.resolve("./runtime/server/routes/storage/files.get")
|
|
@@ -3272,6 +3368,10 @@ export default queueHandler;
|
|
|
3272
3368
|
filePath: resolver.resolve("./runtime/app/components/FileUpload")
|
|
3273
3369
|
});
|
|
3274
3370
|
addServerImports([
|
|
3371
|
+
{
|
|
3372
|
+
name: "handleUpload",
|
|
3373
|
+
from: resolver.resolve("./runtime/server/utils/storage")
|
|
3374
|
+
},
|
|
3275
3375
|
{
|
|
3276
3376
|
name: "uploadStorageFile",
|
|
3277
3377
|
from: resolver.resolve("./runtime/server/utils/storage")
|
|
@@ -4050,6 +4150,14 @@ export const manifestCollections = ${JSON.stringify(cmsConfig.collections || {})
|
|
|
4050
4150
|
{
|
|
4051
4151
|
name: "useAgentChat",
|
|
4052
4152
|
from: resolver.resolve("./runtime/app/composables/chat")
|
|
4153
|
+
},
|
|
4154
|
+
{
|
|
4155
|
+
name: "useAIStream",
|
|
4156
|
+
from: resolver.resolve("./runtime/app/composables/ai")
|
|
4157
|
+
},
|
|
4158
|
+
{
|
|
4159
|
+
name: "useVectorSearch",
|
|
4160
|
+
from: resolver.resolve("./runtime/app/composables/ai")
|
|
4053
4161
|
}
|
|
4054
4162
|
]);
|
|
4055
4163
|
addServerImports([
|
package/dist/runtime/ai.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AiBinding, QarpeoAI } from "./types/ai";
|
|
2
2
|
import type { CFEvent } from "./types/index";
|
|
3
|
-
import { generateImage, textToImage, generateSpeech, textToSpeech, transcribeAudio, speechToText, generateText, streamText, embedText } from "./server/utils/ai";
|
|
3
|
+
import { generateImage, textToImage, generateSpeech, textToSpeech, transcribeAudio, speechToText, generateText, streamText, embedText, similaritySearch } from "./server/utils/ai";
|
|
4
4
|
export type { AiBinding, AiOptions, QarpeoAI, GenerateImageOptions, GenerateImageResult, GenerateSpeechOptions, GenerateSpeechResult, TranscribeAudioInput, TranscribeAudioOptions, TranscribeAudioResult, StreamTextOptions, } from "./types/ai";
|
|
5
|
-
export { generateImage, textToImage, generateSpeech, textToSpeech, transcribeAudio, speechToText, generateText, streamText, embedText, };
|
|
5
|
+
export { generateImage, textToImage, generateSpeech, textToSpeech, transcribeAudio, speechToText, generateText, streamText, embedText, similaritySearch, };
|
|
6
6
|
/**
|
|
7
7
|
* Returns the raw Cloudflare Workers AI binding from the active environment.
|
|
8
8
|
*
|
|
@@ -23,3 +23,5 @@ export declare const useAI: (bindingName?: string, event?: CFEvent) => QarpeoAI;
|
|
|
23
23
|
export declare const ai: QarpeoAI;
|
|
24
24
|
export { useChat, useAgentChat } from "./app/composables/chat";
|
|
25
25
|
export type { UseChatOptions, UseAgentChatOptions } from "./app/composables/chat";
|
|
26
|
+
export { useAIStream, useVectorSearch } from "./app/composables/ai";
|
|
27
|
+
export type { UseAIStreamOptions, UseVectorSearchOptions } from "./app/composables/ai";
|
package/dist/runtime/ai.mjs
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
speechToText,
|
|
9
9
|
generateText,
|
|
10
10
|
streamText,
|
|
11
|
-
embedText
|
|
11
|
+
embedText,
|
|
12
|
+
similaritySearch
|
|
12
13
|
} from "./server/utils/ai.mjs";
|
|
13
14
|
export {
|
|
14
15
|
generateImage,
|
|
@@ -19,7 +20,8 @@ export {
|
|
|
19
20
|
speechToText,
|
|
20
21
|
generateText,
|
|
21
22
|
streamText,
|
|
22
|
-
embedText
|
|
23
|
+
embedText,
|
|
24
|
+
similaritySearch
|
|
23
25
|
};
|
|
24
26
|
export function getAIBinding(bindingName, event) {
|
|
25
27
|
const resolvedBinding = resolveRuntimeBinding("ai", bindingName, "AI");
|
|
@@ -86,6 +88,9 @@ export function createAI(bindingName, event) {
|
|
|
86
88
|
},
|
|
87
89
|
embed: (text, options) => {
|
|
88
90
|
return embedText(text, { binding: resolvedBinding, event, ...options });
|
|
91
|
+
},
|
|
92
|
+
similaritySearch: (indexName, query, options) => {
|
|
93
|
+
return similaritySearch(indexName, query, { binding: resolvedBinding, event, ...options });
|
|
89
94
|
}
|
|
90
95
|
};
|
|
91
96
|
}
|
|
@@ -104,3 +109,4 @@ export const ai = new Proxy({}, {
|
|
|
104
109
|
}
|
|
105
110
|
});
|
|
106
111
|
export { useChat, useAgentChat } from "./app/composables/chat.mjs";
|
|
112
|
+
export { useAIStream, useVectorSearch } from "./app/composables/ai.mjs";
|
|
@@ -17,18 +17,18 @@ const props = withDefaults(defineProps<{
|
|
|
17
17
|
disabled?: boolean
|
|
18
18
|
/** Automatically trigger upload immediately on file selection. */
|
|
19
19
|
autoUpload?: boolean
|
|
20
|
+
/** Target upload endpoint URL (e.g. '/api/avatars'). Defaults to '/api/upload'. */
|
|
21
|
+
url?: string
|
|
20
22
|
/** Uploaded file(s) v-model. */
|
|
21
23
|
modelValue?: UploadedFile | UploadedFile[] | null
|
|
22
|
-
/** Use presigned direct-to-R2 upload ticket. */
|
|
23
|
-
presigned?: boolean
|
|
24
24
|
/** Additional CSS class for the wrapper container. */
|
|
25
25
|
dropzoneClass?: string
|
|
26
26
|
}>(), {
|
|
27
|
+
url: "/api/upload",
|
|
27
28
|
multiple: false,
|
|
28
29
|
disabled: false,
|
|
29
30
|
autoUpload: true,
|
|
30
31
|
modelValue: null,
|
|
31
|
-
presigned: false,
|
|
32
32
|
dropzoneClass: "",
|
|
33
33
|
})
|
|
34
34
|
|
|
@@ -45,7 +45,7 @@ const inputRef = ref<HTMLInputElement | null>(null)
|
|
|
45
45
|
const isDragging = ref(false)
|
|
46
46
|
const clientError = ref<string | null>(null)
|
|
47
47
|
|
|
48
|
-
const { isUploading, progress, error, upload, uploadMultiple, reset } = useUpload()
|
|
48
|
+
const { isUploading, progress, error, upload, uploadMultiple, reset } = useUpload(() => props.url)
|
|
49
49
|
|
|
50
50
|
function open() {
|
|
51
51
|
if (props.disabled || isUploading.value) return
|
|
@@ -85,7 +85,7 @@ async function processFiles(files: FileList | File[]) {
|
|
|
85
85
|
emit("update:modelValue", results)
|
|
86
86
|
emit("success", results)
|
|
87
87
|
} else {
|
|
88
|
-
const result = await upload(fileList[0]
|
|
88
|
+
const result = await upload(fileList[0]!)
|
|
89
89
|
emit("update:modelValue", result)
|
|
90
90
|
emit("success", result)
|
|
91
91
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useChat, useAgentChat, type UseChatOptions, type UseAgentChatOptions } from "./chat";
|
|
2
|
+
export interface UseAIStreamOptions {
|
|
3
|
+
/** Target API endpoint. Defaults to "/api/ai/stream" */
|
|
4
|
+
api?: string;
|
|
5
|
+
/** Model identifier override */
|
|
6
|
+
model?: string;
|
|
7
|
+
/** System prompt override */
|
|
8
|
+
system?: string;
|
|
9
|
+
/** Model temperature override */
|
|
10
|
+
temperature?: number;
|
|
11
|
+
/** Callback fired for each streamed delta chunk */
|
|
12
|
+
onDelta?: (delta: string) => void;
|
|
13
|
+
/** Callback fired when streaming finishes */
|
|
14
|
+
onFinish?: (fullText: string) => void;
|
|
15
|
+
/** Callback fired on error */
|
|
16
|
+
onError?: (err: Error) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reactive composable for streaming text completions from Cloudflare Workers AI via SSE.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```vue
|
|
23
|
+
* <script setup>
|
|
24
|
+
* const { text, isStreaming, send, abort } = useAIStream()
|
|
25
|
+
* </script>
|
|
26
|
+
* <template>
|
|
27
|
+
* <button @click="send('Explain quantum physics')">Generate</button>
|
|
28
|
+
* <div v-if="isStreaming">Streaming...</div>
|
|
29
|
+
* <p>{{ text }}</p>
|
|
30
|
+
* </template>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function useAIStream(options?: UseAIStreamOptions): {
|
|
34
|
+
text: import("vue").Ref<string, string>;
|
|
35
|
+
isStreaming: import("vue").Ref<boolean, boolean>;
|
|
36
|
+
error: import("vue").Ref<Error | null, Error | null>;
|
|
37
|
+
send: (prompt: string, overrideOptions?: Partial<UseAIStreamOptions>) => Promise<string>;
|
|
38
|
+
abort: () => void;
|
|
39
|
+
reset: () => void;
|
|
40
|
+
};
|
|
41
|
+
export interface UseVectorSearchOptions {
|
|
42
|
+
/** Target API endpoint. Defaults to "/api/ai/search" */
|
|
43
|
+
api?: string;
|
|
44
|
+
/** Vector index name */
|
|
45
|
+
index?: string;
|
|
46
|
+
/** Number of results to return. Defaults to 5 */
|
|
47
|
+
topK?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reactive composable for vector similarity search via Cloudflare Vectorize.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```vue
|
|
54
|
+
* <script setup>
|
|
55
|
+
* const { results, isSearching, search } = useVectorSearch({ index: "articles" })
|
|
56
|
+
* </script>
|
|
57
|
+
* <template>
|
|
58
|
+
* <input @keydown.enter="search($event.target.value)" placeholder="Search semantic articles..." />
|
|
59
|
+
* <div v-if="isSearching">Searching...</div>
|
|
60
|
+
* <ul>
|
|
61
|
+
* <li v-for="res in results" :key="res.id">{{ res.metadata?.title || res.id }}</li>
|
|
62
|
+
* </ul>
|
|
63
|
+
* </template>
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function useVectorSearch<T = any>(options?: UseVectorSearchOptions): {
|
|
67
|
+
results: import("vue").Ref<any[], any[]>;
|
|
68
|
+
isSearching: import("vue").Ref<boolean, boolean>;
|
|
69
|
+
error: import("vue").Ref<Error | null, Error | null>;
|
|
70
|
+
search: (query: string, overrideOptions?: Partial<UseVectorSearchOptions>) => Promise<T[]>;
|
|
71
|
+
clear: () => void;
|
|
72
|
+
};
|
|
73
|
+
export { useChat, useAgentChat };
|
|
74
|
+
export type { UseChatOptions, UseAgentChatOptions };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { useChat, useAgentChat } from "./chat.mjs";
|
|
3
|
+
export function useAIStream(options = {}) {
|
|
4
|
+
const text = ref("");
|
|
5
|
+
const isStreaming = ref(false);
|
|
6
|
+
const error = ref(null);
|
|
7
|
+
let abortController = null;
|
|
8
|
+
const send = async (prompt, overrideOptions) => {
|
|
9
|
+
if (!prompt.trim() || isStreaming.value) return "";
|
|
10
|
+
text.value = "";
|
|
11
|
+
error.value = null;
|
|
12
|
+
isStreaming.value = true;
|
|
13
|
+
abortController = new AbortController();
|
|
14
|
+
const apiEndpoint = overrideOptions?.api || options.api || "/api/ai/stream";
|
|
15
|
+
const model = overrideOptions?.model || options.model;
|
|
16
|
+
const system = overrideOptions?.system || options.system;
|
|
17
|
+
const temperature = overrideOptions?.temperature ?? options.temperature;
|
|
18
|
+
try {
|
|
19
|
+
const res = await fetch(apiEndpoint, {
|
|
20
|
+
method: "POST",
|
|
21
|
+
headers: { "Content-Type": "application/json" },
|
|
22
|
+
body: JSON.stringify({ prompt, model, system, temperature }),
|
|
23
|
+
signal: abortController.signal
|
|
24
|
+
});
|
|
25
|
+
if (!res.ok) {
|
|
26
|
+
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
27
|
+
}
|
|
28
|
+
if (!res.body) {
|
|
29
|
+
throw new Error("No response body received");
|
|
30
|
+
}
|
|
31
|
+
const reader = res.body.getReader();
|
|
32
|
+
const decoder = new TextDecoder();
|
|
33
|
+
let buffer = "";
|
|
34
|
+
while (true) {
|
|
35
|
+
const { done, value } = await reader.read();
|
|
36
|
+
if (done) break;
|
|
37
|
+
buffer += decoder.decode(value, { stream: true });
|
|
38
|
+
const events = buffer.split("\n\n");
|
|
39
|
+
buffer = events.pop() || "";
|
|
40
|
+
for (const rawEvent of events) {
|
|
41
|
+
if (!rawEvent.trim()) continue;
|
|
42
|
+
const lines = rawEvent.split("\n");
|
|
43
|
+
let eventType = "message";
|
|
44
|
+
let dataStr = "";
|
|
45
|
+
for (const line of lines) {
|
|
46
|
+
if (line.startsWith("event: ")) {
|
|
47
|
+
eventType = line.slice(7).trim();
|
|
48
|
+
} else if (line.startsWith("data: ")) {
|
|
49
|
+
dataStr = line.slice(6).trim();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (eventType === "text-delta" && dataStr) {
|
|
53
|
+
try {
|
|
54
|
+
const data = JSON.parse(dataStr);
|
|
55
|
+
if (data.delta) {
|
|
56
|
+
text.value += data.delta;
|
|
57
|
+
options.onDelta?.(data.delta);
|
|
58
|
+
}
|
|
59
|
+
} catch {
|
|
60
|
+
}
|
|
61
|
+
} else if (eventType === "error" && dataStr) {
|
|
62
|
+
try {
|
|
63
|
+
const data = JSON.parse(dataStr);
|
|
64
|
+
throw new Error(data.message || "Streaming failed");
|
|
65
|
+
} catch (err) {
|
|
66
|
+
throw err;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
options.onFinish?.(text.value);
|
|
72
|
+
return text.value;
|
|
73
|
+
} catch (err) {
|
|
74
|
+
if (err.name !== "AbortError") {
|
|
75
|
+
error.value = err;
|
|
76
|
+
options.onError?.(err);
|
|
77
|
+
}
|
|
78
|
+
return "";
|
|
79
|
+
} finally {
|
|
80
|
+
isStreaming.value = false;
|
|
81
|
+
abortController = null;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const abort = () => {
|
|
85
|
+
if (abortController) {
|
|
86
|
+
abortController.abort();
|
|
87
|
+
abortController = null;
|
|
88
|
+
isStreaming.value = false;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const reset = () => {
|
|
92
|
+
abort();
|
|
93
|
+
text.value = "";
|
|
94
|
+
error.value = null;
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
text,
|
|
98
|
+
isStreaming,
|
|
99
|
+
error,
|
|
100
|
+
send,
|
|
101
|
+
abort,
|
|
102
|
+
reset
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
export function useVectorSearch(options = {}) {
|
|
106
|
+
const results = ref([]);
|
|
107
|
+
const isSearching = ref(false);
|
|
108
|
+
const error = ref(null);
|
|
109
|
+
const search = async (query, overrideOptions) => {
|
|
110
|
+
if (!query.trim()) return [];
|
|
111
|
+
isSearching.value = true;
|
|
112
|
+
error.value = null;
|
|
113
|
+
const apiEndpoint = overrideOptions?.api || options.api || "/api/ai/search";
|
|
114
|
+
const index = overrideOptions?.index || options.index || "default";
|
|
115
|
+
const topK = overrideOptions?.topK ?? options.topK ?? 5;
|
|
116
|
+
try {
|
|
117
|
+
const res = await fetch(apiEndpoint, {
|
|
118
|
+
method: "POST",
|
|
119
|
+
headers: { "Content-Type": "application/json" },
|
|
120
|
+
body: JSON.stringify({ query, index, topK })
|
|
121
|
+
});
|
|
122
|
+
if (!res.ok) {
|
|
123
|
+
throw new Error(`HTTP ${res.status}: ${res.statusText}`);
|
|
124
|
+
}
|
|
125
|
+
const data = await res.json();
|
|
126
|
+
const list = data.results || data.matches || data;
|
|
127
|
+
results.value = list;
|
|
128
|
+
return list;
|
|
129
|
+
} catch (err) {
|
|
130
|
+
error.value = err;
|
|
131
|
+
return [];
|
|
132
|
+
} finally {
|
|
133
|
+
isSearching.value = false;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const clear = () => {
|
|
137
|
+
results.value = [];
|
|
138
|
+
error.value = null;
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
results,
|
|
142
|
+
isSearching,
|
|
143
|
+
error,
|
|
144
|
+
search,
|
|
145
|
+
clear
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export { useChat, useAgentChat };
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { QarpeoUser, QarpeoSession, DeleteAccountOptions } from "../../types/auth";
|
|
2
|
+
/**
|
|
3
|
+
* Official Better Auth Vue Client Instance
|
|
4
|
+
*/
|
|
5
|
+
export declare const authClient: any;
|
|
6
|
+
/**
|
|
7
|
+
* Standard Better Auth session composable compatible with Nuxt 5 SSR hydration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useSession(): any;
|
|
2
10
|
export declare function useUserSession(): {
|
|
3
11
|
ready: import("vue").ComputedRef<boolean>;
|
|
4
12
|
loggedIn: import("vue").ComputedRef<boolean>;
|
|
5
13
|
user: import("vue").ComputedRef<any>;
|
|
6
|
-
session: import("vue").
|
|
14
|
+
session: import("vue").ComputedRef<any>;
|
|
15
|
+
data: import("vue").ComputedRef<any>;
|
|
16
|
+
isPending: import("vue").ComputedRef<boolean>;
|
|
17
|
+
error: import("vue").ComputedRef<any>;
|
|
7
18
|
fetch: () => Promise<void>;
|
|
8
19
|
clear: () => Promise<void>;
|
|
9
20
|
};
|
|
@@ -25,6 +36,10 @@ export declare function useAuth(): {
|
|
|
25
36
|
clear: () => Promise<void>;
|
|
26
37
|
logout: (redirect?: string) => Promise<void>;
|
|
27
38
|
logoutAll: (redirect?: string) => Promise<void>;
|
|
39
|
+
client: any;
|
|
40
|
+
signIn: any;
|
|
41
|
+
signUp: any;
|
|
42
|
+
signOut: any;
|
|
28
43
|
mfaRequired: import("vue").ComputedRef<boolean>;
|
|
29
44
|
mfaVerified: import("vue").ComputedRef<boolean>;
|
|
30
45
|
deleteAccount: (options?: DeleteAccountOptions, redirect?: string) => Promise<void>;
|