@causyne/agent 1.20.124 → 1.20.127
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/package.json +4 -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 +83 -27
- package/src/agentLoop.ts +92 -26
- package/src/approvalPolicy.js +34 -10
- package/src/approvalPolicy.ts +42 -11
- package/src/browser/causyneBrowser.js +30 -3
- package/src/browser/causyneBrowser.ts +33 -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 +188 -32
- package/src/commands.ts +209 -32
- 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/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/providers/antigravity.js +62 -9
- package/src/providers/antigravity.ts +73 -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/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/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 +1096 -0
- package/src/tools/ptyTerminal.ts +1231 -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 +702 -0
- package/src/web/client/browserPanel.ts +663 -0
- package/src/web/client/chatStream.js +309 -0
- package/src/web/client/chatStream.ts +289 -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 +220 -0
- package/src/web/client/dom.ts +221 -0
- package/src/web/client/filesAndCanvas.js +231 -0
- package/src/web/client/filesAndCanvas.ts +238 -0
- package/src/web/client/gameLauncherUi.js +78 -0
- package/src/web/client/gameLauncherUi.ts +78 -0
- package/src/web/client/main.js +301 -0
- package/src/web/client/main.ts +368 -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 +191 -0
- package/src/web/client/settingsModal.ts +176 -0
- package/src/web/client/state.js +250 -0
- package/src/web/client/state.ts +233 -0
- package/src/web/client/streamSmoother.js +127 -0
- package/src/web/client/streamSmoother.ts +119 -0
- package/src/web/client/studioLayout.js +54 -0
- package/src/web/client/studioLayout.ts +60 -0
- package/src/web/client/studioShell.js +327 -0
- package/src/web/client/studioShell.ts +340 -0
- package/src/web/client/studioStart.js +77 -0
- package/src/web/client/studioStart.ts +89 -0
- package/src/web/client/terminalPanel.js +357 -0
- package/src/web/client/terminalPanel.ts +345 -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 +319 -0
- package/src/web/client/validators.js +106 -0
- package/src/web/client/validators.ts +96 -0
- package/src/web/server/activeRuns.js +152 -0
- package/src/web/server/activeRuns.ts +171 -0
- package/src/web/server/routesBrowser.js +355 -0
- package/src/web/server/routesBrowser.ts +386 -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/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 +80 -0
- package/src/web/server/staticAssets.ts +91 -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 +76 -2449
- package/src/web/skybridgeServer.ts +118 -2600
- package/src/web/skybridgeUi.js +16 -450
- package/src/web/skybridgeUi.ts +16 -454
- package/src/web/styles/agent.css +380 -0
- package/src/web/styles/composer.css +193 -0
- package/src/web/styles/overlays.css +436 -0
- package/src/web/styles/shell.css +387 -0
- package/src/web/styles/studio.css +723 -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 +139 -0
- package/src/web/ui/modalsTemplate.ts +139 -0
- package/src/web/ui/sidebarTemplate.js +63 -0
- package/src/web/ui/sidebarTemplate.ts +64 -0
- package/src/web/ui/studioTemplate.js +258 -0
- package/src/web/ui/studioTemplate.ts +258 -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,340 @@
|
|
|
1
|
+
import { dom } from './dom.js';
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_STUDIO_W,
|
|
4
|
+
applyStudioWidth,
|
|
5
|
+
state,
|
|
6
|
+
syncExpandedStudioWidth
|
|
7
|
+
} from './state.js';
|
|
8
|
+
import {
|
|
9
|
+
halvesFitWidth,
|
|
10
|
+
isValidStudioTab,
|
|
11
|
+
loadPersistedStudioLayout,
|
|
12
|
+
persistStudioLayout,
|
|
13
|
+
pickDistinctSecondaryTab
|
|
14
|
+
} from './studioLayout.js';
|
|
15
|
+
|
|
16
|
+
export interface StudioTabHandlers {
|
|
17
|
+
onFilesTab(): void;
|
|
18
|
+
onDiffTab(): void;
|
|
19
|
+
onCliTab(): void;
|
|
20
|
+
onTerminalActivate(): void;
|
|
21
|
+
onTerminalDeactivate(): void;
|
|
22
|
+
onBrowserActivate(): void;
|
|
23
|
+
onBrowserDeactivate(): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let tabHandlers: StudioTabHandlers = {
|
|
27
|
+
onFilesTab: () => {},
|
|
28
|
+
onDiffTab: () => {},
|
|
29
|
+
onCliTab: () => {},
|
|
30
|
+
onTerminalActivate: () => {},
|
|
31
|
+
onTerminalDeactivate: () => {},
|
|
32
|
+
onBrowserActivate: () => {},
|
|
33
|
+
onBrowserDeactivate: () => {}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export function configureStudioTabHandlers(handlers: StudioTabHandlers): void {
|
|
37
|
+
tabHandlers = handlers;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function closeAllPopovers(): void {
|
|
41
|
+
dom.modelPopover.classList.remove('open');
|
|
42
|
+
dom.plusPopover.classList.remove('open');
|
|
43
|
+
dom.permPopover.classList.remove('open');
|
|
44
|
+
dom.permTriggerBtn.classList.remove('open');
|
|
45
|
+
dom.mentionPopover.classList.remove('open');
|
|
46
|
+
dom.browserMorePopover.classList.remove('open');
|
|
47
|
+
dom.modelTriggerBtn.setAttribute('aria-expanded', 'false');
|
|
48
|
+
dom.plusBtn.setAttribute('aria-expanded', 'false');
|
|
49
|
+
dom.permTriggerBtn.setAttribute('aria-expanded', 'false');
|
|
50
|
+
dom.browserMoreBtn.setAttribute('aria-expanded', 'false');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function positionPopover(pop: HTMLElement, anchor: HTMLElement, preferUp: boolean): void {
|
|
54
|
+
const rect = anchor.getBoundingClientRect();
|
|
55
|
+
pop.classList.add('open');
|
|
56
|
+
const pw = pop.offsetWidth || 300;
|
|
57
|
+
const ph = pop.offsetHeight || 220;
|
|
58
|
+
let left = rect.left;
|
|
59
|
+
if (left + pw > window.innerWidth - 10) left = rect.right - pw;
|
|
60
|
+
left = Math.max(10, Math.min(window.innerWidth - pw - 10, left));
|
|
61
|
+
let top = preferUp ? (rect.top - ph - 8) : (rect.bottom + 8);
|
|
62
|
+
if (top < 10) top = rect.bottom + 8;
|
|
63
|
+
if (top + ph > window.innerHeight - 10) top = Math.max(10, window.innerHeight - ph - 10);
|
|
64
|
+
pop.style.left = `${left}px`;
|
|
65
|
+
pop.style.top = `${top}px`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function isTabVisible(tab: string): boolean {
|
|
69
|
+
return state.studioTab === tab || (state.studioSplit && state.studioSecondaryTab === tab);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function syncStudioPanes(): void {
|
|
73
|
+
const effectiveSplit = state.studioSplit && state.studioSecondaryTab !== state.studioTab;
|
|
74
|
+
dom.appEl.classList.toggle('studio-split', effectiveSplit);
|
|
75
|
+
if (dom.studioSplitBar) dom.studioSplitBar.classList.toggle('open', effectiveSplit);
|
|
76
|
+
if (dom.studioSplitBtn) {
|
|
77
|
+
dom.studioSplitBtn.classList.toggle('active', effectiveSplit);
|
|
78
|
+
dom.studioSplitBtn.setAttribute('aria-pressed', effectiveSplit ? 'true' : 'false');
|
|
79
|
+
}
|
|
80
|
+
if (dom.studioSecondarySelect && dom.studioSecondarySelect.value !== state.studioSecondaryTab) {
|
|
81
|
+
dom.studioSecondarySelect.value = state.studioSecondaryTab;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
document.querySelectorAll('.studio-tab').forEach((b) => {
|
|
85
|
+
const t = b.getAttribute('data-tab') || '';
|
|
86
|
+
b.classList.toggle('active', t === state.studioTab);
|
|
87
|
+
b.classList.toggle('split-secondary', effectiveSplit && t === state.studioSecondaryTab);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
document.querySelectorAll('.studio-pane').forEach((p) => {
|
|
91
|
+
const t = p.getAttribute('data-pane') || '';
|
|
92
|
+
const isPrimary = t === state.studioTab;
|
|
93
|
+
const isSecondary = effectiveSplit && t === state.studioSecondaryTab;
|
|
94
|
+
p.classList.toggle('active', isPrimary || isSecondary);
|
|
95
|
+
p.classList.toggle('pane-primary', isPrimary);
|
|
96
|
+
p.classList.toggle('pane-secondary', isSecondary);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function notifyVisibleTabs(): void {
|
|
101
|
+
if (!dom.appEl.classList.contains('studio-open')) return;
|
|
102
|
+
if (isTabVisible('files')) tabHandlers.onFilesTab();
|
|
103
|
+
if (isTabVisible('diff')) tabHandlers.onDiffTab();
|
|
104
|
+
if (isTabVisible('cli')) tabHandlers.onCliTab();
|
|
105
|
+
if (isTabVisible('terminal')) tabHandlers.onTerminalActivate();
|
|
106
|
+
else tabHandlers.onTerminalDeactivate();
|
|
107
|
+
|
|
108
|
+
if (isTabVisible('browser') && state.browserEngine === 'agent') {
|
|
109
|
+
tabHandlers.onBrowserActivate();
|
|
110
|
+
} else {
|
|
111
|
+
tabHandlers.onBrowserDeactivate();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function syncPanelChromeState(): void {
|
|
116
|
+
const isOpen = dom.appEl.classList.contains('studio-open');
|
|
117
|
+
dom.studioToggleBtn.classList.toggle('active', isOpen);
|
|
118
|
+
dom.studioToggleBtn.setAttribute('aria-expanded', isOpen ? 'true' : 'false');
|
|
119
|
+
if (dom.studioExpandBtn) {
|
|
120
|
+
dom.studioExpandBtn.classList.toggle('active', state.studioExpanded);
|
|
121
|
+
dom.studioExpandBtn.title = state.studioExpanded ? 'Restore panel width' : 'Expand panel (⌘⌥↵)';
|
|
122
|
+
}
|
|
123
|
+
const navPairs: ReadonlyArray<readonly [HTMLElement | null, string]> = [
|
|
124
|
+
[dom.navFilesBtn, 'files'],
|
|
125
|
+
[dom.navCanvasBtn, 'canvas'],
|
|
126
|
+
[dom.navTerminalBtn, 'terminal'],
|
|
127
|
+
[dom.navBrowserBtn, 'browser'],
|
|
128
|
+
[dom.navCliBtn, 'cli'],
|
|
129
|
+
[dom.navDiffBtn, 'diff']
|
|
130
|
+
];
|
|
131
|
+
for (const [btn, tab] of navPairs) {
|
|
132
|
+
if (!btn) continue;
|
|
133
|
+
btn.classList.toggle('active', isOpen && isTabVisible(tab));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function restoreStudioLayoutPreference(): void {
|
|
138
|
+
const saved = loadPersistedStudioLayout();
|
|
139
|
+
state.studioTab = saved.primaryTab;
|
|
140
|
+
state.studioSplit = saved.splitActive;
|
|
141
|
+
state.studioSecondaryTab = saved.secondaryTab;
|
|
142
|
+
syncStudioPanes();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function setStudioTab(tab: string): void {
|
|
146
|
+
const nextTab = isValidStudioTab(tab) ? tab : 'start';
|
|
147
|
+
if (state.studioSplit && nextTab === state.studioSecondaryTab) {
|
|
148
|
+
state.studioSecondaryTab = pickDistinctSecondaryTab(nextTab, state.studioTab);
|
|
149
|
+
}
|
|
150
|
+
state.studioTab = nextTab;
|
|
151
|
+
persistStudioLayout({
|
|
152
|
+
primaryTab: state.studioTab,
|
|
153
|
+
splitActive: state.studioSplit,
|
|
154
|
+
secondaryTab: state.studioSecondaryTab
|
|
155
|
+
});
|
|
156
|
+
syncStudioPanes();
|
|
157
|
+
syncPanelChromeState();
|
|
158
|
+
notifyVisibleTabs();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function setSecondaryStudioTab(tab: string): void {
|
|
162
|
+
if (!isValidStudioTab(tab)) return;
|
|
163
|
+
if (tab === state.studioTab) {
|
|
164
|
+
const prevPrimary = state.studioTab;
|
|
165
|
+
state.studioTab = state.studioSecondaryTab;
|
|
166
|
+
state.studioSecondaryTab = prevPrimary;
|
|
167
|
+
} else {
|
|
168
|
+
state.studioSecondaryTab = tab;
|
|
169
|
+
}
|
|
170
|
+
persistStudioLayout({
|
|
171
|
+
primaryTab: state.studioTab,
|
|
172
|
+
splitActive: state.studioSplit,
|
|
173
|
+
secondaryTab: state.studioSecondaryTab
|
|
174
|
+
});
|
|
175
|
+
syncStudioPanes();
|
|
176
|
+
syncPanelChromeState();
|
|
177
|
+
notifyVisibleTabs();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function toggleStudioSplit(force?: boolean): void {
|
|
181
|
+
const nextSplit = typeof force === 'boolean' ? force : !state.studioSplit;
|
|
182
|
+
if (nextSplit) {
|
|
183
|
+
if (!dom.appEl.classList.contains('studio-open')) {
|
|
184
|
+
openStudio(state.studioTab || 'start');
|
|
185
|
+
}
|
|
186
|
+
const studioRectW = dom.studioRoot?.getBoundingClientRect().width || state.studioWidth;
|
|
187
|
+
if (!halvesFitWidth(studioRectW) && !state.studioExpanded) {
|
|
188
|
+
state.studioExpanded = true;
|
|
189
|
+
if (window.innerWidth > 960 && window.innerWidth < 1380) {
|
|
190
|
+
dom.appEl.classList.add('sidebar-collapsed');
|
|
191
|
+
}
|
|
192
|
+
syncExpandedStudioWidth();
|
|
193
|
+
dom.appEl.classList.toggle('studio-expanded', true);
|
|
194
|
+
}
|
|
195
|
+
state.studioSecondaryTab = pickDistinctSecondaryTab(state.studioTab, state.studioSecondaryTab);
|
|
196
|
+
}
|
|
197
|
+
state.studioSplit = nextSplit;
|
|
198
|
+
persistStudioLayout({
|
|
199
|
+
primaryTab: state.studioTab,
|
|
200
|
+
splitActive: state.studioSplit,
|
|
201
|
+
secondaryTab: state.studioSecondaryTab
|
|
202
|
+
});
|
|
203
|
+
syncStudioPanes();
|
|
204
|
+
syncPanelChromeState();
|
|
205
|
+
notifyVisibleTabs();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function swapStudioSplitPanes(): void {
|
|
209
|
+
if (!state.studioSplit) return;
|
|
210
|
+
const prevPrimary = state.studioTab;
|
|
211
|
+
state.studioTab = state.studioSecondaryTab;
|
|
212
|
+
state.studioSecondaryTab = prevPrimary;
|
|
213
|
+
persistStudioLayout({
|
|
214
|
+
primaryTab: state.studioTab,
|
|
215
|
+
splitActive: state.studioSplit,
|
|
216
|
+
secondaryTab: state.studioSecondaryTab
|
|
217
|
+
});
|
|
218
|
+
syncStudioPanes();
|
|
219
|
+
syncPanelChromeState();
|
|
220
|
+
notifyVisibleTabs();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function openStudio(tab?: string): void {
|
|
224
|
+
closeAllPopovers();
|
|
225
|
+
if (window.innerWidth <= 960) dom.appEl.classList.add('sidebar-collapsed');
|
|
226
|
+
if (dom.studioRoot) {
|
|
227
|
+
dom.studioRoot.style.flexBasis = '';
|
|
228
|
+
dom.studioRoot.style.width = '';
|
|
229
|
+
}
|
|
230
|
+
applyStudioWidth(state.studioWidth || DEFAULT_STUDIO_W, false);
|
|
231
|
+
dom.appEl.classList.add('studio-open');
|
|
232
|
+
dom.appEl.classList.toggle('studio-expanded', Boolean(state.studioExpanded));
|
|
233
|
+
if (tab) {
|
|
234
|
+
setStudioTab(tab);
|
|
235
|
+
} else {
|
|
236
|
+
syncStudioPanes();
|
|
237
|
+
syncPanelChromeState();
|
|
238
|
+
notifyVisibleTabs();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export function closeStudio(): void {
|
|
243
|
+
state.studioExpanded = false;
|
|
244
|
+
dom.appEl.classList.remove('studio-open', 'studio-expanded', 'studio-resizing');
|
|
245
|
+
dom.studioResizer.classList.remove('dragging', 'snap-close');
|
|
246
|
+
if (dom.studioRoot) {
|
|
247
|
+
dom.studioRoot.style.flexBasis = '';
|
|
248
|
+
dom.studioRoot.style.width = '';
|
|
249
|
+
}
|
|
250
|
+
tabHandlers.onBrowserDeactivate();
|
|
251
|
+
tabHandlers.onTerminalDeactivate();
|
|
252
|
+
syncPanelChromeState();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export function toggleStudioNav(tab: string): void {
|
|
256
|
+
if (dom.appEl.classList.contains('studio-open') && state.studioTab === tab && !state.studioSplit) closeStudio();
|
|
257
|
+
else openStudio(tab);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function toggleStudioMaximize(): void {
|
|
261
|
+
if (!dom.appEl.classList.contains('studio-open')) return;
|
|
262
|
+
state.studioExpanded = !state.studioExpanded;
|
|
263
|
+
if (state.studioExpanded && window.innerWidth > 960 && window.innerWidth < 1380) {
|
|
264
|
+
dom.appEl.classList.add('sidebar-collapsed');
|
|
265
|
+
}
|
|
266
|
+
syncExpandedStudioWidth();
|
|
267
|
+
dom.appEl.classList.toggle('studio-expanded', state.studioExpanded);
|
|
268
|
+
syncPanelChromeState();
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
let resizing = false;
|
|
272
|
+
let snapClosePending = false;
|
|
273
|
+
let resizePointerId: number | null = null;
|
|
274
|
+
let resizeStartWidth = DEFAULT_STUDIO_W;
|
|
275
|
+
|
|
276
|
+
export function isStudioResizing(): boolean {
|
|
277
|
+
return resizing;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function endStudioResize(cancelled: boolean): void {
|
|
281
|
+
if (!resizing) return;
|
|
282
|
+
resizing = false;
|
|
283
|
+
const shouldSnapClose = !cancelled && snapClosePending;
|
|
284
|
+
snapClosePending = false;
|
|
285
|
+
dom.appEl.classList.remove('studio-resizing');
|
|
286
|
+
dom.studioResizer.classList.remove('dragging', 'snap-close');
|
|
287
|
+
if (resizePointerId !== null) {
|
|
288
|
+
try { dom.studioResizer.releasePointerCapture(resizePointerId); } catch { /* ignore */ }
|
|
289
|
+
resizePointerId = null;
|
|
290
|
+
}
|
|
291
|
+
if (shouldSnapClose) {
|
|
292
|
+
applyStudioWidth(resizeStartWidth, false);
|
|
293
|
+
closeStudio();
|
|
294
|
+
} else if (cancelled) {
|
|
295
|
+
applyStudioWidth(resizeStartWidth, false);
|
|
296
|
+
} else {
|
|
297
|
+
applyStudioWidth(state.studioWidth, true);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export function bindStudioResizer(): void {
|
|
302
|
+
dom.studioResizer.addEventListener('pointerdown', (e) => {
|
|
303
|
+
if (!dom.appEl.classList.contains('studio-open') || state.studioExpanded) return;
|
|
304
|
+
e.preventDefault();
|
|
305
|
+
resizing = true;
|
|
306
|
+
snapClosePending = false;
|
|
307
|
+
resizeStartWidth = state.studioWidth || DEFAULT_STUDIO_W;
|
|
308
|
+
resizePointerId = e.pointerId;
|
|
309
|
+
dom.appEl.classList.add('studio-resizing');
|
|
310
|
+
dom.studioResizer.classList.add('dragging');
|
|
311
|
+
try { dom.studioResizer.setPointerCapture(e.pointerId); } catch { /* ignore */ }
|
|
312
|
+
});
|
|
313
|
+
dom.studioResizer.addEventListener('pointermove', (e) => {
|
|
314
|
+
if (!resizing) return;
|
|
315
|
+
const rawW = window.innerWidth - e.clientX;
|
|
316
|
+
if (rawW < 210) {
|
|
317
|
+
snapClosePending = true;
|
|
318
|
+
dom.studioResizer.classList.add('snap-close');
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
snapClosePending = false;
|
|
322
|
+
dom.studioResizer.classList.remove('snap-close');
|
|
323
|
+
applyStudioWidth(rawW, false);
|
|
324
|
+
});
|
|
325
|
+
dom.studioResizer.addEventListener('pointerup', () => endStudioResize(false));
|
|
326
|
+
dom.studioResizer.addEventListener('pointercancel', () => endStudioResize(true));
|
|
327
|
+
dom.studioResizer.addEventListener('dblclick', () => {
|
|
328
|
+
if (!dom.appEl.classList.contains('studio-open')) return;
|
|
329
|
+
state.studioExpanded = false;
|
|
330
|
+
dom.appEl.classList.remove('studio-expanded');
|
|
331
|
+
applyStudioWidth(DEFAULT_STUDIO_W, true);
|
|
332
|
+
syncPanelChromeState();
|
|
333
|
+
});
|
|
334
|
+
window.addEventListener('resize', () => {
|
|
335
|
+
closeAllPopovers();
|
|
336
|
+
if (dom.appEl.classList.contains('studio-open') && window.innerWidth > 960) {
|
|
337
|
+
applyStudioWidth(state.studioWidth, false);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { dom } from './dom.js';
|
|
2
|
+
import { openStudio } from './studioShell.js';
|
|
3
|
+
let callbacks = {
|
|
4
|
+
openNewTerminal: async () => { },
|
|
5
|
+
openSettings: () => { },
|
|
6
|
+
launchGameStudio: () => { }
|
|
7
|
+
};
|
|
8
|
+
export function configureStudioStartCallbacks(cbs) {
|
|
9
|
+
callbacks = cbs;
|
|
10
|
+
}
|
|
11
|
+
export function hydrateStartShellOptions(shells) {
|
|
12
|
+
const targets = [dom.startShellSelect, dom.termShellSelect];
|
|
13
|
+
for (const sel of targets) {
|
|
14
|
+
if (!sel)
|
|
15
|
+
continue;
|
|
16
|
+
const prev = sel.value;
|
|
17
|
+
sel.textContent = '';
|
|
18
|
+
for (const sh of shells) {
|
|
19
|
+
const opt = document.createElement('option');
|
|
20
|
+
opt.value = sh.id;
|
|
21
|
+
opt.textContent = sh.label;
|
|
22
|
+
if (sh.isDefault)
|
|
23
|
+
opt.selected = true;
|
|
24
|
+
sel.appendChild(opt);
|
|
25
|
+
}
|
|
26
|
+
if (prev && shells.some((s) => s.id === prev)) {
|
|
27
|
+
sel.value = prev;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function applyPlatformShortcutLabels() {
|
|
32
|
+
const isMac = /mac/i.test(navigator.platform || navigator.userAgent || '');
|
|
33
|
+
if (dom.startKbdFiles)
|
|
34
|
+
dom.startKbdFiles.textContent = isMac ? '⌘⌥P' : 'Ctrl+Alt+P';
|
|
35
|
+
if (dom.startKbdTerminal)
|
|
36
|
+
dom.startKbdTerminal.textContent = isMac ? '⌃`' : 'Ctrl+`';
|
|
37
|
+
if (dom.startKbdBrowser)
|
|
38
|
+
dom.startKbdBrowser.textContent = isMac ? '⌘⌥T' : 'Ctrl+Alt+T';
|
|
39
|
+
}
|
|
40
|
+
export function bindStudioStartEvents() {
|
|
41
|
+
applyPlatformShortcutLabels();
|
|
42
|
+
dom.startFilesBtn?.addEventListener('click', () => {
|
|
43
|
+
openStudio('files');
|
|
44
|
+
dom.fileFilterEl.focus();
|
|
45
|
+
});
|
|
46
|
+
dom.startTerminalBtn?.addEventListener('click', () => {
|
|
47
|
+
const selectedShell = dom.startShellSelect?.value || undefined;
|
|
48
|
+
openStudio('terminal');
|
|
49
|
+
void callbacks.openNewTerminal(selectedShell);
|
|
50
|
+
});
|
|
51
|
+
dom.startShellSelect?.addEventListener('click', (e) => {
|
|
52
|
+
e.stopPropagation();
|
|
53
|
+
});
|
|
54
|
+
dom.startBrowserBtn?.addEventListener('click', () => {
|
|
55
|
+
openStudio('browser');
|
|
56
|
+
dom.browserUrlInput.focus();
|
|
57
|
+
});
|
|
58
|
+
dom.startMoreBtn?.addEventListener('click', () => {
|
|
59
|
+
const shelf = dom.startMoreShelf;
|
|
60
|
+
if (!shelf || !dom.startMoreBtn)
|
|
61
|
+
return;
|
|
62
|
+
const nextOpen = !shelf.classList.contains('open');
|
|
63
|
+
shelf.classList.toggle('open', nextOpen);
|
|
64
|
+
dom.startMoreBtn.setAttribute('aria-expanded', nextOpen ? 'true' : 'false');
|
|
65
|
+
});
|
|
66
|
+
dom.startEditorBtn?.addEventListener('click', () => {
|
|
67
|
+
openStudio('canvas');
|
|
68
|
+
dom.filePathInput.focus();
|
|
69
|
+
});
|
|
70
|
+
dom.startDiffBtn?.addEventListener('click', () => openStudio('diff'));
|
|
71
|
+
dom.startCliBtn?.addEventListener('click', () => {
|
|
72
|
+
openStudio('cli');
|
|
73
|
+
dom.cliCmdInput.focus();
|
|
74
|
+
});
|
|
75
|
+
dom.startGameBtn?.addEventListener('click', () => callbacks.launchGameStudio());
|
|
76
|
+
dom.startSettingsBtn?.addEventListener('click', () => callbacks.openSettings());
|
|
77
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { dom } from './dom.js';
|
|
2
|
+
import { openStudio } from './studioShell.js';
|
|
3
|
+
import type { AvailableShellPayload } from './types.js';
|
|
4
|
+
|
|
5
|
+
export interface StudioStartCallbacks {
|
|
6
|
+
openNewTerminal(shell?: string): Promise<void>;
|
|
7
|
+
openSettings(): void;
|
|
8
|
+
launchGameStudio(): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let callbacks: StudioStartCallbacks = {
|
|
12
|
+
openNewTerminal: async () => {},
|
|
13
|
+
openSettings: () => {},
|
|
14
|
+
launchGameStudio: () => {}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export function configureStudioStartCallbacks(cbs: StudioStartCallbacks): void {
|
|
18
|
+
callbacks = cbs;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function hydrateStartShellOptions(shells: AvailableShellPayload[]): void {
|
|
22
|
+
const targets = [dom.startShellSelect, dom.termShellSelect];
|
|
23
|
+
for (const sel of targets) {
|
|
24
|
+
if (!sel) continue;
|
|
25
|
+
const prev = sel.value;
|
|
26
|
+
sel.textContent = '';
|
|
27
|
+
for (const sh of shells) {
|
|
28
|
+
const opt = document.createElement('option');
|
|
29
|
+
opt.value = sh.id;
|
|
30
|
+
opt.textContent = sh.label;
|
|
31
|
+
if (sh.isDefault) opt.selected = true;
|
|
32
|
+
sel.appendChild(opt);
|
|
33
|
+
}
|
|
34
|
+
if (prev && shells.some((s) => s.id === prev)) {
|
|
35
|
+
sel.value = prev;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function applyPlatformShortcutLabels(): void {
|
|
41
|
+
const isMac = /mac/i.test(navigator.platform || navigator.userAgent || '');
|
|
42
|
+
if (dom.startKbdFiles) dom.startKbdFiles.textContent = isMac ? '⌘⌥P' : 'Ctrl+Alt+P';
|
|
43
|
+
if (dom.startKbdTerminal) dom.startKbdTerminal.textContent = isMac ? '⌃`' : 'Ctrl+`';
|
|
44
|
+
if (dom.startKbdBrowser) dom.startKbdBrowser.textContent = isMac ? '⌘⌥T' : 'Ctrl+Alt+T';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function bindStudioStartEvents(): void {
|
|
48
|
+
applyPlatformShortcutLabels();
|
|
49
|
+
|
|
50
|
+
dom.startFilesBtn?.addEventListener('click', () => {
|
|
51
|
+
openStudio('files');
|
|
52
|
+
dom.fileFilterEl.focus();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
dom.startTerminalBtn?.addEventListener('click', () => {
|
|
56
|
+
const selectedShell = dom.startShellSelect?.value || undefined;
|
|
57
|
+
openStudio('terminal');
|
|
58
|
+
void callbacks.openNewTerminal(selectedShell);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
dom.startShellSelect?.addEventListener('click', (e) => {
|
|
62
|
+
e.stopPropagation();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
dom.startBrowserBtn?.addEventListener('click', () => {
|
|
66
|
+
openStudio('browser');
|
|
67
|
+
dom.browserUrlInput.focus();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
dom.startMoreBtn?.addEventListener('click', () => {
|
|
71
|
+
const shelf = dom.startMoreShelf;
|
|
72
|
+
if (!shelf || !dom.startMoreBtn) return;
|
|
73
|
+
const nextOpen = !shelf.classList.contains('open');
|
|
74
|
+
shelf.classList.toggle('open', nextOpen);
|
|
75
|
+
dom.startMoreBtn.setAttribute('aria-expanded', nextOpen ? 'true' : 'false');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
dom.startEditorBtn?.addEventListener('click', () => {
|
|
79
|
+
openStudio('canvas');
|
|
80
|
+
dom.filePathInput.focus();
|
|
81
|
+
});
|
|
82
|
+
dom.startDiffBtn?.addEventListener('click', () => openStudio('diff'));
|
|
83
|
+
dom.startCliBtn?.addEventListener('click', () => {
|
|
84
|
+
openStudio('cli');
|
|
85
|
+
dom.cliCmdInput.focus();
|
|
86
|
+
});
|
|
87
|
+
dom.startGameBtn?.addEventListener('click', () => callbacks.launchGameStudio());
|
|
88
|
+
dom.startSettingsBtn?.addEventListener('click', () => callbacks.openSettings());
|
|
89
|
+
}
|