Skip to content

Commit 67a447c

Browse files
committed
refactor: tighten plugin runtime sdk boundaries
1 parent b181930 commit 67a447c

31 files changed

Lines changed: 234 additions & 63 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Docs: https://docs.openclaw.ai
88

99
### Changes
1010

11+
- Plugins/runtime: expose provider-backed thinking policy and normalization through `api.runtime.agent`, letting tool plugins validate thinking overrides without duplicating provider/model level lists. Thanks @openclaw.
1112
- Providers: add Cerebras as a bundled plugin with onboarding, static model catalog, docs, and manifest-owned endpoint metadata.
1213
- Memory/OpenAI-compatible: add optional `memorySearch.inputType`, `queryInputType`, and `documentInputType` config for asymmetric embedding endpoints, including direct query embeddings and provider batch indexing. Carries forward #63313 and #60727. Thanks @HOYALIM and @prospect1314521.
1314
- Ollama/memory: add model-specific retrieval query prefixes for `nomic-embed-text`, `qwen3-embedding`, and `mxbai-embed-large` memory-search queries while leaving document batches unchanged. Carries forward #45013. Thanks @laolin5564.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
491267e919c6bf426f673a9066e703811c7779a32de87edd0ce493147fd4438e plugin-sdk-api-baseline.json
2-
590d21aeb520f34b5bf23abb7b17602b204f170547c772d60b604bb34a3940bb plugin-sdk-api-baseline.jsonl
1+
b81647828ee6599cdd1d76d96ea02c92ccdebb8c1b3b443cefe10ca8bd2ddbfe plugin-sdk-api-baseline.json
2+
ca9f3569352522621857b51872f30b3c31881505fd9eff2451b1b46d77670726 plugin-sdk-api-baseline.jsonl

docs/plugins/sdk-runtime.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,18 @@ Internal OpenClaw runtime code has the same direction: load config once at the C
6262
const identity = api.runtime.agent.resolveAgentIdentity(cfg);
6363

6464
// Get default thinking level
65-
const thinking = api.runtime.agent.resolveThinkingDefault(cfg, provider, model);
65+
const thinking = api.runtime.agent.resolveThinkingDefault({
66+
cfg,
67+
provider,
68+
model,
69+
});
70+
71+
// Validate a user-provided thinking level against the active provider profile
72+
const policy = api.runtime.agent.resolveThinkingPolicy({ provider, model });
73+
const level = api.runtime.agent.normalizeThinkingLevel("extra high");
74+
if (level && policy.levels.some((entry) => entry.id === level)) {
75+
// pass level to an embedded run
76+
}
6677

6778
// Get agent timeout
6879
const timeoutMs = api.runtime.agent.resolveAgentTimeoutMs(cfg);
@@ -86,6 +97,10 @@ Internal OpenClaw runtime code has the same direction: load config once at the C
8697

8798
`runEmbeddedPiAgent(...)` remains as a compatibility alias.
8899

100+
`resolveThinkingPolicy(...)` returns the provider/model's supported thinking levels and optional default. Provider plugins own the model-specific profile through their thinking hooks, so tool plugins should call this runtime helper instead of importing or duplicating provider lists.
101+
102+
`normalizeThinkingLevel(...)` converts user text such as `on`, `x-high`, or `extra high` to the canonical stored level before checking it against the resolved policy.
103+
89104
**Session store helpers** are under `api.runtime.agent.session`:
90105

91106
```typescript

docs/plugins/sdk-subpaths.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview)
138138
| `plugin-sdk/allow-from` | `formatAllowFromLowercase` |
139139
| `plugin-sdk/channel-secret-runtime` | Narrow secret-contract collection helpers for channel/plugin secret surfaces |
140140
| `plugin-sdk/secret-ref-runtime` | Narrow `coerceSecretRef` and SecretRef typing helpers for secret-contract/config parsing |
141-
| `plugin-sdk/security-runtime` | Shared trust, DM gating, external-content, constant-time secret comparison, and secret-collection helpers |
141+
| `plugin-sdk/security-runtime` | Shared trust, DM gating, external-content, sensitive text redaction, constant-time secret comparison, and secret-collection helpers |
142142
| `plugin-sdk/ssrf-policy` | Host allowlist and private-network SSRF policy helpers |
143143
| `plugin-sdk/ssrf-dispatcher` | Narrow pinned-dispatcher helpers without the broad infra runtime surface |
144144
| `plugin-sdk/ssrf-runtime` | Pinned-dispatcher, SSRF-guarded fetch, SSRF error, and SSRF policy helpers |
@@ -201,7 +201,7 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview)
201201
| `plugin-sdk/provider-zai-endpoint` | Z.AI endpoint detection helpers |
202202
| `plugin-sdk/infra-runtime` | System event/heartbeat helpers |
203203
| `plugin-sdk/collection-runtime` | Small bounded cache helpers |
204-
| `plugin-sdk/diagnostic-runtime` | Diagnostic flag and event helpers |
204+
| `plugin-sdk/diagnostic-runtime` | Diagnostic flag, event, and trace-context helpers |
205205
| `plugin-sdk/error-runtime` | Error graph, formatting, shared error classification helpers, `isApprovalNotFoundError` |
206206
| `plugin-sdk/fetch-runtime` | Wrapped fetch, proxy, and pinned lookup helpers |
207207
| `plugin-sdk/runtime-fetch` | Dispatcher-aware runtime fetch without proxy/guarded-fetch imports |

docs/tools/thinking.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,6 @@ Malformed local-model reasoning tags are handled conservatively. Closed `<think>
124124

