@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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
export type PermissionPresetId = 'read-only' | 'workspace-write' | 'danger-full-access';
|
|
2
|
+
|
|
3
|
+
export interface PermissionPresetItem {
|
|
4
|
+
readonly id: PermissionPresetId;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
readonly autonomyMode: 'A' | 'B' | 'C';
|
|
8
|
+
readonly readOnly: boolean;
|
|
9
|
+
readonly requiresRiskConfirmation: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ArtifactVersion {
|
|
13
|
+
version: number;
|
|
14
|
+
content: string;
|
|
15
|
+
at: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface SessionSummary {
|
|
19
|
+
id: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
createdAt?: number;
|
|
22
|
+
updatedAt?: number;
|
|
23
|
+
messageCount?: number;
|
|
24
|
+
running?: boolean;
|
|
25
|
+
awaitingClient?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface SessionWorkspaceSnapshot {
|
|
29
|
+
studioOpen: boolean;
|
|
30
|
+
studioTab: string;
|
|
31
|
+
canvasPath: string;
|
|
32
|
+
canvasContent: string;
|
|
33
|
+
canvasPreviewMode: boolean;
|
|
34
|
+
canvasStatus: string;
|
|
35
|
+
canvasDirty: boolean;
|
|
36
|
+
diffScope: 'session' | 'workspace';
|
|
37
|
+
diffStaged: boolean;
|
|
38
|
+
attachments: string[];
|
|
39
|
+
draftPrompt: string;
|
|
40
|
+
usageTokens: number;
|
|
41
|
+
browserEngine: 'agent' | 'frame';
|
|
42
|
+
browserMode: 'empty' | 'url' | 'srcdoc';
|
|
43
|
+
browserUrl: string;
|
|
44
|
+
browserSrcdoc: string;
|
|
45
|
+
cliConsoleText: string;
|
|
46
|
+
cliStatusText: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ModelItemValue {
|
|
50
|
+
type?: string;
|
|
51
|
+
action?: string;
|
|
52
|
+
isToggle?: boolean;
|
|
53
|
+
peerKey?: string;
|
|
54
|
+
providerId?: string;
|
|
55
|
+
modelId?: string;
|
|
56
|
+
providerLabel?: string;
|
|
57
|
+
envVar?: string;
|
|
58
|
+
setupInstruction?: string;
|
|
59
|
+
installed?: boolean;
|
|
60
|
+
isCurrent?: boolean;
|
|
61
|
+
isConfigured?: boolean;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ModelPickerItem {
|
|
65
|
+
id?: string;
|
|
66
|
+
label?: string;
|
|
67
|
+
category?: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
value?: ModelItemValue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ModelsResponse {
|
|
73
|
+
activeProvider?: string;
|
|
74
|
+
activeModel?: string;
|
|
75
|
+
initialTab?: 'acp' | 'byok' | 'free';
|
|
76
|
+
tabs?: Record<string, ModelPickerItem[]>;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface CliCommandEntry {
|
|
80
|
+
name: string;
|
|
81
|
+
aliases?: string[];
|
|
82
|
+
usage?: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface WorkspaceEntry {
|
|
87
|
+
path: string;
|
|
88
|
+
name: string;
|
|
89
|
+
type: 'dir' | 'file';
|
|
90
|
+
size?: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface MentionEntry {
|
|
94
|
+
name?: string;
|
|
95
|
+
path?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface BrowserTabInfo {
|
|
100
|
+
tabId: string;
|
|
101
|
+
title?: string;
|
|
102
|
+
url?: string;
|
|
103
|
+
active?: boolean;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface BrowserAgentActivityState {
|
|
107
|
+
active?: boolean;
|
|
108
|
+
tool?: string;
|
|
109
|
+
detail?: string;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface LiveBrowserFramePayload {
|
|
113
|
+
type?: string;
|
|
114
|
+
active?: boolean;
|
|
115
|
+
visible?: boolean;
|
|
116
|
+
engine?: string | null;
|
|
117
|
+
enginePreference?: string;
|
|
118
|
+
enginesAvailable?: { camoufox?: boolean; chromium?: boolean };
|
|
119
|
+
streamMode?: string;
|
|
120
|
+
fps?: number;
|
|
121
|
+
controlOwner?: string;
|
|
122
|
+
width?: number;
|
|
123
|
+
height?: number;
|
|
124
|
+
url?: string;
|
|
125
|
+
imageBase64?: string;
|
|
126
|
+
mimeType?: string;
|
|
127
|
+
tabs?: BrowserTabInfo[];
|
|
128
|
+
agentActivity?: BrowserAgentActivityState;
|
|
129
|
+
snapshot?: string;
|
|
130
|
+
refsCount?: number;
|
|
131
|
+
syncedUrl?: string;
|
|
132
|
+
importedUrls?: string[];
|
|
133
|
+
importedCookies?: number;
|
|
134
|
+
error?: string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface RestoredStep {
|
|
138
|
+
tool?: string;
|
|
139
|
+
target?: string;
|
|
140
|
+
status?: string;
|
|
141
|
+
output?: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface RestoredBlock {
|
|
145
|
+
kind: 'reasoning' | 'steps' | 'text';
|
|
146
|
+
content?: string;
|
|
147
|
+
steps?: RestoredStep[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface DecisionOption {
|
|
151
|
+
id?: string;
|
|
152
|
+
label?: string;
|
|
153
|
+
description?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export interface DecisionRequestPayload {
|
|
157
|
+
id?: string;
|
|
158
|
+
question?: string;
|
|
159
|
+
options?: DecisionOption[];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface PlanItemPayload {
|
|
163
|
+
status?: string;
|
|
164
|
+
text?: string;
|
|
165
|
+
step?: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface StreamEventPayload {
|
|
169
|
+
type?: string;
|
|
170
|
+
sessionId?: string;
|
|
171
|
+
title?: string;
|
|
172
|
+
delta?: string;
|
|
173
|
+
content?: string;
|
|
174
|
+
streaming?: boolean;
|
|
175
|
+
elapsedMs?: number;
|
|
176
|
+
plan?: PlanItemPayload[];
|
|
177
|
+
explanation?: string;
|
|
178
|
+
message?: string;
|
|
179
|
+
activity?: string;
|
|
180
|
+
tool?: string;
|
|
181
|
+
toolCallId?: string;
|
|
182
|
+
args?: Record<string, unknown>;
|
|
183
|
+
success?: boolean;
|
|
184
|
+
error?: string;
|
|
185
|
+
summary?: string;
|
|
186
|
+
output?: string;
|
|
187
|
+
result?: Record<string, unknown>;
|
|
188
|
+
id?: string;
|
|
189
|
+
path?: string;
|
|
190
|
+
code?: string;
|
|
191
|
+
phase?: string;
|
|
192
|
+
operation?: string;
|
|
193
|
+
request?: DecisionRequestPayload;
|
|
194
|
+
totalTokens?: number;
|
|
195
|
+
sessionTokens?: number;
|
|
196
|
+
promptTokens?: number;
|
|
197
|
+
nativeStep?: boolean;
|
|
198
|
+
nativeFailed?: boolean;
|
|
199
|
+
actionName?: string;
|
|
200
|
+
detail?: string;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface AssistantTurnHandle {
|
|
204
|
+
setActivity(active: boolean, label: string): void;
|
|
205
|
+
appendText(delta: string): void;
|
|
206
|
+
setText(full: string, streaming: boolean): void;
|
|
207
|
+
updateReasoning(ev: StreamEventPayload): void;
|
|
208
|
+
renderRestoredBlocks(blocks: RestoredBlock[]): void;
|
|
209
|
+
updatePlan(ev: StreamEventPayload): void;
|
|
210
|
+
addStepStart(ev: StreamEventPayload): void;
|
|
211
|
+
addStepEnd(ev: StreamEventPayload, failed: boolean): void;
|
|
212
|
+
addNativeStep(ev: StreamEventPayload, failed: boolean): void;
|
|
213
|
+
upsertCodeProgress(ev: StreamEventPayload): void;
|
|
214
|
+
addApproval(ev: StreamEventPayload): void;
|
|
215
|
+
addDecision(reqObj: DecisionRequestPayload): void;
|
|
216
|
+
addNotice(msg: string): void;
|
|
217
|
+
addError(msg: string, retryText?: string, code?: string): void;
|
|
218
|
+
addInterrupted(msg: string, retryText?: string): void;
|
|
219
|
+
finish(): void;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export interface WorkspaceFileHrefInfo {
|
|
223
|
+
fullPath: string;
|
|
224
|
+
relPath: string | null;
|
|
225
|
+
display: string;
|
|
226
|
+
lineBadge: string;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface AvailableShellPayload {
|
|
230
|
+
id: string;
|
|
231
|
+
label: string;
|
|
232
|
+
path: string;
|
|
233
|
+
isDefault: boolean;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface TerminalSessionPayload {
|
|
237
|
+
id: string;
|
|
238
|
+
name: string;
|
|
239
|
+
shell: string;
|
|
240
|
+
shellLabel: string;
|
|
241
|
+
cwd: string;
|
|
242
|
+
origin: 'user' | 'agent';
|
|
243
|
+
control: 'user' | 'agent';
|
|
244
|
+
transport: 'pty' | 'pipe';
|
|
245
|
+
status: 'running' | 'exited';
|
|
246
|
+
exitCode: number | null;
|
|
247
|
+
cols: number;
|
|
248
|
+
rows: number;
|
|
249
|
+
createdAt: number;
|
|
250
|
+
lastActivityAt: number;
|
|
251
|
+
scrollbackBytes: number;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export interface AppState {
|
|
255
|
+
sessionId: string | null;
|
|
256
|
+
sessions: SessionSummary[];
|
|
257
|
+
models: ModelsResponse | null;
|
|
258
|
+
modelTab: 'acp' | 'byok' | 'free' | null;
|
|
259
|
+
modelQuery: string;
|
|
260
|
+
modelExpandedPeers: Set<string>;
|
|
261
|
+
modelSelectedIndex: number;
|
|
262
|
+
modelRefreshing: boolean;
|
|
263
|
+
modelLiveHydrated: boolean;
|
|
264
|
+
modelNotice: string;
|
|
265
|
+
activeProvider: string;
|
|
266
|
+
activeModel: string;
|
|
267
|
+
permissionPreset: PermissionPresetId;
|
|
268
|
+
defaultPermissionPreset: PermissionPresetId;
|
|
269
|
+
workspaceRoot: string;
|
|
270
|
+
lastScrollTop: number;
|
|
271
|
+
attachments: string[];
|
|
272
|
+
currentDir: string;
|
|
273
|
+
parentDir: string;
|
|
274
|
+
studioTab: string;
|
|
275
|
+
studioOpenTabs: string[];
|
|
276
|
+
studioSplit: boolean;
|
|
277
|
+
studioSecondaryTab: string;
|
|
278
|
+
studioSplitRatio: number;
|
|
279
|
+
studioExpanded: boolean;
|
|
280
|
+
studioWidth: number;
|
|
281
|
+
terminalSessions: TerminalSessionPayload[];
|
|
282
|
+
activeTerminalId: string | null;
|
|
283
|
+
availableShells: AvailableShellPayload[];
|
|
284
|
+
canvasPreviewMode: boolean;
|
|
285
|
+
canvasDirty: boolean;
|
|
286
|
+
artifactVersions: Map<string, ArtifactVersion[]>;
|
|
287
|
+
sessionWorkspaces: Map<string, SessionWorkspaceSnapshot>;
|
|
288
|
+
sessionSwitchSeq: number;
|
|
289
|
+
usageTokens: number;
|
|
290
|
+
diffScope: 'session' | 'workspace';
|
|
291
|
+
browserEngine: 'agent' | 'frame';
|
|
292
|
+
browserMode: 'empty' | 'url' | 'srcdoc';
|
|
293
|
+
browserUrl: string;
|
|
294
|
+
browserSrcdoc: string;
|
|
295
|
+
browserViewport: string;
|
|
296
|
+
browserFrameStrictSandbox: boolean;
|
|
297
|
+
liveBrowserActive: boolean;
|
|
298
|
+
liveBrowserVisible: boolean;
|
|
299
|
+
liveBrowserRuntime: string | null;
|
|
300
|
+
liveBrowserPref: string;
|
|
301
|
+
liveStreamMode: string;
|
|
302
|
+
liveStreamAbort: AbortController | null;
|
|
303
|
+
liveStreamConnected: boolean;
|
|
304
|
+
liveFps: number;
|
|
305
|
+
pointerDragging: boolean;
|
|
306
|
+
liveBrowserWidth: number;
|
|
307
|
+
liveBrowserHeight: number;
|
|
308
|
+
controlOwner: 'human' | 'agent';
|
|
309
|
+
cliCommands: CliCommandEntry[];
|
|
310
|
+
mentionMode: 'file' | 'command';
|
|
311
|
+
mentionItems: MentionEntry[];
|
|
312
|
+
mentionIndex: number;
|
|
313
|
+
mentionStart: number;
|
|
314
|
+
diffStaged: boolean;
|
|
315
|
+
isComposing: boolean;
|
|
316
|
+
stickToBottom: boolean;
|
|
317
|
+
activeController: AbortController | null;
|
|
318
|
+
activeTurn: AssistantTurnHandle | null;
|
|
319
|
+
activePrompt: string;
|
|
320
|
+
gameStatus: Record<string, unknown> | null;
|
|
321
|
+
gameLaunching: boolean;
|
|
322
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
export function isSafeHttpUrl(raw) {
|
|
2
|
+
try {
|
|
3
|
+
const u = new URL(raw);
|
|
4
|
+
return u.protocol === 'https:' || u.protocol === 'http:';
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function parseLoopbackUrl(raw) {
|
|
11
|
+
try {
|
|
12
|
+
const trimmed = String(raw || '').trim();
|
|
13
|
+
if (!trimmed)
|
|
14
|
+
return null;
|
|
15
|
+
const normalized = /^https?:\/\//i.test(trimmed) ? trimmed : (`http://${trimmed}`);
|
|
16
|
+
const u = new URL(normalized);
|
|
17
|
+
const host = u.hostname.toLowerCase();
|
|
18
|
+
if (u.protocol !== 'http:')
|
|
19
|
+
return null;
|
|
20
|
+
if (host !== '127.0.0.1' && host !== 'localhost')
|
|
21
|
+
return null;
|
|
22
|
+
return u.href;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function extractLoopbackUrls(text) {
|
|
29
|
+
const found = [];
|
|
30
|
+
const matches = String(text || '').match(/http:\/\/(?:127\.0\.0\.1|localhost):\d{2,5}(?:\/[^\s)\[\]'"`<>]*)?/gi) || [];
|
|
31
|
+
for (const m of matches) {
|
|
32
|
+
const cleaned = m.replace(/[.,;:!?\])]+$/g, '');
|
|
33
|
+
const valid = parseLoopbackUrl(cleaned);
|
|
34
|
+
if (valid && !found.includes(valid))
|
|
35
|
+
found.push(valid);
|
|
36
|
+
}
|
|
37
|
+
return found.slice(0, 3);
|
|
38
|
+
}
|
|
39
|
+
function normalizePathSlashes(raw) {
|
|
40
|
+
return raw.replace(/\\/g, '/');
|
|
41
|
+
}
|
|
42
|
+
function normalizeDrivePrefix(raw) {
|
|
43
|
+
// file:///C:/foo -> C:/foo (Windows compatibility alongside POSIX /Users/...)
|
|
44
|
+
const winFile = /^\/([a-zA-Z]:\/.*)$/.exec(raw);
|
|
45
|
+
return winFile?.[1] ? winFile[1] : raw;
|
|
46
|
+
}
|
|
47
|
+
export function parseWorkspaceFileHref(rawHref, workspaceRoot) {
|
|
48
|
+
const trimmed = String(rawHref || '').trim();
|
|
49
|
+
if (!trimmed || trimmed.startsWith('#'))
|
|
50
|
+
return null;
|
|
51
|
+
const isFileScheme = trimmed.toLowerCase().startsWith('file://');
|
|
52
|
+
// Reject every non-file URI scheme (javascript:, data:, vbscript:, mailto:, http:, etc.)
|
|
53
|
+
if (!isFileScheme && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed))
|
|
54
|
+
return null;
|
|
55
|
+
let body = isFileScheme ? trimmed.slice(7) : trimmed;
|
|
56
|
+
let lineBadge = '';
|
|
57
|
+
const hashIdx = body.indexOf('#');
|
|
58
|
+
if (hashIdx >= 0) {
|
|
59
|
+
const frag = body.slice(hashIdx + 1);
|
|
60
|
+
body = body.slice(0, hashIdx);
|
|
61
|
+
const lm = frag.match(/^L(\d+)(?:-L?(\d+))?$/i);
|
|
62
|
+
if (lm?.[1])
|
|
63
|
+
lineBadge = lm[2] ? (`:${lm[1]}-${lm[2]}`) : (`:${lm[1]}`);
|
|
64
|
+
}
|
|
65
|
+
const qIdx = body.indexOf('?');
|
|
66
|
+
if (qIdx >= 0)
|
|
67
|
+
body = body.slice(0, qIdx);
|
|
68
|
+
try {
|
|
69
|
+
body = decodeURIComponent(body);
|
|
70
|
+
}
|
|
71
|
+
catch { /* keep raw */ }
|
|
72
|
+
// Reject control characters or NUL bytes
|
|
73
|
+
for (let i = 0; i < body.length; i += 1) {
|
|
74
|
+
const code = body.charCodeAt(i);
|
|
75
|
+
if (code < 0x20 || code === 0x7f)
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const wsRoot = normalizePathSlashes(String(workspaceRoot || '')).replace(/\/+$/, '');
|
|
79
|
+
const normPrivate = (p) => p.replace(/^\/private(?=\/(?:var|tmp)(?:\/|$))/, '');
|
|
80
|
+
if (isFileScheme) {
|
|
81
|
+
const bodyClean = normalizeDrivePrefix(normalizePathSlashes(body));
|
|
82
|
+
const bodyNorm = normPrivate(bodyClean);
|
|
83
|
+
const wsNorm = normPrivate(wsRoot);
|
|
84
|
+
let relPath = null;
|
|
85
|
+
if (wsNorm) {
|
|
86
|
+
const isWin = /^[a-zA-Z]:\//.test(wsNorm);
|
|
87
|
+
const cmpBody = isWin ? bodyNorm.toLowerCase() : bodyNorm;
|
|
88
|
+
const cmpWs = isWin ? wsNorm.toLowerCase() : wsNorm;
|
|
89
|
+
if (cmpBody.startsWith(`${cmpWs}/`)) {
|
|
90
|
+
relPath = bodyNorm.slice(wsNorm.length + 1);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const display = relPath || bodyClean.split('/').slice(-2).join('/') || bodyClean;
|
|
94
|
+
return { fullPath: bodyClean, relPath, display, lineBadge };
|
|
95
|
+
}
|
|
96
|
+
// Safe relative workspace file link (e.g. "package.json", "./src/index.ts", "docs/guide.md#L12")
|
|
97
|
+
const relClean = normalizePathSlashes(body).replace(/^\.\//, '');
|
|
98
|
+
if (!relClean || relClean.startsWith('/') || relClean.endsWith('/'))
|
|
99
|
+
return null;
|
|
100
|
+
if (/^[a-zA-Z]:/.test(relClean))
|
|
101
|
+
return null;
|
|
102
|
+
const segments = relClean.split('/');
|
|
103
|
+
if (segments.some((seg) => !seg || seg === '.' || seg === '..'))
|
|
104
|
+
return null;
|
|
105
|
+
// Require a recognizable file name (has extension or dotfile/Makefile-style relative path)
|
|
106
|
+
const leaf = segments[segments.length - 1] || '';
|
|
107
|
+
if (!leaf.includes('.') && segments.length < 2)
|
|
108
|
+
return null;
|
|
109
|
+
const fullPath = wsRoot ? `${wsRoot}/${relClean}` : relClean;
|
|
110
|
+
return { fullPath, relPath: relClean, display: relClean, lineBadge };
|
|
111
|
+
}
|
|
112
|
+
export function isHtmlOrSvgPath(relPath) {
|
|
113
|
+
const p = String(relPath || '').toLowerCase();
|
|
114
|
+
return p.endsWith('.html') || p.endsWith('.htm') || p.endsWith('.svg');
|
|
115
|
+
}
|
|
116
|
+
export function artifactBadgeFor(relPath, lang) {
|
|
117
|
+
const p = String(relPath || '').toLowerCase();
|
|
118
|
+
if (p.endsWith('.idoc.md'))
|
|
119
|
+
return { tag: 'IDOC', label: 'idoc Document' };
|
|
120
|
+
if (p.endsWith('.html') || p.endsWith('.htm') || lang === 'html')
|
|
121
|
+
return { tag: 'HTML', label: 'Interactive HTML' };
|
|
122
|
+
if (p.endsWith('.svg') || lang === 'svg')
|
|
123
|
+
return { tag: 'SVG', label: 'SVG Graphic' };
|
|
124
|
+
if (p.endsWith('.md') || lang === 'markdown' || lang === 'md')
|
|
125
|
+
return { tag: 'DOC', label: 'Markdown Document' };
|
|
126
|
+
const ext = p.includes('.')
|
|
127
|
+
? (p.split('.').pop() || '').toUpperCase().slice(0, 4)
|
|
128
|
+
: (lang ? lang.toUpperCase().slice(0, 4) : 'CODE');
|
|
129
|
+
return { tag: ext || 'CODE', label: 'Source File' };
|
|
130
|
+
}
|
|
131
|
+
export function isSafeBillingUrl(raw) {
|
|
132
|
+
try {
|
|
133
|
+
const u = new URL(String(raw || ''));
|
|
134
|
+
if (u.protocol !== 'https:' || u.username || u.password || u.port)
|
|
135
|
+
return false;
|
|
136
|
+
const h = u.hostname.toLowerCase();
|
|
137
|
+
return h === 'paddle.com'
|
|
138
|
+
|| h.endsWith('.paddle.com')
|
|
139
|
+
|| h === 'dodopayments.com'
|
|
140
|
+
|| h.endsWith('.dodopayments.com')
|
|
141
|
+
|| h === 'causyne.com'
|
|
142
|
+
|| h.endsWith('.causyne.com');
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { WorkspaceFileHrefInfo } from './types.js';
|
|
2
|
+
|
|
3
|
+
export function isSafeHttpUrl(raw: string): boolean {
|
|
4
|
+
try {
|
|
5
|
+
const u = new URL(raw);
|
|
6
|
+
return u.protocol === 'https:' || u.protocol === 'http:';
|
|
7
|
+
} catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function parseLoopbackUrl(raw: string): string | null {
|
|
13
|
+
try {
|
|
14
|
+
const trimmed = String(raw || '').trim();
|
|
15
|
+
if (!trimmed) return null;
|
|
16
|
+
const normalized = /^https?:\/\//i.test(trimmed) ? trimmed : (`http://${trimmed}`);
|
|
17
|
+
const u = new URL(normalized);
|
|
18
|
+
const host = u.hostname.toLowerCase();
|
|
19
|
+
if (u.protocol !== 'http:') return null;
|
|
20
|
+
if (host !== '127.0.0.1' && host !== 'localhost') return null;
|
|
21
|
+
return u.href;
|
|
22
|
+
} catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function extractLoopbackUrls(text: string): string[] {
|
|
28
|
+
const found: string[] = [];
|
|
29
|
+
const matches = String(text || '').match(/http:\/\/(?:127\.0\.0\.1|localhost):\d{2,5}(?:\/[^\s)\[\]'"`<>]*)?/gi) || [];
|
|
30
|
+
for (const m of matches) {
|
|
31
|
+
const cleaned = m.replace(/[.,;:!?\])]+$/g, '');
|
|
32
|
+
const valid = parseLoopbackUrl(cleaned);
|
|
33
|
+
if (valid && !found.includes(valid)) found.push(valid);
|
|
34
|
+
}
|
|
35
|
+
return found.slice(0, 3);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function normalizePathSlashes(raw: string): string {
|
|
39
|
+
return raw.replace(/\\/g, '/');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function normalizeDrivePrefix(raw: string): string {
|
|
43
|
+
// file:///C:/foo -> C:/foo (Windows compatibility alongside POSIX /Users/...)
|
|
44
|
+
const winFile = /^\/([a-zA-Z]:\/.*)$/.exec(raw);
|
|
45
|
+
return winFile?.[1] ? winFile[1] : raw;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function parseWorkspaceFileHref(rawHref: string, workspaceRoot: string): WorkspaceFileHrefInfo | null {
|
|
49
|
+
const trimmed = String(rawHref || '').trim();
|
|
50
|
+
if (!trimmed || trimmed.startsWith('#')) return null;
|
|
51
|
+
|
|
52
|
+
const isFileScheme = trimmed.toLowerCase().startsWith('file://');
|
|
53
|
+
// Reject every non-file URI scheme (javascript:, data:, vbscript:, mailto:, http:, etc.)
|
|
54
|
+
if (!isFileScheme && /^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) return null;
|
|
55
|
+
|
|
56
|
+
let body = isFileScheme ? trimmed.slice(7) : trimmed;
|
|
57
|
+
let lineBadge = '';
|
|
58
|
+
const hashIdx = body.indexOf('#');
|
|
59
|
+
if (hashIdx >= 0) {
|
|
60
|
+
const frag = body.slice(hashIdx + 1);
|
|
61
|
+
body = body.slice(0, hashIdx);
|
|
62
|
+
const lm = frag.match(/^L(\d+)(?:-L?(\d+))?$/i);
|
|
63
|
+
if (lm?.[1]) lineBadge = lm[2] ? (`:${lm[1]}-${lm[2]}`) : (`:${lm[1]}`);
|
|
64
|
+
}
|
|
65
|
+
const qIdx = body.indexOf('?');
|
|
66
|
+
if (qIdx >= 0) body = body.slice(0, qIdx);
|
|
67
|
+
try { body = decodeURIComponent(body); } catch { /* keep raw */ }
|
|
68
|
+
|
|
69
|
+
// Reject control characters or NUL bytes
|
|
70
|
+
for (let i = 0; i < body.length; i += 1) {
|
|
71
|
+
const code = body.charCodeAt(i);
|
|
72
|
+
if (code < 0x20 || code === 0x7f) return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const wsRoot = normalizePathSlashes(String(workspaceRoot || '')).replace(/\/+$/, '');
|
|
76
|
+
const normPrivate = (p: string): string => p.replace(/^\/private(?=\/(?:var|tmp)(?:\/|$))/, '');
|
|
77
|
+
|
|
78
|
+
if (isFileScheme) {
|
|
79
|
+
const bodyClean = normalizeDrivePrefix(normalizePathSlashes(body));
|
|
80
|
+
const bodyNorm = normPrivate(bodyClean);
|
|
81
|
+
const wsNorm = normPrivate(wsRoot);
|
|
82
|
+
let relPath: string | null = null;
|
|
83
|
+
if (wsNorm) {
|
|
84
|
+
const isWin = /^[a-zA-Z]:\//.test(wsNorm);
|
|
85
|
+
const cmpBody = isWin ? bodyNorm.toLowerCase() : bodyNorm;
|
|
86
|
+
const cmpWs = isWin ? wsNorm.toLowerCase() : wsNorm;
|
|
87
|
+
if (cmpBody.startsWith(`${cmpWs}/`)) {
|
|
88
|
+
relPath = bodyNorm.slice(wsNorm.length + 1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const display = relPath || bodyClean.split('/').slice(-2).join('/') || bodyClean;
|
|
92
|
+
return { fullPath: bodyClean, relPath, display, lineBadge };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Safe relative workspace file link (e.g. "package.json", "./src/index.ts", "docs/guide.md#L12")
|
|
96
|
+
const relClean = normalizePathSlashes(body).replace(/^\.\//, '');
|
|
97
|
+
if (!relClean || relClean.startsWith('/') || relClean.endsWith('/')) return null;
|
|
98
|
+
if (/^[a-zA-Z]:/.test(relClean)) return null;
|
|
99
|
+
const segments = relClean.split('/');
|
|
100
|
+
if (segments.some((seg) => !seg || seg === '.' || seg === '..')) return null;
|
|
101
|
+
// Require a recognizable file name (has extension or dotfile/Makefile-style relative path)
|
|
102
|
+
const leaf = segments[segments.length - 1] || '';
|
|
103
|
+
if (!leaf.includes('.') && segments.length < 2) return null;
|
|
104
|
+
|
|
105
|
+
const fullPath = wsRoot ? `${wsRoot}/${relClean}` : relClean;
|
|
106
|
+
return { fullPath, relPath: relClean, display: relClean, lineBadge };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function isHtmlOrSvgPath(relPath: string): boolean {
|
|
110
|
+
const p = String(relPath || '').toLowerCase();
|
|
111
|
+
return p.endsWith('.html') || p.endsWith('.htm') || p.endsWith('.svg');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function artifactBadgeFor(relPath: string, lang: string): { tag: string; label: string } {
|
|
115
|
+
const p = String(relPath || '').toLowerCase();
|
|
116
|
+
if (p.endsWith('.idoc.md')) return { tag: 'IDOC', label: 'idoc Document' };
|
|
117
|
+
if (p.endsWith('.html') || p.endsWith('.htm') || lang === 'html') return { tag: 'HTML', label: 'Interactive HTML' };
|
|
118
|
+
if (p.endsWith('.svg') || lang === 'svg') return { tag: 'SVG', label: 'SVG Graphic' };
|
|
119
|
+
if (p.endsWith('.md') || lang === 'markdown' || lang === 'md') return { tag: 'DOC', label: 'Markdown Document' };
|
|
120
|
+
const ext = p.includes('.')
|
|
121
|
+
? (p.split('.').pop() || '').toUpperCase().slice(0, 4)
|
|
122
|
+
: (lang ? lang.toUpperCase().slice(0, 4) : 'CODE');
|
|
123
|
+
return { tag: ext || 'CODE', label: 'Source File' };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function isSafeBillingUrl(raw: string): boolean {
|
|
127
|
+
try {
|
|
128
|
+
const u = new URL(String(raw || ''));
|
|
129
|
+
if (u.protocol !== 'https:' || u.username || u.password || u.port) return false;
|
|
130
|
+
const h = u.hostname.toLowerCase();
|
|
131
|
+
return h === 'paddle.com'
|
|
132
|
+
|| h.endsWith('.paddle.com')
|
|
133
|
+
|| h === 'dodopayments.com'
|
|
134
|
+
|| h.endsWith('.dodopayments.com')
|
|
135
|
+
|| h === 'causyne.com'
|
|
136
|
+
|| h.endsWith('.causyne.com');
|
|
137
|
+
} catch {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
}
|