@diegoaltoworks/chatter 0.44.0 → 0.47.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.
- package/README.md +16 -1
- package/dist/client/index.js +615 -0
- package/dist/client/index.mjs +592 -0
- package/dist/core/serve-static.d.ts +38 -0
- package/dist/core/serve-static.d.ts.map +1 -0
- package/dist/core/session.d.ts +1 -0
- package/dist/core/session.d.ts.map +1 -1
- package/dist/index.js +88 -49
- package/dist/index.mjs +70 -37
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1564 -0
- package/dist/server.mjs +1528 -0
- package/package.json +19 -9
- package/dist/auth/apikeys.test.d.ts +0 -2
- package/dist/auth/apikeys.test.d.ts.map +0 -1
- package/dist/channels/gates.test.d.ts +0 -2
- package/dist/channels/gates.test.d.ts.map +0 -1
- package/dist/channels/senders.test.d.ts +0 -2
- package/dist/channels/senders.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/authState.test.d.ts +0 -2
- package/dist/channels/whatsapp/authState.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/baileys.test.d.ts +0 -2
- package/dist/channels/whatsapp/baileys.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/channel.test.d.ts +0 -2
- package/dist/channels/whatsapp/channel.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/crypto.test.d.ts +0 -2
- package/dist/channels/whatsapp/crypto.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/images.test.d.ts +0 -2
- package/dist/channels/whatsapp/images.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/inbound.test.d.ts +0 -2
- package/dist/channels/whatsapp/inbound.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/lease.test.d.ts +0 -2
- package/dist/channels/whatsapp/lease.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/pairing.test.d.ts +0 -2
- package/dist/channels/whatsapp/pairing.test.d.ts.map +0 -1
- package/dist/channels/whatsapp/qr.test.d.ts +0 -2
- package/dist/channels/whatsapp/qr.test.d.ts.map +0 -1
- package/dist/client/__tests__/markdown.test.d.ts +0 -5
- package/dist/client/__tests__/markdown.test.d.ts.map +0 -1
- package/dist/client/__tests__/mobile-chat.test.d.ts +0 -6
- package/dist/client/__tests__/mobile-chat.test.d.ts.map +0 -1
- package/dist/client/examples/node.d.ts +0 -5
- package/dist/client/examples/node.d.ts.map +0 -1
- package/dist/core/answer.test.d.ts +0 -8
- package/dist/core/answer.test.d.ts.map +0 -1
- package/dist/core/buckets.test.d.ts +0 -10
- package/dist/core/buckets.test.d.ts.map +0 -1
- package/dist/core/guardrails.test.d.ts +0 -2
- package/dist/core/guardrails.test.d.ts.map +0 -1
- package/dist/core/loaders.test.d.ts +0 -2
- package/dist/core/loaders.test.d.ts.map +0 -1
- package/dist/core/messages.test.d.ts +0 -8
- package/dist/core/messages.test.d.ts.map +0 -1
- package/dist/core/pipeline.test.d.ts +0 -8
- package/dist/core/pipeline.test.d.ts.map +0 -1
- package/dist/core/prompts.test.d.ts +0 -2
- package/dist/core/prompts.test.d.ts.map +0 -1
- package/dist/core/retrieval.test.d.ts +0 -8
- package/dist/core/retrieval.test.d.ts.map +0 -1
- package/dist/core/session.test.d.ts +0 -2
- package/dist/core/session.test.d.ts.map +0 -1
- package/dist/core/widgets.test.d.ts +0 -2
- package/dist/core/widgets.test.d.ts.map +0 -1
- package/dist/flows/__fixtures__/broken/handler.d.ts +0 -3
- package/dist/flows/__fixtures__/broken/handler.d.ts.map +0 -1
- package/dist/flows/__fixtures__/greeting/handler.d.ts +0 -3
- package/dist/flows/__fixtures__/greeting/handler.d.ts.map +0 -1
- package/dist/flows/__fixtures__/greeting/prefill.d.ts +0 -3
- package/dist/flows/__fixtures__/greeting/prefill.d.ts.map +0 -1
- package/dist/flows/engine.test.d.ts +0 -9
- package/dist/flows/engine.test.d.ts.map +0 -1
- package/dist/flows/intent.test.d.ts +0 -6
- package/dist/flows/intent.test.d.ts.map +0 -1
- package/dist/flows/loader.test.d.ts +0 -8
- package/dist/flows/loader.test.d.ts.map +0 -1
- package/dist/flows/params.test.d.ts +0 -2
- package/dist/flows/params.test.d.ts.map +0 -1
- package/dist/flows/registry.test.d.ts +0 -2
- package/dist/flows/registry.test.d.ts.map +0 -1
- package/dist/flows/session.test.d.ts +0 -7
- package/dist/flows/session.test.d.ts.map +0 -1
- package/dist/flows/utils.test.d.ts +0 -2
- package/dist/flows/utils.test.d.ts.map +0 -1
- package/dist/images/cache.test.d.ts +0 -2
- package/dist/images/cache.test.d.ts.map +0 -1
- package/dist/images/cacheStore.test.d.ts +0 -8
- package/dist/images/cacheStore.test.d.ts.map +0 -1
- package/dist/images/captionComposer.test.d.ts +0 -2
- package/dist/images/captionComposer.test.d.ts.map +0 -1
- package/dist/images/cloudinaryClient.test.d.ts +0 -2
- package/dist/images/cloudinaryClient.test.d.ts.map +0 -1
- package/dist/images/cloudinaryConfig.test.d.ts +0 -2
- package/dist/images/cloudinaryConfig.test.d.ts.map +0 -1
- package/dist/images/cloudinarySignature.test.d.ts +0 -2
- package/dist/images/cloudinarySignature.test.d.ts.map +0 -1
- package/dist/images/config.test.d.ts +0 -2
- package/dist/images/config.test.d.ts.map +0 -1
- package/dist/images/generator.test.d.ts +0 -2
- package/dist/images/generator.test.d.ts.map +0 -1
- package/dist/images/openaiClient.test.d.ts +0 -2
- package/dist/images/openaiClient.test.d.ts.map +0 -1
- package/dist/images/uploader.test.d.ts +0 -2
- package/dist/images/uploader.test.d.ts.map +0 -1
- package/dist/mcp-server/conversation-id.test.d.ts +0 -2
- package/dist/mcp-server/conversation-id.test.d.ts.map +0 -1
- package/dist/mcp-server/cost-tracker.test.d.ts +0 -2
- package/dist/mcp-server/cost-tracker.test.d.ts.map +0 -1
- package/dist/mcp-server/logger.test.d.ts +0 -2
- package/dist/mcp-server/logger.test.d.ts.map +0 -1
- package/dist/mcp-server/rate-limiter.test.d.ts +0 -2
- package/dist/mcp-server/rate-limiter.test.d.ts.map +0 -1
- package/dist/middleware/auth.test.d.ts +0 -2
- package/dist/middleware/auth.test.d.ts.map +0 -1
- package/dist/middleware/cors.test.d.ts +0 -2
- package/dist/middleware/cors.test.d.ts.map +0 -1
- package/dist/middleware/jwt.test.d.ts +0 -2
- package/dist/middleware/jwt.test.d.ts.map +0 -1
- package/dist/middleware/ratelimit.test.d.ts +0 -2
- package/dist/middleware/ratelimit.test.d.ts.map +0 -1
- package/dist/middleware/referrer.test.d.ts +0 -2
- package/dist/middleware/referrer.test.d.ts.map +0 -1
- package/dist/middleware/session.test.d.ts +0 -2
- package/dist/middleware/session.test.d.ts.map +0 -1
- package/dist/personas/greeter.test.d.ts +0 -2
- package/dist/personas/greeter.test.d.ts.map +0 -1
- package/dist/personas/resolver.test.d.ts +0 -2
- package/dist/personas/resolver.test.d.ts.map +0 -1
- package/dist/personas/timeContext.test.d.ts +0 -2
- package/dist/personas/timeContext.test.d.ts.map +0 -1
- package/dist/routes/chat.test.d.ts +0 -9
- package/dist/routes/chat.test.d.ts.map +0 -1
- package/dist/routes/openai.test.d.ts +0 -8
- package/dist/routes/openai.test.d.ts.map +0 -1
- package/dist/scheduler/claimStore.test.d.ts +0 -2
- package/dist/scheduler/claimStore.test.d.ts.map +0 -1
- package/dist/scheduler/compose.test.d.ts +0 -2
- package/dist/scheduler/compose.test.d.ts.map +0 -1
- package/dist/scheduler/deliver.test.d.ts +0 -2
- package/dist/scheduler/deliver.test.d.ts.map +0 -1
- package/dist/scheduler/dueDrops.test.d.ts +0 -2
- package/dist/scheduler/dueDrops.test.d.ts.map +0 -1
- package/dist/scheduler/scheduler.test.d.ts +0 -2
- package/dist/scheduler/scheduler.test.d.ts.map +0 -1
- package/dist/scheduler/tick.test.d.ts +0 -2
- package/dist/scheduler/tick.test.d.ts.map +0 -1
- package/dist/server.test.d.ts +0 -9
- package/dist/server.test.d.ts.map +0 -1
- package/dist/shortener.test.d.ts +0 -2
- package/dist/shortener.test.d.ts.map +0 -1
- package/dist/usage/limits.test.d.ts +0 -10
- package/dist/usage/limits.test.d.ts.map +0 -1
- package/dist/usage/tursoStore.test.d.ts +0 -9
- package/dist/usage/tursoStore.test.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -4265,49 +4265,49 @@ var require_fast_uri = __commonJS({
|
|
|
4265
4265
|
schemelessOptions.skipEscape = true;
|
|
4266
4266
|
return serialize(resolved, schemelessOptions);
|
|
4267
4267
|
}
|
|
4268
|
-
function resolveComponent(base,
|
|
4268
|
+
function resolveComponent(base, relative2, options, skipNormalization) {
|
|
4269
4269
|
const target = {};
|
|
4270
4270
|
if (!skipNormalization) {
|
|
4271
4271
|
base = parse3(serialize(base, options), options);
|
|
4272
|
-
|
|
4272
|
+
relative2 = parse3(serialize(relative2, options), options);
|
|
4273
4273
|
}
|
|
4274
4274
|
options = options || {};
|
|
4275
|
-
if (!options.tolerant &&
|
|
4276
|
-
target.scheme =
|
|
4277
|
-
target.userinfo =
|
|
4278
|
-
target.host =
|
|
4279
|
-
target.port =
|
|
4280
|
-
target.path = removeDotSegments(
|
|
4281
|
-
target.query =
|
|
4275
|
+
if (!options.tolerant && relative2.scheme) {
|
|
4276
|
+
target.scheme = relative2.scheme;
|
|
4277
|
+
target.userinfo = relative2.userinfo;
|
|
4278
|
+
target.host = relative2.host;
|
|
4279
|
+
target.port = relative2.port;
|
|
4280
|
+
target.path = removeDotSegments(relative2.path || "");
|
|
4281
|
+
target.query = relative2.query;
|
|
4282
4282
|
} else {
|
|
4283
|
-
if (
|
|
4284
|
-
target.userinfo =
|
|
4285
|
-
target.host =
|
|
4286
|
-
target.port =
|
|
4287
|
-
target.path = removeDotSegments(
|
|
4288
|
-
target.query =
|
|
4283
|
+
if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
|
|
4284
|
+
target.userinfo = relative2.userinfo;
|
|
4285
|
+
target.host = relative2.host;
|
|
4286
|
+
target.port = relative2.port;
|
|
4287
|
+
target.path = removeDotSegments(relative2.path || "");
|
|
4288
|
+
target.query = relative2.query;
|
|
4289
4289
|
} else {
|
|
4290
|
-
if (!
|
|
4290
|
+
if (!relative2.path) {
|
|
4291
4291
|
target.path = base.path;
|
|
4292
|
-
if (
|
|
4293
|
-
target.query =
|
|
4292
|
+
if (relative2.query !== void 0) {
|
|
4293
|
+
target.query = relative2.query;
|
|
4294
4294
|
} else {
|
|
4295
4295
|
target.query = base.query;
|
|
4296
4296
|
}
|
|
4297
4297
|
} else {
|
|
4298
|
-
if (
|
|
4299
|
-
target.path = removeDotSegments(
|
|
4298
|
+
if (relative2.path[0] === "/") {
|
|
4299
|
+
target.path = removeDotSegments(relative2.path);
|
|
4300
4300
|
} else {
|
|
4301
4301
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
4302
|
-
target.path = "/" +
|
|
4302
|
+
target.path = "/" + relative2.path;
|
|
4303
4303
|
} else if (!base.path) {
|
|
4304
|
-
target.path =
|
|
4304
|
+
target.path = relative2.path;
|
|
4305
4305
|
} else {
|
|
4306
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
4306
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
|
|
4307
4307
|
}
|
|
4308
4308
|
target.path = removeDotSegments(target.path);
|
|
4309
4309
|
}
|
|
4310
|
-
target.query =
|
|
4310
|
+
target.query = relative2.query;
|
|
4311
4311
|
}
|
|
4312
4312
|
target.userinfo = base.userinfo;
|
|
4313
4313
|
target.host = base.host;
|
|
@@ -4315,7 +4315,7 @@ var require_fast_uri = __commonJS({
|
|
|
4315
4315
|
}
|
|
4316
4316
|
target.scheme = base.scheme;
|
|
4317
4317
|
}
|
|
4318
|
-
target.fragment =
|
|
4318
|
+
target.fragment = relative2.fragment;
|
|
4319
4319
|
return target;
|
|
4320
4320
|
}
|
|
4321
4321
|
function equal(uriA, uriB, options) {
|
|
@@ -8140,7 +8140,7 @@ var VectorStore = class _VectorStore {
|
|
|
8140
8140
|
// src/core/session.ts
|
|
8141
8141
|
var import_node_crypto2 = require("node:crypto");
|
|
8142
8142
|
var sessions = /* @__PURE__ */ new Map();
|
|
8143
|
-
setInterval(
|
|
8143
|
+
var sessionSweeper = setInterval(
|
|
8144
8144
|
() => {
|
|
8145
8145
|
const now = Date.now();
|
|
8146
8146
|
for (const [key, data] of Array.from(sessions.entries())) {
|
|
@@ -8151,6 +8151,7 @@ setInterval(
|
|
|
8151
8151
|
},
|
|
8152
8152
|
5 * 60 * 1e3
|
|
8153
8153
|
);
|
|
8154
|
+
sessionSweeper.unref?.();
|
|
8154
8155
|
function createSession(options = {}) {
|
|
8155
8156
|
const { maxRequests = 20, ttl = 3600, metadata } = options;
|
|
8156
8157
|
const key = `session_${(0, import_node_crypto2.randomUUID)()}`;
|
|
@@ -33177,9 +33178,9 @@ function publicRoutes(deps) {
|
|
|
33177
33178
|
}
|
|
33178
33179
|
|
|
33179
33180
|
// src/server.ts
|
|
33181
|
+
var import_node_path4 = require("node:path");
|
|
33180
33182
|
var import_client2 = require("@libsql/client");
|
|
33181
33183
|
var import_hono5 = require("hono");
|
|
33182
|
-
var import_bun = require("hono/bun");
|
|
33183
33184
|
var import_openai2 = __toESM(require("openai"));
|
|
33184
33185
|
|
|
33185
33186
|
// src/channels/senders.ts
|
|
@@ -33234,6 +33235,36 @@ function createSenderRegistry() {
|
|
|
33234
33235
|
};
|
|
33235
33236
|
}
|
|
33236
33237
|
|
|
33238
|
+
// src/core/serve-static.ts
|
|
33239
|
+
var STATIC_ADAPTERS = {
|
|
33240
|
+
bun: "hono/bun",
|
|
33241
|
+
node: "@hono/node-server/serve-static"
|
|
33242
|
+
};
|
|
33243
|
+
function detectRuntime() {
|
|
33244
|
+
return typeof globalThis.Bun === "undefined" ? "node" : "bun";
|
|
33245
|
+
}
|
|
33246
|
+
function wrapMissingAdapterError(runtime, cause) {
|
|
33247
|
+
const specifier = STATIC_ADAPTERS[runtime];
|
|
33248
|
+
return new Error(
|
|
33249
|
+
`Serving static files under ${runtime} requires '${specifier}', which could not be loaded. ` + (runtime === "node" ? "Install the optional peer dependency with `npm install @hono/node-server` (or bun/pnpm/yarn), or run Chatter headless (`features.headless: true`) if it should serve no static assets." : "Upgrade 'hono' to a version that ships the Bun adapter."),
|
|
33250
|
+
{ cause }
|
|
33251
|
+
);
|
|
33252
|
+
}
|
|
33253
|
+
var cache = /* @__PURE__ */ new Map();
|
|
33254
|
+
function loadServeStatic(runtime = detectRuntime()) {
|
|
33255
|
+
const cached2 = cache.get(runtime);
|
|
33256
|
+
if (cached2) return cached2;
|
|
33257
|
+
const loading = (runtime === "bun" ? import("hono/bun") : import("@hono/node-server/serve-static")).then(
|
|
33258
|
+
(module2) => module2.serveStatic,
|
|
33259
|
+
(error51) => {
|
|
33260
|
+
cache.delete(runtime);
|
|
33261
|
+
throw wrapMissingAdapterError(runtime, error51);
|
|
33262
|
+
}
|
|
33263
|
+
);
|
|
33264
|
+
cache.set(runtime, loading);
|
|
33265
|
+
return loading;
|
|
33266
|
+
}
|
|
33267
|
+
|
|
33237
33268
|
// src/core/widgets.ts
|
|
33238
33269
|
var import_node_fs3 = require("node:fs");
|
|
33239
33270
|
var import_node_path3 = require("node:path");
|
|
@@ -33312,52 +33343,60 @@ async function createServer(config2) {
|
|
|
33312
33343
|
chat: config2.chat || {}
|
|
33313
33344
|
})
|
|
33314
33345
|
);
|
|
33315
|
-
|
|
33316
|
-
|
|
33317
|
-
|
|
33318
|
-
|
|
33319
|
-
|
|
33320
|
-
|
|
33321
|
-
|
|
33322
|
-
|
|
33323
|
-
|
|
33324
|
-
|
|
33346
|
+
let serveStatic = null;
|
|
33347
|
+
if (!headless && (staticDir || publicDir)) {
|
|
33348
|
+
try {
|
|
33349
|
+
serveStatic = await loadServeStatic();
|
|
33350
|
+
} catch (error51) {
|
|
33351
|
+
console.error(`\u274C Static assets disabled: ${error51.message}`);
|
|
33352
|
+
}
|
|
33353
|
+
}
|
|
33354
|
+
if (serveStatic && staticDir) {
|
|
33355
|
+
const relativePath = (0, import_node_path4.relative)(process.cwd(), staticDir);
|
|
33356
|
+
app.get("/chatter.js", serveStatic({ path: `${relativePath}/chatter.js` }));
|
|
33357
|
+
app.get("/chatter.css", serveStatic({ path: `${relativePath}/chatter.css` }));
|
|
33358
|
+
}
|
|
33359
|
+
if (serveStatic && publicDir) {
|
|
33360
|
+
app.get("/", serveStatic({ path: `${publicDir}/index.html` }));
|
|
33361
|
+
app.get("/chat", serveStatic({ path: `${publicDir}/chat.html` }));
|
|
33362
|
+
app.get("/private", serveStatic({ path: `${publicDir}/private.html` }));
|
|
33363
|
+
app.get("/vanilla/chat", serveStatic({ path: `${publicDir}/vanilla/chat.html` }));
|
|
33325
33364
|
app.get(
|
|
33326
33365
|
"/demo/widget-button-public",
|
|
33327
|
-
|
|
33366
|
+
serveStatic({ path: `${publicDir}/demo/widget-button-public.html` })
|
|
33328
33367
|
);
|
|
33329
33368
|
app.get(
|
|
33330
33369
|
"/demo/widget-button-private",
|
|
33331
|
-
|
|
33370
|
+
serveStatic({ path: `${publicDir}/demo/widget-button-private.html` })
|
|
33332
33371
|
);
|
|
33333
33372
|
app.get(
|
|
33334
33373
|
"/demo/widget-inline-public",
|
|
33335
|
-
|
|
33374
|
+
serveStatic({ path: `${publicDir}/demo/widget-inline-public.html` })
|
|
33336
33375
|
);
|
|
33337
33376
|
app.get(
|
|
33338
33377
|
"/demo/widget-inline-private",
|
|
33339
|
-
|
|
33378
|
+
serveStatic({ path: `${publicDir}/demo/widget-inline-private.html` })
|
|
33340
33379
|
);
|
|
33341
33380
|
app.get(
|
|
33342
33381
|
"/demo/react-button-public",
|
|
33343
|
-
|
|
33382
|
+
serveStatic({ path: `${publicDir}/demo/react-button-public.html` })
|
|
33344
33383
|
);
|
|
33345
33384
|
app.get(
|
|
33346
33385
|
"/demo/react-button-private",
|
|
33347
|
-
|
|
33386
|
+
serveStatic({ path: `${publicDir}/demo/react-button-private.html` })
|
|
33348
33387
|
);
|
|
33349
33388
|
app.get(
|
|
33350
33389
|
"/demo/react-inline-public",
|
|
33351
|
-
|
|
33390
|
+
serveStatic({ path: `${publicDir}/demo/react-inline-public.html` })
|
|
33352
33391
|
);
|
|
33353
33392
|
app.get(
|
|
33354
33393
|
"/demo/react-inline-private",
|
|
33355
|
-
|
|
33394
|
+
serveStatic({ path: `${publicDir}/demo/react-inline-private.html` })
|
|
33356
33395
|
);
|
|
33357
|
-
app.get("/demo/public",
|
|
33358
|
-
app.get("/demo/private",
|
|
33359
|
-
app.get("/demo/chatbot",
|
|
33360
|
-
app.get("/demo/react",
|
|
33396
|
+
app.get("/demo/public", serveStatic({ path: `${publicDir}/demo-public.html` }));
|
|
33397
|
+
app.get("/demo/private", serveStatic({ path: `${publicDir}/demo-private.html` }));
|
|
33398
|
+
app.get("/demo/chatbot", serveStatic({ path: `${publicDir}/demo-chatbot.html` }));
|
|
33399
|
+
app.get("/demo/react", serveStatic({ path: `${publicDir}/react-demo.html` }));
|
|
33361
33400
|
}
|
|
33362
33401
|
const senders = createSenderRegistry();
|
|
33363
33402
|
const deps = { client, store, db, config: config2, prompts, apiKeyManager, senders };
|
package/dist/index.mjs
CHANGED
|
@@ -4,13 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
14
8
|
try {
|
|
15
9
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
10
|
} catch (e) {
|
|
@@ -4269,49 +4263,49 @@ var require_fast_uri = __commonJS({
|
|
|
4269
4263
|
schemelessOptions.skipEscape = true;
|
|
4270
4264
|
return serialize(resolved, schemelessOptions);
|
|
4271
4265
|
}
|
|
4272
|
-
function resolveComponent(base,
|
|
4266
|
+
function resolveComponent(base, relative2, options, skipNormalization) {
|
|
4273
4267
|
const target = {};
|
|
4274
4268
|
if (!skipNormalization) {
|
|
4275
4269
|
base = parse3(serialize(base, options), options);
|
|
4276
|
-
|
|
4270
|
+
relative2 = parse3(serialize(relative2, options), options);
|
|
4277
4271
|
}
|
|
4278
4272
|
options = options || {};
|
|
4279
|
-
if (!options.tolerant &&
|
|
4280
|
-
target.scheme =
|
|
4281
|
-
target.userinfo =
|
|
4282
|
-
target.host =
|
|
4283
|
-
target.port =
|
|
4284
|
-
target.path = removeDotSegments(
|
|
4285
|
-
target.query =
|
|
4273
|
+
if (!options.tolerant && relative2.scheme) {
|
|
4274
|
+
target.scheme = relative2.scheme;
|
|
4275
|
+
target.userinfo = relative2.userinfo;
|
|
4276
|
+
target.host = relative2.host;
|
|
4277
|
+
target.port = relative2.port;
|
|
4278
|
+
target.path = removeDotSegments(relative2.path || "");
|
|
4279
|
+
target.query = relative2.query;
|
|
4286
4280
|
} else {
|
|
4287
|
-
if (
|
|
4288
|
-
target.userinfo =
|
|
4289
|
-
target.host =
|
|
4290
|
-
target.port =
|
|
4291
|
-
target.path = removeDotSegments(
|
|
4292
|
-
target.query =
|
|
4281
|
+
if (relative2.userinfo !== void 0 || relative2.host !== void 0 || relative2.port !== void 0) {
|
|
4282
|
+
target.userinfo = relative2.userinfo;
|
|
4283
|
+
target.host = relative2.host;
|
|
4284
|
+
target.port = relative2.port;
|
|
4285
|
+
target.path = removeDotSegments(relative2.path || "");
|
|
4286
|
+
target.query = relative2.query;
|
|
4293
4287
|
} else {
|
|
4294
|
-
if (!
|
|
4288
|
+
if (!relative2.path) {
|
|
4295
4289
|
target.path = base.path;
|
|
4296
|
-
if (
|
|
4297
|
-
target.query =
|
|
4290
|
+
if (relative2.query !== void 0) {
|
|
4291
|
+
target.query = relative2.query;
|
|
4298
4292
|
} else {
|
|
4299
4293
|
target.query = base.query;
|
|
4300
4294
|
}
|
|
4301
4295
|
} else {
|
|
4302
|
-
if (
|
|
4303
|
-
target.path = removeDotSegments(
|
|
4296
|
+
if (relative2.path[0] === "/") {
|
|
4297
|
+
target.path = removeDotSegments(relative2.path);
|
|
4304
4298
|
} else {
|
|
4305
4299
|
if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
|
|
4306
|
-
target.path = "/" +
|
|
4300
|
+
target.path = "/" + relative2.path;
|
|
4307
4301
|
} else if (!base.path) {
|
|
4308
|
-
target.path =
|
|
4302
|
+
target.path = relative2.path;
|
|
4309
4303
|
} else {
|
|
4310
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
4304
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative2.path;
|
|
4311
4305
|
}
|
|
4312
4306
|
target.path = removeDotSegments(target.path);
|
|
4313
4307
|
}
|
|
4314
|
-
target.query =
|
|
4308
|
+
target.query = relative2.query;
|
|
4315
4309
|
}
|
|
4316
4310
|
target.userinfo = base.userinfo;
|
|
4317
4311
|
target.host = base.host;
|
|
@@ -4319,7 +4313,7 @@ var require_fast_uri = __commonJS({
|
|
|
4319
4313
|
}
|
|
4320
4314
|
target.scheme = base.scheme;
|
|
4321
4315
|
}
|
|
4322
|
-
target.fragment =
|
|
4316
|
+
target.fragment = relative2.fragment;
|
|
4323
4317
|
return target;
|
|
4324
4318
|
}
|
|
4325
4319
|
function equal(uriA, uriB, options) {
|
|
@@ -8100,7 +8094,7 @@ var VectorStore = class _VectorStore {
|
|
|
8100
8094
|
// src/core/session.ts
|
|
8101
8095
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
8102
8096
|
var sessions = /* @__PURE__ */ new Map();
|
|
8103
|
-
setInterval(
|
|
8097
|
+
var sessionSweeper = setInterval(
|
|
8104
8098
|
() => {
|
|
8105
8099
|
const now = Date.now();
|
|
8106
8100
|
for (const [key, data] of Array.from(sessions.entries())) {
|
|
@@ -8111,6 +8105,7 @@ setInterval(
|
|
|
8111
8105
|
},
|
|
8112
8106
|
5 * 60 * 1e3
|
|
8113
8107
|
);
|
|
8108
|
+
sessionSweeper.unref?.();
|
|
8114
8109
|
function createSession(options = {}) {
|
|
8115
8110
|
const { maxRequests = 20, ttl = 3600, metadata } = options;
|
|
8116
8111
|
const key = `session_${randomUUID2()}`;
|
|
@@ -33137,9 +33132,9 @@ function publicRoutes(deps) {
|
|
|
33137
33132
|
}
|
|
33138
33133
|
|
|
33139
33134
|
// src/server.ts
|
|
33135
|
+
import { relative } from "node:path";
|
|
33140
33136
|
import { createClient as createClient2 } from "@libsql/client";
|
|
33141
33137
|
import { Hono as Hono5 } from "hono";
|
|
33142
|
-
import { serveStatic } from "hono/bun";
|
|
33143
33138
|
import OpenAI2 from "openai";
|
|
33144
33139
|
|
|
33145
33140
|
// src/channels/senders.ts
|
|
@@ -33194,6 +33189,36 @@ function createSenderRegistry() {
|
|
|
33194
33189
|
};
|
|
33195
33190
|
}
|
|
33196
33191
|
|
|
33192
|
+
// src/core/serve-static.ts
|
|
33193
|
+
var STATIC_ADAPTERS = {
|
|
33194
|
+
bun: "hono/bun",
|
|
33195
|
+
node: "@hono/node-server/serve-static"
|
|
33196
|
+
};
|
|
33197
|
+
function detectRuntime() {
|
|
33198
|
+
return typeof globalThis.Bun === "undefined" ? "node" : "bun";
|
|
33199
|
+
}
|
|
33200
|
+
function wrapMissingAdapterError(runtime, cause) {
|
|
33201
|
+
const specifier = STATIC_ADAPTERS[runtime];
|
|
33202
|
+
return new Error(
|
|
33203
|
+
`Serving static files under ${runtime} requires '${specifier}', which could not be loaded. ` + (runtime === "node" ? "Install the optional peer dependency with `npm install @hono/node-server` (or bun/pnpm/yarn), or run Chatter headless (`features.headless: true`) if it should serve no static assets." : "Upgrade 'hono' to a version that ships the Bun adapter."),
|
|
33204
|
+
{ cause }
|
|
33205
|
+
);
|
|
33206
|
+
}
|
|
33207
|
+
var cache = /* @__PURE__ */ new Map();
|
|
33208
|
+
function loadServeStatic(runtime = detectRuntime()) {
|
|
33209
|
+
const cached2 = cache.get(runtime);
|
|
33210
|
+
if (cached2) return cached2;
|
|
33211
|
+
const loading = (runtime === "bun" ? import("hono/bun") : import("@hono/node-server/serve-static")).then(
|
|
33212
|
+
(module) => module.serveStatic,
|
|
33213
|
+
(error51) => {
|
|
33214
|
+
cache.delete(runtime);
|
|
33215
|
+
throw wrapMissingAdapterError(runtime, error51);
|
|
33216
|
+
}
|
|
33217
|
+
);
|
|
33218
|
+
cache.set(runtime, loading);
|
|
33219
|
+
return loading;
|
|
33220
|
+
}
|
|
33221
|
+
|
|
33197
33222
|
// src/core/widgets.ts
|
|
33198
33223
|
import { existsSync } from "node:fs";
|
|
33199
33224
|
import { dirname, join as join3 } from "node:path";
|
|
@@ -33271,12 +33296,20 @@ async function createServer(config2) {
|
|
|
33271
33296
|
chat: config2.chat || {}
|
|
33272
33297
|
})
|
|
33273
33298
|
);
|
|
33274
|
-
|
|
33275
|
-
|
|
33299
|
+
let serveStatic = null;
|
|
33300
|
+
if (!headless && (staticDir || publicDir)) {
|
|
33301
|
+
try {
|
|
33302
|
+
serveStatic = await loadServeStatic();
|
|
33303
|
+
} catch (error51) {
|
|
33304
|
+
console.error(`\u274C Static assets disabled: ${error51.message}`);
|
|
33305
|
+
}
|
|
33306
|
+
}
|
|
33307
|
+
if (serveStatic && staticDir) {
|
|
33308
|
+
const relativePath = relative(process.cwd(), staticDir);
|
|
33276
33309
|
app.get("/chatter.js", serveStatic({ path: `${relativePath}/chatter.js` }));
|
|
33277
33310
|
app.get("/chatter.css", serveStatic({ path: `${relativePath}/chatter.css` }));
|
|
33278
33311
|
}
|
|
33279
|
-
if (
|
|
33312
|
+
if (serveStatic && publicDir) {
|
|
33280
33313
|
app.get("/", serveStatic({ path: `${publicDir}/index.html` }));
|
|
33281
33314
|
app.get("/chat", serveStatic({ path: `${publicDir}/chat.html` }));
|
|
33282
33315
|
app.get("/private", serveStatic({ path: `${publicDir}/private.html` }));
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAc5B,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,SAAS,CAAC;AAEjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG;IAAE,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC;AAEtE;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CA+M7E"}
|