mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
refactor(client): group experimental SDK methods under client.experimental (#59072)
This commit is contained in:
committed by
GitHub
Unverified
parent
fe04f0ef13
commit
9a9386edbc
@@ -169,6 +169,17 @@ const table = sqliteTable("session", {
|
||||
})
|
||||
```
|
||||
|
||||
### Experimental API
|
||||
|
||||
- An experimental endpoint lives at `/api/experimental/<group>/...`, its OpenAPI identifier is `experimental.<group>.<method>`, and it lands in the SDK as `client.experimental.<group>.<method>`. Its description says "Experimental: may change without compatibility guarantees."
|
||||
- `packages/protocol/test/experimental-identifiers.test.ts` enforces the path and identifier match in both directions; the SDK namespace follows from the path.
|
||||
- An experimental field or parameter on a stable endpoint goes under an `experimental` key (`experimental.<name>`), the same way config does (`config.experimental.*`).
|
||||
- New endpoints and new default behaviors start experimental.
|
||||
- To graduate one, move the route out of `/api/experimental`, drop the `experimental.` prefix, and note it in `CHANGELOG.md`.
|
||||
- Experimental HTTP routes change without aliases: rename or remove the route, then update the callers.
|
||||
- A breaking move of shipped SDK or plugin API (including moving it under `experimental`) keeps the old path and type names as deprecated aliases of the new ones until the next minor, each marked `@deprecated` with the replacement and "Removed in the next minor". Generated SDK moves get them from the codegen (`compile(..., { aliases: true })` in `packages/client/script/generate.ts`), not by hand.
|
||||
- Experimental plugin hooks are named `experimental.*` (`experimental.ws.handshake`).
|
||||
|
||||
## Testing
|
||||
|
||||
- Avoid mocks as much as possible, you shouldn't be using globalThis.\* at all unless it's the only option.
|
||||
|
||||
@@ -123,7 +123,7 @@ export function createHomeProjectsController(home: HomeController) {
|
||||
Schema.fromJsonString(Schema.Record(Schema.String, Schema.Json)),
|
||||
)(await file.text())
|
||||
|
||||
const api = home.server.context(conn).sdk.api.session
|
||||
const api = home.server.context(conn).sdk.api.experimental.session
|
||||
|
||||
// SAFETY: the import endpoint validates the transcript, including exports written by earlier releases.
|
||||
const imported = await api.import({
|
||||
|
||||
@@ -13,7 +13,7 @@ export type McpControls = {
|
||||
change: (name: string, enabled: boolean) => void
|
||||
}
|
||||
|
||||
export function useMcpToggle(directory?: Accessor<string | undefined>, onSuccess?: () => unknown) {
|
||||
export function useMcpToggle(directory?: Accessor<string | undefined>, onSuccess?: () => void) {
|
||||
const data = useData()
|
||||
const serverSDK = useServerSDK()
|
||||
const platform = usePlatform()
|
||||
@@ -27,19 +27,22 @@ export function useMcpToggle(directory?: Accessor<string | undefined>, onSuccess
|
||||
|
||||
return useMutation(() => ({
|
||||
mutationFn: async (input: string | { name: string; enabled: boolean; directory?: string }) => {
|
||||
const name = typeof input === "string" ? input : input.name
|
||||
const ref = typeof input !== "string" && input.directory ? { directory: input.directory } : location()
|
||||
// A bare name toggles the server; an object sets an explicit state.
|
||||
// oxlint-disable-next-line anti-slop/no-runtime-typeof -- discriminates this function's own input union
|
||||
const request: { name: string; enabled?: boolean; directory?: string } = typeof input === "string" ? { name: input } : input
|
||||
const name = request.name
|
||||
const ref = request.directory ? { directory: request.directory } : location()
|
||||
const server = (await serverSDK.api.mcp.list({ location: ref })).data.find((item) => item.name === name)
|
||||
|
||||
if (!server || (server.status.status === "pending" && typeof input === "string")) return
|
||||
const enabled = typeof input === "string" ? server.status.status !== "connected" : input.enabled
|
||||
if (!server || (server.status.status === "pending" && request.enabled === undefined)) return
|
||||
const enabled = request.enabled ?? server.status.status !== "connected"
|
||||
|
||||
if (!enabled) {
|
||||
await serverSDK.api.mcp.disconnect({ server: name, location: ref })
|
||||
await serverSDK.api.experimental.mcp.disconnect({ server: name, location: ref })
|
||||
}
|
||||
|
||||
if (enabled && server.status.status !== "needs_auth") {
|
||||
await serverSDK.api.mcp.connect({ server: name, location: ref })
|
||||
await serverSDK.api.experimental.mcp.connect({ server: name, location: ref })
|
||||
}
|
||||
|
||||
data.location.mcp.server.invalidate(ref)
|
||||
|
||||
@@ -244,6 +244,7 @@ function createServerSyncContextInner(serverSDK: ServerSDK, data: Data) {
|
||||
if (update.time.archived) return rest
|
||||
|
||||
const previous = projects.find((project) => project.id === update.id)
|
||||
|
||||
// The wire payload carries no worktrees; keep the inventory this project already loaded.
|
||||
const next = withWorktreeInventory(
|
||||
previous ? updateProjectInfo(previous, update) : normalizeProjectInfo(update),
|
||||
@@ -314,7 +315,7 @@ function createServerSyncContextInner(serverSDK: ServerSDK, data: Data) {
|
||||
const updateConfigMutation = useMutation(() => ({
|
||||
mutationFn: async (config: Config) => {
|
||||
// TODO: Restore config updates when the V2 client exposes a config API.
|
||||
// await serverSDK.api.config.update({ config })
|
||||
// await serverSDK.api.experimental.config.update({ config })
|
||||
throw new Error(`Config updates are unavailable: ${Object.keys(config).length} fields were not saved`)
|
||||
},
|
||||
onSuccess: () => {
|
||||
@@ -343,10 +344,10 @@ function createServerSyncContextInner(serverSDK: ServerSDK, data: Data) {
|
||||
await toggleMcp({
|
||||
status,
|
||||
connect: async () => {
|
||||
await serverSDK.api.mcp.connect({ server: name, location: { directory: key } })
|
||||
await serverSDK.api.experimental.mcp.connect({ server: name, location: { directory: key } })
|
||||
},
|
||||
disconnect: async () => {
|
||||
await serverSDK.api.mcp.disconnect({ server: name, location: { directory: key } })
|
||||
await serverSDK.api.experimental.mcp.disconnect({ server: name, location: { directory: key } })
|
||||
},
|
||||
authenticate: async () => {
|
||||
const server = (await serverSDK.api.mcp.list({ location: { directory: key } })).data.find(
|
||||
|
||||
@@ -88,7 +88,7 @@ export function createSessionRevert(input: {
|
||||
// Like the TUI, stop at the first failure instead of waiting on work that was never interrupted.
|
||||
if (!(await request(() => server.api.session.interrupt({ sessionID })))) return
|
||||
|
||||
if (!(await request(() => server.api.session.wait({ sessionID })))) return
|
||||
if (!(await request(() => server.api.experimental.session.wait({ sessionID })))) return
|
||||
|
||||
// Read before staging: the staged event can land before the request resolves.
|
||||
const prior = input.session.data.revertMessageID()
|
||||
|
||||
@@ -59,7 +59,7 @@ export function createServerShellController(server: Accessor<ServerConnection.An
|
||||
const previous = state.latest
|
||||
actions.mutate({ ...previous, shell: value || undefined })
|
||||
void serverCtx()
|
||||
.sdk.api.config.update({ shell: value || null })
|
||||
.sdk.api.experimental.config.update({ shell: value || null })
|
||||
.catch((error) => {
|
||||
actions.mutate(previous)
|
||||
showToast({
|
||||
|
||||
@@ -120,6 +120,7 @@ export class VoiceTools {
|
||||
|
||||
const seen = new Set<string>()
|
||||
const tabs = new Set(this.screen.tabs())
|
||||
|
||||
// Best match first; among equal matches, top-level sessions with an open tab, then the most recent.
|
||||
const rank = (session: SessionInfo) =>
|
||||
(search.score(session) ?? 0) * 4 + (session.parentID ? 0 : 2) + (tabs.has(session.id) ? 1 : 0)
|
||||
@@ -300,7 +301,7 @@ export class VoiceTools {
|
||||
|
||||
if (call.name === "read_session" || call.name === "wait_for_session") {
|
||||
if (call.name === "wait_for_session") {
|
||||
await api.session.wait({ sessionID }, { signal: AbortSignal.any([signal, AbortSignal.timeout(90_000)]) })
|
||||
await api.experimental.session.wait({ sessionID }, { signal: AbortSignal.any([signal, AbortSignal.timeout(90_000)]) })
|
||||
}
|
||||
|
||||
const [session, messages] = await Promise.all([
|
||||
|
||||
@@ -8,6 +8,13 @@ export class VoiceFailure extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
/** A client event sent over the Live data channel; the transport adds `event_id`. */
|
||||
export type VoiceClientEvent =
|
||||
| { type: "session.input_audio.mute" | "session.input_audio.unmute" | "response.create" }
|
||||
| { type: "session.update"; session: { delegation: { type: "responses"; responses: { instructions: string } } } }
|
||||
| { type: "response.item.create"; item: { type: "function_call_output"; call_id: string; output: string } }
|
||||
| { type: "session.commentary.append"; delegation_id: null; content: string }
|
||||
|
||||
export class VoiceTransport {
|
||||
readonly abort = new AbortController()
|
||||
private peer = new RTCPeerConnection({ iceServers: [], bundlePolicy: "max-bundle", rtcpMuxPolicy: "require" })
|
||||
@@ -78,7 +85,7 @@ export class VoiceTransport {
|
||||
async join(viewing: { id: string; title?: string }, tail: string) {
|
||||
const signal = AbortSignal.any([this.abort.signal, AbortSignal.timeout(35_000)])
|
||||
await this.context.resume()
|
||||
const offered = await this.inputOptions.api.voice.models({ signal })
|
||||
const offered = await this.inputOptions.api.experimental.voice.models({ signal })
|
||||
|
||||
if (
|
||||
!offered.models.some(
|
||||
@@ -106,7 +113,7 @@ export class VoiceTransport {
|
||||
})
|
||||
signal.throwIfAborted()
|
||||
|
||||
const response = await this.inputOptions.api.voice.session(
|
||||
const response = await this.inputOptions.api.experimental.voice.session(
|
||||
{
|
||||
model: "gpt-live-1",
|
||||
session: {
|
||||
@@ -153,7 +160,7 @@ export class VoiceTransport {
|
||||
this.timer = setInterval(() => this.inputOptions.levels(this.level(this.input), this.level(this.output)), 100)
|
||||
}
|
||||
|
||||
send(event: object) {
|
||||
send(event: VoiceClientEvent) {
|
||||
if (this.ended || this.channel.readyState !== "open") throw new VoiceFailure("dropped")
|
||||
this.channel.send(JSON.stringify({ event_id: crypto.randomUUID(), ...event }))
|
||||
}
|
||||
|
||||
@@ -298,14 +298,14 @@ export const { use: useFile, provider: FileProvider } = createSimpleContext({
|
||||
const file = path.normalize(input)
|
||||
|
||||
if (!file || path.absolute(file)) return
|
||||
void serverSDK.api.file.watch({ path: file, location: { directory: scope() } }).catch(() => {})
|
||||
void serverSDK.api.experimental.file.watch({ path: file, location: { directory: scope() } }).catch(() => {})
|
||||
}
|
||||
|
||||
const unwatch = (input: string) => {
|
||||
const file = path.normalize(input)
|
||||
|
||||
if (!file || path.absolute(file)) return
|
||||
void serverSDK.api.file.unwatch({ path: file, location: { directory: scope() } }).catch(() => {})
|
||||
void serverSDK.api.experimental.file.unwatch({ path: file, location: { directory: scope() } }).catch(() => {})
|
||||
}
|
||||
|
||||
createEffect(() => {
|
||||
|
||||
@@ -101,7 +101,7 @@ export const make = Effect.fnUntraced(function* (input: {
|
||||
const config = mcpConfig(server)
|
||||
if (isDeepStrictEqual(registered.get(server.name), config)) return Effect.void
|
||||
registered.set(server.name, config)
|
||||
return input.client.mcp.add({ server: server.name, location: { directory: attached.cwd }, config }).pipe(
|
||||
return input.client.experimental.mcp.add({ server: server.name, location: { directory: attached.cwd }, config }).pipe(
|
||||
Effect.catch(ACPClient.classify),
|
||||
Effect.onError(() => Effect.sync(() => registered.delete(server.name))),
|
||||
Effect.uninterruptible,
|
||||
|
||||
@@ -61,7 +61,7 @@ const findIntegration = Effect.fn("cli.auth.login.integration")(function* (clien
|
||||
if (protocol === "http:" || protocol === "https:") {
|
||||
const progress = spinner()
|
||||
progress.start("Discovering authentication provider...")
|
||||
yield* request((signal) => client.integration.wellknown.add({ url: target, location }, { signal })).pipe(
|
||||
yield* request((signal) => client.experimental.integration.wellknown.add({ url: target, location }, { signal })).pipe(
|
||||
Effect.tap(() => Effect.sync(() => progress.stop("Authentication provider discovered"))),
|
||||
Effect.tapCause(() => Effect.sync(() => progress.stop("Discovery failed", 1))),
|
||||
)
|
||||
|
||||
@@ -68,7 +68,7 @@ export default Runtime.handler(
|
||||
})
|
||||
if (!sessionID) return
|
||||
const data = yield* Effect.tryPromise({
|
||||
try: () => client.session.export({ sessionID, sanitize: input.sanitize }),
|
||||
try: () => client.experimental.session.export({ sessionID, sanitize: input.sanitize }),
|
||||
catch: (cause) => cause,
|
||||
})
|
||||
process.stdout.write(JSON.stringify(data, null, 2) + EOL)
|
||||
|
||||
@@ -29,7 +29,7 @@ const handler = Effect.fn("cli.stats")(function* (input: Runtime.Input<typeof Co
|
||||
: project
|
||||
const details = input.models || input.tools || input.cost || input.full
|
||||
const stats = yield* request(server.endpoint.url, (signal) =>
|
||||
client.session.stats(
|
||||
client.experimental.session.stats(
|
||||
{
|
||||
from: range.from,
|
||||
to: range.to,
|
||||
|
||||
@@ -758,7 +758,7 @@ export async function runNonInteractivePrompt(input: Input) {
|
||||
return
|
||||
}
|
||||
|
||||
const waiting = input.client.session.wait({ sessionID: input.sessionID })
|
||||
const waiting = input.client.experimental.session.wait({ sessionID: input.sessionID })
|
||||
await Promise.race([waiting, completed.then(() => waiting)])
|
||||
finalizing = true
|
||||
const projected = await reconcile()
|
||||
|
||||
@@ -14,11 +14,11 @@ const timeout = (error: unknown) =>
|
||||
error.cause.name === "TimeoutError"
|
||||
|
||||
await Promise.all([
|
||||
connection.sdk.session.wait({ sessionID: "ses_initial" }),
|
||||
replacement.session.wait({ sessionID: "ses_reconnected" }),
|
||||
assert.rejects(OpenCode.make({ baseUrl: endpoint.url }).session.wait({ sessionID: "ses_control" }), timeout),
|
||||
connection.sdk.experimental.session.wait({ sessionID: "ses_initial" }),
|
||||
replacement.experimental.session.wait({ sessionID: "ses_reconnected" }),
|
||||
assert.rejects(OpenCode.make({ baseUrl: endpoint.url }).experimental.session.wait({ sessionID: "ses_control" }), timeout),
|
||||
assert.rejects(
|
||||
connection.sdk.session.wait({ sessionID: "ses_cancelled" }, { signal: AbortSignal.timeout(100) }),
|
||||
connection.sdk.experimental.session.wait({ sessionID: "ses_cancelled" }, { signal: AbortSignal.timeout(100) }),
|
||||
timeout,
|
||||
),
|
||||
])
|
||||
|
||||
@@ -253,7 +253,7 @@ async function run(input: {
|
||||
)
|
||||
spyOn(sdk.session.form, "cancel").mockImplementation((request) => (input.cancel?.(request) ?? ok(undefined)) as never)
|
||||
let promptID = "msg_prompt"
|
||||
spyOn(sdk.session, "wait").mockImplementation(() => input.wait?.() ?? wait.promise)
|
||||
spyOn(sdk.experimental.session, "wait").mockImplementation(() => input.wait?.() ?? wait.promise)
|
||||
spyOn(sdk.message, "list").mockImplementation(() =>
|
||||
ok({
|
||||
data: input.messages?.(promptID) ?? [{ id: promptID, type: "user", text: "hello", time: { created: 1 } }],
|
||||
@@ -479,7 +479,7 @@ describe("runNonInteractivePrompt", () => {
|
||||
])
|
||||
expect(output.stderr).toBe("")
|
||||
const sdk = await run({ compatibility: "v1", turn: (messageID) => [prompted(messageID), settled()] })
|
||||
expect(sdk.session.wait).not.toHaveBeenCalled()
|
||||
expect(sdk.experimental.session.wait).not.toHaveBeenCalled()
|
||||
expect(sdk.message.list).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { NodeFileSystem } from "@effect/platform-node"
|
||||
import { compile, emitEffectImported, emitEffectShape, emitPromise, write } from "@opencode/httpapi-codegen"
|
||||
import { ClientApi, effectOmitEndpoints, groupNames, promiseOmitEndpoints } from "@opencode/protocol/client"
|
||||
import {
|
||||
ClientApi,
|
||||
clientNamespace,
|
||||
effectOmitEndpoints,
|
||||
groupNames,
|
||||
promiseOmitEndpoints,
|
||||
} from "@opencode/protocol/client"
|
||||
import { Agent } from "@opencode/schema/agent"
|
||||
import { Command } from "@opencode/schema/command"
|
||||
import { Config } from "@opencode/schema/config"
|
||||
@@ -44,8 +50,18 @@ import { Workspace } from "@opencode/schema/workspace"
|
||||
import { Effect, Schema } from "effect"
|
||||
import { fileURLToPath } from "url"
|
||||
|
||||
const promiseContract = compile(ClientApi, { groupNames, omitEndpoints: promiseOmitEndpoints })
|
||||
const effectContract = compile(ClientApi, { groupNames, omitEndpoints: effectOmitEndpoints })
|
||||
const promiseContract = compile(ClientApi, {
|
||||
groupNames,
|
||||
omitEndpoints: promiseOmitEndpoints,
|
||||
namespace: clientNamespace,
|
||||
aliases: true,
|
||||
})
|
||||
const effectContract = compile(ClientApi, {
|
||||
groupNames,
|
||||
omitEndpoints: effectOmitEndpoints,
|
||||
namespace: clientNamespace,
|
||||
aliases: true,
|
||||
})
|
||||
const effectTypeReferences = [
|
||||
...namespaceTypes("Agent", "@opencode/schema/agent", Agent),
|
||||
...namespaceTypes("Command", "@opencode/schema/command", Command),
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { ClientApi, effectOmitEndpoints, groupNames, promiseOmitEndpoints } from "@opencode/protocol/client"
|
||||
export { ClientApi, clientNamespace, effectOmitEndpoints, groupNames, promiseOmitEndpoints } from "@opencode/protocol/client"
|
||||
|
||||
Generated
+756
-349
File diff suppressed because it is too large
Load Diff
+421
-293
@@ -26,14 +26,8 @@ import type {
|
||||
PluginUpdateOutput,
|
||||
SessionListInput,
|
||||
SessionListOutput,
|
||||
SessionStatsInput,
|
||||
SessionStatsOutput,
|
||||
SessionCreateInput,
|
||||
SessionCreateOutput,
|
||||
SessionImportInput,
|
||||
SessionImportOutput,
|
||||
SessionExportInput,
|
||||
SessionExportOutput,
|
||||
SessionActiveOutput,
|
||||
SessionGetInput,
|
||||
SessionGetOutput,
|
||||
@@ -53,16 +47,12 @@ import type {
|
||||
SessionPromptOutput,
|
||||
SessionCommandInput,
|
||||
SessionCommandOutput,
|
||||
SessionSkillInput,
|
||||
SessionSkillOutput,
|
||||
SessionSyntheticInput,
|
||||
SessionSyntheticOutput,
|
||||
SessionShellInput,
|
||||
SessionShellOutput,
|
||||
SessionCompactInput,
|
||||
SessionCompactOutput,
|
||||
SessionWaitInput,
|
||||
SessionWaitOutput,
|
||||
SessionRevertStageInput,
|
||||
SessionRevertStageOutput,
|
||||
SessionRevertClearInput,
|
||||
@@ -79,16 +69,8 @@ import type {
|
||||
SessionInboxCancelOutput,
|
||||
SessionInboxUpdateInput,
|
||||
SessionInboxUpdateOutput,
|
||||
SessionInstructionsEntryListInput,
|
||||
SessionInstructionsEntryListOutput,
|
||||
SessionInstructionsEntryPutInput,
|
||||
SessionInstructionsEntryPutOutput,
|
||||
SessionInstructionsEntryRemoveInput,
|
||||
SessionInstructionsEntryRemoveOutput,
|
||||
SessionGenerateInput,
|
||||
SessionGenerateOutput,
|
||||
SessionLogInput,
|
||||
SessionLogOutput,
|
||||
SessionInterruptInput,
|
||||
SessionInterruptOutput,
|
||||
SessionBackgroundInput,
|
||||
@@ -109,21 +91,39 @@ import type {
|
||||
SessionEnvironmentOutput,
|
||||
SessionViewInput,
|
||||
SessionViewOutput,
|
||||
ExperimentalSessionStatsInput,
|
||||
ExperimentalSessionStatsOutput,
|
||||
ExperimentalSessionImportInput,
|
||||
ExperimentalSessionImportOutput,
|
||||
ExperimentalSessionExportInput,
|
||||
ExperimentalSessionExportOutput,
|
||||
ExperimentalSessionSkillInput,
|
||||
ExperimentalSessionSkillOutput,
|
||||
ExperimentalSessionWaitInput,
|
||||
ExperimentalSessionWaitOutput,
|
||||
ExperimentalSessionInstructionsEntryListInput,
|
||||
ExperimentalSessionInstructionsEntryListOutput,
|
||||
ExperimentalSessionInstructionsEntryPutInput,
|
||||
ExperimentalSessionInstructionsEntryPutOutput,
|
||||
ExperimentalSessionInstructionsEntryRemoveInput,
|
||||
ExperimentalSessionInstructionsEntryRemoveOutput,
|
||||
ExperimentalSessionLogInput,
|
||||
ExperimentalSessionLogOutput,
|
||||
MessageListInput,
|
||||
MessageListOutput,
|
||||
ModelListInput,
|
||||
ModelListOutput,
|
||||
ModelDefaultInput,
|
||||
ModelDefaultOutput,
|
||||
GenerateTextInput,
|
||||
GenerateTextOutput,
|
||||
GenerateImageInput,
|
||||
GenerateImageOutput,
|
||||
GenerateDecisionsInput,
|
||||
GenerateDecisionsOutput,
|
||||
VoiceModelsOutput,
|
||||
VoiceSessionInput,
|
||||
VoiceSessionOutput,
|
||||
ExperimentalGenerateTextInput,
|
||||
ExperimentalGenerateTextOutput,
|
||||
ExperimentalGenerateImageInput,
|
||||
ExperimentalGenerateImageOutput,
|
||||
ExperimentalGenerateDecisionsInput,
|
||||
ExperimentalGenerateDecisionsOutput,
|
||||
ExperimentalVoiceModelsOutput,
|
||||
ExperimentalVoiceSessionInput,
|
||||
ExperimentalVoiceSessionOutput,
|
||||
ProviderListInput,
|
||||
ProviderListOutput,
|
||||
ProviderGetInput,
|
||||
@@ -132,8 +132,6 @@ import type {
|
||||
IntegrationListOutput,
|
||||
IntegrationGetInput,
|
||||
IntegrationGetOutput,
|
||||
IntegrationWellknownAddInput,
|
||||
IntegrationWellknownAddOutput,
|
||||
IntegrationConnectKeyInput,
|
||||
IntegrationConnectKeyOutput,
|
||||
IntegrationConnectExternalInput,
|
||||
@@ -152,20 +150,22 @@ import type {
|
||||
IntegrationCommandStatusOutput,
|
||||
IntegrationCommandCancelInput,
|
||||
IntegrationCommandCancelOutput,
|
||||
ExperimentalIntegrationWellknownAddInput,
|
||||
ExperimentalIntegrationWellknownAddOutput,
|
||||
McpListInput,
|
||||
McpListOutput,
|
||||
McpAddInput,
|
||||
McpAddOutput,
|
||||
McpRemoveInput,
|
||||
McpRemoveOutput,
|
||||
McpConnectInput,
|
||||
McpConnectOutput,
|
||||
McpDisconnectInput,
|
||||
McpDisconnectOutput,
|
||||
McpResourceCatalogInput,
|
||||
McpResourceCatalogOutput,
|
||||
McpClientTokenInput,
|
||||
McpClientTokenOutput,
|
||||
ExperimentalMcpAddInput,
|
||||
ExperimentalMcpAddOutput,
|
||||
ExperimentalMcpRemoveInput,
|
||||
ExperimentalMcpRemoveOutput,
|
||||
ExperimentalMcpConnectInput,
|
||||
ExperimentalMcpConnectOutput,
|
||||
ExperimentalMcpDisconnectInput,
|
||||
ExperimentalMcpDisconnectOutput,
|
||||
ExperimentalMcpClientTokenInput,
|
||||
ExperimentalMcpClientTokenOutput,
|
||||
CredentialListOutput,
|
||||
CredentialCreateInput,
|
||||
CredentialCreateOutput,
|
||||
@@ -201,10 +201,10 @@ import type {
|
||||
FileListOutput,
|
||||
FileFindInput,
|
||||
FileFindOutput,
|
||||
FileWatchInput,
|
||||
FileWatchOutput,
|
||||
FileUnwatchInput,
|
||||
FileUnwatchOutput,
|
||||
ExperimentalFileWatchInput,
|
||||
ExperimentalFileWatchOutput,
|
||||
ExperimentalFileUnwatchInput,
|
||||
ExperimentalFileUnwatchOutput,
|
||||
CommandListInput,
|
||||
CommandListOutput,
|
||||
SkillListInput,
|
||||
@@ -280,18 +280,18 @@ import type {
|
||||
DebugLocationListOutput,
|
||||
DebugLocationEvictInput,
|
||||
DebugLocationEvictOutput,
|
||||
MigrationV1StatusOutput,
|
||||
ExperimentalMigrationV1StatusOutput,
|
||||
WebsearchProvidersInput,
|
||||
WebsearchProvidersOutput,
|
||||
WebsearchQueryInput,
|
||||
WebsearchQueryOutput,
|
||||
UsageLimitsInput,
|
||||
UsageLimitsOutput,
|
||||
ExperimentalUsageLimitsInput,
|
||||
ExperimentalUsageLimitsOutput,
|
||||
ConfigGetInput,
|
||||
ConfigGetOutput,
|
||||
ConfigShellsOutput,
|
||||
ConfigUpdateInput,
|
||||
ConfigUpdateOutput,
|
||||
ExperimentalConfigUpdateInput,
|
||||
ExperimentalConfigUpdateOutput,
|
||||
} from "../api/api.js"
|
||||
import { ClientError } from "./client-error.js"
|
||||
|
||||
@@ -418,22 +418,6 @@ const EndpointSessionList = (raw: RawClient["server.session"]) => (input?: Sessi
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointSessionStats = (raw: RawClient["server.session"]) => (input?: SessionStatsInput) =>
|
||||
preserveEffect<SessionStatsOutput>()(
|
||||
raw["session.stats"]({
|
||||
query: {
|
||||
from: input?.["from"],
|
||||
to: input?.["to"],
|
||||
project: input?.["project"],
|
||||
timezone: input?.["timezone"],
|
||||
tools: input?.["tools"],
|
||||
},
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionCreate = (raw: RawClient["server.session"]) => (input?: SessionCreateInput) =>
|
||||
preserveEffect<SessionCreateOutput>()(
|
||||
raw["session.create"]({
|
||||
@@ -453,24 +437,6 @@ const EndpointSessionCreate = (raw: RawClient["server.session"]) => (input?: Ses
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionImport = (raw: RawClient["server.session"]) => (input: SessionImportInput) =>
|
||||
preserveEffect<SessionImportOutput>()(
|
||||
raw["session.import"]({
|
||||
payload: { info: input["info"], messages: input["messages"], location: input["location"] },
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionExport = (raw: RawClient["server.session"]) => (input: SessionExportInput) =>
|
||||
preserveEffect<SessionExportOutput>()(
|
||||
raw["session.export"]({ params: { sessionID: input["sessionID"] }, query: { sanitize: input["sanitize"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionActive = (raw: RawClient["server.session"]) => () =>
|
||||
preserveEffect<SessionActiveOutput>()(
|
||||
raw["session.active"]({}).pipe(
|
||||
@@ -570,14 +536,6 @@ const EndpointSessionCommand = (raw: RawClient["server.session"]) => (input: Ses
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointSessionSkill = (raw: RawClient["server.session"]) => (input: SessionSkillInput) =>
|
||||
preserveEffect<SessionSkillOutput>()(
|
||||
raw["session.skill"]({
|
||||
params: { sessionID: input["sessionID"] },
|
||||
payload: { id: input["id"], resume: input["resume"] },
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointSessionSynthetic = (raw: RawClient["server.session"]) => (input: SessionSyntheticInput) =>
|
||||
preserveEffect<SessionSyntheticOutput>()(
|
||||
raw["session.synthetic"]({
|
||||
@@ -615,11 +573,6 @@ const EndpointSessionCompact = (raw: RawClient["server.session"]) => (input: Ses
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionWait = (raw: RawClient["server.session"]) => (input: SessionWaitInput) =>
|
||||
preserveEffect<SessionWaitOutput>()(
|
||||
raw["session.wait"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointSessionRevertStage = (raw: RawClient["server.session"]) => (input: SessionRevertStageInput) =>
|
||||
preserveEffect<SessionRevertStageOutput>()(
|
||||
raw["session.revert.stage"]({
|
||||
@@ -683,32 +636,6 @@ const EndpointSessionInboxUpdate = (raw: RawClient["server.session"]) => (input:
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointSessionInstructionsEntryList =
|
||||
(raw: RawClient["server.session"]) => (input: SessionInstructionsEntryListInput) =>
|
||||
preserveEffect<SessionInstructionsEntryListOutput>()(
|
||||
raw["session.instructions.entry.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionInstructionsEntryPut =
|
||||
(raw: RawClient["server.session"]) => (input: SessionInstructionsEntryPutInput) =>
|
||||
preserveEffect<SessionInstructionsEntryPutOutput>()(
|
||||
raw["session.instructions.entry.put"]({
|
||||
params: { sessionID: input["sessionID"], key: input["key"] },
|
||||
payload: { value: input["value"] },
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointSessionInstructionsEntryRemove =
|
||||
(raw: RawClient["server.session"]) => (input: SessionInstructionsEntryRemoveInput) =>
|
||||
preserveEffect<SessionInstructionsEntryRemoveOutput>()(
|
||||
raw["session.instructions.entry.remove"]({ params: { sessionID: input["sessionID"], key: input["key"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionGenerate = (raw: RawClient["server.session"]) => (input: SessionGenerateInput) =>
|
||||
preserveEffect<SessionGenerateOutput>()(
|
||||
raw["session.generate"]({ params: { sessionID: input["sessionID"] }, payload: { prompt: input["prompt"] } }).pipe(
|
||||
@@ -717,19 +644,6 @@ const EndpointSessionGenerate = (raw: RawClient["server.session"]) => (input: Se
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionLog = (raw: RawClient["server.session"]) => (input: SessionLogInput) =>
|
||||
preserveStream<SessionLogOutput>()(
|
||||
Stream.unwrap(
|
||||
raw["session.log"]({
|
||||
params: { sessionID: input["sessionID"] },
|
||||
query: { after: input["after"], follow: input["follow"] },
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((stream) => stream.pipe(Stream.mapError(mapClientError))),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointSessionInterrupt = (raw: RawClient["server.session"]) => (input: SessionInterruptInput) =>
|
||||
preserveEffect<SessionInterruptOutput>()(
|
||||
raw["session.interrupt"]({ params: { sessionID: input["sessionID"] }, query: { resume: input["resume"] } }).pipe(
|
||||
@@ -810,10 +724,7 @@ const EndpointSessionView = (raw: RawClient["server.session"]) => (input: Sessio
|
||||
|
||||
const adaptGroupSession = (raw: RawClient["server.session"]) => ({
|
||||
list: EndpointSessionList(raw),
|
||||
stats: EndpointSessionStats(raw),
|
||||
create: EndpointSessionCreate(raw),
|
||||
import: EndpointSessionImport(raw),
|
||||
export: EndpointSessionExport(raw),
|
||||
active: EndpointSessionActive(raw),
|
||||
get: EndpointSessionGet(raw),
|
||||
remove: EndpointSessionRemove(raw),
|
||||
@@ -824,11 +735,9 @@ const adaptGroupSession = (raw: RawClient["server.session"]) => ({
|
||||
move: EndpointSessionMove(raw),
|
||||
prompt: EndpointSessionPrompt(raw),
|
||||
command: EndpointSessionCommand(raw),
|
||||
skill: EndpointSessionSkill(raw),
|
||||
synthetic: EndpointSessionSynthetic(raw),
|
||||
shell: EndpointSessionShell(raw),
|
||||
compact: EndpointSessionCompact(raw),
|
||||
wait: EndpointSessionWait(raw),
|
||||
revert: {
|
||||
stage: EndpointSessionRevertStage(raw),
|
||||
clear: EndpointSessionRevertClear(raw),
|
||||
@@ -841,15 +750,7 @@ const adaptGroupSession = (raw: RawClient["server.session"]) => ({
|
||||
cancel: EndpointSessionInboxCancel(raw),
|
||||
update: EndpointSessionInboxUpdate(raw),
|
||||
},
|
||||
instructions: {
|
||||
entry: {
|
||||
list: EndpointSessionInstructionsEntryList(raw),
|
||||
put: EndpointSessionInstructionsEntryPut(raw),
|
||||
remove: EndpointSessionInstructionsEntryRemove(raw),
|
||||
},
|
||||
},
|
||||
generate: EndpointSessionGenerate(raw),
|
||||
log: EndpointSessionLog(raw),
|
||||
interrupt: EndpointSessionInterrupt(raw),
|
||||
background: EndpointSessionBackground(raw),
|
||||
message: { get: EndpointSessionMessageGet(raw) },
|
||||
@@ -864,6 +765,111 @@ const adaptGroupSession = (raw: RawClient["server.session"]) => ({
|
||||
view: EndpointSessionView(raw),
|
||||
})
|
||||
|
||||
const EndpointExperimentalSessionStats =
|
||||
(raw: RawClient["server.session"]) => (input?: ExperimentalSessionStatsInput) =>
|
||||
preserveEffect<ExperimentalSessionStatsOutput>()(
|
||||
raw["session.stats"]({
|
||||
query: {
|
||||
from: input?.["from"],
|
||||
to: input?.["to"],
|
||||
project: input?.["project"],
|
||||
timezone: input?.["timezone"],
|
||||
tools: input?.["tools"],
|
||||
},
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointExperimentalSessionImport =
|
||||
(raw: RawClient["server.session"]) => (input: ExperimentalSessionImportInput) =>
|
||||
preserveEffect<ExperimentalSessionImportOutput>()(
|
||||
raw["session.import"]({
|
||||
payload: { info: input["info"], messages: input["messages"], location: input["location"] },
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointExperimentalSessionExport =
|
||||
(raw: RawClient["server.session"]) => (input: ExperimentalSessionExportInput) =>
|
||||
preserveEffect<ExperimentalSessionExportOutput>()(
|
||||
raw["session.export"]({ params: { sessionID: input["sessionID"] }, query: { sanitize: input["sanitize"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointExperimentalSessionSkill = (raw: RawClient["server.session"]) => (input: ExperimentalSessionSkillInput) =>
|
||||
preserveEffect<ExperimentalSessionSkillOutput>()(
|
||||
raw["session.skill"]({
|
||||
params: { sessionID: input["sessionID"] },
|
||||
payload: { id: input["id"], resume: input["resume"] },
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointExperimentalSessionWait = (raw: RawClient["server.session"]) => (input: ExperimentalSessionWaitInput) =>
|
||||
preserveEffect<ExperimentalSessionWaitOutput>()(
|
||||
raw["session.wait"]({ params: { sessionID: input["sessionID"] } }).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointExperimentalSessionInstructionsEntryList =
|
||||
(raw: RawClient["server.session"]) => (input: ExperimentalSessionInstructionsEntryListInput) =>
|
||||
preserveEffect<ExperimentalSessionInstructionsEntryListOutput>()(
|
||||
raw["session.instructions.entry.list"]({ params: { sessionID: input["sessionID"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointExperimentalSessionInstructionsEntryPut =
|
||||
(raw: RawClient["server.session"]) => (input: ExperimentalSessionInstructionsEntryPutInput) =>
|
||||
preserveEffect<ExperimentalSessionInstructionsEntryPutOutput>()(
|
||||
raw["session.instructions.entry.put"]({
|
||||
params: { sessionID: input["sessionID"], key: input["key"] },
|
||||
payload: { value: input["value"] },
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointExperimentalSessionInstructionsEntryRemove =
|
||||
(raw: RawClient["server.session"]) => (input: ExperimentalSessionInstructionsEntryRemoveInput) =>
|
||||
preserveEffect<ExperimentalSessionInstructionsEntryRemoveOutput>()(
|
||||
raw["session.instructions.entry.remove"]({ params: { sessionID: input["sessionID"], key: input["key"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointExperimentalSessionLog = (raw: RawClient["server.session"]) => (input: ExperimentalSessionLogInput) =>
|
||||
preserveStream<ExperimentalSessionLogOutput>()(
|
||||
Stream.unwrap(
|
||||
raw["session.log"]({
|
||||
params: { sessionID: input["sessionID"] },
|
||||
query: { after: input["after"], follow: input["follow"] },
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((stream) => stream.pipe(Stream.mapError(mapClientError))),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
const adaptGroupExperimentalSession = (raw: RawClient["server.session"]) => ({
|
||||
stats: EndpointExperimentalSessionStats(raw),
|
||||
import: EndpointExperimentalSessionImport(raw),
|
||||
export: EndpointExperimentalSessionExport(raw),
|
||||
skill: EndpointExperimentalSessionSkill(raw),
|
||||
wait: EndpointExperimentalSessionWait(raw),
|
||||
instructions: {
|
||||
entry: {
|
||||
list: EndpointExperimentalSessionInstructionsEntryList(raw),
|
||||
put: EndpointExperimentalSessionInstructionsEntryPut(raw),
|
||||
remove: EndpointExperimentalSessionInstructionsEntryRemove(raw),
|
||||
},
|
||||
},
|
||||
log: EndpointExperimentalSessionLog(raw),
|
||||
})
|
||||
|
||||
const EndpointMessageList = (raw: RawClient["server.message"]) => (input: MessageListInput) =>
|
||||
preserveEffect<MessageListOutput>()(
|
||||
raw["session.messages"]({
|
||||
@@ -891,57 +897,60 @@ const adaptGroupModel = (raw: RawClient["server.model"]) => ({
|
||||
default: EndpointModelDefault(raw),
|
||||
})
|
||||
|
||||
const EndpointGenerateText = (raw: RawClient["server.generate"]) => (input: GenerateTextInput) =>
|
||||
preserveEffect<GenerateTextOutput>()(
|
||||
raw["generate.text"]({ payload: { prompt: input["prompt"], model: input["model"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
const EndpointExperimentalGenerateText =
|
||||
(raw: RawClient["server.generate"]) => (input: ExperimentalGenerateTextInput) =>
|
||||
preserveEffect<ExperimentalGenerateTextOutput>()(
|
||||
raw["generate.text"]({ payload: { prompt: input["prompt"], model: input["model"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointGenerateImage = (raw: RawClient["server.generate"]) => (input: GenerateImageInput) =>
|
||||
preserveEffect<GenerateImageOutput>()(
|
||||
raw["generate.image"]({
|
||||
payload: {
|
||||
model: input["model"],
|
||||
prompt: input["prompt"],
|
||||
images: input["images"],
|
||||
n: input["n"],
|
||||
aspect: input["aspect"],
|
||||
resolution: input["resolution"],
|
||||
},
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
const EndpointExperimentalGenerateImage =
|
||||
(raw: RawClient["server.generate"]) => (input: ExperimentalGenerateImageInput) =>
|
||||
preserveEffect<ExperimentalGenerateImageOutput>()(
|
||||
raw["generate.image"]({
|
||||
payload: {
|
||||
model: input["model"],
|
||||
prompt: input["prompt"],
|
||||
images: input["images"],
|
||||
n: input["n"],
|
||||
aspect: input["aspect"],
|
||||
resolution: input["resolution"],
|
||||
},
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointGenerateDecisions = (raw: RawClient["server.generate"]) => (input: GenerateDecisionsInput) =>
|
||||
preserveEffect<GenerateDecisionsOutput>()(
|
||||
raw["generate.decisions"]({
|
||||
payload: { model: input["model"], input: input["input"], questions: input["questions"] },
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
const EndpointExperimentalGenerateDecisions =
|
||||
(raw: RawClient["server.generate"]) => (input: ExperimentalGenerateDecisionsInput) =>
|
||||
preserveEffect<ExperimentalGenerateDecisionsOutput>()(
|
||||
raw["generate.decisions"]({
|
||||
payload: { model: input["model"], input: input["input"], questions: input["questions"] },
|
||||
}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const adaptGroupGenerate = (raw: RawClient["server.generate"]) => ({
|
||||
text: EndpointGenerateText(raw),
|
||||
image: EndpointGenerateImage(raw),
|
||||
decisions: EndpointGenerateDecisions(raw),
|
||||
const adaptGroupExperimentalGenerate = (raw: RawClient["server.generate"]) => ({
|
||||
text: EndpointExperimentalGenerateText(raw),
|
||||
image: EndpointExperimentalGenerateImage(raw),
|
||||
decisions: EndpointExperimentalGenerateDecisions(raw),
|
||||
})
|
||||
|
||||
const EndpointVoiceModels = (raw: RawClient["server.voice"]) => () =>
|
||||
preserveEffect<VoiceModelsOutput>()(
|
||||
const EndpointExperimentalVoiceModels = (raw: RawClient["server.voice"]) => () =>
|
||||
preserveEffect<ExperimentalVoiceModelsOutput>()(
|
||||
raw["voice.models"]({}).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
Effect.map((value) => value.data),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointVoiceSession = (raw: RawClient["server.voice"]) => (input: VoiceSessionInput) =>
|
||||
preserveEffect<VoiceSessionOutput>()(
|
||||
const EndpointExperimentalVoiceSession = (raw: RawClient["server.voice"]) => (input: ExperimentalVoiceSessionInput) =>
|
||||
preserveEffect<ExperimentalVoiceSessionOutput>()(
|
||||
raw["voice.session"]({
|
||||
payload: { model: input["model"], session: input["session"], transport: input["transport"] },
|
||||
}).pipe(
|
||||
@@ -950,9 +959,9 @@ const EndpointVoiceSession = (raw: RawClient["server.voice"]) => (input: VoiceSe
|
||||
),
|
||||
)
|
||||
|
||||
const adaptGroupVoice = (raw: RawClient["server.voice"]) => ({
|
||||
models: EndpointVoiceModels(raw),
|
||||
session: EndpointVoiceSession(raw),
|
||||
const adaptGroupExperimentalVoice = (raw: RawClient["server.voice"]) => ({
|
||||
models: EndpointExperimentalVoiceModels(raw),
|
||||
session: EndpointExperimentalVoiceSession(raw),
|
||||
})
|
||||
|
||||
const EndpointProviderList = (raw: RawClient["server.provider"]) => (input?: ProviderListInput) =>
|
||||
@@ -985,14 +994,6 @@ const EndpointIntegrationGet = (raw: RawClient["server.integration"]) => (input:
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointIntegrationWellknownAdd =
|
||||
(raw: RawClient["server.integration"]) => (input: IntegrationWellknownAddInput) =>
|
||||
preserveEffect<IntegrationWellknownAddOutput>()(
|
||||
raw["integration.wellknown.add"]({ query: { location: input["location"] }, payload: { url: input["url"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointIntegrationConnectKey = (raw: RawClient["server.integration"]) => (input: IntegrationConnectKeyInput) =>
|
||||
preserveEffect<IntegrationConnectKeyOutput>()(
|
||||
raw["integration.connect.key"]({
|
||||
@@ -1079,7 +1080,6 @@ const EndpointIntegrationCommandCancel =
|
||||
const adaptGroupIntegration = (raw: RawClient["server.integration"]) => ({
|
||||
list: EndpointIntegrationList(raw),
|
||||
get: EndpointIntegrationGet(raw),
|
||||
wellknown: { add: EndpointIntegrationWellknownAdd(raw) },
|
||||
connect: { key: EndpointIntegrationConnectKey(raw), external: EndpointIntegrationConnectExternal(raw) },
|
||||
oauth: {
|
||||
connect: EndpointIntegrationOauthConnect(raw),
|
||||
@@ -1094,62 +1094,77 @@ const adaptGroupIntegration = (raw: RawClient["server.integration"]) => ({
|
||||
},
|
||||
})
|
||||
|
||||
const EndpointExperimentalIntegrationWellknownAdd =
|
||||
(raw: RawClient["server.integration"]) => (input: ExperimentalIntegrationWellknownAddInput) =>
|
||||
preserveEffect<ExperimentalIntegrationWellknownAddOutput>()(
|
||||
raw["integration.wellknown.add"]({ query: { location: input["location"] }, payload: { url: input["url"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const adaptGroupExperimentalIntegration = (raw: RawClient["server.integration"]) => ({
|
||||
wellknown: { add: EndpointExperimentalIntegrationWellknownAdd(raw) },
|
||||
})
|
||||
|
||||
const EndpointMcpList = (raw: RawClient["server.mcp"]) => (input?: McpListInput) =>
|
||||
preserveEffect<McpListOutput>()(
|
||||
raw["mcp.list"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointMcpAdd = (raw: RawClient["server.mcp"]) => (input: McpAddInput) =>
|
||||
preserveEffect<McpAddOutput>()(
|
||||
raw["mcp.add"]({
|
||||
params: { server: input["server"] },
|
||||
query: { location: input["location"] },
|
||||
payload: { config: input["config"] },
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointMcpRemove = (raw: RawClient["server.mcp"]) => (input: McpRemoveInput) =>
|
||||
preserveEffect<McpRemoveOutput>()(
|
||||
raw["mcp.remove"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointMcpConnect = (raw: RawClient["server.mcp"]) => (input: McpConnectInput) =>
|
||||
preserveEffect<McpConnectOutput>()(
|
||||
raw["mcp.connect"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointMcpDisconnect = (raw: RawClient["server.mcp"]) => (input: McpDisconnectInput) =>
|
||||
preserveEffect<McpDisconnectOutput>()(
|
||||
raw["mcp.disconnect"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointMcpResourceCatalog = (raw: RawClient["server.mcp"]) => (input?: McpResourceCatalogInput) =>
|
||||
preserveEffect<McpResourceCatalogOutput>()(
|
||||
raw["mcp.resource.catalog"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointMcpClientToken = (raw: RawClient["server.mcp"]) => (input: McpClientTokenInput) =>
|
||||
preserveEffect<McpClientTokenOutput>()(
|
||||
const adaptGroupMcp = (raw: RawClient["server.mcp"]) => ({
|
||||
list: EndpointMcpList(raw),
|
||||
resource: { catalog: EndpointMcpResourceCatalog(raw) },
|
||||
})
|
||||
|
||||
const EndpointExperimentalMcpAdd = (raw: RawClient["server.mcp"]) => (input: ExperimentalMcpAddInput) =>
|
||||
preserveEffect<ExperimentalMcpAddOutput>()(
|
||||
raw["mcp.add"]({
|
||||
params: { server: input["server"] },
|
||||
query: { location: input["location"] },
|
||||
payload: { config: input["config"] },
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointExperimentalMcpRemove = (raw: RawClient["server.mcp"]) => (input: ExperimentalMcpRemoveInput) =>
|
||||
preserveEffect<ExperimentalMcpRemoveOutput>()(
|
||||
raw["mcp.remove"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointExperimentalMcpConnect = (raw: RawClient["server.mcp"]) => (input: ExperimentalMcpConnectInput) =>
|
||||
preserveEffect<ExperimentalMcpConnectOutput>()(
|
||||
raw["mcp.connect"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointExperimentalMcpDisconnect = (raw: RawClient["server.mcp"]) => (input: ExperimentalMcpDisconnectInput) =>
|
||||
preserveEffect<ExperimentalMcpDisconnectOutput>()(
|
||||
raw["mcp.disconnect"]({ params: { server: input["server"] }, query: { location: input["location"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointExperimentalMcpClientToken = (raw: RawClient["server.mcp"]) => (input: ExperimentalMcpClientTokenInput) =>
|
||||
preserveEffect<ExperimentalMcpClientTokenOutput>()(
|
||||
raw["mcp.clientToken"]({
|
||||
query: { location: input["location"], name: input["name"] },
|
||||
headers: { "x-opencode-ticket": input["x-opencode-ticket"] },
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const adaptGroupMcp = (raw: RawClient["server.mcp"]) => ({
|
||||
list: EndpointMcpList(raw),
|
||||
add: EndpointMcpAdd(raw),
|
||||
remove: EndpointMcpRemove(raw),
|
||||
connect: EndpointMcpConnect(raw),
|
||||
disconnect: EndpointMcpDisconnect(raw),
|
||||
resource: { catalog: EndpointMcpResourceCatalog(raw) },
|
||||
client: { token: EndpointMcpClientToken(raw) },
|
||||
const adaptGroupExperimentalMcp = (raw: RawClient["server.mcp"]) => ({
|
||||
add: EndpointExperimentalMcpAdd(raw),
|
||||
remove: EndpointExperimentalMcpRemove(raw),
|
||||
connect: EndpointExperimentalMcpConnect(raw),
|
||||
disconnect: EndpointExperimentalMcpDisconnect(raw),
|
||||
client: { token: EndpointExperimentalMcpClientToken(raw) },
|
||||
})
|
||||
|
||||
const EndpointCredentialList = (raw: RawClient["server.credential"]) => () =>
|
||||
@@ -1328,25 +1343,25 @@ const EndpointFileFind = (raw: RawClient["server.fs"]) => (input: FileFindInput)
|
||||
}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const EndpointFileWatch = (raw: RawClient["server.fs"]) => (input: FileWatchInput) =>
|
||||
preserveEffect<FileWatchOutput>()(
|
||||
const adaptGroupFile = (raw: RawClient["server.fs"]) => ({ list: EndpointFileList(raw), find: EndpointFileFind(raw) })
|
||||
|
||||
const EndpointExperimentalFileWatch = (raw: RawClient["server.fs"]) => (input: ExperimentalFileWatchInput) =>
|
||||
preserveEffect<ExperimentalFileWatchOutput>()(
|
||||
raw["fs.watch"]({ query: { location: input["location"] }, payload: { path: input["path"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const EndpointFileUnwatch = (raw: RawClient["server.fs"]) => (input: FileUnwatchInput) =>
|
||||
preserveEffect<FileUnwatchOutput>()(
|
||||
const EndpointExperimentalFileUnwatch = (raw: RawClient["server.fs"]) => (input: ExperimentalFileUnwatchInput) =>
|
||||
preserveEffect<ExperimentalFileUnwatchOutput>()(
|
||||
raw["fs.unwatch"]({ query: { location: input["location"] }, payload: { path: input["path"] } }).pipe(
|
||||
Effect.mapError(mapClientError),
|
||||
),
|
||||
)
|
||||
|
||||
const adaptGroupFile = (raw: RawClient["server.fs"]) => ({
|
||||
list: EndpointFileList(raw),
|
||||
find: EndpointFileFind(raw),
|
||||
watch: EndpointFileWatch(raw),
|
||||
unwatch: EndpointFileUnwatch(raw),
|
||||
const adaptGroupExperimentalFile = (raw: RawClient["server.fs"]) => ({
|
||||
watch: EndpointExperimentalFileWatch(raw),
|
||||
unwatch: EndpointExperimentalFileUnwatch(raw),
|
||||
})
|
||||
|
||||
const EndpointCommandList = (raw: RawClient["server.command"]) => (input?: CommandListInput) =>
|
||||
@@ -1712,10 +1727,14 @@ const adaptGroupDebug = (raw: RawClient["server.debug"]) => ({
|
||||
location: { list: EndpointDebugLocationList(raw), evict: EndpointDebugLocationEvict(raw) },
|
||||
})
|
||||
|
||||
const EndpointMigrationV1Status = (raw: RawClient["server.migration"]) => () =>
|
||||
preserveEffect<MigrationV1StatusOutput>()(raw["migration.v1.status"]({}).pipe(Effect.mapError(mapClientError)))
|
||||
const EndpointExperimentalMigrationV1Status = (raw: RawClient["server.migration"]) => () =>
|
||||
preserveEffect<ExperimentalMigrationV1StatusOutput>()(
|
||||
raw["migration.v1.status"]({}).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const adaptGroupMigration = (raw: RawClient["server.migration"]) => ({ v1: { status: EndpointMigrationV1Status(raw) } })
|
||||
const adaptGroupExperimentalMigration = (raw: RawClient["server.migration"]) => ({
|
||||
v1: { status: EndpointExperimentalMigrationV1Status(raw) },
|
||||
})
|
||||
|
||||
const EndpointWebsearchProviders = (raw: RawClient["server.websearch"]) => (input?: WebsearchProvidersInput) =>
|
||||
preserveEffect<WebsearchProvidersOutput>()(
|
||||
@@ -1735,12 +1754,14 @@ const adaptGroupWebsearch = (raw: RawClient["server.websearch"]) => ({
|
||||
query: EndpointWebsearchQuery(raw),
|
||||
})
|
||||
|
||||
const EndpointUsageLimits = (raw: RawClient["server.usage"]) => (input?: UsageLimitsInput) =>
|
||||
preserveEffect<UsageLimitsOutput>()(
|
||||
const EndpointExperimentalUsageLimits = (raw: RawClient["server.usage"]) => (input?: ExperimentalUsageLimitsInput) =>
|
||||
preserveEffect<ExperimentalUsageLimitsOutput>()(
|
||||
raw["usage.limits"]({ query: { location: input?.["location"] } }).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const adaptGroupUsage = (raw: RawClient["server.usage"]) => ({ limits: EndpointUsageLimits(raw) })
|
||||
const adaptGroupExperimentalUsage = (raw: RawClient["server.usage"]) => ({
|
||||
limits: EndpointExperimentalUsageLimits(raw),
|
||||
})
|
||||
|
||||
const EndpointConfigGet = (raw: RawClient["server.config"]) => (input?: ConfigGetInput) =>
|
||||
preserveEffect<ConfigGetOutput>()(
|
||||
@@ -1750,51 +1771,158 @@ const EndpointConfigGet = (raw: RawClient["server.config"]) => (input?: ConfigGe
|
||||
const EndpointConfigShells = (raw: RawClient["server.config"]) => () =>
|
||||
preserveEffect<ConfigShellsOutput>()(raw["config.shells"]({}).pipe(Effect.mapError(mapClientError)))
|
||||
|
||||
const EndpointConfigUpdate = (raw: RawClient["server.config"]) => (input: ConfigUpdateInput) =>
|
||||
preserveEffect<ConfigUpdateOutput>()(
|
||||
raw["config.update"]({ payload: { shell: input["shell"] } }).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const adaptGroupConfig = (raw: RawClient["server.config"]) => ({
|
||||
get: EndpointConfigGet(raw),
|
||||
shells: EndpointConfigShells(raw),
|
||||
update: EndpointConfigUpdate(raw),
|
||||
})
|
||||
|
||||
const adaptClient = (raw: RawClient) => ({
|
||||
server: adaptGroupServer(raw["server.server"]),
|
||||
location: adaptGroupLocation(raw["server.location"]),
|
||||
agent: adaptGroupAgent(raw["server.agent"]),
|
||||
plugin: adaptGroupPlugin(raw["server.plugin"]),
|
||||
session: adaptGroupSession(raw["server.session"]),
|
||||
message: adaptGroupMessage(raw["server.message"]),
|
||||
model: adaptGroupModel(raw["server.model"]),
|
||||
generate: adaptGroupGenerate(raw["server.generate"]),
|
||||
voice: adaptGroupVoice(raw["server.voice"]),
|
||||
provider: adaptGroupProvider(raw["server.provider"]),
|
||||
integration: adaptGroupIntegration(raw["server.integration"]),
|
||||
mcp: adaptGroupMcp(raw["server.mcp"]),
|
||||
credential: adaptGroupCredential(raw["server.credential"]),
|
||||
project: adaptGroupProject(raw["server.project"]),
|
||||
form: adaptGroupForm(raw["server.form"]),
|
||||
permission: adaptGroupPermission(raw["server.permission"]),
|
||||
file: adaptGroupFile(raw["server.fs"]),
|
||||
command: adaptGroupCommand(raw["server.command"]),
|
||||
skill: adaptGroupSkill(raw["server.skill"]),
|
||||
rpc: adaptGroupRpc(raw["server.rpc"]),
|
||||
event: adaptGroupEvent(raw["server.event"]),
|
||||
pty: adaptGroupPty(raw["server.pty"]),
|
||||
experimental: adaptGroupExperimental(raw["server.experimental"]),
|
||||
shell: adaptGroupShell(raw["server.shell"]),
|
||||
reference: adaptGroupReference(raw["server.reference"]),
|
||||
worktree: adaptGroupWorktree(raw["server.worktree"]),
|
||||
vcs: adaptGroupVcs(raw["server.vcs"]),
|
||||
debug: adaptGroupDebug(raw["server.debug"]),
|
||||
migration: adaptGroupMigration(raw["server.migration"]),
|
||||
websearch: adaptGroupWebsearch(raw["server.websearch"]),
|
||||
usage: adaptGroupUsage(raw["server.usage"]),
|
||||
config: adaptGroupConfig(raw["server.config"]),
|
||||
const EndpointExperimentalConfigUpdate = (raw: RawClient["server.config"]) => (input: ExperimentalConfigUpdateInput) =>
|
||||
preserveEffect<ExperimentalConfigUpdateOutput>()(
|
||||
raw["config.update"]({ payload: { shell: input["shell"] } }).pipe(Effect.mapError(mapClientError)),
|
||||
)
|
||||
|
||||
const adaptGroupExperimentalConfig = (raw: RawClient["server.config"]) => ({
|
||||
update: EndpointExperimentalConfigUpdate(raw),
|
||||
})
|
||||
|
||||
const adaptClient = (raw: RawClient) => {
|
||||
const client = {
|
||||
server: adaptGroupServer(raw["server.server"]),
|
||||
location: adaptGroupLocation(raw["server.location"]),
|
||||
agent: adaptGroupAgent(raw["server.agent"]),
|
||||
plugin: adaptGroupPlugin(raw["server.plugin"]),
|
||||
session: adaptGroupSession(raw["server.session"]),
|
||||
experimental: {
|
||||
...adaptGroupExperimental(raw["server.experimental"]),
|
||||
session: adaptGroupExperimentalSession(raw["server.session"]),
|
||||
generate: adaptGroupExperimentalGenerate(raw["server.generate"]),
|
||||
voice: adaptGroupExperimentalVoice(raw["server.voice"]),
|
||||
integration: adaptGroupExperimentalIntegration(raw["server.integration"]),
|
||||
mcp: adaptGroupExperimentalMcp(raw["server.mcp"]),
|
||||
file: adaptGroupExperimentalFile(raw["server.fs"]),
|
||||
migration: adaptGroupExperimentalMigration(raw["server.migration"]),
|
||||
usage: adaptGroupExperimentalUsage(raw["server.usage"]),
|
||||
config: adaptGroupExperimentalConfig(raw["server.config"]),
|
||||
},
|
||||
message: adaptGroupMessage(raw["server.message"]),
|
||||
model: adaptGroupModel(raw["server.model"]),
|
||||
provider: adaptGroupProvider(raw["server.provider"]),
|
||||
integration: adaptGroupIntegration(raw["server.integration"]),
|
||||
mcp: adaptGroupMcp(raw["server.mcp"]),
|
||||
credential: adaptGroupCredential(raw["server.credential"]),
|
||||
project: adaptGroupProject(raw["server.project"]),
|
||||
form: adaptGroupForm(raw["server.form"]),
|
||||
permission: adaptGroupPermission(raw["server.permission"]),
|
||||
file: adaptGroupFile(raw["server.fs"]),
|
||||
command: adaptGroupCommand(raw["server.command"]),
|
||||
skill: adaptGroupSkill(raw["server.skill"]),
|
||||
rpc: adaptGroupRpc(raw["server.rpc"]),
|
||||
event: adaptGroupEvent(raw["server.event"]),
|
||||
pty: adaptGroupPty(raw["server.pty"]),
|
||||
shell: adaptGroupShell(raw["server.shell"]),
|
||||
reference: adaptGroupReference(raw["server.reference"]),
|
||||
worktree: adaptGroupWorktree(raw["server.worktree"]),
|
||||
vcs: adaptGroupVcs(raw["server.vcs"]),
|
||||
debug: adaptGroupDebug(raw["server.debug"]),
|
||||
websearch: adaptGroupWebsearch(raw["server.websearch"]),
|
||||
config: adaptGroupConfig(raw["server.config"]),
|
||||
}
|
||||
return {
|
||||
...client,
|
||||
session: {
|
||||
...client.session,
|
||||
/** @deprecated Use `client.experimental.session.stats`. Removed in the next minor. */
|
||||
stats: client.experimental.session.stats,
|
||||
/** @deprecated Use `client.experimental.session.import`. Removed in the next minor. */
|
||||
import: client.experimental.session.import,
|
||||
/** @deprecated Use `client.experimental.session.export`. Removed in the next minor. */
|
||||
export: client.experimental.session.export,
|
||||
/** @deprecated Use `client.experimental.session.skill`. Removed in the next minor. */
|
||||
skill: client.experimental.session.skill,
|
||||
/** @deprecated Use `client.experimental.session.wait`. Removed in the next minor. */
|
||||
wait: client.experimental.session.wait,
|
||||
/** @deprecated Use `client.experimental.session.instructions`. Removed in the next minor. */
|
||||
instructions: {
|
||||
/** @deprecated Use `client.experimental.session.instructions.entry`. Removed in the next minor. */
|
||||
entry: {
|
||||
/** @deprecated Use `client.experimental.session.instructions.entry.list`. Removed in the next minor. */
|
||||
list: client.experimental.session.instructions.entry.list,
|
||||
/** @deprecated Use `client.experimental.session.instructions.entry.put`. Removed in the next minor. */
|
||||
put: client.experimental.session.instructions.entry.put,
|
||||
/** @deprecated Use `client.experimental.session.instructions.entry.remove`. Removed in the next minor. */
|
||||
remove: client.experimental.session.instructions.entry.remove,
|
||||
},
|
||||
},
|
||||
/** @deprecated Use `client.experimental.session.log`. Removed in the next minor. */
|
||||
log: client.experimental.session.log,
|
||||
},
|
||||
/** @deprecated Use `client.experimental.generate`. Removed in the next minor. */
|
||||
generate: {
|
||||
/** @deprecated Use `client.experimental.generate.text`. Removed in the next minor. */
|
||||
text: client.experimental.generate.text,
|
||||
/** @deprecated Use `client.experimental.generate.image`. Removed in the next minor. */
|
||||
image: client.experimental.generate.image,
|
||||
/** @deprecated Use `client.experimental.generate.decisions`. Removed in the next minor. */
|
||||
decisions: client.experimental.generate.decisions,
|
||||
},
|
||||
/** @deprecated Use `client.experimental.voice`. Removed in the next minor. */
|
||||
voice: {
|
||||
/** @deprecated Use `client.experimental.voice.models`. Removed in the next minor. */
|
||||
models: client.experimental.voice.models,
|
||||
/** @deprecated Use `client.experimental.voice.session`. Removed in the next minor. */
|
||||
session: client.experimental.voice.session,
|
||||
},
|
||||
integration: {
|
||||
...client.integration,
|
||||
/** @deprecated Use `client.experimental.integration.wellknown`. Removed in the next minor. */
|
||||
wellknown: {
|
||||
/** @deprecated Use `client.experimental.integration.wellknown.add`. Removed in the next minor. */
|
||||
add: client.experimental.integration.wellknown.add,
|
||||
},
|
||||
},
|
||||
mcp: {
|
||||
...client.mcp,
|
||||
/** @deprecated Use `client.experimental.mcp.add`. Removed in the next minor. */
|
||||
add: client.experimental.mcp.add,
|
||||
/** @deprecated Use `client.experimental.mcp.remove`. Removed in the next minor. */
|
||||
remove: client.experimental.mcp.remove,
|
||||
/** @deprecated Use `client.experimental.mcp.connect`. Removed in the next minor. */
|
||||
connect: client.experimental.mcp.connect,
|
||||
/** @deprecated Use `client.experimental.mcp.disconnect`. Removed in the next minor. */
|
||||
disconnect: client.experimental.mcp.disconnect,
|
||||
/** @deprecated Use `client.experimental.mcp.client`. Removed in the next minor. */
|
||||
client: {
|
||||
/** @deprecated Use `client.experimental.mcp.client.token`. Removed in the next minor. */
|
||||
token: client.experimental.mcp.client.token,
|
||||
},
|
||||
},
|
||||
file: {
|
||||
...client.file,
|
||||
/** @deprecated Use `client.experimental.file.watch`. Removed in the next minor. */
|
||||
watch: client.experimental.file.watch,
|
||||
/** @deprecated Use `client.experimental.file.unwatch`. Removed in the next minor. */
|
||||
unwatch: client.experimental.file.unwatch,
|
||||
},
|
||||
/** @deprecated Use `client.experimental.migration`. Removed in the next minor. */
|
||||
migration: {
|
||||
/** @deprecated Use `client.experimental.migration.v1`. Removed in the next minor. */
|
||||
v1: {
|
||||
/** @deprecated Use `client.experimental.migration.v1.status`. Removed in the next minor. */
|
||||
status: client.experimental.migration.v1.status,
|
||||
},
|
||||
},
|
||||
/** @deprecated Use `client.experimental.usage`. Removed in the next minor. */
|
||||
usage: {
|
||||
/** @deprecated Use `client.experimental.usage.limits`. Removed in the next minor. */
|
||||
limits: client.experimental.usage.limits,
|
||||
},
|
||||
config: {
|
||||
...client.config,
|
||||
/** @deprecated Use `client.experimental.config.update`. Removed in the next minor. */
|
||||
update: client.experimental.config.update,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const make = (options?: { readonly baseUrl?: URL | string }) =>
|
||||
HttpApiClient.make(ClientApi, options).pipe(Effect.map(adaptClient))
|
||||
|
||||
@@ -10,7 +10,10 @@ export type CommandApi = Client["command"]
|
||||
export type ConfigApi = Client["config"]
|
||||
export type CredentialApi = Client["credential"]
|
||||
export type EventApi = Client["event"]
|
||||
/** @deprecated Use `ExperimentalGenerateApi`. Removed in the next minor. */
|
||||
export type GenerateApi = Client["generate"]
|
||||
export type ExperimentalGenerateApi = Client["experimental"]["generate"]
|
||||
export type ExperimentalSessionApi = Client["experimental"]["session"]
|
||||
export type IntegrationApi = Client["integration"]
|
||||
export type McpApi = Client["mcp"]
|
||||
export type ModelApi = Client["model"]
|
||||
|
||||
+645
-535
File diff suppressed because it is too large
Load Diff
+471
-319
File diff suppressed because it is too large
Load Diff
@@ -1433,7 +1433,7 @@ export function createData(config: CreateDataInput) {
|
||||
}
|
||||
|
||||
const vcs = locationResource("vcs", (location) => api().vcs.get({ location }))
|
||||
const usageLimits = locationResource("usageLimits", (location) => api().usage.limits({ location }))
|
||||
const usageLimits = locationResource("usageLimits", (location) => api().experimental.usage.limits({ location }))
|
||||
const shells = locationResource("shell", async (location) => {
|
||||
const response = await api().shell.list({ location })
|
||||
const ref = { directory: response.location.directory }
|
||||
|
||||
@@ -18,30 +18,30 @@ const effectSession: Effect.Effect<Session.Info, unknown> = effectClient.session
|
||||
sessionID: "ses_test" as Session.ID,
|
||||
})
|
||||
|
||||
declare const sessionID: Parameters<typeof effectApi.session.instructions.entry.list>[0]["sessionID"]
|
||||
declare const sessionID: Parameters<typeof effectApi.experimental.session.instructions.entry.list>[0]["sessionID"]
|
||||
|
||||
const effectList: Effect.Effect<
|
||||
ReadonlyArray<{ readonly key: string; readonly value: unknown }>,
|
||||
unknown
|
||||
> = effectApi.session.instructions.entry.list({ sessionID })
|
||||
const effectPut: Effect.Effect<void, unknown> = effectApi.session.instructions.entry.put({
|
||||
> = effectApi.experimental.session.instructions.entry.list({ sessionID })
|
||||
const effectPut: Effect.Effect<void, unknown> = effectApi.experimental.session.instructions.entry.put({
|
||||
sessionID,
|
||||
key: "review-notes",
|
||||
value: { text: "Check the diff" },
|
||||
})
|
||||
const effectRemove: Effect.Effect<void, unknown> = effectApi.session.instructions.entry.remove({
|
||||
const effectRemove: Effect.Effect<void, unknown> = effectApi.experimental.session.instructions.entry.remove({
|
||||
sessionID,
|
||||
key: "review-notes",
|
||||
})
|
||||
|
||||
const promiseList: Promise<ReadonlyArray<{ readonly key: string; readonly value: unknown }>> =
|
||||
promiseClient.session.instructions.entry.list({ sessionID: "ses_test" })
|
||||
const promisePut: Promise<void> = promiseClient.session.instructions.entry.put({
|
||||
promiseClient.experimental.session.instructions.entry.list({ sessionID: "ses_test" })
|
||||
const promisePut: Promise<void> = promiseClient.experimental.session.instructions.entry.put({
|
||||
sessionID: "ses_test",
|
||||
key: "review-notes",
|
||||
value: { text: "Check the diff" },
|
||||
})
|
||||
const promiseRemove: Promise<void> = promiseClient.session.instructions.entry.remove({
|
||||
const promiseRemove: Promise<void> = promiseClient.experimental.session.instructions.entry.remove({
|
||||
sessionID: "ses_test",
|
||||
key: "review-notes",
|
||||
})
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { compile } from "@opencode/httpapi-codegen"
|
||||
import {
|
||||
ClientApi,
|
||||
clientNamespace,
|
||||
effectOmitEndpoints,
|
||||
groupNames,
|
||||
promiseOmitEndpoints,
|
||||
} from "@opencode/protocol/client"
|
||||
import { Effect } from "effect"
|
||||
import { HttpClient } from "effect/http"
|
||||
import { OpenCode as EffectOpenCode } from "../src/effect/index"
|
||||
import { OpenCode as PromiseOpenCode } from "../src/promise/index"
|
||||
|
||||
// The pre-experimental paths stay until the next minor.
|
||||
const aliases = (omitEndpoints: ReadonlySet<string>) =>
|
||||
compile(ClientApi, { groupNames, omitEndpoints, namespace: clientNamespace, aliases: true }).aliases ?? []
|
||||
|
||||
const at = (root: unknown, path: ReadonlyArray<string>) =>
|
||||
path.reduce<unknown>((parent, key) => (parent as Record<string, unknown> | undefined)?.[key], root)
|
||||
|
||||
const expectSameFunctions = (client: unknown, list: ReturnType<typeof aliases>) => {
|
||||
expect(list.length).toBeGreaterThan(20)
|
||||
for (const alias of list) {
|
||||
expect(alias.to[0]).toBe("experimental")
|
||||
const target = at(client, alias.to)
|
||||
expect(target).toBeFunction()
|
||||
expect(at(client, alias.from)).toBe(target)
|
||||
}
|
||||
}
|
||||
|
||||
test("every Promise client alias is the same function as its client.experimental path", () => {
|
||||
expectSameFunctions(PromiseOpenCode.make({ baseUrl: "http://localhost:3000" }), aliases(promiseOmitEndpoints))
|
||||
})
|
||||
|
||||
test("every Effect client alias is the same function as its client.experimental path", async () => {
|
||||
const client = await EffectOpenCode.make({ baseUrl: "http://localhost:3000" }).pipe(
|
||||
Effect.provideService(
|
||||
HttpClient.HttpClient,
|
||||
HttpClient.make(() => Effect.die("unused")),
|
||||
),
|
||||
Effect.runPromise,
|
||||
)
|
||||
expectSameFunctions(client, aliases(effectOmitEndpoints))
|
||||
})
|
||||
@@ -92,13 +92,15 @@ test("session instructions methods use the public HTTP contract", async () => {
|
||||
})
|
||||
const result = await Effect.gen(function* () {
|
||||
const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" })
|
||||
const listed = yield* client.session.instructions.entry.list({ sessionID: Session.ID.make("ses_test") })
|
||||
yield* client.session.instructions.entry.put({
|
||||
const listed = yield* client.experimental.session.instructions.entry.list({
|
||||
sessionID: Session.ID.make("ses_test"),
|
||||
})
|
||||
yield* client.experimental.session.instructions.entry.put({
|
||||
sessionID: Session.ID.make("ses_test"),
|
||||
key: "review-notes",
|
||||
value: instructions[0].value,
|
||||
})
|
||||
yield* client.session.instructions.entry.remove({
|
||||
yield* client.experimental.session.instructions.entry.remove({
|
||||
sessionID: Session.ID.make("ses_test"),
|
||||
key: "review-notes",
|
||||
})
|
||||
@@ -264,9 +266,9 @@ test("session methods retain decoded Effect inputs and outputs", async () => {
|
||||
resume: false,
|
||||
})
|
||||
yield* client.session.compact({ sessionID: Session.ID.make("ses_test") })
|
||||
yield* client.session.wait({ sessionID: Session.ID.make("ses_test") })
|
||||
yield* client.experimental.session.wait({ sessionID: Session.ID.make("ses_test") })
|
||||
const context = yield* client.session.context({ sessionID: Session.ID.make("ses_test") })
|
||||
const log = yield* client.session
|
||||
const log = yield* client.experimental.session
|
||||
.log({ sessionID: Session.ID.make("ses_test"), after: Event.Seq.make(0) })
|
||||
.pipe(Stream.runCollect)
|
||||
const interrupted = yield* client.session.interrupt({ sessionID: Session.ID.make("ses_test") })
|
||||
@@ -314,7 +316,9 @@ test("session.log retains the typed SessionNotFoundError", async () => {
|
||||
)
|
||||
const error = await Effect.gen(function* () {
|
||||
const client = yield* OpenCode.make({ baseUrl: "http://localhost:3000" })
|
||||
return yield* client.session.log({ sessionID: Session.ID.make("ses_missing") }).pipe(Stream.runCollect, Effect.flip)
|
||||
return yield* client.experimental.session
|
||||
.log({ sessionID: Session.ID.make("ses_missing") })
|
||||
.pipe(Stream.runCollect, Effect.flip)
|
||||
}).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.runPromise)
|
||||
|
||||
expect(error._tag).toBe("SessionNotFoundError")
|
||||
|
||||
@@ -10,10 +10,9 @@ test("exposes every standard HTTP API group", () => {
|
||||
"agent",
|
||||
"plugin",
|
||||
"session",
|
||||
"experimental",
|
||||
"message",
|
||||
"model",
|
||||
"generate",
|
||||
"voice",
|
||||
"provider",
|
||||
"integration",
|
||||
"mcp",
|
||||
@@ -27,35 +26,144 @@ test("exposes every standard HTTP API group", () => {
|
||||
"rpc",
|
||||
"event",
|
||||
"pty",
|
||||
"experimental",
|
||||
"shell",
|
||||
"reference",
|
||||
"worktree",
|
||||
"vcs",
|
||||
"debug",
|
||||
"migration",
|
||||
"websearch",
|
||||
"usage",
|
||||
"config",
|
||||
"generate",
|
||||
"voice",
|
||||
"migration",
|
||||
"usage",
|
||||
])
|
||||
expect(Object.keys(client.debug)).toEqual(["heapDump", "location"])
|
||||
expect(Object.keys(client.debug.location)).toEqual(["list", "evict"])
|
||||
expect(Object.keys(client.message)).toEqual(["list"])
|
||||
expect(Object.keys(client.integration)).toEqual(["list", "get", "wellknown", "connect", "oauth", "command"])
|
||||
expect(Object.keys(client.integration.wellknown)).toEqual(["add"])
|
||||
expect(Object.keys(client.integration)).toEqual(["list", "get", "connect", "oauth", "command", "wellknown"])
|
||||
expect(Object.keys(client.integration.connect)).toEqual(["key", "external"])
|
||||
expect(Object.keys(client.integration.oauth)).toEqual(["connect", "status", "complete", "cancel"])
|
||||
expect(Object.keys(client.integration.command)).toEqual(["connect", "status", "cancel"])
|
||||
expect(Object.keys(client.websearch)).toEqual(["providers", "query"])
|
||||
expect(Object.keys(client.voice)).toEqual(["models", "session"])
|
||||
expect(Object.keys(client.usage)).toEqual(["limits"])
|
||||
expect(Object.keys(client.file)).toEqual(["read", "list", "find", "write", "watch", "unwatch"])
|
||||
expect(Object.keys(client.mcp)).toEqual(["list", "resource", "add", "remove", "connect", "disconnect", "client"])
|
||||
expect(Object.keys(client.config)).toEqual(["get", "shells", "update"])
|
||||
expect(Object.keys(client.vcs)).toEqual(["init", "get", "base", "status", "branch", "diff"])
|
||||
expect(Object.keys(client.pty)).toEqual(["list", "create", "get", "update", "remove", "connect"])
|
||||
expect(Object.keys(client.pty.connect)).toEqual(["token"])
|
||||
expect(Object.keys(client.experimental).sort()).toEqual(["media", "persistentPty"])
|
||||
expect(Object.keys(client.experimental)).toEqual([
|
||||
"session",
|
||||
"generate",
|
||||
"voice",
|
||||
"integration",
|
||||
"mcp",
|
||||
"file",
|
||||
"persistentPty",
|
||||
"media",
|
||||
"migration",
|
||||
"usage",
|
||||
"config",
|
||||
])
|
||||
expect(Object.keys(client.experimental.session)).toEqual([
|
||||
"stats",
|
||||
"import",
|
||||
"export",
|
||||
"skill",
|
||||
"wait",
|
||||
"instructions",
|
||||
"log",
|
||||
])
|
||||
expect(Object.keys(client.experimental.voice)).toEqual(["models", "session"])
|
||||
expect(Object.keys(client.experimental.usage)).toEqual(["limits"])
|
||||
expect(Object.keys(client.experimental.mcp)).toEqual(["add", "remove", "connect", "disconnect", "client"])
|
||||
expect(Object.keys(client.experimental.integration.wellknown)).toEqual(["add"])
|
||||
expect(Object.keys(client.experimental.file)).toEqual(["write", "watch", "unwatch"])
|
||||
expect(Object.keys(client.experimental.media)).toEqual(["get"])
|
||||
expect(client.experimental.persistentPty.read).toBeFunction()
|
||||
})
|
||||
|
||||
test("nests a method under client.experimental exactly when its route is experimental", async () => {
|
||||
let url: URL | undefined
|
||||
const client = OpenCode.make({
|
||||
baseUrl: "http://localhost:3000",
|
||||
fetch: async (input) => {
|
||||
url = new URL(input instanceof Request ? input.url : String(input))
|
||||
throw new Error("captured")
|
||||
},
|
||||
})
|
||||
// Every field reads as "x" so path params resolve; request options stay unset.
|
||||
const input = new Proxy(
|
||||
{},
|
||||
{ get: (_target, key) => (key === "signal" || key === "headers" || key === "onActivity" ? undefined : "x") },
|
||||
)
|
||||
const routes: Array<{ readonly method: string; readonly experimentalRoute: boolean }> = []
|
||||
const deprecated: Array<string> = []
|
||||
const visit = async (node: object, path: ReadonlyArray<string>): Promise<void> => {
|
||||
for (const [name, value] of Object.entries(node)) {
|
||||
// `rpc` is a callable that also carries its generated routes.
|
||||
if (typeof value !== "function" || Object.keys(value).length > 0) {
|
||||
await visit(value, [...path, name])
|
||||
continue
|
||||
}
|
||||
const target = [...path, name].reduce<unknown>(
|
||||
(parent, key) => (parent as Record<string, unknown> | undefined)?.[key],
|
||||
client.experimental,
|
||||
)
|
||||
if (path[0] !== "experimental" && target === value) {
|
||||
deprecated.push([...path, name].join("."))
|
||||
continue
|
||||
}
|
||||
url = undefined
|
||||
const result: unknown = value(input)
|
||||
if (typeof result === "object" && result !== null && Symbol.asyncIterator in result) {
|
||||
await (result as AsyncIterable<unknown>)
|
||||
[Symbol.asyncIterator]()
|
||||
.next()
|
||||
.catch(() => undefined)
|
||||
} else await Promise.resolve(result).catch(() => undefined)
|
||||
const method = [...path, name].join(".")
|
||||
if (url === undefined) throw new Error(`${method} did not send a request`)
|
||||
routes.push({ method, experimentalRoute: url.pathname.startsWith("/api/experimental/") })
|
||||
}
|
||||
}
|
||||
await visit(client, [])
|
||||
|
||||
expect(routes.filter((route) => route.experimentalRoute).length).toBeGreaterThan(20)
|
||||
expect(
|
||||
routes
|
||||
.filter((route) => route.experimentalRoute !== route.method.startsWith("experimental."))
|
||||
.map((route) => route.method),
|
||||
).toEqual([])
|
||||
// Pre-experimental paths kept as deprecated aliases until the next minor.
|
||||
expect(deprecated.toSorted()).toEqual([
|
||||
"config.update",
|
||||
"file.unwatch",
|
||||
"file.watch",
|
||||
"file.write",
|
||||
"generate.decisions",
|
||||
"generate.image",
|
||||
"generate.text",
|
||||
"integration.wellknown.add",
|
||||
"mcp.add",
|
||||
"mcp.client.token",
|
||||
"mcp.connect",
|
||||
"mcp.disconnect",
|
||||
"mcp.remove",
|
||||
"migration.v1.status",
|
||||
"session.export",
|
||||
"session.import",
|
||||
"session.instructions.entry.list",
|
||||
"session.instructions.entry.put",
|
||||
"session.instructions.entry.remove",
|
||||
"session.log",
|
||||
"session.skill",
|
||||
"session.stats",
|
||||
"session.wait",
|
||||
"usage.limits",
|
||||
"voice.models",
|
||||
"voice.session",
|
||||
])
|
||||
expect(Object.keys(client.shell)).toEqual(["list", "create", "get", "output", "remove"])
|
||||
expect(Object.keys(client.project)).toEqual(["list", "update"])
|
||||
expect(Object.keys(client.worktree)).toEqual(["list", "create", "remove", "refresh"])
|
||||
@@ -254,7 +362,7 @@ test("generate.text uses the locationless public contract", async () => {
|
||||
},
|
||||
})
|
||||
|
||||
expect(await client.generate.text({ prompt: "ping" })).toEqual({ text: "pong" })
|
||||
expect(await client.experimental.generate.text({ prompt: "ping" })).toEqual({ text: "pong" })
|
||||
expect(request?.url).toBe("http://localhost:3000/api/experimental/generate/text")
|
||||
expect(await request?.json()).toEqual({ prompt: "ping" })
|
||||
})
|
||||
@@ -325,7 +433,7 @@ test("experimental wellknown integration add uses the public HTTP contract", asy
|
||||
},
|
||||
})
|
||||
|
||||
await client.integration.wellknown.add({
|
||||
await client.experimental.integration.wellknown.add({
|
||||
url: "https://example.com",
|
||||
location: { directory: "/tmp/project" },
|
||||
})
|
||||
@@ -587,13 +695,13 @@ test("session instructions methods use the public HTTP contract", async () => {
|
||||
},
|
||||
})
|
||||
|
||||
const result = await client.session.instructions.entry.list({ sessionID: "ses_test" })
|
||||
await client.session.instructions.entry.put({
|
||||
const result = await client.experimental.session.instructions.entry.list({ sessionID: "ses_test" })
|
||||
await client.experimental.session.instructions.entry.put({
|
||||
sessionID: "ses_test",
|
||||
key: "review-notes",
|
||||
value: instructions[0].value,
|
||||
})
|
||||
await client.session.instructions.entry.remove({ sessionID: "ses_test", key: "review-notes" })
|
||||
await client.experimental.session.instructions.entry.remove({ sessionID: "ses_test", key: "review-notes" })
|
||||
|
||||
expect(result).toEqual(instructions)
|
||||
expect(requests).toEqual([
|
||||
@@ -972,10 +1080,10 @@ test("session methods use the public HTTP contract", async () => {
|
||||
resume: false,
|
||||
})
|
||||
await client.session.compact({ sessionID: "ses_test" })
|
||||
await client.session.wait({ sessionID: "ses_test" })
|
||||
await client.experimental.session.wait({ sessionID: "ses_test" })
|
||||
const context = await client.session.context({ sessionID: "ses_test" })
|
||||
const log = []
|
||||
for await (const item of client.session.log({ sessionID: "ses_test", after: 0 })) log.push(item)
|
||||
for await (const item of client.experimental.session.log({ sessionID: "ses_test", after: 0 })) log.push(item)
|
||||
const interrupted = await client.session.interrupt({ sessionID: "ses_test", resume: true })
|
||||
const message = await client.session.message.get({ sessionID: "ses_test", messageID: "msg_model" })
|
||||
|
||||
@@ -1051,7 +1159,7 @@ test("session.log decodes SessionNotFoundError", async () => {
|
||||
})
|
||||
|
||||
try {
|
||||
await client.session.log({ sessionID: "ses_missing" })[Symbol.asyncIterator]().next()
|
||||
await client.experimental.session.log({ sessionID: "ses_missing" })[Symbol.asyncIterator]().next()
|
||||
throw new Error("Expected request to fail")
|
||||
} catch (error) {
|
||||
expect(isSessionNotFoundError(error)).toBe(true)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { OpenCode, type MigrationV1StatusOutput } from "@opencode/client/promise"
|
||||
import { OpenCode, type ExperimentalMigrationV1StatusOutput } from "@opencode/client/promise"
|
||||
import { useLanguage } from "@opencode/app/desktop"
|
||||
import { Loader } from "@opencode/ui/loader"
|
||||
import { showToast, toaster, Toast } from "@opencode/ui/toast"
|
||||
import { createRoot, createSignal, onCleanup, onMount } from "solid-js"
|
||||
import type { ServerReadyData } from "../shared/ipc-contract"
|
||||
|
||||
type Progress = Extract<MigrationV1StatusOutput, { status: "running" }>["progress"]
|
||||
type Progress = Extract<ExperimentalMigrationV1StatusOutput, { status: "running" }>["progress"]
|
||||
|
||||
export function MigrationStatus(props: { server: ServerReadyData }) {
|
||||
const language = useLanguage()
|
||||
@@ -87,7 +87,7 @@ export function MigrationStatus(props: { server: ServerReadyData }) {
|
||||
|
||||
void (async () => {
|
||||
while (true) {
|
||||
const status = await client.migration.v1.status({ signal: abort.signal })
|
||||
const status = await client.experimental.migration.v1.status({ signal: abort.signal })
|
||||
setProgress(status.status === "running" ? status.progress : undefined)
|
||||
|
||||
if (status.status === "running") show()
|
||||
|
||||
@@ -1053,11 +1053,11 @@ function useMcpToggle(session: MountedSession, directory: () => string) {
|
||||
if (!server) return
|
||||
|
||||
if (!input.enabled) {
|
||||
await client.mcp.disconnect({ server: input.name, location: ref })
|
||||
await client.experimental.mcp.disconnect({ server: input.name, location: ref })
|
||||
}
|
||||
|
||||
if (input.enabled && server.status.status !== "needs_auth") {
|
||||
await client.mcp.connect({ server: input.name, location: ref })
|
||||
await client.experimental.mcp.connect({ server: input.name, location: ref })
|
||||
}
|
||||
|
||||
source.location.mcp.server.invalidate(ref)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -393,6 +393,187 @@ describe("HttpApiCodegen.generate", () => {
|
||||
expect(contract.groups[0]?.endpoints[0]?.operation).toMatchObject({ group: "sessions", name: "get" })
|
||||
})
|
||||
|
||||
test("nests namespaced endpoints and merges them with a group of the same name", async () => {
|
||||
const source = HttpApi.make("test")
|
||||
.add(
|
||||
HttpApiGroup.make("server.session")
|
||||
.add(HttpApiEndpoint.get("get", "/session", { success: Schema.String }))
|
||||
.add(HttpApiEndpoint.get("stats", "/experimental/session/stats", { success: Schema.String })),
|
||||
)
|
||||
.add(
|
||||
HttpApiGroup.make("server.experimental").add(
|
||||
HttpApiEndpoint.get("read", "/experimental/terminal", { success: Schema.String }).annotateMerge(
|
||||
OpenApi.annotations({ identifier: "server.experimental.terminal.read" }),
|
||||
),
|
||||
),
|
||||
)
|
||||
const contract = compileContract(source, {
|
||||
groupNames: { "server.session": "session", "server.experimental": "experimental" },
|
||||
namespace: (endpoint) => (endpoint.path.startsWith("/experimental/") ? "experimental" : undefined),
|
||||
})
|
||||
|
||||
expect(contract.groups.map((group) => [group.identifier, group.path])).toEqual([
|
||||
["session", ["session"]],
|
||||
["experimental.session", ["experimental", "session"]],
|
||||
["experimental", ["experimental"]],
|
||||
])
|
||||
|
||||
const paths: Array<string> = []
|
||||
await using emitted = await emittedModule(emitPromise(contract))
|
||||
const client = emitted.module.OpenCode.make({
|
||||
baseUrl: "https://example.com",
|
||||
fetch: async (input: RequestInfo | URL) => {
|
||||
paths.push(new URL(input instanceof Request ? input.url : input).pathname)
|
||||
return Response.json("ok")
|
||||
},
|
||||
})
|
||||
expect(Object.keys(client)).toEqual(["session", "experimental"])
|
||||
expect(Object.keys(client.session)).toEqual(["get"])
|
||||
expect(Object.keys(client.experimental)).toEqual(["session", "terminal"])
|
||||
expect(await client.session.get()).toBe("ok")
|
||||
expect(await client.experimental.session.stats()).toBe("ok")
|
||||
expect(await client.experimental.terminal.read()).toBe("ok")
|
||||
expect(paths).toEqual(["/session", "/experimental/session/stats", "/experimental/terminal"])
|
||||
|
||||
expect(emitEffect(contract).files.find((file) => file.path === "client.ts")?.content).toContain(
|
||||
'"experimental": { ...adaptGroupExperimental(raw["experimental"]), "session": adaptGroupExperimentalSession(raw["experimental.session"]) }',
|
||||
)
|
||||
const imported = emitEffectImported(contract, { module: "@example/api", api: "Api" })
|
||||
expect(imported.files.find((file) => file.path === "client.ts")?.content).toContain(
|
||||
'"experimental": { ...adaptGroupExperimental(raw["server.experimental"]), "session": adaptGroupExperimentalSession(raw["server.session"]) }',
|
||||
)
|
||||
// A projection rebuilds the split group under its client name, so the raw client is keyed by that name.
|
||||
const projected = emitEffectImported(contract, {
|
||||
module: "@example/api",
|
||||
endpoints: { "session.get": "Get", "experimental.session.stats": "Stats", "experimental.read": "Read" },
|
||||
}).files.find((file) => file.path === "client.ts")?.content
|
||||
expect(projected).toContain('HttpApiGroup.make("experimental.session").add(Stats)')
|
||||
expect(projected).toContain('const adaptGroupExperimentalSession = (raw: RawClient["experimental.session"])')
|
||||
expect(projected).toContain(
|
||||
'"experimental": { ...adaptGroupExperimental(raw["experimental"]), "session": adaptGroupExperimentalSession(raw["experimental.session"]) }',
|
||||
)
|
||||
expect(projected).not.toContain('raw["server.')
|
||||
const shape = emitEffectShape(contract).files.find((file) => file.path === "api.ts")?.content
|
||||
expect(shape).toContain('readonly "session": SessionApi<E>')
|
||||
expect(shape).toContain(
|
||||
'readonly "experimental": ExperimentalApi<E> & {\nreadonly "session": ExperimentalSessionApi<E>\n}',
|
||||
)
|
||||
})
|
||||
|
||||
test("rejects a namespaced group that collides with a method in the namespace", () => {
|
||||
const source = HttpApi.make("test")
|
||||
.add(
|
||||
HttpApiGroup.make("experimental").add(
|
||||
HttpApiEndpoint.get("read", "/experimental/session", { success: Schema.String }).annotateMerge(
|
||||
OpenApi.annotations({ identifier: "experimental.session.read" }),
|
||||
),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiGroup.make("session").add(
|
||||
HttpApiEndpoint.get("stats", "/experimental/stats", { success: Schema.String }),
|
||||
),
|
||||
)
|
||||
|
||||
expect(() => compileContract(source, { namespace: () => "experimental" })).toThrow(
|
||||
"Client name collision: experimental.session",
|
||||
)
|
||||
})
|
||||
|
||||
test("keeps pre-namespace paths and type names as deprecated aliases", async () => {
|
||||
const source = HttpApi.make("test")
|
||||
.add(
|
||||
HttpApiGroup.make("server.session")
|
||||
.add(HttpApiEndpoint.get("get", "/session", { success: Schema.String }))
|
||||
.add(
|
||||
HttpApiEndpoint.get("stats", "/experimental/session/:sessionID/stats", {
|
||||
params: { sessionID: Schema.String },
|
||||
success: Schema.String,
|
||||
}),
|
||||
),
|
||||
)
|
||||
.add(
|
||||
HttpApiGroup.make("server.generate").add(
|
||||
HttpApiEndpoint.post("text", "/experimental/generate/text", {
|
||||
payload: Schema.Struct({ prompt: Schema.String }),
|
||||
success: Schema.String,
|
||||
}),
|
||||
),
|
||||
)
|
||||
const options = {
|
||||
groupNames: { "server.session": "session", "server.generate": "generate" },
|
||||
namespace: (endpoint: HttpApiEndpoint.Top) =>
|
||||
endpoint.path.startsWith("/experimental/") ? "experimental" : undefined,
|
||||
}
|
||||
expect(compileContract(source, options).aliases).toBeUndefined()
|
||||
expect(
|
||||
emitPromise(compileContract(source, options))
|
||||
.files.map((file) => file.content)
|
||||
.join(""),
|
||||
).not.toContain("@deprecated")
|
||||
|
||||
const contract = compileContract(source, { ...options, aliases: true })
|
||||
expect(contract.aliases?.map((alias) => [alias.from.join("."), alias.to.join(".")])).toEqual([
|
||||
["session.stats", "experimental.session.stats"],
|
||||
["generate.text", "experimental.generate.text"],
|
||||
])
|
||||
|
||||
const paths: Array<string> = []
|
||||
const promise = emitPromise(contract)
|
||||
await using emitted = await emittedModule(promise)
|
||||
const client = emitted.module.OpenCode.make({
|
||||
baseUrl: "https://example.com",
|
||||
fetch: async (input: RequestInfo | URL) => {
|
||||
paths.push(new URL(input instanceof Request ? input.url : input).pathname)
|
||||
return Response.json("ok")
|
||||
},
|
||||
})
|
||||
expect(Object.keys(client)).toEqual(["session", "experimental", "generate"])
|
||||
expect(Object.keys(client.session)).toEqual(["get", "stats"])
|
||||
expect(client.session.stats).toBe(client.experimental.session.stats)
|
||||
expect(client.generate.text).toBe(client.experimental.generate.text)
|
||||
expect(await client.session.stats({ sessionID: "a" })).toBe("ok")
|
||||
expect(paths).toEqual(["/experimental/session/a/stats"])
|
||||
const promiseFile = (path: string) => promise.files.find((file) => file.path === path)?.content
|
||||
expect(promiseFile("client.ts")).toContain(
|
||||
"/** @deprecated Use `client.experimental.generate.text`. Removed in the next minor. */",
|
||||
)
|
||||
expect(promiseFile("types.ts")).toContain(
|
||||
"/** @deprecated Use `ExperimentalSessionStatsInput`. Removed in the next minor. */\nexport type SessionStatsInput = ExperimentalSessionStatsInput",
|
||||
)
|
||||
|
||||
const shape = emitEffectShape(contract).files.find((file) => file.path === "api.ts")?.content
|
||||
// The alias joins the interface of the group still at its old path, so code typed against SessionApi compiles.
|
||||
expect(shape).toContain(
|
||||
'export interface SessionApi<E = never> {\nreadonly "get": SessionGetOperation<E>\n\n/** @deprecated Use `client.experimental.session.stats`. Removed in the next minor. */\nreadonly "stats": ExperimentalSessionStatsOperation<E>\n}',
|
||||
)
|
||||
expect(shape).toContain("export type SessionStatsOperation<E = never> = ExperimentalSessionStatsOperation<E>")
|
||||
expect(shape).toContain("export type GenerateApi<E = never> = ExperimentalGenerateApi<E>")
|
||||
expect(shape).toContain(
|
||||
'/** @deprecated Use `client.experimental.generate`. Removed in the next minor. */\nreadonly "generate": {',
|
||||
)
|
||||
expect(emitEffect(contract).files.find((file) => file.path === "client.ts")?.content).toContain(
|
||||
'return { ...client, "session": { ...client.session, ',
|
||||
)
|
||||
})
|
||||
|
||||
test("rejects an alias that collides with a client path", () => {
|
||||
const source = HttpApi.make("test").add(
|
||||
HttpApiGroup.make("session")
|
||||
.add(HttpApiEndpoint.get("stats", "/session/stats", { success: Schema.String }))
|
||||
.add(
|
||||
HttpApiEndpoint.get("experimentalStats", "/experimental/session/stats", {
|
||||
success: Schema.String,
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.session.stats" })),
|
||||
),
|
||||
)
|
||||
const namespace = (endpoint: HttpApiEndpoint.Top) =>
|
||||
endpoint.path.startsWith("/experimental/") ? "experimental" : undefined
|
||||
|
||||
expect(() => compileContract(source, { namespace })).not.toThrow()
|
||||
expect(() => compileContract(source, { namespace, aliases: true })).toThrow("Client alias collision: session.stats")
|
||||
})
|
||||
|
||||
test("derives nested paths from OpenAPI operation IDs", () => {
|
||||
const source = HttpApi.make("test").add(
|
||||
HttpApiGroup.make("server.session").add(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CredentialApi, ExperimentalApi, GenerateApi, PluginApi } from "@opencode/client/effect/api"
|
||||
import type { CredentialApi, ExperimentalApi, ExperimentalGenerateApi, PluginApi } from "@opencode/client/effect/api"
|
||||
import type { Location } from "@opencode/schema/location"
|
||||
import type { Effect, Scope } from "effect"
|
||||
import type { PluginOptions } from "../options.js"
|
||||
@@ -35,13 +35,13 @@ export interface Context {
|
||||
readonly experimental: {
|
||||
readonly terminal: Pick<ExperimentalApi<unknown>["persistentPty"], "read">
|
||||
/** Stateless generation with a model and a prompt: no session, history or tools. */
|
||||
readonly generate: GenerateApi<unknown>
|
||||
readonly generate: ExperimentalGenerateApi<unknown>
|
||||
}
|
||||
readonly integration: IntegrationDomain
|
||||
readonly mcp: MCPDomain
|
||||
readonly model: ModelDomain
|
||||
/** @deprecated Use `experimental.generate.text`. */
|
||||
readonly generate: Pick<GenerateApi<unknown>, "text">
|
||||
readonly generate: Pick<ExperimentalGenerateApi<unknown>, "text">
|
||||
readonly permission: PermissionDomain
|
||||
readonly plugin: Pick<PluginApi<unknown>, "list">
|
||||
readonly provider: ProviderDomain
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SessionApi } from "@opencode/client/effect/api"
|
||||
import type { ExperimentalSessionApi, SessionApi } from "@opencode/client/effect/api"
|
||||
import type { GenerationOptionsFields, Message, SystemPart } from "@opencode/ai/effect"
|
||||
import type { Agent } from "@opencode/schema/agent"
|
||||
import type { Model } from "@opencode/schema/model"
|
||||
@@ -167,9 +167,8 @@ export type SessionDomain = Pick<
|
||||
| "interrupt"
|
||||
| "update"
|
||||
| "move"
|
||||
| "wait"
|
||||
| "context"
|
||||
| "instructions"
|
||||
> & {
|
||||
readonly hook: ModelHooks<SessionHooks>
|
||||
}
|
||||
> &
|
||||
Pick<ExperimentalSessionApi<unknown>, "wait" | "instructions"> & {
|
||||
readonly hook: ModelHooks<SessionHooks>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { OpenCodeClient } from "@opencode/client"
|
||||
import type { CredentialApi, GenerateApi, PluginApi } from "@opencode/client/promise/api"
|
||||
import type { CredentialApi, ExperimentalGenerateApi, PluginApi } from "@opencode/client/promise/api"
|
||||
import type { Location } from "@opencode/schema/location"
|
||||
import type { PluginOptions } from "../options.js"
|
||||
import type { App } from "../app.js"
|
||||
@@ -35,13 +35,13 @@ export interface Context {
|
||||
readonly experimental: {
|
||||
readonly terminal: Pick<OpenCodeClient["experimental"]["persistentPty"], "read">
|
||||
/** Stateless generation with a model and a prompt: no session, history or tools. */
|
||||
readonly generate: GenerateApi
|
||||
readonly generate: ExperimentalGenerateApi
|
||||
}
|
||||
readonly integration: IntegrationDomain
|
||||
readonly mcp: MCPDomain
|
||||
readonly model: ModelDomain
|
||||
/** @deprecated Use `experimental.generate.text`. */
|
||||
readonly generate: Pick<GenerateApi, "text">
|
||||
readonly generate: Pick<ExperimentalGenerateApi, "text">
|
||||
readonly permission: PermissionDomain
|
||||
readonly plugin: Pick<PluginApi, "list">
|
||||
readonly provider: ProviderDomain
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SessionApi } from "@opencode/client/promise/api"
|
||||
import type { ExperimentalSessionApi, SessionApi } from "@opencode/client/promise/api"
|
||||
import type { GenerationOptionsFields, Message, SystemPart } from "@opencode/ai/effect"
|
||||
import type { Agent } from "@opencode/schema/agent"
|
||||
import type { Model } from "@opencode/schema/model"
|
||||
@@ -167,9 +167,8 @@ export type SessionDomain = Pick<
|
||||
| "interrupt"
|
||||
| "update"
|
||||
| "move"
|
||||
| "wait"
|
||||
| "context"
|
||||
| "instructions"
|
||||
> & {
|
||||
readonly hook: ModelHooks<SessionHooks>
|
||||
}
|
||||
> &
|
||||
Pick<ExperimentalSessionApi, "wait" | "instructions"> & {
|
||||
readonly hook: ModelHooks<SessionHooks>
|
||||
}
|
||||
|
||||
Generated
+12
-12
@@ -3993,7 +3993,7 @@
|
||||
"/api/experimental/session/{sessionID}/log": {
|
||||
"get": {
|
||||
"tags": ["session"],
|
||||
"operationId": "session.log",
|
||||
"operationId": "experimental.session.log",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "sessionID",
|
||||
@@ -11732,7 +11732,7 @@
|
||||
"/api/experimental/session/{sessionID}/terminal/read": {
|
||||
"get": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.read",
|
||||
"operationId": "experimental.persistentPty.read",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "sessionID",
|
||||
@@ -11822,7 +11822,7 @@
|
||||
"/api/experimental/session/{sessionID}/terminal": {
|
||||
"get": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.list",
|
||||
"operationId": "experimental.persistentPty.list",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "sessionID",
|
||||
@@ -11889,7 +11889,7 @@
|
||||
},
|
||||
"post": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.create",
|
||||
"operationId": "experimental.persistentPty.create",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "sessionID",
|
||||
@@ -11965,7 +11965,7 @@
|
||||
"/api/experimental/persistent-pty/shutdown": {
|
||||
"post": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.shutdown",
|
||||
"operationId": "experimental.persistentPty.shutdown",
|
||||
"parameters": [],
|
||||
"security": [],
|
||||
"responses": {
|
||||
@@ -12008,7 +12008,7 @@
|
||||
"/api/experimental/persistent-pty/handoff": {
|
||||
"post": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.handoff",
|
||||
"operationId": "experimental.persistentPty.handoff",
|
||||
"parameters": [],
|
||||
"security": [],
|
||||
"responses": {
|
||||
@@ -12072,7 +12072,7 @@
|
||||
"/api/experimental/persistent-pty/{ptyID}": {
|
||||
"get": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.get",
|
||||
"operationId": "experimental.persistentPty.get",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "ptyID",
|
||||
@@ -12146,7 +12146,7 @@
|
||||
},
|
||||
"put": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.update",
|
||||
"operationId": "experimental.persistentPty.update",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "ptyID",
|
||||
@@ -12230,7 +12230,7 @@
|
||||
},
|
||||
"delete": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.remove",
|
||||
"operationId": "experimental.persistentPty.remove",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "ptyID",
|
||||
@@ -12292,7 +12292,7 @@
|
||||
"/api/experimental/persistent-pty/{ptyID}/snapshot": {
|
||||
"get": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.snapshot",
|
||||
"operationId": "experimental.persistentPty.snapshot",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "ptyID",
|
||||
@@ -12368,7 +12368,7 @@
|
||||
"/api/experimental/persistent-pty/{ptyID}/connect-token": {
|
||||
"post": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "server.experimental.persistentPty.connectToken",
|
||||
"operationId": "experimental.persistentPty.connectToken",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "ptyID",
|
||||
@@ -12469,7 +12469,7 @@
|
||||
"/api/experimental/persistent-pty/{ptyID}/connect": {
|
||||
"get": {
|
||||
"tags": ["persistentPty"],
|
||||
"operationId": "persistentPty.connect",
|
||||
"operationId": "experimental.persistentPty.connect",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "ptyID",
|
||||
|
||||
@@ -68,6 +68,12 @@ export const groupNames = {
|
||||
"server.config": "config",
|
||||
} as const
|
||||
|
||||
// Experimental routes carry no compatibility promise, so the generated clients nest them under
|
||||
// `client.experimental` instead of beside stable methods. The URL decides rather than the OpenAPI
|
||||
// id, because the URL is what callers depend on and an id can miss its `experimental.` prefix.
|
||||
export const clientNamespace = (endpoint: { readonly path: string }) =>
|
||||
endpoint.path === "/api/experimental" || endpoint.path.startsWith("/api/experimental/") ? "experimental" : undefined
|
||||
|
||||
export const promiseOmitEndpoints = new Set([
|
||||
"pty.connect",
|
||||
"persistentPty.connect",
|
||||
|
||||
@@ -31,6 +31,7 @@ export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
||||
error: [ServiceUnavailableError],
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "experimental.persistentPty.read",
|
||||
summary: "Read the session's most recently controlled terminal",
|
||||
description:
|
||||
"Read the last physical rows without changing selection or taking control. Omitted lines uses the live terminal height; larger counts include retained history. Blank rows are preserved. Screen dimensions and cursor remain relative to the live screen. Returns null when no current terminal exists. Selection is server-local and resets on restart. Experimental: may change without compatibility guarantees.",
|
||||
@@ -42,7 +43,7 @@ export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
||||
params: { sessionID: Session.ID },
|
||||
success: Schema.Struct({ data: Schema.Array(PersistentPty.Info) }),
|
||||
error: errors,
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.list" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.post("persistentPty.create", "/api/experimental/session/:sessionID/terminal", {
|
||||
@@ -50,26 +51,26 @@ export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
||||
payload: PersistentPty.CreateInput,
|
||||
success: Schema.Struct({ data: PersistentPty.Info }),
|
||||
error: errors,
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.create" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.post("persistentPty.shutdown", "/api/experimental/persistent-pty/shutdown", {
|
||||
success: HttpApiSchema.NoContent,
|
||||
error: [ServiceUnavailableError],
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.shutdown" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.post("persistentPty.handoff", "/api/experimental/persistent-pty/handoff", {
|
||||
success: Schema.Struct({ handoff: Schema.NullOr(PersistentPty.Handoff) }),
|
||||
error: [ServiceUnavailableError],
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.handoff" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.get("persistentPty.get", "/api/experimental/persistent-pty/:ptyID", {
|
||||
params: { ptyID: Pty.ID },
|
||||
success: Schema.Struct({ data: PersistentPty.Info }),
|
||||
error: terminalErrors,
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.get" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.put("persistentPty.update", "/api/experimental/persistent-pty/:ptyID", {
|
||||
@@ -77,21 +78,21 @@ export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
||||
payload: PersistentPty.UpdateInput,
|
||||
success: Schema.Struct({ data: PersistentPty.Info }),
|
||||
error: terminalErrors,
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.update" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.get("persistentPty.snapshot", "/api/experimental/persistent-pty/:ptyID/snapshot", {
|
||||
params: { ptyID: Pty.ID },
|
||||
success: Schema.Struct({ data: PersistentPty.Snapshot }),
|
||||
error: terminalErrors,
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.snapshot" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.delete("persistentPty.remove", "/api/experimental/persistent-pty/:ptyID", {
|
||||
params: { ptyID: Pty.ID },
|
||||
success: HttpApiSchema.NoContent,
|
||||
error: terminalErrors,
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.remove" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.post("persistentPty.connectToken", "/api/experimental/persistent-pty/:ptyID/connect-token", {
|
||||
@@ -99,7 +100,7 @@ export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
||||
headers: Schema.Struct({ [PTY_CONNECT_TOKEN_HEADER]: Schema.optional(Schema.String) }),
|
||||
success: Schema.Struct({ data: PtyTicket.ConnectToken }),
|
||||
error: [ForbiddenError, PtyNotFoundError, ServiceUnavailableError],
|
||||
}),
|
||||
}).annotateMerge(OpenApi.annotations({ identifier: "experimental.persistentPty.connectToken" })),
|
||||
)
|
||||
.add(
|
||||
HttpApiEndpoint.get("persistentPty.connect", PERSISTENT_PTY_CONNECT_PATH, {
|
||||
@@ -108,7 +109,7 @@ export const PersistentPtyGroup = HttpApiGroup.make("server.experimental")
|
||||
error: [ForbiddenError, PtyNotFoundError, ServiceUnavailableError],
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "persistentPty.connect",
|
||||
identifier: "experimental.persistentPty.connect",
|
||||
summary: "Connect to a persistent PTY",
|
||||
description: "Stream persistent PTY output through the OpenCode server.",
|
||||
transform: (operation) => ({
|
||||
|
||||
@@ -665,7 +665,7 @@ export const makeSessionGroup = <I extends HttpApiMiddleware.AnyId, S, FormI ext
|
||||
error: SessionNotFoundError,
|
||||
}).annotateMerge(
|
||||
OpenApi.annotations({
|
||||
identifier: "session.log",
|
||||
identifier: "experimental.session.log",
|
||||
summary: "Read the session log",
|
||||
description:
|
||||
"Experimental durable session event log. Reads events after an exclusive aggregate sequence and continues with live events when follow=true.",
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { expect, test } from "bun:test"
|
||||
import { OpenApi } from "effect/http-api"
|
||||
import { ClientApi } from "../src/client.js"
|
||||
|
||||
const methods = ["get", "put", "post", "delete", "patch", "head", "options", "trace"] as const
|
||||
|
||||
test("routes under /api/experimental, and only those, have experimental.* identifiers", () => {
|
||||
const operations = Object.entries(OpenApi.fromApi(ClientApi).paths).flatMap(([path, item]) =>
|
||||
methods.flatMap((method) => {
|
||||
const operation = item[method]
|
||||
return operation ? [{ path, identifier: operation.operationId }] : []
|
||||
}),
|
||||
)
|
||||
const offenders = operations
|
||||
.filter(
|
||||
({ path, identifier }) =>
|
||||
(path === "/api/experimental" || path.startsWith("/api/experimental/")) !==
|
||||
identifier.startsWith("experimental."),
|
||||
)
|
||||
.map(({ path, identifier }) => `${identifier} ${path}`)
|
||||
|
||||
expect(operations.length).toBeGreaterThan(100)
|
||||
expect(offenders).toEqual([])
|
||||
})
|
||||
@@ -19,7 +19,7 @@ import { SessionMessage } from "@opencode/schema/session-message"
|
||||
import { Workspace } from "@opencode/schema/workspace"
|
||||
import { Worktree } from "@opencode/schema/worktree"
|
||||
import { Api } from "@opencode/server/api"
|
||||
import { ClientApi, groupNames, promiseOmitEndpoints } from "@opencode/protocol/client"
|
||||
import { ClientApi, clientNamespace, groupNames, promiseOmitEndpoints } from "@opencode/protocol/client"
|
||||
import { compile, emitPromise } from "@opencode/httpapi-codegen"
|
||||
|
||||
const SDK = await import("../src/index")
|
||||
@@ -97,8 +97,8 @@ test("Core and Server reuse the authoritative Schema and Protocol values", () =>
|
||||
})
|
||||
|
||||
test("client and Server contracts generate identically", () => {
|
||||
const server = compile(Api, { groupNames, omitEndpoints: promiseOmitEndpoints })
|
||||
const client = compile(ClientApi, { groupNames, omitEndpoints: promiseOmitEndpoints })
|
||||
const server = compile(Api, { groupNames, omitEndpoints: promiseOmitEndpoints, namespace: clientNamespace })
|
||||
const client = compile(ClientApi, { groupNames, omitEndpoints: promiseOmitEndpoints, namespace: clientNamespace })
|
||||
|
||||
expect(emitPromise(client)).toEqual(emitPromise(server))
|
||||
})
|
||||
|
||||
@@ -68,7 +68,7 @@ for (const selection of ["explicit", "default"] as const) {
|
||||
},
|
||||
)
|
||||
|
||||
const result = yield* opencode.generate.text({
|
||||
const result = yield* opencode.experimental.generate.text({
|
||||
prompt: "Say ready",
|
||||
...(selection === "explicit"
|
||||
? {
|
||||
@@ -137,7 +137,7 @@ it.live("seeds host plugins from CreateOptions and waits for delayed model plugi
|
||||
)
|
||||
|
||||
const [defaultModel, generated] = yield* Effect.all(
|
||||
[opencode.model.default({ location: location(fixture) }), opencode.generate.text({ prompt: "Say ready" })],
|
||||
[opencode.model.default({ location: location(fixture) }), opencode.experimental.generate.text({ prompt: "Say ready" })],
|
||||
{ concurrency: "unbounded" },
|
||||
)
|
||||
|
||||
@@ -223,16 +223,16 @@ it.live(
|
||||
})
|
||||
const context = yield* opencode.sessions.context({ sessionID: id })
|
||||
const pendingAfterAdmit = yield* opencode.sessions.inbox.list({ sessionID: id })
|
||||
yield* opencode.sessions.instructions.entry.put({ sessionID: id, key: "deploy-target", value: "production" })
|
||||
yield* opencode.sessions.instructions.entry.put({ sessionID: id, key: "flags", value: { beta: true } })
|
||||
const contextEntries = yield* opencode.sessions.instructions.entry.list({ sessionID: id })
|
||||
yield* opencode.sessions.instructions.entry.remove({ sessionID: id, key: "flags" })
|
||||
const remainingContextEntries = yield* opencode.sessions.instructions.entry.list({ sessionID: id })
|
||||
yield* opencode.experimental.session.instructions.entry.put({ sessionID: id, key: "deploy-target", value: "production" })
|
||||
yield* opencode.experimental.session.instructions.entry.put({ sessionID: id, key: "flags", value: { beta: true } })
|
||||
const contextEntries = yield* opencode.experimental.session.instructions.entry.list({ sessionID: id })
|
||||
yield* opencode.experimental.session.instructions.entry.remove({ sessionID: id, key: "flags" })
|
||||
const remainingContextEntries = yield* opencode.experimental.session.instructions.entry.list({ sessionID: id })
|
||||
const wake = yield* opencode.sessions.prompt({
|
||||
sessionID: id,
|
||||
text: "Promote this input",
|
||||
})
|
||||
const prompted = yield* opencode.sessions.log({ sessionID: id, follow: true }).pipe(
|
||||
const prompted = yield* opencode.experimental.session.log({ sessionID: id, follow: true }).pipe(
|
||||
Stream.filter((event) => event.type === "session.inbox.delivered" && event.data.inboxID === wake.id),
|
||||
Stream.runHead,
|
||||
Effect.timeout("10 seconds"),
|
||||
@@ -240,7 +240,7 @@ it.live(
|
||||
)
|
||||
const wakeContext = yield* opencode.sessions.context({ sessionID: id })
|
||||
const pendingAfterPromote = yield* opencode.sessions.inbox.list({ sessionID: id })
|
||||
const event = yield* opencode.sessions.log({ sessionID: id }).pipe(
|
||||
const event = yield* opencode.experimental.session.log({ sessionID: id }).pipe(
|
||||
Stream.filter((item) => item.type === "session.model.selected"),
|
||||
Stream.take(1),
|
||||
Stream.runHead,
|
||||
@@ -255,10 +255,10 @@ it.live(
|
||||
const missingSessionID = fixture.sdk.Session.ID.create()
|
||||
const missing = yield* Effect.all(
|
||||
[
|
||||
opencode.sessions.log({ sessionID: missingSessionID }).pipe(Stream.runHead, Effect.flip),
|
||||
opencode.experimental.session.log({ sessionID: missingSessionID }).pipe(Stream.runHead, Effect.flip),
|
||||
opencode.sessions.interrupt({ sessionID: missingSessionID }).pipe(Effect.flip),
|
||||
opencode.sessions.message.get({ sessionID: missingSessionID, messageID: modelMessage.id }).pipe(Effect.flip),
|
||||
opencode.sessions.instructions.entry.list({ sessionID: missingSessionID }).pipe(Effect.flip),
|
||||
opencode.experimental.session.instructions.entry.list({ sessionID: missingSessionID }).pipe(Effect.flip),
|
||||
opencode.sessions.inbox.list({ sessionID: missingSessionID }).pipe(Effect.flip),
|
||||
],
|
||||
{ concurrency: "unbounded" },
|
||||
@@ -635,7 +635,7 @@ it.live(
|
||||
expect(calls).toEqual(["create"])
|
||||
|
||||
yield* Deferred.succeed(createRelease, undefined)
|
||||
yield* opencode.sessions.wait({ sessionID: session.id })
|
||||
yield* opencode.experimental.session.wait({ sessionID: session.id })
|
||||
// Provisioning settled, the workspace connected, and the turn completed. The
|
||||
// memory driver rejects the actual spawn, which surfaces to the model as an
|
||||
// ordinary tool error before the final text response.
|
||||
|
||||
@@ -126,7 +126,7 @@ it.live(
|
||||
expect((yield* llm.requests()).length).toBe(1)
|
||||
yield* Deferred.succeed(release, undefined)
|
||||
yield* llm.wait(3).pipe(Effect.timeout("5 seconds"))
|
||||
yield* second.sessions.wait({ sessionID: session.id })
|
||||
yield* second.experimental.session.wait({ sessionID: session.id })
|
||||
|
||||
expect(configured).toEqual(["thread-recovery", "thread-recovery"])
|
||||
expect(executed).toEqual([2])
|
||||
@@ -215,7 +215,7 @@ it.live(
|
||||
for (const session of [first, second]) {
|
||||
const admitted = yield* opencode.sessions.prompt({ sessionID: session.id, text: "Hello" })
|
||||
expect(admitted.payload.text).toBe(`Hello:${session.location.workspaceID}`)
|
||||
yield* opencode.sessions.wait({ sessionID: session.id })
|
||||
yield* opencode.experimental.session.wait({ sessionID: session.id })
|
||||
}
|
||||
expect(configured).toEqual(["same-thread", "same-thread"])
|
||||
expect(placements.map((location) => location.workspaceID)).toEqual([firstWorkspace, secondWorkspace])
|
||||
@@ -225,7 +225,7 @@ it.live(
|
||||
directory: AbsolutePath.make(directory.path),
|
||||
workspaceID: secondWorkspace,
|
||||
})
|
||||
yield* opencode.sessions.wait({ sessionID: first.id })
|
||||
yield* opencode.experimental.session.wait({ sessionID: first.id })
|
||||
const moved = yield* opencode.sessions.get({ sessionID: first.id })
|
||||
expect(moved.location.workspaceID).toBe(secondWorkspace)
|
||||
const admitted = yield* opencode.sessions.prompt({ sessionID: first.id, text: "Moved", resume: false })
|
||||
|
||||
@@ -18,7 +18,7 @@ test("Promise host uses the embedded router", async () => {
|
||||
const session = await opencode.sessions.create({ location })
|
||||
const selected = await opencode.sessions.get({ sessionID: session.id })
|
||||
const page = await opencode.sessions.list({ directory: directory.path })
|
||||
const events = Array.fromAsync(opencode.sessions.log({ sessionID: session.id }))
|
||||
const events = Array.fromAsync(opencode.experimental.session.log({ sessionID: session.id }))
|
||||
|
||||
expect(selected.id).toBe(session.id)
|
||||
expect(page.data.some((item) => item.id === session.id)).toBe(true)
|
||||
|
||||
@@ -40,14 +40,14 @@ for (const entrypoint of ["create", "layer"] as const) {
|
||||
location: Location.Ref.make({ directory: AbsolutePath.make(directory.path) }),
|
||||
})
|
||||
expect((yield* client.sessions.get({ sessionID: session.id })).id).toBe(session.id)
|
||||
const events = yield* client.sessions.log({ sessionID: session.id }).pipe(Stream.runCollect)
|
||||
const events = yield* client.experimental.session.log({ sessionID: session.id }).pipe(Stream.runCollect)
|
||||
expect(events.some((event) => event.type === "session.created")).toBe(true)
|
||||
expect(yield* client.events.subscribe().pipe(Stream.take(1), Stream.runCollect)).toMatchObject([
|
||||
{ type: "server.connected" },
|
||||
])
|
||||
const missing = Session.ID.create()
|
||||
// Error responses must decode over the SDK transport too; sessions.get is served by core without HTTP.
|
||||
expect(yield* client.sessions.export({ sessionID: missing }).pipe(Effect.flip)).toMatchObject({
|
||||
expect(yield* client.experimental.session.export({ sessionID: missing }).pipe(Effect.flip)).toMatchObject({
|
||||
_tag: "SessionNotFoundError",
|
||||
})
|
||||
expect(yield* client.sessions.get({ sessionID: missing }).pipe(Effect.flip)).toMatchObject({
|
||||
|
||||
@@ -125,7 +125,7 @@ it.live("serves stored media as refs only to clients that opt in while experimen
|
||||
|
||||
yield* Effect.promise(async () => {
|
||||
const template = await plain.session.create({ title: "Media wire" })
|
||||
await plain.session.import({ info: { ...template, id: sessionID }, messages: [user, assistant] })
|
||||
await plain.experimental.session.import({ info: { ...template, id: sessionID }, messages: [user, assistant] })
|
||||
storeAsBlobs(database)
|
||||
|
||||
// Without the capability, reads stay byte-for-byte what was imported.
|
||||
@@ -187,7 +187,7 @@ it.live("serves stored media as refs only to clients that opt in while experimen
|
||||
const single: unknown = await opted.session.message.get({ sessionID, messageID: "msg_media_user" })
|
||||
expect(single).toMatchObject({ files: [{ uri: media(png) }, { uri: media(text) }, {}, {}] })
|
||||
expect(await plain.session.message.get({ sessionID, messageID: "msg_media_user" })).toEqual(user)
|
||||
expect((await opted.session.export({ sessionID })).messages).toEqual([user, assistant])
|
||||
expect((await opted.experimental.session.export({ sessionID })).messages).toEqual([user, assistant])
|
||||
|
||||
// The route serves raw bytes, immutable caching and a 304, and never renders active content inline.
|
||||
const image = await handler(new Request(route(png)))
|
||||
|
||||
@@ -48,7 +48,7 @@ const setup = Effect.gen(function* () {
|
||||
})
|
||||
const session = yield* Effect.promise(async () => {
|
||||
const template = await api.session.create({ title: "Message filtering" })
|
||||
return api.session.import({ info: { ...template, id: Session.ID.create() }, messages })
|
||||
return api.experimental.session.import({ info: { ...template, id: Session.ID.create() }, messages })
|
||||
})
|
||||
return { api, handler, sessionID: session.id }
|
||||
})
|
||||
|
||||
@@ -58,7 +58,7 @@ it.live("the generated Effect client fails the session log stream with the serve
|
||||
const received: unknown[] = []
|
||||
const exit = yield* Effect.gen(function* () {
|
||||
const client = yield* OpenCode.make({ baseUrl: "http://opencode.local" })
|
||||
return yield* client.session
|
||||
return yield* client.experimental.session
|
||||
.log({ sessionID: Session.ID.make("ses_test") })
|
||||
.pipe(Stream.runForEach((item) => Effect.sync(() => received.push(item))))
|
||||
}).pipe(Effect.provideService(HttpClient.HttpClient, httpClient), Effect.exit)
|
||||
|
||||
@@ -162,7 +162,7 @@ export function DevToolsBar() {
|
||||
const events = await (sessionID
|
||||
? (async () => {
|
||||
const events: { readonly created: number }[] = []
|
||||
for await (const event of client.api.session.log({ sessionID, follow: false })) {
|
||||
for await (const event of client.api.experimental.session.log({ sessionID, follow: false })) {
|
||||
if (event.type !== "log.synced") events.push(event)
|
||||
}
|
||||
// Durable events stay in aggregate order even when their wall-clock timestamps differ.
|
||||
|
||||
@@ -121,7 +121,7 @@ export function DialogMcp(props: { initialServer?: string; details?: boolean } =
|
||||
setLoading((prev) => new Set(prev).add(name))
|
||||
const target = current()
|
||||
const input = { server: name, location: { directory: target.directory } }
|
||||
const call = server.status.status === "connected" ? client.api.mcp.disconnect(input) : client.api.mcp.connect(input)
|
||||
const call = server.status.status === "connected" ? client.api.experimental.mcp.disconnect(input) : client.api.experimental.mcp.connect(input)
|
||||
void call.catch(toast.error).finally(() =>
|
||||
setLoading((prev) => {
|
||||
const next = new Set(prev)
|
||||
|
||||
@@ -19,7 +19,7 @@ export function MigrationOverlay() {
|
||||
await Bun.sleep(1_000)
|
||||
void (async () => {
|
||||
while (true) {
|
||||
const status = await client.api.migration.v1.status({ signal: abort.signal })
|
||||
const status = await client.api.experimental.migration.v1.status({ signal: abort.signal })
|
||||
setProgress(status.status === "running" ? status.progress : undefined)
|
||||
if (status.status === "completed") return
|
||||
if (status.status === "error") throw new Error(status.error)
|
||||
|
||||
@@ -140,7 +140,7 @@ export function StatsPoster(props: { stats: SessionStatsInfo }) {
|
||||
function StatsPage(props: { context: Plugin.Context; onClose: () => void }) {
|
||||
const [result] = createResource(() => {
|
||||
const now = new Date()
|
||||
return props.context.client.session.stats({
|
||||
return props.context.client.experimental.session.stats({
|
||||
from: new Date(now.getFullYear(), 0, 1).getTime(),
|
||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC",
|
||||
tools: "none",
|
||||
|
||||
@@ -911,7 +911,7 @@ export async function createSessionTransport(input: StreamInput): Promise<Sessio
|
||||
let client = initial
|
||||
while (true) {
|
||||
try {
|
||||
await client.session.wait({ sessionID: input.sessionID }, { signal: controller.signal })
|
||||
await client.experimental.session.wait({ sessionID: input.sessionID }, { signal: controller.signal })
|
||||
return client
|
||||
} catch (error) {
|
||||
// session.wait is a long poll that only answers once the session settles, so a dropped
|
||||
|
||||
@@ -1121,7 +1121,7 @@ export function Session(props: {
|
||||
if (!(await mutatePending("cancel", message.id))) return
|
||||
} else {
|
||||
await client.api.session.interrupt({ sessionID })
|
||||
await client.api.session.wait({ sessionID })
|
||||
await client.api.experimental.session.wait({ sessionID })
|
||||
await client.api.session.revert.stage({ sessionID, messageID: message.id })
|
||||
}
|
||||
target?.set({
|
||||
@@ -1321,7 +1321,7 @@ export function Session(props: {
|
||||
try {
|
||||
const sessionData = session()
|
||||
if (!sessionData) return
|
||||
const transcript = await client.api.session.export({ sessionID: sessionData.id })
|
||||
const transcript = await client.api.experimental.session.export({ sessionID: sessionData.id })
|
||||
const content = formatSessionTranscript(transcript.info, transcript.messages, true)
|
||||
await clipboard.write(content)
|
||||
toast.show({ message: "Session transcript copied to clipboard!", variant: "success" })
|
||||
@@ -1347,7 +1347,7 @@ export function Session(props: {
|
||||
|
||||
if (options === null) return
|
||||
|
||||
const transcript = await client.api.session.export({
|
||||
const transcript = await client.api.experimental.session.export({
|
||||
sessionID: sessionData.id,
|
||||
sanitize: options.format === "json" ? options.sanitize : undefined,
|
||||
})
|
||||
|
||||
@@ -193,7 +193,7 @@ function sdk(input: {
|
||||
)
|
||||
spyOn(client.session, "active").mockImplementation(() => ok(input.active?.() ?? {}))
|
||||
spyOn(client.session.inbox, "list").mockImplementation((request) => ok(input.pending?.[request.sessionID] ?? []))
|
||||
spyOn(client.session, "wait").mockImplementation(() => input.wait?.() ?? ok(undefined))
|
||||
spyOn(client.experimental.session, "wait").mockImplementation(() => input.wait?.() ?? ok(undefined))
|
||||
spyOn(client.session.message, "get").mockImplementation((request) => {
|
||||
const message = input.messages?.[request.sessionID]?.find((item) => item.id === request.messageID)
|
||||
return message ? (ok(message) as never) : Promise.reject(new Error(`message not found: ${request.messageID}`))
|
||||
|
||||
@@ -58,7 +58,7 @@ const sessions = yield* client.session.list()
|
||||
|
||||
## Stream events
|
||||
|
||||
Streaming operations such as `event.subscribe()` and `session.log()` return Effect Streams.
|
||||
Streaming operations such as `event.subscribe()` and `experimental.session.log()` return Effect Streams.
|
||||
|
||||
{/* prettier-ignore */}
|
||||
```ts
|
||||
|
||||
@@ -129,7 +129,7 @@ interface Context {
|
||||
readonly mcp: MCPDomain
|
||||
readonly model: ModelDomain
|
||||
/** @deprecated Use `experimental.generate.text`. */
|
||||
readonly generate: Pick<GenerateApi<unknown>, "text">
|
||||
readonly generate: Pick<ExperimentalGenerateApi<unknown>, "text">
|
||||
readonly permission: PermissionDomain
|
||||
readonly plugin: Pick<PluginApi<unknown>, "list">
|
||||
readonly provider: ProviderDomain
|
||||
|
||||
@@ -846,11 +846,11 @@ interface SessionContext {
|
||||
instructions: {
|
||||
entry: {
|
||||
list(
|
||||
input: SessionInstructionsEntryListInput,
|
||||
input: ExperimentalSessionInstructionsEntryListInput,
|
||||
requestOptions?: RequestOptions,
|
||||
): Promise<readonly InstructionEntryInfo[]>
|
||||
put(input: SessionInstructionsEntryPutInput, requestOptions?: RequestOptions): Promise<void>
|
||||
remove(input: SessionInstructionsEntryRemoveInput, requestOptions?: RequestOptions): Promise<void>
|
||||
put(input: ExperimentalSessionInstructionsEntryPutInput, requestOptions?: RequestOptions): Promise<void>
|
||||
remove(input: ExperimentalSessionInstructionsEntryRemoveInput, requestOptions?: RequestOptions): Promise<void>
|
||||
}
|
||||
}
|
||||
switchAgent(input: SessionSwitchAgentInput, requestOptions?: RequestOptions): Promise<void>
|
||||
@@ -863,7 +863,7 @@ interface SessionContext {
|
||||
compact(input: SessionCompactInput, requestOptions?: RequestOptions): Promise<SessionInboxCompaction>
|
||||
synthetic(input: SessionSyntheticInput, requestOptions?: RequestOptions): Promise<SessionInboxSynthetic>
|
||||
interrupt(input: SessionInterruptInput, requestOptions?: RequestOptions): Promise<{ interrupted: boolean }>
|
||||
wait(input: SessionWaitInput, requestOptions?: RequestOptions): Promise<void>
|
||||
wait(input: ExperimentalSessionWaitInput, requestOptions?: RequestOptions): Promise<void>
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user