

























@@ -97,6 +97,28 @@ function buildPluginApprovalElicitation(overrides: Record<string, unknown> = {})
9797};
9898}
9999100+function buildConnectorPluginApprovalElicitation(overrides: Record<string, unknown> = {}) {
101+return {
102+threadId: "thread-1",
103+turnId: "turn-1",
104+serverName: "codex_apps",
105+mode: "form",
106+message: "Allow Google Calendar to create an event?",
107+_meta: {
108+codex_approval_kind: "mcp_tool_call",
109+source: "connector",
110+connector_id: "connector_google_calendar",
111+connector_name: "Google Calendar",
112+tool_title: "create_event",
113+},
114+requestedSchema: {
115+type: "object",
116+properties: {},
117+},
118+ ...overrides,
119+};
120+}
121+100122function createPluginAppPolicyContext(
101123params: {
102124allowDestructiveActions?: boolean;
@@ -543,6 +565,114 @@ describe("Codex app-server elicitation bridge", () => {
543565expect(mockCallGatewayTool).not.toHaveBeenCalled();
544566});
545567568+it("accepts connector-id plugin app elicitations when destructive actions are enabled", async () => {
569+const result = await handleCodexAppServerElicitationRequest({
570+requestParams: buildConnectorPluginApprovalElicitation(),
571+paramsForRun: createParams(),
572+threadId: "thread-1",
573+turnId: "turn-1",
574+pluginAppPolicyContext: createPluginAppPolicyContext({
575+allowDestructiveActions: true,
576+apps: [
577+{
578+appId: "connector_google_calendar",
579+pluginName: "google-calendar",
580+mcpServerNames: [],
581+},
582+],
583+}),
584+});
585+586+expect(result).toEqual({
587+action: "accept",
588+content: null,
589+_meta: null,
590+});
591+expect(mockCallGatewayTool).not.toHaveBeenCalled();
592+});
593+594+it("declines connector-id plugin app elicitations when destructive actions are disabled", async () => {
595+const result = await handleCodexAppServerElicitationRequest({
596+requestParams: buildConnectorPluginApprovalElicitation(),
597+paramsForRun: createParams(),
598+threadId: "thread-1",
599+turnId: "turn-1",
600+pluginAppPolicyContext: createPluginAppPolicyContext({
601+allowDestructiveActions: false,
602+apps: [
603+{
604+appId: "connector_google_calendar",
605+pluginName: "google-calendar",
606+mcpServerNames: [],
607+},
608+],
609+}),
610+});
611+612+expect(result).toEqual({ action: "decline", content: null, _meta: null });
613+expect(mockCallGatewayTool).not.toHaveBeenCalled();
614+});
615+616+it("declines live connector elicitations that only match display names", async () => {
617+const result = await handleCodexAppServerElicitationRequest({
618+requestParams: buildConnectorPluginApprovalElicitation({
619+_meta: {
620+codex_approval_kind: "mcp_tool_call",
621+source: "connector",
622+connector_name: "Google Calendar",
623+tool_title: "create_event",
624+},
625+}),
626+paramsForRun: createParams(),
627+threadId: "thread-1",
628+turnId: "turn-1",
629+pluginAppPolicyContext: createPluginAppPolicyContext({
630+allowDestructiveActions: true,
631+apps: [
632+{
633+appId: "connector_google_calendar",
634+pluginName: "google-calendar",
635+mcpServerNames: [],
636+},
637+],
638+}),
639+});
640+641+expect(result).toEqual({ action: "decline", content: null, _meta: null });
642+expect(mockCallGatewayTool).not.toHaveBeenCalled();
643+});
644+645+it("declines live connector elicitations with mismatched app and connector ids", async () => {
646+const result = await handleCodexAppServerElicitationRequest({
647+requestParams: buildConnectorPluginApprovalElicitation({
648+_meta: {
649+codex_approval_kind: "mcp_tool_call",
650+source: "connector",
651+app_id: "other-app",
652+connector_id: "connector_google_calendar",
653+connector_name: "Google Calendar",
654+tool_title: "create_event",
655+},
656+}),
657+paramsForRun: createParams(),
658+threadId: "thread-1",
659+turnId: "turn-1",
660+pluginAppPolicyContext: createPluginAppPolicyContext({
661+allowDestructiveActions: true,
662+apps: [
663+{
664+appId: "connector_google_calendar",
665+pluginName: "google-calendar",
666+mcpServerNames: [],
667+},
668+],
669+}),
670+});
671+672+expect(result).toEqual({ action: "decline", content: null, _meta: null });
673+expect(mockCallGatewayTool).not.toHaveBeenCalled();
674+});
675+546676it("declines plugin app elicitations that are missing active turn correlation", async () => {
547677const result = await handleCodexAppServerElicitationRequest({
548678requestParams: buildPluginApprovalElicitation({ turnId: null }),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。