mcp-twake-ai 0.3.2 → 0.4.0
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/README.md +17 -1
- package/build/agents/entries.js +5 -2
- package/build/agents/entries.js.map +1 -1
- package/build/agents/index.js +7 -3
- package/build/agents/index.js.map +1 -1
- package/build/agents/locations.js +2 -0
- package/build/agents/locations.js.map +1 -1
- package/build/agents/skill.js +72 -0
- package/build/agents/skill.js.map +1 -0
- package/build/catalog.js +6 -6
- package/build/cli-call.js +125 -0
- package/build/cli-call.js.map +1 -0
- package/build/cli.js +125 -10
- package/build/cli.js.map +1 -1
- package/build/exporter.js +5 -1
- package/build/exporter.js.map +1 -1
- package/build/i18n.js +2 -0
- package/build/i18n.js.map +1 -1
- package/build/launcher.js +56 -4
- package/build/launcher.js.map +1 -1
- package/build/login-chat.js +49 -13
- package/build/login-chat.js.map +1 -1
- package/build/logout.js +15 -3
- package/build/logout.js.map +1 -1
- package/build/proof.js +55 -0
- package/build/proof.js.map +1 -0
- package/build/proxy.js +405 -0
- package/build/proxy.js.map +1 -0
- package/build/shared-chat.js +303 -0
- package/build/shared-chat.js.map +1 -0
- package/package.json +3 -1
- package/skills/twake-batch-approval/SKILL.md +17 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { chmod, lstat, mkdir, open, readFile, unlink } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { CATALOG } from './catalog.js';
|
|
5
|
+
import { TwakeAiError } from './errors.js';
|
|
6
|
+
import { entryPoint, serverDir } from './installer.js';
|
|
7
|
+
import { probe, proves } from './proof.js';
|
|
8
|
+
/**
|
|
9
|
+
* One mcp-twake-chat per agent, shared by the agent's clients (spec shared-chat §3). mcp-twake-chat holds the store lock
|
|
10
|
+
* (one process per device), publishes server.json once it listens, and stops on POST /mcp/shutdown or once idle: this
|
|
11
|
+
* module only finds it, starts it, and asks it to stop. It never signals a process it did not start in this command,
|
|
12
|
+
* and never sends the token to what listens on the server's port before it proved it holds that token (proof.ts).
|
|
13
|
+
*/
|
|
14
|
+
const READY_MS = 5 * 60_000;
|
|
15
|
+
const PING_MS = 2000;
|
|
16
|
+
const GONE_MS = 15_000;
|
|
17
|
+
const PROGRESS_MS = 3000;
|
|
18
|
+
const STORE_IN_USE = 75;
|
|
19
|
+
/** after a start that found the store held, the next try comes this late, then twice as late, up to RETRY_MAX_MS */
|
|
20
|
+
const RETRY_MS = 1000;
|
|
21
|
+
const RETRY_MAX_MS = 15_000;
|
|
22
|
+
export function sharedChatFiles(paths, agent) {
|
|
23
|
+
const dir = join(paths.dataDir, 'chat', agent);
|
|
24
|
+
return { dir, state: join(dir, 'server.json'), log: join(dir, 'server.log') };
|
|
25
|
+
}
|
|
26
|
+
/** What turns mcp-twake-chat into the agent's shared server (spec §3.1), on top of serviceEnv('chat', agent). */
|
|
27
|
+
export function sharedChatEnv(paths, agent) {
|
|
28
|
+
return {
|
|
29
|
+
MCP_TRANSPORT: 'http',
|
|
30
|
+
MCP_HTTP_HOST: '127.0.0.1',
|
|
31
|
+
MCP_HTTP_PORT: '0',
|
|
32
|
+
MCP_HTTP_STATE_FILE: sharedChatFiles(paths, agent).state,
|
|
33
|
+
MCP_HTTP_EXIT_WHEN_IDLE_MS: '600000',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** mcp-twake-chat 0.7.0 and later declare `"twake": { "sharedHttp": 1 }`: older ones keep running over stdio. */
|
|
37
|
+
export async function supportsSharedHttp(paths) {
|
|
38
|
+
const pkg = CATALOG.chat;
|
|
39
|
+
try {
|
|
40
|
+
const json = JSON.parse(await readFile(join(serverDir(paths, pkg.name), 'node_modules', pkg.name, 'package.json'), 'utf8'));
|
|
41
|
+
const level = json.twake?.sharedHttp;
|
|
42
|
+
return typeof level === 'number' && level >= 1;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** http://127.0.0.1:<port>/mcp or http://localhost:<port>/mcp: what the shared mode publishes, and where the token may go. */
|
|
49
|
+
function loopbackEndpoint(url) {
|
|
50
|
+
try {
|
|
51
|
+
const u = new URL(url);
|
|
52
|
+
return (u.protocol === 'http:' &&
|
|
53
|
+
(u.hostname === '127.0.0.1' || u.hostname === 'localhost') &&
|
|
54
|
+
u.port !== '' &&
|
|
55
|
+
u.pathname === '/mcp' &&
|
|
56
|
+
u.search === '' &&
|
|
57
|
+
u.hash === '' &&
|
|
58
|
+
u.username === '' &&
|
|
59
|
+
u.password === '' &&
|
|
60
|
+
url === `http://${u.hostname}:${u.port}/mcp`);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function parseState(text) {
|
|
67
|
+
try {
|
|
68
|
+
const s = JSON.parse(text);
|
|
69
|
+
if (s.version !== 1 || typeof s.url !== 'string' || typeof s.token !== 'string' || typeof s.pid !== 'number' || typeof s.deviceId !== 'string')
|
|
70
|
+
return undefined;
|
|
71
|
+
return { url: s.url, token: s.token, pid: s.pid, deviceId: s.deviceId, ...(typeof s.startedAt === 'string' ? { startedAt: s.startedAt } : {}) };
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** The pid server.json names now, whoever wrote it: only to see a server go, never to use its token. */
|
|
78
|
+
async function statePid(file) {
|
|
79
|
+
return parseState(await readFile(file, 'utf8').catch(() => ''))?.pid;
|
|
80
|
+
}
|
|
81
|
+
const notFound = (error) => error.code === 'ENOENT';
|
|
82
|
+
/**
|
|
83
|
+
* server.json, when mcp-twake-ai can trust it with a token: a regular file (not a link), and on POSIX, it and its folder
|
|
84
|
+
* this account's and closed to others (0600, 0700), with a loopback address. A folder of another account makes it fail;
|
|
85
|
+
* a file that is not to be trusted is `refused`, with the reason, and its token never used.
|
|
86
|
+
*/
|
|
87
|
+
async function trustedState(files, uid) {
|
|
88
|
+
const posix = process.platform !== 'win32';
|
|
89
|
+
const folder = await lstat(files.dir).catch((error) => {
|
|
90
|
+
if (notFound(error))
|
|
91
|
+
return undefined;
|
|
92
|
+
throw error;
|
|
93
|
+
});
|
|
94
|
+
if (!folder)
|
|
95
|
+
return {};
|
|
96
|
+
if (!folder.isDirectory() || (posix && uid !== undefined && folder.uid !== uid)) {
|
|
97
|
+
throw new TwakeAiError('insecure_file', `${files.dir} is not a folder of this account: mcp-twake-ai does not use it. Remove it, then run this command again.`);
|
|
98
|
+
}
|
|
99
|
+
const file = await lstat(files.state).catch((error) => {
|
|
100
|
+
if (notFound(error))
|
|
101
|
+
return undefined;
|
|
102
|
+
throw error;
|
|
103
|
+
});
|
|
104
|
+
if (!file)
|
|
105
|
+
return {};
|
|
106
|
+
if (file.isSymbolicLink())
|
|
107
|
+
return { refused: 'it is a symbolic link' };
|
|
108
|
+
if (!file.isFile())
|
|
109
|
+
return { refused: 'it is not a file' };
|
|
110
|
+
if (posix) {
|
|
111
|
+
if (uid !== undefined && file.uid !== uid)
|
|
112
|
+
return { refused: 'it belongs to another account' };
|
|
113
|
+
if (file.mode & 0o077)
|
|
114
|
+
return { refused: 'other accounts can read or change it' };
|
|
115
|
+
if (folder.mode & 0o077)
|
|
116
|
+
return { refused: `other accounts can enter ${files.dir}` };
|
|
117
|
+
}
|
|
118
|
+
const state = parseState(await readFile(files.state, 'utf8').catch(() => ''));
|
|
119
|
+
if (!state)
|
|
120
|
+
return {};
|
|
121
|
+
if (!loopbackEndpoint(state.url))
|
|
122
|
+
return { refused: 'its address is not a loopback address of this computer' };
|
|
123
|
+
return { state };
|
|
124
|
+
}
|
|
125
|
+
const accountOf = (d) => d.uid ?? process.getuid?.();
|
|
126
|
+
/**
|
|
127
|
+
* The server of this state file, and nothing else, answers: it proves it holds the token (without the token going
|
|
128
|
+
* anywhere), then answers a JSON-RPC ping sent with the token.
|
|
129
|
+
*/
|
|
130
|
+
export async function answers(server) {
|
|
131
|
+
if (!(await proves(server.url, server.token, { pid: server.pid })))
|
|
132
|
+
return false;
|
|
133
|
+
try {
|
|
134
|
+
const r = await fetch(server.url, {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
headers: { authorization: `Bearer ${server.token}`, 'content-type': 'application/json', accept: 'application/json, text/event-stream' },
|
|
137
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: 'twake-ai-ping', method: 'ping' }),
|
|
138
|
+
signal: AbortSignal.timeout(PING_MS),
|
|
139
|
+
redirect: 'error',
|
|
140
|
+
});
|
|
141
|
+
if (r.status !== 200)
|
|
142
|
+
return false;
|
|
143
|
+
return (await r.text()).includes('"jsonrpc"');
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
150
|
+
async function waitGone(file, pid) {
|
|
151
|
+
const deadline = Date.now() + GONE_MS;
|
|
152
|
+
while (Date.now() < deadline) {
|
|
153
|
+
if ((await statePid(file)) !== pid)
|
|
154
|
+
return true;
|
|
155
|
+
await sleep(200);
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
async function lastLine(file) {
|
|
160
|
+
const text = await readFile(file, 'utf8').catch(() => '');
|
|
161
|
+
return text.trim().split('\n').pop()?.trim() ?? '';
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* The agent's shared server (spec §3.1): the one server.json describes when it proves itself and runs on the agent's
|
|
165
|
+
* device now, or a new one. The config is read again at every call: a client that reconnects after `login --chat`
|
|
166
|
+
* lands on the new device.
|
|
167
|
+
*/
|
|
168
|
+
export async function enterSharedChat(agent, d) {
|
|
169
|
+
const files = sharedChatFiles(d.paths, agent);
|
|
170
|
+
const device = await d.deviceId();
|
|
171
|
+
const { state: current, refused } = await trustedState(files, accountOf(d));
|
|
172
|
+
if (refused) {
|
|
173
|
+
// its token is never used; the folder is ours (trustedState checked it): the file goes, and our server writes its own
|
|
174
|
+
d.stderr(`mcp-twake-ai: ${files.state} is not to be trusted (${refused}): ignored, a shared Chat server of our own starts.\n`);
|
|
175
|
+
await unlink(files.state).catch(() => { });
|
|
176
|
+
}
|
|
177
|
+
if (current && (await answers(current))) {
|
|
178
|
+
if (current.deviceId === device)
|
|
179
|
+
return current;
|
|
180
|
+
// the agent has another device now: the server of the old one goes, by its route
|
|
181
|
+
await stopServer(current);
|
|
182
|
+
await waitGone(files.state, current.pid);
|
|
183
|
+
}
|
|
184
|
+
return start(agent, files, device, d);
|
|
185
|
+
}
|
|
186
|
+
async function spawnServer(files, d) {
|
|
187
|
+
await mkdir(files.dir, { recursive: true, mode: 0o700 });
|
|
188
|
+
if (process.platform !== 'win32')
|
|
189
|
+
await chmod(files.dir, 0o700);
|
|
190
|
+
const log = await open(files.log, 'a', 0o600);
|
|
191
|
+
try {
|
|
192
|
+
if (process.platform !== 'win32')
|
|
193
|
+
await log.chmod(0o600);
|
|
194
|
+
const entry = await entryPoint(d.paths, 'chat');
|
|
195
|
+
const env = await d.buildEnv();
|
|
196
|
+
// detached, with no stdio of ours: the server outlives this client, and serves the next ones
|
|
197
|
+
const child = spawn(d.nodePath, [entry], { env, stdio: ['ignore', 'ignore', log.fd], detached: true, windowsHide: true });
|
|
198
|
+
child.unref();
|
|
199
|
+
return child;
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
await log.close();
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async function start(agent, files, device, d) {
|
|
206
|
+
const readyMs = d.readyMs ?? READY_MS;
|
|
207
|
+
const started = Date.now();
|
|
208
|
+
let child = await spawnServer(files, d);
|
|
209
|
+
let exited;
|
|
210
|
+
const watch = (c) => {
|
|
211
|
+
exited = undefined;
|
|
212
|
+
c.once('exit', (code) => {
|
|
213
|
+
if (c === child)
|
|
214
|
+
exited = code;
|
|
215
|
+
});
|
|
216
|
+
c.once('error', () => {
|
|
217
|
+
if (c === child)
|
|
218
|
+
exited = 1;
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
watch(child);
|
|
222
|
+
let told = false;
|
|
223
|
+
let retries = 0;
|
|
224
|
+
let retryAt = 0;
|
|
225
|
+
for (;;) {
|
|
226
|
+
const { state } = await trustedState(files, accountOf(d));
|
|
227
|
+
// ours, or the one that won the store lock against ours: answers() proved it holds the token of its state file, so
|
|
228
|
+
// its pid does not have to be our child's, nor our child to have gone first (a losing start exits 75 on its own)
|
|
229
|
+
if (state && state.deviceId === device && (await answers(state)))
|
|
230
|
+
return state;
|
|
231
|
+
if (exited !== undefined && exited !== STORE_IN_USE) {
|
|
232
|
+
throw new TwakeAiError('unavailable', `The shared Twake Chat server for ${agent} stopped (${await lastLine(files.log)}). Its log: ${files.log}`);
|
|
233
|
+
}
|
|
234
|
+
if (exited === STORE_IN_USE) {
|
|
235
|
+
// another process holds the store: a start that won (it publishes once it listens), or a server that is stopping
|
|
236
|
+
// (its state file already gone). Try again now and then: the store is free once that server has stopped.
|
|
237
|
+
if (retryAt === 0)
|
|
238
|
+
retryAt = Date.now() + Math.min(RETRY_MS * 2 ** retries, RETRY_MAX_MS);
|
|
239
|
+
else if (Date.now() >= retryAt) {
|
|
240
|
+
retries++;
|
|
241
|
+
retryAt = 0;
|
|
242
|
+
child = await spawnServer(files, d);
|
|
243
|
+
watch(child);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (!told && Date.now() - started > PROGRESS_MS) {
|
|
247
|
+
told = true;
|
|
248
|
+
d.stderr(`Starting the shared Twake Chat server for ${agent} (pid ${child.pid ?? '?'}, log ${files.log})…\n`);
|
|
249
|
+
}
|
|
250
|
+
if (Date.now() - started > readyMs) {
|
|
251
|
+
// our child, in this command: the only process we ever signal
|
|
252
|
+
if (exited === undefined)
|
|
253
|
+
child.kill();
|
|
254
|
+
throw new TwakeAiError('unavailable', `The shared Twake Chat server for ${agent} did not start within ${Math.round(readyMs / 1000)} s. Its log: ${files.log}`);
|
|
255
|
+
}
|
|
256
|
+
await sleep(250);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** POST /mcp/shutdown, only to a server that proved it holds the token. */
|
|
260
|
+
async function stopServer(server) {
|
|
261
|
+
if (!(await proves(server.url, server.token, { pid: server.pid })))
|
|
262
|
+
return false;
|
|
263
|
+
try {
|
|
264
|
+
const r = await fetch(`${server.url}/shutdown`, { method: 'POST', headers: { authorization: `Bearer ${server.token}` }, signal: AbortSignal.timeout(PING_MS), redirect: 'error' });
|
|
265
|
+
return r.status === 202;
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/** What `status` shows: the agent's shared server, when its state file is trusted and it answers. */
|
|
272
|
+
export async function sharedChatStatus(agent, d) {
|
|
273
|
+
const { state } = await trustedState(sharedChatFiles(d.paths, agent), accountOf(d)).catch(() => ({ state: undefined }));
|
|
274
|
+
if (!state || !(await answers(state)))
|
|
275
|
+
return undefined;
|
|
276
|
+
return { pid: state.pid, deviceId: state.deviceId, startedAt: state.startedAt };
|
|
277
|
+
}
|
|
278
|
+
/** Stops the agent's shared server by its route (spec §3.3): logout, uninstall and login --chat. */
|
|
279
|
+
export async function stopSharedChat(agent, d) {
|
|
280
|
+
const files = sharedChatFiles(d.paths, agent);
|
|
281
|
+
const { state, refused } = await trustedState(files, accountOf(d));
|
|
282
|
+
if (refused)
|
|
283
|
+
throw new TwakeAiError('insecure_file', `${files.state} is not to be trusted (${refused}): nothing was stopped. Remove it, then run this command again.`);
|
|
284
|
+
if (!state)
|
|
285
|
+
return 'none';
|
|
286
|
+
const found = await probe(state.url, state.token, { pid: state.pid });
|
|
287
|
+
if (found === 'gone') {
|
|
288
|
+
// the server removes its state file before it leaves its port: a refused port, or another program on it, means it
|
|
289
|
+
// is gone (killed, crashed, the computer stopped). Its file goes, unless a newer server wrote its own meanwhile.
|
|
290
|
+
if ((await statePid(files.state)) === state.pid)
|
|
291
|
+
await unlink(files.state).catch(() => { });
|
|
292
|
+
return 'none';
|
|
293
|
+
}
|
|
294
|
+
const hint = `If no mcp-twake-chat runs for ${agent} any more, remove ${files.state}, then run this command again.`;
|
|
295
|
+
if (found === 'silent' || !(await answers(state))) {
|
|
296
|
+
throw new TwakeAiError('unavailable', `The shared Twake Chat server for ${agent} (pid ${state.pid}) does not answer. ${hint}`);
|
|
297
|
+
}
|
|
298
|
+
if (!(await stopServer(state)) || !(await waitGone(files.state, state.pid))) {
|
|
299
|
+
throw new TwakeAiError('unavailable', `The shared Twake Chat server for ${agent} (pid ${state.pid}) did not stop within ${GONE_MS / 1000} s: run this command again in a moment. ${hint}`);
|
|
300
|
+
}
|
|
301
|
+
return 'stopped';
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=shared-chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared-chat.js","sourceRoot":"","sources":["../src/shared-chat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC;AAC5B,MAAM,OAAO,GAAG,IAAI,CAAC;AACrB,MAAM,OAAO,GAAG,MAAM,CAAC;A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,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,YAAY,CAAC,aAAa,EAAE,oCAAoC,KAAK,SAAS,KAAK,CAAC,GAAG,yBAAyB,OAAO,GAAG,IAAI,2CAA2C,IAAI,EAAE,CAAC,CAAC;IAC7L,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-twake-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Install, configure and authenticate the Twake.ai MCP servers in your AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"build",
|
|
11
|
+
"skills",
|
|
11
12
|
"README.md",
|
|
12
13
|
"LICENSE"
|
|
13
14
|
],
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"license": "AGPL-3.0-only",
|
|
32
33
|
"dependencies": {
|
|
33
34
|
"@clack/prompts": "1.8.1",
|
|
35
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
34
36
|
"@napi-rs/keyring": "^2.1.2",
|
|
35
37
|
"jsonc-parser": "^3.3.1",
|
|
36
38
|
"open": "^11.0.4",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: twake-batch-approval
|
|
3
|
+
description: Use before making 3 or more similar writes with a Twake.ai server (several tasks in Twake Projects, several uploads to Twake Drive, several drafts, events or posts) — propose one approval for the exact list with approve_batch.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Approving a series of Twake.ai writes at once
|
|
7
|
+
|
|
8
|
+
Each Twake.ai write asks the user for approval. For a series, ask once:
|
|
9
|
+
|
|
10
|
+
1. **Plan the exact calls.** When you are about to make 3 or more writes with the same Twake.ai server, write down each call: the tool and its exact arguments.
|
|
11
|
+
2. **Ask in the conversation.** Show the list to the user, numbered, and ask: "Do you want to approve these N actions in one go?" Never call `approve_batch` without that yes.
|
|
12
|
+
3. **Call `approve_batch`** of that server with `actions: [{ tool, arguments }, …]`, the arguments exactly as you will send them. The user sees the whole list in one approval.
|
|
13
|
+
4. **Make each call** with exactly those arguments plus the `batchId` you got. Each one runs without another question, once, within 15 minutes.
|
|
14
|
+
5. **Never change an approved action.** If the plan changes (another title, another folder, a new step), make a new batch, or let each call ask as usual. A call not in the list, or whose target changed since, asks as usual: that is expected.
|
|
15
|
+
6. **Calls that depend on earlier results** (assigning tasks you are creating, moving files you are uploading) cannot be listed before those results exist: make a first batch, then a second one with the identifiers the first returned.
|
|
16
|
+
7. **Batches are per server and per session.** One batch for Projects, another for Drive; a new session needs a new batch.
|
|
17
|
+
8. Mail's `batch_*` tools (`batch_move`, `batch_mark_read`…) are one action on several e-mails, not an approval batch: they ask once already.
|