Skip to content

Commit aba3a0a

Browse files
committed
fix(pair): keep qr metadata internal
1 parent 34e8aa9 commit aba3a0a

9 files changed

Lines changed: 58 additions & 40 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
98292ad12038af1d555dc50060a60074e58cec49d54bdf4e82ad4b8929f27c47 plugin-sdk-api-baseline.json
2-
4a8ec727632214ec2864e18a88564d7dfc86af3a56829f5a898548e80f0a4c7b plugin-sdk-api-baseline.jsonl
1+
2db6de6d4d7beb886de3077cd9d59cd364422e4175467b03c834fb41e6c9d695 plugin-sdk-api-baseline.json
2+
cb4b4efc0e33ade171cd8ebd2ff73f850bdd752232700ec983448c77a46a2002 plugin-sdk-api-baseline.jsonl

extensions/device-pair/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { rm } from "node:fs/promises";
33
import os from "node:os";
44
import path from "node:path";
55
import { definePluginEntry, type OpenClawPluginApi } from "openclaw/plugin-sdk/plugin-entry";
6-
import { buildPairingQrReplyChannelData } from "openclaw/plugin-sdk/reply-payload";
76
import {
87
normalizeLowercaseStringOrEmpty,
98
normalizeOptionalString,
109
} from "openclaw/plugin-sdk/string-coerce-runtime";
10+
import { buildDevicePairPairingQrChannelData } from "./pairing-qr-channel-data.js";
1111

