zidane-gui 9.1.6 → 9.1.9

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.
Files changed (73) hide show
  1. package/out/main/index.js +398 -55
  2. package/out/preload/index.mjs +7 -5
  3. package/out/renderer/assets/{43YPWK3Q-z5jpEo82.js → 43YPWK3Q-BVJpf1u1.js} +6 -6
  4. package/out/renderer/assets/{45MVAN6X-GiMurZcH.js → 45MVAN6X-BWuIeWOc.js} +5 -5
  5. package/out/renderer/assets/{46GJKBLZ-BK9JvL-z.js → 46GJKBLZ-41BAHmt4.js} +10 -10
  6. package/out/renderer/assets/{63WH7YNF-oZNJFk32.js → 63WH7YNF-DuatnhlB.js} +8 -8
  7. package/out/renderer/assets/{6DDU7VKX-Q8ape99y.js → 6DDU7VKX-BAI-vKC1.js} +6 -6
  8. package/out/renderer/assets/{CLQLV5VT-1CokruIk.js → CLQLV5VT-CmHu2HE3.js} +6 -6
  9. package/out/renderer/assets/{CUSPXG5M-CXI47Yx3.js → CUSPXG5M-DE3uzfbs.js} +6 -6
  10. package/out/renderer/assets/{CodeEditor-D8TMSvb4.js → CodeEditor-CIwCP1F_.js} +3 -3
  11. package/out/renderer/assets/{ComposerEditor-MwH3w7kQ.js → ComposerEditor-leA8S_Yk.js} +2 -2
  12. package/out/renderer/assets/{D3L7O4X2-CZlDY3Xj.js → D3L7O4X2-BZ4caDcX.js} +4 -4
  13. package/out/renderer/assets/{D5TW5CPZ-C04jssFu.js → D5TW5CPZ-BXdKc68h.js} +1 -1
  14. package/out/renderer/assets/{DiffsTab-CD4Z6LsX.js → DiffsTab-CyRIVfQk.js} +5 -5
  15. package/out/renderer/assets/{EGADTWYV-C6IiGlh0.js → EGADTWYV-Bf6Kicdv.js} +5 -5
  16. package/out/renderer/assets/{EOJSJZXM-Bw1Qp21K.js → EOJSJZXM-NAa-K4U0.js} +8 -8
  17. package/out/renderer/assets/{EditorWorkers-D0xeQ5Kf.js → EditorWorkers-CY0St-9O.js} +4 -4
  18. package/out/renderer/assets/{FilesTab-Pp8_PSfd.js → FilesTab-CnRw0KCN.js} +111 -17
  19. package/out/renderer/assets/{G2OEIG6X-foim2Z_m.js → G2OEIG6X-BarwxCkp.js} +5 -5
  20. package/out/renderer/assets/{GXJ2T77W-FIOAlHlR.js → GXJ2T77W-CyQVHlsG.js} +6 -6
  21. package/out/renderer/assets/{HX3UMAK7-COan20yP.js → HX3UMAK7-BcoG4mYG.js} +5 -5
  22. package/out/renderer/assets/{IU7WZTP6-DeXscWir.js → IU7WZTP6-kOLrUSwF.js} +1 -1
  23. package/out/renderer/assets/{J5J2NR2G-B7up1iuZ.js → J5J2NR2G-DE-SGCIz.js} +4 -4
  24. package/out/renderer/assets/{JRCWTJEL-M4z7DV1k.js → JRCWTJEL-DZY5HKk0.js} +3 -3
  25. package/out/renderer/assets/{KHUP5TOH-0CDf31VX.js → KHUP5TOH-DevvG2jY.js} +1 -1
  26. package/out/renderer/assets/{L74FQTH5-xlC3E1u8.js → L74FQTH5-CnOj-zIY.js} +4 -4
  27. package/out/renderer/assets/{LAV4ZXOS-CWOm214F.js → LAV4ZXOS-BATWssHi.js} +6 -6
  28. package/out/renderer/assets/{LBIZYCRR-BRMO_zpo.js → LBIZYCRR-BXTsyX1O.js} +7 -7
  29. package/out/renderer/assets/{LFFXNLRS-CQDwxn8S.js → LFFXNLRS-BpnXEoXM.js} +3 -3
  30. package/out/renderer/assets/{LLLWOAQD-NLayfyRk.js → LLLWOAQD-BjLHR3Pk.js} +1 -1
  31. package/out/renderer/assets/{LTYQZ5U5-CfgFK_8S.js → LTYQZ5U5-CDOIyknV.js} +8 -8
  32. package/out/renderer/assets/{NDSCUZ25-CRhHG4rp.js → NDSCUZ25-Bl1idg0d.js} +2 -2
  33. package/out/renderer/assets/{NMN3IKWL-pNFku5nG.js → NMN3IKWL-BYE2yrn3.js} +9 -9
  34. package/out/renderer/assets/{NMUA3R2D-D5EpYecE.js → NMUA3R2D-Xl410xeQ.js} +7 -7
  35. package/out/renderer/assets/{NY5A6PPW-BFqrOF96.js → NY5A6PPW-CkzCXBsB.js} +3 -3
  36. package/out/renderer/assets/{OHJ2EJXK-DUXRo20H.js → OHJ2EJXK-DCVoLmOH.js} +1 -1
  37. package/out/renderer/assets/{OU2GIT2H-RERREQg4.js → OU2GIT2H-DG4LbVmY.js} +4 -4
  38. package/out/renderer/assets/{PDMLSE6I-B6VLJpYF.js → PDMLSE6I-Cr8MjczD.js} +2 -2
  39. package/out/renderer/assets/{PJ7X32S5-CiX4IRfi.js → PJ7X32S5-DFZu5Xsj.js} +5 -5
  40. package/out/renderer/assets/{RLLQ44NJ-DI-w7C3g.js → RLLQ44NJ-D-LvBssh.js} +7 -7
  41. package/out/renderer/assets/{S6DWMCK5-BFYfpKyU.js → S6DWMCK5-BQEAXG2z.js} +8 -8
  42. package/out/renderer/assets/{STIOTUT7-BsXqNDoB.js → STIOTUT7-jszPNHGr.js} +6 -6
  43. package/out/renderer/assets/{SXSLPWUD-DsiZBZ2L.js → SXSLPWUD-CEMEDuKR.js} +2 -2
  44. package/out/renderer/assets/{TR4WJQGX-DdGw5EgP.js → TR4WJQGX-8wGWCKKm.js} +1 -1
  45. package/out/renderer/assets/{UWRPUF3N-B9f5cVuf.js → UWRPUF3N-ONJaPLUk.js} +1 -1
  46. package/out/renderer/assets/{VSWIZJ7B-B67GWWkR.js → VSWIZJ7B-DbkRTlJD.js} +1 -1
  47. package/out/renderer/assets/{WM7NR6YK-BjDcbecJ.js → WM7NR6YK-CFy2rge0.js} +4 -4
  48. package/out/renderer/assets/{WXKV2YEK-DkO54WUi.js → WXKV2YEK-BFHYSpQF.js} +3 -3
  49. package/out/renderer/assets/{XLHPVVFU-CgBgWtsm.js → XLHPVVFU-BJFPh1Rn.js} +1 -1
  50. package/out/renderer/assets/{YNX532HU-GZs01vUI.js → YNX532HU-3QqofRh5.js} +5 -5
  51. package/out/renderer/assets/{YUPSMAUO-3HW0N7cY.js → YUPSMAUO-COLbQro8.js} +1 -1
  52. package/out/renderer/assets/{ZFRCZTLK-Bv3j48XJ.js → ZFRCZTLK-BuPbgRNC.js} +6 -6
  53. package/out/renderer/assets/{ZZDR4CN3-bxop59us.js → ZZDR4CN3-Do4onAxu.js} +4 -4
  54. package/out/renderer/assets/{core-DUTJyMGZ.js → core-T80gwwf3.js} +591 -344
  55. package/out/renderer/assets/{file-tabs-CDruoNmZ.js → file-tabs-DWQZlQfx.js} +5 -5
  56. package/out/renderer/assets/{ghostty-web-CtIJ7i7e.js → ghostty-web-DXNGAB4P.js} +1 -1
  57. package/out/renderer/assets/{highlights-26TXpsMP.js → highlights-B0vcJ7-n.js} +2 -2
  58. package/out/renderer/assets/{highlights-Bmhv1Dz1.js → highlights-Yvd7kpJw.js} +3 -3
  59. package/out/renderer/assets/{index-CpGbxp8B.js → index-BbyDWT39.js} +227 -250
  60. package/out/renderer/assets/{index-B5DcyIyT.css → index-CsOxRbAw.css} +146 -19
  61. package/out/renderer/assets/{kit-u_PHwNWF.js → kit-DgkO1_s6.js} +2354 -1186
  62. package/out/renderer/assets/{langs-DQ-AW7Q8.js → langs-7bXaMxtL.js} +1 -1
  63. package/out/renderer/assets/{lazy-xGoFzwfG.js → lazy-DE7xn_YD.js} +3 -3
  64. package/out/renderer/assets/{loader-BwgXVB75.js → loader-CdKsI-e2.js} +1 -1
  65. package/out/renderer/assets/{pierre-theme-CwuG23St.js → pierre-theme-BouAfjrk.js} +7 -7
  66. package/out/renderer/assets/{shiki-DCldjjSl.js → shiki-CIKuDsHH.js} +3 -3
  67. package/out/renderer/assets/{stream-tokenizer-BJjKxfTj.js → stream-tokenizer-JLLsdqkH.js} +1 -1
  68. package/out/renderer/assets/{themes-Bt8pRd53.js → themes-mM7Qtyxf.js} +2 -2
  69. package/out/renderer/assets/{useDetachCleanup-hiha0T2M.js → useDetachCleanup-1PVBQ1U4.js} +2 -2
  70. package/out/renderer/assets/{useFolderChanges-AOk0dbsA.js → useFolderChanges-_vflCTEj.js} +3 -3
  71. package/out/renderer/index.html +4 -4
  72. package/package.json +2 -2
  73. package/scripts/app-installer.mjs +9 -0
