Commit Graph

11 Commits

Author SHA1 Message Date
kshitijk4poor ab2f4602de refactor: MessageEvent to gateway/platforms/event.py; ElicitationHandler takes a call_context thunk
Breaks the two import cycles that forced Protocol stand-ins in the F821 sweep, so the two
sites now name the real types.

gateway/platforms/event.py (new leaf): MessageType, ProcessingOutcome, MessageEvent moved
out of base.py verbatim. Their only dependency is gateway.session.SessionSource; base.py
imported helpers.py at module level, so helpers could not name MessageEvent. Now
TextBatchAggregator is typed by the real MessageEvent. 249 importers repointed
(`from gateway.platforms.base import` -> `.event`, preserving each import's layout);
gateway.platforms.__init__ re-exports from .event. The three revert-scheduled PLUGIN-COMPAT
pointers that named these symbols (gateway.slash_commands → MessageType, dingtalk → MessageType,
photon → ProcessingOutcome) and their COMPAT_MANIFEST rows now target gateway.platforms.event.
Docs updated: ADDING_A_PLATFORM.md, adding-platform-adapters.md (en + zh-Hans).

tools/mcp_tool_sampling.py: ElicitationHandler no longer holds a back-reference to its
MCPServerTask (mcp_tool imports sampling, so the task type cannot be named there). It only
ever read owner._pending_call_context, so it takes `call_context: Callable[[], Context | None]`
and MCPServerTask passes `lambda: self._pending_call_context`. The consent call is one
`functools.partial`, run directly or inside the captured Context.

ty on the 11 touched production files vs origin/main: 0 new diagnostics, 14 resolved.
(The one `source: SessionSource = None` diagnostic moves with the class; typing it Optional
exposes ~60 unguarded call sites — separate follow-up.)

Tests: tests/gateway + tests/plugins + tests/tools + touched files, 18,235 passed; the 31
failures reproduce identically on origin/main (macOS /private/tmp, systemd socket,
long-path fixtures, live-service tests).
2026-09-07 22:47:33 +05:30
Teknium 7a33369e81 simplify(compat): interrupt — drop _ThreadAwareEventProxy/_interrupt_event legacy alias, repoint 2 test files
No runtime consumer read the proxy (terminal_tool/environments call is_interrupted()/set_interrupt()
directly); its only users were tests patching tools.interrupt._interrupt_event, which had no effect on
the code under test. tools/terminal_tool.py's own re-export of the name is owned by another worker.
2026-09-03 14:00:59 -07:00
Teknium c93ace77c2 simplify(compat): config/runtime_provider/plugins/commands/secrets_cli/kanban — drop 96 re-exports (incl. PEP 562 facades) + 3 aliases (get_pre_tool_call_directive/_block_message, get_telegram_handler_factories), repoint 56 callers + 50 test files 2026-09-03 14:00:17 -07:00
Teknium 1e6cfaa0d0 simplify(compat): setup/model_switch/nous_subscription — drop 34 re-exports, repoint 14 callers + 26 test files (~100 sites) 2026-09-03 13:33:10 -07:00
Teknium e83816a4d1 review-fix(comments): restore lost #NNNN rationale comments across non-test source (mechanical sweep, condensed, code unchanged)
For each issue anchor present in BASE 63279301bc non-test .py and absent on HEAD, the BASE comment/docstring block was re-attached at the HEAD location of the code it explained (matched by the distinctive code line / enclosing def). Sentences already covered by an existing HEAD comment were deduped; the issue number always survives. Insert-only: no code lines changed.
2026-09-03 09:44:26 -07:00
Teknium 901796093b refactor(gateway): fold long string literals and dict/call layouts in slash_commands_session/model
Implicit-concatenation string literals re-wrapped to 100 cols (byte-identical values, verified
by AST constant diff vs base); remaining fitted calls folded. Group now -25.2% LOC.
2026-09-02 19:55:39 -07:00
Teknium 559714fb18 refactor(gateway): compact slash_commands_session/model — fold calls, inline single-use helpers, tighten docs
- Fold parenthesised multi-line calls that fit in 100 cols; inline _switch_and_commit,
  _reasoning_picker_choices, _configured_display_context, listing_kwargs (single-use).
- Collapse getattr-guarded calls on always-present mixin methods (_is_user_authorized,
  _schedule_telegram_topic_title_rename); next()-based lookups; contextlib.suppress.
- Docstrings/comments compacted by hand — every WHY (IDOR guards, cache/rotation
  invariants, off-loop rationale) kept; narrative and issue-number history dropped.
- Differential parity vs base: 9216 traced cases for /new,/title,/undo,/branch;
  12000 for the resume ownership guards; /fast + /reasoning tables; listing goldens.
2026-09-02 19:40:07 -07:00
Teknium f7c5b16fcc refactor(gateway): break /model, /new, /compress, /resume god methods into phase helpers
- slash_commands_model: _ModelSwitchContext dataclass replaces 12-kwarg plumbing;
  _handle_model_command (193 LOC) -> listing / switch / guard / commit phases;
  _commit_model_switch (175) -> cached-agent swap / record / confirmation;
  /fast and /reasoning display toggles routed through dict tables.
- slash_commands_session: /new hooks + cleanup lifted; _handle_compress_command_inner
  -> _run_manual_compression; /resume -> resolve target / access-denied helpers;
  persisted-row ownership proof extracted (_persisted_row_proves_owner, _sattr).
- Zero user-visible change (golden + differential fuzz vs base for guards, listing,
  /fast, /reasoning); test net 137 files / 1842 passed.
2026-09-02 19:04:09 -07:00
Teknium 2e9a5e9f32 refactor(gateway/slash): collapse /whoami, /platform, /stop, /footer, /verbose duplication; extract /compress preview; module docstrings 2026-09-02 16:41:41 -07:00
Teknium 59acca1850 refactor(gateway/slash): unify context-breakdown transcript load; tidy module headers and import order 2026-09-02 16:30:01 -07:00
Teknium 8ba0350b31 refactor(gateway/slash): extract model-route commands into gateway/slash_commands_model.py (GatewayModelCommandsMixin) 2026-09-02 15:59:06 -07:00