pi-subagentura 1.0.7 → 1.0.9
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/helpers.ts +2 -1
- package/package.json +1 -1
- package/subagent.ts +61 -0
package/helpers.ts
CHANGED
|
@@ -27,9 +27,10 @@ import {
|
|
|
27
27
|
|
|
28
28
|
const DEBUG_LOG_DIR = process.env.SUBAGENT_DEBUG_LOG_DIR
|
|
29
29
|
? resolve(process.env.SUBAGENT_DEBUG_LOG_DIR)
|
|
30
|
-
:
|
|
30
|
+
: undefined;
|
|
31
31
|
|
|
32
32
|
export function debugLog(level: string, event: string, data: Record<string, unknown> = {}) {
|
|
33
|
+
if (!DEBUG_LOG_DIR) return;
|
|
33
34
|
try {
|
|
34
35
|
if (!existsSync(DEBUG_LOG_DIR)) {
|
|
35
36
|
mkdirSync(DEBUG_LOG_DIR, { recursive: true });
|
package/package.json
CHANGED
package/subagent.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
pruneCompletedJobs,
|
|
40
40
|
scheduleJobCleanup,
|
|
41
41
|
startSubagentJob,
|
|
42
|
+
debugLog,
|
|
42
43
|
type JobState,
|
|
43
44
|
type JobStatus,
|
|
44
45
|
type NotifyOnComplete,
|
|
@@ -508,6 +509,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
508
509
|
parameters: BaseParams,
|
|
509
510
|
|
|
510
511
|
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
512
|
+
debugLog("info", "tool_call", {
|
|
513
|
+
toolName: "subagent_with_context",
|
|
514
|
+
toolCallId: _toolCallId,
|
|
515
|
+
async: params.async ?? false,
|
|
516
|
+
taskLength: params.task?.length ?? 0,
|
|
517
|
+
persona: params.persona ?? null,
|
|
518
|
+
model: params.model ?? null,
|
|
519
|
+
cwd: params.cwd ?? ctx.cwd,
|
|
520
|
+
notifyOnComplete: params.notifyOnComplete ?? null,
|
|
521
|
+
maxAge: params.maxAge ?? null,
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
|
|
511
525
|
// Gather conversation history
|
|
512
526
|
const branch = ctx.sessionManager.getBranch();
|
|
513
527
|
const messages = branch
|
|
@@ -730,6 +744,19 @@ export default function (pi: ExtensionAPI) {
|
|
|
730
744
|
parameters: BaseParams,
|
|
731
745
|
|
|
732
746
|
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
|
747
|
+
debugLog("info", "tool_call", {
|
|
748
|
+
toolName: "subagent_isolated",
|
|
749
|
+
toolCallId: _toolCallId,
|
|
750
|
+
async: params.async ?? false,
|
|
751
|
+
taskLength: params.task?.length ?? 0,
|
|
752
|
+
persona: params.persona ?? null,
|
|
753
|
+
model: params.model ?? null,
|
|
754
|
+
cwd: params.cwd ?? ctx.cwd,
|
|
755
|
+
notifyOnComplete: params.notifyOnComplete ?? null,
|
|
756
|
+
maxAge: params.maxAge ?? null,
|
|
757
|
+
});
|
|
758
|
+
|
|
759
|
+
|
|
733
760
|
// ── Async path ──
|
|
734
761
|
if (params.async === true) {
|
|
735
762
|
const targetCwd = params.cwd ?? ctx.cwd;
|
|
@@ -906,6 +933,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
906
933
|
parameters: StatusParams,
|
|
907
934
|
|
|
908
935
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
936
|
+
debugLog("info", "tool_call", {
|
|
937
|
+
toolName: "get_subagent_status",
|
|
938
|
+
toolCallId: _toolCallId,
|
|
939
|
+
jobId: params.jobId,
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
|
|
909
943
|
const job = jobRegistry.get(params.jobId);
|
|
910
944
|
|
|
911
945
|
if (!job) {
|
|
@@ -983,6 +1017,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
983
1017
|
|
|
984
1018
|
async execute(_toolCallId, params, signal, _onUpdate, _ctx) {
|
|
985
1019
|
const job = jobRegistry.get(params.jobId);
|
|
1020
|
+
debugLog("info", "tool_call", {
|
|
1021
|
+
toolName: "get_subagent_result",
|
|
1022
|
+
toolCallId: _toolCallId,
|
|
1023
|
+
jobId: params.jobId,
|
|
1024
|
+
});
|
|
1025
|
+
|
|
1026
|
+
|
|
986
1027
|
|
|
987
1028
|
if (!job) {
|
|
988
1029
|
return {
|
|
@@ -1077,6 +1118,13 @@ export default function (pi: ExtensionAPI) {
|
|
|
1077
1118
|
|
|
1078
1119
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
1079
1120
|
const job = jobRegistry.get(params.jobId);
|
|
1121
|
+
debugLog("info", "tool_call", {
|
|
1122
|
+
toolName: "cancel_subagent",
|
|
1123
|
+
toolCallId: _toolCallId,
|
|
1124
|
+
jobId: params.jobId,
|
|
1125
|
+
});
|
|
1126
|
+
|
|
1127
|
+
|
|
1080
1128
|
|
|
1081
1129
|
if (!job) {
|
|
1082
1130
|
return {
|
|
@@ -1199,6 +1247,14 @@ export default function (pi: ExtensionAPI) {
|
|
|
1199
1247
|
|
|
1200
1248
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
1201
1249
|
const modelRegistry = ctx.modelRegistry;
|
|
1250
|
+
debugLog("info", "tool_call", {
|
|
1251
|
+
toolName: "list_available_models",
|
|
1252
|
+
toolCallId: _toolCallId,
|
|
1253
|
+
authOnly: params.authOnly ?? true,
|
|
1254
|
+
filter: params.filter ?? null,
|
|
1255
|
+
});
|
|
1256
|
+
|
|
1257
|
+
|
|
1202
1258
|
const models =
|
|
1203
1259
|
params.authOnly !== false
|
|
1204
1260
|
? modelRegistry.getAvailable()
|
|
@@ -1262,6 +1318,11 @@ export default function (pi: ExtensionAPI) {
|
|
|
1262
1318
|
|
|
1263
1319
|
async execute() {
|
|
1264
1320
|
const before = jobRegistry.size;
|
|
1321
|
+
debugLog("info", "tool_call", {
|
|
1322
|
+
toolName: "prune_subagent_jobs",
|
|
1323
|
+
});
|
|
1324
|
+
|
|
1325
|
+
|
|
1265
1326
|
const removed = pruneCompletedJobs();
|
|
1266
1327
|
const after = jobRegistry.size;
|
|
1267
1328
|
|