package/out/main/index.js CHANGED
@@ -8,12 +8,12 @@ import * as electron from "electron";
8
8
  import { shell, app, BrowserWindow, ipcMain, nativeImage, Notification, session, webContents, utilityProcess, protocol, Tray, Menu, powerMonitor, dialog, net, nativeTheme } from "electron";
9
9
  import { createSharedWatches, migrateSessionArtifactDirs, createRingBufferSink, fanoutSink, consoleSink, createLogger, installExtensionFromSpec, ExtensionInstallError, updateInstalledExtension, removeInstalledExtension, createExtensionHostRuntimeBridge, registerExtensionApiHostModules, inlineLoadedExtension, loadableExtensionDirs, discoverAndBuildExtensionRegistry, disposeExtensionRegistry, toWireConfigSchema, defaultExtensionScanPaths, createSqliteDriver, createSqliteWriteQueue, createSqliteSessionStore, loginMcpServer, saveMcpClientSecret, resolveInlineSuggestion, createPathAutocompleteProvider, refreshArtifact as refreshArtifact$1, BUILTIN_ARTIFACT_KINDS, renderArtifactRow, sessionsBadges, isThinkingLevel, panelHostRuntime, panelSummaries, loadExtensionPanel, runExtensionPanelAction, subscribeExtensionPanel, normalizeBadgeTarget, extensionBadgeActions, runBadgeAction, createCompletionRunner, completionProviderSummaries, listExtensionPaletteItems, runExtensionPaletteItem, subscribeExtensionPalette, createExtension, listActionSummaries, probeActionStatuses, runExtensionAction, parseGithubRefKey, githubPullUrl, pullFromMeta, githubPullConfirmedAt, isPullFresh, viewForRead, queueGithubPull, pullMeta, referenceProviderWires, createReferenceResolver, GITHUB_PULL_PROVIDER_ID, GITHUB_ISSUE_PROVIDER_ID, registerSessionProcess, treeProcesses, createGpuReader, createOwnedProcesses, listSessionProcesses, listOwnedProcesses, ownCommands, readProcessTree, labelSessions, originTotals, createMainThreadMeter, createSampler, readOsThreads, configureGithubClient, createFileGithubStateStore } from "zidane";
10
10
  import { randomUUID, createHash, randomBytes } from "node:crypto";
11
- import { parseEditorCommand, keybindingsPath, stripJsonComments, normalizeBindingValue, ensureKeybindingsFile, credentialsPath, applyApiKeyEnv, BUILTIN_PROVIDERS, readCredentials, detectAuth, supportsOAuth, signsInWithIntegration, runIntegrationSignIn, runOAuthLogin, DEFAULT_OAUTH_ACCOUNT_LABEL, setProviderCredential, mcpsWritePath, upsertMcpServer, discoverProjectMcps, removeMcpServer, compactPath as compactPath$1, createExtensionMcpHost, createFileMcpCredentialStore, projectRootOf, runningEstimateViews, resolveConfig, scopeCwd, settingsFromStored, DEFAULT_SETTINGS, SETTINGS_DEFAULTS_VERSION_KEY, SETTINGS_DEFAULTS_VERSION, enforceSettingsInvariants, sparseSettingsUpdate, createMcpStatusTracker, describeForkFailure, DEFAULT_SPACE_ID, SPACE_METADATA_KEY, TITLE_SOURCE_KEY, createCapabilityProbe, createPromptSubmissions, localDayString, summarizeUsage, createChatHost, findGitRoot, fileEntriesFromPaths, WORKSPACE_MAX_ENTRIES, WORKSPACE_MAX_FILE_BYTES, gitStatusOf, assembleDiff, importEntries, hostImportItems, toolResultText, sumRunCosts, lastContextSizeFromTurns, availableAgents, liveAgentProfiles, groupArtifacts, defaultModelOf, restoreModelOptions, enabledModelOptions, modelOptionsFor, readProviderCredential, isSecretCustomField, removeProviderCredential, setPreferredCredential, removeStoredCredential, setCredentialLabel, providerFieldViews, configuredProviderFields, sessionEnvironmentSummary, sessionModelFallbacks, readSessionSpaceId, isMainSession, readSessionAccount, deriveSessionTitle, isStaleRunMarker, cachedRepoKeyOf, spaceIdForNewSession, newSessionModel, defaultSessionModel, defaultSessionKnobs, defaultSessionAgent, modelSupportsReasoning, deleteSessionData, writeSessionExport, hasClaudeCodeSetup, countClaudeSessionFiles, previewClaudeImport, importFromClaudeCode, runInProgress, runProgress, resolveSessionCwd, effectiveContextWindow, fmtTokens, getContextWindow, listProjectFiles, discoverProjectPlugins, applyEnvironmentSettingsChange, folderLocation, connectorGithubToken, listExtensionSource, hasUntimedOpenCalls, withRunningCallStarts, listSafelists, removeFromSafelist, buildModelCatalog, modelsForDescriptor, listDecisionModels, listImageModels, testDecisionModel, testModel, providerFactoryOptions, describeTitleStatus, overlayHostSettings, splitHostSettingsPatch, settingsToWire, storeHasDurability, onboardingInstallSignals, needsOnboarding, mergeOnboardingState, migratedOnboardingRecords, detectOnboardingEnvironment, onboardingProviders, BUILTIN_THEMES, toolCallPreview, readSessionEnvironment, assertEnvironmentReady, discoverProjectSkills, fetchAllProviderUsage, fetchProviderUsage, redeemProviderReset, fetchGithubUsage, forgetGitCaches, createGitWatches, watchGitRepository, listWorkspace, resolvePaths, readWorkspaceFile, writeWorkspaceFile, invalidateDiagnostics, listDiagnosticsTools, supersededTools, runDiagnostics, gitStatus, gitDiff, gitShowHead, searchWorkspace, gitInfo, gitOriginUrl, gitPr, gitCommit, gitBranches, gitPrList, gitSwitch, gitCreateBranch, gitSync, workspaceEntryOps, changedCatalogItems, writeCredentialEntry, readCredentialEntry, createProviderBuilder, createArtifactKindsHost, createCatalogPorts, resolveSessionModel, linkCatalogs, readKeybindingsRaw, cloneRepository, fetchRepoInfo, compareSemver, checkForUpdate, watchInstalledVersion, isAutoInstallCandidate, findInstalledCompanion, followRunningUpdate, describeUpdateLockHolder, upgradeError, startUpdateWorker, autoInstallViaWorker, serveWorkspaceMedia } from "zidane/chat";
11
+ import { parseEditorCommand, keybindingsPath, stripJsonComments, normalizeBindingValue, ensureKeybindingsFile, credentialsPath, applyApiKeyEnv, BUILTIN_PROVIDERS, readCredentials, detectAuth, supportsOAuth, signsInWithIntegration, runIntegrationSignIn, runOAuthLogin, DEFAULT_OAUTH_ACCOUNT_LABEL, setProviderCredential, mcpsWritePath, upsertMcpServer, discoverProjectMcps, removeMcpServer, compactPath as compactPath$1, createExtensionMcpHost, createFileMcpCredentialStore, projectRootOf, runningEstimateViews, resolveConfig, scopeCwd, settingsFromStored, DEFAULT_SETTINGS, SETTINGS_DEFAULTS_VERSION_KEY, SETTINGS_DEFAULTS_VERSION, enforceSettingsInvariants, sparseSettingsUpdate, createMcpStatusTracker, describeForkFailure, DEFAULT_SPACE_ID, SPACE_METADATA_KEY, TITLE_SOURCE_KEY, createCapabilityProbe, createPromptSubmissions, localDayString, summarizeUsage, createChatHost, findGitRoot, fileEntriesFromPaths, WORKSPACE_MAX_ENTRIES, WORKSPACE_MAX_FILE_BYTES, gitStatusOf, assembleDiff, importEntries, hostImportItems, toolResultText, sumRunCosts, lastContextSizeFromTurns, availableAgents, liveAgentProfiles, groupArtifacts, defaultModelOf, restoreModelOptions, enabledModelOptions, modelOptionsFor, backfillAccountEmails, readProviderCredential, isSecretCustomField, removeProviderCredential, setPreferredCredential, removeStoredCredential, setCredentialLabel, providerFieldViews, configuredProviderFields, sessionEnvironmentSummary, sessionModelFallbacks, readSessionSpaceId, isMainSession, readSessionAccount, deriveSessionTitle, isStaleRunMarker, cachedRepoKeyOf, spaceIdForNewSession, newSessionModel, defaultSessionModel, defaultSessionKnobs, defaultSessionAgent, modelSupportsReasoning, deleteSessionData, writeSessionExport, hasClaudeCodeSetup, countClaudeSessionFiles, previewClaudeImport, importFromClaudeCode, runInProgress, runProgress, resolveSessionCwd, effectiveContextWindow, fmtTokens, getContextWindow, listProjectFiles, discoverProjectPlugins, applyEnvironmentSettingsChange, folderLocation, connectorGithubToken, listExtensionSource, hasUntimedOpenCalls, withRunningCallStarts, listSafelists, removeFromSafelist, buildModelCatalog, modelsForDescriptor, listDecisionModels, listImageModels, testDecisionModel, testModel, providerFactoryOptions, describeTitleStatus, overlayHostSettings, splitHostSettingsPatch, settingsToWire, storeHasDurability, onboardingInstallSignals, needsOnboarding, mergeOnboardingState, migratedOnboardingRecords, detectOnboardingEnvironment, onboardingProviders, BUILTIN_THEMES, toolCallPreview, readSessionEnvironment, assertEnvironmentReady, discoverProjectSkills, fetchAllProviderUsage, fetchProviderUsage, redeemProviderReset, fetchGithubUsage, forgetGitCaches, createGitWatches, watchGitRepository, listWorkspace, resolvePaths, readWorkspaceFile, writeWorkspaceFile, invalidateDiagnostics, listDiagnosticsTools, supersededTools, runDiagnostics, gitStatus, gitDiff, gitShowHead, searchWorkspace, gitInfo, gitOriginUrl, gitPr, gitCommit, gitBranches, gitPrList, gitSwitch, gitCreateBranch, gitSync, workspaceEntryOps, changedCatalogItems, writeCredentialEntry, readCredentialEntry, createProviderBuilder, createArtifactKindsHost, createCatalogPorts, resolveSessionModel, linkCatalogs, readKeybindingsRaw, cloneRepository, fetchRepoInfo, compareSemver, checkForUpdate, watchInstalledVersion, isAutoInstallCandidate, findInstalledCompanion, followRunningUpdate, describeUpdateLockHolder, upgradeError, startUpdateWorker, autoInstallViaWorker, serveWorkspaceMedia } from "zidane/chat";
12
12
  import { execFile, spawn } from "node:child_process";
