pi-harness-runtime 1.1.398 → 1.1.402
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +44 -2
- package/CHANGELOG.md +21 -0
- package/RULES.md +28 -0
- package/harness/agent-handoff.ts +2 -3
- package/harness/autonomous-review.ts +1 -1
- package/harness/blackboard.ts +2 -3
- package/harness/context-compact-orchestrator.ts +1 -1
- package/harness/context-window-manager.ts +2 -2
- package/harness/e2e/playwright-runner.ts +6 -4
- package/harness/herdr-agents.ts +1 -1
- package/harness/job-state-machine.ts +1 -1
- package/harness/langchain/daemon.ts +3 -3
- package/harness/langchain/graph.ts +2 -2
- package/harness/langchain/ping-pong-middleware.ts +2 -2
- package/harness/loop-code-agent.ts +6 -4
- package/harness/loop-controller.ts +1 -1
- package/harness/loop-review-agent.ts +1 -1
- package/harness/loop-types.ts +1 -1
- package/harness/master-planner.ts +1 -1
- package/harness/project-detector/detector.ts +1 -2
- package/harness/repair-engine.ts +2 -4
- package/harness/service-diagnostics.ts +1 -1
- package/harness/skill-sync.ts +3 -3
- package/index.ts +276 -55
- package/mirror.ts +1 -1
- package/package.json +5 -3
- package/packages/a2a-adapter/dist/discovery.d.ts.map +1 -1
- package/packages/a2a-adapter/dist/discovery.js +0 -1
- package/packages/a2a-adapter/dist/discovery.js.map +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/a2a-adapter/src/discovery.ts +0 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/dist/index.d.ts +9 -0
- package/packages/auth/dist/index.d.ts.map +1 -0
- package/packages/auth/dist/index.js +9 -0
- package/packages/auth/dist/index.js.map +1 -0
- package/packages/auth/package.json +1 -1
- package/packages/auth/src/index.ts +9 -0
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/dist/index.d.ts +52 -0
- package/packages/config-capture/dist/index.d.ts.map +1 -0
- package/packages/config-capture/dist/index.js +261 -0
- package/packages/config-capture/dist/index.js.map +1 -0
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/dist/extension.d.ts +15 -0
- package/packages/file-copy-helper/dist/extension.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/extension.debug.d.ts +15 -0
- package/packages/file-copy-helper/dist/extension.debug.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/extension.debug.js +215 -0
- package/packages/file-copy-helper/dist/extension.debug.js.map +1 -0
- package/packages/file-copy-helper/dist/extension.js +222 -0
- package/packages/file-copy-helper/dist/extension.js.map +1 -0
- package/packages/file-copy-helper/dist/index.d.ts +3 -0
- package/packages/file-copy-helper/dist/index.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/index.js +3 -0
- package/packages/file-copy-helper/dist/index.js.map +1 -0
- package/packages/file-copy-helper/dist/intent-detector.d.ts +21 -0
- package/packages/file-copy-helper/dist/intent-detector.d.ts.map +1 -0
- package/packages/file-copy-helper/dist/intent-detector.js +348 -0
- package/packages/file-copy-helper/dist/intent-detector.js.map +1 -0
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/dist/auto-continue.d.ts +161 -2
- package/packages/jev-judge/dist/auto-continue.d.ts.map +1 -1
- package/packages/jev-judge/dist/auto-continue.js +267 -22
- package/packages/jev-judge/dist/auto-continue.js.map +1 -1
- package/packages/jev-judge/dist/index.d.ts +2 -0
- package/packages/jev-judge/dist/index.d.ts.map +1 -1
- package/packages/jev-judge/dist/index.js +2 -0
- package/packages/jev-judge/dist/index.js.map +1 -1
- package/packages/jev-judge/dist/question-risk.d.ts +50 -0
- package/packages/jev-judge/dist/question-risk.d.ts.map +1 -0
- package/packages/jev-judge/dist/question-risk.js +100 -0
- package/packages/jev-judge/dist/question-risk.js.map +1 -0
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/auto-continue.ts +426 -29
- package/packages/jev-judge/src/index.ts +4 -0
- package/packages/jev-judge/src/question-risk.ts +151 -0
- package/packages/jev-judge/tests/auto-continue-context.test.ts +221 -0
- package/packages/jev-judge/tests/outcome-application.test.ts +132 -0
- package/packages/jev-judge/tests/question-risk.test.ts +116 -0
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/README.md +36 -3
- package/packages/logging/dist/config.d.ts +7 -0
- package/packages/logging/dist/config.d.ts.map +1 -1
- package/packages/logging/dist/config.js +14 -0
- package/packages/logging/dist/config.js.map +1 -1
- package/packages/logging/dist/incidents/schema.d.ts +111 -0
- package/packages/logging/dist/incidents/schema.d.ts.map +1 -0
- package/packages/logging/dist/incidents/schema.js +0 -0
- package/packages/logging/dist/incidents/schema.js.map +1 -0
- package/packages/logging/dist/index.d.ts +2 -0
- package/packages/logging/dist/index.d.ts.map +1 -1
- package/packages/logging/dist/index.js +2 -0
- package/packages/logging/dist/index.js.map +1 -1
- package/packages/logging/dist/server/http.d.ts +4 -3
- package/packages/logging/dist/server/http.d.ts.map +1 -1
- package/packages/logging/dist/server/http.js +35 -3
- package/packages/logging/dist/server/http.js.map +1 -1
- package/packages/logging/dist/server/incident-qdrant.d.ts +83 -0
- package/packages/logging/dist/server/incident-qdrant.d.ts.map +1 -0
- package/packages/logging/dist/server/incident-qdrant.js +129 -0
- package/packages/logging/dist/server/incident-qdrant.js.map +1 -0
- package/packages/logging/dist/server/incident-store.d.ts +76 -0
- package/packages/logging/dist/server/incident-store.d.ts.map +1 -0
- package/packages/logging/dist/server/incident-store.js +157 -0
- package/packages/logging/dist/server/incident-store.js.map +1 -0
- package/packages/logging/dist/server/index.d.ts +4 -0
- package/packages/logging/dist/server/index.d.ts.map +1 -1
- package/packages/logging/dist/server/index.js +2 -0
- package/packages/logging/dist/server/index.js.map +1 -1
- package/packages/logging/dist/server/service.d.ts +33 -0
- package/packages/logging/dist/server/service.d.ts.map +1 -1
- package/packages/logging/dist/server/service.js +63 -0
- package/packages/logging/dist/server/service.js.map +1 -1
- package/packages/logging/dist/shipper.d.ts +74 -3
- package/packages/logging/dist/shipper.d.ts.map +1 -1
- package/packages/logging/dist/shipper.js +88 -5
- package/packages/logging/dist/shipper.js.map +1 -1
- package/packages/logging/dist/singleton.d.ts.map +1 -1
- package/packages/logging/dist/singleton.js +1 -0
- package/packages/logging/dist/singleton.js.map +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/logging/src/config.ts +22 -0
- package/packages/logging/src/incidents/schema.ts +0 -0
- package/packages/logging/src/index.ts +17 -0
- package/packages/logging/src/server/http.ts +42 -3
- package/packages/logging/src/server/incident-qdrant.ts +177 -0
- package/packages/logging/src/server/incident-store.ts +192 -0
- package/packages/logging/src/server/index.ts +21 -0
- package/packages/logging/src/server/service.ts +79 -0
- package/packages/logging/src/shipper.ts +120 -5
- package/packages/logging/src/singleton.ts +1 -0
- package/packages/logging/test/fanout.test.ts +186 -0
- package/packages/logging/test/incidents.test.ts +404 -0
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/dist/adapters/detail-format.d.ts +10 -2
- package/packages/notification/dist/adapters/detail-format.d.ts.map +1 -1
- package/packages/notification/dist/adapters/detail-format.js +39 -0
- package/packages/notification/dist/adapters/detail-format.js.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.d.ts +33 -0
- package/packages/notification/dist/adapters/line-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.js +84 -7
- package/packages/notification/dist/adapters/line-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.js +6 -2
- package/packages/notification/dist/adapters/telegram-adapter.js.map +1 -1
- package/packages/notification/dist/notification-center.d.ts.map +1 -1
- package/packages/notification/dist/notification-center.js +59 -7
- package/packages/notification/dist/notification-center.js.map +1 -1
- package/packages/notification/dist/pending-question.d.ts +69 -2
- package/packages/notification/dist/pending-question.d.ts.map +1 -1
- package/packages/notification/dist/pending-question.js +88 -2
- package/packages/notification/dist/pending-question.js.map +1 -1
- package/packages/notification/dist/types.d.ts +18 -0
- package/packages/notification/dist/types.d.ts.map +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/adapters/detail-format.ts +42 -2
- package/packages/notification/src/adapters/line-adapter.ts +94 -7
- package/packages/notification/src/adapters/telegram-adapter.ts +6 -2
- package/packages/notification/src/notification-center.ts +65 -8
- package/packages/notification/src/pending-question.ts +160 -8
- package/packages/notification/src/types.ts +18 -0
- package/packages/notification/test/approval-payload.test.ts +269 -0
- package/packages/notification/test/pending-question-lifecycle.test.ts +195 -0
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/dist/index.d.ts +9 -0
- package/packages/okf-indexer/dist/index.d.ts.map +1 -0
- package/packages/okf-indexer/dist/index.js +9 -0
- package/packages/okf-indexer/dist/index.js.map +1 -0
- package/packages/okf-indexer/package.json +1 -1
- package/packages/okf-indexer/src/index.ts +9 -0
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/dist/provider-router.d.ts.map +1 -1
- package/packages/provider-router/dist/types.d.ts +2 -2
- package/packages/provider-router/dist/types.d.ts.map +1 -1
- package/packages/provider-router/dist/types.js +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-router/src/types.ts +2 -2
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/dist/index.d.ts +9 -0
- package/packages/scheduler/dist/index.d.ts.map +1 -0
- package/packages/scheduler/dist/index.js +9 -0
- package/packages/scheduler/dist/index.js.map +1 -0
- package/packages/scheduler/dist/scheduler.d.ts +17 -0
- package/packages/scheduler/dist/scheduler.d.ts.map +1 -0
- package/packages/scheduler/dist/scheduler.js +41 -0
- package/packages/scheduler/dist/scheduler.js.map +1 -0
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler/src/index.ts +9 -0
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/dist/index.d.ts +7 -0
- package/packages/shared-context/dist/index.d.ts.map +1 -0
- package/packages/shared-context/dist/index.js +7 -0
- package/packages/shared-context/dist/index.js.map +1 -0
- package/packages/shared-context/dist/shared-context.d.ts +12 -0
- package/packages/shared-context/dist/shared-context.d.ts.map +1 -0
- package/packages/shared-context/dist/shared-context.js +39 -0
- package/packages/shared-context/dist/shared-context.js.map +1 -0
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/dist/client.d.ts +56 -0
- package/packages/skill-mcp-client/dist/client.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/client.js +101 -0
- package/packages/skill-mcp-client/dist/client.js.map +1 -0
- package/packages/skill-mcp-client/dist/errors.d.ts +44 -0
- package/packages/skill-mcp-client/dist/errors.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/errors.js +68 -0
- package/packages/skill-mcp-client/dist/errors.js.map +1 -0
- package/packages/skill-mcp-client/dist/index.d.ts +9 -0
- package/packages/skill-mcp-client/dist/index.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/index.js +9 -0
- package/packages/skill-mcp-client/dist/index.js.map +1 -0
- package/packages/skill-mcp-client/dist/types.d.ts +106 -0
- package/packages/skill-mcp-client/dist/types.d.ts.map +1 -0
- package/packages/skill-mcp-client/dist/types.js +14 -0
- package/packages/skill-mcp-client/dist/types.js.map +1 -0
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -5
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/telegram/src/agent-messages.d.ts +28 -0
- package/packages/telegram/src/agent-messages.js +90 -0
- package/packages/telegram/src/bindings.d.ts +296 -0
- package/packages/telegram/src/bindings.js +1086 -0
- package/packages/telegram/src/bus.d.ts +759 -0
- package/packages/telegram/src/bus.js +2732 -0
- package/packages/telegram/src/commands.d.ts +761 -0
- package/packages/telegram/src/commands.js +2622 -0
- package/packages/telegram/src/config.d.ts +222 -0
- package/packages/telegram/src/config.js +844 -0
- package/packages/telegram/src/delivery.d.ts +161 -0
- package/packages/telegram/src/delivery.js +550 -0
- package/packages/telegram/src/extension.d.ts +7 -0
- package/packages/telegram/src/extension.js +2444 -0
- package/packages/telegram/src/inbound.d.ts +94 -0
- package/packages/telegram/src/inbound.js +478 -0
- package/packages/telegram/src/index.d.ts +6 -0
- package/packages/telegram/src/index.js +6 -0
- package/packages/telegram/src/keyboard.d.ts +21 -0
- package/packages/telegram/src/keyboard.js +37 -0
- package/packages/telegram/src/lifecycle.d.ts +210 -0
- package/packages/telegram/src/lifecycle.js +538 -0
- package/packages/telegram/src/pi.d.ts +76 -0
- package/packages/telegram/src/pi.js +130 -0
- package/packages/telegram/src/polling.d.ts +332 -0
- package/packages/telegram/src/polling.js +1219 -0
- package/packages/telegram/src/replies.d.ts +210 -0
- package/packages/telegram/src/replies.js +752 -0
- package/packages/telegram/src/routing.d.ts +388 -0
- package/packages/telegram/src/routing.js +7886 -0
- package/packages/telegram/src/runtime.d.ts +159 -0
- package/packages/telegram/src/runtime.js +351 -0
- package/packages/telegram/src/telegram-api.d.ts +564 -0
- package/packages/telegram/src/telegram-api.js +1332 -0
- package/packages/telegram/src/turns.d.ts +108 -0
- package/packages/telegram/src/turns.js +482 -0
- package/packages/telegram/src/updates.d.ts +1545 -0
- package/packages/telegram/src/updates.js +6420 -0
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/dist/detector.d.ts +54 -0
- package/packages/todo-bd-sync/dist/detector.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/detector.js +132 -0
- package/packages/todo-bd-sync/dist/detector.js.map +1 -0
- package/packages/todo-bd-sync/dist/extension.d.ts +30 -0
- package/packages/todo-bd-sync/dist/extension.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/extension.js +35 -0
- package/packages/todo-bd-sync/dist/extension.js.map +1 -0
- package/packages/todo-bd-sync/dist/index.d.ts +87 -0
- package/packages/todo-bd-sync/dist/index.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/index.js +296 -0
- package/packages/todo-bd-sync/dist/index.js.map +1 -0
- package/packages/todo-bd-sync/dist/sync.d.ts +72 -0
- package/packages/todo-bd-sync/dist/sync.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/sync.js +290 -0
- package/packages/todo-bd-sync/dist/sync.js.map +1 -0
- package/packages/todo-bd-sync/dist/task-analyzer.d.ts +49 -0
- package/packages/todo-bd-sync/dist/task-analyzer.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/task-analyzer.js +240 -0
- package/packages/todo-bd-sync/dist/task-analyzer.js.map +1 -0
- package/packages/todo-bd-sync/dist/todo-reminder.d.ts +126 -0
- package/packages/todo-bd-sync/dist/todo-reminder.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/todo-reminder.js +329 -0
- package/packages/todo-bd-sync/dist/todo-reminder.js.map +1 -0
- package/packages/todo-bd-sync/dist/types.d.ts +65 -0
- package/packages/todo-bd-sync/dist/types.d.ts.map +1 -0
- package/packages/todo-bd-sync/dist/types.js +67 -0
- package/packages/todo-bd-sync/dist/types.js.map +1 -0
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/dist/index.d.ts +94 -0
- package/packages/token-estimation/dist/index.d.ts.map +1 -0
- package/packages/token-estimation/dist/index.js +115 -0
- package/packages/token-estimation/dist/index.js.map +1 -0
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/dist/ai-providers.d.ts +36 -0
- package/packages/types/dist/ai-providers.d.ts.map +1 -0
- package/packages/types/dist/ai-providers.js +66 -0
- package/packages/types/dist/ai-providers.js.map +1 -0
- package/packages/types/dist/index.d.ts +12 -0
- package/packages/types/dist/index.d.ts.map +1 -0
- package/packages/types/dist/index.js +12 -0
- package/packages/types/dist/index.js.map +1 -0
- package/packages/types/package.json +5 -5
- package/packages/types/src/index.ts +12 -0
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/worktree/worktree.ts +1 -1
- package/packages/write-review/package.json +1 -1
- package/renderer.ts +1 -1
- package/scripts/build-packages.ts +162 -0
- package/scripts/relay-client.ts +2 -2
- package/scripts/typecheck-packages.mjs +3 -3
- package/scripts/unified-webhook-server.ts +22 -10
- package/scripts/verify-package-contents.ts +345 -0
- package/scripts/ws-server.ts +1 -1
- package/tracker.ts +1 -1
- package/harness/browser-scrapers/base-browser-scraper.d.ts +0 -91
- package/harness/browser-scrapers/chrome-profile-manager.d.ts +0 -80
- package/harness/browser-scrapers/codex-browser-scraper.d.ts +0 -60
- package/harness/browser-scrapers/index.d.ts +0 -29
- package/harness/browser-scrapers/zai-browser-scraper.d.ts +0 -79
- package/harness/e2e/browser-scrapers/base-browser-scraper.d.ts +0 -92
- package/harness/e2e/browser-scrapers/chrome-profile-manager.d.ts +0 -81
- package/harness/e2e/browser-scrapers/codex-browser-scraper.d.ts +0 -61
- package/harness/e2e/browser-scrapers/index.d.ts +0 -30
- package/harness/e2e/browser-scrapers/zai-browser-scraper.d.ts +0 -80
- package/harness/langchain/agents.d.ts +0 -143
- package/harness/langchain/agents.test.d.ts +0 -2
- package/harness/langchain/checkpointer.d.ts +0 -48
- package/harness/langchain/checkpointer.test.d.ts +0 -8
- package/harness/langchain/cron-cli.d.ts +0 -12
- package/harness/langchain/daemon.d.ts +0 -161
- package/harness/langchain/daemon.test.d.ts +0 -11
- package/harness/langchain/file-tools.d.ts +0 -97
- package/harness/langchain/graph.d.ts +0 -706
- package/harness/langchain/model-router.d.ts +0 -63
- package/harness/langchain/model-router.test.d.ts +0 -2
- package/harness/langchain/models.d.ts +0 -72
- package/harness/langchain/ping-pong-middleware.d.ts +0 -28
- package/harness/langchain/ping-pong-middleware.test.d.ts +0 -2
- package/harness/langchain/run.d.ts +0 -15
- package/harness/langchain/scoreboard.test.d.ts +0 -13
- package/harness/langchain/status-line.d.ts +0 -91
- package/harness/langchain/status-line.test.d.ts +0 -8
- package/harness/langchain/surge.d.ts +0 -111
- package/harness/langchain/surge.test.d.ts +0 -10
- package/harness/langchain/widget.d.ts +0 -105
- package/harness/langchain/widget.test.d.ts +0 -8
- package/packages/autonomous-runtime/dist/worker.d.ts +0 -63
- package/packages/autonomous-runtime/dist/worker.js +0 -133
- package/packages/capability-registry/src/types.d.ts +0 -47
- package/packages/clipboard/dist/clipboard.d.ts +0 -11
- package/packages/clipboard/dist/clipboard.js +0 -40
- package/packages/clipboard/dist/index.d.ts +0 -2
- package/packages/clipboard/dist/index.js +0 -2
- package/packages/clipboard/dist/types.d.ts +0 -13
- package/packages/clipboard/dist/types.js +0 -5
- package/packages/context-discovery/dist/discover.d.ts +0 -3
- package/packages/context-discovery/dist/discover.js +0 -42
- package/packages/context-discovery/dist/discovery.d.ts +0 -28
- package/packages/context-discovery/dist/discovery.js +0 -21
- package/packages/context-discovery/dist/index.d.ts +0 -3
- package/packages/context-discovery/dist/index.js +0 -2
- package/packages/context-discovery/dist/types.d.ts +0 -16
- package/packages/context-discovery/dist/types.js +0 -2
- package/packages/event-bus/dist/bus.d.ts +0 -15
- package/packages/event-bus/dist/bus.js +0 -90
- package/packages/event-bus/dist/index.d.ts +0 -4
- package/packages/event-bus/dist/index.js +0 -3
- package/packages/event-bus/dist/test/bus.test.js +0 -52
- package/packages/event-bus/dist/types.d.ts +0 -27
- package/packages/event-bus/dist/types.js +0 -10
- package/packages/event-store/dist/index.d.ts +0 -3
- package/packages/event-store/dist/index.js +0 -2
- package/packages/event-store/dist/store.d.ts +0 -15
- package/packages/event-store/dist/store.js +0 -131
- package/packages/event-store/dist/test/store.test.js +0 -57
- package/packages/event-store/dist/types.d.ts +0 -48
- package/packages/event-store/dist/types.js +0 -5
- package/packages/event-store/src/types.d.ts +0 -48
- package/packages/file-copy-helper/dist/src/extension.js +0 -186
- package/packages/model-registry/src/types.d.ts +0 -63
- package/packages/notification/dist/src/adapters/email-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/email-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/email-adapter.js +0 -89
- package/packages/notification/dist/src/adapters/email-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/line-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/line-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/line-adapter.js +0 -99
- package/packages/notification/dist/src/adapters/line-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/ntfy-adapter.d.ts +0 -17
- package/packages/notification/dist/src/adapters/ntfy-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/ntfy-adapter.js +0 -84
- package/packages/notification/dist/src/adapters/ntfy-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/telegram-adapter.d.ts +0 -56
- package/packages/notification/dist/src/adapters/telegram-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/telegram-adapter.js +0 -251
- package/packages/notification/dist/src/adapters/telegram-adapter.js.map +0 -1
- package/packages/notification/dist/src/adapters/webhook-adapter.d.ts +0 -15
- package/packages/notification/dist/src/adapters/webhook-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/adapters/webhook-adapter.js +0 -64
- package/packages/notification/dist/src/adapters/webhook-adapter.js.map +0 -1
- package/packages/notification/dist/src/base-adapter.d.ts +0 -36
- package/packages/notification/dist/src/base-adapter.d.ts.map +0 -1
- package/packages/notification/dist/src/base-adapter.js +0 -39
- package/packages/notification/dist/src/base-adapter.js.map +0 -1
- package/packages/notification/dist/src/index.d.ts +0 -12
- package/packages/notification/dist/src/index.d.ts.map +0 -1
- package/packages/notification/dist/src/index.js +0 -12
- package/packages/notification/dist/src/index.js.map +0 -1
- package/packages/notification/dist/src/notification-center.d.ts +0 -89
- package/packages/notification/dist/src/notification-center.d.ts.map +0 -1
- package/packages/notification/dist/src/notification-center.js +0 -356
- package/packages/notification/dist/src/notification-center.js.map +0 -1
- package/packages/notification/dist/src/notification-policy.d.ts +0 -66
- package/packages/notification/dist/src/notification-policy.d.ts.map +0 -1
- package/packages/notification/dist/src/notification-policy.js +0 -153
- package/packages/notification/dist/src/notification-policy.js.map +0 -1
- package/packages/notification/dist/src/telegram-webhook-handler.d.ts +0 -86
- package/packages/notification/dist/src/telegram-webhook-handler.d.ts.map +0 -1
- package/packages/notification/dist/src/telegram-webhook-handler.js +0 -149
- package/packages/notification/dist/src/telegram-webhook-handler.js.map +0 -1
- package/packages/notification/dist/src/types.d.ts +0 -106
- package/packages/notification/dist/src/types.d.ts.map +0 -1
- package/packages/notification/dist/src/types.js +0 -7
- package/packages/notification/dist/src/types.js.map +0 -1
- package/packages/projection-engine/dist/engine.d.ts +0 -61
- package/packages/projection-engine/dist/engine.js +0 -76
- package/packages/projection-engine/dist/index.d.ts +0 -2
- package/packages/projection-engine/dist/index.js +0 -2
- package/packages/projection-engine/dist/project.d.ts +0 -3
- package/packages/projection-engine/dist/project.js +0 -24
- package/packages/projection-engine/dist/types.d.ts +0 -55
- package/packages/projection-engine/dist/types.js +0 -5
- package/packages/projection-engine/src/types.d.ts +0 -55
- package/packages/provider-adapter-sdk/dist/src/builder.d.ts +0 -140
- package/packages/provider-adapter-sdk/dist/src/builder.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/builder.js +0 -332
- package/packages/provider-adapter-sdk/dist/src/builder.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/errors.d.ts +0 -71
- package/packages/provider-adapter-sdk/dist/src/errors.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/errors.js +0 -111
- package/packages/provider-adapter-sdk/dist/src/errors.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/index.d.ts +0 -15
- package/packages/provider-adapter-sdk/dist/src/index.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/index.js +0 -19
- package/packages/provider-adapter-sdk/dist/src/index.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/registry.d.ts +0 -108
- package/packages/provider-adapter-sdk/dist/src/registry.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/registry.js +0 -301
- package/packages/provider-adapter-sdk/dist/src/registry.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/tester.d.ts +0 -71
- package/packages/provider-adapter-sdk/dist/src/tester.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/tester.js +0 -392
- package/packages/provider-adapter-sdk/dist/src/tester.js.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/types.d.ts +0 -182
- package/packages/provider-adapter-sdk/dist/src/types.d.ts.map +0 -1
- package/packages/provider-adapter-sdk/dist/src/types.js +0 -11
- package/packages/provider-adapter-sdk/dist/src/types.js.map +0 -1
- package/packages/provider-router/dist/capability-registry/src/types.d.ts +0 -47
- package/packages/provider-router/dist/capability-registry/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/capability-registry/src/types.js +0 -10
- package/packages/provider-router/dist/capability-registry/src/types.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/index.d.ts +0 -23
- package/packages/provider-router/dist/provider-router/src/index.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/index.js +0 -25
- package/packages/provider-router/dist/provider-router/src/index.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/policy.d.ts +0 -10
- package/packages/provider-router/dist/provider-router/src/policy.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/policy.js +0 -45
- package/packages/provider-router/dist/provider-router/src/policy.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/provider-router.d.ts +0 -56
- package/packages/provider-router/dist/provider-router/src/provider-router.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/provider-router.js +0 -222
- package/packages/provider-router/dist/provider-router/src/provider-router.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/strategies.d.ts +0 -19
- package/packages/provider-router/dist/provider-router/src/strategies.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/strategies.js +0 -110
- package/packages/provider-router/dist/provider-router/src/strategies.js.map +0 -1
- package/packages/provider-router/dist/provider-router/src/types.d.ts +0 -91
- package/packages/provider-router/dist/provider-router/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/provider-router/src/types.js +0 -10
- package/packages/provider-router/dist/provider-router/src/types.js.map +0 -1
- package/packages/provider-router/dist/src/index.d.ts +0 -23
- package/packages/provider-router/dist/src/index.d.ts.map +0 -1
- package/packages/provider-router/dist/src/index.js +0 -25
- package/packages/provider-router/dist/src/index.js.map +0 -1
- package/packages/provider-router/dist/src/policy.d.ts +0 -10
- package/packages/provider-router/dist/src/policy.d.ts.map +0 -1
- package/packages/provider-router/dist/src/policy.js +0 -45
- package/packages/provider-router/dist/src/policy.js.map +0 -1
- package/packages/provider-router/dist/src/provider-router.d.ts +0 -56
- package/packages/provider-router/dist/src/provider-router.d.ts.map +0 -1
- package/packages/provider-router/dist/src/provider-router.js +0 -222
- package/packages/provider-router/dist/src/provider-router.js.map +0 -1
- package/packages/provider-router/dist/src/strategies.d.ts +0 -19
- package/packages/provider-router/dist/src/strategies.d.ts.map +0 -1
- package/packages/provider-router/dist/src/strategies.js +0 -110
- package/packages/provider-router/dist/src/strategies.js.map +0 -1
- package/packages/provider-router/dist/src/types.d.ts +0 -91
- package/packages/provider-router/dist/src/types.d.ts.map +0 -1
- package/packages/provider-router/dist/src/types.js +0 -10
- package/packages/provider-router/dist/src/types.js.map +0 -1
- package/packages/provider-router/dist/types/src/runtime-types.d.ts +0 -412
- package/packages/provider-router/dist/types/src/runtime-types.d.ts.map +0 -1
- package/packages/provider-router/dist/types/src/runtime-types.js +0 -2
- package/packages/provider-router/dist/types/src/runtime-types.js.map +0 -1
- package/packages/session-api/dist/api.d.ts +0 -83
- package/packages/session-api/dist/api.js +0 -35
- package/packages/session-api/dist/index.d.ts +0 -2
- package/packages/session-api/dist/index.js +0 -2
- package/packages/session-api/dist/types.d.ts +0 -22
- package/packages/session-api/dist/types.js +0 -5
- package/packages/session-export/dist/exporter.d.ts +0 -28
- package/packages/session-export/dist/exporter.js +0 -38
- package/packages/session-export/dist/index.d.ts +0 -2
- package/packages/session-export/dist/index.js +0 -2
- package/packages/session-export/dist/types.d.ts +0 -20
- package/packages/session-export/dist/types.js +0 -5
- package/packages/subscription-engine/dist/engine.d.ts +0 -13
- package/packages/subscription-engine/dist/engine.js +0 -40
- package/packages/subscription-engine/dist/index.d.ts +0 -2
- package/packages/subscription-engine/dist/index.js +0 -2
- package/packages/subscription-engine/dist/subscriptions.d.ts +0 -19
- package/packages/subscription-engine/dist/subscriptions.js +0 -32
- package/packages/subscription-engine/dist/types.d.ts +0 -24
- package/packages/subscription-engine/dist/types.js +0 -5
- package/packages/trajectory/test/store.test.d.ts +0 -2
- package/packages/workflow-events/dist/events.d.ts +0 -38
- package/packages/workflow-events/dist/events.js +0 -46
- package/packages/workflow-events/dist/index.d.ts +0 -2
- package/packages/workflow-events/dist/index.js +0 -2
- package/packages/workflow-events/dist/pipeline.d.ts +0 -21
- package/packages/workflow-events/dist/pipeline.js +0 -27
- package/packages/workflow-events/dist/types.d.ts +0 -110
- package/packages/workflow-events/dist/types.js +0 -5
- package/packages/workflow-events/src/types.d.ts +0 -110
|
@@ -0,0 +1,1545 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram updates domain helpers
|
|
3
|
+
* Zones: telegram inbound, authorization, routing plans
|
|
4
|
+
* Owns update extraction, authorization, execution planning, generation-fenced journal draining, and the public update-handler registry
|
|
5
|
+
*/
|
|
6
|
+
import type { TelegramBusEnvelope, TelegramBusFollowerView, TelegramBusForeignUpdateSettlement, TelegramBusFollowerQueueHandoffOffer, TelegramBusForwardOwnership, TelegramBusLeaderQueueHandoffOffer } from "./bus.ts";
|
|
7
|
+
import { type TelegramAuthorizationState, type TelegramUserPairingRuntimeDeps } from "./config.ts";
|
|
8
|
+
import { TELEGRAM_UPDATE_JOURNAL_CUSTODY_VERSION, TELEGRAM_UPDATE_JOURNAL_EXCLUSION_VERSION, TELEGRAM_UPDATE_JOURNAL_VERSION, type TelegramInputJournalReceipt, type TelegramInputJournalSourceReference, type TelegramInputJournalStore, type TelegramJournaledUpdate, type TelegramRoutingInputExpiryResult, type TelegramRoutingInputJournal, type TelegramUpdateJournalAppendResult, type TelegramUpdateJournalDeadQueueOwnerRecoveryResult, type TelegramUpdateJournalEntry, type TelegramUpdateJournalEntryDigest, type TelegramUpdateJournalInputClaim, type TelegramUpdateJournalOperatorDispositionInput, type TelegramUpdateJournalOperatorDispositionResult, type TelegramUpdateJournalPendingAbandonmentInput, type TelegramUpdateJournalPendingAbandonmentResult, type TelegramUpdateJournalPendingRetentionEvidence, type TelegramUpdateJournalQueueDiscardResult, type TelegramUpdateJournalQueueHandoffAcceptResult, type TelegramUpdateJournalQueueHandoffCancelResult, type TelegramUpdateJournalQueueHandoffInput, type TelegramUpdateJournalQueueHandoffOfferResult, type TelegramUpdateJournalQueueOwner, type TelegramUpdateJournalQueueOwnerIdentity, type TelegramUpdateJournalQueuedCompletion, type TelegramUpdateJournalQueuedReceiptEvidence, type TelegramUpdateJournalRoutingChooser, type TelegramUpdateJournalRoutingInput, type TelegramUpdateJournalSourceCompletion } from "./journal.ts";
|
|
9
|
+
import type { TelegramMessageOwnershipStore } from "./ownership.ts";
|
|
10
|
+
import type { TelegramProcessLiveness } from "./process-identity.ts";
|
|
11
|
+
import { type PendingTelegramControlItem, type TelegramControlQueueHandoffPayload, type TelegramQueueAdmissionReceipt, type TelegramQueueHandoffPayload, type TelegramQueueHandoffStageResult, type TelegramQueueHandoffStagingRuntime, type TelegramQueueItem, type TelegramQueueReactionDisposition } from "./queue.ts";
|
|
12
|
+
import { type TelegramTarget } from "./target.ts";
|
|
13
|
+
export interface TelegramReactionTypeEmoji {
|
|
14
|
+
type: "emoji";
|
|
15
|
+
emoji: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TelegramReactionTypeNonEmoji {
|
|
18
|
+
type: string;
|
|
19
|
+
}
|
|
20
|
+
export type TelegramReactionType = TelegramReactionTypeEmoji | TelegramReactionTypeNonEmoji;
|
|
21
|
+
export declare const TELEGRAM_PRIORITY_REACTIONS: readonly [{
|
|
22
|
+
readonly id: 10;
|
|
23
|
+
readonly name: "like";
|
|
24
|
+
readonly emoji: "👍";
|
|
25
|
+
}, {
|
|
26
|
+
readonly id: 11;
|
|
27
|
+
readonly name: "lightning";
|
|
28
|
+
readonly emoji: "⚡";
|
|
29
|
+
}, {
|
|
30
|
+
readonly id: 12;
|
|
31
|
+
readonly name: "heart";
|
|
32
|
+
readonly emoji: "❤";
|
|
33
|
+
}, {
|
|
34
|
+
readonly id: 13;
|
|
35
|
+
readonly name: "dove";
|
|
36
|
+
readonly emoji: "🕊";
|
|
37
|
+
}, {
|
|
38
|
+
readonly id: 14;
|
|
39
|
+
readonly name: "fire";
|
|
40
|
+
readonly emoji: "🔥";
|
|
41
|
+
}];
|
|
42
|
+
export declare const TELEGRAM_REMOVAL_REACTIONS: readonly [{
|
|
43
|
+
readonly id: 20;
|
|
44
|
+
readonly name: "dislike";
|
|
45
|
+
readonly emoji: "👎";
|
|
46
|
+
}, {
|
|
47
|
+
readonly id: 21;
|
|
48
|
+
readonly name: "ghost";
|
|
49
|
+
readonly emoji: "👻";
|
|
50
|
+
}, {
|
|
51
|
+
readonly id: 22;
|
|
52
|
+
readonly name: "broken-heart";
|
|
53
|
+
readonly emoji: "💔";
|
|
54
|
+
}, {
|
|
55
|
+
readonly id: 23;
|
|
56
|
+
readonly name: "poop";
|
|
57
|
+
readonly emoji: "💩";
|
|
58
|
+
}, {
|
|
59
|
+
readonly id: 24;
|
|
60
|
+
readonly name: "wastebasket";
|
|
61
|
+
readonly emoji: "🗑";
|
|
62
|
+
}];
|
|
63
|
+
export declare const TELEGRAM_PRIORITY_REACTION_EMOJIS: ("👍" | "⚡" | "❤" | "🕊" | "🔥")[];
|
|
64
|
+
export declare const TELEGRAM_REMOVAL_REACTION_EMOJIS: ("👎" | "👻" | "💔" | "💩" | "🗑")[];
|
|
65
|
+
export interface TelegramUpdateDeletion {
|
|
66
|
+
deleted_business_messages?: {
|
|
67
|
+
message_ids?: unknown;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export declare function normalizeTelegramReactionEmoji(emoji: string): string;
|
|
71
|
+
export declare function collectTelegramReactionEmojis(reactions: TelegramReactionType[]): Set<string>;
|
|
72
|
+
export interface TelegramUser {
|
|
73
|
+
id: number;
|
|
74
|
+
is_bot: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface TelegramChat {
|
|
77
|
+
id?: number;
|
|
78
|
+
type: string;
|
|
79
|
+
}
|
|
80
|
+
export interface TelegramUpdateMessage {
|
|
81
|
+
chat: TelegramChat;
|
|
82
|
+
from?: TelegramUser;
|
|
83
|
+
message_id?: number;
|
|
84
|
+
message_thread_id?: number;
|
|
85
|
+
pi_telegram_agent_source_thread?: string;
|
|
86
|
+
forum_topic_created?: unknown;
|
|
87
|
+
forum_topic_closed?: unknown;
|
|
88
|
+
forum_topic_reopened?: unknown;
|
|
89
|
+
}
|
|
90
|
+
export type TelegramTopicLifecycleKind = "created" | "closed" | "reopened";
|
|
91
|
+
export interface TelegramTopicLifecycleUpdate<TMessage = TelegramUpdateMessage> {
|
|
92
|
+
kind: TelegramTopicLifecycleKind;
|
|
93
|
+
message: TMessage;
|
|
94
|
+
target: TelegramTarget & {
|
|
95
|
+
threadId: number;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export declare function getTelegramTopicLifecycleUpdate<TMessage extends TelegramUpdateMessage>(message: TMessage | undefined): TelegramTopicLifecycleUpdate<TMessage> | undefined;
|
|
99
|
+
export interface TelegramCallbackQuery {
|
|
100
|
+
id?: string;
|
|
101
|
+
from: TelegramUser;
|
|
102
|
+
message?: TelegramUpdateMessage;
|
|
103
|
+
}
|
|
104
|
+
export interface TelegramGuestMessage {
|
|
105
|
+
guest_query_id: string;
|
|
106
|
+
chat: TelegramChat;
|
|
107
|
+
from?: TelegramUser;
|
|
108
|
+
message_id?: number;
|
|
109
|
+
text?: string;
|
|
110
|
+
/** Text sent together with a photo, document or other media. */
|
|
111
|
+
caption?: string;
|
|
112
|
+
reply_to_message?: TelegramUpdateMessage;
|
|
113
|
+
}
|
|
114
|
+
export declare function getTelegramMessageTarget(message: TelegramUpdateMessage): TelegramTarget | undefined;
|
|
115
|
+
export interface TelegramUpdateRouting {
|
|
116
|
+
message?: TelegramUpdateMessage;
|
|
117
|
+
edited_message?: TelegramUpdateMessage;
|
|
118
|
+
callback_query?: TelegramCallbackQuery;
|
|
119
|
+
guest_message?: TelegramGuestMessage;
|
|
120
|
+
}
|
|
121
|
+
export declare function getAuthorizedTelegramCallbackQuery(update: TelegramUpdateRouting, allowedUserId?: number): TelegramCallbackQuery | undefined;
|
|
122
|
+
export declare function getAuthorizedTelegramMessage(update: TelegramUpdateRouting, allowedUserId?: number): TelegramUpdateMessage | undefined;
|
|
123
|
+
export declare function getAuthorizedTelegramEditedMessage(update: TelegramUpdateRouting, allowedUserId?: number): TelegramUpdateMessage | undefined;
|
|
124
|
+
export declare function getAuthorizedTelegramGuestMessage(update: TelegramUpdateRouting): TelegramGuestMessage | undefined;
|
|
125
|
+
export type TelegramMessageOwnershipView = TelegramBusForwardOwnership;
|
|
126
|
+
export type TelegramMessageOwnershipLookup = (chatId: number, messageId: number) => TelegramMessageOwnershipView | undefined;
|
|
127
|
+
export type TelegramTargetOwnershipView = TelegramBusForwardOwnership;
|
|
128
|
+
export type TelegramTargetOwnershipLookup = (target: TelegramTarget) => TelegramTargetOwnershipView | undefined;
|
|
129
|
+
export interface TelegramForeignOwnedUpdateForwarder<TContext, TReactionUpdate extends TelegramMessageReactionUpdated = TelegramMessageReactionUpdated, TCallbackQuery extends TelegramCallbackQuery = TelegramCallbackQuery, TMessage extends TelegramUpdateMessage = TelegramUpdateMessage> {
|
|
130
|
+
forwardCallback?: (input: {
|
|
131
|
+
query: TCallbackQuery;
|
|
132
|
+
ownership: TelegramMessageOwnershipView;
|
|
133
|
+
ctx: TContext;
|
|
134
|
+
}) => Promise<TelegramBusForeignUpdateSettlement> | TelegramBusForeignUpdateSettlement;
|
|
135
|
+
forwardReaction?: (input: {
|
|
136
|
+
reactionUpdate: TReactionUpdate;
|
|
137
|
+
ownership: TelegramMessageOwnershipView;
|
|
138
|
+
ctx: TContext;
|
|
139
|
+
}) => Promise<TelegramBusForeignUpdateSettlement> | TelegramBusForeignUpdateSettlement;
|
|
140
|
+
forwardMessage?: (input: {
|
|
141
|
+
message: TMessage;
|
|
142
|
+
ownership: TelegramTargetOwnershipView;
|
|
143
|
+
ctx: TContext;
|
|
144
|
+
}) => Promise<TelegramBusForeignUpdateSettlement> | TelegramBusForeignUpdateSettlement;
|
|
145
|
+
forwardEditedMessage?: (input: {
|
|
146
|
+
message: TMessage;
|
|
147
|
+
ownership: TelegramTargetOwnershipView;
|
|
148
|
+
ctx: TContext;
|
|
149
|
+
}) => Promise<TelegramBusForeignUpdateSettlement> | TelegramBusForeignUpdateSettlement;
|
|
150
|
+
}
|
|
151
|
+
export interface TelegramMessageReactionUpdated {
|
|
152
|
+
chat: {
|
|
153
|
+
id?: number;
|
|
154
|
+
type: string;
|
|
155
|
+
};
|
|
156
|
+
user?: TelegramUser;
|
|
157
|
+
actor_chat?: unknown;
|
|
158
|
+
message_id: number;
|
|
159
|
+
old_reaction: TelegramReactionType[];
|
|
160
|
+
new_reaction: TelegramReactionType[];
|
|
161
|
+
}
|
|
162
|
+
export declare const TELEGRAM_INTERNAL_AGENT_MESSAGE: unique symbol;
|
|
163
|
+
export interface TelegramUpdateFlow extends TelegramUpdateRouting, TelegramUpdateDeletion {
|
|
164
|
+
message_reaction?: TelegramMessageReactionUpdated;
|
|
165
|
+
[TELEGRAM_INTERNAL_AGENT_MESSAGE]?: true;
|
|
166
|
+
}
|
|
167
|
+
export type TelegramUpdateAdmissionOutcome = {
|
|
168
|
+
kind: "complete";
|
|
169
|
+
expectedSource?: TelegramDeferredSourceEvidence;
|
|
170
|
+
} | {
|
|
171
|
+
kind: "deferred";
|
|
172
|
+
routingReview?: true;
|
|
173
|
+
} | {
|
|
174
|
+
kind: "queued";
|
|
175
|
+
queueKind: "prompt" | "control";
|
|
176
|
+
receiptId: string;
|
|
177
|
+
sourceUpdateIds: readonly number[];
|
|
178
|
+
};
|
|
179
|
+
export type TelegramDeferredUpdateAbandonmentAuthority = Pick<TelegramUpdateJournalPendingAbandonmentInput, "operatorAuthorityId" | "isCurrent">;
|
|
180
|
+
export interface TelegramDeferredAbandonmentRecoveryRequest {
|
|
181
|
+
journalBindingKey: string;
|
|
182
|
+
afterUpdateId?: number;
|
|
183
|
+
isCurrent: () => boolean;
|
|
184
|
+
}
|
|
185
|
+
/** A generation-owned post-drain hint for the new-world restart; never execution, completion or deletion authority by itself. */
|
|
186
|
+
export interface TelegramHeldSourcePreparation<TContext> {
|
|
187
|
+
ctx: TContext;
|
|
188
|
+
journalBindingKey: string;
|
|
189
|
+
/** Exact prepared worker owner, context, key and authority; the consumer adds its own domain fences. */
|
|
190
|
+
isCurrent: () => boolean;
|
|
191
|
+
signal: AbortSignal;
|
|
192
|
+
/** Chooser-clock sources that must survive cold spending until their fixed expiry. */
|
|
193
|
+
routingSourceIds?: readonly number[];
|
|
194
|
+
}
|
|
195
|
+
export interface TelegramDeferredAbandonmentRecoveryPage {
|
|
196
|
+
sources: {
|
|
197
|
+
/** Detached original evidence, not proof of current eligibility or archive integrity. */
|
|
198
|
+
original: TelegramUpdateJournalEntry;
|
|
199
|
+
retry: (authority: TelegramDeferredUpdateAbandonmentAuthority) => TelegramUpdateJournalPendingAbandonmentResult | undefined;
|
|
200
|
+
}[];
|
|
201
|
+
nextAfterUpdateId?: number;
|
|
202
|
+
}
|
|
203
|
+
type TelegramHistoricalInputPredicate = (original: TelegramUpdateJournalEntry) => boolean;
|
|
204
|
+
/** Read-only exact-source observation by its live worker; not an acceptance or removal grant. */
|
|
205
|
+
export interface TelegramDeferredSourceEvidence extends TelegramUpdateJournalEntryDigest {
|
|
206
|
+
journalBindingKey: string;
|
|
207
|
+
/** Supplied only after caller-owned acceptance publication; requires a durable removal ACK. */
|
|
208
|
+
completionSha256?: string;
|
|
209
|
+
}
|
|
210
|
+
/** Fresh source-owner projection; the payload is copied from the retained journal, never a routed carrier. */
|
|
211
|
+
export interface TelegramDeferredSourceSnapshot {
|
|
212
|
+
source: TelegramDeferredSourceEvidence;
|
|
213
|
+
update: TelegramJournaledUpdate;
|
|
214
|
+
}
|
|
215
|
+
/** Warm exact-removal ACK plus its issuing worker lifetime; never persisted or sent over IPC. */
|
|
216
|
+
interface TelegramDeferredSourceCompletion {
|
|
217
|
+
source: TelegramDeferredSourceEvidence;
|
|
218
|
+
isCurrent(): boolean;
|
|
219
|
+
}
|
|
220
|
+
interface TelegramUpdateAdmissionBinding {
|
|
221
|
+
sourceUpdateId: number;
|
|
222
|
+
report: (outcome: TelegramUpdateAdmissionOutcome) => void;
|
|
223
|
+
abandon?: (authority: TelegramDeferredUpdateAbandonmentAuthority) => TelegramUpdateJournalPendingAbandonmentResult | undefined;
|
|
224
|
+
armRoutingInput?: (operatorUserId: number, sourceUpdateIds: readonly number[], chooser?: TelegramUpdateJournalRoutingChooser) => TelegramUpdateJournalRoutingInput | undefined;
|
|
225
|
+
/** The source's saved routing clock, including where its chooser was published. */
|
|
226
|
+
getRoutingInput?: () => TelegramUpdateJournalRoutingInput | undefined;
|
|
227
|
+
acquireRouting?: (select?: boolean, sourceUpdateIds?: readonly number[]) => () => void;
|
|
228
|
+
inspectSource?: () => TelegramDeferredSourceEvidence | undefined;
|
|
229
|
+
inspectSourceSnapshot?: () => TelegramDeferredSourceSnapshot | undefined;
|
|
230
|
+
inspectCompletion?: () => TelegramDeferredSourceEvidence | undefined;
|
|
231
|
+
isSourceUnsettled?: () => boolean;
|
|
232
|
+
prepareLiveInput?: (sourceUpdateIds: readonly number[], isCurrent: () => boolean) => TelegramLiveDeferredInputPreparation | undefined;
|
|
233
|
+
prepareQueueAdmission?: () => TelegramDeferredQueueAdmissionPreparation | undefined;
|
|
234
|
+
prepareSourceCompletion?: () => Pick<TelegramDeferredSourceCompletionPreparation, "source" | "isCurrent"> | undefined;
|
|
235
|
+
supportsAbandonment?: (journalBindingKey: string) => boolean;
|
|
236
|
+
inspectAbandoning?: (request: TelegramDeferredAbandonmentRecoveryRequest) => TelegramDeferredAbandonmentRecoveryPage | undefined;
|
|
237
|
+
inspectHistorical?: (request: TelegramDeferredAbandonmentRecoveryRequest) => TelegramDeferredAbandonmentRecoveryPage | undefined;
|
|
238
|
+
isHistorical?: (matchesOriginal?: TelegramHistoricalInputPredicate) => boolean;
|
|
239
|
+
isHistoricalReviewHeld?: () => boolean;
|
|
240
|
+
}
|
|
241
|
+
export type TelegramQueueAdmissionReceiptLike = TelegramQueueAdmissionReceipt;
|
|
242
|
+
export declare function bindTelegramUpdateAdmissionSource<TUpdate extends TelegramUpdateFlow & {
|
|
243
|
+
update_id: number;
|
|
244
|
+
}>(update: TUpdate, report: TelegramUpdateAdmissionBinding["report"], controls?: Pick<TelegramUpdateAdmissionBinding, "abandon" | "armRoutingInput" | "getRoutingInput" | "acquireRouting" | "inspectSource" | "inspectSourceSnapshot" | "inspectCompletion" | "isSourceUnsettled" | "prepareLiveInput" | "prepareQueueAdmission" | "prepareSourceCompletion" | "supportsAbandonment" | "inspectAbandoning" | "inspectHistorical" | "isHistorical" | "isHistoricalReviewHeld">): TUpdate;
|
|
245
|
+
/**
|
|
246
|
+
* Conservative read-only census: any retained entry naming this Thread, in any nested Telegram object or state,
|
|
247
|
+
* is unresolved custody, except a lone button tap, which carries no input (the in-flight Cancel itself).
|
|
248
|
+
* It cannot see updates still in transit before journal append.
|
|
249
|
+
*/
|
|
250
|
+
export declare function collectTelegramJournalThreadUpdateIds(entries: readonly {
|
|
251
|
+
updateId: number;
|
|
252
|
+
update: unknown;
|
|
253
|
+
}[], target: {
|
|
254
|
+
chatId: number;
|
|
255
|
+
threadId: number;
|
|
256
|
+
}): number[];
|
|
257
|
+
export declare function collectTelegramAdmissionSourceUpdateIds(values: readonly unknown[]): number[];
|
|
258
|
+
/** Observe the original journal entry, never the mutable routed carrier, through current worker authority. */
|
|
259
|
+
export declare function inspectTelegramDeferredSource(value: unknown): TelegramDeferredSourceEvidence | undefined;
|
|
260
|
+
/** Read an exact current original for peer preparation without another payload authority. */
|
|
261
|
+
export declare function inspectTelegramDeferredSourceSnapshot(value: unknown): TelegramDeferredSourceSnapshot | undefined;
|
|
262
|
+
/** Exact warm removal ACK only; reporting, source absence and a replaced worker cannot supply it. */
|
|
263
|
+
export declare function inspectTelegramDeferredSourceCompletion(value: unknown): TelegramDeferredSourceEvidence | undefined;
|
|
264
|
+
/** Reuse only live bound deferred originals; raw IDs or cold/adopted input cannot mint this carrier. */
|
|
265
|
+
export declare function prepareTelegramLiveDeferredInput(values: readonly unknown[], isCurrent: () => boolean): TelegramLiveDeferredInputPreparation | undefined;
|
|
266
|
+
/** A route-owned pre-disposition acceptance publisher; wraps only this carrier, never the shared worker binding. */
|
|
267
|
+
export declare function bindTelegramUpdateCompletionAcceptance<TValue>(value: TValue, publish: () => TelegramDeferredSourceEvidence): TValue;
|
|
268
|
+
/** Report source completion; true means reported, not a durable settlement acknowledgement. */
|
|
269
|
+
export declare function reportTelegramUpdateCompleted(value: unknown, expectedSource?: TelegramDeferredSourceEvidence): boolean;
|
|
270
|
+
export declare function reportTelegramUpdateDeferred(value: unknown): boolean;
|
|
271
|
+
/** Exact source-bound cancellation; undefined means no eligible attempt was made. */
|
|
272
|
+
export declare function abandonTelegramDeferredUpdate(value: unknown, authority: TelegramDeferredUpdateAbandonmentAuthority): TelegramUpdateJournalPendingAbandonmentResult | undefined;
|
|
273
|
+
/** Capability for chooser publication; the eventual action still requires exact deferred authority. */
|
|
274
|
+
export declare function supportsTelegramDeferredAbandonment(value: unknown, journalBindingKey: string): boolean;
|
|
275
|
+
/** Observe protected attempts through a current carrier; the UI still owns human authorization. */
|
|
276
|
+
export declare function inspectTelegramAbandoningUpdates(value: unknown, request: TelegramDeferredAbandonmentRecoveryRequest): TelegramDeferredAbandonmentRecoveryPage | undefined;
|
|
277
|
+
/** Historical inspection is not human confirmation or permission to stop delivery. */
|
|
278
|
+
export declare function inspectTelegramHistoricalInputs(value: unknown, request: TelegramDeferredAbandonmentRecoveryRequest): TelegramDeferredAbandonmentRecoveryPage | undefined;
|
|
279
|
+
export declare function isTelegramHistoricalInput(value: unknown, matchesOriginal?: TelegramHistoricalInputPredicate): boolean;
|
|
280
|
+
/** Routing's last-boundary hold when ownership changed after early classification. */
|
|
281
|
+
export declare function reportTelegramHistoricalRoutingReview(value: unknown): boolean;
|
|
282
|
+
/** Arm only a positively published chooser; the journal owns the immutable hour deadline. */
|
|
283
|
+
export declare function armTelegramRoutingInputs(values: readonly unknown[], operatorUserId: number, chooser?: TelegramUpdateJournalRoutingChooser): TelegramUpdateJournalRoutingInput | undefined;
|
|
284
|
+
/** A routed carrier's saved routing clock; a revived chooser reuses its recorded message. */
|
|
285
|
+
export declare function getTelegramUpdateRoutingInput(value: unknown): TelegramUpdateJournalRoutingInput | undefined;
|
|
286
|
+
/** Reserve source execution; an actual choice must also freeze its durable TTL before any effect. */
|
|
287
|
+
export declare function acquireTelegramUpdateRouting(value: unknown, select?: boolean, sourceUpdateIds?: readonly number[]): () => void;
|
|
288
|
+
/** Capture existing warm completion authority; only explicit reporting may dispose this exact original. */
|
|
289
|
+
export declare function prepareTelegramDeferredSourceCompletion(value: unknown): TelegramDeferredSourceCompletionPreparation | undefined;
|
|
290
|
+
/** Read-only warm owner availability; no source freeze, admission, report or receipt reconstruction. */
|
|
291
|
+
export declare function prepareTelegramDeferredQueueAdmission(value: unknown): TelegramDeferredQueueAdmissionPreparation | undefined;
|
|
292
|
+
export declare function reportTelegramQueueAdmission(values: readonly unknown[], receipts: readonly TelegramQueueAdmissionReceiptLike[]): boolean;
|
|
293
|
+
export type TelegramUpdateFlowAction<TReactionUpdate extends TelegramMessageReactionUpdated = TelegramMessageReactionUpdated, TCallbackQuery extends TelegramCallbackQuery = TelegramCallbackQuery, TMessage extends TelegramUpdateMessage = TelegramUpdateMessage, TGuestMessage extends TelegramGuestMessage = TelegramGuestMessage> = {
|
|
294
|
+
kind: "ignore";
|
|
295
|
+
} | {
|
|
296
|
+
kind: "deleted";
|
|
297
|
+
messageIds: number[];
|
|
298
|
+
} | {
|
|
299
|
+
kind: "reaction";
|
|
300
|
+
reactionUpdate: TReactionUpdate;
|
|
301
|
+
} | {
|
|
302
|
+
kind: "topic-lifecycle";
|
|
303
|
+
lifecycle: TelegramTopicLifecycleUpdate<TMessage>;
|
|
304
|
+
} | {
|
|
305
|
+
kind: "callback";
|
|
306
|
+
query: TCallbackQuery;
|
|
307
|
+
authorization: TelegramAuthorizationState;
|
|
308
|
+
} | {
|
|
309
|
+
kind: "message";
|
|
310
|
+
message: TMessage & {
|
|
311
|
+
from: TelegramUser;
|
|
312
|
+
};
|
|
313
|
+
authorization: TelegramAuthorizationState;
|
|
314
|
+
} | {
|
|
315
|
+
kind: "edited-message";
|
|
316
|
+
message: TMessage & {
|
|
317
|
+
from: TelegramUser;
|
|
318
|
+
};
|
|
319
|
+
authorization: TelegramAuthorizationState;
|
|
320
|
+
} | {
|
|
321
|
+
kind: "guest";
|
|
322
|
+
guestMessage: TGuestMessage & {
|
|
323
|
+
from: TelegramUser;
|
|
324
|
+
};
|
|
325
|
+
authorization: TelegramAuthorizationState;
|
|
326
|
+
};
|
|
327
|
+
export declare function buildTelegramUpdateFlowAction<TUpdate extends TelegramUpdateFlow>(update: TUpdate, allowedUserId?: number): TelegramUpdateFlowAction<NonNullable<TUpdate["message_reaction"]>, NonNullable<TUpdate["callback_query"]>, NonNullable<TUpdate["message"] | TUpdate["edited_message"]>, NonNullable<TUpdate["guest_message"]>>;
|
|
328
|
+
export type TelegramUpdateExecutionPlan<TReactionUpdate extends TelegramMessageReactionUpdated = TelegramMessageReactionUpdated, TCallbackQuery extends TelegramCallbackQuery = TelegramCallbackQuery, TMessage extends TelegramUpdateMessage = TelegramUpdateMessage, TGuestMessage extends TelegramGuestMessage = TelegramGuestMessage> = {
|
|
329
|
+
kind: "ignore";
|
|
330
|
+
} | {
|
|
331
|
+
kind: "deleted";
|
|
332
|
+
messageIds: number[];
|
|
333
|
+
} | {
|
|
334
|
+
kind: "reaction";
|
|
335
|
+
reactionUpdate: TReactionUpdate;
|
|
336
|
+
} | {
|
|
337
|
+
kind: "topic-lifecycle";
|
|
338
|
+
lifecycle: TelegramTopicLifecycleUpdate<TMessage>;
|
|
339
|
+
} | {
|
|
340
|
+
kind: "callback";
|
|
341
|
+
query: TCallbackQuery;
|
|
342
|
+
shouldPair: boolean;
|
|
343
|
+
shouldDeny: boolean;
|
|
344
|
+
} | {
|
|
345
|
+
kind: "message";
|
|
346
|
+
message: TMessage & {
|
|
347
|
+
from: TelegramUser;
|
|
348
|
+
};
|
|
349
|
+
shouldPair: boolean;
|
|
350
|
+
shouldNotifyPaired: boolean;
|
|
351
|
+
shouldDeny: boolean;
|
|
352
|
+
} | {
|
|
353
|
+
kind: "edited-message";
|
|
354
|
+
message: TMessage & {
|
|
355
|
+
from: TelegramUser;
|
|
356
|
+
};
|
|
357
|
+
shouldPair: boolean;
|
|
358
|
+
shouldDeny: boolean;
|
|
359
|
+
} | {
|
|
360
|
+
kind: "guest";
|
|
361
|
+
guestMessage: TGuestMessage & {
|
|
362
|
+
from: TelegramUser;
|
|
363
|
+
};
|
|
364
|
+
shouldDeny: boolean;
|
|
365
|
+
};
|
|
366
|
+
export declare function buildTelegramUpdateExecutionPlan<TReactionUpdate extends TelegramMessageReactionUpdated, TCallbackQuery extends TelegramCallbackQuery, TMessage extends TelegramUpdateMessage, TGuestMessage extends TelegramGuestMessage>(action: TelegramUpdateFlowAction<TReactionUpdate, TCallbackQuery, TMessage, TGuestMessage>): TelegramUpdateExecutionPlan<TReactionUpdate, TCallbackQuery, TMessage, TGuestMessage>;
|
|
367
|
+
export declare function buildTelegramUpdateExecutionPlanFromUpdate<TUpdate extends TelegramUpdateFlow>(update: TUpdate, allowedUserId?: number): TelegramUpdateExecutionPlan<NonNullable<TUpdate["message_reaction"]>, NonNullable<TUpdate["callback_query"]>, NonNullable<TUpdate["message"] | TUpdate["edited_message"]>>;
|
|
368
|
+
export type TelegramMessageOwnershipRecorderInput = Parameters<TelegramMessageOwnershipStore["record"]>[0];
|
|
369
|
+
export type TelegramMessageOwnershipRecorder = (input: TelegramMessageOwnershipRecorderInput) => void;
|
|
370
|
+
interface TelegramUnauthorizedReplyOptions {
|
|
371
|
+
parseMode?: "HTML";
|
|
372
|
+
target?: {
|
|
373
|
+
chatId: number;
|
|
374
|
+
threadId?: number;
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
/** Ownership lookups and authorized-update handlers shared by the per-update runtime and its controller. */
|
|
378
|
+
export interface TelegramUpdateHandlerPorts<TContext, TCallbackQuery extends TelegramCallbackQuery, TMessage extends TelegramUpdateMessage> {
|
|
379
|
+
getCurrentInstanceId?: () => string | undefined;
|
|
380
|
+
getMessageOwnership?: TelegramMessageOwnershipLookup;
|
|
381
|
+
getTargetOwnership?: TelegramTargetOwnershipLookup;
|
|
382
|
+
recordMessageOwnership?: TelegramMessageOwnershipRecorder;
|
|
383
|
+
removePendingMediaGroupMessages: (messageIds: number[]) => void;
|
|
384
|
+
pairTelegramUserIfNeeded: (userId: number, ctx: TContext, assertExecutionCurrent?: () => void) => Promise<boolean>;
|
|
385
|
+
answerCallbackQuery: (callbackQueryId: string, text?: string) => Promise<void>;
|
|
386
|
+
answerGuestQuery: (guestQueryId: string, text?: string, options?: Pick<TelegramUnauthorizedReplyOptions, "parseMode">) => Promise<void>;
|
|
387
|
+
handleAuthorizedTelegramCallbackQuery: (query: TCallbackQuery, ctx: TContext) => Promise<void>;
|
|
388
|
+
sendTextReply: (chatId: number, replyToMessageId: number, text: string, options?: TelegramUnauthorizedReplyOptions) => Promise<number | undefined>;
|
|
389
|
+
handleAuthorizedTelegramMessage: (message: TMessage, ctx: TContext) => Promise<void>;
|
|
390
|
+
handleAuthorizedTelegramEditedMessage: (message: TMessage, ctx: TContext) => unknown;
|
|
391
|
+
handleAuthorizedTelegramGuestMessage?: (guestMessage: TelegramGuestMessage & {
|
|
392
|
+
from: TelegramUser;
|
|
393
|
+
}, ctx: TContext) => Promise<void>;
|
|
394
|
+
handleTelegramTopicLifecycleUpdate?: (lifecycle: TelegramTopicLifecycleUpdate<TMessage>, ctx: TContext) => Promise<void> | void;
|
|
395
|
+
/** Called when the owner writes in an unbound thread no live instance owns. */
|
|
396
|
+
handleUnboundTelegramTopicMessage?: (message: TMessage & {
|
|
397
|
+
from: TelegramUser;
|
|
398
|
+
}, ctx: TContext) => Promise<void>;
|
|
399
|
+
}
|
|
400
|
+
export interface TelegramUpdateRuntimeDeps<TContext = unknown, TReactionUpdate extends TelegramMessageReactionUpdated = TelegramMessageReactionUpdated, TCallbackQuery extends TelegramCallbackQuery = TelegramCallbackQuery, TMessage extends TelegramUpdateMessage = TelegramUpdateMessage> extends TelegramUpdateHandlerPorts<TContext, TCallbackQuery, TMessage> {
|
|
401
|
+
ctx: TContext;
|
|
402
|
+
execution?: TelegramUpdateExecutionFence;
|
|
403
|
+
foreignOwnedUpdateForwarder?: TelegramForeignOwnedUpdateForwarder<TContext, TReactionUpdate, TCallbackQuery, TMessage>;
|
|
404
|
+
removeQueuedTelegramTurnsByMessageIds: (messageIds: number[], ctx: TContext) => number;
|
|
405
|
+
handleAuthorizedTelegramReactionUpdate: (reactionUpdate: TReactionUpdate, ctx: TContext) => Promise<void>;
|
|
406
|
+
}
|
|
407
|
+
export interface TelegramUpdateRuntimeControllerDeps<TContext = unknown, TCallbackQuery extends TelegramCallbackQuery = TelegramCallbackQuery, TMessage extends TelegramUpdateMessage = TelegramUpdateMessage> extends TelegramUpdateHandlerPorts<TContext, TCallbackQuery, TMessage> {
|
|
408
|
+
getAllowedUserId: () => number | undefined;
|
|
409
|
+
foreignOwnedUpdateForwarder?: TelegramForeignOwnedUpdateForwarder<TContext, TelegramMessageReactionUpdated, TCallbackQuery, TMessage>;
|
|
410
|
+
flushPendingMediaGroupMessage?: (messageId: number) => Promise<boolean>;
|
|
411
|
+
flushPendingTextGroupMessage?: (messageId: number) => Promise<boolean>;
|
|
412
|
+
removeQueuedTelegramTurnsByMessageIds: (messageIds: number[], ctx: TContext, scope?: {
|
|
413
|
+
chatId?: number;
|
|
414
|
+
threadId?: number;
|
|
415
|
+
}) => number;
|
|
416
|
+
applyQueuedTelegramTurnReactionByMessageId: (messageId: number, disposition: TelegramQueueReactionDisposition, ctx: TContext, scope?: {
|
|
417
|
+
chatId?: number;
|
|
418
|
+
threadId?: number;
|
|
419
|
+
}) => boolean;
|
|
420
|
+
}
|
|
421
|
+
export interface TelegramUpdateRuntimeController<TContext = unknown, TUpdate extends TelegramUpdateFlow = TelegramUpdateFlow> {
|
|
422
|
+
handleAuthorizedReactionUpdate: (reactionUpdate: NonNullable<TUpdate["message_reaction"]>, ctx: TContext) => Promise<void>;
|
|
423
|
+
handleUpdate: (update: TUpdate, ctx: TContext, execution?: TelegramUpdateExecutionFence) => Promise<void>;
|
|
424
|
+
}
|
|
425
|
+
export declare function executeTelegramUpdate<TUpdate extends TelegramUpdateFlow, TContext = unknown>(update: TUpdate, allowedUserId: number | undefined, deps: TelegramUpdateRuntimeDeps<TContext, NonNullable<TUpdate["message_reaction"]>, NonNullable<TUpdate["callback_query"]>, NonNullable<TUpdate["message"] | TUpdate["edited_message"]>>): Promise<void>;
|
|
426
|
+
export type TelegramPairedUpdateRuntimeControllerDeps<TContext = unknown, TUpdate extends TelegramUpdateFlow = TelegramUpdateFlow> = Omit<TelegramUpdateRuntimeControllerDeps<TContext, NonNullable<TUpdate["callback_query"]>, NonNullable<TUpdate["message"] | TUpdate["edited_message"]>>, "pairTelegramUserIfNeeded"> & TelegramUserPairingRuntimeDeps<TContext>;
|
|
427
|
+
export declare function createTelegramPairedUpdateRuntime<TContext = unknown, TUpdate extends TelegramUpdateFlow = TelegramUpdateFlow>(deps: TelegramPairedUpdateRuntimeControllerDeps<TContext, TUpdate>): TelegramUpdateRuntimeController<TContext, TUpdate>;
|
|
428
|
+
export declare function createTelegramUpdateRuntime<TContext = unknown, TUpdate extends TelegramUpdateFlow = TelegramUpdateFlow>(deps: TelegramUpdateRuntimeControllerDeps<TContext, NonNullable<TUpdate["callback_query"]>, NonNullable<TUpdate["message"] | TUpdate["edited_message"]>>): TelegramUpdateRuntimeController<TContext, TUpdate>;
|
|
429
|
+
export interface AuthorizedTelegramReactionUpdateDeps<TContext> {
|
|
430
|
+
allowedUserId?: number;
|
|
431
|
+
ctx: TContext;
|
|
432
|
+
getCurrentInstanceId?: () => string | undefined;
|
|
433
|
+
getMessageOwnership?: TelegramMessageOwnershipLookup;
|
|
434
|
+
foreignOwnedUpdateForwarder?: TelegramForeignOwnedUpdateForwarder<TContext>;
|
|
435
|
+
assertExecutionCurrent?: () => void;
|
|
436
|
+
flushPendingMediaGroupMessage?: (messageId: number) => Promise<boolean>;
|
|
437
|
+
flushPendingTextGroupMessage?: (messageId: number) => Promise<boolean>;
|
|
438
|
+
applyQueuedTelegramTurnReactionByMessageId: (messageId: number, disposition: TelegramQueueReactionDisposition, ctx: TContext, scope?: {
|
|
439
|
+
chatId?: number;
|
|
440
|
+
threadId?: number;
|
|
441
|
+
}) => boolean;
|
|
442
|
+
}
|
|
443
|
+
export declare function handleAuthorizedTelegramReactionUpdate<TContext>(reactionUpdate: TelegramMessageReactionUpdated, deps: AuthorizedTelegramReactionUpdateDeps<TContext>): Promise<void>;
|
|
444
|
+
export declare function executeTelegramUpdatePlan<TContext = unknown, TReactionUpdate extends TelegramMessageReactionUpdated = TelegramMessageReactionUpdated, TCallbackQuery extends TelegramCallbackQuery = TelegramCallbackQuery, TMessage extends TelegramUpdateMessage = TelegramUpdateMessage>(plan: TelegramUpdateExecutionPlan<TReactionUpdate, TCallbackQuery, TMessage>, deps: TelegramUpdateRuntimeDeps<TContext, TReactionUpdate, TCallbackQuery, TMessage>): Promise<void>;
|
|
445
|
+
export type TelegramUpdateWorkerPhase = "stopped" | "idle" | "executing" | "retry-wait" | "failed" | "deferred" | "queued" | "blocked";
|
|
446
|
+
export type TelegramUpdateWorkerBlockedReason = "authority-lost" | "authority-check" | "journal-read" | "journal-write" | "execution" | "input-custody" | "prior-generation-executing" | "invalid-outcome";
|
|
447
|
+
export interface TelegramUpdateWorkerStateSnapshot {
|
|
448
|
+
phase: TelegramUpdateWorkerPhase;
|
|
449
|
+
generation: number;
|
|
450
|
+
phaseStartedAtMs?: number;
|
|
451
|
+
currentUpdateId?: number;
|
|
452
|
+
blockedReason?: TelegramUpdateWorkerBlockedReason;
|
|
453
|
+
blockedInputCustody?: {
|
|
454
|
+
updateId: number;
|
|
455
|
+
kind: "running-outcome-unknown" | "foreign-ready" | "handoff-frozen" | "legacy-retry-state";
|
|
456
|
+
};
|
|
457
|
+
journalEntryCount: number;
|
|
458
|
+
journalSerializedBytes: number;
|
|
459
|
+
oldestAdmittedAtMs?: number;
|
|
460
|
+
deferredClaimCount: number;
|
|
461
|
+
/** Protected cancellation attempts, not proof of a committed discard. */
|
|
462
|
+
abandoningClaimCount?: number;
|
|
463
|
+
/** Historical sources held before routing, not evidence of prior non-delivery. */
|
|
464
|
+
historicalClaimCount?: number;
|
|
465
|
+
/** Fresh recipient inputs reserved before append; not executable prompt-queue work. */
|
|
466
|
+
preparedInputCount?: number;
|
|
467
|
+
queuedClaimCount: number;
|
|
468
|
+
foreignQueuedCount: number;
|
|
469
|
+
foreignQueuedOwner?: TelegramUpdateJournalQueueOwner;
|
|
470
|
+
foreignQueuedOwnerLiveness?: TelegramProcessLiveness;
|
|
471
|
+
retryWaitCount: number;
|
|
472
|
+
failedCount: number;
|
|
473
|
+
nextRetryUpdateId?: number;
|
|
474
|
+
nextRetryAtMs?: number;
|
|
475
|
+
nextRetryAttemptCount?: number;
|
|
476
|
+
nextRetryFailureClass?: string;
|
|
477
|
+
failedUpdateId?: number;
|
|
478
|
+
failedFailureId?: string;
|
|
479
|
+
failedAttemptCount?: number;
|
|
480
|
+
failedClass?: string;
|
|
481
|
+
failedSummary?: string;
|
|
482
|
+
terminalFailureAtMs?: number;
|
|
483
|
+
unsettledExecutionCount: number;
|
|
484
|
+
lastCompletedUpdateId?: number;
|
|
485
|
+
lastCompletedAtMs?: number;
|
|
486
|
+
lastFailureAtMs?: number;
|
|
487
|
+
lastFailurePhase?: string;
|
|
488
|
+
}
|
|
489
|
+
export interface TelegramUpdateWorkerJournalSnapshot {
|
|
490
|
+
version: typeof TELEGRAM_UPDATE_JOURNAL_VERSION | typeof TELEGRAM_UPDATE_JOURNAL_EXCLUSION_VERSION | typeof TELEGRAM_UPDATE_JOURNAL_CUSTODY_VERSION;
|
|
491
|
+
acceptedThroughUpdateId?: number;
|
|
492
|
+
entries: readonly {
|
|
493
|
+
updateId: number;
|
|
494
|
+
update: TelegramJournaledUpdate;
|
|
495
|
+
readonly preApprovalExcluded?: boolean;
|
|
496
|
+
admittedAtMs: number;
|
|
497
|
+
routingInput?: TelegramUpdateJournalRoutingInput;
|
|
498
|
+
state: "pending" | "retry-wait" | "queued" | "failed";
|
|
499
|
+
inputClaim?: TelegramUpdateJournalInputClaim;
|
|
500
|
+
queueKind?: "prompt" | "control";
|
|
501
|
+
queueReceiptId?: string;
|
|
502
|
+
queueOwner?: TelegramUpdateJournalQueueOwner;
|
|
503
|
+
queueHandoff?: {
|
|
504
|
+
handoffId: string;
|
|
505
|
+
offeredAtMs: number;
|
|
506
|
+
recipientOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
507
|
+
};
|
|
508
|
+
failure?: {
|
|
509
|
+
attemptCount: number;
|
|
510
|
+
failedAtMs: number;
|
|
511
|
+
failureClass: string;
|
|
512
|
+
summary: string;
|
|
513
|
+
};
|
|
514
|
+
nextRetryAtMs?: number;
|
|
515
|
+
terminalAtMs?: number;
|
|
516
|
+
terminalReason?: string;
|
|
517
|
+
terminalFailureId?: string;
|
|
518
|
+
}[];
|
|
519
|
+
serializedBytes: number;
|
|
520
|
+
}
|
|
521
|
+
export interface TelegramRoutingInputExpirySource {
|
|
522
|
+
original: TelegramUpdateJournalEntry;
|
|
523
|
+
journalBindingKey: string;
|
|
524
|
+
isCurrent(): boolean;
|
|
525
|
+
expire(): TelegramRoutingInputExpiryResult | undefined;
|
|
526
|
+
}
|
|
527
|
+
export interface TelegramUpdateWorkerJournalPort {
|
|
528
|
+
routingInputs?: TelegramRoutingInputJournal;
|
|
529
|
+
read: () => TelegramUpdateWorkerJournalSnapshot;
|
|
530
|
+
inspectPendingRetention?: (entry: TelegramUpdateJournalEntry) => TelegramUpdateJournalPendingRetentionEvidence | undefined;
|
|
531
|
+
abandonPending?: (input: TelegramUpdateJournalPendingAbandonmentInput) => TelegramUpdateJournalPendingAbandonmentResult;
|
|
532
|
+
/** Optional strict observation; it must not recover, repair or grant new receipt authority. */
|
|
533
|
+
isQueueReceiptCurrent?: (receipt: TelegramQueueAdmissionReceiptLike, owner: TelegramUpdateJournalQueueOwner) => boolean;
|
|
534
|
+
/** Strict full-group origin observation for prepared partial scopes; no writer or readiness acquisition. */
|
|
535
|
+
inspectQueuedReceipt?: (expected: TelegramUpdateJournalQueuedCompletion) => TelegramUpdateJournalQueuedReceiptEvidence | undefined;
|
|
536
|
+
markQueued: (receipt: {
|
|
537
|
+
queueKind: "prompt" | "control";
|
|
538
|
+
receiptId: string;
|
|
539
|
+
sourceUpdateIds: readonly number[];
|
|
540
|
+
owner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
541
|
+
}) => {
|
|
542
|
+
queuedUpdateIds: readonly number[];
|
|
543
|
+
duplicateUpdateIds: readonly number[];
|
|
544
|
+
queueOwner?: TelegramUpdateJournalQueueOwner;
|
|
545
|
+
};
|
|
546
|
+
completeQueued: (receipts: readonly {
|
|
547
|
+
queueKind: "prompt" | "control";
|
|
548
|
+
receiptId: string;
|
|
549
|
+
sourceUpdateIds: readonly number[];
|
|
550
|
+
queueOwner: TelegramUpdateJournalQueueOwner;
|
|
551
|
+
}[]) => {
|
|
552
|
+
removedUpdateIds: readonly number[];
|
|
553
|
+
};
|
|
554
|
+
completeQueuedExact?: (receipts: readonly {
|
|
555
|
+
queueKind: "prompt" | "control";
|
|
556
|
+
receiptId: string;
|
|
557
|
+
sourceUpdateIds: readonly number[];
|
|
558
|
+
queueOwner: TelegramUpdateJournalQueueOwner;
|
|
559
|
+
}[], completions: readonly TelegramUpdateJournalSourceCompletion[]) => {
|
|
560
|
+
removedUpdateIds: readonly number[];
|
|
561
|
+
sourceCompletions?: readonly TelegramUpdateJournalSourceCompletion[];
|
|
562
|
+
};
|
|
563
|
+
markExecutionFailure: (input: {
|
|
564
|
+
updateId: number;
|
|
565
|
+
expectedAttemptCount: number;
|
|
566
|
+
failedAtMs: number;
|
|
567
|
+
failureClass: string;
|
|
568
|
+
summary: string;
|
|
569
|
+
disposition: "retry-wait" | "failed";
|
|
570
|
+
nextRetryAtMs?: number;
|
|
571
|
+
terminalReason?: string;
|
|
572
|
+
}) => {
|
|
573
|
+
entry: TelegramUpdateWorkerJournalSnapshot["entries"][number];
|
|
574
|
+
};
|
|
575
|
+
removeCompleted: (updateIds: readonly number[]) => {
|
|
576
|
+
removedUpdateIds: readonly number[];
|
|
577
|
+
};
|
|
578
|
+
/** No ID-only fallback is allowed for a guarded completion report. */
|
|
579
|
+
removeCompletedExact?: (updateIds: readonly number[], expectedSources: readonly TelegramUpdateJournalEntryDigest[], completions?: readonly TelegramUpdateJournalSourceCompletion[], isCurrent?: () => boolean) => {
|
|
580
|
+
removedUpdateIds: readonly number[];
|
|
581
|
+
sourceCompletions?: readonly TelegramUpdateJournalSourceCompletion[];
|
|
582
|
+
};
|
|
583
|
+
inspectSourceCompletion?: (expected: TelegramUpdateJournalSourceCompletion) => TelegramUpdateJournalSourceCompletion | undefined;
|
|
584
|
+
}
|
|
585
|
+
export type TelegramQueueSourceCompletion = TelegramDeferredSourceEvidence & {
|
|
586
|
+
completionSha256: string;
|
|
587
|
+
};
|
|
588
|
+
export interface TelegramUpdateRetryPolicy {
|
|
589
|
+
baseDelayMs: number;
|
|
590
|
+
maxDelayMs: number;
|
|
591
|
+
}
|
|
592
|
+
export interface TelegramUpdateExecutionFailureClassification {
|
|
593
|
+
disposition: "retryable" | "terminal";
|
|
594
|
+
failureClass: string;
|
|
595
|
+
summary: string;
|
|
596
|
+
}
|
|
597
|
+
export interface TelegramUpdateWorkerRuntimeDeps<TContext> {
|
|
598
|
+
journal: TelegramUpdateWorkerJournalPort;
|
|
599
|
+
executeUpdate: (update: TelegramJournaledUpdate, ctx: TContext, signal: AbortSignal) => Promise<TelegramUpdateAdmissionOutcome> | TelegramUpdateAdmissionOutcome;
|
|
600
|
+
/** Native source-only binding, installed by the admission-worker assembly rather than ordinary dispatch. */
|
|
601
|
+
admitPreparedLiveInput?: (update: TelegramJournaledUpdate, ctx: TContext, signal: AbortSignal) => Promise<{
|
|
602
|
+
outcome: TelegramUpdateAdmissionOutcome;
|
|
603
|
+
carrier: unknown;
|
|
604
|
+
}>;
|
|
605
|
+
executeCustodiedUpdate?: (update: TelegramJournaledUpdate, ctx: TContext, signal: AbortSignal) => Promise<TelegramCustodiedExecutionResult>;
|
|
606
|
+
hasAuthority: (ctx: TContext) => boolean;
|
|
607
|
+
getJournalBindingKey?: () => string | undefined;
|
|
608
|
+
getRecipientBindingKey?: () => string | undefined;
|
|
609
|
+
/**
|
|
610
|
+
* True selects legacy historical review/spending; retain protects unsupported originals without disposition
|
|
611
|
+
* authority; revive re-admits a still-waiting chooser source as this generation's live input.
|
|
612
|
+
*/
|
|
613
|
+
shouldReviewHistoricalInput?: (entry: TelegramUpdateJournalEntry, ctx: TContext, signal: AbortSignal) => TelegramHistoricalReviewVerdict | Promise<TelegramHistoricalReviewVerdict>;
|
|
614
|
+
/** New-world restart: spend unclocked classified routing input without delivery, copy or completion. Chooser clocks wait for expiry; interrupted private abandonment keeps exact recovery. */
|
|
615
|
+
spendHistoricalInput?: boolean;
|
|
616
|
+
/** Holds protected live or retry sources before execution; never cancels or disposes them. */
|
|
617
|
+
shouldHoldPendingInput?: (entry: TelegramUpdateJournalEntry, ctx: TContext, signal: AbortSignal) => boolean | Promise<boolean>;
|
|
618
|
+
getQueueOwnerIdentity?: (ctx: TContext) => TelegramUpdateJournalQueueOwnerIdentity;
|
|
619
|
+
isContextCurrent?: (ctx: TContext) => boolean;
|
|
620
|
+
createAbortController?: () => AbortController;
|
|
621
|
+
getNowMs?: () => number;
|
|
622
|
+
expireRoutingInput?: (source: TelegramRoutingInputExpirySource, ctx: TContext, signal: AbortSignal) => Promise<void> | void;
|
|
623
|
+
retryPolicy?: Partial<TelegramUpdateRetryPolicy>;
|
|
624
|
+
classifyExecutionFailure?: (error: unknown) => TelegramUpdateExecutionFailureClassification;
|
|
625
|
+
settleTerminalExecutionFailure?: (error: unknown) => Promise<boolean>;
|
|
626
|
+
scheduleRetry?: (callback: () => void, delayMs: number) => unknown;
|
|
627
|
+
cancelRetry?: (handle: unknown) => void;
|
|
628
|
+
batchSize?: number;
|
|
629
|
+
yieldToEventLoop?: () => Promise<void>;
|
|
630
|
+
onStateChange?: (state: TelegramUpdateWorkerStateSnapshot) => void;
|
|
631
|
+
/** One nonblocking hint after a quiescent validated startup projection, never execution or deletion authority. */
|
|
632
|
+
onHeldSourcesPrepared?: (input: TelegramHeldSourcePreparation<TContext>) => Promise<void> | void;
|
|
633
|
+
/** Prepared readiness barrier after durable queue admission; never authorizes replay or source removal. */
|
|
634
|
+
beforeQueueReceiptPublished?: (receipt: TelegramQueueAdmissionReceiptLike, queueOwner: TelegramUpdateJournalQueueOwner, ctx: TContext, isCurrent: () => boolean) => Promise<void | readonly TelegramQueueSourceCompletion[]> | void | readonly TelegramQueueSourceCompletion[];
|
|
635
|
+
/** Post-ACK hint only; it must not request Pi dispatch or inherit a Workspace admission lease. */
|
|
636
|
+
onQueueReceiptCompleted?: (receipt: TelegramQueueAdmissionReceiptLike, ctx: TContext) => void;
|
|
637
|
+
onQueueReceiptCommitted?: (receipt: TelegramQueueAdmissionReceiptLike, ctx: TContext) => void;
|
|
638
|
+
onUpdateCompleted?: (updateId: number, ctx: TContext, journalBindingKey?: string) => void;
|
|
639
|
+
recordRuntimeEvent?: (category: string, error: unknown, details?: Record<string, unknown>) => void;
|
|
640
|
+
}
|
|
641
|
+
export type TelegramQueueReceiptCompletionReason = "prompt-handoff" | "control-settlement" | "discard";
|
|
642
|
+
/** Read-only singleton hold projection; only the exact warm post-release admission carrier may supply completion. */
|
|
643
|
+
export interface TelegramLiveSourceCompletionReadiness {
|
|
644
|
+
readonly snapshot: TelegramDeferredSourceSnapshot;
|
|
645
|
+
/** Captured issuing owner/ports only; not a source disposition or canonical-release grant. */
|
|
646
|
+
isCurrent(): boolean;
|
|
647
|
+
bindCarrier(value: unknown): TelegramDeferredSourceCompletionPreparation | undefined;
|
|
648
|
+
}
|
|
649
|
+
/** Process-local gate for fresh recipient input; never durable replay/custody or a binding grant. */
|
|
650
|
+
export interface TelegramLiveInputPreparation {
|
|
651
|
+
readonly sourceUpdateIds: readonly number[];
|
|
652
|
+
/** Authority-only observation: no nested journal transaction under a Workspace snapshot. */
|
|
653
|
+
isCurrent(): boolean;
|
|
654
|
+
/** Same captured worker/source lifetime, including a finished warm preparation. */
|
|
655
|
+
isOwnerCurrent(): boolean;
|
|
656
|
+
confirmSaved(): boolean;
|
|
657
|
+
/** Read/copy completion-owner availability after save, without claiming/admitting/dispatching the held input. */
|
|
658
|
+
prepareSourceCompletion?(): TelegramLiveSourceCompletionReadiness | undefined;
|
|
659
|
+
/** Captures one same-source status continuation without activating future recipient authority. */
|
|
660
|
+
prepareStatusConsumption?(input: TelegramLiveStatusConsumption): boolean;
|
|
661
|
+
/** Native owner availability before recipient append; not admission or future target activation. */
|
|
662
|
+
canPrepareStatusConsumption?(): boolean;
|
|
663
|
+
release(canRelease: () => boolean): boolean;
|
|
664
|
+
/** Ends a failed pre-append attempt only when no selected input was saved. */
|
|
665
|
+
cancelEmpty(): boolean;
|
|
666
|
+
/** One fenced removal of this never-dispatched recipient copy; unknown issuance cannot be retried. */
|
|
667
|
+
discardSaved(canDiscard: () => boolean): "discarded" | "protected" | "unknown";
|
|
668
|
+
}
|
|
669
|
+
/** Routing owns continuation or positively released peer transfer; preparation never appends or reexecutes originals. */
|
|
670
|
+
export interface TelegramLiveDeferredInputPreparation extends Pick<TelegramLiveInputPreparation, "sourceUpdateIds" | "isCurrent" | "isOwnerCurrent" | "confirmSaved"> {
|
|
671
|
+
beginRelease(canRelease: () => boolean): boolean;
|
|
672
|
+
/** One exact donor-group removal after routing confirms peer release; unknown issuance never retries. */
|
|
673
|
+
settleTransferred(canSettle: () => boolean): "settled" | "protected" | "unknown";
|
|
674
|
+
cancel(): boolean;
|
|
675
|
+
}
|
|
676
|
+
export interface TelegramDeferredSourceCompletionPreparation {
|
|
677
|
+
readonly source: TelegramDeferredSourceEvidence;
|
|
678
|
+
/** Issuer lifetime remains observable after reporting/removal; never a settled/source-absence inference. */
|
|
679
|
+
isCurrent(): boolean;
|
|
680
|
+
/** One exact report after required command semantics; true is report acceptance, not a removal ACK. */
|
|
681
|
+
reportCompleted(): boolean;
|
|
682
|
+
/** Existing warm worker ACK only, read-only and without journal I/O or another report/removal. */
|
|
683
|
+
inspectCompletion(): TelegramDeferredSourceEvidence | undefined;
|
|
684
|
+
}
|
|
685
|
+
export interface TelegramDeferredQueueAdmissionPreparation {
|
|
686
|
+
/** Worker/session/journal/acquiring-owner lifetime, independent of the source's later queued report. */
|
|
687
|
+
isCurrent(): boolean;
|
|
688
|
+
/** Only the existing warm committed receipt owner can certify the same original; absence never permits replay. */
|
|
689
|
+
inspectReceipt(receipt: TelegramQueueAdmissionReceiptLike): {
|
|
690
|
+
source: TelegramDeferredSourceEvidence;
|
|
691
|
+
receipt: TelegramUpdateJournalQueuedCompletion;
|
|
692
|
+
} | undefined;
|
|
693
|
+
/** Read-only original/queued-owner CAS scope for the existing pre-publication boundary; never readiness or disposal. */
|
|
694
|
+
prepareCompletionScope(receipt: TelegramQueueAdmissionReceiptLike, queueOwner: TelegramUpdateJournalQueueOwner, completionSha256: string): TelegramQueueSourceCompletion | undefined;
|
|
695
|
+
/** Exact previously observed receipt object's native whole-removal ACK; never admission, absence or another disposal. */
|
|
696
|
+
inspectCompletion(receipt: TelegramQueueAdmissionReceiptLike): TelegramDeferredSourceEvidence | undefined;
|
|
697
|
+
}
|
|
698
|
+
export interface TelegramUpdateWorkerRuntime<TContext> {
|
|
699
|
+
start: (ctx: TContext) => void;
|
|
700
|
+
/** Reserve absent IDs before recipient append; existing leader deferred sources use their original carrier. */
|
|
701
|
+
prepareLiveInput?: (ctx: TContext, sourceUpdateIds: readonly number[], isCurrent?: () => boolean) => TelegramLiveInputPreparation | undefined;
|
|
702
|
+
prepareDeferredLiveInput?: (input: {
|
|
703
|
+
updateId: number;
|
|
704
|
+
sourceUpdateIds: readonly number[];
|
|
705
|
+
signal: AbortSignal;
|
|
706
|
+
isCurrent(): boolean;
|
|
707
|
+
}) => TelegramLiveDeferredInputPreparation | undefined;
|
|
708
|
+
prepareDeferredQueueAdmission?: (input: {
|
|
709
|
+
updateId: number;
|
|
710
|
+
signal: AbortSignal;
|
|
711
|
+
}) => TelegramDeferredQueueAdmissionPreparation | undefined;
|
|
712
|
+
prepareDeferredSourceCompletion?: (input: {
|
|
713
|
+
updateId: number;
|
|
714
|
+
signal: AbortSignal;
|
|
715
|
+
}) => Pick<TelegramDeferredSourceCompletionPreparation, "source" | "isCurrent"> | undefined;
|
|
716
|
+
signal: () => void;
|
|
717
|
+
settleDeferred: (input: {
|
|
718
|
+
updateId: number;
|
|
719
|
+
outcome: TelegramUpdateAdmissionOutcome;
|
|
720
|
+
signal: AbortSignal;
|
|
721
|
+
}) => void | TelegramDeferredSourceCompletion | Promise<void | TelegramDeferredSourceCompletion>;
|
|
722
|
+
armRoutingInput?: (input: {
|
|
723
|
+
updateId: number;
|
|
724
|
+
signal: AbortSignal;
|
|
725
|
+
operatorUserId: number;
|
|
726
|
+
sourceUpdateIds: readonly number[];
|
|
727
|
+
chooser?: TelegramUpdateJournalRoutingChooser;
|
|
728
|
+
}) => TelegramUpdateJournalRoutingInput | undefined;
|
|
729
|
+
selectRoutingInput?: (input: {
|
|
730
|
+
updateId: number;
|
|
731
|
+
signal: AbortSignal;
|
|
732
|
+
operatorUserId: number;
|
|
733
|
+
sourceUpdateIds: readonly number[];
|
|
734
|
+
}) => boolean;
|
|
735
|
+
isRoutingInputCurrent?: (input: {
|
|
736
|
+
updateId: number;
|
|
737
|
+
signal: AbortSignal;
|
|
738
|
+
}) => boolean;
|
|
739
|
+
getRoutingInput?: (input: {
|
|
740
|
+
updateId: number;
|
|
741
|
+
signal: AbortSignal;
|
|
742
|
+
}) => TelegramUpdateJournalRoutingInput | undefined;
|
|
743
|
+
supportsDeferredAbandonment?: (input: {
|
|
744
|
+
updateId: number;
|
|
745
|
+
signal: AbortSignal;
|
|
746
|
+
journalBindingKey: string;
|
|
747
|
+
}) => boolean;
|
|
748
|
+
inspectAbandoning?: (input: TelegramDeferredAbandonmentRecoveryRequest & {
|
|
749
|
+
signal: AbortSignal;
|
|
750
|
+
}) => TelegramDeferredAbandonmentRecoveryPage | undefined;
|
|
751
|
+
inspectHistorical?: (input: TelegramDeferredAbandonmentRecoveryRequest & {
|
|
752
|
+
signal: AbortSignal;
|
|
753
|
+
}) => TelegramDeferredAbandonmentRecoveryPage | undefined;
|
|
754
|
+
inspectDeferredSource?: (input: {
|
|
755
|
+
updateId: number;
|
|
756
|
+
signal: AbortSignal;
|
|
757
|
+
}) => TelegramDeferredSourceEvidence | undefined;
|
|
758
|
+
inspectDeferredSourceSnapshot?: (input: {
|
|
759
|
+
updateId: number;
|
|
760
|
+
signal: AbortSignal;
|
|
761
|
+
}) => TelegramDeferredSourceSnapshot | undefined;
|
|
762
|
+
isHistoricalSource?: (input: {
|
|
763
|
+
updateId: number;
|
|
764
|
+
signal: AbortSignal;
|
|
765
|
+
matchesOriginal?: TelegramHistoricalInputPredicate;
|
|
766
|
+
}) => boolean;
|
|
767
|
+
abandonDeferred?: (input: TelegramDeferredUpdateAbandonmentAuthority & {
|
|
768
|
+
updateId: number;
|
|
769
|
+
signal: AbortSignal;
|
|
770
|
+
}) => TelegramUpdateJournalPendingAbandonmentResult | undefined;
|
|
771
|
+
settleCustodied: (input: {
|
|
772
|
+
updateId: number;
|
|
773
|
+
result: TelegramCustodiedExecutionResult;
|
|
774
|
+
signal: AbortSignal;
|
|
775
|
+
}) => void;
|
|
776
|
+
isQueueReceiptCommitted: (receipt: TelegramQueueAdmissionReceiptLike) => boolean;
|
|
777
|
+
getQueueReceiptOwner: (receipt: TelegramQueueAdmissionReceiptLike) => TelegramUpdateJournalQueueOwner | undefined;
|
|
778
|
+
/** Completion-only owner observation; issued attempts are never dispatch readiness. */
|
|
779
|
+
getQueueReceiptSettlementOwner?: (receipt: TelegramQueueAdmissionReceiptLike, ctx: TContext, reason: TelegramQueueReceiptCompletionReason) => TelegramUpdateJournalQueueOwner | undefined;
|
|
780
|
+
completeQueueReceipts: (input: {
|
|
781
|
+
receipts: readonly TelegramQueueAdmissionReceiptLike[];
|
|
782
|
+
ctx: TContext;
|
|
783
|
+
reason: TelegramQueueReceiptCompletionReason;
|
|
784
|
+
/** Prepared immutable scopes for every source; the exact receipt owner still authorizes disposal. */
|
|
785
|
+
sourceCompletions?: readonly TelegramQueueSourceCompletion[];
|
|
786
|
+
}) => boolean;
|
|
787
|
+
stop: () => Promise<void>;
|
|
788
|
+
waitForDrain: () => Promise<void>;
|
|
789
|
+
getState: () => TelegramUpdateWorkerStateSnapshot;
|
|
790
|
+
}
|
|
791
|
+
export interface TelegramLiveStatusConsumption {
|
|
792
|
+
readonly source: TelegramDeferredSourceEvidence;
|
|
793
|
+
assertCurrent(): void;
|
|
794
|
+
bindCarrier(value: unknown): boolean;
|
|
795
|
+
execute(): Promise<boolean>;
|
|
796
|
+
}
|
|
797
|
+
export type TelegramHistoricalReviewVerdict = boolean | "retain" | "revive";
|
|
798
|
+
/** A saved chooser clock that proves an untouched, unexpired choice whose chooser message can be revived. */
|
|
799
|
+
export declare function isRevivableTelegramRoutingInput(entry: Pick<TelegramUpdateJournalEntry, "state" | "routingInput">, nowMs: number): boolean;
|
|
800
|
+
export declare function createTelegramUpdateWorkerRuntime<TContext>(deps: TelegramUpdateWorkerRuntimeDeps<TContext>): TelegramUpdateWorkerRuntime<TContext>;
|
|
801
|
+
/**
|
|
802
|
+
* Verdict returned by a public Telegram update handler.
|
|
803
|
+
*
|
|
804
|
+
* - `"consume"` — the handler processed this update; pi-telegram skips default routing.
|
|
805
|
+
* - `"pass"` (or `void`/`undefined`) — pi-telegram routes the update normally.
|
|
806
|
+
*/
|
|
807
|
+
export type TelegramUpdateHandlerVerdict = "consume" | "pass";
|
|
808
|
+
export interface TelegramUpdateExecutionFence {
|
|
809
|
+
readonly generation: number;
|
|
810
|
+
readonly updateId: number;
|
|
811
|
+
readonly signal: AbortSignal;
|
|
812
|
+
isCurrent: () => boolean;
|
|
813
|
+
assertCurrent: () => void;
|
|
814
|
+
}
|
|
815
|
+
export declare function getTelegramUpdateExecutionFence(update: unknown): TelegramUpdateExecutionFence | undefined;
|
|
816
|
+
export declare function assertTelegramUpdateExecutionCurrent(update: unknown): void;
|
|
817
|
+
export declare function createTelegramUpdateExecutionFenceGuard(update: unknown): () => void;
|
|
818
|
+
export declare function carryTelegramUpdateExecutionFence<TTarget extends object>(source: unknown, target: TTarget): TTarget;
|
|
819
|
+
export type TelegramUpdateHandler = (update: unknown, execution?: TelegramUpdateExecutionFence) => TelegramUpdateHandlerVerdict | void | Promise<TelegramUpdateHandlerVerdict | void>;
|
|
820
|
+
export interface TelegramUpdateHandlerRegistry {
|
|
821
|
+
/** Schema version of this registry shape. */
|
|
822
|
+
readonly version: 1;
|
|
823
|
+
/**
|
|
824
|
+
* Register an update handler. Returns a disposer that removes it.
|
|
825
|
+
*
|
|
826
|
+
* Handlers are invoked in registration order on every Telegram update,
|
|
827
|
+
* before pi-telegram's own routing. The first handler that returns
|
|
828
|
+
* `"consume"` wins and stops the chain for that update.
|
|
829
|
+
*/
|
|
830
|
+
add: (handler: TelegramUpdateHandler) => () => void;
|
|
831
|
+
/**
|
|
832
|
+
* Run all registered handlers against an update.
|
|
833
|
+
*
|
|
834
|
+
* Used by pi-telegram's polling runtime; extension consumers should call
|
|
835
|
+
* {@link registerTelegramUpdateHandler} or `add` instead of dispatching directly.
|
|
836
|
+
*/
|
|
837
|
+
dispatch: (update: unknown, execution?: TelegramUpdateExecutionFence) => Promise<TelegramUpdateHandlerVerdict>;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Called by pi-telegram's own runtime to obtain the registry it dispatches
|
|
841
|
+
* through. Extension consumers should not call this; use
|
|
842
|
+
* {@link registerTelegramUpdateHandler} instead.
|
|
843
|
+
*/
|
|
844
|
+
export declare function getTelegramUpdateHandlerRegistry(): TelegramUpdateHandlerRegistry;
|
|
845
|
+
export interface TelegramUpdateAdmissionHandleDeps<TUpdate extends TelegramUpdateFlow & {
|
|
846
|
+
update_id: number;
|
|
847
|
+
}, TContext> {
|
|
848
|
+
defaultHandle: (update: TUpdate, ctx: TContext, execution?: TelegramUpdateExecutionFence) => Promise<void>;
|
|
849
|
+
registry?: TelegramUpdateHandlerRegistry;
|
|
850
|
+
onLateOutcome?: (outcome: TelegramUpdateAdmissionOutcome, details: {
|
|
851
|
+
updateId: number;
|
|
852
|
+
ctx: TContext;
|
|
853
|
+
signal: AbortSignal;
|
|
854
|
+
}) => void | TelegramDeferredSourceCompletion | Promise<void | TelegramDeferredSourceCompletion>;
|
|
855
|
+
onLateOutcomeError?: (error: unknown, updateId: number) => void;
|
|
856
|
+
abandonDeferred?: TelegramUpdateWorkerRuntime<TContext>["abandonDeferred"];
|
|
857
|
+
armRoutingInput?: TelegramUpdateWorkerRuntime<TContext>["armRoutingInput"];
|
|
858
|
+
selectRoutingInput?: TelegramUpdateWorkerRuntime<TContext>["selectRoutingInput"];
|
|
859
|
+
isRoutingInputCurrent?: TelegramUpdateWorkerRuntime<TContext>["isRoutingInputCurrent"];
|
|
860
|
+
getRoutingInput?: TelegramUpdateWorkerRuntime<TContext>["getRoutingInput"];
|
|
861
|
+
supportsDeferredAbandonment?: TelegramUpdateWorkerRuntime<TContext>["supportsDeferredAbandonment"];
|
|
862
|
+
inspectAbandoning?: TelegramUpdateWorkerRuntime<TContext>["inspectAbandoning"];
|
|
863
|
+
inspectHistorical?: TelegramUpdateWorkerRuntime<TContext>["inspectHistorical"];
|
|
864
|
+
inspectDeferredSource?: TelegramUpdateWorkerRuntime<TContext>["inspectDeferredSource"];
|
|
865
|
+
inspectDeferredSourceSnapshot?: TelegramUpdateWorkerRuntime<TContext>["inspectDeferredSourceSnapshot"];
|
|
866
|
+
prepareDeferredLiveInput?: TelegramUpdateWorkerRuntime<TContext>["prepareDeferredLiveInput"];
|
|
867
|
+
prepareDeferredQueueAdmission?: TelegramUpdateWorkerRuntime<TContext>["prepareDeferredQueueAdmission"];
|
|
868
|
+
prepareDeferredSourceCompletion?: TelegramUpdateWorkerRuntime<TContext>["prepareDeferredSourceCompletion"];
|
|
869
|
+
isHistoricalSource?: TelegramUpdateWorkerRuntime<TContext>["isHistoricalSource"];
|
|
870
|
+
}
|
|
871
|
+
export type TelegramCustodiedExecutionResult = {
|
|
872
|
+
status: "completed";
|
|
873
|
+
} | {
|
|
874
|
+
status: "deferred";
|
|
875
|
+
receipt: TelegramInputJournalReceipt;
|
|
876
|
+
} | {
|
|
877
|
+
status: "queued";
|
|
878
|
+
queueReceipt: ReturnType<TelegramInputJournalStore["queueInputs"]>["queueReceipt"];
|
|
879
|
+
} | {
|
|
880
|
+
status: "outcome-unknown";
|
|
881
|
+
receipt: TelegramInputJournalReceipt;
|
|
882
|
+
};
|
|
883
|
+
type TelegramCustodyExecutionJournal = Pick<TelegramInputJournalStore, "acquireInput" | "startInput" | "completeInput" | "queueInputs">;
|
|
884
|
+
export declare function createTelegramInputCustodyWorkerJournalPort(store: TelegramInputJournalStore): TelegramUpdateWorkerJournalPort & {
|
|
885
|
+
inputCustody: TelegramCustodyExecutionJournal;
|
|
886
|
+
};
|
|
887
|
+
export declare function createTelegramInputCustodyLegacyDispositionRuntime(deps: {
|
|
888
|
+
withBindingReference<T>(recoveryKey: string, operation: (binding: {
|
|
889
|
+
recoveryKey: string;
|
|
890
|
+
journal: Pick<TelegramInputJournalStore, "listLegacyCustodyCandidates" | "applyLegacyCustodyDisposition">;
|
|
891
|
+
}) => T): T;
|
|
892
|
+
}): {
|
|
893
|
+
list(recoveryKey: string): import("./journal.ts").TelegramUpdateJournalLegacyCustodyCandidate[];
|
|
894
|
+
apply(recoveryKey: string, authority: Parameters<TelegramInputJournalStore["applyLegacyCustodyDisposition"]>[0]): import("./journal.ts").TelegramUpdateJournalLegacyCustodyDispositionResult;
|
|
895
|
+
};
|
|
896
|
+
export declare function createTelegramInputCustodyHandoffClient(deps: {
|
|
897
|
+
journal: Pick<TelegramInputJournalStore, "offerInputHandoff">;
|
|
898
|
+
resolveAcceptedReference?: (input: {
|
|
899
|
+
sourceUpdateId: number;
|
|
900
|
+
recipientBindingKey: string;
|
|
901
|
+
}) => {
|
|
902
|
+
sourceRecoveryKey: string;
|
|
903
|
+
source: {
|
|
904
|
+
updateId: number;
|
|
905
|
+
owner: {
|
|
906
|
+
acquisitionId: string;
|
|
907
|
+
handoffId: string;
|
|
908
|
+
};
|
|
909
|
+
};
|
|
910
|
+
} | undefined;
|
|
911
|
+
sendEnvelope(envelope: Extract<TelegramBusEnvelope, {
|
|
912
|
+
kind: "leader.offerInputCustodyHandoff";
|
|
913
|
+
}>): Promise<TelegramBusEnvelope | undefined>;
|
|
914
|
+
}): {
|
|
915
|
+
transfer(input: {
|
|
916
|
+
requestId: string;
|
|
917
|
+
receipt: TelegramInputJournalReceipt;
|
|
918
|
+
recipientInstanceId: string;
|
|
919
|
+
recipientRegistrationGeneration: string;
|
|
920
|
+
recipientBindingKey: string;
|
|
921
|
+
recipientOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
922
|
+
handoffToken: string;
|
|
923
|
+
sentAtMs: number;
|
|
924
|
+
auth?: string;
|
|
925
|
+
}): Promise<{
|
|
926
|
+
sourceRecoveryKey: string;
|
|
927
|
+
source: {
|
|
928
|
+
updateId: number;
|
|
929
|
+
owner: {
|
|
930
|
+
acquisitionId: string;
|
|
931
|
+
handoffId: string;
|
|
932
|
+
};
|
|
933
|
+
};
|
|
934
|
+
duplicate: boolean;
|
|
935
|
+
}>;
|
|
936
|
+
};
|
|
937
|
+
export interface TelegramInputCustodyHandoffAcceptanceInput {
|
|
938
|
+
sourceRecoveryKey: string;
|
|
939
|
+
recipientBindingKey: string;
|
|
940
|
+
source: TelegramInputJournalSourceReference;
|
|
941
|
+
handoffId: string;
|
|
942
|
+
}
|
|
943
|
+
export declare function createTelegramInputCustodyHandoffAcceptanceRuntime<TContext>(deps: {
|
|
944
|
+
resolveBinding(recoveryKey: string): {
|
|
945
|
+
recoveryKey: string;
|
|
946
|
+
recipientBindingKey: string;
|
|
947
|
+
recipientOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
948
|
+
journal: Pick<TelegramInputJournalStore, "acceptInputHandoff">;
|
|
949
|
+
signalWorker(ctx: TContext): void;
|
|
950
|
+
} | undefined;
|
|
951
|
+
}): {
|
|
952
|
+
accept(input: TelegramInputCustodyHandoffAcceptanceInput, ctx: TContext): {
|
|
953
|
+
sourceRecoveryKey: string;
|
|
954
|
+
source: {
|
|
955
|
+
updateId: number;
|
|
956
|
+
owner: {
|
|
957
|
+
acquisitionId: string;
|
|
958
|
+
handoffId: string;
|
|
959
|
+
};
|
|
960
|
+
};
|
|
961
|
+
duplicate: boolean;
|
|
962
|
+
};
|
|
963
|
+
};
|
|
964
|
+
export declare function createTelegramInputCustodyForwardReferenceResolver(deps: {
|
|
965
|
+
recoveryKey: string;
|
|
966
|
+
recipientBindingKey: string;
|
|
967
|
+
recipientOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
968
|
+
journal: Pick<TelegramInputJournalStore, "read">;
|
|
969
|
+
}): (input: {
|
|
970
|
+
sourceUpdateId: number;
|
|
971
|
+
recipientBindingKey: string;
|
|
972
|
+
}) => {
|
|
973
|
+
sourceRecoveryKey: string;
|
|
974
|
+
source: {
|
|
975
|
+
updateId: number;
|
|
976
|
+
owner: {
|
|
977
|
+
acquisitionId: string;
|
|
978
|
+
handoffId: string;
|
|
979
|
+
};
|
|
980
|
+
};
|
|
981
|
+
} | undefined;
|
|
982
|
+
export interface TelegramCustodiedSourceReferenceWakeInput {
|
|
983
|
+
deliveryId: string;
|
|
984
|
+
sourceUpdateId: number;
|
|
985
|
+
recipientBindingKey: string;
|
|
986
|
+
sourceRecoveryKey: string;
|
|
987
|
+
sourceClaim: {
|
|
988
|
+
acquisitionId: string;
|
|
989
|
+
handoffId: string;
|
|
990
|
+
};
|
|
991
|
+
}
|
|
992
|
+
export declare function createTelegramInputCustodySourceReferenceWakeRuntime<TContext>(deps: {
|
|
993
|
+
resolveBinding(recoveryKey: string): {
|
|
994
|
+
recoveryKey: string;
|
|
995
|
+
recipientBindingKey: string;
|
|
996
|
+
recipientOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
997
|
+
journal: Pick<TelegramInputJournalStore, "read">;
|
|
998
|
+
signalWorker(ctx: TContext): void;
|
|
999
|
+
} | undefined;
|
|
1000
|
+
}): {
|
|
1001
|
+
wakeSource(input: TelegramCustodiedSourceReferenceWakeInput, ctx: TContext): void;
|
|
1002
|
+
};
|
|
1003
|
+
export interface TelegramInputCustodyBusBindingRuntime<TContext> {
|
|
1004
|
+
acceptHandoff(input: TelegramInputCustodyHandoffAcceptanceInput, ctx: TContext): {
|
|
1005
|
+
sourceRecoveryKey: string;
|
|
1006
|
+
source: {
|
|
1007
|
+
updateId: number;
|
|
1008
|
+
owner: {
|
|
1009
|
+
acquisitionId: string;
|
|
1010
|
+
handoffId: string;
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
duplicate: boolean;
|
|
1014
|
+
};
|
|
1015
|
+
wakeSource(input: TelegramCustodiedSourceReferenceWakeInput, ctx: TContext): void;
|
|
1016
|
+
resolveForwardReference(input: {
|
|
1017
|
+
sourceUpdateId: number;
|
|
1018
|
+
recipientBindingKey: string;
|
|
1019
|
+
}): {
|
|
1020
|
+
sourceRecoveryKey: string;
|
|
1021
|
+
source: {
|
|
1022
|
+
updateId: number;
|
|
1023
|
+
owner: {
|
|
1024
|
+
acquisitionId: string;
|
|
1025
|
+
handoffId: string;
|
|
1026
|
+
};
|
|
1027
|
+
};
|
|
1028
|
+
} | undefined;
|
|
1029
|
+
}
|
|
1030
|
+
export declare function createTelegramInputCustodyBusBindingRuntime<TContext>(deps: {
|
|
1031
|
+
getForwardRecoveryKey(): string | undefined;
|
|
1032
|
+
resolveBinding(recoveryKey: string): {
|
|
1033
|
+
recoveryKey: string;
|
|
1034
|
+
recipientBindingKey: string;
|
|
1035
|
+
recipientOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
1036
|
+
journal: Pick<TelegramInputJournalStore, "read" | "acceptInputHandoff">;
|
|
1037
|
+
signalWorker(ctx: TContext): void;
|
|
1038
|
+
} | undefined;
|
|
1039
|
+
}): TelegramInputCustodyBusBindingRuntime<TContext>;
|
|
1040
|
+
export type TelegramInputCustodyActivationBlocker = "disabled" | "source-unready" | "legacy-writers-present" | "migration-incomplete" | "peer-capability-mismatch";
|
|
1041
|
+
export declare function evaluateTelegramInputCustodyActivationReadiness(input: {
|
|
1042
|
+
requested: boolean;
|
|
1043
|
+
sourceStatus: "absent" | "v3" | "legacy" | "unsupported" | "ambiguous";
|
|
1044
|
+
legacyWritersExcluded: boolean;
|
|
1045
|
+
historicalMigrationComplete: boolean;
|
|
1046
|
+
peerReadiness: readonly ("ready" | "legacy" | "unknown")[];
|
|
1047
|
+
}): {
|
|
1048
|
+
enabled: true;
|
|
1049
|
+
} | {
|
|
1050
|
+
enabled: false;
|
|
1051
|
+
blocker: TelegramInputCustodyActivationBlocker;
|
|
1052
|
+
};
|
|
1053
|
+
export interface TelegramInputCustodyReadinessEvidenceSnapshot {
|
|
1054
|
+
version: 1;
|
|
1055
|
+
revision: number;
|
|
1056
|
+
writerExclusion?: TelegramInputCustodyWriterExclusionEvidence;
|
|
1057
|
+
migration?: TelegramInputCustodyMigrationEvidence;
|
|
1058
|
+
startupExclusion?: TelegramInputCustodyStartupExclusionAuthority;
|
|
1059
|
+
migrationCompletion?: TelegramInputCustodyMigrationCompletionAuthority;
|
|
1060
|
+
}
|
|
1061
|
+
export declare function createTelegramInputCustodyReadinessEvidenceStore(deps: {
|
|
1062
|
+
readRetained(): string | undefined;
|
|
1063
|
+
publishRetained(serialized: string): void;
|
|
1064
|
+
withSerialization<T>(operation: () => T): T;
|
|
1065
|
+
authorizePublication(kind: "writer-exclusion" | "migration" | "startup-exclusion" | "migration-completion", evidence: TelegramInputCustodyWriterExclusionEvidence | TelegramInputCustodyMigrationEvidence | TelegramInputCustodyStartupExclusionAuthority | TelegramInputCustodyMigrationCompletionAuthority): boolean;
|
|
1066
|
+
}): {
|
|
1067
|
+
read: () => TelegramInputCustodyReadinessEvidenceSnapshot;
|
|
1068
|
+
publish: (input: {
|
|
1069
|
+
expectedRevision: number;
|
|
1070
|
+
} & ({
|
|
1071
|
+
kind: "writer-exclusion";
|
|
1072
|
+
evidence: TelegramInputCustodyWriterExclusionEvidence;
|
|
1073
|
+
} | {
|
|
1074
|
+
kind: "migration";
|
|
1075
|
+
evidence: TelegramInputCustodyMigrationEvidence;
|
|
1076
|
+
} | {
|
|
1077
|
+
kind: "startup-exclusion";
|
|
1078
|
+
evidence: TelegramInputCustodyStartupExclusionAuthority;
|
|
1079
|
+
} | {
|
|
1080
|
+
kind: "migration-completion";
|
|
1081
|
+
evidence: TelegramInputCustodyMigrationCompletionAuthority;
|
|
1082
|
+
})) => TelegramInputCustodyReadinessEvidenceSnapshot;
|
|
1083
|
+
};
|
|
1084
|
+
export interface TelegramInputCustodyActivationEvidenceIdentity {
|
|
1085
|
+
profileKey: string;
|
|
1086
|
+
recoveryKey: string;
|
|
1087
|
+
}
|
|
1088
|
+
export interface TelegramInputCustodyStartupExclusionAuthority extends TelegramInputCustodyActivationEvidenceIdentity {
|
|
1089
|
+
version: 1;
|
|
1090
|
+
status: "enforced" | "revoked";
|
|
1091
|
+
authorityId: string;
|
|
1092
|
+
closureOperationId: string;
|
|
1093
|
+
writerInventorySha256: string;
|
|
1094
|
+
allowedWriterProtocol: "custody-v3";
|
|
1095
|
+
authorizedAtMs: number;
|
|
1096
|
+
}
|
|
1097
|
+
export declare function normalizeTelegramInputCustodyStartupExclusionAuthority(value: unknown, expected: TelegramInputCustodyActivationEvidenceIdentity): TelegramInputCustodyStartupExclusionAuthority | undefined;
|
|
1098
|
+
export interface TelegramInputCustodyWriterExclusionEvidence extends TelegramInputCustodyActivationEvidenceIdentity {
|
|
1099
|
+
version: 1;
|
|
1100
|
+
status: "excluded" | "present" | "unknown";
|
|
1101
|
+
startupAuthorityId?: string;
|
|
1102
|
+
closureOperationId?: string;
|
|
1103
|
+
writerInventorySha256?: string;
|
|
1104
|
+
}
|
|
1105
|
+
export interface TelegramInputCustodyWriterInventory extends TelegramInputCustodyActivationEvidenceIdentity {
|
|
1106
|
+
complete: boolean;
|
|
1107
|
+
writerInventorySha256: string;
|
|
1108
|
+
writers: readonly {
|
|
1109
|
+
processId: number;
|
|
1110
|
+
processBirthId: string;
|
|
1111
|
+
}[];
|
|
1112
|
+
}
|
|
1113
|
+
export declare function evaluateTelegramInputCustodyWriterExclusionEvidence(input: {
|
|
1114
|
+
expected: TelegramInputCustodyActivationEvidenceIdentity;
|
|
1115
|
+
inventory: TelegramInputCustodyWriterInventory;
|
|
1116
|
+
startupAuthority: TelegramInputCustodyStartupExclusionAuthority | undefined;
|
|
1117
|
+
getProcessLiveness(writer: {
|
|
1118
|
+
processId: number;
|
|
1119
|
+
processBirthId: string;
|
|
1120
|
+
}): TelegramProcessLiveness;
|
|
1121
|
+
}): TelegramInputCustodyWriterExclusionEvidence;
|
|
1122
|
+
export interface TelegramInputCustodyMigrationCompletionAuthority extends TelegramInputCustodyActivationEvidenceIdentity {
|
|
1123
|
+
version: 1;
|
|
1124
|
+
status: "authorized" | "revoked";
|
|
1125
|
+
authorityId: string;
|
|
1126
|
+
startupAuthorityId: string;
|
|
1127
|
+
closureOperationId: string;
|
|
1128
|
+
migrationInventorySha256: string;
|
|
1129
|
+
resultingSourceFamily: "absent" | "v3";
|
|
1130
|
+
authorizedAtMs: number;
|
|
1131
|
+
}
|
|
1132
|
+
export declare function normalizeTelegramInputCustodyMigrationCompletionAuthority(value: unknown, expected: TelegramInputCustodyActivationEvidenceIdentity): TelegramInputCustodyMigrationCompletionAuthority | undefined;
|
|
1133
|
+
export interface TelegramInputCustodyMigrationEvidence extends TelegramInputCustodyActivationEvidenceIdentity {
|
|
1134
|
+
version: 1;
|
|
1135
|
+
status: "complete" | "incomplete" | "unknown";
|
|
1136
|
+
migrationAuthorityId?: string;
|
|
1137
|
+
startupAuthorityId?: string;
|
|
1138
|
+
closureOperationId?: string;
|
|
1139
|
+
migrationInventorySha256?: string;
|
|
1140
|
+
resultingSourceFamily?: "absent" | "v3";
|
|
1141
|
+
}
|
|
1142
|
+
export type TelegramInputCustodyWriterCutoverResult<TMode> = {
|
|
1143
|
+
kind: "blocked";
|
|
1144
|
+
blocker: "startup-authority" | "writer-inventory";
|
|
1145
|
+
evidence?: TelegramInputCustodyWriterExclusionEvidence;
|
|
1146
|
+
} | {
|
|
1147
|
+
kind: "completed";
|
|
1148
|
+
mode: TMode;
|
|
1149
|
+
evidence: TelegramInputCustodyWriterExclusionEvidence;
|
|
1150
|
+
resumed: boolean;
|
|
1151
|
+
};
|
|
1152
|
+
export declare function executeTelegramInputCustodyWriterCutover<TClosure extends {
|
|
1153
|
+
operationId: string;
|
|
1154
|
+
profileKey: string;
|
|
1155
|
+
recoveryKey: string;
|
|
1156
|
+
}, TMode extends TelegramInputCustodyWriterProtocolModeEvidence>(input: {
|
|
1157
|
+
expected: TelegramInputCustodyActivationEvidenceIdentity;
|
|
1158
|
+
closure: TClosure;
|
|
1159
|
+
startupAuthority: TelegramInputCustodyStartupExclusionAuthority;
|
|
1160
|
+
inventory: TelegramInputCustodyWriterInventory;
|
|
1161
|
+
getProcessLiveness(writer: {
|
|
1162
|
+
processId: number;
|
|
1163
|
+
processBirthId: string;
|
|
1164
|
+
}): TelegramProcessLiveness;
|
|
1165
|
+
installProtocolMode(closure: TClosure, authority: {
|
|
1166
|
+
startupAuthorityId: string;
|
|
1167
|
+
writerInventorySha256: string;
|
|
1168
|
+
}): {
|
|
1169
|
+
mode: TMode;
|
|
1170
|
+
resumed: boolean;
|
|
1171
|
+
};
|
|
1172
|
+
evidenceStore: {
|
|
1173
|
+
read(): TelegramInputCustodyReadinessEvidenceSnapshot;
|
|
1174
|
+
publish(input: {
|
|
1175
|
+
expectedRevision: number;
|
|
1176
|
+
kind: "writer-exclusion";
|
|
1177
|
+
evidence: TelegramInputCustodyWriterExclusionEvidence;
|
|
1178
|
+
}): TelegramInputCustodyReadinessEvidenceSnapshot;
|
|
1179
|
+
};
|
|
1180
|
+
}): TelegramInputCustodyWriterCutoverResult<TMode>;
|
|
1181
|
+
export type TelegramInputCustodyMigrationCompletionResult = {
|
|
1182
|
+
kind: "blocked";
|
|
1183
|
+
blocker: "migration-authority" | "source-drift" | "inventory-drift";
|
|
1184
|
+
} | {
|
|
1185
|
+
kind: "completed";
|
|
1186
|
+
evidence: TelegramInputCustodyMigrationEvidence;
|
|
1187
|
+
resumed: boolean;
|
|
1188
|
+
};
|
|
1189
|
+
export declare function executeTelegramInputCustodyMigrationCompletion(input: {
|
|
1190
|
+
expected: TelegramInputCustodyActivationEvidenceIdentity;
|
|
1191
|
+
authority: TelegramInputCustodyMigrationCompletionAuthority;
|
|
1192
|
+
migrationInventorySha256: string;
|
|
1193
|
+
inspectSource(): "absent" | "v3" | "legacy" | "unsupported" | "ambiguous";
|
|
1194
|
+
evidenceStore: {
|
|
1195
|
+
read(): TelegramInputCustodyReadinessEvidenceSnapshot;
|
|
1196
|
+
publish(input: {
|
|
1197
|
+
expectedRevision: number;
|
|
1198
|
+
kind: "migration";
|
|
1199
|
+
evidence: TelegramInputCustodyMigrationEvidence;
|
|
1200
|
+
}): TelegramInputCustodyReadinessEvidenceSnapshot;
|
|
1201
|
+
};
|
|
1202
|
+
}): TelegramInputCustodyMigrationCompletionResult;
|
|
1203
|
+
export interface TelegramInputCustodyWriterProtocolModeEvidence extends TelegramInputCustodyActivationEvidenceIdentity {
|
|
1204
|
+
protocol: "custody-v3";
|
|
1205
|
+
startupAuthorityId: string;
|
|
1206
|
+
closureOperationId: string;
|
|
1207
|
+
writerInventorySha256: string;
|
|
1208
|
+
}
|
|
1209
|
+
export declare function createTelegramInputCustodyProvenReadinessResolver(deps: {
|
|
1210
|
+
isRequested(): boolean;
|
|
1211
|
+
expectedIdentity(): TelegramInputCustodyActivationEvidenceIdentity;
|
|
1212
|
+
inspectSource(): "absent" | "v3" | "legacy" | "unsupported" | "ambiguous";
|
|
1213
|
+
readWriterExclusionEvidence(): TelegramInputCustodyWriterExclusionEvidence | undefined;
|
|
1214
|
+
readStartupExclusionAuthority(): TelegramInputCustodyStartupExclusionAuthority | undefined;
|
|
1215
|
+
readWriterProtocolMode(): TelegramInputCustodyWriterProtocolModeEvidence | undefined;
|
|
1216
|
+
readMigrationCompletionAuthority(): TelegramInputCustodyMigrationCompletionAuthority | undefined;
|
|
1217
|
+
readMigrationEvidence(): TelegramInputCustodyMigrationEvidence | undefined;
|
|
1218
|
+
listPeerReadiness(): readonly ("ready" | "legacy" | "unknown")[];
|
|
1219
|
+
}): () => ReturnType<typeof evaluateTelegramInputCustodyActivationReadiness>;
|
|
1220
|
+
export declare function createTelegramInputCustodyActivationReadinessResolver(deps: {
|
|
1221
|
+
isRequested(): boolean;
|
|
1222
|
+
inspectSource(): "absent" | "v3" | "legacy" | "unsupported" | "ambiguous";
|
|
1223
|
+
areLegacyWritersExcluded(): boolean;
|
|
1224
|
+
isHistoricalMigrationComplete(): boolean;
|
|
1225
|
+
listPeerReadiness(): readonly ("ready" | "legacy" | "unknown")[];
|
|
1226
|
+
}): () => ReturnType<typeof evaluateTelegramInputCustodyActivationReadiness>;
|
|
1227
|
+
export declare function createTelegramInputCustodyLifecycleBindingResolver(deps: {
|
|
1228
|
+
isEnabled(): boolean;
|
|
1229
|
+
resolveInputJournal(): {
|
|
1230
|
+
runtimeKey: string;
|
|
1231
|
+
recoveryKey: string;
|
|
1232
|
+
journal: TelegramInputJournalStore;
|
|
1233
|
+
} | undefined;
|
|
1234
|
+
getRecipientBindingKey(): string | undefined;
|
|
1235
|
+
}): () => TelegramUpdateAdmissionLifecycleJournalBinding | undefined;
|
|
1236
|
+
export declare function createTelegramCustodiedExecutionSession(input: {
|
|
1237
|
+
journal: TelegramCustodyExecutionJournal;
|
|
1238
|
+
recipientBindingKey: string;
|
|
1239
|
+
}): {
|
|
1240
|
+
execute(update: TelegramJournaledUpdate, handler: (update: TelegramJournaledUpdate) => Promise<TelegramUpdateAdmissionOutcome>): Promise<TelegramCustodiedExecutionResult>;
|
|
1241
|
+
settle(updateId: number, outcome: TelegramUpdateAdmissionOutcome): Promise<TelegramCustodiedExecutionResult>;
|
|
1242
|
+
};
|
|
1243
|
+
export declare function executeTelegramCustodiedInput(input: {
|
|
1244
|
+
journal: TelegramCustodyExecutionJournal;
|
|
1245
|
+
update: TelegramJournaledUpdate;
|
|
1246
|
+
recipientBindingKey: string;
|
|
1247
|
+
execute(update: TelegramJournaledUpdate): Promise<TelegramUpdateAdmissionOutcome>;
|
|
1248
|
+
}): Promise<TelegramCustodiedExecutionResult>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Compose the stable public handler registry with source-bound semantic
|
|
1251
|
+
* admission. Production polling switches to this only with the journal worker.
|
|
1252
|
+
*/
|
|
1253
|
+
export declare function createTelegramUpdateAdmissionHandle<TUpdate extends TelegramUpdateFlow & {
|
|
1254
|
+
update_id: number;
|
|
1255
|
+
}, TContext>(deps: TelegramUpdateAdmissionHandleDeps<TUpdate, TContext>): (update: TUpdate, ctx: TContext, signal: AbortSignal) => Promise<TelegramUpdateAdmissionOutcome>;
|
|
1256
|
+
export declare function createTelegramCustodiedUpdateAdmissionHandle<TUpdate extends TelegramJournaledUpdate & TelegramUpdateFlow, TContext>(deps: Omit<TelegramUpdateAdmissionHandleDeps<TUpdate, TContext>, "onLateOutcome" | "onLateOutcomeError" | "abandonDeferred" | "armRoutingInput" | "getRoutingInput" | "selectRoutingInput" | "isRoutingInputCurrent" | "supportsDeferredAbandonment" | "inspectAbandoning" | "inspectHistorical" | "inspectDeferredSource" | "inspectDeferredSourceSnapshot" | "prepareDeferredLiveInput" | "prepareDeferredQueueAdmission" | "prepareDeferredSourceCompletion" | "isHistoricalSource"> & {
|
|
1257
|
+
journal: TelegramCustodyExecutionJournal;
|
|
1258
|
+
recipientBindingKey: string;
|
|
1259
|
+
onLateOutcomeError(error: unknown, updateId: number): void;
|
|
1260
|
+
onCustodiedLateSettlement?: (result: TelegramCustodiedExecutionResult, details: {
|
|
1261
|
+
updateId: number;
|
|
1262
|
+
signal: AbortSignal;
|
|
1263
|
+
}) => void;
|
|
1264
|
+
}): (update: TUpdate, ctx: TContext, signal: AbortSignal) => Promise<TelegramCustodiedExecutionResult>;
|
|
1265
|
+
export interface TelegramQueueAdmissionItemLike {
|
|
1266
|
+
admissionReceipts?: readonly TelegramQueueAdmissionReceiptLike[];
|
|
1267
|
+
}
|
|
1268
|
+
export interface TelegramQueueAdmissionSettlementRuntime<TContext> {
|
|
1269
|
+
isItemReady: (item: TelegramQueueAdmissionItemLike) => boolean;
|
|
1270
|
+
getQueueReceiptSettlementOwner?: (receipt: TelegramQueueAdmissionReceiptLike, ctx: TContext, reason: TelegramQueueReceiptCompletionReason) => TelegramUpdateJournalQueueOwner | undefined;
|
|
1271
|
+
getQueueReceiptOwner: (receipt: TelegramQueueAdmissionReceiptLike) => TelegramUpdateJournalQueueOwner | undefined;
|
|
1272
|
+
onPromptHandedOff: (item: TelegramQueueAdmissionItemLike, ctx: TContext) => boolean;
|
|
1273
|
+
onControlSettled: (item: TelegramQueueAdmissionItemLike, ctx: TContext) => boolean;
|
|
1274
|
+
onItemsDiscarded: (items: readonly TelegramQueueAdmissionItemLike[], ctx: TContext) => boolean;
|
|
1275
|
+
}
|
|
1276
|
+
export declare function createTelegramQueueAdmissionSettlementMuxRuntime<TContext>(runtimes: readonly TelegramQueueAdmissionSettlementRuntime<TContext>[]): TelegramQueueAdmissionSettlementRuntime<TContext>;
|
|
1277
|
+
export declare function createTelegramQueueAdmissionSettlementRuntime<TContext>(worker: TelegramUpdateWorkerRuntime<TContext>): TelegramQueueAdmissionSettlementRuntime<TContext>;
|
|
1278
|
+
export interface TelegramUpdateAdmissionLifecycleJournalBinding {
|
|
1279
|
+
runtimeKey: string;
|
|
1280
|
+
recoveryKey: string;
|
|
1281
|
+
recipientBindingKey?: string;
|
|
1282
|
+
journal: TelegramUpdateWorkerJournalPort & {
|
|
1283
|
+
inputCustody?: TelegramCustodyExecutionJournal;
|
|
1284
|
+
appendBatch: (updates: readonly TelegramJournaledUpdate[], acceptedThroughUpdateId?: number) => Pick<TelegramUpdateJournalAppendResult, "nonExcludedUpdateIds">;
|
|
1285
|
+
applyOperatorDisposition?: (input: TelegramUpdateJournalOperatorDispositionInput) => TelegramUpdateJournalOperatorDispositionResult;
|
|
1286
|
+
discardQueued?: (input: {
|
|
1287
|
+
queueKind: "prompt" | "control";
|
|
1288
|
+
receiptId: string;
|
|
1289
|
+
sourceUpdateIds: readonly number[];
|
|
1290
|
+
expectedOwner: TelegramUpdateJournalQueueOwner;
|
|
1291
|
+
}) => TelegramUpdateJournalQueueDiscardResult;
|
|
1292
|
+
offerQueuedHandoff?: (input: TelegramUpdateJournalQueueHandoffInput) => TelegramUpdateJournalQueueHandoffOfferResult;
|
|
1293
|
+
acceptQueuedHandoff?: (input: TelegramUpdateJournalQueueHandoffInput) => TelegramUpdateJournalQueueHandoffAcceptResult;
|
|
1294
|
+
cancelQueuedHandoff?: (input: TelegramUpdateJournalQueueHandoffInput) => TelegramUpdateJournalQueueHandoffCancelResult;
|
|
1295
|
+
recoverDeadQueueOwner?: (input: {
|
|
1296
|
+
queueKind: "prompt" | "control";
|
|
1297
|
+
receiptId: string;
|
|
1298
|
+
sourceUpdateIds: readonly number[];
|
|
1299
|
+
deadOwner: TelegramUpdateJournalQueueOwner;
|
|
1300
|
+
recoveryOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
1301
|
+
}) => TelegramUpdateJournalDeadQueueOwnerRecoveryResult;
|
|
1302
|
+
};
|
|
1303
|
+
hasAuthority?: () => boolean;
|
|
1304
|
+
}
|
|
1305
|
+
export interface TelegramQueueHandoffControlExecutionDeps<TContext> {
|
|
1306
|
+
isContextCurrent: (ctx: TContext) => boolean;
|
|
1307
|
+
showStatus: (chatId: number, replyToMessageId: number, ctx: TContext, threadId?: number) => Promise<void>;
|
|
1308
|
+
openModelMenu: (chatId: number, replyToMessageId: number, ctx: TContext, threadId?: number) => Promise<void>;
|
|
1309
|
+
}
|
|
1310
|
+
export declare function createTelegramQueueHandoffControlExecutionFactory<TContext>(deps: TelegramQueueHandoffControlExecutionDeps<TContext>): (payload: TelegramControlQueueHandoffPayload) => PendingTelegramControlItem<TContext>["execute"];
|
|
1311
|
+
export interface TelegramQueueHandoffCoordinatorInput<TContext> {
|
|
1312
|
+
item: TelegramQueueItem<TContext>;
|
|
1313
|
+
expectedOwner: TelegramUpdateJournalQueueOwner;
|
|
1314
|
+
recipientOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
1315
|
+
handoffToken: string;
|
|
1316
|
+
stageRemote: (input: {
|
|
1317
|
+
handoffToken: string;
|
|
1318
|
+
expectedOwner: TelegramUpdateJournalQueueOwner;
|
|
1319
|
+
recipientOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
1320
|
+
payload: TelegramQueueHandoffPayload;
|
|
1321
|
+
}) => Promise<TelegramQueueHandoffStageResult>;
|
|
1322
|
+
lifecycle: Pick<TelegramUpdateAdmissionLifecycleRuntime<TContext>, "offerQueueReceiptHandoff" | "acceptQueueReceiptHandoff" | "cancelQueueReceiptHandoff">;
|
|
1323
|
+
removeDonorItem: (receipt: TelegramQueueAdmissionReceipt) => boolean;
|
|
1324
|
+
}
|
|
1325
|
+
export type TelegramQueueHandoffCoordinatorResult = {
|
|
1326
|
+
status: "transferred";
|
|
1327
|
+
receipt: TelegramQueueAdmissionReceipt;
|
|
1328
|
+
queueOwner: TelegramUpdateJournalQueueOwner;
|
|
1329
|
+
} | {
|
|
1330
|
+
status: "retained";
|
|
1331
|
+
receipt: TelegramQueueAdmissionReceipt;
|
|
1332
|
+
error: unknown;
|
|
1333
|
+
cancelled: boolean;
|
|
1334
|
+
};
|
|
1335
|
+
export declare function coordinateTelegramQueueHandoff<TContext>(input: TelegramQueueHandoffCoordinatorInput<TContext>): Promise<TelegramQueueHandoffCoordinatorResult>;
|
|
1336
|
+
export interface TelegramQueueHandoffReconciliationBinding<TContext> {
|
|
1337
|
+
request: (ctx: TContext) => void;
|
|
1338
|
+
set: (reconcile: (ctx: TContext) => Promise<void>) => void;
|
|
1339
|
+
}
|
|
1340
|
+
export declare function createTelegramQueueHandoffReconciliationBinding<TContext>(recordFailure?: (error: unknown) => void): TelegramQueueHandoffReconciliationBinding<TContext>;
|
|
1341
|
+
export interface TelegramQueueHandoffRecipientRuntimeDeps<TContext> {
|
|
1342
|
+
staging: TelegramQueueHandoffStagingRuntime;
|
|
1343
|
+
getRecipientOwner: () => TelegramUpdateJournalQueueOwnerIdentity;
|
|
1344
|
+
getLifecycleForBinding: (journalBindingKey: string) => TelegramUpdateAdmissionLifecycleRuntime<TContext> | undefined;
|
|
1345
|
+
isTransportStampActive?: (stamp: TelegramQueueHandoffPayload["transportStamp"]) => boolean;
|
|
1346
|
+
dispatchNext: (ctx: TContext) => void;
|
|
1347
|
+
}
|
|
1348
|
+
export declare function createTelegramQueueHandoffRecipientRuntime<TContext>(deps: TelegramQueueHandoffRecipientRuntimeDeps<TContext>): (envelope: Extract<TelegramBusEnvelope, {
|
|
1349
|
+
kind: "leader.offerQueueHandoff";
|
|
1350
|
+
}>, ctx: TContext) => Promise<TelegramQueueHandoffStageResult>;
|
|
1351
|
+
export interface TelegramQueueHandoffReconcilerDeps<TContext> {
|
|
1352
|
+
ownsDirect: () => boolean;
|
|
1353
|
+
isFollowerRegistered: () => boolean;
|
|
1354
|
+
isBusEnabled: () => boolean;
|
|
1355
|
+
canHandoffWithLeader?: () => boolean;
|
|
1356
|
+
listFollowers: () => readonly TelegramBusFollowerView[];
|
|
1357
|
+
createRecipientJournalBindingKey: (recipient: TelegramBusFollowerView) => string | undefined;
|
|
1358
|
+
getQueuedItems: () => readonly TelegramQueueItem<TContext>[];
|
|
1359
|
+
getReceiptOwner: (receipt: TelegramQueueAdmissionReceipt) => TelegramUpdateJournalQueueOwner | undefined;
|
|
1360
|
+
getLifecycleForReceipt: (receipt: TelegramQueueAdmissionReceipt) => TelegramUpdateAdmissionLifecycleRuntime<TContext> | undefined;
|
|
1361
|
+
createHandoffToken: () => string;
|
|
1362
|
+
createRequestId: () => string;
|
|
1363
|
+
donorInstanceId: string;
|
|
1364
|
+
authSecret?: string;
|
|
1365
|
+
stageThroughFollower: (input: {
|
|
1366
|
+
recipient: TelegramBusFollowerView;
|
|
1367
|
+
expectedOwner: TelegramUpdateJournalQueueOwner;
|
|
1368
|
+
handoffToken: string;
|
|
1369
|
+
payload: TelegramQueueHandoffPayload;
|
|
1370
|
+
}) => Promise<TelegramQueueHandoffStageResult>;
|
|
1371
|
+
routeThroughLeader: (input: TelegramBusLeaderQueueHandoffOffer) => Promise<TelegramBusEnvelope>;
|
|
1372
|
+
removeDonorItem: (receipt: TelegramQueueAdmissionReceipt, ctx: TContext) => boolean;
|
|
1373
|
+
recordFailure?: (error: unknown, details: Record<string, unknown>) => void;
|
|
1374
|
+
}
|
|
1375
|
+
export interface TelegramQueueHandoffReconciliationRuntimeAssemblyDeps<TContext> {
|
|
1376
|
+
ownsDirect: () => boolean;
|
|
1377
|
+
isFollowerRegistered: () => boolean;
|
|
1378
|
+
isBusEnabled: () => boolean;
|
|
1379
|
+
canHandoffWithLeader?: () => boolean;
|
|
1380
|
+
listFollowers: () => readonly TelegramBusFollowerView[];
|
|
1381
|
+
createRecipientJournalResolver: (profileKey: string, sessionId: string) => () => {
|
|
1382
|
+
recoveryKey: string;
|
|
1383
|
+
} | undefined;
|
|
1384
|
+
queueStore: {
|
|
1385
|
+
getQueuedItems: () => TelegramQueueItem<TContext>[];
|
|
1386
|
+
setQueuedItems: (items: TelegramQueueItem<TContext>[]) => void;
|
|
1387
|
+
};
|
|
1388
|
+
admission: Pick<TelegramUpdateAdmissionRuntimeBinding<TContext>, "getSettlement" | "getLifecycleForJournalBinding">;
|
|
1389
|
+
createHandoffToken: () => string;
|
|
1390
|
+
createRequestId: () => string;
|
|
1391
|
+
donorInstanceId: string;
|
|
1392
|
+
authSecret?: string;
|
|
1393
|
+
stageThroughFollower: (input: TelegramBusFollowerQueueHandoffOffer) => Promise<TelegramQueueHandoffStageResult>;
|
|
1394
|
+
routeThroughLeader: TelegramQueueHandoffReconcilerDeps<TContext>["routeThroughLeader"];
|
|
1395
|
+
recordRuntimeEvent?: (category: string, error: unknown, details?: Record<string, unknown>) => void;
|
|
1396
|
+
}
|
|
1397
|
+
/** Own queue-handoff projections over journals, admission, IPC, and live queue state. */
|
|
1398
|
+
export declare function createTelegramQueueHandoffReconciliationRuntimeAssembly<TContext>(deps: TelegramQueueHandoffReconciliationRuntimeAssemblyDeps<TContext>): (ctx: TContext) => Promise<void>;
|
|
1399
|
+
export declare function createTelegramQueueHandoffReconciler<TContext>(deps: TelegramQueueHandoffReconcilerDeps<TContext>): (ctx: TContext) => Promise<void>;
|
|
1400
|
+
export interface TelegramQueueMutationDependencyItem {
|
|
1401
|
+
chatId: number;
|
|
1402
|
+
target?: {
|
|
1403
|
+
chatId: number;
|
|
1404
|
+
};
|
|
1405
|
+
replyToMessageId: number;
|
|
1406
|
+
sourceMessageIds?: readonly number[];
|
|
1407
|
+
}
|
|
1408
|
+
export interface TelegramUpdateAdmissionLifecycleRuntimeDeps<TContext> {
|
|
1409
|
+
resolveBinding: () => TelegramUpdateAdmissionLifecycleJournalBinding | undefined;
|
|
1410
|
+
getQueueOwnerIdentity?: (ctx: TContext) => TelegramUpdateJournalQueueOwnerIdentity;
|
|
1411
|
+
createWorker: (journal: TelegramUpdateWorkerJournalPort, binding: TelegramUpdateAdmissionLifecycleJournalBinding) => TelegramUpdateWorkerRuntime<TContext>;
|
|
1412
|
+
acquireSourceReference?: (binding: TelegramUpdateAdmissionLifecycleJournalBinding) => () => void;
|
|
1413
|
+
/** Runs after the previous worker stopped and before the replacement worker exists; throwing refuses binding. */
|
|
1414
|
+
prepareBinding?: (binding: TelegramUpdateAdmissionLifecycleJournalBinding) => void;
|
|
1415
|
+
recordRuntimeEvent?: TelegramUpdateWorkerRuntimeDeps<TContext>["recordRuntimeEvent"];
|
|
1416
|
+
}
|
|
1417
|
+
export interface TelegramUpdateAdmissionLifecycleRuntime<TContext> extends TelegramQueueAdmissionSettlementRuntime<TContext> {
|
|
1418
|
+
onSessionStart: (ctx: TContext) => Promise<void>;
|
|
1419
|
+
onSessionShutdown: () => Promise<void>;
|
|
1420
|
+
onTransportChanged: (ctx?: TContext) => Promise<void>;
|
|
1421
|
+
appendBatch: (updates: readonly TelegramJournaledUpdate[], acceptedThroughUpdateId?: number) => Pick<TelegramUpdateJournalAppendResult, "nonExcludedUpdateIds">;
|
|
1422
|
+
discardQueueReceipt: (input: {
|
|
1423
|
+
queueKind: "prompt" | "control";
|
|
1424
|
+
receiptId: string;
|
|
1425
|
+
sourceUpdateIds: readonly number[];
|
|
1426
|
+
expectedOwner: TelegramUpdateJournalQueueOwner;
|
|
1427
|
+
}) => TelegramUpdateJournalQueueDiscardResult;
|
|
1428
|
+
recoverDeadQueueReceipt: (input: {
|
|
1429
|
+
queueKind: "prompt" | "control";
|
|
1430
|
+
receiptId: string;
|
|
1431
|
+
sourceUpdateIds: readonly number[];
|
|
1432
|
+
deadOwner: TelegramUpdateJournalQueueOwner;
|
|
1433
|
+
recoveryOwner: TelegramUpdateJournalQueueOwnerIdentity;
|
|
1434
|
+
}) => TelegramUpdateJournalDeadQueueOwnerRecoveryResult;
|
|
1435
|
+
offerQueueReceiptHandoff: (input: TelegramUpdateJournalQueueHandoffInput) => TelegramUpdateJournalQueueHandoffOfferResult;
|
|
1436
|
+
acceptQueueReceiptHandoff: (input: TelegramUpdateJournalQueueHandoffInput) => TelegramUpdateJournalQueueHandoffAcceptResult;
|
|
1437
|
+
cancelQueueReceiptHandoff: (input: TelegramUpdateJournalQueueHandoffInput) => TelegramUpdateJournalQueueHandoffCancelResult;
|
|
1438
|
+
publishAcceptedQueueReceipt: (input: {
|
|
1439
|
+
receipt: TelegramQueueAdmissionReceiptLike;
|
|
1440
|
+
queueOwner: TelegramUpdateJournalQueueOwner;
|
|
1441
|
+
ctx: TContext;
|
|
1442
|
+
}) => Promise<void>;
|
|
1443
|
+
getQueueReceiptOwner: (receipt: TelegramQueueAdmissionReceiptLike) => TelegramUpdateJournalQueueOwner | undefined;
|
|
1444
|
+
getJournalBindingKey: () => string | undefined;
|
|
1445
|
+
getJournalPath: () => string | undefined;
|
|
1446
|
+
ownsJournalBinding: (journalBindingKey: string) => boolean;
|
|
1447
|
+
getJournalEntryCount: () => number;
|
|
1448
|
+
getForeignQueueOwnerLiveness: () => TelegramProcessLiveness | undefined;
|
|
1449
|
+
hasPendingQueueMutationForItem: (item: TelegramQueueMutationDependencyItem) => boolean;
|
|
1450
|
+
signal: () => void;
|
|
1451
|
+
/** Fresh recipient input only; the leader's existing deferred original keeps its original carrier. */
|
|
1452
|
+
prepareLiveInput?: TelegramUpdateWorkerRuntime<TContext>["prepareLiveInput"];
|
|
1453
|
+
getState: () => TelegramUpdateWorkerStateSnapshot | undefined;
|
|
1454
|
+
}
|
|
1455
|
+
export interface TelegramUpdateWorkerOwnerRuntime<TContext> {
|
|
1456
|
+
getQueueOwnerIdentity: () => TelegramUpdateJournalQueueOwnerIdentity;
|
|
1457
|
+
onQueueReceiptCommitted: (receipt: TelegramQueueAdmissionReceiptLike, ctx: TContext) => void;
|
|
1458
|
+
onUpdateCompleted: (updateId: number, ctx: TContext, journalBindingKey?: string) => void;
|
|
1459
|
+
}
|
|
1460
|
+
export interface TelegramUpdateWorkerOwnerRuntimeDeps<TContext> {
|
|
1461
|
+
instanceId: string;
|
|
1462
|
+
processId: number;
|
|
1463
|
+
processBirthId: string;
|
|
1464
|
+
getSessionGeneration: () => number;
|
|
1465
|
+
isContextCurrent: (ctx: TContext) => boolean;
|
|
1466
|
+
dispatchNext: (ctx: TContext) => void;
|
|
1467
|
+
requestQueueHandoffReconciliation: (ctx: TContext) => void;
|
|
1468
|
+
afterQueueReceiptCommitted?: (receipt: TelegramQueueAdmissionReceiptLike, ctx: TContext) => void;
|
|
1469
|
+
afterUpdateCompleted?: (updateId: number, ctx: TContext, journalBindingKey?: string) => void;
|
|
1470
|
+
}
|
|
1471
|
+
export declare function createTelegramUpdateWorkerOwnerRuntime<TContext>(deps: TelegramUpdateWorkerOwnerRuntimeDeps<TContext>): TelegramUpdateWorkerOwnerRuntime<TContext>;
|
|
1472
|
+
export interface TelegramUpdateAdmissionRuntimeBinding<TContext> {
|
|
1473
|
+
bind: (input: {
|
|
1474
|
+
leader: TelegramUpdateAdmissionLifecycleRuntime<TContext>;
|
|
1475
|
+
follower: TelegramUpdateAdmissionLifecycleRuntime<TContext>;
|
|
1476
|
+
inputCustodyBus?: TelegramInputCustodyBusBindingRuntime<TContext>;
|
|
1477
|
+
}) => void;
|
|
1478
|
+
getLeader: () => TelegramUpdateAdmissionLifecycleRuntime<TContext> | undefined;
|
|
1479
|
+
getFollower: () => TelegramUpdateAdmissionLifecycleRuntime<TContext> | undefined;
|
|
1480
|
+
getActive: () => TelegramUpdateAdmissionLifecycleRuntime<TContext> | undefined;
|
|
1481
|
+
getSettlement: () => TelegramQueueAdmissionSettlementRuntime<TContext> | undefined;
|
|
1482
|
+
getInputCustodyBus: () => TelegramInputCustodyBusBindingRuntime<TContext> | undefined;
|
|
1483
|
+
getLifecycleForJournalBinding: (journalBindingKey: string) => TelegramUpdateAdmissionLifecycleRuntime<TContext> | undefined;
|
|
1484
|
+
hasPendingQueueMutationForItem: (item: TelegramQueueMutationDependencyItem) => boolean;
|
|
1485
|
+
onSessionShutdown: () => Promise<void>;
|
|
1486
|
+
}
|
|
1487
|
+
export declare function createTelegramUpdateAdmissionRuntimeBinding<TContext>(deps: {
|
|
1488
|
+
isFollowerRegistered: () => boolean;
|
|
1489
|
+
}): TelegramUpdateAdmissionRuntimeBinding<TContext>;
|
|
1490
|
+
/** Own one worker per active transport identity without assuming queued-owner death. */
|
|
1491
|
+
export declare function createTelegramUpdateAdmissionLifecycleRuntime<TContext>(deps: TelegramUpdateAdmissionLifecycleRuntimeDeps<TContext>): TelegramUpdateAdmissionLifecycleRuntime<TContext>;
|
|
1492
|
+
export interface TelegramUpdateAdmissionLifecycleAssembly<TContext> {
|
|
1493
|
+
leader: TelegramUpdateAdmissionLifecycleRuntime<TContext>;
|
|
1494
|
+
follower: TelegramUpdateAdmissionLifecycleRuntime<TContext>;
|
|
1495
|
+
}
|
|
1496
|
+
export interface TelegramUpdateAdmissionLifecycleAssemblyDeps<TUpdate extends TelegramJournaledUpdate & TelegramUpdateFlow, TContext> {
|
|
1497
|
+
runtimeBinding: TelegramUpdateAdmissionRuntimeBinding<TContext>;
|
|
1498
|
+
inputCustodyBus?: TelegramInputCustodyBusBindingRuntime<TContext>;
|
|
1499
|
+
acquireSourceReference?: (role: "leader" | "follower", binding: TelegramUpdateAdmissionLifecycleJournalBinding) => () => void;
|
|
1500
|
+
worker: Omit<TelegramUpdateAdmissionWorkerRuntimeDeps<TUpdate, TContext>, "journal" | "getJournalBindingKey" | "getRecipientBindingKey" | "hasAuthority" | "prepareUpdateForExecution">;
|
|
1501
|
+
leader: {
|
|
1502
|
+
resolveBinding: () => TelegramUpdateAdmissionLifecycleJournalBinding | undefined;
|
|
1503
|
+
hasAuthority: (ctx: TContext) => boolean;
|
|
1504
|
+
};
|
|
1505
|
+
follower: {
|
|
1506
|
+
resolveBinding: () => TelegramUpdateAdmissionLifecycleJournalBinding | undefined;
|
|
1507
|
+
isRegistered: () => boolean;
|
|
1508
|
+
getGeneration: () => string | undefined;
|
|
1509
|
+
prepareUpdateForExecution: (update: TUpdate) => TUpdate;
|
|
1510
|
+
/** Session succession before worker creation, under the exact generation-fenced binding. */
|
|
1511
|
+
prepareBinding?: (binding: TelegramUpdateAdmissionLifecycleJournalBinding & {
|
|
1512
|
+
hasAuthority?: () => boolean;
|
|
1513
|
+
}) => void;
|
|
1514
|
+
};
|
|
1515
|
+
recordRuntimeEvent?: TelegramUpdateWorkerRuntimeDeps<TContext>["recordRuntimeEvent"];
|
|
1516
|
+
}
|
|
1517
|
+
export type TelegramUpdateAdmissionWorkerRuntimeDeps<TUpdate extends TelegramJournaledUpdate & TelegramUpdateFlow, TContext> = Omit<TelegramUpdateWorkerRuntimeDeps<TContext>, "executeUpdate" | "executeCustodiedUpdate"> & {
|
|
1518
|
+
inputCustody?: TelegramCustodyExecutionJournal;
|
|
1519
|
+
defaultHandle: (update: TUpdate, ctx: TContext, execution?: TelegramUpdateExecutionFence) => Promise<void>;
|
|
1520
|
+
prepareUpdateForExecution?: (update: TUpdate) => TUpdate;
|
|
1521
|
+
registry?: TelegramUpdateHandlerRegistry;
|
|
1522
|
+
};
|
|
1523
|
+
/** Compose source-bound routing and late grouped settlement under one worker. */
|
|
1524
|
+
export declare function createTelegramUpdateAdmissionWorkerRuntime<TUpdate extends TelegramJournaledUpdate & TelegramUpdateFlow, TContext>(deps: TelegramUpdateAdmissionWorkerRuntimeDeps<TUpdate, TContext>): TelegramUpdateWorkerRuntime<TContext>;
|
|
1525
|
+
/** Own leader/follower journal lifecycle construction and generation fencing. */
|
|
1526
|
+
export declare function createTelegramUpdateAdmissionLifecycleAssembly<TUpdate extends TelegramJournaledUpdate & TelegramUpdateFlow, TContext>(deps: TelegramUpdateAdmissionLifecycleAssemblyDeps<TUpdate, TContext>): TelegramUpdateAdmissionLifecycleAssembly<TContext>;
|
|
1527
|
+
export interface TelegramUpdateAdmissionRuntimeAssembly<TContext> extends TelegramUpdateAdmissionLifecycleAssembly<TContext> {
|
|
1528
|
+
owner: TelegramUpdateWorkerOwnerRuntime<TContext>;
|
|
1529
|
+
}
|
|
1530
|
+
export type TelegramUpdateAdmissionRuntimeAssemblyDeps<TUpdate extends TelegramJournaledUpdate & TelegramUpdateFlow, TContext> = Omit<TelegramUpdateAdmissionLifecycleAssemblyDeps<TUpdate, TContext>, "worker" | "recordRuntimeEvent"> & {
|
|
1531
|
+
owner: TelegramUpdateWorkerOwnerRuntimeDeps<TContext>;
|
|
1532
|
+
worker: Omit<TelegramUpdateAdmissionLifecycleAssemblyDeps<TUpdate, TContext>["worker"], keyof TelegramUpdateWorkerOwnerRuntime<TContext> | "isContextCurrent" | "recordRuntimeEvent">;
|
|
1533
|
+
recordRuntimeEvent?: TelegramUpdateWorkerRuntimeDeps<TContext>["recordRuntimeEvent"];
|
|
1534
|
+
};
|
|
1535
|
+
/** Own queue-owner projection and shared leader/follower worker composition. */
|
|
1536
|
+
export declare function createTelegramUpdateAdmissionRuntimeAssembly<TUpdate extends TelegramJournaledUpdate & TelegramUpdateFlow, TContext>(deps: TelegramUpdateAdmissionRuntimeAssemblyDeps<TUpdate, TContext>): TelegramUpdateAdmissionRuntimeAssembly<TContext>;
|
|
1537
|
+
/**
|
|
1538
|
+
* Register a handler that runs before pi-telegram routes a Telegram update
|
|
1539
|
+
* through its built-in handlers.
|
|
1540
|
+
*
|
|
1541
|
+
* This is the low-level public surface for extensions that share the same bot
|
|
1542
|
+
* and Pi process with pi-telegram.
|
|
1543
|
+
*/
|
|
1544
|
+
export declare function registerTelegramUpdateHandler(handler: TelegramUpdateHandler): () => void;
|
|
1545
|
+
export {};
|