@coffer-org/server 7.2.0 → 7.3.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/auth-api.d.ts +4 -0
- package/dist/auth-api.js +53 -0
- package/dist/auth-store.d.ts +2 -0
- package/dist/auth-store.js +1 -0
- package/dist/entity-schema.d.ts +2 -0
- package/dist/entity-schema.js +26 -0
- package/dist/identity-link.d.ts +15 -0
- package/dist/identity-link.js +76 -0
- package/dist/index.js +8 -1
- package/dist/mcp-http.js +7 -3
- package/dist/mcp-tools.d.ts +4 -3
- package/dist/mcp-tools.js +84 -84
- package/dist/media/image.d.ts +23 -0
- package/dist/media/image.js +103 -0
- package/dist/media/index.d.ts +1 -0
- package/dist/media/index.js +1 -0
- package/dist/migrations.js +1 -1
- package/dist/orchestrator/agent-capabilities.d.ts +2 -2
- package/dist/orchestrator/agent-capabilities.js +3 -3
- package/dist/orchestrator/allow.d.ts +1 -16
- package/dist/orchestrator/allow.js +3 -53
- package/dist/orchestrator/config.js +0 -1
- package/dist/orchestrator/context-facts.d.ts +27 -0
- package/dist/orchestrator/context-facts.js +89 -0
- package/dist/orchestrator/conversation-access.d.ts +9 -0
- package/dist/orchestrator/conversation-access.js +12 -0
- package/dist/orchestrator/environment.d.ts +1 -0
- package/dist/orchestrator/environment.js +10 -0
- package/dist/orchestrator/file-inspection.d.ts +2 -2
- package/dist/orchestrator/file-inspection.js +41 -19
- package/dist/orchestrator/index.d.ts +15 -9
- package/dist/orchestrator/index.js +13 -7
- package/dist/orchestrator/live-message.d.ts +7 -4
- package/dist/orchestrator/live-message.js +48 -31
- package/dist/orchestrator/pipeline.d.ts +25 -4
- package/dist/orchestrator/pipeline.js +214 -94
- package/dist/orchestrator/registry.d.ts +4 -2
- package/dist/orchestrator/registry.js +10 -1
- package/dist/orchestrator/system-areas.d.ts +12 -0
- package/dist/orchestrator/system-areas.js +63 -0
- package/dist/orchestrator/system-capabilities.js +1 -1
- package/dist/orchestrator/turn-context.d.ts +18 -0
- package/dist/orchestrator/turn-context.js +39 -0
- package/dist/orchestrator/types.d.ts +101 -44
- package/dist/plugin-hooks.d.ts +26 -0
- package/dist/plugin-http-mounts.d.ts +18 -0
- package/dist/plugin-http-mounts.js +94 -0
- package/dist/plugin-runtime.js +2 -2
- package/dist/records-api.js +15 -3
- package/dist/system-settings.js +0 -1
- package/dist/thread-state.d.ts +14 -0
- package/dist/thread-state.js +71 -11
- package/dist/thread-store.d.ts +5 -3
- package/dist/thread-store.js +12 -9
- package/dist/turn-gate.d.ts +8 -0
- package/dist/turn-gate.js +39 -0
- package/package.json +7 -2
package/dist/thread-store.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getEm } from "./db.js";
|
|
2
|
+
export const HIDDEN_ROLES = ['reasoning', 'suggestions', 'context'];
|
|
2
3
|
export const SIDECAR_ROLES = ['reasoning', 'suggestions'];
|
|
3
4
|
function toStored(r) {
|
|
4
5
|
let attachments;
|
|
@@ -50,7 +51,7 @@ export async function pruneThreadMessages(connector, cutoffTs) {
|
|
|
50
51
|
}
|
|
51
52
|
export async function listThreadMessages(connector, chatId, limit = 200) {
|
|
52
53
|
const em = getEm().fork();
|
|
53
|
-
const visible = (await em.find('_ThreadMessage', { connector, chat_id: chatId, role: { $nin:
|
|
54
|
+
const visible = (await em.find('_ThreadMessage', { connector, chat_id: chatId, role: { $nin: HIDDEN_ROLES } }, { orderBy: { ts: 'desc', msg_id: 'desc' }, limit }));
|
|
54
55
|
const oldest = visible.at(-1)?.ts;
|
|
55
56
|
const sidecars = oldest === undefined
|
|
56
57
|
? []
|
|
@@ -60,17 +61,14 @@ export async function listThreadMessages(connector, chatId, limit = 200) {
|
|
|
60
61
|
.reverse()
|
|
61
62
|
.map(toStored);
|
|
62
63
|
}
|
|
63
|
-
export async function
|
|
64
|
+
export async function countUserTurns(connector, chatId) {
|
|
64
65
|
const em = getEm().fork();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const last = chatIdPrefix.charCodeAt(chatIdPrefix.length - 1);
|
|
69
|
-
const upper = chatIdPrefix.slice(0, -1) + String.fromCharCode(last + 1);
|
|
70
|
-
const rows = (await em.find('_ThreadMessage', { connector, chat_id: { $gte: chatIdPrefix, $lt: upper } }, { orderBy: { ts: 'asc' } }));
|
|
66
|
+
return em.count('_ThreadMessage', { connector, chat_id: chatId, role: 'user' });
|
|
67
|
+
}
|
|
68
|
+
function groupIntoChats(rows) {
|
|
71
69
|
const byChat = new Map();
|
|
72
70
|
for (const r of rows) {
|
|
73
|
-
if (
|
|
71
|
+
if (HIDDEN_ROLES.includes(r.role))
|
|
74
72
|
continue;
|
|
75
73
|
const cur = byChat.get(r.chat_id);
|
|
76
74
|
if (!cur) {
|
|
@@ -90,3 +88,8 @@ export async function listThreadChats(connector, chatIdPrefix) {
|
|
|
90
88
|
}
|
|
91
89
|
return [...byChat.values()].sort((a, b) => b.lastTs - a.lastTs);
|
|
92
90
|
}
|
|
91
|
+
export async function listAllThreadChats(connector) {
|
|
92
|
+
const em = getEm().fork();
|
|
93
|
+
const rows = (await em.find('_ThreadMessage', { connector }, { orderBy: { ts: 'asc' } }));
|
|
94
|
+
return groupIntoChats(rows);
|
|
95
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface BeginTurnOpts {
|
|
2
|
+
supersede: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function beginTurn(connector: string, chatId: string, opts: BeginTurnOpts): Promise<{
|
|
5
|
+
signal: AbortSignal;
|
|
6
|
+
end(): void;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function abortTurn(connector: string, chatId: string): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const turns = new Map();
|
|
2
|
+
function turnKey(connector, chatId) {
|
|
3
|
+
return `${connector}\0${chatId}`;
|
|
4
|
+
}
|
|
5
|
+
export async function beginTurn(connector, chatId, opts) {
|
|
6
|
+
const key = turnKey(connector, chatId);
|
|
7
|
+
const previous = turns.get(key);
|
|
8
|
+
const controller = new AbortController();
|
|
9
|
+
let resolveDone;
|
|
10
|
+
const done = new Promise((resolve) => {
|
|
11
|
+
resolveDone = resolve;
|
|
12
|
+
});
|
|
13
|
+
const turn = { controller, done };
|
|
14
|
+
turns.set(key, turn);
|
|
15
|
+
if (previous) {
|
|
16
|
+
if (opts.supersede)
|
|
17
|
+
previous.controller.abort();
|
|
18
|
+
await previous.done;
|
|
19
|
+
}
|
|
20
|
+
let ended = false;
|
|
21
|
+
return {
|
|
22
|
+
signal: controller.signal,
|
|
23
|
+
end() {
|
|
24
|
+
if (ended)
|
|
25
|
+
return;
|
|
26
|
+
ended = true;
|
|
27
|
+
if (turns.get(key) === turn)
|
|
28
|
+
turns.delete(key);
|
|
29
|
+
resolveDone();
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function abortTurn(connector, chatId) {
|
|
34
|
+
const turn = turns.get(turnKey(connector, chatId));
|
|
35
|
+
if (!turn)
|
|
36
|
+
return false;
|
|
37
|
+
turn.controller.abort();
|
|
38
|
+
return true;
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffer-org/server",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
"types": "./dist/orchestrator/index.d.ts",
|
|
18
18
|
"default": "./dist/orchestrator/index.js"
|
|
19
19
|
},
|
|
20
|
+
"./media": {
|
|
21
|
+
"types": "./dist/media/index.d.ts",
|
|
22
|
+
"default": "./dist/media/index.js"
|
|
23
|
+
},
|
|
20
24
|
"./mcp": {
|
|
21
25
|
"types": "./dist/mcp-contract/tools.d.ts",
|
|
22
26
|
"default": "./dist/mcp-contract/tools.js"
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
"postpack": "node ../../scripts/swap-exports.mjs src"
|
|
37
41
|
},
|
|
38
42
|
"dependencies": {
|
|
39
|
-
"@coffer-org/sdk": "^7.
|
|
43
|
+
"@coffer-org/sdk": "^7.3.0",
|
|
40
44
|
"@extractus/oembed-extractor": "^4.1.0",
|
|
41
45
|
"@fastify/cors": "^11.2.0",
|
|
42
46
|
"@fastify/multipart": "^10.0.0",
|
|
@@ -48,6 +52,7 @@
|
|
|
48
52
|
"open-graph-scraper": "^6.11.0",
|
|
49
53
|
"pino": "^9.14.0",
|
|
50
54
|
"pino-pretty": "^13.1.3",
|
|
55
|
+
"sharp": "^0.35.4",
|
|
51
56
|
"zod": "^4.4.3"
|
|
52
57
|
},
|
|
53
58
|
"optionalDependencies": {
|