aegiscode 7.0.26 → 7.0.27

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 (118) hide show
  1. package/SOURCE-OFFER.txt +9 -0
  2. package/package.json +4 -7
  3. package/scripts/check.mjs +1 -52
  4. package/scripts/demo.mjs +1 -94
  5. package/scripts/predist.mjs +1 -75
  6. package/scripts/runtests.mjs +1 -56
  7. package/scripts/seal-gate.mjs +1 -74
  8. package/src/agents.js +1 -139
  9. package/src/app.js +1 -2957
  10. package/src/art.js +1 -289
  11. package/src/chatflow.js +1 -3023
  12. package/src/checkpoint.js +1 -90
  13. package/src/clipboard.js +1 -424
  14. package/src/cloudsync.js +1 -528
  15. package/src/commands.js +1 -4089
  16. package/src/config.js +1 -581
  17. package/src/connect.js +1 -349
  18. package/src/credentials.js +1 -33
  19. package/src/deps.js +1 -232
  20. package/src/devrun.js +1 -187
  21. package/src/diff.js +1 -333
  22. package/src/diffview.js +1 -296
  23. package/src/engine.js +1 -297
  24. package/src/entitlement.js +1 -355
  25. package/src/events.js +1 -707
  26. package/src/export.js +1 -67
  27. package/src/filepreview.js +1 -153
  28. package/src/fingerprint.js +1 -592
  29. package/src/format.js +1 -259
  30. package/src/fuzzy.js +1 -119
  31. package/src/history.js +1 -423
  32. package/src/init.js +1 -175
  33. package/src/input.js +1 -139
  34. package/src/keys.js +1 -183
  35. package/src/markdown.js +1 -306
  36. package/src/models.js +1 -507
  37. package/src/naming.js +1 -57
  38. package/src/overlays.js +1 -462
  39. package/src/panels.js +1 -1418
  40. package/src/ping.js +1 -226
  41. package/src/presence.js +1 -238
  42. package/src/render.js +1 -516
  43. package/src/screen.js +1 -518
  44. package/src/screens.js +1 -896
  45. package/src/secret.js +1 -59
  46. package/src/securefs.js +1 -359
  47. package/src/settings.js +1 -155
  48. package/src/shared.js +1 -52
  49. package/src/sharedpaths.js +1 -53
  50. package/src/signup.js +1 -156
  51. package/src/summarize.js +1 -95
  52. package/src/sysdiag.js +1 -585
  53. package/src/system.js +1 -40
  54. package/src/theme.js +1 -570
  55. package/src/title.js +1 -220
  56. package/src/todos.js +1 -115
  57. package/src/tokens.js +1 -263
  58. package/src/topup.js +1 -210
  59. package/src/update.js +1 -191
  60. package/vendor/client/aegis.js +1 -2441
  61. package/vendor/client/attest.js +1 -518
  62. package/vendor/client/authorship-key.js +1 -410
  63. package/vendor/client/auto-provision.js +1 -134
  64. package/vendor/client/brain-catalog.js +1 -268
  65. package/vendor/client/byok-catalog.js +1 -199
  66. package/vendor/client/catalog-client.js +1 -487
  67. package/vendor/client/conversation-export.js +1 -177
  68. package/vendor/client/credentials.js +1 -494
  69. package/vendor/client/device-fingerprint.js +1 -141
  70. package/vendor/client/drive-connect.js +1 -110
  71. package/vendor/client/drive-upload.js +1 -234
  72. package/vendor/client/env-file.js +1 -1273
  73. package/vendor/client/fingerprint.js +1 -1064
  74. package/vendor/client/foreign-memory.js +1 -669
  75. package/vendor/client/google-signin.js +1 -133
  76. package/vendor/client/hooks.js +1 -430
  77. package/vendor/client/model-discovery.js +1 -373
  78. package/vendor/client/naming.js +1 -283
  79. package/vendor/client/platform.js +1 -937
  80. package/vendor/client/prefs.js +1 -351
  81. package/vendor/client/presence-constants.js +1 -107
  82. package/vendor/client/presence.js +1 -438
  83. package/vendor/client/record-vault.js +3 -1055
  84. package/vendor/client/session-store.js +1 -575
  85. package/vendor/client/topup.js +1 -297
  86. package/vendor/client/touch.js +1 -458
  87. package/vendor/client/update.js +1 -763
  88. package/vendor/client/user-models.js +1 -381
  89. package/vendor/desktop/lib/local/agents.js +1 -105
  90. package/vendor/desktop/lib/local/attachments.js +1 -276
  91. package/vendor/desktop/lib/local/autonomous.js +1 -1045
  92. package/vendor/desktop/lib/local/claude-pro.js +1 -1028
  93. package/vendor/desktop/lib/local/context.js +1 -125
  94. package/vendor/desktop/lib/local/engine.js +1 -3666
  95. package/vendor/desktop/lib/local/entitlement.js +1 -660
  96. package/vendor/desktop/lib/local/exec-plan.js +1 -269
  97. package/vendor/desktop/lib/local/git-scope.js +1 -228
  98. package/vendor/desktop/lib/local/integrity.js +1 -163
  99. package/vendor/desktop/lib/local/local.js +1 -2145
  100. package/vendor/desktop/lib/local/prompt.js +1 -280
  101. package/vendor/desktop/lib/local/queue.js +1 -560
  102. package/vendor/desktop/lib/local/session-rounds.js +1 -238
  103. package/vendor/desktop/lib/local/shell.js +1 -712
  104. package/vendor/desktop/lib/local/spill.js +1 -75
  105. package/vendor/desktop/lib/local/tools.js +1 -1328
  106. package/vendor/desktop/lib/local/turn-guard.js +1 -300
  107. package/vendor/desktop/lib/local/worktree-lock.js +1 -235
  108. package/vendor/desktop/lib/settings.js +1 -890
  109. package/vendor/desktop/main.js +3 -4890
  110. package/vendor/desktop/renderer/usage.js +1 -1239
  111. package/vendor/hosts/install.js +1 -638
  112. package/vendor/hosts/openai-shim.js +1 -515
  113. package/vendor/hosts/spec.js +1 -164
  114. package/vendor/hosts/targets.js +1 -346
  115. package/vendor/mcp/server.js +1 -221
  116. package/vendor/mcp/tools.js +1 -408
  117. package/vendor/one/src/child.js +1 -285
  118. package/vendor/one/src/permissions.js +1 -383
