wip: undo properly remove messages from UI

This commit is contained in:
Dax Raad
2025-07-28 22:58:12 -04:00
parent c24fbb4292
commit 9c9cbb3e81
25 changed files with 699 additions and 472 deletions

View File

@@ -113,7 +113,7 @@ export const TuiCommand = cmd({
}) })
;(async () => { ;(async () => {
if (Installation.VERSION === "dev") return if (Installation.isDev()) return
if (Installation.isSnapshot()) return if (Installation.isSnapshot()) return
const config = await Config.global() const config = await Config.global()
if (config.autoupdate === false) return if (config.autoupdate === false) return

View File

@@ -43,6 +43,10 @@ export namespace Server {
export type Routes = ReturnType<typeof app> export type Routes = ReturnType<typeof app>
export const Event = {
Connected: Bus.event("server.connected", z.object({})),
}
function app() { function app() {
const app = new Hono() const app = new Hono()
@@ -109,7 +113,10 @@ export namespace Server {
log.info("event connected") log.info("event connected")
return streamSSE(c, async (stream) => { return streamSSE(c, async (stream) => {
stream.writeSSE({ stream.writeSSE({
data: JSON.stringify({}), data: JSON.stringify({
type: "server.connected",
properties: {},
}),
}) })
const unsub = Bus.subscribeAll(async (event) => { const unsub = Bus.subscribeAll(async (event) => {
await stream.writeSSE({ await stream.writeSSE({

View File

@@ -540,8 +540,6 @@ export namespace Session {
for (const part of userParts) { for (const part of userParts) {
await updatePart(part) await updatePart(part)
} }
// mark session as updated since a message has been added to it
await update(input.sessionID, (_draft) => {})
if (isLocked(input.sessionID)) { if (isLocked(input.sessionID)) {
return new Promise((resolve) => { return new Promise((resolve) => {
@@ -566,6 +564,7 @@ export namespace Session {
const [preserve, remove] = splitWhen(msgs, (x) => x.info.id === messageID) const [preserve, remove] = splitWhen(msgs, (x) => x.info.id === messageID)
msgs = preserve msgs = preserve
for (const msg of remove) { for (const msg of remove) {
if (msg.info.id === userMsg.id) continue
await Storage.remove(`session/message/${input.sessionID}/${msg.info.id}`) await Storage.remove(`session/message/${input.sessionID}/${msg.info.id}`)
await Bus.publish(MessageV2.Event.Removed, { sessionID: input.sessionID, messageID: msg.info.id }) await Bus.publish(MessageV2.Event.Removed, { sessionID: input.sessionID, messageID: msg.info.id })
} }
@@ -577,11 +576,15 @@ export namespace Session {
for (const part of removeParts) { for (const part of removeParts) {
await Storage.remove(`session/part/${input.sessionID}/${last.info.id}/${part.id}`) await Storage.remove(`session/part/${input.sessionID}/${last.info.id}/${part.id}`)
await Bus.publish(MessageV2.Event.PartRemoved, { await Bus.publish(MessageV2.Event.PartRemoved, {
sessionID: input.sessionID,
messageID: last.info.id, messageID: last.info.id,
partID: part.id, partID: part.id,
}) })
} }
} }
await update(input.sessionID, (draft) => {
draft.revert = undefined
})
} }
const previous = msgs.filter((x) => x.info.role === "assistant").at(-1)?.info as MessageV2.Assistant const previous = msgs.filter((x) => x.info.role === "assistant").at(-1)?.info as MessageV2.Assistant

View File

@@ -284,6 +284,7 @@ export namespace MessageV2 {
PartRemoved: Bus.event( PartRemoved: Bus.event(
"message.part.removed", "message.part.removed",
z.object({ z.object({
sessionID: z.string(),
messageID: z.string(), messageID: z.string(),
partID: z.string(), partID: z.string(),
}), }),

View File

@@ -14,8 +14,8 @@ export const ReadTool = Tool.define("read", {
description: DESCRIPTION, description: DESCRIPTION,
parameters: z.object({ parameters: z.object({
filePath: z.string().describe("The path to the file to read"), filePath: z.string().describe("The path to the file to read"),
offset: z.number().describe("The line number to start reading from (0-based)").optional(), offset: z.coerce.number().describe("The line number to start reading from (0-based)").optional(),
limit: z.number().describe("The number of lines to read (defaults to 2000)").optional(), limit: z.coerce.number().describe("The number of lines to read (defaults to 2000)").optional(),
}), }),
async execute(params, ctx) { async execute(params, ctx) {
let filePath = params.filePath let filePath = params.filePath

View File

@@ -1,4 +1,4 @@
configured_endpoints: 26 configured_endpoints: 26
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-5748199af356c3243a46a466e73b5d0bab7eaa0c56895e1d0f903d637f61d0bb.yml openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-62d8fccba4eb8dc3a80434e0849eab3352e49fb96a718bb7b6d17ed8e582b716.yml
openapi_spec_hash: c04f6b6be54b05d9b1283c24e870163b openapi_spec_hash: 4ff9376cf9634e91731e63fe482ea532
config_hash: 1ae82c93499b9f0b9ba828b8919f9cb3 config_hash: 1ae82c93499b9f0b9ba828b8919f9cb3

View File

@@ -41,7 +41,6 @@ Methods:
Types: Types:
- <code><a href="./src/resources/find.ts">Match</a></code>
- <code><a href="./src/resources/find.ts">Symbol</a></code> - <code><a href="./src/resources/find.ts">Symbol</a></code>
- <code><a href="./src/resources/find.ts">FindFilesResponse</a></code> - <code><a href="./src/resources/find.ts">FindFilesResponse</a></code>
- <code><a href="./src/resources/find.ts">FindSymbolsResponse</a></code> - <code><a href="./src/resources/find.ts">FindSymbolsResponse</a></code>

View File

@@ -46,7 +46,6 @@ import {
FindSymbolsResponse, FindSymbolsResponse,
FindTextParams, FindTextParams,
FindTextResponse, FindTextResponse,
Match,
Symbol, Symbol,
} from './resources/find'; } from './resources/find';
import { import {
@@ -789,7 +788,6 @@ export declare namespace Opencode {
export { export {
Find as Find, Find as Find,
type Match as Match,
type Symbol as Symbol, type Symbol as Symbol,
type FindFilesResponse as FindFilesResponse, type FindFilesResponse as FindFilesResponse,
type FindSymbolsResponse as FindSymbolsResponse, type FindSymbolsResponse as FindSymbolsResponse,

View File

@@ -77,6 +77,8 @@ export interface Mode {
model?: Mode.Model; model?: Mode.Model;
prompt?: string; prompt?: string;
temperature?: number;
} }
export namespace Mode { export namespace Mode {

View File

@@ -20,6 +20,11 @@ export interface Config {
*/ */
$schema?: string; $schema?: string;
/**
* Modes configuration, see https://opencode.ai/docs/modes
*/
agent?: Config.Agent;
/** /**
* @deprecated Use 'share' field instead. Share newly created sessions * @deprecated Use 'share' field instead. Share newly created sessions
* automatically * automatically
@@ -97,6 +102,33 @@ export interface Config {
} }
export namespace Config { export namespace Config {
/**
* Modes configuration, see https://opencode.ai/docs/modes
*/
export interface Agent {
general?: Agent.General;
[k: string]: Agent.AgentConfig | undefined;
}
export namespace Agent {
export interface General extends ConfigAPI.ModeConfig {
description: string;
}
export interface AgentConfig extends ConfigAPI.ModeConfig {
description: string;
}
}
export interface AgentConfig extends ConfigAPI.ModeConfig {
description: string;
}
export interface AgentConfig extends ConfigAPI.ModeConfig {
description: string;
}
export interface Experimental { export interface Experimental {
hook?: Experimental.Hook; hook?: Experimental.Hook;
} }
@@ -438,10 +470,14 @@ export interface McpRemoteConfig {
} }
export interface ModeConfig { export interface ModeConfig {
disable?: boolean;
model?: string; model?: string;
prompt?: string; prompt?: string;
temperature?: number;
tools?: { [key: string]: boolean }; tools?: { [key: string]: boolean };
} }

View File

@@ -17,23 +17,36 @@ export class Event extends APIResource {
} }
export type EventListResponse = export type EventListResponse =
| EventListResponse.EventLspClientDiagnostics
| EventListResponse.EventPermissionUpdated
| EventListResponse.EventFileEdited
| EventListResponse.EventInstallationUpdated | EventListResponse.EventInstallationUpdated
| EventListResponse.EventLspClientDiagnostics
| EventListResponse.EventMessageUpdated | EventListResponse.EventMessageUpdated
| EventListResponse.EventMessageRemoved | EventListResponse.EventMessageRemoved
| EventListResponse.EventMessagePartUpdated | EventListResponse.EventMessagePartUpdated
| EventListResponse.EventMessagePartRemoved | EventListResponse.EventMessagePartRemoved
| EventListResponse.EventStorageWrite | EventListResponse.EventStorageWrite
| EventListResponse.EventPermissionUpdated
| EventListResponse.EventFileEdited
| EventListResponse.EventSessionUpdated | EventListResponse.EventSessionUpdated
| EventListResponse.EventSessionDeleted | EventListResponse.EventSessionDeleted
| EventListResponse.EventSessionIdle | EventListResponse.EventSessionIdle
| EventListResponse.EventSessionError | EventListResponse.EventSessionError
| EventListResponse.EventServerConnected
| EventListResponse.EventFileWatcherUpdated | EventListResponse.EventFileWatcherUpdated
| EventListResponse.EventIdeInstalled; | EventListResponse.EventIdeInstalled;
export namespace EventListResponse { export namespace EventListResponse {
export interface EventInstallationUpdated {
properties: EventInstallationUpdated.Properties;
type: 'installation.updated';
}
export namespace EventInstallationUpdated {
export interface Properties {
version: string;
}
}
export interface EventLspClientDiagnostics { export interface EventLspClientDiagnostics {
properties: EventLspClientDiagnostics.Properties; properties: EventLspClientDiagnostics.Properties;
@@ -48,56 +61,6 @@ export namespace EventListResponse {
} }
} }
export interface EventPermissionUpdated {
properties: EventPermissionUpdated.Properties;
type: 'permission.updated';
}
export namespace EventPermissionUpdated {
export interface Properties {
id: string;
metadata: { [key: string]: unknown };
sessionID: string;
time: Properties.Time;
title: string;
}
export namespace Properties {
export interface Time {
created: number;
}
}
}
export interface EventFileEdited {
properties: EventFileEdited.Properties;
type: 'file.edited';
}
export namespace EventFileEdited {
export interface Properties {
file: string;
}
}
export interface EventInstallationUpdated {
properties: EventInstallationUpdated.Properties;
type: 'installation.updated';
}
export namespace EventInstallationUpdated {
export interface Properties {
version: string;
}
}
export interface EventMessageUpdated { export interface EventMessageUpdated {
properties: EventMessageUpdated.Properties; properties: EventMessageUpdated.Properties;
@@ -147,6 +110,8 @@ export namespace EventListResponse {
messageID: string; messageID: string;
partID: string; partID: string;
sessionID: string;
} }
} }
@@ -164,6 +129,44 @@ export namespace EventListResponse {
} }
} }
export interface EventPermissionUpdated {
properties: EventPermissionUpdated.Properties;
type: 'permission.updated';
}
export namespace EventPermissionUpdated {
export interface Properties {
id: string;
metadata: { [key: string]: unknown };
sessionID: string;
time: Properties.Time;
title: string;
}
export namespace Properties {
export interface Time {
created: number;
}
}
}
export interface EventFileEdited {
properties: EventFileEdited.Properties;
type: 'file.edited';
}
export namespace EventFileEdited {
export interface Properties {
file: string;
}
}
export interface EventSessionUpdated { export interface EventSessionUpdated {
properties: EventSessionUpdated.Properties; properties: EventSessionUpdated.Properties;
@@ -226,6 +229,12 @@ export namespace EventListResponse {
} }
} }
export interface EventServerConnected {
properties: unknown;
type: 'server.connected';
}
export interface EventFileWatcherUpdated { export interface EventFileWatcherUpdated {
properties: EventFileWatcherUpdated.Properties; properties: EventFileWatcherUpdated.Properties;

View File

@@ -27,42 +27,6 @@ export class Find extends APIResource {
} }
} }
export interface Match {
absolute_offset: number;
line_number: number;
lines: Match.Lines;
path: Match.Path;
submatches: Array<Match.Submatch>;
}
export namespace Match {
export interface Lines {
text: string;
}
export interface Path {
text: string;
}
export interface Submatch {
end: number;
match: Submatch.Match;
start: number;
}
export namespace Submatch {
export interface Match {
text: string;
}
}
}
export interface Symbol { export interface Symbol {
kind: number; kind: number;
@@ -105,7 +69,45 @@ export type FindFilesResponse = Array<string>;
export type FindSymbolsResponse = Array<Symbol>; export type FindSymbolsResponse = Array<Symbol>;
export type FindTextResponse = Array<Match>; export type FindTextResponse = Array<FindTextResponse.FindTextResponseItem>;
export namespace FindTextResponse {
export interface FindTextResponseItem {
absolute_offset: number;
line_number: number;
lines: FindTextResponseItem.Lines;
path: FindTextResponseItem.Path;
submatches: Array<FindTextResponseItem.Submatch>;
}
export namespace FindTextResponseItem {
export interface Lines {
text: string;
}
export interface Path {
text: string;
}
export interface Submatch {
end: number;
match: Submatch.Match;
start: number;
}
export namespace Submatch {
export interface Match {
text: string;
}
}
}
}
export interface FindFilesParams { export interface FindFilesParams {
query: string; query: string;
@@ -121,7 +123,6 @@ export interface FindTextParams {
export declare namespace Find { export declare namespace Find {
export { export {
type Match as Match,
type Symbol as Symbol, type Symbol as Symbol,
type FindFilesResponse as FindFilesResponse, type FindFilesResponse as FindFilesResponse,
type FindSymbolsResponse as FindSymbolsResponse, type FindSymbolsResponse as FindSymbolsResponse,

View File

@@ -31,7 +31,6 @@ export {
} from './file'; } from './file';
export { export {
Find, Find,
type Match,
type Symbol, type Symbol,
type FindFilesResponse, type FindFilesResponse,
type FindSymbolsResponse, type FindSymbolsResponse,

View File

@@ -270,6 +270,8 @@ export namespace Session {
export interface Revert { export interface Revert {
messageID: string; messageID: string;
diff?: string;
partID?: string; partID?: string;
snapshot?: string; snapshot?: string;
@@ -541,6 +543,8 @@ export interface SessionChatParams {
mode?: string; mode?: string;
system?: string;
tools?: { [key: string]: boolean }; tools?: { [key: string]: boolean };
} }

View File

@@ -77,6 +77,7 @@ describe('resource session', () => {
providerID: 'providerID', providerID: 'providerID',
messageID: 'msg', messageID: 'msg',
mode: 'mode', mode: 'mode',
system: 'system',
tools: { foo: true }, tools: { foo: true },
}); });
}); });

View File

@@ -190,6 +190,12 @@ func (m *messagesComponent) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if msg.Properties.Part.SessionID == m.app.Session.ID { if msg.Properties.Part.SessionID == m.app.Session.ID {
cmds = append(cmds, m.renderView()) cmds = append(cmds, m.renderView())
} }
case opencode.EventListResponseEventMessagePartRemoved:
if msg.Properties.SessionID == m.app.Session.ID {
// Clear the cache when a part is removed to ensure proper re-rendering
m.cache.Clear()
cmds = append(cmds, m.renderView())
}
case renderCompleteMsg: case renderCompleteMsg:
m.partCount = msg.partCount m.partCount = msg.partCount
m.lineCount = msg.lineCount m.lineCount = msg.lineCount

View File

@@ -402,6 +402,58 @@ func (a Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
a.app.Messages[messageIndex] = message a.app.Messages[messageIndex] = message
} }
} }
case opencode.EventListResponseEventMessagePartRemoved:
slog.Info("message part removed", "session", msg.Properties.SessionID, "message", msg.Properties.MessageID, "part", msg.Properties.PartID)
if msg.Properties.SessionID == a.app.Session.ID {
messageIndex := slices.IndexFunc(a.app.Messages, func(m app.Message) bool {
switch casted := m.Info.(type) {
case opencode.UserMessage:
return casted.ID == msg.Properties.MessageID
case opencode.AssistantMessage:
return casted.ID == msg.Properties.MessageID
}
return false
})
if messageIndex > -1 {
message := a.app.Messages[messageIndex]
partIndex := slices.IndexFunc(message.Parts, func(p opencode.PartUnion) bool {
switch casted := p.(type) {
case opencode.TextPart:
return casted.ID == msg.Properties.PartID
case opencode.FilePart:
return casted.ID == msg.Properties.PartID
case opencode.ToolPart:
return casted.ID == msg.Properties.PartID
case opencode.StepStartPart:
return casted.ID == msg.Properties.PartID
case opencode.StepFinishPart:
return casted.ID == msg.Properties.PartID
}
return false
})
if partIndex > -1 {
// Remove the part at partIndex
message.Parts = append(message.Parts[:partIndex], message.Parts[partIndex+1:]...)
a.app.Messages[messageIndex] = message
}
}
}
case opencode.EventListResponseEventMessageRemoved:
slog.Info("message removed", "session", msg.Properties.SessionID, "message", msg.Properties.MessageID)
if msg.Properties.SessionID == a.app.Session.ID {
messageIndex := slices.IndexFunc(a.app.Messages, func(m app.Message) bool {
switch casted := m.Info.(type) {
case opencode.UserMessage:
return casted.ID == msg.Properties.MessageID
case opencode.AssistantMessage:
return casted.ID == msg.Properties.MessageID
}
return false
})
if messageIndex > -1 {
a.app.Messages = append(a.app.Messages[:messageIndex], a.app.Messages[messageIndex+1:]...)
}
}
case opencode.EventListResponseEventMessageUpdated: case opencode.EventListResponseEventMessageUpdated:
if msg.Properties.Info.SessionID == a.app.Session.ID { if msg.Properties.Info.SessionID == a.app.Session.ID {
matchIndex := slices.IndexFunc(a.app.Messages, func(m app.Message) bool { matchIndex := slices.IndexFunc(a.app.Messages, func(m app.Message) bool {

View File

@@ -1,4 +1,4 @@
configured_endpoints: 26 configured_endpoints: 26
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-5748199af356c3243a46a466e73b5d0bab7eaa0c56895e1d0f903d637f61d0bb.yml openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-62d8fccba4eb8dc3a80434e0849eab3352e49fb96a718bb7b6d17ed8e582b716.yml
openapi_spec_hash: c04f6b6be54b05d9b1283c24e870163b openapi_spec_hash: 4ff9376cf9634e91731e63fe482ea532
config_hash: 1ae82c93499b9f0b9ba828b8919f9cb3 config_hash: 1ae82c93499b9f0b9ba828b8919f9cb3

View File

@@ -36,14 +36,14 @@ Methods:
Response Types: Response Types:
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Match">Match</a>
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Symbol">Symbol</a> - <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Symbol">Symbol</a>
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindTextResponse">FindTextResponse</a>
Methods: Methods:
- <code title="get /find/file">client.Find.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindService.Files">Files</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindFilesParams">FindFilesParams</a>) ([]<a href="https://pkg.go.dev/builtin#string">string</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="get /find/file">client.Find.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindService.Files">Files</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindFilesParams">FindFilesParams</a>) ([]<a href="https://pkg.go.dev/builtin#string">string</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /find/symbol">client.Find.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindService.Symbols">Symbols</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindSymbolsParams">FindSymbolsParams</a>) ([]<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Symbol">Symbol</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="get /find/symbol">client.Find.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindService.Symbols">Symbols</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindSymbolsParams">FindSymbolsParams</a>) ([]<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Symbol">Symbol</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /find">client.Find.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindService.Text">Text</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindTextParams">FindTextParams</a>) ([]<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Match">Match</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="get /find">client.Find.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindService.Text">Text</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindTextParams">FindTextParams</a>) ([]<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#FindTextResponse">FindTextResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
# File # File

View File

@@ -150,6 +150,7 @@ type Mode struct {
Tools map[string]bool `json:"tools,required"` Tools map[string]bool `json:"tools,required"`
Model ModeModel `json:"model"` Model ModeModel `json:"model"`
Prompt string `json:"prompt"` Prompt string `json:"prompt"`
Temperature float64 `json:"temperature"`
JSON modeJSON `json:"-"` JSON modeJSON `json:"-"`
} }
@@ -159,6 +160,7 @@ type modeJSON struct {
Tools apijson.Field Tools apijson.Field
Model apijson.Field Model apijson.Field
Prompt apijson.Field Prompt apijson.Field
Temperature apijson.Field
raw string raw string
ExtraFields map[string]apijson.Field ExtraFields map[string]apijson.Field
} }

View File

@@ -43,6 +43,8 @@ func (r *ConfigService) Get(ctx context.Context, opts ...option.RequestOption) (
type Config struct { type Config struct {
// JSON schema reference for configuration validation // JSON schema reference for configuration validation
Schema string `json:"$schema"` Schema string `json:"$schema"`
// Modes configuration, see https://opencode.ai/docs/modes
Agent ConfigAgent `json:"agent"`
// @deprecated Use 'share' field instead. Share newly created sessions // @deprecated Use 'share' field instead. Share newly created sessions
// automatically // automatically
Autoshare bool `json:"autoshare"` Autoshare bool `json:"autoshare"`
@@ -81,6 +83,7 @@ type Config struct {
// configJSON contains the JSON metadata for the struct [Config] // configJSON contains the JSON metadata for the struct [Config]
type configJSON struct { type configJSON struct {
Schema apijson.Field Schema apijson.Field
Agent apijson.Field
Autoshare apijson.Field Autoshare apijson.Field
Autoupdate apijson.Field Autoupdate apijson.Field
DisabledProviders apijson.Field DisabledProviders apijson.Field
@@ -108,6 +111,50 @@ func (r configJSON) RawJSON() string {
return r.raw return r.raw
} }
// Modes configuration, see https://opencode.ai/docs/modes
type ConfigAgent struct {
General ConfigAgentGeneral `json:"general"`
ExtraFields map[string]ConfigAgent `json:"-,extras"`
JSON configAgentJSON `json:"-"`
}
// configAgentJSON contains the JSON metadata for the struct [ConfigAgent]
type configAgentJSON struct {
General apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ConfigAgent) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r configAgentJSON) RawJSON() string {
return r.raw
}
type ConfigAgentGeneral struct {
Description string `json:"description,required"`
JSON configAgentGeneralJSON `json:"-"`
ModeConfig
}
// configAgentGeneralJSON contains the JSON metadata for the struct
// [ConfigAgentGeneral]
type configAgentGeneralJSON struct {
Description apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *ConfigAgentGeneral) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r configAgentGeneralJSON) RawJSON() string {
return r.raw
}
type ConfigExperimental struct { type ConfigExperimental struct {
Hook ConfigExperimentalHook `json:"hook"` Hook ConfigExperimentalHook `json:"hook"`
JSON configExperimentalJSON `json:"-"` JSON configExperimentalJSON `json:"-"`
@@ -716,16 +763,20 @@ func (r McpRemoteConfigType) IsKnown() bool {
} }
type ModeConfig struct { type ModeConfig struct {
Disable bool `json:"disable"`
Model string `json:"model"` Model string `json:"model"`
Prompt string `json:"prompt"` Prompt string `json:"prompt"`
Temperature float64 `json:"temperature"`
Tools map[string]bool `json:"tools"` Tools map[string]bool `json:"tools"`
JSON modeConfigJSON `json:"-"` JSON modeConfigJSON `json:"-"`
} }
// modeConfigJSON contains the JSON metadata for the struct [ModeConfig] // modeConfigJSON contains the JSON metadata for the struct [ModeConfig]
type modeConfigJSON struct { type modeConfigJSON struct {
Disable apijson.Field
Model apijson.Field Model apijson.Field
Prompt apijson.Field Prompt apijson.Field
Temperature apijson.Field
Tools apijson.Field Tools apijson.Field
raw string raw string
ExtraFields map[string]apijson.Field ExtraFields map[string]apijson.Field

View File

@@ -48,19 +48,19 @@ func (r *EventService) ListStreaming(ctx context.Context, opts ...option.Request
type EventListResponse struct { type EventListResponse struct {
// This field can have the runtime type of // This field can have the runtime type of
// [EventListResponseEventLspClientDiagnosticsProperties],
// [EventListResponseEventPermissionUpdatedProperties],
// [EventListResponseEventFileEditedProperties],
// [EventListResponseEventInstallationUpdatedProperties], // [EventListResponseEventInstallationUpdatedProperties],
// [EventListResponseEventLspClientDiagnosticsProperties],
// [EventListResponseEventMessageUpdatedProperties], // [EventListResponseEventMessageUpdatedProperties],
// [EventListResponseEventMessageRemovedProperties], // [EventListResponseEventMessageRemovedProperties],
// [EventListResponseEventMessagePartUpdatedProperties], // [EventListResponseEventMessagePartUpdatedProperties],
// [EventListResponseEventMessagePartRemovedProperties], // [EventListResponseEventMessagePartRemovedProperties],
// [EventListResponseEventStorageWriteProperties], // [EventListResponseEventStorageWriteProperties],
// [EventListResponseEventPermissionUpdatedProperties],
// [EventListResponseEventFileEditedProperties],
// [EventListResponseEventSessionUpdatedProperties], // [EventListResponseEventSessionUpdatedProperties],
// [EventListResponseEventSessionDeletedProperties], // [EventListResponseEventSessionDeletedProperties],
// [EventListResponseEventSessionIdleProperties], // [EventListResponseEventSessionIdleProperties],
// [EventListResponseEventSessionErrorProperties], // [EventListResponseEventSessionErrorProperties], [interface{}],
// [EventListResponseEventFileWatcherUpdatedProperties], // [EventListResponseEventFileWatcherUpdatedProperties],
// [EventListResponseEventIdeInstalledProperties]. // [EventListResponseEventIdeInstalledProperties].
Properties interface{} `json:"properties,required"` Properties interface{} `json:"properties,required"`
@@ -95,31 +95,32 @@ func (r *EventListResponse) UnmarshalJSON(data []byte) (err error) {
// specific types for more type safety. // specific types for more type safety.
// //
// Possible runtime types of the union are // Possible runtime types of the union are
// [EventListResponseEventLspClientDiagnostics],
// [EventListResponseEventPermissionUpdated], [EventListResponseEventFileEdited],
// [EventListResponseEventInstallationUpdated], // [EventListResponseEventInstallationUpdated],
// [EventListResponseEventLspClientDiagnostics],
// [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved], // [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved],
// [EventListResponseEventMessagePartUpdated], // [EventListResponseEventMessagePartUpdated],
// [EventListResponseEventMessagePartRemoved], // [EventListResponseEventMessagePartRemoved],
// [EventListResponseEventStorageWrite], [EventListResponseEventSessionUpdated], // [EventListResponseEventStorageWrite], [EventListResponseEventPermissionUpdated],
// [EventListResponseEventFileEdited], [EventListResponseEventSessionUpdated],
// [EventListResponseEventSessionDeleted], [EventListResponseEventSessionIdle], // [EventListResponseEventSessionDeleted], [EventListResponseEventSessionIdle],
// [EventListResponseEventSessionError], // [EventListResponseEventSessionError], [EventListResponseEventServerConnected],
// [EventListResponseEventFileWatcherUpdated], // [EventListResponseEventFileWatcherUpdated],
// [EventListResponseEventIdeInstalled]. // [EventListResponseEventIdeInstalled].
func (r EventListResponse) AsUnion() EventListResponseUnion { func (r EventListResponse) AsUnion() EventListResponseUnion {
return r.union return r.union
} }
// Union satisfied by [EventListResponseEventLspClientDiagnostics], // Union satisfied by [EventListResponseEventInstallationUpdated],
// [EventListResponseEventPermissionUpdated], [EventListResponseEventFileEdited], // [EventListResponseEventLspClientDiagnostics],
// [EventListResponseEventInstallationUpdated],
// [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved], // [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved],
// [EventListResponseEventMessagePartUpdated], // [EventListResponseEventMessagePartUpdated],
// [EventListResponseEventMessagePartRemoved], // [EventListResponseEventMessagePartRemoved],
// [EventListResponseEventStorageWrite], [EventListResponseEventSessionUpdated], // [EventListResponseEventStorageWrite], [EventListResponseEventPermissionUpdated],
// [EventListResponseEventFileEdited], [EventListResponseEventSessionUpdated],
// [EventListResponseEventSessionDeleted], [EventListResponseEventSessionIdle], // [EventListResponseEventSessionDeleted], [EventListResponseEventSessionIdle],
// [EventListResponseEventSessionError], [EventListResponseEventFileWatcherUpdated] // [EventListResponseEventSessionError], [EventListResponseEventServerConnected],
// or [EventListResponseEventIdeInstalled]. // [EventListResponseEventFileWatcherUpdated] or
// [EventListResponseEventIdeInstalled].
type EventListResponseUnion interface { type EventListResponseUnion interface {
implementsEventListResponse() implementsEventListResponse()
} }
@@ -128,26 +129,16 @@ func init() {
apijson.RegisterUnion( apijson.RegisterUnion(
reflect.TypeOf((*EventListResponseUnion)(nil)).Elem(), reflect.TypeOf((*EventListResponseUnion)(nil)).Elem(),
"type", "type",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventLspClientDiagnostics{}),
DiscriminatorValue: "lsp.client.diagnostics",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventPermissionUpdated{}),
DiscriminatorValue: "permission.updated",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventFileEdited{}),
DiscriminatorValue: "file.edited",
},
apijson.UnionVariant{ apijson.UnionVariant{
TypeFilter: gjson.JSON, TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventInstallationUpdated{}), Type: reflect.TypeOf(EventListResponseEventInstallationUpdated{}),
DiscriminatorValue: "installation.updated", DiscriminatorValue: "installation.updated",
}, },
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventLspClientDiagnostics{}),
DiscriminatorValue: "lsp.client.diagnostics",
},
apijson.UnionVariant{ apijson.UnionVariant{
TypeFilter: gjson.JSON, TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventMessageUpdated{}), Type: reflect.TypeOf(EventListResponseEventMessageUpdated{}),
@@ -173,6 +164,16 @@ func init() {
Type: reflect.TypeOf(EventListResponseEventStorageWrite{}), Type: reflect.TypeOf(EventListResponseEventStorageWrite{}),
DiscriminatorValue: "storage.write", DiscriminatorValue: "storage.write",
}, },
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventPermissionUpdated{}),
DiscriminatorValue: "permission.updated",
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventFileEdited{}),
DiscriminatorValue: "file.edited",
},
apijson.UnionVariant{ apijson.UnionVariant{
TypeFilter: gjson.JSON, TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventSessionUpdated{}), Type: reflect.TypeOf(EventListResponseEventSessionUpdated{}),
@@ -193,6 +194,11 @@ func init() {
Type: reflect.TypeOf(EventListResponseEventSessionError{}), Type: reflect.TypeOf(EventListResponseEventSessionError{}),
DiscriminatorValue: "session.error", DiscriminatorValue: "session.error",
}, },
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventServerConnected{}),
DiscriminatorValue: "server.connected",
},
apijson.UnionVariant{ apijson.UnionVariant{
TypeFilter: gjson.JSON, TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventFileWatcherUpdated{}), Type: reflect.TypeOf(EventListResponseEventFileWatcherUpdated{}),
@@ -206,6 +212,66 @@ func init() {
) )
} }
type EventListResponseEventInstallationUpdated struct {
Properties EventListResponseEventInstallationUpdatedProperties `json:"properties,required"`
Type EventListResponseEventInstallationUpdatedType `json:"type,required"`
JSON eventListResponseEventInstallationUpdatedJSON `json:"-"`
}
// eventListResponseEventInstallationUpdatedJSON contains the JSON metadata for the
// struct [EventListResponseEventInstallationUpdated]
type eventListResponseEventInstallationUpdatedJSON struct {
Properties apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventInstallationUpdated) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventInstallationUpdatedJSON) RawJSON() string {
return r.raw
}
func (r EventListResponseEventInstallationUpdated) implementsEventListResponse() {}
type EventListResponseEventInstallationUpdatedProperties struct {
Version string `json:"version,required"`
JSON eventListResponseEventInstallationUpdatedPropertiesJSON `json:"-"`
}
// eventListResponseEventInstallationUpdatedPropertiesJSON contains the JSON
// metadata for the struct [EventListResponseEventInstallationUpdatedProperties]
type eventListResponseEventInstallationUpdatedPropertiesJSON struct {
Version apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventInstallationUpdatedProperties) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventInstallationUpdatedPropertiesJSON) RawJSON() string {
return r.raw
}
type EventListResponseEventInstallationUpdatedType string
const (
EventListResponseEventInstallationUpdatedTypeInstallationUpdated EventListResponseEventInstallationUpdatedType = "installation.updated"
)
func (r EventListResponseEventInstallationUpdatedType) IsKnown() bool {
switch r {
case EventListResponseEventInstallationUpdatedTypeInstallationUpdated:
return true
}
return false
}
type EventListResponseEventLspClientDiagnostics struct { type EventListResponseEventLspClientDiagnostics struct {
Properties EventListResponseEventLspClientDiagnosticsProperties `json:"properties,required"` Properties EventListResponseEventLspClientDiagnosticsProperties `json:"properties,required"`
Type EventListResponseEventLspClientDiagnosticsType `json:"type,required"` Type EventListResponseEventLspClientDiagnosticsType `json:"type,required"`
@@ -268,215 +334,6 @@ func (r EventListResponseEventLspClientDiagnosticsType) IsKnown() bool {
return false return false
} }
type EventListResponseEventPermissionUpdated struct {
Properties EventListResponseEventPermissionUpdatedProperties `json:"properties,required"`
Type EventListResponseEventPermissionUpdatedType `json:"type,required"`
JSON eventListResponseEventPermissionUpdatedJSON `json:"-"`
}
// eventListResponseEventPermissionUpdatedJSON contains the JSON metadata for the
// struct [EventListResponseEventPermissionUpdated]
type eventListResponseEventPermissionUpdatedJSON struct {
Properties apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventPermissionUpdated) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventPermissionUpdatedJSON) RawJSON() string {
return r.raw
}
func (r EventListResponseEventPermissionUpdated) implementsEventListResponse() {}
type EventListResponseEventPermissionUpdatedProperties struct {
ID string `json:"id,required"`
Metadata map[string]interface{} `json:"metadata,required"`
SessionID string `json:"sessionID,required"`
Time EventListResponseEventPermissionUpdatedPropertiesTime `json:"time,required"`
Title string `json:"title,required"`
JSON eventListResponseEventPermissionUpdatedPropertiesJSON `json:"-"`
}
// eventListResponseEventPermissionUpdatedPropertiesJSON contains the JSON metadata
// for the struct [EventListResponseEventPermissionUpdatedProperties]
type eventListResponseEventPermissionUpdatedPropertiesJSON struct {
ID apijson.Field
Metadata apijson.Field
SessionID apijson.Field
Time apijson.Field
Title apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventPermissionUpdatedProperties) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventPermissionUpdatedPropertiesJSON) RawJSON() string {
return r.raw
}
type EventListResponseEventPermissionUpdatedPropertiesTime struct {
Created float64 `json:"created,required"`
JSON eventListResponseEventPermissionUpdatedPropertiesTimeJSON `json:"-"`
}
// eventListResponseEventPermissionUpdatedPropertiesTimeJSON contains the JSON
// metadata for the struct [EventListResponseEventPermissionUpdatedPropertiesTime]
type eventListResponseEventPermissionUpdatedPropertiesTimeJSON struct {
Created apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventPermissionUpdatedPropertiesTime) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventPermissionUpdatedPropertiesTimeJSON) RawJSON() string {
return r.raw
}
type EventListResponseEventPermissionUpdatedType string
const (
EventListResponseEventPermissionUpdatedTypePermissionUpdated EventListResponseEventPermissionUpdatedType = "permission.updated"
)
func (r EventListResponseEventPermissionUpdatedType) IsKnown() bool {
switch r {
case EventListResponseEventPermissionUpdatedTypePermissionUpdated:
return true
}
return false
}
type EventListResponseEventFileEdited struct {
Properties EventListResponseEventFileEditedProperties `json:"properties,required"`
Type EventListResponseEventFileEditedType `json:"type,required"`
JSON eventListResponseEventFileEditedJSON `json:"-"`
}
// eventListResponseEventFileEditedJSON contains the JSON metadata for the struct
// [EventListResponseEventFileEdited]
type eventListResponseEventFileEditedJSON struct {
Properties apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventFileEdited) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventFileEditedJSON) RawJSON() string {
return r.raw
}
func (r EventListResponseEventFileEdited) implementsEventListResponse() {}
type EventListResponseEventFileEditedProperties struct {
File string `json:"file,required"`
JSON eventListResponseEventFileEditedPropertiesJSON `json:"-"`
}
// eventListResponseEventFileEditedPropertiesJSON contains the JSON metadata for
// the struct [EventListResponseEventFileEditedProperties]
type eventListResponseEventFileEditedPropertiesJSON struct {
File apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventFileEditedProperties) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventFileEditedPropertiesJSON) RawJSON() string {
return r.raw
}
type EventListResponseEventFileEditedType string
const (
EventListResponseEventFileEditedTypeFileEdited EventListResponseEventFileEditedType = "file.edited"
)
func (r EventListResponseEventFileEditedType) IsKnown() bool {
switch r {
case EventListResponseEventFileEditedTypeFileEdited:
return true
}
return false
}
type EventListResponseEventInstallationUpdated struct {
Properties EventListResponseEventInstallationUpdatedProperties `json:"properties,required"`
Type EventListResponseEventInstallationUpdatedType `json:"type,required"`
JSON eventListResponseEventInstallationUpdatedJSON `json:"-"`
}
// eventListResponseEventInstallationUpdatedJSON contains the JSON metadata for the
// struct [EventListResponseEventInstallationUpdated]
type eventListResponseEventInstallationUpdatedJSON struct {
Properties apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventInstallationUpdated) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventInstallationUpdatedJSON) RawJSON() string {
return r.raw
}
func (r EventListResponseEventInstallationUpdated) implementsEventListResponse() {}
type EventListResponseEventInstallationUpdatedProperties struct {
Version string `json:"version,required"`
JSON eventListResponseEventInstallationUpdatedPropertiesJSON `json:"-"`
}
// eventListResponseEventInstallationUpdatedPropertiesJSON contains the JSON
// metadata for the struct [EventListResponseEventInstallationUpdatedProperties]
type eventListResponseEventInstallationUpdatedPropertiesJSON struct {
Version apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventInstallationUpdatedProperties) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventInstallationUpdatedPropertiesJSON) RawJSON() string {
return r.raw
}
type EventListResponseEventInstallationUpdatedType string
const (
EventListResponseEventInstallationUpdatedTypeInstallationUpdated EventListResponseEventInstallationUpdatedType = "installation.updated"
)
func (r EventListResponseEventInstallationUpdatedType) IsKnown() bool {
switch r {
case EventListResponseEventInstallationUpdatedTypeInstallationUpdated:
return true
}
return false
}
type EventListResponseEventMessageUpdated struct { type EventListResponseEventMessageUpdated struct {
Properties EventListResponseEventMessageUpdatedProperties `json:"properties,required"` Properties EventListResponseEventMessageUpdatedProperties `json:"properties,required"`
Type EventListResponseEventMessageUpdatedType `json:"type,required"` Type EventListResponseEventMessageUpdatedType `json:"type,required"`
@@ -687,6 +544,7 @@ func (r EventListResponseEventMessagePartRemoved) implementsEventListResponse()
type EventListResponseEventMessagePartRemovedProperties struct { type EventListResponseEventMessagePartRemovedProperties struct {
MessageID string `json:"messageID,required"` MessageID string `json:"messageID,required"`
PartID string `json:"partID,required"` PartID string `json:"partID,required"`
SessionID string `json:"sessionID,required"`
JSON eventListResponseEventMessagePartRemovedPropertiesJSON `json:"-"` JSON eventListResponseEventMessagePartRemovedPropertiesJSON `json:"-"`
} }
@@ -695,6 +553,7 @@ type EventListResponseEventMessagePartRemovedProperties struct {
type eventListResponseEventMessagePartRemovedPropertiesJSON struct { type eventListResponseEventMessagePartRemovedPropertiesJSON struct {
MessageID apijson.Field MessageID apijson.Field
PartID apijson.Field PartID apijson.Field
SessionID apijson.Field
raw string raw string
ExtraFields map[string]apijson.Field ExtraFields map[string]apijson.Field
} }
@@ -783,6 +642,155 @@ func (r EventListResponseEventStorageWriteType) IsKnown() bool {
return false return false
} }
type EventListResponseEventPermissionUpdated struct {
Properties EventListResponseEventPermissionUpdatedProperties `json:"properties,required"`
Type EventListResponseEventPermissionUpdatedType `json:"type,required"`
JSON eventListResponseEventPermissionUpdatedJSON `json:"-"`
}
// eventListResponseEventPermissionUpdatedJSON contains the JSON metadata for the
// struct [EventListResponseEventPermissionUpdated]
type eventListResponseEventPermissionUpdatedJSON struct {
Properties apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventPermissionUpdated) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventPermissionUpdatedJSON) RawJSON() string {
return r.raw
}
func (r EventListResponseEventPermissionUpdated) implementsEventListResponse() {}
type EventListResponseEventPermissionUpdatedProperties struct {
ID string `json:"id,required"`
Metadata map[string]interface{} `json:"metadata,required"`
SessionID string `json:"sessionID,required"`
Time EventListResponseEventPermissionUpdatedPropertiesTime `json:"time,required"`
Title string `json:"title,required"`
JSON eventListResponseEventPermissionUpdatedPropertiesJSON `json:"-"`
}
// eventListResponseEventPermissionUpdatedPropertiesJSON contains the JSON metadata
// for the struct [EventListResponseEventPermissionUpdatedProperties]
type eventListResponseEventPermissionUpdatedPropertiesJSON struct {
ID apijson.Field
Metadata apijson.Field
SessionID apijson.Field
Time apijson.Field
Title apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventPermissionUpdatedProperties) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventPermissionUpdatedPropertiesJSON) RawJSON() string {
return r.raw
}
type EventListResponseEventPermissionUpdatedPropertiesTime struct {
Created float64 `json:"created,required"`
JSON eventListResponseEventPermissionUpdatedPropertiesTimeJSON `json:"-"`
}
// eventListResponseEventPermissionUpdatedPropertiesTimeJSON contains the JSON
// metadata for the struct [EventListResponseEventPermissionUpdatedPropertiesTime]
type eventListResponseEventPermissionUpdatedPropertiesTimeJSON struct {
Created apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventPermissionUpdatedPropertiesTime) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventPermissionUpdatedPropertiesTimeJSON) RawJSON() string {
return r.raw
}
type EventListResponseEventPermissionUpdatedType string
const (
EventListResponseEventPermissionUpdatedTypePermissionUpdated EventListResponseEventPermissionUpdatedType = "permission.updated"
)
func (r EventListResponseEventPermissionUpdatedType) IsKnown() bool {
switch r {
case EventListResponseEventPermissionUpdatedTypePermissionUpdated:
return true
}
return false
}
type EventListResponseEventFileEdited struct {
Properties EventListResponseEventFileEditedProperties `json:"properties,required"`
Type EventListResponseEventFileEditedType `json:"type,required"`
JSON eventListResponseEventFileEditedJSON `json:"-"`
}
// eventListResponseEventFileEditedJSON contains the JSON metadata for the struct
// [EventListResponseEventFileEdited]
type eventListResponseEventFileEditedJSON struct {
Properties apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventFileEdited) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventFileEditedJSON) RawJSON() string {
return r.raw
}
func (r EventListResponseEventFileEdited) implementsEventListResponse() {}
type EventListResponseEventFileEditedProperties struct {
File string `json:"file,required"`
JSON eventListResponseEventFileEditedPropertiesJSON `json:"-"`
}
// eventListResponseEventFileEditedPropertiesJSON contains the JSON metadata for
// the struct [EventListResponseEventFileEditedProperties]
type eventListResponseEventFileEditedPropertiesJSON struct {
File apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventFileEditedProperties) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventFileEditedPropertiesJSON) RawJSON() string {
return r.raw
}
type EventListResponseEventFileEditedType string
const (
EventListResponseEventFileEditedTypeFileEdited EventListResponseEventFileEditedType = "file.edited"
)
func (r EventListResponseEventFileEditedType) IsKnown() bool {
switch r {
case EventListResponseEventFileEditedTypeFileEdited:
return true
}
return false
}
type EventListResponseEventSessionUpdated struct { type EventListResponseEventSessionUpdated struct {
Properties EventListResponseEventSessionUpdatedProperties `json:"properties,required"` Properties EventListResponseEventSessionUpdatedProperties `json:"properties,required"`
Type EventListResponseEventSessionUpdatedType `json:"type,required"` Type EventListResponseEventSessionUpdatedType `json:"type,required"`
@@ -1159,6 +1167,45 @@ func (r EventListResponseEventSessionErrorType) IsKnown() bool {
return false return false
} }
type EventListResponseEventServerConnected struct {
Properties interface{} `json:"properties,required"`
Type EventListResponseEventServerConnectedType `json:"type,required"`
JSON eventListResponseEventServerConnectedJSON `json:"-"`
}
// eventListResponseEventServerConnectedJSON contains the JSON metadata for the
// struct [EventListResponseEventServerConnected]
type eventListResponseEventServerConnectedJSON struct {
Properties apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *EventListResponseEventServerConnected) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r eventListResponseEventServerConnectedJSON) RawJSON() string {
return r.raw
}
func (r EventListResponseEventServerConnected) implementsEventListResponse() {}
type EventListResponseEventServerConnectedType string
const (
EventListResponseEventServerConnectedTypeServerConnected EventListResponseEventServerConnectedType = "server.connected"
)
func (r EventListResponseEventServerConnectedType) IsKnown() bool {
switch r {
case EventListResponseEventServerConnectedTypeServerConnected:
return true
}
return false
}
type EventListResponseEventFileWatcherUpdated struct { type EventListResponseEventFileWatcherUpdated struct {
Properties EventListResponseEventFileWatcherUpdatedProperties `json:"properties,required"` Properties EventListResponseEventFileWatcherUpdatedProperties `json:"properties,required"`
Type EventListResponseEventFileWatcherUpdatedType `json:"type,required"` Type EventListResponseEventFileWatcherUpdatedType `json:"type,required"`
@@ -1299,26 +1346,27 @@ func (r EventListResponseEventIdeInstalledType) IsKnown() bool {
type EventListResponseType string type EventListResponseType string
const ( const (
EventListResponseTypeLspClientDiagnostics EventListResponseType = "lsp.client.diagnostics"
EventListResponseTypePermissionUpdated EventListResponseType = "permission.updated"
EventListResponseTypeFileEdited EventListResponseType = "file.edited"
EventListResponseTypeInstallationUpdated EventListResponseType = "installation.updated" EventListResponseTypeInstallationUpdated EventListResponseType = "installation.updated"
EventListResponseTypeLspClientDiagnostics EventListResponseType = "lsp.client.diagnostics"
EventListResponseTypeMessageUpdated EventListResponseType = "message.updated" EventListResponseTypeMessageUpdated EventListResponseType = "message.updated"
EventListResponseTypeMessageRemoved EventListResponseType = "message.removed" EventListResponseTypeMessageRemoved EventListResponseType = "message.removed"
EventListResponseTypeMessagePartUpdated EventListResponseType = "message.part.updated" EventListResponseTypeMessagePartUpdated EventListResponseType = "message.part.updated"
EventListResponseTypeMessagePartRemoved EventListResponseType = "message.part.removed" EventListResponseTypeMessagePartRemoved EventListResponseType = "message.part.removed"
EventListResponseTypeStorageWrite EventListResponseType = "storage.write" EventListResponseTypeStorageWrite EventListResponseType = "storage.write"
EventListResponseTypePermissionUpdated EventListResponseType = "permission.updated"
EventListResponseTypeFileEdited EventListResponseType = "file.edited"
EventListResponseTypeSessionUpdated EventListResponseType = "session.updated" EventListResponseTypeSessionUpdated EventListResponseType = "session.updated"
EventListResponseTypeSessionDeleted EventListResponseType = "session.deleted" EventListResponseTypeSessionDeleted EventListResponseType = "session.deleted"
EventListResponseTypeSessionIdle EventListResponseType = "session.idle" EventListResponseTypeSessionIdle EventListResponseType = "session.idle"
EventListResponseTypeSessionError EventListResponseType = "session.error" EventListResponseTypeSessionError EventListResponseType = "session.error"
EventListResponseTypeServerConnected EventListResponseType = "server.connected"
EventListResponseTypeFileWatcherUpdated EventListResponseType = "file.watcher.updated" EventListResponseTypeFileWatcherUpdated EventListResponseType = "file.watcher.updated"
EventListResponseTypeIdeInstalled EventListResponseType = "ide.installed" EventListResponseTypeIdeInstalled EventListResponseType = "ide.installed"
) )
func (r EventListResponseType) IsKnown() bool { func (r EventListResponseType) IsKnown() bool {
switch r { switch r {
case EventListResponseTypeLspClientDiagnostics, EventListResponseTypePermissionUpdated, EventListResponseTypeFileEdited, EventListResponseTypeInstallationUpdated, EventListResponseTypeMessageUpdated, EventListResponseTypeMessageRemoved, EventListResponseTypeMessagePartUpdated, EventListResponseTypeMessagePartRemoved, EventListResponseTypeStorageWrite, EventListResponseTypeSessionUpdated, EventListResponseTypeSessionDeleted, EventListResponseTypeSessionIdle, EventListResponseTypeSessionError, EventListResponseTypeFileWatcherUpdated, EventListResponseTypeIdeInstalled: case EventListResponseTypeInstallationUpdated, EventListResponseTypeLspClientDiagnostics, EventListResponseTypeMessageUpdated, EventListResponseTypeMessageRemoved, EventListResponseTypeMessagePartUpdated, EventListResponseTypeMessagePartRemoved, EventListResponseTypeStorageWrite, EventListResponseTypePermissionUpdated, EventListResponseTypeFileEdited, EventListResponseTypeSessionUpdated, EventListResponseTypeSessionDeleted, EventListResponseTypeSessionIdle, EventListResponseTypeSessionError, EventListResponseTypeServerConnected, EventListResponseTypeFileWatcherUpdated, EventListResponseTypeIdeInstalled:
return true return true
} }
return false return false

View File

@@ -50,126 +50,13 @@ func (r *FindService) Symbols(ctx context.Context, query FindSymbolsParams, opts
} }
// Find text in files // Find text in files
func (r *FindService) Text(ctx context.Context, query FindTextParams, opts ...option.RequestOption) (res *[]Match, err error) { func (r *FindService) Text(ctx context.Context, query FindTextParams, opts ...option.RequestOption) (res *[]FindTextResponse, err error) {
opts = append(r.Options[:], opts...) opts = append(r.Options[:], opts...)
path := "find" path := "find"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return return
} }
type Match struct {
AbsoluteOffset float64 `json:"absolute_offset,required"`
LineNumber float64 `json:"line_number,required"`
Lines MatchLines `json:"lines,required"`
Path MatchPath `json:"path,required"`
Submatches []MatchSubmatch `json:"submatches,required"`
JSON matchJSON `json:"-"`
}
// matchJSON contains the JSON metadata for the struct [Match]
type matchJSON struct {
AbsoluteOffset apijson.Field
LineNumber apijson.Field
Lines apijson.Field
Path apijson.Field
Submatches apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *Match) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r matchJSON) RawJSON() string {
return r.raw
}
type MatchLines struct {
Text string `json:"text,required"`
JSON matchLinesJSON `json:"-"`
}
// matchLinesJSON contains the JSON metadata for the struct [MatchLines]
type matchLinesJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MatchLines) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r matchLinesJSON) RawJSON() string {
return r.raw
}
type MatchPath struct {
Text string `json:"text,required"`
JSON matchPathJSON `json:"-"`
}
// matchPathJSON contains the JSON metadata for the struct [MatchPath]
type matchPathJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MatchPath) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r matchPathJSON) RawJSON() string {
return r.raw
}
type MatchSubmatch struct {
End float64 `json:"end,required"`
Match MatchSubmatchesMatch `json:"match,required"`
Start float64 `json:"start,required"`
JSON matchSubmatchJSON `json:"-"`
}
// matchSubmatchJSON contains the JSON metadata for the struct [MatchSubmatch]
type matchSubmatchJSON struct {
End apijson.Field
Match apijson.Field
Start apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MatchSubmatch) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r matchSubmatchJSON) RawJSON() string {
return r.raw
}
type MatchSubmatchesMatch struct {
Text string `json:"text,required"`
JSON matchSubmatchesMatchJSON `json:"-"`
}
// matchSubmatchesMatchJSON contains the JSON metadata for the struct
// [MatchSubmatchesMatch]
type matchSubmatchesMatchJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *MatchSubmatchesMatch) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r matchSubmatchesMatchJSON) RawJSON() string {
return r.raw
}
type Symbol struct { type Symbol struct {
Kind float64 `json:"kind,required"` Kind float64 `json:"kind,required"`
Location SymbolLocation `json:"location,required"` Location SymbolLocation `json:"location,required"`
@@ -285,6 +172,123 @@ func (r symbolLocationRangeStartJSON) RawJSON() string {
return r.raw return r.raw
} }
type FindTextResponse struct {
AbsoluteOffset float64 `json:"absolute_offset,required"`
LineNumber float64 `json:"line_number,required"`
Lines FindTextResponseLines `json:"lines,required"`
Path FindTextResponsePath `json:"path,required"`
Submatches []FindTextResponseSubmatch `json:"submatches,required"`
JSON findTextResponseJSON `json:"-"`
}
// findTextResponseJSON contains the JSON metadata for the struct
// [FindTextResponse]
type findTextResponseJSON struct {
AbsoluteOffset apijson.Field
LineNumber apijson.Field
Lines apijson.Field
Path apijson.Field
Submatches apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FindTextResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r findTextResponseJSON) RawJSON() string {
return r.raw
}
type FindTextResponseLines struct {
Text string `json:"text,required"`
JSON findTextResponseLinesJSON `json:"-"`
}
// findTextResponseLinesJSON contains the JSON metadata for the struct
// [FindTextResponseLines]
type findTextResponseLinesJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FindTextResponseLines) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r findTextResponseLinesJSON) RawJSON() string {
return r.raw
}
type FindTextResponsePath struct {
Text string `json:"text,required"`
JSON findTextResponsePathJSON `json:"-"`
}
// findTextResponsePathJSON contains the JSON metadata for the struct
// [FindTextResponsePath]
type findTextResponsePathJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FindTextResponsePath) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r findTextResponsePathJSON) RawJSON() string {
return r.raw
}
type FindTextResponseSubmatch struct {
End float64 `json:"end,required"`
Match FindTextResponseSubmatchesMatch `json:"match,required"`
Start float64 `json:"start,required"`
JSON findTextResponseSubmatchJSON `json:"-"`
}
// findTextResponseSubmatchJSON contains the JSON metadata for the struct
// [FindTextResponseSubmatch]
type findTextResponseSubmatchJSON struct {
End apijson.Field
Match apijson.Field
Start apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FindTextResponseSubmatch) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r findTextResponseSubmatchJSON) RawJSON() string {
return r.raw
}
type FindTextResponseSubmatchesMatch struct {
Text string `json:"text,required"`
JSON findTextResponseSubmatchesMatchJSON `json:"-"`
}
// findTextResponseSubmatchesMatchJSON contains the JSON metadata for the struct
// [FindTextResponseSubmatchesMatch]
type findTextResponseSubmatchesMatchJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *FindTextResponseSubmatchesMatch) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r findTextResponseSubmatchesMatchJSON) RawJSON() string {
return r.raw
}
type FindFilesParams struct { type FindFilesParams struct {
Query param.Field[string] `query:"query,required"` Query param.Field[string] `query:"query,required"`
} }

View File

@@ -1073,6 +1073,7 @@ func (r sessionTimeJSON) RawJSON() string {
type SessionRevert struct { type SessionRevert struct {
MessageID string `json:"messageID,required"` MessageID string `json:"messageID,required"`
Diff string `json:"diff"`
PartID string `json:"partID"` PartID string `json:"partID"`
Snapshot string `json:"snapshot"` Snapshot string `json:"snapshot"`
JSON sessionRevertJSON `json:"-"` JSON sessionRevertJSON `json:"-"`
@@ -1081,6 +1082,7 @@ type SessionRevert struct {
// sessionRevertJSON contains the JSON metadata for the struct [SessionRevert] // sessionRevertJSON contains the JSON metadata for the struct [SessionRevert]
type sessionRevertJSON struct { type sessionRevertJSON struct {
MessageID apijson.Field MessageID apijson.Field
Diff apijson.Field
PartID apijson.Field PartID apijson.Field
Snapshot apijson.Field Snapshot apijson.Field
raw string raw string
@@ -2039,6 +2041,7 @@ type SessionChatParams struct {
ProviderID param.Field[string] `json:"providerID,required"` ProviderID param.Field[string] `json:"providerID,required"`
MessageID param.Field[string] `json:"messageID"` MessageID param.Field[string] `json:"messageID"`
Mode param.Field[string] `json:"mode"` Mode param.Field[string] `json:"mode"`
System param.Field[string] `json:"system"`
Tools param.Field[map[string]bool] `json:"tools"` Tools param.Field[map[string]bool] `json:"tools"`
} }

View File

@@ -131,6 +131,7 @@ func TestSessionChatWithOptionalParams(t *testing.T) {
ProviderID: opencode.F("providerID"), ProviderID: opencode.F("providerID"),
MessageID: opencode.F("msg"), MessageID: opencode.F("msg"),
Mode: opencode.F("mode"), Mode: opencode.F("mode"),
System: opencode.F("system"),
Tools: opencode.F(map[string]bool{ Tools: opencode.F(map[string]bool{
"foo": true, "foo": true,
}), }),