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

推荐订阅源

F
Fortinet All Blogs
有赞技术团队
有赞技术团队
量子位
N
Netflix TechBlog - Medium
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
GbyAI
GbyAI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
月光博客
月光博客
Martin Fowler
Martin Fowler
Y
Y Combinator Blog
宝玉的分享
宝玉的分享
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
V2EX
IT之家
IT之家
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

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
feat(plugin-sdk): add extensible channel identity hook co...
lanzhi-lee · 2026-06-23 · via Recent Commits to openclaw:main

@@ -7,6 +7,14 @@ import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";

77

import { OPENCLAW_CLI_ENV_VALUE } from "../infra/openclaw-exec-env.js";

88

import type { ExtensionContext } from "./sessions/index.js";

9910+

declare module "../plugins/hook-types.js" {

11+

interface PluginHookChannelSenderContext {

12+

unionId?: string;

13+

}

14+

}

15+16+

const CHANNEL_CONTEXT_ENV_KEY = "OPENCLAW_CHANNEL_CONTEXT";

17+1018

const mocks = vi.hoisted(() => ({

1119

hookRunner: undefined as

1220

| {

@@ -129,6 +137,31 @@ describe("exec resolve_exec_env hook wiring", () => {

129137

mocks.spawnInputs.length = 0;

130138

});

131139140+

it("adds only channel identity env to gateway exec subprocesses", async () => {

141+

const tool = createExecTool({

142+

host: "auto",

143+

security: "full",

144+

ask: "off",

145+

channelContext: {

146+

sender: { id: "ou_1", unionId: "on_1" },

147+

chat: { id: "oc_1" },

148+

},

149+

});

150+151+

await tool.execute("call-channel-env", {

152+

command: "echo ok",

153+

yieldMs: 120_000,

154+

});

155+156+

expect(JSON.parse(mocks.gatewayParams[0]?.env[CHANNEL_CONTEXT_ENV_KEY] ?? "{}")).toEqual({

157+

chat: { id: "oc_1" },

158+

sender: { id: "ou_1" },

159+

});

160+

expect(mocks.spawnInputs[0]?.env?.[CHANNEL_CONTEXT_ENV_KEY]).toBe(

161+

mocks.gatewayParams[0]?.env[CHANNEL_CONTEXT_ENV_KEY],

162+

);

163+

});

164+132165

it("merges filtered plugin env into gateway execution and approval-visible requested env", async () => {

133166

installResolveExecEnvHook({

134167

EXISTING: "plugin",

@@ -146,6 +179,10 @@ describe("exec resolve_exec_env hook wiring", () => {

146179

sessionKey: "agent:main:telegram:chat-1",

147180

messageProvider: "telegram",

148181

currentChannelId: "chat-1",

182+

channelContext: {

183+

sender: { id: "ou_1", unionId: "on_1" },

184+

chat: { id: "oc_1" },

185+

},

149186

});

150187

await tool.execute("call-1", {

151188

command: "echo ok",

@@ -164,12 +201,22 @@ describe("exec resolve_exec_env hook wiring", () => {

164201

sessionKey: "agent:main:telegram:chat-1",

165202

messageProvider: "telegram",

166203

channelId: "chat-1",

204+

channelContext: {

205+

sender: { id: "ou_1", unionId: "on_1" },

206+

chat: { id: "oc_1" },

207+

},

167208

},

168209

);

169-

expect(mocks.gatewayParams[0]?.requestedEnv).toEqual({

210+

expect(mocks.gatewayParams[0]?.requestedEnv).toMatchObject({

170211

EXISTING: "plugin",

171212

PLUGIN_SAFE: "yes",

172213

});

214+

expect(

215+

JSON.parse(mocks.gatewayParams[0]?.requestedEnv?.[CHANNEL_CONTEXT_ENV_KEY] ?? "{}"),

216+

).toEqual({

217+

chat: { id: "oc_1" },

218+

sender: { id: "ou_1" },

219+

});

173220

expect(mocks.gatewayParams[0]?.env).toMatchObject({

174221

EXISTING: "plugin",

175222

PLUGIN_SAFE: "yes",

@@ -194,20 +241,34 @@ describe("exec resolve_exec_env hook wiring", () => {

194241

security: "full",

195242

ask: "off",

196243

sessionKey: "agent:main:main",

244+

channelContext: {

245+

sender: { id: "ou_node" },

246+

chat: { id: "oc_node" },

247+

},

197248

});

198249

await tool.execute("call-node", {

199250

command: "echo ok",

200251

env: { REQUEST_SAFE: "request" },

201252

});

202253203-

expect(mocks.nodeHostParams[0]?.requestedEnv).toEqual({

254+

expect(mocks.nodeHostParams[0]?.requestedEnv).toMatchObject({

204255

NODE_HOST_SAFE: "yes",

205256

REQUEST_SAFE: "request",

206257

});

207258

expect(mocks.nodeHostParams[0]?.env).toMatchObject({

208259

NODE_HOST_SAFE: "yes",

209260

REQUEST_SAFE: "request",

210261

});

262+

expect(

263+

JSON.parse(mocks.nodeHostParams[0]?.requestedEnv?.[CHANNEL_CONTEXT_ENV_KEY] ?? "{}"),

264+

).toEqual({

265+

chat: { id: "oc_node" },

266+

sender: { id: "ou_node" },

267+

});

268+

expect(JSON.parse(mocks.nodeHostParams[0]?.env?.[CHANNEL_CONTEXT_ENV_KEY] ?? "{}")).toEqual({

269+

chat: { id: "oc_node" },

270+

sender: { id: "ou_node" },

271+

});

211272

expect(mocks.nodeHostParams[0]?.env).not.toHaveProperty("LD_PRELOAD");

212273

});

213274