@pipeshub-ai/mcp 2.0.1 → 2.1.0

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 (80) hide show
  1. package/bin/mcp-server.js +685 -76
  2. package/bin/mcp-server.js.map +20 -13
  3. package/esm/funcs/agentsListAgents.d.ts +10 -0
  4. package/esm/funcs/agentsListAgents.d.ts.map +1 -0
  5. package/esm/funcs/agentsListAgents.js +83 -0
  6. package/esm/funcs/agentsListAgents.js.map +1 -0
  7. package/esm/funcs/agentsStreamConversation.d.ts +10 -0
  8. package/esm/funcs/agentsStreamConversation.d.ts.map +1 -0
  9. package/esm/funcs/agentsStreamConversation.js +83 -0
  10. package/esm/funcs/agentsStreamConversation.js.map +1 -0
  11. package/esm/funcs/agentsStreamMessage.d.ts +10 -0
  12. package/esm/funcs/agentsStreamMessage.d.ts.map +1 -0
  13. package/esm/funcs/agentsStreamMessage.js +86 -0
  14. package/esm/funcs/agentsStreamMessage.js.map +1 -0
  15. package/esm/funcs/conversationsStreamConversation.d.ts.map +1 -1
  16. package/esm/funcs/conversationsStreamConversation.js +1 -3
  17. package/esm/funcs/conversationsStreamConversation.js.map +1 -1
  18. package/esm/funcs/conversationsStreamMessage.d.ts.map +1 -1
  19. package/esm/funcs/conversationsStreamMessage.js +0 -7
  20. package/esm/funcs/conversationsStreamMessage.js.map +1 -1
  21. package/esm/mcp-server/instructions.d.ts +2 -0
  22. package/esm/mcp-server/instructions.d.ts.map +1 -0
  23. package/esm/mcp-server/instructions.js +83 -0
  24. package/esm/mcp-server/instructions.js.map +1 -0
  25. package/esm/mcp-server/prompts/pipeshubAssistant.d.ts +8 -0
  26. package/esm/mcp-server/prompts/pipeshubAssistant.d.ts.map +1 -0
  27. package/esm/mcp-server/prompts/pipeshubAssistant.js +31 -0
  28. package/esm/mcp-server/prompts/pipeshubAssistant.js.map +1 -0
  29. package/esm/mcp-server/server.d.ts.map +1 -1
  30. package/esm/mcp-server/server.js +7 -60
  31. package/esm/mcp-server/server.js.map +1 -1
  32. package/esm/mcp-server/tools/_helpers.d.ts +78 -0
  33. package/esm/mcp-server/tools/_helpers.d.ts.map +1 -1
  34. package/esm/mcp-server/tools/_helpers.js +155 -1
  35. package/esm/mcp-server/tools/_helpers.js.map +1 -1
  36. package/esm/mcp-server/tools/pipeshubAgents.d.ts +8 -0
  37. package/esm/mcp-server/tools/pipeshubAgents.d.ts.map +1 -0
  38. package/esm/mcp-server/tools/pipeshubAgents.js +62 -0
  39. package/esm/mcp-server/tools/pipeshubAgents.js.map +1 -0
  40. package/esm/mcp-server/tools/pipeshubChat.d.ts +6 -1
  41. package/esm/mcp-server/tools/pipeshubChat.d.ts.map +1 -1
  42. package/esm/mcp-server/tools/pipeshubChat.js +71 -21
  43. package/esm/mcp-server/tools/pipeshubChat.js.map +1 -1
  44. package/esm/mcp-server/tools/pipeshubDirectory.d.ts.map +1 -1
  45. package/esm/mcp-server/tools/pipeshubDirectory.js +0 -1
  46. package/esm/mcp-server/tools/pipeshubDirectory.js.map +1 -1
  47. package/esm/mcp-server/tools/pipeshubDownloadRecord.d.ts.map +1 -1
  48. package/esm/mcp-server/tools/pipeshubDownloadRecord.js +0 -3
  49. package/esm/mcp-server/tools/pipeshubDownloadRecord.js.map +1 -1
  50. package/esm/mcp-server/tools/pipeshubSearch.d.ts.map +1 -1
  51. package/esm/mcp-server/tools/pipeshubSearch.js +0 -3
  52. package/esm/mcp-server/tools/pipeshubSearch.js.map +1 -1
  53. package/esm/mcp-server/tools/pipeshubSources.d.ts.map +1 -1
  54. package/esm/mcp-server/tools/pipeshubSources.js +0 -4
  55. package/esm/mcp-server/tools/pipeshubSources.js.map +1 -1
  56. package/esm/models/agentops.d.ts +119 -0
  57. package/esm/models/agentops.d.ts.map +1 -0
  58. package/esm/models/agentops.js +97 -0
  59. package/esm/models/agentops.js.map +1 -0
  60. package/esm/tool-names.d.ts.map +1 -1
  61. package/esm/tool-names.js +4 -0
  62. package/esm/tool-names.js.map +1 -1
  63. package/package.json +2 -2
  64. package/src/funcs/agentsListAgents.ts +141 -0
  65. package/src/funcs/agentsStreamConversation.ts +144 -0
  66. package/src/funcs/agentsStreamMessage.ts +147 -0
  67. package/src/funcs/conversationsStreamConversation.ts +1 -3
  68. package/src/funcs/conversationsStreamMessage.ts +0 -8
  69. package/src/mcp-server/instructions.ts +83 -0
  70. package/src/mcp-server/prompts/pipeshubAssistant.ts +37 -0
  71. package/src/mcp-server/server.ts +8 -62
  72. package/src/mcp-server/tools/_helpers.ts +216 -1
  73. package/src/mcp-server/tools/pipeshubAgents.ts +68 -0
  74. package/src/mcp-server/tools/pipeshubChat.ts +70 -21
  75. package/src/mcp-server/tools/pipeshubDirectory.ts +0 -1
  76. package/src/mcp-server/tools/pipeshubDownloadRecord.ts +0 -4
  77. package/src/mcp-server/tools/pipeshubSearch.ts +0 -3
  78. package/src/mcp-server/tools/pipeshubSources.ts +0 -5
  79. package/src/models/agentops.ts +160 -0
  80. package/src/tool-names.ts +4 -0
package/bin/mcp-server.js CHANGED
@@ -50387,6 +50387,86 @@ var init_mcp = __esm(() => {
50387
50387
  };
50388
50388
  });
50389
50389
 
