@xynogen/pix-toolbox 0.1.4 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-toolbox",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Pi tool — gated tool toggle UI (/toolbox)",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -34,7 +34,7 @@
34
34
  "access": "public"
35
35
  },
36
36
  "dependencies": {
37
- "@xynogen/pix-pretty": "*"
37
+ "@xynogen/pix-pretty": "^1.7.9"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@earendil-works/pi-coding-agent": "*",
@@ -191,14 +191,20 @@ afterAll(() => {
191
191
  function makeHost(toolNames: string[]) {
192
192
  const handlers: Record<string, Array<(p: unknown) => unknown>> = {};
193
193
  let active: string[] = [...toolNames];
194
- const commands: Array<{ name: string; handler: Function }> = [];
194
+ const commands: Array<{
195
+ name: string;
196
+ handler: (...args: unknown[]) => unknown;
197
+ }> = [];
195
198
  const pi = {
196
199
  on(ev: string, fn: (p: unknown) => unknown) {
197
- (handlers[ev] ??= []).push(fn);
200
+ if (!handlers[ev]) handlers[ev] = [];
201
+ handlers[ev].push(fn);
198
202
  },
199
203
  emit(ev: string, payload: unknown, ctx?: unknown) {
200
204
  return Promise.all(
201
- (handlers[ev] ?? []).map((f) => (f as Function)(payload, ctx)),
205
+ (handlers[ev] ?? []).map((f) =>
206
+ (f as (...args: unknown[]) => unknown)(payload, ctx),
207
+ ),
202
208
  );
203
209
  },
204
210
  getAllTools() {
@@ -220,12 +226,19 @@ function makeHost(toolNames: string[]) {
220
226
  },
221
227
  appendEntry() {},
222
228
  registerTool() {},
223
- registerCommand(name: string, def: { handler: Function }) {
229
+ registerCommand(
230
+ name: string,
231
+ def: { handler: (...args: unknown[]) => unknown },
232
+ ) {
224
233
  commands.push({ name, handler: def.handler });
225
234
  },
226
235
  } as never;
227
236
  const emit = (ev: string, payload: unknown, ctx?: unknown) =>
228
- Promise.all((handlers[ev] ?? []).map((f) => (f as Function)(payload, ctx)));
237
+ Promise.all(
238
+ (handlers[ev] ?? []).map((f) =>
239
+ (f as (...args: unknown[]) => unknown)(payload, ctx),
240
+ ),
241
+ );
229
242
  return {
230
243
  pi,
231
244
  emit,