13
13
  import { MEDIA_BY_EXTENSION, createPresenceMerge, createHostIndex, LOCAL_HOST_NAME, LOCAL_HOST_KEY, isMethodNotFound, HostRemovedError, sideSessionParent, orchestratedBy, BrowserOpError, normalizeBrowserUrl, isAllowedBrowserUrl, BROWSER_OUTLINE_MAX_ELEMENTS, BROWSER_TEXT_MAX_CHARS, BROWSER_EVALUATE_MAX_BYTES, BROWSER_MAX_WAIT_MS, BROWSER_ACTION_TIMEOUT_MS, BROWSER_WAIT_TIMEOUT_MS, BROWSER_OPEN_MOUNT_MS, TERMINAL_VIEW_MAX_LINES, daemonGate, remoteHostsGate, ARTIFACT_BADGES_MAX, readSessionFacets, isExtensionSpaceId, spacesEnabled, extensionSpace, usageHomeBlock, recentSessionsHomeBlock, HostRegistryError, SYNC_MODES, SYNC_CATEGORIES, isValidMachineName, toMachineName, engagedKillSwitches, isPaletteContext, BASH_CALL_ID_PREFIX, parseMachineKind, mediaTypeOfPath } from "zidane/chat/pure";
14
14
  import { createRequire } from "node:module";
15
15
  import { DatabaseSync } from "node:sqlite";
16
- import { changeExtensionOrigin, configuredExtensions, createExtensionsConfigSync, reloadChangedExtensions, readExtensionInstallOrigin, applyExtensionsConfigReport, mergeWireSettings, runtimeSettingsWire, normalizeBadgeTarget as normalizeBadgeTarget$1, isJson, isUiHostModule, resolveUiEntries, UI_TOKEN_NAMES, MAX_LINK_URL_LENGTH, LINK_SOURCES, classifyUiImport, NoUiError, createFileStoragePort, createCredentialsAuthStore, extensionRuntimeOf, loadExtensionsConfig, createConfigSettingsLayer, builtinKeymapEntries } from "zidane/extensions";
16
+ import { changeExtensionOrigin, configuredExtensions, createExtensionsConfigSync, reloadChangedExtensions, readExtensionInstallOrigin, applyExtensionsConfigReport, mergeWireSettings, runtimeSettingsWire, normalizeBadgeTarget as normalizeBadgeTarget$1, isJson, isUiHostModule, resolveUiEntries, UI_TOKEN_NAMES, MAX_LINK_URL_LENGTH, LINK_SOURCES, classifyUiImport, NoUiError, createFileStoragePort, projectStorageFolder, createCredentialsAuthStore, extensionRuntimeOf, loadExtensionsConfig, createConfigSettingsLayer, builtinKeymapEntries } from "zidane/extensions";
17
17
  import { installSkillFromSpec, SkillInstallError, browseSkillSource } from "zidane/skills";
18
18
  import { Worker } from "node:worker_threads";
19
19
  import { w as watchInThread, c as createExtensionDirWatcher } from "./chunks/extension-watch-Bk_X4gTf.js";