1212
type DevicePairApiModule = typeof import("./api.js");
1313
type NotifyModule = typeof import("./notify.js");
@@ -862,7 +862,7 @@ export default definePluginEntry({
862862
expiresAtMs: payload.expiresAtMs,
863863
}),
864864
].join("\n"),
865-
channelData: buildPairingQrReplyChannelData({
865+
channelData: buildDevicePairPairingQrChannelData({
866866
setupCode,
867867
expiresAtMs: payload.expiresAtMs,
868868
}),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Private device-pair -> Gateway live-display envelope.
2+
// Keep this local so pairing QR metadata does not become public Plugin SDK API.
3+
export const DEVICE_PAIR_PAIRING_QR_CHANNEL_DATA_KEY = "openclawPairingQr";
4+
5+
export type DevicePairPairingQrChannelData = {
6+
setupCode: string;
7+
expiresAtMs: number;
8+
};
9+
10+
export function buildDevicePairPairingQrChannelData(
11+
params: DevicePairPairingQrChannelData,
12+
): Record<string, unknown> {
13+
return {
14+
[DEVICE_PAIR_PAIRING_QR_CHANNEL_DATA_KEY]: {
15+
setupCode: params.setupCode,
16+
expiresAtMs: params.expiresAtMs,
17+
},
18+
};
19+
}

scripts/plugin-sdk-surface-report.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ let publicDeprecatedExportsByEntrypointBudget;
202202
try {
203203
budgets = {
204204
publicEntrypoints: readBudgetEnv("OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_ENTRYPOINTS", 322),
205-
publicExports: readBudgetEnv("OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_EXPORTS", 10404),
206-
publicFunctionExports: readBudgetEnv("OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS", 5221),
205+
publicExports: readBudgetEnv("OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_EXPORTS", 10400),
206+
publicFunctionExports: readBudgetEnv("OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_FUNCTION_EXPORTS", 5219),
207207
publicDeprecatedExports: readBudgetEnv(
208208
"OPENCLAW_PLUGIN_SDK_MAX_PUBLIC_DEPRECATED_EXPORTS",
209209
3256,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Reply payload tests cover internal reply metadata contracts.
2+
import { describe, expect, it } from "vitest";
3+
import { buildPairingQrReplyChannelData, readPairingQrReplyChannelData } from "./reply-payload.js";
4+
5+
describe("pairing QR reply channel data", () => {
6+
it("builds and reads the private pairing QR payload metadata", () => {
7+
const channelData = buildPairingQrReplyChannelData({
8+
setupCode: "setup-code",
9+
expiresAtMs: 1_800_000_000_000,
10+
});
11+
12+
expect(readPairingQrReplyChannelData({ channelData })).toEqual({
13+
setupCode: "setup-code",
14+
expiresAtMs: 1_800_000_000_000,
15+
});
16+
});
17+
18+
it("ignores malformed pairing QR metadata", () => {
19+
expect(
20+
readPairingQrReplyChannelData({
21+
channelData: {
22+
openclawPairingQr: {
23+
setupCode: "",
24+
expiresAtMs: 0,
25+
},
26+
},
27+
}),
28+
).toBeUndefined();
29+
});
30+
});

src/auto-reply/reply-payload.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export type ReplyPayload = {
6262
channelData?: Record<string, unknown>;
6363
};
6464

65+
// Private device-pair -> Gateway live-display envelope key. Do not re-export
66+
// through Plugin SDK; this is not a third-party plugin contract.
6567
export const PAIRING_QR_REPLY_CHANNEL_DATA_KEY = "openclawPairingQr";
6668

6769
export type PairingQrReplyChannelData = {

src/gateway/server-methods/chat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
buildTtsSupplementMediaPayload,
1414
getReplyPayloadTtsSupplement,
1515
isReplyPayloadTtsSupplement,
16-
readPairingQrReplyChannelData,
1716
resolveSendableOutboundReplyParts,
1817
} from "openclaw/plugin-sdk/reply-payload";
1918
import {
@@ -52,6 +51,7 @@ import { dispatchInboundMessage } from "../../auto-reply/dispatch.js";
5251
import {
5352
getReplyPayloadMetadata,
5453
isReplyPayloadStatusNotice,
54+
readPairingQrReplyChannelData,
5555
type ReplyPayload,
5656
} from "../../auto-reply/reply-payload.js";
5757
import { createReplyDispatcher } from "../../auto-reply/reply/reply-dispatcher.js";

src/plugin-sdk/reply-payload.test.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Reply payload tests cover reply target parsing, media payloads, and approval metadata.
22
import { describe, expect, it, vi } from "vitest";
33
import {
4-
buildPairingQrReplyChannelData,
54
buildTtsSupplementMediaPayload,
65
countOutboundMedia,
76
createNormalizedOutboundDeliverer,
@@ -16,7 +15,6 @@ import {
1615
markReplyPayloadAsTtsSupplement,
1716
normalizeOutboundReplyPayload,
1817
resolveOutboundMediaUrls,
19-
readPairingQrReplyChannelData,
2018
resolveSendableOutboundReplyParts,
2119
resolveTextChunksWithFallback,
2220
sendTextMediaPayload,
@@ -482,33 +480,6 @@ describe("hasOutboundReplyContent", () => {
482480
});
483481
});
484482

485-
describe("pairing QR reply channel data", () => {
486-
it("builds and reads the typed pairing QR payload metadata", () => {
487-
const channelData = buildPairingQrReplyChannelData({
488-
setupCode: "setup-code",
489-
expiresAtMs: 1_800_000_000_000,
490-
});
491-
492-
expect(readPairingQrReplyChannelData({ channelData })).toEqual({
493-
setupCode: "setup-code",
494-
expiresAtMs: 1_800_000_000_000,
495-
});
496-
});
497-
498-
it("ignores malformed pairing QR metadata", () => {
499-
expect(
500-
readPairingQrReplyChannelData({
501-
channelData: {
502-
openclawPairingQr: {
503-
setupCode: "",
504-
expiresAtMs: 0,
505-
},
506-
},
507-
}),
508-
).toBeUndefined();
509-
});
510-
});
511-
512483
describe("resolveSendableOutboundReplyParts", () => {
513484
it("normalizes missing text and trims media urls", () => {
514485
expect(

src/plugin-sdk/reply-payload.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ export { buildMediaPayload } from "../channels/plugins/media-payload.js";
1313
export type ReplyPayload = Omit<InternalReplyPayload, "trustedLocalMedia">;
1414
export type { ReplyPayloadTtsSupplement } from "../auto-reply/reply-payload.js";
1515
export {
16-
buildPairingQrReplyChannelData,
1716
buildTtsSupplementMediaPayload,
1817
FAST_MODE_AUTO_PROGRESS_KIND,
1918
getReplyPayloadTtsSupplement,
2019
isFastModeAutoProgressPayload,
2120
isReplyPayloadNonTerminalToolErrorWarning,
2221
isReplyPayloadTtsSupplement,
2322
markReplyPayloadAsTtsSupplement,
24-
PAIRING_QR_REPLY_CHANNEL_DATA_KEY,
25-
readPairingQrReplyChannelData,
2623
} from "../auto-reply/reply-payload.js";
27-
export type { PairingQrReplyChannelData } from "../auto-reply/reply-payload.js";
2824

2925
/** Normalized outbound reply payload accepted by channel send helpers. */
3026
export type OutboundReplyPayload = {

0 commit comments

Comments
 (0)