Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

merge(main): 合入主干并保留隐藏任务入口

xuzini-xzn09c890971238
diff --cc apps/desktop/src/renderer/features/bots/__tests__/botChannelsPage.test.tsx
index bb93382922,c8e3e9fc7a..12afe65dbd
--- a/apps/desktop/src/renderer/features/bots/__tests__/botChannelsPage.test.tsx
+++ b/apps/desktop/src/renderer/features/bots/__tests__/botChannelsPage.test.tsx
@@@ -11,10 -11,10 +11,12 @@@ import type { BotProfile } from '../bot
const mocks = vi.hoisted(() => ({
confirm: vi.fn(async () => true),
+ navigate: vi.fn(),
}));
+vi.mock('react-router-dom', () => ({ useNavigate: () => mocks.navigate }));
+ // The shared-quota rail observes auth; this component fixture has no auth host.
+ vi.mock('@/contexts/AuthContext', () => ({ useOptionalAuthUser: () => null }));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
diff --cc packages/maker-core/src/agents/pi/pi-subagent-runs.ts
index 5b2f1821c1,976fd4c7ef..098d4f43d8
--- a/packages/maker-core/src/agents/pi/pi-subagent-runs.ts
+++ b/packages/maker-core/src/agents/pi/pi-subagent-runs.ts
@@@ -3148,101 -3135,14 +3148,109 @@@ async function terminalResultProcessIde
/**
* Inventory only for receipt recovery; never a source of PIDs to signal.
- * Empty/failed/truncated probes are unknown, not proof of absence. Windows can
- * omit command lines for protected processes in other accounts. Use the OS
- * user filter first (tasklist /FI USERNAME, like POSIX ps -u), then require a
- * readable command line or independent exit confirmation for every selected
- * PID, except OS-confirmed antimalware PPL processes (which cannot be our
- * ordinary Node/Electron/Pi runtimes). Other inaccessible live processes keep
- * recovery closed; PID discovery never authorizes a kill.
+ * Empty stdout, a failed probe, or `complete: false` are unknown, not proof of
+ * absence. A finished Windows probe may return no command lines: that means
+ * the current user had no process left to read, which is absence.
+ * Windows can omit command lines for protected processes in other accounts.
+ * Use the OS user filter first (tasklist /FI USERNAME, like POSIX ps -u), then
+ * require a readable command line or independent exit confirmation for every
+ * selected PID, except OS-confirmed antimalware PPL processes (which cannot be
+ * our ordinary Node/Electron/Pi runtimes). Other inaccessible live processes
+ * keep recovery closed; PID discovery never authorizes a kill.
+ *
+ * The Windows probe has to finish inside the kill budget. Enumerating every
+ * Win32_Process property, plus compiling a protection helper before checking
+ * which PIDs are still alive, exceeded that budget on hosted runners (8238ms
+ * against an 8000ms cap) and failed a dead child closed.
+ */
+/** Full Linux argv, or null if that pid is already gone. `'unknown'` is fail-closed. */
- async function readLinuxProcArgs(pid: string): Promise<string | null | 'unknown'> {
++async function readLinuxProcArgs(
++ pid: string,
++ options: { ignorePermission?: boolean } = {},
++): Promise<string | null | 'unknown'> {
+ try {
+ const cmdline = await fs.readFile(`/proc/${pid}/cmdline`);
+ const args = cmdline.toString('utf8').split('\0').filter((part) => part.length > 0).join(' ');
+ return args.trim() ? args : null;
+ } catch (error) {
- return (error as NodeJS.ErrnoException).code === 'ENOENT' ? null : 'unknown';
++ const code = (error as NodeJS.ErrnoException).code;
++ if (code === 'ENOENT') return null;
++ if (options.ignorePermission && (code === 'EACCES' || code === 'EPERM')) return null;
++ return 'unknown';
+ }
+}
+
+/**
+ * Identities still visible in `/proc` after `ps` missed them.
+ * `unavailable` means this is not a Linux procfs (a unit test may only pretend
+ * to be Linux). `unknown` means the scan could not finish and must fail closed.
*/
+async function linuxProcfsLiveIdentities(
+ identities: readonly string[],
+ deadline: number,
+): Promise<Set<string> | 'unavailable' | 'unknown'> {
+ const sought = identities.filter((id) => id.length >= 32);
+ if (sought.length === 0) return new Set();
+ let names: string[];
+ try {
+ names = await fs.readdir('/proc');
+ } catch (error) {
+ const code = (error as NodeJS.ErrnoException).code;
+ return code === 'ENOENT' || code === 'ENOTDIR' ? 'unavailable' : 'unknown';
+ }
+ const found = new Set<string>();
+ for (const name of names) {
+ if (Date.now() >= deadline) return 'unknown';
+ if (!/^[1-9]\d*$/.test(name)) continue;
- const args = await readLinuxProcArgs(name);
++ // Other users' cmdlines are often unreadable. Skip those; a permission
++ // error is not evidence that our own child is still alive.
++ const args = await readLinuxProcArgs(name, { ignorePermission: true });
+ if (args === 'unknown') return 'unknown';
+ if (!args) continue;
+ for (const id of sought) {
+ if (args.includes(id)) found.add(id);
+ }
+ if (sought.every((id) => found.has(id))) break;
+ }
+ return found;
+}
+
+/** Add same-user processes `ps` omitted. An unreadable live command line is unknown. */
+async function supplementLinuxProcCommandLines(
+ commands: string[],
+ seenPids: Set<string>,
+ uid: number,
+ deadline: number,
+): Promise<string[] | null> {
+ let names: string[];
+ try {
+ names = await fs.readdir('/proc');
+ } catch {
+ return null;
+ }
+ for (const name of names) {
+ if (Date.now() >= deadline) return null;
+ if (!/^[1-9]\d*$/.test(name) || seenPids.has(name)) continue;
+ let statusText: string;
+ try {
+ statusText = await fs.readFile(`/proc/${name}/status`, 'utf8');
+ } catch {
+ continue;
+ }
+ const uidField = statusText.split('\n').find((line) => line.startsWith('Uid:'));
+ const realUid = uidField ? Number(uidField.slice(4).trim().split(/\s+/)[0]) : Number.NaN;
+ if (realUid !== uid) continue;
+ const stateField = statusText.split('\n').find((line) => line.startsWith('State:'));
+ if (stateField?.slice(6).trim().startsWith('Z')) continue;
+ const args = await readLinuxProcArgs(name);
+ if (args === 'unknown') return null;
+ if (!args) continue;
+ commands.push(args);
+ seenPids.add(name);
+ }
+ return commands;
+}
+
async function readRecoveryProcessInventory(deadline: number): Promise<string[] | null> {
try {
const remaining = Math.floor(deadline - Date.now());