Skip to content

refactor(plugins): route Telegram runtime through plugin sdk#51772

Merged
scoootscooob merged 1 commit intoopenclaw:mainfrom
scoootscooob:codex/telegram-runtime-plugin-sdk
Mar 21, 2026
Merged

refactor(plugins): route Telegram runtime through plugin sdk#51772
scoootscooob merged 1 commit intoopenclaw:mainfrom
scoootscooob:codex/telegram-runtime-plugin-sdk

Conversation

@scoootscooob
Copy link
Copy Markdown
Contributor

Summary

  • route src/plugins/runtime/runtime-telegram.ts and src/plugins/runtime/runtime-telegram-ops.runtime.ts through src/plugin-sdk/telegram.ts
  • remove the final direct plugin-to-extension imports from the plugin-extension import boundary inventory
  • bring the src/plugins/** must not import extensions/** inventory to zero

Testing

  • pnpm lint:plugins:no-extension-imports
  • pnpm test -- src/plugin-sdk/runtime-api-guardrails.test.ts
  • pnpm test -- extensions/telegram/src/send.test.ts extensions/telegram/src/probe.test.ts extensions/telegram/src/channel.test.ts
  • node --import tsx - <<'EON'
    import { createRuntimeTelegram } from './src/plugins/runtime/runtime-telegram.ts';
    const runtime = createRuntimeTelegram();
    console.log(JSON.stringify({
    hasAudit: typeof runtime.auditGroupMembership === 'function',
    hasCollectUnmentioned: typeof runtime.collectUnmentionedGroupIds === 'function',
    hasProbe: typeof runtime.probeTelegram === 'function',
    hasToken: typeof runtime.resolveTelegramToken === 'function',
    hasSend: typeof runtime.sendMessageTelegram === 'function',
    hasPoll: typeof runtime.sendPollTelegram === 'function',
    hasMonitor: typeof runtime.monitorTelegramProvider === 'function',
    hasMessageActions: typeof runtime.messageActions === 'object',
    hasTypingPulse: typeof runtime.typing.pulse === 'function',
    hasEdit: typeof runtime.conversationActions.editMessage === 'function'
    }, null, 2));
    EON

@openclaw-barnacle openclaw-barnacle bot added size: S maintainer Maintainer-authored PR labels Mar 21, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 21, 2026

Greptile Summary

This PR completes the src/plugins/**extensions/** import boundary cleanup by routing the remaining direct imports in runtime-telegram.ts, runtime-telegram-ops.runtime.ts, runtime-imessage.ts, and runtime-slack-ops.runtime.ts through the corresponding src/plugin-sdk/ modules, and clears the boundary inventory to [].

  • All imported symbols (auditTelegramGroupMembership, resolveTelegramToken, telegramMessageActions, monitorIMessageProvider, sendMessageSlack, etc.) are correctly re-exported from the plugin-sdk shims, so there are no missing-export or runtime errors.
  • The two separate import … from "../../plugin-sdk/telegram.js" blocks in runtime-telegram-ops.runtime.ts can be merged into one (they were previously two blocks importing from the same extensions/telegram/runtime-api.js path; that split can now be cleaned up).
  • The boundary enforcement fixture (plugin-extension-import-boundary-inventory.json) is correctly set to [], confirming zero known violations remain.

Confidence Score: 5/5

  • This PR is safe to merge — it's a purely mechanical import-path refactor with no behavioral changes.
  • All changed files are straightforward import-path redirections. Every symbol imported via the plugin-sdk shims is verified to be re-exported by the respective src/plugin-sdk/*.ts files. The only note is a minor style opportunity to merge two duplicate import blocks in runtime-telegram-ops.runtime.ts.
  • No files require special attention.

Comments Outside Diff (1)

  1. src/plugins/runtime/runtime-telegram-ops.runtime.ts, line 1-16 (link)

    P2 Duplicate imports from same module

    Both import blocks now resolve to the same module path (../../plugin-sdk/telegram.js). They can be merged into a single import statement, which is cleaner and avoids any potential confusion.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: src/plugins/runtime/runtime-telegram-ops.runtime.ts
    Line: 1-16
    
    Comment:
    **Duplicate imports from same module**
    
    Both import blocks now resolve to the same module path (`../../plugin-sdk/telegram.js`). They can be merged into a single import statement, which is cleaner and avoids any potential confusion.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/plugins/runtime/runtime-telegram-ops.runtime.ts
Line: 1-16

Comment:
**Duplicate imports from same module**

Both import blocks now resolve to the same module path (`../../plugin-sdk/telegram.js`). They can be merged into a single import statement, which is cleaner and avoids any potential confusion.

```suggestion
import {
  auditTelegramGroupMembership as auditTelegramGroupMembershipImpl,
  monitorTelegramProvider as monitorTelegramProviderImpl,
  probeTelegram as probeTelegramImpl,
  deleteMessageTelegram as deleteMessageTelegramImpl,
  editMessageReplyMarkupTelegram as editMessageReplyMarkupTelegramImpl,
  editMessageTelegram as editMessageTelegramImpl,
  pinMessageTelegram as pinMessageTelegramImpl,
  renameForumTopicTelegram as renameForumTopicTelegramImpl,
  sendMessageTelegram as sendMessageTelegramImpl,
  sendPollTelegram as sendPollTelegramImpl,
  sendTypingTelegram as sendTypingTelegramImpl,
  unpinMessageTelegram as unpinMessageTelegramImpl,
} from "../../plugin-sdk/telegram.js";
```

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "refactor: route Tele..."

@scoootscooob scoootscooob self-assigned this Mar 21, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f65e91a175

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 4 to +7
setTelegramThreadBindingIdleTimeoutBySessionKey,
setTelegramThreadBindingMaxAgeBySessionKey,
telegramMessageActions,
} from "../../../extensions/telegram/runtime-api.js";
} from "../../plugin-sdk/telegram.js";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid routing Telegram cold paths through the full SDK barrel

Switching this eager import to ../../plugin-sdk/telegram.js widens createRuntimeTelegram()'s cold path from the narrow runtime API to the entire Telegram SDK barrel. src/plugin-sdk/telegram.ts re-exports src/plugins/runtime/runtime-telegram-contract.ts, which in turn pulls in extensions/telegram/api.ts and modules like extensions/telegram/src/sticker-cache.ts that load model-catalog/media-understanding code. As a result, even lightweight callers that only need resolveTelegramToken or collectUnmentionedGroupIds now pay that startup cost the first time channel.telegram is touched, which regresses Telegram startup and defeats the intent of the existing lazy runtime-telegram-ops.runtime.ts split.

Useful? React with 👍 / 👎.

Comment on lines 7 to +10
resolveSlackUserAllowlist as resolveSlackUserAllowlistImpl,
sendMessageSlack as sendMessageSlackImpl,
handleSlackAction as handleSlackActionImpl,
} from "../../../extensions/slack/runtime-api.js";
} from "../../plugin-sdk/slack.js";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve the narrow Slack lazy-runtime import surface

This lazy runtime boundary used to depend only on extensions/slack/runtime-api.js; routing it through ../../plugin-sdk/slack.js now forces the whole Slack SDK barrel to initialize on first use. That barrel re-exports extensions/slack/api.ts, which brings in unrelated HTTP/action/client modules (for example extensions/slack/src/client.ts and extensions/slack/src/http/index.ts) before simple operations like probeSlack or allowlist resolution run. For Slack status/onboarding flows, that turns a targeted lazy load into a much heavier cold-start and memory hit.

Useful? React with 👍 / 👎.

@scoootscooob scoootscooob force-pushed the codex/telegram-runtime-plugin-sdk branch from f65e91a to a0c4175 Compare March 21, 2026 17:20
@scoootscooob scoootscooob force-pushed the codex/telegram-runtime-plugin-sdk branch from a0c4175 to d45230f Compare March 21, 2026 17:22
@scoootscooob scoootscooob merged commit d6367c2 into openclaw:main Mar 21, 2026
37 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d45230fb11

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

setTelegramThreadBindingMaxAgeBySessionKey,
telegramMessageActions,
} from "../../../extensions/telegram/runtime-api.js";
} from "../../plugin-sdk/telegram.js";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep Telegram runtime off the full plugin-sdk barrel

Switching this import to ../../plugin-sdk/telegram.js widens runtime-telegram.ts from the narrow runtime API to the full Telegram SDK barrel, which re-exports extensions/telegram/api.ts and modules like extensions/telegram/src/sticker-cache.ts. Fresh evidence: src/plugins/runtime/runtime-channel.ts imports createRuntimeTelegram unconditionally, so this extra Telegram API graph is now loaded on every plugin-runtime startup, even in non-Telegram flows that never touch channel.telegram. That turns a boundary cleanup into a real startup and memory regression for all plugin-backed commands.

Useful? React with 👍 / 👎.

mrosmarin added a commit to mrosmarin/openclaw that referenced this pull request Mar 21, 2026
* main: (516 commits)
  fix: use content hash for memory flush dedup instead of compactionCount (openclaw#30115) (openclaw#34222)
  fix(tts): add matrix to VOICE_BUBBLE_CHANNELS (openclaw#37080)
  feat(memory): pluggable system prompt section for memory plugins (openclaw#40126)
  fix: detect nvm services from installed command (openclaw#51146)
  fix: handle Linux nvm CA env before startup (openclaw#51146) (thanks @GodsBoy)
  refactor: route Telegram runtime through plugin sdk (openclaw#51772)
  refactor: route iMessage runtime through plugin sdk (openclaw#51770)
  refactor: route Slack runtime through plugin sdk (openclaw#51766)
  refactor(doctor): extract provider and shared config helpers (openclaw#51753)
  Fix Discord `/codex_resume` picker expiration (openclaw#51260)
  fix(ci): remove duplicate embedding default export
  fix(ci): restore embedding defaults and plugin boundaries
  fix: compaction safeguard summary budget (openclaw#27727)
  web UI: fix context notice using accumulated inputTokens instead of prompt snapshot (openclaw#51721)
  fix(status): skip cold-start status probes
  refactor(doctor): extract telegram provider warnings (openclaw#51704)
  fix(telegram): default fresh setups to mention-gated groups
  docs(changelog): note telegram doctor first-run guidance
  fix(doctor): add telegram first-run guidance
  fix(doctor): suppress telegram fresh-install group warning
  ...
JohnJAS pushed a commit to JohnJAS/openclaw that referenced this pull request Mar 22, 2026
pholpaphankorn pushed a commit to pholpaphankorn/openclaw that referenced this pull request Mar 22, 2026
MaheshBhushan pushed a commit to MaheshBhushan/openclaw that referenced this pull request Mar 22, 2026
frankekn pushed a commit to artwalker/openclaw that referenced this pull request Mar 23, 2026
furaul pushed a commit to furaul/openclaw that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant