@tangle-network/agent-app 0.50.31 → 0.50.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/integrations-react/callback.tsx","../../src/integrations-react/popup.ts","../../src/integrations-react/client.ts","../../src/integrations-react/panel.tsx","../../src/integrations-react/projection.ts","../../src/integrations-react/use-hub-integrations.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\nimport { HUB_CONNECTED_MESSAGE_TYPE, HUB_CONNECT_CHANNEL, HUB_CONNECT_FAILED_MESSAGE_TYPE, localAppUrl } from './popup'\n\nexport interface HubConnectCallbackPageProps {\n /** Local settings destination owned by the consuming app. */\n returnHref: string\n}\n\n/** The callback only signals completion; the opener verifies fresh Hub state. */\nexport function HubConnectCallbackPage({ returnHref }: HubConnectCallbackPageProps) {\n const [phase, setPhase] = useState<'checking' | 'returned' | 'failed'>('checking')\n const [reason, setReason] = useState('')\n\n useEffect(() => {\n const params = new URLSearchParams(window.location.search)\n const provider = params.get('provider')\n const nonce = params.get('nonce')\n const context = params.get('context')\n if (!provider || !nonce || !context) { setReason('This connection callback is incomplete.'); setPhase('failed'); return }\n const failure = params.get('error_description') || params.get('error')\n try {\n const channel = new BroadcastChannel(HUB_CONNECT_CHANNEL)\n channel.postMessage({ type: failure ? HUB_CONNECT_FAILED_MESSAGE_TYPE : HUB_CONNECTED_MESSAGE_TYPE, provider, nonce, context })\n channel.close()\n } catch { /* The opener also polls the authoritative connection list. */ }\n if (failure) { setReason(failure.slice(0, 200)); setPhase('failed'); return }\n window.close()\n const timer = window.setTimeout(() => setPhase('returned'), 150)\n return () => window.clearTimeout(timer)\n }, [])\n\n const destination = localAppUrl(returnHref)\n const localReturn = destination ? `${destination.pathname}${destination.search}${destination.hash}` : '/'\n return <main aria-live=\"polite\" style={{ maxWidth: 560, margin: '20vh auto', padding: 24, textAlign: 'center' }}>\n {phase === 'checking' ? <p>Checking your connection…</p> : phase === 'returned'\n ? <p>Return to the app to check your connection. You can close this window.</p>\n : <p>Could not complete the connection. {reason}</p>}\n <a href={localReturn}>Return to integrations</a>\n </main>\n}\n","import type { HubConnection } from '@tangle-network/hub-sdk'\nimport type { HubIntegrationsClient, HubIntegrationsIdentity } from './client'\n\nexport const HUB_CONNECT_CHANNEL = 'tangle:hub-connect'\nexport const HUB_CONNECTED_MESSAGE_TYPE = 'tangle:hub-connected'\nexport const HUB_CONNECT_FAILED_MESSAGE_TYPE = 'tangle:hub-connect-failed'\nexport const POPUP_TIMEOUT_MS = 5 * 60 * 1000\nconst PRE_REDIRECT_TIMEOUT_MS = 30_000\nconst POLL_INTERVAL_MS = 2500\nconst POPUP_FEATURES = 'popup=yes,width=520,height=680'\n\nexport type PopupConnectResult = 'connected' | 'blocked' | 'cancelled' | 'unverified' | 'unavailable'\n\nexport function localAppUrl(path: string): URL | null {\n if (!path.startsWith('/') || path.startsWith('//')) return null\n try {\n const origin = typeof window === 'undefined' ? 'https://local.invalid' : window.location.origin\n const url = new URL(path, origin)\n return url.origin === origin && !url.username && !url.password ? url : null\n } catch { return null }\n}\n\nfunction updatedConnection(providerId: string, before: readonly HubConnection[], after: readonly HubConnection[]): boolean {\n const previous = new Map(before.filter(connection => connection.providerId === providerId).map(connection => [connection.id, connection]))\n return after.some(connection => {\n if (connection.providerId !== providerId || connection.status !== 'active' || connection.health === 'unhealthy') return false\n const old = previous.get(connection.id)\n return !old || old.updatedAt !== connection.updatedAt || old.status !== connection.status\n })\n}\n\nfunction closePopup(popup: Window): void {\n try { if (!popup.closed) popup.close() } catch { /* COOP may sever the handle. */ }\n}\n\nfunction withAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n return new Promise((resolve, reject) => {\n if (signal.aborted) { reject(new DOMException('Aborted', 'AbortError')); return }\n const onAbort = () => reject(new DOMException('Aborted', 'AbortError'))\n signal.addEventListener('abort', onAbort, { once: true })\n promise.then(value => { signal.removeEventListener('abort', onAbort); resolve(value) }, error => { signal.removeEventListener('abort', onAbort); reject(error) })\n })\n}\n\nfunction waitForConnection(input: {\n popup: Window\n client: HubIntegrationsClient\n identity: HubIntegrationsIdentity\n providerId: string\n before: readonly HubConnection[]\n nonce: string\n contextToken: string\n signal: AbortSignal\n isCurrent: () => boolean\n}): Promise<PopupConnectResult> {\n return new Promise(resolve => {\n let settled = false\n let checking = false\n let pollId: number | undefined\n let timeoutId: number | undefined\n let channel: BroadcastChannel | undefined\n const finish = (result: PopupConnectResult) => {\n if (settled) return\n settled = true\n if (pollId !== undefined) window.clearTimeout(pollId)\n if (timeoutId !== undefined) window.clearTimeout(timeoutId)\n input.signal.removeEventListener('abort', onAbort)\n channel?.close()\n closePopup(input.popup)\n resolve(result)\n }\n const onAbort = () => finish('cancelled')\n const check = async () => {\n if (settled || checking) return\n checking = true\n if (!input.isCurrent() || input.signal.aborted) { finish('cancelled'); return }\n try {\n const after = await input.client.connections(input.identity, input.signal)\n if (input.isCurrent() && updatedConnection(input.providerId, input.before, after)) { finish('connected'); return }\n } catch { /* A lost read is never evidence of a connection. Keep polling. */ }\n checking = false\n if (!settled) pollId = window.setTimeout(check, POLL_INTERVAL_MS)\n }\n if (input.signal.aborted) { finish('cancelled'); return }\n input.signal.addEventListener('abort', onAbort, { once: true })\n try {\n const candidate = new BroadcastChannel(HUB_CONNECT_CHANNEL)\n candidate.onmessage = event => {\n const message = event.data as Record<string, unknown> | null\n if (!message || message.provider !== input.providerId || message.nonce !== input.nonce || message.context !== input.contextToken) return\n if (message.type === HUB_CONNECT_FAILED_MESSAGE_TYPE) finish('cancelled')\n if (message.type === HUB_CONNECTED_MESSAGE_TYPE) {\n if (pollId !== undefined) window.clearTimeout(pollId)\n void check()\n }\n }\n channel = candidate\n } catch { /* Polling covers browsers without BroadcastChannel. */ }\n pollId = window.setTimeout(check, POLL_INTERVAL_MS)\n timeoutId = window.setTimeout(() => finish('unverified'), POPUP_TIMEOUT_MS)\n })\n}\n\n/** Opens before the first await, preserving the initiating user gesture. */\nexport async function connectWithPopup(input: {\n client: HubIntegrationsClient\n identity: HubIntegrationsIdentity\n providerId: string\n before: readonly HubConnection[]\n callbackPath: string\n connectionParameters?: Record<string, string>\n signal: AbortSignal\n isCurrent: () => boolean\n}): Promise<PopupConnectResult> {\n const callback = localAppUrl(input.callbackPath)\n if (!callback) throw new TypeError('Callback path must be local.')\n const popup = window.open('', '_blank', POPUP_FEATURES)\n if (!popup) return 'blocked'\n // Keep the parent handle for navigation while removing the provider page's opener.\n try { popup.opener = null } catch { /* Some browsers make this read-only. */ }\n const nonce = crypto.randomUUID()\n const contextToken = crypto.randomUUID()\n callback.searchParams.set('provider', input.providerId)\n callback.searchParams.set('nonce', nonce)\n callback.searchParams.set('context', contextToken)\n const timeout = new AbortController()\n const onAbort = () => timeout.abort()\n input.signal.addEventListener('abort', onAbort, { once: true })\n const preRedirectId = window.setTimeout(() => timeout.abort(), PRE_REDIRECT_TIMEOUT_MS)\n try {\n if (!input.isCurrent()) return 'cancelled'\n const start = await withAbort(input.client.startOAuth(input.identity, input.providerId, {\n returnUrl: callback.href,\n ...(input.connectionParameters === undefined ? {} : { connectionParameters: input.connectionParameters }),\n }, timeout.signal), timeout.signal)\n if (!input.isCurrent() || input.signal.aborted) return 'cancelled'\n let redirect: URL\n try { redirect = new URL(start.redirectUrl) } catch { return 'unavailable' }\n if (redirect.protocol !== 'https:' || redirect.username || redirect.password) return 'unavailable'\n window.clearTimeout(preRedirectId)\n const waitController = new AbortController()\n const abortWait = () => waitController.abort()\n input.signal.addEventListener('abort', abortWait, { once: true })\n if (input.signal.aborted) abortWait()\n const waiting = waitForConnection({ ...input, popup, nonce, contextToken, signal: waitController.signal })\n try {\n popup.location.href = redirect.href\n return await waiting\n } catch {\n waitController.abort()\n await waiting\n return 'unavailable'\n } finally {\n input.signal.removeEventListener('abort', abortWait)\n }\n } catch {\n return input.signal.aborted || timeout.signal.aborted ? 'cancelled' : 'unavailable'\n } finally {\n window.clearTimeout(preRedirectId)\n input.signal.removeEventListener('abort', onAbort)\n closePopup(popup)\n }\n}\n","import type {\n HubApiKeyConnectionMetadata,\n HubConnection,\n HubConnectionHealthResponse,\n HubOAuthStartResponse,\n HubPolicy,\n HubPolicyDecision,\n HubProvider,\n HubTool,\n} from '@tangle-network/hub-sdk'\n\n/** The host must bind each request to this server-verified identity. */\nexport interface HubIntegrationsIdentity {\n readonly userId: string\n readonly sessionId: string\n readonly workspaceId: string\n}\n\nexport interface HubSettingsRequest {\n readonly identity: HubIntegrationsIdentity\n readonly path: string\n readonly init: RequestInit\n}\n\n/**\n * The host supplies its authenticated fetch, CSRF protection and expected\n * identity check. The browser never receives a Hub credential or SDK client.\n */\nexport type HubSettingsRequestFn = (request: HubSettingsRequest) => Promise<Response>\n\nexport interface HubIntegrationsClient {\n providers(identity: HubIntegrationsIdentity, signal?: AbortSignal): Promise<HubProvider[]>\n connections(identity: HubIntegrationsIdentity, signal?: AbortSignal): Promise<HubConnection[]>\n startOAuth(identity: HubIntegrationsIdentity, providerId: string, input: { returnUrl: string; connectionParameters?: Record<string, string> }, signal?: AbortSignal): Promise<HubOAuthStartResponse>\n connectApiKey(identity: HubIntegrationsIdentity, providerId: string, apiKey: string, metadata?: HubApiKeyConnectionMetadata, signal?: AbortSignal): Promise<HubConnection>\n revoke(identity: HubIntegrationsIdentity, connectionId: string, signal?: AbortSignal): Promise<HubConnection>\n health(identity: HubIntegrationsIdentity, connectionId: string, signal?: AbortSignal): Promise<HubConnectionHealthResponse>\n actions(identity: HubIntegrationsIdentity, providerId: string, limit: number, signal?: AbortSignal): Promise<HubTool[]>\n policies(identity: HubIntegrationsIdentity, connectionId: string, signal?: AbortSignal): Promise<HubPolicy[]>\n setPolicy(identity: HubIntegrationsIdentity, connectionId: string, actionPath: string, decision: HubPolicyDecision, signal?: AbortSignal): Promise<HubPolicy>\n resetPolicy(identity: HubIntegrationsIdentity, connectionId: string, actionPath: string, signal?: AbortSignal): Promise<void>\n}\n\nfunction object(value: unknown): Record<string, unknown> {\n if (value === null || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid Hub settings response.')\n return value as Record<string, unknown>\n}\n\nfunction array(value: unknown): unknown[] {\n if (!Array.isArray(value)) throw new Error('Invalid Hub settings response.')\n return value\n}\n\nfunction namedArray<T>(value: unknown, key: string): T[] {\n const rows = array(object(value)[key])\n if (rows.some(row => row === null || typeof row !== 'object' || Array.isArray(row))) throw new Error('Invalid Hub settings response.')\n return rows as T[]\n}\n\nfunction namedObject<T>(value: unknown, key: string): T {\n return object(object(value)[key]) as T\n}\n\nfunction segment(value: string): string {\n if (!/^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(value)) throw new TypeError('Invalid Hub settings identifier.')\n return encodeURIComponent(value)\n}\n\n/** Finite browser transport for the server-owned `createHubSettingsRoutes` API. */\nexport function createHubIntegrationsClient(request: HubSettingsRequestFn, basePath = '/api/hub/settings'): HubIntegrationsClient {\n if (!/^\\/(?:[A-Za-z0-9_-]+\\/)*[A-Za-z0-9_-]+$/.test(basePath)) throw new TypeError('Invalid Hub settings basePath.')\n\n async function call(identity: HubIntegrationsIdentity, path: string, method: 'GET' | 'POST' | 'PUT' | 'DELETE', signal?: AbortSignal, body?: object): Promise<unknown> {\n if (![identity.userId, identity.sessionId, identity.workspaceId].every(part => typeof part === 'string' && part.trim())) {\n throw new TypeError('Hub settings identity is required.')\n }\n const response = await request({\n identity,\n path: `${basePath}${path}`,\n init: { method, signal, ...(body === undefined ? {} : { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) }) },\n })\n if (!response.ok) {\n let code: string | undefined\n try {\n const error = object(await response.json())\n if (typeof error.code === 'string') code = error.code\n } catch { /* Status remains authoritative when a response is unreadable. */ }\n throw new Error(`Hub settings request failed (${response.status}${code ? `, ${code}` : ''}).`)\n }\n return response.json()\n }\n\n return {\n async providers(identity, signal) { return namedArray<HubProvider>(await call(identity, '/providers', 'GET', signal), 'providers') },\n async connections(identity, signal) { return namedArray<HubConnection>(await call(identity, '/connections', 'GET', signal), 'connections') },\n async startOAuth(identity, providerId, input, signal) {\n const response = object(await call(identity, `/connections/${segment(providerId)}/start`, 'POST', signal, input))\n if (typeof response.redirectUrl !== 'string') throw new Error('Invalid Hub OAuth response.')\n return response as unknown as HubOAuthStartResponse\n },\n async connectApiKey(identity, providerId, apiKey, metadata, signal) {\n return namedObject<HubConnection>(await call(identity, `/connections/${segment(providerId)}/connect-key`, 'POST', signal, { apiKey, ...(metadata === undefined ? {} : { metadata }) }), 'connection')\n },\n async revoke(identity, connectionId, signal) { return namedObject<HubConnection>(await call(identity, `/connections/${segment(connectionId)}`, 'DELETE', signal), 'connection') },\n async health(identity, connectionId, signal) {\n const response = object(await call(identity, `/connections/${segment(connectionId)}/health`, 'POST', signal))\n object(response.connection)\n object(response.health)\n return response as unknown as HubConnectionHealthResponse\n },\n async actions(identity, providerId, limit, signal) {\n if (!Number.isInteger(limit) || limit < 1 || limit > 200) throw new TypeError('Hub action limit must be 1–200.')\n const search = new URLSearchParams({ query: '', limit: String(limit) })\n return namedArray<HubTool>(await call(identity, `/providers/${segment(providerId)}/actions?${search}`, 'GET', signal), 'tools')\n },\n async policies(identity, connectionId, signal) {\n const search = new URLSearchParams({ connectionId })\n return namedArray<HubPolicy>(await call(identity, `/policies?${search}`, 'GET', signal), 'policies')\n },\n async setPolicy(identity, connectionId, actionPath, decision, signal) {\n return namedObject<HubPolicy>(await call(identity, '/policies', 'PUT', signal, { connectionId, actionPath, decision }), 'policy')\n },\n async resetPolicy(identity, connectionId, actionPath, signal) {\n const response = object(await call(identity, '/policies', 'DELETE', signal, { connectionId, actionPath }))\n if (response.connectionId !== connectionId || response.actionPath !== actionPath || typeof response.deleted !== 'boolean') {\n throw new Error('Invalid Hub policy reset response.')\n }\n },\n }\n}\n","import type { HubApiKeyConnectionMetadata, HubProvider } from '@tangle-network/hub-sdk'\nimport {\n ApiKeyConnectDialog,\n IntegrationConnectionDetail,\n IntegrationsCatalog,\n OAuthConnectionParameterDialog,\n type IntegrationSort,\n} from '@tangle-network/sandbox-ui/integrations'\nimport { Button } from '@tangle-network/ui/primitives'\nimport { useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport type { HubIntegrationsClient, HubIntegrationsIdentity } from './client'\nimport { contextKey, displayProvider, type HubIntegrationCapabilities } from './projection'\nimport { useHubIntegrations } from './use-hub-integrations'\n\nexport interface HubIntegrationsPanelProps {\n identity: HubIntegrationsIdentity\n client: HubIntegrationsClient\n can: HubIntegrationCapabilities\n callbackPath: string\n title?: string\n className?: string\n onRequestIntegration?: (prefill: string) => void\n onUnsupportedConnect?: (provider: HubProvider) => void\n /** Host-owned, transient fields for providers that require API-key metadata. */\n renderApiKeyMetadata?: (input: {\n provider: HubProvider\n value: HubApiKeyConnectionMetadata | undefined\n onChange: (value: HubApiKeyConnectionMetadata | undefined) => void\n }) => ReactNode\n}\n\nfunction catalogHref(): string {\n if (typeof window === 'undefined') return '/'\n const url = new URL(window.location.href)\n url.searchParams.delete('integration')\n url.searchParams.delete('connection')\n return `${url.pathname}${url.search}${url.hash}`\n}\n\n/** Embeddable settings surface. The app supplies authenticated transport and grants. */\nexport function HubIntegrationsPanel(props: HubIntegrationsPanelProps) {\n const hub = useHubIntegrations(props)\n const scope = contextKey(props.identity)\n const activeScope = useRef(scope)\n activeScope.current = scope\n const activeDialog = useRef(hub.dialog)\n activeDialog.current = hub.dialog\n const [query, setQuery] = useState('')\n const [category, setCategory] = useState('')\n const [sort, setSort] = useState<IntegrationSort>('featured')\n const [keyInput, setKeyInput] = useState({ scope, value: '' })\n const apiKey = keyInput.scope === scope ? keyInput.value : ''\n const setApiKey = (value: string) => setKeyInput({ scope, value })\n const [metadataInput, setMetadataInput] = useState<{ scope: string; value: HubApiKeyConnectionMetadata | undefined }>({ scope, value: undefined })\n const metadata = metadataInput.scope === scope ? metadataInput.value : undefined\n const setMetadata = (value: HubApiKeyConnectionMetadata | undefined) => setMetadataInput({ scope, value })\n const [parameterInput, setParameterInput] = useState({ scope, values: {} as Record<string, string> })\n const parameters = parameterInput.scope === scope ? parameterInput.values : {}\n const setParameters = (values: Record<string, string>) => setParameterInput({ scope, values })\n\n useEffect(() => { setApiKey(''); setMetadata(undefined); setParameters({}) }, [scope])\n const pending = hub.writeState.status === 'pending' || hub.connectStatus.status === 'pending'\n const error = hub.providers.status === 'error' ? hub.providers.message\n : hub.connections.status === 'error' ? hub.connections.message : null\n const mutationError = hub.writeState.status === 'failed' ? hub.writeState.message : null\n const writeMessage = hub.writeState.status === 'succeeded' ? hub.writeState.value.message : null\n const writeWarning = hub.writeState.status === 'succeeded' && hub.writeState.value.reconciliation === 'refresh-failed'\n const selectedRow = hub.rows.find(row => row.providerId === hub.provider?.providerId)\n const detailError = hub.detail.status === 'error' ? hub.detail.message\n : hub.detail.status === 'ready' && hub.detail.value.truncated\n ? `Showing at most ${hub.detail.value.tools.length} actions. The provider catalog may be incomplete.` : null\n const detailsByConnectionId = useMemo(() => hub.connection ? {\n [hub.connection.id]: {\n ...hub.details,\n loading: hub.detail.status === 'loading',\n busy: pending,\n error: detailError,\n },\n } : {}, [hub.connection, hub.details, hub.detail.status, pending, detailError])\n\n const closeDialog = () => {\n if (hub.connectStatus.status === 'pending') hub.cancelConnect()\n else hub.setDialog(null)\n setApiKey(''); setMetadata(undefined); setParameters({})\n }\n\n return <section className={props.className}>\n {hub.connectStatus.status === 'pending' ? <div role=\"status\" className=\"mb-4 flex flex-wrap items-center gap-3\">\n <span>Finish connecting in the popup.</span>\n <Button type=\"button\" variant=\"outline\" onClick={hub.cancelConnect}>Cancel connection</Button>\n </div> : null}\n {hub.writeState.status === 'pending' ? <p role=\"status\">Saving Hub settings…</p> : null}\n {mutationError ? <p role=\"alert\">{mutationError}</p> : null}\n {writeMessage ? <p role={writeWarning ? 'alert' : 'status'}>{writeMessage}</p> : null}\n {hub.connectStatus.message && hub.provider ? <p role={hub.connectStatus.status === 'failed' ? 'alert' : 'status'}>{hub.connectStatus.message}</p> : null}\n {hub.provider ? <>\n {selectedRow?.canConnect ? <div className=\"mb-4 flex justify-end\"><Button type=\"button\" variant=\"outline\" disabled={pending}\n onClick={() => hub.beginConnect(hub.provider!)}>Connect another account</Button></div> : null}\n <IntegrationConnectionDetail\n provider={displayProvider(hub.provider)}\n connections={selectedRow?.connections ?? []}\n selectedConnectionId={hub.connection?.id ?? null}\n onSelectConnection={connectionId => hub.selectConnection(hub.provider!.providerId, connectionId)}\n detailsByConnectionId={detailsByConnectionId}\n loading={hub.connections.status === 'loading' || hub.detail.status === 'loading'}\n error={detailError}\n backHref={catalogHref()}\n onRetry={() => hub.refresh()}\n onTestConnection={connectionId => { void hub.test(connectionId) }}\n onDisconnect={connectionId => { void hub.revoke(connectionId) }}\n onDecisionChange={(connectionId, actionPath, decision) => {\n if (decision !== 'allow' && decision !== 'ask' && decision !== 'deny') return\n void hub.setDecision(connectionId, actionPath, decision)\n }}\n onResetDecision={(connectionId, actionPath) => { void hub.resetDecision(connectionId, actionPath) }}\n />\n </> : <IntegrationsCatalog\n title={props.title ?? 'Integrations'}\n rows={hub.rows}\n query={query}\n onQueryChange={setQuery}\n categoryFilter={category}\n onCategoryFilterChange={setCategory}\n sort={sort}\n onSortChange={setSort}\n onSelectConnection={(providerId, connectionId) => hub.selectConnection(providerId, connectionId)}\n onConnect={row => { const provider = hub.providers.status === 'ready' ? hub.providers.value.find(item => item.providerId === row.providerId) : null; if (provider) hub.beginConnect(provider) }}\n onManage={(connection, row) => hub.selectConnection(row.providerId, connection.id)}\n onDisconnect={connection => { void hub.revoke(connection.id) }}\n onRequestIntegration={props.onRequestIntegration}\n onRetry={() => hub.refresh()}\n loading={hub.providers.status === 'loading' || hub.connections.status === 'loading'}\n error={error}\n actionError={mutationError}\n connectError={hub.connectStatus.status === 'failed' ? hub.connectStatus.message : null}\n busyProviderId={hub.connectStatus.status === 'pending' ? hub.connectStatus.providerId ?? null : null}\n reserveConnectionContext\n />}\n {hub.dialog?.kind === 'api-key' ? <ApiKeyConnectDialog\n open\n onOpenChange={open => { if (!open) closeDialog() }}\n providerId={hub.dialog.provider.providerId}\n title={hub.dialog.provider.title}\n description={hub.dialog.provider.authHint}\n value={apiKey}\n onValueChange={setApiKey}\n busy={pending}\n error={mutationError}\n canSubmit={apiKey.trim().length > 0 && !pending}\n onSubmit={() => {\n const secret = apiKey\n const target = hub.dialog?.provider.providerId\n const submittedDialog = hub.dialog\n setApiKey('')\n if (target) void hub.submitApiKey(target, secret, metadata).then(result => {\n if (result.succeeded && activeScope.current === scope && activeDialog.current === submittedDialog) {\n hub.setDialog(null); setMetadata(undefined)\n }\n })\n }}\n >{props.renderApiKeyMetadata?.({ provider: hub.dialog.provider, value: metadata, onChange: setMetadata })}</ApiKeyConnectDialog> : null}\n {hub.dialog?.kind === 'oauth' ? <OAuthConnectionParameterDialog\n open\n onOpenChange={open => { if (!open) closeDialog() }}\n providerId={hub.dialog.provider.providerId}\n title={hub.dialog.provider.title}\n parameters={hub.dialog.provider.connectionParameters ?? []}\n values={parameters}\n onValueChange={(key, value) => setParameters({ ...parameters, [key]: value })}\n busy={pending}\n error={hub.connectStatus.status === 'failed' ? hub.connectStatus.message : null}\n canSubmit={!pending && (hub.dialog.provider.connectionParameters ?? []).every(field => !field.required || !!parameters[field.key]?.trim())}\n onSubmit={() => {\n const target = hub.dialog?.provider\n const submittedDialog = hub.dialog\n if (target) void hub.startOAuth(target, parameters).then(result => {\n if (result === 'connected' && activeScope.current === scope && activeDialog.current === submittedDialog) setParameters({})\n })\n }}\n /> : null}\n </section>\n}\n","import type { HubConnection, HubPolicy, HubProvider, HubTool } from '@tangle-network/hub-sdk'\nimport type {\n IntegrationConnectionDetails,\n IntegrationDisplayProvider,\n IntegrationPermissionDisplay,\n IntegrationPermissionGroup,\n IntegrationsProviderRow,\n} from '@tangle-network/sandbox-ui/integrations'\n\nexport type HubIntegrationCapability =\n | { operation: 'oauth.start' | 'api-key.connect'; providerId: string }\n | { operation: 'connection.revoke' | 'connection.health' | 'policies.list'; connectionId: string }\n | { operation: 'policy.set' | 'policy.reset'; connectionId: string; actionPath: string }\n\n/** Display hints only. `createHubSettingsRoutes.authorize` remains authoritative. */\nexport type HubIntegrationCapabilities = (intent: HubIntegrationCapability) => boolean\n\nexport const ACTION_LIMIT = 200\n\nexport function contextKey(identity: { userId: string; sessionId: string; workspaceId: string }): string {\n return JSON.stringify([identity.userId, identity.sessionId, identity.workspaceId])\n}\n\nexport function displayProvider(provider: HubProvider): IntegrationDisplayProvider {\n return { providerId: provider.providerId, title: provider.title, category: provider.category }\n}\n\nexport function catalogRows(\n providers: readonly HubProvider[],\n connections: readonly HubConnection[],\n selectedIds: Readonly<Record<string, string | null>>,\n can: HubIntegrationCapabilities,\n hasUnsupportedConnect = false,\n): IntegrationsProviderRow[] {\n return providers.map(provider => {\n const accounts = connections.filter(connection => connection.providerId === provider.providerId)\n return {\n ...displayProvider(provider),\n kind: 'provider',\n authKind: provider.authKind,\n selectedConnectionId: accounts.some(account => account.id === selectedIds[provider.providerId])\n ? selectedIds[provider.providerId] ?? null : null,\n canConnect: provider.authKind === 'oauth2'\n ? provider.configured && can({ operation: 'oauth.start', providerId: provider.providerId })\n : provider.authKind === 'api_key'\n ? provider.configured && can({ operation: 'api-key.connect', providerId: provider.providerId })\n : hasUnsupportedConnect,\n connections: accounts.map(connection => ({\n id: connection.id,\n accountDisplay: connection.accountDisplay ?? connection.displayName,\n statusLabel: connection.status === 'active' ? 'Connected' : connection.status.replaceAll('_', ' '),\n statusTone: connection.status === 'active' && connection.health !== 'unhealthy' ? 'success' : 'warning',\n detail: connection.providerAccountId ?? undefined,\n capabilities: {\n manage: can({ operation: 'policies.list', connectionId: connection.id }),\n disconnect: can({ operation: 'connection.revoke', connectionId: connection.id }),\n test: can({ operation: 'connection.health', connectionId: connection.id }),\n editPermissions: can({ operation: 'policies.list', connectionId: connection.id }),\n resetPermissions: can({ operation: 'policies.list', connectionId: connection.id }),\n },\n })),\n }\n })\n}\n\nconst OPTIONS = [\n { value: 'allow', label: 'Allow' },\n { value: 'ask', label: 'Ask' },\n { value: 'deny', label: 'Deny' },\n] as const\n\n/** Stored overrides are shown; app-specific effective policy is never guessed. */\nexport function permissionDetails(\n tools: readonly HubTool[],\n policies: readonly HubPolicy[],\n connectionId: string,\n can: HubIntegrationCapabilities,\n): IntegrationConnectionDetails {\n const overrides = new Map(policies.filter(policy => policy.connectionId === connectionId).map(policy => [policy.actionPath, policy.decision]))\n const groups: IntegrationPermissionGroup[] = [\n { id: 'writes', title: 'Write and unknown actions', rows: [] },\n { id: 'reads', title: 'Read actions', collapsed: true, rows: [] },\n ]\n const writes: IntegrationPermissionDisplay[] = []\n const reads: IntegrationPermissionDisplay[] = []\n for (const tool of tools) {\n const override = overrides.get(tool.path)\n const row = {\n actionPath: tool.path,\n title: tool.title ?? tool.path,\n riskLabel: tool.risk ?? 'unknown',\n riskTone: tool.risk === 'destructive' ? 'error' : tool.risk === 'write' || tool.risk === undefined ? 'warning' : 'neutral',\n decision: override ?? null,\n decisionOptions: OPTIONS,\n sourceLabel: override ? 'Stored override' : 'No stored override',\n canReset: override !== undefined && can({ operation: 'policy.reset', connectionId, actionPath: tool.path }),\n disabled: !can({ operation: 'policy.set', connectionId, actionPath: tool.path }),\n } as const\n if (tool.risk === 'read') reads.push(row)\n else writes.push(row)\n }\n writes.sort((a, b) => a.title.localeCompare(b.title))\n reads.sort((a, b) => a.title.localeCompare(b.title))\n groups[0] = { ...groups[0]!, rows: writes }\n groups[1] = { ...groups[1]!, rows: reads }\n return { permissionGroups: groups }\n}\n","import type { HubApiKeyConnectionMetadata, HubConnection, HubPolicyDecision, HubProvider } from '@tangle-network/hub-sdk'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { confirmWrite, useAsyncResource, useConfirmedMutation } from '../web-react/async'\nimport type { HubIntegrationsClient, HubIntegrationsIdentity } from './client'\nimport { connectWithPopup, type PopupConnectResult } from './popup'\nimport { ACTION_LIMIT, catalogRows, contextKey, permissionDetails, type HubIntegrationCapabilities } from './projection'\n\ntype Selection = { scope: string; providerId: string | null; connectionId: string | null }\ntype Dialog = { scope: string; kind: 'api-key' | 'oauth'; provider: HubProvider } | null\n\nexport interface UseHubIntegrationsOptions {\n identity: HubIntegrationsIdentity\n client: HubIntegrationsClient\n /** Display only. The host server must authorize every exact operation. */\n can: HubIntegrationCapabilities\n /** Local app route that renders `HubConnectCallbackPage`. */\n callbackPath: string\n /** Optional host handler for custom/native signup. No Platform redirect is assumed. */\n onUnsupportedConnect?: (provider: HubProvider) => void\n}\n\ntype WriteInput =\n | { kind: 'api-key'; identity: HubIntegrationsIdentity; scope: string; providerId: string; apiKey: string; metadata?: HubApiKeyConnectionMetadata }\n | { kind: 'revoke'; identity: HubIntegrationsIdentity; scope: string; connectionId: string }\n | { kind: 'health'; identity: HubIntegrationsIdentity; scope: string; connectionId: string }\n | { kind: 'set'; identity: HubIntegrationsIdentity; scope: string; connectionId: string; actionPath: string; decision: HubPolicyDecision }\n | { kind: 'reset'; identity: HubIntegrationsIdentity; scope: string; connectionId: string; actionPath: string }\n\nexport interface HubWriteReceipt {\n scope: string\n kind: WriteInput['kind']\n reconciliation: 'verified' | 'refresh-failed'\n message: string\n}\n\nfunction initialSelection(scope: string): Selection {\n if (typeof window === 'undefined') return { scope, providerId: null, connectionId: null }\n const query = new URL(window.location.href).searchParams\n return { scope, providerId: query.get('integration'), connectionId: query.get('connection') }\n}\n\nfunction updateUrl(providerId: string | null, connectionId: string | null): void {\n if (typeof window === 'undefined') return\n const url = new URL(window.location.href)\n if (providerId) url.searchParams.set('integration', providerId)\n else url.searchParams.delete('integration')\n if (connectionId) url.searchParams.set('connection', connectionId)\n else url.searchParams.delete('connection')\n window.history.pushState(window.history.state, '', url)\n}\n\n/** Identity-bound Hub settings controller; connection state is always server-read. */\nexport function useHubIntegrations({ identity, client, can, callbackPath, onUnsupportedConnect }: UseHubIntegrationsOptions) {\n const scope = contextKey(identity)\n const activeScope = useRef(scope)\n activeScope.current = scope\n const [selection, setSelection] = useState<Selection>(() => initialSelection(scope))\n const visibleSelection = selection.scope === scope ? selection : { scope, providerId: null, connectionId: null }\n const [dialog, setDialog] = useState<Dialog>(null)\n const visibleDialog = dialog?.scope === scope ? dialog : null\n const [connectStatus, setConnectStatus] = useState<{ scope: string; status: 'idle' | 'pending' | 'connected' | 'failed'; providerId?: string; message?: string }>({ scope, status: 'idle' })\n const [writeScope, setWriteScope] = useState(scope)\n const pendingPopup = useRef<AbortController | null>(null)\n\n useEffect(() => {\n const onPop = () => setSelection(initialSelection(scope))\n window.addEventListener('popstate', onPop)\n return () => window.removeEventListener('popstate', onPop)\n }, [scope])\n\n const providers = useAsyncResource({ load: ({ signal }) => client.providers(identity, signal), deps: [client, scope], isEmpty: () => false })\n const connections = useAsyncResource({ load: ({ signal }) => client.connections(identity, signal), deps: [client, scope], isEmpty: () => false })\n const providerList = providers.status === 'ready' ? providers.value : []\n const connectionList = connections.status === 'ready' ? connections.value : []\n const provider = providerList.find(item => item.providerId === visibleSelection.providerId) ?? null\n const connection = connectionList.find(item => item.id === visibleSelection.connectionId && item.providerId === provider?.providerId) ?? null\n const canReadPolicies = connection !== null && can({ operation: 'policies.list', connectionId: connection.id })\n const detail = useAsyncResource({\n enabled: canReadPolicies && connection?.status === 'active',\n deps: [client, scope, provider?.providerId, connection?.id, canReadPolicies],\n isEmpty: () => false,\n load: async ({ signal }) => {\n if (!provider || !connection) throw new Error('Choose a connection.')\n const [tools, policies] = await Promise.all([\n client.actions(identity, provider.providerId, ACTION_LIMIT, signal),\n client.policies(identity, connection.id, signal),\n ])\n if (tools.some(tool => !tool.path.startsWith(`${provider.providerId}.`)) || policies.some(policy => policy.connectionId !== connection.id)) {\n throw new Error('Hub settings response changed connection or provider.')\n }\n return { tools, policies, truncated: tools.length >= ACTION_LIMIT }\n },\n })\n\n const write = useConfirmedMutation<WriteInput, HubWriteReceipt>({\n concurrency: 'reject',\n mutate: async (input, { signal }) => {\n if (input.scope !== activeScope.current) throw new Error('Integration context changed. Retry in the current workspace.')\n const origin = input.identity\n const receipt = (reconciliation: HubWriteReceipt['reconciliation'], message: string) => confirmWrite<HubWriteReceipt>({ scope: input.scope, kind: input.kind, reconciliation, message })\n if (input.kind === 'api-key') {\n if (!can({ operation: 'api-key.connect', providerId: input.providerId })) throw new Error('Connection setup is unavailable.')\n const created = await client.connectApiKey(origin, input.providerId, input.apiKey, input.metadata, signal)\n if (created.providerId !== input.providerId || created.status !== 'active') throw new Error('Hub did not confirm the requested connection.')\n try {\n const current = await client.connections(origin, signal)\n return current.some(item => item.id === created.id && item.status === 'active')\n ? receipt('verified', 'Connection saved and verified.') : receipt('refresh-failed', 'Connection saved; current account state could not be confirmed.')\n } catch { return receipt('refresh-failed', 'Connection saved; refresh failed.') }\n }\n if (input.kind === 'revoke') {\n if (!can({ operation: 'connection.revoke', connectionId: input.connectionId })) throw new Error('Disconnect is unavailable.')\n await client.revoke(origin, input.connectionId, signal)\n try {\n const current = await client.connections(origin, signal)\n return current.some(item => item.id === input.connectionId && item.status === 'active')\n ? receipt('refresh-failed', 'Disconnected, but the current account state disagrees.') : receipt('verified', 'Connection disconnected and verified.')\n } catch { return receipt('refresh-failed', 'Disconnected; refresh failed.') }\n }\n if (input.kind === 'health') {\n if (!can({ operation: 'connection.health', connectionId: input.connectionId })) throw new Error('Connection test is unavailable.')\n const result = await client.health(origin, input.connectionId, signal)\n if (result.connection.id !== input.connectionId) throw new Error('Hub returned another connection.')\n return receipt('verified', `Connection test: ${result.health.status.replaceAll('_', ' ')}.`)\n }\n if (!can({ operation: input.kind === 'set' ? 'policy.set' : 'policy.reset', connectionId: input.connectionId, actionPath: input.actionPath })) {\n throw new Error('Permission editing is unavailable.')\n }\n if (input.kind === 'set') {\n const stored = await client.setPolicy(origin, input.connectionId, input.actionPath, input.decision, signal)\n if (stored.connectionId !== input.connectionId || stored.actionPath !== input.actionPath || stored.decision !== input.decision) {\n throw new Error('Hub did not confirm the requested permission.')\n }\n } else await client.resetPolicy(origin, input.connectionId, input.actionPath, signal)\n try {\n const current = await client.policies(origin, input.connectionId, signal)\n const override = current.find(policy => policy.actionPath === input.actionPath)\n const matches = input.kind === 'set' ? override?.decision === input.decision : override === undefined\n return matches\n ? receipt('verified', 'Permission saved and verified.') : receipt('refresh-failed', 'Permission write was accepted; current policy state disagrees.')\n } catch { return receipt('refresh-failed', 'Permission write was accepted; refresh failed.') }\n },\n onSucceeded: value => { if (value.scope === activeScope.current) { connections.retry(); detail.retry() } },\n })\n\n useEffect(() => {\n pendingPopup.current?.abort()\n pendingPopup.current = null\n setDialog(null)\n setConnectStatus({ scope, status: 'idle' })\n setWriteScope(scope)\n write.reset()\n return () => { pendingPopup.current?.abort(); pendingPopup.current = null }\n }, [scope, client, write.reset])\n\n const selectProvider = useCallback((providerId: string | null) => {\n const next = { scope, providerId, connectionId: null }\n setSelection(next)\n updateUrl(providerId, null)\n }, [scope])\n\n const selectConnection = useCallback((providerId: string, connectionId: string | null) => {\n if (connectionId && !connectionList.some(item => item.id === connectionId && item.providerId === providerId)) return\n setSelection({ scope, providerId, connectionId })\n updateUrl(providerId, connectionId)\n }, [scope, connectionList])\n\n const startOAuth = useCallback(async (target: HubProvider, connectionParameters?: Record<string, string>): Promise<PopupConnectResult> => {\n if (!can({ operation: 'oauth.start', providerId: target.providerId })) return 'unavailable'\n if (connections.status !== 'ready') { setConnectStatus({ scope, status: 'failed', message: 'Load connections before connecting.' }); return 'unavailable' }\n pendingPopup.current?.abort()\n const controller = new AbortController()\n pendingPopup.current = controller\n setConnectStatus({ scope, status: 'pending', providerId: target.providerId })\n const result = await connectWithPopup({\n client, identity, providerId: target.providerId, before: connections.value,\n callbackPath, connectionParameters, signal: controller.signal,\n isCurrent: () => activeScope.current === scope && !controller.signal.aborted,\n })\n if (pendingPopup.current !== controller || activeScope.current !== scope) return result\n pendingPopup.current = null\n if (result === 'connected') {\n connections.retry()\n setDialog(null)\n setConnectStatus({ scope, status: 'connected', message: 'Connection verified.' })\n } else setConnectStatus({ scope, status: 'failed', message: result === 'blocked' ? 'Allow the popup and try again.' : result === 'unverified' ? 'Could not verify a new connection. Refresh and try again.' : result === 'cancelled' ? 'Connection was cancelled.' : 'This connection flow is unavailable.' })\n return result\n }, [can, connections, client, identity, callbackPath, scope])\n\n const beginConnect = useCallback((target: HubProvider) => {\n if (target.authKind !== 'api_key' && target.authKind !== 'oauth2') {\n if (onUnsupportedConnect) onUnsupportedConnect(target)\n else setConnectStatus({ scope, status: 'failed', message: 'This provider needs an app-specific connection flow.' })\n return\n }\n if (!target.configured) {\n setConnectStatus({ scope, status: 'failed', message: 'This provider is not configured for connection.' })\n return\n }\n if (target.authKind === 'api_key') {\n if (can({ operation: 'api-key.connect', providerId: target.providerId })) setDialog({ scope, kind: 'api-key', provider: target })\n else setConnectStatus({ scope, status: 'failed', message: 'Connection setup is unavailable.' })\n return\n }\n if (target.authKind === 'oauth2') {\n if (!can({ operation: 'oauth.start', providerId: target.providerId })) {\n setConnectStatus({ scope, status: 'failed', message: 'Connection setup is unavailable.' }); return\n }\n if (target.connectionParameters?.length) setDialog({ scope, kind: 'oauth', provider: target })\n else void startOAuth(target)\n return\n }\n }, [can, onUnsupportedConnect, scope, startOAuth])\n\n const cancelConnect = useCallback(() => {\n pendingPopup.current?.abort()\n pendingPopup.current = null\n setDialog(null)\n setConnectStatus({ scope, status: 'failed', message: 'Connection was cancelled.' })\n }, [scope])\n\n const rows = useMemo(() => catalogRows(providerList, connectionList, visibleSelection.providerId && visibleSelection.connectionId\n ? { [visibleSelection.providerId]: visibleSelection.connectionId } : {}, can, !!onUnsupportedConnect),\n [providerList, connectionList, visibleSelection.providerId, visibleSelection.connectionId, can, onUnsupportedConnect])\n const details = detail.status === 'ready' && connection\n ? permissionDetails(detail.value.tools, detail.value.policies, connection.id, can) : undefined\n\n return {\n providers, connections, detail, rows, provider, connection, dialog: visibleDialog, setDialog,\n connectStatus: connectStatus.scope === scope ? connectStatus : { scope, status: 'idle' as const, providerId: undefined },\n selection: visibleSelection, selectProvider, selectConnection, beginConnect, startOAuth, cancelConnect,\n write, writeState: writeScope === scope ? write.state : { status: 'idle' as const }, details,\n refresh: () => { providers.retry(); connections.retry(); detail.retry() },\n submitApiKey: (providerId: string, apiKey: string, metadata?: HubApiKeyConnectionMetadata) => { setWriteScope(scope); return write.run({ kind: 'api-key', identity, scope, providerId, apiKey, metadata }) },\n revoke: (connectionId: string) => { setWriteScope(scope); return write.run({ kind: 'revoke', identity, scope, connectionId }) },\n test: (connectionId: string) => { setWriteScope(scope); return write.run({ kind: 'health', identity, scope, connectionId }) },\n setDecision: (connectionId: string, actionPath: string, decision: HubPolicyDecision) => { setWriteScope(scope); return write.run({ kind: 'set', identity, scope, connectionId, actionPath, decision }) },\n resetDecision: (connectionId: string, actionPath: string) => { setWriteScope(scope); return write.run({ kind: 'reset', identity, scope, connectionId, actionPath }) },\n }\n}\n"],"mappings":";;;;;;;AAAA,SAAS,WAAW,gBAAgB;;;ACG7B,IAAM,sBAAsB;AAC5B,IAAM,6BAA6B;AACnC,IAAM,kCAAkC;AACxC,IAAM,mBAAmB,IAAI,KAAK;AACzC,IAAM,0BAA0B;AAChC,IAAM,mBAAmB;AACzB,IAAM,iBAAiB;AAIhB,SAAS,YAAY,MAA0B;AACpD,MAAI,CAAC,KAAK,WAAW,GAAG,KAAK,KAAK,WAAW,IAAI,EAAG,QAAO;AAC3D,MAAI;AACF,UAAM,SAAS,OAAO,WAAW,cAAc,0BAA0B,OAAO,SAAS;AACzF,UAAM,MAAM,IAAI,IAAI,MAAM,MAAM;AAChC,WAAO,IAAI,WAAW,UAAU,CAAC,IAAI,YAAY,CAAC,IAAI,WAAW,MAAM;AAAA,EACzE,QAAQ;AAAE,WAAO;AAAA,EAAK;AACxB;AAEA,SAAS,kBAAkB,YAAoB,QAAkC,OAA0C;AACzH,QAAM,WAAW,IAAI,IAAI,OAAO,OAAO,gBAAc,WAAW,eAAe,UAAU,EAAE,IAAI,gBAAc,CAAC,WAAW,IAAI,UAAU,CAAC,CAAC;AACzI,SAAO,MAA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UAAU,cAAc,EAAE,GAAG,YAAY,CAAC,GAAG,GAAG,MAAM,CAAC;AAAA,QAC5E,MAAM;AAAA,QACN,OAAO,IAAI,cAAc,WAAW,WAAW,IAAI,cAAc,UAAU;AAAA,QAC3E,WAAW,CAAC,YAAY,IAAI,OAAO,SAAS,wBAAwB,CAAC,GAAG,MAAM,WAAS,CAAC,MAAM,YAAY,CAAC,CAAC,WAAW,MAAM,GAAG,GAAG,KAAK,CAAC;AAAA,QACzI,UAAU,MAAM;AACd,gBAAM,SAAS,IAAI,QAAQ;AAC3B,gBAAM,kBAAkB,IAAI;AAC5B,cAAI,OAAQ,MAAK,IAAI,WAAW,QAAQ,UAAU,EAAE,KAAK,YAAU;AACjE,gBAAI,WAAW,eAAe,YAAY,YAAY,SAAS,aAAa,YAAY,gBAAiB,eAAc,CAAC,CAAC;AAAA,UAC3H,CAAC;AAAA,QACH;AAAA;AAAA,IACF,IAAK;AAAA,KACP;AACF;","names":["useEffect","useMemo","useRef","useState","useEffect","useState","useState","useEffect","jsx","jsxs","useRef","useState","useEffect","useMemo"]}
@@ -0,0 +1,22 @@
1
+ import type { HubApiKeyConnectionMetadata, HubProvider } from '@tangle-network/hub-sdk';
2
+ import { type ReactNode } from 'react';
3
+ import type { HubIntegrationsClient, HubIntegrationsIdentity } from './client';
4
+ import { type HubIntegrationCapabilities } from './projection';
5
+ export interface HubIntegrationsPanelProps {
6
+ identity: HubIntegrationsIdentity;
7
+ client: HubIntegrationsClient;
8
+ can: HubIntegrationCapabilities;
9
+ callbackPath: string;
10
+ title?: string;
11
+ className?: string;
12
+ onRequestIntegration?: (prefill: string) => void;
13
+ onUnsupportedConnect?: (provider: HubProvider) => void;
14
+ /** Host-owned, transient fields for providers that require API-key metadata. */
15
+ renderApiKeyMetadata?: (input: {
16
+ provider: HubProvider;
17
+ value: HubApiKeyConnectionMetadata | undefined;
18
+ onChange: (value: HubApiKeyConnectionMetadata | undefined) => void;
19
+ }) => ReactNode;
20
+ }
21
+ /** Embeddable settings surface. The app supplies authenticated transport and grants. */
22
+ export declare function HubIntegrationsPanel(props: HubIntegrationsPanelProps): import("react").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import type { HubConnection } from '@tangle-network/hub-sdk';
2
+ import type { HubIntegrationsClient, HubIntegrationsIdentity } from './client';
3
+ export declare const HUB_CONNECT_CHANNEL = "tangle:hub-connect";
4
+ export declare const HUB_CONNECTED_MESSAGE_TYPE = "tangle:hub-connected";
5
+ export declare const HUB_CONNECT_FAILED_MESSAGE_TYPE = "tangle:hub-connect-failed";
6
+ export declare const POPUP_TIMEOUT_MS: number;
7
+ export type PopupConnectResult = 'connected' | 'blocked' | 'cancelled' | 'unverified' | 'unavailable';
8
+ export declare function localAppUrl(path: string): URL | null;
9
+ /** Opens before the first await, preserving the initiating user gesture. */
10
+ export declare function connectWithPopup(input: {
11
+ client: HubIntegrationsClient;
12
+ identity: HubIntegrationsIdentity;
13
+ providerId: string;
14
+ before: readonly HubConnection[];
15
+ callbackPath: string;
16
+ connectionParameters?: Record<string, string>;
17
+ signal: AbortSignal;
18
+ isCurrent: () => boolean;
19
+ }): Promise<PopupConnectResult>;
@@ -0,0 +1,25 @@
1
+ import type { HubConnection, HubPolicy, HubProvider, HubTool } from '@tangle-network/hub-sdk';
2
+ import type { IntegrationConnectionDetails, IntegrationDisplayProvider, IntegrationsProviderRow } from '@tangle-network/sandbox-ui/integrations';
3
+ export type HubIntegrationCapability = {
4
+ operation: 'oauth.start' | 'api-key.connect';
5
+ providerId: string;
6
+ } | {
7
+ operation: 'connection.revoke' | 'connection.health' | 'policies.list';
8
+ connectionId: string;
9
+ } | {
10
+ operation: 'policy.set' | 'policy.reset';
11
+ connectionId: string;
12
+ actionPath: string;
13
+ };
14
+ /** Display hints only. `createHubSettingsRoutes.authorize` remains authoritative. */
15
+ export type HubIntegrationCapabilities = (intent: HubIntegrationCapability) => boolean;
16
+ export declare const ACTION_LIMIT = 200;
17
+ export declare function contextKey(identity: {
18
+ userId: string;
19
+ sessionId: string;
20
+ workspaceId: string;
21
+ }): string;
22
+ export declare function displayProvider(provider: HubProvider): IntegrationDisplayProvider;
23
+ export declare function catalogRows(providers: readonly HubProvider[], connections: readonly HubConnection[], selectedIds: Readonly<Record<string, string | null>>, can: HubIntegrationCapabilities, hasUnsupportedConnect?: boolean): IntegrationsProviderRow[];
24
+ /** Stored overrides are shown; app-specific effective policy is never guessed. */
25
+ export declare function permissionDetails(tools: readonly HubTool[], policies: readonly HubPolicy[], connectionId: string, can: HubIntegrationCapabilities): IntegrationConnectionDetails;
@@ -0,0 +1,102 @@
1
+ import type { HubApiKeyConnectionMetadata, HubConnection, HubPolicyDecision, HubProvider } from '@tangle-network/hub-sdk';
2
+ import type { HubIntegrationsClient, HubIntegrationsIdentity } from './client';
3
+ import { type PopupConnectResult } from './popup';
4
+ import { type HubIntegrationCapabilities } from './projection';
5
+ type Selection = {
6
+ scope: string;
7
+ providerId: string | null;
8
+ connectionId: string | null;
9
+ };
10
+ type Dialog = {
11
+ scope: string;
12
+ kind: 'api-key' | 'oauth';
13
+ provider: HubProvider;
14
+ } | null;
15
+ export interface UseHubIntegrationsOptions {
16
+ identity: HubIntegrationsIdentity;
17
+ client: HubIntegrationsClient;
18
+ /** Display only. The host server must authorize every exact operation. */
19
+ can: HubIntegrationCapabilities;
20
+ /** Local app route that renders `HubConnectCallbackPage`. */
21
+ callbackPath: string;
22
+ /** Optional host handler for custom/native signup. No Platform redirect is assumed. */
23
+ onUnsupportedConnect?: (provider: HubProvider) => void;
24
+ }
25
+ type WriteInput = {
26
+ kind: 'api-key';
27
+ identity: HubIntegrationsIdentity;
28
+ scope: string;
29
+ providerId: string;
30
+ apiKey: string;
31
+ metadata?: HubApiKeyConnectionMetadata;
32
+ } | {
33
+ kind: 'revoke';
34
+ identity: HubIntegrationsIdentity;
35
+ scope: string;
36
+ connectionId: string;
37
+ } | {
38
+ kind: 'health';
39
+ identity: HubIntegrationsIdentity;
40
+ scope: string;
41
+ connectionId: string;
42
+ } | {
43
+ kind: 'set';
44
+ identity: HubIntegrationsIdentity;
45
+ scope: string;
46
+ connectionId: string;
47
+ actionPath: string;
48
+ decision: HubPolicyDecision;
49
+ } | {
50
+ kind: 'reset';
51
+ identity: HubIntegrationsIdentity;
52
+ scope: string;
53
+ connectionId: string;
54
+ actionPath: string;
55
+ };
56
+ export interface HubWriteReceipt {
57
+ scope: string;
58
+ kind: WriteInput['kind'];
59
+ reconciliation: 'verified' | 'refresh-failed';
60
+ message: string;
61
+ }
62
+ /** Identity-bound Hub settings controller; connection state is always server-read. */
63
+ export declare function useHubIntegrations({ identity, client, can, callbackPath, onUnsupportedConnect }: UseHubIntegrationsOptions): {
64
+ providers: import("../web-react/async").AsyncResourceState<HubProvider[]>;
65
+ connections: import("../web-react/async").AsyncResourceState<HubConnection[]>;
66
+ detail: import("../web-react/async").AsyncResourceState<{
67
+ tools: import("@tangle-network/hub-sdk").HubTool[];
68
+ policies: import("@tangle-network/hub-sdk").HubPolicy[];
69
+ truncated: boolean;
70
+ }>;
71
+ rows: import("@tangle-network/sandbox-ui/integrations").IntegrationsProviderRow[];
72
+ provider: HubProvider | null;
73
+ connection: HubConnection | null;
74
+ dialog: {
75
+ scope: string;
76
+ kind: 'api-key' | 'oauth';
77
+ provider: HubProvider;
78
+ } | null;
79
+ setDialog: import("react").Dispatch<import("react").SetStateAction<Dialog>>;
80
+ connectStatus: {
81
+ scope: string;
82
+ status: 'idle' | 'pending' | 'connected' | 'failed';
83
+ providerId?: string;
84
+ message?: string;
85
+ };
86
+ selection: Selection;
87
+ selectProvider: (providerId: string | null) => void;
88
+ selectConnection: (providerId: string, connectionId: string | null) => void;
89
+ beginConnect: (target: HubProvider) => void;
90
+ startOAuth: (target: HubProvider, connectionParameters?: Record<string, string>) => Promise<PopupConnectResult>;
91
+ cancelConnect: () => void;
92
+ write: import("../web-react/async").ConfirmedMutation<WriteInput, HubWriteReceipt>;
93
+ writeState: import("../web-react/async").MutationState<HubWriteReceipt>;
94
+ details: import("@tangle-network/sandbox-ui/integrations").IntegrationConnectionDetails | undefined;
95
+ refresh: () => void;
96
+ submitApiKey: (providerId: string, apiKey: string, metadata?: HubApiKeyConnectionMetadata) => Promise<import("../web-react/async").MutationOutcome<HubWriteReceipt>>;
97
+ revoke: (connectionId: string) => Promise<import("../web-react/async").MutationOutcome<HubWriteReceipt>>;
98
+ test: (connectionId: string) => Promise<import("../web-react/async").MutationOutcome<HubWriteReceipt>>;
99
+ setDecision: (connectionId: string, actionPath: string, decision: HubPolicyDecision) => Promise<import("../web-react/async").MutationOutcome<HubWriteReceipt>>;
100
+ resetDecision: (connectionId: string, actionPath: string) => Promise<import("../web-react/async").MutationOutcome<HubWriteReceipt>>;
101
+ };
102
+ export {};
@@ -1,6 +1,3 @@
1
- import {
2
- InviteAcceptPage
3
- } from "../chunk-W7P5KV6O.js";
4
1
  import {
5
2
  MembersPanel
6
3
  } from "../chunk-GRDLGQ6A.js";