125125
- Provider plugins can expose `resolveThinkingProfile(ctx)` to define the model's supported levels and default.
126126
- Each profile level has a stored canonical `id` (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `adaptive`, or `max`) and may include a display `label`. Binary providers use `{ id: "low", label: "on" }`.
127+
- Tool plugins that need to validate an explicit thinking override should use `api.runtime.agent.resolveThinkingPolicy({ provider, model })` plus `api.runtime.agent.normalizeThinkingLevel(...)`; they should not keep their own provider/model level lists.
127128
- Published legacy hooks (`supportsXHighThinking`, `isBinaryThinking`, and `resolveDefaultThinkingLevel`) remain as compatibility adapters, but new custom level sets should use `resolveThinkingProfile`.
128129
- Gateway rows/defaults expose `thinkingLevels`, `thinkingOptions`, and `thinkingDefault` so ACP/chat clients render the same profile ids and labels that runtime validation uses.

extensions/diagnostics-otel/api.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1-
export * from "openclaw/plugin-sdk/diagnostics-otel";
1+
export {
2+
createChildDiagnosticTraceContext,
3+
createDiagnosticTraceContext,
4+
emitDiagnosticEvent,
5+
formatDiagnosticTraceparent,
6+
isValidDiagnosticSpanId,
7+
isValidDiagnosticTraceFlags,
8+
isValidDiagnosticTraceId,
9+
onDiagnosticEvent,
10+
parseDiagnosticTraceparent,
11+
type DiagnosticEventMetadata,
12+
type DiagnosticEventPayload,
13+
type DiagnosticTraceContext,
14+
} from "openclaw/plugin-sdk/diagnostic-runtime";
15+
export { emptyPluginConfigSchema, type OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
16+
export type {
17+
OpenClawPluginService,
18+
OpenClawPluginServiceContext,
19+
} from "openclaw/plugin-sdk/plugin-entry";
20+
export { redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
export * from "openclaw/plugin-sdk/diagnostics-prometheus";
1+
export type {
2+
DiagnosticEventMetadata,
3+
DiagnosticEventPayload,
4+
} from "openclaw/plugin-sdk/diagnostic-runtime";
5+
export {
6+
emptyPluginConfigSchema,
7+
type OpenClawPluginApi,
8+
type OpenClawPluginHttpRouteHandler,
9+
type OpenClawPluginService,
10+
type OpenClawPluginServiceContext,
11+
} from "openclaw/plugin-sdk/plugin-entry";
12+
export { redactSensitiveText } from "openclaw/plugin-sdk/security-runtime";

extensions/diffs/api.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
export * from "openclaw/plugin-sdk/diffs";
1+
export type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
2+
export {
3+
definePluginEntry,
4+
type AnyAgentTool,
5+
type OpenClawPluginApi,
6+
type OpenClawPluginConfigSchema,
7+
type OpenClawPluginToolContext,
8+
type PluginLogger,
9+
} from "openclaw/plugin-sdk/plugin-entry";
10+
export { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";

extensions/googlechat/runtime-api.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export {
3030
export { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";
3131
export { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
3232
export type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
33+
export { GoogleChatConfigSchema } from "openclaw/plugin-sdk/channel-config-schema-legacy";
3334
export {
3435
GROUP_POLICY_BLOCKED_LABEL,
3536
isDangerousNameMatchingEnabled,
@@ -41,11 +42,7 @@ export { fetchRemoteMedia, resolveChannelMediaMaxBytes } from "openclaw/plugin-s
4142
export { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
4243
export type { PluginRuntime } from "openclaw/plugin-sdk/runtime-store";
4344
export { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
44-
export {
45-
GoogleChatConfigSchema,
46-
type GoogleChatAccountConfig,
47-
type GoogleChatConfig,
48-
} from "openclaw/plugin-sdk/googlechat-runtime-shared";
45+
export type { GoogleChatAccountConfig, GoogleChatConfig } from "openclaw/plugin-sdk/config-runtime";
4946
export { extractToolSend } from "openclaw/plugin-sdk/tool-send";
5047
export { resolveInboundMentionDecision } from "openclaw/plugin-sdk/channel-inbound";
5148
export { resolveInboundRouteEnvelopeBuilderWithRuntime } from "openclaw/plugin-sdk/inbound-envelope";

extensions/llm-task/api.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
export * from "openclaw/plugin-sdk/llm-task";
1+
export * from "./src/runtime-api.js";
2+
export {
3+
definePluginEntry,
4+
type AnyAgentTool,
5+
type OpenClawPluginApi,
6+
} from "openclaw/plugin-sdk/plugin-entry";

0 commit comments

Comments
 (0)