@openchambery/web 1.19.7 → 1.19.8-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/dist/assets/AssistantView-DqU0LpWe.js +2 -0
- package/dist/assets/{DiagramView-B2UtQ8mw.js → DiagramView-B1cr5UPr.js} +1 -1
- package/dist/assets/MarkdownRenderer-3WAUET64.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-Cslh4XN_.js → MarkdownRendererImpl-834FCgUq.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-Ymm12x6J.js → MarkstreamRendererImpl-Bi3gx3MP.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-DD29ENgU.js → MobileDetailNavigation-DUYT-w-b.js} +1 -1
- package/dist/assets/{MobileShareBridge-CrTe_QND.js → MobileShareBridge-BdkKcPfM.js} +1 -1
- package/dist/assets/MobileSurface-BipQrFN7.js +2 -0
- package/dist/assets/{MultiRunWindow-jG5dCEMH.js → MultiRunWindow-KznXYi4R.js} +1 -1
- package/dist/assets/{SettingsView-UKlEewdq.js → SettingsView-yD6YjBtn.js} +1 -1
- package/dist/assets/{SettingsWindow-DO1aAplT.js → SettingsWindow-lc0HYe8D.js} +1 -1
- package/dist/assets/{TerminalView-BG1UPLsz.js → TerminalView-BiftutsX.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CWr5eVTK.js → ToolOutputDialog-_Tc2D64N.js} +1 -1
- package/dist/assets/{appThemeRegistry-BI5drVpC.js → appThemeRegistry-CbdJL978.js} +1 -1
- package/dist/assets/{gitApi-D9hFlE3T.js → gitApi-DhafzShm.js} +1 -1
- package/dist/assets/{insertionBoundaries-D2L7D0Oe.js → insertionBoundaries-D82BN9Nn.js} +1 -1
- package/dist/assets/{main-DlXpJ0Vw.js → main-DONRSGbm.js} +2 -2
- package/dist/assets/{main-BRedOs_V.js → main-UPkDYyZy.js} +4 -4
- package/dist/assets/{miniChat-CBLbFpfy.js → miniChat-CQlBJDTL.js} +2 -2
- package/dist/assets/{mobile-CoZsWdWk.js → mobile-C_PBZouC.js} +2 -2
- package/dist/assets/{multirun-BF-I0r2_.js → multirun-Qahvkk53.js} +1 -1
- package/dist/assets/{projectMeta-2t4L5_4a.js → projectMeta-B6cvcYxv.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-fl7O3iHy.js → renderElectronMiniChatApp-CvMcHfej.js} +2 -2
- package/dist/assets/{renderMobileApp-CKYDwf4U.js → renderMobileApp-WptF-y5w.js} +4 -4
- package/dist/assets/{runtimeConfig-B4eb4ZiU.js → runtimeConfig-BOf8a6dv.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-BHuTYyzc.js → runtimeEndpointReset-eaItEnQo.js} +1 -1
- package/dist/assets/{sessionLookup-DNc0ZeR3.js → sessionLookup-DQxTr5Hf.js} +1 -1
- package/dist/assets/{useAppFontEffects-Dle8xs5h.js → useAppFontEffects-DT00lvd_.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-_QAwKcQn.js → useDesktopWindowControlsLayout-Bzkb1Y05.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-BSyuAgz6.js → useEffectiveDirectory-C55Dluga.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-f8xHJk7C.js → useMobileNavigationStore-DpPEzHZ1.js} +1 -1
- package/dist/assets/{useSessionAutoCleanup-BHiXaW0J.js → useSessionAutoCleanup-BF_zxuMv.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-DuvXTSm_.js → useWorkerHighlightedLines-BAd14WJR.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/assistants/DOCUMENTATION.md +3 -3
- package/server/lib/assistants/contact-tools.js +7 -4
- package/server/lib/assistants/contact-tools.test.js +12 -3
- package/server/lib/assistants/harness.js +117 -93
- package/server/lib/assistants/harness.test.js +90 -0
- package/server/lib/assistants/pi-tools.js +118 -0
- package/server/lib/assistants/pi-tools.test.js +114 -0
- package/dist/assets/AssistantView-nVF0kdFh.js +0 -2
- package/dist/assets/MarkdownRenderer-DT_GN1Ex.js +0 -2
- package/dist/assets/MobileSurface-DjxchpUC.js +0 -2
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import os from 'node:os';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {
|
|
4
|
+
createBashTool,
|
|
5
|
+
createEditTool,
|
|
6
|
+
createReadTool,
|
|
7
|
+
createWriteTool,
|
|
8
|
+
formatSkillsForSystemPrompt,
|
|
9
|
+
loadSkills,
|
|
10
|
+
} from '@earendil-works/pi-agent-core';
|
|
11
|
+
import { NodeExecutionEnv } from '@earendil-works/pi-agent-core/node';
|
|
12
|
+
|
|
13
|
+
const EXTERNAL_SKILL_ROOTS = Object.freeze(['.claude', '.agents']);
|
|
14
|
+
|
|
15
|
+
export const PI_CODING_TOOL_NAMES = Object.freeze(['read', 'write', 'edit', 'bash']);
|
|
16
|
+
const PI_CODING_TOOL_NAME_SET = new Set(PI_CODING_TOOL_NAMES);
|
|
17
|
+
|
|
18
|
+
export function isPiCodingToolName(name) {
|
|
19
|
+
return typeof name === 'string' && PI_CODING_TOOL_NAME_SET.has(name);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function resolveAssistantCwd(assistant) {
|
|
23
|
+
for (const value of [assistant?.effectiveWorkspacePath, assistant?.workspacePath]) {
|
|
24
|
+
if (typeof value === 'string' && value.trim()) return value.trim();
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Global ~/.claude/skills + ~/.agents/skills, then this project cwd (.claude then .agents). Later dirs win on name. */
|
|
30
|
+
export function collectAssistantSkillDirectories(cwd, { homeDir = os.homedir() } = {}) {
|
|
31
|
+
const dirs = [];
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
const push = (dir) => {
|
|
34
|
+
if (typeof dir !== 'string' || !dir.trim()) return;
|
|
35
|
+
const resolved = path.resolve(dir);
|
|
36
|
+
if (seen.has(resolved)) return;
|
|
37
|
+
seen.add(resolved);
|
|
38
|
+
dirs.push(resolved);
|
|
39
|
+
};
|
|
40
|
+
const home = typeof homeDir === 'string' && homeDir.trim() ? path.resolve(homeDir.trim()) : os.homedir();
|
|
41
|
+
for (const root of EXTERNAL_SKILL_ROOTS) {
|
|
42
|
+
push(path.join(home, root, 'skills'));
|
|
43
|
+
}
|
|
44
|
+
if (typeof cwd === 'string' && cwd.trim()) {
|
|
45
|
+
const project = path.resolve(cwd.trim());
|
|
46
|
+
for (const root of EXTERNAL_SKILL_ROOTS) {
|
|
47
|
+
push(path.join(project, root, 'skills'));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return dirs;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function mergeSkillsByName(skills) {
|
|
54
|
+
const map = new Map();
|
|
55
|
+
for (const skill of Array.isArray(skills) ? skills : []) {
|
|
56
|
+
const name = typeof skill?.name === 'string' ? skill.name.trim() : '';
|
|
57
|
+
if (!name) continue;
|
|
58
|
+
map.set(name, skill);
|
|
59
|
+
}
|
|
60
|
+
return [...map.values()];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const bindHarnessTool = (tool, context) => ({
|
|
64
|
+
name: tool.name,
|
|
65
|
+
label: tool.label,
|
|
66
|
+
description: tool.description,
|
|
67
|
+
parameters: tool.parameters,
|
|
68
|
+
execute: (toolCallId, params, signal, onUpdate) => (
|
|
69
|
+
tool.execute(toolCallId, params, signal, onUpdate, context)
|
|
70
|
+
),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export function formatPiCodingPrompt({ cwd, skillsPrompt = '' } = {}) {
|
|
74
|
+
if (typeof cwd !== 'string' || !cwd.trim()) return '';
|
|
75
|
+
return [
|
|
76
|
+
`Working directory: ${cwd}`,
|
|
77
|
+
'You have pi coding tools in this directory: read, write, edit, bash.',
|
|
78
|
+
'This is your working directory. Ignore any other cwd from the environment, including temporary generator workspaces under /var/folders or os.tmpdir.',
|
|
79
|
+
'When the user asks pwd, the current directory, or to look at files, call bash/read yourself. Never say you have no terminal or cannot read or write files.',
|
|
80
|
+
'Skills are merged from ~/.claude/skills, ~/.agents/skills, and this project\'s .claude/skills plus .agents/skills (project wins on name). Read a skill file when the task matches its description.',
|
|
81
|
+
'Call these tools with the same fenced JSON as other tools:',
|
|
82
|
+
'```openchamber-tool',
|
|
83
|
+
'{"name":"bash","arguments":{"command":"pwd"}}',
|
|
84
|
+
'```',
|
|
85
|
+
'```openchamber-tool',
|
|
86
|
+
'{"name":"read","arguments":{"path":".agents/skills/example/SKILL.md"}}',
|
|
87
|
+
'```',
|
|
88
|
+
typeof skillsPrompt === 'string' && skillsPrompt.trim() ? skillsPrompt.trim() : '',
|
|
89
|
+
].filter(Boolean).join('\n');
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export async function createPiCodingRuntime(cwd, { homeDir = os.homedir() } = {}) {
|
|
93
|
+
if (typeof cwd !== 'string' || !cwd.trim()) return null;
|
|
94
|
+
const resolved = cwd.trim();
|
|
95
|
+
const env = new NodeExecutionEnv({ cwd: resolved });
|
|
96
|
+
const context = { env };
|
|
97
|
+
const tools = [
|
|
98
|
+
bindHarnessTool(createReadTool(), context),
|
|
99
|
+
bindHarnessTool(createWriteTool(), context),
|
|
100
|
+
bindHarnessTool(createEditTool(), context),
|
|
101
|
+
bindHarnessTool(createBashTool(), context),
|
|
102
|
+
];
|
|
103
|
+
let skillsPrompt = '';
|
|
104
|
+
try {
|
|
105
|
+
const loaded = await loadSkills(env, collectAssistantSkillDirectories(resolved, { homeDir }));
|
|
106
|
+
skillsPrompt = formatSkillsForSystemPrompt(mergeSkillsByName(loaded?.skills));
|
|
107
|
+
} catch {
|
|
108
|
+
skillsPrompt = '';
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
cwd: resolved,
|
|
112
|
+
tools,
|
|
113
|
+
skillsPrompt,
|
|
114
|
+
close: async () => {
|
|
115
|
+
await env.cleanup();
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import {
|
|
6
|
+
collectAssistantSkillDirectories,
|
|
7
|
+
createPiCodingRuntime,
|
|
8
|
+
mergeSkillsByName,
|
|
9
|
+
PI_CODING_TOOL_NAMES,
|
|
10
|
+
resolveAssistantCwd,
|
|
11
|
+
} from './pi-tools.js';
|
|
12
|
+
|
|
13
|
+
const temps = [];
|
|
14
|
+
const temp = () => {
|
|
15
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'oc-pi-tools-'));
|
|
16
|
+
temps.push(dir);
|
|
17
|
+
return dir;
|
|
18
|
+
};
|
|
19
|
+
const writeSkill = (root, name, description = `${name} skill`) => {
|
|
20
|
+
const dir = path.join(root, name);
|
|
21
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
22
|
+
fs.writeFileSync(path.join(dir, 'SKILL.md'), `---\nname: ${name}\ndescription: ${description}\n---\nInstructions for ${name}\n`);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
while (temps.length > 0) {
|
|
27
|
+
fs.rmSync(temps.pop(), { recursive: true, force: true });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('resolveAssistantCwd', () => {
|
|
32
|
+
it('prefers effectiveWorkspacePath over workspacePath', () => {
|
|
33
|
+
expect(resolveAssistantCwd({
|
|
34
|
+
effectiveWorkspacePath: '/effective',
|
|
35
|
+
workspacePath: '/workspace',
|
|
36
|
+
})).toBe('/effective');
|
|
37
|
+
expect(resolveAssistantCwd({ workspacePath: '/workspace' })).toBe('/workspace');
|
|
38
|
+
expect(resolveAssistantCwd({ defaultPrompt: 'x' })).toBeNull();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('collectAssistantSkillDirectories', () => {
|
|
43
|
+
it('lists global ~/.claude and ~/.agents then project .claude and .agents', () => {
|
|
44
|
+
const home = temp();
|
|
45
|
+
const cwd = temp();
|
|
46
|
+
expect(collectAssistantSkillDirectories(cwd, { homeDir: home })).toEqual([
|
|
47
|
+
path.resolve(home, '.claude', 'skills'),
|
|
48
|
+
path.resolve(home, '.agents', 'skills'),
|
|
49
|
+
path.resolve(cwd, '.claude', 'skills'),
|
|
50
|
+
path.resolve(cwd, '.agents', 'skills'),
|
|
51
|
+
]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('does not invent skill roots on intermediate parent folders', () => {
|
|
55
|
+
const home = temp();
|
|
56
|
+
const root = temp();
|
|
57
|
+
const nested = path.join(root, 'apps', 'web');
|
|
58
|
+
fs.mkdirSync(nested, { recursive: true });
|
|
59
|
+
expect(collectAssistantSkillDirectories(nested, { homeDir: home })).toEqual([
|
|
60
|
+
path.resolve(home, '.claude', 'skills'),
|
|
61
|
+
path.resolve(home, '.agents', 'skills'),
|
|
62
|
+
path.resolve(nested, '.claude', 'skills'),
|
|
63
|
+
path.resolve(nested, '.agents', 'skills'),
|
|
64
|
+
]);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('mergeSkillsByName', () => {
|
|
69
|
+
it('keeps the last skill with the same name', () => {
|
|
70
|
+
expect(mergeSkillsByName([
|
|
71
|
+
{ name: 'shared', filePath: '/global' },
|
|
72
|
+
{ name: 'shared', filePath: '/project' },
|
|
73
|
+
{ name: 'other', filePath: '/other' },
|
|
74
|
+
])).toEqual([
|
|
75
|
+
{ name: 'shared', filePath: '/project' },
|
|
76
|
+
{ name: 'other', filePath: '/other' },
|
|
77
|
+
]);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('createPiCodingRuntime', () => {
|
|
82
|
+
it('installs read/write/edit/bash and merges global plus project skills', async () => {
|
|
83
|
+
const home = temp();
|
|
84
|
+
const cwd = temp();
|
|
85
|
+
writeSkill(path.join(home, '.claude', 'skills'), 'claude-global', 'Claude global');
|
|
86
|
+
writeSkill(path.join(home, '.agents', 'skills'), 'agents-global', 'Agents global');
|
|
87
|
+
writeSkill(path.join(cwd, '.claude', 'skills'), 'claude-project', 'Claude project');
|
|
88
|
+
writeSkill(path.join(cwd, '.agents', 'skills'), 'project-skill', 'Project skill');
|
|
89
|
+
writeSkill(path.join(home, '.agents', 'skills'), 'shared', 'Global shared');
|
|
90
|
+
writeSkill(path.join(cwd, '.agents', 'skills'), 'shared', 'Project shared');
|
|
91
|
+
|
|
92
|
+
const runtime = await createPiCodingRuntime(cwd, { homeDir: home });
|
|
93
|
+
expect(runtime.tools.map((tool) => tool.name)).toEqual([...PI_CODING_TOOL_NAMES]);
|
|
94
|
+
expect(runtime.skillsPrompt).toContain('claude-global');
|
|
95
|
+
expect(runtime.skillsPrompt).toContain('agents-global');
|
|
96
|
+
expect(runtime.skillsPrompt).toContain('claude-project');
|
|
97
|
+
expect(runtime.skillsPrompt).toContain('project-skill');
|
|
98
|
+
expect(runtime.skillsPrompt).toContain('Project shared');
|
|
99
|
+
expect(runtime.skillsPrompt).not.toContain('Global shared');
|
|
100
|
+
await runtime.close();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('runs bash pwd in the workspace', async () => {
|
|
104
|
+
const cwd = temp();
|
|
105
|
+
const home = temp();
|
|
106
|
+
const runtime = await createPiCodingRuntime(cwd, { homeDir: home });
|
|
107
|
+
const bash = runtime.tools.find((tool) => tool.name === 'bash');
|
|
108
|
+
const result = await bash.execute('call_pwd', { command: 'pwd' });
|
|
109
|
+
const text = result.content.map((part) => part.text).join('');
|
|
110
|
+
const resolved = fs.realpathSync(cwd);
|
|
111
|
+
expect(text.includes(cwd) || text.includes(resolved)).toBe(true);
|
|
112
|
+
await runtime.close();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{A as n,E as r,t as i}from"./useUIStore-CuaA8-Hp.js";import{et as a}from"./persistence-DdUac14I.js";import{a as o}from"./vendor-zustand-B4dlGEM2.js";import{nt as s,rt as c}from"./vendor-base-ui-CnHfUmDN.js";import{r as l}from"./platform-B4KKLnZ5.js";import{n as u}from"./vendor-react-DLPElpoQ.js";import{r as d}from"./vendor-sonner-DVzioF3d.js";import{n as f}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as p}from"./clipboard-DJ4nQEuY.js";import{a as m,n as h}from"./MobileShareBridge-CrTe_QND.js";import{Oo as g,dr as _,qt as v,r as y,vn as b}from"./useMobileNavigationStore-f8xHJk7C.js";import{a as x,b as S,c as C,f as w,h as T,p as E,r as D,t as O,v as k}from"./MobileDetailNavigation-DD29ENgU.js";import{i as A,n as j,r as M}from"./useAssistantUIStore-me6s63b2.js";import{a as N,i as P,n as F,o as I,r as L,t as R}from"./dialog-CgbV5ljg.js";import{t as z}from"./utils-BiK3tBGM.js";import{t as B}from"./AgentAvatar-CX0a1rKE.js";import{n as V}from"./Icon-BYM02QyU.js";import{t as H}from"./button-C0cth9tl.js";import{i as U}from"./OverlayScrollbar-KUpvYHdv.js";import{t as W}from"./MarkdownRenderer-DT_GN1Ex.js";import{a as G,i as ee,n as te,r as ne,t as re,u as K}from"./sessionChangeSummary-DOq8EN_H.js";import{a as ie,i as ae,n as oe,r as se,t as ce}from"./context-menu-CAp74NfV.js";import{t as q}from"./sessionLookup-DNc0ZeR3.js";var J=u(),Y=e(c(),1),X=s(),le=e=>{let t=(0,J.c)(17),{name:n,emoji:r,size:i,label:a,working:o,className:s}=e,c=i===void 0?24:i,l=o!==void 0&&o,{t:u}=p(),d=`calc(${c}px * var(--dpt-n, 1))`,f;t[0]===s?f=t[1]:(f=z(`relative inline-block shrink-0 align-middle leading-none`,s),t[0]=s,t[1]=f);let m;t[2]===d?m=t[3]:(m={width:d,height:d},t[2]=d,t[3]=m);let h;t[4]!==r||t[5]!==a||t[6]!==n||t[7]!==c?(h=(0,X.jsx)(B,{name:n,emoji:r,size:c,label:a,shape:`circle`}),t[4]=r,t[5]=a,t[6]=n,t[7]=c,t[8]=h):h=t[8];let g;t[9]!==u||t[10]!==l?(g=l?(0,X.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2 translate-x-1/4 translate-y-1/4 rounded-full bg-[var(--status-success)] ring-2 ring-background`,"data-assistant-working-dot":``,"aria-label":u(`assistants.contact.working`)}):null,t[9]=u,t[10]=l,t[11]=g):g=t[11];let _;return t[12]!==f||t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,X.jsxs)(`span`,{className:f,style:m,"data-assistant-working-avatar":``,children:[h,g]}),t[12]=f,t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16],_},ue=o(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),de=({sending:e=!1,processing:t=!1})=>e||t,Z=e=>{let t=(0,J.c)(4),n;t[0]===e?n=t[1]:(n=t=>!!t.workingByID[e],t[0]=e,t[1]=n);let r=ue(n),i;return t[2]===r?i=t[3]:(i=de({processing:r}),t[2]=r,t[3]=i),i},fe=[],pe=e=>e.flatMap(e=>e.type===`text`&&e.text.trim()?[e.text]:[]).join(`
|
|
2
|
-
`),me=(e,t,n,r=Date.now())=>({assistantID:e,messageID:t,parts:n,status:`sending`,createdAt:r}),he=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},Q=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},ge=(e,t,n,r)=>({messageID:t?`${e.turnID}:preview:${t.bubbleIndex}`:`${e.turnID}:preview:${r}`,assistantID:e.assistantID,role:`assistant`,turnID:e.turnID,bubbleIndex:t?.bubbleIndex??0,createdAt:t?.occurredAt??e.occurredAt,ordinal:n,status:r,fromAssistantID:null,fromAssistantName:null,parts:t?[{type:`text`,text:t.text}]:[],text:t?.text??``,cards:[]}),_e=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>ge(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`failed`?[...r,ge(e,null,n+r.length,`failed`)]:e.status===`admitted`||e.status===`streaming`?[...r,ge(e,null,n+r.length,`admitted`)]:r},ve=(e,t,n,r=[])=>{let i=new Set(e.map(e=>e.messageID)),a=t.flatMap((t,r)=>t.assistantID!==n||i.has(t.messageID)?[]:[{messageID:t.messageID,assistantID:n,role:`user`,turnID:t.messageID,bubbleIndex:0,createdAt:t.createdAt,ordinal:e.length+r,status:t.status,fromAssistantID:null,fromAssistantName:null,parts:[...t.parts],text:pe(t.parts),cards:[]}]),o=a.length===0?e:[...e,...a],s=r.filter(e=>e.assistantID===n);if(s.length===0)return o;let c=new Map,l=new Map;o.forEach((e,t)=>{if(c.set(e.turnID,t),e.role!==`assistant`||e.messageID.includes(`:preview:`))return;let n=l.get(e.turnID)??new Set;n.add(e.bubbleIndex),l.set(e.turnID,n)});let u=new Map,d=[];for(let e of s){let t=_e(e,l.get(e.turnID)??new Set,o.length+d.length);if(t.length===0)continue;let n=c.get(e.turnID);if(n===void 0){d.push(...t);continue}let r=u.get(n)??[];r.push(...t),u.set(n,r)}return u.size===0&&d.length===0?o:o.flatMap((e,t)=>[e,...u.get(t)??[]]).concat(d)},ye=(e,t)=>{let n=new Set(t.map(e=>e.messageID)),r=e.filter(e=>!n.has(e.messageID));return r.length===e.length?e:r},be=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),$=(e,t,n,r=Date.now())=>e.some(e=>e.assistantID===t&&e.turnID===n)?e:[...e,{assistantID:t,turnID:n,status:`admitted`,bubbles:[],occurredAt:r}],xe=(e,t)=>$(e,t.assistantID,t.turnID,t.occurredAt).map(e=>{if(e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`failed`||e.status===`complete`)return e;let n=e.bubbles.find(e=>e.bubbleIndex===t.bubbleIndex);if(n?.done)return e;let r=n?{...n,text:`${n.text}${t.delta}`,done:t.done,occurredAt:t.occurredAt}:{bubbleIndex:t.bubbleIndex,text:t.delta,done:t.done,occurredAt:t.occurredAt},i=n?e.bubbles.map(e=>e.bubbleIndex===t.bubbleIndex?r:e):[...e.bubbles,r].sort((e,t)=>e.bubbleIndex-t.bubbleIndex);return{...e,status:`streaming`,bubbles:i}}),Se=(e,t)=>$(e,t.assistantID,t.turnID,t.occurredAt).map(e=>e.assistantID!==t.assistantID||e.turnID!==t.turnID?e:{...e,status:t.status===`error`?`failed`:`complete`,...t.error?{error:t.error}:{}}),Ce=(e,t)=>{let n=new Set(t.flatMap(e=>e.role===`assistant`?[e.turnID]:[])),r=e.filter(e=>e.status!==`complete`||!n.has(e.turnID));return r.length===e.length?e:r},we=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),Te=(e,t)=>{if(e instanceof k){if(e.code===`no_provider`)return t.noProvider;if(e.code===`admission_timeout`||e.code===`generate_timeout`)return t.timedOut;if(e.message&&e.message!==e.code)return e.message}return S(e)?t.timedOut:t.sendFailed},Ee=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},De=e=>{let t=e.text.trim();if(e.sending||!t&&e.attachments.length===0||!e.gate.tryAcquire())return{ok:!1};let n=[...t?[{type:`text`,text:t}]:[],...e.attachments.map(e=>({type:`file`,mime:e.mime,url:e.url,filename:e.name}))],r=e.createMessageID();return{ok:!0,messageID:r,parts:n,turn:me(e.assistantID,r,n,e.createdAt)}},Oe=e=>e.some(e=>e.status===`sending`),ke=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),Ae=[`cursor-pointer rounded-[1.35rem] bg-[var(--surface-elevated)] ring-1 ring-inset ring-[var(--surface-subtle)]`,`px-3.5 py-3 text-left transition-[background-color,box-shadow,transform] duration-200 ease-out motion-reduce:transition-none`,`hover:-translate-y-px hover:bg-interactive-hover/45 hover:shadow-sm active:translate-y-0 motion-reduce:hover:translate-y-0`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),je=`${Ae} w-fit max-w-[15rem]`,Me=`${Ae} w-fit max-w-[20rem]`;function Ne(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var Pe=e=>{let t=(0,J.c)(26),{card:n}=e,{t:r}=p(),i=K(),a;t[0]===i?a=t[1]:(a=i&&!l(),t[0]=i,t[1]=a);let o=!!a,s=n.name,c=`${n.providerID}/${n.modelID}`,u;t[2]!==n.mode||t[3]!==c?(u=[c,n.mode].filter(Boolean),t[2]=n.mode,t[3]=c,t[4]=u):u=t[4];let d=u,m;t[5]!==n.assistantID||t[6]!==o?(m=()=>{if(o){y.getState().openAssistant(n.assistantID);return}j(n.assistantID)},t[5]=n.assistantID,t[6]=o,t[7]=m):m=t[7];let h=f(m),g;t[8]===h?g=t[9]:(g=e=>{Ne(e,h)},t[8]=h,t[9]=g);let _=f(g),v;t[10]!==r||t[11]!==s?(v=r(`assistants.contact.card.assistant.aria`,{name:s}),t[10]=r,t[11]=s,t[12]=v):v=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:(0,X.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,X.jsx)(V,{name:`robot-2`,className:`size-3`})})}),t[13]=b):b=t[13];let x;t[14]===s?x=t[15]:(x=(0,X.jsx)(`h3`,{className:`min-w-0 truncate typography-ui-label font-medium text-foreground`,children:s}),t[14]=s,t[15]=x);let S;t[16]===d?S=t[17]:(S=d.length>0?(0,X.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:d.join(` · `)}):null,t[16]=d,t[17]=S);let C;t[18]!==x||t[19]!==S?(C=(0,X.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[b,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[x,S]})]}),t[18]=x,t[19]=S,t[20]=C):C=t[20];let w;return t[21]!==_||t[22]!==h||t[23]!==C||t[24]!==v?(w=(0,X.jsx)(`article`,{className:je,role:`button`,tabIndex:0,"aria-label":v,"data-assistant-contact-card":`assistant`,onClick:h,onKeyDown:_,children:C}),t[21]=_,t[22]=h,t[23]=C,t[24]=v,t[25]=w):w=t[25],w},Fe=e=>{let t=(0,J.c)(25),{card:n}=e,{t:r}=p(),i=n.name,a;t[0]!==n.kind||t[1]!==n.time||t[2]!==n.timezone?(a=[n.kind,n.time,n.timezone].filter(Boolean),t[0]=n.kind,t[1]=n.time,t[2]=n.timezone,t[3]=a):a=t[3];let o=a.join(` `),s;t[4]!==n.prompt||t[5]!==o?(s=o.trim()||(typeof n.prompt==`string`?n.prompt.trim():``),t[4]=n.prompt,t[5]=o,t[6]=s):s=t[6];let c=s,l=f(Ie),u;t[7]===l?u=t[8]:(u=e=>{Ne(e,l)},t[7]=l,t[8]=u);let d=f(u),m;t[9]!==r||t[10]!==i?(m=r(`assistants.contact.card.schedule.aria`,{name:i}),t[9]=r,t[10]=i,t[11]=m):m=t[11];let h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:(0,X.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,X.jsx)(V,{name:`calendar`,className:`size-3`})})}),t[12]=h):h=t[12];let g;t[13]===i?g=t[14]:(g=(0,X.jsx)(`h3`,{className:`min-w-0 truncate typography-ui-label font-medium text-foreground`,children:i}),t[13]=i,t[14]=g);let _;t[15]===c?_=t[16]:(_=c?(0,X.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:c}):null,t[15]=c,t[16]=_);let v;t[17]!==g||t[18]!==_?(v=(0,X.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[h,(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[g,_]})]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==d||t[21]!==l||t[22]!==m||t[23]!==v?(y=(0,X.jsx)(`article`,{className:je,role:`button`,tabIndex:0,"aria-label":m,"data-assistant-contact-card":`schedule`,onClick:l,onKeyDown:d,children:v}),t[20]=d,t[21]=l,t[22]=m,t[23]=v,t[24]=y):y=t[24],y};function Ie(){i.getState().setActiveMainTab(`schedule`),i.getState().setScheduledTasksDialogOpen(!0)}var Le=(e,t)=>e===`busy`||e===`retry`?e:t===`error`||t===`question`||t===`complete`?t:e===`idle`?`complete`:t===`busy`||t===`retry`||t===`idle`?t:t||`busy`,Re=e=>e===`busy`?`assistants.contact.card.session.status.busy`:e===`retry`?`assistants.contact.card.session.status.retry`:e===`idle`?`assistants.contact.card.session.status.idle`:e===`complete`?`assistants.contact.card.session.status.complete`:e===`error`?`assistants.contact.card.session.status.error`:e===`question`?`assistants.contact.card.session.status.question`:null,ze=e=>e===`busy`?`bg-[var(--status-info)]/10 text-[var(--status-info)]`:e===`retry`||e===`question`?`bg-[var(--status-warning)]/10 text-[var(--status-warning)]`:e===`error`?`bg-[var(--status-error)]/10 text-[var(--status-error)]`:e===`idle`||e===`complete`?`bg-[var(--status-success)]/10 text-[var(--status-success)]`:`bg-[var(--surface-muted)] text-muted-foreground`,Be=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,Ve=e=>{let t=(0,J.c)(35),{card:n}=e,{t:r}=p(),a=K(),o;t[0]===a?o=t[1]:(o=a&&!l(),t[0]=a,t[1]=o);let s=!!o,c;t[2]===n.sessionID?c=t[3]:(c=e=>e.activeSessions.find(e=>e.id===n.sessionID)??e.archivedSessions.find(e=>e.id===n.sessionID)??null,t[2]=n.sessionID,t[3]=c);let u=_(c),d=v(n.sessionID),m=(typeof u?.title==`string`&&u.title.trim()?u.title.trim():null)||n.title||r(`assistants.contact.card.session.untitled`),h=Le(d?.type,n.status),g=Re(h),y=h===`busy`||h===`retry`,x=Be(typeof u?.directory==`string`&&u.directory.trim()?u.directory.trim():n.directory),S=te(u)||n.branch,C=ee(u),w=ne(u),T=re(w),E=[x,C,S].filter(He),D;t[4]!==n.directory||t[5]!==n.sessionID||t[6]!==s?(D=()=>{let e=q(n.sessionID)?.directory||n.directory;b(n.sessionID,e,{phoneShell:s,switchToChat:!0}),s||i.getState().setActiveMainTab(`chat`)},t[4]=n.directory,t[5]=n.sessionID,t[6]=s,t[7]=D):D=t[7];let O=f(D),k;t[8]===O?k=t[9]:(k=e=>{Ne(e,O)},t[8]=O,t[9]=k);let A=f(k),j=Me,M=r(`assistants.contact.card.session.aria`,{title:m}),N;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(`span`,{className:`flex size-6 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,X.jsx)(V,{name:`chat-3`,className:`size-3`})}),t[10]=N):N=t[10];let P;t[11]===y?P=t[12]:(P=y?(0,X.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2 translate-x-1/4 translate-y-1/4 rounded-full bg-[var(--status-success)] ring-2 ring-[var(--surface-elevated)]`,"data-assistant-working-dot":``,"aria-hidden":!0}):null,t[11]=y,t[12]=P);let F;t[13]===P?F=t[14]:(F=(0,X.jsxs)(`span`,{className:`relative inline-block size-6 shrink-0 leading-none`,children:[N,P]}),t[13]=P,t[14]=F);let I;t[15]===m?I=t[16]:(I=(0,X.jsx)(`h3`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:m}),t[15]=m,t[16]=I);let L=g?(0,X.jsx)(`span`,{className:z(`shrink-0 rounded-full px-1.5 py-0.5 typography-micro leading-none`,ze(h)),children:r(g)}):null,R;t[17]!==I||t[18]!==L?(R=(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[I,L]}),t[17]=I,t[18]=L,t[19]=R):R=t[19];let B;t[20]===E?B=t[21]:(B=E.length>0?(0,X.jsx)(`p`,{className:`truncate typography-micro text-muted-foreground`,children:E.join(` · `)}):null,t[20]=E,t[21]=B);let H=T||w?.files!==void 0&&w.files>0?(0,X.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-1.5 typography-micro tabular-nums`,children:[w?.additions===void 0?null:(0,X.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,w.additions]}),w?.deletions===void 0?null:(0,X.jsxs)(`span`,{className:`text-[var(--status-error)]`,children:[`−`,w.deletions]}),w?.files===void 0?null:(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:w.files===1?r(`assistants.contact.card.session.changes.filesSingle`,{count:w.files}):r(`assistants.contact.card.session.changes.filesPlural`,{count:w.files})})]}):null,U;t[22]!==R||t[23]!==B||t[24]!==H?(U=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[R,B,H]}),t[22]=R,t[23]=B,t[24]=H,t[25]=U):U=t[25];let W;t[26]!==F||t[27]!==U?(W=(0,X.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[F,U]}),t[26]=F,t[27]=U,t[28]=W):W=t[28];let G;return t[29]!==A||t[30]!==O||t[31]!==W||t[32]!==j||t[33]!==M?(G=(0,X.jsx)(`article`,{className:j,role:`button`,tabIndex:0,"aria-label":M,"data-assistant-contact-card":`session`,onClick:O,onKeyDown:A,children:W}),t[29]=A,t[30]=O,t[31]=W,t[32]=j,t[33]=M,t[34]=G):G=t[34],G};function He(e){return!!(e&&e.trim())}var Ue=64,We=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{t(typeof r.result==`string`?r.result:``)},r.onerror=()=>{n(r.error??Error(`read_failed`))},r.readAsDataURL(e)}),Ge=e=>{if(!e)return[];let t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e instanceof File)},Ke=e=>Array.from(e?.files||[]),qe=async(e,t=a)=>{let n=[],r=0;for(let i of Array.from(e||[])){if(!i||i.size<=0)continue;if(i.size>52428800){r+=1;continue}let e=await We(i);e.startsWith(`data:`)&&n.push({id:t(),url:e,name:i.name.trim()||`attachment`,mime:i.type.trim()||`application/octet-stream`})}return{attachments:n,skippedTooLarge:r}},Je=(e,t)=>[...e,...t].slice(0,Ue),Ye={"oc.settle.complete":`assistants.contact.settle.complete`,"oc.settle.error":`assistants.contact.settle.error`,"oc.settle.question":`assistants.contact.settle.question`},Xe=({assistant:e,warning:t,active:n,overlayHeader:r=!1})=>{let{t:o}=p(),s=i(e=>e.isMobile),c=w(),l=T(),u=E(e.id,n),d=m(e.name),_=d.displayName||e.name,v=(e,t)=>{let n=e?l.data?.assistants.find(t=>t.id===e):void 0;return n?m(n.name).displayName||n.name:t||o(`assistants.contact.peer.unknown`)},[y,b]=Y.useState(``),[x,S]=Y.useState([]),[D,O]=Y.useState([]),[k,A]=Y.useState([]),[j,M]=Y.useState(null),N=Y.useMemo(()=>Ee(),[]),P=Y.useRef(new Set),F=ue(e=>e.setWorking),I=Y.useRef(null),L=u.data?.messages??fe,R=he(D,e.id),B=Q(k,e.id),H=ve(L,R,e.id,B),U=Oe(R),ee=ke(B),te=B.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),ne=new Map(B.map(e=>[e.turnID,e]));Y.useEffect(()=>{M(null),P.current.clear(),O(t=>he(t,e.id)),A(t=>Q(t,e.id))},[e.id]),Y.useEffect(()=>{O(e=>ye(e,L)),A(e=>Ce(e,L))},[L]),Y.useEffect(()=>{F(e.id,U||ee)},[e.id,ee,U,F]),Y.useEffect(()=>{let t=e.id;return()=>{F(t,!1)}},[e.id,F]);let re=f(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){if(P.current.has(t.turnID))return;A(e=>$(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(P.current.has(t.turnID))return;A(e=>xe(e,t));return}t.type===`contact-turn-end`&&(P.current.add(t.turnID),A(e=>Ce(Se(e,t),L)))}});Y.useEffect(()=>{if(n)return g(re)},[n,e.id]),Y.useEffect(()=>{let e=I.current;e&&(e.scrollTop=e.scrollHeight)},[te,H.length]);let K=f(async e=>{let t=await qe(e);t.skippedTooLarge>0&&M(o(`assistants.contact.attachment.tooLarge`)),t.attachments.length!==0&&S(e=>Je(e,t.attachments))}),ie=f(e=>{let t=Ge(e.clipboardData);t.length!==0&&(e.preventDefault(),K(t))}),ae=f(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),oe=f(e=>{let t=Ke(e.dataTransfer);t.length!==0&&(e.preventDefault(),K(t))}),se=f(async()=>{let t=y,n=x,r=e.id,i=De({gate:N,sending:Oe(R),text:t,attachments:n,assistantID:r,createMessageID:()=>`oc_contact_${a()}`});if(i.ok){O(e=>[...e,i.turn]),b(``),S([]),M(null);try{await C(r,i.messageID,{parts:i.parts}),O(e=>be(e,i.messageID)),P.current.has(i.messageID)||A(e=>$(e,r,i.messageID)),c.data?.serverInstanceID&&h({serverInstanceID:c.data.serverInstanceID,assistantID:r,name:_,avatarSeed:r,...d.avatarEmoji?{avatarEmoji:d.avatarEmoji}:{}}).catch(()=>void 0)}catch(e){let t=Te(e,{noProvider:o(`assistants.contact.noProvider`),sendFailed:o(`assistants.contact.sendFailed`),timedOut:o(`assistants.contact.timedOut`)});O(e=>we(e,i.messageID,t))}finally{N.release()}}}),ce=u.isError&&H.length===0,q=u.isSuccess&&H.length===0,J=new Map(R.map(e=>[e.messageID,e]));return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,children:[(0,X.jsxs)(`div`,{ref:I,className:z(`min-h-0 flex-1 overflow-y-auto px-4 pb-9 sm:px-8 sm:pb-12`,r?`pt-[calc(max(0.625rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height)+1.25rem)]`:`pt-5 sm:pt-7`),"data-assistant-contact-transcript":``,children:[t?(0,X.jsx)(`p`,{className:`mb-3 typography-micro text-[var(--status-warning)]`,children:t}):null,ce?(0,X.jsxs)(`div`,{className:`mx-auto flex h-full min-h-56 max-w-xs flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-error":``,children:[(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(le,{name:e.id,emoji:d.avatarEmoji,size:44,label:_}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--surface-elevated)] text-[var(--status-error)] ring-2 ring-background`,children:(0,X.jsx)(V,{name:`error-warning`,className:`size-3`})})]}),(0,X.jsx)(`p`,{className:`mt-4 typography-ui-label font-medium text-foreground`,children:_}),(0,X.jsx)(`p`,{className:`mt-1.5 typography-ui leading-6 text-muted-foreground`,children:o(`assistants.contact.loadFailed`)})]}):q?(0,X.jsxs)(`div`,{className:`mx-auto flex h-full min-h-56 max-w-sm flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-empty":``,children:[(0,X.jsx)(le,{name:e.id,emoji:d.avatarEmoji,size:48,label:_,className:`opacity-90`}),(0,X.jsx)(`p`,{className:`mt-5 typography-ui-header font-medium tracking-[-0.01em] text-foreground`,children:o(`assistants.conversation.emptyTitle`,{name:_})}),(0,X.jsx)(`p`,{className:`mt-2 max-w-xs typography-ui leading-6 text-muted-foreground/80`,children:o(`assistants.contact.empty`)})]}):(0,X.jsx)(`div`,{className:`mx-auto flex w-full max-w-[42rem] flex-col`,children:H.map((t,n)=>{let r=n>0?H[n-1]:null,i=t.role===`user`,a=t.role===`peer`,s=t.role===`assistant`&&r?.role===`assistant`&&r.turnID===t.turnID,c=r?.turnID!==t.turnID,u=!i&&(a||!s),d=a?v(t.fromAssistantID,t.fromAssistantName):_,f=a&&t.fromAssistantID?l.data?.assistants.find(e=>e.id===t.fromAssistantID):e,p=f?m(f.name):null,h=J.get(t.messageID),g=ne.get(t.turnID),y=t.status===`admitted`&&t.messageID.endsWith(`:preview:admitted`),b=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`);return(0,X.jsxs)(`div`,{className:z(`flex w-full`,i?`justify-end`:`justify-start`,c?`mt-6 first:mt-0`:s?`mt-1.5`:`mt-3`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":h?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!s?``:void 0,children:[i?null:(0,X.jsx)(`div`,{className:`mr-2.5 flex w-8 shrink-0 justify-center pt-0.5`,children:u?(0,X.jsx)(le,{name:f?.id||t.fromAssistantID||e.id,emoji:p?.avatarEmoji,size:28,label:d}):(0,X.jsx)(`span`,{className:`size-7`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:z(`flex min-w-0 flex-col gap-1.5`,i?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[a?(0,X.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:o(`assistants.contact.peer.from`,{name:d})}):null,y?(0,X.jsxs)(`div`,{role:`status`,"aria-label":o(`assistants.contact.processing`),className:`inline-flex w-fit items-center gap-1 rounded-full bg-[var(--surface-muted)] px-3.5 py-2.5 text-muted-foreground/70`,"data-assistant-contact-processing":``,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.45s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.22s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-duration:1.4s] motion-reduce:animate-none`})]}):null,t.parts.map((e,n)=>{if(e.type===`card`&&e.cardType===`session`)return(0,X.jsx)(Ve,{card:e},`${t.messageID}:card:${n}`);if(e.type===`card`&&e.cardType===`assistant`)return(0,X.jsx)(Pe,{card:e},`${t.messageID}:card:${n}`);if(e.type===`card`&&e.cardType===`schedule`)return(0,X.jsx)(Fe,{card:e},`${t.messageID}:card:${n}`);if(e.type===`file`&&e.mime.startsWith(`image/`)&&e.url)return(0,X.jsx)(`img`,{src:e.url,alt:e.filename||o(`assistants.contact.attachment.image`),className:`max-h-72 max-w-full rounded-[1.35rem] border border-border/40 object-contain`,"data-assistant-contact-image":``},`${t.messageID}:file:${n}`);if(e.type===`file`)return(0,X.jsxs)(`div`,{className:`flex max-w-full items-center gap-2.5 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5 ring-1 ring-inset ring-[var(--surface-subtle)]`,"data-assistant-contact-file":``,children:[(0,X.jsx)(V,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:e.filename||o(`assistants.contact.attachment.file`)})]},`${t.messageID}:file:${n}`);if(e.type===`text`&&(e.text.trim()||t.status===`streaming`)){let r=Ye[e.text],c=!i&&!r;return(0,X.jsxs)(`div`,{"aria-label":a?o(`assistants.contact.peer.aria`,{name:d}):void 0,className:z(`break-words rounded-[1.35rem] px-4 py-2.5 typography-ui leading-6`,c?`min-w-0`:`whitespace-pre-wrap`,i?`rounded-[1.15rem] rounded-br-lg bg-[var(--primary-base)]/90 text-[var(--primary-foreground)]`:a?`rounded-[1.25rem] border border-dashed border-border/50 bg-[var(--surface-muted)]/70 text-foreground`:z(`bg-[var(--surface-muted)] text-foreground`,s&&`rounded-tl-lg`)),children:[c?(0,X.jsx)(W,{content:e.text,messageId:t.messageID,isAnimated:!1,isStreaming:t.status===`streaming`,variant:`assistant`,enableFileReferences:!1,className:`w-auto max-w-full`}):r?o(r):e.text,t.status===`streaming`&&n===t.parts.length-1?(0,X.jsx)(`span`,{"aria-hidden":!0,className:`ml-0.5 inline-block h-[1em] w-px translate-y-[0.12em] animate-pulse bg-current opacity-45 [animation-duration:1.1s] motion-reduce:animate-none`,"data-assistant-contact-streaming-caret":``}):null]},`${t.messageID}:text:${n}`)}return null}),h?.status===`sending`?(0,X.jsx)(`p`,{className:`px-1 typography-micro text-muted-foreground/75`,children:o(`assistants.contact.sending`)}):null,h?.status===`failed`?(0,X.jsx)(`p`,{className:`px-1 typography-micro text-[var(--status-error)]`,children:h.error||o(`assistants.contact.sendFailed`)}):null,b?(0,X.jsx)(`p`,{className:`px-1 typography-micro text-[var(--status-error)]`,children:g?.error||o(`assistants.contact.sendFailed`)}):null]})]},t.messageID)})})]}),(0,X.jsxs)(`footer`,{className:`relative z-10 shrink-0 bg-background pt-1`,"data-assistant-contact-composer":``,children:[j?(0,X.jsx)(`p`,{className:`chat-input-column mb-2 typography-micro text-[var(--status-error)]`,children:j}):null,(0,X.jsx)(`form`,{className:z(`relative w-full pt-1.5 pb-4`,s&&`bottom-safe-area oc-mobile-composer`),onSubmit:e=>{e.preventDefault(),se()},onDragOver:ae,onDrop:oe,children:(0,X.jsx)(`div`,{className:`chat-input-column relative overflow-visible`,children:(0,X.jsx)(G,{layout:`inline`,value:y,attachments:x,pending:!1,isMobile:s,placeholder:o(`assistants.contact.placeholder`,{name:_}),sendLabel:o(`assistants.contact.send`),addFilesLabel:o(`assistants.contact.addFiles`),removeAttachmentLabel:o(`assistants.contact.removeAttachment`),fileAccept:`*/*`,onChange:e=>b(e),onSubmit:()=>{se()},onAddFiles:e=>{K(e)},onRemoveAttachment:e=>{S(t=>t.filter(t=>t.id!==e))},onPaste:ie,onDragOver:ae,onDrop:oe,className:z(`relative z-10`,s&&`oc-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":o(`assistants.contact.placeholder`,{name:_})}})})})]})]})};async function Ze(e){await D(e);let t=A.getState().defaultShareAssistant;if(t?.assistantID!==e.id)return;let n=await x();n.serverInstanceID&&t.serverInstanceID===n.serverInstanceID&&A.getState().setDefaultShareAssistant(null)}function Qe({assistant:e,open:t,onOpenChange:n,onDeleted:r}){let{t:i}=p(),[a,o]=Y.useState(!1),s=e?m(e.name).displayName||e.name:``,c=f(e=>{a&&!e||n(e)}),l=f(()=>{a||n(!1)}),u=f(async()=>{if(!(!e||a)){o(!0);try{await Ze(e),r?.(e.id),n(!1),d.success(i(`assistants.settings.toast.deleted`))}catch{d.error(i(`assistants.settings.toast.deleteFailed`))}finally{o(!1)}}});return(0,X.jsx)(R,{open:t&&e!==null,onOpenChange:c,children:(0,X.jsxs)(F,{className:`max-w-md`,children:[(0,X.jsxs)(N,{children:[(0,X.jsx)(I,{children:i(`assistants.settings.delete`)}),(0,X.jsx)(L,{children:i(`assistants.settings.deleteConfirm`,{name:s})})]}),(0,X.jsxs)(P,{children:[(0,X.jsx)(H,{size:`sm`,variant:`ghost`,onClick:l,disabled:a,children:i(`settings.common.actions.cancel`)}),(0,X.jsx)(H,{size:`sm`,variant:`destructive`,onClick:u,disabled:a,children:i(`settings.common.actions.delete`)})]})]})})}var $e=e=>e.capabilityPending?`loading`:e.capabilityError||e.supported!==!0||e.capabilityEnabled!==!0?`unavailable`:e.snapshotPending?`loading`:e.snapshotEnabled===!0?e.assistantCount===0?`onboarding`:e.hasAssistant?`ready`:e.snapshotSettled?`unavailable`:`loading`:`unavailable`,et=t({AssistantView:()=>rt}),tt=e=>{let t=(0,J.c)(21),{assistant:n,onBack:r}=e,{t:i}=p(),a=K(),o;t[0]===n?o=t[1]:(o=n?m(n.name):null,t[0]=n,t[1]=o);let s=o,c=n&&s?s.displayName||n.name:``,l;t[2]!==n||t[3]!==a?(l=()=>{n&&M(n.id,a?{openMobileSettings:a.openSettings}:void 0)},t[2]=n,t[3]=a,t[4]=l):l=t[4];let u=f(l),d;t[5]!==n||t[6]!==c||t[7]!==s?.avatarEmoji||t[8]!==i?(d=n?(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2.5`,children:[(0,X.jsx)(le,{name:n.id,emoji:s?.avatarEmoji,size:28,label:c}),(0,X.jsx)(`span`,{className:`truncate font-medium tracking-[-0.01em]`,children:c||i(`assistants.title`)})]}):c||i(`assistants.title`),t[5]=n,t[6]=c,t[7]=s?.avatarEmoji,t[8]=i,t[9]=d):d=t[9];let h;t[10]===i?h=t[11]:(h=i(`assistants.actions.backToChat`),t[10]=i,t[11]=h);let g;t[12]!==n||t[13]!==u||t[14]!==i?(g=n?[{icon:`settings-3`,ariaLabel:i(`assistants.conversation.openSettings`),onClick:u}]:[],t[12]=n,t[13]=u,t[14]=i,t[15]=g):g=t[15];let _;return t[16]!==r||t[17]!==d||t[18]!==h||t[19]!==g?(_=(0,X.jsx)(O,{title:d,backAriaLabel:h,onBack:r,actions:g,overlay:!0}),t[16]=r,t[17]=d,t[18]=h,t[19]=g,t[20]=_):_=t[20],_},nt=e=>{let t=(0,J.c)(41),{assistantID:n,displayName:r,avatarEmoji:i,selected:a,enabled:o,editLabel:s,deleteLabel:c,onSelect:l,onEdit:u,onDelete:d}=e,p=Z(n),[m,h]=Y.useState(!1),g;t[0]===l?g=t[1]:(g=()=>l(),t[0]=l,t[1]=g);let _=f(g),v;t[2]===u?v=t[3]:(v=()=>{h(!1),u()},t[2]=u,t[3]=v);let y=f(v),b;t[4]===d?b=t[5]:(b=()=>{h(!1),d()},t[4]=d,t[5]=b);let x=f(b),S;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(S=e=>{e.preventDefault(),h(!0)},t[6]=S):S=t[6];let C=a?`border-border/50 bg-[var(--surface-elevated)]`:`border-transparent hover:bg-interactive-hover`,w=!o&&`opacity-65`,T;t[7]!==C||t[8]!==w?(T=z(`flex w-full min-h-11 items-center gap-3 rounded-xl border px-3 py-3 text-left outline-none transition-[background-color,border-color,opacity] duration-150 ease-out active:bg-interactive-active focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] motion-reduce:transition-none`,C,w),t[7]=C,t[8]=w,t[9]=T):T=t[9];let E;t[10]!==_||t[11]!==a||t[12]!==T?(E=(0,X.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":a,onClick:_,onContextMenu:S,className:T}),t[10]=_,t[11]=a,t[12]=T,t[13]=E):E=t[13];let D;t[14]!==n||t[15]!==i||t[16]!==r||t[17]!==p?(D=(0,X.jsx)(le,{name:n,emoji:i,size:24,label:r,working:p}),t[14]=n,t[15]=i,t[16]=r,t[17]=p,t[18]=D):D=t[18];let O;t[19]===r?O=t[20]:(O=(0,X.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(`span`,{className:`block truncate typography-ui-label font-medium`,children:r})}),t[19]=r,t[20]=O);let k;t[21]!==O||t[22]!==E||t[23]!==D?(k=(0,X.jsxs)(ie,{render:E,children:[D,O]}),t[21]=O,t[22]=E,t[23]=D,t[24]=k):k=t[24];let A;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,X.jsx)(V,{name:`edit`,className:`size-4`}),t[25]=A):A=t[25];let j;t[26]!==s||t[27]!==y?(j=(0,X.jsxs)(se,{onClick:y,children:[A,s]}),t[26]=s,t[27]=y,t[28]=j):j=t[28];let M;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,X.jsx)(ae,{}),t[29]=M):M=t[29];let N;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(V,{name:`delete-bin`,className:`size-4`}),t[30]=N):N=t[30];let P;t[31]!==c||t[32]!==x?(P=(0,X.jsxs)(se,{onClick:x,className:`text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)] [&_svg]:text-[var(--status-error)]`,children:[N,c]}),t[31]=c,t[32]=x,t[33]=P):P=t[33];let F;t[34]!==j||t[35]!==P?(F=(0,X.jsxs)(oe,{className:`min-w-[10rem]`,children:[j,M,P]}),t[34]=j,t[35]=P,t[36]=F):F=t[36];let I;return t[37]!==m||t[38]!==k||t[39]!==F?(I=(0,X.jsxs)(ce,{open:m,onOpenChange:h,children:[k,F]}),t[37]=m,t[38]=k,t[39]=F,t[40]=I):I=t[40],I},rt=e=>{let t=(0,J.c)(109),{activeOverride:a,onMobileBack:o}=e,{t:s}=p(),{isMobile:c}=U(),l=K(),u=Y.useSyncExternalStore(n,r,r),d=i(it),h=a??d,g=i(at),_=c||g,v=w(),y=T(),b=y.data,x;t[0]===u?x=t[1]:(x=e=>e.assistantByTransport[u]??null,t[0]=u,t[1]=x);let S=A(x),C=A(ot),E=A(st),D;t[2]!==S||t[3]!==b?.assistants?(D=b?.assistants.find(e=>e.id===S)??null,t[2]=S,t[3]=b?.assistants,t[4]=D):D=t[4];let O=D,k;t[5]!==C||t[6]!==S||t[7]!==b?(k=()=>{!S&&b?.assistants[0]&&C(b.assistants[0].id)},t[5]=C,t[6]=S,t[7]=b,t[8]=k):k=t[8];let j=b?.assistants,N;t[9]!==C||t[10]!==S||t[11]!==j?(N=[C,S,j],t[9]=C,t[10]=S,t[11]=j,t[12]=N):N=t[12],Y.useEffect(k,N);let P;t[13]!==O||t[14]!==C||t[15]!==S||t[16]!==b?.assistants||t[17]!==y.isSuccess?(P=()=>{y.isSuccess&&S&&!O&&C(b?.assistants[0]?.id??null)},t[13]=O,t[14]=C,t[15]=S,t[16]=b?.assistants,t[17]=y.isSuccess,t[18]=P):P=t[18];let F=b?.assistants,I;t[19]!==O||t[20]!==C||t[21]!==S||t[22]!==y.isSuccess||t[23]!==F?(I=[O,C,S,F,y.isSuccess],t[19]=O,t[20]=C,t[21]=S,t[22]=y.isSuccess,t[23]=F,t[24]=I):I=t[24],Y.useEffect(P,I);let L;t[25]!==l||t[26]!==E?(L=()=>{if(E(),l){l.openSettings();return}let e=i.getState();e.setSettingsPage(`assistants`),e.setSettingsDialogOpen(!0)},t[25]=l,t[26]=E,t[27]=L):L=t[27];let R=f(L),B;t[28]===l?B=t[29]:(B=e=>{M(e,l?{openMobileSettings:l.openSettings}:void 0)},t[28]=l,t[29]=B);let W=f(B),G;t[30]!==O||t[31]!==l?(G=()=>{O&&M(O.id,l?{openMobileSettings:l.openSettings}:void 0)},t[30]=O,t[31]=l,t[32]=G):G=t[32];let ee=f(G),[te,ne]=Y.useState(null),re;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(re=e=>{ne(e)},t[33]=re):re=t[33];let ie=f(re),ae;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>{e||ne(null)},t[34]=ae):ae=t[34];let oe=f(ae),se=f(ct),ce;t[35]!==o||t[36]!==se?(ce=()=>{if(o){o();return}se()},t[35]=o,t[36]=se,t[37]=ce):ce=t[37];let q=f(ce),ue=$e({capabilityPending:v.isPending,snapshotPending:y.isPending,capabilityError:v.isError,supported:v.data?.supported,capabilityEnabled:v.data?.enabled,snapshotEnabled:b?.enabled,snapshotSettled:y.isSuccess,assistantCount:b?.assistants.length??0,hasAssistant:!!O}),de;t[38]!==O||t[39]!==q||t[40]!==_?(de=(e,t,n,r)=>(0,X.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[_?(0,X.jsx)(tt,{assistant:O,onBack:q}):null,(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,children:[(0,X.jsx)(V,{name:e,className:`size-6 text-muted-foreground`}),(0,X.jsx)(`h1`,{className:`mt-4 typography-ui-header font-semibold`,children:t}),n?(0,X.jsx)(`p`,{className:`mt-2 max-w-md typography-ui text-muted-foreground`,children:n}):null,r?(0,X.jsx)(`div`,{className:`mt-5`,children:r}):null]})]}),t[38]=O,t[39]=q,t[40]=_,t[41]=de):de=t[41];let Z=de;if(ue===`loading`){let e;t[42]!==O||t[43]!==q||t[44]!==_?(e=_?(0,X.jsx)(tt,{assistant:O,onBack:q}):null,t[42]=O,t[43]=q,t[44]=_,t[45]=e):e=t[45];let n;t[46]===s?n=t[47]:(n=s(`common.loading`),t[46]=s,t[47]=n);let r;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsx)(V,{name:`loader-4`,className:`size-6 animate-spin text-muted-foreground`}),t[48]=r):r=t[48];let i;t[49]===n?i=t[50]:(i=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center px-6 pt-[calc(max(0.25rem,var(--oc-safe-area-top,0px))+var(--oc-mobile-detail-navigation-height,3.5rem))] text-center`,"aria-busy":`true`,"aria-label":n,"data-assistant-workspace-loading":``,children:r}),t[49]=n,t[50]=i);let a;return t[51]!==e||t[52]!==i?(a=(0,X.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col`,children:[e,i]}),t[51]=e,t[52]=i,t[53]=a):a=t[53],a}if(ue===`unavailable`){let e;return t[54]!==Z||t[55]!==s?(e=Z(`cloud-off`,s(`assistants.state.unavailable`)),t[54]=Z,t[55]=s,t[56]=e):e=t[56],e}if(ue===`onboarding`){let e;if(t[57]!==R||t[58]!==Z||t[59]!==s){let n=s(`assistants.onboarding.title`),r=s(`assistants.onboarding.description`),i;t[61]===s?i=t[62]:(i=s(`assistants.onboarding.action`),t[61]=s,t[62]=i);let a;t[63]!==R||t[64]!==i?(a=(0,X.jsx)(H,{onClick:R,children:i}),t[63]=R,t[64]=i,t[65]=a):a=t[65],e=Z(`ai-agent`,n,r,a),t[57]=R,t[58]=Z,t[59]=s,t[60]=e}else e=t[60];return e}if(!b||!O){let e;return t[66]!==Z||t[67]!==s?(e=Z(`cloud-off`,s(`assistants.state.unavailable`)),t[66]=Z,t[67]=s,t[68]=e):e=t[68],e}let fe;t[69]===O.name?fe=t[70]:(fe=m(O.name),t[69]=O.name,t[70]=fe);let pe=fe,me;t[71]!==O.enabled||t[72]!==y.isError||t[73]!==s?(me=O.enabled?y.isError?s(`assistants.state.staleSnapshot`):null:s(`assistants.state.assistantDisabled`),t[71]=O.enabled,t[72]=y.isError,t[73]=s,t[74]=me):me=t[74];let he=me,Q;t[75]!==_||t[76]!==W||t[77]!==ie||t[78]!==C||t[79]!==S||t[80]!==b||t[81]!==s?(Q=_?null:(0,X.jsxs)(`section`,{className:`flex h-full min-h-0 w-[clamp(16rem,22vw,20rem)] shrink-0 flex-col overflow-hidden`,children:[(0,X.jsx)(`header`,{className:`shrink-0 px-4 pb-3 pt-4 sm:px-5`,children:(0,X.jsx)(`h1`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:s(`assistants.title`)})}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3 pb-4 sm:px-4`,role:`listbox`,"aria-label":s(`assistants.listAria`),children:(0,X.jsx)(`div`,{className:`flex flex-col gap-1 border-t border-border/40 pt-3`,children:b.assistants.map(e=>{let t=e.id===S,n=m(e.name);return(0,X.jsx)(nt,{assistantID:e.id,displayName:n.displayName,avatarEmoji:n.avatarEmoji??void 0,selected:t,enabled:e.enabled,editLabel:s(`assistants.menu.edit`),deleteLabel:s(`assistants.settings.delete`),assignedSessionIDs:e.assignedSessionIDs,serverWorking:e.working,onSelect:()=>C(e.id),onEdit:()=>W(e.id),onDelete:()=>ie(e)},e.id)})})})]}),t[75]=_,t[76]=W,t[77]=ie,t[78]=C,t[79]=S,t[80]=b,t[81]=s,t[82]=Q):Q=t[82];let ge=te!==null,_e;t[83]!==te||t[84]!==oe||t[85]!==ge?(_e=(0,X.jsx)(Qe,{assistant:te,open:ge,onOpenChange:oe}),t[83]=te,t[84]=oe,t[85]=ge,t[86]=_e):_e=t[86];let ve=!_&&`border-l border-[var(--surface-subtle)]`,ye;t[87]===ve?ye=t[88]:(ye=z(`relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,ve),t[87]=ve,t[88]=ye);let be;t[89]!==O||t[90]!==q||t[91]!==_||t[92]!==ee||t[93]!==pe||t[94]!==s?(be=_?(0,X.jsx)(tt,{assistant:O,onBack:q}):(0,X.jsxs)(`header`,{className:`flex h-16 shrink-0 items-center gap-3.5 border-b border-[var(--surface-subtle)]/70 px-5 sm:px-7`,children:[(0,X.jsx)(le,{name:O.id,emoji:pe.avatarEmoji,size:30,label:pe.displayName||O.name}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate typography-ui-label font-semibold tracking-[-0.01em] text-foreground`,children:pe.displayName}),(0,X.jsx)(`div`,{className:`mt-1 truncate typography-micro leading-none text-muted-foreground/55`,children:s(`assistants.conversation.contactHint`)})]}),(0,X.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,className:`size-8 shrink-0 rounded-full text-muted-foreground/65 transition-colors hover:text-foreground`,onClick:ee,"aria-label":s(`assistants.conversation.openSettings`),children:(0,X.jsx)(V,{name:`settings-3`,className:`size-4`})})]}),t[89]=O,t[90]=q,t[91]=_,t[92]=ee,t[93]=pe,t[94]=s,t[95]=be):be=t[95];let $;t[96]!==h||t[97]!==O||t[98]!==_||t[99]!==he?($=(0,X.jsx)(Xe,{assistant:O,warning:he,active:h,overlayHeader:_}),t[96]=h,t[97]=O,t[98]=_,t[99]=he,t[100]=$):$=t[100];let xe;t[101]!==ye||t[102]!==be||t[103]!==$?(xe=(0,X.jsxs)(`div`,{className:ye,children:[be,$]}),t[101]=ye,t[102]=be,t[103]=$,t[104]=xe):xe=t[104];let Se;return t[105]!==Q||t[106]!==_e||t[107]!==xe?(Se=(0,X.jsxs)(`div`,{className:`relative flex h-full min-h-0 overflow-hidden bg-background`,"data-presentation":`workspace`,children:[Q,_e,xe]}),t[105]=Q,t[106]=_e,t[107]=xe,t[108]=Se):Se=t[108],Se};function it(e){return e.activeMainTab===`assistant`}function at(e){return e.isMobile}function ot(e){return e.selectAssistant}function st(e){return e.requestCreate}function ct(){i.getState().setActiveMainTab(`chat`)}export{le as a,Z as i,et as n,Qe as r,rt as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-Ymm12x6J.js","assets/rolldown-runtime-C0FnF6B9.js","assets/vendor-base-ui-CnHfUmDN.js","assets/vendor-react-DLPElpoQ.js","assets/vendor-markstream-react-C3K8YH0d.js","assets/vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/vendor-markstream-react-CGQrpq8a.css","assets/vendor-reactuses-core-DDoDDyM9.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/useMobileNavigationStore-f8xHJk7C.js","assets/useUIStore-CuaA8-Hp.js","assets/vendor-zustand-B4dlGEM2.js","assets/persistence-DdUac14I.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/platform-B4KKLnZ5.js","assets/vendor-opencode-sdk-C07HQypa.js","assets/vendor-tanstack-react-query-D7pys_c9.js","assets/vendor-sonner-DVzioF3d.js","assets/clipboard-DJ4nQEuY.js","assets/store-BDFdnk6l.js","assets/useAssistantUIStore-me6s63b2.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/utils-BiK3tBGM.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-DMzWVJaW.js","assets/useRuntimeAPIs-DSLXJybW.js","assets/url-Pk6tQ1EZ.js","assets/useEffectiveDirectory-BSyuAgz6.js","assets/markdownHeightCache-CvUyZT4q.js","assets/fileReferenceActions-BJJtX_S5.js","assets/toolHelpers-DEvVP9U0.js","assets/path-utils-jGozTg9d.js","assets/outsideFileGrants-DnplRxr-.js","assets/MarkstreamRendererImpl-CsNwy1T5.css","assets/MarkdownRendererImpl-Cslh4XN_.js","assets/vendor-katex--B5dHUyk.js","assets/markdownTheme-CzZm3riB.js","assets/vendor-pierre-diffs-DX7XTPG3.js","assets/vendor-hast-util-to-html-B0p1k5Xa.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-DpDied8H.js","assets/FadeInOnReveal-CK4asqVR.js","assets/MarkdownLoadingSkeleton-DWs4Jg7b.js","assets/markdown-worker-BuveaH3O.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-beautiful-mermaid-DykqIK5D.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t}from"./vendor-zustand-B4dlGEM2.js";import{nt as n,rt as r}from"./vendor-base-ui-CnHfUmDN.js";import{o as i}from"./vendor-aparajita-capacitor-secure-storage-CjQdwfjS.js";import{n as a}from"./vendor-react-DLPElpoQ.js";import{t as o}from"./utils-BiK3tBGM.js";import{t as s}from"./MarkdownLoadingSkeleton-DWs4Jg7b.js";import{n as c,t as l}from"./markdownHeightCache-CvUyZT4q.js";var u=a(),d=e(r(),1),f=`openchamber:chunk-import-reload`,p=250,m=3e4,h=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function g(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function _(e){let t=g(e);return h.some(e=>e.test(t))}function v(e){return`1.19.7:${g(e).slice(0,500)}`}function y(e){if(typeof window>`u`)return;let t=Date.now(),n=v(e),r=null;try{let e=window.sessionStorage.getItem(f);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<m)){try{window.sessionStorage.setItem(f,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:g(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function b(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!_(e)||t>=n)break;await new Promise(e=>setTimeout(e,p*(t+1)))}throw _(r)&&y(r),r}var x=e=>(0,d.lazy)(()=>b(e)),S=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return n?n.getItem(e)===`1`:!1}catch{return!1}},C=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},w=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},T=`oc:legend-timeline`,E=e=>S(T,e),D=`oc:markstream-react`,O=e=>C(D,e),k=t(e=>({legendTimelineEnabled:E(),setLegendTimelineEnabled:t=>{w(T,t),e({legendTimelineEnabled:t})},markstreamReactEnabled:O(),setMarkstreamReactEnabled:t=>{w(D,t),e({markstreamReactEnabled:t})}})),A=null,j=()=>(A??=i(()=>import(`./MarkstreamRendererImpl-Ymm12x6J.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39])).catch(e=>{throw A=null,e}),A),M=()=>{j().catch(()=>void 0)},N=null,P=()=>(N??=i(()=>import(`./MarkdownRendererImpl-Cslh4XN_.js`),__vite__mapDeps([40,1,14,15,2,16,17,3,18,19,20,5,41,10,11,12,23,24,13,21,22,25,26,27,28,29,30,42,43,44,45,46,47,48,49,50,51,52,37,31,32,33,53,54,34,55,56,57,58,59,60,35,36,38])).catch(e=>{throw N=null,e}),N),F=()=>{P().catch(()=>void 0),O()&&M()},I=class extends d.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},L=d.createContext(!0),R=()=>d.useContext(L),z=n(),B=x(()=>P().then(e=>({default:e.MarkdownRenderer}))),V=x(()=>j().then(e=>({default:e.MarkstreamRenderer}))),H=x(()=>P().then(e=>({default:e.SimpleMarkdownRenderer}))),U=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,W=e=>{let t=(0,u.c)(15),n=k(q),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?c(l(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let d=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,U(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==d?(p=(0,z.jsx)(s,{animated:e.animated,content:r,reservedHeight:d}),t[8]=r,t[9]=e.animated,t[10]=d,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,z.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},G=e=>{let t=(0,u.c)(9),n=R(),r=k(J);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(W,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,z.jsx)(d.Suspense,{fallback:(0,z.jsx)(W,{...e,reserveMeasuredHeight:!0}),children:(0,z.jsx)(B,{...e})}),t[2]=e,t[3]=i);let a=i;if(!r)return a;let o;t[4]===e?o=t[5]:(o=(0,z.jsx)(d.Suspense,{fallback:(0,z.jsx)(W,{...e,reserveMeasuredHeight:!0}),children:(0,z.jsx)(V,{...e})}),t[4]=e,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s=(0,z.jsx)(I,{fallback:a,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s},K=e=>{let t=(0,u.c)(4);if(!R()){let n;return t[0]===e?n=t[1]:(n=(0,z.jsx)(W,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,z.jsx)(d.Suspense,{fallback:(0,z.jsx)(W,{...e}),children:(0,z.jsx)(H,{...e})}),t[2]=e,t[3]=n),n};function q(e){return e.markstreamReactEnabled}function J(e){return e.markstreamReactEnabled}export{k as a,F as i,K as n,x as o,L as r,G as t};
|