The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(connectors): words typed in the composer answer the connector directory card
alt-glitch2f0d97f22a7b
diff --git a/apps/desktop/src/components/assistant-ui/connector-tool.tsx b/apps/desktop/src/components/assistant-ui/connector-tool.tsxindex a4fc8fcfe3b..b53e0957431 100644--- a/apps/desktop/src/components/assistant-ui/connector-tool.tsx+++ b/apps/desktop/src/components/assistant-ui/connector-tool.tsx@@ -188,11 +188,20 @@ function ConnectorDirectoryTool({ live, part, request }: ConnectorDirectoryToolP}// A timed-out card still names what the user connected before walking away.-function receiptText(copy: ConnectorCopy['directory'], outcome: ReturnType<typeof recordOf>, added: string[]): string {+function receiptText(+ copy: ConnectorCopy['directory'],+ answeredInChat: string,+ outcome: ReturnType<typeof recordOf>,+ added: string[]+): string {if (added.length > 0) {return copy.receiptConnected(added.map(connectorTitle).join(', '))}+ if (connectorText(outcome.said) !== undefined) {+ return answeredInChat+ }+return outcome.timed_out === true ? copy.receiptTimedOut : copy.receiptNone}@@ -205,7 +214,7 @@ export function ConnectorDirectoryReceipt({ result }: { result: unknown }) {? outcome.newly_connected.flatMap(name => connectorText(name) ?? []): []- const text = receiptText(copy, outcome, added)+ const text = receiptText(copy, t.firstRun.answeredInChat, outcome, added)return (<div data-conversation-scaffold="" data-slot="connector-directory-receipt">diff --git a/apps/desktop/src/store/connection-request.ts b/apps/desktop/src/store/connection-request.tsindex a488116debf..a1b41d48b4c 100644--- a/apps/desktop/src/store/connection-request.ts+++ b/apps/desktop/src/store/connection-request.ts@@ -24,6 +24,7 @@ import type { SetupField } from '@/components/ui/setup-field-list'import { connectorText } from '@/lib/connector-tools'import { $gateway, requestGatewayForAgent } from './gateway'+import { registerParkedCardAnswer } from './parked-card-answers'import { $activeGatewayProfile } from './profile'import { assertSessionOwnerResolved } from './session-owner-resolution'import { isSessionOwnerRoute } from './session-request-router'@@ -513,6 +514,21 @@ export const skipConnectionTarget = (request: ConnectionRequest, name: string):export const continueConnectionRequest = (request: ConnectionRequest): Promise<boolean> =>respondToConnectionRequest(request, { settled_by: 'continue' })+/** The composer's words answer an open connector directory card; the tool returns them as `said`. */+export function answerConnectorDirectory(sessionId: string, text: string): boolean {+ const request = $connectionRequests.get()[keyFor(sessionId)]++ if (!request?.display || request.settled || !text.trim()) {+ return false+ }++ void respondToConnectionRequest(request, { said: text.trim(), settled_by: 'continue' }).catch(() => undefined)++ return true+}++registerParkedCardAnswer('connector-directory', answerConnectorDirectory)+// Typing a message while the card is open ends the operation, otherwise the typed message waits behind// the blocked tool until the deadline.export async function skipConnectionRequest(sessionId: string | null | undefined): Promise<boolean> {diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex 609aa40509b..99fac2ecd2b 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -1115,6 +1115,7 @@ export interface ConnectionRespondParams {export interface ConnectionAnswer {targets?: ConnectionAnswerTarget[]settled_by?: ConnectionSettleReason | null+ said?: string | null}/** One row's answer from the card. ``env`` carries the credential values an install asked for through ``required_env``. */export interface ConnectionAnswerTarget {diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex a5eaccf781e..9d972fcdd58 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -9367,6 +9367,18 @@}],"default": null+ },+ "said": {+ "anyOf": [+ {+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Said"}},"title": "ConnectionAnswer",diff --git a/tests/tools/test_connectors_display.py b/tests/tools/test_connectors_display.pyindex f662c990ebb..28e8f0f4120 100644--- a/tests/tools/test_connectors_display.py+++ b/tests/tools/test_connectors_display.py@@ -2,7 +2,8 @@Contracts:- on desktop the call emits a card with no targets, waits for Continue or the deadline, and reports what is- connected, computed from the gateway list read at the start and at settle; the deadline adds timed_out+ connected, computed from the gateway list read at the start and at settle; the deadline adds timed_out,+ and words typed in the composer settle it like Continue and come back as said- without a card surface it returns at once with the status list and where to connect"""@@ -38,17 +39,18 @@ def _display(gw, *, callback, card_surface):))[email protected]("ending", ["continue", "deadline"])[email protected]("ending", ["continue", "deadline", "said"])def test_display_waits_for_the_user_and_reports_what_they_connected(ending):gw = ListFake({"gmail"})seen = []def card(payload):- # The user connects Slack while the card is open, then presses Continue or walks away.+ # The user connects Slack while the card is open, then presses Continue, types an answer or walks away.seen.append(payload)gw.connected.add("slack")- if ending == "continue":- apply_answer(live.get("s1", payload["op_id"]), json.dumps({"settled_by": "continue"}))+ if ending != "deadline":+ answer = {"settled_by": "continue"} if ending == "continue" else {"said": " maybe later "}+ apply_answer(live.get("s1", payload["op_id"]), json.dumps(answer))with patch("tools.connectors.operation.OPERATION_DEADLINE_SECONDS", 2 if ending == "deadline" else 60):out = _display(gw, callback=card, card_surface=True)@@ -56,7 +58,8 @@ def test_display_waits_for_the_user_and_reports_what_they_connected(ending):(payload,) = seenassert payload["targets"] == [] and payload["display"] == {"suggested": ["slack", "linear"]}expected = {"connected": ["gmail", "slack"], "newly_connected": ["slack"], "suggested": ["slack", "linear"]}- assert out == ({**expected, "timed_out": True} if ending == "deadline" else expected)+ extra = {"deadline": {"timed_out": True}, "said": {"said": "maybe later"}}.get(ending, {})+ assert out == {**expected, **extra}assert live.current("s1") is Nonediff --git a/tools/connectors/display.py b/tools/connectors/display.pyindex 7793da08bc0..b23a538ece5 100644--- a/tools/connectors/display.py+++ b/tools/connectors/display.py@@ -1,6 +1,6 @@"""``manage_connections`` action ``display``: the desktop's browsable connector card.-The card is an operation with no targets, so only Continue, the deadline or /stop settles it. Connecting from the card runs the Connectors page's own account operation, never this one."""+The card is an operation with no targets, so only Continue, words typed in the composer, the deadline or /stop settle it. Connecting from the card runs the Connectors page's own account operation, never this one."""from __future__ import annotations@@ -21,13 +21,18 @@ OFF_DESKTOP_NOTE = (@dataclassclass DisplayOperation(ConnectionOperation):suggested: list[str] = field(default_factory=list)+ said: str | None = Nonedef request_payload(self) -> dict[str, Any]:return {**super().request_payload(), "display": {"suggested": list(self.suggested)}}def apply_answer(operation: DisplayOperation, raw: str) -> None:- if json.loads(raw).get("settled_by") == SettleReason.continue_.value:+ answer = json.loads(raw)+ said = str(answer.get("said") or "").strip()+ if said:+ operation.said = said+ if said or answer.get("settled_by") == SettleReason.continue_.value:operation.settle(SettleReason.continue_)@@ -39,6 +44,8 @@ def connected_slugs(client: Any) -> set[str]:def _result(client: Any, before: set[str], operation: DisplayOperation) -> dict[str, Any]:after = connected_slugs(client)result = {"connected": sorted(after), "newly_connected": sorted(after - before), "suggested": operation.suggested}+ if operation.said:+ result["said"] = operation.said# A user who connected an app and walked away still gets it reported.return {**result, "timed_out": True} if operation.settled_by == SettleReason.deadline else resultdiff --git a/tui_gateway/contracts/connectors_operation.py b/tui_gateway/contracts/connectors_operation.pyindex 47199755765..4b5444bc9da 100644--- a/tui_gateway/contracts/connectors_operation.py+++ b/tui_gateway/contracts/connectors_operation.py@@ -262,6 +262,8 @@ class ConnectionAnswer(Params):targets: list[ConnectionAnswerTarget] = Field(default_factory=list)settled_by: ConnectionSettleReason | None = None+ # A display card answered by the user's words typed in the composer; it settles the card like Continue.+ said: str | None = Noneclass ConnectionRespondParams(ConnectionOperationParams):