clay-server 2.27.0-beta.8 → 2.27.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 +10 -0
- package/lib/daemon-projects.js +164 -0
- package/lib/daemon.js +13 -126
- package/lib/mates-identity.js +132 -0
- package/lib/mates-knowledge.js +113 -0
- package/lib/mates-prompts.js +398 -0
- package/lib/mates.js +40 -599
- package/lib/project-connection.js +2 -0
- package/lib/project-debate.js +19 -12
- package/lib/project-http.js +4 -2
- package/lib/project-loop.js +110 -48
- package/lib/project-mate-interaction.js +4 -0
- package/lib/project-notifications.js +210 -0
- package/lib/project-sessions.js +5 -2
- package/lib/project-user-message.js +2 -1
- package/lib/project.js +26 -2
- package/lib/public/app.js +1193 -8521
- package/lib/public/css/command-palette.css +14 -0
- package/lib/public/css/loop.css +301 -0
- package/lib/public/css/notifications-center.css +190 -0
- package/lib/public/css/rewind.css +6 -0
- package/lib/public/index.html +89 -35
- package/lib/public/modules/app-connection.js +160 -0
- package/lib/public/modules/app-cursors.js +473 -0
- package/lib/public/modules/app-debate-ui.js +389 -0
- package/lib/public/modules/app-dm.js +627 -0
- package/lib/public/modules/app-favicon.js +212 -0
- package/lib/public/modules/app-header.js +229 -0
- package/lib/public/modules/app-home-hub.js +600 -0
- package/lib/public/modules/app-loop-ui.js +589 -0
- package/lib/public/modules/app-loop-wizard.js +439 -0
- package/lib/public/modules/app-messages.js +1560 -0
- package/lib/public/modules/app-misc.js +299 -0
- package/lib/public/modules/app-notifications.js +372 -0
- package/lib/public/modules/app-panels.js +888 -0
- package/lib/public/modules/app-projects.js +798 -0
- package/lib/public/modules/app-rate-limit.js +451 -0
- package/lib/public/modules/app-rendering.js +597 -0
- package/lib/public/modules/app-skills-install.js +234 -0
- package/lib/public/modules/command-palette.js +27 -4
- package/lib/public/modules/input.js +31 -20
- package/lib/public/modules/scheduler-config.js +1532 -0
- package/lib/public/modules/scheduler-history.js +79 -0
- package/lib/public/modules/scheduler.js +33 -1554
- package/lib/public/modules/session-search.js +13 -1
- package/lib/public/modules/sidebar-mates.js +812 -0
- package/lib/public/modules/sidebar-mobile.js +1269 -0
- package/lib/public/modules/sidebar-projects.js +1449 -0
- package/lib/public/modules/sidebar-sessions.js +986 -0
- package/lib/public/modules/sidebar.js +232 -4591
- package/lib/public/modules/store.js +27 -0
- package/lib/public/modules/ws-ref.js +7 -0
- package/lib/public/style.css +1 -0
- package/lib/sdk-bridge.js +96 -717
- package/lib/sdk-message-processor.js +587 -0
- package/lib/sdk-message-queue.js +42 -0
- package/lib/sdk-skill-discovery.js +131 -0
- package/lib/server-admin.js +712 -0
- package/lib/server-auth.js +737 -0
- package/lib/server-dm.js +221 -0
- package/lib/server-mates.js +281 -0
- package/lib/server-palette.js +110 -0
- package/lib/server-settings.js +479 -0
- package/lib/server-skills.js +280 -0
- package/lib/server.js +246 -2755
- package/lib/sessions.js +11 -4
- package/lib/users-auth.js +146 -0
- package/lib/users-permissions.js +118 -0
- package/lib/users-preferences.js +210 -0
- package/lib/users.js +48 -398
- package/lib/ws-schema.js +498 -0
- package/package.json +1 -1
package/lib/project-sessions.js
CHANGED
|
@@ -681,12 +681,15 @@ function attachSessions(ctx) {
|
|
|
681
681
|
}
|
|
682
682
|
|
|
683
683
|
if (msg.type === "permission_response") {
|
|
684
|
-
var session = getSessionForWs(ws);
|
|
685
|
-
if (!session) return true;
|
|
686
684
|
var requestId = msg.requestId;
|
|
687
685
|
var decision = msg.decision;
|
|
686
|
+
// Look up session by requestId index (O(1)), fall back to active session
|
|
687
|
+
var sessionId = sm.permissionRequestIndex[requestId];
|
|
688
|
+
var session = sessionId ? sm.sessions.get(sessionId) : getSessionForWs(ws);
|
|
689
|
+
if (!session) return true;
|
|
688
690
|
var pending = session.pendingPermissions[requestId];
|
|
689
691
|
if (!pending) return true;
|
|
692
|
+
delete sm.permissionRequestIndex[requestId];
|
|
690
693
|
delete session.pendingPermissions[requestId];
|
|
691
694
|
onProcessingChanged(); // update cross-project permission badge
|
|
692
695
|
|
|
@@ -268,7 +268,7 @@ function attachUserMessage(ctx) {
|
|
|
268
268
|
nowSession.scheduledMessage = null;
|
|
269
269
|
console.log("[project] Scheduled message sent immediately for session " + nowSession.localId);
|
|
270
270
|
sm.sendAndRecord(nowSession, { type: "scheduled_message_sent" });
|
|
271
|
-
var userMsg = { type: "user_message", text: schedText };
|
|
271
|
+
var userMsg = { type: "user_message", text: schedText, _ts: Date.now() };
|
|
272
272
|
nowSession.history.push(userMsg);
|
|
273
273
|
sm.appendToSessionFile(nowSession, userMsg);
|
|
274
274
|
sendToSession(nowSession.localId, userMsg);
|
|
@@ -320,6 +320,7 @@ function attachUserMessage(ctx) {
|
|
|
320
320
|
if (msg.pastes && msg.pastes.length > 0) {
|
|
321
321
|
userMsg2.pastes = msg.pastes;
|
|
322
322
|
}
|
|
323
|
+
if (!userMsg2._ts) userMsg2._ts = Date.now();
|
|
323
324
|
session.history.push(userMsg2);
|
|
324
325
|
sm.appendToSessionFile(session, userMsg2);
|
|
325
326
|
sendToSessionOthers(ws, session.localId, hydrateImageRefs(userMsg2));
|
package/lib/project.js
CHANGED
|
@@ -26,6 +26,7 @@ var { attachFilesystem } = require("./project-filesystem");
|
|
|
26
26
|
var { attachSessions } = require("./project-sessions");
|
|
27
27
|
var { attachUserMessage } = require("./project-user-message");
|
|
28
28
|
var { attachConnection } = require("./project-connection");
|
|
29
|
+
// project-notifications is attached globally in server.js, passed via opts.notificationsModule
|
|
29
30
|
|
|
30
31
|
// --- Context Sources persistence ---
|
|
31
32
|
var _ctxSrcConfig = require("./config");
|
|
@@ -411,6 +412,7 @@ function createProjectContext(opts) {
|
|
|
411
412
|
sessionManager: sm,
|
|
412
413
|
send: send,
|
|
413
414
|
pushModule: pushModule,
|
|
415
|
+
getNotificationsModule: function () { return _notifications; },
|
|
414
416
|
getSDK: getSDK,
|
|
415
417
|
mateDisplayName: opts.mateDisplayName || "",
|
|
416
418
|
isMate: isMate,
|
|
@@ -499,6 +501,9 @@ function createProjectContext(opts) {
|
|
|
499
501
|
});
|
|
500
502
|
|
|
501
503
|
// --- Loop engine (delegated to project-loop.js) ---
|
|
504
|
+
// --- Notification center (global singleton from server.js) ---
|
|
505
|
+
var _notifications = opts.notificationsModule || null;
|
|
506
|
+
|
|
502
507
|
var _loop = attachLoop({
|
|
503
508
|
cwd: cwd,
|
|
504
509
|
slug: slug,
|
|
@@ -508,6 +513,7 @@ function createProjectContext(opts) {
|
|
|
508
513
|
sendTo: sendTo,
|
|
509
514
|
sendToSession: sendToSession,
|
|
510
515
|
pushModule: pushModule,
|
|
516
|
+
notificationsModule: _notifications,
|
|
511
517
|
getHubSchedules: getHubSchedules,
|
|
512
518
|
getLinuxUserForSession: getLinuxUserForSession,
|
|
513
519
|
onProcessingChanged: onProcessingChanged,
|
|
@@ -575,7 +581,7 @@ function createProjectContext(opts) {
|
|
|
575
581
|
if (session.destroying) return;
|
|
576
582
|
console.log("[project] Scheduled message firing for session " + session.localId);
|
|
577
583
|
sm.sendAndRecord(session, { type: "scheduled_message_sent" });
|
|
578
|
-
var schedUserMsg = { type: "user_message", text: text };
|
|
584
|
+
var schedUserMsg = { type: "user_message", text: text, _ts: Date.now() };
|
|
579
585
|
session.history.push(schedUserMsg);
|
|
580
586
|
sm.appendToSessionFile(session, schedUserMsg);
|
|
581
587
|
sendToSession(session.localId, schedUserMsg);
|
|
@@ -599,6 +605,15 @@ function createProjectContext(opts) {
|
|
|
599
605
|
}
|
|
600
606
|
|
|
601
607
|
function handleMessage(ws, msg) {
|
|
608
|
+
// --- Cross-project routing (e.g. permission_response from notification banner) ---
|
|
609
|
+
if (msg.targetSlug && msg.targetSlug !== slug && opts.getProject) {
|
|
610
|
+
var targetCtx = opts.getProject(msg.targetSlug);
|
|
611
|
+
if (targetCtx) {
|
|
612
|
+
targetCtx.handleMessage(ws, msg);
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
602
617
|
// --- DM messages (delegated to server-level handler) ---
|
|
603
618
|
if (msg.type === "dm_open" || msg.type === "dm_send" || msg.type === "dm_list" || msg.type === "dm_typing" || msg.type === "dm_add_favorite" || msg.type === "dm_remove_favorite" || msg.type === "mate_create" || msg.type === "mate_list" || msg.type === "mate_delete" || msg.type === "mate_update" || msg.type === "mate_readd_builtin" || msg.type === "mate_list_available_builtins") {
|
|
604
619
|
if (typeof opts.onDmMessage === "function") {
|
|
@@ -685,6 +700,9 @@ function createProjectContext(opts) {
|
|
|
685
700
|
// --- Knowledge file management (delegated to project-knowledge.js) ---
|
|
686
701
|
if (_knowledge.handleKnowledgeMessage(ws, msg)) return;
|
|
687
702
|
|
|
703
|
+
// --- Notifications (delegated to project-notifications.js) ---
|
|
704
|
+
if (_notifications.handleNotificationMessage(ws, msg)) return;
|
|
705
|
+
|
|
688
706
|
// --- Memory (session digests) management (delegated to project-memory.js) ---
|
|
689
707
|
if (msg.type === "memory_list") { _memory.handleMemoryList(ws); return; }
|
|
690
708
|
if (msg.type === "memory_search") { _memory.handleMemorySearch(ws, msg); return; }
|
|
@@ -968,6 +986,7 @@ function createProjectContext(opts) {
|
|
|
968
986
|
sendTo: sendTo,
|
|
969
987
|
opts: opts,
|
|
970
988
|
_loop: _loop,
|
|
989
|
+
_notifications: _notifications,
|
|
971
990
|
hydrateImageRefs: hydrateImageRefs,
|
|
972
991
|
broadcastClientCount: broadcastClientCount,
|
|
973
992
|
broadcastPresence: broadcastPresence,
|
|
@@ -1163,6 +1182,7 @@ function createProjectContext(opts) {
|
|
|
1163
1182
|
handleHTTP: handleHTTP,
|
|
1164
1183
|
getStatus: getStatus,
|
|
1165
1184
|
getSessionManager: function () { return sm; },
|
|
1185
|
+
getNotificationsModule: function () { return _notifications; },
|
|
1166
1186
|
getSchedules: _loop.getSchedules,
|
|
1167
1187
|
importSchedule: _loop.importSchedule,
|
|
1168
1188
|
removeSchedule: _loop.removeSchedule,
|
|
@@ -1183,10 +1203,14 @@ function createProjectContext(opts) {
|
|
|
1183
1203
|
},
|
|
1184
1204
|
warmup: function () {
|
|
1185
1205
|
sdk.warmup();
|
|
1206
|
+
sdk.startIdleReaper();
|
|
1186
1207
|
// Migrate existing relay session titles to SDK format (one-time, async)
|
|
1187
1208
|
sm.migrateSessionTitles(getSDK, cwd);
|
|
1188
1209
|
},
|
|
1189
|
-
destroy:
|
|
1210
|
+
destroy: function () {
|
|
1211
|
+
sdk.stopIdleReaper();
|
|
1212
|
+
destroy();
|
|
1213
|
+
},
|
|
1190
1214
|
};
|
|
1191
1215
|
}
|
|
1192
1216
|
|