The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(connectors): account rows say when an account is retired, and a repair can name one by id
Siddharth Balyancd764c5ce091
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex b0842b8488a..6c49e4eb968 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -1151,6 +1151,7 @@ export interface ConnectorsConnectParams {connectors: string[]reconnect?: booleanalias?: string | null+ connection_id?: string | null}/** ``methods_connectors._reissue`` / ``managed._off_desktop_result``: the operation the connect opened; ``status``/``note`` ride along from the tool result. */export interface ConnectorsConnectResult {@@ -1215,6 +1216,7 @@ export interface ConnectorAccountRow {label: stringalias?: string | nullactive: boolean+ disabled?: booleancreated_at: stringupdated_at: string}diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex 2be45684163..fb9663d6cad 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -10211,6 +10211,11 @@"title": "Active","type": "boolean"},+ "disabled": {+ "default": false,+ "title": "Disabled",+ "type": "boolean"+ },"created_at": {"title": "Created At","type": "string"@@ -11260,6 +11265,19 @@],"default": null,"title": "Alias"+ },+ "connection_id": {+ "anyOf": [+ {+ "minLength": 1,+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Connection Id"}},"required": [diff --git a/tools/connectors/account.py b/tools/connectors/account.pyindex 91aac30e6ef..90d97f28ad1 100644--- a/tools/connectors/account.py+++ b/tools/connectors/account.py@@ -40,13 +40,15 @@ def find_or_start_operation(action: str,profile_home: str | None,alias: str | None = None,+ repair_id: str | None = None,) -> AccountOperationStart:- """``alias`` names the one account of ``names[0]`` to connect; the caller passes one name with it."""+ """``alias`` names the one account of ``names[0]`` to connect; ``repair_id`` names the existing+ account a reconnect repairs. The caller passes one name with either."""with _start_lock:if operation := _matching_open_operation(names, alias=alias, profile_home=profile_home):return AccountOperationStart(operation=operation, started=False)operation = ConnectionOperation(- [Target(name, "connector", action, alias=alias) for name in names],+ [Target(name, "connector", action, alias=alias, repair_id=repair_id) for name in names],session_key=f"account:{uuid.uuid4().hex}",)started = AccountOperationStart(operation=operation, started=True)diff --git a/tools/connectors/gateway/wire.py b/tools/connectors/gateway/wire.pyindex 2426fe46c74..231f7326575 100644--- a/tools/connectors/gateway/wire.py+++ b/tools/connectors/gateway/wire.py@@ -184,6 +184,8 @@ class ConnectorAccount(_Wire):alias: Optional[str] = None# The newest active account for this connector: the one the vendor executes with.active: bool+ # Retired by a reconnect that replaced it; kept, never selectable.+ disabled: bool = Falsecreated_at: str = Field(alias="createdAt")updated_at: str = Field(alias="updatedAt")diff --git a/tools/connectors/operation.py b/tools/connectors/operation.pyindex c9caf4e757a..73adcae6d55 100644--- a/tools/connectors/operation.py+++ b/tools/connectors/operation.py@@ -43,6 +43,8 @@ class Target:phase: Optional[str] = None# The name of the one hosted account this target connects or repairs; absent for the connector's default account.alias: Optional[str] = None+ # The existing account a reconnect repairs, by id: an unnamed account, which no alias can address.+ repair_id: Optional[str] = None@propertydef resolved(self) -> bool:diff --git a/tui_gateway/contracts/connectors.py b/tui_gateway/contracts/connectors.pyindex 2f56e417e9d..18b070b6497 100644--- a/tui_gateway/contracts/connectors.py+++ b/tui_gateway/contracts/connectors.py@@ -75,11 +75,15 @@ class ConnectorsConnectParams(ProfileParams):reconnect: bool = False# Connects (or, with ``reconnect``, repairs) the account of that name; one connector per call.alias: ConnectorAlias | None = None+ # With ``reconnect``: repairs this existing account, the only way to address an unnamed one.+ connection_id: str | None = Field(default=None, min_length=1)@model_validator(mode="after")def _one_connector_per_alias(self):if self.alias is not None and len(self.connectors) != 1:raise ValueError("alias names one account, so it takes exactly one connector")+ if self.connection_id is not None and (not self.reconnect or len(self.connectors) != 1 or self.alias):+ raise ValueError("connection_id repairs one account: it needs reconnect, one connector and no alias")return self@@ -194,6 +198,8 @@ class ConnectorAccountRow(Result):label: stralias: str | None = Noneactive: bool+ # Retired by a reconnect that replaced it; kept, never selectable.+ disabled: bool = Falsecreated_at: strupdated_at: strdiff --git a/tui_gateway/methods_connectors.py b/tui_gateway/methods_connectors.pyindex 4aa7eb7680e..c34e0cbeab9 100644--- a/tui_gateway/methods_connectors.py+++ b/tui_gateway/methods_connectors.py@@ -200,7 +200,8 @@ def _account_connector_connect(rid, request):action = "reconnect" if request.reconnect else "connect"try:start = account.find_or_start_operation(- request.connectors, action=action, profile_home=_account_home(request), alias=request.alias)+ request.connectors, action=action, profile_home=_account_home(request), alias=request.alias,+ repair_id=request.connection_id)if not start.started:from tools.connectors.contract import TargetStatediff --git a/tui_gateway/methods_connectors_account.py b/tui_gateway/methods_connectors_account.pyindex f9858b6ee0c..08371e4229f 100644--- a/tui_gateway/methods_connectors_account.py+++ b/tui_gateway/methods_connectors_account.py@@ -116,6 +116,7 @@ def _account_row(account):label=account["label"],alias=account.get("alias"),active=account["active"],+ disabled=bool(account.get("disabled")),created_at=account["createdAt"],updated_at=account["updatedAt"],)