@burdenoff/microfe-botmanor 2026.1123.9 → 2026.1127.1
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.
- package/dist/botlit/BotlitRoutes.js +142 -138
- package/dist/botlit/BotlitRoutes.js.map +1 -1
- package/dist/botlit/hooks/internal/workspaceGateway.d.ts +12 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +1 -1
- package/dist/botlit/hooks/internal/workspaceGateway.js.map +1 -1
- package/dist/botlit/hooks/useA2A.js +2 -1
- package/dist/botlit/hooks/useA2A.js.map +1 -1
- package/dist/botlit/hooks/useA2AConnections.js +30 -38
- package/dist/botlit/hooks/useA2AConnections.js.map +1 -1
- package/dist/botlit/hooks/useKnowledgeBases.js +91 -48
- package/dist/botlit/hooks/useKnowledgeBases.js.map +1 -1
- package/dist/botlit/pages/BucketsPage.js +164 -158
- package/dist/botlit/pages/BucketsPage.js.map +1 -1
- package/dist/botlit/pages/bucketCreateDialog.d.ts +17 -0
- package/dist/botlit/pages/bucketCreateDialog.js +17 -0
- package/dist/botlit/pages/bucketCreateDialog.js.map +1 -0
- package/dist/generated/wspace-operations.d.ts +106 -42
- package/dist/generated/wspace-operations.js +198 -172
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/generated/wspace-types.d.ts +9859 -49
- package/dist/generated/wspace-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -27,6 +27,18 @@ export interface MutationState<T> {
|
|
|
27
27
|
loading: boolean;
|
|
28
28
|
error: Error | undefined;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Normalises any mutation failure to an Error with the server's
|
|
32
|
+
* user-actionable message where one exists.
|
|
33
|
+
*
|
|
34
|
+
* Apollo Client v4 does not reject with a plain Error: failures arrive as
|
|
35
|
+
* `{ networkError }` / `{ graphQLErrors }` objects, and the batched fetch
|
|
36
|
+
* layer attaches the structured GraphQL errors as `.errors` on the
|
|
37
|
+
* networkError. `extractGraphqlFailureMessage` unwraps all of those; only
|
|
38
|
+
* when nothing user-actionable is present do we fall back to the hook's
|
|
39
|
+
* generic `errorMessage`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function toError(cause: unknown, fallbackMessage: string): Error;
|
|
30
42
|
export interface WorkspaceQueryOptions<TData, TResult> {
|
|
31
43
|
/** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */
|
|
32
44
|
document: DocumentNode;
|
|
@@ -181,6 +181,6 @@ function g(e) {
|
|
|
181
181
|
a
|
|
182
182
|
]), l];
|
|
183
183
|
}
|
|
184
|
-
export { h as useWorkspaceAllPagesQuery, c as useWorkspaceClient, l as useWorkspaceId, g as useWorkspaceMutation, m as useWorkspacePaginatedQuery, f as useWorkspaceQuery };
|
|
184
|
+
export { u as toError, h as useWorkspaceAllPagesQuery, c as useWorkspaceClient, l as useWorkspaceId, g as useWorkspaceMutation, m as useWorkspacePaginatedQuery, f as useWorkspaceQuery };
|
|
185
185
|
|
|
186
186
|
//# sourceMappingURL=workspaceGateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workspaceGateway.js","names":["useWorkspaceClient","useGatewayClient","useWorkspaceId","useBotlit","toError","message","extractGraphqlFailureMessage","cause","fallbackMessage","useLatest","ref","useRef","value","useLayoutEffect","useWorkspaceQuery","options","client","selectRef","fallbackRef","data","setData","useState","loading","setLoading","error","setError","refetch","useCallback","enabled","result","document","operationError","errorMessage","queryError","variables","useEffect","NO_ROWS","useWorkspacePaginatedQuery","extractRowsRef","extractNextOffsetRef","rows","setRows","rowsRef","loadingMore","setLoadingMore","nextOffset","setNextOffset","nextOffsetRef","fetchInFlightRef","generationRef","replaceRows","next","fetchPage","append","generation","isCurrent","pageSize","payload","pageRows","extractNextOffset","continuation","offset","loadMore","useWorkspaceAllPagesQuery","hasMore","useWorkspaceMutation","variablesRef","state","setState","input","selected","mutationError","failure"],"sources":["../../../../src/botlit/hooks/internal/workspaceGateway.ts"],"sourcesContent":["/**\n * Workspace gateway hook primitives\n * @module botlit/hooks/internal\n *\n * Every BotManor hook talks to the workspace public gateway through the Apollo\n * client the shell installs (`useGatewayClient('workspace')`) — never through a\n * client of its own. These primitives capture the exact shape used by the\n * reference hooks (`useAgents`, `useBots`): `network-only` reads, an explicit\n * `Error` in state rather than a thrown promise, and a `refetch` the caller can\n * run after a mutation.\n */\n\nimport type { ApolloClient, DocumentNode } from '@apollo/client';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../../providers/BotlitProvider';\nimport { extractGraphqlFailureMessage } from '../../utils/errors';\n\nexport type WorkspaceClient = ApolloClient;\n\n/** Apollo client for the workspace gateway, provided by the host shell. */\nexport function useWorkspaceClient(): WorkspaceClient {\n return useGatewayClient('workspace');\n}\n\n/** Current workspace id from the BotManor context (undefined until the shell resolves it). */\nexport function useWorkspaceId(): string | undefined {\n return useBotlit().workspaceId;\n}\n\nexport interface QueryResult<T> {\n data: T;\n loading: boolean;\n /** Set only when the request FAILED. An empty `data` with no `error` means \"no records yet\". */\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\nexport interface PaginatedQueryResult<T> extends QueryResult<T> {\n /** True while the next page is being appended. */\n loadingMore: boolean;\n /** True when the latest page has a continuation. */\n hasMore: boolean;\n /**\n * Fetches the next page at its continuation offset and appends it.\n * No-op while a fetch is in flight or when `hasMore` is false.\n */\n loadMore: () => Promise<void>;\n}\n\nexport interface MutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\n/**\n * Normalises any mutation failure to an Error with the server's\n * user-actionable message where one exists.\n *\n * Apollo Client v4 does not reject with a plain Error: failures arrive as\n * `{ networkError }` / `{ graphQLErrors }` objects, and the batched fetch\n * layer attaches the structured GraphQL errors as `.errors` on the\n * networkError. `extractGraphqlFailureMessage` unwraps all of those; only\n * when nothing user-actionable is present do we fall back to the hook's\n * generic `errorMessage`.\n */\nfunction toError(cause: unknown, fallbackMessage: string): Error {\n const message = extractGraphqlFailureMessage(cause);\n if (message) {\n // Preserve the original rejection on the chain so error monitoring can\n // still reach the structured GraphQL errors (extensions.code, requestId…).\n return new Error(message, { cause });\n }\n if (cause instanceof Error) return cause;\n return new Error(fallbackMessage, { cause });\n}\n\n/** Keeps a mutable ref pointing at the latest value without re-running effects. */\nfunction useLatest<T>(value: T): { readonly current: T } {\n const ref = useRef(value);\n useLayoutEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\nexport interface WorkspaceQueryOptions<TData, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Must be referentially stable — memoize at the call site. */\n variables: Record<string, unknown> | undefined;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id / no entity id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Reads from the workspace gateway and keeps `{ data, loading, error, refetch }`\n * in sync. `error` is reserved for real failures so callers can tell an empty\n * collection apart from a failed request.\n */\nexport function useWorkspaceQuery<TData, TResult>(\n options: WorkspaceQueryOptions<TData, TResult>\n): QueryResult<TResult> {\n const { document, variables, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const fallbackRef = useLatest(options.fallback);\n\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n setData(fallbackRef.current);\n setError(undefined);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables,\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL\n // errors — same handling as useWorkspaceMutation.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n setData(selectRef.current(result.data ?? undefined));\n } catch (queryError) {\n setData(fallbackRef.current);\n setError(toError(queryError, errorMessage));\n } finally {\n setLoading(false);\n }\n // fallbackRef/selectRef are stable refs by construction\n }, [client, document, variables, enabled, errorMessage, fallbackRef, selectRef]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\n/** Shared empty page, so a disabled paginated query keeps one stable value. */\nconst NO_ROWS: never[] = [];\n\nexport interface WorkspacePaginatedQueryOptions<TData, TRow, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /**\n * Base variables (filters, ids, …) WITHOUT `pagination` — the hook adds\n * `{ limit: pageSize, offset }` per fetch. Must be referentially stable;\n * a new identity resets the accumulation back to page one.\n */\n variables: Record<string, unknown> | undefined;\n /** Page size for each fetch. */\n pageSize: number;\n /** Extracts the raw row list from a page payload; missing data yields []. */\n extractRows: (data: TData | undefined) => TRow[] | undefined;\n /** Server continuation for envelope APIs. Null marks the final page. */\n extractNextOffset?: (data: TData | undefined) => number | null;\n /** Projects the ACCUMULATED raw rows onto the record shape the UI consumes. */\n select: (rows: TRow[]) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Offset-paginated variant of `useWorkspaceQuery` for unbounded lists.\n *\n * `refetch()` restarts at offset 0 and REPLACES the accumulated rows;\n * `loadMore()` fetches the next page and appends it. Envelope APIs set the\n * continuation explicitly. On legacy array APIs a short page ends the list.\n * `select` runs over the accumulated raw rows, so client-side narrowing\n * (e.g. executions search) sees every loaded page, not just the last one.\n */\nexport function useWorkspacePaginatedQuery<TData, TRow, TResult>(\n options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>\n): PaginatedQueryResult<TResult> {\n const { document, variables, pageSize, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const extractRowsRef = useLatest(options.extractRows);\n const extractNextOffsetRef = useLatest(options.extractNextOffset);\n\n const [rows, setRows] = useState<TRow[]>([]);\n const rowsRef = useRef<TRow[]>([]);\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [loadingMore, setLoadingMore] = useState(false);\n const [nextOffset, setNextOffset] = useState<number | null>(null);\n const nextOffsetRef = useRef<number | null>(null);\n const fetchInFlightRef = useRef(false);\n const [error, setError] = useState<Error | undefined>();\n // Bumped by every page-one read: a page from a superseded read (e.g. a\n // workspace switch mid-paging) must not touch the newer read's state.\n const generationRef = useRef(0);\n\n const replaceRows = useCallback(\n (next: TRow[]) => {\n rowsRef.current = next;\n setRows(next);\n setData(selectRef.current(next));\n },\n [selectRef]\n );\n\n const fetchPage = useCallback(\n async (offset: number, append: boolean) => {\n if (append && fetchInFlightRef.current) return;\n fetchInFlightRef.current = true;\n const generation = append ? generationRef.current : ++generationRef.current;\n const isCurrent = () => generation === generationRef.current;\n if (append) {\n setLoadingMore(true);\n } else {\n setLoading(true);\n // A new page-one read supersedes any in-flight append; that append\n // no longer owns `loadingMore` and will not clear it.\n setLoadingMore(false);\n }\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables: { ...variables, pagination: { limit: pageSize, offset } },\n fetchPolicy: 'network-only',\n });\n if (!isCurrent()) return;\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n const payload = result.data ?? undefined;\n const pageRows = extractRowsRef.current(payload) ?? [];\n const extractNextOffset = extractNextOffsetRef.current;\n const continuation = extractNextOffset\n ? extractNextOffset(payload)\n : pageRows.length < pageSize\n ? null\n : offset + pageRows.length;\n if (\n continuation !== null &&\n (!Number.isSafeInteger(continuation) || continuation <= offset)\n ) {\n throw new Error(errorMessage);\n }\n replaceRows(append ? [...rowsRef.current, ...pageRows] : pageRows);\n nextOffsetRef.current = continuation;\n setNextOffset(continuation);\n } catch (queryError) {\n if (isCurrent()) setError(toError(queryError, errorMessage));\n } finally {\n // Only the current read owns the flags: a superseded append must not\n // clear a newer read's `loadingMore` (that would start a duplicate\n // append at the same offset).\n if (isCurrent()) {\n fetchInFlightRef.current = false;\n if (append) setLoadingMore(false);\n else setLoading(false);\n }\n }\n },\n [\n client,\n document,\n variables,\n pageSize,\n errorMessage,\n extractRowsRef,\n extractNextOffsetRef,\n replaceRows,\n ]\n );\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n ++generationRef.current;\n fetchInFlightRef.current = false;\n // The same empty list every time: a disabled query must not change state, or a\n // caller whose client identity changes per render would refetch forever.\n replaceRows(NO_ROWS);\n setLoading(false);\n setLoadingMore(false);\n nextOffsetRef.current = null;\n setNextOffset(null);\n setError(undefined);\n return;\n }\n await fetchPage(0, false);\n }, [enabled, fetchPage, replaceRows]);\n\n const loadMore = useCallback(async () => {\n if (!enabled || loading || nextOffset === null) return;\n // A page can resolve before React publishes the new continuation.\n if (nextOffset !== nextOffsetRef.current) return;\n await fetchPage(nextOffset, true);\n }, [enabled, loading, nextOffset, fetchPage]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, loadingMore, hasMore: nextOffset !== null, error, refetch, loadMore };\n}\n\n/**\n * Every page of an offset-paginated list (BOFF-15360), for callers that must\n * see the whole list at once (pickers, \"already configured\" checks).\n * `loading` holds until the last page has arrived; a failed page stops paging\n * and sets `error`. `refetch` restarts from page one.\n */\nexport function useWorkspaceAllPagesQuery<TData, TRow, TResult>(\n options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>\n): QueryResult<TResult> {\n const { data, loading, loadingMore, hasMore, error, refetch, loadMore } =\n useWorkspacePaginatedQuery(options);\n\n useEffect(() => {\n if (hasMore && !loading && !loadingMore && !error) void loadMore();\n }, [hasMore, loading, loadingMore, error, loadMore]);\n\n return { data, loading: loading || loadingMore || (hasMore && !error), error, refetch };\n}\n\nexport interface WorkspaceMutationOptions<TData, TInput, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Maps the caller's input onto GraphQL variables. */\n variables: (input: TInput) => Record<string, unknown>;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult | undefined;\n /** Thrown (and stored) when the payload is missing or the request fails. */\n errorMessage: string;\n}\n\n/**\n * Writes to the workspace gateway. Returns the `[mutate, state]` tuple used by\n * the reference hooks. `mutate` REJECTS on failure so callers cannot mistake a\n * failed write for a successful one.\n */\nexport function useWorkspaceMutation<TData, TInput, TResult>(\n options: WorkspaceMutationOptions<TData, TInput, TResult>\n): readonly [(input: TInput) => Promise<TResult>, MutationState<TResult>] {\n const { document, errorMessage } = options;\n const client = useWorkspaceClient();\n const variablesRef = useLatest(options.variables);\n const selectRef = useLatest(options.select);\n\n const [state, setState] = useState<MutationState<TResult>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const mutate = useCallback(\n async (input: TInput): Promise<TResult> => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<TData>({\n mutation: document,\n variables: variablesRef.current(input),\n });\n // Apollo v4 does not reject on GraphQL errors by default: the mutation\n // RESOLVES with `data` undefined and the failure on `result.error`\n // (CombinedGraphQLErrors / networkError). Surface it like a rejection\n // so callers see the server's field-level message, not the fallback.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n const selected = selectRef.current(result.data ?? undefined);\n if (selected === undefined) {\n throw new Error(errorMessage);\n }\n setState({ data: selected, loading: false, error: undefined });\n return selected;\n } catch (mutationError) {\n const failure = toError(mutationError, errorMessage);\n setState({ data: undefined, loading: false, error: failure });\n throw failure;\n }\n },\n [client, document, errorMessage, selectRef, variablesRef]\n );\n\n return [mutate, state] as const;\n}\n"],"mappings":";;;;;AAsBA,SAAgBA,IAAsC;CACpD,OAAOC,EAAiB,WAAW;AACrC;AAGA,SAAgBC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,QAAQ,KAAA,CAAS;GAC3D,IAAIyC,MAAa,KAAA,GACf,MAAU,MAAMtC,CAAY;GAG9B,OADAoC,EAAS;IAAE,MAAME;IAAU,SAAS;IAAO,OAAO,KAAA;GAAU,CAAC,GACtDA;EACT,SAASC,GAAe;GACtB,IAAMC,IAAUpE,EAAQmE,GAAevC,CAAY;GAEnD,MADAoC,EAAS;IAAE,MAAM,KAAA;IAAW,SAAS;IAAO,OAAOI;GAAQ,CAAC,GACtDA;EACR;CACF,GACA;EAACxD;EAAQc;EAAUE;EAAcf;EAAWiD;CAAY,CAGlD,GAAQC,CAAK;AACvB"}
|
|
1
|
+
{"version":3,"file":"workspaceGateway.js","names":["useWorkspaceClient","useGatewayClient","useWorkspaceId","useBotlit","toError","message","extractGraphqlFailureMessage","cause","fallbackMessage","useLatest","ref","useRef","value","useLayoutEffect","useWorkspaceQuery","options","client","selectRef","fallbackRef","data","setData","useState","loading","setLoading","error","setError","refetch","useCallback","enabled","result","document","operationError","errorMessage","queryError","variables","useEffect","NO_ROWS","useWorkspacePaginatedQuery","extractRowsRef","extractNextOffsetRef","rows","setRows","rowsRef","loadingMore","setLoadingMore","nextOffset","setNextOffset","nextOffsetRef","fetchInFlightRef","generationRef","replaceRows","next","fetchPage","append","generation","isCurrent","pageSize","payload","pageRows","extractNextOffset","continuation","offset","loadMore","useWorkspaceAllPagesQuery","hasMore","useWorkspaceMutation","variablesRef","state","setState","input","selected","mutationError","failure"],"sources":["../../../../src/botlit/hooks/internal/workspaceGateway.ts"],"sourcesContent":["/**\n * Workspace gateway hook primitives\n * @module botlit/hooks/internal\n *\n * Every BotManor hook talks to the workspace public gateway through the Apollo\n * client the shell installs (`useGatewayClient('workspace')`) — never through a\n * client of its own. These primitives capture the exact shape used by the\n * reference hooks (`useAgents`, `useBots`): `network-only` reads, an explicit\n * `Error` in state rather than a thrown promise, and a `refetch` the caller can\n * run after a mutation.\n */\n\nimport type { ApolloClient, DocumentNode } from '@apollo/client';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../../providers/BotlitProvider';\nimport { extractGraphqlFailureMessage } from '../../utils/errors';\n\nexport type WorkspaceClient = ApolloClient;\n\n/** Apollo client for the workspace gateway, provided by the host shell. */\nexport function useWorkspaceClient(): WorkspaceClient {\n return useGatewayClient('workspace');\n}\n\n/** Current workspace id from the BotManor context (undefined until the shell resolves it). */\nexport function useWorkspaceId(): string | undefined {\n return useBotlit().workspaceId;\n}\n\nexport interface QueryResult<T> {\n data: T;\n loading: boolean;\n /** Set only when the request FAILED. An empty `data` with no `error` means \"no records yet\". */\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\nexport interface PaginatedQueryResult<T> extends QueryResult<T> {\n /** True while the next page is being appended. */\n loadingMore: boolean;\n /** True when the latest page has a continuation. */\n hasMore: boolean;\n /**\n * Fetches the next page at its continuation offset and appends it.\n * No-op while a fetch is in flight or when `hasMore` is false.\n */\n loadMore: () => Promise<void>;\n}\n\nexport interface MutationState<T> {\n data: T | undefined;\n loading: boolean;\n error: Error | undefined;\n}\n\n/**\n * Normalises any mutation failure to an Error with the server's\n * user-actionable message where one exists.\n *\n * Apollo Client v4 does not reject with a plain Error: failures arrive as\n * `{ networkError }` / `{ graphQLErrors }` objects, and the batched fetch\n * layer attaches the structured GraphQL errors as `.errors` on the\n * networkError. `extractGraphqlFailureMessage` unwraps all of those; only\n * when nothing user-actionable is present do we fall back to the hook's\n * generic `errorMessage`.\n */\nexport function toError(cause: unknown, fallbackMessage: string): Error {\n const message = extractGraphqlFailureMessage(cause);\n if (message) {\n // Preserve the original rejection on the chain so error monitoring can\n // still reach the structured GraphQL errors (extensions.code, requestId…).\n return new Error(message, { cause });\n }\n if (cause instanceof Error) return cause;\n return new Error(fallbackMessage, { cause });\n}\n\n/** Keeps a mutable ref pointing at the latest value without re-running effects. */\nfunction useLatest<T>(value: T): { readonly current: T } {\n const ref = useRef(value);\n useLayoutEffect(() => {\n ref.current = value;\n }, [value]);\n return ref;\n}\n\nexport interface WorkspaceQueryOptions<TData, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Must be referentially stable — memoize at the call site. */\n variables: Record<string, unknown> | undefined;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id / no entity id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Reads from the workspace gateway and keeps `{ data, loading, error, refetch }`\n * in sync. `error` is reserved for real failures so callers can tell an empty\n * collection apart from a failed request.\n */\nexport function useWorkspaceQuery<TData, TResult>(\n options: WorkspaceQueryOptions<TData, TResult>\n): QueryResult<TResult> {\n const { document, variables, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const fallbackRef = useLatest(options.fallback);\n\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>();\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n setData(fallbackRef.current);\n setError(undefined);\n return;\n }\n\n setLoading(true);\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables,\n fetchPolicy: 'network-only',\n });\n // Apollo v4 resolves (not rejects) with `result.error` set on GraphQL\n // errors — same handling as useWorkspaceMutation.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n setData(selectRef.current(result.data ?? undefined));\n } catch (queryError) {\n setData(fallbackRef.current);\n setError(toError(queryError, errorMessage));\n } finally {\n setLoading(false);\n }\n // fallbackRef/selectRef are stable refs by construction\n }, [client, document, variables, enabled, errorMessage, fallbackRef, selectRef]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\n/** Shared empty page, so a disabled paginated query keeps one stable value. */\nconst NO_ROWS: never[] = [];\n\nexport interface WorkspacePaginatedQueryOptions<TData, TRow, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /**\n * Base variables (filters, ids, …) WITHOUT `pagination` — the hook adds\n * `{ limit: pageSize, offset }` per fetch. Must be referentially stable;\n * a new identity resets the accumulation back to page one.\n */\n variables: Record<string, unknown> | undefined;\n /** Page size for each fetch. */\n pageSize: number;\n /** Extracts the raw row list from a page payload; missing data yields []. */\n extractRows: (data: TData | undefined) => TRow[] | undefined;\n /** Server continuation for envelope APIs. Null marks the final page. */\n extractNextOffset?: (data: TData | undefined) => number | null;\n /** Projects the ACCUMULATED raw rows onto the record shape the UI consumes. */\n select: (rows: TRow[]) => TResult;\n /** Value held while disabled or before the first successful read. */\n fallback: TResult;\n /** When false the request is skipped (e.g. no workspace id yet). */\n enabled: boolean;\n /** Used when the thrown value is not an Error. */\n errorMessage: string;\n}\n\n/**\n * Offset-paginated variant of `useWorkspaceQuery` for unbounded lists.\n *\n * `refetch()` restarts at offset 0 and REPLACES the accumulated rows;\n * `loadMore()` fetches the next page and appends it. Envelope APIs set the\n * continuation explicitly. On legacy array APIs a short page ends the list.\n * `select` runs over the accumulated raw rows, so client-side narrowing\n * (e.g. executions search) sees every loaded page, not just the last one.\n */\nexport function useWorkspacePaginatedQuery<TData, TRow, TResult>(\n options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>\n): PaginatedQueryResult<TResult> {\n const { document, variables, pageSize, enabled, errorMessage } = options;\n const client = useWorkspaceClient();\n const selectRef = useLatest(options.select);\n const extractRowsRef = useLatest(options.extractRows);\n const extractNextOffsetRef = useLatest(options.extractNextOffset);\n\n const [rows, setRows] = useState<TRow[]>([]);\n const rowsRef = useRef<TRow[]>([]);\n const [data, setData] = useState<TResult>(options.fallback);\n const [loading, setLoading] = useState(false);\n const [loadingMore, setLoadingMore] = useState(false);\n const [nextOffset, setNextOffset] = useState<number | null>(null);\n const nextOffsetRef = useRef<number | null>(null);\n const fetchInFlightRef = useRef(false);\n const [error, setError] = useState<Error | undefined>();\n // Bumped by every page-one read: a page from a superseded read (e.g. a\n // workspace switch mid-paging) must not touch the newer read's state.\n const generationRef = useRef(0);\n\n const replaceRows = useCallback(\n (next: TRow[]) => {\n rowsRef.current = next;\n setRows(next);\n setData(selectRef.current(next));\n },\n [selectRef]\n );\n\n const fetchPage = useCallback(\n async (offset: number, append: boolean) => {\n if (append && fetchInFlightRef.current) return;\n fetchInFlightRef.current = true;\n const generation = append ? generationRef.current : ++generationRef.current;\n const isCurrent = () => generation === generationRef.current;\n if (append) {\n setLoadingMore(true);\n } else {\n setLoading(true);\n // A new page-one read supersedes any in-flight append; that append\n // no longer owns `loadingMore` and will not clear it.\n setLoadingMore(false);\n }\n setError(undefined);\n try {\n const result = await client.query<TData>({\n query: document,\n variables: { ...variables, pagination: { limit: pageSize, offset } },\n fetchPolicy: 'network-only',\n });\n if (!isCurrent()) return;\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n const payload = result.data ?? undefined;\n const pageRows = extractRowsRef.current(payload) ?? [];\n const extractNextOffset = extractNextOffsetRef.current;\n const continuation = extractNextOffset\n ? extractNextOffset(payload)\n : pageRows.length < pageSize\n ? null\n : offset + pageRows.length;\n if (\n continuation !== null &&\n (!Number.isSafeInteger(continuation) || continuation <= offset)\n ) {\n throw new Error(errorMessage);\n }\n replaceRows(append ? [...rowsRef.current, ...pageRows] : pageRows);\n nextOffsetRef.current = continuation;\n setNextOffset(continuation);\n } catch (queryError) {\n if (isCurrent()) setError(toError(queryError, errorMessage));\n } finally {\n // Only the current read owns the flags: a superseded append must not\n // clear a newer read's `loadingMore` (that would start a duplicate\n // append at the same offset).\n if (isCurrent()) {\n fetchInFlightRef.current = false;\n if (append) setLoadingMore(false);\n else setLoading(false);\n }\n }\n },\n [\n client,\n document,\n variables,\n pageSize,\n errorMessage,\n extractRowsRef,\n extractNextOffsetRef,\n replaceRows,\n ]\n );\n\n const refetch = useCallback(async () => {\n if (!enabled) {\n ++generationRef.current;\n fetchInFlightRef.current = false;\n // The same empty list every time: a disabled query must not change state, or a\n // caller whose client identity changes per render would refetch forever.\n replaceRows(NO_ROWS);\n setLoading(false);\n setLoadingMore(false);\n nextOffsetRef.current = null;\n setNextOffset(null);\n setError(undefined);\n return;\n }\n await fetchPage(0, false);\n }, [enabled, fetchPage, replaceRows]);\n\n const loadMore = useCallback(async () => {\n if (!enabled || loading || nextOffset === null) return;\n // A page can resolve before React publishes the new continuation.\n if (nextOffset !== nextOffsetRef.current) return;\n await fetchPage(nextOffset, true);\n }, [enabled, loading, nextOffset, fetchPage]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, loadingMore, hasMore: nextOffset !== null, error, refetch, loadMore };\n}\n\n/**\n * Every page of an offset-paginated list (BOFF-15360), for callers that must\n * see the whole list at once (pickers, \"already configured\" checks).\n * `loading` holds until the last page has arrived; a failed page stops paging\n * and sets `error`. `refetch` restarts from page one.\n */\nexport function useWorkspaceAllPagesQuery<TData, TRow, TResult>(\n options: WorkspacePaginatedQueryOptions<TData, TRow, TResult>\n): QueryResult<TResult> {\n const { data, loading, loadingMore, hasMore, error, refetch, loadMore } =\n useWorkspacePaginatedQuery(options);\n\n useEffect(() => {\n if (hasMore && !loading && !loadingMore && !error) void loadMore();\n }, [hasMore, loading, loadingMore, error, loadMore]);\n\n return { data, loading: loading || loadingMore || (hasMore && !error), error, refetch };\n}\n\nexport interface WorkspaceMutationOptions<TData, TInput, TResult> {\n /** Generated GraphQL document (see `src/generated/wspace-operations.ts`). */\n document: DocumentNode;\n /** Maps the caller's input onto GraphQL variables. */\n variables: (input: TInput) => Record<string, unknown>;\n /** Projects the raw payload onto the record shape the UI consumes. */\n select: (data: TData | undefined) => TResult | undefined;\n /** Thrown (and stored) when the payload is missing or the request fails. */\n errorMessage: string;\n}\n\n/**\n * Writes to the workspace gateway. Returns the `[mutate, state]` tuple used by\n * the reference hooks. `mutate` REJECTS on failure so callers cannot mistake a\n * failed write for a successful one.\n */\nexport function useWorkspaceMutation<TData, TInput, TResult>(\n options: WorkspaceMutationOptions<TData, TInput, TResult>\n): readonly [(input: TInput) => Promise<TResult>, MutationState<TResult>] {\n const { document, errorMessage } = options;\n const client = useWorkspaceClient();\n const variablesRef = useLatest(options.variables);\n const selectRef = useLatest(options.select);\n\n const [state, setState] = useState<MutationState<TResult>>({\n data: undefined,\n loading: false,\n error: undefined,\n });\n\n const mutate = useCallback(\n async (input: TInput): Promise<TResult> => {\n setState({ data: undefined, loading: true, error: undefined });\n try {\n const result = await client.mutate<TData>({\n mutation: document,\n variables: variablesRef.current(input),\n });\n // Apollo v4 does not reject on GraphQL errors by default: the mutation\n // RESOLVES with `data` undefined and the failure on `result.error`\n // (CombinedGraphQLErrors / networkError). Surface it like a rejection\n // so callers see the server's field-level message, not the fallback.\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) {\n throw toError(operationError, errorMessage);\n }\n const selected = selectRef.current(result.data ?? undefined);\n if (selected === undefined) {\n throw new Error(errorMessage);\n }\n setState({ data: selected, loading: false, error: undefined });\n return selected;\n } catch (mutationError) {\n const failure = toError(mutationError, errorMessage);\n setState({ data: undefined, loading: false, error: failure });\n throw failure;\n }\n },\n [client, document, errorMessage, selectRef, variablesRef]\n );\n\n return [mutate, state] as const;\n}\n"],"mappings":";;;;;AAsBA,SAAgBA,IAAsC;CACpD,OAAOC,EAAiB,WAAW;AACrC;AAGA,SAAgBC,IAAqC;CACnD,OAAOC,EAAU,CAAC,CAAC;AACrB;AAuCA,SAAgBC,EAAQ,GAAgB,GAAgC;CACtE,IAAMC,IAAUC,EAA6BC,CAAK;CAOlD,OANIF,IAGS,MAAMA,GAAS,EAAE,SAAM,CAAC,IAEjCE,aAAiB,QAAcA,IACxB,MAAMC,GAAiB,EAAE,SAAM,CAAC;AAC7C;AAGA,SAASC,EAAa,GAAmC;CACvD,IA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O,OAAOI;GAAQ,CAAC,GACtDA;EACR;CACF,GACA;EAACxD;EAAQc;EAAUE;EAAcf;EAAWiD;CAAY,CAGlD,GAAQC,CAAK;AACvB"}
|
|
@@ -264,7 +264,7 @@ function K(e) {
|
|
|
264
264
|
return e;
|
|
265
265
|
}
|
|
266
266
|
function q(e) {
|
|
267
|
-
return e?.
|
|
267
|
+
return e?.listBotmanorA2ARegistryEntriesPage.items ?? b;
|
|
268
268
|
}
|
|
269
269
|
function J(e) {
|
|
270
270
|
let t = l(), n = e?.search?.trim().toLowerCase() ?? "", r = e?.status?.[0], a = e?.visibility?.[0], o = e?.trustLevel?.[0], s = e?.bucketId, c = m(() => ({ filters: {
|
|
@@ -284,6 +284,7 @@ function J(e) {
|
|
|
284
284
|
variables: c,
|
|
285
285
|
pageSize: 50,
|
|
286
286
|
extractRows: q,
|
|
287
|
+
extractNextOffset: (e) => e?.listBotmanorA2ARegistryEntriesPage.nextOffset ?? null,
|
|
287
288
|
select: K,
|
|
288
289
|
fallback: b,
|
|
289
290
|
enabled: !!t,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useA2A.js","names":["A2A_DESCRIPTION_MAX","A2A_URL_MAX","A2A_AGENT_CARD_MAX_BYTES","REGISTER_AGENT_FIELDS","fieldsOf","UPDATE_AGENT_FIELDS","A2A_ENTITLEMENT_PERMISSIONS","NO_AGENTS","asRecord","value","asString","fallback","asBoolean","asStringArray","entry","asObjectArray","preferredCardEndpoint","source","card","readSchemes","readAgentCard","capabilities","authentication","skill","index","UNENFORCED_SCOPE_KEYS","unenforcedFields","scope","entitlement","fields","key","readEntitlements","entitlements","permission","validFrom","validUntil","toDateInput","parsed","isEntitlementPermission","toEntitlementDrafts","rows","view","unmanagedEntitlements","toEntitlementsInput","drafts","row","draft","original","keep","stored","field","unmanaged","entitlementDraftError","entitlementsAllowConnections","isActive","from","until","now","a2aAgentSkillCount","skills","agent","validateAgentCard","errors","endpoint","isHttpsUrl","interfaceUrls","url","parseAgentCardJson","json","effectiveEntryName","typed","values","cardName","effectiveEntryDescription","cardDescription","validateRegistryForm","issues","cardCheck","name","wellKnownUrl","identityRows","selectAgents","data","useA2AAgents","workspaceId","useWorkspaceId","search","filter","status","visibility","trustLevel","bucketId","variables","useMemo","result","useWorkspacePaginatedQuery","ListA2ARegistryEntriesDocument","useA2AAgent","agentId","useWorkspaceQuery","GetA2ARegistryEntryDocument","useRegisterA2AAgent","useCallback","buildMutationInput","input","useWorkspaceMutation","CreateA2ARegistryEntryDocument","useUpdateA2AAgent","UpdateA2ARegistryEntryDocument","useDeleteA2AAgent","DeleteA2ARegistryEntryDocument","useVerifyA2AAgent","VerifyA2ARegistryEntryDocument","NO_USAGE","useA2AAgentUsage","GetA2ARegistryEntryUsageDocument","enabled"],"sources":["../../../src/botlit/hooks/useA2A.ts"],"sourcesContent":["/**\n * A2A Registry Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listA2ARegistryEntries` / `getA2ARegistryEntry`\n * operations and the create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateA2ARegistryEntryDocument,\n DeleteA2ARegistryEntryDocument,\n GetA2ARegistryEntryDocument,\n GetA2ARegistryEntryUsageDocument,\n ListA2ARegistryEntriesDocument,\n UpdateA2ARegistryEntryDocument,\n VerifyA2ARegistryEntryDocument,\n type CreateA2ARegistryEntryMutation,\n type DeleteA2ARegistryEntryMutation,\n type GetA2ARegistryEntryQuery,\n type GetA2ARegistryEntryUsageQuery,\n type ListA2ARegistryEntriesQuery,\n type UpdateA2ARegistryEntryMutation,\n type VerifyA2ARegistryEntryMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateA2ARegistryEntryInput,\n UpdateA2ARegistryEntryInput,\n} from '../../generated/wspace-types';\nimport type { A2AAgentFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\n/** Page size for the registry list; further pages load on demand (BOFF-12509). */\nexport const A2A_LIST_PAGE_SIZE = 50;\n\n/** Field limits for a registry entry (BOFF-12508). The name column is VARCHAR(255). */\nexport const A2A_NAME_MAX = 255;\nexport const A2A_DESCRIPTION_MAX = 2000;\nexport const A2A_URL_MAX = 2048;\n/** The service refuses an agent card larger than 1 MiB. */\nexport const A2A_AGENT_CARD_MAX_BYTES = 1024 * 1024;\n\nexport interface A2AAgentRecord {\n id: string;\n name: string;\n status: string;\n visibility: string;\n trustLevel: string;\n /** A2A agent card (the `/.well-known/agent.json` document). */\n agentCard: Record<string, unknown>;\n entitlements: Record<string, unknown> | unknown[];\n description?: string | null;\n wellKnownUrl?: string | null;\n bucketId?: string | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n /** BOFF-15360 — the outcome of the last check of the published card. */\n verificationStatus: string;\n /** Why the last check failed (fetch, schema, origin or signature). */\n verificationError?: string | null;\n verifiedAt?: string | null;\n /** The card's JWS signature verified against the publisher's keys. */\n cardSigned: boolean;\n /** The trust level the registrant asked for; verification caps what it gets. */\n requestedTrustLevel: string;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\n/** `CreateA2ARegistryEntryInput` minus the `workspaceId` the hook supplies. */\nexport type RegisterA2AAgentVariables = Omit<\n GraphQLInput<CreateA2ARegistryEntryInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateA2AAgentVariables {\n agentId: string;\n input: GraphQLInput<UpdateA2ARegistryEntryInput>;\n}\n\nconst REGISTER_AGENT_FIELDS = fieldsOf<CreateA2ARegistryEntryInput>({\n agentCard: true,\n bucketId: true,\n description: true,\n entitlements: true,\n metadata: true,\n name: true,\n status: true,\n tags: true,\n trustLevel: true,\n visibility: true,\n wellKnownUrl: true,\n workspaceId: true,\n});\n\nconst UPDATE_AGENT_FIELDS = fieldsOf<UpdateA2ARegistryEntryInput>({\n agentCard: true,\n bucketId: true,\n description: true,\n entitlements: true,\n metadata: true,\n name: true,\n status: true,\n tags: true,\n trustLevel: true,\n visibility: true,\n wellKnownUrl: true,\n});\n\n/** One validation problem, as a translation key plus its English fallback. */\nexport interface A2AValidationIssue {\n key: string;\n fallback: string;\n params?: Record<string, string | number>;\n}\n\nexport interface AgentCardValidation {\n valid: boolean;\n errors: A2AValidationIssue[];\n}\n\n/**\n * The agent-card fields the UI renders. `agentCard` is a free-form `JSON`\n * column on the service, so every field is read defensively — a card that is\n * missing `capabilities`, or that stores `skills` as an object instead of an\n * array, must render as \"not supported\"/\"none\" rather than throw.\n */\nexport interface A2AAgentCardView {\n url: string;\n version: string;\n providerOrganization: string;\n documentationUrl: string;\n capabilities: {\n streaming: boolean;\n pushNotifications: boolean;\n stateTransitionHistory: boolean;\n };\n authenticationSchemes: string[];\n defaultInputModes: string[];\n defaultOutputModes: string[];\n skills: A2AAgentCardSkill[];\n}\n\nexport interface A2AAgentCardSkill {\n id: string;\n name: string;\n description: string;\n tags: string[];\n examples: string[];\n}\n\n/**\n * The permissions the service checks on a registry entry's entitlements\n * (`A2AEntitlementService`): a connection needs `agent:delegate` or\n * `task:create`, and a task sent to the entry needs `task:create`.\n */\nexport const A2A_ENTITLEMENT_PERMISSIONS = ['agent:delegate', 'task:create'] as const;\nexport type A2AEntitlementPermission = (typeof A2A_ENTITLEMENT_PERMISSIONS)[number];\n\n/**\n * One row of the `entitlements` JSON in the shape the service enforces\n * (BOFF-12506): a permission, an optional list of local sender agents it is\n * limited to, and an optional validity window. A row without a permission is\n * ignored by the service, so it is flagged `recognised: false` instead of\n * being shown as if it granted anything.\n */\nexport interface A2AEntitlementView {\n id: string;\n recognised: boolean;\n permission: string;\n /** Local agents that may use this grant; empty means every agent in the workspace. */\n agentIds: string[];\n validFrom?: string;\n validUntil?: string;\n /**\n * Fields the service stores but does not enforce on an A2A call (bucket, app\n * and knowledge-base scope, rate limits). Kept on save, listed read-only.\n */\n unenforced: string[];\n}\n\n/** Editable form of one entitlement. Dates are `YYYY-MM-DD` (empty = open-ended). */\nexport interface A2AEntitlementDraft {\n permission: A2AEntitlementPermission;\n agentIds: string[];\n validFrom: string;\n validUntil: string;\n /** The original JSON row, so fields the editor does not show survive a save. */\n original?: Record<string, unknown>;\n}\n\nconst NO_AGENTS: A2AAgentRecord[] = [];\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n}\n\nfunction asString(value: unknown, fallback = ''): string {\n return typeof value === 'string' ? value : fallback;\n}\n\nfunction asBoolean(value: unknown): boolean {\n return value === true;\n}\n\nfunction asStringArray(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((entry): entry is string => typeof entry === 'string')\n : [];\n}\n\nfunction asObjectArray(value: unknown): Record<string, unknown>[] {\n return Array.isArray(value) ? value.map(asRecord) : [];\n}\n\n/**\n * BOFF-15360 — the endpoint a card names first: `url` (A2A 0.x), else the\n * first of `supportedInterfaces` (A2A 1.0), else 0.3 `additionalInterfaces`.\n */\nexport function preferredCardEndpoint(card: Record<string, unknown> | undefined): string {\n const source = asRecord(card);\n const candidates = [\n source.url,\n ...asObjectArray(source.supportedInterfaces).map((entry) => entry.url),\n ...asObjectArray(source.additionalInterfaces).map((entry) => entry.url),\n ];\n const found = candidates.find(\n (value): value is string => typeof value === 'string' && value.trim() !== ''\n );\n return found ?? '';\n}\n\n/** Scheme names, whether a card lists them as strings or as `{ scheme }` objects. */\nfunction readSchemes(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value\n .map((entry) => (typeof entry === 'string' ? entry : asString(asRecord(entry).scheme)))\n .filter((entry) => entry !== '');\n}\n\n/** Reads the renderable view of an A2A agent card out of its JSON document. */\nexport function readAgentCard(card: Record<string, unknown> | undefined): A2AAgentCardView {\n const source = asRecord(card);\n const capabilities = asRecord(source.capabilities);\n const authentication = asRecord(source.authentication);\n\n return {\n url: preferredCardEndpoint(source),\n version: asString(source.version),\n providerOrganization: asString(asRecord(source.provider).organization),\n documentationUrl: asString(source.documentationUrl),\n capabilities: {\n streaming: asBoolean(capabilities.streaming),\n pushNotifications: asBoolean(capabilities.pushNotifications),\n stateTransitionHistory: asBoolean(capabilities.stateTransitionHistory),\n },\n authenticationSchemes: readSchemes(authentication.schemes),\n defaultInputModes: asStringArray(source.defaultInputModes),\n defaultOutputModes: asStringArray(source.defaultOutputModes),\n skills: asObjectArray(source.skills).map((skill, index) => ({\n id: asString(skill.id, `skill-${index}`),\n name: asString(skill.name),\n description: asString(skill.description),\n tags: asStringArray(skill.tags),\n examples: asStringArray(skill.examples),\n })),\n };\n}\n\nconst UNENFORCED_SCOPE_KEYS = ['bucketIds', 'appIds', 'knowledgeBaseIds'] as const;\n\nfunction unenforcedFields(entitlement: Record<string, unknown>): string[] {\n const scope = asRecord(entitlement.scope);\n const fields: string[] = UNENFORCED_SCOPE_KEYS.filter(\n (key) => asStringArray(scope[key]).length > 0\n ).map((key) => `scope.${key}`);\n if (Object.keys(asRecord(entitlement.rateLimit)).length > 0) fields.push('rateLimit');\n return fields;\n}\n\n/** Reads the entitlement rows out of the `entitlements` JSON column. */\nexport function readEntitlements(\n entitlements: Record<string, unknown> | unknown[] | null | undefined\n): A2AEntitlementView[] {\n return asObjectArray(entitlements).map((entitlement, index) => {\n const permission = asString(entitlement.permission).trim().toLowerCase();\n const validFrom = asString(entitlement.validFrom);\n const validUntil = asString(entitlement.validUntil);\n return {\n id: `entitlement-${index}`,\n recognised: permission.length > 0,\n permission,\n agentIds: asStringArray(asRecord(entitlement.scope).agentIds),\n validFrom: validFrom || undefined,\n validUntil: validUntil || undefined,\n unenforced: unenforcedFields(entitlement),\n };\n });\n}\n\nfunction toDateInput(value: string | undefined): string {\n if (!value) return '';\n const parsed = Date.parse(value);\n return Number.isFinite(parsed) ? new Date(parsed).toISOString().slice(0, 10) : '';\n}\n\nfunction isEntitlementPermission(value: string): value is A2AEntitlementPermission {\n return (A2A_ENTITLEMENT_PERMISSIONS as readonly string[]).includes(value);\n}\n\n/**\n * Editable drafts for the entitlements the service recognises. Rows it ignores\n * (no permission, or a permission it never checks) are not editable here;\n * `toEntitlementsInput` keeps them untouched.\n */\nexport function toEntitlementDrafts(\n entitlements: Record<string, unknown> | unknown[] | null | undefined\n): A2AEntitlementDraft[] {\n const rows = asObjectArray(entitlements);\n return readEntitlements(entitlements).flatMap((view, index) =>\n view.recognised && isEntitlementPermission(view.permission)\n ? [\n {\n permission: view.permission,\n agentIds: view.agentIds,\n validFrom: toDateInput(view.validFrom),\n validUntil: toDateInput(view.validUntil),\n original: rows[index],\n },\n ]\n : []\n );\n}\n\n/**\n * Rows of the stored JSON the editor does not manage, so a save from the\n * editor does not silently drop them.\n */\nexport function unmanagedEntitlements(\n entitlements: Record<string, unknown> | unknown[] | null | undefined\n): Record<string, unknown>[] {\n const rows = asObjectArray(entitlements);\n return readEntitlements(entitlements).flatMap((view, index) =>\n view.recognised && isEntitlementPermission(view.permission) ? [] : [rows[index]]\n );\n}\n\n/**\n * Serialises edited entitlements to the JSON the service enforces. A newly\n * chosen start date begins at 00:00 UTC and an end date runs to the end of\n * that UTC day; an unchanged stored timestamp is kept as it was.\n */\nexport function toEntitlementsInput(\n drafts: A2AEntitlementDraft[],\n unmanaged: Record<string, unknown>[] = []\n): Record<string, unknown>[] {\n const edited = drafts.map((draft) => {\n const row: Record<string, unknown> = { ...(draft.original ?? {}) };\n row.permission = draft.permission;\n const scope = { ...asRecord(row.scope) };\n if (draft.agentIds.length > 0) scope.agentIds = draft.agentIds;\n else delete scope.agentIds;\n if (Object.keys(scope).length > 0) row.scope = scope;\n else delete row.scope;\n // A stored timestamp whose day was not changed is kept exactly: the editor\n // works in days, and rewriting 12:00 as 23:59:59 would quietly extend it.\n const original = draft.original ?? {};\n const keep = (field: 'validFrom' | 'validUntil') => {\n const stored = asString(original[field]);\n return stored && toDateInput(stored) === draft[field] ? stored : undefined;\n };\n if (draft.validFrom) row.validFrom = keep('validFrom') ?? `${draft.validFrom}T00:00:00.000Z`;\n else delete row.validFrom;\n if (draft.validUntil)\n row.validUntil = keep('validUntil') ?? `${draft.validUntil}T23:59:59.999Z`;\n else delete row.validUntil;\n return row;\n });\n return [...edited, ...unmanaged];\n}\n\n/** Per-draft validation: an end date must not come before the start date. */\nexport function entitlementDraftError(draft: A2AEntitlementDraft): 'validityOrder' | undefined {\n if (draft.validFrom && draft.validUntil && draft.validUntil < draft.validFrom) {\n return 'validityOrder';\n }\n return undefined;\n}\n\n/**\n * True when at least one entitlement, valid now, lets a connection be made —\n * the service refuses every connection to an entry without one (default deny).\n */\nexport function entitlementsAllowConnections(\n entitlements: Record<string, unknown> | unknown[] | null | undefined,\n now: number = Date.now()\n): boolean {\n const isActive = (view: A2AEntitlementView) => {\n const from = view.validFrom ? Date.parse(view.validFrom) : NaN;\n const until = view.validUntil ? Date.parse(view.validUntil) : NaN;\n return !(Number.isFinite(from) && now < from) && !(Number.isFinite(until) && now > until);\n };\n return readEntitlements(entitlements).some(\n (view) => view.recognised && isEntitlementPermission(view.permission) && isActive(view)\n );\n}\n\n/** Number of skills the registered agent card advertises. */\nexport function a2aAgentSkillCount(agent: Pick<A2AAgentRecord, 'agentCard'>): number {\n const skills = agent.agentCard?.skills;\n return Array.isArray(skills) ? skills.length : 0;\n}\n\n/**\n * Structural check of an A2A agent card before it is registered. This validates\n * the document the caller supplies — it does NOT contact the remote agent.\n */\nexport function validateAgentCard(card: Record<string, unknown> | undefined): AgentCardValidation {\n const errors: A2AValidationIssue[] = [];\n if (!card) {\n return {\n valid: false,\n errors: [\n {\n key: 'botlit.a2aRegistry.validation.cardRequired',\n fallback: 'An agent card is required',\n },\n ],\n };\n }\n for (const field of ['name', 'description', 'version'] as const) {\n if (typeof card[field] !== 'string' || (card[field] as string).trim() === '') {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardMissingField',\n fallback: 'Agent card is missing \"{{field}}\"',\n params: { field },\n });\n }\n }\n // BOFF-15360 — an A2A 1.0 card may name its endpoint only in\n // supportedInterfaces; a 0.x card names it in \"url\".\n const endpoint = preferredCardEndpoint(card);\n if (endpoint === '') {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardNoEndpoint',\n fallback: 'Agent card is missing \"url\" (or an endpoint in \"supportedInterfaces\")',\n });\n } else if (!isHttpsUrl(endpoint)) {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardUrlHttps',\n fallback: \"The card's endpoint must be an https:// address\",\n });\n }\n // Every advertised endpoint, not only the preferred one, must be https.\n const interfaceUrls = [\n ...asObjectArray(card.supportedInterfaces),\n ...asObjectArray(card.additionalInterfaces),\n ].map((entry) => entry.url);\n if (\n endpoint !== '' &&\n isHttpsUrl(endpoint) &&\n interfaceUrls.some((url) => typeof url !== 'string' || !isHttpsUrl(url))\n ) {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardInterfaceUrl',\n fallback: 'Every interface in the card needs an https:// \"url\"',\n });\n }\n // An A2A 1.0 interface names the protocol binding and version it speaks.\n const incomplete = asObjectArray(card.supportedInterfaces).some(\n (entry) =>\n asString(entry.protocolBinding).trim() === '' || asString(entry.protocolVersion).trim() === ''\n );\n if (incomplete) {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardInterfaceProtocol',\n fallback:\n 'Each entry in \"supportedInterfaces\" needs a \"protocolBinding\" and a \"protocolVersion\"',\n });\n }\n if (!Array.isArray(card.skills) || card.skills.length === 0) {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardNoSkills',\n fallback: 'Agent card must advertise at least one skill',\n });\n }\n return { valid: errors.length === 0, errors };\n}\n\n/** True for an absolute `https://` URL with a host. */\nexport function isHttpsUrl(value: string): boolean {\n try {\n const url = new URL(value.trim());\n return url.protocol === 'https:' && url.hostname.length > 0;\n } catch {\n return false;\n }\n}\n\n/** The registry form as the page edits it. */\nexport interface A2ARegistryFormValues {\n name: string;\n description: string;\n wellKnownUrl: string;\n agentCardJson: string;\n}\n\nexport type A2ARegistryFormField = 'name' | 'description' | 'wellKnownUrl' | 'agentCardJson';\n\n/** Parses the edited agent card; returns undefined when the JSON is malformed. */\nexport function parseAgentCardJson(json: string): Record<string, unknown> | undefined {\n try {\n const parsed: unknown = JSON.parse(json);\n return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The name the entry is saved with: the typed name, or the card's own name\n * when the field is left empty (BOFF-12510), so the list and the card agree\n * unless the user deliberately overrides it.\n */\nexport function effectiveEntryName(values: A2ARegistryFormValues): string {\n const typed = values.name.trim();\n if (typed) return typed;\n const cardName = parseAgentCardJson(values.agentCardJson)?.name;\n return typeof cardName === 'string' ? cardName.trim() : '';\n}\n\n/** The description the entry is saved with (typed, else the card's). */\nexport function effectiveEntryDescription(values: A2ARegistryFormValues): string {\n const typed = values.description.trim();\n if (typed) return typed;\n const cardDescription = parseAgentCardJson(values.agentCardJson)?.description;\n return typeof cardDescription === 'string' ? cardDescription.trim() : '';\n}\n\n/**\n * Field-level validation for the register/edit form (BOFF-12508). Returns at\n * most one issue per field, so each can be shown inline next to its input.\n */\nexport function validateRegistryForm(\n values: A2ARegistryFormValues\n): Partial<Record<A2ARegistryFormField, A2AValidationIssue>> {\n const issues: Partial<Record<A2ARegistryFormField, A2AValidationIssue>> = {};\n\n const card = parseAgentCardJson(values.agentCardJson);\n if (!values.agentCardJson.trim()) {\n issues.agentCardJson = {\n key: 'botlit.a2aRegistry.validation.cardRequired',\n fallback: 'An agent card is required',\n };\n } else if (new TextEncoder().encode(values.agentCardJson).length > A2A_AGENT_CARD_MAX_BYTES) {\n issues.agentCardJson = {\n key: 'botlit.a2aRegistry.validation.cardTooLarge',\n fallback: 'The agent card must be at most 1 MiB',\n };\n } else if (!card) {\n issues.agentCardJson = {\n key: 'botlit.a2aRegistry.validation.cardInvalidJson',\n fallback: 'Agent card must be a valid JSON object',\n };\n } else {\n const cardCheck = validateAgentCard(card);\n if (!cardCheck.valid) issues.agentCardJson = cardCheck.errors[0];\n }\n\n const name = effectiveEntryName(values);\n if (!name) {\n issues.name = {\n key: 'botlit.a2aRegistry.validation.nameRequired',\n fallback: 'Enter a name, or paste a card that has one',\n };\n } else if (name.length > A2A_NAME_MAX) {\n issues.name = {\n key: 'botlit.a2aRegistry.validation.nameTooLong',\n fallback: 'Name must be at most {{max}} characters',\n params: { max: A2A_NAME_MAX },\n };\n }\n\n if (effectiveEntryDescription(values).length > A2A_DESCRIPTION_MAX) {\n issues.description = {\n key: 'botlit.a2aRegistry.validation.descriptionTooLong',\n fallback: 'Description must be at most {{max}} characters',\n params: { max: A2A_DESCRIPTION_MAX },\n };\n }\n\n const wellKnownUrl = values.wellKnownUrl.trim();\n if (wellKnownUrl) {\n if (wellKnownUrl.length > A2A_URL_MAX) {\n issues.wellKnownUrl = {\n key: 'botlit.a2aRegistry.validation.urlTooLong',\n fallback: 'URL must be at most {{max}} characters',\n params: { max: A2A_URL_MAX },\n };\n } else if (!isHttpsUrl(wellKnownUrl)) {\n issues.wellKnownUrl = {\n key: 'botlit.a2aRegistry.validation.wellKnownHttps',\n fallback: 'Enter an https:// URL, e.g. https://agent.example.com/.well-known/agent.json',\n };\n }\n }\n\n return issues;\n}\n\nfunction identityRows(rows: A2AAgentRecord[]): A2AAgentRecord[] {\n return rows;\n}\n\nfunction selectAgents(data: ListA2ARegistryEntriesQuery | undefined): A2AAgentRecord[] {\n return data?.listA2ARegistryEntries ?? NO_AGENTS;\n}\n\nexport const a2aKeys = {\n all: ['a2a'] as const,\n lists: () => [...a2aKeys.all, 'list'] as const,\n list: (filter?: A2AAgentFilter) => [...a2aKeys.lists(), filter] as const,\n details: () => [...a2aKeys.all, 'detail'] as const,\n detail: (id: string) => [...a2aKeys.details(), id] as const,\n};\n\n/**\n * The registry list, one page at a time (BOFF-12509). Status, trust level,\n * visibility and bucket filter on the server. The service has no free-text\n * filter, so `search` narrows the rows loaded so far; the page keeps loading\n * further pages while a search is active, so a match is never hidden behind\n * an unloaded page.\n */\nexport function useA2AAgents(filter?: A2AAgentFilter): PaginatedQueryResult<A2AAgentRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search?.trim().toLowerCase() ?? '';\n const status = filter?.status?.[0];\n const visibility = filter?.visibility?.[0];\n const trustLevel = filter?.trustLevel?.[0];\n const bucketId = filter?.bucketId;\n\n const variables = useMemo(\n () => ({ filters: { workspaceId, status, visibility, trustLevel, bucketId } }),\n [workspaceId, status, visibility, trustLevel, bucketId]\n );\n\n const result = useWorkspacePaginatedQuery<\n ListA2ARegistryEntriesQuery,\n A2AAgentRecord,\n A2AAgentRecord[]\n >({\n document: ListA2ARegistryEntriesDocument,\n variables,\n pageSize: A2A_LIST_PAGE_SIZE,\n extractRows: selectAgents,\n select: identityRows,\n fallback: NO_AGENTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load the A2A registry',\n });\n\n // Narrowed here, not in `select`: the paginated hook applies `select` only\n // when a page arrives, and a new search term must re-filter the loaded rows.\n const rows = result.data;\n const data = useMemo(\n () =>\n search\n ? rows.filter(\n (row) =>\n row.name.toLowerCase().includes(search) ||\n (row.description ?? '').toLowerCase().includes(search)\n )\n : rows,\n [rows, search]\n );\n\n return { ...result, data };\n}\n\nexport function useA2AAgent(agentId: string | undefined): QueryResult<A2AAgentRecord | null> {\n const variables = useMemo(() => ({ id: agentId ?? '' }), [agentId]);\n\n return useWorkspaceQuery<GetA2ARegistryEntryQuery, A2AAgentRecord | null>({\n document: GetA2ARegistryEntryDocument,\n variables,\n select: (data) => data?.getA2ARegistryEntry ?? null,\n fallback: null,\n enabled: Boolean(agentId),\n errorMessage: 'Failed to load A2A agent',\n });\n}\n\nexport function useRegisterA2AAgent() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: RegisterA2AAgentVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, REGISTER_AGENT_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<\n CreateA2ARegistryEntryMutation,\n RegisterA2AAgentVariables,\n A2AAgentRecord\n >({\n document: CreateA2ARegistryEntryDocument,\n variables,\n select: (data) => data?.createA2ARegistryEntry,\n errorMessage: 'Failed to register A2A agent',\n });\n}\n\nexport function useUpdateA2AAgent() {\n return useWorkspaceMutation<\n UpdateA2ARegistryEntryMutation,\n UpdateA2AAgentVariables,\n A2AAgentRecord\n >({\n document: UpdateA2ARegistryEntryDocument,\n variables: ({ agentId, input }) => ({\n id: agentId,\n input: buildMutationInput(input, UPDATE_AGENT_FIELDS),\n }),\n select: (data) => data?.updateA2ARegistryEntry,\n errorMessage: 'Failed to update A2A agent',\n });\n}\n\nexport function useDeleteA2AAgent() {\n return useWorkspaceMutation<DeleteA2ARegistryEntryMutation, string, boolean>({\n document: DeleteA2ARegistryEntryDocument,\n variables: (agentId) => ({ id: agentId }),\n select: (data) => data?.deleteA2ARegistryEntry,\n errorMessage: 'Failed to remove A2A agent',\n });\n}\n\n/**\n * BOFF-15360 — fetch the entry's published card again through the service\n * (SSRF guard, schema, endpoint origin, signature) and re-derive its trust.\n * A failed check is a result, not an error: the entry comes back FAILED with\n * the reason in `verificationError`.\n */\nexport function useVerifyA2AAgent() {\n return useWorkspaceMutation<VerifyA2ARegistryEntryMutation, string, A2AAgentRecord>({\n document: VerifyA2ARegistryEntryDocument,\n variables: (agentId) => ({ id: agentId }),\n select: (data) => data?.verifyA2ARegistryEntry,\n errorMessage: 'Failed to verify the agent card',\n });\n}\n\n/**\n * Validates an agent card locally before registration. There is no server-side\n * validation operation, so this deliberately reports only what can be checked\n * from the document itself.\n */\nexport function useValidateA2AAgent() {\n const validate = useCallback(\n async (card: Record<string, unknown> | undefined): Promise<AgentCardValidation> =>\n validateAgentCard(card),\n []\n );\n\n return [validate, { loading: false, error: undefined }] as const;\n}\n\nexport interface A2AAgentUsage {\n connectionCount: number;\n connections: {\n id: string;\n name: string;\n senderAgentId: string;\n senderAgentName?: string | null;\n isActive: boolean;\n }[];\n}\n\nconst NO_USAGE: A2AAgentUsage = { connectionCount: 0, connections: [] };\n\n/**\n * BOFF-12511 — the A2A connections that target a registry entry, for the\n * delete confirmation. Deleting the entry removes them.\n */\nexport function useA2AAgentUsage(\n agentId: string | undefined,\n enabled: boolean\n): QueryResult<A2AAgentUsage> {\n const variables = useMemo(() => ({ id: agentId ?? '' }), [agentId]);\n return useWorkspaceQuery<GetA2ARegistryEntryUsageQuery, A2AAgentUsage>({\n document: GetA2ARegistryEntryUsageDocument,\n variables,\n select: (data) => data?.getA2ARegistryEntryUsage ?? NO_USAGE,\n fallback: NO_USAGE,\n enabled: Boolean(agentId) && enabled,\n errorMessage: 'Failed to load what uses this A2A agent',\n });\n}\n"],"mappings":";;;;AA6CA,IAAaA,IAAsB,KACtBC,IAAc,MAEdC,KAA2B,SA4ClCC,IAAwBC,EAAsC;CAClE,WAAW;CACX,UAAU;CACV,aAAa;CACb,cAAc;CACd,UAAU;CACV,MAAM;CACN,QAAQ;CACR,MAAM;CACN,YAAY;CACZ,YAAY;CACZ,cAAc;CACd,aAAa;AACf,CAAC,GAEKC,IAAsBD,EAAsC;CAChE,WAAW;CACX,UAAU;CACV,aAAa;CACb,cAAc;CACd,UAAU;CACV,MAAM;CACN,QAAQ;CACR,MAAM;CACN,YAAY;CACZ,YAAY;CACZ,cAAc;AAChB,CAAC,GAiDYE,IAA8B,CAAC,kBAAkB,aAAa,GAmCrEC,IAA8B,CAAC;AAErC,SAASC,EAAS,GAAyC;CACzD,OAAO,OAAOC,KAAU,YAAYA,KAAkB,CAAC,MAAM,QAAQA,CAAK,IACrEA,IACD,CAAC;AACP;AAEA,SAASC,EAAS,GAAgB,IAAW,IAAY;CACvD,OAAO,OAAOD,KAAU,WAAWA,IAAQE;AAC7C;AAEA,SAASC,EAAU,GAAyB;CAC1C,OAAOH,MAAU;AACnB;AAEA,SAASI,EAAc,GAA0B;CAC/C,OAAO,MAAM,QAAQJ,CAAK,IAC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MISSIONS","NO_AGENTS","asRecord","value","asString","fallback","asBoolean","asStringArray","entry","asObjectArray","preferredCardEndpoint","source","card","readSchemes","readAgentCard","capabilities","authentication","skill","index","UNENFORCED_SCOPE_KEYS","unenforcedFields","scope","entitlement","fields","key","readEntitlements","entitlements","permission","validFrom","validUntil","toDateInput","parsed","isEntitlementPermission","toEntitlementDrafts","rows","view","unmanagedEntitlements","toEntitlementsInput","drafts","row","draft","original","keep","stored","field","unmanaged","entitlementDraftError","entitlementsAllowConnections","isActive","from","until","now","a2aAgentSkillCount","skills","agent","validateAgentCard","errors","endpoint","isHttpsUrl","interfaceUrls","url","parseAgentCardJson","json","effectiveEntryName","typed","values","cardName","effectiveEntryDescription","cardDescription","validateRegistryForm","issues","cardCheck","name","wellKnownUrl","identityRows","selectAgents","data","useA2AAgents","workspaceId","useWorkspaceId","search","filter","status","visibility","trustLevel","bucketId","variables","useMemo","result","useWorkspacePaginatedQuery","ListA2ARegistryEntriesDocument","useA2AAgent","agentId","useWorkspaceQuery","GetA2ARegistryEntryDocument","useRegisterA2AAgent","useCallback","buildMutationInput","input","useWorkspaceMutation","CreateA2ARegistryEntryDocument","useUpdateA2AAgent","UpdateA2ARegistryEntryDocument","useDeleteA2AAgent","DeleteA2ARegistryEntryDocument","useVerifyA2AAgent","VerifyA2ARegistryEntryDocument","NO_USAGE","useA2AAgentUsage","GetA2ARegistryEntryUsageDocument","enabled"],"sources":["../../../src/botlit/hooks/useA2A.ts"],"sourcesContent":["/**\n * A2A Registry Hooks\n * @module botlit/hooks\n *\n * Backed by the live `listBotmanorA2ARegistryEntriesPage` / `getA2ARegistryEntry`\n * operations and the create/update/delete mutations on wspace-botlit-svc.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateA2ARegistryEntryDocument,\n DeleteA2ARegistryEntryDocument,\n GetA2ARegistryEntryDocument,\n GetA2ARegistryEntryUsageDocument,\n ListA2ARegistryEntriesDocument,\n UpdateA2ARegistryEntryDocument,\n VerifyA2ARegistryEntryDocument,\n type CreateA2ARegistryEntryMutation,\n type DeleteA2ARegistryEntryMutation,\n type GetA2ARegistryEntryQuery,\n type GetA2ARegistryEntryUsageQuery,\n type ListA2ARegistryEntriesQuery,\n type UpdateA2ARegistryEntryMutation,\n type VerifyA2ARegistryEntryMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateA2ARegistryEntryInput,\n UpdateA2ARegistryEntryInput,\n} from '../../generated/wspace-types';\nimport type { A2AAgentFilter } from '../types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspacePaginatedQuery,\n useWorkspaceQuery,\n type PaginatedQueryResult,\n type QueryResult,\n} from './internal/workspaceGateway';\n\n/** Page size for the registry list; further pages load on demand (BOFF-12509). */\nexport const A2A_LIST_PAGE_SIZE = 50;\n\n/** Field limits for a registry entry (BOFF-12508). The name column is VARCHAR(255). */\nexport const A2A_NAME_MAX = 255;\nexport const A2A_DESCRIPTION_MAX = 2000;\nexport const A2A_URL_MAX = 2048;\n/** The service refuses an agent card larger than 1 MiB. */\nexport const A2A_AGENT_CARD_MAX_BYTES = 1024 * 1024;\n\nexport interface A2AAgentRecord {\n id: string;\n name: string;\n status: string;\n visibility: string;\n trustLevel: string;\n /** A2A agent card (the `/.well-known/agent.json` document). */\n agentCard: Record<string, unknown>;\n entitlements: Record<string, unknown> | unknown[];\n description?: string | null;\n wellKnownUrl?: string | null;\n bucketId?: string | null;\n metadata?: Record<string, unknown> | null;\n revision: number;\n tags: string[];\n /** BOFF-15360 — the outcome of the last check of the published card. */\n verificationStatus: string;\n /** Why the last check failed (fetch, schema, origin or signature). */\n verificationError?: string | null;\n verifiedAt?: string | null;\n /** The card's JWS signature verified against the publisher's keys. */\n cardSigned: boolean;\n /** The trust level the registrant asked for; verification caps what it gets. */\n requestedTrustLevel: string;\n createdAt: string;\n updatedAt: string;\n createdById: string;\n updatedById: string;\n workspaceId: string;\n}\n\n/** `CreateA2ARegistryEntryInput` minus the `workspaceId` the hook supplies. */\nexport type RegisterA2AAgentVariables = Omit<\n GraphQLInput<CreateA2ARegistryEntryInput>,\n 'workspaceId'\n>;\n\nexport interface UpdateA2AAgentVariables {\n agentId: string;\n input: GraphQLInput<UpdateA2ARegistryEntryInput>;\n}\n\nconst REGISTER_AGENT_FIELDS = fieldsOf<CreateA2ARegistryEntryInput>({\n agentCard: true,\n bucketId: true,\n description: true,\n entitlements: true,\n metadata: true,\n name: true,\n status: true,\n tags: true,\n trustLevel: true,\n visibility: true,\n wellKnownUrl: true,\n workspaceId: true,\n});\n\nconst UPDATE_AGENT_FIELDS = fieldsOf<UpdateA2ARegistryEntryInput>({\n agentCard: true,\n bucketId: true,\n description: true,\n entitlements: true,\n metadata: true,\n name: true,\n status: true,\n tags: true,\n trustLevel: true,\n visibility: true,\n wellKnownUrl: true,\n});\n\n/** One validation problem, as a translation key plus its English fallback. */\nexport interface A2AValidationIssue {\n key: string;\n fallback: string;\n params?: Record<string, string | number>;\n}\n\nexport interface AgentCardValidation {\n valid: boolean;\n errors: A2AValidationIssue[];\n}\n\n/**\n * The agent-card fields the UI renders. `agentCard` is a free-form `JSON`\n * column on the service, so every field is read defensively — a card that is\n * missing `capabilities`, or that stores `skills` as an object instead of an\n * array, must render as \"not supported\"/\"none\" rather than throw.\n */\nexport interface A2AAgentCardView {\n url: string;\n version: string;\n providerOrganization: string;\n documentationUrl: string;\n capabilities: {\n streaming: boolean;\n pushNotifications: boolean;\n stateTransitionHistory: boolean;\n };\n authenticationSchemes: string[];\n defaultInputModes: string[];\n defaultOutputModes: string[];\n skills: A2AAgentCardSkill[];\n}\n\nexport interface A2AAgentCardSkill {\n id: string;\n name: string;\n description: string;\n tags: string[];\n examples: string[];\n}\n\n/**\n * The permissions the service checks on a registry entry's entitlements\n * (`A2AEntitlementService`): a connection needs `agent:delegate` or\n * `task:create`, and a task sent to the entry needs `task:create`.\n */\nexport const A2A_ENTITLEMENT_PERMISSIONS = ['agent:delegate', 'task:create'] as const;\nexport type A2AEntitlementPermission = (typeof A2A_ENTITLEMENT_PERMISSIONS)[number];\n\n/**\n * One row of the `entitlements` JSON in the shape the service enforces\n * (BOFF-12506): a permission, an optional list of local sender agents it is\n * limited to, and an optional validity window. A row without a permission is\n * ignored by the service, so it is flagged `recognised: false` instead of\n * being shown as if it granted anything.\n */\nexport interface A2AEntitlementView {\n id: string;\n recognised: boolean;\n permission: string;\n /** Local agents that may use this grant; empty means every agent in the workspace. */\n agentIds: string[];\n validFrom?: string;\n validUntil?: string;\n /**\n * Fields the service stores but does not enforce on an A2A call (bucket, app\n * and knowledge-base scope, rate limits). Kept on save, listed read-only.\n */\n unenforced: string[];\n}\n\n/** Editable form of one entitlement. Dates are `YYYY-MM-DD` (empty = open-ended). */\nexport interface A2AEntitlementDraft {\n permission: A2AEntitlementPermission;\n agentIds: string[];\n validFrom: string;\n validUntil: string;\n /** The original JSON row, so fields the editor does not show survive a save. */\n original?: Record<string, unknown>;\n}\n\nconst NO_AGENTS: A2AAgentRecord[] = [];\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n}\n\nfunction asString(value: unknown, fallback = ''): string {\n return typeof value === 'string' ? value : fallback;\n}\n\nfunction asBoolean(value: unknown): boolean {\n return value === true;\n}\n\nfunction asStringArray(value: unknown): string[] {\n return Array.isArray(value)\n ? value.filter((entry): entry is string => typeof entry === 'string')\n : [];\n}\n\nfunction asObjectArray(value: unknown): Record<string, unknown>[] {\n return Array.isArray(value) ? value.map(asRecord) : [];\n}\n\n/**\n * BOFF-15360 — the endpoint a card names first: `url` (A2A 0.x), else the\n * first of `supportedInterfaces` (A2A 1.0), else 0.3 `additionalInterfaces`.\n */\nexport function preferredCardEndpoint(card: Record<string, unknown> | undefined): string {\n const source = asRecord(card);\n const candidates = [\n source.url,\n ...asObjectArray(source.supportedInterfaces).map((entry) => entry.url),\n ...asObjectArray(source.additionalInterfaces).map((entry) => entry.url),\n ];\n const found = candidates.find(\n (value): value is string => typeof value === 'string' && value.trim() !== ''\n );\n return found ?? '';\n}\n\n/** Scheme names, whether a card lists them as strings or as `{ scheme }` objects. */\nfunction readSchemes(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n return value\n .map((entry) => (typeof entry === 'string' ? entry : asString(asRecord(entry).scheme)))\n .filter((entry) => entry !== '');\n}\n\n/** Reads the renderable view of an A2A agent card out of its JSON document. */\nexport function readAgentCard(card: Record<string, unknown> | undefined): A2AAgentCardView {\n const source = asRecord(card);\n const capabilities = asRecord(source.capabilities);\n const authentication = asRecord(source.authentication);\n\n return {\n url: preferredCardEndpoint(source),\n version: asString(source.version),\n providerOrganization: asString(asRecord(source.provider).organization),\n documentationUrl: asString(source.documentationUrl),\n capabilities: {\n streaming: asBoolean(capabilities.streaming),\n pushNotifications: asBoolean(capabilities.pushNotifications),\n stateTransitionHistory: asBoolean(capabilities.stateTransitionHistory),\n },\n authenticationSchemes: readSchemes(authentication.schemes),\n defaultInputModes: asStringArray(source.defaultInputModes),\n defaultOutputModes: asStringArray(source.defaultOutputModes),\n skills: asObjectArray(source.skills).map((skill, index) => ({\n id: asString(skill.id, `skill-${index}`),\n name: asString(skill.name),\n description: asString(skill.description),\n tags: asStringArray(skill.tags),\n examples: asStringArray(skill.examples),\n })),\n };\n}\n\nconst UNENFORCED_SCOPE_KEYS = ['bucketIds', 'appIds', 'knowledgeBaseIds'] as const;\n\nfunction unenforcedFields(entitlement: Record<string, unknown>): string[] {\n const scope = asRecord(entitlement.scope);\n const fields: string[] = UNENFORCED_SCOPE_KEYS.filter(\n (key) => asStringArray(scope[key]).length > 0\n ).map((key) => `scope.${key}`);\n if (Object.keys(asRecord(entitlement.rateLimit)).length > 0) fields.push('rateLimit');\n return fields;\n}\n\n/** Reads the entitlement rows out of the `entitlements` JSON column. */\nexport function readEntitlements(\n entitlements: Record<string, unknown> | unknown[] | null | undefined\n): A2AEntitlementView[] {\n return asObjectArray(entitlements).map((entitlement, index) => {\n const permission = asString(entitlement.permission).trim().toLowerCase();\n const validFrom = asString(entitlement.validFrom);\n const validUntil = asString(entitlement.validUntil);\n return {\n id: `entitlement-${index}`,\n recognised: permission.length > 0,\n permission,\n agentIds: asStringArray(asRecord(entitlement.scope).agentIds),\n validFrom: validFrom || undefined,\n validUntil: validUntil || undefined,\n unenforced: unenforcedFields(entitlement),\n };\n });\n}\n\nfunction toDateInput(value: string | undefined): string {\n if (!value) return '';\n const parsed = Date.parse(value);\n return Number.isFinite(parsed) ? new Date(parsed).toISOString().slice(0, 10) : '';\n}\n\nfunction isEntitlementPermission(value: string): value is A2AEntitlementPermission {\n return (A2A_ENTITLEMENT_PERMISSIONS as readonly string[]).includes(value);\n}\n\n/**\n * Editable drafts for the entitlements the service recognises. Rows it ignores\n * (no permission, or a permission it never checks) are not editable here;\n * `toEntitlementsInput` keeps them untouched.\n */\nexport function toEntitlementDrafts(\n entitlements: Record<string, unknown> | unknown[] | null | undefined\n): A2AEntitlementDraft[] {\n const rows = asObjectArray(entitlements);\n return readEntitlements(entitlements).flatMap((view, index) =>\n view.recognised && isEntitlementPermission(view.permission)\n ? [\n {\n permission: view.permission,\n agentIds: view.agentIds,\n validFrom: toDateInput(view.validFrom),\n validUntil: toDateInput(view.validUntil),\n original: rows[index],\n },\n ]\n : []\n );\n}\n\n/**\n * Rows of the stored JSON the editor does not manage, so a save from the\n * editor does not silently drop them.\n */\nexport function unmanagedEntitlements(\n entitlements: Record<string, unknown> | unknown[] | null | undefined\n): Record<string, unknown>[] {\n const rows = asObjectArray(entitlements);\n return readEntitlements(entitlements).flatMap((view, index) =>\n view.recognised && isEntitlementPermission(view.permission) ? [] : [rows[index]]\n );\n}\n\n/**\n * Serialises edited entitlements to the JSON the service enforces. A newly\n * chosen start date begins at 00:00 UTC and an end date runs to the end of\n * that UTC day; an unchanged stored timestamp is kept as it was.\n */\nexport function toEntitlementsInput(\n drafts: A2AEntitlementDraft[],\n unmanaged: Record<string, unknown>[] = []\n): Record<string, unknown>[] {\n const edited = drafts.map((draft) => {\n const row: Record<string, unknown> = { ...(draft.original ?? {}) };\n row.permission = draft.permission;\n const scope = { ...asRecord(row.scope) };\n if (draft.agentIds.length > 0) scope.agentIds = draft.agentIds;\n else delete scope.agentIds;\n if (Object.keys(scope).length > 0) row.scope = scope;\n else delete row.scope;\n // A stored timestamp whose day was not changed is kept exactly: the editor\n // works in days, and rewriting 12:00 as 23:59:59 would quietly extend it.\n const original = draft.original ?? {};\n const keep = (field: 'validFrom' | 'validUntil') => {\n const stored = asString(original[field]);\n return stored && toDateInput(stored) === draft[field] ? stored : undefined;\n };\n if (draft.validFrom) row.validFrom = keep('validFrom') ?? `${draft.validFrom}T00:00:00.000Z`;\n else delete row.validFrom;\n if (draft.validUntil)\n row.validUntil = keep('validUntil') ?? `${draft.validUntil}T23:59:59.999Z`;\n else delete row.validUntil;\n return row;\n });\n return [...edited, ...unmanaged];\n}\n\n/** Per-draft validation: an end date must not come before the start date. */\nexport function entitlementDraftError(draft: A2AEntitlementDraft): 'validityOrder' | undefined {\n if (draft.validFrom && draft.validUntil && draft.validUntil < draft.validFrom) {\n return 'validityOrder';\n }\n return undefined;\n}\n\n/**\n * True when at least one entitlement, valid now, lets a connection be made —\n * the service refuses every connection to an entry without one (default deny).\n */\nexport function entitlementsAllowConnections(\n entitlements: Record<string, unknown> | unknown[] | null | undefined,\n now: number = Date.now()\n): boolean {\n const isActive = (view: A2AEntitlementView) => {\n const from = view.validFrom ? Date.parse(view.validFrom) : NaN;\n const until = view.validUntil ? Date.parse(view.validUntil) : NaN;\n return !(Number.isFinite(from) && now < from) && !(Number.isFinite(until) && now > until);\n };\n return readEntitlements(entitlements).some(\n (view) => view.recognised && isEntitlementPermission(view.permission) && isActive(view)\n );\n}\n\n/** Number of skills the registered agent card advertises. */\nexport function a2aAgentSkillCount(agent: Pick<A2AAgentRecord, 'agentCard'>): number {\n const skills = agent.agentCard?.skills;\n return Array.isArray(skills) ? skills.length : 0;\n}\n\n/**\n * Structural check of an A2A agent card before it is registered. This validates\n * the document the caller supplies — it does NOT contact the remote agent.\n */\nexport function validateAgentCard(card: Record<string, unknown> | undefined): AgentCardValidation {\n const errors: A2AValidationIssue[] = [];\n if (!card) {\n return {\n valid: false,\n errors: [\n {\n key: 'botlit.a2aRegistry.validation.cardRequired',\n fallback: 'An agent card is required',\n },\n ],\n };\n }\n for (const field of ['name', 'description', 'version'] as const) {\n if (typeof card[field] !== 'string' || (card[field] as string).trim() === '') {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardMissingField',\n fallback: 'Agent card is missing \"{{field}}\"',\n params: { field },\n });\n }\n }\n // BOFF-15360 — an A2A 1.0 card may name its endpoint only in\n // supportedInterfaces; a 0.x card names it in \"url\".\n const endpoint = preferredCardEndpoint(card);\n if (endpoint === '') {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardNoEndpoint',\n fallback: 'Agent card is missing \"url\" (or an endpoint in \"supportedInterfaces\")',\n });\n } else if (!isHttpsUrl(endpoint)) {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardUrlHttps',\n fallback: \"The card's endpoint must be an https:// address\",\n });\n }\n // Every advertised endpoint, not only the preferred one, must be https.\n const interfaceUrls = [\n ...asObjectArray(card.supportedInterfaces),\n ...asObjectArray(card.additionalInterfaces),\n ].map((entry) => entry.url);\n if (\n endpoint !== '' &&\n isHttpsUrl(endpoint) &&\n interfaceUrls.some((url) => typeof url !== 'string' || !isHttpsUrl(url))\n ) {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardInterfaceUrl',\n fallback: 'Every interface in the card needs an https:// \"url\"',\n });\n }\n // An A2A 1.0 interface names the protocol binding and version it speaks.\n const incomplete = asObjectArray(card.supportedInterfaces).some(\n (entry) =>\n asString(entry.protocolBinding).trim() === '' || asString(entry.protocolVersion).trim() === ''\n );\n if (incomplete) {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardInterfaceProtocol',\n fallback:\n 'Each entry in \"supportedInterfaces\" needs a \"protocolBinding\" and a \"protocolVersion\"',\n });\n }\n if (!Array.isArray(card.skills) || card.skills.length === 0) {\n errors.push({\n key: 'botlit.a2aRegistry.validation.cardNoSkills',\n fallback: 'Agent card must advertise at least one skill',\n });\n }\n return { valid: errors.length === 0, errors };\n}\n\n/** True for an absolute `https://` URL with a host. */\nexport function isHttpsUrl(value: string): boolean {\n try {\n const url = new URL(value.trim());\n return url.protocol === 'https:' && url.hostname.length > 0;\n } catch {\n return false;\n }\n}\n\n/** The registry form as the page edits it. */\nexport interface A2ARegistryFormValues {\n name: string;\n description: string;\n wellKnownUrl: string;\n agentCardJson: string;\n}\n\nexport type A2ARegistryFormField = 'name' | 'description' | 'wellKnownUrl' | 'agentCardJson';\n\n/** Parses the edited agent card; returns undefined when the JSON is malformed. */\nexport function parseAgentCardJson(json: string): Record<string, unknown> | undefined {\n try {\n const parsed: unknown = JSON.parse(json);\n return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * The name the entry is saved with: the typed name, or the card's own name\n * when the field is left empty (BOFF-12510), so the list and the card agree\n * unless the user deliberately overrides it.\n */\nexport function effectiveEntryName(values: A2ARegistryFormValues): string {\n const typed = values.name.trim();\n if (typed) return typed;\n const cardName = parseAgentCardJson(values.agentCardJson)?.name;\n return typeof cardName === 'string' ? cardName.trim() : '';\n}\n\n/** The description the entry is saved with (typed, else the card's). */\nexport function effectiveEntryDescription(values: A2ARegistryFormValues): string {\n const typed = values.description.trim();\n if (typed) return typed;\n const cardDescription = parseAgentCardJson(values.agentCardJson)?.description;\n return typeof cardDescription === 'string' ? cardDescription.trim() : '';\n}\n\n/**\n * Field-level validation for the register/edit form (BOFF-12508). Returns at\n * most one issue per field, so each can be shown inline next to its input.\n */\nexport function validateRegistryForm(\n values: A2ARegistryFormValues\n): Partial<Record<A2ARegistryFormField, A2AValidationIssue>> {\n const issues: Partial<Record<A2ARegistryFormField, A2AValidationIssue>> = {};\n\n const card = parseAgentCardJson(values.agentCardJson);\n if (!values.agentCardJson.trim()) {\n issues.agentCardJson = {\n key: 'botlit.a2aRegistry.validation.cardRequired',\n fallback: 'An agent card is required',\n };\n } else if (new TextEncoder().encode(values.agentCardJson).length > A2A_AGENT_CARD_MAX_BYTES) {\n issues.agentCardJson = {\n key: 'botlit.a2aRegistry.validation.cardTooLarge',\n fallback: 'The agent card must be at most 1 MiB',\n };\n } else if (!card) {\n issues.agentCardJson = {\n key: 'botlit.a2aRegistry.validation.cardInvalidJson',\n fallback: 'Agent card must be a valid JSON object',\n };\n } else {\n const cardCheck = validateAgentCard(card);\n if (!cardCheck.valid) issues.agentCardJson = cardCheck.errors[0];\n }\n\n const name = effectiveEntryName(values);\n if (!name) {\n issues.name = {\n key: 'botlit.a2aRegistry.validation.nameRequired',\n fallback: 'Enter a name, or paste a card that has one',\n };\n } else if (name.length > A2A_NAME_MAX) {\n issues.name = {\n key: 'botlit.a2aRegistry.validation.nameTooLong',\n fallback: 'Name must be at most {{max}} characters',\n params: { max: A2A_NAME_MAX },\n };\n }\n\n if (effectiveEntryDescription(values).length > A2A_DESCRIPTION_MAX) {\n issues.description = {\n key: 'botlit.a2aRegistry.validation.descriptionTooLong',\n fallback: 'Description must be at most {{max}} characters',\n params: { max: A2A_DESCRIPTION_MAX },\n };\n }\n\n const wellKnownUrl = values.wellKnownUrl.trim();\n if (wellKnownUrl) {\n if (wellKnownUrl.length > A2A_URL_MAX) {\n issues.wellKnownUrl = {\n key: 'botlit.a2aRegistry.validation.urlTooLong',\n fallback: 'URL must be at most {{max}} characters',\n params: { max: A2A_URL_MAX },\n };\n } else if (!isHttpsUrl(wellKnownUrl)) {\n issues.wellKnownUrl = {\n key: 'botlit.a2aRegistry.validation.wellKnownHttps',\n fallback: 'Enter an https:// URL, e.g. https://agent.example.com/.well-known/agent.json',\n };\n }\n }\n\n return issues;\n}\n\nfunction identityRows(rows: A2AAgentRecord[]): A2AAgentRecord[] {\n return rows;\n}\n\nfunction selectAgents(data: ListA2ARegistryEntriesQuery | undefined): A2AAgentRecord[] {\n return data?.listBotmanorA2ARegistryEntriesPage.items ?? NO_AGENTS;\n}\n\nexport const a2aKeys = {\n all: ['a2a'] as const,\n lists: () => [...a2aKeys.all, 'list'] as const,\n list: (filter?: A2AAgentFilter) => [...a2aKeys.lists(), filter] as const,\n details: () => [...a2aKeys.all, 'detail'] as const,\n detail: (id: string) => [...a2aKeys.details(), id] as const,\n};\n\n/**\n * The registry list, one page at a time (BOFF-12509). Status, trust level,\n * visibility and bucket filter on the server. The service has no free-text\n * filter, so `search` narrows the rows loaded so far; the page keeps loading\n * further pages while a search is active, so a match is never hidden behind\n * an unloaded page.\n */\nexport function useA2AAgents(filter?: A2AAgentFilter): PaginatedQueryResult<A2AAgentRecord[]> {\n const workspaceId = useWorkspaceId();\n const search = filter?.search?.trim().toLowerCase() ?? '';\n const status = filter?.status?.[0];\n const visibility = filter?.visibility?.[0];\n const trustLevel = filter?.trustLevel?.[0];\n const bucketId = filter?.bucketId;\n\n const variables = useMemo(\n () => ({ filters: { workspaceId, status, visibility, trustLevel, bucketId } }),\n [workspaceId, status, visibility, trustLevel, bucketId]\n );\n\n const result = useWorkspacePaginatedQuery<\n ListA2ARegistryEntriesQuery,\n A2AAgentRecord,\n A2AAgentRecord[]\n >({\n document: ListA2ARegistryEntriesDocument,\n variables,\n pageSize: A2A_LIST_PAGE_SIZE,\n extractRows: selectAgents,\n extractNextOffset: (data) => data?.listBotmanorA2ARegistryEntriesPage.nextOffset ?? null,\n select: identityRows,\n fallback: NO_AGENTS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load the A2A registry',\n });\n\n // Narrowed here, not in `select`: the paginated hook applies `select` only\n // when a page arrives, and a new search term must re-filter the loaded rows.\n const rows = result.data;\n const data = useMemo(\n () =>\n search\n ? rows.filter(\n (row) =>\n row.name.toLowerCase().includes(search) ||\n (row.description ?? '').toLowerCase().includes(search)\n )\n : rows,\n [rows, search]\n );\n\n return { ...result, data };\n}\n\nexport function useA2AAgent(agentId: string | undefined): QueryResult<A2AAgentRecord | null> {\n const variables = useMemo(() => ({ id: agentId ?? '' }), [agentId]);\n\n return useWorkspaceQuery<GetA2ARegistryEntryQuery, A2AAgentRecord | null>({\n document: GetA2ARegistryEntryDocument,\n variables,\n select: (data) => data?.getA2ARegistryEntry ?? null,\n fallback: null,\n enabled: Boolean(agentId),\n errorMessage: 'Failed to load A2A agent',\n });\n}\n\nexport function useRegisterA2AAgent() {\n const workspaceId = useWorkspaceId();\n\n const variables = useCallback(\n (input: RegisterA2AAgentVariables) => ({\n input: buildMutationInput({ ...input, workspaceId }, REGISTER_AGENT_FIELDS),\n }),\n [workspaceId]\n );\n\n return useWorkspaceMutation<\n CreateA2ARegistryEntryMutation,\n RegisterA2AAgentVariables,\n A2AAgentRecord\n >({\n document: CreateA2ARegistryEntryDocument,\n variables,\n select: (data) => data?.createA2ARegistryEntry,\n errorMessage: 'Failed to register A2A agent',\n });\n}\n\nexport function useUpdateA2AAgent() {\n return useWorkspaceMutation<\n UpdateA2ARegistryEntryMutation,\n UpdateA2AAgentVariables,\n A2AAgentRecord\n >({\n document: UpdateA2ARegistryEntryDocument,\n variables: ({ agentId, input }) => ({\n id: agentId,\n input: buildMutationInput(input, UPDATE_AGENT_FIELDS),\n }),\n select: (data) => data?.updateA2ARegistryEntry,\n errorMessage: 'Failed to update A2A agent',\n });\n}\n\nexport function useDeleteA2AAgent() {\n return useWorkspaceMutation<DeleteA2ARegistryEntryMutation, string, boolean>({\n document: DeleteA2ARegistryEntryDocument,\n variables: (agentId) => ({ id: agentId }),\n select: (data) => data?.deleteA2ARegistryEntry,\n errorMessage: 'Failed to remove A2A agent',\n });\n}\n\n/**\n * BOFF-15360 — fetch the entry's published card again through the service\n * (SSRF guard, schema, endpoint origin, signature) and re-derive its trust.\n * A failed check is a result, not an error: the entry comes back FAILED with\n * the reason in `verificationError`.\n */\nexport function useVerifyA2AAgent() {\n return useWorkspaceMutation<VerifyA2ARegistryEntryMutation, string, A2AAgentRecord>({\n document: VerifyA2ARegistryEntryDocument,\n variables: (agentId) => ({ id: agentId }),\n select: (data) => data?.verifyA2ARegistryEntry,\n errorMessage: 'Failed to verify the agent card',\n });\n}\n\n/**\n * Validates an agent card locally before registration. There is no server-side\n * validation operation, so this deliberately reports only what can be checked\n * from the document itself.\n */\nexport function useValidateA2AAgent() {\n const validate = useCallback(\n async (card: Record<string, unknown> | undefined): Promise<AgentCardValidation> =>\n validateAgentCard(card),\n []\n );\n\n return [validate, { loading: false, error: undefined }] as const;\n}\n\nexport interface A2AAgentUsage {\n connectionCount: number;\n connections: {\n id: string;\n name: string;\n senderAgentId: string;\n senderAgentName?: string | null;\n isActive: boolean;\n }[];\n}\n\nconst NO_USAGE: A2AAgentUsage = { connectionCount: 0, connections: [] };\n\n/**\n * BOFF-12511 — the A2A connections that target a registry entry, for the\n * delete confirmation. Deleting the entry removes them.\n */\nexport function useA2AAgentUsage(\n agentId: string | undefined,\n enabled: boolean\n): QueryResult<A2AAgentUsage> {\n const variables = useMemo(() => ({ id: agentId ?? '' }), [agentId]);\n return useWorkspaceQuery<GetA2ARegistryEntryUsageQuery, A2AAgentUsage>({\n document: GetA2ARegistryEntryUsageDocument,\n variables,\n select: (data) => data?.getA2ARegistryEntryUsage ?? NO_USAGE,\n fallback: NO_USAGE,\n enabled: Boolean(agentId) && enabled,\n errorMessage: 'Failed to load what uses this A2A agent',\n });\n}\n"],"mappings":";;;;AA6CA,IAAaA,IAAsB,KACtBC,IAAc,MAEdC,KAA2B,SA4ClCC,IAAwBC,EAAsC;CAClE,WAAW;CACX,UAAU;CACV,aAAa;CACb,cAAc;CACd,UAAU;CACV,MAAM;CACN,QAAQ;CACR,MAAM;CACN,YAAY;CACZ,YAAY;CACZ,cAAc;CACd,aAAa;AACf,CAAC,GAEKC,IAAsBD,EAAsC;CAChE,WAAW;CACX,UAAU;CACV,aAAa;CACb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AM;EACxB,cAAc;CAChB,CAAC;AACH;AA4BA,IAAM+B,IAA0B;CAAE,iBAAiB;CAAG,aAAa,CAAC;AAAE;AAMtE,SAAgBC,GACd,GACA,GAC4B;CAC5B,IAAMtB,IAAYC,SAAe,EAAE,IAAIK,KAAW,GAAG,IAAI,CAACA,CAAO,CAAC;CAClE,OAAOC,EAAgE;EACrE,UAAUgB;EACV;EACA,SAAS,MAASjC,GAAM,4BAA4B+B;EACpD,UAAUA;EACV,SAAS,EAAQf,KAAYkB;EAC7B,cAAc;CAChB,CAAC;AACH"}
|
|
@@ -1,65 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ListAgentA2AConnectionsDocument as e } from "../../generated/wspace-operations.js";
|
|
2
|
+
import { useAllPagesQuery as t } from "./internal/allPages.js";
|
|
3
|
+
import { useWorkspaceId as n, useWorkspaceMutation as r } from "./internal/workspaceGateway.js";
|
|
4
|
+
import { useMemo as i } from "react";
|
|
5
|
+
import { gql as a } from "@apollo/client";
|
|
4
6
|
// src/botlit/hooks/useA2AConnections.ts
|
|
5
|
-
var
|
|
6
|
-
query ListAgentA2AConnections($filters: A2AConnectionFilterInput, $pagination: PaginationInput) {
|
|
7
|
-
listA2AConnections(filters: $filters, pagination: $pagination) {
|
|
8
|
-
${a}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`, s = i`
|
|
7
|
+
var o = "\n id\n name\n senderAgentId\n targetAgentId\n isActive\n createdAt\n", s = a`
|
|
12
8
|
mutation CreateAgentA2AConnection($input: CreateA2AConnectionInput!) {
|
|
13
9
|
createA2AConnection(input: $input) {
|
|
14
|
-
${
|
|
10
|
+
${o}
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
|
-
`, c =
|
|
13
|
+
`, c = a`
|
|
18
14
|
mutation UpdateAgentA2AConnection($id: ID!, $input: UpdateA2AConnectionInput!) {
|
|
19
15
|
updateA2AConnection(id: $id, input: $input) {
|
|
20
|
-
${
|
|
16
|
+
${o}
|
|
21
17
|
}
|
|
22
18
|
}
|
|
23
|
-
`, l =
|
|
19
|
+
`, l = a`
|
|
24
20
|
mutation DeleteAgentA2AConnection($id: ID!) {
|
|
25
21
|
deleteA2AConnection(id: $id)
|
|
26
22
|
}
|
|
27
23
|
`, u = [];
|
|
28
|
-
function d(
|
|
29
|
-
let
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return n({
|
|
40
|
-
document: o,
|
|
41
|
-
variables: a,
|
|
42
|
-
select: (e) => e?.listA2AConnections ?? u,
|
|
24
|
+
function d(r) {
|
|
25
|
+
let a = n(), o = i(() => ({ filters: {
|
|
26
|
+
workspaceId: a,
|
|
27
|
+
senderAgentId: r
|
|
28
|
+
} }), [a, r]);
|
|
29
|
+
return t({
|
|
30
|
+
document: e,
|
|
31
|
+
variables: o,
|
|
32
|
+
pageSize: 100,
|
|
33
|
+
extractRows: (e) => e?.listBotmanorA2AConnectionsPage.items ?? u,
|
|
34
|
+
extractNextOffset: (e) => e?.listBotmanorA2AConnectionsPage.nextOffset ?? null,
|
|
43
35
|
fallback: u,
|
|
44
|
-
enabled: !!(
|
|
36
|
+
enabled: !!(a && r),
|
|
45
37
|
errorMessage: "Failed to load agent connections"
|
|
46
38
|
});
|
|
47
39
|
}
|
|
48
40
|
function f() {
|
|
49
|
-
let
|
|
50
|
-
return
|
|
41
|
+
let e = n();
|
|
42
|
+
return r({
|
|
51
43
|
document: s,
|
|
52
|
-
variables: (
|
|
53
|
-
...
|
|
54
|
-
name:
|
|
55
|
-
workspaceId:
|
|
44
|
+
variables: (t) => ({ input: {
|
|
45
|
+
...t,
|
|
46
|
+
name: t.name.trim(),
|
|
47
|
+
workspaceId: e
|
|
56
48
|
} }),
|
|
57
49
|
select: (e) => e?.createA2AConnection ?? void 0,
|
|
58
50
|
errorMessage: "Failed to connect the agents"
|
|
59
51
|
});
|
|
60
52
|
}
|
|
61
53
|
function p() {
|
|
62
|
-
return
|
|
54
|
+
return r({
|
|
63
55
|
document: c,
|
|
64
56
|
variables: ({ id: e, isActive: t }) => ({
|
|
65
57
|
id: e,
|
|
@@ -70,7 +62,7 @@ function p() {
|
|
|
70
62
|
});
|
|
71
63
|
}
|
|
72
64
|
function m() {
|
|
73
|
-
return
|
|
65
|
+
return r({
|
|
74
66
|
document: l,
|
|
75
67
|
variables: (e) => ({ id: e }),
|
|
76
68
|
select: (e) => e?.deleteA2AConnection ?? void 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useA2AConnections.js","names":["FIELDS","
|
|
1
|
+
{"version":3,"file":"useA2AConnections.js","names":["FIELDS","CREATE_DOCUMENT","UPDATE_DOCUMENT","DELETE_DOCUMENT","NONE","useAgentA2AConnections","workspaceId","useWorkspaceId","variables","useMemo","agentId","useAllPagesQuery","ListAgentA2AConnectionsDocument","data","useCreateA2AConnection","useWorkspaceMutation","input","useSetA2AConnectionActive","useDeleteA2AConnection"],"sources":["../../../src/botlit/hooks/useA2AConnections.ts"],"sourcesContent":["/**\n * Agent-to-agent connections (BOFF-15360)\n * @module botlit/hooks\n *\n * An `A2AConnection` lets one agent (the sender) delegate to another (the\n * target) when the sender has the agent-delegation capability. These hooks list\n * the connections an agent sends on and add, toggle or remove one.\n */\n\nimport { gql } from '@apollo/client';\nimport { useMemo } from 'react';\n\nimport {\n ListAgentA2AConnectionsDocument,\n type ListAgentA2AConnectionsQuery,\n} from '../../generated/wspace-operations';\nimport { useAllPagesQuery } from './internal/allPages';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nexport interface A2AConnectionRecord {\n id: string;\n name: string;\n senderAgentId: string;\n targetAgentId: string;\n isActive: boolean;\n createdAt?: string | null;\n}\n\ninterface CreateA2AConnectionData {\n createA2AConnection?: A2AConnectionRecord | null;\n}\n\ninterface UpdateA2AConnectionData {\n updateA2AConnection?: A2AConnectionRecord | null;\n}\n\ninterface DeleteA2AConnectionData {\n deleteA2AConnection?: boolean | null;\n}\n\nconst FIELDS = `\n id\n name\n senderAgentId\n targetAgentId\n isActive\n createdAt\n`;\n\nconst CREATE_DOCUMENT = gql`\n mutation CreateAgentA2AConnection($input: CreateA2AConnectionInput!) {\n createA2AConnection(input: $input) {\n ${FIELDS}\n }\n }\n`;\n\nconst UPDATE_DOCUMENT = gql`\n mutation UpdateAgentA2AConnection($id: ID!, $input: UpdateA2AConnectionInput!) {\n updateA2AConnection(id: $id, input: $input) {\n ${FIELDS}\n }\n }\n`;\n\nconst DELETE_DOCUMENT = gql`\n mutation DeleteAgentA2AConnection($id: ID!) {\n deleteA2AConnection(id: $id)\n }\n`;\n\nconst NONE: A2AConnectionRecord[] = [];\n\nexport function useAgentA2AConnections(\n agentId: string | undefined\n): QueryResult<A2AConnectionRecord[]> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(\n () => ({\n filters: { workspaceId, senderAgentId: agentId },\n }),\n [workspaceId, agentId]\n );\n return useAllPagesQuery<ListAgentA2AConnectionsQuery, A2AConnectionRecord>({\n document: ListAgentA2AConnectionsDocument,\n variables,\n pageSize: 100,\n extractRows: (data) => data?.listBotmanorA2AConnectionsPage.items ?? NONE,\n extractNextOffset: (data) => data?.listBotmanorA2AConnectionsPage.nextOffset ?? null,\n fallback: NONE,\n enabled: Boolean(workspaceId && agentId),\n errorMessage: 'Failed to load agent connections',\n });\n}\n\nexport interface CreateA2AConnectionVariables {\n name: string;\n senderAgentId: string;\n targetAgentId: string;\n}\n\nexport function useCreateA2AConnection() {\n const workspaceId = useWorkspaceId();\n return useWorkspaceMutation<\n CreateA2AConnectionData,\n CreateA2AConnectionVariables,\n A2AConnectionRecord\n >({\n document: CREATE_DOCUMENT,\n variables: (input) => ({ input: { ...input, name: input.name.trim(), workspaceId } }),\n select: (data) => data?.createA2AConnection ?? undefined,\n errorMessage: 'Failed to connect the agents',\n });\n}\n\nexport function useSetA2AConnectionActive() {\n return useWorkspaceMutation<\n UpdateA2AConnectionData,\n { id: string; isActive: boolean },\n A2AConnectionRecord\n >({\n document: UPDATE_DOCUMENT,\n variables: ({ id, isActive }) => ({ id, input: { isActive } }),\n select: (data) => data?.updateA2AConnection ?? undefined,\n errorMessage: 'Failed to update the connection',\n });\n}\n\nexport function useDeleteA2AConnection() {\n return useWorkspaceMutation<DeleteA2AConnectionData, string, boolean>({\n document: DELETE_DOCUMENT,\n variables: (id) => ({ id }),\n select: (data) => data?.deleteA2AConnection ?? undefined,\n errorMessage: 'Failed to remove the connection',\n });\n}\n"],"mappings":";;;;;;AA4CA,IAAMA,IAAS,+EASTC,IAAkB,CAAG;;;QAGnBD,EAAO;;;GAKTE,IAAkB,CAAG;;;QAGnBF,EAAO;;;GAKTG,IAAkB,CAAG;;;;GAMrBC,IAA8B,CAAC;AAErC,SAAgBC,EACd,GACoC;CACpC,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,SACT,EACL,SAAS;EAAE;EAAa,eAAeC;CAAQ,EACjD,IACA,CAACJ,GAAaI,CAAO,CACvB;CACA,OAAOC,EAAoE;EACzE,UAAUC;EACV;EACA,UAAU;EACV,cAAc,MAASC,GAAM,+BAA+B,SAAST;EACrE,oBAAoB,MAASS,GAAM,+BAA+B,cAAc;EAChF,UAAUT;EACV,SAAS,GAAQE,KAAeI;EAChC,cAAc;CAChB,CAAC;AACH;AAQA,SAAgBI,IAAyB;CACvC,IAAMR,IAAcC,EAAe;CACnC,OAAOQ,EAIL;EACA,UAAUd;EACV,YAAY,OAAW,EAAE,OAAO;GAAE,GAAGe;GAAO,MAAMA,EAAM,KAAK,KAAK;GAAG;EAAY,EAAE;EACnF,SAAS,MAASH,GAAM,uBAAuB,KAAA;EAC/C,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBI,IAA4B;CAC1C,OAAOF,EAIL;EACA,UAAUb;EACV,YAAY,EAAE,OAAI,mBAAgB;GAAE;GAAI,OAAO,EAAE,YAAS;EAAE;EAC5D,SAAS,MAASW,GAAM,uBAAuB,KAAA;EAC/C,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBK,IAAyB;CACvC,OAAOH,EAA+D;EACpE,UAAUZ;EACV,YAAY,OAAQ,EAAE,MAAG;EACzB,SAAS,MAASU,GAAM,uBAAuB,KAAA;EAC/C,cAAc;CAChB,CAAC;AACH"}
|