From a50bef69139976e9ce95c71a2757afcf835c34ec Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Sun, 3 Aug 2025 17:08:42 -0400 Subject: [PATCH] ignore: cleanup --- packages/sdk/.github/workflows/ci.yml | 88 --- .../sdk/.github/workflows/publish-npm.yml | 32 - .../sdk/.github/workflows/release-doctor.yml | 21 - packages/sdk/go/.stats.yml | 4 +- packages/sdk/go/app.go | 2 + packages/sdk/go/config.go | 173 ++++- packages/sdk/go/event.go | 244 +++---- packages/sdk/src/resources/session/index.ts | 44 -- .../sdk/src/resources/session/permissions.ts | 64 -- packages/sdk/src/resources/session/session.ts | 645 ------------------ .../api-resources/session/permissions.test.ts | 27 - script/publish.ts | 1 - 12 files changed, 297 insertions(+), 1048 deletions(-) delete mode 100644 packages/sdk/.github/workflows/ci.yml delete mode 100644 packages/sdk/.github/workflows/publish-npm.yml delete mode 100644 packages/sdk/.github/workflows/release-doctor.yml delete mode 100644 packages/sdk/src/resources/session/index.ts delete mode 100644 packages/sdk/src/resources/session/permissions.ts delete mode 100644 packages/sdk/src/resources/session/session.ts delete mode 100644 packages/sdk/tests/api-resources/session/permissions.test.ts diff --git a/packages/sdk/.github/workflows/ci.yml b/packages/sdk/.github/workflows/ci.yml deleted file mode 100644 index 5770c194..00000000 --- a/packages/sdk/.github/workflows/ci.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: CI -on: - push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' - pull_request: - branches-ignore: - - 'stl-preview-head/**' - - 'stl-preview-base/**' - -jobs: - lint: - timeout-minutes: 10 - name: lint - runs-on: ${{ github.repository == 'stainless-sdks/opencode-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork - steps: - - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Bootstrap - run: ./scripts/bootstrap - - - name: Check types - run: ./scripts/lint - - build: - timeout-minutes: 5 - name: build - runs-on: ${{ github.repository == 'stainless-sdks/opencode-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork - permissions: - contents: read - id-token: write - steps: - - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Bootstrap - run: ./scripts/bootstrap - - - name: Check build - run: ./scripts/build - - - name: Get GitHub OIDC Token - if: github.repository == 'stainless-sdks/opencode-typescript' - id: github-oidc - uses: actions/github-script@v6 - with: - script: core.setOutput('github_token', await core.getIDToken()); - - - name: Upload tarball - if: github.repository == 'stainless-sdks/opencode-typescript' - env: - URL: https://pkg.stainless.com/s - AUTH: ${{ steps.github-oidc.outputs.github_token }} - SHA: ${{ github.sha }} - run: ./scripts/utils/upload-artifact.sh - test: - timeout-minutes: 10 - name: test - runs-on: ${{ github.repository == 'stainless-sdks/opencode-typescript' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork - steps: - - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v4 - with: - node-version: '20' - - - name: Bootstrap - run: ./scripts/bootstrap - - - name: Run tests - run: ./scripts/test diff --git a/packages/sdk/.github/workflows/publish-npm.yml b/packages/sdk/.github/workflows/publish-npm.yml deleted file mode 100644 index 787fb3a7..00000000 --- a/packages/sdk/.github/workflows/publish-npm.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This workflow is triggered when a GitHub release is created. -# It can also be run manually to re-publish to NPM in case it failed for some reason. -# You can run this workflow by navigating to https://www.github.com/sst/opencode-sdk-js/actions/workflows/publish-npm.yml -name: Publish NPM -on: - workflow_dispatch: - - release: - types: [published] - -jobs: - publish: - name: publish - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Set up Node - uses: actions/setup-node@v3 - with: - node-version: '20' - - - name: Install dependencies - run: | - yarn install - - - name: Publish to NPM - run: | - bash ./bin/publish-npm - env: - NPM_TOKEN: ${{ secrets.OPENCODE_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/packages/sdk/.github/workflows/release-doctor.yml b/packages/sdk/.github/workflows/release-doctor.yml deleted file mode 100644 index d3a4b9e5..00000000 --- a/packages/sdk/.github/workflows/release-doctor.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Release Doctor -on: - pull_request: - branches: - - main - workflow_dispatch: - -jobs: - release_doctor: - name: release doctor - runs-on: ubuntu-latest - if: github.repository == 'sst/opencode-sdk-js' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') - - steps: - - uses: actions/checkout@v4 - - - name: Check release environment - run: | - bash ./bin/check-release-environment - env: - NPM_TOKEN: ${{ secrets.OPENCODE_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/packages/sdk/go/.stats.yml b/packages/sdk/go/.stats.yml index 7b29797c..013bb9ac 100644 --- a/packages/sdk/go/.stats.yml +++ b/packages/sdk/go/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 34 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-2ebd9d5478864042a2e01b4995f42acbc39069fa7fcccd1c2e567366ee6c243d.yml -openapi_spec_hash: 2a34451b288ea30af1cb61332c417c2a +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-52fd0b61e84fdc1cdd31ec12e1600510e9dd2f9d4fb20c2315b4975cb763ee98.yml +openapi_spec_hash: e851b8d5a2412f5fc9be82ab88ebdfde config_hash: 11a6f0803eb407367c3f677d3e524c37 diff --git a/packages/sdk/go/app.go b/packages/sdk/go/app.go index 479011a2..0a7d14e7 100644 --- a/packages/sdk/go/app.go +++ b/packages/sdk/go/app.go @@ -151,6 +151,7 @@ type Mode struct { Model ModeModel `json:"model"` Prompt string `json:"prompt"` Temperature float64 `json:"temperature"` + TopP float64 `json:"topP"` JSON modeJSON `json:"-"` } @@ -161,6 +162,7 @@ type modeJSON struct { Model apijson.Field Prompt apijson.Field Temperature apijson.Field + TopP apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/packages/sdk/go/config.go b/packages/sdk/go/config.go index 5fcfd1ed..77b1b760 100644 --- a/packages/sdk/go/config.go +++ b/packages/sdk/go/config.go @@ -51,14 +51,16 @@ type Config struct { // Automatically update to the latest version Autoupdate bool `json:"autoupdate"` // Disable providers that are loaded automatically - DisabledProviders []string `json:"disabled_providers"` - Experimental ConfigExperimental `json:"experimental"` + DisabledProviders []string `json:"disabled_providers"` + Experimental ConfigExperimental `json:"experimental"` + Formatter map[string]ConfigFormatter `json:"formatter"` // Additional instruction files or patterns to include Instructions []string `json:"instructions"` // Custom keybind configurations Keybinds KeybindsConfig `json:"keybinds"` // @deprecated Always uses stretch layout. - Layout ConfigLayout `json:"layout"` + Layout ConfigLayout `json:"layout"` + Lsp map[string]ConfigLsp `json:"lsp"` // MCP (Model Context Protocol) server configurations Mcp map[string]ConfigMcp `json:"mcp"` // Modes configuration, see https://opencode.ai/docs/modes @@ -66,6 +68,7 @@ type Config struct { // Model to use in the format of provider/model, eg anthropic/claude-2 Model string `json:"model"` Permission ConfigPermission `json:"permission"` + Plugin []string `json:"plugin"` // Custom provider configurations and model overrides Provider map[string]ConfigProvider `json:"provider"` // Control sharing behavior:'manual' allows manual sharing via commands, 'auto' @@ -89,13 +92,16 @@ type configJSON struct { Autoupdate apijson.Field DisabledProviders apijson.Field Experimental apijson.Field + Formatter apijson.Field Instructions apijson.Field Keybinds apijson.Field Layout apijson.Field + Lsp apijson.Field Mcp apijson.Field Mode apijson.Field Model apijson.Field Permission apijson.Field + Plugin apijson.Field Provider apijson.Field Share apijson.Field SmallModel apijson.Field @@ -247,6 +253,32 @@ func (r configExperimentalHookSessionCompletedJSON) RawJSON() string { return r.raw } +type ConfigFormatter struct { + Command []string `json:"command"` + Disabled bool `json:"disabled"` + Environment map[string]string `json:"environment"` + Extensions []string `json:"extensions"` + JSON configFormatterJSON `json:"-"` +} + +// configFormatterJSON contains the JSON metadata for the struct [ConfigFormatter] +type configFormatterJSON struct { + Command apijson.Field + Disabled apijson.Field + Environment apijson.Field + Extensions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigFormatter) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configFormatterJSON) RawJSON() string { + return r.raw +} + // @deprecated Always uses stretch layout. type ConfigLayout string @@ -263,6 +295,139 @@ func (r ConfigLayout) IsKnown() bool { return false } +type ConfigLsp struct { + // This field can have the runtime type of [[]string]. + Command interface{} `json:"command"` + Disabled bool `json:"disabled"` + // This field can have the runtime type of [map[string]string]. + Env interface{} `json:"env"` + // This field can have the runtime type of [[]string]. + Extensions interface{} `json:"extensions"` + // This field can have the runtime type of [map[string]interface{}]. + Initialization interface{} `json:"initialization"` + JSON configLspJSON `json:"-"` + union ConfigLspUnion +} + +// configLspJSON contains the JSON metadata for the struct [ConfigLsp] +type configLspJSON struct { + Command apijson.Field + Disabled apijson.Field + Env apijson.Field + Extensions apijson.Field + Initialization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r configLspJSON) RawJSON() string { + return r.raw +} + +func (r *ConfigLsp) UnmarshalJSON(data []byte) (err error) { + *r = ConfigLsp{} + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +// AsUnion returns a [ConfigLspUnion] interface which you can cast to the specific +// types for more type safety. +// +// Possible runtime types of the union are [ConfigLspDisabled], [ConfigLspObject]. +func (r ConfigLsp) AsUnion() ConfigLspUnion { + return r.union +} + +// Union satisfied by [ConfigLspDisabled] or [ConfigLspObject]. +type ConfigLspUnion interface { + implementsConfigLsp() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ConfigLspUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ConfigLspDisabled{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ConfigLspObject{}), + }, + ) +} + +type ConfigLspDisabled struct { + Disabled ConfigLspDisabledDisabled `json:"disabled,required"` + JSON configLspDisabledJSON `json:"-"` +} + +// configLspDisabledJSON contains the JSON metadata for the struct +// [ConfigLspDisabled] +type configLspDisabledJSON struct { + Disabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigLspDisabled) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configLspDisabledJSON) RawJSON() string { + return r.raw +} + +func (r ConfigLspDisabled) implementsConfigLsp() {} + +type ConfigLspDisabledDisabled bool + +const ( + ConfigLspDisabledDisabledTrue ConfigLspDisabledDisabled = true +) + +func (r ConfigLspDisabledDisabled) IsKnown() bool { + switch r { + case ConfigLspDisabledDisabledTrue: + return true + } + return false +} + +type ConfigLspObject struct { + Command []string `json:"command,required"` + Disabled bool `json:"disabled"` + Env map[string]string `json:"env"` + Extensions []string `json:"extensions"` + Initialization map[string]interface{} `json:"initialization"` + JSON configLspObjectJSON `json:"-"` +} + +// configLspObjectJSON contains the JSON metadata for the struct [ConfigLspObject] +type configLspObjectJSON struct { + Command apijson.Field + Disabled apijson.Field + Env apijson.Field + Extensions apijson.Field + Initialization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigLspObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configLspObjectJSON) RawJSON() string { + return r.raw +} + +func (r ConfigLspObject) implementsConfigLsp() {} + type ConfigMcp struct { // Type of MCP server connection Type ConfigMcpType `json:"type,required"` @@ -864,6 +1029,7 @@ type ModeConfig struct { Prompt string `json:"prompt"` Temperature float64 `json:"temperature"` Tools map[string]bool `json:"tools"` + TopP float64 `json:"top_p"` JSON modeConfigJSON `json:"-"` } @@ -874,6 +1040,7 @@ type modeConfigJSON struct { Prompt apijson.Field Temperature apijson.Field Tools apijson.Field + TopP apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/packages/sdk/go/event.go b/packages/sdk/go/event.go index f1627080..9823cdc5 100644 --- a/packages/sdk/go/event.go +++ b/packages/sdk/go/event.go @@ -54,13 +54,13 @@ type EventListResponse struct { // [EventListResponseEventMessageRemovedProperties], // [EventListResponseEventMessagePartUpdatedProperties], // [EventListResponseEventMessagePartRemovedProperties], - // [EventListResponseEventStorageWriteProperties], [Permission], + // [EventListResponseEventStorageWriteProperties], + // [EventListResponseEventFileEditedProperties], [interface{}], [Permission], // [EventListResponseEventPermissionRepliedProperties], - // [EventListResponseEventFileEditedProperties], // [EventListResponseEventSessionUpdatedProperties], // [EventListResponseEventSessionDeletedProperties], // [EventListResponseEventSessionIdleProperties], - // [EventListResponseEventSessionErrorProperties], [interface{}], + // [EventListResponseEventSessionErrorProperties], // [EventListResponseEventFileWatcherUpdatedProperties], // [EventListResponseEventIdeInstalledProperties]. Properties interface{} `json:"properties,required"` @@ -100,11 +100,12 @@ func (r *EventListResponse) UnmarshalJSON(data []byte) (err error) { // [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved], // [EventListResponseEventMessagePartUpdated], // [EventListResponseEventMessagePartRemoved], -// [EventListResponseEventStorageWrite], [EventListResponseEventPermissionUpdated], -// [EventListResponseEventPermissionReplied], [EventListResponseEventFileEdited], +// [EventListResponseEventStorageWrite], [EventListResponseEventFileEdited], +// [EventListResponseEventServerConnected], +// [EventListResponseEventPermissionUpdated], +// [EventListResponseEventPermissionReplied], // [EventListResponseEventSessionUpdated], [EventListResponseEventSessionDeleted], // [EventListResponseEventSessionIdle], [EventListResponseEventSessionError], -// [EventListResponseEventServerConnected], // [EventListResponseEventFileWatcherUpdated], // [EventListResponseEventIdeInstalled]. func (r EventListResponse) AsUnion() EventListResponseUnion { @@ -116,11 +117,12 @@ func (r EventListResponse) AsUnion() EventListResponseUnion { // [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved], // [EventListResponseEventMessagePartUpdated], // [EventListResponseEventMessagePartRemoved], -// [EventListResponseEventStorageWrite], [EventListResponseEventPermissionUpdated], -// [EventListResponseEventPermissionReplied], [EventListResponseEventFileEdited], +// [EventListResponseEventStorageWrite], [EventListResponseEventFileEdited], +// [EventListResponseEventServerConnected], +// [EventListResponseEventPermissionUpdated], +// [EventListResponseEventPermissionReplied], // [EventListResponseEventSessionUpdated], [EventListResponseEventSessionDeleted], // [EventListResponseEventSessionIdle], [EventListResponseEventSessionError], -// [EventListResponseEventServerConnected], // [EventListResponseEventFileWatcherUpdated] or // [EventListResponseEventIdeInstalled]. type EventListResponseUnion interface { @@ -166,6 +168,16 @@ func init() { Type: reflect.TypeOf(EventListResponseEventStorageWrite{}), DiscriminatorValue: "storage.write", }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventFileEdited{}), + DiscriminatorValue: "file.edited", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventServerConnected{}), + DiscriminatorValue: "server.connected", + }, apijson.UnionVariant{ TypeFilter: gjson.JSON, Type: reflect.TypeOf(EventListResponseEventPermissionUpdated{}), @@ -176,11 +188,6 @@ func init() { Type: reflect.TypeOf(EventListResponseEventPermissionReplied{}), DiscriminatorValue: "permission.replied", }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventFileEdited{}), - DiscriminatorValue: "file.edited", - }, apijson.UnionVariant{ TypeFilter: gjson.JSON, Type: reflect.TypeOf(EventListResponseEventSessionUpdated{}), @@ -201,11 +208,6 @@ func init() { Type: reflect.TypeOf(EventListResponseEventSessionError{}), DiscriminatorValue: "session.error", }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventServerConnected{}), - DiscriminatorValue: "server.connected", - }, apijson.UnionVariant{ TypeFilter: gjson.JSON, Type: reflect.TypeOf(EventListResponseEventFileWatcherUpdated{}), @@ -649,6 +651,105 @@ func (r EventListResponseEventStorageWriteType) IsKnown() bool { 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 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 EventListResponseEventPermissionUpdated struct { Properties Permission `json:"properties,required"` Type EventListResponseEventPermissionUpdatedType `json:"type,required"` @@ -752,66 +853,6 @@ func (r EventListResponseEventPermissionRepliedType) IsKnown() bool { 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 { Properties EventListResponseEventSessionUpdatedProperties `json:"properties,required"` Type EventListResponseEventSessionUpdatedType `json:"type,required"` @@ -1188,45 +1229,6 @@ func (r EventListResponseEventSessionErrorType) IsKnown() bool { 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 { Properties EventListResponseEventFileWatcherUpdatedProperties `json:"properties,required"` Type EventListResponseEventFileWatcherUpdatedType `json:"type,required"` @@ -1374,21 +1376,21 @@ const ( EventListResponseTypeMessagePartUpdated EventListResponseType = "message.part.updated" EventListResponseTypeMessagePartRemoved EventListResponseType = "message.part.removed" EventListResponseTypeStorageWrite EventListResponseType = "storage.write" + EventListResponseTypeFileEdited EventListResponseType = "file.edited" + EventListResponseTypeServerConnected EventListResponseType = "server.connected" EventListResponseTypePermissionUpdated EventListResponseType = "permission.updated" EventListResponseTypePermissionReplied EventListResponseType = "permission.replied" - EventListResponseTypeFileEdited EventListResponseType = "file.edited" EventListResponseTypeSessionUpdated EventListResponseType = "session.updated" EventListResponseTypeSessionDeleted EventListResponseType = "session.deleted" EventListResponseTypeSessionIdle EventListResponseType = "session.idle" EventListResponseTypeSessionError EventListResponseType = "session.error" - EventListResponseTypeServerConnected EventListResponseType = "server.connected" EventListResponseTypeFileWatcherUpdated EventListResponseType = "file.watcher.updated" EventListResponseTypeIdeInstalled EventListResponseType = "ide.installed" ) func (r EventListResponseType) IsKnown() bool { switch r { - case EventListResponseTypeInstallationUpdated, EventListResponseTypeLspClientDiagnostics, EventListResponseTypeMessageUpdated, EventListResponseTypeMessageRemoved, EventListResponseTypeMessagePartUpdated, EventListResponseTypeMessagePartRemoved, EventListResponseTypeStorageWrite, EventListResponseTypePermissionUpdated, EventListResponseTypePermissionReplied, EventListResponseTypeFileEdited, EventListResponseTypeSessionUpdated, EventListResponseTypeSessionDeleted, EventListResponseTypeSessionIdle, EventListResponseTypeSessionError, EventListResponseTypeServerConnected, EventListResponseTypeFileWatcherUpdated, EventListResponseTypeIdeInstalled: + case EventListResponseTypeInstallationUpdated, EventListResponseTypeLspClientDiagnostics, EventListResponseTypeMessageUpdated, EventListResponseTypeMessageRemoved, EventListResponseTypeMessagePartUpdated, EventListResponseTypeMessagePartRemoved, EventListResponseTypeStorageWrite, EventListResponseTypeFileEdited, EventListResponseTypeServerConnected, EventListResponseTypePermissionUpdated, EventListResponseTypePermissionReplied, EventListResponseTypeSessionUpdated, EventListResponseTypeSessionDeleted, EventListResponseTypeSessionIdle, EventListResponseTypeSessionError, EventListResponseTypeFileWatcherUpdated, EventListResponseTypeIdeInstalled: return true } return false diff --git a/packages/sdk/src/resources/session/index.ts b/packages/sdk/src/resources/session/index.ts deleted file mode 100644 index 19e30449..00000000 --- a/packages/sdk/src/resources/session/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -export { - Permissions, - type Permission, - type PermissionRespondResponse, - type PermissionRespondParams, -} from './permissions'; -export { - SessionResource, - type AssistantMessage, - type FilePart, - type FilePartInput, - type FilePartSource, - type FilePartSourceText, - type FileSource, - type Message, - type Part, - type Session, - type SnapshotPart, - type StepFinishPart, - type StepStartPart, - type SymbolSource, - type TextPart, - type TextPartInput, - type ToolPart, - type ToolStateCompleted, - type ToolStateError, - type ToolStatePending, - type ToolStateRunning, - type UserMessage, - type SessionListResponse, - type SessionDeleteResponse, - type SessionAbortResponse, - type SessionInitResponse, - type SessionMessageResponse, - type SessionMessagesResponse, - type SessionSummarizeResponse, - type SessionChatParams, - type SessionInitParams, - type SessionMessageParams, - type SessionRevertParams, - type SessionSummarizeParams, -} from './session'; diff --git a/packages/sdk/src/resources/session/permissions.ts b/packages/sdk/src/resources/session/permissions.ts deleted file mode 100644 index 62fa9469..00000000 --- a/packages/sdk/src/resources/session/permissions.ts +++ /dev/null @@ -1,64 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { APIResource } from '../../core/resource'; -import { APIPromise } from '../../core/api-promise'; -import { RequestOptions } from '../../internal/request-options'; -import { path } from '../../internal/utils/path'; - -export class Permissions extends APIResource { - /** - * Respond to a permission request - */ - respond( - permissionID: string, - params: PermissionRespondParams, - options?: RequestOptions, - ): APIPromise { - const { id, ...body } = params; - return this._client.post(path`/session/${id}/permissions/${permissionID}`, { body, ...options }); - } -} - -export interface Permission { - id: string; - - messageID: string; - - metadata: { [key: string]: unknown }; - - sessionID: string; - - time: Permission.Time; - - title: string; - - toolCallID?: string; -} - -export namespace Permission { - export interface Time { - created: number; - } -} - -export type PermissionRespondResponse = boolean; - -export interface PermissionRespondParams { - /** - * Path param: - */ - id: string; - - /** - * Body param: - */ - response: 'once' | 'always' | 'reject'; -} - -export declare namespace Permissions { - export { - type Permission as Permission, - type PermissionRespondResponse as PermissionRespondResponse, - type PermissionRespondParams as PermissionRespondParams, - }; -} diff --git a/packages/sdk/src/resources/session/session.ts b/packages/sdk/src/resources/session/session.ts deleted file mode 100644 index 348fff84..00000000 --- a/packages/sdk/src/resources/session/session.ts +++ /dev/null @@ -1,645 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import { APIResource } from '../../core/resource'; -import * as SessionAPI from './session'; -import * as Shared from '../shared'; -import * as PermissionsAPI from './permissions'; -import { Permission, PermissionRespondParams, PermissionRespondResponse, Permissions } from './permissions'; -import { APIPromise } from '../../core/api-promise'; -import { RequestOptions } from '../../internal/request-options'; -import { path } from '../../internal/utils/path'; - -export class SessionResource extends APIResource { - permissions: PermissionsAPI.Permissions = new PermissionsAPI.Permissions(this._client); - - /** - * Create a new session - */ - create(options?: RequestOptions): APIPromise { - return this._client.post('/session', options); - } - - /** - * List all sessions - */ - list(options?: RequestOptions): APIPromise { - return this._client.get('/session', options); - } - - /** - * Delete a session and all its data - */ - delete(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/session/${id}`, options); - } - - /** - * Abort a session - */ - abort(id: string, options?: RequestOptions): APIPromise { - return this._client.post(path`/session/${id}/abort`, options); - } - - /** - * Create and send a new message to a session - */ - chat(id: string, body: SessionChatParams, options?: RequestOptions): APIPromise { - return this._client.post(path`/session/${id}/message`, { body, ...options }); - } - - /** - * Analyze the app and create an AGENTS.md file - */ - init(id: string, body: SessionInitParams, options?: RequestOptions): APIPromise { - return this._client.post(path`/session/${id}/init`, { body, ...options }); - } - - /** - * Get a message from a session - */ - message( - messageID: string, - params: SessionMessageParams, - options?: RequestOptions, - ): APIPromise { - const { id } = params; - return this._client.get(path`/session/${id}/message/${messageID}`, options); - } - - /** - * List messages for a session - */ - messages(id: string, options?: RequestOptions): APIPromise { - return this._client.get(path`/session/${id}/message`, options); - } - - /** - * Revert a message - */ - revert(id: string, body: SessionRevertParams, options?: RequestOptions): APIPromise { - return this._client.post(path`/session/${id}/revert`, { body, ...options }); - } - - /** - * Share a session - */ - share(id: string, options?: RequestOptions): APIPromise { - return this._client.post(path`/session/${id}/share`, options); - } - - /** - * Summarize the session - */ - summarize( - id: string, - body: SessionSummarizeParams, - options?: RequestOptions, - ): APIPromise { - return this._client.post(path`/session/${id}/summarize`, { body, ...options }); - } - - /** - * Restore all reverted messages - */ - unrevert(id: string, options?: RequestOptions): APIPromise { - return this._client.post(path`/session/${id}/unrevert`, options); - } - - /** - * Unshare the session - */ - unshare(id: string, options?: RequestOptions): APIPromise { - return this._client.delete(path`/session/${id}/share`, options); - } -} - -export interface AssistantMessage { - id: string; - - cost: number; - - mode: string; - - modelID: string; - - path: AssistantMessage.Path; - - providerID: string; - - role: 'assistant'; - - sessionID: string; - - system: Array; - - time: AssistantMessage.Time; - - tokens: AssistantMessage.Tokens; - - error?: - | Shared.ProviderAuthError - | Shared.UnknownError - | AssistantMessage.MessageOutputLengthError - | Shared.MessageAbortedError; - - summary?: boolean; -} - -export namespace AssistantMessage { - export interface Path { - cwd: string; - - root: string; - } - - export interface Time { - created: number; - - completed?: number; - } - - export interface Tokens { - cache: Tokens.Cache; - - input: number; - - output: number; - - reasoning: number; - } - - export namespace Tokens { - export interface Cache { - read: number; - - write: number; - } - } - - export interface MessageOutputLengthError { - data: unknown; - - name: 'MessageOutputLengthError'; - } -} - -export interface FilePart { - id: string; - - messageID: string; - - mime: string; - - sessionID: string; - - type: 'file'; - - url: string; - - filename?: string; - - source?: FilePartSource; -} - -export interface FilePartInput { - mime: string; - - type: 'file'; - - url: string; - - id?: string; - - filename?: string; - - source?: FilePartSource; -} - -export type FilePartSource = FileSource | SymbolSource; - -export interface FilePartSourceText { - end: number; - - start: number; - - value: string; -} - -export interface FileSource { - path: string; - - text: FilePartSourceText; - - type: 'file'; -} - -export type Message = UserMessage | AssistantMessage; - -export type Part = - | TextPart - | FilePart - | ToolPart - | StepStartPart - | StepFinishPart - | SnapshotPart - | Part.PatchPart; - -export namespace Part { - export interface PatchPart { - id: string; - - files: Array; - - hash: string; - - messageID: string; - - sessionID: string; - - type: 'patch'; - } -} - -export interface Session { - id: string; - - time: Session.Time; - - title: string; - - version: string; - - parentID?: string; - - revert?: Session.Revert; - - share?: Session.Share; -} - -export namespace Session { - export interface Time { - created: number; - - updated: number; - } - - export interface Revert { - messageID: string; - - diff?: string; - - partID?: string; - - snapshot?: string; - } - - export interface Share { - url: string; - } -} - -export interface SnapshotPart { - id: string; - - messageID: string; - - sessionID: string; - - snapshot: string; - - type: 'snapshot'; -} - -export interface StepFinishPart { - id: string; - - cost: number; - - messageID: string; - - sessionID: string; - - tokens: StepFinishPart.Tokens; - - type: 'step-finish'; -} - -export namespace StepFinishPart { - export interface Tokens { - cache: Tokens.Cache; - - input: number; - - output: number; - - reasoning: number; - } - - export namespace Tokens { - export interface Cache { - read: number; - - write: number; - } - } -} - -export interface StepStartPart { - id: string; - - messageID: string; - - sessionID: string; - - type: 'step-start'; -} - -export interface SymbolSource { - kind: number; - - name: string; - - path: string; - - range: SymbolSource.Range; - - text: FilePartSourceText; - - type: 'symbol'; -} - -export namespace SymbolSource { - export interface Range { - end: Range.End; - - start: Range.Start; - } - - export namespace Range { - export interface End { - character: number; - - line: number; - } - - export interface Start { - character: number; - - line: number; - } - } -} - -export interface TextPart { - id: string; - - messageID: string; - - sessionID: string; - - text: string; - - type: 'text'; - - synthetic?: boolean; - - time?: TextPart.Time; -} - -export namespace TextPart { - export interface Time { - start: number; - - end?: number; - } -} - -export interface TextPartInput { - text: string; - - type: 'text'; - - id?: string; - - synthetic?: boolean; - - time?: TextPartInput.Time; -} - -export namespace TextPartInput { - export interface Time { - start: number; - - end?: number; - } -} - -export interface ToolPart { - id: string; - - callID: string; - - messageID: string; - - sessionID: string; - - state: ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError; - - tool: string; - - type: 'tool'; -} - -export interface ToolStateCompleted { - input: { [key: string]: unknown }; - - metadata: { [key: string]: unknown }; - - output: string; - - status: 'completed'; - - time: ToolStateCompleted.Time; - - title: string; -} - -export namespace ToolStateCompleted { - export interface Time { - end: number; - - start: number; - } -} - -export interface ToolStateError { - error: string; - - input: { [key: string]: unknown }; - - status: 'error'; - - time: ToolStateError.Time; -} - -export namespace ToolStateError { - export interface Time { - end: number; - - start: number; - } -} - -export interface ToolStatePending { - status: 'pending'; -} - -export interface ToolStateRunning { - status: 'running'; - - time: ToolStateRunning.Time; - - input?: unknown; - - metadata?: { [key: string]: unknown }; - - title?: string; -} - -export namespace ToolStateRunning { - export interface Time { - start: number; - } -} - -export interface UserMessage { - id: string; - - role: 'user'; - - sessionID: string; - - time: UserMessage.Time; -} - -export namespace UserMessage { - export interface Time { - created: number; - } -} - -export type SessionListResponse = Array; - -export type SessionDeleteResponse = boolean; - -export type SessionAbortResponse = boolean; - -export type SessionInitResponse = boolean; - -export interface SessionMessageResponse { - info: Message; - - parts: Array; -} - -export type SessionMessagesResponse = Array; - -export namespace SessionMessagesResponse { - export interface SessionMessagesResponseItem { - info: SessionAPI.Message; - - parts: Array; - } -} - -export type SessionSummarizeResponse = boolean; - -export interface SessionChatParams { - modelID: string; - - parts: Array; - - providerID: string; - - messageID?: string; - - mode?: string; - - system?: string; - - tools?: { [key: string]: boolean }; -} - -export interface SessionInitParams { - messageID: string; - - modelID: string; - - providerID: string; -} - -export interface SessionMessageParams { - /** - * Session ID - */ - id: string; -} - -export interface SessionRevertParams { - messageID: string; - - partID?: string; -} - -export interface SessionSummarizeParams { - modelID: string; - - providerID: string; -} - -SessionResource.Permissions = Permissions; - -export declare namespace SessionResource { - export { - type AssistantMessage as AssistantMessage, - type FilePart as FilePart, - type FilePartInput as FilePartInput, - type FilePartSource as FilePartSource, - type FilePartSourceText as FilePartSourceText, - type FileSource as FileSource, - type Message as Message, - type Part as Part, - type Session as Session, - type SnapshotPart as SnapshotPart, - type StepFinishPart as StepFinishPart, - type StepStartPart as StepStartPart, - type SymbolSource as SymbolSource, - type TextPart as TextPart, - type TextPartInput as TextPartInput, - type ToolPart as ToolPart, - type ToolStateCompleted as ToolStateCompleted, - type ToolStateError as ToolStateError, - type ToolStatePending as ToolStatePending, - type ToolStateRunning as ToolStateRunning, - type UserMessage as UserMessage, - type SessionListResponse as SessionListResponse, - type SessionDeleteResponse as SessionDeleteResponse, - type SessionAbortResponse as SessionAbortResponse, - type SessionInitResponse as SessionInitResponse, - type SessionMessageResponse as SessionMessageResponse, - type SessionMessagesResponse as SessionMessagesResponse, - type SessionSummarizeResponse as SessionSummarizeResponse, - type SessionChatParams as SessionChatParams, - type SessionInitParams as SessionInitParams, - type SessionMessageParams as SessionMessageParams, - type SessionRevertParams as SessionRevertParams, - type SessionSummarizeParams as SessionSummarizeParams, - }; - - export { - Permissions as Permissions, - type Permission as Permission, - type PermissionRespondResponse as PermissionRespondResponse, - type PermissionRespondParams as PermissionRespondParams, - }; -} diff --git a/packages/sdk/tests/api-resources/session/permissions.test.ts b/packages/sdk/tests/api-resources/session/permissions.test.ts deleted file mode 100644 index 6377c564..00000000 --- a/packages/sdk/tests/api-resources/session/permissions.test.ts +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Opencode from '@opencode-ai/sdk'; - -const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' }); - -describe('resource permissions', () => { - // skipped: tests are disabled for the time being - test.skip('respond: only required params', async () => { - const responsePromise = client.session.permissions.respond('permissionID', { - id: 'id', - response: 'once', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // skipped: tests are disabled for the time being - test.skip('respond: required and optional params', async () => { - const response = await client.session.permissions.respond('permissionID', { id: 'id', response: 'once' }); - }); -}); diff --git a/script/publish.ts b/script/publish.ts index a97c783a..066f90e4 100755 --- a/script/publish.ts +++ b/script/publish.ts @@ -36,7 +36,6 @@ await import(`../packages/sdk/js/script/publish.ts`) console.log("\n=== plugin ===\n") await import(`../packages/plugin/script/publish.ts`) -// await import(`../packages/sdk/stainless/generate.ts`) if (!snapshot) { await $`git commit -am "release: v${version}"`