sneakoscope 8.0.2 → 8.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +150 -37
- package/config/skills-hash-ledger.v1.json +1 -1
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/dist/bin/fast-inline.js +55 -27
- package/dist/bin/install.js +6 -32
- package/dist/bin/sks-dispatch.js +1 -1
- package/dist/cli/args.js +0 -2
- package/dist/cli/cli-theme.js +18 -9
- package/dist/cli/command-manifest-lite.js +6 -6
- package/dist/cli/command-registry.js +6 -6
- package/dist/cli/feature-commands.js +9 -7
- package/dist/cli/install-helpers-codex-lb-chain.js +198 -7
- package/dist/cli/install-helpers-codex-lb-config.js +78 -10
- package/dist/cli/install-helpers-install-support.js +9 -6
- package/dist/cli/install-helpers.js +101 -49
- package/dist/cli/install-tool-helpers.js +2 -82
- package/dist/cli/output.js +6 -1
- package/dist/cli/router.js +101 -2
- package/dist/commands/codex-lb.js +119 -19
- package/dist/commands/doctor-profile.js +1 -1
- package/dist/commands/doctor.js +727 -144
- package/dist/commands/mad-sks.js +1 -5
- package/dist/config/skills-manifest.json +4 -2
- package/dist/core/agents/agent-codex-cockpit.js +0 -3
- package/dist/core/agents/agent-effort-policy.js +5 -5
- package/dist/core/agents/agent-janitor.js +0 -20
- package/dist/core/agents/agent-orchestrator.js +9 -56
- package/dist/core/agents/agent-output-validator.js +2 -3
- package/dist/core/agents/agent-patch-schema.js +2 -2
- package/dist/core/agents/agent-proof-evidence.js +0 -65
- package/dist/core/agents/agent-recursion-guard.js +1 -1
- package/dist/core/agents/agent-runner-codex-exec.js +5 -3
- package/dist/core/agents/agent-scheduler.js +327 -85
- package/dist/core/agents/agent-schema.js +1 -1
- package/dist/core/agents/agent-trust-report.js +0 -36
- package/dist/core/agents/agent-worker-pipeline.js +0 -1
- package/dist/core/agents/fast-mode-policy.js +1 -3
- package/dist/core/agents/native-cli-worker-runtime-proof.js +1 -1
- package/dist/core/agents/native-cli-worker-runtime.js +69 -647
- package/dist/core/agents/native-cli-worker.js +6 -7
- package/dist/core/agents/native-worker-backend-router.js +2 -32
- package/dist/core/agents/no-subagent-scaling-policy.js +1 -1
- package/dist/core/agents/parallel-runtime-proof.js +1 -6
- package/dist/core/agents/runtime-proof-summary.js +1 -35
- package/dist/core/architecture-hardening/contracts/contracts.js +193 -0
- package/dist/core/architecture-hardening/migration/migration.js +111 -0
- package/dist/core/architecture-hardening/state/state-service.js +155 -0
- package/dist/core/artifact-schemas.js +0 -3
- package/dist/core/codex/codex-config-guard.js +238 -52
- package/dist/core/codex-adapter.js +5 -3
- package/dist/core/codex-app/auxiliary-oauth-policy.js +36 -0
- package/dist/core/codex-app/catalog-compat/catalog-service.js +104 -0
- package/dist/core/codex-app/child-policy/child-policy.js +35 -0
- package/dist/core/codex-app/codex-app-handoff.js +0 -1
- package/dist/core/codex-app/codex-hook-lifecycle.js +1 -1
- package/dist/core/codex-app/codex-init-deep.js +1 -1
- package/dist/core/codex-app/menubar/app-bundle.js +2 -0
- package/dist/core/codex-app/menubar/constants.js +14 -1
- package/dist/core/codex-app/menubar/global-install.js +288 -0
- package/dist/core/codex-app/menubar/installer.js +79 -14
- package/dist/core/codex-app/menubar/launch-agent.js +267 -45
- package/dist/core/codex-app/menubar/paths.js +3 -0
- package/dist/core/codex-app/menubar/rollback.js +55 -7
- package/dist/core/codex-app/menubar/status.js +75 -4
- package/dist/core/codex-app/provider-child-policy.js +64 -0
- package/dist/core/codex-app/provider-mode.js +91 -0
- package/dist/core/codex-app/provider-operation-stages.js +20 -0
- package/dist/core/codex-app/provider-session-policy.js +85 -0
- package/dist/core/codex-app/session-policy/session-pinning.js +68 -0
- package/dist/core/codex-app.js +3 -2
- package/dist/core/codex-control/codex-0139-image-path-real-probe.js +3 -1
- package/dist/core/codex-control/codex-0139-web-search-probe.js +3 -1
- package/dist/core/codex-control/codex-app-server-runtime-env.js +13 -4
- package/dist/core/codex-control/codex-app-server-v2-client.js +3 -3
- package/dist/core/codex-control/codex-control-proof.js +0 -1
- package/dist/core/codex-control/codex-task-runner.js +1 -4
- package/dist/core/codex-exec-output-schema.js +4 -1
- package/dist/core/codex-lb/codex-lb-env.js +63 -72
- package/dist/core/codex-lb/codex-lb-setup.js +15 -2
- package/dist/core/codex-lb/desktop-bridge/header-policy.js +6 -0
- package/dist/core/codex-lb/desktop-bridge/http-forward.js +48 -6
- package/dist/core/codex-lb/desktop-bridge/security.js +134 -0
- package/dist/core/codex-lb/desktop-bridge/server.js +9 -3
- package/dist/core/codex-lb/desktop-bridge/state.js +26 -6
- package/dist/core/codex-lb/desktop-bridge/types.js +1 -0
- package/dist/core/codex-lb/desktop-center-credentials.js +517 -58
- package/dist/core/codex-lb/desktop-controller.js +177 -56
- package/dist/core/codex-lb/desktop-service.js +179 -40
- package/dist/core/codex-lb/legacy-migration.js +1 -3
- package/dist/core/codex-lb/native-openai-transport/transport.js +68 -0
- package/dist/core/codex-lb/probes/cli-image-tool-probe.js +1 -1
- package/dist/core/codex-lb/provider-routing/provider-router.js +58 -0
- package/dist/core/codex-lb/routing-truth.js +327 -0
- package/dist/core/codex-native/codex-native-feature-broker.js +4 -0
- package/dist/core/codex-native/codex-native-pattern-analysis.js +1 -2
- package/dist/core/codex-native/core-skill-manifest.js +1 -1
- package/dist/core/codex-plugins/codex-plugin-json.js +26 -6
- package/dist/core/codex-plugins/codex-plugin-repair.js +32 -6
- package/dist/core/commands/basic-cli.js +9 -7
- package/dist/core/commands/computer-use-command.js +1 -1
- package/dist/core/commands/image-ux-review-command.js +16 -9
- package/dist/core/commands/install-package-command.js +105 -0
- package/dist/core/commands/intent-normalization/normalizer.js +96 -0
- package/dist/core/commands/mad-sks-command.js +23 -274
- package/dist/core/commands/mad-sks-headless.js +11 -30
- package/dist/core/commands/naruto-command.js +0 -25
- package/dist/core/commands/qa-loop-command.js +104 -22
- package/dist/core/commands/remote-command.js +2 -2
- package/dist/core/commands/research-command.js +10 -5
- package/dist/core/commands/telegram-command.js +407 -0
- package/dist/core/config-adopt/config-adopt-command.js +35 -0
- package/dist/core/config-adopt/config-adopt.js +346 -0
- package/dist/core/config-adopt/index.js +3 -0
- package/dist/core/doctor/command-alias-cleanup.js +4 -1
- package/dist/core/doctor/current-project-guidance-nested.js +37 -6
- package/dist/core/doctor/current-project-guidance.js +15 -9
- package/dist/core/doctor/doctor-dirty-planner.js +1 -4
- package/dist/core/doctor/doctor-readiness-matrix.js +15 -18
- package/dist/core/doctor/retired-managed-residue-private.js +4 -3
- package/dist/core/doctor/retired-managed-residue-runtime.js +2 -2
- package/dist/core/doctor/skill-legacy-surface.js +11 -10
- package/dist/core/doctor/sks-menubar-doctor.js +4 -0
- package/dist/core/evaluation.js +0 -19
- package/dist/core/evidence/v2/evidence-key.js +105 -0
- package/dist/core/feature-fixtures.js +12 -7
- package/dist/core/feature-registry.js +52 -21
- package/dist/core/hooks-runtime/hook-context.js +9 -0
- package/dist/core/hooks-runtime/managed-skill-admission.js +54 -4
- package/dist/core/hooks-runtime/official-subagent-lifecycle.js +69 -52
- package/dist/core/hooks-runtime/stop-finalization.js +226 -0
- package/dist/core/hooks-runtime/stop-repeat-guard.js +21 -2
- package/dist/core/hooks-runtime/subagent-skill-availability-contract.js +2 -2
- package/dist/core/hooks-runtime/subagent-skill-availability-evidence.js +3 -3
- package/dist/core/hooks-runtime/subagent-skill-availability-guards.js +43 -5
- package/dist/core/hooks-runtime/subagent-skill-availability.js +64 -30
- package/dist/core/hooks-runtime/subagent-stop-hook.js +15 -2
- package/dist/core/hooks-runtime.js +179 -212
- package/dist/core/image/reference-evidence/reference-registry.js +145 -0
- package/dist/core/image-ux-review/imagegen-adapter.js +21 -9
- package/dist/core/image-ux-review/reference-policy/reference-policy.js +9 -0
- package/dist/core/imagegen/codex-lb-imagegen-target.js +8 -0
- package/dist/core/imagegen/imagegen-capability.js +59 -2
- package/dist/core/imagegen/require-imagegen.js +2 -2
- package/dist/core/init/skills.js +17 -3
- package/dist/core/init.js +3 -3
- package/dist/core/install/installed-package-smoke.js +23 -5
- package/dist/core/json/canonical.js +9 -0
- package/dist/core/locks/file-lock.js +0 -1
- package/dist/core/loops/loop-continuation-enforcer.js +65 -7
- package/dist/core/loops/loop-decomposer.js +0 -1
- package/dist/core/loops/loop-gate-runner.js +65 -4
- package/dist/core/loops/loop-gate-selector.js +0 -2
- package/dist/core/loops/loop-proof-validation.js +38 -0
- package/dist/core/loops/loop-risk-classifier.js +1 -1
- package/dist/core/loops/loop-runtime.js +14 -2
- package/dist/core/loops/loop-scheduler.js +7 -2
- package/dist/core/loops/loop-worker-runtime.js +0 -15
- package/dist/core/loops/loop-worktree-runtime.js +52 -4
- package/dist/core/managed-assets/managed-assets-manifest.js +14 -14
- package/dist/core/naruto/hardware-capacity-probe.js +9 -6
- package/dist/core/naruto/naruto-active-pool.js +2 -14
- package/dist/core/naruto/naruto-concurrency-governor.js +71 -31
- package/dist/core/naruto/naruto-loop-worker-router.js +0 -2
- package/dist/core/naruto/naruto-verification-dag.js +0 -1
- package/dist/core/naruto/naruto-write-e2e.js +1 -2
- package/dist/core/naruto/resource-pressure-monitor.js +0 -4
- package/dist/core/observability/architecture-hardening/safe-projection.js +65 -0
- package/dist/core/perf/import-graph-budget.js +0 -1
- package/dist/core/perf/release-latency-slo.js +3 -2
- package/dist/core/preflight/parallel-preflight-engine.js +2 -15
- package/dist/core/product-design-app-server.js +13 -1
- package/dist/core/proof/fake-real-proof-policy.js +2 -17
- package/dist/core/proof/route-proof-gate.js +2 -10
- package/dist/core/proof/route-proof-policy.js +1 -1
- package/dist/core/proof/runtime-evidence-policy.js +185 -0
- package/dist/core/proof/runtime-truth-matrix.js +64 -39
- package/dist/core/proof/validation.js +27 -11
- package/dist/core/provider/provider-context.js +18 -2
- package/dist/core/providers/openrouter/openrouter-account.js +3 -2
- package/dist/core/python-tools/python-tool-runner.js +1 -1
- package/dist/core/qa-loop/qa-execution-control.js +57 -0
- package/dist/core/questions.js +1 -1
- package/dist/core/release/extreme-parallel-scheduler.js +0 -3
- package/dist/core/release/gate-manifest.js +3 -7
- package/dist/core/release/gate-pack-manifest.js +3 -7
- package/dist/core/release/package-size-budget.js +2 -2
- package/dist/core/release/physical-release-gates.js +189 -0
- package/dist/core/release/publish-preflight.js +113 -0
- package/dist/core/release/release-gate-affected-selector.js +0 -2
- package/dist/core/release/release-gate-batch-runner.js +1 -1
- package/dist/core/release/release-gate-node.js +0 -1
- package/dist/core/release/release-gate-resource-governor.js +0 -1
- package/dist/core/release/release-pack-receipt.js +5 -8
- package/dist/core/release/release-real-contract.js +0 -6
- package/dist/core/release/resource-class-budget.js +0 -1
- package/dist/core/release/stage-publish.js +178 -36
- package/dist/core/research/research-adversarial-review.js +103 -9
- package/dist/core/research.js +1 -1
- package/dist/core/retention.js +0 -1
- package/dist/core/routes/constants.js +1 -1
- package/dist/core/routes/diagnostic-allowlist.js +0 -1
- package/dist/core/routes/dollar-manifest-lite.js +1 -1
- package/dist/core/routes.js +46 -15
- package/dist/core/runtime/execution-control.js +226 -0
- package/dist/core/runtime/progress-recovery/progress-recovery.js +89 -0
- package/dist/core/runtime/task-profile.js +10 -4
- package/dist/core/runtime/verification-budget.js +10 -1
- package/dist/core/safety/intent-contract/intent-contract.js +94 -0
- package/dist/core/safety/mutation-guard.js +0 -2
- package/dist/core/safety/mutation-ledger.js +0 -2
- package/dist/core/safety/requested-scope-contract.js +0 -0
- package/dist/core/search-visibility/discovery.js +1 -1
- package/dist/core/search-visibility/index.js +12 -0
- package/dist/core/search-visibility/verifier.js +112 -3
- package/dist/core/security/private-credential-file.js +209 -0
- package/dist/core/session/project-namespace.js +0 -5
- package/dist/core/skills/skill-agent-metadata.js +1 -3
- package/dist/core/strategy/adhd-orchestrating-gate.js +0 -1
- package/dist/core/subagents/agent-catalog.js +19 -34
- package/dist/core/subagents/model-policy.js +65 -24
- package/dist/core/subagents/naruto-help-contract.js +8 -8
- package/dist/core/subagents/naruto-host-credentials.js +13 -0
- package/dist/core/subagents/official-subagent-config.js +16 -6
- package/dist/core/subagents/official-subagent-preparation.js +35 -16
- package/dist/core/subagents/official-subagent-prompt.js +7 -7
- package/dist/core/subagents/official-subagent-runner.js +27 -4
- package/dist/core/subagents/role-model-preferences.js +1 -1
- package/dist/core/subagents/thread-budget.js +19 -12
- package/dist/core/subagents/wave-lifecycle.js +18 -6
- package/dist/core/telegram/access.js +58 -0
- package/dist/core/telegram/client.js +157 -0
- package/dist/core/telegram/confirmation.js +37 -0
- package/dist/core/telegram/doctor.js +154 -0
- package/dist/core/telegram/index.js +9 -0
- package/dist/core/telegram/keychain.js +317 -0
- package/dist/core/telegram/liveness.js +118 -0
- package/dist/core/telegram/poller.js +90 -0
- package/dist/core/telegram/redaction.js +15 -0
- package/dist/core/telegram/state-lock.js +416 -0
- package/dist/core/telegram/types.js +1 -0
- package/dist/core/text/strings.js +3 -0
- package/dist/core/triwiki/context-graph/store/evidence-write-lock.js +29 -0
- package/dist/core/triwiki/context-graph/store/fragment-cache.js +24 -0
- package/dist/core/triwiki/context-graph/store/snapshot-store.js +69 -21
- package/dist/core/triwiki/triwiki-gate-impact-map.js +2 -2
- package/dist/core/triwiki/triwiki-module-card.js +1 -2
- package/dist/core/update/installed-cli-resolution.js +170 -0
- package/dist/core/update/update-diagnostics.js +52 -0
- package/dist/core/update/update-migration-state.js +30 -12
- package/dist/core/update/update-operation.js +2 -1
- package/dist/core/update/update-stage-diagnostics.js +38 -0
- package/dist/core/update/update-status.js +2 -9
- package/dist/core/update-check.js +279 -91
- package/dist/core/version.js +1 -1
- package/dist/native/sks-menubar/Sources/AppDelegate.swift +19 -1
- package/dist/native/sks-menubar/Sources/AppIdentity.swift +7 -0
- package/dist/native/sks-menubar/Sources/ControlCenterWindowController.swift +6 -2
- package/dist/native/sks-menubar/Sources/OperationCoordinator.swift +159 -92
- package/dist/native/sks-menubar/Sources/OperationModels.swift +389 -0
- package/dist/native/sks-menubar/Sources/OverviewViewController.swift +57 -0
- package/dist/native/sks-menubar/Sources/ProcessClient.swift +3 -1
- package/dist/native/sks-menubar/Sources/ProvidersConnectTest.swift +115 -0
- package/dist/native/sks-menubar/Sources/ProvidersFastMode.swift +17 -0
- package/dist/native/sks-menubar/Sources/ProvidersMultiProvider.swift +3 -0
- package/dist/native/sks-menubar/Sources/ProvidersOpenRouter.swift +58 -17
- package/dist/native/sks-menubar/Sources/ProvidersReliability.swift +302 -0
- package/dist/native/sks-menubar/Sources/ProvidersRoleModels.swift +5 -0
- package/dist/native/sks-menubar/Sources/ProvidersRoutingTruth.swift +190 -0
- package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +158 -126
- package/dist/native/sks-menubar/Sources/RemoteCodingViewController.swift +462 -26
- package/dist/native/sks-menubar/Sources/SKSKeychainStore.swift +344 -0
- package/dist/native/sks-menubar/Sources/SecureProcessEnvelope.swift +27 -0
- package/dist/native/sks-menubar/Sources/SingletonInstanceGuard.swift +328 -0
- package/dist/native/sks-menubar/Sources/StatusItemController.swift +10 -2
- package/dist/native/sks-menubar/Sources/TelegramPrivateFileStore.swift +498 -0
- package/dist/native/sks-menubar/Sources/TelegramPrivateFileSupport.swift +236 -0
- package/dist/native/sks-menubar/Sources/TelegramProcessGateway.swift +454 -0
- package/dist/native/sks-menubar/Sources/TelegramRuntimeSupport.swift +56 -0
- package/dist/native/sks-menubar/Sources/TelegramStateLock.swift +448 -0
- package/dist/native/sks-menubar/Sources/TelegramSupport.swift +187 -0
- package/dist/native/sks-menubar/Sources/TelegramTransport.swift +499 -0
- package/dist/native/sks-menubar/Sources/main.swift +15 -1
- package/dist/scripts/all-feature-deep-completion-check.js +5 -1
- package/dist/scripts/check-publish-tag.js +56 -0
- package/dist/scripts/codex-lb-fast-mode-truth-check.js +10 -3
- package/dist/scripts/codex-lb-fast-ui-preservation-check.js +12 -3
- package/dist/scripts/codex-lb-gpt56-fast-profile-check.js +4 -2
- package/dist/scripts/codex-native-agent-role-content-check.js +3 -3
- package/dist/scripts/codex-native-gate-lib.js +14 -7
- package/dist/scripts/current-command-surface-check.js +7 -7
- package/dist/scripts/current-surface-update-e2e-check.js +4 -3
- package/dist/scripts/current-upgrade-matrix-check.js +5 -24
- package/dist/scripts/docs-truthfulness-check.js +17 -13
- package/dist/scripts/gate-lib.js +0 -2
- package/dist/scripts/gate-policy-audit-check.js +3 -2
- package/dist/scripts/harness-benchmark-check.js +1 -1
- package/dist/scripts/init-deep-backup-retention-check.js +1 -1
- package/dist/scripts/lib/codex-sdk-gate-lib.js +1 -2
- package/dist/scripts/loop-directive-check-lib.js +28 -38
- package/dist/scripts/mad-sks-app-ui-no-mutation-check.js +14 -180
- package/dist/scripts/mad-sks-launch-sql-plane-boundary-check.js +2 -11
- package/dist/scripts/official-subagent-workflow-check.js +1 -1
- package/dist/scripts/packlist-performance-check.js +1 -2
- package/dist/scripts/prepublish-release-check-or-fast.js +32 -0
- package/dist/scripts/publish-preflight.js +12 -0
- package/dist/scripts/release-affected-selector-check.js +2 -2
- package/dist/scripts/release-gate-batch-runner-check.js +2 -2
- package/dist/scripts/release-metadata-check.js +8 -12
- package/dist/scripts/release-real-check.js +2 -54
- package/dist/scripts/runtime-domain-gate-lib.js +2 -96
- package/dist/scripts/runtime-proof-summary-check.js +2 -6
- package/dist/scripts/search-visibility-gate-lib.js +0 -1
- package/dist/scripts/sks-cli-gate-lib.js +1 -1
- package/dist/scripts/typed-routing-gate-lib.js +7 -59
- package/docs/demo.tape +1 -1
- package/infra-harness-gates.json +1 -1456
- package/package.json +10 -7
- package/release-gates.v2.json +0 -1
- package/schemas/agents/parallel-runtime-proof.schema.json +0 -2
- package/schemas/codex/agent-result.schema.json +0 -6
- package/schemas/naruto/naruto-concurrency-governor.schema.json +1 -3
- package/schemas/release/release-gate-node.schema.json +1 -1
- package/dist/commands/zellij-lane.js +0 -22
- package/dist/commands/zellij-monitor-pane.js +0 -26
- package/dist/commands/zellij-slot-column-anchor.js +0 -22
- package/dist/commands/zellij-slot-pane.js +0 -80
- package/dist/commands/zellij-viewport-pane.js +0 -57
- package/dist/commands/zellij.js +0 -422
- package/dist/core/agents/agent-runner-zellij.js +0 -164
- package/dist/core/agents/agent-slot-pane-binding-proof.js +0 -96
- package/dist/core/agents/parallel-write-fixture.js +0 -305
- package/dist/core/agents/worker-pane-communication-contract.js +0 -100
- package/dist/core/agents/zellij-lane-supervisor.js +0 -428
- package/dist/core/agents/zellij-right-lane-cockpit.js +0 -66
- package/dist/core/doctor/doctor-zellij-repair.js +0 -40
- package/dist/core/ops/upgrade-migration-fixtures.js +0 -119
- package/dist/core/proof/route-finalizer-fixtures.js +0 -21
- package/dist/core/zellij/homebrew-policy.js +0 -43
- package/dist/core/zellij/zellij-capability.js +0 -126
- package/dist/core/zellij/zellij-clipboard-config.js +0 -52
- package/dist/core/zellij/zellij-command.js +0 -149
- package/dist/core/zellij/zellij-fake-adapter.js +0 -186
- package/dist/core/zellij/zellij-lane-renderer.js +0 -706
- package/dist/core/zellij/zellij-lane-runtime.js +0 -189
- package/dist/core/zellij/zellij-launcher.js +0 -268
- package/dist/core/zellij/zellij-layout-builder.js +0 -191
- package/dist/core/zellij/zellij-monitor-renderer.js +0 -52
- package/dist/core/zellij/zellij-official-subagent-activity.js +0 -526
- package/dist/core/zellij/zellij-official-subagent-telemetry.js +0 -258
- package/dist/core/zellij/zellij-pane-proof.js +0 -226
- package/dist/core/zellij/zellij-right-column-manager.js +0 -308
- package/dist/core/zellij/zellij-screen-proof.js +0 -120
- package/dist/core/zellij/zellij-self-heal-types.js +0 -44
- package/dist/core/zellij/zellij-self-heal.js +0 -408
- package/dist/core/zellij/zellij-slot-column-anchor.js +0 -304
- package/dist/core/zellij/zellij-slot-pane-renderer.js +0 -521
- package/dist/core/zellij/zellij-slot-telemetry.js +0 -384
- package/dist/core/zellij/zellij-theme.js +0 -66
- package/dist/core/zellij/zellij-ui-mode.js +0 -34
- package/dist/core/zellij/zellij-update.js +0 -348
- package/dist/core/zellij/zellij-viewport-binder.js +0 -61
- package/dist/core/zellij/zellij-worker-pane-manager.js +0 -881
- package/dist/core/zellij/zellij-worker-pane-summary.js +0 -64
- package/dist/native/sks-menubar/Tests/AppRuntimeTestSupport.swift +0 -26
- package/dist/native/sks-menubar/Tests/OperationCoordinatorTests.swift +0 -174
- package/dist/native/sks-menubar/Tests/ProcessClientTests.swift +0 -20
- package/dist/native/sks-menubar/Tests/ProvidersViewControllerTests.swift +0 -142
- package/dist/scripts/zellij-pane-proof-check.js +0 -88
- package/dist/scripts/zellij-real-session-cleanup-check.js +0 -139
- package/dist/scripts/zellij-real-session-launch-check.js +0 -126
- package/dist/scripts/zellij-screen-proof-check.js +0 -43
- package/schemas/zellij/zellij-right-column-state.schema.json +0 -40
- package/schemas/zellij/zellij-slot-telemetry.schema.json +0 -89
- package/schemas/zellij/zellij-worker-pane.schema.json +0 -53
- package/scripts/build-clean-atomic.mjs +0 -323
|
@@ -4,6 +4,7 @@ import { readSubagentEvents } from './subagent-evidence.js';
|
|
|
4
4
|
import { MAX_AUTOMATIC_SUBAGENT_COUNT, MAX_MASS_AUTOMATIC_SUBAGENT_COUNT } from './agent-catalog.js';
|
|
5
5
|
import { buildWaveParentGuidance } from './wave-parent-guidance.js';
|
|
6
6
|
export const SUBAGENT_WAVE_LIFECYCLE_SCHEMA = 'sks.subagent-wave-lifecycle.v1';
|
|
7
|
+
const LEGACY_SKS_AUTOMATIC_SUBAGENT_CEILINGS = new Set([12, 64]);
|
|
7
8
|
export function subagentCountPolicy(plan) {
|
|
8
9
|
const lifecycle = plan?.wave_lifecycle;
|
|
9
10
|
if (lifecycle?.count_policy === 'dynamic_automatic')
|
|
@@ -61,11 +62,17 @@ export function subagentCountContractBlockers(plan, observedStarts = 0) {
|
|
|
61
62
|
}
|
|
62
63
|
export function automaticSubagentTargetCap(plan) {
|
|
63
64
|
const fanout = plan?.fanout_policy;
|
|
64
|
-
const configuredCeiling = positiveCount(fanout?.automatic_ceiling) || MAX_AUTOMATIC_SUBAGENT_COUNT;
|
|
65
65
|
const hardAutomaticCeiling = fanout?.mass_parallel === true
|
|
66
66
|
? MAX_MASS_AUTOMATIC_SUBAGENT_COUNT
|
|
67
67
|
: MAX_AUTOMATIC_SUBAGENT_COUNT;
|
|
68
|
-
|
|
68
|
+
const configuredCeiling = positiveCount(fanout?.automatic_ceiling);
|
|
69
|
+
const legacySksOwnedCeiling = fanout?.mode === 'parent_owned_risk_based'
|
|
70
|
+
&& fanout?.count_source === 'automatic'
|
|
71
|
+
&& LEGACY_SKS_AUTOMATIC_SUBAGENT_CEILINGS.has(configuredCeiling);
|
|
72
|
+
const effectiveConfiguredCeiling = legacySksOwnedCeiling
|
|
73
|
+
? hardAutomaticCeiling
|
|
74
|
+
: configuredCeiling || hardAutomaticCeiling;
|
|
75
|
+
return Math.min(effectiveConfiguredCeiling, hardAutomaticCeiling);
|
|
69
76
|
}
|
|
70
77
|
export function effectiveSubagentTarget(plan, observedStarts = 0) {
|
|
71
78
|
const countPolicy = subagentCountPolicy(plan);
|
|
@@ -211,10 +218,15 @@ function projectLifecycle(previous, input) {
|
|
|
211
218
|
? latestEventTime(input.events, 'SubagentStop', wave.settled_thread_ids) || wave.settled_at || nowIso()
|
|
212
219
|
: null;
|
|
213
220
|
}
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
221
|
+
const latestStopOutcomes = new Map();
|
|
222
|
+
for (const event of input.events) {
|
|
223
|
+
if (event.event_name === 'SubagentStop' && event.thread_id) {
|
|
224
|
+
latestStopOutcomes.set(event.thread_id, event.outcome);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const failed = new Set([...latestStopOutcomes]
|
|
228
|
+
.filter(([, outcome]) => outcome === 'failed')
|
|
229
|
+
.map(([threadId]) => threadId));
|
|
218
230
|
const cumulativeSettled = [...stops].filter((threadId) => starts.includes(threadId)).length;
|
|
219
231
|
const completed = Math.max(0, cumulativeSettled - failed.size);
|
|
220
232
|
const openThreads = Math.max(0, starts.length - cumulativeSettled);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { randomInt, randomUUID } from 'node:crypto';
|
|
2
|
+
import { SYSTEM_TELEGRAM_CLOCK } from './types.js';
|
|
3
|
+
export class InMemoryTelegramAccessStore {
|
|
4
|
+
clock;
|
|
5
|
+
pairings = new Map();
|
|
6
|
+
chats = new Map();
|
|
7
|
+
transactionTail = Promise.resolve();
|
|
8
|
+
constructor(clock = SYSTEM_TELEGRAM_CLOCK) {
|
|
9
|
+
this.clock = clock;
|
|
10
|
+
}
|
|
11
|
+
async issuePairingCode(ttlMs = 5 * 60_000) {
|
|
12
|
+
return this.transaction(async () => {
|
|
13
|
+
this.expireCodes();
|
|
14
|
+
const code = `${randomInt(100_000, 1_000_000)}-${randomUUID().slice(0, 4).toUpperCase()}`;
|
|
15
|
+
const expiresAt = this.clock.now() + Math.max(30_000, Math.min(ttlMs, 15 * 60_000));
|
|
16
|
+
this.pairings.set(code, { code, expiresAt, used: false });
|
|
17
|
+
return { code, expires_at: new Date(expiresAt).toISOString() };
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async pairAtomically(input) {
|
|
21
|
+
return this.transaction(async () => {
|
|
22
|
+
const record = this.pairings.get(input.code);
|
|
23
|
+
if (input.chatType !== 'private'
|
|
24
|
+
|| !Number.isSafeInteger(input.chatId) || input.chatId <= 0
|
|
25
|
+
|| !Number.isSafeInteger(input.senderId) || input.senderId <= 0
|
|
26
|
+
|| !record || record.used || record.expiresAt <= this.clock.now())
|
|
27
|
+
return false;
|
|
28
|
+
record.used = true;
|
|
29
|
+
this.chats.clear();
|
|
30
|
+
this.chats.set(input.chatId, {
|
|
31
|
+
chatId: input.chatId,
|
|
32
|
+
senderId: input.senderId,
|
|
33
|
+
pairedAt: new Date(this.clock.now()).toISOString()
|
|
34
|
+
});
|
|
35
|
+
return true;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async authorized(chatId, senderId) {
|
|
39
|
+
return this.transaction(async () => {
|
|
40
|
+
const chat = this.chats.get(chatId);
|
|
41
|
+
return chat?.senderId === senderId;
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async authorizedCount() {
|
|
45
|
+
return this.transaction(async () => this.chats.size);
|
|
46
|
+
}
|
|
47
|
+
expireCodes() {
|
|
48
|
+
for (const [code, record] of this.pairings) {
|
|
49
|
+
if (record.used || record.expiresAt <= this.clock.now())
|
|
50
|
+
this.pairings.delete(code);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
transaction(operation) {
|
|
54
|
+
const next = this.transactionTail.then(operation, operation);
|
|
55
|
+
this.transactionTail = next.then(() => undefined, () => undefined);
|
|
56
|
+
return next;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { redactTelegramError } from './redaction.js';
|
|
2
|
+
export class TelegramApiError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
retryAfterSeconds;
|
|
5
|
+
constructor(message, code = null, retryAfterSeconds = null) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'TelegramApiError';
|
|
8
|
+
this.code = code;
|
|
9
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class TelegramClient {
|
|
13
|
+
tokenProvider;
|
|
14
|
+
fetchImpl;
|
|
15
|
+
baseUrl;
|
|
16
|
+
requestTimeoutMs;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.tokenProvider = options.tokenProvider;
|
|
19
|
+
this.fetchImpl = options.fetch ?? globalThis.fetch;
|
|
20
|
+
this.baseUrl = validatedBaseUrl(options.baseUrl ?? 'https://api.telegram.org', options.allowInsecureLocalhost === true);
|
|
21
|
+
this.requestTimeoutMs = Math.max(1_000, Math.min(options.requestTimeoutMs ?? 20_000, 120_000));
|
|
22
|
+
}
|
|
23
|
+
getMe(signal) {
|
|
24
|
+
return this.call('getMe', {}, signal);
|
|
25
|
+
}
|
|
26
|
+
async getWebhookInfo(signal) {
|
|
27
|
+
const info = await this.call('getWebhookInfo', {}, signal);
|
|
28
|
+
if (!info || typeof info.url !== 'string')
|
|
29
|
+
throw new TelegramApiError('telegram_webhook_info_invalid');
|
|
30
|
+
return info;
|
|
31
|
+
}
|
|
32
|
+
async deleteWebhook(signal) {
|
|
33
|
+
const removed = await this.call('deleteWebhook', {
|
|
34
|
+
drop_pending_updates: false
|
|
35
|
+
}, signal);
|
|
36
|
+
if (removed !== true)
|
|
37
|
+
throw new TelegramApiError('telegram_delete_webhook_failed');
|
|
38
|
+
}
|
|
39
|
+
getUpdates(input) {
|
|
40
|
+
if (!Number.isSafeInteger(input.offset) || input.offset < 0) {
|
|
41
|
+
return Promise.reject(new TelegramApiError('telegram_offset_invalid'));
|
|
42
|
+
}
|
|
43
|
+
const timeoutSeconds = Number.isFinite(input.timeoutSeconds)
|
|
44
|
+
? Math.max(0, Math.min(50, Math.floor(input.timeoutSeconds)))
|
|
45
|
+
: 0;
|
|
46
|
+
return this.call('getUpdates', {
|
|
47
|
+
offset: input.offset,
|
|
48
|
+
timeout: timeoutSeconds,
|
|
49
|
+
allowed_updates: [...(input.allowedUpdates ?? ['message'])]
|
|
50
|
+
}, input.signal, Math.max(this.requestTimeoutMs, Math.min(70_000, (timeoutSeconds * 1_000) + 10_000)));
|
|
51
|
+
}
|
|
52
|
+
sendMessage(chatId, text, signal) {
|
|
53
|
+
if (!Number.isSafeInteger(chatId))
|
|
54
|
+
return Promise.reject(new TelegramApiError('telegram_chat_id_invalid'));
|
|
55
|
+
const bounded = text.slice(0, 4_000);
|
|
56
|
+
if (!bounded)
|
|
57
|
+
return Promise.reject(new TelegramApiError('telegram_message_empty'));
|
|
58
|
+
return this.call('sendMessage', { chat_id: chatId, text: bounded }, signal);
|
|
59
|
+
}
|
|
60
|
+
async call(method, body, signal, timeoutMs = this.requestTimeoutMs) {
|
|
61
|
+
const token = String(await this.tokenProvider.loadToken() ?? '').trim();
|
|
62
|
+
if (!token)
|
|
63
|
+
throw new TelegramApiError('telegram_token_unavailable');
|
|
64
|
+
if (!/^\d+:[A-Za-z0-9_-]+$/.test(token))
|
|
65
|
+
throw new TelegramApiError('telegram_token_invalid');
|
|
66
|
+
const endpoint = new URL(`/bot${token}/${method}`, this.baseUrl);
|
|
67
|
+
const requestController = new AbortController();
|
|
68
|
+
let timedOut = false;
|
|
69
|
+
const timer = setTimeout(() => {
|
|
70
|
+
timedOut = true;
|
|
71
|
+
requestController.abort(new Error('telegram_request_timeout'));
|
|
72
|
+
}, timeoutMs);
|
|
73
|
+
const abort = () => requestController.abort(signal?.reason);
|
|
74
|
+
if (signal?.aborted)
|
|
75
|
+
requestController.abort(signal.reason);
|
|
76
|
+
else
|
|
77
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
78
|
+
try {
|
|
79
|
+
const response = await this.fetchImpl(endpoint, {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
headers: { 'content-type': 'application/json; charset=utf-8' },
|
|
82
|
+
body: JSON.stringify(body),
|
|
83
|
+
redirect: 'error',
|
|
84
|
+
signal: requestController.signal
|
|
85
|
+
});
|
|
86
|
+
const decoded = await decodeBoundedJson(response);
|
|
87
|
+
if (!response.ok || !decoded.ok) {
|
|
88
|
+
const failure = decoded.ok ? null : decoded;
|
|
89
|
+
throw new TelegramApiError(redactTelegramError(failure?.description || `telegram_http_${response.status}`, token), failure?.error_code ?? response.status, failure?.parameters?.retry_after ?? null);
|
|
90
|
+
}
|
|
91
|
+
return decoded.result;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error instanceof TelegramApiError)
|
|
95
|
+
throw error;
|
|
96
|
+
if (timedOut)
|
|
97
|
+
throw new TelegramApiError('telegram_request_timeout');
|
|
98
|
+
if (signal?.aborted)
|
|
99
|
+
throw error;
|
|
100
|
+
throw new TelegramApiError(redactTelegramError(error, token));
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
clearTimeout(timer);
|
|
104
|
+
signal?.removeEventListener('abort', abort);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function decodeBoundedJson(response) {
|
|
109
|
+
const maximum = 2 * 1024 * 1024;
|
|
110
|
+
const declared = Number(response.headers.get('content-length') ?? '0');
|
|
111
|
+
if (Number.isFinite(declared) && declared > maximum)
|
|
112
|
+
throw new TelegramApiError('telegram_response_too_large');
|
|
113
|
+
const reader = response.body?.getReader();
|
|
114
|
+
let text = '';
|
|
115
|
+
if (reader) {
|
|
116
|
+
const decoder = new TextDecoder();
|
|
117
|
+
let bytes = 0;
|
|
118
|
+
while (true) {
|
|
119
|
+
const chunk = await reader.read();
|
|
120
|
+
if (chunk.done)
|
|
121
|
+
break;
|
|
122
|
+
bytes += chunk.value.byteLength;
|
|
123
|
+
if (bytes > maximum) {
|
|
124
|
+
await reader.cancel().catch(() => undefined);
|
|
125
|
+
throw new TelegramApiError('telegram_response_too_large');
|
|
126
|
+
}
|
|
127
|
+
text += decoder.decode(chunk.value, { stream: true });
|
|
128
|
+
}
|
|
129
|
+
text += decoder.decode();
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
text = await response.text();
|
|
133
|
+
if (Buffer.byteLength(text, 'utf8') > maximum)
|
|
134
|
+
throw new TelegramApiError('telegram_response_too_large');
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const value = JSON.parse(text);
|
|
138
|
+
if (!value || typeof value !== 'object' || typeof value.ok !== 'boolean'
|
|
139
|
+
|| (value.ok && !('result' in value))) {
|
|
140
|
+
throw new Error('shape');
|
|
141
|
+
}
|
|
142
|
+
return value;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
throw new TelegramApiError('telegram_response_invalid');
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function validatedBaseUrl(raw, allowInsecureLocalhost) {
|
|
149
|
+
const url = new URL(raw);
|
|
150
|
+
const local = url.hostname === '127.0.0.1' || url.hostname === 'localhost' || url.hostname === '::1';
|
|
151
|
+
if (url.username || url.password || url.search || url.hash)
|
|
152
|
+
throw new Error('telegram_base_url_invalid');
|
|
153
|
+
if (url.protocol !== 'https:' && !(allowInsecureLocalhost && local && url.protocol === 'http:')) {
|
|
154
|
+
throw new Error('telegram_base_url_https_required');
|
|
155
|
+
}
|
|
156
|
+
return url;
|
|
157
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { SYSTEM_TELEGRAM_CLOCK } from './types.js';
|
|
3
|
+
export class TelegramConfirmationStore {
|
|
4
|
+
clock;
|
|
5
|
+
ttlMs;
|
|
6
|
+
pending = new Map();
|
|
7
|
+
constructor(options = {}) {
|
|
8
|
+
this.clock = options.clock ?? SYSTEM_TELEGRAM_CLOCK;
|
|
9
|
+
this.ttlMs = Math.max(15_000, Math.min(options.ttlMs ?? 2 * 60_000, 10 * 60_000));
|
|
10
|
+
}
|
|
11
|
+
issue(command) {
|
|
12
|
+
this.expire();
|
|
13
|
+
const nonce = randomBytes(12).toString('base64url');
|
|
14
|
+
const expiresAt = this.clock.now() + this.ttlMs;
|
|
15
|
+
this.pending.set(nonce, { ...command, input: structuredClone(command.input), nonce, expiresAt, consumed: false });
|
|
16
|
+
return { nonce, expires_at: new Date(expiresAt).toISOString() };
|
|
17
|
+
}
|
|
18
|
+
consume(nonce, chatId, senderId) {
|
|
19
|
+
const item = this.pending.get(nonce);
|
|
20
|
+
if (!item || item.consumed || item.expiresAt <= this.clock.now()) {
|
|
21
|
+
if (item)
|
|
22
|
+
this.pending.delete(nonce);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (item.chatId !== chatId || item.senderId !== senderId)
|
|
26
|
+
return null;
|
|
27
|
+
item.consumed = true;
|
|
28
|
+
this.pending.delete(nonce);
|
|
29
|
+
return { chatId: item.chatId, senderId: item.senderId, command: item.command, input: structuredClone(item.input) };
|
|
30
|
+
}
|
|
31
|
+
expire() {
|
|
32
|
+
for (const [nonce, item] of this.pending) {
|
|
33
|
+
if (item.consumed || item.expiresAt <= this.clock.now())
|
|
34
|
+
this.pending.delete(nonce);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { redactTelegramError } from './redaction.js';
|
|
2
|
+
import { readTelegramLivenessReceipt, telegramLivenessPath } from './liveness.js';
|
|
3
|
+
export async function probeTelegram(input) {
|
|
4
|
+
const now = input.now ?? Date.now();
|
|
5
|
+
if (!input.client || !input.tokenProvider) {
|
|
6
|
+
return probeTelegramReceipt(input.receiptPath, now);
|
|
7
|
+
}
|
|
8
|
+
const receiptProbe = !input.access || !input.poller
|
|
9
|
+
? await probeTelegramReceipt(input.receiptPath, now)
|
|
10
|
+
: null;
|
|
11
|
+
const blockers = receiptProbe
|
|
12
|
+
? receiptProbe.blockers.filter((blocker) => ![
|
|
13
|
+
'telegram_token_missing',
|
|
14
|
+
'telegram_getme_not_valid',
|
|
15
|
+
'telegram_getme_stale'
|
|
16
|
+
].includes(blocker))
|
|
17
|
+
: [];
|
|
18
|
+
let tokenConfigured = false;
|
|
19
|
+
try {
|
|
20
|
+
tokenConfigured = Boolean(String(await input.tokenProvider.loadToken() ?? '').trim());
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
blockers.push(`telegram_token_load_failed:${redactTelegramError(error)}`);
|
|
24
|
+
}
|
|
25
|
+
let identityValid = false;
|
|
26
|
+
let getMeCheckedAt = null;
|
|
27
|
+
let getMeLatencyMs = null;
|
|
28
|
+
if (!tokenConfigured)
|
|
29
|
+
blockers.push('telegram_token_missing');
|
|
30
|
+
else {
|
|
31
|
+
const started = Date.now();
|
|
32
|
+
try {
|
|
33
|
+
identityValid = (await input.client.getMe()).is_bot === true;
|
|
34
|
+
if (!identityValid)
|
|
35
|
+
blockers.push('telegram_getme_not_bot');
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
blockers.push(`telegram_getme_failed:${redactTelegramError(error)}`);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
getMeLatencyMs = Date.now() - started;
|
|
42
|
+
getMeCheckedAt = new Date().toISOString();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
let pairedChatCount = receiptProbe?.paired_chat_count ?? 0;
|
|
46
|
+
if (input.access) {
|
|
47
|
+
try {
|
|
48
|
+
pairedChatCount = await input.access.authorizedCount();
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
blockers.push(`telegram_access_state_failed:${redactTelegramError(error)}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (pairedChatCount === 0 && !blockers.includes('telegram_private_chat_not_paired')) {
|
|
55
|
+
blockers.push('telegram_private_chat_not_paired');
|
|
56
|
+
}
|
|
57
|
+
let poller = receiptProbe?.poller ?? emptyPoller();
|
|
58
|
+
if (input.poller) {
|
|
59
|
+
try {
|
|
60
|
+
poller = input.poller.snapshot();
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
blockers.push(`telegram_poller_state_failed:${redactTelegramError(error)}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (!poller.running && !blockers.includes('telegram_poller_not_running')) {
|
|
67
|
+
blockers.push('telegram_poller_not_running');
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
schema: 'sks.telegram-doctor-probe.v1',
|
|
71
|
+
ok: blockers.length === 0,
|
|
72
|
+
status: !tokenConfigured ? 'not_configured' : blockers.length ? 'degraded' : 'ready',
|
|
73
|
+
token_configured: tokenConfigured,
|
|
74
|
+
token_source: tokenConfigured ? (receiptProbe?.token_source ?? 'unknown') : 'none',
|
|
75
|
+
bot_identity_valid: identityValid,
|
|
76
|
+
getme_checked_at: getMeCheckedAt,
|
|
77
|
+
getme_latency_ms: getMeLatencyMs,
|
|
78
|
+
getme_check_kind: 'live',
|
|
79
|
+
paired_chat_count: pairedChatCount,
|
|
80
|
+
audit_healthy: receiptProbe?.audit_healthy ?? true,
|
|
81
|
+
audit_last_error: receiptProbe?.audit_last_error ?? null,
|
|
82
|
+
poller,
|
|
83
|
+
blockers: [...new Set(blockers)],
|
|
84
|
+
checked_at: new Date().toISOString()
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
async function probeTelegramReceipt(receiptPath, now) {
|
|
88
|
+
const liveness = await readTelegramLivenessReceipt(receiptPath ?? telegramLivenessPath(), now);
|
|
89
|
+
if (!liveness.ok) {
|
|
90
|
+
return {
|
|
91
|
+
schema: 'sks.telegram-doctor-probe.v1', ok: false, status: 'not_configured',
|
|
92
|
+
token_configured: false, bot_identity_valid: false, paired_chat_count: 0,
|
|
93
|
+
token_source: 'none',
|
|
94
|
+
audit_healthy: false, audit_last_error: null,
|
|
95
|
+
getme_checked_at: null, getme_latency_ms: null,
|
|
96
|
+
getme_check_kind: 'receipt',
|
|
97
|
+
poller: emptyPoller(), blockers: [liveness.blocker], checked_at: new Date(now).toISOString()
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const receipt = liveness.receipt;
|
|
101
|
+
const blockers = [];
|
|
102
|
+
if (!receipt.token_configured)
|
|
103
|
+
blockers.push('telegram_token_missing');
|
|
104
|
+
if (receipt.token_configured && !receipt.bot_identity_valid)
|
|
105
|
+
blockers.push('telegram_getme_not_valid');
|
|
106
|
+
const getMeAge = receipt.getme_checked_at ? now - Date.parse(receipt.getme_checked_at) : Number.POSITIVE_INFINITY;
|
|
107
|
+
if (receipt.bot_identity_valid && getMeAge > 10 * 60_000)
|
|
108
|
+
blockers.push('telegram_getme_stale');
|
|
109
|
+
if (receipt.paired_chat_count === 0)
|
|
110
|
+
blockers.push('telegram_private_chat_not_paired');
|
|
111
|
+
if (receipt.audit_healthy === false)
|
|
112
|
+
blockers.push('telegram_audit_unavailable');
|
|
113
|
+
if (!receipt.running || !receipt.poller.running)
|
|
114
|
+
blockers.push('telegram_poller_not_running');
|
|
115
|
+
if (liveness.stale)
|
|
116
|
+
blockers.push('telegram_liveness_stale');
|
|
117
|
+
if (receipt.poller.consecutive_failures > 0)
|
|
118
|
+
blockers.push('telegram_poller_degraded');
|
|
119
|
+
return {
|
|
120
|
+
schema: 'sks.telegram-doctor-probe.v1',
|
|
121
|
+
ok: blockers.length === 0,
|
|
122
|
+
status: !receipt.token_configured ? 'not_configured' : blockers.length ? 'degraded' : 'ready',
|
|
123
|
+
token_configured: receipt.token_configured,
|
|
124
|
+
token_source: receipt.token_source ?? (receipt.token_configured ? 'unknown' : 'none'),
|
|
125
|
+
bot_identity_valid: receipt.bot_identity_valid,
|
|
126
|
+
getme_checked_at: receipt.getme_checked_at,
|
|
127
|
+
getme_latency_ms: receipt.getme_latency_ms,
|
|
128
|
+
getme_check_kind: 'receipt',
|
|
129
|
+
paired_chat_count: receipt.paired_chat_count,
|
|
130
|
+
audit_healthy: receipt.audit_healthy !== false,
|
|
131
|
+
audit_last_error: receipt.audit_last_error ?? null,
|
|
132
|
+
poller: receipt.poller,
|
|
133
|
+
blockers,
|
|
134
|
+
checked_at: new Date(now).toISOString()
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function emptyPoller() {
|
|
138
|
+
return {
|
|
139
|
+
schema: 'sks.telegram-poller-state.v1', running: false, offset: 0,
|
|
140
|
+
consecutive_failures: 0, last_poll_at: null, last_success_at: null,
|
|
141
|
+
last_update_at: null, last_error: null
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
export function telegramSelfHealAction(probe) {
|
|
145
|
+
if (!probe.audit_healthy || probe.blockers.includes('telegram_audit_unavailable'))
|
|
146
|
+
return 'operator_repair_audit';
|
|
147
|
+
if (!probe.token_configured || !probe.bot_identity_valid || probe.blockers.includes('telegram_getme_stale'))
|
|
148
|
+
return 'revalidate_token';
|
|
149
|
+
if (/409|webhook/i.test(probe.poller.last_error ?? ''))
|
|
150
|
+
return 'operator_remove_webhook';
|
|
151
|
+
if (probe.blockers.includes('telegram_liveness_stale') || !probe.poller.running || probe.poller.consecutive_failures > 0)
|
|
152
|
+
return 'restart_poll';
|
|
153
|
+
return 'none';
|
|
154
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './access.js';
|
|
2
|
+
export * from './client.js';
|
|
3
|
+
export * from './confirmation.js';
|
|
4
|
+
export * from './doctor.js';
|
|
5
|
+
export * from './liveness.js';
|
|
6
|
+
export * from './keychain.js';
|
|
7
|
+
export * from './poller.js';
|
|
8
|
+
export * from './redaction.js';
|
|
9
|
+
export * from './types.js';
|