botinabox 1.8.0 → 1.8.2
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/index.d.ts +5 -0
- package/dist/index.js +33 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1090,6 +1090,10 @@ declare class MessageStore {
|
|
|
1090
1090
|
* Get recent outbound messages in a thread for redundancy checking.
|
|
1091
1091
|
*/
|
|
1092
1092
|
getRecentOutbound(threadId: string, limit?: number): Promise<Array<Record<string, unknown>>>;
|
|
1093
|
+
/**
|
|
1094
|
+
* Get recent messages from a specific user across all threads.
|
|
1095
|
+
*/
|
|
1096
|
+
getUserHistory(userId: string, channel: string, limit?: number): Promise<Array<Record<string, unknown>>>;
|
|
1093
1097
|
/**
|
|
1094
1098
|
* Get attachments for a message.
|
|
1095
1099
|
*/
|
|
@@ -1147,6 +1151,7 @@ declare class ChatResponder {
|
|
|
1147
1151
|
channel: string;
|
|
1148
1152
|
userName?: string;
|
|
1149
1153
|
capabilities?: string;
|
|
1154
|
+
additionalContext?: string;
|
|
1150
1155
|
}): Promise<string>;
|
|
1151
1156
|
/**
|
|
1152
1157
|
* Filter any outbound message through the LLM for human readability.
|
package/dist/index.js
CHANGED
|
@@ -1263,6 +1263,16 @@ var MessageStore = class {
|
|
|
1263
1263
|
});
|
|
1264
1264
|
return messages;
|
|
1265
1265
|
}
|
|
1266
|
+
/**
|
|
1267
|
+
* Get recent messages from a specific user across all threads.
|
|
1268
|
+
*/
|
|
1269
|
+
async getUserHistory(userId, channel, limit = 50) {
|
|
1270
|
+
return this.db.query("messages", {
|
|
1271
|
+
where: { from_user: userId, channel },
|
|
1272
|
+
orderBy: "created_at",
|
|
1273
|
+
limit
|
|
1274
|
+
});
|
|
1275
|
+
}
|
|
1266
1276
|
/**
|
|
1267
1277
|
* Get attachments for a message.
|
|
1268
1278
|
*/
|
|
@@ -1329,6 +1339,9 @@ ${opts.capabilities}`;
|
|
|
1329
1339
|
|
|
1330
1340
|
You are talking to: ${opts.userName}`;
|
|
1331
1341
|
}
|
|
1342
|
+
if (opts.additionalContext) {
|
|
1343
|
+
system += opts.additionalContext;
|
|
1344
|
+
}
|
|
1332
1345
|
const result = await this.llmCall({
|
|
1333
1346
|
model: this.model,
|
|
1334
1347
|
messages,
|
|
@@ -1663,11 +1676,24 @@ var ChatPipeline = class {
|
|
|
1663
1676
|
this.threadChannelMap.set(threadTs, channelId);
|
|
1664
1677
|
}
|
|
1665
1678
|
const { messageId } = await this.messageStore.storeInbound(msg);
|
|
1679
|
+
const userHistory = await this.messageStore.getUserHistory(
|
|
1680
|
+
msg.from,
|
|
1681
|
+
this.channel,
|
|
1682
|
+
50
|
|
1683
|
+
);
|
|
1684
|
+
const historyContext = userHistory.map((m) => {
|
|
1685
|
+
const dir = m.direction === "inbound" ? "User" : "Bot";
|
|
1686
|
+
return `${dir}: ${m.body?.slice(0, 200) ?? ""}`;
|
|
1687
|
+
}).join("\n");
|
|
1666
1688
|
const ackResponse = await this.responder.respond({
|
|
1667
1689
|
messageBody: msg.body,
|
|
1668
1690
|
threadId: threadTs,
|
|
1669
1691
|
channel: this.channel,
|
|
1670
|
-
capabilities: this.capabilities
|
|
1692
|
+
capabilities: this.capabilities,
|
|
1693
|
+
additionalContext: historyContext ? `
|
|
1694
|
+
|
|
1695
|
+
Recent conversation history:
|
|
1696
|
+
${historyContext}` : void 0
|
|
1671
1697
|
});
|
|
1672
1698
|
await this.responder.sendResponse({
|
|
1673
1699
|
text: ackResponse,
|
|
@@ -2682,7 +2708,7 @@ function defineCoreEntityContexts(db) {
|
|
|
2682
2708
|
db.defineEntityContext("users", {
|
|
2683
2709
|
table: "users",
|
|
2684
2710
|
directory: "users",
|
|
2685
|
-
slugColumn: "
|
|
2711
|
+
slugColumn: "id",
|
|
2686
2712
|
protected: true,
|
|
2687
2713
|
indexFile: "users/USERS.md",
|
|
2688
2714
|
files: {
|
|
@@ -3095,7 +3121,7 @@ function defineDomainEntityContexts(db, options = {}) {
|
|
|
3095
3121
|
db.defineEntityContext("org", {
|
|
3096
3122
|
table: "org",
|
|
3097
3123
|
directory: "orgs",
|
|
3098
|
-
slugColumn: "
|
|
3124
|
+
slugColumn: "id",
|
|
3099
3125
|
indexFile: "orgs/ORGS.md",
|
|
3100
3126
|
files: {
|
|
3101
3127
|
"ORG.md": {
|
|
@@ -3121,7 +3147,7 @@ ${o.description}` : null,
|
|
|
3121
3147
|
db.defineEntityContext("project", {
|
|
3122
3148
|
table: "project",
|
|
3123
3149
|
directory: "projects",
|
|
3124
|
-
slugColumn: "
|
|
3150
|
+
slugColumn: "id",
|
|
3125
3151
|
indexFile: "projects/PROJECTS.md",
|
|
3126
3152
|
files: {
|
|
3127
3153
|
"PROJECT.md": {
|
|
@@ -3245,7 +3271,7 @@ ${lines.join("\n")}
|
|
|
3245
3271
|
db.defineEntityContext("client", {
|
|
3246
3272
|
table: "client",
|
|
3247
3273
|
directory: "clients",
|
|
3248
|
-
slugColumn: "
|
|
3274
|
+
slugColumn: "id",
|
|
3249
3275
|
indexFile: "clients/CLIENTS.md",
|
|
3250
3276
|
files: {
|
|
3251
3277
|
"CLIENT.md": {
|
|
@@ -3332,7 +3358,7 @@ ${lines.join("\n")}
|
|
|
3332
3358
|
db.defineEntityContext("file", {
|
|
3333
3359
|
table: "file",
|
|
3334
3360
|
directory: "files",
|
|
3335
|
-
slugColumn: "
|
|
3361
|
+
slugColumn: "id",
|
|
3336
3362
|
indexFile: "files/FILES.md",
|
|
3337
3363
|
files: {
|
|
3338
3364
|
"FILE.md": {
|
|
@@ -3359,7 +3385,7 @@ ${f.description}` : null,
|
|
|
3359
3385
|
db.defineEntityContext("channel", {
|
|
3360
3386
|
table: "channel",
|
|
3361
3387
|
directory: "channels",
|
|
3362
|
-
slugColumn: "
|
|
3388
|
+
slugColumn: "id",
|
|
3363
3389
|
indexFile: "channels/CHANNELS.md",
|
|
3364
3390
|
files: {
|
|
3365
3391
|
"CHANNEL.md": {
|