@cursor/july 0.1.97 → 0.1.100
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/AGENTS.md +5 -3
- package/dist/bin/agent-serve.js +6 -7
- package/dist/channels/github/defaults.d.ts.map +1 -1
- package/dist/channels/github/defaults.js +28 -3
- package/dist/channels/github/github-channel.d.ts.map +1 -1
- package/dist/channels/github/github-channel.js +16 -0
- package/dist/channels/github/progress.d.ts +7 -0
- package/dist/channels/github/progress.d.ts.map +1 -1
- package/dist/channels/origin/origin-channel.d.ts +2 -0
- package/dist/channels/origin/origin-channel.d.ts.map +1 -1
- package/dist/channels/origin/origin-channel.js +37 -4
- package/dist/channels/slack/api.d.ts +16 -7
- package/dist/channels/slack/api.d.ts.map +1 -1
- package/dist/channels/slack/api.js +29 -13
- package/dist/channels/slack/constants.d.ts +6 -0
- package/dist/channels/slack/constants.d.ts.map +1 -1
- package/dist/channels/slack/constants.js +6 -0
- package/dist/channels/slack/defaults.d.ts +9 -4
- package/dist/channels/slack/defaults.d.ts.map +1 -1
- package/dist/channels/slack/defaults.js +221 -122
- package/dist/channels/slack/dispatch.d.ts.map +1 -1
- package/dist/channels/slack/dispatch.js +3 -3
- package/dist/channels/slack/inbound.d.ts +9 -0
- package/dist/channels/slack/inbound.d.ts.map +1 -1
- package/dist/channels/slack/inbound.js +14 -0
- package/dist/channels/slack/index.d.ts +1 -0
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +1 -0
- package/dist/channels/slack/live-delivery.d.ts +6 -1
- package/dist/channels/slack/live-delivery.d.ts.map +1 -1
- package/dist/channels/slack/live-delivery.js +110 -20
- package/dist/channels/slack/progress-delivery.d.ts +28 -0
- package/dist/channels/slack/progress-delivery.d.ts.map +1 -0
- package/dist/channels/slack/progress-delivery.js +115 -0
- package/dist/channels/slack/reasoning-card.d.ts +38 -0
- package/dist/channels/slack/reasoning-card.d.ts.map +1 -0
- package/dist/channels/slack/reasoning-card.js +104 -0
- package/dist/channels/slack/redact.d.ts +2 -0
- package/dist/channels/slack/redact.d.ts.map +1 -0
- package/dist/channels/slack/redact.js +5 -0
- package/dist/channels/slack/reply-options.d.ts +40 -0
- package/dist/channels/slack/reply-options.d.ts.map +1 -0
- package/dist/channels/slack/reply-options.js +150 -0
- package/dist/channels/slack/slack-channel.d.ts.map +1 -1
- package/dist/channels/slack/slack-channel.js +8 -4
- package/dist/channels/slack/stream.d.ts +22 -10
- package/dist/channels/slack/stream.d.ts.map +1 -1
- package/dist/channels/slack/stream.js +9 -16
- package/dist/channels/slack/tool-cards.d.ts +22 -0
- package/dist/channels/slack/tool-cards.d.ts.map +1 -0
- package/dist/channels/slack/tool-cards.js +178 -0
- package/dist/channels/slack/types.d.ts +154 -7
- package/dist/channels/slack/types.d.ts.map +1 -1
- package/dist/docs/404.html +2 -2
- package/dist/docs/ab.html +6 -6
- package/dist/docs/ab.md +1 -1
- package/dist/docs/assets/{ab.md.DJo5r4R-.js → ab.md.mlVgqvSk.js} +1 -1
- package/dist/docs/assets/{app.B3rWNYE1.js → app.DZ1e0Ycq.js} +1 -1
- package/dist/docs/assets/{building-with-agents.md.DI4mEzlt.js → building-with-agents.md.CUSWxlP_.js} +2 -2
- package/dist/docs/assets/chunks/@localSearchIndexroot.j70vvPL4.js +1 -0
- package/dist/docs/assets/chunks/{VPLocalSearchBox.C1lhqJJR.js → VPLocalSearchBox.l8omwc6D.js} +1 -1
- package/dist/docs/assets/chunks/{theme.B40_SXuv.js → theme.JVcD6gel.js} +2 -2
- package/dist/docs/assets/{evals.md.lfJoEVc8.js → evals.md.CPzDAwoH.js} +1 -1
- package/dist/docs/assets/{guides_github.md.Cnh2mL4a.js → guides_github.md.BtPr9GaP.js} +1 -1
- package/dist/docs/assets/{guides_mcp-oauth.md.CN-6YmTJ.js → guides_mcp-oauth.md.Dp6cDP7f.js} +1 -1
- package/dist/docs/assets/{guides_opentelemetry.md.bmPmkvJu.js → guides_opentelemetry.md.BVTXDCRg.js} +2 -2
- package/dist/docs/assets/{guides_slack.md.VDXQV3ja.js → guides_slack.md.9oHPye9o.js} +19 -3
- package/dist/docs/assets/{guides_slack.md.VDXQV3ja.lean.js → guides_slack.md.9oHPye9o.lean.js} +1 -1
- package/dist/docs/assets/hillclimbing.md.CpTGTCle.js +4 -0
- package/dist/docs/assets/{index.md.CVeRUOeZ.js → index.md.Bb4k8kUm.js} +1 -1
- package/dist/docs/assets/{quickstart.md.Nj_LjW_a.js → quickstart.md.DdQOF7Y8.js} +1 -1
- package/dist/docs/assets/{reference_cli.md.RyZf5OTE.js → reference_cli.md.DfoeyvL0.js} +4 -4
- package/dist/docs/assets/{reference_cli.md.RyZf5OTE.lean.js → reference_cli.md.DfoeyvL0.lean.js} +1 -1
- package/dist/docs/assets/{reference_connections.md.DxldvyIB.js → reference_connections.md.BiGoBAk2.js} +1 -1
- package/dist/docs/assets/{reference_http-api.md.5zOAbV86.js → reference_http-api.md.BEJx9XVj.js} +1 -1
- package/dist/docs/assets/{reference_tools.md.B84gw9Ii.js → reference_tools.md.CvAHsdSp.js} +10 -2
- package/dist/docs/assets/{reference_tools.md.B84gw9Ii.lean.js → reference_tools.md.CvAHsdSp.lean.js} +1 -1
- package/dist/docs/assets/scaffolding-agents.md.em43xlY1.js +1 -0
- package/dist/docs/assets/skills_ab.md.CsFNatVx.js +26 -0
- package/dist/docs/assets/skills_ab.md.CsFNatVx.lean.js +1 -0
- package/dist/docs/assets/skills_create-agent.md.BVoWPcan.js +8 -0
- package/dist/docs/assets/skills_create-agent.md.BVoWPcan.lean.js +1 -0
- package/dist/docs/assets/skills_debug.md.CDbPhHfg.js +1 -0
- package/dist/docs/assets/skills_debug.md.CDbPhHfg.lean.js +1 -0
- package/dist/docs/assets/skills_evals.md.723kpUmA.js +25 -0
- package/dist/docs/assets/skills_evals.md.723kpUmA.lean.js +1 -0
- package/dist/docs/assets/skills_framework-map.md.BTi817yv.js +1 -0
- package/dist/docs/assets/skills_framework-map.md.BTi817yv.lean.js +1 -0
- package/dist/docs/assets/skills_github.md.D0JahM8c.js +16 -0
- package/dist/docs/assets/skills_github.md.D0JahM8c.lean.js +1 -0
- package/dist/docs/assets/skills_hillclimb.md.B_zJerxA.js +7 -0
- package/dist/docs/assets/skills_hillclimb.md.B_zJerxA.lean.js +1 -0
- package/dist/docs/assets/skills_index.md.DKwIxzGg.js +1 -0
- package/dist/docs/assets/skills_index.md.DKwIxzGg.lean.js +1 -0
- package/dist/docs/assets/skills_mcp-auth.md.DGvFP3HE.js +18 -0
- package/dist/docs/assets/skills_mcp-auth.md.DGvFP3HE.lean.js +1 -0
- package/dist/docs/assets/skills_otel.md.CgiZryR3.js +8 -0
- package/dist/docs/assets/skills_otel.md.CgiZryR3.lean.js +1 -0
- package/dist/docs/assets/skills_setup-slack.md.BBgx8lUz.js +20 -0
- package/dist/docs/assets/skills_setup-slack.md.BBgx8lUz.lean.js +1 -0
- package/dist/docs/assets/{troubleshooting.md.DCiPBhYs.js → troubleshooting.md.Cus_YZga.js} +1 -1
- package/dist/docs/building-with-agents.html +6 -6
- package/dist/docs/building-with-agents.md +14 -11
- package/dist/docs/concepts.html +4 -4
- package/dist/docs/deployment.html +4 -4
- package/dist/docs/design/runtime-abstraction.md +1757 -0
- package/dist/docs/evals.html +6 -6
- package/dist/docs/evals.md +1 -1
- package/dist/docs/guides/agent-to-agent.html +4 -4
- package/dist/docs/guides/cloud-runtime.html +4 -4
- package/dist/docs/guides/convert-automation.html +4 -4
- package/dist/docs/guides/github.html +5 -5
- package/dist/docs/guides/github.md +1 -1
- package/dist/docs/guides/human-in-the-loop.html +4 -4
- package/dist/docs/guides/mcp-oauth.html +5 -5
- package/dist/docs/guides/mcp-oauth.md +1 -1
- package/dist/docs/guides/opentelemetry.html +7 -7
- package/dist/docs/guides/opentelemetry.md +2 -2
- package/dist/docs/guides/slack.html +22 -6
- package/dist/docs/guides/slack.md +80 -1
- package/dist/docs/guides/webhooks.html +5 -5
- package/dist/docs/hashmap.json +1 -1
- package/dist/docs/hillclimbing.html +6 -6
- package/dist/docs/hillclimbing.md +5 -5
- package/dist/docs/index.html +6 -6
- package/dist/docs/index.md +1 -1
- package/dist/docs/llms-full.txt +2830 -37
- package/dist/docs/llms.txt +15 -0
- package/dist/docs/quickstart.html +5 -5
- package/dist/docs/quickstart.md +1 -1
- package/dist/docs/reference/agent-config.html +4 -4
- package/dist/docs/reference/artifacts.html +4 -4
- package/dist/docs/reference/channels.html +4 -4
- package/dist/docs/reference/cli.html +7 -7
- package/dist/docs/reference/cli.md +1 -7
- package/dist/docs/reference/connections.html +6 -6
- package/dist/docs/reference/connections.md +1 -1
- package/dist/docs/reference/hooks.html +4 -4
- package/dist/docs/reference/http-api.html +6 -6
- package/dist/docs/reference/http-api.md +1 -0
- package/dist/docs/reference/instructions.html +4 -4
- package/dist/docs/reference/playground.html +4 -4
- package/dist/docs/reference/project-layout.html +4 -4
- package/dist/docs/reference/prompt.html +4 -4
- package/dist/docs/reference/schedules.html +4 -4
- package/dist/docs/reference/sessions.html +4 -4
- package/dist/docs/reference/skills.html +4 -4
- package/dist/docs/reference/subagents.html +4 -4
- package/dist/docs/reference/tools.html +14 -6
- package/dist/docs/reference/tools.md +25 -0
- package/dist/docs/scaffolding-agents.html +5 -5
- package/dist/docs/scaffolding-agents.md +3 -3
- package/dist/docs/skills/ab.html +52 -0
- package/dist/docs/skills/ab.md +50 -0
- package/dist/docs/skills/create-agent.html +34 -0
- package/dist/docs/skills/create-agent.md +160 -0
- package/dist/docs/skills/debug.html +27 -0
- package/dist/docs/skills/debug.md +36 -0
- package/dist/docs/skills/evals.html +51 -0
- package/dist/docs/skills/evals.md +99 -0
- package/dist/docs/skills/framework-map.html +27 -0
- package/dist/docs/skills/framework-map.md +95 -0
- package/dist/docs/skills/github.html +42 -0
- package/dist/docs/skills/github.md +93 -0
- package/dist/docs/skills/hillclimb.html +33 -0
- package/dist/docs/skills/hillclimb.md +55 -0
- package/dist/docs/skills/index.html +27 -0
- package/dist/docs/skills/index.md +21 -0
- package/dist/docs/skills/mcp-auth.html +44 -0
- package/dist/docs/skills/mcp-auth.md +76 -0
- package/dist/docs/skills/otel.html +34 -0
- package/dist/docs/skills/otel.md +48 -0
- package/dist/docs/skills/setup-slack.html +46 -0
- package/dist/docs/skills/setup-slack.md +141 -0
- package/dist/docs/storage.html +4 -4
- package/dist/docs/templates/agentic-owners.html +4 -4
- package/dist/docs/templates/agents-md.html +4 -4
- package/dist/docs/templates/code-wiki.html +4 -4
- package/dist/docs/templates/demo.html +4 -4
- package/dist/docs/templates/pr-autofixer.html +4 -4
- package/dist/docs/templates/security-help.html +4 -4
- package/dist/docs/templates/security-reviewer.html +4 -4
- package/dist/docs/templates/triage.html +4 -4
- package/dist/docs/troubleshooting.html +5 -5
- package/dist/docs/troubleshooting.md +1 -1
- package/dist/files-backends/cursor-hosted.d.ts +9 -2
- package/dist/files-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/files-backends/cursor-hosted.js +9 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internal/as-of.d.ts +19 -0
- package/dist/internal/as-of.d.ts.map +1 -0
- package/dist/internal/as-of.js +82 -0
- package/dist/internal/cli-deploy.d.ts +2 -1
- package/dist/internal/cli-deploy.d.ts.map +1 -1
- package/dist/internal/cli-deploy.js +102 -7
- package/dist/internal/conversation-mirror.d.ts.map +1 -1
- package/dist/internal/conversation-mirror.js +3 -4
- package/dist/internal/cursor/hosted-store-secrets.d.ts +15 -0
- package/dist/internal/cursor/hosted-store-secrets.d.ts.map +1 -0
- package/dist/internal/cursor/hosted-store-secrets.js +48 -0
- package/dist/internal/cursor-event-relay.d.ts.map +1 -1
- package/dist/internal/cursor-event-relay.js +5 -6
- package/dist/internal/deploy-client.d.ts +6 -6
- package/dist/internal/deploy-client.js +7 -7
- package/dist/internal/discovery.d.ts.map +1 -1
- package/dist/internal/discovery.js +11 -1
- package/dist/internal/framework-file-storage.d.ts +5 -4
- package/dist/internal/framework-file-storage.d.ts.map +1 -1
- package/dist/internal/framework-file-storage.js +6 -4
- package/dist/internal/framework-storage-selection.d.ts +13 -11
- package/dist/internal/framework-storage-selection.d.ts.map +1 -1
- package/dist/internal/framework-storage-selection.js +28 -23
- package/dist/internal/hosted-admission-adapter.d.ts +28 -0
- package/dist/internal/hosted-admission-adapter.d.ts.map +1 -0
- package/dist/internal/hosted-admission-adapter.js +7 -0
- package/dist/internal/hosted-delivery-protocol.d.ts +6 -1
- package/dist/internal/hosted-delivery-protocol.d.ts.map +1 -1
- package/dist/internal/hosted-delivery-protocol.js +1 -1
- package/dist/internal/hosted-delivery.d.ts +15 -1
- package/dist/internal/hosted-delivery.d.ts.map +1 -1
- package/dist/internal/hosted-delivery.js +47 -21
- package/dist/internal/hosted-execution-diag.d.ts +11 -0
- package/dist/internal/hosted-execution-diag.d.ts.map +1 -1
- package/dist/internal/hosted-execution-diag.js +39 -2
- package/dist/internal/http-channel.d.ts.map +1 -1
- package/dist/internal/http-channel.js +4 -1
- package/dist/internal/server.d.ts +3 -0
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +82 -19
- package/dist/internal/session-engine.d.ts.map +1 -1
- package/dist/internal/session-engine.js +24 -4
- package/dist/internal/session-run-log.d.ts +120 -0
- package/dist/internal/session-run-log.d.ts.map +1 -0
- package/dist/internal/session-run-log.js +358 -0
- package/dist/internal/tool-policy.d.ts +20 -8
- package/dist/internal/tool-policy.d.ts.map +1 -1
- package/dist/internal/tool-policy.js +11 -0
- package/dist/playground/assets/index-BszoQDc6.css +1 -0
- package/dist/playground/assets/index-DVs98vPL.js +69 -0
- package/dist/playground/index.html +2 -2
- package/dist/storage-backends/cursor-hosted-v2.d.ts +83 -0
- package/dist/storage-backends/cursor-hosted-v2.d.ts.map +1 -0
- package/dist/storage-backends/cursor-hosted-v2.js +164 -0
- package/dist/storage-backends/cursor-hosted.d.ts +6 -0
- package/dist/storage-backends/cursor-hosted.d.ts.map +1 -1
- package/dist/storage-backends/cursor-hosted.js +6 -1
- package/dist/storage-protocol.d.ts +8 -0
- package/dist/storage-protocol.d.ts.map +1 -1
- package/dist/storage-protocol.js +8 -0
- package/dist/tools.d.ts +12 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/types.d.ts +30 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +1 -1
- package/docs/ab.md +1 -1
- package/docs/building-with-agents.md +14 -11
- package/docs/design/runtime-abstraction.md +1757 -0
- package/docs/evals.md +1 -1
- package/docs/guides/github.md +1 -1
- package/docs/guides/mcp-oauth.md +1 -1
- package/docs/guides/opentelemetry.md +2 -2
- package/docs/guides/slack.md +80 -1
- package/docs/hillclimbing.md +5 -5
- package/docs/quickstart.md +1 -1
- package/docs/reference/cli.md +1 -7
- package/docs/reference/connections.md +1 -1
- package/docs/reference/http-api.md +1 -0
- package/docs/reference/tools.md +25 -0
- package/docs/scaffolding-agents.md +3 -3
- package/docs/skills/index.md +26 -0
- package/docs/troubleshooting.md +1 -1
- package/package.json +1 -1
- package/src/bin/agent-serve.ts +6 -7
- package/src/channels/github/defaults.ts +36 -3
- package/src/channels/github/github-channel.ts +17 -0
- package/src/channels/github/progress.ts +7 -0
- package/src/channels/origin/origin-channel.ts +74 -10
- package/src/channels/slack/api.ts +35 -17
- package/src/channels/slack/constants.ts +6 -0
- package/src/channels/slack/defaults.ts +253 -144
- package/src/channels/slack/dispatch.ts +10 -1
- package/src/channels/slack/inbound.ts +17 -0
- package/src/channels/slack/index.ts +1 -0
- package/src/channels/slack/live-delivery.ts +135 -22
- package/src/channels/slack/progress-delivery.ts +133 -0
- package/src/channels/slack/reasoning-card.ts +140 -0
- package/src/channels/slack/redact.ts +6 -0
- package/src/channels/slack/reply-options.ts +229 -0
- package/src/channels/slack/slack-channel.ts +7 -2
- package/src/channels/slack/stream.ts +31 -24
- package/src/channels/slack/tool-cards.ts +221 -0
- package/src/channels/slack/types.ts +168 -7
- package/src/files-backends/cursor-hosted.ts +18 -7
- package/src/index.ts +4 -0
- package/src/internal/as-of.ts +107 -0
- package/src/internal/cli-deploy.ts +130 -10
- package/src/internal/conversation-mirror.ts +3 -8
- package/src/internal/cursor/hosted-store-secrets.ts +72 -0
- package/src/internal/cursor-event-relay.ts +5 -6
- package/src/internal/deploy-client.ts +10 -10
- package/src/internal/discovery.ts +9 -1
- package/src/internal/framework-file-storage.ts +6 -4
- package/src/internal/framework-storage-selection.ts +28 -25
- package/src/internal/hosted-admission-adapter.ts +42 -0
- package/src/internal/hosted-delivery-protocol.ts +7 -2
- package/src/internal/hosted-delivery.ts +88 -36
- package/src/internal/hosted-execution-diag.ts +45 -0
- package/src/internal/http-channel.ts +8 -0
- package/src/internal/server.ts +100 -2
- package/src/internal/session-engine.ts +32 -1
- package/src/internal/session-run-log.ts +579 -0
- package/src/internal/tool-policy.ts +31 -9
- package/src/storage-backends/cursor-hosted-v2.ts +219 -0
- package/src/storage-backends/cursor-hosted.ts +6 -1
- package/src/storage-protocol.ts +10 -0
- package/src/tools.ts +12 -2
- package/src/types.ts +30 -0
- package/dist/docs/assets/chunks/@localSearchIndexroot.BU9nHdnQ.js +0 -1
- package/dist/docs/assets/hillclimbing.md.DhESf3OO.js +0 -4
- package/dist/docs/assets/scaffolding-agents.md.D7UUkWw0.js +0 -1
- package/dist/playground/assets/index-DrkI6y5O.js +0 -88
- package/dist/playground/assets/index-DzNGwm7q.css +0 -1
- /package/dist/docs/assets/{ab.md.DJo5r4R-.lean.js → ab.md.mlVgqvSk.lean.js} +0 -0
- /package/dist/docs/assets/{building-with-agents.md.DI4mEzlt.lean.js → building-with-agents.md.CUSWxlP_.lean.js} +0 -0
- /package/dist/docs/assets/{evals.md.lfJoEVc8.lean.js → evals.md.CPzDAwoH.lean.js} +0 -0
- /package/dist/docs/assets/{guides_github.md.Cnh2mL4a.lean.js → guides_github.md.BtPr9GaP.lean.js} +0 -0
- /package/dist/docs/assets/{guides_mcp-oauth.md.CN-6YmTJ.lean.js → guides_mcp-oauth.md.Dp6cDP7f.lean.js} +0 -0
- /package/dist/docs/assets/{guides_opentelemetry.md.bmPmkvJu.lean.js → guides_opentelemetry.md.BVTXDCRg.lean.js} +0 -0
- /package/dist/docs/assets/{hillclimbing.md.DhESf3OO.lean.js → hillclimbing.md.CpTGTCle.lean.js} +0 -0
- /package/dist/docs/assets/{index.md.CVeRUOeZ.lean.js → index.md.Bb4k8kUm.lean.js} +0 -0
- /package/dist/docs/assets/{quickstart.md.Nj_LjW_a.lean.js → quickstart.md.DdQOF7Y8.lean.js} +0 -0
- /package/dist/docs/assets/{reference_connections.md.DxldvyIB.lean.js → reference_connections.md.BiGoBAk2.lean.js} +0 -0
- /package/dist/docs/assets/{reference_http-api.md.5zOAbV86.lean.js → reference_http-api.md.BEJx9XVj.lean.js} +0 -0
- /package/dist/docs/assets/{scaffolding-agents.md.D7UUkWw0.lean.js → scaffolding-agents.md.em43xlY1.lean.js} +0 -0
- /package/dist/docs/assets/{troubleshooting.md.DCiPBhYs.lean.js → troubleshooting.md.Cus_YZga.lean.js} +0 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve `slackChannel({ reply, toolLabels })` — and the deprecated
|
|
3
|
+
* `streaming` / `thinkingSteps` / `loadingMessages` flags — into one config
|
|
4
|
+
* the default event handlers read.
|
|
5
|
+
*/
|
|
6
|
+
import { SLACK_DEFAULT_LOADING_MESSAGES } from "./constants.js";
|
|
7
|
+
import { defaultToolCardDetails } from "./tool-cards.js";
|
|
8
|
+
export const DEFAULT_REASONING_CARD_TITLE = "Thinking";
|
|
9
|
+
/** A modest share of `SLACK_MARKDOWN_TEXT_MAX_LEN`, which the whole streamed message shares. */
|
|
10
|
+
export const DEFAULT_REASONING_CARD_MAX_CHARS = 1500;
|
|
11
|
+
function resolveToolLabel(labels) {
|
|
12
|
+
if (labels === undefined) {
|
|
13
|
+
return (toolName) => toolName;
|
|
14
|
+
}
|
|
15
|
+
const lookup = typeof labels === "function" ? labels : (name) => labels[name];
|
|
16
|
+
return (toolName) => {
|
|
17
|
+
const label = lookup(toolName);
|
|
18
|
+
return label === undefined || label === "" ? toolName : label;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function defaultToolStatusLine(toolLabel) {
|
|
22
|
+
return (calls) => {
|
|
23
|
+
const names = [...new Set(calls.map((call) => toolLabel(call.toolName)))];
|
|
24
|
+
return `Running ${names.join(", ")}…`;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function resolveIdle(idle) {
|
|
28
|
+
const cleaned = (idle !== null && idle !== void 0 ? idle : []).filter((line) => line.trim() !== "");
|
|
29
|
+
return cleaned.length > 0 ? cleaned : [...SLACK_DEFAULT_LOADING_MESSAGES];
|
|
30
|
+
}
|
|
31
|
+
function resolveReasoningCard(option) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (option === undefined || option === false) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
const options = option === true ? {} : option;
|
|
37
|
+
const title = (_a = options.title) === null || _a === void 0 ? void 0 : _a.trim();
|
|
38
|
+
return {
|
|
39
|
+
title: title === undefined || title === ""
|
|
40
|
+
? DEFAULT_REASONING_CARD_TITLE
|
|
41
|
+
: title,
|
|
42
|
+
maxChars: options.maxChars !== undefined && options.maxChars > 0
|
|
43
|
+
? options.maxChars
|
|
44
|
+
: DEFAULT_REASONING_CARD_MAX_CHARS,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function resolveToolCards(option) {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const cards = option.toolCards;
|
|
50
|
+
if (cards === undefined || cards === false) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (cards === true) {
|
|
54
|
+
return { group: "per-tool", details: defaultToolCardDetails };
|
|
55
|
+
}
|
|
56
|
+
const group = (_a = cards.group) !== null && _a !== void 0 ? _a : "per-tool";
|
|
57
|
+
if (cards.collapsible === false) {
|
|
58
|
+
return { group };
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
group,
|
|
62
|
+
details: (_b = cards.details) !== null && _b !== void 0 ? _b : defaultToolCardDetails,
|
|
63
|
+
output: cards.output,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Map the deprecated flags onto a `reply` shape with their old defaults
|
|
68
|
+
* (streaming on, per-call cards on), so a config that only sets these keeps
|
|
69
|
+
* behaving as it did. `null` when none of them is set.
|
|
70
|
+
*/
|
|
71
|
+
function legacyReplyOptions(options) {
|
|
72
|
+
const idle = options.loadingMessages;
|
|
73
|
+
if (options.streaming === undefined &&
|
|
74
|
+
options.thinkingSteps === undefined &&
|
|
75
|
+
idle === undefined) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const deprecations = [];
|
|
79
|
+
const mode = options.streaming === false ? "post" : "stream";
|
|
80
|
+
// What legacy streaming showed: one title-only card per call.
|
|
81
|
+
const cards = options.thinkingSteps === false ? false : LEGACY_CARDS;
|
|
82
|
+
const replacement = mode === "post"
|
|
83
|
+
? 'reply: { mode: "post" }'
|
|
84
|
+
: cards === false
|
|
85
|
+
? 'reply: { mode: "stream" }'
|
|
86
|
+
: 'reply: { mode: "stream", toolCards: { group: "per-call", collapsible: false } }';
|
|
87
|
+
if (idle !== undefined) {
|
|
88
|
+
deprecations.push(`slackChannel({ loadingMessages }) is deprecated; use reply: { mode: "${mode}", status: { idle: [...] } }.`);
|
|
89
|
+
}
|
|
90
|
+
if (options.streaming !== undefined) {
|
|
91
|
+
deprecations.push(`slackChannel({ streaming: ${String(options.streaming)} }) is deprecated; use ${replacement}.`);
|
|
92
|
+
}
|
|
93
|
+
if (options.thinkingSteps !== undefined) {
|
|
94
|
+
deprecations.push(mode === "post"
|
|
95
|
+
? "slackChannel({ thinkingSteps }) has no effect in post mode; remove it."
|
|
96
|
+
: `slackChannel({ thinkingSteps: ${String(options.thinkingSteps)} }) is deprecated; use ${replacement}.`);
|
|
97
|
+
}
|
|
98
|
+
const status = { idle };
|
|
99
|
+
if (mode === "post") {
|
|
100
|
+
return { reply: { mode, status }, deprecations };
|
|
101
|
+
}
|
|
102
|
+
return { reply: { mode, status, toolCards: cards }, deprecations };
|
|
103
|
+
}
|
|
104
|
+
const LEGACY_CARDS = { group: "per-call", collapsible: false };
|
|
105
|
+
export function resolveSlackReply(options) {
|
|
106
|
+
var _a;
|
|
107
|
+
const deprecations = [];
|
|
108
|
+
let reply = { mode: "post" };
|
|
109
|
+
const legacy = legacyReplyOptions(options);
|
|
110
|
+
if (options.reply !== undefined) {
|
|
111
|
+
reply = options.reply;
|
|
112
|
+
if (legacy !== null) {
|
|
113
|
+
const ignored = ["streaming", "thinkingSteps", "loadingMessages"].filter((key) => options[key] !== undefined);
|
|
114
|
+
deprecations.push(`slackChannel({ ${ignored.join(", ")} }) is ignored because reply is set; remove the deprecated option${ignored.length === 1 ? "" : "s"}.`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if (legacy !== null) {
|
|
118
|
+
reply = legacy.reply;
|
|
119
|
+
deprecations.push(...legacy.deprecations);
|
|
120
|
+
}
|
|
121
|
+
const toolLabel = resolveToolLabel(options.toolLabels);
|
|
122
|
+
const statusInput = (_a = reply.status) !== null && _a !== void 0 ? _a : {};
|
|
123
|
+
const status = {
|
|
124
|
+
reasoning: statusInput.reasoning !== false,
|
|
125
|
+
tools: statusInput.tools === false
|
|
126
|
+
? false
|
|
127
|
+
: typeof statusInput.tools === "function"
|
|
128
|
+
? statusInput.tools
|
|
129
|
+
: defaultToolStatusLine(toolLabel),
|
|
130
|
+
idle: resolveIdle(statusInput.idle),
|
|
131
|
+
};
|
|
132
|
+
if (reply.mode === "post") {
|
|
133
|
+
return {
|
|
134
|
+
mode: "post",
|
|
135
|
+
status,
|
|
136
|
+
toolCards: false,
|
|
137
|
+
reasoningCard: false,
|
|
138
|
+
toolLabel,
|
|
139
|
+
deprecations,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
mode: "stream",
|
|
144
|
+
status,
|
|
145
|
+
toolCards: resolveToolCards(reply),
|
|
146
|
+
reasoningCard: resolveReasoningCard(reply.reasoningCard),
|
|
147
|
+
toolLabel,
|
|
148
|
+
deprecations,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack-channel.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/slack-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAEV,iBAAiB,EAMlB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"slack-channel.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/slack-channel.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAEV,iBAAiB,EAMlB,MAAM,gBAAgB,CAAC;AA4CxB,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,MAAM,GACjB,mBAAmB,GAAG,SAAS,CAEjC;AAED,0EAA0E;AAC1E,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,gBAAgB,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,aAAa,CAAC;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,GAC9C,uBAAuB,GAAG,SAAS,CAYrC;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,GAAE,mBAAwB,GACjC,iBAAiB,CAAC,iBAAiB,CAAC,CAgbtC"}
|
|
@@ -26,6 +26,7 @@ import { dispatchInboundFromEventBody, dispatchInboundMessage, emptySlackChannel
|
|
|
26
26
|
import { createEventIdDedupe } from "./event-id-dedupe.js";
|
|
27
27
|
import { dispatchBlockAction, dispatchInteractiveFromPayload, } from "./interactive.js";
|
|
28
28
|
import { createSlackLogger } from "./log.js";
|
|
29
|
+
import { resolveSlackReply } from "./reply-options.js";
|
|
29
30
|
import { startSlackSocketMode, } from "./socket-mode.js";
|
|
30
31
|
import { buildToolApprovalEvents } from "./tool-approval-events.js";
|
|
31
32
|
/** Options used to construct a slack channel — for host-level credential binding. */
|
|
@@ -70,7 +71,8 @@ export function slackChannel(authored = {}) {
|
|
|
70
71
|
}
|
|
71
72
|
const credentials = (_a = options.credentials) !== null && _a !== void 0 ? _a : credentialsFromEnv(options.envPrefix);
|
|
72
73
|
const envKeys = slackEnvKeys(options.envPrefix);
|
|
73
|
-
const
|
|
74
|
+
const reply = resolveSlackReply(options);
|
|
75
|
+
const loadingMessages = reply.status.idle;
|
|
74
76
|
const policy = options.policy;
|
|
75
77
|
const blockExternals = resolveSlackBlockExternals(policy);
|
|
76
78
|
const defaultInbound = createDefaultOnInbound(loadingMessages, policy);
|
|
@@ -107,11 +109,13 @@ export function slackChannel(authored = {}) {
|
|
|
107
109
|
if (options.deliverDefaults !== false) {
|
|
108
110
|
Object.assign(events, buildDefaultEvents({
|
|
109
111
|
credentials,
|
|
112
|
+
reply: options.reply,
|
|
113
|
+
toolLabels: options.toolLabels,
|
|
110
114
|
streaming: options.streaming,
|
|
111
115
|
thinkingSteps: options.thinkingSteps,
|
|
116
|
+
loadingMessages: options.loadingMessages,
|
|
112
117
|
suggestedPrompts: options.suggestedPrompts,
|
|
113
118
|
suggestedPromptsTitle: options.suggestedPromptsTitle,
|
|
114
|
-
loadingMessages,
|
|
115
119
|
getLog,
|
|
116
120
|
}));
|
|
117
121
|
}
|
|
@@ -145,9 +149,9 @@ export function slackChannel(authored = {}) {
|
|
|
145
149
|
auth: [allowAll()],
|
|
146
150
|
state: emptySlackChannelState(),
|
|
147
151
|
routes: [],
|
|
148
|
-
meta: Object.assign({ kind: "slack" }, (channelPosts === undefined
|
|
152
|
+
meta: Object.assign(Object.assign({ kind: "slack" }, (channelPosts === undefined
|
|
149
153
|
? {}
|
|
150
|
-
: { slackChannelPosts: [...channelPosts.allow] })),
|
|
154
|
+
: { slackChannelPosts: [...channelPosts.allow] })), { deprecations: reply.deprecations }),
|
|
151
155
|
receive(input_1, _a) {
|
|
152
156
|
return __awaiter(this, arguments, void 0, function* (input, { send }) {
|
|
153
157
|
var _b;
|
|
@@ -2,25 +2,37 @@
|
|
|
2
2
|
* Chat streaming helpers for Slack AI / agent features.
|
|
3
3
|
*/
|
|
4
4
|
export type StreamTaskStatus = "pending" | "in_progress" | "complete" | "error";
|
|
5
|
+
/**
|
|
6
|
+
* One update to a task card. Slack keeps one card per `id`: `title` and
|
|
7
|
+
* `status` replace the previous values, `details` and `output` are appended
|
|
8
|
+
* to what the card already shows.
|
|
9
|
+
*/
|
|
5
10
|
export interface StreamTaskChunk {
|
|
6
11
|
type: "task_update";
|
|
7
12
|
id: string;
|
|
8
13
|
title: string;
|
|
9
14
|
status: StreamTaskStatus;
|
|
15
|
+
details?: string;
|
|
16
|
+
output?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface StreamMarkdownChunk {
|
|
19
|
+
type: "markdown_text";
|
|
20
|
+
text: string;
|
|
10
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* A `chat.*Stream` chunk. Slack fixes a stream's mode at `chat.startStream`:
|
|
24
|
+
* one opened with bare `markdown_text` rejects every later `chunks` append
|
|
25
|
+
* (`streaming_mode_mismatch`), and vice versa. The live-delivery strategy
|
|
26
|
+
* therefore always speaks chunks, wrapping text as `markdown_text` chunks so
|
|
27
|
+
* tool-step `task_update`s can share the same message.
|
|
28
|
+
*/
|
|
29
|
+
export type StreamChunk = StreamMarkdownChunk | StreamTaskChunk;
|
|
30
|
+
export declare function markdownChunk(text: string): StreamMarkdownChunk;
|
|
11
31
|
/**
|
|
12
32
|
* Given previously sent cumulative text and the new cumulative text, return
|
|
13
33
|
* the suffix to append. Empty string when there is nothing new to send.
|
|
14
34
|
*/
|
|
15
35
|
export declare function computeStreamAppend(lastPostedText: string | null | undefined, cumulative: string): string;
|
|
16
|
-
/**
|
|
17
|
-
export declare function
|
|
18
|
-
callId: string;
|
|
19
|
-
toolName: string;
|
|
20
|
-
}>, status: StreamTaskStatus): StreamTaskChunk[];
|
|
21
|
-
export declare function buildTaskChunkForResult(args: {
|
|
22
|
-
callId: string;
|
|
23
|
-
toolName: string;
|
|
24
|
-
isError: boolean;
|
|
25
|
-
}): StreamTaskChunk;
|
|
36
|
+
/** Clamp to `max` characters, ending in an ellipsis when cut. */
|
|
37
|
+
export declare function truncateCardText(text: string, max: number): string;
|
|
26
38
|
//# sourceMappingURL=stream.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/stream.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,OAAO,CAAC;AAEhF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/stream.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,OAAO,CAAC;AAEhF;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAC;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,eAAe,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,GAAG,eAAe,CAAC;AAEhE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAE/D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACzC,UAAU,EAAE,MAAM,GACjB,MAAM,CAgBR;AAED,iEAAiE;AACjE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKlE"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Chat streaming helpers for Slack AI / agent features.
|
|
3
3
|
*/
|
|
4
|
+
export function markdownChunk(text) {
|
|
5
|
+
return { type: "markdown_text", text };
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* Given previously sent cumulative text and the new cumulative text, return
|
|
6
9
|
* the suffix to append. Empty string when there is nothing new to send.
|
|
@@ -20,20 +23,10 @@ export function computeStreamAppend(lastPostedText, cumulative) {
|
|
|
20
23
|
// Text rewound / rewritten — cannot unsend; skip append.
|
|
21
24
|
return "";
|
|
22
25
|
}
|
|
23
|
-
/**
|
|
24
|
-
export function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
status,
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
export function buildTaskChunkForResult(args) {
|
|
33
|
-
return {
|
|
34
|
-
type: "task_update",
|
|
35
|
-
id: args.callId,
|
|
36
|
-
title: args.toolName,
|
|
37
|
-
status: args.isError ? "error" : "complete",
|
|
38
|
-
};
|
|
26
|
+
/** Clamp to `max` characters, ending in an ellipsis when cut. */
|
|
27
|
+
export function truncateCardText(text, max) {
|
|
28
|
+
if (text.length <= max) {
|
|
29
|
+
return text;
|
|
30
|
+
}
|
|
31
|
+
return `${text.slice(0, max - 1)}…`;
|
|
39
32
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task cards for tool calls inside the streamed reply. One card per key:
|
|
3
|
+
* the call id for `per-call`, the tool name for `per-tool`. A card's title
|
|
4
|
+
* counts its calls and its status follows the whole group; with one call
|
|
5
|
+
* per key that reduces to the plain per-call card.
|
|
6
|
+
*/
|
|
7
|
+
import type { ResolvedSlackToolCards } from "./reply-options.js";
|
|
8
|
+
import { type StreamTaskChunk } from "./stream.js";
|
|
9
|
+
import type { SlackChannelState, SlackToolCall, SlackToolResult } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Default tool-card line for a call, matching the playground's tool header:
|
|
12
|
+
* the grep pattern, the glob pattern, the file path, the shell command. Other
|
|
13
|
+
* tools show a lone string argument bare, else compact JSON. No key labels,
|
|
14
|
+
* no knobs like `headLimit`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function defaultToolCardDetails(call: SlackToolCall): string | undefined;
|
|
17
|
+
export interface ToolCards {
|
|
18
|
+
forCalls(state: SlackChannelState, calls: readonly SlackToolCall[]): StreamTaskChunk[];
|
|
19
|
+
forResult(state: SlackChannelState, result: SlackToolResult): StreamTaskChunk;
|
|
20
|
+
}
|
|
21
|
+
export declare function createToolCards(cards: ResolvedSlackToolCards, toolLabel: (toolName: string) => string): ToolCards;
|
|
22
|
+
//# sourceMappingURL=tool-cards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-cards.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/tool-cards.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,eAAe,EAEhB,MAAM,YAAY,CAAC;AAwDpB;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,aAAa,GAClB,MAAM,GAAG,SAAS,CA8BpB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CACN,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,SAAS,aAAa,EAAE,GAC9B,eAAe,EAAE,CAAC;IACrB,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,eAAe,GAAG,eAAe,CAAC;CAC/E;AAoCD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,sBAAsB,EAC7B,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GACtC,SAAS,CAgEX"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task cards for tool calls inside the streamed reply. One card per key:
|
|
3
|
+
* the call id for `per-call`, the tool name for `per-tool`. A card's title
|
|
4
|
+
* counts its calls and its status follows the whole group; with one call
|
|
5
|
+
* per key that reduces to the plain per-call card.
|
|
6
|
+
*/
|
|
7
|
+
import { redactSecretTokens } from "./redact.js";
|
|
8
|
+
import { truncateCardText } from "./stream.js";
|
|
9
|
+
/** The argument the playground puts in a built-in tool's header. */
|
|
10
|
+
const TOOL_PRIMARY_ARGS = {
|
|
11
|
+
grep: ["pattern"],
|
|
12
|
+
glob: ["glob_pattern", "globPattern"],
|
|
13
|
+
read: ["path", "file_path", "target_file"],
|
|
14
|
+
shell: ["command", "cmd"],
|
|
15
|
+
task: ["description", "prompt"],
|
|
16
|
+
};
|
|
17
|
+
/** For other tools: the telling key, if any. */
|
|
18
|
+
const GENERIC_PRIMARY_ARGS = [
|
|
19
|
+
"pattern",
|
|
20
|
+
"query",
|
|
21
|
+
"command",
|
|
22
|
+
"cmd",
|
|
23
|
+
"path",
|
|
24
|
+
"file",
|
|
25
|
+
"file_path",
|
|
26
|
+
"target_file",
|
|
27
|
+
"url",
|
|
28
|
+
"prompt",
|
|
29
|
+
"description",
|
|
30
|
+
"name",
|
|
31
|
+
"message",
|
|
32
|
+
];
|
|
33
|
+
const PATH_ARGS = new Set([
|
|
34
|
+
"path",
|
|
35
|
+
"file",
|
|
36
|
+
"file_path",
|
|
37
|
+
"target_file",
|
|
38
|
+
"target_directory",
|
|
39
|
+
"targetDirectory",
|
|
40
|
+
]);
|
|
41
|
+
const LINE_MAX = 80;
|
|
42
|
+
const JSON_MAX = 120;
|
|
43
|
+
function oneLine(text, max) {
|
|
44
|
+
return truncateCardText(redactSecretTokens(text).replace(/\s+/g, " ").trim(), max);
|
|
45
|
+
}
|
|
46
|
+
/** Clamp the middle so both ends stay visible; tail-biased to keep filenames. */
|
|
47
|
+
function clampPath(text, max) {
|
|
48
|
+
const one = redactSecretTokens(text).replace(/\s+/g, " ").trim();
|
|
49
|
+
if (one.length <= max) {
|
|
50
|
+
return one;
|
|
51
|
+
}
|
|
52
|
+
const budget = max - 1;
|
|
53
|
+
const head = Math.max(1, Math.floor(budget * 0.35));
|
|
54
|
+
const tail = Math.max(1, budget - head);
|
|
55
|
+
return `${one.slice(0, head)}…${one.slice(one.length - tail)}`;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Default tool-card line for a call, matching the playground's tool header:
|
|
59
|
+
* the grep pattern, the glob pattern, the file path, the shell command. Other
|
|
60
|
+
* tools show a lone string argument bare, else compact JSON. No key labels,
|
|
61
|
+
* no knobs like `headLimit`.
|
|
62
|
+
*/
|
|
63
|
+
export function defaultToolCardDetails(call) {
|
|
64
|
+
var _a;
|
|
65
|
+
var _b;
|
|
66
|
+
const args = call.args;
|
|
67
|
+
if (args === undefined || args === null) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
if (typeof args === "string") {
|
|
71
|
+
const line = oneLine(args, LINE_MAX);
|
|
72
|
+
return line === "" ? undefined : line;
|
|
73
|
+
}
|
|
74
|
+
if (typeof args !== "object" || Array.isArray(args)) {
|
|
75
|
+
return oneLine(JSON.stringify(args), JSON_MAX);
|
|
76
|
+
}
|
|
77
|
+
const record = args;
|
|
78
|
+
for (const key of (_b = TOOL_PRIMARY_ARGS[call.toolName]) !== null && _b !== void 0 ? _b : GENERIC_PRIMARY_ARGS) {
|
|
79
|
+
const value = record[key];
|
|
80
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
81
|
+
return PATH_ARGS.has(key)
|
|
82
|
+
? clampPath(value, LINE_MAX)
|
|
83
|
+
: oneLine(value, LINE_MAX);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const entries = Object.entries(record);
|
|
87
|
+
if (entries.length === 0) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const lone = entries.length === 1 ? (_a = entries[0]) === null || _a === void 0 ? void 0 : _a[1] : undefined;
|
|
91
|
+
if (typeof lone === "string" && lone.trim() !== "") {
|
|
92
|
+
return oneLine(lone, LINE_MAX);
|
|
93
|
+
}
|
|
94
|
+
return oneLine(JSON.stringify(record), JSON_MAX);
|
|
95
|
+
}
|
|
96
|
+
function tallyFor(state, key) {
|
|
97
|
+
if (state.toolCardCounts === undefined) {
|
|
98
|
+
state.toolCardCounts = {};
|
|
99
|
+
}
|
|
100
|
+
const existing = state.toolCardCounts[key];
|
|
101
|
+
if (existing !== undefined) {
|
|
102
|
+
return existing;
|
|
103
|
+
}
|
|
104
|
+
const created = { started: 0, done: 0, errors: 0 };
|
|
105
|
+
state.toolCardCounts[key] = created;
|
|
106
|
+
return created;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Slack appends each update's text to the card verbatim, so a group's later
|
|
110
|
+
* batch of lines brings its own line break.
|
|
111
|
+
*/
|
|
112
|
+
function appendLines(tally, field, lines) {
|
|
113
|
+
var _a;
|
|
114
|
+
if (lines.length === 0) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const already = (_a = tally[field]) !== null && _a !== void 0 ? _a : 0;
|
|
118
|
+
tally[field] = already + lines.length;
|
|
119
|
+
return `${already > 0 ? "\n" : ""}${lines.join("\n")}`;
|
|
120
|
+
}
|
|
121
|
+
function present(line) {
|
|
122
|
+
return line !== undefined && line !== "";
|
|
123
|
+
}
|
|
124
|
+
export function createToolCards(cards, toolLabel) {
|
|
125
|
+
const keyOf = (call) => cards.group === "per-call" ? call.callId : `tool:${call.toolName}`;
|
|
126
|
+
const title = (toolName, started) => {
|
|
127
|
+
const label = toolLabel(toolName);
|
|
128
|
+
return started > 1 ? `${label} ×${started}` : label;
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
forCalls(state, calls) {
|
|
132
|
+
var _a;
|
|
133
|
+
const groups = new Map();
|
|
134
|
+
for (const call of calls) {
|
|
135
|
+
const key = keyOf(call);
|
|
136
|
+
groups.set(key, [...((_a = groups.get(key)) !== null && _a !== void 0 ? _a : []), call]);
|
|
137
|
+
}
|
|
138
|
+
return [...groups.entries()].map(([key, group]) => {
|
|
139
|
+
const tally = tallyFor(state, key);
|
|
140
|
+
tally.started += group.length;
|
|
141
|
+
const chunk = {
|
|
142
|
+
type: "task_update",
|
|
143
|
+
id: key,
|
|
144
|
+
title: title(group[0].toolName, tally.started),
|
|
145
|
+
status: "in_progress",
|
|
146
|
+
};
|
|
147
|
+
const details = appendLines(tally, "details", group.map((call) => { var _a; return (_a = cards.details) === null || _a === void 0 ? void 0 : _a.call(cards, call); }).filter(present));
|
|
148
|
+
if (details !== undefined) {
|
|
149
|
+
chunk.details = details;
|
|
150
|
+
}
|
|
151
|
+
return chunk;
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
forResult(state, result) {
|
|
155
|
+
var _a;
|
|
156
|
+
const tally = tallyFor(state, keyOf(result));
|
|
157
|
+
tally.done += 1;
|
|
158
|
+
if (result.isError) {
|
|
159
|
+
tally.errors += 1;
|
|
160
|
+
}
|
|
161
|
+
const chunk = {
|
|
162
|
+
type: "task_update",
|
|
163
|
+
id: keyOf(result),
|
|
164
|
+
title: title(result.toolName, tally.started),
|
|
165
|
+
status: tally.done < tally.started
|
|
166
|
+
? "in_progress"
|
|
167
|
+
: tally.errors > 0
|
|
168
|
+
? "error"
|
|
169
|
+
: "complete",
|
|
170
|
+
};
|
|
171
|
+
const output = appendLines(tally, "output", [(_a = cards.output) === null || _a === void 0 ? void 0 : _a.call(cards, result)].filter(present));
|
|
172
|
+
if (output !== undefined) {
|
|
173
|
+
chunk.output = output;
|
|
174
|
+
}
|
|
175
|
+
return chunk;
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|