@desplega.ai/agent-swarm 2.9.0 → 2.10.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/dist/acp-adapter-bht22g3k.js +16 -0
- package/dist/{acp-targets-swxq55dr.js → acp-targets-arrwv4f0.js} +7 -7
- package/dist/{actions-pb678g3e.js → actions-y0d2n1c2.js} +102 -21
- package/dist/{agent-fs-provision-dmhnc38q.js → agent-fs-provision-tpj7sktd.js} +4 -4
- package/dist/{amp-adapter-3pa66q27.js → amp-adapter-vmmnmw8d.js} +2 -2
- package/dist/{anthropic-messages-x2cp5fvf.js → anthropic-messages-zdca3gv1.js} +22 -22
- package/dist/{app-17d12ev4.js → app-wb7w45dq.js} +6 -3
- package/dist/{approval-notifications-h7vd9pmg.js → approval-notifications-7mqr6vbd.js} +8 -5
- package/dist/{assistant-t7k39ree.js → assistant-gf60454p.js} +23 -21
- package/dist/{boot-args-schema-0gqmkfbe.js → boot-args-schema-qxmd59sr.js} +1 -1
- package/dist/{boot-reembed-f064w382.js → boot-reembed-5tmeskj2.js} +1 -1
- package/dist/{boot-reembed-n6anc01d.js → boot-reembed-wb44vc3s.js} +1 -1
- package/dist/boot-scrub-sweep-25bxhnw4.js +9 -0
- package/dist/{boot-seeds-f99fjs5q.js → boot-seeds-nj9za0vk.js} +4 -4
- package/dist/{claude-adapter-gvznwxgc.js → claude-adapter-d3krpdyb.js} +7 -7
- package/dist/{claude-managed-adapter-pbrbvc64.js → claude-managed-adapter-t8nfgcgz.js} +2 -2
- package/dist/{claude-managed-setup-kdxttvc3.js → claude-managed-setup-7y4pwd81.js} +3 -3
- package/dist/{claude-sdk-session-0t2teq6n.js → claude-sdk-session-d138zy0e.js} +7 -7
- package/dist/{cli-6dp0jkfj.js → cli-01k6wpr9.js} +4 -4
- package/dist/{cli-c07v0qfa.js → cli-124ntmf0.js} +83 -74
- package/dist/{cli-1tvdx9t5.js → cli-2rnd5j3t.js} +1 -1
- package/dist/{cli-4ghh072d.js → cli-2spnz7ye.js} +36 -36
- package/dist/{cli-dd37e0cm.js → cli-2v2zdm0a.js} +1 -1
- package/dist/{cli-aa8s22gn.js → cli-3aaeb78m.js} +195 -186
- package/dist/{cli-8x8y70av.js → cli-3caf7pmg.js} +2 -2
- package/dist/{cli-jd3kxppb.js → cli-3et6fmfe.js} +1 -1
- package/dist/{cli-kaa4bd7x.js → cli-3f8zbtqa.js} +9 -8
- package/dist/{cli-57pvhnyt.js → cli-43evxwj4.js} +1 -1
- package/dist/cli-43ms35q9.js +270 -0
- package/dist/cli-47hz21se.js +25584 -0
- package/dist/{cli-n515ex5z.js → cli-4ymxrwg5.js} +16 -16
- package/dist/{cli-2tnbc3gw.js → cli-539h29es.js} +2379 -66
- package/dist/{cli-rts1qvb4.js → cli-5qhfv9rw.js} +2 -2
- package/dist/{cli-faf46gdq.js → cli-6037prsx.js} +10 -10
- package/dist/{cli-bk9v1xrv.js → cli-6cwr32fe.js} +25 -25
- package/dist/{cli-812paz57.js → cli-6ehs4mta.js} +18 -2
- package/dist/{cli-95930z69.js → cli-6ym4jhzp.js} +2 -2
- package/dist/{cli-zg3z63x3.js → cli-7mv4h3sn.js} +1 -1
- package/dist/{cli-9a2rtd77.js → cli-7r162fxe.js} +24 -15
- package/dist/{cli-eg437b5p.js → cli-7sf9sb0w.js} +2 -1
- package/dist/{cli-vw5x18yj.js → cli-8st34zhr.js} +20 -10
- package/dist/{cli-fgphc007.js → cli-91pkxres.js} +1 -1
- package/dist/{cli-2kg31ted.js → cli-9fjr27ez.js} +11 -11
- package/dist/{cli-wr1h0k28.js → cli-9w8712tq.js} +617 -278
- package/dist/cli-aw83sr40.js +98 -0
- package/dist/{cli-ssvdrk4y.js → cli-b6px1k1q.js} +1 -1
- package/dist/{cli-w7dxb2fj.js → cli-cc93xzes.js} +6 -6
- package/dist/{cli-js8zrfyg.js → cli-fcfbct2j.js} +5 -5
- package/dist/{cli-3zxdz9r7.js → cli-fq2rr3jb.js} +6 -6
- package/dist/{boot-scrub-sweep-ejd5dnrz.js → cli-had1p04a.js} +8 -9
- package/dist/{cli-7cgf614g.js → cli-j6te8keb.js} +5 -5
- package/dist/{cli-25nstr34.js → cli-jrbq4djp.js} +1 -1
- package/dist/{cli-pz1c00aa.js → cli-k3q2va86.js} +2 -2
- package/dist/{cli-nhq5js1b.js → cli-k5yewqgd.js} +3 -3
- package/dist/cli-kbtzfrxj.js +404 -0
- package/dist/{cli-dx439zpg.js → cli-kpgcm7xy.js} +13 -1
- package/dist/{cli-mc1fx4xd.js → cli-m9cvf7vs.js} +10 -10
- package/dist/{cli-kmvcm34h.js → cli-md50mj0r.js} +2 -2
- package/dist/{cli-q8cfh1t9.js → cli-mk7c5ac4.js} +1 -1
- package/dist/cli-mys27d03.js +321 -0
- package/dist/{cli-spzkdgtg.js → cli-n3qe7tyr.js} +172 -168
- package/dist/{cli-7akn6ze9.js → cli-nh7x3133.js} +7 -28
- package/dist/{cli-fnh4b12r.js → cli-nstkanmx.js} +6 -6
- package/dist/{cli-g3zzby8t.js → cli-nv4xsvmk.js} +5 -5
- package/dist/{cli-sn4pc4qx.js → cli-p0c3vtch.js} +2 -2
- package/dist/{cli-5ntc4we6.js → cli-p0n7b5rz.js} +859 -2058
- package/dist/{cli-pn1v1pb0.js → cli-psffsanb.js} +3 -2
- package/dist/{cli-svc803vq.js → cli-q5srsxq2.js} +15 -15
- package/dist/{cli-nmcpzbty.js → cli-qrta34nb.js} +4 -4
- package/dist/{cli-k09cxm6m.js → cli-qx4f057j.js} +2 -2
- package/dist/{cli-eepnpee7.js → cli-s1khw52h.js} +12 -12
- package/dist/{cli-h474mvp5.js → cli-s1zqk1aj.js} +21 -11
- package/dist/{cli-8axx8vnw.js → cli-sb4426be.js} +10 -10
- package/dist/{cli-kqh27v2y.js → cli-th1dkc2v.js} +1 -1
- package/dist/{cli-cw7mc1je.js → cli-tr27kwyg.js} +3 -3
- package/dist/{cli-5kcmxwxv.js → cli-tvgqesec.js} +7 -5
- package/dist/{cli-a9hfzg2r.js → cli-ty3gha1p.js} +6 -6
- package/dist/{cli-fjggej24.js → cli-v46zsvqk.js} +1 -1
- package/dist/{cli-5gygrr67.js → cli-v8z0yga9.js} +4 -4
- package/dist/{cli-k7pt28ad.js → cli-vfqvrd82.js} +5 -5
- package/dist/{cli-vvgaz8t6.js → cli-vq2eg24x.js} +2 -2
- package/dist/{cli-pwsax0vp.js → cli-vsw91x06.js} +23 -22
- package/dist/{cli-7fx9jyfs.js → cli-w1q68d8x.js} +67 -11
- package/dist/{cli-c5cspahx.js → cli-wafmk3fn.js} +45 -20
- package/dist/{cli-ymct0ycy.js → cli-wwp1bd3n.js} +5495 -5095
- package/dist/{cli-me4maa4j.js → cli-y4ccxtz5.js} +45 -9
- package/dist/{cli-m1fbz2wj.js → cli-y8p78ekx.js} +178 -19
- package/dist/{cli-nr46j5pw.js → cli-z0m452jr.js} +1 -1
- package/dist/{cli-gddgcnav.js → cli-zeh2mhkg.js} +1 -1
- package/dist/{cli-e9973bf0.js → cli-zk7v5s89.js} +2 -2
- package/dist/cli.js +24 -23
- package/dist/{cloudflare-workers-ai-system-one-9y1zx3pt.js → cloudflare-workers-ai-system-one-4aysy6rh.js} +2 -2
- package/dist/{codex-adapter-44yq2fkn.js → codex-adapter-exfdbj73.js} +6 -6
- package/dist/{codex-hook-h1zb7cfk.js → codex-hook-59atdwd8.js} +1 -1
- package/dist/{codex-login-cdyrr5y1.js → codex-login-a239g1ah.js} +1 -1
- package/dist/{codex-session-runner-zbh26gbw.js → codex-session-runner-xhznc4g3.js} +6 -6
- package/dist/{commands-54f02v5b.js → commands-d8g349v4.js} +3 -3
- package/dist/{controller-9gpwcdek.js → controller-mwgdmb8y.js} +6 -3
- package/dist/{controllers-connect-61re6k1n.js → controllers-connect-5v7qx04j.js} +22 -20
- package/dist/core-sxy4epp2.js +38 -0
- package/dist/{cursor-adapter-7e4g81vd.js → cursor-adapter-p2q5h35d.js} +1 -1
- package/dist/{db-wnh0qjy1.js → db-qpganbeb.js} +3 -3
- package/dist/{db-dg2gc7fd.js → db-wcw0b2j8.js} +8 -2
- package/dist/{dispatcher-jrm24r43.js → dispatcher-8d8s49yz.js} +20 -18
- package/dist/{docker-9aq30pp2.js → docker-09tkkg0n.js} +42 -3
- package/dist/{dsh-adapter-1yqk267c.js → dsh-adapter-me0twn13.js} +1 -1
- package/dist/{easter-egg-3d-r4h9cs9m.js → easter-egg-3d-wv7w5ty6.js} +1 -1
- package/dist/{embedding-space-bafjr5f7.js → embedding-space-e48xchqa.js} +6 -6
- package/dist/{embeddings-7xmgqe0e.js → embeddings-tgq2afbq.js} +1 -1
- package/dist/{execute-d6jg5ns0.js → execute-8rhwrk7f.js} +1 -1
- package/dist/{external-channel-frq1xvq2.js → external-channel-8bt3j2pm.js} +2 -2
- package/dist/fx-adapter-adtdb3jb.js +19 -0
- package/dist/{google-generative-ai-hh7strj3.js → google-generative-ai-bh0djqjp.js} +5 -5
- package/dist/{google-vertex-fy5bw2pm.js → google-vertex-prjbw8dj.js} +9 -9
- package/dist/grok-adapter-accnn9km.js +19 -0
- package/dist/handlers-1x77561e.js +35 -0
- package/dist/{heartbeat-6bpa611t.js → heartbeat-x0056ra5.js} +23 -21
- package/dist/{hook-hvm5nf46.js → hook-a7vmn2st.js} +5 -5
- package/dist/{hook-w12k146y.js → hook-mrd2ayxv.js} +6 -6
- package/dist/{http-43tthdvs.js → http-ym9c5svp.js} +1335 -363
- package/dist/{index-fn054vsf.js → index-01ns1pkw.js} +1 -1
- package/dist/{index-1f0vypbg.js → index-0h6qd4p1.js} +34 -24
- package/dist/index-48qzcqzj.js +35 -0
- package/dist/{index-4b1q8kan.js → index-4k7m5dgj.js} +629 -354
- package/dist/index-620y7jzq.js +15 -0
- package/dist/{index-cret47a5.js → index-8p0j4h4j.js} +506 -43
- package/dist/{index-m5gx1xd6.js → index-9myfj74s.js} +40 -40
- package/dist/{index-bs7gw5fd.js → index-b5wgnm78.js} +44 -44
- package/dist/{index-ftywhyr0.js → index-ny60jcat.js} +394 -66
- package/dist/{index-tx9mc2ap.js → index-p46tvwtx.js} +24 -22
- package/dist/{index-585gyczt.js → index-pe3d8jfy.js} +3 -3
- package/dist/index-rkvaambe.js +36 -0
- package/dist/{index-mhq4sh5w.js → index-x6azjwm8.js} +1 -1
- package/dist/index-xj1mq27m.js +40 -0
- package/dist/k8s-m56sw868.js +217 -0
- package/dist/{keepalive-rk0j0jvh.js → keepalive-7yxg8z4c.js} +3 -3
- package/dist/lead-enzn86bz.js +74 -0
- package/dist/{maintenance-g6z6kaxw.js → maintenance-6tefxmk1.js} +1 -1
- package/dist/{node-jftbyawr.js → node-2wfcey7d.js} +1 -1
- package/dist/{oauth-refresh-sweep-2k3g2q4w.js → oauth-refresh-sweep-70cavc3a.js} +2 -2
- package/dist/{onboard-6fdbvh3v.js → onboard-fja65z08.js} +5 -5
- package/dist/{openai-decisions-q3hh60wr.js → openai-decisions-ytp6w6xh.js} +1 -1
- package/dist/{opencode-adapter-fdbsvts7.js → opencode-adapter-hakkm7yh.js} +6 -6
- package/dist/{otel-impl-rvwtc09q.js → otel-impl-7zhnt6gj.js} +1 -1
- package/dist/{pending-sqkrb836.js → pending-h01yzpx4.js} +21 -19
- package/dist/{pi-mono-adapter-asqayqcg.js → pi-mono-adapter-f52hz743.js} +40 -13
- package/dist/{pricing-refresh-f5tkgmw2.js → pricing-refresh-fzxvk2zf.js} +2 -2
- package/dist/{rbac-roles-06s555fa.js → rbac-roles-9v6vhgbs.js} +3 -3
- package/dist/{rbac-roles-szxsg8t1.js → rbac-roles-hfgh8sba.js} +2 -2
- package/dist/{render-v2-103p266q.js → render-v2-1rgspxzf.js} +6 -3
- package/dist/{resume-v7kjewt9.js → resume-tqy61x24.js} +10 -7
- package/dist/{runtime-f1gmk0b7.js → runtime-exkxyx5f.js} +1 -1
- package/dist/{session-access-6shev8ts.js → session-access-3act7vt4.js} +4 -4
- package/dist/{session-source-backfill-bd7spzjd.js → session-source-backfill-82qe7fqq.js} +3 -3
- package/dist/{setup-kmxmztdb.js → setup-ry1vfdef.js} +1 -1
- package/dist/thread-buffer-3x93yexa.js +38 -0
- package/dist/{typesafe-system-one-f2en2knd.js → typesafe-system-one-vcfj2ak8.js} +2 -2
- package/dist/user-merge-jobs-bx6bf7db.js +22 -0
- package/dist/{virtual-modules-57eje5wy.js → virtual-modules-s0rjzcqq.js} +3 -3
- package/dist/{work-objects-zr47ygmf.js → work-objects-z2e5tv03.js} +29 -23
- package/dist/{worker-follow-up-grrr3fda.js → worker-follow-up-y3xeg89w.js} +20 -18
- package/dist/worker-zfcv2wbf.js +74 -0
- package/openapi.json +2763 -147
- package/package.json +9 -8
- package/src/apps/catalog.generated.json +43 -3
- package/src/apps/page-validator.ts +27 -0
- package/src/be/boot-seeds.ts +7 -1
- package/src/be/db/model-groups.ts +238 -0
- package/src/be/db/model-profiles.ts +28 -7
- package/src/be/db/session-costs.ts +225 -0
- package/src/be/db/session-log-reasoning.ts +36 -0
- package/src/be/db/tasks/read.ts +8 -3
- package/src/be/db/tasks/write.ts +34 -1
- package/src/be/db/user-references.ts +75 -0
- package/src/be/db/users/references.ts +185 -0
- package/src/be/db-client.ts +70 -19
- package/src/be/db.ts +232 -361
- package/src/be/key-window-usage.ts +386 -0
- package/src/be/memory/demotion-evidence.ts +34 -0
- package/src/be/memory/reranker.ts +34 -12
- package/src/be/memory/review-recall-filter.ts +83 -0
- package/src/be/memory/search-candidates.ts +19 -6
- package/src/be/memory/types.ts +11 -0
- package/src/be/migrations/303_task_ui_specs.sql +28 -0
- package/src/be/migrations/306_provider_account_telemetry.sql +1 -0
- package/src/be/migrations/307_session_cost_credential_attribution.sql +23 -0
- package/src/be/migrations/310_session_logs_reasoning.sql +12 -0
- package/src/be/migrations/312_task_ui_action_runs_repeatable.sql +6 -0
- package/src/be/migrations/314_model_groups.sql +85 -0
- package/src/be/migrations/318_superseded_workflow_cut_backfill.sql +22 -0
- package/src/be/migrations/319_user_fk_indexes.sql +153 -0
- package/src/be/migrations/320_session_costs_kind.sql +4 -0
- package/src/be/migrations/321_user_merge_jobs.sql +52 -0
- package/src/be/pricing-normalize.ts +2 -0
- package/src/be/rbac-roles.ts +6 -4
- package/src/be/runtime-pools/db.ts +23 -5
- package/src/be/runtime-pools/supervisor.ts +15 -1
- package/src/be/scripts/db.ts +11 -0
- package/src/be/scripts/typecheck.ts +2 -0
- package/src/be/seed-model-groups.ts +86 -0
- package/src/be/seed-model-profiles.ts +20 -13
- package/src/be/seed-scripts/catalog/boot-triage.inline.ts +1 -0
- package/src/be/seed-scripts/catalog/boot-triage.ts +1 -0
- package/src/be/seed-scripts/catalog/dreaming-gather.ts +165 -1
- package/src/be/seed-scripts/catalog/wait-for-task.ts +5 -1
- package/src/be/seed-skills/index.ts +3 -0
- package/src/be/swarm-config-guard.ts +58 -1
- package/src/be/task-ui-spec.ts +259 -0
- package/src/be/user-merge-jobs.ts +564 -0
- package/src/be/users.ts +41 -23
- package/src/commands/controller.ts +3 -0
- package/src/commands/credential-outcome-report.ts +13 -3
- package/src/commands/onboard/agent-fs-version.ts +1 -1
- package/src/commands/onboard/compose-generator.ts +1 -1
- package/src/commands/onboard/env-generator.ts +1 -1
- package/src/commands/provider-credentials.ts +1 -1
- package/src/commands/rate-limit-outcome.ts +6 -0
- package/src/commands/runner.ts +34 -53
- package/src/extensions/catalog.generated.json +3 -3
- package/src/extensions/contract-types.generated.ts +1 -1
- package/src/extensions/contract.ts +15 -0
- package/src/extensions/dispatcher.ts +14 -4
- package/src/github/handlers.ts +57 -0
- package/src/github/types.ts +4 -0
- package/src/http/all-routes.ts +2 -0
- package/src/http/api-keys.ts +258 -30
- package/src/http/approval-requests.ts +5 -1
- package/src/http/auth.ts +3 -1
- package/src/http/config.ts +34 -1
- package/src/http/index.ts +13 -0
- package/src/http/memory.ts +19 -6
- package/src/http/model-groups.ts +277 -0
- package/src/http/model-profiles.ts +30 -13
- package/src/http/session-data.ts +74 -23
- package/src/http/sessions.ts +6 -2
- package/src/http/tasks.ts +140 -5
- package/src/http/tool-hooks.ts +140 -0
- package/src/http/users.ts +142 -19
- package/src/http/workflows.ts +19 -1
- package/src/integrations/chat-sdk/inbound.ts +8 -2
- package/src/integrations/chat-sdk/limits.ts +8 -3
- package/src/integrations/chat-sdk/relay.ts +87 -0
- package/src/jira/outbound.ts +5 -3
- package/src/linear/outbound.ts +5 -1
- package/src/prompts/base-prompt.ts +8 -0
- package/src/prompts/session-templates.ts +19 -2
- package/src/providers/acp-targets.ts +2 -2
- package/src/providers/amp-adapter.ts +1 -1
- package/src/providers/claude-adapter.ts +27 -4
- package/src/providers/claude-flag-settings.ts +39 -1
- package/src/providers/codex-adapter.ts +85 -3
- package/src/providers/codex-app-server.ts +9 -5
- package/src/providers/codex-oauth/auth-json.ts +1 -0
- package/src/providers/pi-mono-adapter.ts +35 -2
- package/src/providers/pricing-sources.md +41 -0
- package/src/providers/types.ts +11 -0
- package/src/rbac/legacy-policy.ts +1 -0
- package/src/rbac/permissions.ts +5 -0
- package/src/runtime-providers/docker.ts +65 -1
- package/src/runtime-providers/index.ts +7 -5
- package/src/runtime-providers/k8s.ts +250 -0
- package/src/scheduler/deferred-task-waits.ts +18 -5
- package/src/scripts-runtime/types/stdlib.d.ts +2 -0
- package/src/scripts-runtime/types/swarm-extension.d.ts +24 -9
- package/src/scripts-runtime/types/swarm-sdk.d.ts +2 -0
- package/src/slack/actions.ts +79 -0
- package/src/slack/app.ts +22 -15
- package/src/slack/blocks.ts +23 -2
- package/src/slack/inbound-files.ts +2 -0
- package/src/slack/render-v2.ts +154 -23
- package/src/slack/responses.ts +3 -2
- package/src/slack/work-objects.ts +4 -1
- package/src/tasks/errors.ts +5 -0
- package/src/tests/acp-adapter.test.ts +30 -6
- package/src/tests/api-key-tracking.test.ts +0 -72
- package/src/tests/api-keys-status-model-limits.test.ts +93 -1
- package/src/tests/api-keys-validation.test.ts +42 -0
- package/src/tests/approval-card-resolution.test.ts +7 -1
- package/src/tests/approval-requests-notifications.test.ts +11 -1
- package/src/tests/apps-catalog-page-frame.test.ts +49 -0
- package/src/tests/apps-session-thread.test.ts +79 -0
- package/src/tests/base-prompt.test.ts +111 -5
- package/src/tests/chat-sdk-relay.test.ts +170 -2
- package/src/tests/check-pr-body.test.ts +43 -0
- package/src/tests/claude-adapter-binary.test.ts +67 -6
- package/src/tests/claude-flag-settings.test.ts +29 -0
- package/src/tests/claude-sdk-lifecycle.test.ts +5 -0
- package/src/tests/codex-adapter.test.ts +340 -2
- package/src/tests/codex-app-server.test.ts +16 -0
- package/src/tests/codex-oauth.test.ts +3 -1
- package/src/tests/codex-rate-limits.test.ts +384 -0
- package/src/tests/credential-check.test.ts +14 -6
- package/src/tests/credential-outcome-report.test.ts +20 -0
- package/src/tests/db-client.test.ts +146 -0
- package/src/tests/db-task-read-contract.test.ts +3 -0
- package/src/tests/db-task-write-contract.test.ts +4 -0
- package/src/tests/deferred-task-wake.test.ts +63 -1
- package/src/tests/deploy-guard.test.ts +7 -7
- package/src/tests/deploy-select.test.ts +83 -0
- package/src/tests/docker-isolation-config-guard.test.ts +29 -0
- package/src/tests/docs-index-footprint.test.js +11 -3
- package/src/tests/dreaming-gather-corrections.test.ts +467 -0
- package/src/tests/e2e-visuals-comment.test.ts +82 -0
- package/src/tests/e2e-visuals-verify-pr.test.ts +138 -0
- package/src/tests/event-loop-lag.test.ts +9 -7
- package/src/tests/extensions-example-sql-admin-only.test.ts +7 -4
- package/src/tests/fixtures/extensions/native-tool-recorder/hooks.ts +26 -0
- package/src/tests/fixtures/extensions/native-tool-recorder/manifest.json +10 -0
- package/src/tests/fixtures/onboard/content.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/content.env.txt +1 -1
- package/src/tests/fixtures/onboard/dev.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/dev.env.txt +1 -1
- package/src/tests/fixtures/onboard/full-all.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/full-all.env.txt +1 -1
- package/src/tests/fixtures/onboard/full.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/full.env.txt +1 -1
- package/src/tests/fixtures/onboard/research.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/research.env.txt +1 -1
- package/src/tests/fixtures/onboard/solo.compose.yml.txt +1 -1
- package/src/tests/fixtures/onboard/solo.env.txt +1 -1
- package/src/tests/fixtures/ui-spec-slack/deploys.json +121 -0
- package/src/tests/fixtures/ui-spec-slack/incident.json +183 -0
- package/src/tests/fixtures/ui-spec-slack/three-charts-stale.json +196 -0
- package/src/tests/fixtures/ui-spec-slack/video-rejected-by-slack.json +183 -0
- package/src/tests/fixtures/ui-spec-slack/video.json +446 -0
- package/src/tests/github-event-filter.test.ts +8 -0
- package/src/tests/github-handlers-inline-comments.test.ts +2 -0
- package/src/tests/github-handlers-reactions.test.ts +4 -0
- package/src/tests/github-handlers.test.ts +3 -0
- package/src/tests/github-sender-trust.test.ts +223 -0
- package/src/tests/gitleaks-download-retry.test.ts +85 -0
- package/src/tests/http-users.test.ts +142 -41
- package/src/tests/human-thread-routing.test.ts +187 -0
- package/src/tests/jira-outbound-sync.test.ts +33 -1
- package/src/tests/k8s-pool-smoke.test.ts +190 -0
- package/src/tests/key-window-usage.test.ts +846 -0
- package/src/tests/linear-outbound-sync.test.ts +30 -1
- package/src/tests/memory-rater-store.test.ts +35 -1
- package/src/tests/memory-reranker.test.ts +39 -4
- package/src/tests/memory-review-recall-filter.test.ts +205 -0
- package/src/tests/migration-318-superseded-workflow-cut-backfill.test.ts +74 -0
- package/src/tests/model-groups-api.test.ts +415 -0
- package/src/tests/model-profiles-api.test.ts +1 -0
- package/src/tests/operator-granted-credentials.test.ts +7 -2
- package/src/tests/operator-granted-role-wire.test.ts +2 -1
- package/src/tests/pi-mono-adapter.test.ts +79 -0
- package/src/tests/preload-env.test.ts +2 -0
- package/src/tests/preload.ts +3 -1
- package/src/tests/prompt-template-session.test.ts +4 -3
- package/src/tests/provider-quota-persistence.test.ts +362 -0
- package/src/tests/rate-limit-event.test.ts +22 -0
- package/src/tests/rbac-engine.test.ts +1 -0
- package/src/tests/reasoning-events.test.ts +164 -0
- package/src/tests/routing-affinity-inventory.test.ts +22 -0
- package/src/tests/runtime-k8s-pools.test.ts +142 -0
- package/src/tests/runtime-pools-db.test.ts +42 -2
- package/src/tests/runtime-pools-http.test.ts +47 -2
- package/src/tests/runtime-provider-registration.test.ts +5 -14
- package/src/tests/runtime-providers-docker.test.ts +91 -0
- package/src/tests/runtime-providers-k8s.test.ts +303 -0
- package/src/tests/script-connections.test.ts +18 -1
- package/src/tests/secret-canary-sweep.test.ts +41 -5
- package/src/tests/seed-scripts.test.ts +23 -0
- package/src/tests/session-cost-attribution.test.ts +748 -0
- package/src/tests/session-costs.test.ts +14 -15
- package/src/tests/session-logs.test.ts +83 -0
- package/src/tests/sessions-detail-batch.test.ts +7 -0
- package/src/tests/short-id.test.ts +23 -0
- package/src/tests/slack-blocks.test.ts +69 -0
- package/src/tests/slack-render-v2.test.ts +411 -0
- package/src/tests/slack-start-reload-race.test.ts +67 -0
- package/src/tests/spec-base-url.test.ts +13 -1
- package/src/tests/subscription-plans.test.ts +20 -1
- package/src/tests/system-one-decide-session-cost.test.ts +196 -0
- package/src/tests/task-ui-action-route.test.ts +249 -0
- package/src/tests/task-ui-actions.test.ts +195 -0
- package/src/tests/task-ui-script-actions.test.ts +517 -0
- package/src/tests/task-ui-spec-fallback.test.ts +65 -0
- package/src/tests/task-ui-spec.test.ts +368 -0
- package/src/tests/tool-hooks-http.test.ts +187 -0
- package/src/tests/ui-spec-script-actions-config.test.ts +196 -0
- package/src/tests/user-delete-perf.test.ts +321 -0
- package/src/tests/user-merge-jobs.test.ts +680 -0
- package/src/tests/vcs-provider.test.ts +25 -5
- package/src/tests/vendored-openapi.test.ts +13 -1
- package/src/tests/workflow-agent-task-retry.test.ts +96 -1
- package/src/tests/workflow-foreach-supersede-retry.test.ts +10 -0
- package/src/tests/workflow-http-v2.test.ts +27 -0
- package/src/tests/workflow-replay.test.ts +10 -1
- package/src/tests/workflow-triggers-v2.test.ts +128 -0
- package/src/tests/workflow-wait-event.test.ts +109 -1
- package/src/tools/defer-task.ts +1 -1
- package/src/tools/memory-search.ts +14 -3
- package/src/tools/store-progress.ts +69 -3
- package/src/tools/swarm-config/delete-config.ts +12 -1
- package/src/tools/swarm-config/set-config.ts +8 -0
- package/src/tools/system-one-decide.ts +113 -3
- package/src/tools/utils.ts +4 -1
- package/src/tools/workflows/create-workflow.ts +2 -0
- package/src/tools/workflows/update-workflow.ts +3 -1
- package/src/types.ts +93 -4
- package/src/ui-spec/actions.ts +112 -0
- package/src/ui-spec/fallback.ts +19 -0
- package/src/ui-spec/schema.ts +38 -0
- package/src/ui-spec/script-actions.ts +340 -0
- package/src/ui-spec/script-allowlist.ts +48 -0
- package/src/ui-spec/slack.ts +17 -0
- package/src/ui-spec/validate.ts +169 -0
- package/src/utils/codex-rate-limits.ts +159 -0
- package/src/utils/credentials.ts +2 -0
- package/src/utils/error-tracker.ts +19 -0
- package/src/utils/provider-account-telemetry.ts +331 -0
- package/src/utils/reasoning-events.ts +107 -0
- package/src/utils/short-id.ts +20 -14
- package/src/utils/subscription-plans.ts +11 -59
- package/src/utils/task-ui-spec.ts +79 -0
- package/src/vcs/index.ts +12 -2
- package/src/workflows/executors/system-one-decision.ts +2 -2
- package/src/workflows/resume.ts +3 -2
- package/src/workflows/task-step-routing.ts +38 -13
- package/src/workflows/triggers.ts +35 -3
- package/templates/extensions/manifest.schema.json +13 -0
- package/templates/extensions/sql-admin-only/README.md +2 -1
- package/templates/extensions/sql-admin-only/hooks.ts +7 -3
- package/templates/extensions/sql-admin-only/manifest.json +1 -1
- package/templates/skills/apps/SKILL.md +32 -5
- package/templates/skills/apps/content.md +32 -5
- package/templates/skills/swarm-docs/content.md +2 -0
- package/templates/skills/ui-spec/config.json +14 -0
- package/templates/skills/ui-spec/content.md +133 -0
- package/templates/workflows/dreaming/content.md +1 -1
- package/dist/acp-adapter-jqn86aam.js +0 -16
- package/dist/cli-7831nhaw.js +0 -93
- package/dist/cli-srtkr1h2.js +0 -12078
- package/dist/fx-adapter-0zrkfbkd.js +0 -19
- package/dist/grok-adapter-3db1c538.js +0 -19
- package/dist/handlers-k22n8mnn.js +0 -33
- package/dist/index-8xcyd3mc.js +0 -33
- package/dist/index-9sy2bh6n.js +0 -38
- package/dist/index-b24j7t2m.js +0 -12797
- package/dist/index-wjd56k1v.js +0 -34
- package/dist/lead-atxf3q6e.js +0 -72
- package/dist/thread-buffer-4yz236d0.js +0 -36
- package/dist/worker-p4hbtcy3.js +0 -72
- package/dist/{azure-openai-responses-590s1eea.js → azure-openai-responses-b3y7fz36.js} +8 -8
- package/dist/{cli-j49yqpvh.js → cli-7evph51z.js} +3 -3
- package/dist/{cli-g0vv9dg4.js → cli-8y43jx2r.js} +8 -8
- package/dist/{cli-m0cy2vyf.js → cli-k6nejceb.js} +4 -4
- package/dist/{mistral-conversations-0c30em7t.js → mistral-conversations-tm2vd4gc.js} +8 -8
- package/dist/{openai-codex-responses-bkcd8pjj.js → openai-codex-responses-sxjv60xx.js} +4 -4
- package/dist/{openai-completions-f3n69rep.js → openai-completions-0c7qnhsx.js} +20 -20
- package/dist/{openai-responses-gbh0wfqe.js → openai-responses-a7h29chp.js} +15 -15
- package/dist/{pi-messages-zebyt7gb.js → pi-messages-2j0fpqwq.js} +5 -5
|
@@ -14,21 +14,21 @@ import {
|
|
|
14
14
|
getEmoji2,
|
|
15
15
|
defaultEmojiResolver2,
|
|
16
16
|
convertEmojiPlaceholders2,
|
|
17
|
-
|
|
18
|
-
} from "./cli-
|
|
17
|
+
init_dist8
|
|
18
|
+
} from "./cli-9w8712tq.js";
|
|
19
19
|
import {
|
|
20
20
|
extractCard,
|
|
21
21
|
extractFiles,
|
|
22
22
|
extractPostableAttachments,
|
|
23
23
|
AdapterRateLimitError,
|
|
24
|
-
|
|
24
|
+
AuthenticationError3,
|
|
25
25
|
ResourceNotFoundError,
|
|
26
26
|
PermissionError,
|
|
27
27
|
ValidationError,
|
|
28
28
|
NetworkError,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} from "./cli-
|
|
29
|
+
cardToFallbackText3,
|
|
30
|
+
init_dist7
|
|
31
|
+
} from "./cli-n3qe7tyr.js";
|
|
32
32
|
import {
|
|
33
33
|
__esm
|
|
34
34
|
} from "./cli-242037k3.js";
|
|
@@ -293,7 +293,7 @@ ${val}
|
|
|
293
293
|
const content = item2.children.map(renderMarkdownV2).join(`
|
|
294
294
|
`);
|
|
295
295
|
if (node.ordered) {
|
|
296
|
-
return `${escapeMarkdownV2(`${
|
|
296
|
+
return `${escapeMarkdownV2(`${(node.start ?? 1) + i}.`)} ${content}`;
|
|
297
297
|
}
|
|
298
298
|
return `\\- ${content}`;
|
|
299
299
|
}).join(`
|
|
@@ -340,11 +340,17 @@ ${val}
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
+
function fitsRichMessage(markdown) {
|
|
344
|
+
if (markdown.length <= TELEGRAM_RICH_MESSAGE_LIMIT) {
|
|
345
|
+
return true;
|
|
346
|
+
}
|
|
347
|
+
return Array.from(markdown).length <= TELEGRAM_RICH_MESSAGE_LIMIT;
|
|
348
|
+
}
|
|
343
349
|
function truncateRichMarkdown(markdown) {
|
|
344
|
-
|
|
345
|
-
if (characters.length <= TELEGRAM_RICH_MESSAGE_LIMIT) {
|
|
350
|
+
if (fitsRichMessage(markdown)) {
|
|
346
351
|
return markdown;
|
|
347
352
|
}
|
|
353
|
+
const characters = Array.from(markdown);
|
|
348
354
|
let end = TELEGRAM_RICH_MESSAGE_LIMIT - 3;
|
|
349
355
|
while (end > 0) {
|
|
350
356
|
const renderer = new StreamingMarkdownRenderer2;
|
|
@@ -753,6 +759,315 @@ function richMessageMedia(message) {
|
|
|
753
759
|
media(message.blocks, result);
|
|
754
760
|
return result;
|
|
755
761
|
}
|
|
762
|
+
function splitMarkdownAst(root, fits) {
|
|
763
|
+
if (fits(root)) {
|
|
764
|
+
return [root];
|
|
765
|
+
}
|
|
766
|
+
const definitions = [];
|
|
767
|
+
const stripped = stripDefinitions(root, definitions) ?? root;
|
|
768
|
+
if (definitions.length === 0) {
|
|
769
|
+
return splitRoot(root, fits);
|
|
770
|
+
}
|
|
771
|
+
const withDefinitions = definitionAppender(definitions);
|
|
772
|
+
return splitRoot(stripped, (part) => fits(withDefinitions(part))).map(withDefinitions);
|
|
773
|
+
}
|
|
774
|
+
function splitText(value, fits) {
|
|
775
|
+
return splitValue(value, (part) => fits(part), TEXT_BREAKS);
|
|
776
|
+
}
|
|
777
|
+
function splitRoot(root, fits) {
|
|
778
|
+
const parts = splitChildren(root, (node) => node, fits) ?? [
|
|
779
|
+
root
|
|
780
|
+
];
|
|
781
|
+
const trimmed = [];
|
|
782
|
+
for (const part of parts) {
|
|
783
|
+
const start = trimEdgeText(part, "start");
|
|
784
|
+
const both = start && trimEdgeText(start, "end");
|
|
785
|
+
if (both && both.children.length > 0) {
|
|
786
|
+
trimmed.push(both);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return trimmed;
|
|
790
|
+
}
|
|
791
|
+
function trimEdgeText(node, edge) {
|
|
792
|
+
if (node.type === "text") {
|
|
793
|
+
const value = edge === "start" ? node.value.trimStart() : node.value.trimEnd();
|
|
794
|
+
if (value === node.value) {
|
|
795
|
+
return node;
|
|
796
|
+
}
|
|
797
|
+
return value ? { ...node, value } : null;
|
|
798
|
+
}
|
|
799
|
+
if (!("children" in node) || node.children.length === 0) {
|
|
800
|
+
return node;
|
|
801
|
+
}
|
|
802
|
+
const children = [...node.children];
|
|
803
|
+
let changed = false;
|
|
804
|
+
while (children.length > 0) {
|
|
805
|
+
const index = edge === "start" ? 0 : children.length - 1;
|
|
806
|
+
const child = children[index];
|
|
807
|
+
const trimmed = trimEdgeText(child, edge);
|
|
808
|
+
if (trimmed === child) {
|
|
809
|
+
break;
|
|
810
|
+
}
|
|
811
|
+
changed = true;
|
|
812
|
+
if (trimmed) {
|
|
813
|
+
children[index] = trimmed;
|
|
814
|
+
break;
|
|
815
|
+
}
|
|
816
|
+
children.splice(index, 1);
|
|
817
|
+
}
|
|
818
|
+
if (!changed) {
|
|
819
|
+
return node;
|
|
820
|
+
}
|
|
821
|
+
if (children.length === 0 && node.type !== "root" && node.type !== "tableCell") {
|
|
822
|
+
return null;
|
|
823
|
+
}
|
|
824
|
+
return { ...node, children };
|
|
825
|
+
}
|
|
826
|
+
function stripDefinitions(node, found) {
|
|
827
|
+
if (!("children" in node)) {
|
|
828
|
+
return node;
|
|
829
|
+
}
|
|
830
|
+
let changed = false;
|
|
831
|
+
const children = [];
|
|
832
|
+
for (const child of node.children) {
|
|
833
|
+
if (child.type === "definition" || child.type === "footnoteDefinition") {
|
|
834
|
+
found.push(child);
|
|
835
|
+
changed = true;
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
const stripped = stripDefinitions(child, found);
|
|
839
|
+
changed ||= stripped !== child;
|
|
840
|
+
if (stripped) {
|
|
841
|
+
children.push(stripped);
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (!changed) {
|
|
845
|
+
return node;
|
|
846
|
+
}
|
|
847
|
+
if (children.length === 0 && node.type !== "root") {
|
|
848
|
+
return null;
|
|
849
|
+
}
|
|
850
|
+
return { ...node, children };
|
|
851
|
+
}
|
|
852
|
+
function definitionAppender(definitions) {
|
|
853
|
+
const links = /* @__PURE__ */ new Map;
|
|
854
|
+
const footnotes = /* @__PURE__ */ new Map;
|
|
855
|
+
for (const definition of definitions) {
|
|
856
|
+
const byId = definition.type === "definition" ? links : footnotes;
|
|
857
|
+
if (!byId.has(definition.identifier)) {
|
|
858
|
+
byId.set(definition.identifier, definition);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
const definitionFor = (node) => {
|
|
862
|
+
if (node.type === "linkReference" || node.type === "imageReference") {
|
|
863
|
+
return links.get(node.identifier);
|
|
864
|
+
}
|
|
865
|
+
if (node.type === "footnoteReference") {
|
|
866
|
+
return footnotes.get(node.identifier);
|
|
867
|
+
}
|
|
868
|
+
return;
|
|
869
|
+
};
|
|
870
|
+
return (part) => {
|
|
871
|
+
const used = /* @__PURE__ */ new Set;
|
|
872
|
+
const visit = (node) => {
|
|
873
|
+
const definition = definitionFor(node);
|
|
874
|
+
if (definition && !used.has(definition)) {
|
|
875
|
+
used.add(definition);
|
|
876
|
+
visit(definition);
|
|
877
|
+
}
|
|
878
|
+
if ("children" in node) {
|
|
879
|
+
for (const child of node.children) {
|
|
880
|
+
visit(child);
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
visit(part);
|
|
885
|
+
if (used.size === 0) {
|
|
886
|
+
return part;
|
|
887
|
+
}
|
|
888
|
+
return {
|
|
889
|
+
...part,
|
|
890
|
+
children: [
|
|
891
|
+
...part.children,
|
|
892
|
+
...definitions.filter((definition) => used.has(definition))
|
|
893
|
+
]
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
function splitValue(value, fits, rules) {
|
|
898
|
+
const parts = [];
|
|
899
|
+
let rest = value;
|
|
900
|
+
while (rest.length > 0) {
|
|
901
|
+
const first = parts.length === 0;
|
|
902
|
+
if (fits(rest, first)) {
|
|
903
|
+
parts.push(rest);
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
const max = largestFitting(rest.length - 1, (length) => fits(rest.slice(0, length), first));
|
|
907
|
+
if (max === 0) {
|
|
908
|
+
parts.push(rest);
|
|
909
|
+
break;
|
|
910
|
+
}
|
|
911
|
+
const { end, next } = findBreak(rest, max, rules);
|
|
912
|
+
if (end === 0) {
|
|
913
|
+
parts.push(rest);
|
|
914
|
+
break;
|
|
915
|
+
}
|
|
916
|
+
parts.push(rest.slice(0, end));
|
|
917
|
+
rest = rest.slice(next);
|
|
918
|
+
}
|
|
919
|
+
return parts;
|
|
920
|
+
}
|
|
921
|
+
function largestFitting(max, test) {
|
|
922
|
+
if (max < 1 || !test(1)) {
|
|
923
|
+
return 0;
|
|
924
|
+
}
|
|
925
|
+
let low = 1;
|
|
926
|
+
let high = 2;
|
|
927
|
+
while (high <= max && test(high)) {
|
|
928
|
+
low = high;
|
|
929
|
+
high *= 2;
|
|
930
|
+
}
|
|
931
|
+
high = Math.min(high, max + 1);
|
|
932
|
+
while (high - low > 1) {
|
|
933
|
+
const mid = Math.floor((low + high) / 2);
|
|
934
|
+
if (test(mid)) {
|
|
935
|
+
low = mid;
|
|
936
|
+
} else {
|
|
937
|
+
high = mid;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return low;
|
|
941
|
+
}
|
|
942
|
+
function findBreak(value, max, rules) {
|
|
943
|
+
const minimum = Math.floor(max * rules.minRatio);
|
|
944
|
+
for (const separator of rules.separators) {
|
|
945
|
+
const index = value.lastIndexOf(separator, max);
|
|
946
|
+
if (index > 0 && index >= minimum) {
|
|
947
|
+
return { end: index, next: index + separator.length };
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
const end = hardBreak(value, max);
|
|
951
|
+
return { end, next: end };
|
|
952
|
+
}
|
|
953
|
+
function hardBreak(value, max) {
|
|
954
|
+
for (const match of value.matchAll(EMOJI_PLACEHOLDER)) {
|
|
955
|
+
if (match.index >= max) {
|
|
956
|
+
break;
|
|
957
|
+
}
|
|
958
|
+
if (max < match.index + match[0].length) {
|
|
959
|
+
return match.index;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
const code = value.charCodeAt(max - 1);
|
|
963
|
+
return code >= 55296 && code <= 56319 ? max - 1 : max;
|
|
964
|
+
}
|
|
965
|
+
function splitNode(node, wrap, fits) {
|
|
966
|
+
if ("children" in node && node.children.length > 0) {
|
|
967
|
+
return splitChildren(node, wrap, fits);
|
|
968
|
+
}
|
|
969
|
+
if ("value" in node && typeof node.value === "string" && node.value) {
|
|
970
|
+
const valueNode = node;
|
|
971
|
+
return splitValue(valueNode.value, (value, first) => fits(wrap({ ...valueNode, value }, first)), node.type === "code" ? CODE_BREAKS : TEXT_BREAKS).map((value) => ({ ...valueNode, value }));
|
|
972
|
+
}
|
|
973
|
+
return [node];
|
|
974
|
+
}
|
|
975
|
+
function withChildren(node, children, firstIndex) {
|
|
976
|
+
const copy = { ...node, children };
|
|
977
|
+
if (copy.type === "list" && copy.ordered && node.type === "list") {
|
|
978
|
+
copy.start = (node.start ?? 1) + firstIndex;
|
|
979
|
+
}
|
|
980
|
+
return copy;
|
|
981
|
+
}
|
|
982
|
+
function emptyCell() {
|
|
983
|
+
return { type: "tableCell", children: [] };
|
|
984
|
+
}
|
|
985
|
+
function pieceBuilder(node, wrap, fits) {
|
|
986
|
+
const children = node.children;
|
|
987
|
+
const [firstChild, ...bodyRows] = children;
|
|
988
|
+
const header = node.type === "table" && firstChild && bodyRows.some((row) => fits(wrap(withChildren(node, [firstChild, row], 0), false))) ? firstChild : undefined;
|
|
989
|
+
const build = (items, firstIndex) => {
|
|
990
|
+
if (header && firstIndex > 0) {
|
|
991
|
+
return withChildren(node, [header, ...items], firstIndex);
|
|
992
|
+
}
|
|
993
|
+
if (node.type === "tableRow") {
|
|
994
|
+
const after = children.length - firstIndex - items.length;
|
|
995
|
+
return withChildren(node, [
|
|
996
|
+
...Array.from({ length: firstIndex }, emptyCell),
|
|
997
|
+
...items,
|
|
998
|
+
...Array.from({ length: after }, emptyCell)
|
|
999
|
+
], firstIndex);
|
|
1000
|
+
}
|
|
1001
|
+
return withChildren(node, items, firstIndex);
|
|
1002
|
+
};
|
|
1003
|
+
return { build, header };
|
|
1004
|
+
}
|
|
1005
|
+
function splitChildren(node, wrap, fits) {
|
|
1006
|
+
const children = node.children;
|
|
1007
|
+
const { build, header } = pieceBuilder(node, wrap, fits);
|
|
1008
|
+
const pieces = [];
|
|
1009
|
+
const fitsAs = (items, firstIndex) => fits(wrap(build(items, firstIndex), pieces.length === 0));
|
|
1010
|
+
let batch = [];
|
|
1011
|
+
let batchStart = 0;
|
|
1012
|
+
let index = 0;
|
|
1013
|
+
while (index < children.length) {
|
|
1014
|
+
const start = batch.length > 0 ? batchStart : index;
|
|
1015
|
+
const taken = largestFitting(children.length - index, (n) => fitsAs([...batch, ...children.slice(index, index + n)], start));
|
|
1016
|
+
batch = [...batch, ...children.slice(index, index + taken)];
|
|
1017
|
+
batchStart = start;
|
|
1018
|
+
index += taken;
|
|
1019
|
+
const child = children[index];
|
|
1020
|
+
if (!child) {
|
|
1021
|
+
break;
|
|
1022
|
+
}
|
|
1023
|
+
if (fits(wrap(build([child], index), false))) {
|
|
1024
|
+
if (batch.length === 0 || header && batch.length === 1 && start === 0) {
|
|
1025
|
+
return null;
|
|
1026
|
+
}
|
|
1027
|
+
pieces.push(build(batch, batchStart));
|
|
1028
|
+
batch = [];
|
|
1029
|
+
continue;
|
|
1030
|
+
}
|
|
1031
|
+
const childIndex = index;
|
|
1032
|
+
const splitChild = (leading, leadingStart) => {
|
|
1033
|
+
const first = pieces.length === 0;
|
|
1034
|
+
return splitNode(child, (piece, childFirst) => childFirst ? wrap(build([...leading, piece], leadingStart), first) : wrap(build([piece], childIndex), false), fits);
|
|
1035
|
+
};
|
|
1036
|
+
let childPieces = splitChild(batch, start);
|
|
1037
|
+
if (batch.length > 0) {
|
|
1038
|
+
const head2 = childPieces?.[0];
|
|
1039
|
+
if (!(head2 && fitsAs([...batch, head2], batchStart))) {
|
|
1040
|
+
if (!(header && batch.length === 1 && batchStart === 0)) {
|
|
1041
|
+
pieces.push(build(batch, batchStart));
|
|
1042
|
+
}
|
|
1043
|
+
batch = [];
|
|
1044
|
+
childPieces = splitChild([], childIndex);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
if (!childPieces) {
|
|
1048
|
+
return null;
|
|
1049
|
+
}
|
|
1050
|
+
const [head, ...rest] = childPieces;
|
|
1051
|
+
const headStart = batch.length > 0 ? batchStart : childIndex;
|
|
1052
|
+
const last = rest.pop();
|
|
1053
|
+
if (last) {
|
|
1054
|
+
pieces.push(build([...batch, head], headStart));
|
|
1055
|
+
for (const piece of rest) {
|
|
1056
|
+
pieces.push(build([piece], childIndex));
|
|
1057
|
+
}
|
|
1058
|
+
batch = [last];
|
|
1059
|
+
batchStart = childIndex;
|
|
1060
|
+
} else {
|
|
1061
|
+
batch = [...batch, head];
|
|
1062
|
+
batchStart = headStart;
|
|
1063
|
+
}
|
|
1064
|
+
index += 1;
|
|
1065
|
+
}
|
|
1066
|
+
if (batch.length > 0) {
|
|
1067
|
+
pieces.push(build(batch, batchStart));
|
|
1068
|
+
}
|
|
1069
|
+
return pieces;
|
|
1070
|
+
}
|
|
756
1071
|
async function readTelegramFile(response, fileId) {
|
|
757
1072
|
const declared = Number(response.headers.get("content-length"));
|
|
758
1073
|
if (Number.isFinite(declared) && declared > TELEGRAM_FILE_LIMIT) {
|
|
@@ -894,16 +1209,16 @@ function stickerAttachmentFormat(sticker) {
|
|
|
894
1209
|
}
|
|
895
1210
|
return { type: "image", mimeType: "image/webp" };
|
|
896
1211
|
}
|
|
897
|
-
var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MARKDOWNV2_SPECIAL_CHARS, CODE_BLOCK_SPECIAL_CHARS, LINK_URL_SPECIAL_CHARS, TELEGRAM_MESSAGE_LIMIT = 4096, TELEGRAM_CAPTION_LIMIT = 1024, MARKDOWN_V2_ENTITY_MARKERS, MARKDOWN_V2_ELLIPSIS = "\\.\\.\\.", PLAIN_ELLIPSIS = "...", TelegramFormatConverter, TELEGRAM_RICH_MESSAGE_LIMIT = 32768, MARKDOWN_PUNCTUATION, LINE_BREAKS, BACKTICKS, TELEGRAM_API_BASE = "https://api.telegram.org", TELEGRAM_FILE_LIMIT, TELEGRAM_FILE_TIMEOUT_MS = 30000, TELEGRAM_SECRET_TOKEN_HEADER = "x-telegram-bot-api-secret-token", TELEGRAM_WEBHOOK_VERIFICATION_ERROR = "secretToken is required in webhook mode. Set TELEGRAM_WEBHOOK_SECRET_TOKEN or provide secretToken. To accept unverified webhooks, set allowUnverifiedWebhooks: true or TELEGRAM_ALLOW_UNVERIFIED_WEBHOOKS=true.", MESSAGE_ID_PATTERN, BARE_MESSAGE_ID_PATTERN, trimTrailingSlashes = (url) => {
|
|
1212
|
+
var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MARKDOWNV2_SPECIAL_CHARS, CODE_BLOCK_SPECIAL_CHARS, LINK_URL_SPECIAL_CHARS, TELEGRAM_MESSAGE_LIMIT = 4096, TELEGRAM_CAPTION_LIMIT = 1024, MARKDOWN_V2_ENTITY_MARKERS, MARKDOWN_V2_ELLIPSIS = "\\.\\.\\.", PLAIN_ELLIPSIS = "...", TelegramFormatConverter, TELEGRAM_RICH_MESSAGE_LIMIT = 32768, MARKDOWN_PUNCTUATION, LINE_BREAKS, BACKTICKS, TEXT_BREAKS, CODE_BREAKS, EMOJI_PLACEHOLDER, TELEGRAM_API_BASE = "https://api.telegram.org", TELEGRAM_FILE_LIMIT, TELEGRAM_FILE_TIMEOUT_MS = 30000, TELEGRAM_SECRET_TOKEN_HEADER = "x-telegram-bot-api-secret-token", TELEGRAM_WEBHOOK_VERIFICATION_ERROR = "secretToken is required in webhook mode. Set TELEGRAM_WEBHOOK_SECRET_TOKEN or provide secretToken. To accept unverified webhooks, set allowUnverifiedWebhooks: true or TELEGRAM_ALLOW_UNVERIFIED_WEBHOOKS=true.", MESSAGE_ID_PATTERN, BARE_MESSAGE_ID_PATTERN, trimTrailingSlashes = (url) => {
|
|
898
1213
|
let end = url.length;
|
|
899
1214
|
while (end > 0 && url[end - 1] === "/") {
|
|
900
1215
|
end--;
|
|
901
1216
|
}
|
|
902
1217
|
return url.slice(0, end);
|
|
903
|
-
}, MESSAGE_SEQUENCE_PATTERN, ATTACHMENT_UPLOADS, ATTACHMENT_MEDIA_GROUP_TYPES, LEADING_AT_PATTERN, EMOJI_PLACEHOLDER_PATTERN, EMOJI_NAME_PATTERN, TELEGRAM_DEFAULT_POLLING_TIMEOUT_SECONDS = 30, TELEGRAM_DEFAULT_POLLING_LIMIT = 100, TELEGRAM_DEFAULT_POLLING_RETRY_DELAY_MS = 1000, TELEGRAM_DEFAULT_STREAM_UPDATE_INTERVAL_MS = 250, TELEGRAM_DEFAULT_PRIVATE_STREAMING_EDIT_INTERVAL_MS = 1100, TELEGRAM_DEFAULT_NON_PRIVATE_STREAMING_EDIT_INTERVAL_MS = 3100, TELEGRAM_STREAM_FINAL_EDIT_RETRY_CAP_MS = 5000, TELEGRAM_STREAM_PLACEHOLDER_TEXT = "...", TELEGRAM_INCOMING_MEDIA_GROUP_BUFFER_TTL_MS = 30000, TELEGRAM_INCOMING_MEDIA_GROUP_LOCK_TTL_MS = 5000, TELEGRAM_INCOMING_MEDIA_GROUP_RETRY_MS = 50, TELEGRAM_INCOMING_MEDIA_GROUP_SETTLE_MS = 1000, TELEGRAM_WEBHOOK_UPDATE_TTL_MS, TELEGRAM_MEDIA_GROUP_MIN = 2, TELEGRAM_MEDIA_GROUP_MAX = 10, TELEGRAM_MARKDOWN_PARSE_ERROR_PATTERN, TELEGRAM_MAX_POLLING_LIMIT = 100, TELEGRAM_MIN_POLLING_LIMIT = 1, TELEGRAM_MIN_POLLING_TIMEOUT_SECONDS = 0, TELEGRAM_MAX_POLLING_TIMEOUT_SECONDS = 300, TELEGRAM_BUSINESS_ALLOWED_UPDATES, TELEGRAM_DEFAULT_ALLOWED_UPDATES, TELEGRAM_BUSINESS_CONNECTION_TTL_MS, escapeMarkdownInEntity = (text2) => text2.replace(/([[\]()\\])/g, "\\$1"), ZERO_EXPONENT_CURRENCIES, THREE_EXPONENT_CURRENCIES, TelegramAdapter = class {
|
|
1218
|
+
}, MESSAGE_SEQUENCE_PATTERN, ATTACHMENT_UPLOADS, ATTACHMENT_MEDIA_GROUP_TYPES, LEADING_AT_PATTERN, EMOJI_PLACEHOLDER_PATTERN, EMOJI_NAME_PATTERN, TELEGRAM_DEFAULT_POLLING_TIMEOUT_SECONDS = 30, TELEGRAM_DEFAULT_POLLING_LIMIT = 100, TELEGRAM_DEFAULT_POLLING_RETRY_DELAY_MS = 1000, TELEGRAM_DEFAULT_STREAM_UPDATE_INTERVAL_MS = 250, TELEGRAM_DEFAULT_PRIVATE_STREAMING_EDIT_INTERVAL_MS = 1100, TELEGRAM_DEFAULT_NON_PRIVATE_STREAMING_EDIT_INTERVAL_MS = 3100, TELEGRAM_STREAM_FINAL_EDIT_RETRY_CAP_MS = 5000, TELEGRAM_SPLIT_PART_RETRY_CAP_MS = 30000, TELEGRAM_SPLIT_PART_MAX_ATTEMPTS = 3, TELEGRAM_SPLIT_RETRY_BUDGET_MS = 60000, TELEGRAM_STREAM_PLACEHOLDER_TEXT = "...", TELEGRAM_INCOMING_MEDIA_GROUP_BUFFER_TTL_MS = 30000, TELEGRAM_INCOMING_MEDIA_GROUP_LOCK_TTL_MS = 5000, TELEGRAM_INCOMING_MEDIA_GROUP_RETRY_MS = 50, TELEGRAM_INCOMING_MEDIA_GROUP_SETTLE_MS = 1000, TELEGRAM_WEBHOOK_UPDATE_TTL_MS, TELEGRAM_MEDIA_GROUP_MIN = 2, TELEGRAM_MEDIA_GROUP_MAX = 10, TELEGRAM_MARKDOWN_PARSE_ERROR_PATTERN, TELEGRAM_MAX_POLLING_LIMIT = 100, TELEGRAM_MIN_POLLING_LIMIT = 1, TELEGRAM_MIN_POLLING_TIMEOUT_SECONDS = 0, TELEGRAM_MAX_POLLING_TIMEOUT_SECONDS = 300, TELEGRAM_BUSINESS_ALLOWED_UPDATES, TELEGRAM_DEFAULT_ALLOWED_UPDATES, TELEGRAM_BUSINESS_CONNECTION_TTL_MS, escapeMarkdownInEntity = (text2) => text2.replace(/([[\]()\\])/g, "\\$1"), ZERO_EXPONENT_CURRENCIES, THREE_EXPONENT_CURRENCIES, TelegramAdapter = class {
|
|
904
1219
|
name = "telegram";
|
|
905
1220
|
lockScope = "channel";
|
|
906
|
-
persistThreadHistory
|
|
1221
|
+
persistThreadHistory;
|
|
907
1222
|
allowedUserIds;
|
|
908
1223
|
allowUnverifiedWebhooks;
|
|
909
1224
|
botTokenProvider;
|
|
@@ -927,6 +1242,7 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
927
1242
|
nativeStreaming;
|
|
928
1243
|
streamingEditIntervalMs;
|
|
929
1244
|
longPolling;
|
|
1245
|
+
longMessages;
|
|
930
1246
|
businessMode;
|
|
931
1247
|
_runtimeMode = "webhook";
|
|
932
1248
|
pollingAbortController = null;
|
|
@@ -966,12 +1282,17 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
966
1282
|
this.hasExplicitUserName = Boolean(userName);
|
|
967
1283
|
this.mode = config.mode ?? "auto";
|
|
968
1284
|
this.nativeStreaming = config.nativeStreaming ?? false;
|
|
1285
|
+
this.persistThreadHistory = config.persistThreadHistory ?? true;
|
|
969
1286
|
this.streamingEditIntervalMs = typeof config.streamingEditIntervalMs !== "number" || !Number.isFinite(config.streamingEditIntervalMs) ? undefined : this.clampInteger(config.streamingEditIntervalMs, 0, 0, Number.MAX_SAFE_INTEGER);
|
|
970
1287
|
this.longPolling = config.longPolling;
|
|
1288
|
+
this.longMessages = config.longMessages ?? "truncate";
|
|
971
1289
|
this.businessMode = config.businessMode ?? false;
|
|
972
1290
|
if (!["auto", "webhook", "polling"].includes(this.mode)) {
|
|
973
1291
|
throw new ValidationError("telegram", `Invalid mode: ${this.mode}. Expected "auto", "webhook", or "polling".`);
|
|
974
1292
|
}
|
|
1293
|
+
if (!["truncate", "split"].includes(this.longMessages)) {
|
|
1294
|
+
throw new ValidationError("telegram", `Invalid longMessages: ${this.longMessages}. Expected "truncate" or "split".`);
|
|
1295
|
+
}
|
|
975
1296
|
if (this.mode === "webhook" && !(this.secretToken || this.allowUnverifiedWebhooks)) {
|
|
976
1297
|
throw new ValidationError("telegram", TELEGRAM_WEBHOOK_VERIFICATION_ERROR);
|
|
977
1298
|
}
|
|
@@ -979,7 +1300,7 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
979
1300
|
async resolveBotToken() {
|
|
980
1301
|
const botToken = await this.botTokenProvider();
|
|
981
1302
|
if (!botToken) {
|
|
982
|
-
throw new
|
|
1303
|
+
throw new AuthenticationError3("telegram", "Telegram bot token resolver returned an empty token. Check TELEGRAM_BOT_TOKEN or the Vercel Connect connector.");
|
|
983
1304
|
}
|
|
984
1305
|
return botToken;
|
|
985
1306
|
}
|
|
@@ -1592,13 +1913,46 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
1592
1913
|
return tasks;
|
|
1593
1914
|
}
|
|
1594
1915
|
async postMessage(threadId, message, replyToMessageId) {
|
|
1916
|
+
if (this.longMessages !== "split") {
|
|
1917
|
+
return await this.sendPostable(threadId, message, replyToMessageId);
|
|
1918
|
+
}
|
|
1919
|
+
const state = {
|
|
1920
|
+
delivered: 0,
|
|
1921
|
+
lastDeliveredAt: 0,
|
|
1922
|
+
retryWaitMs: 0
|
|
1923
|
+
};
|
|
1924
|
+
try {
|
|
1925
|
+
const parts = this.splitLongMessage(message, this.richMessagesAvailable);
|
|
1926
|
+
if (!parts) {
|
|
1927
|
+
return await this.sendPostable(threadId, message, replyToMessageId, state);
|
|
1928
|
+
}
|
|
1929
|
+
let sent;
|
|
1930
|
+
for (const [index, part] of parts.entries()) {
|
|
1931
|
+
sent = await this.sendPostable(threadId, part, index === 0 ? replyToMessageId : undefined, state);
|
|
1932
|
+
}
|
|
1933
|
+
if (!sent) {
|
|
1934
|
+
throw new ValidationError("telegram", "Message text cannot be empty");
|
|
1935
|
+
}
|
|
1936
|
+
return sent;
|
|
1937
|
+
} catch (error) {
|
|
1938
|
+
if (state.delivered > 0) {
|
|
1939
|
+
this.logger.warn("Telegram split message only partly sent", {
|
|
1940
|
+
deliveredMessages: state.delivered,
|
|
1941
|
+
error: String(error),
|
|
1942
|
+
threadId
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
throw error;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
async sendPostable(threadId, message, replyToMessageId, splitState) {
|
|
1595
1949
|
const parsedThread = this.resolveThreadId(threadId);
|
|
1596
1950
|
const replyParameters = this.buildReplyParameters(replyToMessageId, parsedThread.chatId);
|
|
1597
1951
|
const card = extractCard(message);
|
|
1598
1952
|
const replyMarkup = card ? cardToTelegramInlineKeyboard(card) : undefined;
|
|
1599
1953
|
const parseMode = this.resolveParseMode(message, card);
|
|
1600
|
-
const
|
|
1601
|
-
const
|
|
1954
|
+
const bodies = this.renderUntruncatedBodies(message, card);
|
|
1955
|
+
const { text: text2, plainText } = this.truncateMessageBodies(bodies, parseMode);
|
|
1602
1956
|
const files = extractFiles(message);
|
|
1603
1957
|
const attachments = extractPostableAttachments(message);
|
|
1604
1958
|
if (files.length > 0 && attachments.length > 0) {
|
|
@@ -1626,26 +1980,39 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
1626
1980
|
if (!text2.trim()) {
|
|
1627
1981
|
throw new ValidationError("telegram", "Message text cannot be empty");
|
|
1628
1982
|
}
|
|
1629
|
-
const
|
|
1630
|
-
|
|
1631
|
-
|
|
1983
|
+
const send = (operation) => splitState ? this.sendSplitPart(operation, threadId, splitState) : operation();
|
|
1984
|
+
const sendRegular = async () => {
|
|
1985
|
+
const parts = splitState && !this.fitsRegularMessage(bodies) ? this.splitLongMessage(message, false) : null;
|
|
1986
|
+
if (!parts) {
|
|
1987
|
+
return [
|
|
1988
|
+
await send(() => this.sendRegularMessage(parsedThread, text2, plainText, parseMode, replyMarkup, threadId, replyParameters))
|
|
1989
|
+
];
|
|
1990
|
+
}
|
|
1991
|
+
const sent = [];
|
|
1992
|
+
for (const [index, part] of parts.entries()) {
|
|
1993
|
+
const partParseMode = this.resolveParseMode(part, null);
|
|
1994
|
+
const partBodies = this.renderMessageBodies(part, null, partParseMode);
|
|
1995
|
+
sent.push(await send(() => this.sendRegularMessage(parsedThread, partBodies.text, partBodies.plainText, partParseMode, undefined, threadId, index === 0 ? replyParameters : undefined)));
|
|
1996
|
+
}
|
|
1997
|
+
return sent;
|
|
1998
|
+
};
|
|
1999
|
+
rawMessages = rich ? await this.withTelegramRichFallback(async () => [
|
|
2000
|
+
await send(() => this.telegramFetch("sendRichMessage", {
|
|
1632
2001
|
...this.buildChatTargetParams(parsedThread),
|
|
1633
|
-
rich_message: {
|
|
1634
|
-
markdown: rich.markdown
|
|
1635
|
-
},
|
|
2002
|
+
rich_message: { markdown: rich.markdown },
|
|
1636
2003
|
reply_markup: replyMarkup,
|
|
1637
2004
|
reply_parameters: replyParameters
|
|
1638
|
-
})
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
2005
|
+
}))
|
|
2006
|
+
], sendRegular, {
|
|
2007
|
+
method: "sendRichMessage",
|
|
2008
|
+
threadId
|
|
2009
|
+
}) : await sendRegular();
|
|
1643
2010
|
}
|
|
1644
2011
|
const parsedMessages = rawMessages.map((rawMessage) => this.parseTelegramMessage(rawMessage, this.encodeThreadId({
|
|
1645
2012
|
chatId: String(rawMessage.chat.id),
|
|
1646
2013
|
messageThreadId: rawMessage.message_thread_id ?? parsedThread.messageThreadId,
|
|
1647
2014
|
businessConnectionId: parsedThread.businessConnectionId
|
|
1648
|
-
}), rich ? {
|
|
2015
|
+
}), rich && rawMessages.length === 1 ? {
|
|
1649
2016
|
formatted: rich.formatted,
|
|
1650
2017
|
text: rich.text
|
|
1651
2018
|
} : undefined));
|
|
@@ -1665,6 +2032,42 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
1665
2032
|
async postChannelMessage(channelId, message) {
|
|
1666
2033
|
return this.postMessage(channelId, message);
|
|
1667
2034
|
}
|
|
2035
|
+
async sendSplitPart(send, threadId, state) {
|
|
2036
|
+
if (state.delivered > 0) {
|
|
2037
|
+
const pacingMs = this.splitPartIntervalMs(threadId) - (Date.now() - state.lastDeliveredAt);
|
|
2038
|
+
if (pacingMs > 0) {
|
|
2039
|
+
await this.sleep(pacingMs);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
let attempt = 1;
|
|
2043
|
+
while (true) {
|
|
2044
|
+
try {
|
|
2045
|
+
const result = await send();
|
|
2046
|
+
state.delivered += 1;
|
|
2047
|
+
state.lastDeliveredAt = Date.now();
|
|
2048
|
+
return result;
|
|
2049
|
+
} catch (error) {
|
|
2050
|
+
if (!(error instanceof AdapterRateLimitError) || state.delivered === 0 || attempt >= TELEGRAM_SPLIT_PART_MAX_ATTEMPTS) {
|
|
2051
|
+
throw error;
|
|
2052
|
+
}
|
|
2053
|
+
const retryAfterMs = (error.retryAfter ?? 1) * 1000;
|
|
2054
|
+
if (retryAfterMs > TELEGRAM_SPLIT_PART_RETRY_CAP_MS || state.retryWaitMs + retryAfterMs > TELEGRAM_SPLIT_RETRY_BUDGET_MS) {
|
|
2055
|
+
throw error;
|
|
2056
|
+
}
|
|
2057
|
+
this.logger.warn("Telegram rate limited a split message part", {
|
|
2058
|
+
attempt,
|
|
2059
|
+
retryAfterMs,
|
|
2060
|
+
threadId
|
|
2061
|
+
});
|
|
2062
|
+
await this.sleep(retryAfterMs);
|
|
2063
|
+
state.retryWaitMs += retryAfterMs;
|
|
2064
|
+
attempt += 1;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
splitPartIntervalMs(threadId) {
|
|
2069
|
+
return this.isDM(threadId) ? TELEGRAM_DEFAULT_PRIVATE_STREAMING_EDIT_INTERVAL_MS : TELEGRAM_DEFAULT_NON_PRIVATE_STREAMING_EDIT_INTERVAL_MS;
|
|
2070
|
+
}
|
|
1668
2071
|
async reply(threadId, messageId, message) {
|
|
1669
2072
|
return this.postMessage(threadId, message, messageId);
|
|
1670
2073
|
}
|
|
@@ -1674,8 +2077,7 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
1674
2077
|
const card = extractCard(message);
|
|
1675
2078
|
const replyMarkup = card ? cardToTelegramInlineKeyboard(card) : undefined;
|
|
1676
2079
|
const parseMode = this.resolveParseMode(message, card);
|
|
1677
|
-
const plainText =
|
|
1678
|
-
const text2 = truncateForTelegram(convertEmojiPlaceholders2(card ? this.formatConverter.fromMarkdown(cardToFallbackText2(card, { boldFormat: "**" })) : this.formatConverter.renderPostable(message), "gchat"), TELEGRAM_MESSAGE_LIMIT, parseMode);
|
|
2080
|
+
const { text: text2, plainText } = this.renderMessageBodies(message, card, parseMode);
|
|
1679
2081
|
const rich = this.resolveRichMessage(message, card, 0, 0);
|
|
1680
2082
|
if (!text2.trim()) {
|
|
1681
2083
|
throw new ValidationError("telegram", "Message text cannot be empty");
|
|
@@ -2281,7 +2683,7 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
2281
2683
|
id: this.encodeMessageId(String(raw.chat.id), raw.message_id),
|
|
2282
2684
|
threadId,
|
|
2283
2685
|
text: text2,
|
|
2284
|
-
formatted: content?.formatted ?? this.formatConverter.
|
|
2686
|
+
formatted: content?.formatted ?? this.formatConverter.parseIncoming(richMarkdown || text2).formatted,
|
|
2285
2687
|
raw,
|
|
2286
2688
|
author,
|
|
2287
2689
|
metadata: {
|
|
@@ -2827,7 +3229,7 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
2827
3229
|
return chat.username;
|
|
2828
3230
|
}
|
|
2829
3231
|
isBotMentioned(message, text2) {
|
|
2830
|
-
if (this.mentionOnReply && this._botUserId && message.reply_to_message?.from && String(message.reply_to_message.from.id) === this._botUserId && message.reply_to_message.message_id
|
|
3232
|
+
if (this.mentionOnReply && this._botUserId && message.reply_to_message?.from && String(message.reply_to_message.from.id) === this._botUserId && !(message.is_topic_message && message.reply_to_message.message_id === message.message_thread_id) && !(message.from && String(message.from.id) === this._botUserId)) {
|
|
2831
3233
|
return true;
|
|
2832
3234
|
}
|
|
2833
3235
|
if (!text2) {
|
|
@@ -2894,22 +3296,25 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
2894
3296
|
const formatted = this.formatConverter.toAst(message.markdown);
|
|
2895
3297
|
return {
|
|
2896
3298
|
formatted,
|
|
2897
|
-
markdown: truncateRichMarkdown(
|
|
3299
|
+
markdown: truncateRichMarkdown(this.renderRichMarkdown(message)),
|
|
2898
3300
|
text: toPlainText2(formatted)
|
|
2899
3301
|
};
|
|
2900
3302
|
}
|
|
2901
3303
|
if ("ast" in message) {
|
|
2902
3304
|
return {
|
|
2903
3305
|
formatted: message.ast,
|
|
2904
|
-
markdown: truncateRichMarkdown(
|
|
3306
|
+
markdown: truncateRichMarkdown(this.renderRichMarkdown(message)),
|
|
2905
3307
|
text: toPlainText2(message.ast)
|
|
2906
3308
|
};
|
|
2907
3309
|
}
|
|
2908
3310
|
return null;
|
|
2909
3311
|
}
|
|
3312
|
+
renderRichMarkdown(message) {
|
|
3313
|
+
return convertEmojiPlaceholders2("markdown" in message ? message.markdown : stringifyMarkdown2(message.ast), "gchat");
|
|
3314
|
+
}
|
|
2910
3315
|
renderPlainTextMessage(message, card) {
|
|
2911
3316
|
if (card) {
|
|
2912
|
-
return
|
|
3317
|
+
return cardToFallbackText3(card);
|
|
2913
3318
|
}
|
|
2914
3319
|
if (typeof message === "string") {
|
|
2915
3320
|
return message;
|
|
@@ -2925,6 +3330,54 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
2925
3330
|
}
|
|
2926
3331
|
return this.formatConverter.renderPostable(message);
|
|
2927
3332
|
}
|
|
3333
|
+
renderMessageBodies(message, card, parseMode) {
|
|
3334
|
+
return this.truncateMessageBodies(this.renderUntruncatedBodies(message, card), parseMode);
|
|
3335
|
+
}
|
|
3336
|
+
truncateMessageBodies(bodies, parseMode) {
|
|
3337
|
+
return {
|
|
3338
|
+
plainText: truncateForTelegram(bodies.plainText, TELEGRAM_MESSAGE_LIMIT, "plain"),
|
|
3339
|
+
text: truncateForTelegram(bodies.text, TELEGRAM_MESSAGE_LIMIT, parseMode)
|
|
3340
|
+
};
|
|
3341
|
+
}
|
|
3342
|
+
renderUntruncatedBodies(message, card) {
|
|
3343
|
+
return {
|
|
3344
|
+
plainText: convertEmojiPlaceholders2(this.renderPlainTextMessage(message, card), "gchat"),
|
|
3345
|
+
text: convertEmojiPlaceholders2(card ? this.formatConverter.fromMarkdown(cardToFallbackText3(card, { boldFormat: "**" })) : this.formatConverter.renderPostable(message), "gchat")
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3348
|
+
fitsRegularMessage(bodies) {
|
|
3349
|
+
return bodies.text.length <= TELEGRAM_MESSAGE_LIMIT && bodies.plainText.length <= TELEGRAM_MESSAGE_LIMIT;
|
|
3350
|
+
}
|
|
3351
|
+
splitLongMessage(message, richLimit) {
|
|
3352
|
+
if (extractCard(message) || extractFiles(message).length > 0 || extractPostableAttachments(message).length > 0) {
|
|
3353
|
+
return null;
|
|
3354
|
+
}
|
|
3355
|
+
if (typeof message === "string" || "raw" in message) {
|
|
3356
|
+
const source = convertEmojiPlaceholders2(typeof message === "string" ? message : message.raw, "gchat");
|
|
3357
|
+
if (source.length <= TELEGRAM_MESSAGE_LIMIT) {
|
|
3358
|
+
return null;
|
|
3359
|
+
}
|
|
3360
|
+
const parts2 = splitText(source, (value) => value.length <= TELEGRAM_MESSAGE_LIMIT).filter((part) => part.trim().length > 0);
|
|
3361
|
+
if (parts2.length === 0) {
|
|
3362
|
+
return null;
|
|
3363
|
+
}
|
|
3364
|
+
return typeof message === "string" ? parts2 : parts2.map((raw) => ({ raw }));
|
|
3365
|
+
}
|
|
3366
|
+
if (!(("markdown" in message) || ("ast" in message))) {
|
|
3367
|
+
return null;
|
|
3368
|
+
}
|
|
3369
|
+
const fitsAsSent = richLimit ? fitsRichMessage(this.renderRichMarkdown(message)) : this.fitsRegularMessage(this.renderUntruncatedBodies(message, null));
|
|
3370
|
+
if (fitsAsSent) {
|
|
3371
|
+
return null;
|
|
3372
|
+
}
|
|
3373
|
+
const ast = "markdown" in message ? this.formatConverter.toAst(convertEmojiPlaceholders2(message.markdown, "gchat")) : message.ast;
|
|
3374
|
+
const fits = richLimit ? (root) => fitsRichMessage(this.renderRichMarkdown({ ast: root })) : (root) => this.fitsRegularMessage(this.renderUntruncatedBodies({ ast: root }, null));
|
|
3375
|
+
const parts = splitMarkdownAst(ast, fits).filter((part) => this.formatConverter.fromAst(part).trim().length > 0);
|
|
3376
|
+
if (parts.length === 0 || parts.length === 1 && !richLimit) {
|
|
3377
|
+
return null;
|
|
3378
|
+
}
|
|
3379
|
+
return parts.map((part) => ({ ast: part }));
|
|
3380
|
+
}
|
|
2928
3381
|
resolveTelegramFallbackText(originalText, fallbackText) {
|
|
2929
3382
|
return fallbackText.trim() ? fallbackText : originalText;
|
|
2930
3383
|
}
|
|
@@ -3293,7 +3746,7 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
3293
3746
|
throw new AdapterRateLimitError("telegram", data.parameters?.retry_after);
|
|
3294
3747
|
}
|
|
3295
3748
|
if (errorCode === 401) {
|
|
3296
|
-
throw new
|
|
3749
|
+
throw new AuthenticationError3("telegram", description);
|
|
3297
3750
|
}
|
|
3298
3751
|
if (errorCode === 403) {
|
|
3299
3752
|
throw new PermissionError("telegram", method);
|
|
@@ -3339,13 +3792,13 @@ var CALLBACK_DATA_PREFIX = "chat:", TELEGRAM_CALLBACK_DATA_LIMIT_BYTES = 64, MAR
|
|
|
3339
3792
|
}
|
|
3340
3793
|
}
|
|
3341
3794
|
};
|
|
3342
|
-
var
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3795
|
+
var init_dist = __esm(() => {
|
|
3796
|
+
init_dist7();
|
|
3797
|
+
init_dist8();
|
|
3798
|
+
init_dist7();
|
|
3799
|
+
init_dist8();
|
|
3800
|
+
init_dist8();
|
|
3801
|
+
init_dist8();
|
|
3349
3802
|
MARKDOWNV2_SPECIAL_CHARS = /([_*[\]()~`>#+\-=|{}.!\\])/g;
|
|
3350
3803
|
CODE_BLOCK_SPECIAL_CHARS = /([`\\])/g;
|
|
3351
3804
|
LINK_URL_SPECIAL_CHARS = /([)\\])/g;
|
|
@@ -3386,6 +3839,16 @@ var init_dist2 = __esm(() => {
|
|
|
3386
3839
|
MARKDOWN_PUNCTUATION = /[!-/:-@[-`{-~]/g;
|
|
3387
3840
|
LINE_BREAKS = /[\r\n]/g;
|
|
3388
3841
|
BACKTICKS = /`+/g;
|
|
3842
|
+
TEXT_BREAKS = {
|
|
3843
|
+
minRatio: 0.5,
|
|
3844
|
+
separators: [`
|
|
3845
|
+
|
|
3846
|
+
`, `
|
|
3847
|
+
`, " "]
|
|
3848
|
+
};
|
|
3849
|
+
CODE_BREAKS = { minRatio: 0, separators: [`
|
|
3850
|
+
`] };
|
|
3851
|
+
EMOJI_PLACEHOLDER = /\{\{emoji:[a-z0-9_]+\}\}/gi;
|
|
3389
3852
|
TELEGRAM_FILE_LIMIT = 25 * 1024 * 1024;
|
|
3390
3853
|
MESSAGE_ID_PATTERN = /^([^:]+):(\d+)$/;
|
|
3391
3854
|
BARE_MESSAGE_ID_PATTERN = /^\d+$/;
|
|
@@ -3432,7 +3895,7 @@ var init_dist2 = __esm(() => {
|
|
|
3432
3895
|
]);
|
|
3433
3896
|
THREE_EXPONENT_CURRENCIES = /* @__PURE__ */ new Set(["BHD", "IQD", "JOD"]);
|
|
3434
3897
|
});
|
|
3435
|
-
|
|
3898
|
+
init_dist();
|
|
3436
3899
|
|
|
3437
3900
|
export {
|
|
3438
3901
|
TelegramAdapter
|