@burdenoff/microfe-botmanor 2026.1118.5 → 2026.1118.7

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.
Files changed (46) hide show
  1. package/dist/botlit/components/AgentBindingsPanel.d.ts +4 -0
  2. package/dist/botlit/components/AgentBindingsPanel.js +305 -0
  3. package/dist/botlit/components/AgentBindingsPanel.js.map +1 -0
  4. package/dist/botlit/components/ChannelSetupPanels.d.ts +21 -0
  5. package/dist/botlit/components/ChannelSetupPanels.js +139 -0
  6. package/dist/botlit/components/ChannelSetupPanels.js.map +1 -0
  7. package/dist/botlit/hooks/index.d.ts +5 -1
  8. package/dist/botlit/hooks/index.js +14 -12
  9. package/dist/botlit/hooks/useAgentBindings.d.ts +58 -0
  10. package/dist/botlit/hooks/useAgentBindings.js +87 -0
  11. package/dist/botlit/hooks/useAgentBindings.js.map +1 -0
  12. package/dist/botlit/hooks/useChannelSetup.d.ts +96 -0
  13. package/dist/botlit/hooks/useChannelSetup.js +199 -0
  14. package/dist/botlit/hooks/useChannelSetup.js.map +1 -0
  15. package/dist/botlit/hooks/useChannels.d.ts +6 -0
  16. package/dist/botlit/hooks/useChannels.js +80 -58
  17. package/dist/botlit/hooks/useChannels.js.map +1 -1
  18. package/dist/botlit/hooks/useUserPlatformConnection.d.ts +1 -0
  19. package/dist/botlit/hooks/useUserPlatformConnection.js +1 -0
  20. package/dist/botlit/hooks/useUserPlatformConnection.js.map +1 -1
  21. package/dist/botlit/pages/AgentDetailPage.js +56 -55
  22. package/dist/botlit/pages/AgentDetailPage.js.map +1 -1
  23. package/dist/botlit/pages/BotChannelsTab.js +204 -186
  24. package/dist/botlit/pages/BotChannelsTab.js.map +1 -1
  25. package/dist/botlit/pages/ChannelDetailPage.js +658 -526
  26. package/dist/botlit/pages/ChannelDetailPage.js.map +1 -1
  27. package/dist/botlit/pages/ChannelsPage.js +2 -1
  28. package/dist/botlit/pages/ChannelsPage.js.map +1 -1
  29. package/dist/botlit/pages/PromptStudioPage.js +365 -175
  30. package/dist/botlit/pages/PromptStudioPage.js.map +1 -1
  31. package/dist/botlit/providers/BotlitProvider.js +39 -35
  32. package/dist/botlit/providers/BotlitProvider.js.map +1 -1
  33. package/dist/botlit/types/index.d.ts +2 -0
  34. package/dist/botlit/utils/channelConnectors.d.ts +16 -0
  35. package/dist/botlit/utils/channelConnectors.js +24 -0
  36. package/dist/botlit/utils/channelConnectors.js.map +1 -0
  37. package/dist/botlit/utils/promptVariables.d.ts +6 -0
  38. package/dist/botlit/utils/promptVariables.js +20 -0
  39. package/dist/botlit/utils/promptVariables.js.map +1 -0
  40. package/dist/generated/wspace-operations.d.ts +314 -0
  41. package/dist/generated/wspace-operations.js +189 -101
  42. package/dist/generated/wspace-operations.js.map +1 -1
  43. package/dist/generated/wspace-types.d.ts +139 -0
  44. package/dist/generated/wspace-types.js +3 -1
  45. package/dist/generated/wspace-types.js.map +1 -1
  46. package/package.json +1 -1
