Skip to content

Commit 8a3f5c8

Browse files
authored
fix(plugin-sdk): ship documented public typings (#116345)
* fix(plugin-sdk): ship documented public typings * fix(plugin-sdk): refresh public contract artifacts
1 parent a4c6efc commit 8a3f5c8

8 files changed

Lines changed: 64 additions & 21 deletions

‎docs/.generated/plugin-sdk-api-baseline.sha256‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ aa8a411ad37c1d1143b67376bf2d20255b9eedff61d80815f42e4f8ed7bd8e58 module/secret-
121121
57dcb1462d4c4f9a98d934c4ca975b163d704758af9821a64001ff3ac05637c3 module/secret-input-runtime
122122
e576b537880f63b3a91f3608f7e84c873bce6c6a3d9a0ba98c247f46de788d25 module/secret-ref-runtime
123123
62ccaafc8e0677e850339f4a4333f9f16ae9fed979bcef003890b2a47507147f module/security-runtime
124+
673c64502fdffb2d6361a7cf2ad0c33ffe15707b5e5027de1d88701ce3d8ade1 module/session-catalog
124125
31b785e74f1f8f56241b7756ef6a5d86199c5ce177cbb1c234a261866972f270 module/session-discussion
125126
f112bdabc51ba8659b37d0a6f6a32a2b1d471e5b49b56e108bf750ec55a7ea71 module/session-store-runtime
126127
36affbe151431a6141664b6838e20f2d121ff210d57a3c1b4b41a8818b5c81d8 module/setup
@@ -138,6 +139,7 @@ ff35f9f74d35d37a2eb6126b57f3dc5a4d580b6222fe3a34c9368779ad32eab7 module/state-p
138139
0e230313a7a27a915a7aa399c0afd94c4c3e10d485c7b513e757f41bfc362dbe module/text-chunking
139140
25b5366f5d0f5826f520f847e0ae701936e97302d5ac62042d65f5be0f6974d2 module/text-runtime
140141
a94c9ff59cc361b04f8731a47d722c4bc88cfabf942221369a8cb67bdcda7249 module/tool-plugin
142+
89846974257b7551d46a514902998d0592fc67b1d8ce036c6514d7b9cd1bc159 module/tool-results
141143
9d6ab352913a573b226e054e1dc8c6d088493aea9954950c65585923b5b6895a module/tool-send
142144
541df9dea799f25e83ea483d481ecebc5b91c016effab593c54d3efe3ee6517b module/web-media
143145
2d9a53e49d9092804945248efa6d03ce0099cfa7a1c9d7836782754b5e99ebb3 module/webhook-ingress

‎docs/plugins/sdk-subpaths.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ Use `isLoopbackHost(host)` when a plugin must accept only the local machine. It
248248
| `plugin-sdk/reply-reference` | Private-local after July 2026; `createReplyReferencePlanner` |
249249
| `plugin-sdk/reply-chunking` | Narrow text/markdown chunking helpers |
250250
| `plugin-sdk/session-store-runtime` | Session workflow helpers (`getSessionEntry`, `listSessionEntries`, `patchSessionEntry`, `upsertSessionEntry`), repair/lifecycle helpers (`deleteSessionEntry`, `cleanupSessionLifecycleArtifacts`, `resolveSessionStoreBackupPaths`), marker helpers for transitional `sessionFile` values, bounded recent user/assistant transcript text reads by session identity, session store path/session-key helpers, and updated-at reads, without broad config writes/maintenance imports |
251+
| `plugin-sdk/session-catalog` | External session catalog contracts, projections, adoption helpers, and history import |
251252
| `plugin-sdk/session-transcript-runtime` | Private-local after July 2026; Transcript identity, bounded raw and visible cursors, scoped target/read/write helpers, visible message-entry projection, update publishing, write locks, and transcript memory hit keys |
252253
| `plugin-sdk/sqlite-runtime` | Private-local after July 2026; Focused SQLite agent-schema, path, and transaction helpers for first-party runtime, without database lifecycle controls |
253254
| `plugin-sdk/cron-store-runtime` | Private-local after July 2026; Cron store path/load/save helpers |
@@ -262,6 +263,7 @@ Use `isLoopbackHost(host)` when a plugin must accept only the local machine. It
262263
| `plugin-sdk/param-readers` | Common tool/CLI param readers |
263264
| `plugin-sdk/tool-plugin` | Define a simple typed agent-tool plugin and expose static metadata for manifest generation |
264265
| `plugin-sdk/tool-payload` | Private-local after July 2026; Extract normalized payloads from tool result objects |
266+
| `plugin-sdk/tool-results` | Typed text and JSON agent tool result builders |
265267
| `plugin-sdk/tool-send` | Extract canonical send target fields from tool args |
266268
| `plugin-sdk/sandbox` | Private-local after July 2026; Sandbox backend types and SSH/OpenShell command helpers, including fail-fast exec command preflight |
267269
| `plugin-sdk/temp-path` | Shared temp-download path helpers and private secure temp workspaces |

‎extensions/tsconfig.package-boundary.paths.json‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,6 @@
296296
"openclaw/plugin-sdk/session-binding-runtime": [
297297
"../packages/plugin-sdk/dist/src/plugin-sdk/session-binding-runtime.d.ts"
298298
],
299-
"openclaw/plugin-sdk/session-catalog": [
300-
"../packages/plugin-sdk/dist/src/plugin-sdk/session-catalog.d.ts"
301-
],
302299
"openclaw/plugin-sdk/session-catalog-runtime": [
303300
"../packages/plugin-sdk/dist/src/plugin-sdk/session-catalog-runtime.d.ts"
304301
],
@@ -515,9 +512,6 @@
515512
"openclaw/plugin-sdk/tool-payload": [
516513
"../packages/plugin-sdk/dist/src/plugin-sdk/tool-payload.d.ts"
517514
],
518-
"openclaw/plugin-sdk/tool-results": [
519-
"../packages/plugin-sdk/dist/src/plugin-sdk/tool-results.d.ts"
520-
],
521515
"openclaw/plugin-sdk/webhook-targets": [
522516
"../packages/plugin-sdk/dist/src/plugin-sdk/webhook-targets.d.ts"
523517
],

‎extensions/xai/tsconfig.json‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,6 @@
294294
"openclaw/plugin-sdk/session-binding-runtime": [
295295
"../../packages/plugin-sdk/dist/src/plugin-sdk/session-binding-runtime.d.ts"
296296
],
297-
"openclaw/plugin-sdk/session-catalog": [
298-
"../../packages/plugin-sdk/dist/src/plugin-sdk/session-catalog.d.ts"
299-
],
300297
"openclaw/plugin-sdk/session-catalog-runtime": [
301298
"../../packages/plugin-sdk/dist/src/plugin-sdk/session-catalog-runtime.d.ts"
302299
],
@@ -513,9 +510,6 @@
513510
"openclaw/plugin-sdk/tool-payload": [
514511
"../../packages/plugin-sdk/dist/src/plugin-sdk/tool-payload.d.ts"
515512
],
516-
"openclaw/plugin-sdk/tool-results": [
517-
"../../packages/plugin-sdk/dist/src/plugin-sdk/tool-results.d.ts"
518-
],
519513
"openclaw/plugin-sdk/webhook-targets": [
520514
"../../packages/plugin-sdk/dist/src/plugin-sdk/webhook-targets.d.ts"
521515
],

‎package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@
183183
"!dist/plugin-sdk/secret-file-runtime.d.ts",
184184
"!dist/plugin-sdk/secure-random-runtime.d.ts",
185185
"!dist/plugin-sdk/session-binding-runtime.d.ts",
186-
"!dist/plugin-sdk/session-catalog.d.ts",
187186
"!dist/plugin-sdk/session-catalog-runtime.d.ts",
188187
"!dist/plugin-sdk/session-key-runtime.d.ts",
189188
"!dist/plugin-sdk/session-transcript-hit.d.ts",
@@ -224,7 +223,6 @@
224223
"!dist/plugin-sdk/thread-bindings-session-runtime.d.ts",
225224
"!dist/plugin-sdk/time-runtime.d.ts",
226225
"!dist/plugin-sdk/tool-payload.d.ts",
227-
"!dist/plugin-sdk/tool-results.d.ts",
228226
"!dist/plugin-sdk/transcripts.d.ts",
229227
"!dist/plugin-sdk/transport-ready-runtime.d.ts",
230228
"!dist/plugin-sdk/tts-runtime.d.ts",
@@ -1022,6 +1020,7 @@
10221020
"default": "./dist/plugin-sdk/session-binding-runtime.js"
10231021
},
10241022
"./plugin-sdk/session-catalog": {
1023+
"types": "./dist/plugin-sdk/session-catalog.d.ts",
10251024
"default": "./dist/plugin-sdk/session-catalog.js"
10261025
},
10271026
"./plugin-sdk/session-catalog-runtime": {
@@ -1370,6 +1369,7 @@
13701369
"default": "./dist/plugin-sdk/tool-payload.js"
13711370
},
13721371
"./plugin-sdk/tool-results": {
1372+
"types": "./dist/plugin-sdk/tool-results.d.ts",
13731373
"default": "./dist/plugin-sdk/tool-results.js"
13741374
},
13751375
"./plugin-sdk/tool-send": {

‎scripts/lib/plugin-sdk-private-local-only-subpaths.json‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@
136136
"secret-file-runtime",
137137
"secure-random-runtime",
138138
"session-binding-runtime",
139-
"session-catalog",
140139
"session-catalog-runtime",
141140
"session-key-runtime",
142141
"session-transcript-hit",
@@ -167,7 +166,6 @@
167166
"thread-bindings-session-runtime",
168167
"time-runtime",
169168
"tool-payload",
170-
"tool-results",
171169
"transcripts",
172170
"transport-ready-runtime",
173171
"tts-runtime",

‎scripts/plugin-sdk-surface-report.mjs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ export function readPluginSdkSurfaceBudgets(env = process.env) {
158158
// +1: bounded archive extraction and single-entry reads.
159159
// +1: budgeted root-bounded directory walking.
160160
// +1: pinned secret reads and first-writer-wins creation.
161-
146,
161+
// +2: restore the documented session-catalog and tool-results plugin contracts.
162+
148,
162163
env,
163164
),
164165
publicExports: readPluginSdkSurfaceBudgetEnv(
@@ -204,7 +205,8 @@ export function readPluginSdkSurfaceBudgets(env = process.env) {
204205
// +2: shared ingress error factory through channel-outbound and channel-message.
205206
// +2: shared ingress retention defaults through channel-outbound and channel-message.
206207
// +1: collision-safe MCP server-name assignment for native harness catalogs.
207-
4774,
208+
// +45: restore typed session-catalog and tool-results exports promised to plugins.
209+
4819,
208210
env,
209211
),
210212
publicFunctionExports: readPluginSdkSurfaceBudgetEnv(
@@ -242,7 +244,8 @@ export function readPluginSdkSurfaceBudgets(env = process.env) {
242244
// +1: inbound media-fact metadata projection for plugin-owned channel ingestion.
243245
// +2: shared ingress error factory through channel-outbound and channel-message.
244246
// +1: collision-safe MCP server-name assignment for native harness catalogs.
245-
2882,
247+
// +14: restore callable session-catalog and tool-results helpers promised to plugins.
248+
2896,
246249
env,
247250
),
248251
publicDeprecatedExports: readPluginSdkSurfaceBudgetEnv(

‎src/plugins/contracts/plugin-sdk-package-contract-guardrails.test.ts‎

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const PUBLIC_CONTRACT_REFERENCE_FILES = [
2727
"docs/plugins/architecture.md",
2828
"src/plugins/contracts/plugin-sdk-subpaths.test.ts",
2929
] as const;
30+
const TYPED_PUBLIC_CONTRACT_REFERENCE_FILES = ["docs/plugins/sdk-entrypoints.md"] as const;
3031
const PLUGIN_SDK_SUBPATH_PATTERN = /openclaw\/plugin-sdk\/([a-z0-9][a-z0-9-]*)\b/g;
3132
const BUNDLED_PLUGIN_FACADE_LOADER_PATTERN =
3233
/\bload(?:Activated)?BundledPluginPublicSurfaceModuleSync\b/;
@@ -142,9 +143,39 @@ function collectPluginSdkPackageExports(): string[] {
142143
return subpaths.toSorted();
143144
}
144145

145-
function collectPluginSdkSubpathReferences() {
146+
function collectTypedPluginSdkPackageExports(): Set<string> {
147+
const packageJson = JSON.parse(fs.readFileSync(resolve(REPO_ROOT, "package.json"), "utf8")) as {
148+
exports?: Record<string, unknown>;
149+
};
150+
const typedSubpaths = new Set<string>();
151+
for (const [key, value] of Object.entries(packageJson.exports ?? {})) {
152+
if (
153+
key.startsWith("./plugin-sdk/") &&
154+
value &&
155+
typeof value === "object" &&
156+
"types" in value &&
157+
typeof value.types === "string"
158+
) {
159+
typedSubpaths.add(key.slice("./plugin-sdk/".length));
160+
}
161+
}
162+
return typedSubpaths;
163+
}
164+
165+
function collectPackExcludedPluginSdkDeclarations(): Set<string> {
166+
const packageJson = readRootPackageJson();
167+
return new Set(
168+
(packageJson.files ?? [])
169+
.map((entry) => /^!dist\/plugin-sdk\/([a-z0-9][a-z0-9-]*)\.d\.ts$/u.exec(entry)?.[1])
170+
.filter((subpath): subpath is string => Boolean(subpath)),
171+
);
172+
}
173+
174+
function collectPluginSdkSubpathReferences(
175+
files: readonly string[] = PUBLIC_CONTRACT_REFERENCE_FILES,
176+
) {
146177
const references: Array<{ file: string; subpath: string }> = [];
147-
for (const file of PUBLIC_CONTRACT_REFERENCE_FILES) {
178+
for (const file of files) {
148179
const source = fs.readFileSync(resolve(REPO_ROOT, file), "utf8");
149180
for (const match of source.matchAll(PLUGIN_SDK_SUBPATH_PATTERN)) {
150181
const subpath = match[1];
@@ -876,6 +907,25 @@ describe("plugin-sdk package contract guardrails", () => {
876907
expect(failures).toStrictEqual([]);
877908
});
878909

910+
it("keeps SDK entrypoint guide imports on typed public package exports", () => {
911+
const publicEntrypoints = new Set(publicPluginSdkEntrypoints);
912+
const typedExports = collectTypedPluginSdkPackageExports();
913+
const excludedDeclarations = collectPackExcludedPluginSdkDeclarations();
914+
const failures = collectPluginSdkSubpathReferences(TYPED_PUBLIC_CONTRACT_REFERENCE_FILES)
915+
.filter(
916+
({ subpath }) =>
917+
!publicEntrypoints.has(subpath) ||
918+
!typedExports.has(subpath) ||
919+
excludedDeclarations.has(subpath),
920+
)
921+
.map(
922+
({ file, subpath }) =>
923+
`${file} references openclaw/plugin-sdk/${subpath}, but its declaration is not included in the typed public package`,
924+
);
925+
926+
expect(failures).toStrictEqual([]);
927+
});
928+
879929
it("keeps deprecated public SDK subpaths unused by extension production code", () => {
880930
const publicEntrypoints = new Set(publicPluginSdkEntrypoints);
881931
const unknownDeprecated = deprecatedPublicPluginSdkEntrypoints.filter(

0 commit comments

Comments
 (0)