@aliou/pi-processes 0.10.7 → 0.10.8

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.
@@ -3,7 +3,7 @@ import {
3
3
  defineTool,
4
4
  type ExtensionAPI,
5
5
  type ExtensionContext,
6
- Theme,
6
+ type Theme,
7
7
  type ToolDefinition,
8
8
  } from "@earendil-works/pi-coding-agent";
9
9
  import { type Component, Container, Text } from "@earendil-works/pi-tui";
@@ -112,13 +112,17 @@ type RenderCallFn = NonNullable<ToolDefinition["renderCall"]>;
112
112
  type RenderCallFnContext = Parameters<RenderCallFn>[2];
113
113
 
114
114
  /**
115
- * pi invokes renderCall as (args, theme, context) where theme is pi's Theme
116
- * class instance. Detecting that exact class distinguishes pi's argument
117
- * order from OMP's (args, options, theme), where the second argument is a
118
- * plain options object.
115
+ * pi invokes renderCall as (args, theme, context), while OMP invokes it as
116
+ * (args, options, theme). Detect the theme by shape instead of Theme class
117
+ * identity because host and extension package copies can differ.
119
118
  */
120
- function isPiTheme(value: unknown): value is Theme {
121
- return value instanceof Theme;
119
+ function isThemeLike(value: unknown): value is Theme {
120
+ return (
121
+ typeof value === "object" &&
122
+ value !== null &&
123
+ typeof (value as { fg?: unknown }).fg === "function" &&
124
+ typeof (value as { bold?: unknown }).bold === "function"
125
+ );
122
126
  }
123
127
 
124
128
  function renderProcessCall(
@@ -126,7 +130,7 @@ function renderProcessCall(
126
130
  second: Theme | RenderCallFnContext,
127
131
  third?: RenderCallFnContext | Theme,
128
132
  ): Component {
129
- const usesPiOrder = isPiTheme(second);
133
+ const usesPiOrder = isThemeLike(second);
130
134
  const theme = usesPiOrder ? second : (third as Theme);
131
135
  const context = (usesPiOrder ? third : second) as
132
136
  | RenderCallFnContext
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aliou/pi-processes",
3
- "version": "0.10.7",
3
+ "version": "0.10.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "private": false,