lastlight 0.16.0 → 0.16.2
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/README.md +71 -692
- package/dist/cli-config.js.map +1 -0
- package/dist/cli-format.js.map +1 -0
- package/dist/{cli/cli-server.d.ts → cli-server.d.ts} +39 -1
- package/dist/{cli/cli-server.js → cli-server.js} +105 -5
- package/dist/cli-server.js.map +1 -0
- package/dist/cli-timeline.js.map +1 -0
- package/dist/{cli/cli.js → cli.js} +9 -7
- package/dist/cli.js.map +1 -0
- package/dist/{cli/fork-cli.d.ts → fork-cli.d.ts} +3 -3
- package/dist/{cli/fork-cli.js → fork-cli.js} +28 -27
- package/dist/fork-cli.js.map +1 -0
- package/dist/{cli/oauth-cli.js → oauth-cli.js} +1 -1
- package/dist/oauth-cli.js.map +1 -0
- package/dist/{cli/setup.js → setup.js} +10 -4
- package/dist/setup.js.map +1 -0
- package/dist/{cli/skills-install.d.ts → skills-install.d.ts} +6 -0
- package/dist/{cli/skills-install.js → skills-install.js} +6 -2
- package/dist/skills-install.js.map +1 -0
- package/package.json +20 -65
- package/plugins/lastlight/.claude-plugin/plugin.json +1 -1
- package/agent-context/rules.md +0 -80
- package/agent-context/security.md +0 -69
- package/agent-context/soul.md +0 -21
- package/config/default.yaml +0 -119
- package/deploy/.env.production.example +0 -100
- package/deploy/entrypoint.sh +0 -82
- package/deploy/native/README.md +0 -160
- package/deploy/native/install.sh +0 -110
- package/deploy/native/lastlight.env.example +0 -95
- package/deploy/native/lastlight.service +0 -50
- package/deploy/sandbox-entrypoint.sh +0 -93
- package/dist/admin/auth.d.ts +0 -51
- package/dist/admin/auth.js +0 -121
- package/dist/admin/auth.js.map +0 -1
- package/dist/admin/chat-session-reader.d.ts +0 -39
- package/dist/admin/chat-session-reader.js +0 -84
- package/dist/admin/chat-session-reader.js.map +0 -1
- package/dist/admin/docker.d.ts +0 -61
- package/dist/admin/docker.js +0 -187
- package/dist/admin/docker.js.map +0 -1
- package/dist/admin/index.d.ts +0 -9
- package/dist/admin/index.js +0 -59
- package/dist/admin/index.js.map +0 -1
- package/dist/admin/routes.d.ts +0 -81
- package/dist/admin/routes.js +0 -1381
- package/dist/admin/routes.js.map +0 -1
- package/dist/admin/sessions.d.ts +0 -89
- package/dist/admin/sessions.js +0 -204
- package/dist/admin/sessions.js.map +0 -1
- package/dist/admin/tail.d.ts +0 -12
- package/dist/admin/tail.js +0 -145
- package/dist/admin/tail.js.map +0 -1
- package/dist/admin/version.d.ts +0 -22
- package/dist/admin/version.js +0 -92
- package/dist/admin/version.js.map +0 -1
- package/dist/cli/cli-config.js.map +0 -1
- package/dist/cli/cli-format.js.map +0 -1
- package/dist/cli/cli-server.js.map +0 -1
- package/dist/cli/cli-timeline.js.map +0 -1
- package/dist/cli/cli.js.map +0 -1
- package/dist/cli/fork-cli.js.map +0 -1
- package/dist/cli/oauth-cli.js.map +0 -1
- package/dist/cli/setup.js.map +0 -1
- package/dist/cli/skills-install.js.map +0 -1
- package/dist/config/config-resolve.d.ts +0 -28
- package/dist/config/config-resolve.js +0 -47
- package/dist/config/config-resolve.js.map +0 -1
- package/dist/config/config.d.ts +0 -157
- package/dist/config/config.js +0 -581
- package/dist/config/config.js.map +0 -1
- package/dist/config/core-pin.d.ts +0 -16
- package/dist/config/core-pin.js +0 -85
- package/dist/config/core-pin.js.map +0 -1
- package/dist/config/overlay-assets.d.ts +0 -20
- package/dist/config/overlay-assets.js +0 -114
- package/dist/config/overlay-assets.js.map +0 -1
- package/dist/config/overlay-bootstrap.d.ts +0 -44
- package/dist/config/overlay-bootstrap.js +0 -304
- package/dist/config/overlay-bootstrap.js.map +0 -1
- package/dist/connectors/github-webhook.d.ts +0 -45
- package/dist/connectors/github-webhook.js +0 -321
- package/dist/connectors/github-webhook.js.map +0 -1
- package/dist/connectors/index.d.ts +0 -18
- package/dist/connectors/index.js +0 -41
- package/dist/connectors/index.js.map +0 -1
- package/dist/connectors/messaging/base.d.ts +0 -42
- package/dist/connectors/messaging/base.js +0 -139
- package/dist/connectors/messaging/base.js.map +0 -1
- package/dist/connectors/messaging/delivery.d.ts +0 -14
- package/dist/connectors/messaging/delivery.js +0 -38
- package/dist/connectors/messaging/delivery.js.map +0 -1
- package/dist/connectors/messaging/index.d.ts +0 -4
- package/dist/connectors/messaging/index.js +0 -4
- package/dist/connectors/messaging/index.js.map +0 -1
- package/dist/connectors/messaging/session-manager.d.ts +0 -53
- package/dist/connectors/messaging/session-manager.js +0 -255
- package/dist/connectors/messaging/session-manager.js.map +0 -1
- package/dist/connectors/messaging/types.d.ts +0 -58
- package/dist/connectors/messaging/types.js +0 -7
- package/dist/connectors/messaging/types.js.map +0 -1
- package/dist/connectors/slack/connector.d.ts +0 -142
- package/dist/connectors/slack/connector.js +0 -494
- package/dist/connectors/slack/connector.js.map +0 -1
- package/dist/connectors/slack/index.d.ts +0 -2
- package/dist/connectors/slack/index.js +0 -3
- package/dist/connectors/slack/index.js.map +0 -1
- package/dist/connectors/slack/mrkdwn.d.ts +0 -19
- package/dist/connectors/slack/mrkdwn.js +0 -240
- package/dist/connectors/slack/mrkdwn.js.map +0 -1
- package/dist/connectors/types.d.ts +0 -61
- package/dist/connectors/types.js +0 -2
- package/dist/connectors/types.js.map +0 -1
- package/dist/cron/fanout.d.ts +0 -33
- package/dist/cron/fanout.js +0 -55
- package/dist/cron/fanout.js.map +0 -1
- package/dist/cron/jobs.d.ts +0 -18
- package/dist/cron/jobs.js +0 -37
- package/dist/cron/jobs.js.map +0 -1
- package/dist/cron/scheduler.d.ts +0 -45
- package/dist/cron/scheduler.js +0 -105
- package/dist/cron/scheduler.js.map +0 -1
- package/dist/engine/agent-executor.d.ts +0 -34
- package/dist/engine/agent-executor.js +0 -246
- package/dist/engine/agent-executor.js.map +0 -1
- package/dist/engine/chat/chat-runner.d.ts +0 -132
- package/dist/engine/chat/chat-runner.js +0 -424
- package/dist/engine/chat/chat-runner.js.map +0 -1
- package/dist/engine/chat/chat-skills.d.ts +0 -45
- package/dist/engine/chat/chat-skills.js +0 -184
- package/dist/engine/chat/chat-skills.js.map +0 -1
- package/dist/engine/chat/chat.d.ts +0 -54
- package/dist/engine/chat/chat.js +0 -316
- package/dist/engine/chat/chat.js.map +0 -1
- package/dist/engine/chat/message-batcher.d.ts +0 -32
- package/dist/engine/chat/message-batcher.js +0 -109
- package/dist/engine/chat/message-batcher.js.map +0 -1
- package/dist/engine/dispatcher.d.ts +0 -73
- package/dist/engine/dispatcher.js +0 -663
- package/dist/engine/dispatcher.js.map +0 -1
- package/dist/engine/event-shim.d.ts +0 -117
- package/dist/engine/event-shim.js +0 -435
- package/dist/engine/event-shim.js.map +0 -1
- package/dist/engine/executors/orchestrator.d.ts +0 -81
- package/dist/engine/executors/orchestrator.js +0 -365
- package/dist/engine/executors/orchestrator.js.map +0 -1
- package/dist/engine/executors/shared.d.ts +0 -189
- package/dist/engine/executors/shared.js +0 -616
- package/dist/engine/executors/shared.js.map +0 -1
- package/dist/engine/github/git-auth.d.ts +0 -62
- package/dist/engine/github/git-auth.js +0 -161
- package/dist/engine/github/git-auth.js.map +0 -1
- package/dist/engine/github/github-app-client.d.ts +0 -23
- package/dist/engine/github/github-app-client.js +0 -33
- package/dist/engine/github/github-app-client.js.map +0 -1
- package/dist/engine/github/github-tools.d.ts +0 -18
- package/dist/engine/github/github-tools.js +0 -263
- package/dist/engine/github/github-tools.js.map +0 -1
- package/dist/engine/github/github.d.ts +0 -1193
- package/dist/engine/github/github.js +0 -357
- package/dist/engine/github/github.js.map +0 -1
- package/dist/engine/github/profiles.d.ts +0 -279
- package/dist/engine/github/profiles.js +0 -42
- package/dist/engine/github/profiles.js.map +0 -1
- package/dist/engine/github/review-poster.d.ts +0 -98
- package/dist/engine/github/review-poster.js +0 -177
- package/dist/engine/github/review-poster.js.map +0 -1
- package/dist/engine/llm.d.ts +0 -79
- package/dist/engine/llm.js +0 -269
- package/dist/engine/llm.js.map +0 -1
- package/dist/engine/oauth.d.ts +0 -43
- package/dist/engine/oauth.js +0 -103
- package/dist/engine/oauth.js.map +0 -1
- package/dist/engine/router.d.ts +0 -29
- package/dist/engine/router.js +0 -680
- package/dist/engine/router.js.map +0 -1
- package/dist/engine/screen/classifier.d.ts +0 -93
- package/dist/engine/screen/classifier.js +0 -215
- package/dist/engine/screen/classifier.js.map +0 -1
- package/dist/engine/screen/screen.d.ts +0 -41
- package/dist/engine/screen/screen.js +0 -93
- package/dist/engine/screen/screen.js.map +0 -1
- package/dist/evals-api.d.ts +0 -24
- package/dist/evals-api.js +0 -22
- package/dist/evals-api.js.map +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -940
- package/dist/index.js.map +0 -1
- package/dist/managed-repos.d.ts +0 -30
- package/dist/managed-repos.js +0 -72
- package/dist/managed-repos.js.map +0 -1
- package/dist/notify/blocks.d.ts +0 -23
- package/dist/notify/blocks.js +0 -118
- package/dist/notify/blocks.js.map +0 -1
- package/dist/notify/index.d.ts +0 -17
- package/dist/notify/index.js +0 -7
- package/dist/notify/index.js.map +0 -1
- package/dist/notify/model.d.ts +0 -57
- package/dist/notify/model.js +0 -89
- package/dist/notify/model.js.map +0 -1
- package/dist/notify/notifier.d.ts +0 -18
- package/dist/notify/notifier.js +0 -100
- package/dist/notify/notifier.js.map +0 -1
- package/dist/notify/render.d.ts +0 -21
- package/dist/notify/render.js +0 -59
- package/dist/notify/render.js.map +0 -1
- package/dist/notify/transports/github.d.ts +0 -26
- package/dist/notify/transports/github.js +0 -27
- package/dist/notify/transports/github.js.map +0 -1
- package/dist/notify/transports/slack.d.ts +0 -27
- package/dist/notify/transports/slack.js +0 -37
- package/dist/notify/transports/slack.js.map +0 -1
- package/dist/notify/types.d.ts +0 -119
- package/dist/notify/types.js +0 -16
- package/dist/notify/types.js.map +0 -1
- package/dist/providers.d.ts +0 -125
- package/dist/providers.js +0 -279
- package/dist/providers.js.map +0 -1
- package/dist/sandbox/docker.d.ts +0 -180
- package/dist/sandbox/docker.js +0 -517
- package/dist/sandbox/docker.js.map +0 -1
- package/dist/sandbox/egress-allowlist.d.ts +0 -74
- package/dist/sandbox/egress-allowlist.js +0 -164
- package/dist/sandbox/egress-allowlist.js.map +0 -1
- package/dist/sandbox/egress-firewall-config.d.ts +0 -127
- package/dist/sandbox/egress-firewall-config.js +0 -434
- package/dist/sandbox/egress-firewall-config.js.map +0 -1
- package/dist/sandbox/images.d.ts +0 -23
- package/dist/sandbox/images.js +0 -55
- package/dist/sandbox/images.js.map +0 -1
- package/dist/sandbox/index.d.ts +0 -112
- package/dist/sandbox/index.js +0 -332
- package/dist/sandbox/index.js.map +0 -1
- package/dist/sandbox/sandbox.d.ts +0 -214
- package/dist/sandbox/sandbox.js +0 -453
- package/dist/sandbox/sandbox.js.map +0 -1
- package/dist/sandbox/smol.d.ts +0 -162
- package/dist/sandbox/smol.js +0 -485
- package/dist/sandbox/smol.js.map +0 -1
- package/dist/session-log.d.ts +0 -63
- package/dist/session-log.js +0 -290
- package/dist/session-log.js.map +0 -1
- package/dist/state/approval-store.d.ts +0 -88
- package/dist/state/approval-store.js +0 -149
- package/dist/state/approval-store.js.map +0 -1
- package/dist/state/build-assets.d.ts +0 -50
- package/dist/state/build-assets.js +0 -154
- package/dist/state/build-assets.js.map +0 -1
- package/dist/state/db.d.ts +0 -81
- package/dist/state/db.js +0 -155
- package/dist/state/db.js.map +0 -1
- package/dist/state/execution-store.d.ts +0 -257
- package/dist/state/execution-store.js +0 -527
- package/dist/state/execution-store.js.map +0 -1
- package/dist/state/migrate.d.ts +0 -15
- package/dist/state/migrate.js +0 -175
- package/dist/state/migrate.js.map +0 -1
- package/dist/state/workflow-run-store.d.ts +0 -216
- package/dist/state/workflow-run-store.js +0 -403
- package/dist/state/workflow-run-store.js.map +0 -1
- package/dist/telemetry/index.d.ts +0 -38
- package/dist/telemetry/index.js +0 -253
- package/dist/telemetry/index.js.map +0 -1
- package/dist/telemetry/pi-events.d.ts +0 -12
- package/dist/telemetry/pi-events.js +0 -134
- package/dist/telemetry/pi-events.js.map +0 -1
- package/dist/workflows/dag.d.ts +0 -37
- package/dist/workflows/dag.js +0 -118
- package/dist/workflows/dag.js.map +0 -1
- package/dist/workflows/loader.d.ts +0 -53
- package/dist/workflows/loader.js +0 -421
- package/dist/workflows/loader.js.map +0 -1
- package/dist/workflows/loop-eval.d.ts +0 -28
- package/dist/workflows/loop-eval.js +0 -74
- package/dist/workflows/loop-eval.js.map +0 -1
- package/dist/workflows/phase-executor.d.ts +0 -222
- package/dist/workflows/phase-executor.js +0 -1153
- package/dist/workflows/phase-executor.js.map +0 -1
- package/dist/workflows/phase-ref.d.ts +0 -50
- package/dist/workflows/phase-ref.js +0 -91
- package/dist/workflows/phase-ref.js.map +0 -1
- package/dist/workflows/resume.d.ts +0 -58
- package/dist/workflows/resume.js +0 -313
- package/dist/workflows/resume.js.map +0 -1
- package/dist/workflows/runner.d.ts +0 -63
- package/dist/workflows/runner.js +0 -381
- package/dist/workflows/runner.js.map +0 -1
- package/dist/workflows/schema.d.ts +0 -344
- package/dist/workflows/schema.js +0 -460
- package/dist/workflows/schema.js.map +0 -1
- package/dist/workflows/simple.d.ts +0 -90
- package/dist/workflows/simple.js +0 -393
- package/dist/workflows/simple.js.map +0 -1
- package/dist/workflows/target-policy.d.ts +0 -74
- package/dist/workflows/target-policy.js +0 -80
- package/dist/workflows/target-policy.js.map +0 -1
- package/dist/workflows/templates.d.ts +0 -88
- package/dist/workflows/templates.js +0 -127
- package/dist/workflows/templates.js.map +0 -1
- package/dist/workflows/triggers.d.ts +0 -21
- package/dist/workflows/triggers.js +0 -45
- package/dist/workflows/triggers.js.map +0 -1
- package/dist/workflows/verdict.d.ts +0 -19
- package/dist/workflows/verdict.js +0 -30
- package/dist/workflows/verdict.js.map +0 -1
- package/dist/worktree/manager.d.ts +0 -43
- package/dist/worktree/manager.js +0 -127
- package/dist/worktree/manager.js.map +0 -1
- package/docker-compose.yml +0 -274
- package/sandbox.Dockerfile +0 -68
- package/skills/README.md +0 -42
- package/skills/browser-qa/SKILL.md +0 -208
- package/skills/browser-qa/scripts/agent-browser.mjs +0 -531
- package/skills/building/SKILL.md +0 -95
- package/skills/chat/SKILL.md +0 -36
- package/skills/code-review/SKILL.md +0 -82
- package/skills/debug-production/SKILL.md +0 -108
- package/skills/demo/SKILL.md +0 -228
- package/skills/demo/scripts/compose-demo.sh +0 -243
- package/skills/issue-answer/SKILL.md +0 -91
- package/skills/issue-comment/SKILL.md +0 -49
- package/skills/issue-triage/SKILL.md +0 -149
- package/skills/issue-triage/references/AGENT-BRIEF.md +0 -65
- package/skills/pr-comment/SKILL.md +0 -64
- package/skills/pr-review/SKILL.md +0 -148
- package/skills/pr-review/references/findings-schema.md +0 -89
- package/skills/qa-test/SKILL.md +0 -97
- package/skills/repo-health/SKILL.md +0 -67
- package/skills/security-feedback/SKILL.md +0 -173
- package/skills/security-feedback/references/templates.md +0 -77
- package/skills/security-review/SKILL.md +0 -215
- package/skills/security-review/references/issue-format.md +0 -302
- package/skills/verify/SKILL.md +0 -118
- package/workflows/answer.yaml +0 -44
- package/workflows/build.yaml +0 -129
- package/workflows/cron-health.yaml +0 -6
- package/workflows/cron-review.yaml +0 -8
- package/workflows/cron-security.yaml +0 -6
- package/workflows/cron-triage.yaml +0 -8
- package/workflows/demo.yaml +0 -62
- package/workflows/examples/bash-smoke.yaml +0 -41
- package/workflows/examples/parallel-review.yaml +0 -36
- package/workflows/examples/tdd-loop.yaml +0 -17
- package/workflows/explore.yaml +0 -80
- package/workflows/issue-comment.yaml +0 -15
- package/workflows/issue-triage.yaml +0 -22
- package/workflows/pr-comment.yaml +0 -16
- package/workflows/pr-fix.yaml +0 -17
- package/workflows/pr-review.yaml +0 -50
- package/workflows/prompts/answer.md +0 -68
- package/workflows/prompts/architect.md +0 -44
- package/workflows/prompts/classifier.md +0 -60
- package/workflows/prompts/classify-adds-info.md +0 -17
- package/workflows/prompts/demo.md +0 -125
- package/workflows/prompts/executor.md +0 -42
- package/workflows/prompts/explore-ask.md +0 -99
- package/workflows/prompts/explore-publish.md +0 -31
- package/workflows/prompts/explore-read.md +0 -120
- package/workflows/prompts/explore-synthesize.md +0 -88
- package/workflows/prompts/fix.md +0 -18
- package/workflows/prompts/guardrails.md +0 -96
- package/workflows/prompts/pr-fix.md +0 -26
- package/workflows/prompts/pr.md +0 -39
- package/workflows/prompts/qa-browser.md +0 -95
- package/workflows/prompts/qa-synth.md +0 -44
- package/workflows/prompts/qa-test.md +0 -60
- package/workflows/prompts/re-reviewer.md +0 -33
- package/workflows/prompts/reviewer.md +0 -60
- package/workflows/prompts/verify-browser.md +0 -93
- package/workflows/prompts/verify-synth.md +0 -44
- package/workflows/prompts/verify.md +0 -63
- package/workflows/qa-test.yaml +0 -94
- package/workflows/repo-health.yaml +0 -15
- package/workflows/security-feedback.yaml +0 -25
- package/workflows/security-review.yaml +0 -37
- package/workflows/verify.yaml +0 -93
- /package/dist/{cli/cli-config.d.ts → cli-config.d.ts} +0 -0
- /package/dist/{cli/cli-config.js → cli-config.js} +0 -0
- /package/dist/{cli/cli-format.d.ts → cli-format.d.ts} +0 -0
- /package/dist/{cli/cli-format.js → cli-format.js} +0 -0
- /package/dist/{cli/cli-timeline.d.ts → cli-timeline.d.ts} +0 -0
- /package/dist/{cli/cli-timeline.js → cli-timeline.js} +0 -0
- /package/dist/{cli/cli.d.ts → cli.d.ts} +0 -0
- /package/dist/{cli/oauth-cli.d.ts → oauth-cli.d.ts} +0 -0
- /package/dist/{cli/setup.d.ts → setup.d.ts} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../../../src/connectors/messaging/delivery.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,OAAO,sBAAsB;IACzB,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEpD,gDAAgD;IAChD,QAAQ,CAAC,QAAgB,EAAE,MAAsB;QAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,iCAAiC,QAAQ,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,yEAAyE;IACzE,KAAK,CAAC,OAAO,CAAC,OAAe,EAAE,QAAiB;QAC9C,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;gBACZ,OAAO,CAAC,IAAI,CAAC,iDAAiD,QAAQ,EAAE,CAAC,CAAC;gBAC1E,OAAO;YACT,CAAC;YACD,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;YACtB,OAAO;QACT,CAAC;QAED,oCAAoC;QACpC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC1C,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;YACxB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,mCAAmC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;IAED,mDAAmD;IACnD,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { MessagingConnector } from "./base.js";
|
|
2
|
-
export { SessionManager } from "./session-manager.js";
|
|
3
|
-
export { MessageDeliveryService, type DeliveryTarget } from "./delivery.js";
|
|
4
|
-
export type { MessagingConfig, ConversationKey, ConversationSession, ConversationMessage, IncomingMessageParams, } from "./types.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connectors/messaging/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAuB,MAAM,eAAe,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type Database from "better-sqlite3";
|
|
2
|
-
import type { ConversationKey, ConversationSession, ConversationMessage } from "./types.js";
|
|
3
|
-
/**
|
|
4
|
-
* SQLite-backed session manager for messaging conversations.
|
|
5
|
-
* Shared across all messaging platform connectors.
|
|
6
|
-
*/
|
|
7
|
-
export declare class SessionManager {
|
|
8
|
-
private db;
|
|
9
|
-
constructor(db: Database.Database);
|
|
10
|
-
private migrate;
|
|
11
|
-
/**
|
|
12
|
-
* One-shot migration: copy `messaging_sessions` rows into a table
|
|
13
|
-
* without the table-level UNIQUE constraint. `messaging_messages.session_id`
|
|
14
|
-
* has a foreign key to this table, so `DROP TABLE messaging_sessions`
|
|
15
|
-
* trips FK enforcement.
|
|
16
|
-
*
|
|
17
|
-
* Follows SQLite's official table-rebuild recipe
|
|
18
|
-
* (https://www.sqlite.org/lang_altertable.html#otheralter): toggle
|
|
19
|
-
* `foreign_keys` OFF *outside* a transaction, do the rebuild, run
|
|
20
|
-
* `foreign_key_check` to confirm no orphans, COMMIT, re-enable.
|
|
21
|
-
* `defer_foreign_keys` isn't enough — it pushes the check to COMMIT but
|
|
22
|
-
* still fails when the schema flux at rename-time is observed.
|
|
23
|
-
*
|
|
24
|
-
* `foreign_key_check` after the rebuild is belt-and-suspenders: if the
|
|
25
|
-
* copy somehow missed rows the messages reference, fail the migration
|
|
26
|
-
* loudly rather than commit a half-broken schema.
|
|
27
|
-
*/
|
|
28
|
-
private rebuildWithoutTableUnique;
|
|
29
|
-
/** Look up an existing session by id (used to read its agent_session_id). */
|
|
30
|
-
getSession(id: string): ConversationSession | null;
|
|
31
|
-
/** Get an existing active session or create a new one */
|
|
32
|
-
getOrCreateSession(key: ConversationKey): ConversationSession;
|
|
33
|
-
/**
|
|
34
|
-
* Persist the Agent SDK session id captured from the first chat reply in
|
|
35
|
-
* a thread. Subsequent replies in the same thread pass this id back to
|
|
36
|
-
* the SDK as `resume`, so the whole Slack thread maps to one continuous
|
|
37
|
-
* Agent SDK session jsonl instead of a fresh file per message.
|
|
38
|
-
*/
|
|
39
|
-
setAgentSessionId(id: string, agentSessionId: string | null): void;
|
|
40
|
-
/** Update last activity timestamp and increment message count */
|
|
41
|
-
touchSession(id: string): void;
|
|
42
|
-
/** Deactivate a session (e.g., user sends /new or /reset) */
|
|
43
|
-
deactivateSession(id: string): void;
|
|
44
|
-
/** Store a message in the conversation history */
|
|
45
|
-
addMessage(sessionId: string, role: "user" | "assistant", content: string, platformMessageId?: string): void;
|
|
46
|
-
/** Get conversation history for a session (most recent N messages) */
|
|
47
|
-
getHistory(sessionId: string, limit?: number): ConversationMessage[];
|
|
48
|
-
/** Check if the bot is already participating in a thread (any user, any active non-stale session) */
|
|
49
|
-
hasActiveThread(platform: string, channelId: string, threadId: string): boolean;
|
|
50
|
-
/** Clean up old inactive sessions (call from cron) */
|
|
51
|
-
cleanupStaleSessions(maxAgeDays?: number): number;
|
|
52
|
-
private rowToSession;
|
|
53
|
-
}
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "crypto";
|
|
2
|
-
/** Inactivity timeout before a session is considered stale (30 minutes) */
|
|
3
|
-
const SESSION_TIMEOUT_MS = 30 * 60 * 1000;
|
|
4
|
-
/**
|
|
5
|
-
* SQLite-backed session manager for messaging conversations.
|
|
6
|
-
* Shared across all messaging platform connectors.
|
|
7
|
-
*/
|
|
8
|
-
export class SessionManager {
|
|
9
|
-
db;
|
|
10
|
-
constructor(db) {
|
|
11
|
-
this.db = db;
|
|
12
|
-
this.migrate();
|
|
13
|
-
}
|
|
14
|
-
migrate() {
|
|
15
|
-
this.db.exec(`
|
|
16
|
-
CREATE TABLE IF NOT EXISTS messaging_sessions (
|
|
17
|
-
id TEXT PRIMARY KEY,
|
|
18
|
-
platform TEXT NOT NULL,
|
|
19
|
-
channel_id TEXT NOT NULL,
|
|
20
|
-
thread_id TEXT,
|
|
21
|
-
user_id TEXT NOT NULL,
|
|
22
|
-
agent_session_id TEXT,
|
|
23
|
-
created_at TEXT NOT NULL,
|
|
24
|
-
last_activity_at TEXT NOT NULL,
|
|
25
|
-
message_count INTEGER DEFAULT 0,
|
|
26
|
-
active INTEGER DEFAULT 1
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
CREATE TABLE IF NOT EXISTS messaging_messages (
|
|
30
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
31
|
-
session_id TEXT NOT NULL REFERENCES messaging_sessions(id),
|
|
32
|
-
role TEXT NOT NULL,
|
|
33
|
-
content TEXT NOT NULL,
|
|
34
|
-
timestamp TEXT NOT NULL,
|
|
35
|
-
platform_message_id TEXT
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
CREATE INDEX IF NOT EXISTS idx_msg_sessions_lookup
|
|
39
|
-
ON messaging_sessions(platform, channel_id, thread_id, user_id);
|
|
40
|
-
CREATE INDEX IF NOT EXISTS idx_msg_messages_session
|
|
41
|
-
ON messaging_messages(session_id, timestamp);
|
|
42
|
-
`);
|
|
43
|
-
// Older versions of this code put an unconditional
|
|
44
|
-
// `UNIQUE(platform, channel_id, thread_id, user_id)` on the table.
|
|
45
|
-
// That collides with the get-or-create flow: a stale (active=0) row
|
|
46
|
-
// for a returning user/thread would block the INSERT of a fresh
|
|
47
|
-
// session. Replace it with a partial unique index that only enforces
|
|
48
|
-
// the "one active session per key" invariant — the actually-desired
|
|
49
|
-
// semantic. Inactive rows from past sessions are allowed to pile up
|
|
50
|
-
// (deleted later by clearStale).
|
|
51
|
-
const tableSql = this.db
|
|
52
|
-
.prepare(`SELECT sql FROM sqlite_master WHERE type='table' AND name='messaging_sessions'`)
|
|
53
|
-
.get()?.sql ?? "";
|
|
54
|
-
if (tableSql.includes("UNIQUE(platform")) {
|
|
55
|
-
this.rebuildWithoutTableUnique();
|
|
56
|
-
}
|
|
57
|
-
this.db.exec(`
|
|
58
|
-
CREATE UNIQUE INDEX IF NOT EXISTS idx_msg_sessions_unique_active
|
|
59
|
-
ON messaging_sessions(platform, channel_id, thread_id, user_id)
|
|
60
|
-
WHERE active = 1
|
|
61
|
-
`);
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* One-shot migration: copy `messaging_sessions` rows into a table
|
|
65
|
-
* without the table-level UNIQUE constraint. `messaging_messages.session_id`
|
|
66
|
-
* has a foreign key to this table, so `DROP TABLE messaging_sessions`
|
|
67
|
-
* trips FK enforcement.
|
|
68
|
-
*
|
|
69
|
-
* Follows SQLite's official table-rebuild recipe
|
|
70
|
-
* (https://www.sqlite.org/lang_altertable.html#otheralter): toggle
|
|
71
|
-
* `foreign_keys` OFF *outside* a transaction, do the rebuild, run
|
|
72
|
-
* `foreign_key_check` to confirm no orphans, COMMIT, re-enable.
|
|
73
|
-
* `defer_foreign_keys` isn't enough — it pushes the check to COMMIT but
|
|
74
|
-
* still fails when the schema flux at rename-time is observed.
|
|
75
|
-
*
|
|
76
|
-
* `foreign_key_check` after the rebuild is belt-and-suspenders: if the
|
|
77
|
-
* copy somehow missed rows the messages reference, fail the migration
|
|
78
|
-
* loudly rather than commit a half-broken schema.
|
|
79
|
-
*/
|
|
80
|
-
rebuildWithoutTableUnique() {
|
|
81
|
-
console.log("[messaging] migrating messaging_sessions: dropping unconditional UNIQUE constraint");
|
|
82
|
-
const fkOriginal = this.db.pragma("foreign_keys", { simple: true });
|
|
83
|
-
this.db.pragma("foreign_keys = OFF");
|
|
84
|
-
try {
|
|
85
|
-
this.db.exec("BEGIN");
|
|
86
|
-
try {
|
|
87
|
-
this.db.exec(`
|
|
88
|
-
CREATE TABLE messaging_sessions__new (
|
|
89
|
-
id TEXT PRIMARY KEY,
|
|
90
|
-
platform TEXT NOT NULL,
|
|
91
|
-
channel_id TEXT NOT NULL,
|
|
92
|
-
thread_id TEXT,
|
|
93
|
-
user_id TEXT NOT NULL,
|
|
94
|
-
agent_session_id TEXT,
|
|
95
|
-
created_at TEXT NOT NULL,
|
|
96
|
-
last_activity_at TEXT NOT NULL,
|
|
97
|
-
message_count INTEGER DEFAULT 0,
|
|
98
|
-
active INTEGER DEFAULT 1
|
|
99
|
-
);
|
|
100
|
-
INSERT INTO messaging_sessions__new
|
|
101
|
-
SELECT id, platform, channel_id, thread_id, user_id, agent_session_id,
|
|
102
|
-
created_at, last_activity_at, message_count, active
|
|
103
|
-
FROM messaging_sessions;
|
|
104
|
-
DROP TABLE messaging_sessions;
|
|
105
|
-
ALTER TABLE messaging_sessions__new RENAME TO messaging_sessions;
|
|
106
|
-
CREATE INDEX IF NOT EXISTS idx_msg_sessions_lookup
|
|
107
|
-
ON messaging_sessions(platform, channel_id, thread_id, user_id);
|
|
108
|
-
`);
|
|
109
|
-
const violations = this.db.pragma("foreign_key_check");
|
|
110
|
-
if (violations.length > 0) {
|
|
111
|
-
throw new Error(`FK check failed after migration — ${violations.length} dangling reference(s): ` +
|
|
112
|
-
JSON.stringify(violations));
|
|
113
|
-
}
|
|
114
|
-
this.db.exec("COMMIT");
|
|
115
|
-
}
|
|
116
|
-
catch (err) {
|
|
117
|
-
this.db.exec("ROLLBACK");
|
|
118
|
-
throw err;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
if (fkOriginal)
|
|
123
|
-
this.db.pragma("foreign_keys = ON");
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
/** Look up an existing session by id (used to read its agent_session_id). */
|
|
127
|
-
getSession(id) {
|
|
128
|
-
const row = this.db.prepare(`SELECT * FROM messaging_sessions WHERE id = ?`).get(id);
|
|
129
|
-
return row ? this.rowToSession(row) : null;
|
|
130
|
-
}
|
|
131
|
-
/** Get an existing active session or create a new one */
|
|
132
|
-
getOrCreateSession(key) {
|
|
133
|
-
const now = new Date().toISOString();
|
|
134
|
-
const cutoff = new Date(Date.now() - SESSION_TIMEOUT_MS).toISOString();
|
|
135
|
-
// Look for an active, non-stale session
|
|
136
|
-
const existing = this.db.prepare(`
|
|
137
|
-
SELECT * FROM messaging_sessions
|
|
138
|
-
WHERE platform = ? AND channel_id = ? AND thread_id IS ? AND user_id = ?
|
|
139
|
-
AND active = 1 AND last_activity_at >= ?
|
|
140
|
-
`).get(key.platform, key.channelId, key.threadId, key.userId, cutoff);
|
|
141
|
-
if (existing) {
|
|
142
|
-
return this.rowToSession(existing);
|
|
143
|
-
}
|
|
144
|
-
// Deactivate any stale sessions for this key
|
|
145
|
-
this.db.prepare(`
|
|
146
|
-
UPDATE messaging_sessions SET active = 0
|
|
147
|
-
WHERE platform = ? AND channel_id = ? AND thread_id IS ? AND user_id = ? AND active = 1
|
|
148
|
-
`).run(key.platform, key.channelId, key.threadId, key.userId);
|
|
149
|
-
// Create new session
|
|
150
|
-
const id = randomUUID();
|
|
151
|
-
this.db.prepare(`
|
|
152
|
-
INSERT INTO messaging_sessions (id, platform, channel_id, thread_id, user_id, created_at, last_activity_at)
|
|
153
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
154
|
-
`).run(id, key.platform, key.channelId, key.threadId, key.userId, now, now);
|
|
155
|
-
return {
|
|
156
|
-
id,
|
|
157
|
-
platform: key.platform,
|
|
158
|
-
channelId: key.channelId,
|
|
159
|
-
threadId: key.threadId,
|
|
160
|
-
userId: key.userId,
|
|
161
|
-
agentSessionId: null,
|
|
162
|
-
createdAt: now,
|
|
163
|
-
lastActivityAt: now,
|
|
164
|
-
messageCount: 0,
|
|
165
|
-
active: true,
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Persist the Agent SDK session id captured from the first chat reply in
|
|
170
|
-
* a thread. Subsequent replies in the same thread pass this id back to
|
|
171
|
-
* the SDK as `resume`, so the whole Slack thread maps to one continuous
|
|
172
|
-
* Agent SDK session jsonl instead of a fresh file per message.
|
|
173
|
-
*/
|
|
174
|
-
setAgentSessionId(id, agentSessionId) {
|
|
175
|
-
this.db.prepare(`
|
|
176
|
-
UPDATE messaging_sessions SET agent_session_id = ? WHERE id = ?
|
|
177
|
-
`).run(agentSessionId, id);
|
|
178
|
-
}
|
|
179
|
-
/** Update last activity timestamp and increment message count */
|
|
180
|
-
touchSession(id) {
|
|
181
|
-
this.db.prepare(`
|
|
182
|
-
UPDATE messaging_sessions
|
|
183
|
-
SET last_activity_at = ?, message_count = message_count + 1
|
|
184
|
-
WHERE id = ?
|
|
185
|
-
`).run(new Date().toISOString(), id);
|
|
186
|
-
}
|
|
187
|
-
/** Deactivate a session (e.g., user sends /new or /reset) */
|
|
188
|
-
deactivateSession(id) {
|
|
189
|
-
this.db.prepare(`UPDATE messaging_sessions SET active = 0 WHERE id = ?`).run(id);
|
|
190
|
-
}
|
|
191
|
-
/** Store a message in the conversation history */
|
|
192
|
-
addMessage(sessionId, role, content, platformMessageId) {
|
|
193
|
-
this.db.prepare(`
|
|
194
|
-
INSERT INTO messaging_messages (session_id, role, content, timestamp, platform_message_id)
|
|
195
|
-
VALUES (?, ?, ?, ?, ?)
|
|
196
|
-
`).run(sessionId, role, content, new Date().toISOString(), platformMessageId || null);
|
|
197
|
-
}
|
|
198
|
-
/** Get conversation history for a session (most recent N messages) */
|
|
199
|
-
getHistory(sessionId, limit = 50) {
|
|
200
|
-
const rows = this.db.prepare(`
|
|
201
|
-
SELECT * FROM messaging_messages
|
|
202
|
-
WHERE session_id = ?
|
|
203
|
-
ORDER BY timestamp ASC
|
|
204
|
-
LIMIT ?
|
|
205
|
-
`).all(sessionId, limit);
|
|
206
|
-
return rows.map((r) => ({
|
|
207
|
-
id: r.id,
|
|
208
|
-
sessionId: r.session_id,
|
|
209
|
-
role: r.role,
|
|
210
|
-
content: r.content,
|
|
211
|
-
timestamp: r.timestamp,
|
|
212
|
-
platformMessageId: r.platform_message_id,
|
|
213
|
-
}));
|
|
214
|
-
}
|
|
215
|
-
/** Check if the bot is already participating in a thread (any user, any active non-stale session) */
|
|
216
|
-
hasActiveThread(platform, channelId, threadId) {
|
|
217
|
-
const cutoff = new Date(Date.now() - SESSION_TIMEOUT_MS).toISOString();
|
|
218
|
-
const row = this.db.prepare(`
|
|
219
|
-
SELECT 1 FROM messaging_sessions
|
|
220
|
-
WHERE platform = ? AND channel_id = ? AND thread_id = ?
|
|
221
|
-
AND active = 1 AND last_activity_at >= ?
|
|
222
|
-
LIMIT 1
|
|
223
|
-
`).get(platform, channelId, threadId);
|
|
224
|
-
return !!row;
|
|
225
|
-
}
|
|
226
|
-
/** Clean up old inactive sessions (call from cron) */
|
|
227
|
-
cleanupStaleSessions(maxAgeDays = 7) {
|
|
228
|
-
const cutoff = new Date(Date.now() - maxAgeDays * 24 * 60 * 60 * 1000).toISOString();
|
|
229
|
-
// Delete messages for old sessions first
|
|
230
|
-
this.db.prepare(`
|
|
231
|
-
DELETE FROM messaging_messages WHERE session_id IN (
|
|
232
|
-
SELECT id FROM messaging_sessions WHERE active = 0 AND last_activity_at < ?
|
|
233
|
-
)
|
|
234
|
-
`).run(cutoff);
|
|
235
|
-
const result = this.db.prepare(`
|
|
236
|
-
DELETE FROM messaging_sessions WHERE active = 0 AND last_activity_at < ?
|
|
237
|
-
`).run(cutoff);
|
|
238
|
-
return result.changes;
|
|
239
|
-
}
|
|
240
|
-
rowToSession(row) {
|
|
241
|
-
return {
|
|
242
|
-
id: row.id,
|
|
243
|
-
platform: row.platform,
|
|
244
|
-
channelId: row.channel_id,
|
|
245
|
-
threadId: row.thread_id,
|
|
246
|
-
userId: row.user_id,
|
|
247
|
-
agentSessionId: row.agent_session_id,
|
|
248
|
-
createdAt: row.created_at,
|
|
249
|
-
lastActivityAt: row.last_activity_at,
|
|
250
|
-
messageCount: row.message_count,
|
|
251
|
-
active: !!row.active,
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
//# sourceMappingURL=session-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.js","sourceRo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|
-
* Shared types for messaging platform connectors (Slack, Discord, Teams, etc.).
|
|
3
|
-
* Platform-specific connectors extend MessagingConfig and implement
|
|
4
|
-
* the abstract methods in MessagingConnector.
|
|
5
|
-
*/
|
|
6
|
-
/** Base config shared by all messaging connectors */
|
|
7
|
-
export interface MessagingConfig {
|
|
8
|
-
/** Platform user IDs allowed to interact with the bot */
|
|
9
|
-
allowedUsers: string[];
|
|
10
|
-
/** Bot's identifier for @mention detection (platform-specific format) */
|
|
11
|
-
botIdentifier: string;
|
|
12
|
-
}
|
|
13
|
-
/** Unique key identifying a conversation thread */
|
|
14
|
-
export interface ConversationKey {
|
|
15
|
-
/** Platform name (e.g., "slack", "discord") */
|
|
16
|
-
platform: string;
|
|
17
|
-
/** Platform-specific channel/DM identifier */
|
|
18
|
-
channelId: string;
|
|
19
|
-
/** Thread identifier (null for top-level DMs) */
|
|
20
|
-
threadId: string | null;
|
|
21
|
-
/** User who initiated */
|
|
22
|
-
userId: string;
|
|
23
|
-
}
|
|
24
|
-
/** Persisted conversation session */
|
|
25
|
-
export interface ConversationSession {
|
|
26
|
-
id: string;
|
|
27
|
-
platform: string;
|
|
28
|
-
channelId: string;
|
|
29
|
-
threadId: string | null;
|
|
30
|
-
userId: string;
|
|
31
|
-
/** Agent SDK session ID for multi-turn context (reserved for future use) */
|
|
32
|
-
agentSessionId: string | null;
|
|
33
|
-
createdAt: string;
|
|
34
|
-
lastActivityAt: string;
|
|
35
|
-
messageCount: number;
|
|
36
|
-
active: boolean;
|
|
37
|
-
}
|
|
38
|
-
/** A single message in a conversation */
|
|
39
|
-
export interface ConversationMessage {
|
|
40
|
-
id: number;
|
|
41
|
-
sessionId: string;
|
|
42
|
-
role: "user" | "assistant";
|
|
43
|
-
content: string;
|
|
44
|
-
timestamp: string;
|
|
45
|
-
platformMessageId: string | null;
|
|
46
|
-
}
|
|
47
|
-
/** Parameters passed from platform connector to handleIncomingMessage() */
|
|
48
|
-
export interface IncomingMessageParams {
|
|
49
|
-
platformUserId: string;
|
|
50
|
-
platformUsername: string;
|
|
51
|
-
channelId: string;
|
|
52
|
-
threadId: string | null;
|
|
53
|
-
messageId: string;
|
|
54
|
-
text: string;
|
|
55
|
-
isDM: boolean;
|
|
56
|
-
isMention: boolean;
|
|
57
|
-
raw: unknown;
|
|
58
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/connectors/messaging/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { type KnownBlock } from "@slack/web-api";
|
|
2
|
-
import type { Hono } from "hono";
|
|
3
|
-
import { MessagingConnector } from "../messaging/base.js";
|
|
4
|
-
import type { SessionManager } from "../messaging/session-manager.js";
|
|
5
|
-
import type { MessagingConfig } from "../messaging/types.js";
|
|
6
|
-
import type { EventEnvelope } from "../types.js";
|
|
7
|
-
/**
|
|
8
|
-
* A resolved approval-button click, handed to the app for routing. `envelope`
|
|
9
|
-
* carries a `reply()` that posts a confirmation into the button's thread, so
|
|
10
|
-
* the same approval-resolution path used by `/approve` can run unchanged.
|
|
11
|
-
*/
|
|
12
|
-
export interface SlackApprovalAction {
|
|
13
|
-
decision: "approved" | "rejected";
|
|
14
|
-
/** The paused workflow run id (the button's `value`). */
|
|
15
|
-
workflowRunId: string;
|
|
16
|
-
sender: string;
|
|
17
|
-
envelope: EventEnvelope;
|
|
18
|
-
}
|
|
19
|
-
export interface SlackConnectorConfig extends MessagingConfig {
|
|
20
|
-
/** Bot User OAuth Token (xoxb-…) — used for all Web API calls (sending). */
|
|
21
|
-
botToken: string;
|
|
22
|
-
/** How events are received. */
|
|
23
|
-
mode: "webhook" | "socket";
|
|
24
|
-
/** App-Level Token for Socket Mode (xapp-…). Required when mode === "socket". */
|
|
25
|
-
appToken?: string;
|
|
26
|
-
/** Events API signing secret. Required when mode === "webhook". */
|
|
27
|
-
signingSecret?: string;
|
|
28
|
-
/** Channel ID for cron report delivery */
|
|
29
|
-
deliveryChannel?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Shared Hono app to mount `POST /webhooks/slack` on (webhook mode). This is
|
|
32
|
-
* the same HTTP server the GitHub webhook + /api/chat already run on. Must be
|
|
33
|
-
* present in webhook mode.
|
|
34
|
-
*/
|
|
35
|
-
honoApp?: Hono;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Slack connector. Two receive modes:
|
|
39
|
-
*
|
|
40
|
-
* - **webhook** (default/prod): the HTTP Events API. Slack POSTs to
|
|
41
|
-
* `/webhooks/slack`; we verify the signing-secret signature, answer the
|
|
42
|
-
* one-time url_verification handshake, dedup retries by `event_id`, and ack
|
|
43
|
-
* within Slack's 3s window while processing async. Slack retries failed
|
|
44
|
-
* deliveries, so this is at-least-once — it does not silently drop messages
|
|
45
|
-
* the way Socket Mode does.
|
|
46
|
-
* - **socket** (dev fallback): Socket Mode over a WebSocket, no public URL
|
|
47
|
-
* needed. At-most-once; kept only for local development.
|
|
48
|
-
*
|
|
49
|
-
* Sending is identical in both modes via a `WebClient`.
|
|
50
|
-
*
|
|
51
|
-
* Behaviors:
|
|
52
|
-
* - DMs: responds to every message (subscribe `message.im` in webhook mode)
|
|
53
|
-
* - Channels: only responds when @mentioned (subscribe `app_mention`)
|
|
54
|
-
*/
|
|
55
|
-
export declare class SlackConnector extends MessagingConnector {
|
|
56
|
-
readonly name = "slack";
|
|
57
|
-
/** Web API client for sending — used in both modes. */
|
|
58
|
-
private web;
|
|
59
|
-
/** Bolt app — constructed only in socket mode, purely as the receiver. */
|
|
60
|
-
private bolt;
|
|
61
|
-
private slackConfig;
|
|
62
|
-
private userCache;
|
|
63
|
-
/** Bounded set of processed Events API delivery ids, to drop Slack retries. */
|
|
64
|
-
private seenEventIds;
|
|
65
|
-
private seenEventOrder;
|
|
66
|
-
/** App-provided hook that routes an approval button click into the dispatcher. */
|
|
67
|
-
private approvalHandler?;
|
|
68
|
-
constructor(config: SlackConnectorConfig, sessionManager: SessionManager);
|
|
69
|
-
/**
|
|
70
|
-
* Register the hook that routes an approval button click into the app's
|
|
71
|
-
* dispatcher. Wired in `src/index.ts` (after the dispatch deps exist) to the
|
|
72
|
-
* same `approval-response` resolution path as the `/approve` slash command.
|
|
73
|
-
*/
|
|
74
|
-
onApprovalAction(handler: (action: SlackApprovalAction) => Promise<void>): void;
|
|
75
|
-
start(): Promise<void>;
|
|
76
|
-
stop(): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Post a message. When `blocks` are supplied they carry the rich rendering;
|
|
79
|
-
* `text` is still sent as the notification preview + accessibility fallback
|
|
80
|
-
* (Slack requires it and truncates it for the push/desktop notification).
|
|
81
|
-
* When no explicit blocks are given but the text contains a markdown image,
|
|
82
|
-
* the message is auto-promoted to Block Kit so the image renders inline (the
|
|
83
|
-
* mrkdwn text path can only downgrade `` to a link); if Slack
|
|
84
|
-
* rejects the generated blocks (e.g. an unreachable image URL) it falls back
|
|
85
|
-
* to a plain-text post.
|
|
86
|
-
*/
|
|
87
|
-
sendMessage(channelId: string, threadId: string | null, text: string, blocks?: KnownBlock[]): Promise<string | void>;
|
|
88
|
-
/**
|
|
89
|
-
* Edit a previously-sent message in place (`chat.update`). Paired with the
|
|
90
|
-
* `ts` returned by `sendMessage`, this powers the single in-place status
|
|
91
|
-
* checklist (see `src/notify/transports/slack.ts`) so a workflow's progress
|
|
92
|
-
* updates one message instead of flooding the thread. Note: `chat.update` is
|
|
93
|
-
* silent — it does not re-notify — so a separate terminal message is posted
|
|
94
|
-
* at the end for an actual ping.
|
|
95
|
-
*/
|
|
96
|
-
updateMessage(channelId: string, ts: string, text: string, blocks?: KnownBlock[]): Promise<void>;
|
|
97
|
-
addReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
|
|
98
|
-
showTyping(channelId: string, messageId: string, threadRootId: string): Promise<void>;
|
|
99
|
-
/** Clear the thinking status after processing completes */
|
|
100
|
-
clearTyping(channelId: string, threadId: string): Promise<void>;
|
|
101
|
-
/** Send a message to the configured delivery channel (for cron reports) */
|
|
102
|
-
sendToDeliveryChannel(text: string): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Mount `POST /webhooks/slack` on the shared Hono app. Verifies the request
|
|
105
|
-
* signature, handles the url_verification handshake, dedups retries, and
|
|
106
|
-
* acks fast while processing the event asynchronously.
|
|
107
|
-
*/
|
|
108
|
-
private mountWebhookRoute;
|
|
109
|
-
/** Wire Bolt block-action listeners (socket mode) to the same handler. */
|
|
110
|
-
private setupInteractionListeners;
|
|
111
|
-
/**
|
|
112
|
-
* Resolve an approval button click: rewrite the prompt message to a
|
|
113
|
-
* button-free resolved state, then route the decision through the app's
|
|
114
|
-
* approval handler (the same path as the `/approve` slash command).
|
|
115
|
-
*/
|
|
116
|
-
private handleInteraction;
|
|
117
|
-
/** Rewrite an approval prompt to a resolved, button-free state. */
|
|
118
|
-
private resolveApprovalMessage;
|
|
119
|
-
/** Route a raw Events API `event` object to the right handler. */
|
|
120
|
-
private dispatchSlackEvent;
|
|
121
|
-
/**
|
|
122
|
-
* Record an Events API delivery id as seen. Returns true if it was already
|
|
123
|
-
* seen (a Slack retry). Bounded to the most recent ~1000 ids.
|
|
124
|
-
*/
|
|
125
|
-
private markSeen;
|
|
126
|
-
private setupSocketListeners;
|
|
127
|
-
/** A raw Slack `message` event (DM or channel). */
|
|
128
|
-
private onMessageEvent;
|
|
129
|
-
/** A raw Slack `app_mention` event (always a channel mention). */
|
|
130
|
-
private onAppMention;
|
|
131
|
-
/** Resolve a Slack user ID to a username (cached) */
|
|
132
|
-
private resolveUsername;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Verify a Slack Events API request signature.
|
|
136
|
-
*
|
|
137
|
-
* Slack signs `v0:{timestamp}:{rawBody}` with the app's signing secret and
|
|
138
|
-
* sends it as `x-slack-signature: v0=…`. We recompute and compare in constant
|
|
139
|
-
* time, and reject requests whose timestamp is more than 5 minutes off (replay
|
|
140
|
-
* protection). `now` is injectable for tests. Exported for unit testing.
|
|
141
|
-
*/
|
|
142
|
-
export declare function verifySlackSignature(body: string, timestamp: string, signature: string, signingSecret: string, now?: number): boolean;
|