50390
+ // src/mcp-server/instructions.ts
50391
+ var PIPESHUB_INSTRUCTIONS = `# PipesHub MCP — instructions for the LLM
50392
+
50393
+ PipesHub is the user's workplace AI platform. It indexes their documents,
50394
+ knowledge base content, and connector sources (Drive, Box, Confluence,
50395
+ Slack, Jira, Gmail, ...). When in doubt, the answer is in PipesHub.
50396
+
50397
+ ## Default tool: \`pipeshub_chat\`
50398
+
50399
+ **Use \`pipeshub_chat\` for any question that could plausibly be answered
50400
+ by the user's PipesHub-indexed data.** That includes:
50401
+
50402
+ - Anything about a specific document, file, report, ticket, message, or
50403
+ page (e.g. "what's in the Q4 sales report?", "summarize the langchain
50404
+ doc", "what did Aashil say about onboarding?").
50405
+ - Anything about company / org policies, processes, decisions, or
50406
+ history (e.g. "what's our vacation policy?", "who owns the auth
50407
+ service?").
50408
+ - Anything explicitly mentioning PipesHub itself, or its sources
50409
+ (Drive / Box / Confluence / Slack / Gmail / Jira / etc.) when the
50410
+ user has those connected.
50411
+ - Open-ended "what do we know about X" questions where the answer
50412
+ likely lives in the org's documents.
50413
+
50414
+ Do NOT answer those from your own knowledge — \`pipeshub_chat\` grounds
50415
+ the answer in the user's actual indexed content and returns citations
50416
+ the user can verify.
50417
+
50418
+ ## When to use the other tools
50419
+
50420
+ - \`pipeshub_search\` — only when the user asks specifically to **find /
50421
+ locate** a document by name or topic (so you can hand them a list, or
50422
+ resolve a filename to a \`recordId\` for download). For "what does
50423
+ the doc say?" use \`pipeshub_chat\` instead — it does the retrieval
50424
+ internally.
50425
+ - \`pipeshub_download_record\` — when the user wants the actual file
50426
+ bytes (download, attach, open). Get the \`recordId\` either from
50427
+ citations on a prior \`pipeshub_chat\` response or from
50428
+ \`pipeshub_search\`.
50429
+ - \`pipeshub_directory\` — people, groups, teams, and \`whoami\` lookups.
50430
+ Not for documents.
50431
+ - \`pipeshub_sources\` — call once at the start of a session to discover
50432
+ which connectors / KB / models are available, then cache the result.
50433
+ - \`pipeshub_agents\` — list the org's configured **agents** (specialized
50434
+ assistants with their own prompt, tools, and knowledge scope).
50435
+
50436
+ ## Agents
50437
+
50438
+ Some orgs configure **agents** for specific jobs (e.g. a Slack messenger, a
50439
+ Jira ticket creator, a Salesforce CRM updater). To run a turn against an
50440
+ agent, call \`pipeshub_chat\` with its \`agentId\` (from \`pipeshub_agents\`)
50441
+ — optionally with an agent \`chatMode\` (\`auto\` by default, or \`quick\` /
50442
+ \`verification\` / \`deep\`). Keep passing the same \`agentId\` plus the
50443
+ returned \`conversationId\` on follow-up turns.
50444
+
50445
+ **When to route to an agent vs plain chat:**
50446
+ - The user names a system/action that maps to an agent (e.g. "post to
50447
+ Slack", "create a Jira ticket", "update the Salesforce deal") → call
50448
+ \`pipeshub_agents\`, pick the matching agent, and use it.
50449
+ - Plain question about the org's knowledge or the public web → just use
50450
+ \`pipeshub_chat\` (no \`agentId\`) with \`internal_search\` or \`web_search\`.
50451
+
50452
+ **If you are unsure which agent or route fits the request**, call
50453
+ \`pipeshub_agents\` FIRST and read the returned names/descriptions, then
50454
+ either pick the best match or present the list to the user and let them
50455
+ choose. Do NOT guess an agent blindly, and do NOT refuse — list the agents
50456
+ and decide from real data. The list may be empty (no agents configured),
50457
+ in which case fall back to plain \`pipeshub_chat\`.
50458
+
50459
+ ## Conversation lifecycle
50460
+
50461
+ \`pipeshub_chat\` is a single tool that handles both starting and
50462
+ continuing conversations (plain or with an \`agentId\`). On the first turn
50463
+ omit \`conversationId\`; on every subsequent turn pass back the
50464
+ \`conversationId\` returned by the previous call (along with the same
50465
+ \`agentId\` if you used one). Server-side context is preserved — do NOT
50466
+ replay prior messages. Only start a fresh conversation when the user
50467
+ explicitly asks to clear context.
50468
+ `;
50469
+
50390
50470
  // src/hooks/registration.ts
50391
50471
  function initHooks(hooks) {}
50392
50472
 
@@ -52460,6 +52540,326 @@ var init_conversationsStreamMessage = __esm(() => {
52460
52540
  init_async();
52461
52541
  });
52462
52542
 
