@openclaw/google-meet 2026.5.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.boundary-tsc.stamp +1 -0
- package/dist/.boundary-tsc.tsbuildinfo +1 -0
- package/google-meet.live.test.ts +85 -0
- package/index.create.test.ts +554 -0
- package/index.test.ts +3397 -0
- package/index.ts +1045 -0
- package/node-host.test.ts +222 -0
- package/openclaw.plugin.json +479 -0
- package/package.json +46 -0
- package/src/agent-consult.ts +70 -0
- package/src/calendar.ts +243 -0
- package/src/cli.test.ts +906 -0
- package/src/cli.ts +2055 -0
- package/src/config.ts +509 -0
- package/src/create.ts +103 -0
- package/src/drive.ts +72 -0
- package/src/google-api-errors.ts +20 -0
- package/src/meet.ts +962 -0
- package/src/node-host.ts +498 -0
- package/src/oauth.test.ts +71 -0
- package/src/oauth.ts +228 -0
- package/src/realtime-node.ts +271 -0
- package/src/realtime.ts +423 -0
- package/src/runtime.ts +674 -0
- package/src/setup.ts +259 -0
- package/src/test-support/plugin-harness.ts +215 -0
- package/src/transports/chrome-browser-proxy.ts +198 -0
- package/src/transports/chrome-create.ts +367 -0
- package/src/transports/chrome.ts +925 -0
- package/src/transports/twilio.ts +46 -0
- package/src/transports/types.ts +112 -0
- package/src/voice-call-gateway.test.ts +59 -0
- package/src/voice-call-gateway.ts +155 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isLiveTestEnabled } from "openclaw/plugin-sdk/test-env";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { buildGoogleMeetExportManifest, googleMeetExportFileNames } from "./src/cli.js";
|
|
4
|
+
import {
|
|
5
|
+
fetchGoogleMeetArtifacts,
|
|
6
|
+
fetchGoogleMeetAttendance,
|
|
7
|
+
fetchLatestGoogleMeetConferenceRecord,
|
|
8
|
+
} from "./src/meet.js";
|
|
9
|
+
import { resolveGoogleMeetAccessToken } from "./src/oauth.js";
|
|
10
|
+
|
|
11
|
+
const LIVE_MEETING = process.env.OPENCLAW_GOOGLE_MEET_LIVE_MEETING?.trim() ?? "";
|
|
12
|
+
const CLIENT_ID =
|
|
13
|
+
process.env.OPENCLAW_GOOGLE_MEET_CLIENT_ID?.trim() ??
|
|
14
|
+
process.env.GOOGLE_MEET_CLIENT_ID?.trim() ??
|
|
15
|
+
"";
|
|
16
|
+
const CLIENT_SECRET =
|
|
17
|
+
process.env.OPENCLAW_GOOGLE_MEET_CLIENT_SECRET?.trim() ??
|
|
18
|
+
process.env.GOOGLE_MEET_CLIENT_SECRET?.trim();
|
|
19
|
+
const REFRESH_TOKEN =
|
|
20
|
+
process.env.OPENCLAW_GOOGLE_MEET_REFRESH_TOKEN?.trim() ??
|
|
21
|
+
process.env.GOOGLE_MEET_REFRESH_TOKEN?.trim() ??
|
|
22
|
+
"";
|
|
23
|
+
const ACCESS_TOKEN =
|
|
24
|
+
process.env.OPENCLAW_GOOGLE_MEET_ACCESS_TOKEN?.trim() ??
|
|
25
|
+
process.env.GOOGLE_MEET_ACCESS_TOKEN?.trim();
|
|
26
|
+
const EXPIRES_AT = Number(
|
|
27
|
+
process.env.OPENCLAW_GOOGLE_MEET_ACCESS_TOKEN_EXPIRES_AT ??
|
|
28
|
+
process.env.GOOGLE_MEET_ACCESS_TOKEN_EXPIRES_AT,
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
const LIVE =
|
|
32
|
+
isLiveTestEnabled() &&
|
|
33
|
+
LIVE_MEETING.length > 0 &&
|
|
34
|
+
((CLIENT_ID.length > 0 && REFRESH_TOKEN.length > 0) || Boolean(ACCESS_TOKEN));
|
|
35
|
+
const describeLive = LIVE ? describe : describe.skip;
|
|
36
|
+
|
|
37
|
+
describeLive("google-meet live", () => {
|
|
38
|
+
it("resolves latest conference record and artifacts for a real meeting", async () => {
|
|
39
|
+
const token = await resolveGoogleMeetAccessToken({
|
|
40
|
+
clientId: CLIENT_ID,
|
|
41
|
+
clientSecret: CLIENT_SECRET,
|
|
42
|
+
refreshToken: REFRESH_TOKEN,
|
|
43
|
+
accessToken: ACCESS_TOKEN,
|
|
44
|
+
expiresAt: Number.isFinite(EXPIRES_AT) ? EXPIRES_AT : undefined,
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const latest = await fetchLatestGoogleMeetConferenceRecord({
|
|
48
|
+
accessToken: token.accessToken,
|
|
49
|
+
meeting: LIVE_MEETING,
|
|
50
|
+
});
|
|
51
|
+
expect(latest.space.name).toMatch(/^spaces\//);
|
|
52
|
+
|
|
53
|
+
const artifacts = await fetchGoogleMeetArtifacts({
|
|
54
|
+
accessToken: token.accessToken,
|
|
55
|
+
meeting: LIVE_MEETING,
|
|
56
|
+
pageSize: 5,
|
|
57
|
+
});
|
|
58
|
+
expect(artifacts.conferenceRecords.length).toBeLessThanOrEqual(1);
|
|
59
|
+
expect(Array.isArray(artifacts.artifacts)).toBe(true);
|
|
60
|
+
|
|
61
|
+
const attendance = await fetchGoogleMeetAttendance({
|
|
62
|
+
accessToken: token.accessToken,
|
|
63
|
+
meeting: LIVE_MEETING,
|
|
64
|
+
pageSize: 5,
|
|
65
|
+
});
|
|
66
|
+
expect(attendance.conferenceRecords.length).toBe(artifacts.conferenceRecords.length);
|
|
67
|
+
|
|
68
|
+
const manifest = buildGoogleMeetExportManifest({
|
|
69
|
+
artifacts,
|
|
70
|
+
attendance,
|
|
71
|
+
files: googleMeetExportFileNames(),
|
|
72
|
+
request: {
|
|
73
|
+
meeting: LIVE_MEETING,
|
|
74
|
+
pageSize: 5,
|
|
75
|
+
includeTranscriptEntries: true,
|
|
76
|
+
includeDocumentBodies: false,
|
|
77
|
+
allConferenceRecords: false,
|
|
78
|
+
mergeDuplicateParticipants: true,
|
|
79
|
+
},
|
|
80
|
+
tokenSource: token.refreshed ? "refresh-token" : "cached-access-token",
|
|
81
|
+
});
|
|
82
|
+
expect(manifest.files).toContain("manifest.json");
|
|
83
|
+
expect(manifest.counts.conferenceRecords).toBe(artifacts.conferenceRecords.length);
|
|
84
|
+
}, 120_000);
|
|
85
|
+
});
|
|
@@ -0,0 +1,554 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import plugin, { __testing as googleMeetPluginTesting } from "./index.js";
|
|
4
|
+
import { registerGoogleMeetCli } from "./src/cli.js";
|
|
5
|
+
import { resolveGoogleMeetConfig } from "./src/config.js";
|
|
6
|
+
import type { GoogleMeetRuntime } from "./src/runtime.js";
|
|
7
|
+
import {
|
|
8
|
+
captureStdout,
|
|
9
|
+
invokeGoogleMeetGatewayMethodForTest,
|
|
10
|
+
setupGoogleMeetPlugin,
|
|
11
|
+
} from "./src/test-support/plugin-harness.js";
|
|
12
|
+
import { CREATE_MEET_FROM_BROWSER_SCRIPT } from "./src/transports/chrome-create.js";
|
|
13
|
+
|
|
14
|
+
const voiceCallMocks = vi.hoisted(() => ({
|
|
15
|
+
joinMeetViaVoiceCallGateway: vi.fn(async () => ({
|
|
16
|
+
callId: "call-1",
|
|
17
|
+
dtmfSent: true,
|
|
18
|
+
introSent: true,
|
|
19
|
+
})),
|
|
20
|
+
endMeetVoiceCallGatewayCall: vi.fn(async () => {}),
|
|
21
|
+
speakMeetViaVoiceCallGateway: vi.fn(async () => {}),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const fetchGuardMocks = vi.hoisted(() => ({
|
|
25
|
+
fetchWithSsrFGuard: vi.fn(
|
|
26
|
+
async (params: {
|
|
27
|
+
url: string;
|
|
28
|
+
init?: RequestInit;
|
|
29
|
+
}): Promise<{
|
|
30
|
+
response: Response;
|
|
31
|
+
release: () => Promise<void>;
|
|
32
|
+
}> => ({
|
|
33
|
+
response: await fetch(params.url, params.init),
|
|
34
|
+
release: vi.fn(async () => {}),
|
|
35
|
+
}),
|
|
36
|
+
),
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
vi.mock("openclaw/plugin-sdk/ssrf-runtime", async (importOriginal) => {
|
|
40
|
+
const actual = await importOriginal<typeof import("openclaw/plugin-sdk/ssrf-runtime")>();
|
|
41
|
+
return {
|
|
42
|
+
...actual,
|
|
43
|
+
fetchWithSsrFGuard: fetchGuardMocks.fetchWithSsrFGuard,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
vi.mock("./src/voice-call-gateway.js", () => ({
|
|
48
|
+
joinMeetViaVoiceCallGateway: voiceCallMocks.joinMeetViaVoiceCallGateway,
|
|
49
|
+
endMeetVoiceCallGatewayCall: voiceCallMocks.endMeetVoiceCallGatewayCall,
|
|
50
|
+
speakMeetViaVoiceCallGateway: voiceCallMocks.speakMeetViaVoiceCallGateway,
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
function setup(
|
|
54
|
+
config?: Parameters<typeof setupGoogleMeetPlugin>[1],
|
|
55
|
+
options?: Parameters<typeof setupGoogleMeetPlugin>[2],
|
|
56
|
+
) {
|
|
57
|
+
const harness = setupGoogleMeetPlugin(plugin, config, options);
|
|
58
|
+
googleMeetPluginTesting.setCallGatewayFromCliForTests(
|
|
59
|
+
async (method, _opts, params) =>
|
|
60
|
+
(await invokeGoogleMeetGatewayMethodForTest(harness.methods, method, params)) as Record<
|
|
61
|
+
string,
|
|
62
|
+
unknown
|
|
63
|
+
>,
|
|
64
|
+
);
|
|
65
|
+
return harness;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function runCreateMeetBrowserScript(params: { buttonText: string }) {
|
|
69
|
+
const location = {
|
|
70
|
+
href: "https://meet.google.com/new",
|
|
71
|
+
hostname: "meet.google.com",
|
|
72
|
+
};
|
|
73
|
+
const button = {
|
|
74
|
+
disabled: false,
|
|
75
|
+
innerText: params.buttonText,
|
|
76
|
+
textContent: params.buttonText,
|
|
77
|
+
getAttribute: (name: string) => (name === "aria-label" ? params.buttonText : null),
|
|
78
|
+
click: vi.fn(() => {
|
|
79
|
+
location.href = "https://meet.google.com/abc-defg-hij";
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
const document = {
|
|
83
|
+
title: "Meet",
|
|
84
|
+
body: {
|
|
85
|
+
innerText: "Do you want people to hear you in the meeting?",
|
|
86
|
+
textContent: "Do you want people to hear you in the meeting?",
|
|
87
|
+
},
|
|
88
|
+
querySelectorAll: (selector: string) => (selector === "button" ? [button] : []),
|
|
89
|
+
};
|
|
90
|
+
vi.stubGlobal("document", document);
|
|
91
|
+
vi.stubGlobal("location", location);
|
|
92
|
+
const fn = (0, eval)(`(${CREATE_MEET_FROM_BROWSER_SCRIPT})`) as () => Promise<{
|
|
93
|
+
meetingUri?: string;
|
|
94
|
+
manualActionReason?: string;
|
|
95
|
+
notes?: string[];
|
|
96
|
+
retryAfterMs?: number;
|
|
97
|
+
}>;
|
|
98
|
+
return { button, result: await fn() };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
describe("google-meet create flow", () => {
|
|
102
|
+
beforeEach(() => {
|
|
103
|
+
vi.clearAllMocks();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
afterEach(() => {
|
|
107
|
+
vi.unstubAllGlobals();
|
|
108
|
+
googleMeetPluginTesting.setCallGatewayFromCliForTests();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("CLI create prints the new meeting URL", async () => {
|
|
112
|
+
const fetchMock = vi.fn(async (input: RequestInfo | URL, _init?: RequestInit) => {
|
|
113
|
+
const url = input instanceof Request ? input.url : input.toString();
|
|
114
|
+
if (url.includes("oauth2.googleapis.com")) {
|
|
115
|
+
return new Response(
|
|
116
|
+
JSON.stringify({
|
|
117
|
+
access_token: "new-access-token",
|
|
118
|
+
expires_in: 3600,
|
|
119
|
+
token_type: "Bearer",
|
|
120
|
+
}),
|
|
121
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return new Response(
|
|
125
|
+
JSON.stringify({
|
|
126
|
+
name: "spaces/new-space",
|
|
127
|
+
meetingCode: "new-abcd-xyz",
|
|
128
|
+
meetingUri: "https://meet.google.com/new-abcd-xyz",
|
|
129
|
+
}),
|
|
130
|
+
{ status: 200, headers: { "Content-Type": "application/json" } },
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
134
|
+
const program = new Command();
|
|
135
|
+
const stdout = captureStdout();
|
|
136
|
+
registerGoogleMeetCli({
|
|
137
|
+
program,
|
|
138
|
+
config: resolveGoogleMeetConfig({
|
|
139
|
+
oauth: { clientId: "client-id", refreshToken: "refresh-token" },
|
|
140
|
+
}),
|
|
141
|
+
ensureRuntime: async () => ({}) as GoogleMeetRuntime,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
await program.parseAsync(["googlemeet", "create", "--no-join"], { from: "user" });
|
|
146
|
+
expect(stdout.output()).toContain("meeting uri: https://meet.google.com/new-abcd-xyz");
|
|
147
|
+
expect(stdout.output()).toContain("space: spaces/new-space");
|
|
148
|
+
} finally {
|
|
149
|
+
stdout.restore();
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("can create a Meet through browser fallback without joining when requested", async () => {
|
|
154
|
+
const { methods, nodesInvoke } = setup(
|
|
155
|
+
{
|
|
156
|
+
defaultTransport: "chrome-node",
|
|
157
|
+
chromeNode: { node: "parallels-macos" },
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
nodesInvokeHandler: async (params) => {
|
|
161
|
+
const proxy = params.params as { path?: string; body?: { url?: string } };
|
|
162
|
+
if (proxy.path === "/tabs") {
|
|
163
|
+
return { payload: { result: { tabs: [] } } };
|
|
164
|
+
}
|
|
165
|
+
if (proxy.path === "/tabs/open") {
|
|
166
|
+
return {
|
|
167
|
+
payload: {
|
|
168
|
+
result: {
|
|
169
|
+
targetId: "tab-1",
|
|
170
|
+
title: "Meet",
|
|
171
|
+
url: proxy.body?.url,
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (proxy.path === "/act") {
|
|
177
|
+
return {
|
|
178
|
+
payload: {
|
|
179
|
+
result: {
|
|
180
|
+
ok: true,
|
|
181
|
+
targetId: "tab-1",
|
|
182
|
+
result: {
|
|
183
|
+
meetingUri: "https://meet.google.com/browser-made-url",
|
|
184
|
+
browserUrl: "https://meet.google.com/browser-made-url",
|
|
185
|
+
browserTitle: "Meet",
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
return { payload: { result: { ok: true } } };
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
);
|
|
195
|
+
const handler = methods.get("googlemeet.create") as
|
|
196
|
+
| ((ctx: {
|
|
197
|
+
params: Record<string, unknown>;
|
|
198
|
+
respond: ReturnType<typeof vi.fn>;
|
|
199
|
+
}) => Promise<void>)
|
|
200
|
+
| undefined;
|
|
201
|
+
const respond = vi.fn();
|
|
202
|
+
|
|
203
|
+
await handler?.({ params: { join: false }, respond });
|
|
204
|
+
|
|
205
|
+
expect(respond.mock.calls[0]?.[0]).toBe(true);
|
|
206
|
+
expect(respond.mock.calls[0]?.[1]).toMatchObject({
|
|
207
|
+
source: "browser",
|
|
208
|
+
meetingUri: "https://meet.google.com/browser-made-url",
|
|
209
|
+
joined: false,
|
|
210
|
+
browser: { nodeId: "node-1", targetId: "tab-1" },
|
|
211
|
+
});
|
|
212
|
+
expect(nodesInvoke).toHaveBeenCalledWith(
|
|
213
|
+
expect.objectContaining({
|
|
214
|
+
command: "browser.proxy",
|
|
215
|
+
params: expect.objectContaining({
|
|
216
|
+
path: "/tabs/open",
|
|
217
|
+
body: { url: "https://meet.google.com/new" },
|
|
218
|
+
}),
|
|
219
|
+
}),
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
it("reports structured manual action when browser creation needs Google login", async () => {
|
|
224
|
+
const { methods } = setup(
|
|
225
|
+
{
|
|
226
|
+
defaultTransport: "chrome-node",
|
|
227
|
+
chromeNode: { node: "parallels-macos" },
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
nodesInvokeHandler: async (params) => {
|
|
231
|
+
const proxy = params.params as { path?: string; body?: { url?: string } };
|
|
232
|
+
if (proxy.path === "/tabs") {
|
|
233
|
+
return { payload: { result: { tabs: [] } } };
|
|
234
|
+
}
|
|
235
|
+
if (proxy.path === "/tabs/open") {
|
|
236
|
+
return {
|
|
237
|
+
payload: {
|
|
238
|
+
result: {
|
|
239
|
+
targetId: "login-tab",
|
|
240
|
+
title: "New Tab",
|
|
241
|
+
url: proxy.body?.url,
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
if (proxy.path === "/act") {
|
|
247
|
+
return {
|
|
248
|
+
payload: {
|
|
249
|
+
result: {
|
|
250
|
+
ok: true,
|
|
251
|
+
targetId: "login-tab",
|
|
252
|
+
result: {
|
|
253
|
+
manualActionReason: "google-login-required",
|
|
254
|
+
manualAction:
|
|
255
|
+
"Sign in to Google in the OpenClaw browser profile, then retry meeting creation.",
|
|
256
|
+
browserUrl: "https://accounts.google.com/signin",
|
|
257
|
+
browserTitle: "Sign in - Google Accounts",
|
|
258
|
+
notes: ["Sign-in page detected."],
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
throw new Error(`unexpected browser proxy path ${proxy.path}`);
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
);
|
|
268
|
+
const handler = methods.get("googlemeet.create") as
|
|
269
|
+
| ((ctx: {
|
|
270
|
+
params: Record<string, unknown>;
|
|
271
|
+
respond: ReturnType<typeof vi.fn>;
|
|
272
|
+
}) => Promise<void>)
|
|
273
|
+
| undefined;
|
|
274
|
+
const respond = vi.fn();
|
|
275
|
+
|
|
276
|
+
await handler?.({ params: {}, respond });
|
|
277
|
+
|
|
278
|
+
expect(respond.mock.calls[0]?.[0]).toBe(false);
|
|
279
|
+
expect(respond.mock.calls[0]?.[1]).toMatchObject({
|
|
280
|
+
source: "browser",
|
|
281
|
+
error:
|
|
282
|
+
"google-login-required: Sign in to Google in the OpenClaw browser profile, then retry meeting creation.",
|
|
283
|
+
manualActionRequired: true,
|
|
284
|
+
manualActionReason: "google-login-required",
|
|
285
|
+
manualActionMessage:
|
|
286
|
+
"Sign in to Google in the OpenClaw browser profile, then retry meeting creation.",
|
|
287
|
+
browser: {
|
|
288
|
+
nodeId: "node-1",
|
|
289
|
+
targetId: "login-tab",
|
|
290
|
+
browserUrl: "https://accounts.google.com/signin",
|
|
291
|
+
browserTitle: "Sign in - Google Accounts",
|
|
292
|
+
notes: ["Sign-in page detected."],
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
it("creates and joins a Meet through the create tool action by default", async () => {
|
|
298
|
+
const { tools, nodesInvoke } = setup(
|
|
299
|
+
{
|
|
300
|
+
defaultTransport: "chrome-node",
|
|
301
|
+
defaultMode: "transcribe",
|
|
302
|
+
chromeNode: { node: "parallels-macos" },
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
nodesInvokeHandler: async (params) => {
|
|
306
|
+
if (params.command === "googlemeet.chrome") {
|
|
307
|
+
return { payload: { launched: true } };
|
|
308
|
+
}
|
|
309
|
+
const proxy = params.params as {
|
|
310
|
+
path?: string;
|
|
311
|
+
body?: { url?: string; targetId?: string; fn?: string };
|
|
312
|
+
};
|
|
313
|
+
if (proxy.path === "/tabs") {
|
|
314
|
+
return { payload: { result: { tabs: [] } } };
|
|
315
|
+
}
|
|
316
|
+
if (proxy.path === "/tabs/open") {
|
|
317
|
+
return {
|
|
318
|
+
payload: {
|
|
319
|
+
result: {
|
|
320
|
+
targetId:
|
|
321
|
+
proxy.body?.url === "https://meet.google.com/new" ? "create-tab" : "join-tab",
|
|
322
|
+
title: "Meet",
|
|
323
|
+
url: proxy.body?.url,
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
if (proxy.path === "/act" && proxy.body?.fn?.includes("meetUrlPattern")) {
|
|
329
|
+
return {
|
|
330
|
+
payload: {
|
|
331
|
+
result: {
|
|
332
|
+
ok: true,
|
|
333
|
+
targetId: "create-tab",
|
|
334
|
+
result: {
|
|
335
|
+
meetingUri: "https://meet.google.com/new-abcd-xyz",
|
|
336
|
+
browserUrl: "https://meet.google.com/new-abcd-xyz",
|
|
337
|
+
browserTitle: "Meet",
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
if (proxy.path === "/act") {
|
|
344
|
+
return {
|
|
345
|
+
payload: {
|
|
346
|
+
result: {
|
|
347
|
+
ok: true,
|
|
348
|
+
targetId: "join-tab",
|
|
349
|
+
result: JSON.stringify({
|
|
350
|
+
inCall: true,
|
|
351
|
+
micMuted: false,
|
|
352
|
+
title: "Meet call",
|
|
353
|
+
url: "https://meet.google.com/new-abcd-xyz",
|
|
354
|
+
}),
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
return { payload: { result: { ok: true } } };
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
);
|
|
363
|
+
const tool = tools[0] as {
|
|
364
|
+
execute: (
|
|
365
|
+
id: string,
|
|
366
|
+
params: unknown,
|
|
367
|
+
) => Promise<{
|
|
368
|
+
details: { joined?: boolean; meetingUri?: string; join?: { session: { url: string } } };
|
|
369
|
+
}>;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const result = await tool.execute("id", { action: "create" });
|
|
373
|
+
|
|
374
|
+
expect(result.details).toMatchObject({
|
|
375
|
+
source: "browser",
|
|
376
|
+
joined: true,
|
|
377
|
+
meetingUri: "https://meet.google.com/new-abcd-xyz",
|
|
378
|
+
join: { session: { url: "https://meet.google.com/new-abcd-xyz" } },
|
|
379
|
+
});
|
|
380
|
+
expect(nodesInvoke).toHaveBeenCalledWith(
|
|
381
|
+
expect.objectContaining({
|
|
382
|
+
command: "googlemeet.chrome",
|
|
383
|
+
params: expect.objectContaining({
|
|
384
|
+
action: "start",
|
|
385
|
+
url: "https://meet.google.com/new-abcd-xyz",
|
|
386
|
+
launch: false,
|
|
387
|
+
}),
|
|
388
|
+
}),
|
|
389
|
+
);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it("returns structured manual action from the create tool action", async () => {
|
|
393
|
+
const { tools } = setup(
|
|
394
|
+
{
|
|
395
|
+
defaultTransport: "chrome-node",
|
|
396
|
+
chromeNode: { node: "parallels-macos" },
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
nodesInvokeHandler: async (params) => {
|
|
400
|
+
const proxy = params.params as { path?: string; body?: { url?: string } };
|
|
401
|
+
if (proxy.path === "/tabs") {
|
|
402
|
+
return { payload: { result: { tabs: [] } } };
|
|
403
|
+
}
|
|
404
|
+
if (proxy.path === "/tabs/open") {
|
|
405
|
+
return {
|
|
406
|
+
payload: {
|
|
407
|
+
result: {
|
|
408
|
+
targetId: "permission-tab",
|
|
409
|
+
title: "Meet",
|
|
410
|
+
url: proxy.body?.url,
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
if (proxy.path === "/act") {
|
|
416
|
+
return {
|
|
417
|
+
payload: {
|
|
418
|
+
result: {
|
|
419
|
+
ok: true,
|
|
420
|
+
targetId: "permission-tab",
|
|
421
|
+
result: {
|
|
422
|
+
manualActionReason: "meet-permission-required",
|
|
423
|
+
manualAction:
|
|
424
|
+
"Allow microphone/camera permissions for Meet in the OpenClaw browser profile, then retry meeting creation.",
|
|
425
|
+
browserUrl: "https://meet.google.com/new",
|
|
426
|
+
browserTitle: "Meet",
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
throw new Error(`unexpected browser proxy path ${proxy.path}`);
|
|
433
|
+
},
|
|
434
|
+
},
|
|
435
|
+
);
|
|
436
|
+
const tool = tools[0] as {
|
|
437
|
+
execute: (id: string, params: unknown) => Promise<{ details: Record<string, unknown> }>;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
const result = await tool.execute("id", { action: "create" });
|
|
441
|
+
|
|
442
|
+
expect(result.details).toMatchObject({
|
|
443
|
+
source: "browser",
|
|
444
|
+
manualActionRequired: true,
|
|
445
|
+
manualActionReason: "meet-permission-required",
|
|
446
|
+
manualActionMessage:
|
|
447
|
+
"Allow microphone/camera permissions for Meet in the OpenClaw browser profile, then retry meeting creation.",
|
|
448
|
+
browser: {
|
|
449
|
+
nodeId: "node-1",
|
|
450
|
+
targetId: "permission-tab",
|
|
451
|
+
browserUrl: "https://meet.google.com/new",
|
|
452
|
+
browserTitle: "Meet",
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
it("reuses an existing browser create tab instead of opening duplicates", async () => {
|
|
458
|
+
const { methods, nodesInvoke } = setup(
|
|
459
|
+
{
|
|
460
|
+
defaultTransport: "chrome-node",
|
|
461
|
+
chromeNode: { node: "parallels-macos" },
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
nodesInvokeHandler: async (params) => {
|
|
465
|
+
const proxy = params.params as { path?: string; body?: { targetId?: string } };
|
|
466
|
+
if (proxy.path === "/tabs") {
|
|
467
|
+
return {
|
|
468
|
+
payload: {
|
|
469
|
+
result: {
|
|
470
|
+
tabs: [
|
|
471
|
+
{
|
|
472
|
+
targetId: "existing-create-tab",
|
|
473
|
+
title: "Meet",
|
|
474
|
+
url: "https://meet.google.com/new",
|
|
475
|
+
},
|
|
476
|
+
],
|
|
477
|
+
},
|
|
478
|
+
},
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
if (proxy.path === "/tabs/focus") {
|
|
482
|
+
return { payload: { result: { ok: true } } };
|
|
483
|
+
}
|
|
484
|
+
if (proxy.path === "/act") {
|
|
485
|
+
return {
|
|
486
|
+
payload: {
|
|
487
|
+
result: {
|
|
488
|
+
ok: true,
|
|
489
|
+
targetId: proxy.body?.targetId ?? "existing-create-tab",
|
|
490
|
+
result: {
|
|
491
|
+
meetingUri: "https://meet.google.com/reu-sedx-tab",
|
|
492
|
+
browserUrl: "https://meet.google.com/reu-sedx-tab",
|
|
493
|
+
browserTitle: "Meet",
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
throw new Error(`unexpected browser proxy path ${proxy.path}`);
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
);
|
|
503
|
+
const handler = methods.get("googlemeet.create") as
|
|
504
|
+
| ((ctx: {
|
|
505
|
+
params: Record<string, unknown>;
|
|
506
|
+
respond: ReturnType<typeof vi.fn>;
|
|
507
|
+
}) => Promise<void>)
|
|
508
|
+
| undefined;
|
|
509
|
+
const respond = vi.fn();
|
|
510
|
+
|
|
511
|
+
await handler?.({ params: { join: false }, respond });
|
|
512
|
+
|
|
513
|
+
expect(respond.mock.calls[0]?.[0]).toBe(true);
|
|
514
|
+
expect(respond.mock.calls[0]?.[1]).toMatchObject({
|
|
515
|
+
source: "browser",
|
|
516
|
+
meetingUri: "https://meet.google.com/reu-sedx-tab",
|
|
517
|
+
browser: { nodeId: "node-1", targetId: "existing-create-tab" },
|
|
518
|
+
});
|
|
519
|
+
expect(nodesInvoke).toHaveBeenCalledWith(
|
|
520
|
+
expect.objectContaining({
|
|
521
|
+
params: expect.objectContaining({
|
|
522
|
+
path: "/tabs/focus",
|
|
523
|
+
body: { targetId: "existing-create-tab" },
|
|
524
|
+
}),
|
|
525
|
+
}),
|
|
526
|
+
);
|
|
527
|
+
expect(nodesInvoke).not.toHaveBeenCalledWith(
|
|
528
|
+
expect.objectContaining({
|
|
529
|
+
params: expect.objectContaining({ path: "/tabs/open" }),
|
|
530
|
+
}),
|
|
531
|
+
);
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it.each([
|
|
535
|
+
["Use microphone", "Accepted Meet microphone prompt with browser automation."],
|
|
536
|
+
[
|
|
537
|
+
"Continue without microphone",
|
|
538
|
+
"Continued through Meet microphone prompt with browser automation.",
|
|
539
|
+
],
|
|
540
|
+
])(
|
|
541
|
+
"uses browser automation for Meet's %s choice during browser creation",
|
|
542
|
+
async (buttonText, note) => {
|
|
543
|
+
const { button, result } = await runCreateMeetBrowserScript({ buttonText });
|
|
544
|
+
|
|
545
|
+
expect(result).toMatchObject({
|
|
546
|
+
retryAfterMs: 1000,
|
|
547
|
+
notes: [note],
|
|
548
|
+
});
|
|
549
|
+
expect(button.click).toHaveBeenCalledTimes(1);
|
|
550
|
+
expect(result.meetingUri).toBeUndefined();
|
|
551
|
+
expect(result.manualActionReason).toBeUndefined();
|
|
552
|
+
},
|
|
553
|
+
);
|
|
554
|
+
});
|