diff --git a/packages/core/src/plugin/promise.ts b/packages/core/src/plugin/promise.ts index b1d9bd21d..d0bf82c2a 100644 --- a/packages/core/src/plugin/promise.ts +++ b/packages/core/src/plugin/promise.ts @@ -67,8 +67,7 @@ export function fromPromise(plugin: Plugin) { reload: () => run(host.integration.reload()), connection: { active: (id) => Effect.runPromiseWith(context)(host.integration.connection.active(id)), - resolve: (connection) => - Effect.runPromiseWith(context)(host.integration.connection.resolve(connection)), + resolve: (connection) => Effect.runPromiseWith(context)(host.integration.connection.resolve(connection)), }, }, plugin: { diff --git a/packages/plugin/src/v2/effect/integration.ts b/packages/plugin/src/v2/effect/integration.ts index 6c9fbde53..64052b150 100644 --- a/packages/plugin/src/v2/effect/integration.ts +++ b/packages/plugin/src/v2/effect/integration.ts @@ -28,9 +28,7 @@ export type IntegrationOAuthAuthorization = { export type IntegrationOAuthMethodRegistration = { readonly integrationID: string readonly method: IntegrationOAuthMethod - readonly authorize: ( - inputs: IntegrationInputs, - ) => Effect.Effect + readonly authorize: (inputs: IntegrationInputs) => Effect.Effect readonly refresh?: (credential: CredentialOAuth) => Effect.Effect readonly label?: (credential: CredentialOAuth) => string | undefined } diff --git a/packages/plugin/src/v2/promise/index.ts b/packages/plugin/src/v2/promise/index.ts index f9c1480b3..828795565 100644 --- a/packages/plugin/src/v2/promise/index.ts +++ b/packages/plugin/src/v2/promise/index.ts @@ -7,10 +7,6 @@ export type { AgentDraft, AgentHooks } from "./agent.js" export type { AISDKHooks } from "./aisdk.js" export type { CatalogDraft, CatalogHooks, CatalogProviderRecord } from "./catalog.js" export type { CommandDraft, CommandHooks } from "./command.js" -export type { - IntegrationDraft, - IntegrationHooks, - IntegrationMethodRegistration, -} from "./integration.js" +export type { IntegrationDraft, IntegrationHooks, IntegrationMethodRegistration } from "./integration.js" export type { ReferenceDraft, ReferenceHooks } from "./reference.js" export type { SkillDraft, SkillHooks } from "./skill.js" diff --git a/packages/plugin/src/v2/promise/integration.ts b/packages/plugin/src/v2/promise/integration.ts index e14e0298e..6a798a029 100644 --- a/packages/plugin/src/v2/promise/integration.ts +++ b/packages/plugin/src/v2/promise/integration.ts @@ -1,7 +1,4 @@ -import type { - IntegrationDraft, - IntegrationMethodRegistration, -} from "../effect/integration.js" +import type { IntegrationDraft, IntegrationMethodRegistration } from "../effect/integration.js" import type { CredentialValue } from "@opencode-ai/sdk/v2/types" import type { Hooks } from "./registration.js" @@ -9,9 +6,7 @@ export type { IntegrationDraft, IntegrationMethodRegistration } export interface IntegrationHooks extends Hooks<{ transform: IntegrationDraft }> { readonly connection: { - readonly active: ( - integrationID: string, - ) => Promise + readonly active: (integrationID: string) => Promise readonly resolve: ( connection: import("@opencode-ai/sdk/v2/types").ConnectionInfo, ) => Promise diff --git a/packages/sdk/openapi.json b/packages/sdk/openapi.json index 932cb8a49..44e405cfc 100644 --- a/packages/sdk/openapi.json +++ b/packages/sdk/openapi.json @@ -14647,6 +14647,9 @@ { "$ref": "#/components/schemas/EventIntegrationUpdated" }, + { + "$ref": "#/components/schemas/EventIntegrationConnectionUpdated" + }, { "$ref": "#/components/schemas/EventCatalogUpdated" }, @@ -16821,6 +16824,31 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, + { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "type": { + "type": "string", + "enum": ["integration.connection.updated"] + }, + "properties": { + "type": "object", + "properties": { + "integrationID": { + "type": "string" + } + }, + "required": ["integrationID"], + "additionalProperties": false + } + }, + "required": ["id", "type", "properties"], + "additionalProperties": false + }, { "type": "object", "properties": { @@ -22989,6 +23017,9 @@ { "$ref": "#/components/schemas/V2EventIntegrationUpdated" }, + { + "$ref": "#/components/schemas/V2EventIntegrationConnectionUpdated" + }, { "$ref": "#/components/schemas/V2EventCatalogUpdated" }, @@ -23427,6 +23458,61 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, + "CredentialValue": { + "anyOf": [ + { + "$ref": "#/components/schemas/CredentialOAuth" + }, + { + "$ref": "#/components/schemas/CredentialKey" + } + ] + }, + "IntegrationInputs": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "IntegrationMethod": { + "anyOf": [ + { + "$ref": "#/components/schemas/IntegrationOAuthMethod" + }, + { + "$ref": "#/components/schemas/IntegrationKeyMethod" + }, + { + "$ref": "#/components/schemas/IntegrationEnvMethod" + } + ] + }, + "IntegrationRef": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "required": ["id", "name"], + "additionalProperties": false + }, + "SkillV2Source": { + "anyOf": [ + { + "$ref": "#/components/schemas/SkillV2DirectorySource" + }, + { + "$ref": "#/components/schemas/SkillV2UrlSource" + }, + { + "$ref": "#/components/schemas/SkillV2EmbeddedSource" + } + ] + }, "MoveSessionDestination": { "type": "object", "properties": { @@ -27487,17 +27573,7 @@ "methods": { "type": "array", "items": { - "anyOf": [ - { - "$ref": "#/components/schemas/IntegrationOAuthMethod" - }, - { - "$ref": "#/components/schemas/IntegrationKeyMethod" - }, - { - "$ref": "#/components/schemas/IntegrationEnvMethod" - } - ] + "$ref": "#/components/schemas/IntegrationMethod" } }, "connections": { @@ -27797,6 +27873,53 @@ "required": ["id", "type", "data"], "additionalProperties": false }, + "V2EventIntegrationConnectionUpdated": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "metadata": { + "type": "object" + }, + "durable": { + "type": "object", + "properties": { + "aggregateID": { + "type": "string" + }, + "seq": { + "type": "integer" + }, + "version": { + "type": "integer" + } + }, + "required": ["aggregateID", "seq", "version"], + "additionalProperties": false + }, + "location": { + "$ref": "#/components/schemas/LocationRef" + }, + "type": { + "type": "string", + "enum": ["integration.connection.updated"] + }, + "data": { + "type": "object", + "properties": { + "integrationID": { + "type": "string" + } + }, + "required": ["integrationID"], + "additionalProperties": false + } + }, + "required": ["id", "type", "data"], + "additionalProperties": false + }, "V2EventCatalogUpdated": { "type": "object", "properties": { @@ -32682,6 +32805,31 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, + "EventIntegrationConnectionUpdated": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^evt_" + }, + "type": { + "type": "string", + "enum": ["integration.connection.updated"] + }, + "properties": { + "type": "object", + "properties": { + "integrationID": { + "type": "string" + } + }, + "required": ["integrationID"], + "additionalProperties": false + } + }, + "required": ["id", "type", "properties"], + "additionalProperties": false + }, "EventCatalogUpdated": { "type": "object", "properties": { @@ -35466,6 +35614,92 @@ "required": ["id", "type", "properties"], "additionalProperties": false }, + "CredentialOAuth": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["oauth"] + }, + "methodID": { + "type": "string" + }, + "refresh": { + "type": "string" + }, + "access": { + "type": "string" + }, + "expires": { + "type": "integer", + "minimum": 0 + }, + "metadata": { + "type": "object" + } + }, + "required": ["type", "methodID", "refresh", "access", "expires"], + "additionalProperties": false + }, + "CredentialKey": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["key"] + }, + "key": { + "type": "string" + }, + "metadata": { + "type": "object" + } + }, + "required": ["type", "key"], + "additionalProperties": false + }, + "SkillV2DirectorySource": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["directory"] + }, + "path": { + "type": "string" + } + }, + "required": ["type", "path"], + "additionalProperties": false + }, + "SkillV2UrlSource": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["url"] + }, + "url": { + "type": "string" + } + }, + "required": ["type", "url"], + "additionalProperties": false + }, + "SkillV2EmbeddedSource": { + "type": "object", + "properties": { + "type": { + "type": "string", + "enum": ["embedded"] + }, + "skill": { + "$ref": "#/components/schemas/SkillV2Info" + } + }, + "required": ["type", "skill"], + "additionalProperties": false + }, "BadRequestError": { "type": "object", "required": ["name", "data"],