@@ -0,0 +1,58 @@
1
+ import { AgentBindingsFieldsFragment, GetPromptTemplateVersionsQuery, TestPromptTemplateMutation } from '../../generated/wspace-operations';
2
+ import { SavePromptTemplateVersionInput, SetAgentBindingsInput, TestPromptTemplateInput } from '../../generated/wspace-types';
3
+ import { QueryResult } from './internal/workspaceGateway';
4
+ export type AgentBindingsRecord = AgentBindingsFieldsFragment;
5
+ export type PromptTemplateTestRecord = TestPromptTemplateMutation['testPromptTemplate'];
6
+ export type PromptTemplateVersionRecord = NonNullable<GetPromptTemplateVersionsQuery['getPromptTemplate']>['versionHistory'][number];
7
+ export declare function useAgentBindings(agentId: string | undefined): QueryResult<AgentBindingsRecord | null>;
8
+ export declare function useSetAgentBindings(agentId: string): {
9
+ save: (input: SetAgentBindingsInput) => Promise<AgentBindingsFieldsFragment>;
10
+ loading: boolean;
11
+ error: Error | undefined;
12
+ };
13
+ export interface TestPromptTemplateVariables {
14
+ templateId: string;
15
+ input: TestPromptTemplateInput;
16
+ }
17
+ export declare function useTestPromptTemplate(): {
18
+ run: (input: TestPromptTemplateVariables) => Promise<{
19
+ renderedPrompt: string;
20
+ output: string;
21
+ model: string;
22
+ tokensUsed: number;
23
+ inputTokens: number | null;
24
+ outputTokens: number | null;
25
+ latencyMs: number;
26
+ }>;
27
+ loading: boolean;
28
+ };
29
+ export interface SavePromptTemplateVersionVariables {
30
+ templateId: string;
31
+ input: SavePromptTemplateVersionInput;
32
+ }
33
+ export declare function useSavePromptTemplateVersion(): {
34
+ save: (input: SavePromptTemplateVersionVariables) => Promise<{
35
+ id: string;
36
+ version: string;
37
+ revision: number;
38
+ templateText: string;
39
+ variables: Record<string, unknown>;
40
+ updatedAt: string;
41
+ versionHistory: Array<{
42
+ version: string;
43
+ revision: number;
44
+ templateText: string;
45
+ variables: Record<string, unknown>;
46
+ changelog: string | null;
47
+ savedAt: string;
48
+ savedById: string;
49
+ }>;
50
+ }>;
51
+ loading: boolean;
52
+ };
53
+ /**
54
+ * Earlier versions of one template. A response for a template that is no
55
+ * longer the requested one (the selection changed mid-flight) is discarded,
56
+ * so one prompt's history can never be shown, loaded or saved into another.
57
+ */
58
+ export declare function usePromptTemplateVersions(templateId: string | undefined): QueryResult<PromptTemplateVersionRecord[]>;
@@ -0,0 +1,87 @@
1
+ import { GetAgentBindingsDocument as e, GetPromptTemplateVersionsDocument as t, SavePromptTemplateVersionDocument as n, SetAgentBindingsDocument as r, TestPromptTemplateDocument as i } from "../../generated/wspace-operations.js";
2
+ import { useWorkspaceId as a, useWorkspaceMutation as o, useWorkspaceQuery as s } from "./internal/workspaceGateway.js";
3
+ import { useEffect as c, useMemo as l } from "react";
4
+ // src/botlit/hooks/useAgentBindings.ts
5
+ function u(t) {
6
+ let n = a(), r = l(() => ({ agentId: t ?? "" }), [t]);
7
+ return s({
8
+ document: e,
9
+ variables: r,
10
+ select: (e) => e?.getAgentBindings ?? null,
11
+ fallback: null,
12
+ enabled: !!(n && t),
13
+ errorMessage: "Failed to load the agent bindings"
14
+ });
15
+ }
16
+ function d(e) {
17
+ let [t, n] = o({
18
+ document: r,
19
+ variables: (t) => ({
20
+ agentId: e,
21
+ input: t
22
+ }),
23
+ select: (e) => e?.setAgentBindings,
24
+ errorMessage: "Failed to save the agent bindings"
25
+ });
26
+ return {
27
+ save: t,
28
+ loading: n.loading,
29
+ error: n.error
30
+ };
31
+ }
32
+ function f() {
33
+ let [e, t] = o({
34
+ document: i,
35
+ variables: ({ templateId: e, input: t }) => ({
36
+ id: e,
37
+ input: t
38
+ }),
39
+ select: (e) => e?.testPromptTemplate,
40
+ errorMessage: "Failed to run the prompt against the model"
41
+ });
42
+ return {
43
+ run: e,
44
+ loading: t.loading
45
+ };
46
+ }
47
+ function p() {
48
+ let [e, t] = o({
49
+ document: n,
50
+ variables: ({ templateId: e, input: t }) => ({
51
+ id: e,
52
+ input: t
53
+ }),
54
+ select: (e) => e?.savePromptTemplateVersion,
55
+ errorMessage: "Failed to save the prompt version"
56
+ });
57
+ return {
58
+ save: e,
59
+ loading: t.loading
60
+ };
61
+ }
62
+ var m = [], h = {
63
+ templateId: null,
64
+ versions: m
65
+ };
66
+ function g(e) {
67
+ let n = l(() => ({ id: e ?? "" }), [e]), r = s({
68
+ document: t,
69
+ variables: n,
70
+ select: (e) => e?.getPromptTemplate ? {
71
+ templateId: e.getPromptTemplate.id,
72
+ versions: e.getPromptTemplate.versionHistory
73
+ } : h,
74
+ fallback: h,
75
+ enabled: !!e,
76
+ errorMessage: "Failed to load the prompt versions"
77
+ }), i = !!e && !r.loading && r.data.templateId !== null && r.data.templateId !== e, { refetch: a } = r;
78
+ return c(() => {
79
+ i && a();
80
+ }, [i, a]), {
81
+ ...r,
82
+ data: r.data.templateId === e ? r.data.versions : m
83
+ };
84
+ }
85
+ export { u as useAgentBindings, g as usePromptTemplateVersions, p as useSavePromptTemplateVersion, d as useSetAgentBindings, f as useTestPromptTemplate };
86
+
87
+ //# sourceMappingURL=useAgentBindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAgentBindings.js","names":["useAgentBindings","workspaceId","useWorkspaceId","variables","useMemo","agentId","useWorkspaceQuery","GetAgentBindingsDocument","data","useSetAgentBindings","save","state","useWorkspaceMutation","SetAgentBindingsDocument","useTestPromptTemplate","run","TestPromptTemplateDocument","templateId","useSavePromptTemplateVersion","SavePromptTemplateVersionDocument","NO_VERSIONS","NO_TEMPLATE_VERSIONS","usePromptTemplateVersions","result","GetPromptTemplateVersionsDocument","stale","useEffect","refetch"],"sources":["../../../src/botlit/hooks/useAgentBindings.ts"],"sourcesContent":["/**\n * Agent Builder bindings + Prompt Studio hooks (BOFF-15360)\n * @module botlit/hooks\n *\n * Backed by `getAgentBindings` / `setAgentBindings` (the prompt template,\n * skills and retrieval profile attached to an agent) and the Prompt Studio\n * mutations `testPromptTemplate` / `savePromptTemplateVersion` on\n * wspace-botmanor-svc.\n */\n\nimport { useEffect, useMemo } from 'react';\nimport {\n GetAgentBindingsDocument,\n GetPromptTemplateVersionsDocument,\n SavePromptTemplateVersionDocument,\n SetAgentBindingsDocument,\n TestPromptTemplateDocument,\n type AgentBindingsFieldsFragment,\n type GetAgentBindingsQuery,\n type GetPromptTemplateVersionsQuery,\n type SavePromptTemplateVersionMutation,\n type SetAgentBindingsMutation,\n type TestPromptTemplateMutation,\n} from '../../generated/wspace-operations';\nimport type {\n SavePromptTemplateVersionInput,\n SetAgentBindingsInput,\n TestPromptTemplateInput,\n} from '../../generated/wspace-types';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nexport type AgentBindingsRecord = AgentBindingsFieldsFragment;\nexport type PromptTemplateTestRecord = TestPromptTemplateMutation['testPromptTemplate'];\nexport type PromptTemplateVersionRecord = NonNullable<\n GetPromptTemplateVersionsQuery['getPromptTemplate']\n>['versionHistory'][number];\n\nexport function useAgentBindings(\n agentId: string | undefined\n): QueryResult<AgentBindingsRecord | null> {\n const workspaceId = useWorkspaceId();\n const variables = useMemo(() => ({ agentId: agentId ?? '' }), [agentId]);\n return useWorkspaceQuery<GetAgentBindingsQuery, AgentBindingsRecord | null>({\n document: GetAgentBindingsDocument,\n variables,\n select: (data) => data?.getAgentBindings ?? null,\n fallback: null,\n enabled: Boolean(workspaceId && agentId),\n errorMessage: 'Failed to load the agent bindings',\n });\n}\n\nexport function useSetAgentBindings(agentId: string) {\n const [save, state] = useWorkspaceMutation<\n SetAgentBindingsMutation,\n SetAgentBindingsInput,\n AgentBindingsRecord\n >({\n document: SetAgentBindingsDocument,\n variables: (input) => ({ agentId, input }),\n select: (data) => data?.setAgentBindings,\n errorMessage: 'Failed to save the agent bindings',\n });\n return { save, loading: state.loading, error: state.error };\n}\n\nexport interface TestPromptTemplateVariables {\n templateId: string;\n input: TestPromptTemplateInput;\n}\n\nexport function useTestPromptTemplate() {\n const [run, state] = useWorkspaceMutation<\n TestPromptTemplateMutation,\n TestPromptTemplateVariables,\n PromptTemplateTestRecord\n >({\n document: TestPromptTemplateDocument,\n variables: ({ templateId, input }) => ({ id: templateId, input }),\n select: (data) => data?.testPromptTemplate,\n errorMessage: 'Failed to run the prompt against the model',\n });\n return { run, loading: state.loading };\n}\n\nexport interface SavePromptTemplateVersionVariables {\n templateId: string;\n input: SavePromptTemplateVersionInput;\n}\n\nexport function useSavePromptTemplateVersion() {\n const [save, state] = useWorkspaceMutation<\n SavePromptTemplateVersionMutation,\n SavePromptTemplateVersionVariables,\n SavePromptTemplateVersionMutation['savePromptTemplateVersion']\n >({\n document: SavePromptTemplateVersionDocument,\n variables: ({ templateId, input }) => ({ id: templateId, input }),\n select: (data) => data?.savePromptTemplateVersion,\n errorMessage: 'Failed to save the prompt version',\n });\n return { save, loading: state.loading };\n}\n\nconst NO_VERSIONS: PromptTemplateVersionRecord[] = [];\n\ninterface PromptTemplateVersions {\n templateId: string | null;\n versions: PromptTemplateVersionRecord[];\n}\n\nconst NO_TEMPLATE_VERSIONS: PromptTemplateVersions = { templateId: null, versions: NO_VERSIONS };\n\n/**\n * Earlier versions of one template. A response for a template that is no\n * longer the requested one (the selection changed mid-flight) is discarded,\n * so one prompt's history can never be shown, loaded or saved into another.\n */\nexport function usePromptTemplateVersions(\n templateId: string | undefined\n): QueryResult<PromptTemplateVersionRecord[]> {\n const variables = useMemo(() => ({ id: templateId ?? '' }), [templateId]);\n const result = useWorkspaceQuery<GetPromptTemplateVersionsQuery, PromptTemplateVersions>({\n document: GetPromptTemplateVersionsDocument,\n variables,\n select: (data) =>\n data?.getPromptTemplate\n ? { templateId: data.getPromptTemplate.id, versions: data.getPromptTemplate.versionHistory }\n : NO_TEMPLATE_VERSIONS,\n fallback: NO_TEMPLATE_VERSIONS,\n enabled: Boolean(templateId),\n errorMessage: 'Failed to load the prompt versions',\n });\n // A stale response that landed last is replaced by a fresh read of the\n // selected template's history.\n const stale =\n Boolean(templateId) &&\n !result.loading &&\n result.data.templateId !== null &&\n result.data.templateId !== templateId;\n const { refetch } = result;\n useEffect(() => {\n if (stale) void refetch();\n }, [stale, refetch]);\n return {\n ...result,\n data: result.data.templateId === templateId ? result.data.versions : NO_VERSIONS,\n };\n}\n"],"mappings":";;;;AA0CA,SAAgBA,EACd,GACyC;CACzC,IAAMC,IAAcC,EAAe,GAC7BC,IAAYC,SAAe,EAAE,SAASC,KAAW,GAAG,IAAI,CAACA,CAAO,CAAC;CACvE,OAAOC,EAAqE;EAC1E,UAAUC;EACV;EACA,SAAS,MAASC,GAAM,oBAAoB;EAC5C,UAAU;EACV,SAAS,GAAQP,KAAeI;EAChC,cAAc;CAChB,CAAC;AACH;AAEA,SAAgBI,EAAoB,GAAiB;CACnD,IAAM,CAACC,GAAMC,KAASC,EAIpB;EACA,UAAUC;EACV,YAAY,OAAW;GAAE;GAAS;EAAM;EACxC,SAAS,MAASL,GAAM;EACxB,cAAc;CAChB,CAAC;CACD,OAAO;EAAE;EAAM,SAASG,EAAM;EAAS,OAAOA,EAAM;CAAM;AAC5D;AAOA,SAAgBG,IAAwB;CACtC,IAAM,CAACC,GAAKJ,KAASC,EAInB;EACA,UAAUI;EACV,YAAY,EAAE,eAAY,gBAAa;GAAE,IAAIC;GAAY;EAAM;EAC/D,SAAS,MAAST,GAAM;EACxB,cAAc;CAChB,CAAC;CACD,OAAO;EAAE;EAAK,SAASG,EAAM;CAAQ;AACvC;AAOA,SAAgBO,IAA+B;CAC7C,IAAM,CAACR,GAAMC,KAASC,EAIpB;EACA,UAAUO;EACV,YAAY,EAAE,eAAY,gBAAa;GAAE,IAAIF;GAAY;EAAM;EAC/D,SAAS,MAAST,GAAM;EACxB,cAAc;CAChB,CAAC;CACD,OAAO;EAAE;EAAM,SAASG,EAAM;CAAQ;AACxC;AAEA,IAAMS,IAA6C,CAAC,GAO9CC,IAA+C;CAAE,YAAY;CAAM,UAAUD;AAAY;AAO/F,SAAgBE,EACd,GAC4C;CAC5C,IAAMnB,IAAYC,SAAe,EAAE,IAAIa,KAAc,GAAG,IAAI,CAACA,CAAU,CAAC,GAClEM,IAASjB,EAA0E;EACvF,UAAUkB;EACV;EACA,SAAS,MACPhB,GAAM,oBACF;GAAE,YAAYA,EAAK,kBAAkB;GAAI,UAAUA,EAAK,kBAAkB;EAAe,IACzFa;EACN,UAAUA;EACV,SAAS,EAAQJ;EACjB,cAAc;CAChB,CAAC,GAGKQ,IACJ,EAAQR,KACR,CAACM,EAAO,WACRA,EAAO,KAAK,eAAe,QAC3BA,EAAO,KAAK,eAAeN,GACvB,EAAE,eAAYM;CAIpB,OAHAG,QAAgB;EACd,AAAID,KAAOE,EAAa;CAC1B,GAAG,CAACF,GAAOE,CAAO,CAAC,GACZ;EACL,GAAGJ;EACH,MAAMA,EAAO,KAAK,eAAeN,IAAaM,EAAO,KAAK,WAAWH;CACvE;AACF"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Channel setup hooks (BOFF-15360)
3
+ * @module botlit/hooks
4
+ *
5
+ * A BotManor channel connector names a channel on global-channel-svc through
6
+ * `credentialsRefId`. That global channel holds the platform credentials (a
7
+ * Slack bot token and signing secret, a webhook's signing secret and reply
8
+ * URL, …) and publishes the public URL the platform must call with inbound
9
+ * events (`Channel.inboundWebhookUrl`, set once an ACTIVE connector binds the
10
+ * channel to this workspace).
11
+ *
12
+ * These hooks let the connector form create that channel with its credentials
13
+ * and the detail page show its inbound URL, all through the shell's global
14
+ * gateway client. The documents are written inline, like `GetChannels` in
15
+ * `useUserPlatformConnection`: `inboundWebhookUrl` / `inboundWorkspaceId` are
16
+ * newer than the checked-in `graphql/global.graphql`, which cannot be
17
+ * re-pulled while gateway introspection is disabled.
18
+ */
19
+ /** Global-channel platforms a connector type delivers through. */
20
+ export type ChannelSetupPlatform = 'SLACK' | 'TEAMS' | 'DISCORD' | 'WHATSAPP' | 'WEBHOOK';
21
+ /** `ChannelAuthType` values the setup form sends. */
22
+ type ChannelSetupAuthType = 'BOT_TOKEN' | 'WEBHOOK';
23
+ export interface CredentialFieldDefinition {
24
+ /** Key stored on the channel connection's credentials. */
25
+ key: string;
26
+ label: string;
27
+ description: string;
28
+ placeholder: string;
29
+ /** Rendered as a password input and never shown again after saving. */
30
+ secret: boolean;
31
+ /** Offer a "Generate" button producing a random 64-hex-character secret. */
32
+ generatable?: boolean;
33
+ /** Must be an absolute https URL. */
34
+ url?: boolean;
35
+ }
36
+ export interface PlatformCredentialDefinition {
37
+ platform: ChannelSetupPlatform;
38
+ authType: ChannelSetupAuthType;
39
+ fields: CredentialFieldDefinition[];
40
+ /** Where to paste the inbound webhook URL on the platform side. */
41
+ inboundHint: string;
42
+ }
43
+ /**
44
+ * Connector types whose credentials the form can collect directly. The keys
45
+ * are the ones global-channel-svc reads: Slack sends with `botToken` and
46
+ * verifies inbound requests with `signingSecret`; a generic webhook verifies
47
+ * with `webhookSecret` (HMAC-SHA256 hex in `X-Signature`) and POSTs replies
48
+ * to `targetUrl`.
49
+ */
50
+ export declare const PLATFORM_CREDENTIALS: Readonly<Record<string, PlatformCredentialDefinition>>;
51
+ export declare function connectorPlatform(connectorType: string): ChannelSetupPlatform | undefined;
52
+ /** A random 32-byte secret, hex encoded, from the browser's CSPRNG. */
53
+ export declare function generateSigningSecret(): string;
54
+ /**
55
+ * Returns the first problem with the entered credentials, or null when they
56
+ * are complete. Every field is required.
57
+ */
58
+ export declare function validateCredentials(definition: PlatformCredentialDefinition, values: Record<string, string>): string | null;
59
+ /**
60
+ * The shell's active organization (the host passes it with the workspace).
61
+ * Global channels belong to an organization, so creating one needs it.
62
+ */
63
+ export declare function useActiveOrganizationId(): string | null;
64
+ export interface InboundChannelData {
65
+ id: string;
66
+ name: string;
67
+ platform: string;
68
+ status: string;
69
+ isConnected: boolean;
70
+ inboundWorkspaceId: string | null;
71
+ inboundWebhookUrl: string | null;
72
+ }
73
+ interface UseInboundChannelResult {
74
+ data: InboundChannelData | null;
75
+ loading: boolean;
76
+ error: Error | undefined;
77
+ refetch: () => Promise<void>;
78
+ }
79
+ /** The global channel a connector names, with its inbound webhook URL. */
80
+ export declare function useInboundChannel(channelId: string | null | undefined): UseInboundChannelResult;
81
+ export interface ProvisionChannelInput {
82
+ name: string;
83
+ description?: string;
84
+ organizationId: string;
85
+ definition: PlatformCredentialDefinition;
86
+ credentials: Record<string, string>;
87
+ }
88
+ interface UseProvisionChannelResult {
89
+ /** Creates the global channel and its connection; resolves to the channel id. */
90
+ provision: (input: ProvisionChannelInput) => Promise<string>;
91
+ /** Deletes a channel `provision` created (rollback when the connector fails). */
92
+ discard: (channelId: string) => Promise<void>;
93
+ loading: boolean;
94
+ }
95
+ export declare function useProvisionChannel(): UseProvisionChannelResult;
96
+ export {};
@@ -0,0 +1,199 @@
1
+ import { useBotlit as e } from "../providers/BotlitProvider.js";
2
+ import { extractGraphqlFailureMessage as t } from "../utils/errors.js";
3
+ import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
4
+ import { gql as o } from "@apollo/client";
5
+ import { useGatewayClient as s } from "@burdenoff/fe-libs/shared/graphql";
6
+ // src/botlit/hooks/useChannelSetup.ts
7
+ var c = {
8
+ SLACK: {
9
+ platform: "SLACK",
10
+ authType: "BOT_TOKEN",
11
+ fields: [{
12
+ key: "botToken",
13
+ label: "Bot User OAuth Token",
14
+ description: "Slack app → OAuth & Permissions. Starts with xoxb-.",
15
+ placeholder: "xoxb-…",
16
+ secret: !0
17
+ }, {
18
+ key: "signingSecret",
19
+ label: "Signing Secret",
20
+ description: "Slack app → Basic Information → App Credentials.",
21
+ placeholder: "Signing secret",
22
+ secret: !0
23
+ }],
24
+ inboundHint: "In your Slack app, open Event Subscriptions, turn events on and paste this as the Request URL. Subscribe the bot to message.channels, message.im and app_mention, then reinstall the app."
25
+ },
26
+ WEBHOOK: {
27
+ platform: "WEBHOOK",
28
+ authType: "WEBHOOK",
29
+ fields: [{
30
+ key: "targetUrl",
31
+ label: "Reply URL",
32
+ description: "The bot POSTs its replies to this https URL.",
33
+ placeholder: "https://example.com/bot-replies",
34
+ secret: !1,
35
+ url: !0
36
+ }, {
37
+ key: "webhookSecret",
38
+ label: "Signing Secret",
39
+ description: "Your sender signs each request body with HMAC-SHA256 using this secret and sends the hex digest in the X-Signature header.",
40
+ placeholder: "Generate or paste a secret",
41
+ secret: !0,
42
+ generatable: !0
43
+ }],
44
+ inboundHint: "POST each inbound message here as JSON ({\"event\":\"message\",\"id\",\"sender_id\",\"text\",\"conversation_id\"}), signed with the signing secret in the X-Signature header."
45
+ }
46
+ }, l = {
47
+ SLACK: "SLACK",
48
+ TEAMS: "TEAMS",
49
+ DISCORD: "DISCORD",
50
+ WHATSAPP: "WHATSAPP",
51
+ WEBHOOK: "WEBHOOK"
52
+ };
53
+ function u(e) {
54
+ return l[e];
55
+ }
56
+ function d() {
57
+ let e = /* @__PURE__ */ new Uint8Array(32);
58
+ return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
59
+ }
60
+ function f(e, t) {
61
+ for (let n of e.fields) {
62
+ let e = t[n.key]?.trim() ?? "";
63
+ if (!e) return `${n.label} is required`;
64
+ if (n.url) {
65
+ let t;
66
+ try {
67
+ t = new URL(e);
68
+ } catch {
69
+ return `${n.label} must be a valid URL`;
70
+ }
71
+ if (t.protocol !== "https:") return `${n.label} must use https`;
72
+ }
73
+ }
74
+ return null;
75
+ }
76
+ function p() {
77
+ return e().organizationId || null;
78
+ }
79
+ var m = o`
80
+ query BotmanorInboundChannel($id: ID!) {
81
+ getChannel(id: $id) {
82
+ id
83
+ name
84
+ platform
85
+ status
86
+ isConnected
87
+ inboundWorkspaceId
88
+ inboundWebhookUrl
89
+ }
90
+ }
91
+ `, h = o`
92
+ mutation BotmanorCreateSetupChannel($input: CreateChannelInput!) {
93
+ createChannel(input: $input) {
94
+ id
95
+ }
96
+ }
97
+ `, g = o`
98
+ mutation BotmanorCreateSetupConnection($input: CreateConnectionInput!) {
99
+ createConnection(input: $input) {
100
+ id
101
+ }
102
+ }
103
+ `, _ = o`
104
+ mutation BotmanorDeleteSetupChannel($id: ID!) {
105
+ deleteChannel(id: $id)
106
+ }
107
+ `;
108
+ function v(e, n) {
109
+ let r = t(e);
110
+ return r ? Error(r, { cause: e }) : e instanceof Error ? e : Error(n, { cause: e });
111
+ }
112
+ function y(e, t) {
113
+ let n = e.error;
114
+ if (n != null) throw v(n, t);
115
+ }
116
+ function b() {
117
+ return s("global");
118
+ }
119
+ function x(e) {
120
+ let t = b(), [o, s] = a(null), [c, l] = a(!1), [u, d] = a(void 0), f = i(0), p = n(async () => {
121
+ let n = ++f.current, r = () => n === f.current;
122
+ if (s(null), d(void 0), e) {
123
+ l(!0);
124
+ try {
125
+ let n = await t.query({
126
+ query: m,
127
+ variables: { id: e },
128
+ fetchPolicy: "network-only"
129
+ });
130
+ y(n, "Failed to load the channel"), r() && s(n.data?.getChannel ?? null);
131
+ } catch (e) {
132
+ r() && d(v(e, "Failed to load the channel"));
133
+ } finally {
134
+ r() && l(!1);
135
+ }
136
+ }
137
+ }, [e, t]);
138
+ return r(() => {
139
+ p();
140
+ }, [p]), {
141
+ data: o,
142
+ loading: c,
143
+ error: u,
144
+ refetch: p
145
+ };
146
+ }
147
+ function S() {
148
+ let e = b(), [t, r] = a(!1), i = n(async (t) => {
149
+ y(await e.mutate({
150
+ mutation: _,
151
+ variables: { id: t }
152
+ }), "Failed to delete the channel");
153
+ }, [e]);
154
+ return {
155
+ provision: n(async ({ name: t, description: n, organizationId: a, definition: o, credentials: s }) => {
156
+ r(!0);
157
+ try {
158
+ let r;
159
+ try {
160
+ let i = await e.mutate({
161
+ mutation: h,
162
+ variables: { input: {
163
+ name: t,
164
+ description: n || void 0,
165
+ platform: o.platform,
166
+ channelType: "COMMUNICATION",
167
+ organizationId: a
168
+ } }
169
+ });
170
+ y(i, "Failed to create the channel"), r = i.data?.createChannel?.id;
171
+ } catch (e) {
172
+ throw v(e, "Failed to create the channel");
173
+ }
174
+ if (!r) throw Error("Failed to create the channel");
175
+ let c = Object.fromEntries(o.fields.map((e) => [e.key, s[e.key]?.trim() ?? ""]));
176
+ try {
177
+ y(await e.mutate({
178
+ mutation: g,
179
+ variables: { input: {
180
+ channelId: r,
181
+ authType: o.authType,
182
+ credentials: c
183
+ } }
184
+ }), "Failed to save the channel credentials");
185
+ } catch (e) {
186
+ throw await i(r).catch(() => void 0), v(e, "Failed to save the channel credentials");
187
+ }
188
+ return r;
189
+ } finally {
190
+ r(!1);
191
+ }
192
+ }, [e, i]),
193
+ discard: i,
194
+ loading: t
195
+ };
196
+ }
197
+ export { c as PLATFORM_CREDENTIALS, u as connectorPlatform, d as generateSigningSecret, p as useActiveOrganizationId, x as useInboundChannel, S as useProvisionChannel, f as validateCredentials };
198
+
199
+ //# sourceMappingURL=useChannelSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChannelSetup.js","names":["PLATFORM_CREDENTIALS","CONNECTOR_PLATFORM","connectorPlatform","connectorType","generateSigningSecret","bytes","byte","validateCredentials","field","definition","value","values","parsed","useActiveOrganizationId","useBotlit","GetInboundChannelDocument","CreateSetupChannelDocument","CreateSetupConnectionDocument","DeleteSetupChannelDocument","toError","message","extractGraphqlFailureMessage","cause","fallback","throwIfOperationFailed","operationError","result","useGlobalClient","useGatewayClient","useInboundChannel","client","data","setData","useState","loading","setLoading","error","setError","latestRequest","useRef","refetch","useCallback","request","isLatest","channelId","useEffect","useProvisionChannel","discard","created","description","trimmed","credentials"],"sources":["../../../src/botlit/hooks/useChannelSetup.ts"],"sourcesContent":["/**\n * Channel setup hooks (BOFF-15360)\n * @module botlit/hooks\n *\n * A BotManor channel connector names a channel on global-channel-svc through\n * `credentialsRefId`. That global channel holds the platform credentials (a\n * Slack bot token and signing secret, a webhook's signing secret and reply\n * URL, …) and publishes the public URL the platform must call with inbound\n * events (`Channel.inboundWebhookUrl`, set once an ACTIVE connector binds the\n * channel to this workspace).\n *\n * These hooks let the connector form create that channel with its credentials\n * and the detail page show its inbound URL, all through the shell's global\n * gateway client. The documents are written inline, like `GetChannels` in\n * `useUserPlatformConnection`: `inboundWebhookUrl` / `inboundWorkspaceId` are\n * newer than the checked-in `graphql/global.graphql`, which cannot be\n * re-pulled while gateway introspection is disabled.\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { gql, type ApolloClient } from '@apollo/client';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { extractGraphqlFailureMessage } from '../utils/errors';\n\n// ============================================================================\n// Platform credential definitions\n// ============================================================================\n\n/** Global-channel platforms a connector type delivers through. */\nexport type ChannelSetupPlatform = 'SLACK' | 'TEAMS' | 'DISCORD' | 'WHATSAPP' | 'WEBHOOK';\n\n/** `ChannelAuthType` values the setup form sends. */\ntype ChannelSetupAuthType = 'BOT_TOKEN' | 'WEBHOOK';\n\nexport interface CredentialFieldDefinition {\n /** Key stored on the channel connection's credentials. */\n key: string;\n label: string;\n description: string;\n placeholder: string;\n /** Rendered as a password input and never shown again after saving. */\n secret: boolean;\n /** Offer a \"Generate\" button producing a random 64-hex-character secret. */\n generatable?: boolean;\n /** Must be an absolute https URL. */\n url?: boolean;\n}\n\nexport interface PlatformCredentialDefinition {\n platform: ChannelSetupPlatform;\n authType: ChannelSetupAuthType;\n fields: CredentialFieldDefinition[];\n /** Where to paste the inbound webhook URL on the platform side. */\n inboundHint: string;\n}\n\n/**\n * Connector types whose credentials the form can collect directly. The keys\n * are the ones global-channel-svc reads: Slack sends with `botToken` and\n * verifies inbound requests with `signingSecret`; a generic webhook verifies\n * with `webhookSecret` (HMAC-SHA256 hex in `X-Signature`) and POSTs replies\n * to `targetUrl`.\n */\nexport const PLATFORM_CREDENTIALS: Readonly<Record<string, PlatformCredentialDefinition>> = {\n SLACK: {\n platform: 'SLACK',\n authType: 'BOT_TOKEN',\n fields: [\n {\n key: 'botToken',\n label: 'Bot User OAuth Token',\n description: 'Slack app → OAuth & Permissions. Starts with xoxb-.',\n placeholder: 'xoxb-…',\n secret: true,\n },\n {\n key: 'signingSecret',\n label: 'Signing Secret',\n description: 'Slack app → Basic Information → App Credentials.',\n placeholder: 'Signing secret',\n secret: true,\n },\n ],\n inboundHint:\n 'In your Slack app, open Event Subscriptions, turn events on and paste this as the Request URL. Subscribe the bot to message.channels, message.im and app_mention, then reinstall the app.',\n },\n WEBHOOK: {\n platform: 'WEBHOOK',\n authType: 'WEBHOOK',\n fields: [\n {\n key: 'targetUrl',\n label: 'Reply URL',\n description: 'The bot POSTs its replies to this https URL.',\n placeholder: 'https://example.com/bot-replies',\n secret: false,\n url: true,\n },\n {\n key: 'webhookSecret',\n label: 'Signing Secret',\n description:\n 'Your sender signs each request body with HMAC-SHA256 using this secret and sends the hex digest in the X-Signature header.',\n placeholder: 'Generate or paste a secret',\n secret: true,\n generatable: true,\n },\n ],\n inboundHint:\n 'POST each inbound message here as JSON ({\"event\":\"message\",\"id\",\"sender_id\",\"text\",\"conversation_id\"}), signed with the signing secret in the X-Signature header.',\n },\n};\n\n/** Connector type → the global-channel platform it uses (none for widget/custom). */\nconst CONNECTOR_PLATFORM: Readonly<Record<string, ChannelSetupPlatform>> = {\n SLACK: 'SLACK',\n TEAMS: 'TEAMS',\n DISCORD: 'DISCORD',\n WHATSAPP: 'WHATSAPP',\n WEBHOOK: 'WEBHOOK',\n};\n\nexport function connectorPlatform(connectorType: string): ChannelSetupPlatform | undefined {\n return CONNECTOR_PLATFORM[connectorType];\n}\n\n/** A random 32-byte secret, hex encoded, from the browser's CSPRNG. */\nexport function generateSigningSecret(): string {\n const bytes = new Uint8Array(32);\n crypto.getRandomValues(bytes);\n return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');\n}\n\n/**\n * Returns the first problem with the entered credentials, or null when they\n * are complete. Every field is required.\n */\nexport function validateCredentials(\n definition: PlatformCredentialDefinition,\n values: Record<string, string>\n): string | null {\n for (const field of definition.fields) {\n const value = values[field.key]?.trim() ?? '';\n if (!value) return `${field.label} is required`;\n if (field.url) {\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n return `${field.label} must be a valid URL`;\n }\n if (parsed.protocol !== 'https:') return `${field.label} must use https`;\n }\n }\n return null;\n}\n\n// ============================================================================\n// Organization\n// ============================================================================\n\n/**\n * The shell's active organization (the host passes it with the workspace).\n * Global channels belong to an organization, so creating one needs it.\n */\nexport function useActiveOrganizationId(): string | null {\n return useBotlit().organizationId || null;\n}\n\n// ============================================================================\n// Documents\n// ============================================================================\n\nconst GetInboundChannelDocument = gql`\n query BotmanorInboundChannel($id: ID!) {\n getChannel(id: $id) {\n id\n name\n platform\n status\n isConnected\n inboundWorkspaceId\n inboundWebhookUrl\n }\n }\n`;\n\nconst CreateSetupChannelDocument = gql`\n mutation BotmanorCreateSetupChannel($input: CreateChannelInput!) {\n createChannel(input: $input) {\n id\n }\n }\n`;\n\nconst CreateSetupConnectionDocument = gql`\n mutation BotmanorCreateSetupConnection($input: CreateConnectionInput!) {\n createConnection(input: $input) {\n id\n }\n }\n`;\n\nconst DeleteSetupChannelDocument = gql`\n mutation BotmanorDeleteSetupChannel($id: ID!) {\n deleteChannel(id: $id)\n }\n`;\n\nexport interface InboundChannelData {\n id: string;\n name: string;\n platform: string;\n status: string;\n isConnected: boolean;\n inboundWorkspaceId: string | null;\n inboundWebhookUrl: string | null;\n}\n\nfunction toError(cause: unknown, fallback: string): Error {\n const message = extractGraphqlFailureMessage(cause);\n if (message) return new Error(message, { cause });\n return cause instanceof Error ? cause : new Error(fallback, { cause });\n}\n\n/**\n * Apollo v4 resolves (rather than rejects) with `error` set when the server\n * answers with GraphQL errors; surface those as a failure like a rejection.\n */\nfunction throwIfOperationFailed(result: unknown, fallback: string): void {\n const operationError = (result as { error?: unknown }).error;\n if (operationError != null) throw toError(operationError, fallback);\n}\n\nfunction useGlobalClient(): ApolloClient {\n return useGatewayClient('global');\n}\n\n// ============================================================================\n// Hook: useInboundChannel\n// ============================================================================\n\ninterface UseInboundChannelResult {\n data: InboundChannelData | null;\n loading: boolean;\n error: Error | undefined;\n refetch: () => Promise<void>;\n}\n\n/** The global channel a connector names, with its inbound webhook URL. */\nexport function useInboundChannel(channelId: string | null | undefined): UseInboundChannelResult {\n const client = useGlobalClient();\n const [data, setData] = useState<InboundChannelData | null>(null);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | undefined>(undefined);\n /** Only the latest request may set state: a slower answer for a previous channel is dropped. */\n const latestRequest = useRef(0);\n\n const refetch = useCallback(async () => {\n const request = ++latestRequest.current;\n const isLatest = () => request === latestRequest.current;\n setData(null);\n setError(undefined);\n if (!channelId) return;\n setLoading(true);\n try {\n const result = await client.query<{ getChannel: InboundChannelData | null }>({\n query: GetInboundChannelDocument,\n variables: { id: channelId },\n fetchPolicy: 'network-only',\n });\n throwIfOperationFailed(result, 'Failed to load the channel');\n if (isLatest()) setData(result.data?.getChannel ?? null);\n } catch (cause) {\n if (isLatest()) setError(toError(cause, 'Failed to load the channel'));\n } finally {\n if (isLatest()) setLoading(false);\n }\n }, [channelId, client]);\n\n useEffect(() => {\n void refetch();\n }, [refetch]);\n\n return { data, loading, error, refetch };\n}\n\n// ============================================================================\n// Hook: useProvisionChannel\n// ============================================================================\n\nexport interface ProvisionChannelInput {\n name: string;\n description?: string;\n organizationId: string;\n definition: PlatformCredentialDefinition;\n credentials: Record<string, string>;\n}\n\ninterface UseProvisionChannelResult {\n /** Creates the global channel and its connection; resolves to the channel id. */\n provision: (input: ProvisionChannelInput) => Promise<string>;\n /** Deletes a channel `provision` created (rollback when the connector fails). */\n discard: (channelId: string) => Promise<void>;\n loading: boolean;\n}\n\nexport function useProvisionChannel(): UseProvisionChannelResult {\n const client = useGlobalClient();\n const [loading, setLoading] = useState(false);\n\n const discard = useCallback(\n async (channelId: string) => {\n const result = await client.mutate({\n mutation: DeleteSetupChannelDocument,\n variables: { id: channelId },\n });\n throwIfOperationFailed(result, 'Failed to delete the channel');\n },\n [client]\n );\n\n const provision = useCallback(\n async ({\n name,\n description,\n organizationId,\n definition,\n credentials,\n }: ProvisionChannelInput): Promise<string> => {\n setLoading(true);\n try {\n let channelId: string | undefined;\n try {\n const created = await client.mutate<{ createChannel: { id: string } | null }>({\n mutation: CreateSetupChannelDocument,\n variables: {\n input: {\n name,\n description: description || undefined,\n platform: definition.platform,\n channelType: 'COMMUNICATION',\n organizationId,\n },\n },\n });\n throwIfOperationFailed(created, 'Failed to create the channel');\n channelId = created.data?.createChannel?.id;\n } catch (cause) {\n throw toError(cause, 'Failed to create the channel');\n }\n if (!channelId) throw new Error('Failed to create the channel');\n\n const trimmed = Object.fromEntries(\n definition.fields.map((field) => [field.key, credentials[field.key]?.trim() ?? ''])\n );\n try {\n const connected = await client.mutate({\n mutation: CreateSetupConnectionDocument,\n variables: {\n input: { channelId, authType: definition.authType, credentials: trimmed },\n },\n });\n throwIfOperationFailed(connected, 'Failed to save the channel credentials');\n } catch (cause) {\n // A channel without its credentials can never deliver: remove it so\n // a retry starts clean instead of leaving an orphan behind.\n await discard(channelId).catch(() => undefined);\n throw toError(cause, 'Failed to save the channel credentials');\n }\n return channelId;\n } finally {\n setLoading(false);\n }\n },\n [client, discard]\n );\n\n return { provision, discard, loading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AAC,YAAY,KAAA,CAAS,GACxCzB,EAAQG,GAAO,wCAAwC;IAC/D;IACA,OAAOsB;GACT,UAAU;IACR,EAAW,EAAK;GAClB;EACF,GACA,CAACd,GAAQiB,CAAO,CAGT;EAAW;EAAS;CAAQ;AACvC"}
@@ -75,6 +75,12 @@ export declare const channelKeys: {
75
75
  };
76
76
  export declare function useChannelConnectors(filter?: ChannelFilter): QueryResult<ChannelConnectorRecord[]>;
77
77
  export declare function useChannelConnector(connectorId: string | undefined): QueryResult<ChannelConnectorRecord | null>;
78
+ /**
79
+ * Looks up whether this workspace already has a connector naming a global
80
+ * channel. Resolves to the connector, null when there is none, and rejects
81
+ * when the lookup itself fails (the answer is then unknown).
82
+ */
83
+ export declare function useFindChannelConnector(): (channelId: string) => Promise<ChannelConnectorRecord | null>;
78
84
  export declare function useCreateChannelConnector(): readonly [(input: CreateChannelConnectorVariables) => Promise<ChannelConnectorRecord>, import('./internal/workspaceGateway').MutationState<ChannelConnectorRecord>];
79
85
  export declare function useUpdateChannelConnector(): readonly [(input: UpdateChannelConnectorVariables) => Promise<ChannelConnectorRecord>, import('./internal/workspaceGateway').MutationState<ChannelConnectorRecord>];
80
86
  export declare function useDeleteChannelConnector(): readonly [(input: string) => Promise<boolean>, import('./internal/workspaceGateway').MutationState<boolean>];