@oai404iao/pi-subagent 0.3.0 → 0.4.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +250 -75
- package/agents/worker.md +1 -1
- package/config.example.json +3 -1
- package/config.schema.json +24 -4
- package/package.json +7 -7
- package/src/agent-state.ts +125 -0
- package/src/agent-sync.ts +64 -53
- package/src/agents.ts +3 -22
- package/src/catalog.ts +49 -0
- package/src/completion-mailbox.ts +656 -0
- package/src/config.ts +51 -6
- package/src/coordinator.ts +2385 -231
- package/src/descriptor.ts +104 -11
- package/src/index.ts +175 -26
- package/src/mailbox.ts +451 -0
- package/src/providers.ts +221 -28
- package/src/render.ts +25 -8
- package/src/scheduler.ts +173 -0
- package/src/schemas.ts +111 -11
- package/src/task-path.ts +188 -0
- package/src/types.ts +56 -7
package/src/config.ts
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join, resolve } from "node:path";
|
|
3
3
|
import { CONFIG_DIR_NAME, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
AgentScope,
|
|
6
|
+
BackgroundProtocol,
|
|
7
|
+
ReportDelivery,
|
|
8
|
+
SubagentSettings,
|
|
9
|
+
} from "./types.ts";
|
|
5
10
|
|
|
6
11
|
export const CONFIG_FILE_NAME = "subagent.json";
|
|
7
12
|
|
|
8
13
|
export const DEFAULT_SETTINGS: Readonly<SubagentSettings> = {
|
|
9
14
|
agentScope: "user",
|
|
10
|
-
syncBundledAgents: false,
|
|
11
15
|
maxDepth: 3,
|
|
12
16
|
enableRunInBackground: true,
|
|
13
17
|
defaultBackground: true,
|
|
18
|
+
maxConcurrentBackgroundRuns: 4,
|
|
19
|
+
maxIdleRuntimes: 0,
|
|
20
|
+
backgroundProtocol: "legacy",
|
|
14
21
|
reportDelivery: "wakeup",
|
|
15
22
|
inheritExtensions: false,
|
|
16
23
|
openAIIdentity: false,
|
|
@@ -24,6 +31,9 @@ const CONFIG_KEYS = new Set([
|
|
|
24
31
|
"maxDepth",
|
|
25
32
|
"enableRunInBackground",
|
|
26
33
|
"defaultBackground",
|
|
34
|
+
"maxConcurrentBackgroundRuns",
|
|
35
|
+
"maxIdleRuntimes",
|
|
36
|
+
"backgroundProtocol",
|
|
27
37
|
"reportDelivery",
|
|
28
38
|
"inheritExtensions",
|
|
29
39
|
"openAIIdentity",
|
|
@@ -86,6 +96,11 @@ function parseReportDelivery(value: unknown, source: string): ReportDelivery {
|
|
|
86
96
|
throw new Error(`${source}: reportDelivery must be "wakeup" or "quiet"`);
|
|
87
97
|
}
|
|
88
98
|
|
|
99
|
+
function parseBackgroundProtocol(value: unknown, source: string): BackgroundProtocol {
|
|
100
|
+
if (value === "legacy" || value === "mailbox-v2") return value;
|
|
101
|
+
throw new Error(`${source}: backgroundProtocol must be "legacy" or "mailbox-v2"`);
|
|
102
|
+
}
|
|
103
|
+
|
|
89
104
|
function parseBoolean(value: unknown, key: string, source: string): boolean {
|
|
90
105
|
if (typeof value === "boolean") return value;
|
|
91
106
|
throw new Error(`${source}: ${key} must be a boolean`);
|
|
@@ -119,13 +134,15 @@ function applyConfig(
|
|
|
119
134
|
if (config.syncBundledAgents !== undefined && !options.allowSyncBundledAgents) {
|
|
120
135
|
throw new Error(`${source}: syncBundledAgents may be configured only in the user-level subagent.json`);
|
|
121
136
|
}
|
|
137
|
+
if (config.syncBundledAgents !== undefined) {
|
|
138
|
+
// Compatibility with 0.2/0.3 configuration files. Bundled templates are
|
|
139
|
+
// now always initialized on first install/version change, and this
|
|
140
|
+
// retired switch no longer controls runtime discovery or writes.
|
|
141
|
+
parseBoolean(config.syncBundledAgents, "syncBundledAgents", source);
|
|
142
|
+
}
|
|
122
143
|
return {
|
|
123
144
|
agentScope:
|
|
124
145
|
config.agentScope === undefined ? settings.agentScope : parseAgentScope(config.agentScope, source),
|
|
125
|
-
syncBundledAgents:
|
|
126
|
-
config.syncBundledAgents === undefined
|
|
127
|
-
? settings.syncBundledAgents
|
|
128
|
-
: parseBoolean(config.syncBundledAgents, "syncBundledAgents", source),
|
|
129
146
|
maxDepth:
|
|
130
147
|
config.maxDepth === undefined
|
|
131
148
|
? settings.maxDepth
|
|
@@ -141,6 +158,34 @@ function applyConfig(
|
|
|
141
158
|
config.defaultBackground === undefined
|
|
142
159
|
? settings.defaultBackground
|
|
143
160
|
: parseBoolean(config.defaultBackground, "defaultBackground", source),
|
|
161
|
+
maxConcurrentBackgroundRuns:
|
|
162
|
+
config.maxConcurrentBackgroundRuns === undefined
|
|
163
|
+
? settings.maxConcurrentBackgroundRuns
|
|
164
|
+
: parseInteger(
|
|
165
|
+
config.maxConcurrentBackgroundRuns,
|
|
166
|
+
"maxConcurrentBackgroundRuns",
|
|
167
|
+
source,
|
|
168
|
+
{
|
|
169
|
+
minimum: 1,
|
|
170
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
171
|
+
},
|
|
172
|
+
),
|
|
173
|
+
maxIdleRuntimes:
|
|
174
|
+
config.maxIdleRuntimes === undefined
|
|
175
|
+
? settings.maxIdleRuntimes
|
|
176
|
+
: parseInteger(
|
|
177
|
+
config.maxIdleRuntimes,
|
|
178
|
+
"maxIdleRuntimes",
|
|
179
|
+
source,
|
|
180
|
+
{
|
|
181
|
+
minimum: 0,
|
|
182
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
183
|
+
},
|
|
184
|
+
),
|
|
185
|
+
backgroundProtocol:
|
|
186
|
+
config.backgroundProtocol === undefined
|
|
187
|
+
? settings.backgroundProtocol
|
|
188
|
+
: parseBackgroundProtocol(config.backgroundProtocol, source),
|
|
144
189
|
reportDelivery:
|
|
145
190
|
config.reportDelivery === undefined
|
|
146
191
|
? settings.reportDelivery
|