|
1 | | -local core = require('opencode.core') |
2 | 1 | ---@type OpencodeState |
3 | 2 | local state = require('opencode.state') |
4 | 3 | local session_store = require('opencode.session') |
5 | 4 | local Promise = require('opencode.promise') |
6 | 5 | local window_actions = require('opencode.commands.handlers.window').actions |
| 6 | +local session_runtime = require('opencode.services.session_runtime') |
| 7 | +local agent_model = require('opencode.services.agent_model') |
7 | 8 |
|
8 | 9 | local M = { |
9 | 10 | actions = {}, |
@@ -77,13 +78,13 @@ local function run_api_action_with_checktime(request_promise, error_prefix) |
77 | 78 | end |
78 | 79 |
|
79 | 80 | function M.actions.open_input_new_session() |
80 | | - return core.open({ new_session = true, focus = 'input', start_insert = true }) |
| 81 | + return session_runtime.open({ new_session = true, focus = 'input', start_insert = true }) |
81 | 82 | end |
82 | 83 |
|
83 | 84 | ---@param title string |
84 | 85 | function M.actions.open_input_new_session_with_title(title) |
85 | 86 | return Promise.async(function(session_title) |
86 | | - local new_session = core.create_new_session(session_title):await() |
| 87 | + local new_session = session_runtime.create_new_session(session_title):await() |
87 | 88 | if not new_session then |
88 | 89 | vim.notify('Failed to create new session', vim.log.levels.ERROR) |
89 | 90 | return |
|
96 | 97 |
|
97 | 98 | ---@param parent_id? string |
98 | 99 | function M.actions.select_session(parent_id) |
99 | | - core.select_session(parent_id) |
| 100 | + session_runtime.select_session(parent_id) |
100 | 101 | end |
101 | 102 |
|
102 | 103 | function M.actions.select_child_session() |
103 | 104 | local active = state.active_session |
104 | | - core.select_session(active and active.id or nil) |
| 105 | + session_runtime.select_session(active and active.id or nil) |
105 | 106 | end |
106 | 107 |
|
107 | 108 | ---@param current_session? Session |
@@ -158,19 +159,18 @@ function M.actions.unshare() |
158 | 159 | end) |
159 | 160 | end |
160 | 161 |
|
161 | | -function M.actions.initialize() |
162 | | - return Promise.async(function() |
163 | | - local id = require('opencode.id') |
164 | | - local state_obj = state |
165 | | - local core_obj = core |
| 162 | + function M.actions.initialize() |
| 163 | + return Promise.async(function() |
| 164 | + local id = require('opencode.id') |
| 165 | + local state_obj = state |
166 | 166 |
|
167 | | - local new_session = core_obj.create_new_session('AGENTS.md Initialization'):await() |
| 167 | + local new_session = session_runtime.create_new_session('AGENTS.md Initialization'):await() |
168 | 168 | if not new_session then |
169 | 169 | vim.notify('Failed to create new session', vim.log.levels.ERROR) |
170 | 170 | return |
171 | 171 | end |
172 | 172 |
|
173 | | - if not core_obj.initialize_current_model():await() or not state_obj.current_model then |
| 173 | + if not agent_model.initialize_current_model():await() or not state_obj.current_model then |
174 | 174 | vim.notify('No model selected', vim.log.levels.ERROR) |
175 | 175 | return |
176 | 176 | end |
@@ -369,7 +369,7 @@ function M.actions.fork_session(message_id) |
369 | 369 | vim.schedule(function() |
370 | 370 | if response and response.id then |
371 | 371 | vim.notify('Session forked successfully. New session ID: ' .. response.id, vim.log.levels.INFO) |
372 | | - core.switch_session(response.id) |
| 372 | + session_runtime.switch_session(response.id) |
373 | 373 | else |
374 | 374 | vim.notify('Session forked but no new session ID received', vim.log.levels.WARN) |
375 | 375 | end |
|
0 commit comments