@bubblelab/bubble-core 0.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.
- package/LICENSE.txt +202 -0
- package/dist/bubble-bundle.d.ts +2021 -0
- package/dist/bubble-factory.d.ts +161 -0
- package/dist/bubble-factory.d.ts.map +1 -0
- package/dist/bubble-factory.js +426 -0
- package/dist/bubble-factory.js.map +1 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts +19 -0
- package/dist/bubble-flow/bubble-flow-class.d.ts.map +1 -0
- package/dist/bubble-flow/bubble-flow-class.js +23 -0
- package/dist/bubble-flow/bubble-flow-class.js.map +1 -0
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts +15 -0
- package/dist/bubble-flow/sample/data-analyst-flow.d.ts.map +1 -0
- package/dist/bubble-flow/sample/data-analyst-flow.js +63 -0
- package/dist/bubble-flow/sample/data-analyst-flow.js.map +1 -0
- package/dist/bubble-flow/sample/error-ts.d.ts +23 -0
- package/dist/bubble-flow/sample/error-ts.d.ts.map +1 -0
- package/dist/bubble-flow/sample/error-ts.js +31 -0
- package/dist/bubble-flow/sample/error-ts.js.map +1 -0
- package/dist/bubble-flow/sample/sanitytest.d.ts +10 -0
- package/dist/bubble-flow/sample/sanitytest.d.ts.map +1 -0
- package/dist/bubble-flow/sample/sanitytest.js +13 -0
- package/dist/bubble-flow/sample/sanitytest.js.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts +19 -0
- package/dist/bubble-flow/sample/simple-webhook-2.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook-2.js +23 -0
- package/dist/bubble-flow/sample/simple-webhook-2.js.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook.d.ts +10 -0
- package/dist/bubble-flow/sample/simple-webhook.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simple-webhook.js +18 -0
- package/dist/bubble-flow/sample/simple-webhook.js.map +1 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts +29 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.d.ts.map +1 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js +150 -0
- package/dist/bubble-flow/sample/simplified-data-analysis.flow.js.map +1 -0
- package/dist/bubble-flow/sample/slack-v0.1.d.ts +10 -0
- package/dist/bubble-flow/sample/slack-v0.1.d.ts.map +1 -0
- package/dist/bubble-flow/sample/slack-v0.1.js +59 -0
- package/dist/bubble-flow/sample/slack-v0.1.js.map +1 -0
- package/dist/bubble-flow/sample/slackagenttest.d.ts +10 -0
- package/dist/bubble-flow/sample/slackagenttest.d.ts.map +1 -0
- package/dist/bubble-flow/sample/slackagenttest.js +59 -0
- package/dist/bubble-flow/sample/slackagenttest.js.map +1 -0
- package/dist/bubble-trigger/index.d.ts +2 -0
- package/dist/bubble-trigger/index.d.ts.map +1 -0
- package/dist/bubble-trigger/index.js +2 -0
- package/dist/bubble-trigger/index.js.map +1 -0
- package/dist/bubble-trigger/types.d.ts +87 -0
- package/dist/bubble-trigger/types.d.ts.map +1 -0
- package/dist/bubble-trigger/types.js +14 -0
- package/dist/bubble-trigger/types.js.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts +428 -0
- package/dist/bubbles/service-bubble/ai-agent.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/ai-agent.js +881 -0
- package/dist/bubbles/service-bubble/ai-agent.js.map +1 -0
- package/dist/bubbles/service-bubble/gmail.d.ts +3073 -0
- package/dist/bubbles/service-bubble/gmail.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/gmail.js +908 -0
- package/dist/bubbles/service-bubble/gmail.js.map +1 -0
- package/dist/bubbles/service-bubble/google-calendar.d.ts +3377 -0
- package/dist/bubbles/service-bubble/google-calendar.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-calendar.js +527 -0
- package/dist/bubbles/service-bubble/google-calendar.js.map +1 -0
- package/dist/bubbles/service-bubble/google-drive.d.ts +1152 -0
- package/dist/bubbles/service-bubble/google-drive.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-drive.js +943 -0
- package/dist/bubbles/service-bubble/google-drive.js.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets.d.ts +1811 -0
- package/dist/bubbles/service-bubble/google-sheets.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/google-sheets.js +904 -0
- package/dist/bubbles/service-bubble/google-sheets.js.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts +74 -0
- package/dist/bubbles/service-bubble/hello-world.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/hello-world.js +67 -0
- package/dist/bubbles/service-bubble/hello-world.js.map +1 -0
- package/dist/bubbles/service-bubble/http.d.ts +134 -0
- package/dist/bubbles/service-bubble/http.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/http.js +184 -0
- package/dist/bubbles/service-bubble/http.js.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts +180 -0
- package/dist/bubbles/service-bubble/postgresql.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/postgresql.js +448 -0
- package/dist/bubbles/service-bubble/postgresql.js.map +1 -0
- package/dist/bubbles/service-bubble/resend.d.ts +301 -0
- package/dist/bubbles/service-bubble/resend.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/resend.js +253 -0
- package/dist/bubbles/service-bubble/resend.js.map +1 -0
- package/dist/bubbles/service-bubble/slack.d.ts +5869 -0
- package/dist/bubbles/service-bubble/slack.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/slack.js +1536 -0
- package/dist/bubbles/service-bubble/slack.js.map +1 -0
- package/dist/bubbles/service-bubble/storage.d.ts +571 -0
- package/dist/bubbles/service-bubble/storage.d.ts.map +1 -0
- package/dist/bubbles/service-bubble/storage.js +504 -0
- package/dist/bubbles/service-bubble/storage.js.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts +308 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js +285 -0
- package/dist/bubbles/tool-bubble/bubbleflow-validation-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts +416 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.js +570 -0
- package/dist/bubbles/tool-bubble/chart-js-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts +99 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js +645 -0
- package/dist/bubbles/tool-bubble/get-bubble-details-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts +112 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.js +82 -0
- package/dist/bubbles/tool-bubble/list-bubbles-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts +413 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js +327 -0
- package/dist/bubbles/tool-bubble/reddit-scrape-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts +122 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.js +343 -0
- package/dist/bubbles/tool-bubble/research-agent-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts +131 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.js +147 -0
- package/dist/bubbles/tool-bubble/sql-query-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts +257 -0
- package/dist/bubbles/tool-bubble/tool-template.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/tool-template.js +238 -0
- package/dist/bubbles/tool-bubble/tool-template.js.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts +8 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.js +65 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor-example.js.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts +125 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js +169 -0
- package/dist/bubbles/tool-bubble/virtual-file-editor.tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts +218 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.js +255 -0
- package/dist/bubbles/tool-bubble/web-crawl-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts +134 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.js +175 -0
- package/dist/bubbles/tool-bubble/web-extract-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts +228 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.js +214 -0
- package/dist/bubbles/tool-bubble/web-scrape-tool.js.map +1 -0
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts +134 -0
- package/dist/bubbles/tool-bubble/web-search-tool.d.ts.map +1 -0
- package/dist/bubbles/tool-bubble/web-search-tool.js +155 -0
- package/dist/bubbles/tool-bubble/web-search-tool.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts +114 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js +777 -0
- package/dist/bubbles/workflow-bubble/bubbleflow-generator.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts +97 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js +327 -0
- package/dist/bubbles/workflow-bubble/bubblscript-generateor.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts +303 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js +297 -0
- package/dist/bubbles/workflow-bubble/database-analyzer.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts +157 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js +310 -0
- package/dist/bubbles/workflow-bubble/file-editor-agent.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts +543 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js +628 -0
- package/dist/bubbles/workflow-bubble/generate-document.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts +679 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js +604 -0
- package/dist/bubbles/workflow-bubble/parse-document.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts +1011 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js +841 -0
- package/dist/bubbles/workflow-bubble/pdf-form-operations.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts +883 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js +781 -0
- package/dist/bubbles/workflow-bubble/pdf-ocr.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts +300 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js +508 -0
- package/dist/bubbles/workflow-bubble/slack-data-assistant.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts +731 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js +690 -0
- package/dist/bubbles/workflow-bubble/slack-formatter-agent.js.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts +401 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js +382 -0
- package/dist/bubbles/workflow-bubble/slack-notifier.workflow.js.map +1 -0
- package/dist/bubbles/workflow-bubble/workflow-template.d.ts +144 -0
- package/dist/bubbles/workflow-bubble/workflow-template.d.ts.map +1 -0
- package/dist/bubbles/workflow-bubble/workflow-template.js +124 -0
- package/dist/bubbles/workflow-bubble/workflow-template.js.map +1 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/BubbleLogger.d.ts +146 -0
- package/dist/logging/BubbleLogger.d.ts.map +1 -0
- package/dist/logging/BubbleLogger.js +472 -0
- package/dist/logging/BubbleLogger.js.map +1 -0
- package/dist/logging/StreamingBubbleLogger.d.ts +85 -0
- package/dist/logging/StreamingBubbleLogger.d.ts.map +1 -0
- package/dist/logging/StreamingBubbleLogger.js +340 -0
- package/dist/logging/StreamingBubbleLogger.js.map +1 -0
- package/dist/types/ai-models.d.ts +4 -0
- package/dist/types/ai-models.d.ts.map +1 -0
- package/dist/types/ai-models.js +14 -0
- package/dist/types/ai-models.js.map +1 -0
- package/dist/types/available-tools.d.ts +4 -0
- package/dist/types/available-tools.d.ts.map +1 -0
- package/dist/types/available-tools.js +19 -0
- package/dist/types/available-tools.js.map +1 -0
- package/dist/types/base-bubble-class.d.ts +47 -0
- package/dist/types/base-bubble-class.d.ts.map +1 -0
- package/dist/types/base-bubble-class.js +212 -0
- package/dist/types/base-bubble-class.js.map +1 -0
- package/dist/types/bubble-errors.d.ts +44 -0
- package/dist/types/bubble-errors.d.ts.map +1 -0
- package/dist/types/bubble-errors.js +51 -0
- package/dist/types/bubble-errors.js.map +1 -0
- package/dist/types/bubble.d.ts +73 -0
- package/dist/types/bubble.d.ts.map +1 -0
- package/dist/types/bubble.js +2 -0
- package/dist/types/bubble.js.map +1 -0
- package/dist/types/credentials.d.ts +6 -0
- package/dist/types/credentials.d.ts.map +1 -0
- package/dist/types/credentials.js +6 -0
- package/dist/types/credentials.js.map +1 -0
- package/dist/types/service-bubble-class.d.ts +31 -0
- package/dist/types/service-bubble-class.d.ts.map +1 -0
- package/dist/types/service-bubble-class.js +36 -0
- package/dist/types/service-bubble-class.js.map +1 -0
- package/dist/types/streaming-events.d.ts +18 -0
- package/dist/types/streaming-events.d.ts.map +1 -0
- package/dist/types/streaming-events.js +5 -0
- package/dist/types/streaming-events.js.map +1 -0
- package/dist/types/tool-bubble-class.d.ts +19 -0
- package/dist/types/tool-bubble-class.d.ts.map +1 -0
- package/dist/types/tool-bubble-class.js +48 -0
- package/dist/types/tool-bubble-class.js.map +1 -0
- package/dist/types/workflow-bubble-class.d.ts +25 -0
- package/dist/types/workflow-bubble-class.d.ts.map +1 -0
- package/dist/types/workflow-bubble-class.js +30 -0
- package/dist/types/workflow-bubble-class.js.map +1 -0
- package/dist/utils/bubbleflow-parser.d.ts +32 -0
- package/dist/utils/bubbleflow-parser.d.ts.map +1 -0
- package/dist/utils/bubbleflow-parser.js +332 -0
- package/dist/utils/bubbleflow-parser.js.map +1 -0
- package/dist/utils/bubbleflow-validation.d.ts +9 -0
- package/dist/utils/bubbleflow-validation.d.ts.map +1 -0
- package/dist/utils/bubbleflow-validation.js +116 -0
- package/dist/utils/bubbleflow-validation.js.map +1 -0
- package/dist/utils/json-parsing.d.ts +20 -0
- package/dist/utils/json-parsing.d.ts.map +1 -0
- package/dist/utils/json-parsing.js +394 -0
- package/dist/utils/json-parsing.js.map +1 -0
- package/dist/utils/mock-data-generator.d.ts +43 -0
- package/dist/utils/mock-data-generator.d.ts.map +1 -0
- package/dist/utils/mock-data-generator.js +312 -0
- package/dist/utils/mock-data-generator.js.map +1 -0
- package/dist/utils/param-helper.d.ts +2 -0
- package/dist/utils/param-helper.d.ts.map +1 -0
- package/dist/utils/param-helper.js +5 -0
- package/dist/utils/param-helper.js.map +1 -0
- package/dist/utils/source-bubble-parser.d.ts +31 -0
- package/dist/utils/source-bubble-parser.d.ts.map +1 -0
- package/dist/utils/source-bubble-parser.js +231 -0
- package/dist/utils/source-bubble-parser.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-formatter-agent.d.ts","sourceRoot":"","sources":["../../../src/bubbles/workflow-bubble/slack-formatter-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAU3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AA2EtE,QAAA,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDnC,CAAC;AAEH,QAAA,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsFnC,CAAC;AAEH,KAAK,yBAAyB,GAAG,CAAC,CAAC,KAAK,CACtC,OAAO,+BAA+B,CACvC,CAAC;AACF,KAAK,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AAEF,KAAK,yBAAyB,GAAG,CAAC,CAAC,MAAM,CACvC,OAAO,+BAA+B,CACvC,CAAC;AAEF,qBAAa,yBAA0B,SAAQ,cAAc,CAC3D,+BAA+B,EAC/B,yBAAyB,CAC1B;IACC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAG,SAAS,CAAU;IAC1C,MAAM,CAAC,QAAQ,CAAC,OAAO,2BAA2B;IAClD,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAG,QAAQ,CAAU;IAC7C,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAA2B;IACjE,MAAM,CAAC,QAAQ,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAmC;IACzD,MAAM,CAAC,QAAQ,CAAC,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAmC;IAC/D,MAAM,CAAC,QAAQ,CAAC,gBAAgB,oGACmE;IACnG,MAAM,CAAC,QAAQ,CAAC,eAAe,03BAe7B;IACF,MAAM,CAAC,QAAQ,CAAC,KAAK,kBAAkB;IAEvC,OAAO,CAAC,OAAO,CAAgB;gBAG7B,MAAM,GAAE,yBAIP,EACD,OAAO,CAAC,EAAE,aAAa;IAMZ,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;cAU/B,aAAa,CAC3B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,yBAAyB,CAAC;IAuErC,SAAS,CAAC,gBAAgB,IAAI,MAAM,GAAG,SAAS;IAuBhD,OAAO,CAAC,0BAA0B;IAkLlC,OAAO,CAAC,eAAe;YA6BT,eAAe;YAoDf,gBAAgB;YAmDhB,YAAY;IAgG1B,OAAO,CAAC,kBAAkB;IAoC1B,OAAO,CAAC,yBAAyB;CAwClC"}
|
|
@@ -0,0 +1,690 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CredentialType } from '@bubblelab/shared-schemas';
|
|
3
|
+
import { StateGraph, MessagesAnnotation } from '@langchain/langgraph';
|
|
4
|
+
import { ToolNode } from '@langchain/langgraph/prebuilt';
|
|
5
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
6
|
+
import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
|
|
7
|
+
import { HumanMessage, AIMessage, ToolMessage } from '@langchain/core/messages';
|
|
8
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
9
|
+
import { AvailableModels } from '../../types/ai-models.js';
|
|
10
|
+
import { BubbleFactory } from '../../bubble-factory.js';
|
|
11
|
+
import { WorkflowBubble } from '../../types/workflow-bubble-class.js';
|
|
12
|
+
// Define verbosity levels
|
|
13
|
+
const VerbosityLevel = z
|
|
14
|
+
.enum(['1', '2', '3', '4', '5'])
|
|
15
|
+
.describe('Verbosity level: 1=concise, 2=brief, 3=moderate, 4=detailed, 5=comprehensive');
|
|
16
|
+
// Define technicality levels
|
|
17
|
+
const TechnicalityLevel = z
|
|
18
|
+
.enum(['1', '2', '3', '4', '5'])
|
|
19
|
+
.describe('Technicality level: 1=non-technical, 2=basic, 3=intermediate, 4=advanced, 5=expert');
|
|
20
|
+
// Define Slack block types for structured output
|
|
21
|
+
const SlackBlockType = z.enum([
|
|
22
|
+
'section',
|
|
23
|
+
'header',
|
|
24
|
+
'divider',
|
|
25
|
+
'context',
|
|
26
|
+
'actions',
|
|
27
|
+
'input',
|
|
28
|
+
'file',
|
|
29
|
+
'image',
|
|
30
|
+
]);
|
|
31
|
+
// Define model configuration
|
|
32
|
+
const ModelConfigSchema = z.object({
|
|
33
|
+
model: AvailableModels.default('google/gemini-2.5-flash').describe('AI model to use (format: provider/model-name)'),
|
|
34
|
+
temperature: z
|
|
35
|
+
.number()
|
|
36
|
+
.min(0)
|
|
37
|
+
.max(2)
|
|
38
|
+
.default(0.7)
|
|
39
|
+
.describe('Temperature for response randomness (0 = deterministic, 2 = very random)'),
|
|
40
|
+
maxTokens: z
|
|
41
|
+
.number()
|
|
42
|
+
.positive()
|
|
43
|
+
.optional()
|
|
44
|
+
.default(10000)
|
|
45
|
+
.describe('Maximum number of tokens to generate in response'),
|
|
46
|
+
});
|
|
47
|
+
// Define tool configuration
|
|
48
|
+
const ToolConfigSchema = z.object({
|
|
49
|
+
name: z
|
|
50
|
+
.string()
|
|
51
|
+
.describe('Name of the tool bubble to enable for the AI agent'),
|
|
52
|
+
credentials: z
|
|
53
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
54
|
+
.default({})
|
|
55
|
+
.optional()
|
|
56
|
+
.describe('Credential types to use for the tool bubble (injected at runtime)'),
|
|
57
|
+
config: z
|
|
58
|
+
.record(z.string(), z.unknown())
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('Configuration for the tool bubble'),
|
|
61
|
+
});
|
|
62
|
+
// Define the parameters schema for the Slack Formatter Agent bubble
|
|
63
|
+
const SlackFormatterAgentParamsSchema = z.object({
|
|
64
|
+
message: z
|
|
65
|
+
.string()
|
|
66
|
+
.min(1, 'Message is required')
|
|
67
|
+
.describe('The message or question to send to the AI agent'),
|
|
68
|
+
verbosity: VerbosityLevel.default('3').describe('Response verbosity level (1-5): 1=concise bullet points, 5=comprehensive explanations'),
|
|
69
|
+
technicality: TechnicalityLevel.default('3').describe('Technical complexity level (1-5): 1=plain English, 5=expert terminology'),
|
|
70
|
+
includeBlockKit: z
|
|
71
|
+
.boolean()
|
|
72
|
+
.default(true)
|
|
73
|
+
.describe('Include Slack Block Kit JSON for rich formatting'),
|
|
74
|
+
includeQuery: z
|
|
75
|
+
.boolean()
|
|
76
|
+
.default(false)
|
|
77
|
+
.describe('Include the query that was executed in the response'),
|
|
78
|
+
includeExplanation: z
|
|
79
|
+
.boolean()
|
|
80
|
+
.default(false)
|
|
81
|
+
.describe('Include explanation of what the query does and why it was chosen'),
|
|
82
|
+
model: ModelConfigSchema.default({
|
|
83
|
+
model: 'google/gemini-2.5-flash',
|
|
84
|
+
temperature: 0.7,
|
|
85
|
+
maxTokens: 50000,
|
|
86
|
+
}).describe('AI model configuration including provider, temperature, and tokens'),
|
|
87
|
+
tools: z
|
|
88
|
+
.array(ToolConfigSchema)
|
|
89
|
+
.default([])
|
|
90
|
+
.describe('Array of tool bubbles the AI agent can use'),
|
|
91
|
+
maxIterations: z
|
|
92
|
+
.number()
|
|
93
|
+
.positive()
|
|
94
|
+
.default(10)
|
|
95
|
+
.describe('Maximum number of iterations for the agent workflow'),
|
|
96
|
+
credentials: z
|
|
97
|
+
.record(z.nativeEnum(CredentialType), z.string())
|
|
98
|
+
.optional()
|
|
99
|
+
.describe('Object mapping credential types to values (injected at runtime)'),
|
|
100
|
+
additionalContext: z
|
|
101
|
+
.string()
|
|
102
|
+
.optional()
|
|
103
|
+
.describe('Additional context about how to answer the question'),
|
|
104
|
+
});
|
|
105
|
+
const SlackFormatterAgentResultSchema = z.object({
|
|
106
|
+
response: z
|
|
107
|
+
.string()
|
|
108
|
+
.describe('The AI agents formatted response in Slack markdown'),
|
|
109
|
+
blocks: z
|
|
110
|
+
.array(z.object({
|
|
111
|
+
type: SlackBlockType,
|
|
112
|
+
text: z
|
|
113
|
+
.object({
|
|
114
|
+
type: z.enum(['plain_text', 'mrkdwn']),
|
|
115
|
+
text: z.string(),
|
|
116
|
+
emoji: z.boolean().optional(),
|
|
117
|
+
verbatim: z.boolean().optional(),
|
|
118
|
+
})
|
|
119
|
+
.optional(),
|
|
120
|
+
block_id: z.string().optional(),
|
|
121
|
+
accessory: z.unknown().optional(),
|
|
122
|
+
fields: z
|
|
123
|
+
.array(z.object({
|
|
124
|
+
type: z.enum(['plain_text', 'mrkdwn']),
|
|
125
|
+
text: z.string(),
|
|
126
|
+
emoji: z.boolean().optional(),
|
|
127
|
+
verbatim: z.boolean().optional(),
|
|
128
|
+
}))
|
|
129
|
+
.optional(),
|
|
130
|
+
element: z.unknown().optional(),
|
|
131
|
+
label: z.unknown().optional(),
|
|
132
|
+
hint: z.unknown().optional(),
|
|
133
|
+
optional: z.boolean().optional(),
|
|
134
|
+
alt_text: z.string().optional(),
|
|
135
|
+
image_url: z.string().optional(),
|
|
136
|
+
title: z
|
|
137
|
+
.object({
|
|
138
|
+
type: z.enum(['plain_text']),
|
|
139
|
+
text: z.string(),
|
|
140
|
+
emoji: z.boolean().optional(),
|
|
141
|
+
})
|
|
142
|
+
.optional(),
|
|
143
|
+
// Add elements field for context blocks
|
|
144
|
+
elements: z
|
|
145
|
+
.array(z.object({
|
|
146
|
+
type: z.enum(['plain_text', 'mrkdwn']),
|
|
147
|
+
text: z.string(),
|
|
148
|
+
emoji: z.boolean().optional(),
|
|
149
|
+
verbatim: z.boolean().optional(),
|
|
150
|
+
}))
|
|
151
|
+
.optional(),
|
|
152
|
+
}))
|
|
153
|
+
.optional()
|
|
154
|
+
.describe('Slack Block Kit formatted blocks for rich message display'),
|
|
155
|
+
metadata: z
|
|
156
|
+
.object({
|
|
157
|
+
verbosityLevel: z.string().describe('Applied verbosity level'),
|
|
158
|
+
technicalityLevel: z.string().describe('Applied technicality level'),
|
|
159
|
+
wordCount: z.number().describe('Total word count of response'),
|
|
160
|
+
blockCount: z
|
|
161
|
+
.number()
|
|
162
|
+
.optional()
|
|
163
|
+
.describe('Number of Slack blocks generated'),
|
|
164
|
+
})
|
|
165
|
+
.describe('Metadata about the formatting'),
|
|
166
|
+
toolCalls: z
|
|
167
|
+
.array(z.object({
|
|
168
|
+
tool: z.string().describe('Name of the tool that was called'),
|
|
169
|
+
input: z.unknown().describe('Input parameters passed to the tool'),
|
|
170
|
+
output: z.unknown().describe('Output returned by the tool'),
|
|
171
|
+
}))
|
|
172
|
+
.optional()
|
|
173
|
+
.describe('Array of tool calls made during the conversation'),
|
|
174
|
+
iterations: z
|
|
175
|
+
.number()
|
|
176
|
+
.describe('Number of back-and-forth iterations in the agent workflow'),
|
|
177
|
+
error: z
|
|
178
|
+
.string()
|
|
179
|
+
.describe('Error message of the run, undefined if successful'),
|
|
180
|
+
success: z
|
|
181
|
+
.boolean()
|
|
182
|
+
.describe('Whether the agent execution completed successfully'),
|
|
183
|
+
});
|
|
184
|
+
export class SlackFormatterAgentBubble extends WorkflowBubble {
|
|
185
|
+
static type = 'service';
|
|
186
|
+
static service = 'slack-formatter-agent';
|
|
187
|
+
static authType = 'apikey';
|
|
188
|
+
static bubbleName = 'slack-formatter-agent';
|
|
189
|
+
static schema = SlackFormatterAgentParamsSchema;
|
|
190
|
+
static resultSchema = SlackFormatterAgentResultSchema;
|
|
191
|
+
static shortDescription = 'AI agent for creating well-formatted Slack messages with adjustable verbosity and technicality';
|
|
192
|
+
static longDescription = `
|
|
193
|
+
An AI agent that specializes in generating properly formatted Slack messages with:
|
|
194
|
+
- Adjustable verbosity levels (1-5): from concise bullet points to comprehensive explanations
|
|
195
|
+
- Adjustable technicality levels (1-5): from plain English to expert terminology
|
|
196
|
+
- Native Slack markdown formatting (bold, italic, code blocks, lists)
|
|
197
|
+
- Optional Slack Block Kit JSON for rich interactive messages
|
|
198
|
+
- Tool integration for dynamic content generation
|
|
199
|
+
|
|
200
|
+
Perfect for:
|
|
201
|
+
- Creating consistent Slack notifications with appropriate detail level
|
|
202
|
+
- Adapting any content for different audiences
|
|
203
|
+
- Generating interactive Slack messages with Block Kit
|
|
204
|
+
- Formatting summaries, reports, and updates for Slack channels
|
|
205
|
+
- Building engaging team communications with proper structure
|
|
206
|
+
- Converting any information into Slack-friendly format
|
|
207
|
+
`;
|
|
208
|
+
static alias = 'slack-format';
|
|
209
|
+
factory;
|
|
210
|
+
constructor(params = {
|
|
211
|
+
message: 'Hello, format this for Slack',
|
|
212
|
+
verbosity: '3',
|
|
213
|
+
technicality: '3',
|
|
214
|
+
}, context) {
|
|
215
|
+
super(params, context);
|
|
216
|
+
this.factory = new BubbleFactory();
|
|
217
|
+
}
|
|
218
|
+
async testCredential() {
|
|
219
|
+
// Make a test API call to the model provider
|
|
220
|
+
const llm = this.initializeModel(this.params.model);
|
|
221
|
+
const response = await llm.invoke(['Hello, test formatting']);
|
|
222
|
+
if (response.content) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
async performAction(context) {
|
|
228
|
+
// Context is available but not currently used in this implementation
|
|
229
|
+
void context;
|
|
230
|
+
const { message, verbosity, technicality, includeBlockKit, model, tools, maxIterations, } = this.params;
|
|
231
|
+
try {
|
|
232
|
+
// Initialize the language model
|
|
233
|
+
const llm = this.initializeModel(model);
|
|
234
|
+
// Initialize tools
|
|
235
|
+
const agentTools = await this.initializeTools(tools);
|
|
236
|
+
// Create the specialized system prompt for Slack formatting
|
|
237
|
+
const systemPrompt = this.createSlackFormatterPrompt(verbosity, technicality, includeBlockKit, this.params.includeQuery, this.params.includeExplanation);
|
|
238
|
+
// Create the agent graph
|
|
239
|
+
const graph = await this.createAgentGraph(llm, agentTools, systemPrompt);
|
|
240
|
+
// Execute the agent
|
|
241
|
+
const result = await this.executeAgent(graph, message, maxIterations);
|
|
242
|
+
// Parse the response to extract blocks if included
|
|
243
|
+
const blocks = includeBlockKit
|
|
244
|
+
? this.extractSlackBlocks(result.response)
|
|
245
|
+
: undefined;
|
|
246
|
+
// Calculate metadata
|
|
247
|
+
const wordCount = result.response.split(/\s+/).length;
|
|
248
|
+
const blockCount = blocks?.length || 0;
|
|
249
|
+
const finalResult = {
|
|
250
|
+
...result,
|
|
251
|
+
blocks,
|
|
252
|
+
metadata: {
|
|
253
|
+
verbosityLevel: verbosity,
|
|
254
|
+
technicalityLevel: technicality,
|
|
255
|
+
wordCount,
|
|
256
|
+
blockCount,
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
return finalResult;
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
return {
|
|
263
|
+
response: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
264
|
+
success: false,
|
|
265
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
266
|
+
iterations: 0,
|
|
267
|
+
metadata: {
|
|
268
|
+
verbosityLevel: verbosity,
|
|
269
|
+
technicalityLevel: technicality,
|
|
270
|
+
wordCount: 0,
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
chooseCredential() {
|
|
276
|
+
const { model } = this.params;
|
|
277
|
+
const credentials = this.params.credentials;
|
|
278
|
+
const [provider] = model.model.split('/');
|
|
279
|
+
// If no credentials were injected, throw error immediately
|
|
280
|
+
if (!credentials || typeof credentials !== 'object') {
|
|
281
|
+
throw new Error(`No ${provider.toUpperCase()} credentials provided`);
|
|
282
|
+
}
|
|
283
|
+
// Choose credential based on the model provider
|
|
284
|
+
switch (provider) {
|
|
285
|
+
case 'openai':
|
|
286
|
+
return credentials[CredentialType.OPENAI_CRED];
|
|
287
|
+
case 'google':
|
|
288
|
+
return credentials[CredentialType.GOOGLE_GEMINI_CRED];
|
|
289
|
+
default:
|
|
290
|
+
throw new Error(`Unsupported model provider: ${provider}`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
createSlackFormatterPrompt(verbosity, technicality, includeBlockKit, includeQuery, includeExplanation) {
|
|
294
|
+
const verbosityDescriptions = {
|
|
295
|
+
'1': 'very concise - key numbers only, minimal text',
|
|
296
|
+
'2': 'brief - essential points in short sentences',
|
|
297
|
+
'3': 'balanced - clear but not lengthy',
|
|
298
|
+
'4': 'detailed - thorough coverage without excess',
|
|
299
|
+
'5': 'comprehensive - complete analysis when needed',
|
|
300
|
+
};
|
|
301
|
+
const technicalityDescriptions = {
|
|
302
|
+
'1': 'non-technical - plain English, no jargon, explain like to a child',
|
|
303
|
+
'2': 'basic - simple terms, minimal technical language',
|
|
304
|
+
'3': 'intermediate - some technical terms with brief explanations',
|
|
305
|
+
'4': 'advanced - technical language appropriate for professionals',
|
|
306
|
+
'5': 'expert - full technical terminology and complex concepts',
|
|
307
|
+
};
|
|
308
|
+
let prompt = `You're a helpful assistant who communicates clearly and effectively. Always be precise but accessible, proactive about providing context, and comfortable admitting limitations when information is incomplete.
|
|
309
|
+
|
|
310
|
+
Additional context:
|
|
311
|
+
${this.params.additionalContext}
|
|
312
|
+
|
|
313
|
+
**Core principles (apply regardless of verbosity):**
|
|
314
|
+
- Be precise but accessible - use specific details and clear explanations
|
|
315
|
+
- Proactively provide relevant context and background information
|
|
316
|
+
- Comfortable admitting when information is incomplete or uncertain
|
|
317
|
+
- Always clarify key definitions, timeframes, and important assumptions
|
|
318
|
+
|
|
319
|
+
**Response style:**
|
|
320
|
+
- Verbosity: ${verbosityDescriptions[verbosity]}
|
|
321
|
+
- Technical level: ${technicalityDescriptions[technicality]}
|
|
322
|
+
|
|
323
|
+
Use standard Slack formatting (*bold*, _italic_, \`code\`) and structure your response:
|
|
324
|
+
`;
|
|
325
|
+
// Add verbosity-specific guidelines
|
|
326
|
+
switch (verbosity) {
|
|
327
|
+
case '1':
|
|
328
|
+
prompt += `
|
|
329
|
+
- Numbers and key finding only
|
|
330
|
+
- Single line answers when possible`;
|
|
331
|
+
break;
|
|
332
|
+
case '2':
|
|
333
|
+
prompt += `
|
|
334
|
+
- Essential findings in 2-3 short sentences
|
|
335
|
+
- Focus on what matters most`;
|
|
336
|
+
break;
|
|
337
|
+
case '3':
|
|
338
|
+
prompt += `
|
|
339
|
+
- Clear summary with necessary context
|
|
340
|
+
- Key insights without extra detail`;
|
|
341
|
+
break;
|
|
342
|
+
case '4':
|
|
343
|
+
prompt += `
|
|
344
|
+
- Thorough analysis with supporting data
|
|
345
|
+
- Include trends and implications concisely`;
|
|
346
|
+
break;
|
|
347
|
+
case '5':
|
|
348
|
+
prompt += `
|
|
349
|
+
- Comprehensive analysis when complexity requires it
|
|
350
|
+
- Include methodology only when essential`;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
prompt += `\n\n**Technical approach:**\n`;
|
|
354
|
+
switch (technicality) {
|
|
355
|
+
case '1':
|
|
356
|
+
prompt += `
|
|
357
|
+
- Plain language, avoid technical jargon
|
|
358
|
+
- Focus on practical impact and implications`;
|
|
359
|
+
break;
|
|
360
|
+
case '2':
|
|
361
|
+
prompt += `
|
|
362
|
+
- Basic terminology with simple explanations
|
|
363
|
+
- Connect information to relevant outcomes`;
|
|
364
|
+
break;
|
|
365
|
+
case '3':
|
|
366
|
+
prompt += `
|
|
367
|
+
- Standard terms with brief explanations when needed
|
|
368
|
+
- Balance technical accuracy with clarity`;
|
|
369
|
+
break;
|
|
370
|
+
case '4':
|
|
371
|
+
prompt += `
|
|
372
|
+
- Professional terminology appropriate for the domain
|
|
373
|
+
- Include methodology and process notes when relevant`;
|
|
374
|
+
break;
|
|
375
|
+
case '5':
|
|
376
|
+
prompt += `
|
|
377
|
+
- Full technical vocabulary and detailed methods
|
|
378
|
+
- Include limitations, assumptions, and methodological details`;
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
if (includeBlockKit) {
|
|
382
|
+
prompt += `
|
|
383
|
+
|
|
384
|
+
IMPORTANT: After your formatted message, include a section labeled "SLACK_BLOCKS_JSON" with a valid JSON array of Slack Block Kit blocks.
|
|
385
|
+
|
|
386
|
+
Block Kit Guidelines:
|
|
387
|
+
- Use section blocks for main content
|
|
388
|
+
- Use header blocks for titles (max 150 chars)
|
|
389
|
+
- Use divider blocks to separate sections
|
|
390
|
+
- Use context blocks for metadata or footnotes (ONLY if you have actual content for them)
|
|
391
|
+
- Include mrkdwn formatting in text objects
|
|
392
|
+
- Ensure all JSON is valid and properly escaped
|
|
393
|
+
- DO NOT include empty context blocks - omit them entirely if you have no context to add
|
|
394
|
+
|
|
395
|
+
Example structure:
|
|
396
|
+
\`\`\`json
|
|
397
|
+
[
|
|
398
|
+
{
|
|
399
|
+
"type": "header",
|
|
400
|
+
"text": {
|
|
401
|
+
"type": "plain_text",
|
|
402
|
+
"text": "Title Here",
|
|
403
|
+
"emoji": true
|
|
404
|
+
}
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
"type": "section",
|
|
408
|
+
"text": {
|
|
409
|
+
"type": "mrkdwn",
|
|
410
|
+
"text": "*Bold text* and _italic text_ with \`code\`"
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
"type": "context",
|
|
415
|
+
"elements": [
|
|
416
|
+
{
|
|
417
|
+
"type": "mrkdwn",
|
|
418
|
+
"text": "Context information here"
|
|
419
|
+
}
|
|
420
|
+
]
|
|
421
|
+
}
|
|
422
|
+
]
|
|
423
|
+
\`\`\`
|
|
424
|
+
|
|
425
|
+
CRITICAL: For context blocks, ensure the "elements" field is always an ARRAY of objects, never a single object.`;
|
|
426
|
+
}
|
|
427
|
+
// Add query and explanation instructions
|
|
428
|
+
if (includeQuery || includeExplanation) {
|
|
429
|
+
prompt += `
|
|
430
|
+
|
|
431
|
+
**Query Information:**`;
|
|
432
|
+
if (includeQuery) {
|
|
433
|
+
prompt += `
|
|
434
|
+
- Always include the actual query that was executed (SQL, API call, etc.)
|
|
435
|
+
- Show it in a code block with proper formatting`;
|
|
436
|
+
}
|
|
437
|
+
if (includeExplanation) {
|
|
438
|
+
prompt += `
|
|
439
|
+
- Explain what the query does and why this approach was chosen
|
|
440
|
+
- Include any important query logic or filtering decisions`;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
prompt += `
|
|
444
|
+
|
|
445
|
+
**Important practices:**
|
|
446
|
+
- Always clarify key definitions and assumptions (e.g., "Recent means within last 30 days")
|
|
447
|
+
- Explain scope, boundaries, and time periods clearly
|
|
448
|
+
- Add quick notes about how information was gathered or processed when relevant
|
|
449
|
+
- Mention limitations or uncertainties naturally
|
|
450
|
+
|
|
451
|
+
Make your response clear and actionable.`;
|
|
452
|
+
return prompt;
|
|
453
|
+
}
|
|
454
|
+
initializeModel(modelConfig) {
|
|
455
|
+
const { model, temperature, maxTokens } = modelConfig;
|
|
456
|
+
const [provider, modelName] = model.split('/');
|
|
457
|
+
// Use chooseCredential to get the appropriate credential
|
|
458
|
+
const apiKey = this.chooseCredential();
|
|
459
|
+
switch (provider) {
|
|
460
|
+
case 'openai':
|
|
461
|
+
return new ChatOpenAI({
|
|
462
|
+
model: modelName,
|
|
463
|
+
temperature,
|
|
464
|
+
maxTokens,
|
|
465
|
+
apiKey,
|
|
466
|
+
});
|
|
467
|
+
case 'google':
|
|
468
|
+
return new ChatGoogleGenerativeAI({
|
|
469
|
+
model: modelName,
|
|
470
|
+
temperature,
|
|
471
|
+
maxOutputTokens: maxTokens,
|
|
472
|
+
apiKey,
|
|
473
|
+
});
|
|
474
|
+
default:
|
|
475
|
+
throw new Error(`Unsupported model provider: ${provider}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
async initializeTools(toolConfigs) {
|
|
479
|
+
const tools = [];
|
|
480
|
+
await this.factory.registerDefaults();
|
|
481
|
+
for (const toolConfig of toolConfigs) {
|
|
482
|
+
try {
|
|
483
|
+
// Get the tool bubble class from the factory
|
|
484
|
+
const ToolBubbleClass = this.factory.get(toolConfig.name);
|
|
485
|
+
if (!ToolBubbleClass) {
|
|
486
|
+
console.warn(`Tool bubble '${toolConfig.name}' not found in factory`);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
// Check if it's a tool bubble (has toAgentTool method)
|
|
490
|
+
if (!('type' in ToolBubbleClass) || ToolBubbleClass.type !== 'tool') {
|
|
491
|
+
console.warn(`Bubble '${toolConfig.name}' is not a tool bubble`);
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
// Convert to LangGraph tool and add to tools array
|
|
495
|
+
if (!ToolBubbleClass.toolAgent) {
|
|
496
|
+
console.warn(`Tool bubble '${toolConfig.name}' does not have a toolAgent method`);
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
const langGraphTool = ToolBubbleClass.toolAgent(toolConfig.credentials || {}, toolConfig.config || {});
|
|
500
|
+
// Convert LangGraph tool to DynamicStructuredTool for compatibility
|
|
501
|
+
const dynamicTool = new DynamicStructuredTool({
|
|
502
|
+
name: langGraphTool.name,
|
|
503
|
+
description: langGraphTool.description,
|
|
504
|
+
schema: langGraphTool.schema,
|
|
505
|
+
func: langGraphTool.func,
|
|
506
|
+
});
|
|
507
|
+
tools.push(dynamicTool);
|
|
508
|
+
}
|
|
509
|
+
catch (error) {
|
|
510
|
+
console.error(`Error initializing tool '${toolConfig.name}':`, error);
|
|
511
|
+
continue;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return tools;
|
|
515
|
+
}
|
|
516
|
+
async createAgentGraph(llm, tools, systemPrompt) {
|
|
517
|
+
// Define the agent node
|
|
518
|
+
const agentNode = async ({ messages }) => {
|
|
519
|
+
const systemMessage = new HumanMessage(systemPrompt);
|
|
520
|
+
const allMessages = [systemMessage, ...messages];
|
|
521
|
+
// If we have tools, bind them to the LLM
|
|
522
|
+
const modelWithTools = tools.length > 0 ? llm.bindTools(tools) : llm;
|
|
523
|
+
const response = await modelWithTools.invoke(allMessages);
|
|
524
|
+
return { messages: [response] };
|
|
525
|
+
};
|
|
526
|
+
// Define conditional edge function
|
|
527
|
+
const shouldContinue = ({ messages }) => {
|
|
528
|
+
const lastMessage = messages[messages.length - 1];
|
|
529
|
+
// Check if the last message has tool calls
|
|
530
|
+
if (lastMessage.tool_calls && lastMessage.tool_calls.length > 0) {
|
|
531
|
+
return 'tools';
|
|
532
|
+
}
|
|
533
|
+
return '__end__';
|
|
534
|
+
};
|
|
535
|
+
// Build the graph
|
|
536
|
+
const graph = new StateGraph(MessagesAnnotation).addNode('agent', agentNode);
|
|
537
|
+
if (tools.length > 0) {
|
|
538
|
+
// Use the official ToolNode for tool execution
|
|
539
|
+
const toolNode = new ToolNode(tools);
|
|
540
|
+
graph
|
|
541
|
+
.addNode('tools', toolNode)
|
|
542
|
+
.addEdge('__start__', 'agent')
|
|
543
|
+
.addConditionalEdges('agent', shouldContinue)
|
|
544
|
+
.addEdge('tools', 'agent');
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
graph.addEdge('__start__', 'agent').addEdge('agent', '__end__');
|
|
548
|
+
}
|
|
549
|
+
return graph.compile();
|
|
550
|
+
}
|
|
551
|
+
async executeAgent(graph, message, maxIterations) {
|
|
552
|
+
const toolCalls = [];
|
|
553
|
+
let iterations = 0;
|
|
554
|
+
try {
|
|
555
|
+
const result = await graph.invoke({ messages: [new HumanMessage(message)] }, { recursionLimit: maxIterations });
|
|
556
|
+
iterations = result.messages.length;
|
|
557
|
+
// Extract tool calls from messages
|
|
558
|
+
const toolCallMap = new Map();
|
|
559
|
+
for (let i = 0; i < result.messages.length; i++) {
|
|
560
|
+
const msg = result.messages[i];
|
|
561
|
+
if (msg instanceof AIMessage && msg.tool_calls) {
|
|
562
|
+
const typedToolCalls = msg.tool_calls;
|
|
563
|
+
for (const toolCall of typedToolCalls) {
|
|
564
|
+
toolCallMap.set(toolCall.id, {
|
|
565
|
+
name: toolCall.name,
|
|
566
|
+
args: toolCall.args,
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
else if (msg instanceof ToolMessage) {
|
|
571
|
+
// Match tool response to its call
|
|
572
|
+
const toolCall = toolCallMap.get(msg.tool_call_id);
|
|
573
|
+
if (toolCall) {
|
|
574
|
+
// Parse content if it's a JSON string
|
|
575
|
+
let output = msg.content;
|
|
576
|
+
if (typeof output === 'string') {
|
|
577
|
+
try {
|
|
578
|
+
output = JSON.parse(output);
|
|
579
|
+
}
|
|
580
|
+
catch {
|
|
581
|
+
// Keep as string if not valid JSON
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
toolCalls.push({
|
|
585
|
+
tool: toolCall.name,
|
|
586
|
+
input: toolCall.args,
|
|
587
|
+
output,
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
// Get the final AI message response
|
|
593
|
+
const aiMessages = result.messages.filter((msg) => msg instanceof AIMessage);
|
|
594
|
+
const finalMessage = aiMessages[aiMessages.length - 1];
|
|
595
|
+
// Check for MAX_TOKENS finish reason
|
|
596
|
+
if (finalMessage?.additional_kwargs?.finishReason === 'MAX_TOKENS') {
|
|
597
|
+
throw new Error('Response was truncated due to max tokens limit. Please increase maxTokens in model configuration.');
|
|
598
|
+
}
|
|
599
|
+
const response = finalMessage?.content || 'No response generated';
|
|
600
|
+
return {
|
|
601
|
+
response: typeof response === 'string' ? response : JSON.stringify(response),
|
|
602
|
+
toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
603
|
+
iterations,
|
|
604
|
+
error: '',
|
|
605
|
+
success: true,
|
|
606
|
+
metadata: {
|
|
607
|
+
verbosityLevel: '3',
|
|
608
|
+
technicalityLevel: '3',
|
|
609
|
+
wordCount: 0,
|
|
610
|
+
},
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
return {
|
|
615
|
+
response: `Execution error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
616
|
+
success: false,
|
|
617
|
+
iterations,
|
|
618
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
619
|
+
metadata: {
|
|
620
|
+
verbosityLevel: '3',
|
|
621
|
+
technicalityLevel: '3',
|
|
622
|
+
wordCount: 0,
|
|
623
|
+
},
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
extractSlackBlocks(response) {
|
|
628
|
+
try {
|
|
629
|
+
// Look for the SLACK_BLOCKS_JSON section
|
|
630
|
+
const jsonMatch = response.match(/SLACK_BLOCKS_JSON[\s\S]*?```json\n([\s\S]*?)\n```/);
|
|
631
|
+
if (!jsonMatch || !jsonMatch[1]) {
|
|
632
|
+
// Try to find any JSON code block that looks like Slack blocks
|
|
633
|
+
const anyJsonMatch = response.match(/```json\n(\[[\s\S]*?\])\n```/);
|
|
634
|
+
if (anyJsonMatch && anyJsonMatch[1]) {
|
|
635
|
+
const parsed = JSON.parse(anyJsonMatch[1]);
|
|
636
|
+
if (Array.isArray(parsed) && parsed.length > 0 && parsed[0].type) {
|
|
637
|
+
return this.validateAndFixSlackBlocks(parsed);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
return undefined;
|
|
641
|
+
}
|
|
642
|
+
const blocksJson = jsonMatch[1];
|
|
643
|
+
const blocks = JSON.parse(blocksJson);
|
|
644
|
+
if (!Array.isArray(blocks)) {
|
|
645
|
+
console.warn('Slack blocks JSON is not an array');
|
|
646
|
+
return undefined;
|
|
647
|
+
}
|
|
648
|
+
return this.validateAndFixSlackBlocks(blocks);
|
|
649
|
+
}
|
|
650
|
+
catch (error) {
|
|
651
|
+
console.warn('Failed to extract Slack blocks from response:', error);
|
|
652
|
+
return undefined;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
validateAndFixSlackBlocks(blocks) {
|
|
656
|
+
const processedBlocks = blocks.map((block) => {
|
|
657
|
+
// Fix context blocks - they must have elements field
|
|
658
|
+
if (block.type === 'context') {
|
|
659
|
+
if (!block.elements) {
|
|
660
|
+
// If no elements at all, remove this block entirely
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
// If elements is not an array, wrap it in an array
|
|
664
|
+
if (!Array.isArray(block.elements)) {
|
|
665
|
+
block.elements = [block.elements];
|
|
666
|
+
}
|
|
667
|
+
// Ensure each element has proper structure
|
|
668
|
+
block.elements = block.elements.map((element) => {
|
|
669
|
+
if (typeof element === 'object' && element.text && !element.type) {
|
|
670
|
+
return {
|
|
671
|
+
type: 'mrkdwn',
|
|
672
|
+
text: element.text,
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
return element;
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
// Validate other required fields
|
|
679
|
+
if (block.type === 'header' && block.text && !block.text.type) {
|
|
680
|
+
block.text.type = 'plain_text';
|
|
681
|
+
}
|
|
682
|
+
if (block.type === 'section' && block.text && !block.text.type) {
|
|
683
|
+
block.text.type = 'mrkdwn';
|
|
684
|
+
}
|
|
685
|
+
return block;
|
|
686
|
+
});
|
|
687
|
+
return processedBlocks.filter((block) => block !== null); // Remove null blocks
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
//# sourceMappingURL=slack-formatter-agent.js.map
|