@@ -8,6 +5,9 @@ import {
8
5
  InvitationsPanel
9
6
  } from "../chunk-5MI2SKQH.js";
10
7
  import "../chunk-AULM4X7U.js";
8
+ import {
9
+ InviteAcceptPage
10
+ } from "../chunk-W7P5KV6O.js";
11
11
  import "../chunk-6XIAPIW6.js";
12
12
  export {
13
13
  InvitationsPanel,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ConfirmDialog,
3
3
  VaultPane
4
- } from "../chunk-2ZNU55YJ.js";
4
+ } from "../chunk-3IATFW4U.js";
5
5
  export {
6
6
  ConfirmDialog,
7
7
  VaultPane
@@ -1,7 +1,7 @@
1
1
  // src/vault/lazy.tsx
2
2
  import { lazy } from "react";
3
3
  var VaultPaneLazy = lazy(
4
- () => import("../VaultPane-OTUP5AEX.js").then((m) => ({ default: m.VaultPane }))
4
+ () => import("../VaultPane-RHLY4DR5.js").then((m) => ({ default: m.VaultPane }))
5
5
  );
6
6
  export {
7
7
  VaultPaneLazy
@@ -192,11 +192,11 @@ import {
192
192
  usePending,
193
193
  usePopover
194
194
  } from "../chunk-XF6ZRY56.js";
195
+ import "../chunk-SJWIZT7B.js";
195
196
  import {
196
197
  tabTerminalConnectionId,
197
198
  useSandboxTerminalConnection
198
199
  } from "../chunk-BATKJP3P.js";
199
- import "../chunk-SJWIZT7B.js";
200
200
  import "../chunk-Q3ZHNN5X.js";
201
201
  import "../chunk-FQYAJYPW.js";
202
202
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.50.31",
3
+ "version": "0.50.32",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [
@@ -213,6 +213,11 @@
213
213
  "import": "./dist/integrations/index.js",
214
214
  "default": "./dist/integrations/index.js"
215
215
  },
216
+ "./integrations-react": {
217
+ "types": "./dist/integrations-react/index.d.ts",
218
+ "import": "./dist/integrations-react/index.js",
219
+ "default": "./dist/integrations-react/index.js"
220
+ },
216
221
  "./channels": {
217
222
  "types": "./dist/channels/index.d.ts",
218
223
  "import": "./dist/channels/index.js",
@@ -228,6 +233,11 @@
228
233
  "import": "./dist/agent-enrollment/index.js",
229
234
  "default": "./dist/agent-enrollment/index.js"
230
235
  },
236
+ "./agent-enrollment/drizzle": {
237
+ "types": "./dist/agent-enrollment/drizzle.d.ts",
238
+ "import": "./dist/agent-enrollment/drizzle.js",
239
+ "default": "./dist/agent-enrollment/drizzle.js"
240
+ },
231
241
  "./hosted-agent/application": {
232
242
  "types": "./dist/hosted-agent/application.d.ts",
233
243
  "import": "./dist/hosted-agent/application.js",
@@ -580,7 +590,7 @@
580
590
  "@tangle-network/brand": "1.9.1",
581
591
  "@tangle-network/hub-sdk": "0.22.1",
582
592
  "@tangle-network/sandbox": "0.59.0",
583
- "@tangle-network/sandbox-ui": "0.116.8",
593
+ "@tangle-network/sandbox-ui": "0.116.9",
584
594
  "@tangle-network/ui": "11.12.0",
585
595
  "@testing-library/dom": "^10.4.1",
586
596
  "@testing-library/react": "^16.3.3",
@@ -1,7 +0,0 @@
1
- import {
2
- VaultPane
3
- } from "./chunk-2ZNU55YJ.js";
4
- export {
5
- VaultPane
6
- };
7
- //# sourceMappingURL=VaultPane-OTUP5AEX.js.map