52543
+ // src/models/agentops.ts
52544
+ var ListAgentsRequest$zodSchema, AgentStreamConversationBody$zodSchema, AgentStreamCreateConversationRequest$zodSchema, AgentAddMessageStreamRequest$zodSchema, AgentWebSearch$zodSchema, AgentToolsetTool$zodSchema, AgentToolset$zodSchema, AgentKnowledge$zodSchema, AgentSummary$zodSchema, AgentListPagination$zodSchema, AgentListEnvelope$zodSchema;
52545
+ var init_agentops = __esm(() => {
52546
+ init_zod();
52547
+ init_filters();
52548
+ ListAgentsRequest$zodSchema = object({
52549
+ page: int().optional(),
52550
+ limit: int().optional(),
52551
+ search: string2().optional(),
52552
+ sortBy: string2().optional(),
52553
+ sortOrder: _enum(["asc", "desc"]).optional()
52554
+ });
52555
+ AgentStreamConversationBody$zodSchema = object({
52556
+ query: string2().min(1),
52557
+ recordIds: array(string2()).optional(),
52558
+ filters: Filters$zodSchema.optional(),
52559
+ chatMode: string2().optional(),
52560
+ modelKey: string2().optional(),
52561
+ modelName: string2().optional(),
52562
+ modelFriendlyName: string2().optional(),
52563
+ tools: array(string2()).optional(),
52564
+ timezone: string2().optional(),
52565
+ currentTime: string2().optional()
52566
+ });
52567
+ AgentStreamCreateConversationRequest$zodSchema = object({
52568
+ agentKey: string2().min(1),
52569
+ body: AgentStreamConversationBody$zodSchema
52570
+ });
52571
+ AgentAddMessageStreamRequest$zodSchema = object({
52572
+ agentKey: string2().min(1),
52573
+ conversationId: string2(),
52574
+ body: AgentStreamConversationBody$zodSchema
52575
+ });
52576
+ AgentWebSearch$zodSchema = object({
52577
+ provider: string2().optional(),
52578
+ providerKey: string2().optional(),
52579
+ providerLabel: string2().optional()
52580
+ });
52581
+ AgentToolsetTool$zodSchema = object({
52582
+ name: string2().nullish(),
52583
+ fullName: string2().nullish()
52584
+ });
52585
+ AgentToolset$zodSchema = object({
52586
+ name: string2().nullish(),
52587
+ displayName: string2().nullish(),
52588
+ instanceName: string2().nullish(),
52589
+ tools: array(AgentToolsetTool$zodSchema).default([])
52590
+ });
52591
+ AgentKnowledge$zodSchema = object({
52592
+ name: string2().nullish(),
52593
+ displayName: string2().nullish(),
52594
+ type: string2().nullish()
52595
+ });
52596
+ AgentSummary$zodSchema = object({
52597
+ _key: string2(),
52598
+ name: string2(),
52599
+ description: string2().nullish(),
52600
+ systemPrompt: string2().nullish(),
52601
+ startMessage: string2().nullish(),
52602
+ tags: array(string2()).default([]),
52603
+ webSearch: AgentWebSearch$zodSchema.nullish(),
52604
+ isActive: boolean2().nullish(),
52605
+ toolsets: array(AgentToolset$zodSchema).default([]),
52606
+ knowledge: array(AgentKnowledge$zodSchema).default([])
52607
+ });
52608
+ AgentListPagination$zodSchema = object({
52609
+ totalItems: number2().nullish(),
52610
+ total: number2().nullish(),
52611
+ hasNext: boolean2().nullish(),
52612
+ hasNextPage: boolean2().nullish()
52613
+ });
52614
+ AgentListEnvelope$zodSchema = object({
52615
+ success: boolean2().nullish(),
52616
+ agents: array(AgentSummary$zodSchema).default([]),
52617
+ pagination: AgentListPagination$zodSchema.nullish()
52618
+ });
52619
+ });
52620
+
52621
+ // src/funcs/agentsStreamConversation.ts
52622
+ function agentsStreamConversation(client$, request, options) {
52623
+ return new APIPromise($do3(client$, request, options));
52624
+ }
52625
+ async function $do3(client$, request, options) {
52626
+ const parsed$ = safeParse4(request, (value$) => AgentStreamCreateConversationRequest$zodSchema.parse(value$), "Input validation failed");
52627
+ if (!parsed$.ok) {
52628
+ return [parsed$, { status: "invalid" }];
52629
+ }
52630
+ const payload$ = parsed$.value;
52631
+ const body$ = encodeJSON("body", payload$.body, { explode: true });
52632
+ const pathParams$ = {
52633
+ agentKey: encodeSimple("agentKey", payload$.agentKey, {
52634
+ explode: false,
52635
+ charEncoding: "percent"
52636
+ })
52637
+ };
52638
+ const path$ = pathToFunc("/agents/{agentKey}/conversations/stream")(pathParams$);
52639
+ const headers$ = new Headers(compactMap({
52640
+ "Content-Type": "application/json",
52641
+ Accept: "text/event-stream"
52642
+ }));
52643
+ const securityInput = await extractSecurity(client$._options.security);
52644
+ const requestSecurity = resolveGlobalSecurity(securityInput);
52645
+ const context = {
52646
+ options: client$._options,
52647
+ baseURL: options?.serverURL ?? client$._baseURL ?? "",
52648
+ operationID: "streamAgentConversation",
52649
+ oAuth2Scopes: ["agent:execute"],
52650
+ resolvedSecurity: requestSecurity,
52651
+ securitySource: client$._options.security,
52652
+ retryConfig: options?.retries || client$._options.retryConfig || { strategy: "none" },
52653
+ retryCodes: options?.retryCodes || [
52654
+ "429",
52655
+ "500",
52656
+ "502",
52657
+ "503",
52658
+ "504"
52659
+ ]
52660
+ };
52661
+ const requestRes = client$._createRequest(context, {
52662
+ security: requestSecurity,
52663
+ method: "POST",
52664
+ baseURL: options?.serverURL,
52665
+ path: path$,
52666
+ headers: headers$,
52667
+ body: body$,
52668
+ userAgent: client$._options.userAgent,
52669
+ timeoutMs: options?.timeoutMs || -1
52670
+ }, options);
52671
+ if (!requestRes.ok) {
52672
+ return [requestRes, { status: "invalid" }];
52673
+ }
52674
+ const req$ = requestRes.value;
52675
+ const doResult = await client$._do(req$, {
52676
+ context,
52677
+ errorCodes: [],
52678
+ retryConfig: context.retryConfig,
52679
+ retryCodes: context.retryCodes
52680
+ });
52681
+ if (!doResult.ok) {
52682
+ return [doResult, { status: "request-error", request: req$ }];
52683
+ }
52684
+ return [doResult, {
52685
+ status: "complete",
52686
+ request: req$,
52687
+ response: doResult.value
52688
+ }];
52689
+ }
52690
+ var init_agentsStreamConversation = __esm(() => {
52691
+ init_encodings();
52692
+ init_primitives();
52693
+ init_schemas4();
52694
+ init_security2();
52695
+ init_url();
52696
+ init_agentops();
52697
+ init_async();
52698
+ });
52699
+
52700
+ // src/funcs/agentsStreamMessage.ts
52701
+ function agentsStreamMessage(client$, request, options) {
52702
+ return new APIPromise($do4(client$, request, options));
52703
+ }
52704
+ async function $do4(client$, request, options) {
52705
+ const parsed$ = safeParse4(request, (value$) => AgentAddMessageStreamRequest$zodSchema.parse(value$), "Input validation failed");
52706
+ if (!parsed$.ok) {
52707
+ return [parsed$, { status: "invalid" }];
52708
+ }
52709
+ const payload$ = parsed$.value;
52710
+ const body$ = encodeJSON("body", payload$.body, { explode: true });
52711
+ const pathParams$ = {
52712
+ agentKey: encodeSimple("agentKey", payload$.agentKey, {
52713
+ explode: false,
52714
+ charEncoding: "percent"
52715
+ }),
52716
+ conversationId: encodeSimple("conversationId", payload$.conversationId, {
52717
+ explode: false,
52718
+ charEncoding: "percent"
52719
+ })
52720
+ };
52721
+ const path$ = pathToFunc("/agents/{agentKey}/conversations/{conversationId}/messages/stream")(pathParams$);
52722
+ const headers$ = new Headers(compactMap({
52723
+ "Content-Type": "application/json",
52724
+ Accept: "text/event-stream"
52725
+ }));
52726
+ const securityInput = await extractSecurity(client$._options.security);
52727
+ const requestSecurity = resolveGlobalSecurity(securityInput);
52728
+ const context = {
52729
+ options: client$._options,
52730
+ baseURL: options?.serverURL ?? client$._baseURL ?? "",
52731
+ operationID: "streamAgentConversationMessage",
52732
+ oAuth2Scopes: ["agent:execute"],
52733
+ resolvedSecurity: requestSecurity,
52734
+ securitySource: client$._options.security,
52735
+ retryConfig: options?.retries || client$._options.retryConfig || { strategy: "none" },
52736
+ retryCodes: options?.retryCodes || [
52737
+ "429",
52738
+ "500",
52739
+ "502",
52740
+ "503",
52741
+ "504"
52742
+ ]
52743
+ };
52744
+ const requestRes = client$._createRequest(context, {
52745
+ security: requestSecurity,
52746
+ method: "POST",
52747
+ baseURL: options?.serverURL,
52748
+ path: path$,
52749
+ headers: headers$,
52750
+ body: body$,
52751
+ userAgent: client$._options.userAgent,
52752
+ timeoutMs: options?.timeoutMs || -1
52753
+ }, options);
52754
+ if (!requestRes.ok) {
52755
+ return [requestRes, { status: "invalid" }];
52756
+ }
52757
+ const req$ = requestRes.value;
52758
+ const doResult = await client$._do(req$, {
52759
+ context,
52760
+ errorCodes: [],
52761
+ retryConfig: context.retryConfig,
52762
+ retryCodes: context.retryCodes
52763
+ });
52764
+ if (!doResult.ok) {
52765
+ return [doResult, { status: "request-error", request: req$ }];
52766
+ }
52767
+ return [doResult, {
52768
+ status: "complete",
52769
+ request: req$,
52770
+ response: doResult.value
52771
+ }];
52772
+ }
52773
+ var init_agentsStreamMessage = __esm(() => {
52774
+ init_encodings();
52775
+ init_primitives();
52776
+ init_schemas4();
52777
+ init_security2();
52778
+ init_url();
52779
+ init_agentops();
52780
+ init_async();
52781
+ });
52782
+
52783
+ // src/funcs/agentsListAgents.ts
52784
+ function agentsListAgents(client$, request, options) {
52785
+ return new APIPromise($do5(client$, request, options));
52786
+ }
52787
+ async function $do5(client$, request, options) {
52788
+ const parsed$ = safeParse4(request, (value$) => ListAgentsRequest$zodSchema.optional().parse(value$), "Input validation failed");
52789
+ if (!parsed$.ok) {
52790
+ return [parsed$, { status: "invalid" }];
52791
+ }
52792
+ const payload$ = parsed$.value;
52793
+ const body$ = null;
52794
+ const path$ = pathToFunc("/agents")();
52795
+ const query$ = encodeFormQuery({
52796
+ page: payload$?.page,
52797
+ limit: payload$?.limit,
52798
+ search: payload$?.search,
52799
+ sort_by: payload$?.sortBy,
52800
+ sort_order: payload$?.sortOrder
52801
+ });
52802
+ const headers$ = new Headers(compactMap({
52803
+ Accept: "application/json"
52804
+ }));
52805
+ const securityInput = await extractSecurity(client$._options.security);
52806
+ const requestSecurity = resolveGlobalSecurity(securityInput);
52807
+ const context = {
52808
+ options: client$._options,
52809
+ baseURL: options?.serverURL ?? client$._baseURL ?? "",
52810
+ operationID: "listAgents",
52811
+ oAuth2Scopes: ["agent:read"],
52812
+ resolvedSecurity: requestSecurity,
52813
+ securitySource: client$._options.security,
52814
+ retryConfig: options?.retries || client$._options.retryConfig || { strategy: "none" },
52815
+ retryCodes: options?.retryCodes || [
52816
+ "429",
52817
+ "500",
52818
+ "502",
52819
+ "503",
52820
+ "504"
52821
+ ]
52822
+ };
52823
+ const requestRes = client$._createRequest(context, {
52824
+ security: requestSecurity,
52825
+ method: "GET",
52826
+ baseURL: options?.serverURL,
52827
+ path: path$,
52828
+ headers: headers$,
52829
+ query: query$,
52830
+ body: body$,
52831
+ userAgent: client$._options.userAgent,
52832
+ timeoutMs: options?.timeoutMs || client$._options.timeoutMs || -1
52833
+ }, options);
52834
+ if (!requestRes.ok) {
52835
+ return [requestRes, { status: "invalid" }];
52836
+ }
52837
+ const req$ = requestRes.value;
52838
+ const doResult = await client$._do(req$, {
52839
+ context,
52840
+ errorCodes: [],
52841
+ retryConfig: context.retryConfig,
52842
+ retryCodes: context.retryCodes
52843
+ });
52844
+ if (!doResult.ok) {
52845
+ return [doResult, { status: "request-error", request: req$ }];
52846
+ }
52847
+ return [doResult, {
52848
+ status: "complete",
52849
+ request: req$,
52850
+ response: doResult.value
52851
+ }];
52852
+ }
52853
+ var init_agentsListAgents = __esm(() => {
52854
+ init_encodings();
52855
+ init_primitives();
52856
+ init_schemas4();
52857
+ init_security2();
52858
+ init_url();
52859
+ init_agentops();
52860
+ init_async();
52861
+ });
52862
+
52463
52863
  // src/mcp-server/tools/_helpers.ts