@@ -1,285 +1,3 @@
1
1
  // SPDX-License-Identifier: AGPL-3.0-or-later
2
2
  // Copyright (C) 2026 Niklas Borneklint — AEGIS Code (aegiscode) / Aegiscloud.
3
- // AEGIS Code (aegiscode) — source: https://github.com/aegisinfo/aegiscode-plugin
4
- // Conveying a modified copy, or running one as a network service, owes the
5
- // corresponding source under this licence (§5/§13) — see LICENSING.md.
6
- 'use strict';
7
-
8
- /**
9
- * Naming a conversation — the ONE implementation, for every host.
10
- *
11
- * `cli/src/naming.js` documented the ladder and the desktop face never got it:
12
- * the window named a thread with `prompt.slice(0, 60)` (renderer/app.js
13
- * `sync.save`) and `session-store.js`'s `recordExchange` seeds every CLI
14
- * session the same way. So a desktop thread called its first message a name —
15
- * "heey" in the sidebar, "can you fix the binaries for aegis-desktop. why is
16
- * old version kicking in" clipped mid-word — while the same conversation in a
17
- * terminal was named "Fix the desktop binaries". Same conversation, two names,
18
- * depending on which host you opened it in.
19
- *
20
- * This module is that ladder moved to `client/` so both faces share one
21
- * implementation instead of the desktop re-deriving it:
22
- *
23
- * 1. topicless first message (a greeting) → GENERIC_TITLE, and NO model call.
24
- * Asking just makes the model echo the prompt back ("heey" → "Heey
25
- * There"), so it is both cheaper and more deterministic to answer locally.
26
- * 2. the session's own model, one no-tool round, asked to name the
27
- * conversation (2–6 words, never the user's words verbatim).
28
- * 3. a purely local derivation from the prompt (capitalized head, stopwords
29
- * trimmed) when no model answered.
30
- *
31
- * Two guarantees carry over, and both are load-bearing:
32
- *
33
- * · a title that merely echoes the prompt ("fix bug" → "Fix The Bug") is not a
34
- * name — it is replaced by GENERIC_TITLE, and the caller keeps re-asking on
35
- * later turns until a real topic lands.
36
- * · naming is best-effort and never on the critical path: `nameConversation`
37
- * resolves (never throws) and its caller is free to ignore the result.
38
- *
39
- * The model round is *injected* (`callModel`), not spawned here: each host's
40
- * turn path already knows how to talk to whichever backend the session uses
41
- * (pooled, BYOK or the reference CLI), and a naming round must not become a
42
- * second, differently-authenticated client.
43
- *
44
- * `cli/src/naming.js` is now a thin re-export of this file, so the CLI's
45
- * existing callers and its test keep working while there is exactly one copy
46
- * of the rules. A fork here is how the two hosts' names would drift apart
47
- * again.
48
- */
49
-
50
- /** The name a conversation gets before it has a topic. Deliberately generic and
51
- * deliberately NOT the raw prompt — the whole point is that "heey" is not a
52
- * name, and the caller re-asks until a real one lands. */
53
- const GENERIC_TITLE = 'New conversation';
54
-
55
- const TITLE_SYSTEM =
56
- 'You name conversations. Write a short descriptive title (2 to 6 words) that captures the topic of the conversation. Never repeat the user\'s words verbatim — if the message is just a greeting or has no clear topic, name it something like "New conversation". Sentence case, no quotes, no markdown, no trailing punctuation, no explanation.';
57
-
58
- const isGenericTitle = (t) => !t || String(t).trim().toLowerCase() === GENERIC_TITLE.toLowerCase();
59
-
60
- // A greeting / topicless first message has no topic to name — asking the model
61
- // just makes it echo the prompt back ("heey" -> "Heey There"). Detect those up
62
- // front and skip the round entirely: it is cheaper and deterministic.
63
- const GREETINGS = new Set([
64
- 'hey', 'heey', 'heyy', 'heyyy', 'hi', 'hii', 'hello', 'hej', 'hejj', 'yo',
65
- 'sup', 'hola', 'howdy', 'hai', 'heyo', 'hiya', 'wassup', 'greetings',
66
- 'namaste', 'ahoy', 'hallo',
67
- ]);
68
-
69
- function isTopicless(raw) {
70
- const p = String(raw).trim().toLowerCase().replace(/[^a-z0-9\s]/g, ' ').replace(/\s+/g, ' ').trim();
71
- if (!p) return true;
72
- const words = p.split(' ');
73
- if (/^(good (morning|afternoon|evening)|whats up|wassup|hey there|hello there|hi there|how are you)\b/.test(p)) return true;
74
- // A lone greeting word, or a short greeting phrase (<=2 words, <=12 chars)
75
- // whose first word is a greeting, has no discernible topic.
76
- return words.length <= 2 && p.length <= 12 && GREETINGS.has(words[0]);
77
- }
78
-
79
- /** The model sometimes still echoes a short prompt despite the instruction
80
- * ("fix bug" -> "Fix The Bug"). That is not a rename; treat it as topicless. */
81
- function looksLikeEcho(title, prompt) {
82
- const norm = (s) => String(s).toLowerCase().replace(/[^a-z0-9\s]/g, '').replace(/\s+/g, ' ').trim();
83
- const t = norm(title);
84
- const p = norm(prompt);
85
- if (!t || !p) return false;
86
- if (t === p) return true;
87
- // Short prompt that the title merely prefixes with a trivial continuation.
88
- if (p.length <= 14 && (t.startsWith(p) || p.startsWith(t))) return true;
89
- // …and the rule the engine's own comment names but its test misses. The
90
- // engine compares raw prefixes, so its documented example — "fix bug" ->
91
- // "Fix The Bug" — slips through: the model inserted "the", `t.startsWith(p)`
92
- // is false, and the session keeps a title that is just the prompt again.
93
- // Compare the CONTENT words instead (function words dropped on both sides),
94
- // for short prompts only, where the risk of discarding a genuine title is
95
- // negligible and the benefit is the case the rule exists for.
96
- if (p.length <= 24) {
97
- const words = (s) => new Set((String(s).toLowerCase().match(/[a-z0-9]+/g) || []).filter((w) => !ECHO_STOP.has(w)));
98
- const a = words(title);
99
- const b = words(prompt);
100
- if (a.size && a.size === b.size && [...a].every((w) => b.has(w))) return true;
101
- }
102
- return false;
103
- }
104
-
105
- /** Function words that carry no topic, dropped before the echo comparison. */
106
- const ECHO_STOP = new Set([
107
- 'the', 'a', 'an', 'to', 'of', 'in', 'on', 'at', 'for', 'and', 'or', 'is',
108
- 'are', 'be', 'it', 'its', 'my', 'our', 'please', 'can', 'you', 'just', 'do',
109
- 'that', 'this',
110
- ]);
111
-
112
- /** One-line cleanup of whatever the model answered: no quotes, no markdown, no
113
- * trailing punctuation, clipped. '' means "unusable".
114
- *
115
- * Order matters: a model asked not to quote often answers `"Title: Fixing the
116
- * slow request."` anyway, and stripping the label prefix BEFORE the quotes
117
- * leaves it in place (the `^` never sees past the opening quote) — measured.
118
- * Quotes and markdown come off first, then the label. */
119
- function cleanTitle(raw) {
120
- return String(raw == null ? '' : raw)
121
- .replace(/\s+/g, ' ')
122
- .trim()
123
- .replace(/["'`“”‘’]/g, '')
124
- .replace(/[*_#]/g, '')
125
- .replace(/^\s*(?:title|name)\s*[:\-–]\s*/i, '')
126
- .replace(/[.\s]+$/g, '')
127
- .slice(0, 60)
128
- .trim();
129
- }
130
-
131
- /** The naming instruction the model is asked to answer (never the user's task). */
132
- const titlePromptOf = (prompt) =>
133
- `Write a short title for a conversation that begins with: "${String(prompt).slice(0, 500)}"`;
134
-
135
- /**
136
- * Politeness and throat-clearing, stripped from the front of a prompt, so the
137
- * fallback name says "Do the thing" instead of "Please Can You Just Do". Same
138
- * list the terminal title uses for its topic — one habit, stripped once.
139
- */
140
- const FILLER =
141
- /^(?:please|pls|plz|hey|hi|hello|ok(?:ay)?|so|now|just|also|and|then|maybe|well|um|uh|can you|could you|would you|will you|i want you to|i want to|i need you to|i need to|i'?d like you to|i would like you to|i'?d like to|help me|help|let'?s|lets|go ahead and)\b[\s,:;-]*/i;
142
-
143
- /** Words that carry no topic when trimming the tail of a derived name. */
144
- const TRAILING_STOP = new Set([
145
- 'the', 'a', 'an', 'in', 'on', 'at', 'to', 'for', 'of', 'and', 'or', 'with',
146
- 'is', 'are', 'my', 'our', 'this', 'that', 'please', 'can', 'you', 'could',
147
- 'would', 'i', 'we', 'just', 'do', 'it',
148
- ]);
149
-
150
- /**
151
- * Last rung: a name derived from the prompt, used only when no model answered.
152
- * Never the bare product name, and never the raw prompt verbatim.
153
- *
154
- * Sentence case, not Title Case: that is what TITLE_SYSTEM asks the model for,
155
- * so the fallback matches the names around it. (The engine's derivation
156
- * capitalizes every word — "Add A Retry To The Fetcher" — which reads like a
157
- * heading next to the model's own answers.)
158
- */
159
- function deriveTitle(prompt) {
160
- let body = String(prompt == null ? '' : prompt).trim().replace(/\s+/g, ' ');
161
- if (!body) return GENERIC_TITLE;
162
- for (let i = 0; i < 6; i++) {
163
- const next = body.replace(FILLER, '').trim();
164
- if (next === body) break;
165
- body = next;
166
- }
167
- const words = body.split(' ').filter(Boolean);
168
- if (!words.length) return GENERIC_TITLE;
169
- const head = words.slice(0, 6);
170
- while (head.length > 2 && TRAILING_STOP.has(head[head.length - 1].toLowerCase().replace(/[^a-z0-9]/g, ''))) head.pop();
171
- let out = head.join(' ').replace(/[.,!?;:]+$/, '').trim();
172
- if (!out) return GENERIC_TITLE;
173
- out = out[0].toUpperCase() + out.slice(1);
174
- return out.slice(0, 60).trim() || GENERIC_TITLE;
175
- }
176
-
177
- /**
178
- * Name a conversation from its first user prompt.
179
- *
180
- * `callModel(prompt, { system, signal, naming })` (async) is the caller's own
181
- * model seam and must return a string (or null). With no `callModel` — demo
182
- * mode, or a caller that has no backend — it answers from the local
183
- * derivation. Never throws; resolves '' only when there was no prompt at all
184
- * (the caller keeps whatever it had).
185
- *
186
- * `{ signal }` is honoured between rounds and passed through, so aborting a turn
187
- * abandons a naming round in flight rather than leaving it running.
188
- */
189
- async function nameConversation(prompt, { callModel, signal } = {}) {
190
- const raw = prompt == null ? '' : String(prompt);
191
- if (!raw.trim()) return '';
192
- if (isTopicless(raw)) return GENERIC_TITLE;
193
- if (typeof callModel === 'function' && !(signal && signal.aborted)) {
194
- let answer = null;
195
- try {
196
- answer = await callModel(titlePromptOf(raw), { system: TITLE_SYSTEM, signal, naming: true });
197
- } catch {
198
- answer = null;
199
- }
200
- const title = cleanTitle(answer);
201
- if (title) return looksLikeEcho(title, raw) ? GENERIC_TITLE : title;
202
- }
203
- return deriveTitle(raw);
204
- }
205
-
206
- /**
207
- * The title a session should carry after a later prompt, given the one it has.
208
- *
209
- * While the session is still wearing GENERIC_TITLE (the user opened with "heey"
210
- * and has now said what they actually want) the next real ask renames it; once
211
- * a real title exists it is kept, so a follow-up does not rename a session away
212
- * from its topic. `null` means "no opinion, keep what you have".
213
- *
214
- * `{ seeded: true }` covers the other way a session can still be unnamed: the
215
- * desktop's `prompt.slice(0, 60)` seed and `recordExchange`'s, which are
216
- * neither GENERIC_TITLE nor a name. The store records that distinction
217
- * (`session.named`), so the caller passes it rather than this module guessing
218
- * from the string.
219
- */
220
- async function refineTitle(currentTitle, prompt, opts = {}) {
221
- const named = opts && opts.named === true;
222
- const seeded = opts && opts.seeded === true;
223
- if (named) return null;
224
- if (!seeded && !isGenericTitle(currentTitle)) return null;
225
- if (!String(prompt || '').trim() || isTopicless(prompt)) return null;
226
- const next = await nameConversation(prompt, opts);
227
- const cleaned = cleanTitle(next);
228
- if (!cleaned || isGenericTitle(cleaned)) return null;
229
- return cleaned;
230
- }
231
-
232
- /**
233
- * Name a session in place, through the store both hosts read.
234
- *
235
- * This is the ONE entry point a host needs: it derives the name from the
236
- * prompt, skips a session that already has a real name, writes it to
237
- * `sessions.json` with `named: true`, and returns the name (or null when it
238
- * had no opinion). Best-effort — a store that cannot be written costs a label,
239
- * never a turn. `store` is injected so this module stays free of the store's
240
- * own locking and so a test can pass a stub.
241
- */
242
- async function nameSession(store, dir, sessionId, prompt, opts = {}) {
243
- if (!store || typeof store.setTitle !== 'function') return null;
244
- if (!sessionId) return null;
245
- const session = typeof store.getSession === 'function' ? store.getSession(dir, sessionId) : null;
246
- const current = session && session.title;
247
- const structured = { ...opts, seeded: !!(session && !session.named) };
248
- const next = await refineTitle(current, prompt, structured);
249
- if (next) {
250
- try {
251
- store.setTitle(dir, sessionId, next, { named: true });
252
- } catch {
253
- return null;
254
- }
255
- return next;
256
- }
257
- // A greeting names nothing, but the row should still say so instead of
258
- // wearing the raw prompt. The CLI does this too: `nameConversation` answers
259
- // GENERIC_TITLE and `setSessionTitle` writes it. Marked unnamed (`setTitle`
260
- // without `named`), so the next real ask still renames it — which is the
261
- // whole point of the ladder's first rung.
262
- if (isTopicless(prompt) && session && !session.named && !isGenericTitle(current)) {
263
- try {
264
- store.setTitle(dir, sessionId, GENERIC_TITLE);
265
- } catch {
266
- return null;
267
- }
268
- return GENERIC_TITLE;
269
- }
270
- return null;
271
- }
272
-
273
- module.exports = {
274
- GENERIC_TITLE,
275
- TITLE_SYSTEM,
276
- isGenericTitle,
277
- isTopicless,
278
- looksLikeEcho,
279
- cleanTitle,
280
- titlePromptOf,
281
- deriveTitle,
282
- nameConversation,
283
- refineTitle,
284
- nameSession,
285
- };
3
+ const e="New conversation",t='You name conversations. Write a short descriptive title (2 to 6 words) that captures the topic of the conversation. Never repeat the user\'s words verbatim — if the message is just a greeting or has no clear topic, name it something like "New conversation". Sentence case, no quotes, no markdown, no trailing punctuation, no explanation.',n=t=>!t||String(t).trim().toLowerCase()===e.toLowerCase(),i=new Set(["hey","heey","heyy","heyyy","hi","hii","hello","hej","hejj","yo","sup","hola","howdy","hai","heyo","hiya","wassup","greetings","namaste","ahoy","hallo"]);function o(e){const t=String(e).trim().toLowerCase().replace(/[^a-z0-9\s]/g," ").replace(/\s+/g," ").trim();if(!t)return!0;const n=t.split(" ");return!!/^(good (morning|afternoon|evening)|whats up|wassup|hey there|hello there|hi there|how are you)\b/.test(t)||n.length<=2&&t.length<=12&&i.has(n[0])}function r(e,t){const n=e=>String(e).toLowerCase().replace(/[^a-z0-9\s]/g,"").replace(/\s+/g," ").trim(),i=n(e),o=n(t);if(!i||!o)return!1;if(i===o)return!0;if(o.length<=14&&(i.startsWith(o)||o.startsWith(i)))return!0;if(o.length<=24){const n=e=>new Set((String(e).toLowerCase().match(/[a-z0-9]+/g)||[]).filter((e=>!s.has(e)))),i=n(e),o=n(t);if(i.size&&i.size===o.size&&[...i].every((e=>o.has(e))))return!0}return!1}const s=new Set(["the","a","an","to","of","in","on","at","for","and","or","is","are","be","it","its","my","our","please","can","you","just","do","that","this"]);function a(e){return String(null==e?"":e).replace(/\s+/g," ").trim().replace(/["'`“”‘’]/g,"").replace(/[*_#]/g,"").replace(/^\s*(?:title|name)\s*[:\-–]\s*/i,"").replace(/[.\s]+$/g,"").slice(0,60).trim()}const l=e=>`Write a short title for a conversation that begins with: "${String(e).slice(0,500)}"`,u=/^(?:please|pls|plz|hey|hi|hello|ok(?:ay)?|so|now|just|also|and|then|maybe|well|um|uh|can you|could you|would you|will you|i want you to|i want to|i need you to|i need to|i'?d like you to|i would like you to|i'?d like to|help me|help|let'?s|lets|go ahead and)\b[\s,:;-]*/i,c=new Set(["the","a","an","in","on","at","to","for","of","and","or","with","is","are","my","our","this","that","please","can","you","could","would","i","we","just","do","it"]);function h(t){let n=String(null==t?"":t).trim().replace(/\s+/g," ");if(!n)return e;for(let e=0;e<6;e++){const e=n.replace(u,"").trim();if(e===n)break;n=e}const i=n.split(" ").filter(Boolean);if(!i.length)return e;const o=i.slice(0,6);for(;o.length>2&&c.has(o[o.length-1].toLowerCase().replace(/[^a-z0-9]/g,""));)o.pop();let r=o.join(" ").replace(/[.,!?;:]+$/,"").trim();return r?(r=r[0].toUpperCase()+r.slice(1),r.slice(0,60).trim()||e):e}async function f(n,{callModel:i,signal:s}={}){const u=null==n?"":String(n);if(!u.trim())return"";if(o(u))return e;if(!("function"!=typeof i||s&&s.aborted)){let n=null;try{n=await i(l(u),{system:t,signal:s,naming:!0})}catch{n=null}const o=a(n);if(o)return r(o,u)?e:o}return h(u)}async function g(e,t,i={}){const r=i&&!0===i.named,s=i&&!0===i.seeded;if(r)return null;if(!s&&!n(e))return null;if(!String(t||"").trim()||o(t))return null;const l=a(await f(t,i));return!l||n(l)?null:l}module.exports={GENERIC_TITLE:e,TITLE_SYSTEM:t,isGenericTitle:n,isTopicless:o,looksLikeEcho:r,cleanTitle:a,titlePromptOf:l,deriveTitle:h,nameConversation:f,refineTitle:g,nameSession:async function(t,i,r,s,a={}){if(!t||"function"!=typeof t.setTitle)return null;if(!r)return null;const l="function"==typeof t.getSession?t.getSession(i,r):null,u=l&&l.title,c={...a,seeded:!(!l||l.named)},h=await g(u,s,c);if(h){try{t.setTitle(i,r,h,{named:!0})}catch{return null}return h}if(o(s)&&l&&!l.named&&!n(u)){try{t.setTitle(i,r,e)}catch{return null}return e}return null}};