Function: eca--initialize
eca--initialize is a natively compiled function defined in eca.el.
Signature
(eca--initialize SESSION &optional ON-READY)
Documentation
Send the initialize request for SESSION.
ON-READY is called with SESSION once the server answered and the first chat is open, for callers that must act on a session which is only usable asynchronously.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca.el
(defun eca--initialize (session &optional on-ready)
"Send the initialize request for SESSION.
ON-READY is called with SESSION once the server answered and the
first chat is open, for callers that must act on a session which
is only usable asynchronously."
(run-hooks 'eca-before-initialize-hook)
(setf (eca--session-status session) 'starting)
(eca-api-request-async
session
:method "initialize"
:params (append (when-let* ((pid (and eca-send-process-id
(unless (-some-> (buffer-file-name)
(file-remote-p))
(emacs-pid)))))
(list :processId pid))
(list :clientInfo (list :name "emacs"
:version (emacs-version))
:capabilities (list :codeAssistant (list :chat t
:chatCapabilities (list :askQuestion t)
:editor (list :diagnostics t
:definition t
:references t)))
:initializationOptions (list :chatAgent eca-chat-custom-agent)
:workspaceFolders (vconcat (-map (lambda (folder)
(list :uri (eca--path-to-uri folder)
:name (file-name-nondirectory (directory-file-name folder))))
(eca--session-workspace-folders session)))))
:success-callback (-lambda (res)
(setf (eca--session-status session) 'started)
(setf (eca--session-chat-welcome-message session) (plist-get res :chatWelcomeMessage))
(setf (eca--session-global-config-path session) (plist-get res :globalConfigPath))
(eca-api-notify session :method "initialized")
(eca-info "Started with workspaces: %s" (string-join (eca--session-workspace-folders session) ","))
(eca-chat-open session)
(run-hooks 'eca-after-initialize-hook)
(when on-ready (funcall on-ready session)))
:error-callback (lambda (e) (eca-error e))))