@nredd/pi-subagents 0.0.0-stage → 0.22.0-nredd.10
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/LICENSE +21 -0
- package/README.md +1444 -2
- package/dist/chunks/chunk-MSGGFB5Q.ts +6755 -0
- package/dist/chunks/chunk-MSGGFB5Q.ts.map +7 -0
- package/dist/chunks/conversation-viewer-A7AMRDVY.ts +15 -0
- package/dist/chunks/conversation-viewer-A7AMRDVY.ts.map +7 -0
- package/dist/index.ts +9874 -0
- package/dist/index.ts.map +7 -0
- package/package.json +82 -4
- package/src/abortable.ts +43 -0
- package/src/agent-color.ts +161 -0
- package/src/agent-file-toggle.ts +298 -0
- package/src/agent-manager.ts +2431 -0
- package/src/agent-runner.ts +1703 -0
- package/src/agent-source-badge.ts +75 -0
- package/src/agent-types.ts +346 -0
- package/src/child-context.ts +33 -0
- package/src/clock.ts +25 -0
- package/src/completion-outbox.ts +144 -0
- package/src/context.ts +58 -0
- package/src/cross-extension-rpc.ts +200 -0
- package/src/custom-agents.ts +441 -0
- package/src/default-agents.ts +126 -0
- package/src/detached-results.ts +150 -0
- package/src/enabled-models.ts +181 -0
- package/src/enterprise-local.ts +67 -0
- package/src/env.ts +33 -0
- package/src/error-message.ts +11 -0
- package/src/git-path.ts +66 -0
- package/src/group-join.ts +142 -0
- package/src/home-paths.ts +27 -0
- package/src/index.ts +5047 -0
- package/src/invocation-config.ts +158 -0
- package/src/memory.ts +179 -0
- package/src/mention-clone.ts +200 -0
- package/src/mention.ts +141 -0
- package/src/model-call.ts +83 -0
- package/src/model-resolver.ts +333 -0
- package/src/model-scope.ts +71 -0
- package/src/model-selection.ts +170 -0
- package/src/model-tiers.ts +176 -0
- package/src/nested-tools.ts +512 -0
- package/src/notification-result.ts +118 -0
- package/src/output-file.ts +186 -0
- package/src/package-resources.ts +639 -0
- package/src/plan-mode-children.ts +176 -0
- package/src/process-budget.ts +346 -0
- package/src/prompts.ts +161 -0
- package/src/quota-admission.ts +121 -0
- package/src/resource-loader.ts +65 -0
- package/src/schedule-store.ts +153 -0
- package/src/schedule.ts +514 -0
- package/src/settings.ts +851 -0
- package/src/skill-loader.ts +288 -0
- package/src/stale-ctx.ts +16 -0
- package/src/startup-error.ts +29 -0
- package/src/status-note.ts +113 -0
- package/src/structured-output.ts +130 -0
- package/src/types.ts +487 -0
- package/src/ui/agent-mention.ts +219 -0
- package/src/ui/agent-row.ts +245 -0
- package/src/ui/agent-widget.ts +722 -0
- package/src/ui/conversation-viewer.ts +837 -0
- package/src/ui/fallback-flag.ts +114 -0
- package/src/ui/fleet-list.ts +1020 -0
- package/src/ui/fleet-state.ts +154 -0
- package/src/ui/notification-view.ts +139 -0
- package/src/ui/schedule-menu.ts +105 -0
- package/src/ui/select-item.ts +45 -0
- package/src/ui/viewer-keys.ts +39 -0
- package/src/ui/workflow-card.ts +459 -0
- package/src/ui/workflow-dialog.ts +1138 -0
- package/src/ui/workflow-menu.ts +193 -0
- package/src/usage.ts +167 -0
- package/src/workflow/collisions.ts +123 -0
- package/src/workflow/entry.ts +47 -0
- package/src/workflow/host.ts +398 -0
- package/src/workflow/journal.ts +176 -0
- package/src/workflow/json-schema.ts +129 -0
- package/src/workflow/meta.ts +329 -0
- package/src/workflow/progress.ts +554 -0
- package/src/workflow/runtime.ts +1249 -0
- package/src/workflow/saved.ts +259 -0
- package/src/workflow/task.ts +317 -0
- package/src/workflow/tool-description.ts +200 -0
- package/src/workflow/worker-source.ts +903 -0
- package/src/worktree.ts +520 -0
- package/src/xml.ts +13 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* group-join.ts — Manages grouped background agent completion notifications.
|
|
3
|
+
*
|
|
4
|
+
* Instead of each agent individually nudging the main agent on completion,
|
|
5
|
+
* agents in a group are held until all complete (or a timeout fires),
|
|
6
|
+
* then a single consolidated notification is sent.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { AgentRecord } from "./types.js";
|
|
10
|
+
|
|
11
|
+
export type DeliveryCallback = (records: AgentRecord[], partial: boolean) => void;
|
|
12
|
+
|
|
13
|
+
interface AgentGroup {
|
|
14
|
+
groupId: string;
|
|
15
|
+
agentIds: Set<string>;
|
|
16
|
+
completedRecords: Map<string, AgentRecord>;
|
|
17
|
+
timeoutHandle?: ReturnType<typeof setTimeout>;
|
|
18
|
+
/** Shorter timeout for stragglers after a partial delivery. */
|
|
19
|
+
isStraggler: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Default timeout: 30s after first completion in a group. */
|
|
23
|
+
const DEFAULT_TIMEOUT = 30_000;
|
|
24
|
+
/** Straggler re-batch timeout: 15s. */
|
|
25
|
+
const STRAGGLER_TIMEOUT = 15_000;
|
|
26
|
+
|
|
27
|
+
export class GroupJoinManager {
|
|
28
|
+
private groups = new Map<string, AgentGroup>();
|
|
29
|
+
private agentToGroup = new Map<string, string>();
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
private deliverCb: DeliveryCallback,
|
|
33
|
+
private groupTimeout = DEFAULT_TIMEOUT,
|
|
34
|
+
) {}
|
|
35
|
+
|
|
36
|
+
/** Register a group of agent IDs that should be joined. */
|
|
37
|
+
registerGroup(groupId: string, agentIds: string[]): void {
|
|
38
|
+
const group: AgentGroup = {
|
|
39
|
+
groupId,
|
|
40
|
+
agentIds: new Set(agentIds),
|
|
41
|
+
completedRecords: new Map(),
|
|
42
|
+
isStraggler: false,
|
|
43
|
+
};
|
|
44
|
+
this.groups.set(groupId, group);
|
|
45
|
+
for (const id of agentIds) {
|
|
46
|
+
this.agentToGroup.set(id, groupId);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Called when an agent completes.
|
|
52
|
+
* Returns:
|
|
53
|
+
* - 'pass' — agent is not grouped, caller should send individual nudge
|
|
54
|
+
* - 'held' — result held, waiting for group completion
|
|
55
|
+
* - 'delivered' — this completion triggered the group notification
|
|
56
|
+
*/
|
|
57
|
+
onAgentComplete(record: AgentRecord): 'delivered' | 'held' | 'pass' {
|
|
58
|
+
const groupId = this.agentToGroup.get(record.id);
|
|
59
|
+
if (!groupId) return 'pass';
|
|
60
|
+
|
|
61
|
+
const group = this.groups.get(groupId);
|
|
62
|
+
if (!group) return 'pass';
|
|
63
|
+
|
|
64
|
+
group.completedRecords.set(record.id, record);
|
|
65
|
+
|
|
66
|
+
// All done — deliver immediately
|
|
67
|
+
if (group.completedRecords.size >= group.agentIds.size) {
|
|
68
|
+
this.deliver(group, false);
|
|
69
|
+
return 'delivered';
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// First completion in this batch — start timeout
|
|
73
|
+
if (!group.timeoutHandle) {
|
|
74
|
+
const timeout = group.isStraggler ? STRAGGLER_TIMEOUT : this.groupTimeout;
|
|
75
|
+
group.timeoutHandle = setTimeout(() => {
|
|
76
|
+
this.onTimeout(group);
|
|
77
|
+
}, timeout);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return 'held';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private onTimeout(group: AgentGroup): void {
|
|
84
|
+
group.timeoutHandle = undefined;
|
|
85
|
+
|
|
86
|
+
// Partial delivery — some agents still running
|
|
87
|
+
const remaining = new Set<string>();
|
|
88
|
+
for (const id of group.agentIds) {
|
|
89
|
+
if (!group.completedRecords.has(id)) remaining.add(id);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Clean up agentToGroup for delivered agents (they won't complete again)
|
|
93
|
+
for (const id of group.completedRecords.keys()) {
|
|
94
|
+
this.agentToGroup.delete(id);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Deliver what we have
|
|
98
|
+
this.deliverCb([...group.completedRecords.values()], true);
|
|
99
|
+
|
|
100
|
+
// Set up straggler group for remaining agents
|
|
101
|
+
group.completedRecords.clear();
|
|
102
|
+
group.agentIds = remaining;
|
|
103
|
+
group.isStraggler = true;
|
|
104
|
+
// Timeout will be started when the next straggler completes
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private deliver(group: AgentGroup, partial: boolean): void {
|
|
108
|
+
if (group.timeoutHandle) {
|
|
109
|
+
clearTimeout(group.timeoutHandle);
|
|
110
|
+
group.timeoutHandle = undefined;
|
|
111
|
+
}
|
|
112
|
+
this.deliverCb([...group.completedRecords.values()], partial);
|
|
113
|
+
this.cleanupGroup(group);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private cleanupGroup(group: AgentGroup): void {
|
|
117
|
+
for (const id of group.agentIds) {
|
|
118
|
+
this.agentToGroup.delete(id);
|
|
119
|
+
}
|
|
120
|
+
this.groups.delete(group.groupId);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Check if an agent is in a group. */
|
|
124
|
+
isGrouped(agentId: string): boolean {
|
|
125
|
+
return this.agentToGroup.has(agentId);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Release held completions to the outbox before a session transfer. */
|
|
129
|
+
flushPending(): void {
|
|
130
|
+
for (const group of [...this.groups.values()]) {
|
|
131
|
+
this.deliver(group, true);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
dispose(): void {
|
|
136
|
+
for (const group of this.groups.values()) {
|
|
137
|
+
if (group.timeoutHandle) clearTimeout(group.timeoutHandle);
|
|
138
|
+
}
|
|
139
|
+
this.groups.clear();
|
|
140
|
+
this.agentToGroup.clear();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** User-scoped paths. Omitted homes keep Pi's call-time runtime defaults. */
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
6
|
+
|
|
7
|
+
/** Mirror Pi's agent-dir override semantics without changing the process environment. */
|
|
8
|
+
export function resolveAgentDir(homeDir?: string): string {
|
|
9
|
+
if (homeDir === undefined) return getAgentDir();
|
|
10
|
+
const configured = process.env.PI_CODING_AGENT_DIR;
|
|
11
|
+
if (!configured) return join(homeDir, ".pi", "agent");
|
|
12
|
+
return normalizeHomePath(configured, homeDir);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Pi's normalizePath is not exported by its public package entry point. */
|
|
16
|
+
export function normalizeHomePath(path: string, homeDir = homedir()): string {
|
|
17
|
+
// Match Pi's native normalization of Git Bash, WSL and Cygwin drive paths.
|
|
18
|
+
if (process.platform === "win32" && path.startsWith("/") && !path.startsWith("//") && !path.includes("\\")) {
|
|
19
|
+
const [, letter, remainder] = path.match(/^\/(?:mnt\/|cygdrive\/)?([a-z])(?:\/(.*))?$/i) ?? [];
|
|
20
|
+
if (letter) path = `${letter.toUpperCase()}:\\${remainder?.replaceAll("/", "\\") ?? ""}`;
|
|
21
|
+
}
|
|
22
|
+
if (path === "~") return homeDir;
|
|
23
|
+
if (path.startsWith("~/") || (process.platform === "win32" && path.startsWith("~\\"))) {
|
|
24
|
+
return join(homeDir, path.slice(2));
|
|
25
|
+
}
|
|
26
|
+
return path.startsWith("file://") ? fileURLToPath(path) : path;
|
|
27
|
+
}
|