@sleep2agi/commhub-server 0.4.3 → 0.4.4
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/package.json +1 -1
- package/src/index.ts +5 -3
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ const TaskSchema = z.object({
|
|
|
34
34
|
alias: z.string().min(1).max(200),
|
|
35
35
|
task: z.string().min(1).max(10000),
|
|
36
36
|
priority: z.enum(["high", "normal", "low"]).default("normal"),
|
|
37
|
+
from: z.string().max(200).optional(),
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
const BroadcastSchema = z.object({
|
|
@@ -159,16 +160,17 @@ Bun.serve({
|
|
|
159
160
|
}
|
|
160
161
|
const body = parsed.data;
|
|
161
162
|
const id = crypto.randomUUID();
|
|
163
|
+
const fromSession = body.from || "api";
|
|
162
164
|
db.run(
|
|
163
165
|
`INSERT INTO inbox (id, session_name, type, priority, content, from_session)
|
|
164
|
-
VALUES (?1, ?2, 'task', ?3, ?4,
|
|
165
|
-
[id, body.alias, body.priority, body.task]
|
|
166
|
+
VALUES (?1, ?2, 'task', ?3, ?4, ?5)`,
|
|
167
|
+
[id, body.alias, body.priority, body.task, fromSession]
|
|
166
168
|
);
|
|
167
169
|
// SSE push: 秒达
|
|
168
170
|
const pending = db.query<{ cnt: number }, [string]>(
|
|
169
171
|
"SELECT COUNT(*) as cnt FROM inbox WHERE session_name = ?1 AND acked = 0"
|
|
170
172
|
).get(body.alias);
|
|
171
|
-
pushEvent(body.alias, { type: "new_task", inbox_count: pending?.cnt ?? 1, priority: body.priority });
|
|
173
|
+
pushEvent(body.alias, { type: "new_task", inbox_count: pending?.cnt ?? 1, priority: body.priority, from: fromSession });
|
|
172
174
|
return withCors(req, Response.json({ ok: true, message_id: id }));
|
|
173
175
|
}
|
|
174
176
|
|