clay-server 3.8.1 → 4.0.0-beta.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/lib/ask-user-mcp-server.js +5 -119
- package/lib/builtin-mates.js +6 -6
- package/lib/claude-hook-installer.js +15 -0
- package/lib/clay-history-mcp-server.js +62 -297
- package/lib/daemon.js +1 -1
- package/lib/debate-model-selection.js +119 -0
- package/lib/home-debate-tool-policy.js +164 -0
- package/lib/home-response-notifications.js +26 -0
- package/lib/mate-creation-mcp-server.js +55 -0
- package/lib/mate-ready-creation.js +95 -0
- package/lib/mates.js +2 -0
- package/lib/notes.js +2 -1
- package/lib/project-ask-user.js +64 -0
- package/lib/project-capsule-catalog.js +101 -0
- package/lib/project-connection.js +4 -0
- package/lib/project-debate-proposal.js +133 -17
- package/lib/project-debate.js +214 -110
- package/lib/project-delegated-follow-up.js +84 -0
- package/lib/project-delegated-session.js +53 -0
- package/lib/project-filesystem.js +7 -9
- package/lib/project-knowledge.js +1 -0
- package/lib/project-mate-creation-proposal.js +120 -0
- package/lib/project-memory.js +14 -7
- package/lib/project-models.js +157 -32
- package/lib/project-session-notes.js +2 -2
- package/lib/project-session-pair.js +8 -8
- package/lib/project-sessions.js +66 -51
- package/lib/project-vendor-login.js +397 -0
- package/lib/project-worker-proposal.js +25 -25
- package/lib/project-workspace-query.js +144 -0
- package/lib/project.js +349 -102
- package/lib/public/app.js +85 -42
- package/lib/public/css/avatar-imprints.css +0 -1
- package/lib/public/css/base.css +4 -0
- package/lib/public/css/capsule-ui.css +389 -0
- package/lib/public/css/command-palette.css +306 -6
- package/lib/public/css/home-capsule-library.css +243 -0
- package/lib/public/css/home-capsule-source.css +192 -0
- package/lib/public/css/home-debate-live.css +146 -0
- package/lib/public/css/home-debate-planning.css +125 -0
- package/lib/public/css/home-debates-archive.css +281 -0
- package/lib/public/css/home-hub.css +896 -405
- package/lib/public/css/home-mate-creation.css +34 -0
- package/lib/public/css/home-mate-model-picker.css +131 -0
- package/lib/public/css/home-mate-settings.css +344 -0
- package/lib/public/css/home-session-actions.css +265 -0
- package/lib/public/css/home-sidebar.css +667 -0
- package/lib/public/css/icon-strip.css +1 -2
- package/lib/public/css/mates.css +7 -34
- package/lib/public/css/pane.css +1 -1
- package/lib/public/css/playbook.css +0 -80
- package/lib/public/css/sticky-notes.css +53 -117
- package/lib/public/css/tui-attention.css +0 -44
- package/lib/public/css/workspace-assignment.css +45 -0
- package/lib/public/fonts/source-serif-4/LICENSE.md +93 -0
- package/lib/public/fonts/source-serif-4/SourceSerif4Caption-Semibold.ttf.woff2 +0 -0
- package/lib/public/index.html +93 -74
- package/lib/public/modules/app-connection.js +10 -1
- package/lib/public/modules/app-dm.js +43 -160
- package/lib/public/modules/app-home-hub.js +328 -585
- package/lib/public/modules/app-message-cards.js +242 -0
- package/lib/public/modules/app-message-router.js +84 -0
- package/lib/public/modules/app-messages.js +102 -37
- package/lib/public/modules/app-notifications.js +8 -119
- package/lib/public/modules/app-projects.js +9 -1
- package/lib/public/modules/app-rendering.js +21 -602
- package/lib/public/modules/avatar-imprint.js +11 -8
- package/lib/public/modules/chat-bubble-renderer.js +152 -0
- package/lib/public/modules/chat-render-runtime.js +198 -0
- package/lib/public/modules/command-palette.js +225 -436
- package/lib/public/modules/dm-render.js +82 -0
- package/lib/public/modules/home-capsule-creation-intent.js +31 -0
- package/lib/public/modules/home-capsule-library.js +146 -0
- package/lib/public/modules/home-capsule-source.js +383 -0
- package/lib/public/modules/home-chat-identity.js +35 -0
- package/lib/public/modules/home-chat-scroll.js +77 -0
- package/lib/public/modules/home-chat-stream-state.js +34 -0
- package/lib/public/modules/home-composer-focus.js +25 -0
- package/lib/public/modules/home-conversations-sheet.js +179 -0
- package/lib/public/modules/home-debate-activity.js +48 -0
- package/lib/public/modules/home-debate-controls.js +295 -0
- package/lib/public/modules/home-debate-launch.js +41 -0
- package/lib/public/modules/home-debate-live.js +284 -0
- package/lib/public/modules/home-debate-models.js +73 -0
- package/lib/public/modules/home-debate-planning.js +335 -0
- package/lib/public/modules/home-debates-archive.js +279 -0
- package/lib/public/modules/home-dock-resize.js +74 -0
- package/lib/public/modules/home-dock.js +446 -0
- package/lib/public/modules/home-mate-chat.js +496 -0
- package/lib/public/modules/home-mate-creation.js +109 -0
- package/lib/public/modules/home-mate-model-picker.js +281 -0
- package/lib/public/modules/home-mate-selection.js +38 -0
- package/lib/public/modules/home-mate-settings-menu.js +131 -0
- package/lib/public/modules/home-mate-settings.js +383 -0
- package/lib/public/modules/home-session-actions.js +373 -0
- package/lib/public/modules/home-session-model-confirmation.js +13 -0
- package/lib/public/modules/home-shell.js +9 -0
- package/lib/public/modules/home-sidebar-chat-list.js +63 -0
- package/lib/public/modules/home-sidebar.js +158 -0
- package/lib/public/modules/home-sub-surface.js +19 -0
- package/lib/public/modules/home-surface-boot.js +68 -0
- package/lib/public/modules/home-surface.js +141 -0
- package/lib/public/modules/home-tools.js +271 -0
- package/lib/public/modules/markdown.js +50 -2
- package/lib/public/modules/mate-management.js +86 -0
- package/lib/public/modules/mate-wizard.js +0 -7
- package/lib/public/modules/mention.js +17 -19
- package/lib/public/modules/pane-bridge.js +9 -0
- package/lib/public/modules/profile.js +4 -5
- package/lib/public/modules/project-settings.js +34 -28
- package/lib/public/modules/project-switcher.js +11 -5
- package/lib/public/modules/project-workspace-assignment.js +23 -0
- package/lib/public/modules/search-clay-chat.js +402 -0
- package/lib/public/modules/server-settings.js +14 -12
- package/lib/public/modules/session-actions.js +1 -1
- package/lib/public/modules/sidebar-mates.js +56 -552
- package/lib/public/modules/sidebar-mobile.js +7 -64
- package/lib/public/modules/sidebar-presence.js +37 -0
- package/lib/public/modules/split-pair-ui.js +13 -13
- package/lib/public/modules/split-view.js +7 -0
- package/lib/public/modules/sticky-notes.js +7 -6
- package/lib/public/modules/tool-input-composition.js +48 -0
- package/lib/public/modules/tool-llm-status.js +167 -0
- package/lib/public/modules/tool-renderer-advanced.js +285 -0
- package/lib/public/modules/tool-renderer-chart.js +158 -0
- package/lib/public/modules/tool-renderer-semantics.js +35 -0
- package/lib/public/modules/tool-renderer.js +464 -0
- package/lib/public/modules/tool-runtime.js +309 -0
- package/lib/public/modules/tool-ui-evaluator.js +97 -0
- package/lib/public/modules/tool-ui-tree.js +21 -0
- package/lib/public/modules/tui-attention.js +10 -0
- package/lib/public/modules/user-settings.js +16 -23
- package/lib/public/modules/vendor-login.js +287 -0
- package/lib/public/modules/worker-proposal.js +2 -2
- package/lib/public/modules/workspace-assignment-card.js +149 -0
- package/lib/public/modules/workspace-assignment-routing.js +4 -0
- package/lib/public/style.css +13 -2
- package/lib/runtime-env.js +65 -0
- package/lib/sdk-bridge.js +120 -32
- package/lib/sdk-message-processor.js +10 -6
- package/lib/server-home-capsule-creation.js +36 -0
- package/lib/server-home-chat-events.js +287 -0
- package/lib/server-home-chat.js +518 -0
- package/lib/server-home-clay-entry.js +65 -0
- package/lib/server-home-clay-session-links.js +26 -0
- package/lib/server-home-debate-planning.js +214 -0
- package/lib/server-home-debates.js +137 -0
- package/lib/server-home-mate-creation.js +261 -0
- package/lib/server-home-models.js +241 -0
- package/lib/server-home-preferences.js +61 -0
- package/lib/server-mates.js +37 -0
- package/lib/server-tools.js +377 -0
- package/lib/server.js +111 -59
- package/lib/session-pair-mcp-server.js +6 -6
- package/lib/sessions.js +18 -3
- package/lib/tool-capsule-source.js +142 -0
- package/lib/tool-control-mcp-server.js +126 -0
- package/lib/tool-llm.js +48 -0
- package/lib/tool-storage.js +77 -0
- package/lib/tool-ui-spec-advanced.js +82 -0
- package/lib/tool-ui-spec.js +261 -0
- package/lib/tools-registry.js +286 -0
- package/lib/users-home-dock-preferences.js +77 -0
- package/lib/users-home-surface-preferences.js +99 -0
- package/lib/users-preferences.js +4 -7
- package/lib/users.js +12 -0
- package/lib/whats-new-content.js +3 -3
- package/lib/workspace-assignment-service.js +420 -0
- package/lib/workspace-query-mcp-server.js +154 -0
- package/lib/workspace-query-service.js +492 -0
- package/lib/ws-schema.js +93 -12
- package/lib/yoke/adapters/acp.js +2 -1
- package/lib/yoke/adapters/antigravity.js +2 -1
- package/lib/yoke/adapters/claude-worker.js +11 -4
- package/lib/yoke/adapters/claude.js +73 -43
- package/lib/yoke/adapters/codex.js +40 -10
- package/lib/yoke/adapters/kiro.js +2 -1
- package/lib/yoke/claude-user-input.js +38 -0
- package/lib/yoke/codex-app-server.js +20 -2
- package/lib/yoke/codex-user-input.js +64 -0
- package/lib/yoke/complete-once.js +164 -0
- package/lib/yoke/index.js +5 -1
- package/lib/yoke/interface.js +19 -0
- package/lib/yoke/mcp-bridge-server.js +2 -6
- package/lib/yoke/user-input.js +254 -0
- package/package.json +3 -2
- package/lib/public/css/home-chat.css +0 -380
- package/lib/public/modules/home-chat.js +0 -438
- package/lib/server-clay-home.js +0 -245
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
// Centered General/Model/Memory/Knowledge settings dialog.
|
|
2
|
+
|
|
3
|
+
import { store } from './store.js';
|
|
4
|
+
import { getWs } from './ws-ref.js';
|
|
5
|
+
import { iconHtml, refreshIcons } from './icons.js';
|
|
6
|
+
import { editMateProfile, confirmMateRemoval } from './mate-management.js';
|
|
7
|
+
import { resetHomeMateModelPicker, clearHomeMateModelPicker, requestHomeMateModels, renderHomeMateModelPicker, applyHomeMateModelsState, applyHomeMateModelResult } from './home-mate-model-picker.js';
|
|
8
|
+
|
|
9
|
+
var dialog = null;
|
|
10
|
+
var dialogOpener = null;
|
|
11
|
+
var dialogMateId = null;
|
|
12
|
+
var dialogSection = "general";
|
|
13
|
+
var modelRequested = false;
|
|
14
|
+
var memoryState = null;
|
|
15
|
+
var knowledgeState = null;
|
|
16
|
+
var memoryRequestId = null;
|
|
17
|
+
var knowledgeRequestId = null;
|
|
18
|
+
var requestSequence = 0;
|
|
19
|
+
|
|
20
|
+
function getMate(mateId) {
|
|
21
|
+
var mates = store.get('cachedMatesList') || [];
|
|
22
|
+
for (var i = 0; i < mates.length; i++) {
|
|
23
|
+
if (mates[i] && mates[i].id === mateId) return mates[i];
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getMateName(mate) {
|
|
29
|
+
var profile = mate && mate.profile ? mate.profile : {};
|
|
30
|
+
return profile.displayName || (mate && (mate.displayName || mate.name)) || "Mate";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function send(message) {
|
|
34
|
+
var ws = getWs();
|
|
35
|
+
if (!ws || ws.readyState !== 1) return false;
|
|
36
|
+
ws.send(JSON.stringify(message));
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function nextRequestId(kind) {
|
|
41
|
+
requestSequence++;
|
|
42
|
+
return "home-mate-settings-" + kind + "-" + Date.now() + "-" + requestSequence;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function isNarrow() {
|
|
46
|
+
return !!window.matchMedia && window.matchMedia("(max-width: 768px)").matches;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function setTransientDrawerMask(masked) {
|
|
50
|
+
var hub = document.getElementById("home-hub");
|
|
51
|
+
if (hub) hub.classList.toggle("home-settings-drawer-masked", masked && isNarrow());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function focusableElements(root) {
|
|
55
|
+
return root ? root.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])') : [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function restoreModelFocusAfterRender() {
|
|
59
|
+
var active = document.activeElement;
|
|
60
|
+
var focusedModel = active && active.dataset ? active.dataset.homeMateModel : null;
|
|
61
|
+
var focusedVendor = active && active.dataset ? active.dataset.homeMateVendor : null;
|
|
62
|
+
var focusedControl = active && active.dataset ? active.dataset.homeModelFocus : null;
|
|
63
|
+
return function () {
|
|
64
|
+
if (!dialog) return;
|
|
65
|
+
var selectors = [
|
|
66
|
+
{ selector: "[data-home-mate-model]", key: "homeMateModel", value: focusedModel },
|
|
67
|
+
{ selector: "[data-home-mate-vendor]", key: "homeMateVendor", value: focusedVendor },
|
|
68
|
+
{ selector: "[data-home-model-focus]", key: "homeModelFocus", value: focusedControl },
|
|
69
|
+
];
|
|
70
|
+
for (var i = 0; i < selectors.length; i++) {
|
|
71
|
+
if (!selectors[i].value) continue;
|
|
72
|
+
var nodes = dialog.querySelectorAll(selectors[i].selector);
|
|
73
|
+
for (var j = 0; j < nodes.length; j++) {
|
|
74
|
+
if (nodes[j].dataset[selectors[i].key] !== selectors[i].value) continue;
|
|
75
|
+
nodes[j].focus({ preventScroll: true });
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function addEmpty(container, text) {
|
|
83
|
+
var empty = document.createElement("div");
|
|
84
|
+
empty.className = "home-mate-settings-empty";
|
|
85
|
+
empty.textContent = text;
|
|
86
|
+
container.appendChild(empty);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function renderGeneral(body, mate) {
|
|
90
|
+
var profile = mate && mate.profile ? mate.profile : {};
|
|
91
|
+
var identity = document.createElement("section");
|
|
92
|
+
identity.className = "home-mate-settings-identity";
|
|
93
|
+
var eyebrow = document.createElement("span");
|
|
94
|
+
eyebrow.textContent = mate && mate.primary ? "Primary Mate" : mate && mate.builtinKey ? "Built-in Mate" : "Custom Mate";
|
|
95
|
+
var name = document.createElement("h3");
|
|
96
|
+
name.textContent = getMateName(mate);
|
|
97
|
+
var bio = document.createElement("p");
|
|
98
|
+
bio.textContent = profile.bio || (mate && mate.bio) || "Profile and management controls for this Mate.";
|
|
99
|
+
identity.appendChild(eyebrow);
|
|
100
|
+
identity.appendChild(name);
|
|
101
|
+
identity.appendChild(bio);
|
|
102
|
+
body.appendChild(identity);
|
|
103
|
+
if (!mate || mate.primary) {
|
|
104
|
+
addEmpty(body, "This primary Mate is managed by Clay.");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
var actions = document.createElement("div");
|
|
108
|
+
actions.className = "home-mate-settings-actions";
|
|
109
|
+
var edit = document.createElement("button");
|
|
110
|
+
edit.type = "button";
|
|
111
|
+
edit.className = "home-mate-settings-action";
|
|
112
|
+
edit.innerHTML = iconHtml("edit-2") + "<span>Edit profile</span>";
|
|
113
|
+
edit.addEventListener("click", function () { editMateProfile(edit, mate); });
|
|
114
|
+
var remove = document.createElement("button");
|
|
115
|
+
remove.type = "button";
|
|
116
|
+
remove.className = "home-mate-settings-action is-danger";
|
|
117
|
+
remove.innerHTML = iconHtml(mate.builtinKey ? "minus-circle" : "trash-2");
|
|
118
|
+
var removeLabel = document.createElement("span");
|
|
119
|
+
removeLabel.textContent = mate.builtinKey ? "Remove Mate" : "Delete Mate";
|
|
120
|
+
remove.appendChild(removeLabel);
|
|
121
|
+
remove.addEventListener("click", function () { confirmMateRemoval(remove, mate, closeHomeMateSettings); });
|
|
122
|
+
actions.appendChild(edit);
|
|
123
|
+
actions.appendChild(remove);
|
|
124
|
+
body.appendChild(actions);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function renderMemory(body) {
|
|
128
|
+
if (!memoryState) {
|
|
129
|
+
addEmpty(body, "Loading memory…");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (memoryState.summary) {
|
|
133
|
+
var summary = document.createElement("section");
|
|
134
|
+
summary.className = "home-mate-settings-summary";
|
|
135
|
+
var heading = document.createElement("h3");
|
|
136
|
+
heading.textContent = "Working summary";
|
|
137
|
+
var text = document.createElement("p");
|
|
138
|
+
text.textContent = memoryState.summary;
|
|
139
|
+
summary.appendChild(heading);
|
|
140
|
+
summary.appendChild(text);
|
|
141
|
+
body.appendChild(summary);
|
|
142
|
+
}
|
|
143
|
+
var entries = memoryState.entries || [];
|
|
144
|
+
for (var i = 0; i < entries.length; i++) {
|
|
145
|
+
var item = document.createElement("article");
|
|
146
|
+
item.className = "home-mate-settings-memory";
|
|
147
|
+
var title = document.createElement("h3");
|
|
148
|
+
title.textContent = entries[i].topic || entries[i].date || "Memory";
|
|
149
|
+
var detail = document.createElement("p");
|
|
150
|
+
detail.textContent = entries[i].my_position || entries[i].decisions || entries[i].outcome || "";
|
|
151
|
+
item.appendChild(title);
|
|
152
|
+
if (detail.textContent) item.appendChild(detail);
|
|
153
|
+
body.appendChild(item);
|
|
154
|
+
}
|
|
155
|
+
if (!memoryState.summary && !entries.length) addEmpty(body, "No memories yet.");
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function renderKnowledge(body) {
|
|
159
|
+
if (!knowledgeState) {
|
|
160
|
+
addEmpty(body, "Loading knowledge…");
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
var files = knowledgeState.files || [];
|
|
164
|
+
for (var i = 0; i < files.length; i++) {
|
|
165
|
+
var item = document.createElement("div");
|
|
166
|
+
item.className = "home-mate-settings-file";
|
|
167
|
+
item.innerHTML = iconHtml("file-text");
|
|
168
|
+
var name = document.createElement("span");
|
|
169
|
+
name.textContent = typeof files[i] === "string" ? files[i] : files[i].name || "Untitled";
|
|
170
|
+
item.appendChild(name);
|
|
171
|
+
body.appendChild(item);
|
|
172
|
+
}
|
|
173
|
+
if (!files.length) addEmpty(body, "No knowledge files yet.");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function requestSection(section) {
|
|
177
|
+
if (section === "model" && !modelRequested) {
|
|
178
|
+
modelRequested = true;
|
|
179
|
+
var mate = getMate(dialogMateId);
|
|
180
|
+
requestHomeMateModels((mate || {}).vendor || "", renderDialogContent, false);
|
|
181
|
+
}
|
|
182
|
+
if (section === "memory") {
|
|
183
|
+
memoryState = null;
|
|
184
|
+
memoryRequestId = nextRequestId("memory");
|
|
185
|
+
send({ type: "home_mate_memory_list", mateId: dialogMateId, requestId: memoryRequestId });
|
|
186
|
+
}
|
|
187
|
+
if (section === "knowledge") {
|
|
188
|
+
knowledgeState = null;
|
|
189
|
+
knowledgeRequestId = nextRequestId("knowledge");
|
|
190
|
+
send({ type: "home_mate_knowledge_list", mateId: dialogMateId, requestId: knowledgeRequestId });
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function renderDialogContent() {
|
|
195
|
+
if (!dialog) return;
|
|
196
|
+
var body = dialog.querySelector(".home-mate-settings-body");
|
|
197
|
+
if (!body) return;
|
|
198
|
+
body.innerHTML = "";
|
|
199
|
+
var mate = getMate(dialogMateId);
|
|
200
|
+
var contentTitle = dialog.querySelector(".home-mate-settings-content-title");
|
|
201
|
+
if (contentTitle) contentTitle.textContent = dialogSection.charAt(0).toUpperCase() + dialogSection.slice(1) + " settings";
|
|
202
|
+
if (dialogSection === "general") renderGeneral(body, mate);
|
|
203
|
+
else if (dialogSection === "model") renderHomeMateModelPicker(body, renderDialogContent);
|
|
204
|
+
else if (dialogSection === "memory") renderMemory(body);
|
|
205
|
+
else renderKnowledge(body);
|
|
206
|
+
var nav = dialog.querySelectorAll("[data-home-mate-settings-section]");
|
|
207
|
+
for (var i = 0; i < nav.length; i++) {
|
|
208
|
+
var active = nav[i].dataset.homeMateSettingsSection === dialogSection;
|
|
209
|
+
nav[i].classList.toggle("is-active", active);
|
|
210
|
+
if (active) nav[i].setAttribute("aria-current", "page");
|
|
211
|
+
else nav[i].removeAttribute("aria-current");
|
|
212
|
+
}
|
|
213
|
+
refreshIcons();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function selectSection(section, focusContent) {
|
|
217
|
+
if (section !== "general" && section !== "model" && section !== "memory" && section !== "knowledge") return;
|
|
218
|
+
dialogSection = section;
|
|
219
|
+
requestSection(section);
|
|
220
|
+
renderDialogContent();
|
|
221
|
+
if (focusContent && dialog) {
|
|
222
|
+
var heading = dialog.querySelector(".home-mate-settings-content-title");
|
|
223
|
+
if (heading) heading.focus({ preventScroll: true });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function handleDialogKeydown(event) {
|
|
228
|
+
if (!dialog) return;
|
|
229
|
+
if (document.querySelector(".profile-popover") || document.querySelector("#confirm-modal:not(.hidden)")) return;
|
|
230
|
+
if (event.key === "Escape") {
|
|
231
|
+
event.preventDefault();
|
|
232
|
+
event.stopPropagation();
|
|
233
|
+
closeHomeMateSettings();
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (event.key !== "Tab") return;
|
|
237
|
+
var focusable = focusableElements(dialog);
|
|
238
|
+
if (!focusable.length) return;
|
|
239
|
+
var first = focusable[0];
|
|
240
|
+
var last = focusable[focusable.length - 1];
|
|
241
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
last.focus();
|
|
244
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
245
|
+
event.preventDefault();
|
|
246
|
+
first.focus();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function closeHomeMateSettings() {
|
|
251
|
+
var opener = dialogOpener;
|
|
252
|
+
if (dialog) dialog.remove();
|
|
253
|
+
dialog = null;
|
|
254
|
+
dialogMateId = null;
|
|
255
|
+
dialogOpener = null;
|
|
256
|
+
memoryRequestId = null;
|
|
257
|
+
knowledgeRequestId = null;
|
|
258
|
+
memoryState = null;
|
|
259
|
+
knowledgeState = null;
|
|
260
|
+
modelRequested = false;
|
|
261
|
+
clearHomeMateModelPicker();
|
|
262
|
+
document.removeEventListener("keydown", handleDialogKeydown, true);
|
|
263
|
+
document.body.classList.remove("home-mate-settings-open");
|
|
264
|
+
setTransientDrawerMask(false);
|
|
265
|
+
if (opener && opener.isConnected) opener.focus({ preventScroll: true });
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function openHomeMateSettings(mateId, opener, options) {
|
|
269
|
+
var mate = getMate(mateId);
|
|
270
|
+
if (!mate) return false;
|
|
271
|
+
closeHomeMateSettings();
|
|
272
|
+
dialogMateId = mateId;
|
|
273
|
+
dialogOpener = opener || document.activeElement;
|
|
274
|
+
dialogSection = options && options.section === "model" ? "model" : "general";
|
|
275
|
+
modelRequested = false;
|
|
276
|
+
resetHomeMateModelPicker(mateId, getMateName(mate), mate, options && options.sessionId);
|
|
277
|
+
var overlay = document.createElement("div");
|
|
278
|
+
overlay.className = "home-mate-settings-overlay";
|
|
279
|
+
var panel = document.createElement("section");
|
|
280
|
+
panel.className = "home-mate-settings-dialog";
|
|
281
|
+
panel.setAttribute("role", "dialog");
|
|
282
|
+
panel.setAttribute("aria-modal", "true");
|
|
283
|
+
panel.setAttribute("aria-labelledby", "home-mate-settings-title");
|
|
284
|
+
var header = document.createElement("header");
|
|
285
|
+
header.className = "home-mate-settings-header";
|
|
286
|
+
var titleWrap = document.createElement("div");
|
|
287
|
+
var eyebrow = document.createElement("span");
|
|
288
|
+
eyebrow.textContent = getMateName(mate);
|
|
289
|
+
var title = document.createElement("h2");
|
|
290
|
+
title.id = "home-mate-settings-title";
|
|
291
|
+
title.textContent = "Mate settings";
|
|
292
|
+
titleWrap.appendChild(eyebrow);
|
|
293
|
+
titleWrap.appendChild(title);
|
|
294
|
+
var close = document.createElement("button");
|
|
295
|
+
close.type = "button";
|
|
296
|
+
close.className = "home-mate-settings-close";
|
|
297
|
+
close.setAttribute("aria-label", "Close Mate settings");
|
|
298
|
+
close.setAttribute("title", "Close");
|
|
299
|
+
close.innerHTML = iconHtml("x");
|
|
300
|
+
close.addEventListener("click", closeHomeMateSettings);
|
|
301
|
+
header.appendChild(titleWrap);
|
|
302
|
+
header.appendChild(close);
|
|
303
|
+
var layout = document.createElement("div");
|
|
304
|
+
layout.className = "home-mate-settings-layout";
|
|
305
|
+
var nav = document.createElement("nav");
|
|
306
|
+
nav.className = "home-mate-settings-nav";
|
|
307
|
+
nav.setAttribute("aria-label", "Mate settings sections");
|
|
308
|
+
var sections = ["general", "model", "memory", "knowledge"];
|
|
309
|
+
for (var i = 0; i < sections.length; i++) {
|
|
310
|
+
(function (section) {
|
|
311
|
+
var button = document.createElement("button");
|
|
312
|
+
button.type = "button";
|
|
313
|
+
button.dataset.homeMateSettingsSection = section;
|
|
314
|
+
button.textContent = section.charAt(0).toUpperCase() + section.slice(1);
|
|
315
|
+
button.addEventListener("click", function () { selectSection(section, true); });
|
|
316
|
+
nav.appendChild(button);
|
|
317
|
+
})(sections[i]);
|
|
318
|
+
}
|
|
319
|
+
var content = document.createElement("section");
|
|
320
|
+
content.className = "home-mate-settings-content";
|
|
321
|
+
var contentTitle = document.createElement("h3");
|
|
322
|
+
contentTitle.className = "home-mate-settings-content-title sr-only";
|
|
323
|
+
contentTitle.tabIndex = -1;
|
|
324
|
+
contentTitle.textContent = "Mate settings content";
|
|
325
|
+
var body = document.createElement("div");
|
|
326
|
+
body.className = "home-mate-settings-body";
|
|
327
|
+
content.appendChild(contentTitle);
|
|
328
|
+
content.appendChild(body);
|
|
329
|
+
layout.appendChild(nav);
|
|
330
|
+
layout.appendChild(content);
|
|
331
|
+
panel.appendChild(header);
|
|
332
|
+
panel.appendChild(layout);
|
|
333
|
+
overlay.appendChild(panel);
|
|
334
|
+
overlay.addEventListener("click", function (event) { if (event.target === overlay) closeHomeMateSettings(); });
|
|
335
|
+
document.body.appendChild(overlay);
|
|
336
|
+
dialog = overlay;
|
|
337
|
+
document.body.classList.add("home-mate-settings-open");
|
|
338
|
+
setTransientDrawerMask(true);
|
|
339
|
+
document.addEventListener("keydown", handleDialogKeydown, true);
|
|
340
|
+
renderDialogContent();
|
|
341
|
+
requestSection(dialogSection);
|
|
342
|
+
refreshIcons();
|
|
343
|
+
requestAnimationFrame(function () { close.focus({ preventScroll: true }); });
|
|
344
|
+
return true;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export function handleHomeMateMemoryState(msg) {
|
|
348
|
+
if (!dialog || dialogSection !== "memory" || msg.mateId !== dialogMateId || msg.requestId !== memoryRequestId) return false;
|
|
349
|
+
memoryState = { summary: msg.summary || "", entries: msg.entries || [] };
|
|
350
|
+
renderDialogContent();
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export function handleHomeMateKnowledgeState(msg) {
|
|
355
|
+
if (!dialog || dialogSection !== "knowledge" || msg.mateId !== dialogMateId || msg.requestId !== knowledgeRequestId) return false;
|
|
356
|
+
knowledgeState = { files: msg.files || [] };
|
|
357
|
+
renderDialogContent();
|
|
358
|
+
return true;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export function handleHomeMateModelsState(msg) {
|
|
362
|
+
if (!dialog || !applyHomeMateModelsState(msg)) return false;
|
|
363
|
+
if (dialogSection === "model") {
|
|
364
|
+
var restoreFocus = restoreModelFocusAfterRender();
|
|
365
|
+
renderDialogContent();
|
|
366
|
+
restoreFocus();
|
|
367
|
+
}
|
|
368
|
+
return true;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export function handleHomeMateModelResult(msg) {
|
|
372
|
+
if (!dialog || !applyHomeMateModelResult(msg)) return false;
|
|
373
|
+
if (dialogSection === "model") {
|
|
374
|
+
var restoreFocus = restoreModelFocusAfterRender();
|
|
375
|
+
renderDialogContent();
|
|
376
|
+
restoreFocus();
|
|
377
|
+
}
|
|
378
|
+
return true;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function syncHomeMateSettingsTarget() {
|
|
382
|
+
if (dialogMateId && !getMate(dialogMateId)) closeHomeMateSettings();
|
|
383
|
+
}
|