oira666_pi-subagent 0.3.15 → 0.3.17
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 +10 -8
- package/agent-names.ts +126 -0
- package/names.ts +4 -4
- package/package.json +2 -2
- package/runner.ts +21 -4
- package/american-names.ts +0 -56
package/README.md
CHANGED
|
@@ -171,12 +171,14 @@ semantics. Embedded hosts without a script entrypoint can use
|
|
|
171
171
|
## Subagent Liveness Timeouts
|
|
172
172
|
|
|
173
173
|
A delegated process cannot block its parents forever. The runner applies a
|
|
174
|
-
startup timeout before the first model turn and
|
|
175
|
-
after startup.
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
startup timeout before the first model turn and an agent-inactivity timeout
|
|
175
|
+
after startup. The inactivity watchdog is paused while any tool call is in
|
|
176
|
+
progress, so tool executions can run for unlimited time; a fresh full idle
|
|
177
|
+
window starts after the last concurrent tool finishes. Agent/turn events and
|
|
178
|
+
changed nested-agent state reset the idle timer; repeated unchanged progress
|
|
179
|
+
heartbeats do not. On timeout or cancellation, the runner terminates the child
|
|
180
|
+
process tree and bounds cleanup; even if a wedged OS process never reports
|
|
181
|
+
`close`, the tool returns an error result so every waiting parent can settle.
|
|
180
182
|
|
|
181
183
|
RPC completion is based on Pi's `agent_settled` event—not `agent_end`.
|
|
182
184
|
`agent_end` is only a low-level run boundary and may be followed by Pi's normal
|
|
@@ -188,7 +190,7 @@ reported immediately as failures.
|
|
|
188
190
|
| --- | --- | --- |
|
|
189
191
|
| `PI_SUBAGENT_STARTUP_TIMEOUT` | `120000` | Milliseconds allowed to reach the first model turn; `0` disables |
|
|
190
192
|
| `PI_SUBAGENT_STARTUP_RETRIES` | `2` | Fresh retries after a startup timeout |
|
|
191
|
-
| `PI_SUBAGENT_IDLE_TIMEOUT` | `1200000` | Milliseconds without
|
|
193
|
+
| `PI_SUBAGENT_IDLE_TIMEOUT` | `1200000` | Milliseconds without agent activity after startup, excluding time spent in ongoing tool calls; `0` disables |
|
|
192
194
|
|
|
193
195
|
## Timestamps & Status Footer
|
|
194
196
|
|
|
@@ -233,7 +235,7 @@ Note: crash-resume covers `subagents` calls only. An interrupted `resume_subagen
|
|
|
233
235
|
## Resumable Subagents by Name (`resume_subagents`)
|
|
234
236
|
|
|
235
237
|
Every subagent run is assigned a random, durable human first name from a bundled
|
|
236
|
-
list of
|
|
238
|
+
list of 1000 culturally diverse names — for example `John`, `Octavian`, or `Vishnu`.
|
|
237
239
|
Names are never reused anywhere in the same delegation tree. The name is
|
|
238
240
|
returned together with the agent type and shown in every TUI view.
|
|
239
241
|
|
package/agent-names.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** 1000 culturally diverse given names used for human-friendly subagent identities. */
|
|
2
|
+
export const AGENT_NAMES = [
|
|
3
|
+
// Common masculine names
|
|
4
|
+
"James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph", "Thomas", "Christopher",
|
|
5
|
+
"Charles", "Daniel", "Matthew", "Anthony", "Mark", "Donald", "Steven", "Andrew", "Paul", "Joshua",
|
|
6
|
+
"Kenneth", "Kevin", "Brian", "George", "Timothy", "Ronald", "Edward", "Jason", "Jeffrey", "Ryan",
|
|
7
|
+
"Jacob", "Gary", "Nicholas", "Eric", "Jonathan", "Stephen", "Larry", "Justin", "Scott", "Brandon",
|
|
8
|
+
"Benjamin", "Samuel", "Gregory", "Alexander", "Patrick", "Frank", "Raymond", "Jack", "Dennis", "Jerry",
|
|
9
|
+
"Tyler", "Aaron", "Jose", "Adam", "Nathan", "Henry", "Douglas", "Zachary", "Peter", "Kyle",
|
|
10
|
+
"Walter", "Ethan", "Jeremy", "Harold", "Keith", "Christian", "Roger", "Noah", "Gerald", "Carl",
|
|
11
|
+
"Terry", "Sean", "Austin", "Arthur", "Lawrence", "Jesse", "Dylan", "Bryan", "Joe", "Jordan",
|
|
12
|
+
"Billy", "Bruce", "Albert", "Willie", "Gabriel", "Logan", "Alan", "Juan", "Wayne", "Roy",
|
|
13
|
+
"Ralph", "Randy", "Eugene", "Vincent", "Russell", "Elijah", "Louis", "Bobby", "Philip", "Johnny",
|
|
14
|
+
"Howard", "Isaac", "Harry", "Victor", "Martin", "Ernest", "Phillip", "Todd", "Craig", "Shawn",
|
|
15
|
+
"Clarence", "Carlos", "Caleb", "Blake", "Mason", "Luke", "Liam", "Owen", "Nathaniel", "Cameron",
|
|
16
|
+
"Hunter", "Connor", "Adrian", "Julian", "Jeremiah", "Angel", "Isaiah", "Evan", "Colton", "Gavin",
|
|
17
|
+
"Dominic", "Cooper", "Ian", "Carson", "Jaxon", "Theodore", "Hudson", "Lincoln", "Asher", "Wyatt",
|
|
18
|
+
"Leo", "Ezra", "Miles", "Micah", "Silas", "Roman", "Wesley", "Brooks", "Bennett", "Parker",
|
|
19
|
+
"Beau", "Weston", "Damian", "Sawyer", "Emmett", "Harrison", "Cole", "Maxwell", "Holden", "Antonio",
|
|
20
|
+
"Miguel", "Oscar", "Diego", "Alejandro", "Marco", "Luis", "Javier", "Sergio", "Ricardo", "Manuel",
|
|
21
|
+
"Roberto", "Francisco", "Eduardo", "Fernando", "Ruben", "Raul", "Andres", "Hector", "Edgar", "Mario",
|
|
22
|
+
"Derek", "Trevor", "Travis", "Cody", "Dustin", "Corey", "Brett", "Chad", "Bradley", "Spencer",
|
|
23
|
+
"Grant", "Joel", "Dean", "Dale", "Glenn", "Stanley", "Leonard", "Francis", "Herbert", "Frederick",
|
|
24
|
+
"Norman", "Melvin", "Marvin", "Gordon", "Allen", "Bernard", "Clifford", "Warren", "Curtis", "Darren",
|
|
25
|
+
"Troy", "Marcus", "Derrick", "Andre", "Terrence", "Maurice", "Darius", "Malcolm", "Xavier", "Preston",
|
|
26
|
+
"Grayson", "Easton", "Nolan", "Everett", "Axel", "Emmanuel", "Kingston", "Elliot", "Tim", "Simon",
|
|
27
|
+
"Riley", "Finn", "Jasper", "Milo", "Rowan", "Declan", "Graham", "Max", "Nash", "Reid",
|
|
28
|
+
"Lane", "Tucker", "Carter", "Chase", "Coleman", "Bryce", "Hayden", "Aidan", "Jonah", "Jonas",
|
|
29
|
+
|
|
30
|
+
// Common feminine names
|
|
31
|
+
"Mary", "Patricia", "Jennifer", "Linda", "Elizabeth", "Barbara", "Susan", "Jessica", "Sarah", "Karen",
|
|
32
|
+
"Lisa", "Nancy", "Betty", "Margaret", "Sandra", "Ashley", "Kimberly", "Emily", "Donna", "Michelle",
|
|
33
|
+
"Carol", "Amanda", "Melissa", "Deborah", "Stephanie", "Dorothy", "Rebecca", "Sharon", "Laura", "Cynthia",
|
|
34
|
+
"Amy", "Kathleen", "Angela", "Shirley", "Brenda", "Emma", "Anna", "Pamela", "Nicole", "Samantha",
|
|
35
|
+
"Katherine", "Christine", "Debra", "Rachel", "Carolyn", "Janet", "Maria", "Heather", "Diane", "Julie",
|
|
36
|
+
"Joyce", "Victoria", "Kelly", "Christina", "Lauren", "Joan", "Evelyn", "Olivia", "Judith", "Megan",
|
|
37
|
+
"Cheryl", "Martha", "Andrea", "Frances", "Hannah", "Jacqueline", "Ann", "Gloria", "Jean", "Kathryn",
|
|
38
|
+
"Alice", "Teresa", "Sara", "Janice", "Doris", "Madison", "Julia", "Grace", "Judy", "Abigail",
|
|
39
|
+
"Marie", "Denise", "Beverly", "Amber", "Theresa", "Marilyn", "Danielle", "Diana", "Brittany", "Natalie",
|
|
40
|
+
"Sophia", "Rose", "Isabella", "Alexis", "Kayla", "Charlotte", "Lori", "Alexandra", "Savannah", "Brooklyn",
|
|
41
|
+
"Bella", "Claire", "Skylar", "Lucy", "Paisley", "Everly", "Caroline", "Nova", "Genesis", "Emilia",
|
|
42
|
+
"Kennedy", "Maya", "Willow", "Kinsley", "Naomi", "Aaliyah", "Elena", "Mckenna", "Ariana", "Allison",
|
|
43
|
+
"Gabriella", "Margot", "Madelyn", "Cora", "Ruby", "Eva", "Serenity", "Autumn", "Adeline", "Hailey",
|
|
44
|
+
"Gianna", "Valentina", "Isla", "Eliana", "Quinn", "Nevaeh", "Ivy", "Sadie", "Piper", "Lydia",
|
|
45
|
+
"Alexa", "Josephine", "Emery", "Phoebe", "Delilah", "Arianna", "Vivian", "Kaylee", "Sophie", "Brielle",
|
|
46
|
+
"Madeline", "Peyton", "Rylee", "Clara", "Hadley", "Melanie", "Mackenzie", "Reagan", "Adalynn", "Liliana",
|
|
47
|
+
"Aubree", "Jade", "Miranda", "Isabelle", "Natalia", "Raelynn", "Dakota", "Athena", "Ximena", "Arya",
|
|
48
|
+
"Leilani", "Taylor", "Faith", "Lena", "Kylie", "Miriam", "Kate", "Summer", "Lyla", "Brooke",
|
|
49
|
+
"Amaya", "Eliza", "Brianna", "Bailey", "Nina", "Khloe", "Jasmine", "Melody", "Isabel", "Norah",
|
|
50
|
+
"Annabelle", "Valeria", "Emerson", "Cecilia", "Valerie", "Molly", "Reese", "Aliyah", "Lilly", "Blair",
|
|
51
|
+
"Finley", "Morgan", "Sydney", "Jordyn", "Eloise", "Trinity", "Daisy", "Catherine", "Lola", "Genevieve",
|
|
52
|
+
"Marley", "Arabella", "Harmony", "Elise", "Remi", "Teagan", "Evie", "London", "Sloane", "Laila",
|
|
53
|
+
"Lucia", "Willa", "Juliana", "Gracie", "June", "Tessa", "Ada", "Camille", "Hope", "Samara",
|
|
54
|
+
"Rosalie", "Ruth", "Fiona", "Georgia", "Noelle", "Vanessa", "Daniela", "Paige", "Violet", "Presley",
|
|
55
|
+
"Adriana", "Joanna", "Giselle", "Harper", "Avery", "Scarlett", "Aria", "Ellie", "Chloe", "Layla",
|
|
56
|
+
|
|
57
|
+
// Ancient Greek, Roman, and Mediterranean names
|
|
58
|
+
"Achilles", "Aeschylus", "Agamemnon", "Alcibiades", "Andromache", "Antigone", "Apollonia", "Archimedes", "Aristides", "Aspasia",
|
|
59
|
+
"Berenice", "Briseis", "Calliope", "Cassander", "Cassia", "Cato", "Cicero", "Cleisthenes", "Clio", "Cornelia",
|
|
60
|
+
"Cyprian", "Damaris", "Demetrius", "Diogenes", "Electra", "Epictetus", "Eudora", "Euripides", "Galen", "Hecuba",
|
|
61
|
+
"Herodotus", "Hippolyta", "Horatia", "Hypatia", "Ianthe", "Isocrates", "Laodamia", "Leander", "Livia", "Lysander",
|
|
62
|
+
"Octavia", "Octavian", "Orestes", "Pericles", "Petronilla", "Plutarch", "Priam", "Sappho", "Seneca", "Themistocles",
|
|
63
|
+
|
|
64
|
+
// Norse, Celtic, and early Germanic names
|
|
65
|
+
"Aethelred", "Alaric", "Alfhild", "Ansgar", "Arnfinn", "Audhild", "Beowulf", "Boudica", "Branwen", "Brennus",
|
|
66
|
+
"Brynhild", "Cadwaladr", "Caradoc", "Cerdic", "Cormac", "Cunegunda", "Dagmar", "Eadric", "Eir", "Eirik",
|
|
67
|
+
"Embla", "Faramund", "Fergus", "Freydis", "Gudrun", "Gunnar", "Guthrum", "Gwendolen", "Halfdan", "Hildegard",
|
|
68
|
+
"Hrolf", "Iseult", "Ivar", "Leif", "Maeve", "Niamh", "Olwen", "Orlaith", "Ragnhild", "Ragnar",
|
|
69
|
+
"Rhiannon", "Sigfrid", "Sigrid", "Sigrun", "Somerled", "Svanhild", "Taliesin", "Theodelinda", "Torsten", "Yseult",
|
|
70
|
+
|
|
71
|
+
// Medieval, Byzantine, Slavic, and Baltic names
|
|
72
|
+
"Aldona", "Basilissa", "Boleslav", "Borivoj", "Bozena", "Bronislava", "Casimir", "Cyrilla", "Dobrawa", "Dragomir",
|
|
73
|
+
"Drazan", "Eudokia", "Euphemia", "Fevronia", "Gavrila", "Gleb", "Jaromir", "Jelena", "Kaloyan", "Kresimir",
|
|
74
|
+
"Ladislav", "Ljubica", "Ludmila", "Mieszko", "Milica", "Milos", "Miroslav", "Mstislav", "Nadezhda", "Niketas",
|
|
75
|
+
"Perun", "Pribislav", "Radoslav", "Rostislav", "Simeon", "Slavomir", "Sviatoslav", "Theodora", "Tomislav", "Vaclava",
|
|
76
|
+
"Vasilisa", "Vesna", "Viesturs", "Vladimir", "Vseslav", "Vytautas", "Yaroslav", "Zbigniew", "Zdislava", "Zvonimir",
|
|
77
|
+
|
|
78
|
+
// Ancient Egyptian, Mesopotamian, Persian, Armenian, and Georgian names
|
|
79
|
+
"Ahmose", "Amasis", "Amenemhat", "Ankhesenamun", "Ardashir", "Arsinoe", "Artabanus", "Artaxerxes", "Ashurbanipal", "Atossa",
|
|
80
|
+
"Bardiya", "Cambyses", "Cyrus", "Enheduanna", "Esarhaddon", "Gilgamesh", "Hatshepsut", "Horemheb", "Imhotep", "Ishtar",
|
|
81
|
+
"Kassandane", "Khafre", "Khufu", "Mandane", "Marduk", "Meritamen", "Mithridates", "Nabonidus", "Naram-Sin", "Nebuchadnezzar",
|
|
82
|
+
"Nefertari", "Nefertiti", "Neithhotep", "Nitocris", "Parmys", "Parysatis", "Pharnaces", "Psamtik", "Roxana", "Sargon",
|
|
83
|
+
"Semiramis", "Shapur", "Sinsharishkun", "Tahmasp", "Tamar", "Tigran", "Tiridates", "Tomyris", "Xerxes", "Zenobia",
|
|
84
|
+
|
|
85
|
+
// South Asian historical, literary, and traditional names
|
|
86
|
+
"Abhimanyu", "Agastya", "Amrapali", "Anasuya", "Arjuna", "Ashoka", "Bharata", "Bhaskara", "Bimbisara", "Chanakya",
|
|
87
|
+
"Chandragupta", "Charulata", "Damayanti", "Dhanvantari", "Draupadi", "Gargi", "Harsha", "Hemachandra", "Ila", "Indrajit",
|
|
88
|
+
"Jambavati", "Janaka", "Kalidasa", "Kanishka", "Karna", "Kausalya", "Krishna", "Lalitaditya", "Lopamudra", "Maitreyi",
|
|
89
|
+
"Mandodari", "Mirabai", "Nachiketa", "Narasimha", "Padmini", "Panini", "Parvati", "Prithviraj", "Razia", "Samudragupta",
|
|
90
|
+
"Savitri", "Shakuntala", "Shivaji", "Sita", "Subhadra", "Tansen", "Udayana", "Vashti", "Vikramaditya", "Vishnu",
|
|
91
|
+
|
|
92
|
+
// East Asian historical and legendary names
|
|
93
|
+
"Akiko", "Amaterasu", "Benkei", "Chiyome", "Okinagatarashi", "Himiko", "Tokimune", "Izumi", "Kaguya", "Kanetsugu",
|
|
94
|
+
"Kiyomori", "Masako", "Masamune", "Murasaki", "Nobunaga", "Raikou", "Sei", "Shingen", "Tadakatsu", "Tomoe",
|
|
95
|
+
"Hideyoshi", "Yamato", "Yoritomo", "Yoshitsune", "Yukimura", "Baochai", "Zhao", "Cao", "Chang'e", "Diaochan",
|
|
96
|
+
"Fuxi", "Guanyu", "Zhu", "Mulan", "Bai", "Bei", "Nuwa", "Zheng", "Ping", "Quan",
|
|
97
|
+
"Shimin", "Qiang", "Meiniang", "Ji", "Xishi", "Xuanzang", "Sun-sin", "Gwan-sun", "He", "Liang",
|
|
98
|
+
|
|
99
|
+
// Southeast Asian, Central Asian, and steppe names
|
|
100
|
+
"Airlangga", "Anawrahta", "Bayinnaung", "Borommatrailokkanat", "Champa", "Chulalongkorn", "Diponegoro", "Mada", "Tuah", "Rajasanagara",
|
|
101
|
+
"Jayavarman", "Kartini", "Arok", "Kertanegara", "Lakshmana", "Mahendravarman", "Parameswara", "Mulavarman", "Srikandi", "Suryavarman",
|
|
102
|
+
"Tribhuwana", "TrưngTrắc", "TrưngNhị", "Udayadityavarman", "Visay", "Arslan", "Babur", "Batu", "Bumin", "Chagatai",
|
|
103
|
+
"Genghis", "Hulagu", "Jebe", "Kublai", "Manas", "Möngke", "Nader", "Ogedei", "Roxelana", "Seljuk",
|
|
104
|
+
"Subutai", "Tokhtamysh", "Temujin", "Timur", "Tomris", "Tughril", "Taraghay", "Yesugei", "Zahiruddin", "Zebunissa",
|
|
105
|
+
|
|
106
|
+
// African historical, royal, and traditional names
|
|
107
|
+
"Amina", "Amanirenas", "Amanishakheto", "Askia", "Behanzin", "Bilqis", "Candace", "Cetshwayo", "Chaka", "Dihya",
|
|
108
|
+
"Efunroye", "Ezana", "Gudit", "Hannibal", "Hanno", "Amanitore", "Idia", "Orompoto", "Jaja", "Taharqa",
|
|
109
|
+
"Shanakhdakheto", "Kassa", "Khama", "Lalibela", "LatDior", "Liholiho", "Lukeni", "Makeda", "Sakura", "Mantatisi",
|
|
110
|
+
"Menen", "Menelik", "Mkabayi", "Moremi", "Moshoeshoe", "Mpande", "Mzilikazi", "Nandi", "YaaAsantewaa", "Njoya",
|
|
111
|
+
"Njinga", "Ewuare", "Osei", "Piankhi", "Prempeh", "Ranavalona", "Sarraounia", "Sekhukhune", "Shaka", "Sundiata",
|
|
112
|
+
|
|
113
|
+
// Indigenous American and Pacific historical and traditional names
|
|
114
|
+
"Ahuizotl", "Anacaona", "Atahualpa", "Caupolicán", "Cuitlahuac", "Cuauhtemoc", "Guarocuya", "Huascar", "Itzcoatl", "Lautaro",
|
|
115
|
+
"Malinalli", "Manco", "Moctezuma", "Nezahualcoyotl", "Ollantay", "Pachacuti", "Quispe", "Rumiñahui", "Sayri", "Sinchi",
|
|
116
|
+
"Tecuichpo", "Tlahuicole", "Tupac", "Xicotencatl", "Yma", "Hine-nui-te-pō", "Hongi", "Kamehameha", "Kaʻahumanu", "Keōpūolani",
|
|
117
|
+
"Kupe", "Liliʻuokalani", "Makea", "Maui", "Olomu", "Ngarimu", "Pakalitha", "Pele", "Pōmare", "Ruatara",
|
|
118
|
+
"Salamasina", "Tāwhiao", "Te Puea", "Tupaia", "Tūtānekai", "Uenuku", "Vaiola", "Whina", "Wherowhero", "Yosihiko",
|
|
119
|
+
|
|
120
|
+
// Middle Eastern, North African, Iberian, and Jewish historical names
|
|
121
|
+
"AbdAl-Rahman", "Aisha", "Hasan", "Ja'far", "Pelayo", "Walid", "Husayn", "Badr", "Bintou", "Abdallah",
|
|
122
|
+
"Bohemond", "Rodrigo", "Fadila", "Fatima", "Qasim", "Ghazala", "Hafsa", "Harun", "Hasdrubal", "Muhammad",
|
|
123
|
+
"Idris", "Ishaq", "Jahanara", "Khadija", "Khayzuran", "Leovigild", "Lubna", "Moshe", "Marwan", "Maslama",
|
|
124
|
+
"Musa", "Nasir", "Rabi'a", "Rashid", "Saadia", "Salahuddin", "Shajar", "Shirin", "Suhaila", "Tariq",
|
|
125
|
+
"Theodoric", "Urraca", "Wallada", "Yehuda", "Yusuf", "Zaynab", "Ziryab", "Zipporah", "Zubaida", "Zuleika",
|
|
126
|
+
] as const;
|
package/names.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Durable subagent name registry.
|
|
3
3
|
*
|
|
4
4
|
* Every spawned subagent gets a random human first name from the bundled
|
|
5
|
-
*
|
|
5
|
+
* 1000-name culturally diverse pool (e.g. `John`, `Octavian`, `Vishnu`). Names are unique within one
|
|
6
6
|
* delegation tree (the tree
|
|
7
7
|
* rooted at the top-level pi session) and are persisted in a JSON registry
|
|
8
8
|
* file under the subagent session root, so they survive process restarts.
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import * as fs from "node:fs";
|
|
22
22
|
import * as path from "node:path";
|
|
23
23
|
import { randomInt } from "node:crypto";
|
|
24
|
-
import {
|
|
24
|
+
import { AGENT_NAMES } from "./agent-names.js";
|
|
25
25
|
|
|
26
26
|
export const SUBAGENT_NAMES_FILE_ENV = "PI_SUBAGENT_NAMES_FILE";
|
|
27
27
|
|
|
@@ -351,7 +351,7 @@ export async function updateNamesRegistry<T>(
|
|
|
351
351
|
|
|
352
352
|
export function getAvailableSubagentNames(registry: NamesRegistry): string[] {
|
|
353
353
|
const used = new Set(Object.keys(registry.agents).map((name) => name.toLowerCase()));
|
|
354
|
-
return
|
|
354
|
+
return AGENT_NAMES.filter((name) => !used.has(name.toLowerCase()));
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
export interface AllocateNameRequest {
|
|
@@ -377,7 +377,7 @@ export async function allocateSubagentNames(
|
|
|
377
377
|
const available = getAvailableSubagentNames(registry);
|
|
378
378
|
if (available.length < requests.length) {
|
|
379
379
|
throw new Error(
|
|
380
|
-
`The
|
|
380
|
+
`The ${AGENT_NAMES.length}-name subagent pool is exhausted (${available.length} available, ${requests.length} requested).`,
|
|
381
381
|
);
|
|
382
382
|
}
|
|
383
383
|
for (const request of requests) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oira666_pi-subagent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "Subagent extension for Pi coding agent. Delegate tasks to specialized agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"runner.ts",
|
|
12
12
|
"resume.ts",
|
|
13
13
|
"names.ts",
|
|
14
|
-
"
|
|
14
|
+
"agent-names.ts",
|
|
15
15
|
"shared.ts",
|
|
16
16
|
"render.ts",
|
|
17
17
|
"tree.ts",
|
package/runner.ts
CHANGED
|
@@ -45,8 +45,9 @@ const RETRY_WAIT_GRACE_MS = 60_000;
|
|
|
45
45
|
const DEFAULT_STARTUP_TIMEOUT_MS = 120_000; // only for startup (before first assistant turn)
|
|
46
46
|
const SUBAGENT_STARTUP_TIMEOUT_ENV = "PI_SUBAGENT_STARTUP_TIMEOUT";
|
|
47
47
|
// Once startup succeeds, a child can otherwise remain alive forever if Pi loses
|
|
48
|
-
// the next model/RPC turn after a tool result. Bound
|
|
49
|
-
// repeated progress heartbeats)
|
|
48
|
+
// the next model/RPC turn after a tool result. Bound agent inactivity (not
|
|
49
|
+
// repeated progress heartbeats), but never while one of its tools is executing:
|
|
50
|
+
// tool runtimes are intentionally unbounded.
|
|
50
51
|
const DEFAULT_IDLE_TIMEOUT_MS = 20 * 60_000;
|
|
51
52
|
const SUBAGENT_IDLE_TIMEOUT_ENV = "PI_SUBAGENT_IDLE_TIMEOUT";
|
|
52
53
|
// A startup timeout is almost always a transient cold-start stall (slow cli /
|
|
@@ -874,6 +875,10 @@ export async function runAgentSubprocess(opts: RunAgentOptions): Promise<SingleR
|
|
|
874
875
|
let agentSettled = false;
|
|
875
876
|
let forcedExitCode: number | undefined;
|
|
876
877
|
let lastNestedProgressSignature: string | undefined;
|
|
878
|
+
// Track only tool calls from this process attempt. Persisted live render
|
|
879
|
+
// state may contain a tool that was interrupted before a resume and must
|
|
880
|
+
// not disable the new process's watchdog forever.
|
|
881
|
+
const activeToolCallIds = new Set<string>();
|
|
877
882
|
let abortHandler: (() => void) | undefined;
|
|
878
883
|
const promptRequestId = `pi-subagent-${process.pid}-${Date.now()}-${attempt}`;
|
|
879
884
|
let steeringRequest = 0;
|
|
@@ -982,12 +987,18 @@ export async function runAgentSubprocess(opts: RunAgentOptions): Promise<SingleR
|
|
|
982
987
|
})();
|
|
983
988
|
|
|
984
989
|
const noteSemanticActivity = (minimumQuietPeriodMs = 0) => {
|
|
990
|
+
if (idleTimer) { clearTimeout(idleTimer); idleTimer = undefined; }
|
|
985
991
|
if (!receivedFirstEvent || idleTimeoutMs === 0 || resolved) return;
|
|
986
|
-
|
|
992
|
+
// The idle timeout measures the agent itself, not tools it has invoked.
|
|
993
|
+
// A tool may legitimately be silent for longer than the configured
|
|
994
|
+
// timeout, so leave the watchdog disarmed until every concurrent tool
|
|
995
|
+
// execution has ended. tool_execution_end will call this again and
|
|
996
|
+
// start a fresh full inactivity window.
|
|
997
|
+
if (activeToolCallIds.size > 0) return;
|
|
987
998
|
const quietPeriodMs = Math.max(idleTimeoutMs, minimumQuietPeriodMs);
|
|
988
999
|
idleTimer = setTimeout(() => {
|
|
989
1000
|
if (resolved) return;
|
|
990
|
-
const message = `Subagent inactivity timeout: no
|
|
1001
|
+
const message = `Subagent inactivity timeout: no agent activity for ${quietPeriodMs}ms.`;
|
|
991
1002
|
forcedExitCode = 1;
|
|
992
1003
|
result.stopReason = "error";
|
|
993
1004
|
result.errorMessage = message;
|
|
@@ -1001,6 +1012,12 @@ export async function runAgentSubprocess(opts: RunAgentOptions): Promise<SingleR
|
|
|
1001
1012
|
let event: any;
|
|
1002
1013
|
try { event = JSON.parse(line); } catch { event = null; }
|
|
1003
1014
|
|
|
1015
|
+
if (event?.type === "tool_execution_start" && typeof event.toolCallId === "string") {
|
|
1016
|
+
activeToolCallIds.add(event.toolCallId);
|
|
1017
|
+
} else if (event?.type === "tool_execution_end" && typeof event.toolCallId === "string") {
|
|
1018
|
+
activeToolCallIds.delete(event.toolCallId);
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1004
1021
|
if (
|
|
1005
1022
|
event?.type === "response" &&
|
|
1006
1023
|
event.id === promptRequestId &&
|
package/american-names.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/** 500 common American first names used for human-friendly subagent identities. */
|
|
2
|
-
export const AMERICAN_NAMES = [
|
|
3
|
-
// Common masculine names
|
|
4
|
-
"James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph", "Thomas", "Christopher",
|
|
5
|
-
"Charles", "Daniel", "Matthew", "Anthony", "Mark", "Donald", "Steven", "Andrew", "Paul", "Joshua",
|
|
6
|
-
"Kenneth", "Kevin", "Brian", "George", "Timothy", "Ronald", "Edward", "Jason", "Jeffrey", "Ryan",
|
|
7
|
-
"Jacob", "Gary", "Nicholas", "Eric", "Jonathan", "Stephen", "Larry", "Justin", "Scott", "Brandon",
|
|
8
|
-
"Benjamin", "Samuel", "Gregory", "Alexander", "Patrick", "Frank", "Raymond", "Jack", "Dennis", "Jerry",
|
|
9
|
-
"Tyler", "Aaron", "Jose", "Adam", "Nathan", "Henry", "Douglas", "Zachary", "Peter", "Kyle",
|
|
10
|
-
"Walter", "Ethan", "Jeremy", "Harold", "Keith", "Christian", "Roger", "Noah", "Gerald", "Carl",
|
|
11
|
-
"Terry", "Sean", "Austin", "Arthur", "Lawrence", "Jesse", "Dylan", "Bryan", "Joe", "Jordan",
|
|
12
|
-
"Billy", "Bruce", "Albert", "Willie", "Gabriel", "Logan", "Alan", "Juan", "Wayne", "Roy",
|
|
13
|
-
"Ralph", "Randy", "Eugene", "Vincent", "Russell", "Elijah", "Louis", "Bobby", "Philip", "Johnny",
|
|
14
|
-
"Howard", "Isaac", "Harry", "Victor", "Martin", "Ernest", "Phillip", "Todd", "Craig", "Shawn",
|
|
15
|
-
"Clarence", "Carlos", "Caleb", "Blake", "Mason", "Luke", "Liam", "Owen", "Nathaniel", "Cameron",
|
|
16
|
-
"Hunter", "Connor", "Adrian", "Julian", "Jeremiah", "Angel", "Isaiah", "Evan", "Colton", "Gavin",
|
|
17
|
-
"Dominic", "Cooper", "Ian", "Carson", "Jaxon", "Theodore", "Hudson", "Lincoln", "Asher", "Wyatt",
|
|
18
|
-
"Leo", "Ezra", "Miles", "Micah", "Silas", "Roman", "Wesley", "Brooks", "Bennett", "Parker",
|
|
19
|
-
"Beau", "Weston", "Damian", "Sawyer", "Emmett", "Harrison", "Cole", "Maxwell", "Holden", "Antonio",
|
|
20
|
-
"Miguel", "Oscar", "Diego", "Alejandro", "Marco", "Luis", "Javier", "Sergio", "Ricardo", "Manuel",
|
|
21
|
-
"Roberto", "Francisco", "Eduardo", "Fernando", "Ruben", "Raul", "Andres", "Hector", "Edgar", "Mario",
|
|
22
|
-
"Derek", "Trevor", "Travis", "Cody", "Dustin", "Corey", "Brett", "Chad", "Bradley", "Spencer",
|
|
23
|
-
"Grant", "Joel", "Dean", "Dale", "Glenn", "Stanley", "Leonard", "Francis", "Herbert", "Frederick",
|
|
24
|
-
"Norman", "Melvin", "Marvin", "Gordon", "Allen", "Bernard", "Clifford", "Warren", "Curtis", "Darren",
|
|
25
|
-
"Troy", "Marcus", "Derrick", "Andre", "Terrence", "Maurice", "Darius", "Malcolm", "Xavier", "Preston",
|
|
26
|
-
"Grayson", "Easton", "Nolan", "Everett", "Axel", "Emmanuel", "Kingston", "Elliot", "Tim", "Simon",
|
|
27
|
-
"Riley", "Finn", "Jasper", "Milo", "Rowan", "Declan", "Graham", "Max", "Nash", "Reid",
|
|
28
|
-
"Lane", "Tucker", "Carter", "Chase", "Coleman", "Bryce", "Hayden", "Aidan", "Jonah", "Jonas",
|
|
29
|
-
|
|
30
|
-
// Common feminine names
|
|
31
|
-
"Mary", "Patricia", "Jennifer", "Linda", "Elizabeth", "Barbara", "Susan", "Jessica", "Sarah", "Karen",
|
|
32
|
-
"Lisa", "Nancy", "Betty", "Margaret", "Sandra", "Ashley", "Kimberly", "Emily", "Donna", "Michelle",
|
|
33
|
-
"Carol", "Amanda", "Melissa", "Deborah", "Stephanie", "Dorothy", "Rebecca", "Sharon", "Laura", "Cynthia",
|
|
34
|
-
"Amy", "Kathleen", "Angela", "Shirley", "Brenda", "Emma", "Anna", "Pamela", "Nicole", "Samantha",
|
|
35
|
-
"Katherine", "Christine", "Debra", "Rachel", "Carolyn", "Janet", "Maria", "Heather", "Diane", "Julie",
|
|
36
|
-
"Joyce", "Victoria", "Kelly", "Christina", "Lauren", "Joan", "Evelyn", "Olivia", "Judith", "Megan",
|
|
37
|
-
"Cheryl", "Martha", "Andrea", "Frances", "Hannah", "Jacqueline", "Ann", "Gloria", "Jean", "Kathryn",
|
|
38
|
-
"Alice", "Teresa", "Sara", "Janice", "Doris", "Madison", "Julia", "Grace", "Judy", "Abigail",
|
|
39
|
-
"Marie", "Denise", "Beverly", "Amber", "Theresa", "Marilyn", "Danielle", "Diana", "Brittany", "Natalie",
|
|
40
|
-
"Sophia", "Rose", "Isabella", "Alexis", "Kayla", "Charlotte", "Lori", "Alexandra", "Savannah", "Brooklyn",
|
|
41
|
-
"Bella", "Claire", "Skylar", "Lucy", "Paisley", "Everly", "Caroline", "Nova", "Genesis", "Emilia",
|
|
42
|
-
"Kennedy", "Maya", "Willow", "Kinsley", "Naomi", "Aaliyah", "Elena", "Mckenna", "Ariana", "Allison",
|
|
43
|
-
"Gabriella", "Margot", "Madelyn", "Cora", "Ruby", "Eva", "Serenity", "Autumn", "Adeline", "Hailey",
|
|
44
|
-
"Gianna", "Valentina", "Isla", "Eliana", "Quinn", "Nevaeh", "Ivy", "Sadie", "Piper", "Lydia",
|
|
45
|
-
"Alexa", "Josephine", "Emery", "Phoebe", "Delilah", "Arianna", "Vivian", "Kaylee", "Sophie", "Brielle",
|
|
46
|
-
"Madeline", "Peyton", "Rylee", "Clara", "Hadley", "Melanie", "Mackenzie", "Reagan", "Adalynn", "Liliana",
|
|
47
|
-
"Aubree", "Jade", "Miranda", "Isabelle", "Natalia", "Raelynn", "Dakota", "Athena", "Ximena", "Arya",
|
|
48
|
-
"Leilani", "Taylor", "Faith", "Lena", "Kylie", "Miriam", "Kate", "Summer", "Lyla", "Brooke",
|
|
49
|
-
"Amaya", "Eliza", "Brianna", "Bailey", "Nina", "Khloe", "Jasmine", "Melody", "Isabel", "Norah",
|
|
50
|
-
"Annabelle", "Valeria", "Emerson", "Cecilia", "Valerie", "Molly", "Reese", "Aliyah", "Lilly", "Blair",
|
|
51
|
-
"Finley", "Morgan", "Sydney", "Jordyn", "Eloise", "Trinity", "Daisy", "Catherine", "Lola", "Genevieve",
|
|
52
|
-
"Marley", "Arabella", "Harmony", "Elise", "Remi", "Teagan", "Evie", "London", "Sloane", "Laila",
|
|
53
|
-
"Lucia", "Willa", "Juliana", "Gracie", "June", "Tessa", "Ada", "Camille", "Hope", "Samara",
|
|
54
|
-
"Rosalie", "Ruth", "Fiona", "Georgia", "Noelle", "Vanessa", "Daniela", "Paige", "Violet", "Presley",
|
|
55
|
-
"Adriana", "Joanna", "Giselle", "Harper", "Avery", "Scarlett", "Aria", "Ellie", "Chloe", "Layla",
|
|
56
|
-
] as const;
|