Skip to content

Commit c26655d

Browse files
committed
fix: stabilize plugin sdk api baselines
1 parent 4240c64 commit c26655d

3 files changed

Lines changed: 61 additions & 26 deletions

File tree

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@
12691269
}
12701270
},
12711271
{
1272-
"declaration": "export type ReplyPrefixContext = import(\"/Users/steipete/Projects/clawdbot2/src/auto-reply/reply/response-prefix-template\").ResponsePrefixContext;",
1272+
"declaration": "export type ReplyPrefixContext = import(\"src/auto-reply/reply/response-prefix-template\").ResponsePrefixContext;",
12731273
"exportName": "ReplyPrefixContext",
12741274
"kind": "type",
12751275
"source": {
@@ -3338,7 +3338,7 @@
33383338
}
33393339
},
33403340
{
3341-
"declaration": "export type ChannelOutboundSessionRouteParams = { cfg: OpenClawConfig; agentId: string; accountId?: string | null; target: string; resolvedTarget?: { to: string; kind: import(\"/Users/steipete/Projects/clawdbot2/src/channels/plugins/types.core\").ChannelDirectoryEntryKind | \"channel\"; display?: string; source: \"normalized\" | \"directory\"; }; replyToId?: string | null; threadId?: string | number | null;};",
3341+
"declaration": "export type ChannelOutboundSessionRouteParams = { cfg: OpenClawConfig; agentId: string; accountId?: string | null; target: string; resolvedTarget?: { to: string; kind: import(\"src/channels/plugins/types.core\").ChannelDirectoryEntryKind | \"channel\"; display?: string; source: \"normalized\" | \"directory\"; }; replyToId?: string | null; threadId?: string | number | null;};",
33423342
"exportName": "ChannelOutboundSessionRouteParams",
33433343
"kind": "type",
33443344
"source": {
@@ -4886,7 +4886,7 @@
48864886
"exportName": "isRequestBodyLimitError",
48874887
"kind": "function",
48884888
"source": {
4889-
"line": 46,
4889+
"line": 47,
48904890
"path": "src/infra/http-body.ts"
48914891
}
48924892
},
@@ -4913,7 +4913,7 @@
49134913
"exportName": "readRequestBodyWithLimit",
49144914
"kind": "function",
49154915
"source": {
4916-
"line": 121,
4916+
"line": 122,
49174917
"path": "src/infra/http-body.ts"
49184918
}
49194919
},
@@ -4958,7 +4958,7 @@
49584958
"exportName": "requestBodyErrorToText",
49594959
"kind": "function",
49604960
"source": {
4961-
"line": 59,
4961+
"line": 60,
49624962
"path": "src/infra/http-body.ts"
49634963
}
49644964
},

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
{"declaration":"export function createChannelReplyPipeline(params: { cfg: OpenClawConfig; agentId: string; channel?: string | undefined; accountId?: string | undefined; typing?: CreateTypingCallbacksParams | undefined; typingCallbacks?: TypingCallbacks | undefined; }): ChannelReplyPipeline;","entrypoint":"channel-reply-pipeline","exportName":"createChannelReplyPipeline","importSpecifier":"openclaw/plugin-sdk/channel-reply-pipeline","kind":"function","recordType":"export","sourceLine":20,"sourcePath":"src/plugin-sdk/channel-reply-pipeline.ts"}
139139
{"declaration":"export type ChannelReplyPipeline = ChannelReplyPipeline;","entrypoint":"channel-reply-pipeline","exportName":"ChannelReplyPipeline","importSpecifier":"openclaw/plugin-sdk/channel-reply-pipeline","kind":"type","recordType":"export","sourceLine":16,"sourcePath":"src/plugin-sdk/channel-reply-pipeline.ts"}
140140
{"declaration":"export type CreateTypingCallbacksParams = CreateTypingCallbacksParams;","entrypoint":"channel-reply-pipeline","exportName":"CreateTypingCallbacksParams","importSpecifier":"openclaw/plugin-sdk/channel-reply-pipeline","kind":"type","recordType":"export","sourceLine":11,"sourcePath":"src/channels/typing.ts"}
141-
{"declaration":"export type ReplyPrefixContext = import(\"/Users/steipete/Projects/clawdbot2/src/auto-reply/reply/response-prefix-template\").ResponsePrefixContext;","entrypoint":"channel-reply-pipeline","exportName":"ReplyPrefixContext","importSpecifier":"openclaw/plugin-sdk/channel-reply-pipeline","kind":"type","recordType":"export","sourceLine":12,"sourcePath":"src/plugin-sdk/channel-reply-pipeline.ts"}
141+
{"declaration":"export type ReplyPrefixContext = import(\"src/auto-reply/reply/response-prefix-template\").ResponsePrefixContext;","entrypoint":"channel-reply-pipeline","exportName":"ReplyPrefixContext","importSpecifier":"openclaw/plugin-sdk/channel-reply-pipeline","kind":"type","recordType":"export","sourceLine":12,"sourcePath":"src/plugin-sdk/channel-reply-pipeline.ts"}
142142
{"declaration":"export type ReplyPrefixContextBundle = ReplyPrefixContextBundle;","entrypoint":"channel-reply-pipeline","exportName":"ReplyPrefixContextBundle","importSpecifier":"openclaw/plugin-sdk/channel-reply-pipeline","kind":"type","recordType":"export","sourceLine":12,"sourcePath":"src/channels/reply-prefix.ts"}
143143
{"declaration":"export type ReplyPrefixOptions = ReplyPrefixOptions;","entrypoint":"channel-reply-pipeline","exportName":"ReplyPrefixOptions","importSpecifier":"openclaw/plugin-sdk/channel-reply-pipeline","kind":"type","recordType":"export","sourceLine":20,"sourcePath":"src/channels/reply-prefix.ts"}
144144
{"declaration":"export type TypingCallbacks = TypingCallbacks;","entrypoint":"channel-reply-pipeline","exportName":"TypingCallbacks","importSpecifier":"openclaw/plugin-sdk/channel-reply-pipeline","kind":"type","recordType":"export","sourceLine":4,"sourcePath":"src/channels/typing.ts"}
@@ -367,7 +367,7 @@
367367
{"declaration":"export type ChannelMessageActionContext = ChannelMessageActionContext;","entrypoint":"core","exportName":"ChannelMessageActionContext","importSpecifier":"openclaw/plugin-sdk/core","kind":"type","recordType":"export","sourceLine":481,"sourcePath":"src/channels/plugins/types.core.ts"}
368368
{"declaration":"export type ChannelMessagingAdapter = ChannelMessagingAdapter;","entrypoint":"core","exportName":"ChannelMessagingAdapter","importSpecifier":"openclaw/plugin-sdk/core","kind":"type","recordType":"export","sourceLine":394,"sourcePath":"src/channels/plugins/types.core.ts"}
369369
{"declaration":"export type ChannelOutboundSessionRoute = ChannelOutboundSessionRoute;","entrypoint":"core","exportName":"ChannelOutboundSessionRoute","importSpecifier":"openclaw/plugin-sdk/core","kind":"type","recordType":"export","sourceLine":308,"sourcePath":"src/channels/plugins/types.core.ts"}
370-
{"declaration":"export type ChannelOutboundSessionRouteParams = { cfg: OpenClawConfig; agentId: string; accountId?: string | null; target: string; resolvedTarget?: { to: string; kind: import(\"/Users/steipete/Projects/clawdbot2/src/channels/plugins/types.core\").ChannelDirectoryEntryKind | \"channel\"; display?: string; source: \"normalized\" | \"directory\"; }; replyToId?: string | null; threadId?: string | number | null;};","entrypoint":"core","exportName":"ChannelOutboundSessionRouteParams","importSpecifier":"openclaw/plugin-sdk/core","kind":"type","recordType":"export","sourceLine":136,"sourcePath":"src/plugin-sdk/core.ts"}
370+
{"declaration":"export type ChannelOutboundSessionRouteParams = { cfg: OpenClawConfig; agentId: string; accountId?: string | null; target: string; resolvedTarget?: { to: string; kind: import(\"src/channels/plugins/types.core\").ChannelDirectoryEntryKind | \"channel\"; display?: string; source: \"normalized\" | \"directory\"; }; replyToId?: string | null; threadId?: string | number | null;};","entrypoint":"core","exportName":"ChannelOutboundSessionRouteParams","importSpecifier":"openclaw/plugin-sdk/core","kind":"type","recordType":"export","sourceLine":136,"sourcePath":"src/plugin-sdk/core.ts"}
371371
{"declaration":"export type ChannelPlugin = ChannelPlugin<ResolvedAccount, Probe, Audit>;","entrypoint":"core","exportName":"ChannelPlugin","importSpecifier":"openclaw/plugin-sdk/core","kind":"type","recordType":"export","sourceLine":55,"sourcePath":"src/channels/plugins/types.plugin.ts"}
372372
{"declaration":"export type GatewayBindUrlResult = GatewayBindUrlResult;","entrypoint":"core","exportName":"GatewayBindUrlResult","importSpecifier":"openclaw/plugin-sdk/core","kind":"type","recordType":"export","sourceLine":1,"sourcePath":"src/shared/gateway-bind-url.ts"}
373373
{"declaration":"export type GatewayRequestHandlerOptions = GatewayRequestHandlerOptions;","entrypoint":"core","exportName":"GatewayRequestHandlerOptions","importSpecifier":"openclaw/plugin-sdk/core","kind":"type","recordType":"export","sourceLine":111,"sourcePath":"src/gateway/server-methods/types.ts"}
@@ -537,15 +537,15 @@
537537
{"declaration":"export function createWebhookAnomalyTracker(options?: { maxTrackedKeys?: number | undefined; ttlMs?: number | undefined; logEvery?: number | undefined; trackedStatusCodes?: readonly number[] | undefined; } | undefined): WebhookAnomalyTracker;","entrypoint":"webhook-ingress","exportName":"createWebhookAnomalyTracker","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":167,"sourcePath":"src/plugin-sdk/webhook-memory-guards.ts"}
538538
{"declaration":"export function createWebhookInFlightLimiter(options?: { maxInFlightPerKey?: number | undefined; maxTrackedKeys?: number | undefined; } | undefined): WebhookInFlightLimiter;","entrypoint":"webhook-ingress","exportName":"createWebhookInFlightLimiter","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":91,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
539539
{"declaration":"export function isJsonContentType(value: string | string[] | undefined): boolean;","entrypoint":"webhook-ingress","exportName":"isJsonContentType","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":138,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
540-
{"declaration":"export function isRequestBodyLimitError(error: unknown, code?: RequestBodyLimitErrorCode | undefined): error is RequestBodyLimitError;","entrypoint":"webhook-ingress","exportName":"isRequestBodyLimitError","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":46,"sourcePath":"src/infra/http-body.ts"}
540+
{"declaration":"export function isRequestBodyLimitError(error: unknown, code?: RequestBodyLimitErrorCode | undefined): error is RequestBodyLimitError;","entrypoint":"webhook-ingress","exportName":"isRequestBodyLimitError","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":47,"sourcePath":"src/infra/http-body.ts"}
541541
{"declaration":"export function normalizeWebhookPath(raw: string): string;","entrypoint":"webhook-ingress","exportName":"normalizeWebhookPath","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":2,"sourcePath":"src/plugin-sdk/webhook-path.ts"}
542542
{"declaration":"export function readJsonWebhookBodyOrReject(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; maxBytes?: number | undefined; timeoutMs?: number | undefined; profile?: WebhookBodyReadProfile | undefined; emptyObjectOnEmpty?: boolean | undefined; invalidJsonMessage?: string | undefined; }): Promise<...>;","entrypoint":"webhook-ingress","exportName":"readJsonWebhookBodyOrReject","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":275,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
543-
{"declaration":"export function readRequestBodyWithLimit(req: IncomingMessage, options: ReadRequestBodyOptions): Promise<string>;","entrypoint":"webhook-ingress","exportName":"readRequestBodyWithLimit","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":121,"sourcePath":"src/infra/http-body.ts"}
543+
{"declaration":"export function readRequestBodyWithLimit(req: IncomingMessage, options: ReadRequestBodyOptions): Promise<string>;","entrypoint":"webhook-ingress","exportName":"readRequestBodyWithLimit","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":122,"sourcePath":"src/infra/http-body.ts"}
544544
{"declaration":"export function readWebhookBodyOrReject(params: { req: IncomingMessage; res: ServerResponse<IncomingMessage>; maxBytes?: number | undefined; timeoutMs?: number | undefined; profile?: WebhookBodyReadProfile | undefined; invalidBodyMessage?: string | undefined; }): Promise<...>;","entrypoint":"webhook-ingress","exportName":"readWebhookBodyOrReject","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":240,"sourcePath":"src/plugin-sdk/webhook-request-guards.ts"}
545545
{"declaration":"export function registerPluginHttpRoute(params: { path?: string | null | undefined; fallbackPath?: string | null | undefined; handler: PluginHttpRouteHandler; auth: OpenClawPluginHttpRouteAuth; ... 6 more ...; registry?: PluginRegistry | undefined; }): () => void;","entrypoint":"webhook-ingress","exportName":"registerPluginHttpRoute","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":12,"sourcePath":"src/plugins/http-registry.ts"}
546546
{"declaration":"export function registerWebhookTarget<T extends { path: string; }>(targetsByPath: Map<string, T[]>, target: T, opts?: RegisterWebhookTargetOptions<T> | undefined): RegisteredWebhookTarget<T>;","entrypoint":"webhook-ingress","exportName":"registerWebhookTarget","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":61,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
547547
{"declaration":"export function registerWebhookTargetWithPluginRoute<T extends { path: string; }>(params: { targetsByPath: Map<string, T[]>; target: T; route: RegisterWebhookPluginRouteOptions; onLastPathTargetRemoved?: ((params: { ...; }) => void) | undefined; }): RegisteredWebhookTarget<...>;","entrypoint":"webhook-ingress","exportName":"registerWebhookTargetWithPluginRoute","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":30,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
548-
{"declaration":"export function requestBodyErrorToText(code: RequestBodyLimitErrorCode): string;","entrypoint":"webhook-ingress","exportName":"requestBodyErrorToText","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":59,"sourcePath":"src/infra/http-body.ts"}
548+
{"declaration":"export function requestBodyErrorToText(code: RequestBodyLimitErrorCode): string;","entrypoint":"webhook-ingress","exportName":"requestBodyErrorToText","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":60,"sourcePath":"src/infra/http-body.ts"}
549549
{"declaration":"export function resolveSingleWebhookTarget<T>(targets: readonly T[], isMatch: (target: T) => boolean): WebhookTargetMatchResult<T>;","entrypoint":"webhook-ingress","exportName":"resolveSingleWebhookTarget","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":193,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
550550
{"declaration":"export function resolveSingleWebhookTargetAsync<T>(targets: readonly T[], isMatch: (target: T) => Promise<boolean>): Promise<WebhookTargetMatchResult<T>>;","entrypoint":"webhook-ingress","exportName":"resolveSingleWebhookTargetAsync","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":212,"sourcePath":"src/plugin-sdk/webhook-targets.ts"}
551551
{"declaration":"export function resolveWebhookPath(params: { webhookPath?: string | undefined; webhookUrl?: string | undefined; defaultPath?: string | null | undefined; }): string | null;","entrypoint":"webhook-ingress","exportName":"resolveWebhookPath","importSpecifier":"openclaw/plugin-sdk/webhook-ingress","kind":"function","recordType":"export","sourceLine":15,"sourcePath":"src/plugin-sdk/webhook-path.ts"}

‎src/plugin-sdk/api-baseline.ts‎

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,30 @@ function relativePath(repoRoot: string, filePath: string): string {
7777
return path.relative(repoRoot, filePath).split(path.sep).join(path.posix.sep);
7878
}
7979

80+
function isAbsoluteImportPath(value: string): boolean {
81+
return path.isAbsolute(value) || /^[A-Za-z]:[\\/]/.test(value);
82+
}
83+
84+
function normalizeDeclarationImportSpecifier(repoRoot: string, value: string): string {
85+
if (!isAbsoluteImportPath(value)) {
86+
return value;
87+
}
88+
89+
const resolvedPath = path.resolve(value);
90+
const relative = path.relative(repoRoot, resolvedPath);
91+
if (relative.startsWith("..") || path.isAbsolute(relative)) {
92+
return value;
93+
}
94+
return relative.split(path.sep).join(path.posix.sep);
95+
}
96+
97+
function normalizeDeclarationText(repoRoot: string, value: string): string {
98+
return value.replaceAll(/import\("([^"]+)"\)/g, (match, specifier: string) => {
99+
const normalized = normalizeDeclarationImportSpecifier(repoRoot, specifier);
100+
return normalized === specifier ? match : `import("${normalized}")`;
101+
});
102+
}
103+
80104
function createCompilerContext(repoRoot: string) {
81105
const configPath = ts.findConfigFile(
82106
repoRoot,
@@ -185,6 +209,7 @@ function resolveSymbolAndDeclaration(
185209
}
186210

187211
function printNode(
212+
repoRoot: string,
188213
checker: ts.TypeChecker,
189214
printer: ts.Printer,
190215
declaration: ts.Declaration,
@@ -194,12 +219,15 @@ function printNode(
194219
if (signatures.length === 0) {
195220
return `export function ${declaration.name?.text ?? "anonymous"}();`;
196221
}
197-
return signatures
198-
.map(
199-
(signature) =>
200-
`export function ${declaration.name?.text ?? "anonymous"}${checker.signatureToString(signature)};`,
201-
)
202-
.join("\n");
222+
return normalizeDeclarationText(
223+
repoRoot,
224+
signatures
225+
.map(
226+
(signature) =>
227+
`export function ${declaration.name?.text ?? "anonymous"}${checker.signatureToString(signature)};`,
228+
)
229+
.join("\n"),
230+
);
203231
}
204232

205233
if (ts.isVariableDeclaration(declaration)) {
@@ -209,7 +237,10 @@ function printNode(
209237
declaration.parent && (ts.getCombinedNodeFlags(declaration.parent) & ts.NodeFlags.Const) !== 0
210238
? "const"
211239
: "let";
212-
return `export ${prefix} ${name}: ${checker.typeToString(type, declaration, ts.TypeFormatFlags.NoTruncation)};`;
240+
return normalizeDeclarationText(
241+
repoRoot,
242+
`export ${prefix} ${name}: ${checker.typeToString(type, declaration, ts.TypeFormatFlags.NoTruncation)};`,
243+
);
213244
}
214245

215246
if (ts.isInterfaceDeclaration(declaration)) {
@@ -230,11 +261,14 @@ function printNode(
230261

231262
if (ts.isTypeAliasDeclaration(declaration)) {
232263
const type = checker.getTypeAtLocation(declaration);
233-
const rendered = `export type ${declaration.name.text} = ${checker.typeToString(
234-
type,
235-
declaration,
236-
ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.MultilineObjectLiterals,
237-
)};`;
264+
const rendered = normalizeDeclarationText(
265+
repoRoot,
266+
`export type ${declaration.name.text} = ${checker.typeToString(
267+
type,
268+
declaration,
269+
ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.MultilineObjectLiterals,
270+
)};`,
271+
);
238272
if (rendered.length > 1200) {
239273
return `export type ${declaration.name.text} = /* see source */`;
240274
}
@@ -247,9 +281,10 @@ function printNode(
247281
if (!text) {
248282
return null;
249283
}
250-
return text.length > 1200
251-
? `${text.slice(0, 1175).trimEnd()}\n/* truncated; see source */`
252-
: text;
284+
const normalizedText = normalizeDeclarationText(repoRoot, text);
285+
return normalizedText.length > 1200
286+
? `${normalizedText.slice(0, 1175).trimEnd()}\n/* truncated; see source */`
287+
: normalizedText;
253288
}
254289

255290
function buildExportSurface(params: {
@@ -262,7 +297,7 @@ function buildExportSurface(params: {
262297
const { checker, printer, program, repoRoot, symbol } = params;
263298
const { declaration, resolvedSymbol } = resolveSymbolAndDeclaration(checker, symbol);
264299
return {
265-
declaration: declaration ? printNode(checker, printer, declaration) : null,
300+
declaration: declaration ? printNode(repoRoot, checker, printer, declaration) : null,
266301
exportName: symbol.getName(),
267302
kind: inferExportKind(resolvedSymbol, declaration),
268303
source: declaration

0 commit comments

Comments
 (0)