52464
52864
  async function readJson(response) {
52465
52865
  const text = await response.text();
@@ -52501,6 +52901,52 @@ function errorResult(message) {
52501
52901
  isError: true
52502
52902
  };
52503
52903
  }
52904
+ async function httpErrorResult(response, context) {
52905
+ if (response.ok)
52906
+ return null;
52907
+ let body = "";
52908
+ try {
52909
+ body = await response.text();
52910
+ } catch {}
52911
+ let message = body;
52912
+ if (body) {
52913
+ try {
52914
+ const parsed = JSON.parse(body);
52915
+ const candidate = typeof parsed?.message === "string" && parsed.message || typeof parsed?.error === "string" && parsed.error || typeof parsed?.error?.message === "string" && parsed.error.message || typeof parsed?.detail === "string" && parsed.detail || "";
52916
+ message = candidate || body;
52917
+ } catch {}
52918
+ }
52919
+ const detail = message ? ` ${message.slice(0, 400)}` : "";
52920
+ const auth = response.status === 401 || response.status === 403 ? " Check that the bearer token / credentials are valid and not expired." : "";
52921
+ return errorResult(`${context} failed (HTTP ${response.status} ${response.statusText}).${detail}${auth}`);
52922
+ }
52923
+ async function readValidated(response, schema) {
52924
+ const text = await response.text();
52925
+ if (!text) {
52926
+ return { ok: false, result: errorResult("Empty response from server") };
52927
+ }
52928
+ let json;
52929
+ try {
52930
+ json = JSON.parse(text);
52931
+ } catch (e) {
52932
+ return {
52933
+ ok: false,
52934
+ result: errorResult(`Failed to parse response as JSON: ${e.message}` + `
52935
+
52936
+ Raw body:
52937
+ ${text.slice(0, 500)}`)
52938
+ };
52939
+ }
52940
+ const parsed = schema.safeParse(json);
52941
+ if (!parsed.success) {
52942
+ return {
52943
+ ok: false,
52944
+ result: errorResult(`Unexpected response shape:
52945
+ ${prettifyError(parsed.error)}`)
52946
+ };
52947
+ }
52948
+ return { ok: true, value: parsed.data };
52949
+ }
52504
52950
  async function resolveSecurity2(client) {
52505
52951
  const sec = client._options.security;
52506
52952
  if (typeof sec === "function") {
@@ -52639,6 +53085,63 @@ async function* iterateSSE(response) {
52639
53085
  } catch {}
52640
53086
  }
52641
53087
  }
