惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
博客园 - 三生石上(FineUI控件)
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
雷峰网
雷峰网
宝玉的分享
宝玉的分享
IT之家
IT之家
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园 - 叶小钗
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
月光博客
月光博客
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
云风的 BLOG
云风的 BLOG
美团技术团队
爱范儿
爱范儿
T
The Blog of Author Tim Ferriss
L
LangChain Blog
U
Unit 42
有赞技术团队
有赞技术团队
博客园_首页

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(secretrefs): resolve external channel contracts (#764...
joshavant · 2026-05-03 · via Recent Commits to openclaw:main

@@ -0,0 +1,116 @@

1+

import fs from "node:fs";

2+

import path from "node:path";

3+

import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

4+

import { cleanupTrackedTempDirs, makeTrackedTempDir } from "../plugins/test-helpers/fs-fixtures.js";

5+6+

const tempDirs: string[] = [];

7+8+

const { loadPluginMetadataSnapshotMock, loadBundledPluginPublicArtifactModuleSyncMock } =

9+

vi.hoisted(() => ({

10+

loadPluginMetadataSnapshotMock: vi.fn(),

11+

loadBundledPluginPublicArtifactModuleSyncMock: vi.fn(() => {

12+

throw new Error(

13+

"Unable to resolve bundled plugin public surface discord/secret-contract-api.js",

14+

);

15+

}),

16+

}));

17+18+

vi.mock("../plugins/plugin-metadata-snapshot.js", () => ({

19+

loadPluginMetadataSnapshot: loadPluginMetadataSnapshotMock,

20+

}));

21+22+

vi.mock("../plugins/public-surface-loader.js", () => ({

23+

loadBundledPluginPublicArtifactModuleSync: loadBundledPluginPublicArtifactModuleSyncMock,

24+

}));

25+26+

import { loadChannelSecretContractApi } from "./channel-contract-api.js";

27+28+

function writeExternalChannelPlugin(params: { pluginId: string; channelId: string }) {

29+

const rootDir = makeTrackedTempDir("openclaw-channel-secret-contract", tempDirs);

30+

fs.writeFileSync(

31+

path.join(rootDir, "secret-contract-api.cjs"),

32+

`

33+

module.exports = {

34+

secretTargetRegistryEntries: [

35+

{

36+

id: "channels.${params.channelId}.token",

37+

targetType: "channels.${params.channelId}.token",

38+

configFile: "openclaw.json",

39+

pathPattern: "channels.${params.channelId}.token",

40+

secretShape: "secret_input",

41+

expectedResolvedValue: "string",

42+

includeInPlan: true,

43+

includeInConfigure: true,

44+

includeInAudit: true

45+

}

46+

],

47+

collectRuntimeConfigAssignments(params) {

48+

params.context.assignments.push({

49+

path: "channels.${params.channelId}.token",

50+

ref: { source: "env", provider: "default", id: "DISCORD_BOT_TOKEN" },

51+

expected: "string",

52+

apply() {}

53+

});

54+

}

55+

};

56+

`,

57+

"utf8",

58+

);

59+

return {

60+

id: params.pluginId,

61+

origin: "global",

62+

channels: [params.channelId],

63+

channelConfigs: {},

64+

rootDir,

65+

};

66+

}

67+68+

describe("external channel secret contract api", () => {

69+

beforeEach(() => {

70+

loadPluginMetadataSnapshotMock.mockReset();

71+

loadBundledPluginPublicArtifactModuleSyncMock.mockClear();

72+

});

73+74+

afterEach(() => {

75+

cleanupTrackedTempDirs(tempDirs);

76+

});

77+78+

it("loads root secret-contract-api sidecars for external channel plugins", () => {

79+

const record = writeExternalChannelPlugin({ pluginId: "discord", channelId: "discord" });

80+

loadPluginMetadataSnapshotMock.mockReturnValue({

81+

plugins: [record],

82+

});

83+84+

const api = loadChannelSecretContractApi({

85+

channelId: "discord",

86+

config: { channels: { discord: {} } },

87+

env: {},

88+

loadablePluginOrigins: new Map([["discord", "global"]]),

89+

});

90+91+

expect(api?.secretTargetRegistryEntries).toEqual(

92+

expect.arrayContaining([

93+

expect.objectContaining({

94+

id: "channels.discord.token",

95+

}),

96+

]),

97+

);

98+

expect(api?.collectRuntimeConfigAssignments).toBeTypeOf("function");

99+

});

100+101+

it("skips external channel records outside the loadable plugin origin set", () => {

102+

const record = writeExternalChannelPlugin({ pluginId: "discord", channelId: "discord" });

103+

loadPluginMetadataSnapshotMock.mockReturnValue({

104+

plugins: [record],

105+

});

106+107+

const api = loadChannelSecretContractApi({

108+

channelId: "discord",

109+

config: { channels: { discord: {} } },

110+

env: {},

111+

loadablePluginOrigins: new Map([["other", "global"]]),

112+

});

113+114+

expect(api).toBeUndefined();

115+

});

116+

});