diff-chat 0.1.0__py3-none-any.whl

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.
Files changed (91) hide show
  1. adapters/README.md +28 -0
  2. adapters/__init__.py +48 -0
  3. adapters/_base.py +102 -0
  4. adapters/_cli.py +405 -0
  5. adapters/claude.py +141 -0
  6. adapters/gemini.py +323 -0
  7. adapters/gpt.py +217 -0
  8. adapters/local.py +146 -0
  9. adapters/registry.py +33 -0
  10. api_fallback.py +189 -0
  11. app.py +827 -0
  12. app_preferences.py +205 -0
  13. archive_schema.py +142 -0
  14. attachments.py +129 -0
  15. chat_titles.py +60 -0
  16. connection_handoff.py +64 -0
  17. context_engine.py +256 -0
  18. conversation_actions.py +160 -0
  19. diff_chat-0.1.0.dist-info/METADATA +101 -0
  20. diff_chat-0.1.0.dist-info/RECORD +91 -0
  21. diff_chat-0.1.0.dist-info/WHEEL +4 -0
  22. diff_chat-0.1.0.dist-info/entry_points.txt +2 -0
  23. diff_chat-0.1.0.dist-info/licenses/LICENSE +21 -0
  24. diff_chat_assets/memory.example.md +1 -0
  25. diff_chat_assets/prompts/about_you_export.md +19 -0
  26. diff_chat_assets/settings.json +6 -0
  27. diff_chat_assets/static/about-you-parser.js +46 -0
  28. diff_chat_assets/static/about-you.js +171 -0
  29. diff_chat_assets/static/actions.css +275 -0
  30. diff_chat_assets/static/actions.js +650 -0
  31. diff_chat_assets/static/app.css +345 -0
  32. diff_chat_assets/static/app.js +1344 -0
  33. diff_chat_assets/static/attachments.js +80 -0
  34. diff_chat_assets/static/brand/favicon-32.png +0 -0
  35. diff_chat_assets/static/brand/icon.svg +11 -0
  36. diff_chat_assets/static/brand/wordmark-dark.svg +15 -0
  37. diff_chat_assets/static/brand/wordmark-light.svg +13 -0
  38. diff_chat_assets/static/characters/CREDITS.md +7 -0
  39. diff_chat_assets/static/characters/characters.css +37 -0
  40. diff_chat_assets/static/characters/claude.json +507 -0
  41. diff_chat_assets/static/characters/claude.png +0 -0
  42. diff_chat_assets/static/characters/claude.webp +0 -0
  43. diff_chat_assets/static/characters/gemini.json +54 -0
  44. diff_chat_assets/static/characters/gemini.png +0 -0
  45. diff_chat_assets/static/characters/gemini.webp +0 -0
  46. diff_chat_assets/static/characters/gpt.json +507 -0
  47. diff_chat_assets/static/characters/gpt.png +0 -0
  48. diff_chat_assets/static/characters/gpt.webp +0 -0
  49. diff_chat_assets/static/characters/local.json +387 -0
  50. diff_chat_assets/static/characters/local.png +0 -0
  51. diff_chat_assets/static/characters/local.webp +0 -0
  52. diff_chat_assets/static/characters/player.js +318 -0
  53. diff_chat_assets/static/chat-filing.js +84 -0
  54. diff_chat_assets/static/controls.js +194 -0
  55. diff_chat_assets/static/corners.css +59 -0
  56. diff_chat_assets/static/craft.css +246 -0
  57. diff_chat_assets/static/drafts.js +41 -0
  58. diff_chat_assets/static/index.html +208 -0
  59. diff_chat_assets/static/library.css +30 -0
  60. diff_chat_assets/static/library.js +181 -0
  61. diff_chat_assets/static/memory.js +81 -0
  62. diff_chat_assets/static/preference-dialog.js +21 -0
  63. diff_chat_assets/static/preferences.css +56 -0
  64. diff_chat_assets/static/session.js +46 -0
  65. diff_chat_assets/static/settings.css +111 -0
  66. diff_chat_assets/static/settings.js +463 -0
  67. diff_chat_assets/static/setup.js +238 -0
  68. diff_chat_assets/static/utility.js +64 -0
  69. diff_chat_assets/static/vendor/LICENSES.txt +531 -0
  70. diff_chat_assets/static/vendor/highlight.min.js +1262 -0
  71. diff_chat_assets/static/vendor/markdown-it.min.js +13 -0
  72. diff_chat_assets/static/vendor/plex-mono.woff2 +0 -0
  73. diff_chat_assets/static/vendor/plex-sans.woff2 +0 -0
  74. diff_launcher.py +93 -0
  75. discussion.py +239 -0
  76. history_search.py +68 -0
  77. library_manager.py +251 -0
  78. model_options.py +132 -0
  79. plan_usage.py +72 -0
  80. private_store.py +71 -0
  81. probe.py +195 -0
  82. runtime_paths.py +195 -0
  83. server_security.py +100 -0
  84. setup_status.py +123 -0
  85. shared_memory.py +189 -0
  86. storage.py +185 -0
  87. usage_budget.py +77 -0
  88. usage_claude.py +110 -0
  89. usage_codex.py +170 -0
  90. usage_gemini.py +70 -0
  91. utility_models.py +104 -0
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+
3
+ (() => {
4
+ const panel = preferenceDialog("connections-panel", "Connect models", `
5
+ <p class="preference-description"></p>
6
+ <div id="connection-list"></div><div class="setup-controls">
7
+ <button id="recheck-connections" class="settings-action" type="button">Check again</button>
8
+ <button id="setup-settings" class="quiet-button" type="button">Settings</button>
9
+ <button id="setup-continue" class="preference-save" type="button" disabled>Continue</button></div>`);
10
+ const list = byId("connection-list"), refresh = byId("recheck-connections");
11
+ const proceed = byId("setup-continue"), settingsButton = byId("setup-settings");
12
+ const close = panel.dialog.querySelector(".preference-head button");
13
+ const pending = new Set(), launching = new Set();
14
+ const rendered = new Map();
15
+ let ready = [], finish, required = false, checking, previous = {};
16
+
17
+ function describe(firstRun) {
18
+ required = firstRun;
19
+ close.hidden = firstRun;
20
+ settingsButton.hidden = proceed.hidden = !firstRun;
21
+ panel.body.querySelector(".preference-description").textContent = firstRun
22
+ ? "Connect one participant to start. You can add others here later."
23
+ : "Connect or disconnect participants for all your chats in diff. Current replies can finish.";
24
+ }
25
+
26
+ function commandLine(provider, command) {
27
+ const line = element("div", "connection-command"), code = element("code", "", command);
28
+ const copy = element("button", "quiet-button", "Copy");
29
+ copy.type = "button";
30
+ copy.setAttribute("aria-label", "Copy " + names[provider] + " setup command");
31
+ copy.onclick = async () => {
32
+ pending.add(provider);
33
+ try { await navigator.clipboard.writeText(command); copy.textContent = "Copied"; }
34
+ catch {
35
+ const range = new Range();
36
+ range.selectNodeContents(code);
37
+ const selection = getSelection();
38
+ selection.removeAllRanges(); selection.addRange(range);
39
+ panel.status.textContent = "Command selected. Use your copy shortcut.";
40
+ }
41
+ };
42
+ line.append(code, copy);
43
+ return line;
44
+ }
45
+
46
+ function available(provider, item) {
47
+ return item?.status === "ready" || (item?.status !== "disconnected" && window.diffSettings?.[provider]?.api_fallback);
48
+ }
49
+
50
+ function connectionButton(provider, disconnect) {
51
+ const label = disconnect ? "Disconnect" : "Reconnect";
52
+ const button = element("button", "connection-action", label);
53
+ button.type = "button";
54
+ button.setAttribute("aria-label", label + " " + names[provider]);
55
+ button.title = disconnect ? "Disconnect from diff on this computer" : "Use this participant in diff again";
56
+ button.onclick = async () => {
57
+ button.disabled = true;
58
+ button.textContent = disconnect ? "Disconnecting…" : "Reconnecting…";
59
+ try {
60
+ await api("/api/setup/" + provider + "/actions/" + label.toLowerCase(), {});
61
+ pending.delete(provider);
62
+ await checking;
63
+ await check(true);
64
+ if (panel.dialog.open && (document.activeElement === document.body || panel.dialog === document.activeElement)) {
65
+ list.querySelector('[data-participant="' + provider + '"] .connection-action')?.focus({preventScroll:true});
66
+ }
67
+ } catch (error) {
68
+ panel.status.textContent = error.message;
69
+ } finally { button.disabled = false; button.textContent = label; }
70
+ };
71
+ return button;
72
+ }
73
+
74
+ function draw(rows) {
75
+ for (const provider of models) {
76
+ const item = rows[provider] || {hint: "Connection status unavailable."};
77
+ const signature = JSON.stringify([item, Boolean(available(provider, item))]);
78
+ if (rendered.get(provider) === signature) continue;
79
+ const old = list.querySelector('[data-participant="' + provider + '"]');
80
+ const row = participantStyle(element("section", "connection-row"), provider);
81
+ const head = element("div", "connection-title");
82
+ head.append(element("h3", "", names[provider]));
83
+ row.append(head, element("p", "", item.hint));
84
+ if (item.status === "ready") {
85
+ head.append(element("span", "connection-ready", "Connected"));
86
+ pending.delete(provider);
87
+ } else if (item.status === "disconnected") {
88
+ head.append(connectionButton(provider, false));
89
+ } else if (item.action) {
90
+ const action = element("button", "connection-action", item.action.label);
91
+ const notice = element("p", "connection-notice");
92
+ notice.setAttribute("role", "status");
93
+ row.append(notice);
94
+ action.type = "button";
95
+ action.disabled = launching.has(provider);
96
+ head.append(action);
97
+ action.onclick = async () => {
98
+ if (launching.has(provider)) return;
99
+ launching.add(provider); pending.add(provider); action.disabled = true;
100
+ try {
101
+ await api("/api/setup/" + provider + "/actions/" + item.action.id, {});
102
+ notice.textContent = "Finish setup in the terminal, then return to diff.";
103
+ } catch (error) {
104
+ pending.delete(provider);
105
+ notice.textContent = error.message;
106
+ const details = row.querySelector("details");
107
+ if (details) details.open = true;
108
+ } finally {
109
+ launching.delete(provider);
110
+ const current = list.querySelector('[data-participant="' + provider + '"] .connection-action');
111
+ if (current) current.disabled = false;
112
+ }
113
+ };
114
+ }
115
+ if (available(provider, item)) head.append(connectionButton(provider, true));
116
+ if (item.install_url && !item.action) {
117
+ const url = new URL(item.install_url);
118
+ if (url.protocol === "https:") {
119
+ const link = element("a", "connection-action", "Installation guide");
120
+ link.href = url.href; link.target = "_blank"; link.rel = "noopener noreferrer";
121
+ link.onclick = () => pending.add(provider);
122
+ head.append(link);
123
+ }
124
+ }
125
+ const commands = item.commands?.length ? item.commands :
126
+ [item.command, item.suggestion].filter(Boolean).map(command => ({command}));
127
+ if (commands.length) {
128
+ const instructions = item.action ? element("details", "connection-manual") : row;
129
+ if (item.action) {
130
+ instructions.append(element("summary", "", "Show setup command"));
131
+ row.append(instructions);
132
+ }
133
+ for (const {label, command} of commands) {
134
+ if (label) instructions.append(element("p", "", label));
135
+ instructions.append(commandLine(provider, command));
136
+ }
137
+ }
138
+ if (old) old.replaceWith(row);
139
+ else list.append(row);
140
+ rendered.set(provider, signature);
141
+ }
142
+ ready = models.filter(p => available(p, rows[p]));
143
+ proceed.disabled = !ready.length;
144
+ proceed.textContent = ready.length === 1 ? "Continue with " + names[ready[0]] : "Continue";
145
+ }
146
+
147
+ async function load(force) {
148
+ refresh.disabled = true; panel.status.textContent = "Checking connections…";
149
+ try {
150
+ const rows = await api("/api/setup" + (force ? "?refresh=1" : ""));
151
+ const newlyReady = models.filter(p => rows[p]?.status === "ready" && previous[p]?.status !== "ready");
152
+ const completed = newlyReady.filter(p => pending.has(p));
153
+ const availabilityChanged = models.some(p => (previous[p]?.status === "ready") !== (rows[p]?.status === "ready") ||
154
+ Boolean(catalog[p]?.disconnected) !== (rows[p]?.status === "disconnected"));
155
+ draw(rows);
156
+ if (chat && availabilityChanged) {
157
+ const state = await api("/api/state");
158
+ await preferenceWrites;
159
+ catalog = state.model_options;
160
+ loadPreferences({...chat.preferences, ...preferences});
161
+ for (const p of models) renderUsage(p);
162
+ refreshUsage();
163
+ }
164
+ previous = rows;
165
+ document.dispatchEvent(new CustomEvent("diff:connections", {detail: rows}));
166
+ panel.status.textContent = completed.length ? completed.map(p => names[p]).join(", ") + " connected. Select the chip beside your message to include it." : "";
167
+ return rows;
168
+ } catch (e) { panel.status.textContent = e.message; return null; }
169
+ finally { refresh.disabled = false; }
170
+ }
171
+
172
+ function check(force) {
173
+ if (!checking) checking = load(force).finally(() => { checking = null; });
174
+ return checking;
175
+ }
176
+ window.openDiffConnections = async (provider) => {
177
+ if (!chat && !panel.dialog.open) return;
178
+ if (!panel.dialog.open) {
179
+ describe(false);
180
+ panel.show();
181
+ } else if (byId("settings-window")?.open && required) {
182
+ byId("settings-window").close();
183
+ }
184
+ await check(true);
185
+ if (models.includes(provider) && panel.dialog.open) {
186
+ list.querySelector('[data-participant="' + provider + '"] :is(.connection-action, button)')?.focus();
187
+ }
188
+ };
189
+ byId("connect-models").onclick = () => window.openDiffConnections();
190
+ window.diffNeedsConnection = provider => catalog[provider]?.disconnected ||
191
+ (previous[provider] && !available(provider, previous[provider]));
192
+ proceed.onclick = () => {
193
+ if (!required) return;
194
+ for (const p of models) {
195
+ if (ready.includes(p)) enabled.add(p); else enabled.delete(p);
196
+ remember("enable." + p, ready.includes(p) ? "yes" : "no");
197
+ fields.get(p).section.open = ready.includes(p);
198
+ }
199
+ required = false;
200
+ panel.dialog.close(); finish?.(); finish = null;
201
+ };
202
+ panel.dialog.addEventListener("cancel", e => { if (required) e.preventDefault(); });
203
+ refresh.onclick = () => check(true);
204
+ const onReturn = async () => {
205
+ if (document.hidden) return;
206
+ if (panel.dialog.open || pending.size) { check(true); return; }
207
+ if (!chat || checking) return;
208
+ try {
209
+ const off = await api("/api/setup/disconnected");
210
+ if (models.some(p => off.includes(p) !== Boolean(catalog[p]?.disconnected) ||
211
+ (previous[p] && off.includes(p) !== (previous[p].status === "disconnected")))) await check(true);
212
+ } catch { /* The next foreground check retries. */ }
213
+ };
214
+ window.addEventListener("focus", onReturn);
215
+ window.addEventListener("diff:active", onReturn);
216
+ document.addEventListener("visibilitychange", onReturn);
217
+ settingsButton.onclick = () => window.openDiffSettings?.("Models");
218
+ window.diffFirstRun = async () => {
219
+ if (setting("setup-complete", "") === "yes") {
220
+ api("/api/setup").then(rows => { if (!Object.keys(previous).length) previous = rows; }).catch(() => {});
221
+ return;
222
+ }
223
+ const desk = byId("desk"); desk.inert = true;
224
+ try {
225
+ describe(true);
226
+ const rows = await check(false);
227
+ const needsSetup = !rows || !models.every(p => rows[p]?.status === "ready");
228
+ if (needsSetup) {
229
+ panel.dialog.showModal();
230
+ await new Promise(resolve => { finish = resolve; });
231
+ }
232
+ required = false;
233
+ await window.diffOfferMemoryImport();
234
+ remember("setup-complete", "yes");
235
+ return needsSetup;
236
+ } finally { desk.inert = false; }
237
+ };
238
+ })();
@@ -0,0 +1,64 @@
1
+ (() => {
2
+ const panel = preferenceDialog('utility-panel', 'Summary model', `
3
+ <p class="preference-description">Choose who summarizes long conversations and prepares summaries for new chats.</p>
4
+ <form><label for="utility-model">Model</label><select id="utility-model"></select>
5
+ <label for="utility-effort">Reasoning level</label><select id="utility-effort"></select>
6
+ <p class="preference-hint" id="utility-hint"></p>
7
+ <div class="preference-footer"><button type="submit" class="preference-save">Save setting</button></div>
8
+ </form>`);
9
+ const select = byId('utility-model'), effort = byId('utility-effort');
10
+ const form = panel.body.querySelector('form');
11
+ let setting, choices, automatic;
12
+ function label(value) {
13
+ return catalog[value.provider]?.models.find(model => model.id === value.model)?.label || value.model || 'Automatic';
14
+ }
15
+ function display(value) {byId('utility-choice').textContent = label(value);}
16
+ function efforts(selected) {
17
+ const item = choices.get(select.value)?.item;
18
+ const levels = item?.efforts || ['automatic'];
19
+ effort.replaceChildren(...levels.map(level => new Option(({xhigh:'Extra high',default:'Model default'})[level] || effortLabel(level), level)));
20
+ effort.value = levels.includes(selected) ? selected : (levels.includes('low') ? 'low' : levels[0]);
21
+ effort.disabled = levels.length < 2;
22
+ const provider = choices.get(select.value)?.provider;
23
+ let hint = 'Automatic chooses a lightweight model from your enabled participants.';
24
+ if (!enabled.size) hint = 'Turn on a participant in the composer to run a summary.';
25
+ else if (provider && !enabled.has(provider)) hint = `${names[provider]} is off. Summaries will use ${label(automatic)} until you turn it on.`;
26
+ else if (provider) hint = `If you turn off ${names[provider]}, summaries use a lightweight model from the remaining participants.`;
27
+ byId('utility-hint').textContent = hint;
28
+ }
29
+ select.addEventListener('change', () => efforts());
30
+ document.addEventListener('transcript:chat-opened', () => api('/api/utility-model').then(data => display(data.value)).catch(() => {}));
31
+ byId('open-utility').addEventListener('click', async () => {
32
+ form.hidden = true; panel.show(); panel.status.textContent = 'Loading models…';
33
+ try {
34
+ const query = new URLSearchParams({models:models.filter(id => enabled.has(id)).join(','), chat_id:chat.id});
35
+ [setting, automatic] = await Promise.all([api('/api/utility-model'), api('/api/utility-model/automatic?' + query)]);
36
+ choices = new Map();
37
+ select.replaceChildren(new Option(automatic.model ? `Automatic · ${label(automatic)}` : 'Automatic · lightweight', 'auto'));
38
+ for (const provider of models) {
39
+ const group = document.createElement('optgroup'); group.label = names[provider];
40
+ for (const item of catalog[provider]?.models || []) {
41
+ const key = provider + '/' + item.id;
42
+ choices.set(key, {provider, item}); group.append(new Option(item.label, key));
43
+ }
44
+ if (group.children.length) select.append(group);
45
+ }
46
+ const current = setting.value.provider + '/' + setting.value.model;
47
+ select.value = choices.has(current) ? current : 'auto'; efforts(setting.value.effort);
48
+ form.hidden = false;
49
+ panel.status.textContent = setting.value.provider !== 'auto' && !choices.has(current) ? 'Your previous choice is unavailable. Automatic is in use.' : '';
50
+ select.focus();
51
+ } catch (error) { panel.status.textContent = error.message; }
52
+ });
53
+ form.addEventListener('submit', async event => {
54
+ event.preventDefault();
55
+ const choice = choices.get(select.value);
56
+ const payload = choice ? {provider:choice.provider, model:choice.item.id, effort:effort.value} : {provider:'auto'};
57
+ const button = form.querySelector('button'); button.disabled = true;
58
+ try {
59
+ setting = await api('/api/utility-model', {...payload, revision:setting.revision}, 'PATCH');
60
+ display(setting.value); panel.dialog.close(); feedback('Summary model saved.');
61
+ } catch (error) {panel.status.textContent = error.message;}
62
+ finally {button.disabled = false;}
63
+ });
64
+ })();