53088
+ function trimAgent(a) {
53089
+ return {
53090
+ agentId: a._key,
53091
+ name: a.name,
53092
+ description: a.description ?? null,
53093
+ systemPrompt: a.systemPrompt ?? null,
53094
+ startMessage: a.startMessage ?? null,
53095
+ tags: a.tags,
53096
+ webSearch: !!a.webSearch,
53097
+ isActive: a.isActive,
53098
+ toolsets: a.toolsets.map((ts) => ({
53099
+ name: ts.name,
53100
+ tools: ts.tools.map((t) => t.fullName ?? t.name).filter((id) => typeof id === "string")
53101
+ })),
53102
+ knowledge: a.knowledge.map((k) => ({
53103
+ name: k.name ?? k.displayName,
53104
+ type: k.type
53105
+ }))
53106
+ };
53107
+ }
53108
+ async function listAllAgents(client, opts = {}) {
53109
+ const PAGE_SIZE = 200;
53110
+ const maxPages = opts.maxPages ?? 25;
53111
+ const reqOptions = opts.signal ? { fetchOptions: { signal: opts.signal } } : {};
53112
+ const all = [];
53113
+ let total = 0;
53114
+ for (let page = 1;page <= maxPages; page++) {
53115
+ const [r] = await agentsListAgents(client, {
53116
+ page,
53117
+ limit: PAGE_SIZE,
53118
+ search: opts.search
53119
+ }, reqOptions).$inspect();
53120
+ if (!r.ok)
53121
+ return { ok: false, result: errorResult(r.error.message) };
53122
+ const httpErr = await httpErrorResult(r.value, "Agent list request");
53123
+ if (httpErr)
53124
+ return { ok: false, result: httpErr };
53125
+ const parsed = await readValidated(r.value, AgentListEnvelope$zodSchema);
53126
+ if (!parsed.ok)
53127
+ return { ok: false, result: parsed.result };
53128
+ if (parsed.value.success === false) {
53129
+ return {
53130
+ ok: false,
53131
+ result: errorResult("Agent list request returned success: false")
53132
+ };
53133
+ }
53134
+ const agents = parsed.value.agents;
53135
+ all.push(...agents);
53136
+ const pg = parsed.value.pagination;
53137
+ total = pg?.totalItems ?? pg?.total ?? all.length;
53138
+ const hasNext = pg?.hasNext ?? pg?.hasNextPage ?? agents.length >= PAGE_SIZE;
53139
+ if (!hasNext || agents.length === 0) {
53140
+ return { ok: true, agents: all, total, truncated: false };
53141
+ }
53142
+ }
53143
+ return { ok: true, agents: all, total: total || all.length, truncated: true };
53144
+ }
52642
53145
  function trimSearchHit(hit) {
52643
53146
  const md = hit?.metadata ?? {};
52644
53147
  return {
@@ -52653,6 +53156,11 @@ function trimSearchHit(hit) {
52653
53156
  pageNum: md.pageNum
52654
53157
  };
52655
53158
  }
53159
+ var init__helpers = __esm(() => {
53160
+ init_zod();
53161
+ init_agentsListAgents();
53162
+ init_agentops();
53163
+ });
52656
53164
 
52657
53165
  // src/mcp-server/tools/pipeshubChat.ts
52658
53166
  var FiltersShape, args, tool$pipeshubChat;
@@ -52660,6 +53168,9 @@ var init_pipeshubChat = __esm(() => {
52660
53168
  init_zod();
52661
53169
  init_conversationsStreamConversation();
52662
53170
  init_conversationsStreamMessage();
53171
+ init_agentsStreamConversation();
53172
+ init_agentsStreamMessage();
53173
+ init__helpers();
52663
53174
  FiltersShape = object({
52664
53175
  apps: array(string2()).optional().describe("Source-scoping ids. Mix connector instance UUIDs with the synthetic " + "`knowledgeBase_<orgId>` id (use pipeshub_sources to discover them). " + "Empty / omitted means no app-side restriction."),
52665
53176
  kb: array(string2()).optional().describe("Legacy / unused. Leave empty.")
@@ -52671,7 +53182,16 @@ var init_pipeshubChat = __esm(() => {
52671
53182
  modelKey: string2().optional().describe("Model id to use (from `pipeshub_sources` `models[*].modelKey`). " + "Defaults to the org's default LLM."),
52672
53183
  modelName: string2().optional(),
52673
53184
  modelFriendlyName: string2().optional(),
52674
- chatMode: _enum(["web_search", "internal_search"]).optional().describe("Controls retrieval source. " + "`internal_search` (default) searches the org's indexed knowledge " + "bases (Drive, Confluence, Slack, Gmail, Jira, Box, etc.) and returns " + "citations. Use this for questions about internal docs, policies, or " + "company data. " + "`web_search` searches the public web instead of internal sources. " + "Use only when the user explicitly asks about current events, public " + "information, or anything not expected to be in the org's KB. " + "Omit this field (or pass `internal_search`) for all normal queries.")
53185
+ agentId: string2().optional().describe("Optional PipesHub agent to converse with — the `agentId` from " + "`pipeshub_agents`. When set, this turn runs against that agent's " + "configuration (prompt, tools, knowledge). On follow-up turns pass the " + "SAME `agentId` together with the `conversationId` returned by the " + "previous call. Omit for a plain (non-agent) conversation. If unsure " + "which agent to use, call `pipeshub_agents` first to see the options."),
53186
+ chatMode: _enum([
53187
+ "internal_search",
53188
+ "web_search",
53189
+ "auto",
53190
+ "quick",
53191
+ "verification",
53192
+ "deep"
53193
+ ]).optional().describe("Response strategy. The valid values depend on whether `agentId` is set:\n" + "- WITHOUT `agentId` (plain chat): `internal_search` — answer from the " + "org's indexed knowledge (default) — or `web_search` — answer from the " + `live web.
53194
+ ` + "- WITH `agentId` (agent chat): `auto` (let the agent decide; default), " + "`quick`, `verification`, or `deep`.")
52675
53195
  };
52676
53196
  tool$pipeshubChat = {
52677
53197
  name: "pipeshub_chat",
@@ -52724,7 +53244,40 @@ cited document, take \`citations[*].recordId\` and call
52724
53244
  tool: async (client, args2, ctx) => {
52725
53245
  const fetchOptions = { signal: ctx.signal };
52726
53246
  let response;
52727
- if (args2.conversationId) {
53247
+ if (args2.agentId) {
53248
+ const agentChatMode = args2.chatMode ?? "auto";
53249
+ if (args2.conversationId) {
53250
+ const [result] = await agentsStreamMessage(client, {
53251
+ agentKey: args2.agentId,
53252
+ conversationId: args2.conversationId,
53253
+ body: {
53254
+ query: args2.query,
53255
+ modelKey: args2.modelKey,
53256
+ modelName: args2.modelName,
53257
+ modelFriendlyName: args2.modelFriendlyName,
53258
+ chatMode: agentChatMode
53259
+ }
53260
+ }, { fetchOptions }).$inspect();
53261
+ if (!result.ok)
53262
+ return errorResult(result.error.message);
53263
+ response = result.value;
53264
+ } else {
53265
+ const [result] = await agentsStreamConversation(client, {
53266
+ agentKey: args2.agentId,
53267
+ body: {
53268
+ query: args2.query,
53269
+ filters: args2.filters,
53270
+ modelKey: args2.modelKey,
53271
+ modelName: args2.modelName,
53272
+ modelFriendlyName: args2.modelFriendlyName,
53273
+ chatMode: agentChatMode
53274
+ }
53275
+ }, { fetchOptions }).$inspect();
53276
+ if (!result.ok)
53277
+ return errorResult(result.error.message);
53278
+ response = result.value;
53279
+ }
53280
+ } else if (args2.conversationId) {
52728
53281
  const [result] = await conversationsStreamMessage(client, {
52729
53282
  conversationId: args2.conversationId,
52730
53283
  body: {
@@ -52732,7 +53285,7 @@ cited document, take \`citations[*].recordId\` and call
52732
53285
  modelKey: args2.modelKey,
52733
53286
  modelName: args2.modelName,
52734
53287
  modelFriendlyName: args2.modelFriendlyName,
52735
- chatMode: args2.chatMode
53288
+ chatMode: args2.chatMode ?? "internal_search"
52736
53289
  }
52737
53290
  }, { fetchOptions }).$inspect();
52738
53291
  if (!result.ok)
@@ -52745,12 +53298,15 @@ cited document, take \`citations[*].recordId\` and call
52745
53298
  modelKey: args2.modelKey,
52746
53299
  modelName: args2.modelName,
52747
53300
  modelFriendlyName: args2.modelFriendlyName,
52748
- chatMode: args2.chatMode
53301
+ chatMode: args2.chatMode ?? "internal_search"
52749
53302
  }, { fetchOptions }).$inspect();
52750
53303
  if (!result.ok)
52751
53304
  return errorResult(result.error.message);
52752
53305
  response = result.value;
52753
53306
  }
53307
+ const httpErr = await httpErrorResult(response, "PipesHub chat request");
53308
+ if (httpErr)
53309
+ return httpErr;
52754
53310
  let finalConversation = null;
52755
53311
  let recordsUsed;
52756
53312
  let lastAccumulated = null;
@@ -52874,9 +53430,9 @@ knowledge base, department, module, or record type. See
52874
53430
 
52875
53431
  // src/funcs/semanticSearchSearch.ts
52876
53432
  function semanticSearchSearch(client$, request, options) {
52877
- return new APIPromise($do3(client$, request, options));
53433
+ return new APIPromise($do6(client$, request, options));
52878
53434
  }
52879
- async function $do3(client$, request, options) {
53435
+ async function $do6(client$, request, options) {
52880
53436
  const parsed$ = safeParse4(request, (value$) => SemanticSearchRequest$zodSchema.parse(value$), "Input validation failed");
52881
53437
  if (!parsed$.ok) {
52882
53438
  return [parsed$, { status: "invalid" }];
@@ -52950,6 +53506,7 @@ var args2, tool$pipeshubSearch;
52950
53506
  var init_pipeshubSearch = __esm(() => {
52951
53507
  init_zod();
52952
53508
  init_semanticSearchSearch();
53509
+ init__helpers();
52953
53510
  args2 = {
52954
53511
  query: string2().min(1).describe("Natural language query. Vector search across the org's indexed records."),
52955
53512
  limit: number2().int().min(1).max(100).optional().describe("Max number of result chunks. Default 10. Use a small value (5–10) " + "when the goal is to resolve a filename / topic into a recordId."),
@@ -53054,9 +53611,9 @@ on this record's knowledge base.
53054
53611
 
53055
53612
  // src/funcs/recordsStreamRecordBuffer.ts
53056
53613
  function recordsStreamRecordBuffer(client$, request, options) {
53057
- return new APIPromise($do4(client$, request, options));
53614
+ return new APIPromise($do7(client$, request, options));
53058
53615
  }
53059
- async function $do4(client$, request, options) {
53616
+ async function $do7(client$, request, options) {
53060
53617
  const parsed$ = safeParse4(request, (value$) => StreamRecordBufferRequest$zodSchema.parse(value$), "Input validation failed");
53061
53618
  if (!parsed$.ok) {
53062
53619
  return [parsed$, { status: "invalid" }];
@@ -53140,6 +53697,7 @@ var init_pipeshubDownloadRecord = __esm(() => {
53140
53697
  init_zod();
53141
53698
  init_recordsStreamRecordBuffer();
53142
53699
  init_tools();
53700
+ init__helpers();
53143
53701
  args3 = {
53144
53702
  recordId: string2().min(1).describe("Record identifier — usually a UUID for connector-sourced records or " + "a 24-character ObjectId for uploaded records. Get it from a chat " + "citation (`citations[*].recordId`) or from a `pipeshub_search` hit."),
53145
53703
  convertTo: string2().optional().describe("Optional server-side format conversion target (e.g. `pdf`). When " + "omitted, the original file bytes are returned.")
@@ -53192,9 +53750,9 @@ var init_getallusersop = __esm(() => {
53192
53750
 
53193
53751
  // src/funcs/usersGetAllUsers.ts
53194
53752
  function usersGetAllUsers(client$, request, options) {
53195
- return new APIPromise($do5(client$, request, options));
53753
+ return new APIPromise($do8(client$, request, options));
53196
53754
  }
53197
- async function $do5(client$, request, options) {
53755
+ async function $do8(client$, request, options) {
53198
53756
  const parsed$ = safeParse4(request, (value$) => GetAllUsersRequest$zodSchema.optional().parse(value$), "Input validation failed");
53199
53757
  if (!parsed$.ok) {
53200
53758
  return [parsed$, { status: "invalid" }];
@@ -53279,9 +53837,9 @@ var init_getuserbyidop = __esm(() => {
53279
53837
 
53280
53838
  // src/funcs/usersGetUserById.ts
53281
53839
  function usersGetUserById(client$, request, options) {
53282
- return new APIPromise($do6(client$, request, options));
53840
+ return new APIPromise($do9(client$, request, options));
53283
53841
  }
53284
- async function $do6(client$, request, options) {
53842
+ async function $do9(client$, request, options) {
53285
53843
  const parsed$ = safeParse4(request, (value$) => GetUserByIdRequest$zodSchema.parse(value$), "Input validation failed");
53286
53844
  if (!parsed$.ok) {
53287
53845
  return [parsed$, { status: "invalid" }];
@@ -53368,9 +53926,9 @@ var init_getallusergroupsop = __esm(() => {
53368
53926
 
53369
53927
  // src/funcs/userGroupsGetAllUserGroups.ts
53370
53928
  function userGroupsGetAllUserGroups(client$, request, options) {
53371
- return new APIPromise($do7(client$, request, options));
53929
+ return new APIPromise($do10(client$, request, options));
53372
53930
  }
53373
- async function $do7(client$, request, options) {
53931
+ async function $do10(client$, request, options) {
53374
53932
  const parsed$ = safeParse4(request, (value$) => GetAllUserGroupsRequest$zodSchema.optional().parse(value$), "Input validation failed");
53375
53933
  if (!parsed$.ok) {
53376
53934
  return [parsed$, { status: "invalid" }];
@@ -53460,9 +54018,9 @@ var init_getuserteamsop = __esm(() => {
53460
54018
 
53461
54019
  // src/funcs/teamsGetUserTeams.ts
53462
54020
  function teamsGetUserTeams(client$, request, options) {
53463
- return new APIPromise($do8(client$, request, options));
54021
+ return new APIPromise($do11(client$, request, options));
53464
54022
  }
53465
- async function $do8(client$, request, options) {
54023
+ async function $do11(client$, request, options) {
53466
54024
  const parsed$ = safeParse4(request, (value$) => GetUserTeamsRequest$zodSchema.optional().parse(value$), "Input validation failed");
53467
54025
  if (!parsed$.ok) {
53468
54026
  return [parsed$, { status: "invalid" }];
@@ -53547,6 +54105,7 @@ var init_pipeshubDirectory = __esm(() => {
53547
54105
  init_usersGetUserById();
53548
54106
  init_userGroupsGetAllUserGroups();
53549
54107
  init_teamsGetUserTeams();
54108
+ init__helpers();
53550
54109
  args4 = {
53551
54110
  action: _enum([
53552
54111
  "whoami",
@@ -53691,9 +54250,9 @@ var init_getknowledgehubrootnodesop = __esm(() => {
53691
54250
 
53692
54251
  // src/funcs/knowledgeHubGetKnowledgeHubRootNodes.ts
53693
54252
  function knowledgeHubGetKnowledgeHubRootNodes(client$, request, options) {
53694
- return new APIPromise($do9(client$, request, options));
54253
+ return new APIPromise($do12(client$, request, options));
53695
54254
  }
53696
- async function $do9(client$, request, options) {
54255
+ async function $do12(client$, request, options) {
53697
54256
  const parsed$ = safeParse4(request, (value$) => GetKnowledgeHubRootNodesRequest$zodSchema.optional().parse(value$), "Input validation failed");
53698
54257
  if (!parsed$.ok) {
53699
54258
  return [parsed$, { status: "invalid" }];
@@ -53809,9 +54368,9 @@ var init_getavailablemodelsbytypeop = __esm(() => {
53809
54368
 
53810
54369
  // src/funcs/aiModelsProvidersGetAvailableModelsByType.ts
53811
54370
  function aiModelsProvidersGetAvailableModelsByType(client$, request, options) {
53812
- return new APIPromise($do10(client$, request, options));
54371
+ return new APIPromise($do13(client$, request, options));
53813
54372
  }
53814
- async function $do10(client$, request, options) {
54373
+ async function $do13(client$, request, options) {
53815
54374
  const parsed$ = safeParse4(request, (value$) => GetAvailableModelsByTypeRequest$zodSchema.parse(value$), "Input validation failed");
53816
54375
  if (!parsed$.ok) {
53817
54376
  return [parsed$, { status: "invalid" }];
@@ -53891,6 +54450,7 @@ var init_pipeshubSources = __esm(() => {
53891
54450
  init_zod();
53892
54451
  init_knowledgeHubGetKnowledgeHubRootNodes();
53893
54452
  init_aiModelsProvidersGetAvailableModelsByType();
54453
+ init__helpers();
53894
54454
  args5 = {
53895
54455
  include: array(_enum(["sources", "llmModels", "embeddingModels"])).optional().describe('Which sections to fetch. Default: `["sources", "llmModels"]`. ' + "Add `embeddingModels` if the user is configuring re-embedding.")
53896
54456
  };
@@ -53974,6 +54534,99 @@ are returned by default; pass \`include\` to override.`,
53974
54534
  };
53975
54535
  });
53976
54536
 
54537
+ // src/mcp-server/tools/pipeshubAgents.ts
54538
+ var args6, tool$pipeshubAgents;
54539
+ var init_pipeshubAgents = __esm(() => {
54540
+ init_zod();
54541
+ init__helpers();
54542
+ args6 = {
54543
+ search: string2().optional().describe("Optional case-insensitive substring match across agent name, " + "description, and tags. Omit to return every agent.")
54544
+ };
54545
+ tool$pipeshubAgents = {
54546
+ name: "pipeshub_agents",
54547
+ description: `List the PipesHub **agents** configured for this org, each with its
54548
+ capabilities.
54549
+
54550
+ Agents are specialized assistants (custom system prompt, tools, knowledge
54551
+ scope). To converse with one, take its \`agentId\` and pass it to
54552
+ \`pipeshub_chat\`'s \`agentId\` argument.
54553
+
54554
+ Each agent is returned as:
54555
+ \`{ agentId, name, description, systemPrompt, startMessage, tags, webSearch,
54556
+ isActive, toolsets, knowledge }\`.
54557
+ - \`toolsets\` — what the agent can DO: each \`{ name, tools }\` where \`name\`
54558
+ is the connector (e.g. \`jira\`, \`gmail\`) and \`tools\` are the runnable
54559
+ tool ids (e.g. \`jira.create_issue\`, \`gmail.send_email\`).
54560
+ - \`knowledge\` — what the agent can READ: each \`{ name, type }\` (e.g.
54561
+ \`Confluence-2\` / \`Confluence\`).
54562
+
54563
+ **Route on \`toolsets\`/\`knowledge\`, not the name** — names and descriptions
54564
+ are often generic or misleading. Match the request to the agent whose tools can
54565
+ actually perform it (e.g. "create a Jira ticket" → the agent whose toolset is
54566
+ \`jira\` and whose tools include \`jira.create_issue\`). If NO agent has a tool
54567
+ for the requested action, say so — don't force an unrelated agent.
54568
+
54569
+ The list **may be empty** (no agents configured). For plain Q&A when no
54570
+ specific agent is needed, use \`pipeshub_chat\` WITHOUT \`agentId\` and pick a
54571
+ \`chatMode\`: \`internal_search\` (org's indexed knowledge) or \`web_search\`
54572
+ (live web). Use \`agentId\` everywhere an agent is referenced.`,
54573
+ scopes: ["read"],
54574
+ annotations: {
54575
+ title: "List PipesHub agents (with toolsets & knowledge)",
54576
+ destructiveHint: false,
54577
+ idempotentHint: true,
54578
+ openWorldHint: false,
54579
+ readOnlyHint: true
54580
+ },
54581
+ args: args6,
54582
+ tool: async (client, args7, ctx) => {
54583
+ const all = await listAllAgents(client, {
54584
+ search: args7.search,
54585
+ signal: ctx.signal
54586
+ });
54587
+ if (!all.ok)
54588
+ return all.result;
54589
+ return jsonResult({
54590
+ agents: all.agents.map(trimAgent),
54591
+ total: all.total,
54592
+ ...all.truncated ? { truncated: true } : {}
54593
+ });
54594
+ }
54595
+ };
54596
+ });
54597
+
54598
+ // src/mcp-server/prompts/pipeshubAssistant.ts
54599
+ var args7, prompt$pipeshubAssistant;
54600
+ var init_pipeshubAssistant = __esm(() => {
54601
+ init_zod();
54602
+ args7 = {
54603
+ query: string2().optional().describe("Optional. The user's request to route. Provide it to have the guidance " + "applied to a concrete request; omit it to just load the routing " + "guidance as a seed system prompt at the start of a session.")
54604
+ };
54605
+ prompt$pipeshubAssistant = {
54606
+ name: "pipeshub-assistant",
54607
+ description: "Load PipesHub tool-routing guidance so the assistant picks the correct " + "tool (pipeshub_chat / search / agents / directory) and lists agents " + "with pipeshub_agents when unsure which route fits the query.",
54608
+ scopes: ["read"],
54609
+ args: args7,
54610
+ prompt: (_client, args8, _extra) => {
54611
+ const text = args8.query ? `${PIPESHUB_INSTRUCTIONS}
54612
+
54613
+ ---
54614
+
54615
+ Follow the routing rules above to ` + `handle this request, picking the right tool (and listing agents via ` + `\`pipeshub_agents\` if unsure which route fits):
54616
+
54617
+ ${args8.query}` : PIPESHUB_INSTRUCTIONS;
54618
+ return {
54619
+ messages: [
54620
+ {
54621
+ role: "user",
54622
+ content: { type: "text", text }
54623
+ }
54624
+ ]
54625
+ };
54626
+ }
54627
+ };
54628
+ });
54629
+
53977
54630
  // src/mcp-server/server.ts
53978
54631
  function createMCPServer(deps) {
53979
54632
  const server = new McpServer({
@@ -53988,9 +54641,9 @@ function createMCPServer(deps) {
53988
54641
  serverIdx: deps.serverIdx,
53989
54642
  instance_url: deps.instance_url,
53990
54643
  debugLogger: deps.logger.level === "debug" ? {
53991
- log: (...args6) => console.log(...args6),
53992
- group: (...args6) => console.group(...args6),
53993
- groupEnd: (...args6) => console.groupEnd(...args6)
54644
+ log: (...args8) => console.log(...args8),
54645
+ group: (...args8) => console.group(...args8),
54646
+ groupEnd: (...args8) => console.groupEnd(...args8)
53994
54647
  } : undefined
53995
54648
  }));
53996
54649
  const scopes = new Set(deps.scopes);
@@ -54005,63 +54658,13 @@ function createMCPServer(deps) {
54005
54658
  tool(tool$pipeshubSearch);
54006
54659
  tool(tool$pipeshubDownloadRecord);
54007
54660
  tool(tool$pipeshubDirectory);
54661
+ tool(tool$pipeshubAgents);
54662
+ prompt(prompt$pipeshubAssistant);
54008
54663
  if (deps.dynamic) {
54009
54664
  registerDynamicTools(deps.logger, server, getClient, toolMap, scopes);
54010
54665
  }
54011
54666
  return { server, tools };
54012
54667
  }
54013
- var PIPESHUB_INSTRUCTIONS = `# PipesHub MCP — instructions for the LLM
54014
-
54015
- PipesHub is the user's workplace AI platform. It indexes their documents,
54016
- knowledge base content, and connector sources (Drive, Box, Confluence,
54017
- Slack, Jira, Gmail, ...). When in doubt, the answer is in PipesHub.
54018
-
54019
- ## Default tool: \`pipeshub_chat\`
54020
-
54021
- **Use \`pipeshub_chat\` for any question that could plausibly be answered
54022
- by the user's PipesHub-indexed data.** That includes:
54023
-
54024
- - Anything about a specific document, file, report, ticket, message, or
54025
- page (e.g. "what's in the Q4 sales report?", "summarize the langchain
54026
- doc", "what did Aashil say about onboarding?").
54027
- - Anything about company / org policies, processes, decisions, or
54028
- history (e.g. "what's our vacation policy?", "who owns the auth
54029
- service?").
54030
- - Anything explicitly mentioning PipesHub itself, or its sources
54031
- (Drive / Box / Confluence / Slack / Gmail / Jira / etc.) when the
54032
- user has those connected.
54033
- - Open-ended "what do we know about X" questions where the answer
54034
- likely lives in the org's documents.
54035
-
54036
- Do NOT answer those from your own knowledge — \`pipeshub_chat\` grounds
54037
- the answer in the user's actual indexed content and returns citations
54038
- the user can verify.
54039
-
54040
- ## When to use the other tools
54041
-
54042
- - \`pipeshub_search\` — only when the user asks specifically to **find /
54043
- locate** a document by name or topic (so you can hand them a list, or
54044
- resolve a filename to a \`recordId\` for download). For "what does
54045
- the doc say?" use \`pipeshub_chat\` instead — it does the retrieval
54046
- internally.
54047
- - \`pipeshub_download_record\` — when the user wants the actual file
54048
- bytes (download, attach, open). Get the \`recordId\` either from
54049
- citations on a prior \`pipeshub_chat\` response or from
54050
- \`pipeshub_search\`.
54051
- - \`pipeshub_directory\` — people, groups, teams, and \`whoami\` lookups.
54052
- Not for documents.
54053
- - \`pipeshub_sources\` — call once at the start of a session to discover
54054
- which connectors / KB / models are available, then cache the result.
54055
-
54056
- ## Conversation lifecycle
54057
-
54058
- \`pipeshub_chat\` is a single tool that handles both starting and
54059
- continuing conversations. On the first turn omit \`conversationId\`; on
54060
- every subsequent turn pass back the \`conversationId\` returned by the
54061
- previous call. Server-side context is preserved — do NOT replay prior
54062
- messages. Only start a fresh conversation when the user explicitly
54063
- asks to clear context.
54064
- `;
54065
54668
  var init_server2 = __esm(() => {
54066
54669
  init_mcp();
54067
54670
  init_core3();
@@ -54072,6 +54675,8 @@ var init_server2 = __esm(() => {
54072
54675
  init_pipeshubDownloadRecord();
54073
54676
  init_pipeshubDirectory();
54074
54677
  init_pipeshubSources();
54678
+ init_pipeshubAgents();
54679
+ init_pipeshubAssistant();
54075
54680
  });
54076
54681
 
54077
54682
  // src/tool-names.ts
@@ -54149,6 +54754,10 @@ Highest \`score\` first; multiple hits may share the same \`recordId\`
54149
54754
  {
54150
54755
  name: "pipeshub_directory",
54151
54756
  description: "Look up people, groups, and teams in PipesHub. One tool with five\nactions — pick the right `action`:\n\n- `whoami` — who is the caller? Use this whenever you need the\n authenticated user's own id, email, or full name (e.g. before\n `get_user` on themselves).\n- `list_users` — search / page through org users.\n- `get_user` — full `User` document for one user (requires `userId`).\n- `list_groups` — list user groups with `userCount`.\n- `list_my_teams` — teams the caller belongs to, with capability flags\n (`canEdit` / `canDelete` / `canManageMembers`).\n\nOutput shape varies by action; see each action's docs above."
54757
+ },
54758
+ {
54759
+ name: "pipeshub_agents",
54760
+ description: 'List the PipesHub **agents** configured for this org, each with its\ncapabilities.\n\nAgents are specialized assistants (custom system prompt, tools, knowledge\nscope). To converse with one, take its `agentId` and pass it to\n`pipeshub_chat`\'s `agentId` argument.\n\nEach agent is returned as:\n`{ agentId, name, description, systemPrompt, startMessage, tags, webSearch,\nisActive, toolsets, knowledge }`.\n- `toolsets` — what the agent can DO: each `{ name, tools }` where `name`\n is the connector (e.g. `jira`, `gmail`) and `tools` are the runnable\n tool ids (e.g. `jira.create_issue`, `gmail.send_email`).\n- `knowledge` — what the agent can READ: each `{ name, type }` (e.g.\n `Confluence-2` / `Confluence`).\n\n**Route on `toolsets`/`knowledge`, not the name** — names and descriptions\nare often generic or misleading. Match the request to the agent whose tools can\nactually perform it (e.g. "create a Jira ticket" → the agent whose toolset is\n`jira` and whose tools include `jira.create_issue`). If NO agent has a tool\nfor the requested action, say so — don\'t force an unrelated agent.\n\nThe list **may be empty** (no agents configured). For plain Q&A when no\nspecific agent is needed, use `pipeshub_chat` WITHOUT `agentId` and pick a\n`chatMode`: `internal_search` (org\'s indexed knowledge) or `web_search`\n(live web). Use `agentId` everywhere an agent is referenced.'
54152
54761
  }
54153
54762
  ];
54154
54763
  });
@@ -57777,5 +58386,5 @@ export {
57777
58386
  app
57778
58387
  };
57779
58388
 
57780
- //# debugId=4F54178F9A67222964756E2164756E21
58389
+ //# debugId=E589470B4E3C258364756E2164756E21
57781
58390
  //# sourceMappingURL=mcp-server.js.map