@diegoaltoworks/chatter 0.22.0 → 0.24.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/dist/core/retrieval.d.ts +31 -6
- package/dist/core/retrieval.d.ts.map +1 -1
- package/dist/core/retrieval.test.d.ts +8 -0
- package/dist/core/retrieval.test.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -9
- package/dist/index.mjs +18 -9
- package/dist/mcp-server.js +6 -1
- package/dist/mcp-server.mjs +6 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.test.d.ts +9 -0
- package/dist/server.test.d.ts.map +1 -0
- package/dist/types.d.ts +25 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -1
package/dist/core/retrieval.d.ts
CHANGED
|
@@ -1,14 +1,39 @@
|
|
|
1
|
+
import { type Client as LibsqlClient } from "@libsql/client";
|
|
1
2
|
import type OpenAI from "openai";
|
|
2
3
|
import { type Bucket } from "./loaders";
|
|
4
|
+
/**
|
|
5
|
+
* How a {@link VectorStore} obtains its database connection: either credentials
|
|
6
|
+
* to open its own, or an existing libsql client to reuse.
|
|
7
|
+
*
|
|
8
|
+
* Reusing a client is preferred when the store lives alongside other consumers
|
|
9
|
+
* of the same database (route factories, custom routes) — the process then
|
|
10
|
+
* holds one connection instead of one per consumer.
|
|
11
|
+
*/
|
|
12
|
+
export type VectorStoreOptions = {
|
|
13
|
+
/** Directory of markdown knowledge files. Default: `./config/knowledge` */
|
|
14
|
+
knowledgeDir?: string;
|
|
15
|
+
} & ({
|
|
16
|
+
/** Turso database URL */
|
|
17
|
+
databaseUrl: string;
|
|
18
|
+
/** Turso auth token */
|
|
19
|
+
databaseAuthToken: string;
|
|
20
|
+
databaseClient?: never;
|
|
21
|
+
} | {
|
|
22
|
+
/** An existing libsql client to reuse instead of opening a second connection */
|
|
23
|
+
databaseClient: LibsqlClient;
|
|
24
|
+
databaseUrl?: never;
|
|
25
|
+
databaseAuthToken?: never;
|
|
26
|
+
});
|
|
3
27
|
export declare class VectorStore {
|
|
4
28
|
private client;
|
|
5
|
-
|
|
29
|
+
/**
|
|
30
|
+
* The libsql client backing this store. When a client was injected this is
|
|
31
|
+
* that same instance, so callers holding it (e.g. `ServerDependencies.db`)
|
|
32
|
+
* and the store share one connection.
|
|
33
|
+
*/
|
|
34
|
+
readonly db: LibsqlClient;
|
|
6
35
|
private knowledgeDir;
|
|
7
|
-
constructor(client: OpenAI, options:
|
|
8
|
-
databaseUrl: string;
|
|
9
|
-
databaseAuthToken: string;
|
|
10
|
-
knowledgeDir?: string;
|
|
11
|
-
});
|
|
36
|
+
constructor(client: OpenAI, options: VectorStoreOptions);
|
|
12
37
|
build(): Promise<void>;
|
|
13
38
|
private cleanupStaleChunks;
|
|
14
39
|
private static cosine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieval.d.ts","sourceRoot":"","sources":["../../src/core/retrieval.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"retrieval.d.ts","sourceRoot":"","sources":["../../src/core/retrieval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,KAAK,MAAM,EAAiB,MAAM,WAAW,CAAC;AAyBvD;;;;;;;GAOG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,2EAA2E;IAC3E,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,CACA;IACE,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB,GACD;IACE,gFAAgF;IAChF,cAAc,EAAE,YAAY,CAAC;IAC7B,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,iBAAiB,CAAC,EAAE,KAAK,CAAC;CAC3B,CACJ,CAAC;AAEF,qBAAa,WAAW;IAUpB,OAAO,CAAC,MAAM;IAThB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,EAAE,YAAY,CAAC;IAC1B,OAAO,CAAC,YAAY,CAAS;IAE7B,YACU,MAAM,EAAE,MAAM,EACtB,OAAO,EAAE,kBAAkB,EAS5B;IAGK,KAAK,kBA0FV;YAGa,kBAAkB;IA8BhC,OAAO,CAAC,MAAM,CAAC,MAAM;IAaf,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,SAAI,EAAE,OAAO,GAAE,MAAM,EAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAsB7E;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval.test.d.ts","sourceRoot":"","sources":["../../src/core/retrieval.test.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { loadKnowledge } from "./core/loaders";
|
|
|
22
22
|
export type { PipelineMessage, PipelineMode, PreparedChat } from "./core/pipeline";
|
|
23
23
|
export { prepareChat } from "./core/pipeline";
|
|
24
24
|
export { PromptLoader } from "./core/prompts";
|
|
25
|
+
export type { VectorStoreOptions } from "./core/retrieval";
|
|
25
26
|
export { VectorStore } from "./core/retrieval";
|
|
26
27
|
export { createSession, getActiveSessions, getSessionInfo, validateSession, } from "./core/session";
|
|
27
28
|
export type { MCPServerOptions, MCPTransportMode } from "./mcp-server";
|
|
@@ -37,5 +38,5 @@ export { openaiRoutes } from "./routes/openai";
|
|
|
37
38
|
export { privateRoutes } from "./routes/private";
|
|
38
39
|
export { publicRoutes } from "./routes/public";
|
|
39
40
|
export { createServer } from "./server";
|
|
40
|
-
export type { BotBranding, BotChatConfig, BotIdentity, ChatterConfig, EmbeddingChunk, KnowledgeDocument, ServerDependencies, } from "./types";
|
|
41
|
+
export type { BotBranding, BotChatConfig, BotIdentity, ChatterConfig, CustomRoutes, EmbeddingChunk, KnowledgeDocument, ServerDependencies, } from "./types";
|
|
41
42
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,eAAe,GAChB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACrD,YAAY,EACV,QAAQ,EACR,aAAa,EACb,cAAc,EACd,aAAa,EACb,WAAW,GACZ,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,YAAY,EAAE,aAAa,EAAE,aAAa,E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,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,YAAY,EACV,WAAW,EACX,aAAa,EACb,WAAW,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7531,9 +7531,9 @@ var require_dist2 = __commonJS({
|
|
|
7531
7531
|
var index_exports = {};
|
|
7532
7532
|
__export(index_exports, {
|
|
7533
7533
|
ApiKeyManager: () => ApiKeyManager,
|
|
7534
|
-
Chat: () =>
|
|
7535
|
-
ChatBot: () =>
|
|
7536
|
-
ChatButton: () =>
|
|
7534
|
+
Chat: () => import_client3.Chat,
|
|
7535
|
+
ChatBot: () => import_client3.ChatBot,
|
|
7536
|
+
ChatButton: () => import_client3.ChatButton,
|
|
7537
7537
|
DEFAULT_MODEL: () => DEFAULT_MODEL,
|
|
7538
7538
|
PromptLoader: () => PromptLoader,
|
|
7539
7539
|
VectorStore: () => VectorStore,
|
|
@@ -7677,7 +7677,7 @@ var ApiKeyManager = class {
|
|
|
7677
7677
|
};
|
|
7678
7678
|
|
|
7679
7679
|
// src/index.ts
|
|
7680
|
-
var
|
|
7680
|
+
var import_client3 = __toESM(require_dist());
|
|
7681
7681
|
|
|
7682
7682
|
// src/core/guardrails.ts
|
|
7683
7683
|
function detectLeakage(text) {
|
|
@@ -7899,13 +7899,18 @@ async function sha256(input) {
|
|
|
7899
7899
|
var VectorStore = class _VectorStore {
|
|
7900
7900
|
constructor(client, options) {
|
|
7901
7901
|
this.client = client;
|
|
7902
|
-
this.db = (0, import_client.createClient)({
|
|
7902
|
+
this.db = options.databaseClient ? options.databaseClient : (0, import_client.createClient)({
|
|
7903
7903
|
url: options.databaseUrl,
|
|
7904
7904
|
authToken: options.databaseAuthToken
|
|
7905
7905
|
});
|
|
7906
7906
|
this.knowledgeDir = options.knowledgeDir || "./config/knowledge";
|
|
7907
7907
|
}
|
|
7908
7908
|
client;
|
|
7909
|
+
/**
|
|
7910
|
+
* The libsql client backing this store. When a client was injected this is
|
|
7911
|
+
* that same instance, so callers holding it (e.g. `ServerDependencies.db`)
|
|
7912
|
+
* and the store share one connection.
|
|
7913
|
+
*/
|
|
7909
7914
|
db;
|
|
7910
7915
|
knowledgeDir;
|
|
7911
7916
|
// On boot: ingest new chunks and embed only missing ones.
|
|
@@ -33097,6 +33102,7 @@ function publicRoutes(deps) {
|
|
|
33097
33102
|
}
|
|
33098
33103
|
|
|
33099
33104
|
// src/server.ts
|
|
33105
|
+
var import_client2 = require("@libsql/client");
|
|
33100
33106
|
var import_hono5 = require("hono");
|
|
33101
33107
|
var import_bun = require("hono/bun");
|
|
33102
33108
|
var import_openai2 = __toESM(require("openai"));
|
|
@@ -33143,9 +33149,12 @@ async function createServer(config2) {
|
|
|
33143
33149
|
const client = new import_openai2.default({
|
|
33144
33150
|
apiKey: config2.openai.apiKey
|
|
33145
33151
|
});
|
|
33152
|
+
const db = (0, import_client2.createClient)({
|
|
33153
|
+
url: config2.database.url,
|
|
33154
|
+
authToken: config2.database.authToken
|
|
33155
|
+
});
|
|
33146
33156
|
const store = new VectorStore(client, {
|
|
33147
|
-
|
|
33148
|
-
databaseAuthToken: config2.database.authToken,
|
|
33157
|
+
databaseClient: db,
|
|
33149
33158
|
knowledgeDir
|
|
33150
33159
|
});
|
|
33151
33160
|
await store.build();
|
|
@@ -33223,7 +33232,7 @@ async function createServer(config2) {
|
|
|
33223
33232
|
app.get("/demo/chatbot", (0, import_bun.serveStatic)({ path: `${publicDir}/demo-chatbot.html` }));
|
|
33224
33233
|
app.get("/demo/react", (0, import_bun.serveStatic)({ path: `${publicDir}/react-demo.html` }));
|
|
33225
33234
|
}
|
|
33226
|
-
const deps = { client, store, config: config2, prompts, apiKeyManager };
|
|
33235
|
+
const deps = { client, store, db, config: config2, prompts, apiKeyManager };
|
|
33227
33236
|
if (enablePublic) {
|
|
33228
33237
|
app.route("/", publicRoutes(deps));
|
|
33229
33238
|
}
|
|
@@ -33237,7 +33246,7 @@ async function createServer(config2) {
|
|
|
33237
33246
|
app.route("/", openaiRoutes(deps));
|
|
33238
33247
|
}
|
|
33239
33248
|
if (config2.customRoutes) {
|
|
33240
|
-
config2.customRoutes(app, deps);
|
|
33249
|
+
await config2.customRoutes(app, deps);
|
|
33241
33250
|
}
|
|
33242
33251
|
console.log(`\u2705 ${config2.bot.name} server ready`);
|
|
33243
33252
|
return app;
|
package/dist/index.mjs
CHANGED
|
@@ -7643,7 +7643,7 @@ var ApiKeyManager = class {
|
|
|
7643
7643
|
};
|
|
7644
7644
|
|
|
7645
7645
|
// src/index.ts
|
|
7646
|
-
var
|
|
7646
|
+
var import_client3 = __toESM(require_dist());
|
|
7647
7647
|
|
|
7648
7648
|
// src/core/guardrails.ts
|
|
7649
7649
|
function detectLeakage(text) {
|
|
@@ -7865,13 +7865,18 @@ async function sha256(input) {
|
|
|
7865
7865
|
var VectorStore = class _VectorStore {
|
|
7866
7866
|
constructor(client, options) {
|
|
7867
7867
|
this.client = client;
|
|
7868
|
-
this.db = createClient({
|
|
7868
|
+
this.db = options.databaseClient ? options.databaseClient : createClient({
|
|
7869
7869
|
url: options.databaseUrl,
|
|
7870
7870
|
authToken: options.databaseAuthToken
|
|
7871
7871
|
});
|
|
7872
7872
|
this.knowledgeDir = options.knowledgeDir || "./config/knowledge";
|
|
7873
7873
|
}
|
|
7874
7874
|
client;
|
|
7875
|
+
/**
|
|
7876
|
+
* The libsql client backing this store. When a client was injected this is
|
|
7877
|
+
* that same instance, so callers holding it (e.g. `ServerDependencies.db`)
|
|
7878
|
+
* and the store share one connection.
|
|
7879
|
+
*/
|
|
7875
7880
|
db;
|
|
7876
7881
|
knowledgeDir;
|
|
7877
7882
|
// On boot: ingest new chunks and embed only missing ones.
|
|
@@ -33063,6 +33068,7 @@ function publicRoutes(deps) {
|
|
|
33063
33068
|
}
|
|
33064
33069
|
|
|
33065
33070
|
// src/server.ts
|
|
33071
|
+
import { createClient as createClient2 } from "@libsql/client";
|
|
33066
33072
|
import { Hono as Hono5 } from "hono";
|
|
33067
33073
|
import { serveStatic } from "hono/bun";
|
|
33068
33074
|
import OpenAI2 from "openai";
|
|
@@ -33108,9 +33114,12 @@ async function createServer(config2) {
|
|
|
33108
33114
|
const client = new OpenAI2({
|
|
33109
33115
|
apiKey: config2.openai.apiKey
|
|
33110
33116
|
});
|
|
33117
|
+
const db = createClient2({
|
|
33118
|
+
url: config2.database.url,
|
|
33119
|
+
authToken: config2.database.authToken
|
|
33120
|
+
});
|
|
33111
33121
|
const store = new VectorStore(client, {
|
|
33112
|
-
|
|
33113
|
-
databaseAuthToken: config2.database.authToken,
|
|
33122
|
+
databaseClient: db,
|
|
33114
33123
|
knowledgeDir
|
|
33115
33124
|
});
|
|
33116
33125
|
await store.build();
|
|
@@ -33188,7 +33197,7 @@ async function createServer(config2) {
|
|
|
33188
33197
|
app.get("/demo/chatbot", serveStatic({ path: `${publicDir}/demo-chatbot.html` }));
|
|
33189
33198
|
app.get("/demo/react", serveStatic({ path: `${publicDir}/react-demo.html` }));
|
|
33190
33199
|
}
|
|
33191
|
-
const deps = { client, store, config: config2, prompts, apiKeyManager };
|
|
33200
|
+
const deps = { client, store, db, config: config2, prompts, apiKeyManager };
|
|
33192
33201
|
if (enablePublic) {
|
|
33193
33202
|
app.route("/", publicRoutes(deps));
|
|
33194
33203
|
}
|
|
@@ -33202,14 +33211,14 @@ async function createServer(config2) {
|
|
|
33202
33211
|
app.route("/", openaiRoutes(deps));
|
|
33203
33212
|
}
|
|
33204
33213
|
if (config2.customRoutes) {
|
|
33205
|
-
config2.customRoutes(app, deps);
|
|
33214
|
+
await config2.customRoutes(app, deps);
|
|
33206
33215
|
}
|
|
33207
33216
|
console.log(`\u2705 ${config2.bot.name} server ready`);
|
|
33208
33217
|
return app;
|
|
33209
33218
|
}
|
|
33210
|
-
var export_Chat =
|
|
33211
|
-
var export_ChatBot =
|
|
33212
|
-
var export_ChatButton =
|
|
33219
|
+
var export_Chat = import_client3.Chat;
|
|
33220
|
+
var export_ChatBot = import_client3.ChatBot;
|
|
33221
|
+
var export_ChatButton = import_client3.ChatButton;
|
|
33213
33222
|
export {
|
|
33214
33223
|
ApiKeyManager,
|
|
33215
33224
|
export_Chat as Chat,
|
package/dist/mcp-server.js
CHANGED
|
@@ -193,13 +193,18 @@ async function sha256(input) {
|
|
|
193
193
|
var VectorStore = class _VectorStore {
|
|
194
194
|
constructor(client, options) {
|
|
195
195
|
this.client = client;
|
|
196
|
-
this.db = (0, import_client.createClient)({
|
|
196
|
+
this.db = options.databaseClient ? options.databaseClient : (0, import_client.createClient)({
|
|
197
197
|
url: options.databaseUrl,
|
|
198
198
|
authToken: options.databaseAuthToken
|
|
199
199
|
});
|
|
200
200
|
this.knowledgeDir = options.knowledgeDir || "./config/knowledge";
|
|
201
201
|
}
|
|
202
202
|
client;
|
|
203
|
+
/**
|
|
204
|
+
* The libsql client backing this store. When a client was injected this is
|
|
205
|
+
* that same instance, so callers holding it (e.g. `ServerDependencies.db`)
|
|
206
|
+
* and the store share one connection.
|
|
207
|
+
*/
|
|
203
208
|
db;
|
|
204
209
|
knowledgeDir;
|
|
205
210
|
// On boot: ingest new chunks and embed only missing ones.
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -159,13 +159,18 @@ async function sha256(input) {
|
|
|
159
159
|
var VectorStore = class _VectorStore {
|
|
160
160
|
constructor(client, options) {
|
|
161
161
|
this.client = client;
|
|
162
|
-
this.db = createClient({
|
|
162
|
+
this.db = options.databaseClient ? options.databaseClient : createClient({
|
|
163
163
|
url: options.databaseUrl,
|
|
164
164
|
authToken: options.databaseAuthToken
|
|
165
165
|
});
|
|
166
166
|
this.knowledgeDir = options.knowledgeDir || "./config/knowledge";
|
|
167
167
|
}
|
|
168
168
|
client;
|
|
169
|
+
/**
|
|
170
|
+
* The libsql client backing this store. When a client was injected this is
|
|
171
|
+
* that same instance, so callers holding it (e.g. `ServerDependencies.db`)
|
|
172
|
+
* and the store share one connection.
|
|
173
|
+
*/
|
|
169
174
|
db;
|
|
170
175
|
knowledgeDir;
|
|
171
176
|
// On boot: ingest new chunks and embed only missing ones.
|
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;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAY5B,OAAO,KAAK,EAAE,aAAa,EAAsB,MAAM,SAAS,CAAC;AAEjE;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,uFA+JvD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* createServer custom-route mounting tests
|
|
3
|
+
*
|
|
4
|
+
* Runs the real server factory against an in-memory libsql database and an
|
|
5
|
+
* empty knowledge directory, so no paid API is reached: with nothing to embed,
|
|
6
|
+
* the vector store build never calls OpenAI.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=server.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.test.d.ts","sourceRoot":"","sources":["../src/server.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Core types for the Chatter chatbot framework.
|
|
5
5
|
* These types define the public API and configuration interface.
|
|
6
6
|
*/
|
|
7
|
+
import type { Client as LibsqlClient } from "@libsql/client";
|
|
7
8
|
import type { Hono } from "hono";
|
|
8
9
|
import type OpenAI from "openai";
|
|
9
10
|
import type { AnswerFn } from "./core/answer";
|
|
@@ -155,9 +156,25 @@ export interface ChatterConfig {
|
|
|
155
156
|
* errors. Unset: the built-in OpenAI completion is used.
|
|
156
157
|
*/
|
|
157
158
|
answerFn?: AnswerFn;
|
|
158
|
-
/** Custom route handler for advanced use cases */
|
|
159
|
-
customRoutes?:
|
|
159
|
+
/** Custom route handler for advanced use cases. May be async — see {@link CustomRoutes} */
|
|
160
|
+
customRoutes?: CustomRoutes;
|
|
160
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* Mounts additional routes on the server's Hono app.
|
|
164
|
+
*
|
|
165
|
+
* May be synchronous or return a promise; `createServer` awaits it, so
|
|
166
|
+
* asynchronous set-up (database migrations, plugin registries, anything the
|
|
167
|
+
* routes depend on) is guaranteed to have finished before the server is handed
|
|
168
|
+
* back and starts serving requests. A rejection fails startup rather than
|
|
169
|
+
* leaving the app half-mounted.
|
|
170
|
+
*
|
|
171
|
+
* Declared as a union of two function types rather than one returning
|
|
172
|
+
* `void | Promise<void>`: TypeScript only ignores a callback's return value
|
|
173
|
+
* when the expected return type is exactly `void`, so the union keeps
|
|
174
|
+
* expression-bodied mounts like `(app) => app.get(...)` — which return the
|
|
175
|
+
* Hono app for chaining — assignable.
|
|
176
|
+
*/
|
|
177
|
+
export type CustomRoutes = ((app: Hono, deps: ServerDependencies) => void) | ((app: Hono, deps: ServerDependencies) => Promise<void>);
|
|
161
178
|
/**
|
|
162
179
|
* Dependencies passed to route factories and middleware
|
|
163
180
|
*/
|
|
@@ -166,6 +183,12 @@ export interface ServerDependencies {
|
|
|
166
183
|
client: OpenAI;
|
|
167
184
|
/** Vector store instance */
|
|
168
185
|
store: VectorStore;
|
|
186
|
+
/**
|
|
187
|
+
* The libsql database client, shared with the vector store. Custom routes
|
|
188
|
+
* should use this handle rather than opening their own connection to the
|
|
189
|
+
* same database.
|
|
190
|
+
*/
|
|
191
|
+
db: LibsqlClient;
|
|
169
192
|
/** Chatter configuration */
|
|
170
193
|
config: ChatterConfig;
|
|
171
194
|
/** Prompt loader instance */
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2CAA2C;IAC3C,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,4CAA4C;IAC5C,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC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AE,MAAM,CAAC;IACb,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,QAAQ,EAAE;QACR,uBAAuB;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,2CAA2C;QAC3C,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;QACrC,8BAA8B;QAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,qBAAqB;IACrB,QAAQ,EAAE;QACR,uBAAuB;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,qBAAqB;QACrB,IAAI,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;QACrC,8BAA8B;QAC9B,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegoaltoworks/chatter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Embeddable AI chatbot framework with RAG, authentication, and customizable widgets",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -59,6 +59,13 @@
|
|
|
59
59
|
"security:audit:fix": "bun update",
|
|
60
60
|
"security:check": "bun audit --audit-level=moderate",
|
|
61
61
|
"check": "bun run typecheck && bun run lint && bun run test && bun run security:check",
|
|
62
|
+
"work": "bun ./.claude/work.ts run",
|
|
63
|
+
"work:continuous": "bun ./.claude/work.ts run --continuous",
|
|
64
|
+
"work:status": "bun ./.claude/work.ts status",
|
|
65
|
+
"work:reset": "bun ./.claude/work.ts reset",
|
|
66
|
+
"work:watch": "bun ./.claude/work.ts watch",
|
|
67
|
+
"work:resume": "bun ./.claude/work.ts resume",
|
|
68
|
+
"work:halt": "bun ./.claude/work.ts halt",
|
|
62
69
|
"prepublishOnly": "bun run lint && bun run typecheck && bun run test && bun run security:check && bun run build",
|
|
63
70
|
"prepare": "husky || true"
|
|
64
71
|
},
|