[docs][plugin sdk] Split host-hook recipes from workflow follow-ups#74853
[docs][plugin sdk] Split host-hook recipes from workflow follow-ups#74853100yenadmin wants to merge 1 commit into
Conversation
|
Codex review: needs changes before merge. Summary Reproducibility: not applicable. this is a docs PR rather than a runtime bug. The high-confidence check is source inspection comparing the new cleanup matrix with Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Merge the docs split after the restart cleanup row and explanation match the current run-context lifecycle contract. Do we have a high-confidence way to reproduce the issue? Not applicable; this is a docs PR rather than a runtime bug. The high-confidence check is source inspection comparing the new cleanup matrix with Is this the best way to solve the issue? No, not yet. The docs split is the right shape, but the cleanup matrix should be corrected rather than changing runtime behavior. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 3b39ff43184d. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57098df02f
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Adds a new Plugin SDK documentation page that collects host-hook “recipe” examples and wires it into the docs navigation + zh-CN glossary, enabling maintainers and plugin authors to reference composition patterns separately from the implementation PR stack.
Changes:
- Added
docs/plugins/host-hooks-examples.md(host-hook recipes/examples page). - Added the page to
docs/docs.jsonnavigation. - Added zh-CN glossary entries for the page title and sidebar label.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| docs/plugins/host-hooks-examples.md | New long-form host-hook recipes page with contracts, examples, diagrams, and archetype compositions. |
| docs/docs.json | Adds the new page to the Plugins section nav. |
| docs/.i18n/glossary.zh-CN.json | Adds zh-CN glossary translations for the new page title/sidebar strings. |
57098df to
268b469
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c04613815
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6e66eb5cc1
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
16c0627 to
2261827
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22618273b2
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
2ce45c2 to
07fe0d2
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Fixed in |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
6fea20f to
a710cbb
Compare
a710cbb to
649ae9e
Compare
Reviewer map: what this docs PR teachesI refreshed the PR body, but I also want the core docs story visible directly in the conversation for reviewers skimming the timeline. The new page is intentionally a recipe book, not another API table. Its core question is:
System modelflowchart LR
A[Plugin entry: definePluginEntry] --> B[Grouped host-hook APIs]
B --> C[Session state, actions, UI descriptors]
B --> D[Next-turn injection, schedules, attachments]
B --> E[Agent events, run context, lifecycle cleanup]
C --> F[Workflow plugin recipes]
D --> F
E --> F
Author routingflowchart TD
Start[Plugin author asks: what can I build?]
Start --> Tools{Only static agent tools?}
Tools -->|yes| ToolDocs[Tool Plugins]
Tools -->|no| Provider{Provider auth, OAuth, runtime auth, model catalog?}
Provider -->|yes| ProviderDocs[Provider Plugins + Architecture Internals]
Provider -->|no| Runtime{Host-owned model calls or runtime utilities?}
Runtime -->|yes| RuntimeDocs[Runtime helpers]
Runtime -->|no| Hooks[Host-hook examples and recipes]
Hooks --> Workflow[Approval flows, policy gates, monitors, wizards, review assistants]
What the recipe page covers
The point of the PR is to make the current SDK seams obvious to both humans and AI agents without implying that provider/OAuth hooks, static tool plugins, or runtime helpers belong in this workflow-hook page. |
Final review evidence for
|
| Check | Result |
|---|---|
| Head commit | 649ae9e73f92a2b2b08aba6e95ff6b13145f3bfe |
check-docs |
Passing |
| Real behavior proof | Passing |
| CI preflight/security docs-relevant checks | Passing |
| Mergeability | MERGEABLE |
| Maintainer edits | maintainerCanModify: true |
| Review threads | 0 unresolved |
The PR body has also been expanded to follow the template and now includes the architecture map, source-aligned API coverage table, diagrams, real behavior proof, security impact, verification, and risks/mitigations so reviewers do not need prior context to understand the contribution.
649ae9e to
3465338
Compare
Follow-up polish on latest head
|
|
Closing temporarily for room. |
Summary
Describe the problem and fix in 2-5 bullets:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Why this PR exists
The SDK surface is no longer just a flat
registerTool(...)story. Current OpenClaw has grouped host-hook families for session state, workflow continuation, session controls, agent events, per-run context, and runtime lifecycle cleanup. That is powerful, but it is also easy to misread if the docs only expose API tables.This PR turns that surface into a recipe book. The new page answers the author-facing question directly:
The examples are intentionally product-neutral. Plan Mode is one tenant of these seams, not the privileged one. The same contracts can support approval workflows, workspace policy gates, background monitors, setup wizards, review assistants, release workflows, and future bundled plugins.
Reviewer guide
Changed files
docs/plugins/host-hooks-examples.mddocs/plugins/sdk-overview.mddocs/plugins/hooks.mddocs/docs.jsondocs/.i18n/glossary.zh-CN.jsondocs:check-i18n-glossary.How the recipe page is structured
The new page deliberately uses the same structure for every recipe:
This makes the page usable both for humans and for AI agents that need a stable pattern to follow.
System flow
Documentation routing
flowchart TD Start[Plugin author asks: what can I build?] Start --> Tools{Only static agent tools?} Tools -->|yes| ToolDocs[Tool Plugins] Tools -->|no| Provider{Provider auth, OAuth, runtime auth, model catalog?} Provider -->|yes| ProviderDocs[Provider Plugins + Architecture Internals] Provider -->|no| Runtime{Host-owned model calls or runtime utilities?} Runtime -->|yes| RuntimeDocs[Runtime helpers] Runtime -->|no| Hooks[Host-hook examples and recipes] Hooks --> Workflow[Approval flows, policy gates, monitors, wizards, review assistants]Current grouped host-hook surface covered
api.session.state.registerSessionExtension(...)SessionEntryslot mirrors.api.session.workflow.enqueueNextTurnInjection(...)api.session.workflow.registerSessionSchedulerJob(...)sendSessionAttachment(...),scheduleSessionTurn(...),unscheduleSessionTurnsByTag(...)api.session.controls.registerSessionAction(...)api.session.controls.registerControlUiDescriptor(...)api.agent.events.registerAgentEventSubscription(...),emitAgentEvent(...)api.runContext.setRunContext(...),getRunContext(...),clearRunContext(...)api.lifecycle.registerRuntimeLifecycle(...)api.registerTrustedToolPolicy(...),api.registerToolMetadata(...),api.registerCommand(...)Pulling directly from the docs
The opening of the new page frames the work this way:
The quick-start block then gives authors the current grouped API map:
Two important examples of source-aligned polish in this PR:
GatewaySessionRow.pluginExtensionsis described as an array of{ pluginId, namespace, value }entries, not a nested object. Any nested lookup map is explicitly client-derived.pluginIdor${pluginId}.*) and calls out that host-reserved streams likelifecycle,assistant,tool, andapprovalare bundled-only.How selected recipes work
Session state projection
sequenceDiagram autonumber participant Plugin participant Reg as Registry participant Store as Session Store participant GW as Gateway participant UI as Control UI Plugin->>Reg: registerSessionExtension({namespace, project, cleanup}) Note over Reg,Store: namespace + pluginId now valid for sessions.pluginPatch UI->>GW: sessions.pluginPatch({pluginId, namespace, value}) GW->>Reg: validate pluginId, namespace, and operator.admin scope Reg->>Store: write namespaced state Store-->>GW: { ok, key, value } GW-->>UI: { ok, key, value } GW-->>UI: sessions.changed notification UI->>GW: refresh session row GW->>Plugin: build row projection with project({sessionKey, sessionId, state}) Plugin-->>GW: pluginExtensions[] projection entry GW-->>UI: refreshed row and declared slot mirror when enabledControl UI descriptors
Control UI contributions are data-only. The plugin supplies a JSON descriptor; clients own rendering. That keeps plugin code out of client surfaces while still letting plugins expose review cards, budget meters, status panels, settings panels, and action-driven UX.
Session action dispatch
sequenceDiagram autonumber participant Client participant Gateway participant Registry participant Plugin participant Agent Client->>Gateway: plugins.sessionAction({pluginId, actionId, sessionKey, payload}) Gateway->>Registry: find action and requiredScopes Gateway->>Gateway: validate caller scopes + JSON schema Gateway->>Plugin: handler({pluginId, actionId, sessionKey, payload, client}) Plugin->>Gateway: { result, continueAgent } Gateway-->>Client: { ok:true, result, continueAgent } Gateway->>Agent: optional continuation path via next-turn injectionEvent emission contract
The event-emission recipe was tightened after review. External plugins must use plugin-id-scoped streams:
That matches
src/plugins/agent-event-emission.ts: external plugins cannot emit host-reserved streams and cannot emit streams owned by another plugin id.Scope boundaries and non-goals
sdk-provider-pluginsandarchitecture-internals; this page does not duplicate that provider catalog.tool-plugins; this page focuses on workflow-style host hooks.sdk-runtime; this page only points authors there.Real behavior proof (required for external PRs)
/Volumes/LEXAR/repos/openclaw-host-hook-docson branchdocs/plugin-sdk-host-hook-recipes-split-refresh, plus GitHub Actions docs CI for commit3465338a09.3465338a09passed after the event-stream wording correction and final docs-consistency polish, includingcheck-docsand Real behavior proof.plugin.review; current docs now usereview-concierge.review, matching plugin-id-scoped stream policy.Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.emitPluginAgentEvent(...)and the contract tests.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.src/plugins/contracts/session-actions.contract.test.tsalready covers plugin-id-scoped event emission; docs checks cover the changed Markdown/links/navigation.session-actions.contract.test.tsacceptsworkspace-event-plugin.workflowand rejectsother-plugin.workflowfor the workspace plugin.User-visible / Behavior Changes
Plugin authors now get a navigable recipe guide for workflow-style host hooks, linked from Plugin SDK overview, Plugin hooks, and the docs sidebar. Runtime users see no behavior change.
Diagram (if applicable)
Additional system diagram:
Security Impact (required)
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
/Volumes/LEXAR/repos/openclaw-host-hook-docs; GitHub Actions Ubuntu runner for docs CI.Steps
3465338a09and wait for PR checks.Expected
Actual
3465338a09.3465338a09passed, includingcheck-docsand Real behavior proof.Evidence
Attach at least one:
Evidence is embedded above under Real behavior proof and includes copied terminal output plus the current GitHub
check-docsand Real behavior proof checks for3465338a09.Human Verification (required)
What you personally verified (not just CI), and how:
pluginExtensionswording, event stream scoping, non-current API caveats,SessionEntryslot mirror wording, bundled-only helper labeling.Review Conversations
The latest ClawSweeper issue-comment finding about
plugin.*event streams is addressed in commit3465338a09: the recipe now uses plugin-id-scoped streams and explains the bundled-only reserved-stream exception.Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoRisks and Mitigations
src/plugins/types.ts, and was checked against the event-emission source/contract test after bot review.