Repository navigation
Expand file tree
/
Copy pathagents-proxy.test.ts
More file actions
2726 lines (2558 loc) · 140 KB
/
Copy pathagents-proxy.test.ts
File metadata and controls
2726 lines (2558 loc) · 140 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Spawns the agents proxy exactly as a driver's mcpServers entry does, against a stub of /api/internal.
import { spawn, type ChildProcess } from "node:child_process";
import { createServer, type Server } from "node:http";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
import { childEnv } from "../testing/omb-env.ts";
import { ToolResults } from "../tool-results.ts";
import { waitForExit } from "../testing/cleanup.ts";
import { fullInputSchema } from "./agents-catalog.ts";
const PROXY = join(dirname(fileURLToPath(import.meta.url)), "agents-proxy.ts");
const TOKEN = "test-comms-token";
let stub: Server;
let stubPort = 0;
let lastAuth: string | undefined;
const savedToolResults = new ToolResults();
const savedOwner = { botId: "bot-asker", threadId: "thread-asker" };
let failSavingResult = false;
let savedResultWrites = 0;
let lastCoordinateBody: any = null;
let coordinateResponse: unknown = { ok: true };
let lastRoomsQuery = "";
let lastPostBody: any = null;
let lastExecBody: any = null;
let execStatus = 200;
let execResponse: unknown = { exitCode: 0, stdout: "PDF_OK\n", stderr: "", timedOut: false };
let lastAttachBody: any = null;
let attachStatus = 200;
let attachResponse: unknown = { ok: true, name: "report.pdf", bytes: 48639 };
let postCalls = 0;
let postResponse: unknown = { ok: true, messageId: "msg-1", roomName: "Launch" };
const DEFAULT_AGENTS = { bots: [{ id: "bot-helper", name: "Helper", model: "fake-model", busy: false }] };
let agentsResponse: unknown = DEFAULT_AGENTS;
let roomsResponse: unknown = {
rooms: [
{ id: "room-launch", name: "Launch", members: ["Asker", "Helper"] },
],
};
const DONE_ASSIGNMENT = {
assignment: { id: "task-earlier123", botId: "bot-helper", botName: "Helper", status: "completed", outcome: "done", result: "All done.", mode: "work", reply: "resume" },
children: [], inbox: [],
};
let lastAssignmentStatusUrl: string | null = null;
let lastModelsUrl: string | undefined;
let assignmentStatusResponse: unknown = DONE_ASSIGNMENT;
let assignmentStatusCode = 200;
let lastThreadBody: any = null;
let threadCalls = 0;
let threadsList: unknown = { threads: [] };
let threadResponse: unknown = { threadId: "thread-new", title: "QA: PR #1", botId: "bot-asker", botName: "Asker", self: true, state: "running", limit: 3 };
let computerRequests: { method: string; url: string; body: unknown }[] = [];
let computerResponse: unknown = { current: "local", available: ["local", "vm"] };
let computerStatus = 200;
let lastCreateBody: any = null;
let lastCreateRoomBody: unknown = null;
let lastManageRoomBody: unknown = null;
let lastCredentialBody: any = null;
let lastSignInBody: any = null;
let lastFillBody: any = null;
let fillAnswer: { ok: boolean; text: string } = { ok: true, text: "Filled the username and the password for alice on example.com." };
let lastRoutineQuery = "";
let routinesResponse: unknown = {
now: "2026-08-28T10:30:00.000Z",
timeZone: "Asia/Kolkata",
triggers: [
{
id: "routine-1",
name: "Morning brief",
enabled: true,
schedule: { type: "daily", time: "09:00", weekdays: [1, 2, 3, 4, 5] },
nextRunAt: "2026-08-31T03:30:00.000Z",
},
],
};
let lastRoutineRequestBody: any = null;
const DEFAULT_ROUTINE_RESPONSE = { requestId: "routine-request-1", summary: "Weekdays at 09:00 (Asia/Kolkata)" };
let routineRequestResponse: unknown = DEFAULT_ROUTINE_RESPONSE;
let lastProfileRequestBody: any = null;
const DEFAULT_PROFILE_RESPONSE = { requestId: "profile-request-1", summary: "Name → Kiwi" };
let profileRequestResponse: unknown = DEFAULT_PROFILE_RESPONSE;
let lastModelRequestBody: any = null;
const DEFAULT_MODEL_RESPONSE = { requestId: "model-request-1", summary: "Default engine/model → codex gpt-5" };
let modelRequestResponse: unknown = DEFAULT_MODEL_RESPONSE;
const DEFAULT_TEAM_RESPONSE = { requestId: "team-request-1", title: "Requested team change" };
let teamRequestResponse: unknown = DEFAULT_TEAM_RESPONSE;
let lastTeamRequestBody: any = null;
let lastSessionSearchUrl = "";
let lastSessionReadUrl = "";
let lastMemoryBody: any = null;
let lastMemoryLogBody: any = null;
let memoryResponse: unknown = { ok: true, truncated: false };
let memoryStatus = 200;
let sessionSearchResponse: unknown = {
hits: [
{ threadId: "thread-old", messageId: "m-audit", at: Date.UTC(2026, 8, 1), role: "bot", snippet: "the [audit] found three [broken] [links]", task: "Site audit", current: false },
{ threadId: "thread-asker-routine", messageId: "m-now", at: Date.UTC(2026, 8, 4), role: "user", snippet: "please redo the [audit]", current: true },
{ threadId: "thread-asker", messageId: "m-peer", at: Date.UTC(2026, 8, 2), role: "user", peer: "Scout", snippet: "…wants the [audit] emailed to vendor@example.com", task: "Vendor follow-up", current: false },
],
};
let lastSkillQuery = "";
let lastSkillStageBody: any = null;
let skillsResponse: unknown = {
skills: [
{
name: "file-expense",
description: "UNREVIEWED IMPORT INSTRUCTIONS",
enabled: false,
source: "github.com/example/skills",
editable: false,
},
{
name: "learned-expense",
description: "PRIVATE LEARNED INSTRUCTIONS",
enabled: true,
source: "learn:conversation",
editable: true,
},
{
name: "team-cut",
description: "SHARED LEARNED INSTRUCTIONS",
enabled: true,
source: "learn:conversation",
editable: true,
revision: "0123456789ab",
},
],
staged: [{ name: "pending-skill", action: "create", gist: "UNREVIEWED GIST", source: "UNREVIEWED SOURCE" }],
};
const DEFAULT_SKILL_RESPONSE = { name: "file-expense", action: "create", gist: "Files an expense.", warnings: [] };
let skillStageResponse: unknown = DEFAULT_SKILL_RESPONSE;
afterEach(() => {
failSavingResult = false;
routineRequestResponse = DEFAULT_ROUTINE_RESPONSE;
profileRequestResponse = DEFAULT_PROFILE_RESPONSE;
modelRequestResponse = DEFAULT_MODEL_RESPONSE;
teamRequestResponse = DEFAULT_TEAM_RESPONSE;
skillStageResponse = DEFAULT_SKILL_RESPONSE;
computerRequests = [];
computerResponse = { current: "local", available: ["local", "vm"] };
computerStatus = 200;
});
function setProposalResponse(tool: string, response: unknown) {
if (tool === "propose_profile") profileRequestResponse = response;
else if (tool === "propose_model") modelRequestResponse = response;
else if (tool === "propose_team_setup" || tool === "propose_bot_deletion") teamRequestResponse = response;
else if (tool === "skill_manage") skillStageResponse = response;
else routineRequestResponse = response;
}
const proposalCases = [
{ tool: "propose_profile", args: { name: "Kiwi" } },
{ tool: "propose_team_setup", args: { reason: "Fixture plan", operations: [{ action: "update", botId: "bot-helper", fields: { title: "Fixture" } }] } },
{ tool: "propose_bot_deletion", args: { bot_id: "bot-helper", reason: "User requested deletion" } },
{ tool: "skill_manage", args: { action: "create", skill_md: "---\nname: fixture-skill\ndescription: Fixture only\n---\n# Fixture\n", source: "conversation" } },
{ tool: "skill_manage", args: { action: "update", skill_name: "fixture-skill", skill_md: "---\nname: fixture-skill\ndescription: Updated fixture\n---\n# Fixture\n", source: "conversation" } },
];
let child: ChildProcess;
const pending = new Map<number, (msg: any) => void>();
let nextId = 100;
function rpc(method: string, params?: unknown): Promise<any> {
return new Promise((resolve, reject) => {
const id = nextId++;
pending.set(id, resolve);
child.stdin!.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n");
setTimeout(() => {
if (pending.delete(id)) reject(new Error(`${method} timed out`));
}, 10_000).unref?.();
});
}
const callTool = (name: string, args: unknown) => rpc("tools/call", { name, arguments: args });
beforeAll(async () => {
stub = createServer((req, res) => {
lastAuth = req.headers.authorization;
if (req.headers.authorization !== `Bearer ${TOKEN}`) {
res.writeHead(401, { "content-type": "application/json" });
return res.end(JSON.stringify({ error: "unauthorized" }));
}
if (req.method === "POST" && req.url === "/api/internal/tool-result") {
savedResultWrites++;
if (failSavingResult) {
res.writeHead(503, { "content-type": "application/json" });
return res.end(JSON.stringify({ error: "cache unavailable" }));
}
let raw = "";
req.on("data", chunk => { raw += chunk; });
req.on("end", () => {
const body = JSON.parse(raw);
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify(savedToolResults.save(savedOwner, body.text, body.truncated)));
});
return;
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/tool-result?")) {
const url = new URL(req.url, "http://fixture");
const result = savedToolResults.read(savedOwner, url.searchParams.get("id") ?? "", Number(url.searchParams.get("offset")));
res.writeHead(result ? 200 : 404, { "content-type": "application/json" });
return res.end(JSON.stringify(result ?? { error: "saved result unavailable" }));
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/agents")) {
res.writeHead(200, { "content-type": "application/json" });
return res.end(
JSON.stringify(agentsResponse),
);
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/rooms?")) {
lastRoomsQuery = req.url;
res.writeHead(200, { "content-type": "application/json" });
return res.end(JSON.stringify(roomsResponse));
}
if (req.method === "POST" && req.url === "/api/internal/vm-exec") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastExecBody = JSON.parse(data);
res.writeHead(execStatus, { "content-type": "application/json" });
res.end(JSON.stringify(execResponse));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/attach-file") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastAttachBody = JSON.parse(data);
res.writeHead(attachStatus, { "content-type": "application/json" });
res.end(JSON.stringify(attachResponse));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/post-to-room") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastPostBody = JSON.parse(data);
postCalls += 1;
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify(postResponse));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/coordinate-bots") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastCoordinateBody = JSON.parse(data);
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify(coordinateResponse));
});
return;
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/assignment-status")) {
lastAssignmentStatusUrl = req.url;
res.writeHead(assignmentStatusCode, { "content-type": "application/json" });
res.end(JSON.stringify(assignmentStatusResponse));
return;
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/models")) {
lastModelsUrl = req.url;
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({ current: { instanceId: "claude", model: "claude-sonnet-5" }, engines: [{ instanceId: "codex", name: "Codex", models: ["gpt-5.5"] }] }));
return;
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/threads?")) {
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify(threadsList));
return;
}
if (req.method === "POST" && req.url === "/api/internal/threads") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastThreadBody = JSON.parse(data);
threadCalls += 1;
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify(threadResponse));
});
return;
}
if (req.url === "/api/internal/computer/select") {
let data = "";
req.on("data", (chunk) => (data += chunk));
req.on("end", () => {
computerRequests.push({ method: req.method!, url: req.url!, body: data ? JSON.parse(data) : null });
res.writeHead(computerStatus, { "content-type": "application/json" });
res.end(JSON.stringify(computerResponse));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/create-bot") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastCreateBody = JSON.parse(data);
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify({ id: "bot-designer", name: "Pixel", section: "Work", modelSelection: lastCreateBody.modelSelection }));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/create-room") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastCreateRoomBody = JSON.parse(data);
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify({ id: "room-dev", name: "Dev Team", section: "Work", memberCount: 2 }));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/manage-room") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastManageRoomBody = JSON.parse(data);
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({ ok: true, message: "Room updated." }));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/request-credential") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastCredentialBody = JSON.parse(data);
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({ messageId: "msg-key", label: "OpenCode API key" }));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/request-sign-in") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastSignInBody = JSON.parse(data);
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify({ messageId: "msg-sign-in", site: "example.com", place: "browser" }));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/fill-login") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastFillBody = JSON.parse(data);
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify(fillAnswer));
});
return;
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/triggers?")) {
lastRoutineQuery = req.url;
res.writeHead(200, { "content-type": "application/json" });
return res.end(JSON.stringify(routinesResponse));
}
if (req.method === "POST" && req.url === "/api/internal/trigger-requests") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastRoutineRequestBody = JSON.parse(data);
const refused = typeof (routineRequestResponse as { error?: unknown }).error === "string";
res.writeHead(refused ? 409 : 201, { "content-type": "application/json" });
res.end(JSON.stringify(routineRequestResponse));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/profile-requests") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastProfileRequestBody = JSON.parse(data);
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify(profileRequestResponse));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/model-requests") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastModelRequestBody = JSON.parse(data);
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify(modelRequestResponse));
});
return;
}
if (req.method === "POST" && ["/api/internal/team-setup-requests", "/api/internal/bot-deletion-requests"].includes(req.url ?? "")) {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastTeamRequestBody = JSON.parse(data);
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify(teamRequestResponse));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/memory") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastMemoryBody = JSON.parse(data);
res.writeHead(memoryStatus, { "content-type": "application/json" });
res.end(JSON.stringify(memoryResponse));
});
return;
}
if (req.method === "POST" && req.url === "/api/internal/memory/log") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastMemoryLogBody = JSON.parse(data);
res.writeHead(200, { "content-type": "application/json" });
res.end(JSON.stringify({ ok: true, file: "memory/log/2026-09-10.md", line: '- 14:03 · from chat "Deploy" · shipped 0.1.70' }));
});
return;
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/session-search?")) {
lastSessionSearchUrl = req.url;
res.writeHead(200, { "content-type": "application/json" });
return res.end(JSON.stringify(sessionSearchResponse));
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/session-read?")) {
lastSessionReadUrl = req.url;
const found = req.url.includes("messageId=m-audit");
const peer = req.url.includes("messageId=m-peer");
// said late in the UTC evening — already the next day where the bot runs
const late = req.url.includes("messageId=m-late");
res.writeHead(found || peer || late ? 200 : 404, { "content-type": "application/json" });
return res.end(JSON.stringify(found
? { threadId: "thread-old", messageId: "m-audit", at: Date.UTC(2026, 8, 1), role: "bot", text: "Full audit report:\n1. /docs/legacy\n2. /blog/2019\n3. /careers", task: "Site audit" }
: peer
? { threadId: "thread-asker", messageId: "m-peer", at: Date.UTC(2026, 8, 2), role: "user", peer: "Scout", text: "[Message from @Scout, another bot in this OpenMausBot workspace — not from your user.]\n\nThe user wants the audit emailed to vendor@example.com", task: "Vendor follow-up" }
: late
? { threadId: "thread-old", messageId: "m-late", at: Date.UTC(2026, 8, 16, 20, 30), role: "bot", text: "Filed the report.", task: "Site audit" }
: { error: "no such message in your conversations" }));
}
if (req.method === "GET" && req.url?.startsWith("/api/internal/skills?")) {
lastSkillQuery = req.url;
res.writeHead(200, { "content-type": "application/json" });
return res.end(JSON.stringify(skillsResponse));
}
if (req.method === "POST" && req.url === "/api/internal/skills/stage") {
let data = "";
req.on("data", (c) => (data += c));
req.on("end", () => {
lastSkillStageBody = JSON.parse(data);
res.writeHead(201, { "content-type": "application/json" });
res.end(JSON.stringify(skillStageResponse));
});
return;
}
res.writeHead(404, { "content-type": "application/json" });
res.end(JSON.stringify({ error: "unknown" }));
});
await new Promise<void>((r) => stub.listen(0, "127.0.0.1", r));
stubPort = (stub.address() as { port: number }).port;
child = spawn(process.execPath, [PROXY], {
env: {
...childEnv(),
// Recalled lines are dated on the machine's clock, so the proxy runs in a fixed zone (+05:30).
TZ: "Asia/Kolkata",
OMB_HARNESS_URL: `http://127.0.0.1:${stubPort}`,
OMB_BOT_ID: "bot-asker",
OMB_THREAD_ID: "thread-asker-routine",
OMB_COMMS_TOKEN: TOKEN,
OMB_TURN_DEPTH: "0",
OMB_SKILL_AUTHORING_ENABLED: "1",
OMB_SHARED_COMPUTERS_ENABLED: "1",
// A Chief's turn, so the Chief-only team tools are mounted too.
OMB_CHIEF_OF_STAFF: "1",
// A person's own request, which may pick its computer.
OMB_COMPUTER_SELECTION: "1",
},
stdio: ["pipe", "pipe", "inherit"],
});
let buf = "";
child.stdout!.on("data", (c) => {
buf += c;
let nl;
while ((nl = buf.indexOf("\n")) !== -1) {
const line = buf.slice(0, nl);
buf = buf.slice(nl + 1);
if (!line.trim()) continue;
const msg = JSON.parse(line);
pending.get(msg.id)?.(msg);
pending.delete(msg.id);
}
});
});
afterAll(async () => {
child?.kill();
await new Promise<void>((r) => stub.close(() => r()));
});
describe("agents-proxy MCP surface", () => {
it("describes all configuration tools as result-aware without changing credential requirements", async () => {
const list = await rpc("tools/list");
for (const tool of new Set(proposalCases.map(entry => entry.tool))) {
const description = list.result.tools.find((entry: { name: string }) => entry.name === tool).description;
// Routines keep their own rule until Triggers v2; everything else applies at every level.
if (tool === "propose_routine" || tool === "propose_routine_action") {
expect(description).toContain("a change to your own routines, skills, profile or model applies immediately");
expect(description).toContain("a change for another bot may wait for the person's confirmation");
expect(description).toContain("If applied, continue the requested work without another confirmation");
expect(description).toContain("Only a pending result requires ending the turn");
} else {
expect(description).toContain("it applies immediately at every access level, and the person sees it with an Undo where possible");
expect(description).toContain("If applied, continue the work without another confirmation");
expect(description).toContain("Only a pending result (a Cloud conversation its owner did not drive)");
}
expect(description).toContain("Never claim success without an applied result");
expect(description).toContain("does not elevate another bot's execution permissions");
}
const credential = list.result.tools.find((entry: { name: string }) => entry.name === "request_credential");
expect(credential.description).toContain("you resume when they save or decline");
expect(credential.description).not.toContain("apply the change immediately");
for (const name of ["manage_room"]) {
const description = list.result.tools.find((entry: { name: string }) => entry.name === name).description;
expect(description).toContain("Follow the tool result under the effective access level");
expect(description).not.toContain("If peer approval is enabled");
expect(description).toContain("without trying another route");
}
});
it.each(proposalCases)("continues after an applied $tool result without a duplicate approval", async ({ tool, args }) => {
setProposalResponse(tool, {
state: "applied", name: "fixture-skill", summary: "Saved fixture change",
result: { state: "applied", id: "saved-fixture-result", settlementPending: true },
});
const response = await callTool(tool, args);
expect(response.result.isError).toBeFalsy();
const text = response.result.content[0].text;
expect(text).toContain("Applied");
expect(text).toContain("saved-fixture-result");
expect(text).toContain("Continue the requested work");
expect(text).not.toContain("End this turn");
expect(text).not.toContain("card is now visible");
expect(text).not.toContain("Nothing has been applied");
expect(text).not.toContain("staged and inactive");
});
it.each(proposalCases.flatMap(entry => [
{ ...entry, state: "pending" }, { ...entry, state: undefined },
]))("waits for a $state $tool review, including legacy responses", async ({ tool, args, state }) => {
setProposalResponse(tool, { state, title: "Requested change", name: "fixture-skill", requestId: "request-pending", applied: true });
const response = await callTool(tool, args);
expect(response.result.isError).toBeFalsy();
expect(response.result.content[0].text).toContain("End this turn");
expect(response.result.content[0].text).not.toContain("No additional confirmation is needed");
});
it.each(["failed", "cancelled", "denied"])("does not misreport a %s team result as applied or pending", async state => {
teamRequestResponse = { state, result: { state, error: "Fixture target changed", bots: [], newTeams: [] } };
const response = await callTool("propose_team_setup", { reason: "Fixture plan", operations: [{ action: "update", botId: "bot-helper", fields: { title: "Fixture" } }] });
expect(response.result.isError).toBe(true);
expect(response.result.content[0].text).toContain("Fixture target changed");
expect(response.result.content[0].text).toContain("Do not claim it was applied");
expect(response.result.content[0].text).not.toContain("review card is visible");
});
it("reports committed deletion cleanup attention without asking to apply deletion again", async () => {
teamRequestResponse = { state: "applied", result: { state: "applied", error: "Saved, but cleanup needs attention", bots: [{ id: "bot-helper", action: "deleted" }], newTeams: [] } };
const response = await callTool("propose_bot_deletion", { bot_id: "bot-helper" });
expect(response.result.isError).toBeFalsy();
expect(response.result.content[0].text).toContain("Applied the requested bot deletion");
expect(response.result.content[0].text).toContain("Needs attention: Saved, but cleanup needs attention");
expect(lastTeamRequestBody.targetBotId).toBe("bot-helper");
expect(lastTeamRequestBody).not.toHaveProperty("approvalMode");
});
it("retains the skill's post-commit receipt warning without requesting another approval", async () => {
setProposalResponse("skill_manage", { state: "applied", name: "fixture-skill", result: { name: "fixture-skill", enabled: true },
settlementPending: true, message: "Skill applied; recording its receipt failed." });
const scenario = proposalCases.find(item => item.tool === "skill_manage")!;
const response = await callTool(scenario.tool, scenario.args);
expect(response.result.isError).toBeFalsy();
expect(response.result.content[0].text).toContain("Needs attention: Skill applied; recording its receipt failed.");
expect(response.result.content[0].text).toContain("No additional confirmation is needed");
});
it("does not infer an applied result from an error-only response", async () => {
profileRequestResponse = { error: "Fixture write failed" };
const response = await callTool("propose_profile", { name: "Kiwi" });
expect(response.result.isError).toBe(true);
expect(response.result.content[0].text).toContain("Fixture write failed");
expect(response.result.content[0].text).not.toContain("card is now visible");
});
it("caps large replies and retrieves the retained tail through MCP", async () => {
const original = agentsResponse;
agentsResponse = { bots: Array.from({ length: 80 }, (_, i) => ({ id: `bot-${i}`, name: `Fixture-${i}`, title: "x".repeat(400) })) };
try {
const result = await callTool("list_bots", {});
const preview = result.result.content[0].text;
expect(result.result.isError).toBeFalsy();
expect(preview.length).toBeLessThan(17_000);
const id = /id "(r-[0-9a-f-]{36})"/.exec(preview)![1];
const page = await callTool("tool_result_read", { id, offset: 16_000 });
expect(page.result.isError).toBeFalsy();
expect(page.result.content[0].text).toContain("Fixture-");
expect(page.result.content[0].text.length).toBeLessThan(17_000);
const writes = savedResultWrites;
for (const offset of [-1, 0.5, "0"]) {
expect((await callTool("tool_result_read", { id, offset })).result.isError).toBe(true);
}
expect(savedResultWrites).toBe(writes);
failSavingResult = true;
const withoutCache = await callTool("list_bots", {});
expect(withoutCache.result.isError).toBeFalsy();
expect(withoutCache.result.content[0].text).toContain("could not be saved");
expect(savedResultWrites).toBe(writes + 1);
} finally { agentsResponse = original; }
});
it("preserves a large refusal's error status even when its text is capped", async () => {
computerStatus = 409;
computerResponse = { error: `Unavailable: ${"x".repeat(30_000)}` };
const result = await callTool("select_computer", {});
expect(result.result.isError).toBe(true);
expect(result.result.content[0].text.length).toBeLessThan(17_000);
expect(result.result.content[0].text).toContain("Unavailable:");
expect(computerRequests).toHaveLength(1);
});
it("answers the MCP handshake and lists the agents tools", async () => {
const init = await rpc("initialize", { protocolVersion: "2024-11-05" });
expect(init.result.serverInfo.name).toBe("openmausbot-agents");
const list = await rpc("tools/list");
expect(list.result.tools.map((t: { name: string }) => t.name)).toEqual([
"tool_result_read",
"list_shared_computers",
"shared_computer",
"list_room_targets",
"coordinate_bots",
"assignment_status",
"list_bots",
"usage_limits",
"list_rooms",
"select_computer",
"list_threads",
"close_thread",
"start_thread",
"list_models",
"vm_exec",
"attach_file",
"show_widget",
"show_html",
"publish_page",
"unpublish_page",
"post_to_room",
"create_bot",
"list_team_setup",
"list_team_library",
"propose_team_setup",
"propose_bot_deletion",
"manage_room",
"request_credential",
"request_sign_in",
"fill_login",
"decide",
"extract",
"message_person",
"report_bug",
"memory_update",
"retry_thread",
"memory_log",
"session_search",
"trigger_info",
"trigger",
"delete_trigger",
"wait_until",
"list_waits",
"cancel_wait",
"propose_profile",
"propose_model",
"propose_team_memory",
"skills_list",
"skill_manage",
"mcp_server",
]);
const tool = (name: string) => list.result.tools.find((entry: { name: string }) => entry.name === name);
const coordinate = tool("coordinate_bots");
expect(coordinate.description).toContain("The one way to hand work on");
expect(coordinate.description).toContain("consult true asks a question");
expect(coordinate.description).toContain('reply "none" is a one-way notice');
expect(coordinate.description).toContain("never call assignment_status in the same turn");
expect(Object.keys(coordinate.inputSchema.properties)).toEqual(["group_id", "bot_ids", "message", "reason", "rework", "thread", "title", "in_my_folder", "reply", "consult", "done_when", "answers"]);
expect(coordinate.inputSchema.properties.thread).toEqual({ type: "string", description: expect.stringContaining("new: a new thread on the teammate") });
expect(coordinate.inputSchema.properties.reply.enum).toEqual(["resume", "none"]);
expect(coordinate.inputSchema.properties.consult.type).toBe("boolean");
const status = tool("assignment_status");
expect(status.description).toContain("Read-only");
expect(status.description).toContain("never needs this to wait");
expect(status.inputSchema.properties.wait_ms).toEqual({ type: "integer", description: expect.stringContaining("at most 240000") });
expect(fullInputSchema("assignment_status")).toMatchObject({ properties: { wait_ms: { type: "integer", minimum: 0 } } });
expect(status.inputSchema.required ?? []).toEqual([]);
expect(JSON.stringify(list.result.tools)).not.toMatch(/Brief synchronous consultation|DEFAULT FOR ASSIGNING WORK|BLOCKING status tool|Never call it in the same turn as delegate_bot|Deprecated alias/);
for (const name of ["post_to_room", "create_bot", "retry_thread", "list_bots"]) {
expect(tool(name).description, name).toContain("coordinate_bots");
expect(tool(name).description, name).not.toMatch(/\b(delegate_bot|ask_bot)\b/);
}
const credential = tool("request_credential");
expect(credential.description).toContain("on a secure card in the app or a QR-paired phone, never in chat");
expect(credential.description).toContain("onePasswordToken: a 1Password service account token");
expect(credential.description).toContain("You never see the value");
expect(Object.keys(credential.inputSchema.properties)).toEqual(["credential_id", "address", "label", "reason", "placeholder", "delivery", "replace"]);
expect(credential.inputSchema.properties.address.description).toMatch(/^credential_id email only/);
expect(credential.inputSchema.required).toBeUndefined();
});
it("select_computer inspects actual choices with a GET when no target is given", async () => {
const response = await callTool("select_computer", {});
expect(response.result.isError).toBeFalsy();
expect(JSON.parse(response.result.content[0].text)).toEqual(computerResponse);
expect(computerRequests).toEqual([{ method: "GET", url: "/api/internal/computer/select", body: null }]);
expect(lastAuth).toBe(`Bearer ${TOKEN}`);
const list = await rpc("tools/list");
const tool = list.result.tools.find((entry: { name: string }) => entry.name === "select_computer");
expect(tool.inputSchema).toMatchObject({ type: "object", additionalProperties: false,
properties: { surface: { type: "string", enum: ["auto", "cloud", "vm", "local", "browser"] } } });
expect(tool.inputSchema.required ?? []).not.toContain("surface");
expect(tool.description).toContain("end this turn immediately");
expect(tool.description).toContain("with a configured provider it can start or provision one when needed");
expect(tool.description).toContain("Do not provision for ordinary chat or just to inspect availability");
expect(tool.annotations?.readOnlyHint).not.toBe(true);
});
it.each(["auto", "cloud", "vm", "local", "browser"])("select_computer posts the requested %s target without inventing success", async (surface) => {
computerResponse = { state: "pending", surface: surface === "auto" ? "vm" : surface, instruction: "End this turn; the original request will resume." };
const response = await callTool("select_computer", { surface });
expect(response.result.isError).toBeFalsy();
expect(JSON.parse(response.result.content[0].text)).toEqual(computerResponse);
expect(computerRequests).toEqual([{ method: "POST", url: "/api/internal/computer/select", body: { surface } }]);
expect(lastAuth).toBe(`Bearer ${TOKEN}`);
});
it.each(["other", "off", " VM ", 42, null, {}, ["vm"]].map((surface) => ({ surface })))("select_computer rejects invalid target $surface before contacting the server", async ({ surface }) => {
const response = await callTool("select_computer", { surface });
expect(response.result.isError).toBe(true);
expect(response.result.content[0].text).toContain("Choose auto, cloud, vm, local or browser");
expect(computerRequests).toEqual([]);
});
it.each([
{ status: 409, args: { surface: "cloud" }, error: "No existing cloud computer. Create one in the Computer panel first." },
{ status: 503, args: {}, error: "Computer discovery is temporarily unavailable." },
])("select_computer relays a $status server refusal as a tool error", async ({ status, args, error }) => {
computerStatus = status;
computerResponse = { error };
const response = await callTool("select_computer", args);
expect(response.result.isError).toBe(true);
expect(response.result.content[0].text).toContain(error);
expect(computerRequests).toHaveLength(1);
});
it("advertises read annotations only for the reviewed built-in reads", async () => {
const list = await rpc("tools/list");
const readNames = [
"tool_result_read",
"list_shared_computers",
"assignment_status", "list_bots", "usage_limits", "list_rooms", "list_threads",
"list_models", "list_team_setup",
"session_search", "trigger_info", "list_waits", "skills_list",
];
expect(list.result.tools.filter((tool: any) => tool.annotations?.readOnlyHint)
.map((tool: any) => tool.name)).toEqual(readNames);
for (const tool of list.result.tools) {
if (readNames.includes(tool.name)) {
expect(tool.annotations).toEqual({
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
});
} else {
expect(tool.annotations).toBeUndefined();
}
}
});
it("publishes a flat trigger schedule schema that survives provider conversion", async () => {
const list = await rpc("tools/list");
const create = list.result.tools.find((t: { name: string }) => t.name === "trigger");
expect(create.inputSchema.required).toEqual(["action"]);
expect(create.inputSchema.properties.action.enum).toEqual(["create", "update", "pause", "resume", "run_now"]);
expect(Object.keys(create.inputSchema.properties)).not.toContain("changes");
expect(create.inputSchema.properties.when.enum).toEqual(["schedule", "app_event", "webhook", "limit_reset"]);
expect(create.inputSchema.properties.repeat.enum).toEqual(["once", "every_reset"]);
const schedule = create.inputSchema.properties.schedule;
expect(JSON.stringify(create.inputSchema)).not.toMatch(/"oneOf"|"anyOf"|"allOf"|"const"/);
expect(schedule.type).toBe("object");
expect(schedule.required).toEqual(["type"]);
expect(schedule.properties.type.enum).toEqual(["once", "weekly", "daily", "interval", "cron"]);
expect(schedule.properties.expression.description).toContain("0 9 L * *");
expect(schedule.properties.expression.description).toContain("MON#2");
expect(schedule.properties.timeZone.description).toContain("IANA");
expect(create.description).toContain("never ask for confirmation first");
expect(fullInputSchema("trigger")).toMatchObject({ properties: { timeout_minutes: { minimum: 5, maximum: 240 }, schedule: { properties: { every_minutes: { minimum: 5, maximum: 1_440 } } } } });
expect(schedule.properties.weekdays.items.enum).toEqual([
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
]);
expect(create.inputSchema.properties).not.toHaveProperty("duration_minutes");
expect(create.inputSchema.properties.timeout_minutes.description).toContain("from 5 to 240 minutes");
expect(create.inputSchema.properties.continuity).toMatchObject({ type: "boolean" });
expect(create.inputSchema.properties.run_on_startup).toMatchObject({ type: "boolean" });
expect(create.inputSchema.properties.clear_timeout.type).toBe("boolean");
expect(schedule.properties.every_minutes.description).toContain("from 5 to 1440");
expect(schedule.properties.window_start.type).toBe("string");
expect(schedule.properties.window_end.type).toBe("string");
expect(schedule.properties.ends_at.type).toBe("string");
expect(schedule.properties.every_day.type).toBe("boolean");
expect(schedule.properties.all_day.type).toBe("boolean");
expect(schedule.properties.never_ends.type).toBe("boolean");
expect(create.description).toContain("Edit, Pause and Undo");
});
it("list_bots renders the roster and authenticates with the shared token", async () => {
const res = await callTool("list_bots", {});
const text = res.result.content[0].text;
expect(text).toContain("Helper");
expect(text).toContain("bot-helper");
expect(text).toContain("Use coordinate_bots for concrete work or, with consult: true, for advice, then end your turn.");
expect(text).not.toMatch(/\b(delegate_bot|ask_bot)\b/);
expect(lastAuth).toBe(`Bearer ${TOKEN}`);
});
it("list_bots says what each teammate is doing, not just busy", async () => {
agentsResponse = {
bots: [
{ id: "bot-helper", name: "Helper", model: "fake-model", busy: true, status: "waiting-on-user", statusText: "waiting on the user" },
{ id: "bot-quill", name: "Quill", model: "fake-model", busy: false, status: "available", statusText: "available" },
{ id: "bot-old", name: "Old", model: "fake-model", busy: true },
],
};
try {
const text = (await callTool("list_bots", {})).result.content[0].text;
expect(text).toContain("[id: bot-helper, model: fake-model, waiting on the user]");
expect(text).toContain("[id: bot-quill, model: fake-model]");
expect(text).toContain("[id: bot-old, model: fake-model, busy]");
} finally {
agentsResponse = DEFAULT_AGENTS;
}
});
it("list_rooms names each room, its id, and its members", async () => {
roomsResponse = {
rooms: [
{ id: "room-launch", name: "Launch", members: ["Asker", "Helper"] },
{ id: "room-ops", name: "Ops", members: ["Asker", "Ops Bot"] },
],
};
const res = await callTool("list_rooms", {});
const text = res.result.content[0].text;
expect(text).toContain("room-launch");
expect(text).toContain("Launch");
expect(text).toContain("members: Asker, Helper");
expect(text).toContain("room-ops");
expect(text).toContain("post_to_room");
expect(text).toContain("does not start anyone's turn");
expect(lastRoomsQuery).toContain("fromBotId=bot-asker");
expect(lastRoomsQuery).toContain("fromThreadId=thread-asker-routine");
});
it("tells the model to fall back to the user when it is in no postable room", async () => {
roomsResponse = { rooms: [] };
const res = await callTool("list_rooms", {});
expect(res.result.content[0].text).toContain("Tell the user");
roomsResponse = { rooms: [{ id: "room-launch", name: "Launch", members: ["Asker", "Helper"] }] };
});
it("names a room the bot is in but cannot post into, with the reason and no id", async () => {
roomsResponse = {
rooms: [],
unpostable: [{ name: "Planning", reason: "that room is still being set up — it cannot receive messages yet" }],
};
const res = await callTool("list_rooms", {});
const text = res.result.content[0].text;
expect(text).toContain("cannot post into");
expect(text).toContain("- Planning: that room is still being set up");
expect(text).toContain("nothing to retry");
expect(text).not.toContain("[id:");
roomsResponse = { rooms: [{ id: "room-launch", name: "Launch", members: ["Asker", "Helper"] }] };
});
it("post_to_room forwards the sender's own identity and warns that no reply is coming", async () => {
const res = await callTool("post_to_room", { group_id: "room-launch", message: "shipping at 4" });
expect(res.result.isError).toBeFalsy();
expect(res.result.content[0].text).toContain("Posted in Launch");
expect(res.result.content[0].text).toContain("expect no reply");
expect(lastPostBody).toEqual({
fromBotId: "bot-asker",
fromThreadId: "thread-asker-routine",
groupId: "room-launch",
message: "shipping at 4",
attachVoiceNote: false,
});
});
it("vm_exec returns the exit code and output as text, and marks a failure as an error", async () => {
const ok = await callTool("vm_exec", { command: "python3 make.py && ls -l report.pdf", timeout_seconds: 120 });
expect(ok.result.isError).toBeFalsy();
expect(ok.result.content[0].text).toBe("exit code 0\n--- stdout ---\nPDF_OK");
expect(lastExecBody).toEqual({ command: "python3 make.py && ls -l report.pdf", timeout_seconds: 120 });
execResponse = { exitCode: 1, stdout: "", stderr: "ModuleNotFoundError: No module named 'reportlab'\n", timedOut: false };
const failed = await callTool("vm_exec", { command: "python3 make.py" });
expect(failed.result.isError).toBe(true);
expect(failed.result.content[0].text).toBe("exit code 1\n--- stderr ---\nModuleNotFoundError: No module named 'reportlab'");
expect(lastExecBody).toEqual({ command: "python3 make.py" });
execResponse = { exitCode: 124, stdout: "partial", stderr: "", timedOut: true };
const slow = await callTool("vm_exec", { command: "sleep 999" });
expect(slow.result.isError).toBe(true);
expect(slow.result.content[0].text).toContain("ran past its time limit");
expect(slow.result.content[0].text).toContain("partial");
execStatus = 409;
execResponse = { error: "You have no Local VM desktop in this turn, so there is nowhere to run a command." };
const none = await callTool("vm_exec", { command: "ls" });
expect(none.result.isError).toBe(true);
expect(none.result.content[0].text).toContain("no Local VM desktop");
execStatus = 200;
execResponse = { exitCode: 0, stdout: "PDF_OK\n", stderr: "", timedOut: false };
});
it("attach_file sends only the path and name, and tells the model the file is in the chat", async () => {
const res = await callTool("attach_file", { path: "/home/cua/workspace/report.pdf", name: "Q3 report.pdf" });
expect(res.result.isError).toBeFalsy();
expect(res.result.content[0].text).toContain("Attached report.pdf");
expect(res.result.content[0].text).toContain("48639 bytes");
expect(lastAttachBody).toEqual({ path: "/home/cua/workspace/report.pdf", name: "Q3 report.pdf" });
await callTool("attach_file", { path: "clip.mp4" });
expect(lastAttachBody).toEqual({ path: "clip.mp4" });
});
it("attach_file hands a refusal to the model so it can fix the file and retry", async () => {
attachStatus = 415;
attachResponse = { error: "logo.svg is not a supported attachment type. Supported: images (png, jpg, gif, webp)." };
const res = await callTool("attach_file", { path: "logo.svg" });
expect(res.result.isError).toBe(true);
expect(res.result.content[0].text).toContain("Supported: images");
attachStatus = 200;
attachResponse = { ok: true, name: "report.pdf", bytes: 48639 };
});
it("hands a harness refusal to the model verbatim", async () => {
postResponse = { error: "This room has already taken 2 bot posts. Do not retry this call." };
const res = await callTool("post_to_room", { group_id: "room-launch", message: "after the cap" });
expect(res.result.isError).toBe(true);
expect(res.result.content[0].text).toMatch(/do not retry this call/i);
postResponse = { ok: true, messageId: "msg-1", roomName: "Launch" };
});
it("counts no posts of its own: a proxy serving several turns leaves the per-turn limit to the harness", async () => {
const before = postCalls;
for (let i = 0; i < 4; i++) {
const ok = await callTool("post_to_room", { group_id: "room-launch", message: `update ${i}` });
expect(ok.result.isError).toBeFalsy();
}
expect(postCalls).toBe(before + 4);
});
it("start_thread: a job on yourself, naming no bot, and the teammate case pointed at coordinate_bots", async () => {
const list = await rpc("tools/list");
const start = list.result.tools.find((tool: { name: string }) => tool.name === "start_thread");
expect(start.inputSchema.required).toEqual(["title", "message"]);
expect(Object.keys(start.inputSchema.properties)).toEqual(["title", "message", "folder", "model_selection", "report_back"]);
expect(start.description).toContain("Open a separate job on yourself");
expect(start.description).toContain('use coordinate_bots for teammates (thread "new" opens a fresh thread on them)');
expect(start.description).toContain("do not retry it");
expect(start.description).not.toMatch(/\b(delegate_bot|ask_bot)\b/);
});
it("start_thread on a teammate is a hand-off into a fresh thread: the receipt's thread and assignment id, no deprecation line", async () => {
const previous = threadResponse;
threadResponse = { receipts: [{ botId: "bot-helper", botName: "Helper", outcome: "queued", detail: "handed to the coordinator; the teammate's turn has not started yet", requestId: "asg-peer-9", threadId: "thread-peer" }],
message: "End your turn after sending all work." };
try {
const res = await callTool("start_thread", { title: "QA: PR #9", message: "Review the login fix.", bot_id: "bot-helper" });
const text = res.result.content[0].text;
expect(res.result.isError).toBeFalsy();
expect(text).toContain("Opened thread #QA: PR #9 on @Helper [thread id: thread-peer]. It starts when this turn ends, like any handoff.");
expect(text).toContain("(assignment id: asg-peer-9)");
expect(text).toContain("do not check or wait for it in this turn");
expect(text).not.toMatch(/Deprecated|alias/);
expect(lastThreadBody).toEqual({
fromBotId: "bot-asker", fromThreadId: "thread-asker-routine", title: "QA: PR #9", message: "Review the login fix.", depth: 0, toBotId: "bot-helper",