@causyne/agent 1.20.124 → 1.20.128
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/bin/causyne.js +1 -1
- package/docs/THIRD_PARTY_NOTICES.md +36 -2
- package/package.json +6 -4
- package/src/acp/protocol.ts +19 -1
- package/src/acp/server.js +282 -8
- package/src/acp/server.ts +284 -8
- package/src/agent/abortableDelay.js +2 -2
- package/src/agent/abortableDelay.ts +2 -2
- package/src/agent/errorClassifier.js +9 -1
- package/src/agent/errorClassifier.ts +8 -1
- package/src/agentLoop.js +142 -53
- package/src/agentLoop.ts +151 -50
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +61 -3
- package/src/browser/causyneBrowser.ts +65 -3
- package/src/browser/urlPolicy.js +14 -1
- package/src/browser/urlPolicy.ts +12 -1
- package/src/cliMode.js +21 -9
- package/src/cliMode.ts +20 -8
- package/src/commands.js +365 -45
- package/src/commands.ts +403 -45
- package/src/config.js +19 -4
- package/src/config.ts +18 -4
- package/src/core/contextCompactor.js +54 -7
- package/src/core/contextCompactor.ts +63 -7
- package/src/core/goalLoop.js +257 -0
- package/src/core/goalLoop.ts +310 -0
- package/src/entrypoint.js +135 -3
- package/src/entrypoint.ts +136 -3
- package/src/game/causyneCoreBridge.js +686 -0
- package/src/game/causyneCoreBridge.ts +702 -0
- package/src/game/gameLauncher.js +287 -0
- package/src/game/gameLauncher.ts +352 -0
- package/src/game/gameProvisioner.js +425 -0
- package/src/game/gameProvisioner.ts +488 -0
- package/src/headlessCli.js +19 -12
- package/src/headlessCli.ts +22 -8
- package/src/infra/atomicWriter.js +40 -4
- package/src/infra/atomicWriter.ts +36 -4
- package/src/launchIntent.js +73 -3
- package/src/launchIntent.ts +76 -3
- package/src/lsp/lspClient.js +83 -12
- package/src/lsp/lspClient.ts +75 -12
- package/src/mcp/mcpRegistry.js +75 -8
- package/src/mcp/mcpRegistry.ts +70 -7
- package/src/memory/contextBudget.js +2 -0
- package/src/memory/contextBudget.ts +1 -0
- package/src/memory/episodicStore.js +40 -0
- package/src/memory/episodicStore.ts +46 -0
- package/src/memory.js +67 -0
- package/src/memory.ts +65 -0
- package/src/modelVariants.js +45 -0
- package/src/modelVariants.ts +54 -0
- package/src/outputRecovery.js +3 -2
- package/src/outputRecovery.ts +4 -2
- package/src/permissionPresets.js +327 -0
- package/src/permissionPresets.ts +361 -0
- package/src/personalization.js +365 -0
- package/src/personalization.ts +471 -0
- package/src/projectInstructions.js +30 -10
- package/src/projectInstructions.ts +31 -12
- package/src/providers/acp.js +3 -2
- package/src/providers/acp.ts +3 -2
- package/src/providers/antigravity.js +64 -9
- package/src/providers/antigravity.ts +75 -9
- package/src/providers/byokHttp.js +7 -1
- package/src/providers/byokHttp.ts +6 -1
- package/src/providers/byokStream.js +21 -8
- package/src/providers/byokStream.ts +17 -7
- package/src/providers/dashscope-byok.js +21 -5
- package/src/providers/dashscope-byok.ts +29 -11
- package/src/providers/moonshot.js +26 -7
- package/src/providers/moonshot.ts +34 -13
- package/src/providers/muse.js +6 -0
- package/src/providers/muse.ts +8 -0
- package/src/providers/ollama.js +39 -7
- package/src/providers/ollama.ts +36 -7
- package/src/providers/openai-compatible.js +16 -3
- package/src/providers/openai-compatible.ts +13 -3
- package/src/providers/openai.js +62 -4
- package/src/providers/openai.ts +50 -4
- package/src/providers/openrouter.js +19 -4
- package/src/providers/openrouter.ts +21 -4
- package/src/providers/qwen-byok.js +21 -5
- package/src/providers/qwen-byok.ts +29 -11
- package/src/providers/xai.js +26 -10
- package/src/providers/xai.ts +34 -16
- package/src/reporting.js +4 -2
- package/src/reporting.ts +4 -2
- package/src/sandbox.js +34 -0
- package/src/sandbox.ts +43 -0
- package/src/scheduler/scheduler.js +372 -0
- package/src/scheduler/scheduler.ts +433 -0
- package/src/sessionSearchIndex.js +267 -0
- package/src/sessionSearchIndex.ts +311 -0
- package/src/skillsManager.js +2 -3
- package/src/skillsManager.ts +2 -3
- package/src/toolPacks.js +6 -0
- package/src/toolPacks.ts +6 -0
- package/src/tools/applyPatch.js +1 -1
- package/src/tools/applyPatch.ts +1 -1
- package/src/tools/generateMediaViaApi.js +4 -3
- package/src/tools/generateMediaViaApi.ts +4 -3
- package/src/tools/memoryWrite.js +15 -1
- package/src/tools/memoryWrite.ts +16 -1
- package/src/tools/nativeEngine.js +2 -2
- package/src/tools/nativeEngine.ts +2 -2
- package/src/tools/openSourceToolProvisioner.js +2 -2
- package/src/tools/openSourceToolProvisioner.ts +2 -2
- package/src/tools/osSandbox.js +1 -1
- package/src/tools/osSandbox.ts +1 -1
- package/src/tools/payloadSanitizer.js +0 -1
- package/src/tools/payloadSanitizer.ts +0 -1
- package/src/tools/pdfReader.js +122 -20
- package/src/tools/pdfReader.ts +111 -20
- package/src/tools/presentDeliverable.js +103 -0
- package/src/tools/presentDeliverable.ts +127 -0
- package/src/tools/ptcRuntime.js +444 -0
- package/src/tools/ptcRuntime.ts +490 -0
- package/src/tools/ptyTerminal.js +1108 -0
- package/src/tools/ptyTerminal.ts +1245 -0
- package/src/tools/registry.js +21 -12
- package/src/tools/registry.ts +21 -12
- package/src/tools/toolOutputStore.js +26 -4
- package/src/tools/toolOutputStore.ts +22 -4
- package/src/tools/webFetch.js +158 -11
- package/src/tools/webFetch.ts +145 -11
- package/src/tools/webSearch.js +123 -36
- package/src/tools/webSearch.ts +124 -33
- package/src/tui/banner.js +5 -1
- package/src/tui/banner.ts +6 -1
- package/src/tui/chatRenderer.js +1 -2
- package/src/tui/chatRenderer.ts +1 -2
- package/src/tui/completion.js +1 -0
- package/src/tui/completion.ts +1 -0
- package/src/tui/composerControls.js +111 -27
- package/src/tui/composerControls.ts +124 -28
- package/src/tui/dialogs.js +3 -16
- package/src/tui/dialogs.ts +3 -16
- package/src/tui/home.js +1 -0
- package/src/tui/home.ts +1 -0
- package/src/tui/invocation.js +1 -2
- package/src/tui/invocation.ts +1 -2
- package/src/tui/modelPicker.js +22 -12
- package/src/tui/modelPicker.ts +22 -12
- package/src/tui/overlay.js +2 -5
- package/src/tui/overlay.ts +2 -5
- package/src/tui/prompt.js +6 -4
- package/src/tui/prompt.ts +6 -4
- package/src/tui/selectList.js +4 -12
- package/src/tui/selectList.ts +4 -12
- package/src/tui/setup.js +22 -9
- package/src/tui/setup.ts +26 -9
- package/src/tui/statusLine.ts +2 -0
- package/src/web/client/browserPanel.js +905 -0
- package/src/web/client/browserPanel.ts +872 -0
- package/src/web/client/chatStream.js +321 -0
- package/src/web/client/chatStream.ts +297 -0
- package/src/web/client/cliPanel.js +165 -0
- package/src/web/client/cliPanel.ts +171 -0
- package/src/web/client/composer.js +204 -0
- package/src/web/client/composer.ts +209 -0
- package/src/web/client/diffPanel.js +176 -0
- package/src/web/client/diffPanel.ts +203 -0
- package/src/web/client/dom.js +271 -0
- package/src/web/client/dom.ts +272 -0
- package/src/web/client/filesAndCanvas.js +233 -0
- package/src/web/client/filesAndCanvas.ts +240 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +316 -0
- package/src/web/client/main.ts +391 -0
- package/src/web/client/markdown.js +364 -0
- package/src/web/client/markdown.ts +373 -0
- package/src/web/client/modelPicker.js +455 -0
- package/src/web/client/modelPicker.ts +451 -0
- package/src/web/client/permissionPresetsUi.js +307 -0
- package/src/web/client/permissionPresetsUi.ts +333 -0
- package/src/web/client/sessions.js +353 -0
- package/src/web/client/sessions.ts +372 -0
- package/src/web/client/settingsModal.js +824 -0
- package/src/web/client/settingsModal.ts +959 -0
- package/src/web/client/state.js +280 -0
- package/src/web/client/state.ts +259 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +89 -0
- package/src/web/client/studioLayout.ts +103 -0
- package/src/web/client/studioShell.js +660 -0
- package/src/web/client/studioShell.ts +672 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +606 -0
- package/src/web/client/terminalPanel.ts +632 -0
- package/src/web/client/terminalTheme.js +249 -0
- package/src/web/client/terminalTheme.ts +258 -0
- package/src/web/client/turnView.js +934 -0
- package/src/web/client/turnView.ts +981 -0
- package/src/web/client/types.js +1 -0
- package/src/web/client/types.ts +322 -0
- package/src/web/client/validators.js +147 -0
- package/src/web/client/validators.ts +140 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +409 -0
- package/src/web/server/routesBrowser.ts +435 -0
- package/src/web/server/routesChat.js +304 -0
- package/src/web/server/routesChat.ts +347 -0
- package/src/web/server/routesCore.js +472 -0
- package/src/web/server/routesCore.ts +522 -0
- package/src/web/server/routesSettings.js +344 -0
- package/src/web/server/routesSettings.ts +397 -0
- package/src/web/server/routesTerminal.js +162 -0
- package/src/web/server/routesTerminal.ts +182 -0
- package/src/web/server/routesWorkspace.js +510 -0
- package/src/web/server/routesWorkspace.ts +546 -0
- package/src/web/server/security.js +98 -0
- package/src/web/server/security.ts +108 -0
- package/src/web/server/sessionTranscript.js +586 -0
- package/src/web/server/sessionTranscript.ts +566 -0
- package/src/web/server/staticAssets.js +104 -0
- package/src/web/server/staticAssets.ts +116 -0
- package/src/web/server/types.js +1 -0
- package/src/web/server/types.ts +135 -0
- package/src/web/server/workspaceFiles.js +368 -0
- package/src/web/server/workspaceFiles.ts +363 -0
- package/src/web/skybridgeServer.js +78 -2448
- package/src/web/skybridgeServer.ts +120 -2600
- package/src/web/skybridgeUi.js +20 -450
- package/src/web/skybridgeUi.ts +24 -455
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +935 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +951 -0
- package/src/web/styles/thread.css +221 -0
- package/src/web/styles/tokens.css +94 -0
- package/src/web/ui/brandMark.js +73 -0
- package/src/web/ui/brandMark.ts +82 -0
- package/src/web/ui/modalsTemplate.js +388 -0
- package/src/web/ui/modalsTemplate.ts +388 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +256 -0
- package/src/web/ui/studioTemplate.ts +256 -0
- package/src/web/ui/workspaceTemplate.js +72 -0
- package/src/web/ui/workspaceTemplate.ts +73 -0
- package/src/worktreeManager.js +16 -1
- package/src/worktreeManager.ts +22 -1
- package/src/web/skybridgeClientScript.js +0 -3951
- package/src/web/skybridgeClientScript.ts +0 -3952
- package/src/web/skybridgeStyles.js +0 -827
- package/src/web/skybridgeStyles.ts +0 -828
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { byId, dom } from './dom.js';
|
|
2
|
+
import {
|
|
3
|
+
applyStudioWidth,
|
|
4
|
+
restorePersistedPreferences,
|
|
5
|
+
scrollToBottom,
|
|
6
|
+
state,
|
|
7
|
+
updateComposerMetrics
|
|
8
|
+
} from './state.js';
|
|
9
|
+
import { configureMarkdownCallbacks } from './markdown.js';
|
|
10
|
+
import {
|
|
11
|
+
bindStudioResizer,
|
|
12
|
+
bindStudioSplitDivider,
|
|
13
|
+
closeAllPopovers,
|
|
14
|
+
closeStudio,
|
|
15
|
+
configureStudioTabHandlers,
|
|
16
|
+
endStudioResize,
|
|
17
|
+
isStudioResizing,
|
|
18
|
+
isStudioTabVisible,
|
|
19
|
+
openStudio,
|
|
20
|
+
positionPopover,
|
|
21
|
+
restoreStudioLayoutPreference,
|
|
22
|
+
setSecondaryStudioTab,
|
|
23
|
+
swapStudioSplitPanes,
|
|
24
|
+
toggleStudioMaximize,
|
|
25
|
+
toggleStudioNav,
|
|
26
|
+
toggleStudioSplit
|
|
27
|
+
} from './studioShell.js';
|
|
28
|
+
import {
|
|
29
|
+
bindStudioStartEvents,
|
|
30
|
+
configureStudioStartCallbacks
|
|
31
|
+
} from './studioStart.js';
|
|
32
|
+
import {
|
|
33
|
+
bindTerminalPanelEvents,
|
|
34
|
+
closeAllTerminalSessions,
|
|
35
|
+
deactivateTerminalPanel,
|
|
36
|
+
fitActiveTerminal,
|
|
37
|
+
focusActiveTerminal,
|
|
38
|
+
loadTerminalSessions,
|
|
39
|
+
openNewTerminalSession
|
|
40
|
+
} from './terminalPanel.js';
|
|
41
|
+
import {
|
|
42
|
+
bindFilesAndCanvasEvents,
|
|
43
|
+
configureFilesAndCanvasCallbacks,
|
|
44
|
+
loadFiles,
|
|
45
|
+
openFile,
|
|
46
|
+
openInCanvas,
|
|
47
|
+
saveFile
|
|
48
|
+
} from './filesAndCanvas.js';
|
|
49
|
+
import {
|
|
50
|
+
bindDiffPanelEvents,
|
|
51
|
+
configureDiffPanelCallbacks,
|
|
52
|
+
loadDiff
|
|
53
|
+
} from './diffPanel.js';
|
|
54
|
+
import {
|
|
55
|
+
bindBrowserPanelEvents,
|
|
56
|
+
closeBrowserWorkspace,
|
|
57
|
+
openBrowserArtifact,
|
|
58
|
+
openBrowserUrl,
|
|
59
|
+
refreshLiveBrowserState,
|
|
60
|
+
startLiveBrowserStream,
|
|
61
|
+
stopLiveBrowserStream,
|
|
62
|
+
syncBrowserViewportToStage
|
|
63
|
+
} from './browserPanel.js';
|
|
64
|
+
import {
|
|
65
|
+
bindCliPanelEvents,
|
|
66
|
+
configureCliPanelCallbacks,
|
|
67
|
+
loadCliCommands,
|
|
68
|
+
loadCliOverview,
|
|
69
|
+
renderCliQuickGrid,
|
|
70
|
+
runCliCommand
|
|
71
|
+
} from './cliPanel.js';
|
|
72
|
+
import { bindGameLauncherEvents, loadGameStatus } from './gameLauncherUi.js';
|
|
73
|
+
import {
|
|
74
|
+
bindModelPickerEvents,
|
|
75
|
+
configureModelPickerCallbacks,
|
|
76
|
+
loadHealth,
|
|
77
|
+
loadModels
|
|
78
|
+
} from './modelPicker.js';
|
|
79
|
+
import {
|
|
80
|
+
applyPermissionPresetUi,
|
|
81
|
+
bindPermissionPresetEvents,
|
|
82
|
+
closePermissionConfirmModal,
|
|
83
|
+
loadPermissionPresets
|
|
84
|
+
} from './permissionPresetsUi.js';
|
|
85
|
+
import {
|
|
86
|
+
bindSettingsModalEvents,
|
|
87
|
+
configureSettingsModalCallbacks,
|
|
88
|
+
loadDoctorReport,
|
|
89
|
+
openSettingsModal
|
|
90
|
+
} from './settingsModal.js';
|
|
91
|
+
import {
|
|
92
|
+
appendUserTurn,
|
|
93
|
+
configureTurnViewCallbacks,
|
|
94
|
+
createAssistantTurn
|
|
95
|
+
} from './turnView.js';
|
|
96
|
+
import {
|
|
97
|
+
attachWorkspaceFile,
|
|
98
|
+
bindComposerEvents,
|
|
99
|
+
configureComposerCallbacks
|
|
100
|
+
} from './composer.js';
|
|
101
|
+
import {
|
|
102
|
+
configureSessionsCallbacks,
|
|
103
|
+
loadSessions,
|
|
104
|
+
renderSessionList,
|
|
105
|
+
saveCurrentSessionWorkspace,
|
|
106
|
+
startFreshChat
|
|
107
|
+
} from './sessions.js';
|
|
108
|
+
import {
|
|
109
|
+
attachToActiveSessionStream,
|
|
110
|
+
stopActiveRun,
|
|
111
|
+
submitPrompt
|
|
112
|
+
} from './chatStream.js';
|
|
113
|
+
|
|
114
|
+
function wireModuleCallbacks(): void {
|
|
115
|
+
configureMarkdownCallbacks({
|
|
116
|
+
openFile,
|
|
117
|
+
openInCanvas,
|
|
118
|
+
openBrowserArtifact
|
|
119
|
+
});
|
|
120
|
+
configureStudioTabHandlers({
|
|
121
|
+
onFilesTab: () => { void loadFiles(state.currentDir, dom.fileFilterEl.value || ''); },
|
|
122
|
+
onDiffTab: () => { void loadDiff(); },
|
|
123
|
+
onCliTab: () => { void loadCliOverview(); },
|
|
124
|
+
onTerminalActivate: () => {
|
|
125
|
+
void loadTerminalSessions().then(() => {
|
|
126
|
+
fitActiveTerminal();
|
|
127
|
+
});
|
|
128
|
+
},
|
|
129
|
+
onTerminalDeactivate: deactivateTerminalPanel,
|
|
130
|
+
onTerminalClose: () => { void closeAllTerminalSessions(); },
|
|
131
|
+
onBrowserActivate: () => {
|
|
132
|
+
void refreshLiveBrowserState(false).then(() => { syncBrowserViewportToStage(false); });
|
|
133
|
+
startLiveBrowserStream();
|
|
134
|
+
},
|
|
135
|
+
onBrowserDeactivate: stopLiveBrowserStream,
|
|
136
|
+
onBrowserClose: () => { void closeBrowserWorkspace(); },
|
|
137
|
+
onLayoutResized: () => {
|
|
138
|
+
fitActiveTerminal();
|
|
139
|
+
syncBrowserViewportToStage(false);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
configureStudioStartCallbacks({
|
|
143
|
+
openNewTerminal: openNewTerminalSession,
|
|
144
|
+
openSettings: openSettingsModal,
|
|
145
|
+
launchGameStudio: () => { dom.navGameBtn?.click(); }
|
|
146
|
+
});
|
|
147
|
+
configureFilesAndCanvasCallbacks({
|
|
148
|
+
attachWorkspaceFile,
|
|
149
|
+
saveCurrentSessionWorkspace,
|
|
150
|
+
refreshDiffIfOpen: () => { if (state.studioTab === 'diff') void loadDiff(); }
|
|
151
|
+
});
|
|
152
|
+
configureDiffPanelCallbacks({
|
|
153
|
+
openFile,
|
|
154
|
+
saveCurrentSessionWorkspace
|
|
155
|
+
});
|
|
156
|
+
configureCliPanelCallbacks({
|
|
157
|
+
startFreshChat,
|
|
158
|
+
appendUserTurn,
|
|
159
|
+
loadHealth
|
|
160
|
+
});
|
|
161
|
+
configureModelPickerCallbacks({
|
|
162
|
+
createErrorTurn: (message) => {
|
|
163
|
+
const turn = createAssistantTurn('');
|
|
164
|
+
turn.addError(message);
|
|
165
|
+
return turn;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
configureSettingsModalCallbacks({
|
|
169
|
+
loadHealth,
|
|
170
|
+
loadModels
|
|
171
|
+
});
|
|
172
|
+
configureTurnViewCallbacks({
|
|
173
|
+
openFile,
|
|
174
|
+
openInCanvas,
|
|
175
|
+
openBrowserUrl,
|
|
176
|
+
openBrowserArtifact,
|
|
177
|
+
openSettingsForUpgrade: () => openSettingsModal('billing'),
|
|
178
|
+
submitPrompt
|
|
179
|
+
});
|
|
180
|
+
configureComposerCallbacks({
|
|
181
|
+
submitPrompt,
|
|
182
|
+
stopActiveRun,
|
|
183
|
+
runCliCommand
|
|
184
|
+
});
|
|
185
|
+
configureSessionsCallbacks({
|
|
186
|
+
attachToActiveSessionStream
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function bindShellAndNavigationEvents(): void {
|
|
191
|
+
dom.threadWrapEl.addEventListener('scroll', () => {
|
|
192
|
+
const curTop = dom.threadWrapEl.scrollTop;
|
|
193
|
+
const gap = dom.threadWrapEl.scrollHeight - curTop - dom.threadWrapEl.clientHeight;
|
|
194
|
+
const atBottom = gap <= 24;
|
|
195
|
+
const scrollingDown = curTop >= state.lastScrollTop;
|
|
196
|
+
if (atBottom && scrollingDown) state.stickToBottom = true;
|
|
197
|
+
else if (!atBottom && !scrollingDown) state.stickToBottom = false;
|
|
198
|
+
state.lastScrollTop = curTop;
|
|
199
|
+
dom.scrollBottomBtn.classList.toggle('visible', gap > 72 && !state.stickToBottom);
|
|
200
|
+
}, { passive: true });
|
|
201
|
+
dom.scrollBottomBtn.addEventListener('click', () => scrollToBottom(true, true));
|
|
202
|
+
|
|
203
|
+
dom.closeSidebarBtn.addEventListener('click', () => {
|
|
204
|
+
dom.appEl.classList.add('sidebar-collapsed');
|
|
205
|
+
if (dom.appEl.classList.contains('studio-open')) applyStudioWidth(state.studioWidth, false);
|
|
206
|
+
});
|
|
207
|
+
dom.openSidebarBtn.addEventListener('click', () => {
|
|
208
|
+
if (window.innerWidth <= 960 && dom.appEl.classList.contains('studio-open')) closeStudio();
|
|
209
|
+
dom.appEl.classList.remove('sidebar-collapsed');
|
|
210
|
+
if (dom.appEl.classList.contains('studio-open')) applyStudioWidth(state.studioWidth, false);
|
|
211
|
+
});
|
|
212
|
+
dom.sidebarBackdrop.addEventListener('click', () => {
|
|
213
|
+
dom.appEl.classList.add('sidebar-collapsed');
|
|
214
|
+
if (window.innerWidth <= 960 && dom.appEl.classList.contains('studio-open')) closeStudio();
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
dom.newChatBtn.addEventListener('click', () => { void startFreshChat(); });
|
|
218
|
+
dom.navFilesBtn.addEventListener('click', () => toggleStudioNav('files'));
|
|
219
|
+
dom.navCanvasBtn.addEventListener('click', () => toggleStudioNav('canvas'));
|
|
220
|
+
dom.navTerminalBtn?.addEventListener('click', () => toggleStudioNav('terminal'));
|
|
221
|
+
dom.navBrowserBtn.addEventListener('click', () => toggleStudioNav('browser'));
|
|
222
|
+
dom.navCliBtn.addEventListener('click', () => toggleStudioNav('cli'));
|
|
223
|
+
dom.navDiffBtn.addEventListener('click', () => toggleStudioNav('diff'));
|
|
224
|
+
|
|
225
|
+
dom.studioToggleBtn.addEventListener('click', () => {
|
|
226
|
+
if (dom.appEl.classList.contains('studio-open')) closeStudio();
|
|
227
|
+
else openStudio(state.studioTab || 'start');
|
|
228
|
+
});
|
|
229
|
+
dom.studioNewTabBtn?.addEventListener('click', () => { openStudio('start'); });
|
|
230
|
+
dom.studioSplitBtn?.addEventListener('click', () => { toggleStudioSplit(); });
|
|
231
|
+
dom.studioSecondarySelect?.addEventListener('change', () => {
|
|
232
|
+
if (dom.studioSecondarySelect) setSecondaryStudioTab(dom.studioSecondarySelect.value);
|
|
233
|
+
});
|
|
234
|
+
dom.studioSplitSwapBtn?.addEventListener('click', swapStudioSplitPanes);
|
|
235
|
+
dom.studioSplitCloseBtn?.addEventListener('click', () => toggleStudioSplit(false));
|
|
236
|
+
if (dom.studioExpandBtn) dom.studioExpandBtn.addEventListener('click', toggleStudioMaximize);
|
|
237
|
+
dom.studioCloseBtn.addEventListener('click', closeStudio);
|
|
238
|
+
|
|
239
|
+
dom.plusBtn.addEventListener('click', (e) => {
|
|
240
|
+
e.stopPropagation();
|
|
241
|
+
const wasOpen = dom.plusPopover.classList.contains('open');
|
|
242
|
+
closeAllPopovers();
|
|
243
|
+
if (!wasOpen) {
|
|
244
|
+
dom.plusBtn.setAttribute('aria-expanded', 'true');
|
|
245
|
+
positionPopover(dom.plusPopover, dom.plusBtn, true);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
byId('plus-attach-file').addEventListener('click', () => { closeAllPopovers(); openStudio('files'); dom.fileFilterEl.focus(); });
|
|
249
|
+
byId('plus-new-idoc').addEventListener('click', () => {
|
|
250
|
+
closeAllPopovers();
|
|
251
|
+
openInCanvas('docs/plan.idoc.md', '# Causyne idoc\n\n## Goal\n\n- \n', false);
|
|
252
|
+
});
|
|
253
|
+
byId('plus-open-browser').addEventListener('click', () => { closeAllPopovers(); openStudio('browser'); dom.browserUrlInput.focus(); });
|
|
254
|
+
byId('plus-open-diff').addEventListener('click', () => { closeAllPopovers(); openStudio('diff'); });
|
|
255
|
+
byId('plus-open-doctor').addEventListener('click', () => {
|
|
256
|
+
closeAllPopovers();
|
|
257
|
+
dom.settingsModal.classList.add('open');
|
|
258
|
+
void loadDoctorReport();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
document.addEventListener('click', (e) => {
|
|
262
|
+
const target = e.target as Node | null;
|
|
263
|
+
if (
|
|
264
|
+
!dom.modelPopover.contains(target) && !dom.modelTriggerBtn.contains(target)
|
|
265
|
+
&& !dom.plusPopover.contains(target) && !dom.plusBtn.contains(target)
|
|
266
|
+
&& !dom.permPopover.contains(target) && !dom.permTriggerBtn.contains(target)
|
|
267
|
+
&& !dom.browserMorePopover.contains(target) && !dom.browserMoreBtn.contains(target)
|
|
268
|
+
&& !dom.mentionPopover.contains(target)
|
|
269
|
+
) {
|
|
270
|
+
closeAllPopovers();
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
dom.sessionSearchEl.addEventListener('input', renderSessionList);
|
|
275
|
+
|
|
276
|
+
document.addEventListener('keydown', (e) => {
|
|
277
|
+
if (document.activeElement === dom.liveViewportSurface && state.liveBrowserActive) return;
|
|
278
|
+
const inTerminal = Boolean(
|
|
279
|
+
dom.termViewport
|
|
280
|
+
&& document.activeElement
|
|
281
|
+
&& dom.termViewport.contains(document.activeElement)
|
|
282
|
+
&& state.activeTerminalId
|
|
283
|
+
);
|
|
284
|
+
if (inTerminal && !(e.ctrlKey && !e.metaKey && !e.altKey && e.key === '`')) return;
|
|
285
|
+
const mod = e.metaKey || e.ctrlKey;
|
|
286
|
+
if (e.ctrlKey && !e.metaKey && !e.altKey && e.key === '`') {
|
|
287
|
+
e.preventDefault();
|
|
288
|
+
openStudio('terminal');
|
|
289
|
+
if (state.terminalSessions.length === 0) void openNewTerminalSession();
|
|
290
|
+
else focusActiveTerminal();
|
|
291
|
+
} else if (mod && e.altKey && e.key.toLowerCase() === 'p') {
|
|
292
|
+
e.preventDefault();
|
|
293
|
+
openStudio('files');
|
|
294
|
+
dom.fileFilterEl.focus();
|
|
295
|
+
} else if (mod && e.altKey && e.key.toLowerCase() === 't') {
|
|
296
|
+
e.preventDefault();
|
|
297
|
+
openStudio('browser');
|
|
298
|
+
dom.browserUrlInput.focus();
|
|
299
|
+
} else if (mod && e.altKey && e.key === 'Enter') {
|
|
300
|
+
e.preventDefault();
|
|
301
|
+
if (!dom.appEl.classList.contains('studio-open')) openStudio(state.studioTab || 'start');
|
|
302
|
+
toggleStudioMaximize();
|
|
303
|
+
} else if (mod && e.key.toLowerCase() === 'b') {
|
|
304
|
+
e.preventDefault();
|
|
305
|
+
dom.appEl.classList.toggle('sidebar-collapsed');
|
|
306
|
+
if (dom.appEl.classList.contains('studio-open')) applyStudioWidth(state.studioWidth, false);
|
|
307
|
+
} else if (mod && e.key === '\\') {
|
|
308
|
+
e.preventDefault();
|
|
309
|
+
if (dom.appEl.classList.contains('studio-open')) toggleStudioSplit();
|
|
310
|
+
else openStudio(state.studioTab || 'start');
|
|
311
|
+
} else if (mod && e.shiftKey && e.key.toLowerCase() === 'o') {
|
|
312
|
+
e.preventDefault();
|
|
313
|
+
void startFreshChat();
|
|
314
|
+
} else if (mod && e.key.toLowerCase() === 's' && dom.appEl.classList.contains('studio-open') && state.studioTab === 'canvas') {
|
|
315
|
+
e.preventDefault();
|
|
316
|
+
void saveFile();
|
|
317
|
+
} else if (e.key === 'Escape') {
|
|
318
|
+
if (isStudioResizing()) { endStudioResize(true); return; }
|
|
319
|
+
if (dom.permConfirmModal.classList.contains('open')) { closePermissionConfirmModal(); return; }
|
|
320
|
+
if (dom.settingsModal.classList.contains('open')) { dom.settingsModal.classList.remove('open'); return; }
|
|
321
|
+
if (
|
|
322
|
+
dom.modelPopover.classList.contains('open')
|
|
323
|
+
|| dom.plusPopover.classList.contains('open')
|
|
324
|
+
|| dom.permPopover.classList.contains('open')
|
|
325
|
+
|| dom.browserMorePopover.classList.contains('open')
|
|
326
|
+
|| dom.mentionPopover.classList.contains('open')
|
|
327
|
+
) {
|
|
328
|
+
closeAllPopovers();
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (dom.appEl.classList.contains('studio-open')) { closeStudio(); return; }
|
|
332
|
+
if (state.activeController) { void stopActiveRun(); }
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function startBackgroundPollers(): void {
|
|
338
|
+
setInterval(() => {
|
|
339
|
+
if (
|
|
340
|
+
state.activeController
|
|
341
|
+
&& dom.appEl.classList.contains('studio-open')
|
|
342
|
+
&& isStudioTabVisible('browser')
|
|
343
|
+
&& state.browserEngine === 'agent'
|
|
344
|
+
&& !state.liveStreamConnected
|
|
345
|
+
) {
|
|
346
|
+
void refreshLiveBrowserState(false);
|
|
347
|
+
startLiveBrowserStream();
|
|
348
|
+
}
|
|
349
|
+
}, 2000);
|
|
350
|
+
|
|
351
|
+
setInterval(() => {
|
|
352
|
+
if (!state.activeController && state.sessions.some((s) => s.running)) {
|
|
353
|
+
void loadSessions();
|
|
354
|
+
}
|
|
355
|
+
}, 4000);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function bootstrap(): void {
|
|
359
|
+
restorePersistedPreferences();
|
|
360
|
+
restoreStudioLayoutPreference();
|
|
361
|
+
wireModuleCallbacks();
|
|
362
|
+
bindStudioResizer();
|
|
363
|
+
bindStudioSplitDivider();
|
|
364
|
+
bindStudioStartEvents();
|
|
365
|
+
bindFilesAndCanvasEvents();
|
|
366
|
+
bindDiffPanelEvents();
|
|
367
|
+
bindBrowserPanelEvents();
|
|
368
|
+
bindTerminalPanelEvents();
|
|
369
|
+
bindCliPanelEvents();
|
|
370
|
+
bindGameLauncherEvents();
|
|
371
|
+
bindModelPickerEvents();
|
|
372
|
+
bindPermissionPresetEvents();
|
|
373
|
+
bindSettingsModalEvents();
|
|
374
|
+
bindComposerEvents();
|
|
375
|
+
bindShellAndNavigationEvents();
|
|
376
|
+
startBackgroundPollers();
|
|
377
|
+
|
|
378
|
+
applyPermissionPresetUi(state.permissionPreset);
|
|
379
|
+
updateComposerMetrics();
|
|
380
|
+
renderCliQuickGrid();
|
|
381
|
+
dom.promptInput.focus();
|
|
382
|
+
void loadHealth();
|
|
383
|
+
void loadPermissionPresets(state.sessionId);
|
|
384
|
+
void loadGameStatus();
|
|
385
|
+
void loadTerminalSessions();
|
|
386
|
+
void loadSessions();
|
|
387
|
+
void loadFiles('', '');
|
|
388
|
+
void loadCliCommands();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
bootstrap();
|