pi-subagentura 1.0.8 → 1.0.11

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.
Files changed (3) hide show
  1. package/helpers.ts +16 -0
  2. package/package.json +1 -1
  3. package/subagent.ts +61 -0
package/helpers.ts CHANGED
@@ -462,10 +462,16 @@ export async function startSubagentJob(
462
462
  liveStatus.turn++;
463
463
  liveStatus.usage.turns = liveStatus.turn;
464
464
  liveStatus.output = "";
465
+ debugLog("info", "turn_start", { jobId, turn: liveStatus.turn });
465
466
  onUpdate?.(buildLiveUpdate(liveStatus, modelLabel));
466
467
  break;
467
468
  }
468
469
  case "tool_execution_start": {
470
+ debugLog("info", "tool_start", {
471
+ jobId,
472
+ toolName: event.toolName,
473
+ args: event.args as Record<string, unknown>,
474
+ });
469
475
  setActiveToolDebounced({
470
476
  name: event.toolName,
471
477
  args: event.args as Record<string, unknown>,
@@ -473,10 +479,12 @@ export async function startSubagentJob(
473
479
  break;
474
480
  }
475
481
  case "tool_execution_end": {
482
+ debugLog("info", "tool_end", { jobId, toolName: liveStatus.activeTool?.name });
476
483
  setActiveToolDebounced(undefined);
477
484
  break;
478
485
  }
479
486
  case "turn_end": {
487
+ debugLog("info", "turn_end", { jobId, turn: liveStatus.turn });
480
488
  if (activeToolTimer) {
481
489
  clearTimeout(activeToolTimer);
482
490
  activeToolTimer = undefined;
@@ -552,6 +560,7 @@ export async function startSubagentJob(
552
560
  };
553
561
  } catch (err) {
554
562
  const msg = err instanceof Error ? err.message : String(err);
563
+ debugLog("error", "subagent_error", { jobId, error: msg });
555
564
  result = {
556
565
  output: `Sub-agent crashed: ${msg}`,
557
566
  usage: {
@@ -567,6 +576,13 @@ export async function startSubagentJob(
567
576
  errorMessage: msg,
568
577
  };
569
578
  } finally {
579
+ debugLog("info", "job_complete", {
580
+ jobId,
581
+ outputLength: result.output.length,
582
+ isError: result.isError,
583
+ errorMessage: result.errorMessage ?? null,
584
+ usage: result.usage,
585
+ });
570
586
  if (activeToolTimer) {
571
587
  clearTimeout(activeToolTimer);
572
588
  activeToolTimer = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-subagentura",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "description": "Public Pi package that adds in-process sub-agents via the SDK",
5
5
  "main": "subagent.ts",
6
6
  "type": "module",
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