@opengeni/contracts 5.1.1 → 5.2.0-canary.36239117573001
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/dist/atlassian.js +2 -2
- package/dist/{chunk-XWQOCVP6.js → chunk-4V5DRSP5.js} +2 -2
- package/dist/{chunk-7ABONTXE.js → chunk-HHZSZYYF.js} +33 -3
- package/dist/chunk-HHZSZYYF.js.map +1 -0
- package/dist/{chunk-4X45RNDK.js → chunk-YINJ3EQ6.js} +7180 -7051
- package/dist/chunk-YINJ3EQ6.js.map +1 -0
- package/dist/client-error-report.d.ts +29 -0
- package/dist/client-error-report.js +22 -0
- package/dist/client-error-report.js.map +1 -0
- package/dist/code-search.d.ts +41 -0
- package/dist/code-search.js +34 -0
- package/dist/code-search.js.map +1 -0
- package/dist/connect.js +2 -2
- package/dist/connection-authority.js +3 -3
- package/dist/google-drive.js +2 -2
- package/dist/host-mcp-bindings.js +5 -5
- package/dist/index.d.ts +156 -11
- package/dist/index.js +20 -2
- package/dist/managed-auth-session-sets.d.ts +7 -0
- package/dist/managed-auth-session-sets.js +15 -1
- package/dist/managed-auth-session-sets.js.map +1 -1
- package/dist/model-context-inspector.d.ts +4 -0
- package/dist/personal-github.js +2 -2
- package/dist/session-titles.js +1 -1
- package/dist/signup-attribution.d.ts +39 -0
- package/package.json +9 -1
- package/src/agent-learning.ts +2 -2
- package/src/client-error-report.ts +39 -0
- package/src/code-search.ts +89 -0
- package/src/index.ts +111 -4
- package/src/managed-auth-session-sets.ts +27 -0
- package/src/model-context-inspector.ts +1 -0
- package/src/session-titles.ts +43 -7
- package/src/signup-attribution.ts +81 -0
- package/dist/chunk-4X45RNDK.js.map +0 -1
- package/dist/chunk-7ABONTXE.js.map +0 -1
- /package/dist/{chunk-XWQOCVP6.js.map → chunk-4V5DRSP5.js.map} +0 -0
package/dist/atlassian.js
CHANGED
|
@@ -17,9 +17,9 @@ import {
|
|
|
17
17
|
AtlassianSyncCadence,
|
|
18
18
|
SaveAtlassianSourcesRequest,
|
|
19
19
|
atlassianScopesAllowRead
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-YINJ3EQ6.js";
|
|
21
21
|
import "./chunk-5IXYF6XN.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-HHZSZYYF.js";
|
|
23
23
|
import "./chunk-NRMCVHAU.js";
|
|
24
24
|
import "./chunk-WYBDERIY.js";
|
|
25
25
|
import "./chunk-P3HLDT77.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConnectionKind,
|
|
3
3
|
SessionTenancyVisibility
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YINJ3EQ6.js";
|
|
5
5
|
|
|
6
6
|
// src/connection-authority.ts
|
|
7
7
|
import { z } from "zod";
|
|
@@ -183,4 +183,4 @@ export {
|
|
|
183
183
|
ConnectionUseAuditFact,
|
|
184
184
|
ConnectionUseAuthorizationResult
|
|
185
185
|
};
|
|
186
|
-
//# sourceMappingURL=chunk-
|
|
186
|
+
//# sourceMappingURL=chunk-4V5DRSP5.js.map
|
|
@@ -171,6 +171,34 @@ function stripAutomaticTitleBoilerplate(value) {
|
|
|
171
171
|
}
|
|
172
172
|
return title;
|
|
173
173
|
}
|
|
174
|
+
var AUTOMATIC_TITLE_TRAILING_PUNCTUATION = /[\s.!?,;:\-–—]+$/u;
|
|
175
|
+
var TRAILING_WRAPPER_MARKS = /* @__PURE__ */ new Map([
|
|
176
|
+
['"', null],
|
|
177
|
+
["'", null],
|
|
178
|
+
["`", null],
|
|
179
|
+
["*", null],
|
|
180
|
+
["\u201D", "\u201C"],
|
|
181
|
+
["\u2019", "\u2018"],
|
|
182
|
+
["\xBB", "\xAB"]
|
|
183
|
+
]);
|
|
184
|
+
function trimAutomaticTitleEnd(value) {
|
|
185
|
+
let title = value;
|
|
186
|
+
for (let pass = 0; pass < 4; pass += 1) {
|
|
187
|
+
const before = title;
|
|
188
|
+
title = title.replace(AUTOMATIC_TITLE_TRAILING_PUNCTUATION, "");
|
|
189
|
+
const last = title.at(-1);
|
|
190
|
+
const opening = last === void 0 ? void 0 : TRAILING_WRAPPER_MARKS.get(last);
|
|
191
|
+
if (last !== void 0 && opening !== void 0) {
|
|
192
|
+
let rest = title;
|
|
193
|
+
while (rest.endsWith(last)) rest = rest.slice(0, -last.length);
|
|
194
|
+
if (!rest.includes(last) && (opening === null || !rest.includes(opening))) {
|
|
195
|
+
title = rest;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (title === before) break;
|
|
199
|
+
}
|
|
200
|
+
return title.trim();
|
|
201
|
+
}
|
|
174
202
|
function automaticTitleGraphemes(value) {
|
|
175
203
|
if (titleSegmenter === void 0) {
|
|
176
204
|
titleSegmenter = typeof Intl.Segmenter === "function" ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : null;
|
|
@@ -203,11 +231,13 @@ function normalizeAutomaticSessionTitle(value) {
|
|
|
203
231
|
if (!firstLine || !hasVisibleAutomaticTitleContent(firstLine) || containsSensitiveAutomaticSessionTitleValue(firstLine)) {
|
|
204
232
|
return null;
|
|
205
233
|
}
|
|
206
|
-
let title =
|
|
234
|
+
let title = trimAutomaticTitleEnd(
|
|
235
|
+
stripAutomaticTitleBoilerplate(firstLine).replace(/\s+/gu, " ")
|
|
236
|
+
);
|
|
207
237
|
if (!title || !hasVisibleAutomaticTitleContent(title) || containsSensitiveAutomaticSessionTitleValue(title)) {
|
|
208
238
|
return null;
|
|
209
239
|
}
|
|
210
|
-
title = boundAutomaticSessionTitle(title)
|
|
240
|
+
title = trimAutomaticTitleEnd(boundAutomaticSessionTitle(title));
|
|
211
241
|
if (!title || !hasVisibleAutomaticTitleContent(title)) return null;
|
|
212
242
|
return title;
|
|
213
243
|
}
|
|
@@ -258,4 +288,4 @@ export {
|
|
|
258
288
|
sessionTitleIsPending,
|
|
259
289
|
deriveSessionDisplayTitle
|
|
260
290
|
};
|
|
261
|
-
//# sourceMappingURL=chunk-
|
|
291
|
+
//# sourceMappingURL=chunk-HHZSZYYF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/session-titles.ts"],"sourcesContent":["/** Human-authored session titles keep the existing public API ceiling. */\nexport const SESSION_TITLE_MAX_CHARACTERS = 200;\n\n/**\n * Automatic titles are intentionally much shorter than the manual rename\n * ceiling. This is measured in grapheme clusters so emoji and combining text\n * are never split into malformed display strings.\n */\nexport const AUTOMATIC_SESSION_TITLE_MAX_GRAPHEMES = 80;\n\n/**\n * Safe durable title used until semantic generation succeeds. It contains no\n * user prompt bytes, so provider failure/offline operation cannot leak a\n * credential or leave a raw prompt prefix in navigation surfaces.\n */\nexport const AUTOMATIC_SESSION_TITLE_FALLBACK = \"New conversation\";\n\n// Session creation accepts a body far larger than a navigation label. Bound\n// the source before any replace/split/normalization so a persisted large prompt\n// cannot amplify memory or CPU on every client render.\nconst PROMPT_PREVIEW_SCAN_MAX_CODE_UNITS = 4_096;\n\nconst SESSION_ID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;\n\nlet titleSegmenter: Intl.Segmenter | null | undefined;\n\nconst KNOWN_SENSITIVE_VALUE_PATTERNS = [\n /-----BEGIN [A-Z ]*PRIVATE KEY-----/iu,\n /\\bBearer\\s+[A-Za-z0-9._~+/=-]{8,}/iu,\n /\\b(?:sk-(?:proj-)?|gh[oprsu]_|github_pat_|glpat-|xox[baprs]-)[A-Za-z0-9_-]{8,}/iu,\n /\\bAKIA[0-9A-Z]{16}\\b/u,\n /\\bAIza[0-9A-Za-z_-]{20,}\\b/u,\n /\\beyJ[A-Za-z0-9_-]+\\.eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\b/u,\n /[?&](?:access_token|api_key|apikey|password|secret|token)=[^\\s&#]+/iu,\n] as const;\n\nconst URI_SCHEME_CANDIDATE_PATTERN = /\\b[a-z][a-z0-9+.-]*:\\S+/giu;\nconst WINDOWS_DRIVE_PATH_PATTERN = /^[a-z]:[\\\\/](?![\\\\/])[^:]*$/iu;\n\nconst SCHEMELESS_HOST_CANDIDATE_PATTERN =\n /\\b(?:www\\.)?(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?(?::\\d{1,5})?(?:[/?#][^\\s]*)?/giu;\n\nconst SCHEMELESS_LOCAL_NETWORK_PATTERNS = [\n /\\blocalhost(?:(?::\\d{1,5})(?:[/?#][^\\s]*)?|[/?#][^\\s]*)/iu,\n /\\b(?:(?:25[0-5]|2[0-4]\\d|1?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1?\\d?\\d)(?:(?::\\d{1,5})(?:[/?#][^\\s]*)?|[/?#][^\\s]*)/u,\n /\\[(?=[0-9a-f:.]*:[0-9a-f:.]*\\])[0-9a-f:.]+\\](?:(?::\\d{1,5})(?:[/?#][^\\s]*)?|[/?#][^\\s]*)/iu,\n] as const;\n\nconst FILE_LIKE_HOST_SUFFIXES = new Set([\n \"css\",\n \"html\",\n \"js\",\n \"json\",\n \"jsx\",\n \"lock\",\n \"md\",\n \"sql\",\n \"toml\",\n \"ts\",\n \"tsx\",\n \"xml\",\n \"yaml\",\n \"yml\",\n]);\n\n// These authorities are established framework/namespace notation whose exact\n// casing is meaningful. Keep this exception deliberately narrow: generic\n// PascalCase or uppercase authorities remain host-like because an uppercase\n// real domain (for example MICROSOFT.COM/Admin) must not bypass the URL gate.\nconst DOTTED_TECHNOLOGY_PATH_AUTHORITIES = new Set([\n \"ASP.NET\",\n \"AWS.SDK\",\n \"Microsoft.Extensions\",\n \"System.IO\",\n]);\n\nconst SECRET_ASSIGNMENT_CANDIDATE_PATTERN =\n /(?:^|[^A-Za-z0-9])(?:(['\"])([A-Za-z][A-Za-z0-9_. -]*)\\1|([A-Za-z][A-Za-z0-9_.-]*))\\s*[=:]\\s*[^\\s,;]+/gu;\n\nconst SECRET_LABEL_ASSIGNMENT_PATTERN =\n /\\b(?:api[ _-]?key|access[ _-]?token|auth[ _-]?token|credential|credentials|password|passwd|private[ _-]?key|secret|token)\\b\\s*[=:]\\s*[^\\s,;]+/iu;\n\nconst SENSITIVE_ASSIGNMENT_KEY_SUFFIXES = new Set([\n \"credential\",\n \"credentials\",\n \"password\",\n \"passwd\",\n \"secret\",\n \"token\",\n]);\n\nconst COMPACT_SENSITIVE_ASSIGNMENT_KEY_SUFFIXES = [\n \"apikey\",\n \"accesskey\",\n \"accesskeyid\",\n \"accesstoken\",\n \"authtoken\",\n \"credential\",\n \"credentials\",\n \"password\",\n \"passwd\",\n \"privatekey\",\n \"secret\",\n \"secretkey\",\n \"token\",\n] as const;\n\nconst SENSITIVE_ASSIGNMENT_KEY_WORD_SUFFIXES = [\n [\"api\", \"key\"],\n [\"access\", \"key\"],\n [\"access\", \"key\", \"id\"],\n [\"auth\", \"key\"],\n [\"private\", \"key\"],\n [\"secret\", \"key\"],\n] as const;\n\nfunction hasWordSuffix(words: readonly string[], suffix: readonly string[]): boolean {\n if (words.length < suffix.length) return false;\n const offset = words.length - suffix.length;\n return suffix.every((word, index) => words[offset + index] === word);\n}\n\nfunction containsSensitiveAssignment(value: string): boolean {\n for (const match of value.matchAll(SECRET_ASSIGNMENT_CANDIDATE_PATTERN)) {\n const key = match[2] ?? match[3];\n if (!key) continue;\n const words = key\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\")\n .toLowerCase()\n .split(/[^a-z0-9]+/)\n .filter(Boolean);\n const last = words.at(-1);\n if (last && SENSITIVE_ASSIGNMENT_KEY_SUFFIXES.has(last)) return true;\n if (last && COMPACT_SENSITIVE_ASSIGNMENT_KEY_SUFFIXES.some((suffix) => last.endsWith(suffix))) {\n return true;\n }\n if (SENSITIVE_ASSIGNMENT_KEY_WORD_SUFFIXES.some((suffix) => hasWordSuffix(words, suffix))) {\n return true;\n }\n }\n return false;\n}\n\nfunction containsUriScheme(value: string): boolean {\n for (const match of value.matchAll(URI_SCHEME_CANDIDATE_PATTERN)) {\n // A Windows drive path is the one scheme-shaped token accepted here. Keep\n // the exception exact: one separator after the drive letter and no later\n // colon, so x://host and a nested scheme remain rejected.\n if (!WINDOWS_DRIVE_PATH_PATTERN.test(match[0])) return true;\n }\n return false;\n}\n\nfunction isDottedTechnologyPath(candidate: string): boolean {\n if (/[?:#]/u.test(candidate)) return false;\n const [authority, ...pathSegments] = candidate.split(\"/\");\n if (!authority || pathSegments.length === 0 || pathSegments.some((segment) => !segment)) {\n return false;\n }\n if (\n !DOTTED_TECHNOLOGY_PATH_AUTHORITIES.has(authority) ||\n pathSegments.some((segment) => !/^[A-Z][A-Za-z0-9_-]*$/u.test(segment))\n ) {\n return false;\n }\n return true;\n}\n\nfunction containsSchemelessUrl(value: string): boolean {\n if (SCHEMELESS_LOCAL_NETWORK_PATTERNS.some((pattern) => pattern.test(value))) return true;\n\n for (const match of value.matchAll(SCHEMELESS_HOST_CANDIDATE_PATTERN)) {\n const candidate = match[0];\n if (candidate.toLowerCase().startsWith(\"www.\")) return true;\n if (!/[/?#]/u.test(candidate)) continue;\n\n const authority = candidate.split(/[/?#]/u, 1)[0] ?? \"\";\n const hostname = authority.replace(/:\\d{1,5}$/u, \"\");\n const suffix = hostname.split(\".\").at(-1)?.toLowerCase();\n if (suffix && FILE_LIKE_HOST_SUFFIXES.has(suffix)) continue;\n if (isDottedTechnologyPath(candidate)) continue;\n return true;\n }\n return false;\n}\n\nconst OPAQUE_IDENTIFIER_PATTERN =\n /\\b(?=[A-Za-z0-9_-]{32,}\\b)(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*\\d)[A-Za-z0-9_-]+\\b/u;\n\nconst DEFAULT_IGNORABLE_CODE_POINTS = /\\p{Default_Ignorable_Code_Point}+/gu;\nconst ESCAPED_QUOTE_DELIMITERS = /\\\\+(?=[\"'])/gu;\n\nconst TITLE_LABEL_PATTERN =\n /^(?:(?:suggested|generated|concise)\\s+)?(?:(?:session|chat|conversation|task)\\s+)?title\\s*[:\\-–—]\\s*/iu;\n\nconst LEADING_BOILERPLATE_PATTERNS = [\n /^(?:hi|hello|hey)(?:\\s+there)?\\s*[,!:.\\-–—]*\\s*/iu,\n /^(?:i\\s+(?:would\\s+like|want|need)\\s+you\\s+to|i['’]d\\s+like\\s+you\\s+to)\\s+/iu,\n /^(?:please\\s+)?(?:can|could|would|will)\\s+you\\s+/iu,\n /^(?:your|the)\\s+(?:task|job)\\s+is\\s+to\\s+/iu,\n /^(?:please\\s+)?help\\s+me\\s+(?:to\\s+)?/iu,\n /^please(?:\\s*[,!:.\\-–—]+\\s*|\\s+|$)/iu,\n] as const;\n\nfunction automaticTitleDetectionValue(value: string): string {\n // Detection uses a compatibility-normalized shadow value so fullwidth\n // punctuation/letters, invisible token splits, and serialized quote\n // delimiters cannot evade the policy.\n // The accepted title itself stays byte-for-byte in the user's language and\n // emoji form; this shadow is never returned or persisted.\n return value\n .normalize(\"NFKC\")\n .replace(DEFAULT_IGNORABLE_CODE_POINTS, \"\")\n .replace(ESCAPED_QUOTE_DELIMITERS, \"\");\n}\n\nfunction hasVisibleAutomaticTitleContent(value: string): boolean {\n return automaticTitleDetectionValue(value).trim().length > 0;\n}\n\n/**\n * Whether a bounded automatic-title candidate contains a credential, URL, or\n * opaque identifier that must stay out of navigation and other display-title\n * surfaces. Callers handling an unbounded source must bound it before invoking\n * this helper.\n */\nexport function containsSensitiveAutomaticSessionTitleValue(value: string): boolean {\n const detectionValue = automaticTitleDetectionValue(value);\n\n if (KNOWN_SENSITIVE_VALUE_PATTERNS.some((pattern) => pattern.test(detectionValue))) return true;\n if (containsUriScheme(detectionValue)) return true;\n if (containsSchemelessUrl(detectionValue)) return true;\n if (SECRET_LABEL_ASSIGNMENT_PATTERN.test(detectionValue)) return true;\n if (containsSensitiveAssignment(detectionValue)) return true;\n if (OPAQUE_IDENTIFIER_PATTERN.test(detectionValue)) return true;\n return false;\n}\n\nfunction stripAutomaticTitleBoilerplate(value: string): string {\n let title = value;\n for (let pass = 0; pass < 4; pass += 1) {\n const before = title;\n title = title\n .replace(/^(?:```[^\\n]*|[\\s#>*_`\"'“”‘’\\-–—]+)+/u, \"\")\n .replace(TITLE_LABEL_PATTERN, \"\");\n for (const pattern of LEADING_BOILERPLATE_PATTERNS) {\n title = title.replace(pattern, \"\");\n }\n title = title.trim();\n if (title === before) break;\n }\n return title;\n}\n\nconst AUTOMATIC_TITLE_TRAILING_PUNCTUATION = /[\\s.!?,;:\\-–—]+$/u;\n\n// Closing quote and markdown marks, mapped to the distinct opening mark that\n// would pair with them inside the title.\nconst TRAILING_WRAPPER_MARKS = new Map<string, string | null>([\n ['\"', null],\n [\"'\", null],\n [\"`\", null],\n [\"*\", null],\n [\"”\", \"“\"],\n [\"’\", \"‘\"],\n [\"»\", \"«\"],\n]);\n\n/**\n * Remove trailing punctuation and a closing quote or markdown mark whose\n * opening counterpart was already stripped as a leading wrapper, so\n * `\"Pod Crash Debugging\"` and `**Pod Crash Debugging**` do not keep a dangling\n * closing mark. A mark that still pairs with one inside the title stays.\n */\nfunction trimAutomaticTitleEnd(value: string): string {\n let title = value;\n for (let pass = 0; pass < 4; pass += 1) {\n const before = title;\n title = title.replace(AUTOMATIC_TITLE_TRAILING_PUNCTUATION, \"\");\n const last = title.at(-1);\n const opening = last === undefined ? undefined : TRAILING_WRAPPER_MARKS.get(last);\n if (last !== undefined && opening !== undefined) {\n let rest = title;\n while (rest.endsWith(last)) rest = rest.slice(0, -last.length);\n if (!rest.includes(last) && (opening === null || !rest.includes(opening))) {\n title = rest;\n }\n }\n if (title === before) break;\n }\n return title.trim();\n}\n\nfunction automaticTitleGraphemes(value: string): string[] {\n if (titleSegmenter === undefined) {\n titleSegmenter =\n typeof Intl.Segmenter === \"function\"\n ? new Intl.Segmenter(undefined, { granularity: \"grapheme\" })\n : null;\n }\n if (titleSegmenter) {\n return Array.from(titleSegmenter.segment(value), (part) => part.segment);\n }\n\n // Older embedded runtimes may not ship Intl.Segmenter. Preserve surrogate\n // pairs plus common combining/emoji sequences instead of failing module load\n // or slicing UTF-16 code units.\n const graphemes: string[] = [];\n for (const point of value) {\n const prior = graphemes.at(-1);\n if (\n prior &&\n (/^[\\p{Mark}\\u{FE0E}\\u{FE0F}\\p{Emoji_Modifier}]$/u.test(point) ||\n point === \"\\u200d\" ||\n prior.endsWith(\"\\u200d\"))\n ) {\n graphemes[graphemes.length - 1] = `${prior}${point}`;\n } else {\n graphemes.push(point);\n }\n }\n return graphemes;\n}\n\n/** Bound an already-normalized automatic-title candidate without splitting graphemes. */\nexport function boundAutomaticSessionTitle(value: string): string {\n const words = value.split(/\\s+/u);\n const wordBounded = words.length > 10 ? words.slice(0, 10).join(\" \") : value;\n const graphemes = automaticTitleGraphemes(wordBounded);\n if (graphemes.length <= AUTOMATIC_SESSION_TITLE_MAX_GRAPHEMES) return wordBounded;\n\n const prefix = graphemes.slice(0, AUTOMATIC_SESSION_TITLE_MAX_GRAPHEMES).join(\"\");\n const lastWhitespace = prefix.search(/\\s+\\S*$/u);\n return (lastWhitespace >= 16 ? prefix.slice(0, lastWhitespace) : prefix).trimEnd();\n}\n\n/**\n * Normalize a model/system-authored title before it reaches durable session\n * metadata. Human renames intentionally do not use this path.\n *\n * Returns null when the candidate is empty, only boilerplate, or appears to\n * contain a credential/opaque prompt value. Callers should retain the current\n * title (normally {@link AUTOMATIC_SESSION_TITLE_FALLBACK}) in that case.\n */\nexport function normalizeAutomaticSessionTitle(value: string): string | null {\n const firstLine = value\n .replace(/[\\u0000-\\u001f\\u007f-\\u009f]+/gu, \"\\n\")\n .split(/\\n+/u)\n .map((line) => line.trim())\n .find(Boolean);\n if (\n !firstLine ||\n !hasVisibleAutomaticTitleContent(firstLine) ||\n containsSensitiveAutomaticSessionTitleValue(firstLine)\n ) {\n return null;\n }\n\n let title = trimAutomaticTitleEnd(\n stripAutomaticTitleBoilerplate(firstLine).replace(/\\s+/gu, \" \"),\n );\n if (\n !title ||\n !hasVisibleAutomaticTitleContent(title) ||\n containsSensitiveAutomaticSessionTitleValue(title)\n ) {\n return null;\n }\n\n title = trimAutomaticTitleEnd(boundAutomaticSessionTitle(title));\n if (!title || !hasVisibleAutomaticTitleContent(title)) return null;\n return title;\n}\n\nexport type SessionDisplayTitleInput = {\n id?: string | null | undefined;\n title?: string | null | undefined;\n titleSource?: \"user\" | \"agent\" | null | undefined;\n initialMessage?: string | null | undefined;\n metadata?: Readonly<Record<string, unknown>> | undefined;\n};\n\nexport type SessionDisplayTitleOptions = {\n /** Optional metadata fields to try before the opening-prompt preview. */\n metadataKeys?: readonly string[] | undefined;\n};\n\n/**\n * Derive a bounded, sensitive-safe preview from the opening prompt.\n *\n * Unsafe leading lines are skipped instead of forcing the whole session back\n * to a generic label. This covers prompts that begin with a pasted URL or\n * identifier followed by an ordinary natural-language request on the next\n * line, without putting the rejected value into navigation surfaces.\n */\nexport function deriveAutomaticSessionTitlePreview(value: unknown): string | null {\n if (typeof value !== \"string\") return null;\n\n const lines = value\n .slice(0, PROMPT_PREVIEW_SCAN_MAX_CODE_UNITS)\n .replace(/[\\u0000-\\u001f\\u007f-\\u009f]+/gu, \"\\n\")\n .split(/\\n+/u);\n\n for (const candidate of lines) {\n const line = candidate.trim();\n if (!line || containsSensitiveAutomaticSessionTitleValue(line)) continue;\n\n const preview = boundAutomaticSessionTitle(line.replace(/\\s+/gu, \" \"))\n .replace(/[\\s.!?,;:\\-–—]+$/u, \"\")\n .trim();\n if (preview) return preview;\n }\n\n return null;\n}\n\nfunction automaticSessionReferenceTitle(id: unknown): string {\n const sessionId = typeof id === \"string\" ? id.trim() : \"\";\n return SESSION_ID_PATTERN.test(sessionId)\n ? `Conversation ${sessionId.slice(0, 13)}`\n : AUTOMATIC_SESSION_TITLE_FALLBACK;\n}\n\n/**\n * Whether the durable title still represents the automatic-title pending state.\n * A user-authored title always wins, even when its literal value is the marker.\n */\nexport function sessionTitleIsPending(input: SessionDisplayTitleInput): boolean {\n const title = input.title?.trim() ?? \"\";\n return input.titleSource !== \"user\" && (!title || title === AUTOMATIC_SESSION_TITLE_FALLBACK);\n}\n\n/**\n * Derive the title a human-facing client should display for a session.\n *\n * A semantic agent title or human rename wins. While automatic naming is still\n * pending, clients show a short, sensitive-safe preview of the opening prompt.\n * If no safe prompt text exists, a UUID-derived reference keeps real sessions\n * distinguishable without exposing prompt bytes. The durable pending marker is\n * therefore an internal lifecycle value rather than the ordinary visible name.\n */\nexport function deriveSessionDisplayTitle(\n input: SessionDisplayTitleInput,\n options: SessionDisplayTitleOptions = {},\n): string {\n const title = input.title?.trim() ?? \"\";\n if (input.titleSource === \"user\") {\n return title || automaticSessionReferenceTitle(input.id);\n }\n if (title && !sessionTitleIsPending(input)) {\n return title;\n }\n\n for (const key of options.metadataKeys ?? []) {\n const value = input.metadata?.[key];\n if (typeof value === \"string\" && value.trim().length > 0) {\n return value.trim();\n }\n }\n\n return (\n deriveAutomaticSessionTitlePreview(input.initialMessage) ??\n automaticSessionReferenceTitle(input.id)\n );\n}\n"],"mappings":";AACO,IAAM,+BAA+B;AAOrC,IAAM,wCAAwC;AAO9C,IAAM,mCAAmC;AAKhD,IAAM,qCAAqC;AAE3C,IAAM,qBACJ;AAEF,IAAI;AAEJ,IAAM,iCAAiC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,+BAA+B;AACrC,IAAM,6BAA6B;AAEnC,IAAM,oCACJ;AAEF,IAAM,oCAAoC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAM,0BAA0B,oBAAI,IAAI;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,E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