@@ -269,7 +269,7 @@ function saveKeybindings(map) {
269
269
  function keybindingsFilePath() {
270
270
  return keybindingsPath(userDataDir());
271
271
  }
272
- async function openFileInEditor(path) {
272
+ async function openFileInEditor(path, at) {
273
273
  const spec = (process.env.VISUAL ?? "").trim() || (process.env.EDITOR ?? "").trim();
274
274
  const tokens = spec ? parseEditorCommand(spec) : [];
275
275
  if (tokens.length === 0) {
@@ -281,7 +281,34 @@ async function openFileInEditor(path) {
281
281
  if (/(?:^|[/\\])(?:vi|vim|nvim|nano|pico)(?:\.exe)?$/i.test(cmd) && !args.includes("-g") || /(?:^|[/\\])emacs(?:client)?(?:\.exe)?$/i.test(cmd) && (args.includes("-nw") || args.includes("-t"))) {
282
282
  throw new Error("Set $VISUAL to a graphical editor for the GUI, or open this artifact in the TUI.");
283
283
  }
284
- return spawnDetached(cmd, [...args, path]);
284
+ return spawnDetached(cmd, [...args, ...editorFileArgs(cmd, path, at)]);
285
+ }
286
+ const VSCODE_LIKE = /* @__PURE__ */ new Set(["code", "code-insiders", "codium", "vscodium", "cursor", "windsurf"]);
287
+ const PATH_LINE_COL = /* @__PURE__ */ new Set(["zed", "subl", "sublime_text"]);
288
+ const JETBRAINS = /* @__PURE__ */ new Set([
289
+ "idea",
290
+ "idea64",
291
+ "webstorm",
292
+ "pycharm",
293
+ "phpstorm",
294
+ "goland",
295
+ "rubymine",
296
+ "clion",
297
+ "rider",
298
+ "datagrip",
299
+ "rustrover",
300
+ "studio"
301
+ ]);
302
+ function editorFileArgs(cmd, path, at) {
303
+ if (!at) return [path];
304
+ const name = (cmd.split(/[/\\]/).pop() ?? cmd).replace(/\.(?:exe|cmd|bat|sh)$/i, "").toLowerCase();
305
+ const lineCol = at.column ? `${path}:${at.line}:${at.column}` : `${path}:${at.line}`;
306
+ if (VSCODE_LIKE.has(name)) return ["-g", lineCol];
307
+ if (PATH_LINE_COL.has(name)) return [lineCol];
308
+ if (JETBRAINS.has(name)) {
309
+ return ["--line", String(at.line), ...at.column ? ["--column", String(at.column)] : [], path];
310
+ }
311
+ return [path];
285
312
  }
286
313
  function hasConfiguredEditor() {
287
314
  const spec = (process.env.VISUAL ?? "").trim() || (process.env.EDITOR ?? "").trim();
@@ -341,6 +368,8 @@ let factory = null;
341
368
  let main = null;
342
369
  let pendingShow = null;
343
370
  let mainListening = false;
371
+ let pendingDraft = null;
372
+ let draftListening = false;
344
373
  const standalone = /* @__PURE__ */ new Map();
345
374
  function setWindowFactory(make) {
346
375
  factory = make;
@@ -355,13 +384,17 @@ function openMainWindow() {
355
384
  const win = factory();
356
385
  main = win;
357
386
  mainListening = false;
387
+ draftListening = false;
358
388
  win.webContents.on("did-start-navigation", (details) => {
359
- if (main === win && details.isMainFrame && !details.isSameDocument) mainListening = false;
389
+ if (main !== win || !details.isMainFrame || details.isSameDocument) return;
390
+ mainListening = false;
391
+ draftListening = false;
360
392
  });
361
393
  win.on("closed", () => {
362
394
  if (main !== win) return;
363
395
  main = null;
364
396
  pendingShow = null;
397
+ pendingDraft = null;
365
398
  });
366
399
  return win;
367
400
  }
@@ -456,6 +489,11 @@ function showInMain(sessionKey2) {
456
489
  if (mainListening) win.webContents.send("windows:show", { sessionKey: sessionKey2 });
457
490
  else pendingShow = sessionKey2;
458
491
  }
492
+ function openNewDraft(request2) {
493
+ const win = openMainWindow();
494
+ if (draftListening) win.webContents.send("windows:newDraft", request2);
495
+ else pendingDraft = request2;
496
+ }
459
497
  function panelsWindowFor(sessionKey2) {
460
498
  const entry = entryFor(sessionKey2);
461
499
  return entry && entry.parts !== "chat" ? entry.win : null;
@@ -501,6 +539,13 @@ function registerWindowIpc() {
501
539
  pendingShow = null;
502
540
  return sessionKey2;
503
541
  });
542
+ ipcMain.handle("windows:takePendingDraft", (e) => {
543
+ if (!main || e.sender !== main.webContents) return null;
544
+ draftListening = true;
545
+ const request2 = pendingDraft;
546
+ pendingDraft = null;
547
+ return request2;
548
+ });
504
549
  ipcMain.handle(
505
550
  "windows:panelAction",
506
551
  (e, sessionKey2, action) => typeof sessionKey2 === "string" ? relayPanelAction(e.sender, sessionKey2, action) : false
@@ -2573,8 +2618,6 @@ const submissions = (host2) => createPromptSubmissions(host2(), host2().transfor
2573
2618
  const EMBEDDED = {
2574
2619
  "chat.send": (host2, p) => submissions(host2).send(p),
2575
2620
  "chat.interrupt": (host2, p) => host2().interrupt(p.sessionId),
2576
- "chat.steer": (host2, p) => submissions(host2).steer(p.sessionId, p.message),
2577
- "chat.followUp": (host2, p) => submissions(host2).followUp(p.sessionId, p.message),
2578
2621
  "chat.pushQueued": (host2, p) => submissions(host2).pushQueued(p.sessionId, p.message, p.activatedSkills),
2579
2622
  "chat.isRunning": (host2, p) => host2().isSessionRunning(p.sessionId),
2580
2623
  "chat.listWork": (host2, p) => host2().listRunningWork(p.sessionId, p.children ? { children: true } : void 0),
@@ -2627,8 +2670,8 @@ const EMBEDDED = {
2627
2670
  { [SPACE_METADATA_KEY]: p.spaceId || DEFAULT_SPACE_ID },
2628
2671
  { bumpUpdatedAt: false }
2629
2672
  ),
2630
- // The in-process host runs no terminals: nothing to end with it.
2631
- "sessions.setArchived": (host2, p) => host2().patchSessionMeta(p.sessionId, { archived: p.archived }),
2673
+ // The in-process host runs no terminals: nothing to end with it. The host releases a clean worktree.
2674
+ "sessions.setArchived": (host2, p) => host2().setSessionArchived(p.sessionId, p.archived),
2632
2675
  // Not activity either: a favorite keeps its place by recency.
2633
2676
  "sessions.setFavorite": (host2, p) => host2().patchSessionMeta(p.sessionId, { favorite: p.favorite }, { bumpUpdatedAt: false }),
2634
2677
  "sessions.setAgentId": async (host2, p) => {
@@ -2798,7 +2841,7 @@ class HostOfflineError extends Error {
2798
2841
  hostId;
2799
2842
  }
2800
2843
  const isUnsupportedMethod = isMethodNotFound;
2801
- const localHost = {
2844
+ const localHost$1 = {
2802
2845
  id: LOCAL_HOST_ID,
2803
2846
  name: LOCAL_HOST_NAME,
2804
2847
  remote: false,
@@ -2865,7 +2908,7 @@ function createHostDirectory(options = {}) {
2865
2908
  const directory2 = {
2866
2909
  hostFor: (ref) => {
2867
2910
  const hostId2 = "key" in ref ? sessionHostId(ref.key) : ref.hostId;
2868
- if (!hostId2 || hostId2 === LOCAL_HOST_ID) return localHost;
2911
+ if (!hostId2 || hostId2 === LOCAL_HOST_ID) return localHost$1;
2869
2912
  const server = servers.get(hostId2);
2870
2913
  if (server) return remoteHost(server);
2871
2914
  throw new Error(`No host "${hostId2}".`);
@@ -5636,7 +5679,7 @@ function releaseDrafts(senderId) {
5636
5679
  for (const draftId of ids) void client2.request("terminal.releaseDraft", { draftId }).catch(() => {
5637
5680
  });
5638
5681
  }
5639
- function handle(channel2, fn) {
5682
+ function handle$1(channel2, fn) {
5640
5683
  ipcMain.removeHandler(channel2);
5641
5684
  ipcMain.handle(channel2, (event, ...args) => {
5642
5685
  if (!fromAppWindow(event)) throw new Error(`${channel2} is only available to the app window`);
@@ -5656,7 +5699,7 @@ function registerTerminalIpc() {
5656
5699
  });
5657
5700
  app.on("browser-window-focus", () => syncViewer());
5658
5701
  syncViewer();
5659
- handle("terminal:state", async (_e, sessionId) => {
5702
+ handle$1("terminal:state", async (_e, sessionId) => {
5660
5703
  const key = asSessionKey(str(sessionId, "sessionId"));
5661
5704
  const { host: host2, sessionId: id } = sessionHost(key);
5662
5705
  if (host2.remote) {
@@ -5675,7 +5718,7 @@ function registerTerminalIpc() {
5675
5718
  }
5676
5719
  return client2.request("terminal.state", { sessionId: id });
5677
5720
  });
5678
- handle("terminal:open", async (_e, sessionId, target, cols, rows) => {
5721
+ handle$1("terminal:open", async (_e, sessionId, target, cols, rows) => {
5679
5722
  const key = asSessionKey(str(sessionId, "sessionId"));
5680
5723
  const { client: client2, sessionId: id } = clientForSession(key);
5681
5724
  const opened = await client2.request("terminal.open", {
@@ -5687,7 +5730,7 @@ function registerTerminalIpc() {
5687
5730
  noteTerminals(key, [opened]);
5688
5731
  return opened;
5689
5732
  });
5690
- handle("terminal:projectState", async (_e, cwd, draftId) => {
5733
+ handle$1("terminal:projectState", async (_e, cwd, draftId) => {
5691
5734
  const params = { cwd: str(cwd, "cwd"), ...withDraft(optionalStr(draftId, "draftId")) };
5692
5735
  const unavailable = (reason) => ({
5693
5736
  available: false,
@@ -5705,7 +5748,7 @@ function registerTerminalIpc() {
5705
5748
  throw err;
5706
5749
  }
5707
5750
  });
5708
- handle("terminal:openInProject", async (event, cwd, draftId, cols, rows) => {
5751
+ handle$1("terminal:openInProject", async (event, cwd, draftId, cols, rows) => {
5709
5752
  const params = {
5710
5753
  cwd: str(cwd, "cwd"),
5711
5754
  ...withDraft(optionalStr(draftId, "draftId")),
@@ -5726,7 +5769,7 @@ function registerTerminalIpc() {
5726
5769
  }
5727
5770
  return opened;
5728
5771
  });
5729
- handle("terminal:adopt", async (event, draftId, sessionId) => {
5772
+ handle$1("terminal:adopt", async (event, draftId, sessionId) => {
5730
5773
  const id = str(draftId, "draftId");
5731
5774
  forgetDraft(event.sender.id, id);
5732
5775
  const { host: host2, sessionId: raw } = sessionHost(asSessionKey(str(sessionId, "sessionId")));
@@ -5741,7 +5784,7 @@ function registerTerminalIpc() {
5741
5784
  throw err;
5742
5785
  }
5743
5786
  });
5744
- handle("terminal:releaseDraft", async (event, draftId) => {
5787
+ handle$1("terminal:releaseDraft", async (event, draftId) => {
5745
5788
  const id = str(draftId, "draftId");
5746
5789
  forgetDraft(event.sender.id, id);
5747
5790
  const client2 = projectDaemon();
@@ -5752,7 +5795,7 @@ function registerTerminalIpc() {
5752
5795
  if (!isUnsupportedMethod(err)) throw err;
5753
5796
  }
5754
5797
  });
5755
- handle("terminal:attach", async (event, terminalId, clientId) => {
5798
+ handle$1("terminal:attach", async (event, terminalId, clientId) => {
5756
5799
  const params = { terminalId: str(terminalId, "terminalId"), clientId: str(clientId, "clientId") };
5757
5800
  const sender = event.sender;
5758
5801
  const generation = watch(sender);
@@ -5768,12 +5811,12 @@ function registerTerminalIpc() {
5768
5811
  }
5769
5812
  return result;
5770
5813
  });
5771
- handle("terminal:detach", async (event, terminalId, clientId) => {
5814
+ handle$1("terminal:detach", async (event, terminalId, clientId) => {
5772
5815
  const params = { terminalId: str(terminalId, "terminalId"), clientId: str(clientId, "clientId") };
5773
5816
  untrack(event.sender.id, params.terminalId, params.clientId);
5774
5817
  await optionalClientForTerminal(params.terminalId)?.request("terminal.detach", params);
5775
5818
  });
5776
- handle("terminal:write", (_e, terminalId, data, from) => {
5819
+ handle$1("terminal:write", (_e, terminalId, data, from) => {
5777
5820
  if (typeof data !== "string") throw new Error("terminal: data must be a string");
5778
5821
  const who = from && typeof from === "object" && typeof from.clientId === "string" ? {
5779
5822
  clientId: from.clientId,
@@ -5782,7 +5825,7 @@ function registerTerminalIpc() {
5782
5825
  const id = str(terminalId, "terminalId");
5783
5826
  return clientForTerminal(id).request("terminal.write", { terminalId: id, data, ...who });
5784
5827
  });
5785
- handle(
5828
+ handle$1(
5786
5829
  "terminal:resize",
5787
5830
  (_e, terminalId, clientId, cols, rows, claim) => clientForTerminal(str(terminalId, "terminalId")).request("terminal.resize", {
5788
5831
  terminalId: str(terminalId, "terminalId"),
@@ -5792,7 +5835,7 @@ function registerTerminalIpc() {
5792
5835
  claim: claim === true
5793
5836
  })
5794
5837
  );
5795
- handle(
5838
+ handle$1(
5796
5839
  "terminal:ack",
5797
5840
  (_e, terminalId, clientId, offset) => optionalClientForTerminal(str(terminalId, "terminalId"))?.request("terminal.ack", {
5798
5841
  terminalId: str(terminalId, "terminalId"),
@@ -5800,18 +5843,18 @@ function registerTerminalIpc() {
5800
5843
  offset: int(offset, "offset")
5801
5844
  })
5802
5845
  );
5803
- handle("terminal:restart", (_e, terminalId) => {
5846
+ handle$1("terminal:restart", (_e, terminalId) => {
5804
5847
  const id = str(terminalId, "terminalId");
5805
5848
  return clientForTerminal(id).request("terminal.restart", { terminalId: id });
5806
5849
  });
5807
- handle("terminal:close", (_e, terminalId) => {
5850
+ handle$1("terminal:close", (_e, terminalId) => {
5808
5851
  const id = str(terminalId, "terminalId");
5809
5852
  return clientForTerminal(id).request("terminal.close", { terminalId: id }).then((result) => {
5810
5853
  getHostDirectory().forgetOwner(id);
5811
5854
  return result;
5812
5855
  });
5813
5856
  });
5814
- handle("terminal:setHidden", (_e, terminalId, hidden) => {
5857
+ handle$1("terminal:setHidden", (_e, terminalId, hidden) => {
5815
5858
  const id = str(terminalId, "terminalId");
5816
5859
  return clientForTerminal(id).request("terminal.setHidden", { terminalId: id, hidden: hidden === true });
5817
5860
  });
@@ -6541,14 +6584,6 @@ function sendPrompt(opts) {
6541
6584
  async function interruptChat(key) {
6542
6585
  await sessionRequest("chat.interrupt", key, {});
6543
6586
  }
6544
- function steerSession(key, message2) {
6545
- void sessionRequest("chat.steer", key, { message: message2 }).catch(() => {
6546
- });
6547
- }
6548
- function followUpSession(key, message2) {
6549
- void sessionRequest("chat.followUp", key, { message: message2 }).catch(() => {
6550
- });
6551
- }
6552
6587
  function isRuntimeSessionRunning(key) {
6553
6588
  return sessionRequest("chat.isRunning", key, {});
6554
6589
  }
@@ -7440,7 +7475,7 @@ function createArtifactFreshness(deps2) {
7440
7475
  const shown2 = /* @__PURE__ */ new Map();
7441
7476
  const checkedAt = /* @__PURE__ */ new Map();
7442
7477
  const queue = [];
7443
- const queued = /* @__PURE__ */ new Set();
7478
+ const queued2 = /* @__PURE__ */ new Set();
7444
7479
  let running2 = null;
7445
7480
  let timer = null;
7446
7481
  const union = () => new Set([...shown2.values()].flatMap((keys) => [...keys]));
@@ -7462,7 +7497,7 @@ function createArtifactFreshness(deps2) {
7462
7497
  running2 = (async () => {
7463
7498
  while (queue.length > 0) {
7464
7499
  const batch = queue.splice(0, BATCH_SESSIONS);
7465
- for (const key of batch) queued.delete(key);
7500
+ for (const key of batch) queued2.delete(key);
7466
7501
  const shownNow = union();
7467
7502
  const due = batch.filter((key) => shownNow.has(key) && stale(key));
7468
7503
  if (due.length > 0) await check(due);
@@ -7474,8 +7509,8 @@ function createArtifactFreshness(deps2) {
7474
7509
  function enqueue(keys) {
7475
7510
  if (!deps2.attended()) return;
7476
7511
  for (const key of keys) {
7477
- if (queued.has(key) || !stale(key)) continue;
7478
- queued.add(key);
7512
+ if (queued2.has(key) || !stale(key)) continue;
7513
+ queued2.add(key);
7479
7514
  queue.push(key);
7480
7515
  }
7481
7516
  drain();
@@ -7712,6 +7747,7 @@ function registerAuthChannels({ ipc }) {
7712
7747
  );
7713
7748
  ipc.handle("auth:detect", async (_e, cwd) => {
7714
7749
  const providers = await providersFor$1(cwd);
7750
+ await backfillAccountEmails(userDataDir(), providers);
7715
7751
  return detectAuth(userDataDir(), providers).map((r) => toAuthStatus(r, providers));
7716
7752
  });
7717
7753
  ipc.handle("auth:setApiKey", async (_e, provider, key, cwd) => {
@@ -9745,7 +9781,9 @@ function summarize(server, entry) {
9745
9781
  ...server.serverName ? { serverName: server.serverName } : {},
9746
9782
  ...server.serverVersion ? { serverVersion: server.serverVersion } : {},
9747
9783
  ...server.client?.hello.machineServe ? { machineServe: true } : {},
9748
- ...server.client?.hello.scope ? { scope: server.client.hello.scope } : {},
9784
+ // An older server's `approve` scope reads as chat: it can't change the server's settings either.
9785
+ ...server.client?.hello.scope ? { scope: server.client.hello.scope === "admin" ? "admin" : "chat" } : {},
9786
+ ...server.client?.hello.adminCommands ? { adminCommands: server.client.hello.adminCommands } : {},
9749
9787
  ...server.client?.hello.homeDir ? { home: server.client.hello.homeDir } : {},
9750
9788
  ...entry?.addedAt ? { addedAt: entry.addedAt } : {},
9751
9789
  ...entry?.lastConnectedAt ? { lastConnectedAt: entry.lastConnectedAt } : {}
@@ -10099,6 +10137,10 @@ function registerHostChannels({ ipc }) {
10099
10137
  };
10100
10138
  }
10101
10139
  });
10140
+ ipc.handle("hosts:installTool", async (_e, hostId2, name) => {
10141
+ if (typeof name !== "string" || !name || name.length > 64) throw new Error("A tool name is required.");
10142
+ return remoteOnly(hostId2).call("host.installTool", { name });
10143
+ });
10102
10144
  ipc.handle(
10103
10145
  "hosts:selfUpdate",
10104
10146
  async (_e, hostId2, action, enabled) => {
@@ -11023,11 +11065,12 @@ function registerQueueChannels({ ipc }) {
11023
11065
  ipc.handle("queue:list", (_e, sessionId) => sessionRequest("queue.list", sessionId, {}));
11024
11066
  ipc.handle(
11025
11067
  "queue:add",
11026
- (_e, sessionId, text2, activatedSkills, attachments) => sessionRequest("queue.add", sessionId, {
11068
+ (_e, sessionId, text2, activatedSkills, attachments, delivery) => sessionRequest("queue.add", sessionId, {
11027
11069
  text: text2,
11028
11070
  requestId: randomUUID(),
11029
11071
  ...activatedSkills ? { activatedSkills } : {},
11030
- ...attachments ? { attachments } : {}
11072
+ ...attachments ? { attachments } : {},
11073
+ ...delivery ? { delivery } : {}
11031
11074
  })
11032
11075
  );
11033
11076
  ipc.handle(
@@ -11250,8 +11293,6 @@ function registerRunChannels({ ipc }) {
11250
11293
  "chat:cancelWork",
11251
11294
  (_e, sessionId, id, reason) => cancelRunningWork(sessionId, id, reason)
11252
11295
  );
11253
- ipc.handle("chat:steer", (_e, sessionId, message2) => steerSession(sessionId, message2));
11254
- ipc.handle("chat:followUp", (_e, sessionId, message2) => followUpSession(sessionId, message2));
11255
11296
  ipc.handle("chat:pushQueued", (_e, sessionId, message2, activatedSkills) => {
11256
11297
  return sessionRequest("chat.pushQueued", sessionId, {
11257
11298
  message: message2,
@@ -11317,7 +11358,7 @@ function runBashStreaming(opts) {
11317
11358
  return new Promise((resolve2) => {
11318
11359
  const slot = { text: "", bytes: 0 };
11319
11360
  let overflowed = false;
11320
- let settled = false;
11361
+ let settled2 = false;
11321
11362
  const shell2 = resolveUserShell();
11322
11363
  const child = spawn(shell2.bin, [...shell2.args, command], {
11323
11364
  cwd,
@@ -11329,10 +11370,10 @@ function runBashStreaming(opts) {
11329
11370
  };
11330
11371
  let graceTimer = null;
11331
11372
  const settle = (exitCode) => {
11332
- if (settled) {
11373
+ if (settled2) {
11333
11374
  return;
11334
11375
  }
11335
- settled = true;
11376
+ settled2 = true;
11336
11377
  untrack2();
11337
11378
  signal.removeEventListener("abort", onAbort);
11338
11379
  if (graceTimer) {
@@ -11364,7 +11405,7 @@ function runBashStreaming(opts) {
11364
11405
  onAbort();
11365
11406
  }
11366
11407
  const onData = (chunk) => {
11367
- if (overflowed || settled) {
11408
+ if (overflowed || settled2) {
11368
11409
  return;
11369
11410
  }
11370
11411
  if (appendCapped(slot, chunk, ceiling) !== "ok") {
@@ -11776,8 +11817,15 @@ function registerSkillChannels({ ipc }) {
11776
11817
  return message2;
11777
11818
  });
11778
11819
  }
11820
+ const positive = (n) => typeof n === "number" && Number.isInteger(n) && n >= 1;
11821
+ function editorPosition(at) {
11822
+ if (!at || typeof at !== "object") return void 0;
11823
+ const { line, column } = at;
11824
+ if (!positive(line)) return void 0;
11825
+ return positive(column) ? { line, column } : { line };
11826
+ }
11779
11827
  function registerSystemChannels({ ipc }) {
11780
- ipc.handle("system:openPath", async (_e, path) => {
11828
+ ipc.handle("system:openPath", async (_e, path, at) => {
11781
11829
  if (typeof path !== "string" || !isAbsolute(path)) return false;
11782
11830
  const stat$1 = await stat(path).catch(() => null);
11783
11831
  if (!stat$1) return false;
@@ -11789,7 +11837,7 @@ function registerSystemChannels({ ipc }) {
11789
11837
  return await shell.openPath(path) === "";
11790
11838
  }
11791
11839
  if (!stat$1.isFile()) return false;
11792
- await openFileInEditor(path);
11840
+ await openFileInEditor(path, editorPosition(at));
11793
11841
  return true;
11794
11842
  });
11795
11843
  ipc.handle("system:repoWebBase", async (_e, cwd) => {
@@ -11813,6 +11861,13 @@ function registerSystemChannels({ ipc }) {
11813
11861
  await mkdir(dir, { recursive: true });
11814
11862
  return await shell.openPath(dir) === "";
11815
11863
  });
11864
+ ipc.handle("system:defaultBrowser", () => {
11865
+ try {
11866
+ return app.getApplicationNameForProtocol("https://example.com").replace(/\.app$/i, "").trim() || null;
11867
+ } catch {
11868
+ return null;
11869
+ }
11870
+ });
11816
11871
  ipc.handle("system:revealPath", async (_e, raw) => {
11817
11872
  const path = typeof raw === "string" ? raw.replace(/^file:\/\//, "") : "";
11818
11873
  if (!isAbsolute(path)) return false;
@@ -12135,10 +12190,16 @@ function unwatchGit(owner, cwd) {
12135
12190
  }
12136
12191
  function registerWorkspaceChannels({ ipc }) {
12137
12192
  const inSandbox = environmentWorkspaceSession;
12138
- ipc.handle("workspace:list", (_e, cwd, options) => {
12139
- const sessionId = inSandbox(cwd);
12140
- return sessionId ? listEnvironmentWorkspace(sessionId) : listWorkspace(cwd, options);
12141
- });
12193
+ ipc.handle(
12194
+ "workspace:list",
12195
+ async (_e, cwd, options) => {
12196
+ const sessionId = inSandbox(cwd);
12197
+ if (!sessionId) return listWorkspace(cwd, options);
12198
+ const entries = await listEnvironmentWorkspace(sessionId);
12199
+ const dir = options?.dir?.replace(/\/+$/, "");
12200
+ return { entries: dir ? entries.filter((e) => e.path.startsWith(`${dir}/`)) : entries };
12201
+ }
12202
+ );
12142
12203
  ipc.handle("workspace:projectRoot", (_e, cwd) => {
12143
12204
  if (typeof cwd !== "string" || !cwd || inSandbox(cwd)) return null;
12144
12205
  try {
@@ -13695,7 +13756,14 @@ function createStorageHub(options) {
13695
13756
  if (memo) return memo;
13696
13757
  const file = createFileStoragePort({
13697
13758
  root: join(options.dataDir, "extension-storage"),
13698
- ...projectRoot ? { projectRoot: join(projectRoot, options.prefix, "extension-storage") } : {},
13759
+ ...projectRoot ? {
13760
+ projectRoot: projectStorageFolder({
13761
+ dataDir: options.dataDir,
13762
+ projectRoot,
13763
+ prefix: options.prefix,
13764
+ ...options.warn ? { warn: options.warn } : {}
13765
+ })
13766
+ } : {},
13699
13767
  watch: false
13700
13768
  });
13701
13769
  const apply = async (loc, area, key, value) => {
@@ -13922,7 +13990,12 @@ function createDesktopExtensionsHost(options) {
13922
13990
  if (!daemon2) options.broadcast(signal, exceptWindowId);
13923
13991
  };
13924
13992
  const clients = createWindowClientDirectory();
13925
- const storage = createStorageHub({ dataDir: options.dataDir(), prefix: options.prefix, publish: publish2 });
13993
+ const storage = createStorageHub({
13994
+ dataDir: options.dataDir(),
13995
+ prefix: options.prefix,
13996
+ publish: publish2,
13997
+ warn: (message2) => console.warn(`[extensions] ${message2}`)
13998
+ });
13926
13999
  const flows = createFlowRegistry({ openExternal: options.openExternal });
13927
14000
  const authStore = createCredentialsAuthStore(options.dataDir());
13928
14001
  const buildProvider = createProviderBuilder({
@@ -16113,6 +16186,271 @@ function registerPerfIpc() {
16113
16186
  return { path, report };
16114
16187
  });
16115
16188
  }
16189
+ const DEEP_LINK_SCHEME = "zidane";
16190
+ const DEV_DEEP_LINK_SCHEME = "zidane-dev";
16191
+ const MAX_ID_LENGTH = 128;
16192
+ const MAX_PATH_LENGTH = 4096;
16193
+ const MAX_PROMPT_LENGTH = 16e3;
16194
+ const MAX_URL_LENGTH = 256 * 1024;
16195
+ const ID = /^[\w.:@-]+$/;
16196
+ function validId(value) {
16197
+ return value.length > 0 && value.length <= MAX_ID_LENGTH && ID.test(value);
16198
+ }
16199
+ function validPath(value) {
16200
+ if (value.length === 0 || value.length > MAX_PATH_LENGTH || value.includes("\0")) return false;
16201
+ return value.startsWith("/") || /^[A-Za-z]:[\\/]/.test(value);
16202
+ }
16203
+ function hostOf(value) {
16204
+ if (value === null || value === "") return LOCAL_HOST_KEY;
16205
+ return validId(value) ? value : null;
16206
+ }
16207
+ function parseDeepLink(url, scheme = DEEP_LINK_SCHEME) {
16208
+ if (typeof url !== "string" || url.length > MAX_URL_LENGTH) return null;
16209
+ let parsed;
16210
+ try {
16211
+ parsed = new URL(url);
16212
+ } catch {
16213
+ return null;
16214
+ }
16215
+ if (parsed.protocol !== `${scheme}:`) return null;
16216
+ if (parsed.username || parsed.password || parsed.port) return null;
16217
+ const action = parsed.hostname.toLowerCase();
16218
+ const segments = parsed.pathname.split("/").filter(Boolean);
16219
+ const params = parsed.searchParams;
16220
+ if (action === "session") {
16221
+ if (segments.length !== 1) return null;
16222
+ let sessionId;
16223
+ try {
16224
+ sessionId = decodeURIComponent(segments[0]);
16225
+ } catch {
16226
+ return null;
16227
+ }
16228
+ const hostId2 = hostOf(params.get("host"));
16229
+ if (!validId(sessionId) || hostId2 === null) return null;
16230
+ return { kind: "session", sessionId, hostId: hostId2 };
16231
+ }
16232
+ if (action === "new") {
16233
+ if (segments.length !== 0) return null;
16234
+ const hostId2 = hostOf(params.get("host"));
16235
+ if (hostId2 === null) return null;
16236
+ const ignored = [];
16237
+ const read = (name, valid) => {
16238
+ const value = params.get(name);
16239
+ if (value === null || value === "") return void 0;
16240
+ if (valid(value)) return value;
16241
+ ignored.push(name);
16242
+ return void 0;
16243
+ };
16244
+ const cwd = read("cwd", validPath);
16245
+ const prompt = read("prompt", (value) => value.length <= MAX_PROMPT_LENGTH && !value.includes("\0"));
16246
+ const agentId = read("agent", validId);
16247
+ const machineId = read("machine", validId);
16248
+ return {
16249
+ kind: "new",
16250
+ hostId: hostId2,
16251
+ ...cwd ? { cwd } : {},
16252
+ ...prompt ? { prompt } : {},
16253
+ ...agentId ? { agentId } : {},
16254
+ ...machineId ? { machineId } : {},
16255
+ ignored
16256
+ };
16257
+ }
16258
+ return null;
16259
+ }
16260
+ function deepLinkFromArgv(argv, scheme = DEEP_LINK_SCHEME) {
16261
+ const prefix = `${scheme}:`;
16262
+ return argv.find((arg) => typeof arg === "string" && arg.toLowerCase().startsWith(prefix)) ?? null;
16263
+ }
16264
+ const PARAM_NAMES = {
16265
+ cwd: "folder",
16266
+ prompt: "prompt",
16267
+ agent: "agent",
16268
+ machine: "machine",
16269
+ host: "host"
16270
+ };
16271
+ function within(root, path) {
16272
+ const base = root.endsWith("/") ? root.slice(0, -1) : root;
16273
+ return path === base || path.startsWith(`${base}/`);
16274
+ }
16275
+ async function settled(check, fallback) {
16276
+ try {
16277
+ return await check;
16278
+ } catch {
16279
+ return fallback;
16280
+ }
16281
+ }
16282
+ async function openSession(link, deps2) {
16283
+ const found = await deps2.host(link.hostId);
16284
+ if ("error" in found) {
16285
+ deps2.notice("Could not open the session.", found.error);
16286
+ return;
16287
+ }
16288
+ const exists = await settled(found.host.sessionExists(link.sessionId), false);
16289
+ if (!exists) {
16290
+ deps2.notice("Session not found.", `${found.host.name} has no session "${link.sessionId}".`);
16291
+ return;
16292
+ }
16293
+ deps2.reveal(sessionKey(link.hostId, link.sessionId));
16294
+ }
16295
+ async function openDraft(link, deps2) {
16296
+ const found = await deps2.host(link.hostId);
16297
+ if ("error" in found) {
16298
+ deps2.notice("Could not start a new chat.", found.error);
16299
+ return;
16300
+ }
16301
+ const { host: host2 } = found;
16302
+ const problems = link.ignored.map((param) => `The ${PARAM_NAMES[param]} in the link is not valid.`);
16303
+ const request2 = { hostId: link.hostId };
16304
+ let machine;
16305
+ if (link.machineId) {
16306
+ const machines = await settled(host2.machines(), []);
16307
+ machine = machines.find((m) => m.id === link.machineId);
16308
+ if (machine) request2.machine = { id: machine.id, name: machine.name };
16309
+ else problems.push(`${host2.name} has no machine "${link.machineId}".`);
16310
+ }
16311
+ if (link.cwd) {
16312
+ const ok = machine ? machine.roots.some((root) => within(root.path, link.cwd)) : await settled(host2.folderExists(link.cwd), false);
16313
+ if (ok) request2.cwd = link.cwd;
16314
+ else problems.push(`${machine ? `Machine ${machine.name}` : host2.name} has no folder "${link.cwd}".`);
16315
+ }
16316
+ if (link.agentId) {
16317
+ const agents = await settled(host2.agentIds(machine ? "" : request2.cwd ?? ""), []);
16318
+ if (agents.includes(link.agentId)) request2.agentId = link.agentId;
16319
+ else problems.push(`There is no agent "${link.agentId}".`);
16320
+ }
16321
+ if (link.prompt) request2.prompt = link.prompt;
16322
+ deps2.openDraft(request2);
16323
+ if (problems.length > 0) deps2.notice("Some of the link was ignored.", problems.join("\n"));
16324
+ }
16325
+ async function handleDeepLink(url, scheme, deps2) {
16326
+ const link = parseDeepLink(url, scheme);
16327
+ if (!link) {
16328
+ deps2.notice("Zidane cannot open this link.", url.length > 200 ? `${url.slice(0, 200)}…` : url);
16329
+ return;
16330
+ }
16331
+ try {
16332
+ if (link.kind === "session") await openSession(link, deps2);
16333
+ else await openDraft(link, deps2);
16334
+ } catch (err) {
16335
+ deps2.notice("Zidane could not open this link.", err instanceof Error ? err.message : String(err));
16336
+ }
16337
+ }
16338
+ const CONNECT_WAIT_MS = 1e4;
16339
+ const MAX_QUEUED = 16;
16340
+ function deepLinkScheme() {
16341
+ return app.isPackaged ? DEEP_LINK_SCHEME : DEV_DEEP_LINK_SCHEME;
16342
+ }
16343
+ const queued = [];
16344
+ let handle = null;
16345
+ function receive(url) {
16346
+ if (handle) handle(url);
16347
+ else if (queued.length < MAX_QUEUED) queued.push(url);
16348
+ }
16349
+ function installDeepLinks() {
16350
+ const scheme = deepLinkScheme();
16351
+ if (app.isPackaged && !app.requestSingleInstanceLock()) return false;
16352
+ app.on("second-instance", (_event, argv) => {
16353
+ const url = deepLinkFromArgv(argv, scheme);
16354
+ if (url) receive(url);
16355
+ else if (handle) openMainWindow();
16356
+ });
16357
+ app.on("will-finish-launching", () => {
16358
+ app.on("open-url", (event, url) => {
16359
+ event.preventDefault();
16360
+ receive(url);
16361
+ });
16362
+ });
16363
+ const launchedWith = deepLinkFromArgv(process.argv, scheme);
16364
+ if (launchedWith) receive(launchedWith);
16365
+ if (app.isPackaged && !app.isDefaultProtocolClient(scheme)) app.setAsDefaultProtocolClient(scheme);
16366
+ return true;
16367
+ }
16368
+ function startDeepLinks(deps2 = appDeepLinkDeps()) {
16369
+ const scheme = deepLinkScheme();
16370
+ handle = (url) => {
16371
+ void handleDeepLink(url, scheme, deps2).catch(
16372
+ (err) => guiLog.warn("deep link failed", { scope: "deep-link", error: String(err) })
16373
+ );
16374
+ };
16375
+ for (const url of queued.splice(0)) handle(url);
16376
+ }
16377
+ const localHost = {
16378
+ name: LOCAL_HOST_NAME,
16379
+ sessionExists: async (sessionId) => sessionExists(sessionId),
16380
+ folderExists: async (path) => (await stat(path)).isDirectory(),
16381
+ agentIds: async (cwd) => {
16382
+ const daemon2 = daemonReads();
16383
+ if (daemon2) return (await daemon2.request("agents.list", { cwd: scopeCwd(cwd) })).map((agent) => agent.id);
16384
+ const config2 = await getRuntimeConfig(scopeCwd(cwd));
16385
+ return Object.values(availableAgents(liveAgentProfiles(config2), readSettings())).map((agent) => agent.id);
16386
+ },
16387
+ machines: () => hostFor({ hostId: LOCAL_HOST_ID }).request("machines.list", {})
16388
+ };
16389
+ function settledConnection(hostId2, ms) {
16390
+ const directory2 = getHostDirectory();
16391
+ return new Promise((resolve2) => {
16392
+ const done = () => {
16393
+ clearTimeout(timer);
16394
+ off();
16395
+ resolve2();
16396
+ };
16397
+ const timer = setTimeout(done, ms);
16398
+ const off = directory2.onChange(() => {
16399
+ const server = directory2.server(hostId2);
16400
+ if (!server || server.client || server.status !== "connecting" && server.status !== "reconnecting") done();
16401
+ });
16402
+ });
16403
+ }
16404
+ async function serverLookup(hostId2) {
16405
+ const running2 = await syncRemoteHosts().catch(() => null);
16406
+ if (!running2) {
16407
+ return {
16408
+ error: "Remote hosts are off. Turn them on in Settings › Advanced › Experimental to open links to a server."
16409
+ };
16410
+ }
16411
+ const directory2 = getHostDirectory();
16412
+ const known = directory2.server(hostId2);
16413
+ if (!known) return { error: `This app has no saved server "${hostId2}".` };
16414
+ if (!known.client && (known.status === "connecting" || known.status === "reconnecting")) {
16415
+ await settledConnection(hostId2, CONNECT_WAIT_MS);
16416
+ }
16417
+ const server = directory2.server(hostId2);
16418
+ if (!server) return { error: `This app has no saved server "${hostId2}".` };
16419
+ if (!server.client) return { error: `${server.name} is not connected right now.` };
16420
+ const host2 = serverHost(hostId2);
16421
+ if (!host2) return { error: `This app has no saved server "${hostId2}".` };
16422
+ return {
16423
+ host: {
16424
+ name: host2.name,
16425
+ sessionExists: async (sessionId) => {
16426
+ try {
16427
+ return await host2.call("sessions.getMeta", { sessionId }) !== null;
16428
+ } catch (err) {
16429
+ if (isUnsupportedMethod(err)) return true;
16430
+ throw err;
16431
+ }
16432
+ },
16433
+ folderExists: async (path) => {
16434
+ await host2.call("fs.listDirs", { path });
16435
+ return true;
16436
+ },
16437
+ agentIds: async (cwd) => (await host2.call("agents.list", { cwd })).map((agent) => agent.id),
16438
+ machines: () => host2.call("machines.list", {})
16439
+ }
16440
+ };
16441
+ }
16442
+ function appDeepLinkDeps() {
16443
+ return {
16444
+ host: async (hostId2) => hostId2 === LOCAL_HOST_ID ? { host: localHost } : serverLookup(hostId2),
16445
+ reveal: revealSession,
16446
+ openDraft: openNewDraft,
16447
+ notice: (message2, detail) => {
16448
+ guiLog.info(`deep link: ${message2}`, { scope: "deep-link", ...detail ? { detail } : {} });
16449
+ if (process.env.ZIDANE_GUI_HEADLESS === "true") return;
16450
+ void dialog.showMessageBox({ type: "info", message: message2, ...detail ? { detail } : {} }).catch(() => void 0);
16451
+ }
16452
+ };
16453
+ }
16116
16454
  const CRASH_LOOP_MS = 3e4;
16117
16455
  const defaultDeps = {
16118
16456
  now: Date.now,
@@ -16237,6 +16575,8 @@ keepDevToolsBindable();
16237
16575
  app.setPath("userData", override);
16238
16576
  }
16239
16577
  }
16578
+ const primaryInstance = installDeepLinks();
16579
+ if (!primaryInstance) app.quit();
16240
16580
  function createWindow(query) {
16241
16581
  const icon = windowIcon();
16242
16582
  const titleSuffix = app.isPackaged ? "" : " (dev)";
@@ -16326,6 +16666,7 @@ function registerAppHandlers() {
16326
16666
  registerAppIconIpc();
16327
16667
  }
16328
16668
  app.whenReady().then(() => {
16669
+ if (!primaryInstance) return;
16329
16670
  applyAppIcon();
16330
16671
  syncBundleIcon();
16331
16672
  applyAuthEnv();
@@ -16353,11 +16694,13 @@ app.whenReady().then(() => {
16353
16694
  registerPerfIpc();
16354
16695
  setWindowFactory(createWindow);
16355
16696
  openMainWindow();
16697
+ startDeepLinks();
16356
16698
  app.on("activate", () => {
16357
16699
  if (!mainWindow()) openMainWindow();
16358
16700
  });
16359
16701
  });
16360
16702
  app.on("before-quit", () => {
16703
+ if (!primaryInstance) return;
16361
16704
  void lspManager.stopAll();
16362
16705
  shutdownChat();
16363
16706
  cancelAllOAuth();