@ian-pascoe/pi-advisor 0.6.0 → 0.7.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/src/index.ts CHANGED
@@ -9,6 +9,7 @@ import { isDeepStrictEqual } from "node:util";
9
9
  import { Type } from "typebox";
10
10
  import { Value } from "typebox/value";
11
11
  import { discoverPiAgentSession } from "@ian-pascoe/pi-utils/pi-agent-session-discovery";
12
+ import { expandEntryOnClick, expandMessageOnClick, noticeText } from "@ian-pascoe/pi-utils/ui";
12
13
  import {
13
14
  parseAdvisorOptions,
14
15
  readAdvisorLayers,
@@ -27,6 +28,7 @@ import {
27
28
  type AdvisorScopedOptions,
28
29
  } from "./advisor-menu.js";
29
30
  import {
31
+ advisorAskToolName as askToolName,
30
32
  advisorFooterText,
31
33
  advisorStatusHeadline,
32
34
  renderAdvisorAskCall,
@@ -48,7 +50,6 @@ interface WatchedChild {
48
50
  resourceInputs: AdvisorResourceInputs;
49
51
  observer: AdvisorObserver | undefined;
50
52
  }
51
- const askToolName = "advisor_ask";
52
53
  const askToolParameters = Type.Object(
53
54
  { message: Type.String({ minLength: 1 }) },
54
55
  { additionalProperties: false },
@@ -86,14 +87,23 @@ export default function advisor(pi: ExtensionAPI): void {
86
87
  attachChild,
87
88
  );
88
89
 
89
- pi.registerEntryRenderer("pi-advisor-child", (entry, { expanded }, theme) =>
90
- renderAdvisorChildEntry(entry.data, expanded, theme),
90
+ pi.registerEntryRenderer(
91
+ "pi-advisor-child",
92
+ expandEntryOnClick((entry, { expanded }, theme) =>
93
+ renderAdvisorChildEntry(entry.data, expanded, theme),
94
+ ),
91
95
  );
92
- pi.registerEntryRenderer("pi-advisor-status", (entry, { expanded }, theme) =>
93
- renderAdvisorStatus(entry.data, expanded, theme),
96
+ pi.registerEntryRenderer(
97
+ "pi-advisor-status",
98
+ expandEntryOnClick((entry, { expanded }, theme) =>
99
+ renderAdvisorStatus(entry.data, expanded, theme),
100
+ ),
94
101
  );
95
- pi.registerMessageRenderer("pi-advisor", (message, options, theme) =>
96
- renderAdvisorIntervention(message.details, options, theme),
102
+ pi.registerMessageRenderer(
103
+ "pi-advisor",
104
+ expandMessageOnClick((message, options, theme) =>
105
+ renderAdvisorIntervention(message.details, options, theme),
106
+ ),
97
107
  );
98
108
 
99
109
  /** Show the current Advisor state in the open settings menu and the footer. */
@@ -127,12 +137,14 @@ export default function advisor(pi: ExtensionAPI): void {
127
137
  openWorldHint: false,
128
138
  },
129
139
  executionMode: "sequential",
130
- renderCall: (args, theme, context) => renderAdvisorAskCall(args, context.expanded, theme),
140
+ renderCall: (args, theme, context) =>
141
+ renderAdvisorAskCall(args, context.expanded, theme, context),
131
142
  renderResult: (result, options, theme, context) =>
132
143
  renderAdvisorAskResult(
133
144
  result.content.map((item) => (item.type === "text" ? item.text : "")).join(""),
134
145
  { expanded: options.expanded, isPartial: options.isPartial, isError: context.isError },
135
146
  theme,
147
+ context,
136
148
  ),
137
149
  execute: async (_id, { message }, signal) => {
138
150
  try {
@@ -254,7 +266,7 @@ export default function advisor(pi: ExtensionAPI): void {
254
266
  state: "paused",
255
267
  error: message,
256
268
  });
257
- warn(`Advisor for ${child.agentId} paused: ${message}`);
269
+ warn(noticeText("Advisor", `${child.agentId} paused: ${message}`));
258
270
  },
259
271
  onStateChange: publishState,
260
272
  onIntervention: (finding) => {
@@ -339,7 +351,7 @@ export default function advisor(pi: ExtensionAPI): void {
339
351
  {
340
352
  onError: (message) => {
341
353
  pi.appendEntry("pi-advisor-status", { state: "paused", error: message });
342
- warn(`Advisor paused: ${message}`);
354
+ warn(noticeText("Advisor", `paused: ${message}`));
343
355
  },
344
356
  onStateChange: publishState,
345
357
  },
@@ -399,7 +411,7 @@ export default function advisor(pi: ExtensionAPI): void {
399
411
  error = cause instanceof Error ? cause.message : String(cause);
400
412
  pi.appendEntry("pi-advisor-status", { state: "paused", error, usage: null, cost: null });
401
413
  }
402
- if (error) ctx.ui.notify(`Advisor: ${error}`, "error");
414
+ if (error) ctx.ui.notify(noticeText("Advisor", error), "error");
403
415
  }
404
416
 
405
417
  /** Persist one validated change at its scope and reconfigure; undefined if superseded. */