fix(client): singularize generated api groups (#34534)

This commit is contained in:
Kit Langton
2026-06-29 21:07:01 -04:00
committed by GitHub
parent f928b5be07
commit 6846542115
21 changed files with 1913 additions and 557 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ export function runTui(transport: Transport, reload?: () => Promise<Transport>)
return Effect.gen(function* () { return Effect.gen(function* () {
const options = { baseUrl: transport.url, headers: transport.headers } const options = { baseUrl: transport.url, headers: transport.headers }
const api = OpenCode.make(options) const api = OpenCode.make(options)
const directory = yield* Effect.tryPromise(() => api.files.list({ location: { directory: process.cwd() } })).pipe( const directory = yield* Effect.tryPromise(() => api.file.list({ location: { directory: process.cwd() } })).pipe(
Effect.map((response) => response.location.directory), Effect.map((response) => response.location.directory),
Effect.catch(() => Effect.catch(() =>
Effect.tryPromise(() => api.location.get()).pipe(Effect.map((response) => response.directory)), Effect.tryPromise(() => api.location.get()).pipe(Effect.map((response) => response.directory)),
+17 -16
View File
@@ -19,24 +19,25 @@ export const ClientApi = makeDefaultApi({
export const groupNames = { export const groupNames = {
"server.health": "health", "server.health": "health",
"server.location": "location", "server.location": "location",
"server.agent": "agents", "server.agent": "agent",
"server.session": "sessions", "server.session": "session",
"server.message": "messages", "server.message": "message",
"server.model": "models", "server.model": "model",
"server.generate": "generate", "server.generate": "generate",
"server.provider": "providers", "server.provider": "provider",
"server.integration": "integrations", "server.integration": "integration",
"server.credential": "credentials", "server.credential": "credential",
"server.permission": "permissions", "server.permission": "permission",
"server.fs": "files", "server.fs": "file",
"server.command": "commands", "server.command": "command",
"server.skill": "skills", "server.skill": "skill",
"server.event": "events", "server.event": "event",
"server.pty": "ptys", "server.pty": "pty",
"server.question": "questions", "server.shell": "shell",
"server.reference": "references", "server.question": "question",
"server.reference": "reference",
"server.project": "project", "server.project": "project",
"server.projectCopy": "projectCopies", "server.projectCopy": "projectCopy",
} as const } as const
export const endpointNames = { export const endpointNames = {
+17 -17
View File
@@ -805,25 +805,25 @@ const adaptGroup20 = (raw: RawClient["server.projectCopy"]) => ({
const adaptClient = (raw: RawClient) => ({ const adaptClient = (raw: RawClient) => ({
health: adaptGroup0(raw["server.health"]), health: adaptGroup0(raw["server.health"]),
location: adaptGroup1(raw["server.location"]), location: adaptGroup1(raw["server.location"]),
agents: adaptGroup2(raw["server.agent"]), agent: adaptGroup2(raw["server.agent"]),
sessions: adaptGroup3(raw["server.session"]), session: adaptGroup3(raw["server.session"]),
messages: adaptGroup4(raw["server.message"]), message: adaptGroup4(raw["server.message"]),
models: adaptGroup5(raw["server.model"]), model: adaptGroup5(raw["server.model"]),
generate: adaptGroup6(raw["server.generate"]), generate: adaptGroup6(raw["server.generate"]),
providers: adaptGroup7(raw["server.provider"]), provider: adaptGroup7(raw["server.provider"]),
integrations: adaptGroup8(raw["server.integration"]), integration: adaptGroup8(raw["server.integration"]),
credentials: adaptGroup9(raw["server.credential"]), credential: adaptGroup9(raw["server.credential"]),
project: adaptGroup10(raw["server.project"]), project: adaptGroup10(raw["server.project"]),
permissions: adaptGroup11(raw["server.permission"]), permission: adaptGroup11(raw["server.permission"]),
files: adaptGroup12(raw["server.fs"]), file: adaptGroup12(raw["server.fs"]),
commands: adaptGroup13(raw["server.command"]), command: adaptGroup13(raw["server.command"]),
skills: adaptGroup14(raw["server.skill"]), skill: adaptGroup14(raw["server.skill"]),
events: adaptGroup15(raw["server.event"]), event: adaptGroup15(raw["server.event"]),
ptys: adaptGroup16(raw["server.pty"]), pty: adaptGroup16(raw["server.pty"]),
"server.shell": adaptGroup17(raw["server.shell"]), shell: adaptGroup17(raw["server.shell"]),
questions: adaptGroup18(raw["server.question"]), question: adaptGroup18(raw["server.question"]),
references: adaptGroup19(raw["server.reference"]), reference: adaptGroup19(raw["server.reference"]),
projectCopies: adaptGroup20(raw["server.projectCopy"]), projectCopy: adaptGroup20(raw["server.projectCopy"]),
}) })
export const make = (options?: { readonly baseUrl?: URL | string }) => export const make = (options?: { readonly baseUrl?: URL | string }) =>
+270 -270
View File
@@ -2,138 +2,138 @@ import type {
HealthGetOutput, HealthGetOutput,
LocationGetInput, LocationGetInput,
LocationGetOutput, LocationGetOutput,
AgentsListInput, AgentListInput,
AgentsListOutput, AgentListOutput,
SessionsListInput, SessionListInput,
SessionsListOutput, SessionListOutput,
SessionsCreateInput, SessionCreateInput,
SessionsCreateOutput, SessionCreateOutput,
SessionsActiveOutput, SessionActiveOutput,
SessionsGetInput, SessionGetInput,
SessionsGetOutput, SessionGetOutput,
SessionsForkInput, SessionForkInput,
SessionsForkOutput, SessionForkOutput,
SessionsSwitchAgentInput, SessionSwitchAgentInput,
SessionsSwitchAgentOutput, SessionSwitchAgentOutput,
SessionsSwitchModelInput, SessionSwitchModelInput,
SessionsSwitchModelOutput, SessionSwitchModelOutput,
SessionsRenameInput, SessionRenameInput,
SessionsRenameOutput, SessionRenameOutput,
SessionsPromptInput, SessionPromptInput,
SessionsPromptOutput, SessionPromptOutput,
SessionsCompactInput, SessionCompactInput,
SessionsCompactOutput, SessionCompactOutput,
SessionsWaitInput, SessionWaitInput,
SessionsWaitOutput, SessionWaitOutput,
SessionsStageInput, SessionStageInput,
SessionsStageOutput, SessionStageOutput,
SessionsClearInput, SessionClearInput,
SessionsClearOutput, SessionClearOutput,
SessionsCommitInput, SessionCommitInput,
SessionsCommitOutput, SessionCommitOutput,
SessionsContextInput, SessionContextInput,
SessionsContextOutput, SessionContextOutput,
SessionsHistoryInput, SessionHistoryInput,
SessionsHistoryOutput, SessionHistoryOutput,
SessionsEventsInput, SessionEventsInput,
SessionsEventsOutput, SessionEventsOutput,
SessionsInterruptInput, SessionInterruptInput,
SessionsInterruptOutput, SessionInterruptOutput,
SessionsMessageInput, SessionMessageInput,
SessionsMessageOutput, SessionMessageOutput,
MessagesListInput, MessageListInput,
MessagesListOutput, MessageListOutput,
ModelsListInput, ModelListInput,
ModelsListOutput, ModelListOutput,
GenerateTextInput, GenerateTextInput,
GenerateTextOutput, GenerateTextOutput,
ProvidersListInput, ProviderListInput,
ProvidersListOutput, ProviderListOutput,
ProvidersGetInput, ProviderGetInput,
ProvidersGetOutput, ProviderGetOutput,
IntegrationsListInput, IntegrationListInput,
IntegrationsListOutput, IntegrationListOutput,
IntegrationsGetInput, IntegrationGetInput,
IntegrationsGetOutput, IntegrationGetOutput,
IntegrationsConnectKeyInput, IntegrationConnectKeyInput,
IntegrationsConnectKeyOutput, IntegrationConnectKeyOutput,
IntegrationsConnectOauthInput, IntegrationConnectOauthInput,
IntegrationsConnectOauthOutput, IntegrationConnectOauthOutput,
IntegrationsAttemptStatusInput, IntegrationAttemptStatusInput,
IntegrationsAttemptStatusOutput, IntegrationAttemptStatusOutput,
IntegrationsAttemptCompleteInput, IntegrationAttemptCompleteInput,
IntegrationsAttemptCompleteOutput, IntegrationAttemptCompleteOutput,
IntegrationsAttemptCancelInput, IntegrationAttemptCancelInput,
IntegrationsAttemptCancelOutput, IntegrationAttemptCancelOutput,
CredentialsUpdateInput, CredentialUpdateInput,
CredentialsUpdateOutput, CredentialUpdateOutput,
CredentialsRemoveInput, CredentialRemoveInput,
CredentialsRemoveOutput, CredentialRemoveOutput,
ProjectCurrentInput, ProjectCurrentInput,
ProjectCurrentOutput, ProjectCurrentOutput,
ProjectDirectoriesInput, ProjectDirectoriesInput,
ProjectDirectoriesOutput, ProjectDirectoriesOutput,
PermissionsListRequestsInput, PermissionListRequestsInput,
PermissionsListRequestsOutput, PermissionListRequestsOutput,
PermissionsListSavedInput, PermissionListSavedInput,
PermissionsListSavedOutput, PermissionListSavedOutput,
PermissionsRemoveSavedInput, PermissionRemoveSavedInput,
PermissionsRemoveSavedOutput, PermissionRemoveSavedOutput,
PermissionsCreateInput, PermissionCreateInput,
PermissionsCreateOutput, PermissionCreateOutput,
PermissionsListInput, PermissionListInput,
PermissionsListOutput, PermissionListOutput,
PermissionsGetInput, PermissionGetInput,
PermissionsGetOutput, PermissionGetOutput,
PermissionsReplyInput, PermissionReplyInput,
PermissionsReplyOutput, PermissionReplyOutput,
FilesReadInput, FileReadInput,
FilesReadOutput, FileReadOutput,
FilesListInput, FileListInput,
FilesListOutput, FileListOutput,
FilesFindInput, FileFindInput,
FilesFindOutput, FileFindOutput,
CommandsListInput, CommandListInput,
CommandsListOutput, CommandListOutput,
SkillsListInput, SkillListInput,
SkillsListOutput, SkillListOutput,
EventsSubscribeOutput, EventSubscribeOutput,
PtysListInput, PtyListInput,
PtysListOutput, PtyListOutput,
PtysCreateInput, PtyCreateInput,
PtysCreateOutput, PtyCreateOutput,
PtysGetInput, PtyGetInput,
PtysGetOutput, PtyGetOutput,
PtysUpdateInput, PtyUpdateInput,
PtysUpdateOutput, PtyUpdateOutput,
PtysRemoveInput, PtyRemoveInput,
PtysRemoveOutput, PtyRemoveOutput,
ServerShellListInput, ShellListInput,
ServerShellListOutput, ShellListOutput,
ServerShellCreateInput, ShellCreateInput,
ServerShellCreateOutput, ShellCreateOutput,
ServerShellGetInput, ShellGetInput,
ServerShellGetOutput, ShellGetOutput,
ServerShellOutputInput, ShellOutputInput,
ServerShellOutputOutput, ShellOutputOutput,
ServerShellRemoveInput, ShellRemoveInput,
ServerShellRemoveOutput, ShellRemoveOutput,
QuestionsListRequestsInput, QuestionListRequestsInput,
QuestionsListRequestsOutput, QuestionListRequestsOutput,
QuestionsListInput, QuestionListInput,
QuestionsListOutput, QuestionListOutput,
QuestionsReplyInput, QuestionReplyInput,
QuestionsReplyOutput, QuestionReplyOutput,
QuestionsRejectInput, QuestionRejectInput,
QuestionsRejectOutput, QuestionRejectOutput,
ReferencesListInput, ReferenceListInput,
ReferencesListOutput, ReferenceListOutput,
ProjectCopiesCreateInput, ProjectCopyCreateInput,
ProjectCopiesCreateOutput, ProjectCopyCreateOutput,
ProjectCopiesRemoveInput, ProjectCopyRemoveInput,
ProjectCopiesRemoveOutput, ProjectCopyRemoveOutput,
ProjectCopiesRefreshInput, ProjectCopyRefreshInput,
ProjectCopiesRefreshOutput, ProjectCopyRefreshOutput,
} from "./types" } from "./types"
import { ClientError } from "./client-error" import { ClientError } from "./client-error"
@@ -292,9 +292,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
agents: { agent: {
list: (input?: AgentsListInput, requestOptions?: RequestOptions) => list: (input?: AgentListInput, requestOptions?: RequestOptions) =>
request<AgentsListOutput>( request<AgentListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/agent`, path: `/api/agent`,
@@ -306,9 +306,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
sessions: { session: {
list: (input?: SessionsListInput, requestOptions?: RequestOptions) => list: (input?: SessionListInput, requestOptions?: RequestOptions) =>
request<SessionsListOutput>( request<SessionListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/session`, path: `/api/session`,
@@ -328,8 +328,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
create: (input?: SessionsCreateInput, requestOptions?: RequestOptions) => create: (input?: SessionCreateInput, requestOptions?: RequestOptions) =>
request<{ readonly data: SessionsCreateOutput }>( request<{ readonly data: SessionCreateOutput }>(
{ {
method: "POST", method: "POST",
path: `/api/session`, path: `/api/session`,
@@ -346,7 +346,7 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
active: (requestOptions?: RequestOptions) => active: (requestOptions?: RequestOptions) =>
request<{ readonly data: SessionsActiveOutput }>( request<{ readonly data: SessionActiveOutput }>(
{ {
method: "GET", method: "GET",
path: `/api/session/active`, path: `/api/session/active`,
@@ -356,8 +356,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
get: (input: SessionsGetInput, requestOptions?: RequestOptions) => get: (input: SessionGetInput, requestOptions?: RequestOptions) =>
request<{ readonly data: SessionsGetOutput }>( request<{ readonly data: SessionGetOutput }>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}`, path: `/api/session/${encodeURIComponent(input.sessionID)}`,
@@ -367,8 +367,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
fork: (input: SessionsForkInput, requestOptions?: RequestOptions) => fork: (input: SessionForkInput, requestOptions?: RequestOptions) =>
request<{ readonly data: SessionsForkOutput }>( request<{ readonly data: SessionForkOutput }>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/fork`, path: `/api/session/${encodeURIComponent(input.sessionID)}/fork`,
@@ -379,8 +379,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
switchAgent: (input: SessionsSwitchAgentInput, requestOptions?: RequestOptions) => switchAgent: (input: SessionSwitchAgentInput, requestOptions?: RequestOptions) =>
request<SessionsSwitchAgentOutput>( request<SessionSwitchAgentOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/agent`, path: `/api/session/${encodeURIComponent(input.sessionID)}/agent`,
@@ -391,8 +391,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
switchModel: (input: SessionsSwitchModelInput, requestOptions?: RequestOptions) => switchModel: (input: SessionSwitchModelInput, requestOptions?: RequestOptions) =>
request<SessionsSwitchModelOutput>( request<SessionSwitchModelOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/model`, path: `/api/session/${encodeURIComponent(input.sessionID)}/model`,
@@ -403,8 +403,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
rename: (input: SessionsRenameInput, requestOptions?: RequestOptions) => rename: (input: SessionRenameInput, requestOptions?: RequestOptions) =>
request<SessionsRenameOutput>( request<SessionRenameOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/rename`, path: `/api/session/${encodeURIComponent(input.sessionID)}/rename`,
@@ -415,8 +415,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
prompt: (input: SessionsPromptInput, requestOptions?: RequestOptions) => prompt: (input: SessionPromptInput, requestOptions?: RequestOptions) =>
request<{ readonly data: SessionsPromptOutput }>( request<{ readonly data: SessionPromptOutput }>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/prompt`, path: `/api/session/${encodeURIComponent(input.sessionID)}/prompt`,
@@ -427,8 +427,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
compact: (input: SessionsCompactInput, requestOptions?: RequestOptions) => compact: (input: SessionCompactInput, requestOptions?: RequestOptions) =>
request<SessionsCompactOutput>( request<SessionCompactOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/compact`, path: `/api/session/${encodeURIComponent(input.sessionID)}/compact`,
@@ -438,8 +438,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
wait: (input: SessionsWaitInput, requestOptions?: RequestOptions) => wait: (input: SessionWaitInput, requestOptions?: RequestOptions) =>
request<SessionsWaitOutput>( request<SessionWaitOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/wait`, path: `/api/session/${encodeURIComponent(input.sessionID)}/wait`,
@@ -449,8 +449,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
stage: (input: SessionsStageInput, requestOptions?: RequestOptions) => stage: (input: SessionStageInput, requestOptions?: RequestOptions) =>
request<{ readonly data: SessionsStageOutput }>( request<{ readonly data: SessionStageOutput }>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/stage`, path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/stage`,
@@ -461,8 +461,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
clear: (input: SessionsClearInput, requestOptions?: RequestOptions) => clear: (input: SessionClearInput, requestOptions?: RequestOptions) =>
request<SessionsClearOutput>( request<SessionClearOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/clear`, path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/clear`,
@@ -472,8 +472,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
commit: (input: SessionsCommitInput, requestOptions?: RequestOptions) => commit: (input: SessionCommitInput, requestOptions?: RequestOptions) =>
request<SessionsCommitOutput>( request<SessionCommitOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/commit`, path: `/api/session/${encodeURIComponent(input.sessionID)}/revert/commit`,
@@ -483,8 +483,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
context: (input: SessionsContextInput, requestOptions?: RequestOptions) => context: (input: SessionContextInput, requestOptions?: RequestOptions) =>
request<{ readonly data: SessionsContextOutput }>( request<{ readonly data: SessionContextOutput }>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}/context`, path: `/api/session/${encodeURIComponent(input.sessionID)}/context`,
@@ -494,8 +494,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
history: (input: SessionsHistoryInput, requestOptions?: RequestOptions) => history: (input: SessionHistoryInput, requestOptions?: RequestOptions) =>
request<SessionsHistoryOutput>( request<SessionHistoryOutput>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}/history`, path: `/api/session/${encodeURIComponent(input.sessionID)}/history`,
@@ -506,8 +506,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
events: (input: SessionsEventsInput, requestOptions?: RequestOptions): AsyncIterable<SessionsEventsOutput> => events: (input: SessionEventsInput, requestOptions?: RequestOptions): AsyncIterable<SessionEventsOutput> =>
sse<SessionsEventsOutput>( sse<SessionEventsOutput>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}/event`, path: `/api/session/${encodeURIComponent(input.sessionID)}/event`,
@@ -518,8 +518,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
interrupt: (input: SessionsInterruptInput, requestOptions?: RequestOptions) => interrupt: (input: SessionInterruptInput, requestOptions?: RequestOptions) =>
request<SessionsInterruptOutput>( request<SessionInterruptOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/interrupt`, path: `/api/session/${encodeURIComponent(input.sessionID)}/interrupt`,
@@ -529,8 +529,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
message: (input: SessionsMessageInput, requestOptions?: RequestOptions) => message: (input: SessionMessageInput, requestOptions?: RequestOptions) =>
request<{ readonly data: SessionsMessageOutput }>( request<{ readonly data: SessionMessageOutput }>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}/message/${encodeURIComponent(input.messageID)}`, path: `/api/session/${encodeURIComponent(input.sessionID)}/message/${encodeURIComponent(input.messageID)}`,
@@ -541,9 +541,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
}, },
messages: { message: {
list: (input: MessagesListInput, requestOptions?: RequestOptions) => list: (input: MessageListInput, requestOptions?: RequestOptions) =>
request<MessagesListOutput>( request<MessageListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}/message`, path: `/api/session/${encodeURIComponent(input.sessionID)}/message`,
@@ -555,9 +555,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
models: { model: {
list: (input?: ModelsListInput, requestOptions?: RequestOptions) => list: (input?: ModelListInput, requestOptions?: RequestOptions) =>
request<ModelsListOutput>( request<ModelListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/model`, path: `/api/model`,
@@ -584,9 +584,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
}, },
providers: { provider: {
list: (input?: ProvidersListInput, requestOptions?: RequestOptions) => list: (input?: ProviderListInput, requestOptions?: RequestOptions) =>
request<ProvidersListOutput>( request<ProviderListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/provider`, path: `/api/provider`,
@@ -597,8 +597,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
get: (input: ProvidersGetInput, requestOptions?: RequestOptions) => get: (input: ProviderGetInput, requestOptions?: RequestOptions) =>
request<ProvidersGetOutput>( request<ProviderGetOutput>(
{ {
method: "GET", method: "GET",
path: `/api/provider/${encodeURIComponent(input.providerID)}`, path: `/api/provider/${encodeURIComponent(input.providerID)}`,
@@ -610,9 +610,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
integrations: { integration: {
list: (input?: IntegrationsListInput, requestOptions?: RequestOptions) => list: (input?: IntegrationListInput, requestOptions?: RequestOptions) =>
request<IntegrationsListOutput>( request<IntegrationListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/integration`, path: `/api/integration`,
@@ -623,8 +623,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
get: (input: IntegrationsGetInput, requestOptions?: RequestOptions) => get: (input: IntegrationGetInput, requestOptions?: RequestOptions) =>
request<IntegrationsGetOutput>( request<IntegrationGetOutput>(
{ {
method: "GET", method: "GET",
path: `/api/integration/${encodeURIComponent(input.integrationID)}`, path: `/api/integration/${encodeURIComponent(input.integrationID)}`,
@@ -635,8 +635,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
connectKey: (input: IntegrationsConnectKeyInput, requestOptions?: RequestOptions) => connectKey: (input: IntegrationConnectKeyInput, requestOptions?: RequestOptions) =>
request<IntegrationsConnectKeyOutput>( request<IntegrationConnectKeyOutput>(
{ {
method: "POST", method: "POST",
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/key`, path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/key`,
@@ -648,8 +648,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
connectOauth: (input: IntegrationsConnectOauthInput, requestOptions?: RequestOptions) => connectOauth: (input: IntegrationConnectOauthInput, requestOptions?: RequestOptions) =>
request<IntegrationsConnectOauthOutput>( request<IntegrationConnectOauthOutput>(
{ {
method: "POST", method: "POST",
path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth`, path: `/api/integration/${encodeURIComponent(input.integrationID)}/connect/oauth`,
@@ -661,8 +661,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
attemptStatus: (input: IntegrationsAttemptStatusInput, requestOptions?: RequestOptions) => attemptStatus: (input: IntegrationAttemptStatusInput, requestOptions?: RequestOptions) =>
request<IntegrationsAttemptStatusOutput>( request<IntegrationAttemptStatusOutput>(
{ {
method: "GET", method: "GET",
path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}`, path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}`,
@@ -673,8 +673,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
attemptComplete: (input: IntegrationsAttemptCompleteInput, requestOptions?: RequestOptions) => attemptComplete: (input: IntegrationAttemptCompleteInput, requestOptions?: RequestOptions) =>
request<IntegrationsAttemptCompleteOutput>( request<IntegrationAttemptCompleteOutput>(
{ {
method: "POST", method: "POST",
path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}/complete`, path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}/complete`,
@@ -686,8 +686,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
attemptCancel: (input: IntegrationsAttemptCancelInput, requestOptions?: RequestOptions) => attemptCancel: (input: IntegrationAttemptCancelInput, requestOptions?: RequestOptions) =>
request<IntegrationsAttemptCancelOutput>( request<IntegrationAttemptCancelOutput>(
{ {
method: "DELETE", method: "DELETE",
path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}`, path: `/api/integration/attempt/${encodeURIComponent(input.attemptID)}`,
@@ -699,9 +699,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
credentials: { credential: {
update: (input: CredentialsUpdateInput, requestOptions?: RequestOptions) => update: (input: CredentialUpdateInput, requestOptions?: RequestOptions) =>
request<CredentialsUpdateOutput>( request<CredentialUpdateOutput>(
{ {
method: "PATCH", method: "PATCH",
path: `/api/credential/${encodeURIComponent(input.credentialID)}`, path: `/api/credential/${encodeURIComponent(input.credentialID)}`,
@@ -713,8 +713,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
remove: (input: CredentialsRemoveInput, requestOptions?: RequestOptions) => remove: (input: CredentialRemoveInput, requestOptions?: RequestOptions) =>
request<CredentialsRemoveOutput>( request<CredentialRemoveOutput>(
{ {
method: "DELETE", method: "DELETE",
path: `/api/credential/${encodeURIComponent(input.credentialID)}`, path: `/api/credential/${encodeURIComponent(input.credentialID)}`,
@@ -752,9 +752,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
permissions: { permission: {
listRequests: (input?: PermissionsListRequestsInput, requestOptions?: RequestOptions) => listRequests: (input?: PermissionListRequestsInput, requestOptions?: RequestOptions) =>
request<PermissionsListRequestsOutput>( request<PermissionListRequestsOutput>(
{ {
method: "GET", method: "GET",
path: `/api/permission/request`, path: `/api/permission/request`,
@@ -765,8 +765,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
listSaved: (input?: PermissionsListSavedInput, requestOptions?: RequestOptions) => listSaved: (input?: PermissionListSavedInput, requestOptions?: RequestOptions) =>
request<{ readonly data: PermissionsListSavedOutput }>( request<{ readonly data: PermissionListSavedOutput }>(
{ {
method: "GET", method: "GET",
path: `/api/permission/saved`, path: `/api/permission/saved`,
@@ -777,8 +777,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
removeSaved: (input: PermissionsRemoveSavedInput, requestOptions?: RequestOptions) => removeSaved: (input: PermissionRemoveSavedInput, requestOptions?: RequestOptions) =>
request<PermissionsRemoveSavedOutput>( request<PermissionRemoveSavedOutput>(
{ {
method: "DELETE", method: "DELETE",
path: `/api/permission/saved/${encodeURIComponent(input.id)}`, path: `/api/permission/saved/${encodeURIComponent(input.id)}`,
@@ -788,8 +788,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
create: (input: PermissionsCreateInput, requestOptions?: RequestOptions) => create: (input: PermissionCreateInput, requestOptions?: RequestOptions) =>
request<{ readonly data: PermissionsCreateOutput }>( request<{ readonly data: PermissionCreateOutput }>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`, path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
@@ -808,8 +808,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
list: (input: PermissionsListInput, requestOptions?: RequestOptions) => list: (input: PermissionListInput, requestOptions?: RequestOptions) =>
request<{ readonly data: PermissionsListOutput }>( request<{ readonly data: PermissionListOutput }>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`, path: `/api/session/${encodeURIComponent(input.sessionID)}/permission`,
@@ -819,8 +819,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
get: (input: PermissionsGetInput, requestOptions?: RequestOptions) => get: (input: PermissionGetInput, requestOptions?: RequestOptions) =>
request<{ readonly data: PermissionsGetOutput }>( request<{ readonly data: PermissionGetOutput }>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}`, path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}`,
@@ -830,8 +830,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
reply: (input: PermissionsReplyInput, requestOptions?: RequestOptions) => reply: (input: PermissionReplyInput, requestOptions?: RequestOptions) =>
request<PermissionsReplyOutput>( request<PermissionReplyOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}/reply`, path: `/api/session/${encodeURIComponent(input.sessionID)}/permission/${encodeURIComponent(input.requestID)}/reply`,
@@ -843,9 +843,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
files: { file: {
read: (input: FilesReadInput, requestOptions?: RequestOptions) => read: (input: FileReadInput, requestOptions?: RequestOptions) =>
request<FilesReadOutput>( request<FileReadOutput>(
{ {
method: "GET", method: "GET",
path: `/api/fs/read/${encodePath(input.path)}`, path: `/api/fs/read/${encodePath(input.path)}`,
@@ -857,8 +857,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
list: (input?: FilesListInput, requestOptions?: RequestOptions) => list: (input?: FileListInput, requestOptions?: RequestOptions) =>
request<FilesListOutput>( request<FileListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/fs/list`, path: `/api/fs/list`,
@@ -869,8 +869,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
find: (input: FilesFindInput, requestOptions?: RequestOptions) => find: (input: FileFindInput, requestOptions?: RequestOptions) =>
request<FilesFindOutput>( request<FileFindOutput>(
{ {
method: "GET", method: "GET",
path: `/api/fs/find`, path: `/api/fs/find`,
@@ -882,9 +882,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
commands: { command: {
list: (input?: CommandsListInput, requestOptions?: RequestOptions) => list: (input?: CommandListInput, requestOptions?: RequestOptions) =>
request<CommandsListOutput>( request<CommandListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/command`, path: `/api/command`,
@@ -896,9 +896,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
skills: { skill: {
list: (input?: SkillsListInput, requestOptions?: RequestOptions) => list: (input?: SkillListInput, requestOptions?: RequestOptions) =>
request<SkillsListOutput>( request<SkillListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/skill`, path: `/api/skill`,
@@ -910,16 +910,16 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
events: { event: {
subscribe: (requestOptions?: RequestOptions): AsyncIterable<EventsSubscribeOutput> => subscribe: (requestOptions?: RequestOptions): AsyncIterable<EventSubscribeOutput> =>
sse<EventsSubscribeOutput>( sse<EventSubscribeOutput>(
{ method: "GET", path: `/api/event`, successStatus: 200, declaredStatuses: [401, 400], empty: false }, { method: "GET", path: `/api/event`, successStatus: 200, declaredStatuses: [401, 400], empty: false },
requestOptions, requestOptions,
), ),
}, },
ptys: { pty: {
list: (input?: PtysListInput, requestOptions?: RequestOptions) => list: (input?: PtyListInput, requestOptions?: RequestOptions) =>
request<PtysListOutput>( request<PtyListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/pty`, path: `/api/pty`,
@@ -930,8 +930,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
create: (input?: PtysCreateInput, requestOptions?: RequestOptions) => create: (input?: PtyCreateInput, requestOptions?: RequestOptions) =>
request<PtysCreateOutput>( request<PtyCreateOutput>(
{ {
method: "POST", method: "POST",
path: `/api/pty`, path: `/api/pty`,
@@ -949,8 +949,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
get: (input: PtysGetInput, requestOptions?: RequestOptions) => get: (input: PtyGetInput, requestOptions?: RequestOptions) =>
request<PtysGetOutput>( request<PtyGetOutput>(
{ {
method: "GET", method: "GET",
path: `/api/pty/${encodeURIComponent(input.ptyID)}`, path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
@@ -961,8 +961,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
update: (input: PtysUpdateInput, requestOptions?: RequestOptions) => update: (input: PtyUpdateInput, requestOptions?: RequestOptions) =>
request<PtysUpdateOutput>( request<PtyUpdateOutput>(
{ {
method: "PUT", method: "PUT",
path: `/api/pty/${encodeURIComponent(input.ptyID)}`, path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
@@ -974,8 +974,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
remove: (input: PtysRemoveInput, requestOptions?: RequestOptions) => remove: (input: PtyRemoveInput, requestOptions?: RequestOptions) =>
request<PtysRemoveOutput>( request<PtyRemoveOutput>(
{ {
method: "DELETE", method: "DELETE",
path: `/api/pty/${encodeURIComponent(input.ptyID)}`, path: `/api/pty/${encodeURIComponent(input.ptyID)}`,
@@ -987,9 +987,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
"server.shell": { shell: {
list: (input?: ServerShellListInput, requestOptions?: RequestOptions) => list: (input?: ShellListInput, requestOptions?: RequestOptions) =>
request<ServerShellListOutput>( request<ShellListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/shell`, path: `/api/shell`,
@@ -1000,8 +1000,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
create: (input: ServerShellCreateInput, requestOptions?: RequestOptions) => create: (input: ShellCreateInput, requestOptions?: RequestOptions) =>
request<ServerShellCreateOutput>( request<ShellCreateOutput>(
{ {
method: "POST", method: "POST",
path: `/api/shell`, path: `/api/shell`,
@@ -1018,8 +1018,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
get: (input: ServerShellGetInput, requestOptions?: RequestOptions) => get: (input: ShellGetInput, requestOptions?: RequestOptions) =>
request<ServerShellGetOutput>( request<ShellGetOutput>(
{ {
method: "GET", method: "GET",
path: `/api/shell/${encodeURIComponent(input.id)}`, path: `/api/shell/${encodeURIComponent(input.id)}`,
@@ -1030,8 +1030,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
output: (input: ServerShellOutputInput, requestOptions?: RequestOptions) => output: (input: ShellOutputInput, requestOptions?: RequestOptions) =>
request<ServerShellOutputOutput>( request<ShellOutputOutput>(
{ {
method: "GET", method: "GET",
path: `/api/shell/${encodeURIComponent(input.id)}/output`, path: `/api/shell/${encodeURIComponent(input.id)}/output`,
@@ -1042,8 +1042,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
remove: (input: ServerShellRemoveInput, requestOptions?: RequestOptions) => remove: (input: ShellRemoveInput, requestOptions?: RequestOptions) =>
request<ServerShellRemoveOutput>( request<ShellRemoveOutput>(
{ {
method: "DELETE", method: "DELETE",
path: `/api/shell/${encodeURIComponent(input.id)}`, path: `/api/shell/${encodeURIComponent(input.id)}`,
@@ -1055,9 +1055,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
questions: { question: {
listRequests: (input?: QuestionsListRequestsInput, requestOptions?: RequestOptions) => listRequests: (input?: QuestionListRequestsInput, requestOptions?: RequestOptions) =>
request<QuestionsListRequestsOutput>( request<QuestionListRequestsOutput>(
{ {
method: "GET", method: "GET",
path: `/api/question/request`, path: `/api/question/request`,
@@ -1068,8 +1068,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
list: (input: QuestionsListInput, requestOptions?: RequestOptions) => list: (input: QuestionListInput, requestOptions?: RequestOptions) =>
request<{ readonly data: QuestionsListOutput }>( request<{ readonly data: QuestionListOutput }>(
{ {
method: "GET", method: "GET",
path: `/api/session/${encodeURIComponent(input.sessionID)}/question`, path: `/api/session/${encodeURIComponent(input.sessionID)}/question`,
@@ -1079,8 +1079,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
).then((value) => value.data), ).then((value) => value.data),
reply: (input: QuestionsReplyInput, requestOptions?: RequestOptions) => reply: (input: QuestionReplyInput, requestOptions?: RequestOptions) =>
request<QuestionsReplyOutput>( request<QuestionReplyOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/question/${encodeURIComponent(input.requestID)}/reply`, path: `/api/session/${encodeURIComponent(input.sessionID)}/question/${encodeURIComponent(input.requestID)}/reply`,
@@ -1091,8 +1091,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
reject: (input: QuestionsRejectInput, requestOptions?: RequestOptions) => reject: (input: QuestionRejectInput, requestOptions?: RequestOptions) =>
request<QuestionsRejectOutput>( request<QuestionRejectOutput>(
{ {
method: "POST", method: "POST",
path: `/api/session/${encodeURIComponent(input.sessionID)}/question/${encodeURIComponent(input.requestID)}/reject`, path: `/api/session/${encodeURIComponent(input.sessionID)}/question/${encodeURIComponent(input.requestID)}/reject`,
@@ -1103,9 +1103,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
references: { reference: {
list: (input?: ReferencesListInput, requestOptions?: RequestOptions) => list: (input?: ReferenceListInput, requestOptions?: RequestOptions) =>
request<ReferencesListOutput>( request<ReferenceListOutput>(
{ {
method: "GET", method: "GET",
path: `/api/reference`, path: `/api/reference`,
@@ -1117,9 +1117,9 @@ export function make(options: ClientOptions) {
requestOptions, requestOptions,
), ),
}, },
projectCopies: { projectCopy: {
create: (input: ProjectCopiesCreateInput, requestOptions?: RequestOptions) => create: (input: ProjectCopyCreateInput, requestOptions?: RequestOptions) =>
request<ProjectCopiesCreateOutput>( request<ProjectCopyCreateOutput>(
{ {
method: "POST", method: "POST",
path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy`, path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy`,
@@ -1131,8 +1131,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
remove: (input: ProjectCopiesRemoveInput, requestOptions?: RequestOptions) => remove: (input: ProjectCopyRemoveInput, requestOptions?: RequestOptions) =>
request<ProjectCopiesRemoveOutput>( request<ProjectCopyRemoveOutput>(
{ {
method: "DELETE", method: "DELETE",
path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy`, path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy`,
@@ -1144,8 +1144,8 @@ export function make(options: ClientOptions) {
}, },
requestOptions, requestOptions,
), ),
refresh: (input: ProjectCopiesRefreshInput, requestOptions?: RequestOptions) => refresh: (input: ProjectCopyRefreshInput, requestOptions?: RequestOptions) =>
request<ProjectCopiesRefreshOutput>( request<ProjectCopyRefreshOutput>(
{ {
method: "POST", method: "POST",
path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy/refresh`, path: `/experimental/project/${encodeURIComponent(input.projectID)}/copy/refresh`,
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,3 +1,3 @@
export * from "./generated/index" export * from "./generated/index"
export type { EventsSubscribeOutput as OpenCodeEvent } from "./generated/types" export type { EventSubscribeOutput as OpenCodeEvent } from "./generated/types"
export type OpenCodeClient = ReturnType<typeof import("./generated/client").make> export type OpenCodeClient = ReturnType<typeof import("./generated/client").make>
+22 -22
View File
@@ -3,19 +3,19 @@ import { DateTime, Effect, Stream } from "effect"
import { HttpClient, HttpClientResponse } from "effect/unstable/http" import { HttpClient, HttpClientResponse } from "effect/unstable/http"
import { AbsolutePath, Agent, Location, Model, OpenCode, Prompt, Session, SessionMessage } from "../src/effect" import { AbsolutePath, Agent, Location, Model, OpenCode, Prompt, Session, SessionMessage } from "../src/effect"
test("sessions.get returns the decoded Effect projection", async () => { test("session.get returns the decoded Effect projection", async () => {
const httpClient = HttpClient.make((request) => const httpClient = HttpClient.make((request) =>
Effect.succeed(HttpClientResponse.fromWeb(request, Response.json(session))), Effect.succeed(HttpClientResponse.fromWeb(request, Response.json(session))),
) )
const result = await Effect.gen(function* () { const result = await Effect.gen(function* () {
const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" }) const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" })
return yield* client.sessions.get({ sessionID: Session.ID.make("ses_test") }) return yield* client.session.get({ sessionID: Session.ID.make("ses_test") })
}).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.runPromise) }).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.runPromise)
expect(DateTime.toEpochMillis(result.time.created)).toBe(1_717_171_717_000) expect(DateTime.toEpochMillis(result.time.created)).toBe(1_717_171_717_000)
}) })
test("events.subscribe exposes and decodes the native Effect event stream", async () => { test("event.subscribe exposes and decodes the native Effect event stream", async () => {
const httpClient = HttpClient.make((request) => const httpClient = HttpClient.make((request) =>
Effect.succeed( Effect.succeed(
HttpClientResponse.fromWeb( HttpClientResponse.fromWeb(
@@ -30,7 +30,7 @@ test("events.subscribe exposes and decodes the native Effect event stream", asyn
) )
const events = await Effect.gen(function* () { const events = await Effect.gen(function* () {
const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" }) const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" })
return yield* client.events.subscribe().pipe(Stream.runCollect) return yield* client.event.subscribe().pipe(Stream.runCollect)
}).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.runPromise) }).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.runPromise)
expect(Array.from(events).map((event) => event.type)).toEqual(["server.connected", "session.next.model.switched"]) expect(Array.from(events).map((event) => event.type)).toEqual(["server.connected", "session.next.model.switched"])
@@ -40,7 +40,7 @@ test("events.subscribe exposes and decodes the native Effect event stream", asyn
expect(durable.durable).toEqual({ aggregateID: "ses_test", seq: 1, version: 1 }) expect(durable.durable).toEqual({ aggregateID: "ses_test", seq: 1, version: 1 })
}) })
test("events.subscribe terminates on Effect protocol decode failures", async () => { test("event.subscribe terminates on Effect protocol decode failures", async () => {
const httpClient = HttpClient.make((request) => const httpClient = HttpClient.make((request) =>
Effect.succeed( Effect.succeed(
HttpClientResponse.fromWeb( HttpClientResponse.fromWeb(
@@ -53,7 +53,7 @@ test("events.subscribe terminates on Effect protocol decode failures", async ()
) )
const error = await Effect.gen(function* () { const error = await Effect.gen(function* () {
const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" }) const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" })
return yield* client.events.subscribe().pipe(Stream.runCollect, Effect.flip) return yield* client.event.subscribe().pipe(Stream.runCollect, Effect.flip)
}).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.runPromise) }).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.runPromise)
expect(error._tag).toBe("ClientError") expect(error._tag).toBe("ClientError")
@@ -112,41 +112,41 @@ test("session methods retain decoded Effect inputs and outputs", async () => {
}) })
const result = await Effect.gen(function* () { const result = await Effect.gen(function* () {
const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" }) const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" })
const page = yield* client.sessions.list({ limit: 10 }) const page = yield* client.session.list({ limit: 10 })
const active = yield* client.sessions.active() const active = yield* client.session.active()
const created = yield* client.sessions.create({ const created = yield* client.session.create({
location: Location.Ref.make({ directory: AbsolutePath.make("/tmp/project") }), location: Location.Ref.make({ directory: AbsolutePath.make("/tmp/project") }),
}) })
yield* client.sessions.switchAgent({ sessionID: Session.ID.make("ses_test"), agent: Agent.ID.make("build") }) yield* client.session.switchAgent({ sessionID: Session.ID.make("ses_test"), agent: Agent.ID.make("build") })
yield* client.sessions.switchModel({ yield* client.session.switchModel({
sessionID: Session.ID.make("ses_test"), sessionID: Session.ID.make("ses_test"),
model: Model.Ref.make({ id: "claude", providerID: "anthropic" }), model: Model.Ref.make({ id: "claude", providerID: "anthropic" }),
}) })
const admitted = yield* client.sessions.prompt({ const admitted = yield* client.session.prompt({
sessionID: Session.ID.make("ses_test"), sessionID: Session.ID.make("ses_test"),
prompt: Prompt.make({ text: "Hello" }), prompt: Prompt.make({ text: "Hello" }),
resume: false, resume: false,
}) })
yield* client.sessions.compact({ sessionID: Session.ID.make("ses_test") }) yield* client.session.compact({ sessionID: Session.ID.make("ses_test") })
yield* client.sessions.wait({ sessionID: Session.ID.make("ses_test") }) yield* client.session.wait({ sessionID: Session.ID.make("ses_test") })
const context = yield* client.sessions.context({ sessionID: Session.ID.make("ses_test") }) const context = yield* client.session.context({ sessionID: Session.ID.make("ses_test") })
const history = yield* client.sessions.history({ const history = yield* client.session.history({
sessionID: Session.ID.make("ses_test"), sessionID: Session.ID.make("ses_test"),
after: 0, after: 0,
limit: 1, limit: 1,
}) })
const historyNext = history.hasMore const historyNext = history.hasMore
? yield* client.sessions.history({ ? yield* client.session.history({
sessionID: Session.ID.make("ses_test"), sessionID: Session.ID.make("ses_test"),
after: history.data.at(-1)?.durable?.seq, after: history.data.at(-1)?.durable?.seq,
limit: 2, limit: 2,
}) })
: undefined : undefined
const events = yield* client.sessions const events = yield* client.session
.events({ sessionID: Session.ID.make("ses_test"), after: 0 }) .events({ sessionID: Session.ID.make("ses_test"), after: 0 })
.pipe(Stream.runCollect) .pipe(Stream.runCollect)
yield* client.sessions.interrupt({ sessionID: Session.ID.make("ses_test") }) yield* client.session.interrupt({ sessionID: Session.ID.make("ses_test") })
const message = yield* client.sessions.message({ const message = yield* client.session.message({
sessionID: Session.ID.make("ses_test"), sessionID: Session.ID.make("ses_test"),
messageID: SessionMessage.ID.make("msg_model"), messageID: SessionMessage.ID.make("msg_model"),
}) })
@@ -171,7 +171,7 @@ test("session methods retain decoded Effect inputs and outputs", async () => {
expect(result.message).toEqual(expect.objectContaining({ id: "msg_model", type: "model-switched" })) expect(result.message).toEqual(expect.objectContaining({ id: "msg_model", type: "model-switched" }))
}) })
test("sessions.history retains the typed SessionNotFoundError", async () => { test("session.history retains the typed SessionNotFoundError", async () => {
const httpClient = HttpClient.make((request) => const httpClient = HttpClient.make((request) =>
Effect.succeed( Effect.succeed(
HttpClientResponse.fromWeb( HttpClientResponse.fromWeb(
@@ -185,7 +185,7 @@ test("sessions.history retains the typed SessionNotFoundError", async () => {
) )
const error = await Effect.gen(function* () { const error = await Effect.gen(function* () {
const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" }) const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" })
return yield* client.sessions return yield* client.session
.history({ .history({
sessionID: Session.ID.make("ses_missing"), sessionID: Session.ID.make("ses_missing"),
}) })
+82 -46
View File
@@ -7,28 +7,28 @@ test("exposes every standard HTTP API group", () => {
expect(Object.keys(client)).toEqual([ expect(Object.keys(client)).toEqual([
"health", "health",
"location", "location",
"agents", "agent",
"sessions", "session",
"messages", "message",
"models", "model",
"generate", "generate",
"providers", "provider",
"integrations", "integration",
"credentials", "credential",
"project", "project",
"permissions", "permission",
"files", "file",
"commands", "command",
"skills", "skill",
"events", "event",
"ptys", "pty",
"server.shell", "shell",
"questions", "question",
"references", "reference",
"projectCopies", "projectCopy",
]) ])
expect(Object.keys(client.messages)).toEqual(["list"]) expect(Object.keys(client.message)).toEqual(["list"])
expect(Object.keys(client.integrations)).toEqual([ expect(Object.keys(client.integration)).toEqual([
"list", "list",
"get", "get",
"connectKey", "connectKey",
@@ -37,12 +37,13 @@ test("exposes every standard HTTP API group", () => {
"attemptComplete", "attemptComplete",
"attemptCancel", "attemptCancel",
]) ])
expect(Object.keys(client.files)).toEqual(["read", "list", "find"]) expect(Object.keys(client.file)).toEqual(["read", "list", "find"])
expect(Object.keys(client.ptys)).toEqual(["list", "create", "get", "update", "remove"]) expect(Object.keys(client.pty)).toEqual(["list", "create", "get", "update", "remove"])
expect(Object.keys(client.shell)).toEqual(["list", "create", "get", "output", "remove"])
expect(Object.keys(client.project)).toEqual(["current", "directories"]) expect(Object.keys(client.project)).toEqual(["current", "directories"])
}) })
test("files.read returns binary content from the public HTTP contract", async () => { test("file.read returns binary content from the public HTTP contract", async () => {
let request: Request | undefined let request: Request | undefined
const client = OpenCode.make({ const client = OpenCode.make({
baseUrl: "http://localhost:3000", baseUrl: "http://localhost:3000",
@@ -52,7 +53,7 @@ test("files.read returns binary content from the public HTTP contract", async ()
}, },
}) })
const content = await client.files.read({ const content = await client.file.read({
path: "src/a b#c.ts", path: "src/a b#c.ts",
location: { directory: "/tmp/project" }, location: { directory: "/tmp/project" },
}) })
@@ -89,7 +90,42 @@ test("project methods use the public HTTP contract", async () => {
]) ])
}) })
test("sessions.get returns the wire projection", async () => { test("shell list and remove use the public HTTP contract", async () => {
const requests: Array<{ method: string; url: string }> = []
const shell = {
id: "sh_test",
status: "running",
command: "pwd",
cwd: "/tmp/project",
shell: "/bin/zsh",
file: "/tmp/opencode-shell",
metadata: { sessionID: "ses_test" },
time: { started: 1_717_171_717_000 },
}
const client = OpenCode.make({
baseUrl: "http://localhost:3000",
fetch: async (input, init) => {
const request = input instanceof Request ? input : new Request(input, init)
requests.push({ method: request.method, url: request.url })
if (request.method === "DELETE") return new Response(null, { status: 204 })
return Response.json({
location: { directory: "/tmp/project", project: { id: "proj_test", directory: "/tmp/project" } },
data: [shell],
})
},
})
const result = await client.shell.list({ location: { directory: "/tmp/project" } })
await client.shell.remove({ id: shell.id })
expect(result.data).toEqual([shell])
expect(requests).toEqual([
{ method: "GET", url: "http://localhost:3000/api/shell?location%5Bdirectory%5D=%2Ftmp%2Fproject" },
{ method: "DELETE", url: "http://localhost:3000/api/shell/sh_test" },
])
})
test("session.get returns the wire projection", async () => {
const client = OpenCode.make({ const client = OpenCode.make({
baseUrl: "http://localhost:3000", baseUrl: "http://localhost:3000",
fetch: async (input) => { fetch: async (input) => {
@@ -100,12 +136,12 @@ test("sessions.get returns the wire projection", async () => {
}, },
}) })
const result = await client.sessions.get({ sessionID: "ses_test" }) const result = await client.session.get({ sessionID: "ses_test" })
expect(result.time.created).toBe(1_717_171_717_000) expect(result.time.created).toBe(1_717_171_717_000)
}) })
test("events.subscribe exposes the Promise event stream wire projection", async () => { test("event.subscribe exposes the Promise event stream wire projection", async () => {
const client = OpenCode.make({ const client = OpenCode.make({
baseUrl: "http://localhost:3000", baseUrl: "http://localhost:3000",
fetch: async () => fetch: async () =>
@@ -116,19 +152,19 @@ test("events.subscribe exposes the Promise event stream wire projection", async
), ),
}) })
const events = [] const events = []
for await (const event of client.events.subscribe()) events.push(event) for await (const event of client.event.subscribe()) events.push(event)
expect(events).toEqual([{ id: "evt_connected", type: "server.connected", data: {} }, modelSwitchedEvent]) expect(events).toEqual([{ id: "evt_connected", type: "server.connected", data: {} }, modelSwitchedEvent])
expect(events[1]?.type === "session.next.model.switched" && events[1].data.timestamp).toBe(1_717_171_717_000) expect(events[1]?.type === "session.next.model.switched" && events[1].data.timestamp).toBe(1_717_171_717_000)
}) })
test("events.subscribe terminates on malformed Promise SSE data", async () => { test("event.subscribe terminates on malformed Promise SSE data", async () => {
const client = OpenCode.make({ const client = OpenCode.make({
baseUrl: "http://localhost:3000", baseUrl: "http://localhost:3000",
fetch: async () => new Response("data: {not-json}\n\n", { headers: { "content-type": "text/event-stream" } }), fetch: async () => new Response("data: {not-json}\n\n", { headers: { "content-type": "text/event-stream" } }),
}) })
await expect(client.events.subscribe()[Symbol.asyncIterator]().next()).rejects.toMatchObject({ await expect(client.event.subscribe()[Symbol.asyncIterator]().next()).rejects.toMatchObject({
name: "ClientError", name: "ClientError",
reason: "MalformedResponse", reason: "MalformedResponse",
}) })
@@ -163,31 +199,31 @@ test("session methods use the public HTTP contract", async () => {
}, },
}) })
const page = await client.sessions.list({ limit: 10, order: "desc" }) const page = await client.session.list({ limit: 10, order: "desc" })
const active = await client.sessions.active() const active = await client.session.active()
const created = await client.sessions.create({ location: { directory: "/tmp/project" } }) const created = await client.session.create({ location: { directory: "/tmp/project" } })
await client.sessions.switchAgent({ sessionID: "ses_test", agent: "build" }) await client.session.switchAgent({ sessionID: "ses_test", agent: "build" })
await client.sessions.switchModel({ await client.session.switchModel({
sessionID: "ses_test", sessionID: "ses_test",
model: { id: "claude", providerID: "anthropic" }, model: { id: "claude", providerID: "anthropic" },
}) })
const admitted = await client.sessions.prompt({ const admitted = await client.session.prompt({
sessionID: "ses_test", sessionID: "ses_test",
prompt: { text: "Hello" }, prompt: { text: "Hello" },
resume: false, resume: false,
}) })
await client.sessions.compact({ sessionID: "ses_test" }) await client.session.compact({ sessionID: "ses_test" })
await client.sessions.wait({ sessionID: "ses_test" }) await client.session.wait({ sessionID: "ses_test" })
const context = await client.sessions.context({ sessionID: "ses_test" }) const context = await client.session.context({ sessionID: "ses_test" })
const history = await client.sessions.history({ sessionID: "ses_test", after: 0, limit: 1 }) const history = await client.session.history({ sessionID: "ses_test", after: 0, limit: 1 })
const historyAfter = history.data.at(-1)?.durable?.seq const historyAfter = history.data.at(-1)?.durable?.seq
const historyNext = history.hasMore const historyNext = history.hasMore
? await client.sessions.history({ sessionID: "ses_test", after: historyAfter, limit: 2 }) ? await client.session.history({ sessionID: "ses_test", after: historyAfter, limit: 2 })
: undefined : undefined
const events = [] const events = []
for await (const event of client.sessions.events({ sessionID: "ses_test", after: 0 })) events.push(event) for await (const event of client.session.events({ sessionID: "ses_test", after: 0 })) events.push(event)
await client.sessions.interrupt({ sessionID: "ses_test" }) await client.session.interrupt({ sessionID: "ses_test" })
const message = await client.sessions.message({ sessionID: "ses_test", messageID: "msg_model" }) const message = await client.session.message({ sessionID: "ses_test", messageID: "msg_model" })
expect(page.cursor.next).toBe("next") expect(page.cursor.next).toBe("next")
expect(active).toEqual({ ses_test: { type: "running" } }) expect(active).toEqual({ ses_test: { type: "running" } })
@@ -230,14 +266,14 @@ test("middleware errors remain declared client errors", async () => {
}) })
try { try {
await client.sessions.create({}) await client.session.create({})
throw new Error("Expected request to fail") throw new Error("Expected request to fail")
} catch (error) { } catch (error) {
expect(isUnauthorizedError(error)).toBe(true) expect(isUnauthorizedError(error)).toBe(true)
} }
}) })
test("sessions.history decodes SessionNotFoundError", async () => { test("session.history decodes SessionNotFoundError", async () => {
const client = OpenCode.make({ const client = OpenCode.make({
baseUrl: "http://localhost:3000", baseUrl: "http://localhost:3000",
fetch: async () => fetch: async () =>
@@ -248,7 +284,7 @@ test("sessions.history decodes SessionNotFoundError", async () => {
}) })
try { try {
await client.sessions.history({ sessionID: "ses_missing" }) await client.session.history({ sessionID: "ses_missing" })
throw new Error("Expected request to fail") throw new Error("Expected request to fail")
} catch (error) { } catch (error) {
expect(isSessionNotFoundError(error)).toBe(true) expect(isSessionNotFoundError(error)).toBe(true)
@@ -1,5 +1,5 @@
import { TextAttributes } from "@opentui/core" import { TextAttributes } from "@opentui/core"
import type { IntegrationsConnectOauthOutput } from "@opencode-ai/client" import type { IntegrationConnectOauthOutput } from "@opencode-ai/client"
import type { ConnectionInfo, IntegrationInfo, IntegrationOAuthMethod } from "@opencode-ai/sdk/v2" import type { ConnectionInfo, IntegrationInfo, IntegrationOAuthMethod } from "@opencode-ai/sdk/v2"
import { createMemo, createSignal, onCleanup, onMount, Show } from "solid-js" import { createMemo, createSignal, onCleanup, onMount, Show } from "solid-js"
import { useClipboard } from "../context/clipboard" import { useClipboard } from "../context/clipboard"
@@ -23,7 +23,7 @@ const INTEGRATION_PRIORITY: Record<string, number> = {
} }
type ConnectMethod = Exclude<IntegrationInfo["methods"][number], { type: "env" }> type ConnectMethod = Exclude<IntegrationInfo["methods"][number], { type: "env" }>
type IntegrationAttempt = IntegrationsConnectOauthOutput["data"] type IntegrationAttempt = IntegrationConnectOauthOutput["data"]
export function integrationOptions(list: IntegrationInfo[]) { export function integrationOptions(list: IntegrationInfo[]) {
return list.toSorted( return list.toSorted(
@@ -111,7 +111,7 @@ function manageConnections(
title: `Disconnect ${connection.label}`, title: `Disconnect ${connection.label}`,
value: connection.id, value: connection.id,
onSelect: () => { onSelect: () => {
void sdk.api.credentials void sdk.api.credential
.remove({ credentialID: connection.id, location: location(data) }) .remove({ credentialID: connection.id, location: location(data) })
.then(() => disconnected(integration.name, data, dialog, toast)) .then(() => disconnected(integration.name, data, dialog, toast))
.catch(toast.error) .catch(toast.error)
@@ -159,7 +159,7 @@ function KeyMethod(props: { integration: IntegrationInfo; method: Extract<Connec
placeholder="API key" placeholder="API key"
onConfirm={(key) => { onConfirm={(key) => {
if (!key) return if (!key) return
void sdk.api.integrations void sdk.api.integration
.connectKey({ .connectKey({
integrationID: props.integration.id, integrationID: props.integration.id,
location: location(data), location: location(data),
@@ -194,7 +194,7 @@ function OAuthStarting(props: {
const toast = useToast() const toast = useToast()
onMount(() => { onMount(() => {
void sdk.api.integrations void sdk.api.integration
.connectOauth({ .connectOauth({
integrationID: props.integration.id, integrationID: props.integration.id,
location: location(data), location: location(data),
@@ -248,7 +248,7 @@ function OAuthAuto(props: { integration: IntegrationInfo; title: string; attempt
})) }))
const poll = () => { const poll = () => {
void sdk.api.integrations void sdk.api.integration
.attemptStatus({ attemptID: props.attempt.attemptID, location: location(data) }) .attemptStatus({ attemptID: props.attempt.attemptID, location: location(data) })
.then((result) => { .then((result) => {
const status = result.data const status = result.data
@@ -275,7 +275,7 @@ function OAuthAuto(props: { integration: IntegrationInfo; title: string; attempt
onCleanup(() => { onCleanup(() => {
if (timer) clearTimeout(timer) if (timer) clearTimeout(timer)
if (settled) return if (settled) return
void sdk.api.integrations.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) }) void sdk.api.integration.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) })
}) })
return ( return (
@@ -300,7 +300,7 @@ function OAuthCode(props: { integration: IntegrationInfo; title: string; attempt
onCleanup(() => { onCleanup(() => {
if (settled) return if (settled) return
void sdk.api.integrations.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) }) void sdk.api.integration.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) })
}) })
return ( return (
@@ -309,7 +309,7 @@ function OAuthCode(props: { integration: IntegrationInfo; title: string; attempt
placeholder="Authorization code" placeholder="Authorization code"
onConfirm={(code) => { onConfirm={(code) => {
if (!code) return if (!code) return
void sdk.api.integrations void sdk.api.integration
.attemptComplete({ attemptID: props.attempt.attemptID, location: location(data), code }) .attemptComplete({ attemptID: props.attempt.attemptID, location: location(data), code })
.then(() => { .then(() => {
settled = true settled = true
@@ -77,7 +77,7 @@ export function DialogMoveSession(props: DialogMoveSessionProps) {
async (projectID, info): Promise<ReadonlyArray<ProjectDirectory> | undefined> => { async (projectID, info): Promise<ReadonlyArray<ProjectDirectory> | undefined> => {
try { try {
const location = { directory: projectContext.instance.directory() || paths.cwd } const location = { directory: projectContext.instance.directory() || paths.cwd }
await sdk.api.projectCopies.refresh({ await sdk.api.projectCopy.refresh({
projectID, projectID,
location, location,
}) })
@@ -227,7 +227,7 @@ export function DialogMoveSession(props: DialogMoveSessionProps) {
setToDelete(undefined) setToDelete(undefined)
setRemoving(selected.directory) setRemoving(selected.directory)
setWorking(true) setWorking(true)
const error = await sdk.api.projectCopies const error = await sdk.api.projectCopy
.remove({ .remove({
projectID: props.projectID, projectID: props.projectID,
location: { directory: projectContext.instance.directory() || paths.cwd }, location: { directory: projectContext.instance.directory() || paths.cwd },
@@ -252,7 +252,7 @@ export function DialogMoveSession(props: DialogMoveSessionProps) {
return return
} }
reopen(selected.directory) reopen(selected.directory)
const forcedError = await sdk.api.projectCopies const forcedError = await sdk.api.projectCopy
.remove({ .remove({
projectID: props.projectID, projectID: props.projectID,
location: { directory: projectContext.instance.directory() || paths.cwd }, location: { directory: projectContext.instance.directory() || paths.cwd },
@@ -32,7 +32,7 @@ export function DialogSessionList() {
const [searchResults] = createResource(search, async (query) => { const [searchResults] = createResource(search, async (query) => {
if (!query) return if (!query) return
const location = data.location.default() const location = data.location.default()
const response = await sdk.api.sessions.list({ const response = await sdk.api.session.list({
search: query, search: query,
limit: 50, limit: 50,
order: "desc", order: "desc",
@@ -17,7 +17,7 @@ export function DialogSessionRename(props: { sessionID: string; currentTitle?: s
onConfirm={(value) => { onConfirm={(value) => {
const title = value.trim() const title = value.trim()
if (!title) return if (!title) return
void sdk.api.sessions void sdk.api.session
.rename({ sessionID: props.sessionID, title }) .rename({ sessionID: props.sessionID, title })
.then(() => dialog.clear()) .then(() => dialog.clear())
.catch((error) => .catch((error) =>
+1 -1
View File
@@ -17,7 +17,7 @@ export function DialogTag(props: { onSelect?: (value: string) => void }) {
const [files] = createResource( const [files] = createResource(
() => [store.filter], () => [store.filter],
async () => { async () => {
const result = await sdk.api.files const result = await sdk.api.file
.find({ .find({
query: store.filter, query: store.filter,
type: "file", type: "file",
@@ -320,7 +320,7 @@ export function Autocomplete(props: {
if (referenceMatch()) return [] if (referenceMatch()) return []
const { lineRange, baseQuery } = extractLineRange(input.query ?? "") const { lineRange, baseQuery } = extractLineRange(input.query ?? "")
const result = await sdk.api.files const result = await sdk.api.file
.find({ .find({
query: baseQuery, query: baseQuery,
limit: 20, limit: 20,
+6 -6
View File
@@ -425,7 +425,7 @@ export function Prompt(props: PromptProps) {
}, 5000) }, 5000)
if (store.interrupt >= 2) { if (store.interrupt >= 2) {
void sdk.api.sessions.interrupt({ void sdk.api.session.interrupt({
sessionID: props.sessionID, sessionID: props.sessionID,
}) })
setStore("interrupt", 0) setStore("interrupt", 0)
@@ -1012,7 +1012,7 @@ export function Prompt(props: PromptProps) {
finishMoveProgress = Boolean(move.progress()) finishMoveProgress = Boolean(move.progress())
const location = data.location.default() const location = data.location.default()
const created = await sdk.api.sessions const created = await sdk.api.session
.create({ .create({
location: directory location: directory
? { directory, workspaceID } ? { directory, workspaceID }
@@ -1114,20 +1114,20 @@ export function Prompt(props: PromptProps) {
session = data.session.get(sessionID) session = data.session.get(sessionID)
} }
if (session?.agent !== agent.id) { if (session?.agent !== agent.id) {
await sdk.api.sessions.switchAgent({ sessionID, agent: agent.id }) await sdk.api.session.switchAgent({ sessionID, agent: agent.id })
} }
if ( if (
session?.model?.providerID !== selectedModel.providerID || session?.model?.providerID !== selectedModel.providerID ||
session.model.id !== selectedModel.modelID || session.model.id !== selectedModel.modelID ||
session.model.variant !== variant session.model.variant !== variant
) { ) {
await sdk.api.sessions.switchModel({ await sdk.api.session.switchModel({
sessionID, sessionID,
model: { providerID: selectedModel.providerID, id: selectedModel.modelID, variant }, model: { providerID: selectedModel.providerID, id: selectedModel.modelID, variant },
}) })
} }
if (session?.revert) { if (session?.revert) {
const error = await sdk.api.sessions.commit({ sessionID }).then( const error = await sdk.api.session.commit({ sessionID }).then(
() => undefined, () => undefined,
(error) => error, (error) => error,
) )
@@ -1136,7 +1136,7 @@ export function Prompt(props: PromptProps) {
return false return false
} }
} }
const error = await sdk.api.sessions const error = await sdk.api.session
.prompt({ .prompt({
sessionID, sessionID,
prompt: { prompt: {
+1 -1
View File
@@ -37,7 +37,7 @@ export function usePromptMove(input: { projectID: () => string | undefined; sess
{ projectID, context }, { projectID, context },
{ throwOnError: true }, { throwOnError: true },
) )
const result = await sdk.api.projectCopies.create({ const result = await sdk.api.projectCopy.create({
projectID, projectID,
location: { directory: project.instance.directory() || paths.cwd }, location: { directory: project.instance.directory() || paths.cwd },
strategy: "git_worktree", strategy: "git_worktree",
+17 -17
View File
@@ -554,7 +554,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.session.status[sessionID] ?? "idle" return store.session.status[sessionID] ?? "idle"
}, },
async refresh(sessionID: string) { async refresh(sessionID: string) {
setStore("session", "info", sessionID, mutable(await sdk.api.sessions.get({ sessionID }))) setStore("session", "info", sessionID, mutable(await sdk.api.session.get({ sessionID })))
}, },
message: { message: {
ids(sessionID: string) { ids(sessionID: string) {
@@ -572,7 +572,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
setStore("session", "message", sessionID, []) setStore("session", "message", sessionID, [])
messageIndex.set(sessionID, new Map()) messageIndex.set(sessionID, new Map())
const loaded = mutable( const loaded = mutable(
(await sdk.api.messages.list({ sessionID, limit: 200, order: "desc" })).data, (await sdk.api.message.list({ sessionID, limit: 200, order: "desc" })).data,
).toReversed() ).toReversed()
const live = store.session.message[sessionID] ?? [] const live = store.session.message[sessionID] ?? []
const liveByID = new Map(live.map((message) => [message.id, message])) const liveByID = new Map(live.map((message) => [message.id, message]))
@@ -588,7 +588,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.session.permission[sessionID] return store.session.permission[sessionID]
}, },
async refresh(sessionID: string) { async refresh(sessionID: string) {
setStore("session", "permission", sessionID, mutable(await sdk.api.permissions.list({ sessionID }))) setStore("session", "permission", sessionID, mutable(await sdk.api.permission.list({ sessionID })))
}, },
}, },
question: { question: {
@@ -596,7 +596,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.session.question[sessionID] return store.session.question[sessionID]
}, },
async refresh(sessionID: string) { async refresh(sessionID: string) {
setStore("session", "question", sessionID, mutable(await sdk.api.questions.list({ sessionID }))) setStore("session", "question", sessionID, mutable(await sdk.api.question.list({ sessionID })))
}, },
}, },
}, },
@@ -606,7 +606,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.project.permission[projectID] return store.project.permission[projectID]
}, },
async refresh(projectID: string) { async refresh(projectID: string) {
setStore("project", "permission", projectID, mutable(await sdk.api.permissions.listSaved({ projectID }))) setStore("project", "permission", projectID, mutable(await sdk.api.permission.listSaved({ projectID })))
}, },
}, },
}, },
@@ -618,16 +618,16 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.shell[id] return store.shell[id]
}, },
async refresh(ref?: LocationRef) { async refresh(ref?: LocationRef) {
const result = await sdk.client.v2.shell.list({ location: locationQuery(ref) }, { throwOnError: true }) const result = await sdk.api.shell.list({ location: locationQuery(ref) })
setStore( setStore(
"shell", "shell",
produce((draft) => { produce((draft) => {
for (const info of result.data.data) draft[info.id] = info for (const info of mutable(result.data)) draft[info.id] = info
}), }),
) )
}, },
async remove(id: string) { async remove(id: string) {
await sdk.client.v2.shell.remove({ id }, { throwOnError: true }) await sdk.api.shell.remove({ id })
setStore("shell", id, undefined!) setStore("shell", id, undefined!)
}, },
}, },
@@ -646,7 +646,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.location[locationKey(location ?? defaultLocation())]?.agent return store.location[locationKey(location ?? defaultLocation())]?.agent
}, },
async refresh(ref?: LocationRef) { async refresh(ref?: LocationRef) {
const result = await sdk.api.agents.list({ location: locationQuery(ref ?? defaultLocation()) }) const result = await sdk.api.agent.list({ location: locationQuery(ref ?? defaultLocation()) })
const key = locationKey(result.location) const key = locationKey(result.location)
setStore("location", key, { ...store.location[key], agent: mutable(result.data) }) setStore("location", key, { ...store.location[key], agent: mutable(result.data) })
}, },
@@ -656,7 +656,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.location[locationKey(location ?? defaultLocation())]?.command return store.location[locationKey(location ?? defaultLocation())]?.command
}, },
async refresh(ref?: LocationRef) { async refresh(ref?: LocationRef) {
const result = await sdk.api.commands.list({ location: locationQuery(ref ?? defaultLocation()) }) const result = await sdk.api.command.list({ location: locationQuery(ref ?? defaultLocation()) })
const key = locationKey(result.location) const key = locationKey(result.location)
setStore("location", key, { ...store.location[key], command: mutable(result.data) }) setStore("location", key, { ...store.location[key], command: mutable(result.data) })
}, },
@@ -666,7 +666,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.location[locationKey(location ?? defaultLocation())]?.integration return store.location[locationKey(location ?? defaultLocation())]?.integration
}, },
async refresh(ref?: LocationRef) { async refresh(ref?: LocationRef) {
const result = await sdk.api.integrations.list({ location: locationQuery(ref ?? defaultLocation()) }) const result = await sdk.api.integration.list({ location: locationQuery(ref ?? defaultLocation()) })
const key = locationKey(result.location) const key = locationKey(result.location)
setStore("location", key, { ...store.location[key], integration: mutable(result.data) }) setStore("location", key, { ...store.location[key], integration: mutable(result.data) })
}, },
@@ -676,7 +676,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.location[locationKey(location ?? defaultLocation())]?.model return store.location[locationKey(location ?? defaultLocation())]?.model
}, },
async refresh(ref?: LocationRef) { async refresh(ref?: LocationRef) {
const result = await sdk.api.models.list({ location: locationQuery(ref ?? defaultLocation()) }) const result = await sdk.api.model.list({ location: locationQuery(ref ?? defaultLocation()) })
const key = locationKey(result.location) const key = locationKey(result.location)
setStore("location", key, { ...store.location[key], model: mutable(result.data) }) setStore("location", key, { ...store.location[key], model: mutable(result.data) })
}, },
@@ -686,7 +686,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.location[locationKey(location ?? defaultLocation())]?.provider return store.location[locationKey(location ?? defaultLocation())]?.provider
}, },
async refresh(ref?: LocationRef) { async refresh(ref?: LocationRef) {
const result = await sdk.api.providers.list({ location: locationQuery(ref ?? defaultLocation()) }) const result = await sdk.api.provider.list({ location: locationQuery(ref ?? defaultLocation()) })
const key = locationKey(result.location) const key = locationKey(result.location)
setStore("location", key, { ...store.location[key], provider: mutable(result.data) }) setStore("location", key, { ...store.location[key], provider: mutable(result.data) })
}, },
@@ -696,7 +696,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.location[locationKey(location ?? defaultLocation())]?.reference return store.location[locationKey(location ?? defaultLocation())]?.reference
}, },
async refresh(ref?: LocationRef) { async refresh(ref?: LocationRef) {
const result = await sdk.api.references.list({ location: locationQuery(ref ?? defaultLocation()) }) const result = await sdk.api.reference.list({ location: locationQuery(ref ?? defaultLocation()) })
const key = locationKey(result.location) const key = locationKey(result.location)
setStore("location", key, { ...store.location[key], reference: mutable(result.data) }) setStore("location", key, { ...store.location[key], reference: mutable(result.data) })
}, },
@@ -706,7 +706,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.location[locationKey(location ?? defaultLocation())]?.skill return store.location[locationKey(location ?? defaultLocation())]?.skill
}, },
async refresh(ref?: LocationRef) { async refresh(ref?: LocationRef) {
const result = await sdk.api.skills.list({ location: locationQuery(ref ?? defaultLocation()) }) const result = await sdk.api.skill.list({ location: locationQuery(ref ?? defaultLocation()) })
const key = locationKey(result.location) const key = locationKey(result.location)
setStore("location", key, { ...store.location[key], skill: mutable(result.data) }) setStore("location", key, { ...store.location[key], skill: mutable(result.data) })
}, },
@@ -716,7 +716,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
async function bootstrap() { async function bootstrap() {
const settled = await Promise.allSettled([ const settled = await Promise.allSettled([
sdk.api.sessions sdk.api.session
.list({ .list({
limit: 50, limit: 50,
order: "desc", order: "desc",
@@ -732,7 +732,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
}), }),
), ),
), ),
sdk.api.sessions sdk.api.session
.active() .active()
.then((active) => .then((active) =>
setStore( setStore(
@@ -22,7 +22,7 @@ export function DialogMessage(props: { messageID: string; sessionID: string; set
value: "session.revert", value: "session.revert",
description: "undo messages and file changes", description: "undo messages and file changes",
onSelect: async (dialog) => { onSelect: async (dialog) => {
await sdk.api.sessions await sdk.api.session
.stage({ sessionID: props.sessionID, messageID: props.messageID }) .stage({ sessionID: props.sessionID, messageID: props.messageID })
.catch((error) => toast.show({ message: errorMessage(error), variant: "error", duration: 5000 })) .catch((error) => toast.show({ message: errorMessage(error), variant: "error", duration: 5000 }))
dialog.clear() dialog.clear()
+11 -8
View File
@@ -369,7 +369,7 @@ export function Session() {
aliases: ["summarize"], aliases: ["summarize"],
}, },
run: () => { run: () => {
void sdk.api.sessions.compact({ sessionID: route.sessionID }) void sdk.api.session.compact({ sessionID: route.sessionID })
dialog.clear() dialog.clear()
}, },
}, },
@@ -403,7 +403,7 @@ export function Session() {
dialog.clear() dialog.clear()
return return
} }
const error = await sdk.api.sessions.stage({ sessionID: route.sessionID, messageID: target }).then( const error = await sdk.api.session.stage({ sessionID: route.sessionID, messageID: target }).then(
() => undefined, () => undefined,
(error) => error, (error) => error,
) )
@@ -420,7 +420,7 @@ export function Session() {
slash: { name: "redo" }, slash: { name: "redo" },
run: () => { run: () => {
void (async () => { void (async () => {
const error = await sdk.api.sessions.clear({ sessionID: route.sessionID }).then( const error = await sdk.api.session.clear({ sessionID: route.sessionID }).then(
() => undefined, () => undefined,
(error) => error, (error) => error,
) )
@@ -843,7 +843,12 @@ export function Session() {
// snap to bottom when session changes // snap to bottom when session changes
createEffect(on(() => route.sessionID, toBottom)) createEffect(on(() => route.sessionID, toBottom))
createEffect(on(() => route.sessionID, () => setComposer("open", false))) createEffect(
on(
() => route.sessionID,
() => setComposer("open", false),
),
)
return ( return (
<LocationProvider location={location()}> <LocationProvider location={location()}>
@@ -913,9 +918,7 @@ export function Session() {
onClose={() => setComposer("open", false)} onClose={() => setComposer("open", false)}
/> />
<Switch> <Switch>
<Match when={composer.open || !!session()?.parentID}> <Match when={composer.open || !!session()?.parentID}>{null}</Match>
{null}
</Match>
<Match when={permissions().length > 0}> <Match when={permissions().length > 0}>
<PermissionPrompt request={permissions()[0]} directory={session()?.location.directory} /> <PermissionPrompt request={permissions()[0]} directory={session()?.location.directory} />
</Match> </Match>
@@ -1230,7 +1233,7 @@ function RevertMessage(props: {
onMouseUp={() => { onMouseUp={() => {
if (renderer.getSelection()?.getSelectedText()) return if (renderer.getSelection()?.getSelectedText()) return
void (async () => { void (async () => {
const error = await sdk.api.sessions.clear({ sessionID: route.sessionID }).then( const error = await sdk.api.session.clear({ sessionID: route.sessionID }).then(
() => undefined, () => undefined,
(error) => error, (error) => error,
) )
@@ -186,7 +186,7 @@ export function PermissionPrompt(props: { request: PermissionV2Request; director
onSelect={(option) => { onSelect={(option) => {
setStore("stage", "permission") setStore("stage", "permission")
if (option === "cancel") return if (option === "cancel") return
void sdk.api.permissions.reply({ void sdk.api.permission.reply({
sessionID: props.request.sessionID, sessionID: props.request.sessionID,
reply: "always", reply: "always",
requestID: props.request.id, requestID: props.request.id,
@@ -197,7 +197,7 @@ export function PermissionPrompt(props: { request: PermissionV2Request; director
<Match when={store.stage === "reject"}> <Match when={store.stage === "reject"}>
<RejectPrompt <RejectPrompt
onConfirm={(message) => { onConfirm={(message) => {
void sdk.api.permissions.reply({ void sdk.api.permission.reply({
sessionID: props.request.sessionID, sessionID: props.request.sessionID,
reply: "reject", reply: "reject",
requestID: props.request.id, requestID: props.request.id,
@@ -443,14 +443,14 @@ export function PermissionPrompt(props: { request: PermissionV2Request; director
setStore("stage", "reject") setStore("stage", "reject")
return return
} }
void sdk.api.permissions.reply({ void sdk.api.permission.reply({
sessionID: props.request.sessionID, sessionID: props.request.sessionID,
reply: "reject", reply: "reject",
requestID: props.request.id, requestID: props.request.id,
}) })
return return
} }
void sdk.api.permissions.reply({ void sdk.api.permission.reply({
sessionID: props.request.sessionID, sessionID: props.request.sessionID,
reply: "once", reply: "once",
requestID: props.request.id, requestID: props.request.id,
+3 -3
View File
@@ -47,7 +47,7 @@ export function QuestionPrompt(props: { request: QuestionV2Request; directory?:
function submit() { function submit() {
const answers = questions().map((_, i) => store.answers[i] ?? []) const answers = questions().map((_, i) => store.answers[i] ?? [])
void sdk.api.questions.reply({ void sdk.api.question.reply({
sessionID: props.request.sessionID, sessionID: props.request.sessionID,
requestID: props.request.id, requestID: props.request.id,
answers, answers,
@@ -55,7 +55,7 @@ export function QuestionPrompt(props: { request: QuestionV2Request; directory?:
} }
function reject() { function reject() {
void sdk.api.questions.reject({ void sdk.api.question.reject({
sessionID: props.request.sessionID, sessionID: props.request.sessionID,
requestID: props.request.id, requestID: props.request.id,
}) })
@@ -71,7 +71,7 @@ export function QuestionPrompt(props: { request: QuestionV2Request; directory?:
setStore("custom", inputs) setStore("custom", inputs)
} }
if (single()) { if (single()) {
void sdk.api.questions.reply({ void sdk.api.question.reply({
sessionID: props.request.sessionID, sessionID: props.request.sessionID,
requestID: props.request.id, requestID: props.request.id,
answers: [[answer]], answers: [[answer]],