opencode-agent[bot] 3 місяців тому
батько
коміт
b0ca0419be

+ 9 - 13
packages/opencode/src/server/routes/instance/httpapi/handlers/v2/provider.ts

@@ -28,20 +28,16 @@ export const providerHandlers = HttpApiBuilder.group(InstanceHttpApi, "v2.provid
           const catalog = yield* Catalog.Service
           const catalog = yield* Catalog.Service
           const pluginBoot = yield* PluginBoot.Service
           const pluginBoot = yield* PluginBoot.Service
           yield* pluginBoot.wait().pipe(Effect.catchDefect(() => Effect.fail(catalogUnavailable)))
           yield* pluginBoot.wait().pipe(Effect.catchDefect(() => Effect.fail(catalogUnavailable)))
-          return yield* catalog.provider
-            .get(ctx.params.providerID)
-            .pipe(
-              Effect.catchTag(
-                "CatalogV2.ProviderNotFound",
-                (error) =>
-                  Effect.fail(
-                    new ProviderNotFoundError({
-                      providerID: error.providerID,
-                      message: `Provider not found: ${error.providerID}`,
-                    }),
-                  ),
+          return yield* catalog.provider.get(ctx.params.providerID).pipe(
+            Effect.catchTag("CatalogV2.ProviderNotFound", (error) =>
+              Effect.fail(
+                new ProviderNotFoundError({
+                  providerID: error.providerID,
+                  message: `Provider not found: ${error.providerID}`,
+                }),
               ),
               ),
-            )
+            ),
+          )
         }),
         }),
       )
       )
   }),
   }),

+ 26 - 2
packages/sdk/js/src/v2/gen/types.gen.ts

@@ -1823,6 +1823,18 @@ export type V2SessionMessagesResponse = {
   }
   }
 }
 }
 
 
+export type ServiceUnavailableError = {
+  _tag: "ServiceUnavailableError"
+  message: string
+  service?: string
+}
+
+export type ProviderNotFoundError = {
+  _tag: "ProviderNotFoundError"
+  providerID: string
+  message: string
+}
+
 export type EventTuiPromptAppend2 = {
 export type EventTuiPromptAppend2 = {
   type: "tui.prompt.append"
   type: "tui.prompt.append"
   properties: {
   properties: {
@@ -7272,6 +7284,10 @@ export type V2ModelListErrors = {
    * UnauthorizedError
    * UnauthorizedError
    */
    */
   401: UnauthorizedError
   401: UnauthorizedError
+  /**
+   * ServiceUnavailableError
+   */
+  503: ServiceUnavailableError
 }
 }
 
 
 export type V2ModelListError = V2ModelListErrors[keyof V2ModelListErrors]
 export type V2ModelListError = V2ModelListErrors[keyof V2ModelListErrors]
@@ -7306,6 +7322,10 @@ export type V2ProviderListErrors = {
    * UnauthorizedError
    * UnauthorizedError
    */
    */
   401: UnauthorizedError
   401: UnauthorizedError
+  /**
+   * ServiceUnavailableError
+   */
+  503: ServiceUnavailableError
 }
 }
 
 
 export type V2ProviderListError = V2ProviderListErrors[keyof V2ProviderListErrors]
 export type V2ProviderListError = V2ProviderListErrors[keyof V2ProviderListErrors]
@@ -7343,9 +7363,13 @@ export type V2ProviderGetErrors = {
    */
    */
   401: UnauthorizedError
   401: UnauthorizedError
   /**
   /**
-   * NotFoundError
+   * ProviderNotFoundError
    */
    */
-  404: NotFoundError
+  404: ProviderNotFoundError
+  /**
+   * ServiceUnavailableError
+   */
+  503: ServiceUnavailableError
 }
 }
 
 
 export type V2ProviderGetError = V2ProviderGetErrors[keyof V2ProviderGetErrors]
 export type V2ProviderGetError = V2ProviderGetErrors[keyof V2ProviderGetErrors]

+ 66 - 2
packages/sdk/openapi.json

@@ -8625,6 +8625,16 @@
                 }
                 }
               }
               }
             }
             }
+          },
+          "503": {
+            "description": "ServiceUnavailableError",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/ServiceUnavailableError"
+                }
+              }
+            }
           }
           }
         },
         },
         "description": "Retrieve available v2 models ordered by release date.",
         "description": "Retrieve available v2 models ordered by release date.",
@@ -8696,6 +8706,16 @@
                 }
                 }
               }
               }
             }
             }
+          },
+          "503": {
+            "description": "ServiceUnavailableError",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/ServiceUnavailableError"
+                }
+              }
+            }
           }
           }
         },
         },
         "description": "Retrieve active v2 AI providers so clients can show provider availability and configuration.",
         "description": "Retrieve active v2 AI providers so clients can show provider availability and configuration.",
@@ -8774,11 +8794,21 @@
             }
             }
           },
           },
           "404": {
           "404": {
-            "description": "NotFoundError",
+            "description": "ProviderNotFoundError",
             "content": {
             "content": {
               "application/json": {
               "application/json": {
                 "schema": {
                 "schema": {
-                  "$ref": "#/components/schemas/NotFoundError"
+                  "$ref": "#/components/schemas/ProviderNotFoundError"
+                }
+              }
+            }
+          },
+          "503": {
+            "description": "ServiceUnavailableError",
+            "content": {
+              "application/json": {
+                "schema": {
+                  "$ref": "#/components/schemas/ServiceUnavailableError"
                 }
                 }
               }
               }
             }
             }
@@ -15589,6 +15619,40 @@
         "required": ["items", "cursor"],
         "required": ["items", "cursor"],
         "additionalProperties": false
         "additionalProperties": false
       },
       },
+      "ServiceUnavailableError": {
+        "type": "object",
+        "properties": {
+          "_tag": {
+            "type": "string",
+            "enum": ["ServiceUnavailableError"]
+          },
+          "message": {
+            "type": "string"
+          },
+          "service": {
+            "type": "string"
+          }
+        },
+        "required": ["_tag", "message"],
+        "additionalProperties": false
+      },
+      "ProviderNotFoundError": {
+        "type": "object",
+        "properties": {
+          "_tag": {
+            "type": "string",
+            "enum": ["ProviderNotFoundError"]
+          },
+          "providerID": {
+            "type": "string"
+          },
+          "message": {
+            "type": "string"
+          }
+        },
+        "required": ["_tag", "providerID", "message"],
+        "additionalProperties": false
+      },
       "EventTuiPromptAppend": {
       "EventTuiPromptAppend": {
         "type": "object",
         "type": "object",
         "properties": {
         "properties": {