Merge branch 'main' into Fix-0-Providers

This commit is contained in:
Wesley Tanner authored and GitHub committed 2026-10-30 06:40:37 -05:00
commit cb7d073af0
84 files changed
+2120 -6323

No files matched your search

+18 -1
View File
@@ -1,4 +1,4 @@
import { openCodeLocation, parseOpenCodeModelRef } from '@opencode-manager/shared/opencode'
import { openCodeLocation, parseOpenCodeModelRef, readSessionGoal } from '@opencode-manager/shared/opencode'
import { MANAGER_PROMPT_CLIENT_METADATA_KEY } from '@opencode-manager/shared/schemas'
import { isMobileViewport } from '@/hooks/useMobile'
import { getDirectoryName } from '@/lib/utils'
@@ -11,6 +11,7 @@ import type {
ModelRef,
OpenCodeApi,
PermissionRequest,
SessionGoalRead,
SessionInboxCompaction,
SessionInboxUser,
SessionInfo,
@@ -231,6 +232,22 @@ export async function getSession(sessionID: string, serverId?: string): Promise<
return callOpenCode((api) => api.session.get({ sessionID }), serverId)
}
/**
* Reads a session goal through the OpenCode goal RPC.
*
* @param sessionID The session whose goal is read.
* @param directory Directory of the session's project, once it is known.
* @param serverId Server that owns the session, when it is not the local one.
* @returns The goal, or an unsupported result when the server has no goal RPC.
*/
export async function getSessionGoal(
sessionID: string,
directory: string | undefined,
serverId?: string,
): Promise<SessionGoalRead> {
return callOpenCode((api) => readSessionGoal(api, { sessionID, directory }), serverId)
}
export async function createSession(input: CreateSessionInput, serverId?: string): Promise<SessionInfo> {
const model = input.model ? parseOpenCodeModelRef(input.model) : undefined
return callOpenCode(
-46
View File
@@ -1,46 +0,0 @@
import { fetchWrapper } from './fetchWrapper'
import { API_BASE_URL } from '@/config'
import {
LOCAL_OPENCODE_SERVER_ID,
type SessionGoal,
type StartSessionGoalRequest,
} from '@opencode-manager/shared/schemas'
export async function getLatestSessionGoal(
sessionId: string,
serverId: string = LOCAL_OPENCODE_SERVER_ID,
): Promise<SessionGoal | null> {
const res = await fetchWrapper<{ goal: SessionGoal | null }>(`${API_BASE_URL}/api/session-goals`, {
params: { sessionId, serverId },
})
return res.goal
}
export async function startSessionGoal(input: StartSessionGoalRequest): Promise<SessionGoal> {
const res = await fetchWrapper<{ goal: SessionGoal }>(`${API_BASE_URL}/api/session-goals`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(input),
})
return res.goal
}
async function runGoalAction(id: number, action: 'pause' | 'resume' | 'cancel'): Promise<SessionGoal> {
const res = await fetchWrapper<{ goal: SessionGoal }>(
`${API_BASE_URL}/api/session-goals/${encodeURIComponent(id)}/${action}`,
{ method: 'POST' },
)
return res.goal
}
export function pauseSessionGoal(id: number): Promise<SessionGoal> {
return runGoalAction(id, 'pause')
}
export function resumeSessionGoal(id: number): Promise<SessionGoal> {
return runGoalAction(id, 'resume')
}
export function cancelSessionGoal(id: number): Promise<SessionGoal> {
return runGoalAction(id, 'cancel')
}