@llblab/pi-actors 0.24.3 → 0.24.5
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/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/index.js +9 -0
- package/dist/lib/tools.js +2 -0
- package/dist/recipes/music-player.json +2 -1
- package/dist/scripts/music-player.mjs +37 -18
- package/dist/skills/actors/SKILL.md +1 -1
- package/dist/skills/swarm/SKILL.md +1 -1
- package/index.ts +8 -0
- package/lib/tools.ts +1 -0
- package/package.json +4 -6
- package/recipes/music-player.json +2 -1
- package/scripts/music-player.mjs +37 -18
- package/skills/actors/SKILL.md +1 -1
- package/skills/swarm/SKILL.md +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.24.5: Auto-Discovered Skills Hotfix
|
|
6
|
+
|
|
7
|
+
- `[Skills]` Auto-discovered source checkouts now contribute their co-located `skills/` directory through Pi resource discovery, so extension-local actors/swarm skills load even when `pi-actors` is used directly from `~/.pi/agent/extensions` instead of installed as a package.
|
|
8
|
+
- `[Packaging]` Kept package skill metadata directory-based for both `dist/skills` and source `skills`, preserving bundled skill discovery through package installs while the extension also contributes co-located skills at runtime.
|
|
9
|
+
|
|
10
|
+
## 0.24.4: Music Player Message Control Hotfix
|
|
11
|
+
|
|
12
|
+
- `[Music Player]` Preserve typed actor-message envelopes for run-mailbox delivery so `player.<action>` messages dispatch by message type instead of relying on body payload text.
|
|
13
|
+
- `[Music Player]` Emit `player.stopped` when playback stops so actor inspector and run messages show an explicit domain stop event before terminal completion.
|
|
14
|
+
|
|
5
15
|
## 0.24.3: Actor Inspector Body Field Hotfix
|
|
6
16
|
|
|
7
17
|
- `[Inspector]` Removed the selected-item key-label shim by projecting actor-message detail rows with a real `body` field instead of rendering `body_preview` under an alias.
|
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Or from git:
|
|
|
43
43
|
pi install git:github.com/llblab/pi-actors
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
The npm package is dist-first for JavaScript-only runtimes: default Pi metadata points at compiled `dist/` entrypoints and mirrored runtime assets. Source TypeScript and source skills remain in the package for TypeScript-native runtimes through optional source metadata.
|
|
46
|
+
The npm package is dist-first for JavaScript-only runtimes: default Pi metadata points at compiled `dist/` entrypoints and mirrored runtime assets. Source TypeScript and source skills remain in the package for TypeScript-native runtimes through optional source metadata. When the source checkout is auto-discovered as an extension, it also contributes its co-located `skills/` directory during Pi resource discovery so the actors and swarm skills travel with the extension.
|
|
47
47
|
|
|
48
48
|
## Address Surface
|
|
49
49
|
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* Wraps command templates as callable pi tools, stores durable user tools as recipe files, and exposes actor orchestration across reloads and sessions.
|
|
6
6
|
*/
|
|
7
7
|
import { existsSync, readdirSync, watch } from "node:fs";
|
|
8
|
+
import { dirname, join } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
8
10
|
import * as ActorInspectorTui from "./lib/actor-inspector-tui.js";
|
|
9
11
|
import * as AsyncRuns from "./lib/async-runs.js";
|
|
10
12
|
import * as CommandTemplates from "./lib/command-templates.js";
|
|
@@ -14,6 +16,8 @@ import * as Prompts from "./lib/prompts.js";
|
|
|
14
16
|
import * as Runtime from "./lib/runtime.js";
|
|
15
17
|
import * as Temp from "./lib/temp.js";
|
|
16
18
|
import * as Tools from "./lib/tools.js";
|
|
19
|
+
const EXTENSION_DIR = dirname(fileURLToPath(import.meta.url));
|
|
20
|
+
const EXTENSION_SKILLS_DIR = join(EXTENSION_DIR, "skills");
|
|
17
21
|
const CONFIG_PATH = Paths.getConfigPath();
|
|
18
22
|
const TEMP_DIR = Paths.getExtensionTmpDir();
|
|
19
23
|
const RUN_STATE_ROOT = Paths.getRunStateRoot();
|
|
@@ -246,6 +250,11 @@ export default function toolRegistryExtension(pi) {
|
|
|
246
250
|
reservedToolNames: RESERVED_TOOL_NAMES,
|
|
247
251
|
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
248
252
|
});
|
|
253
|
+
pi.on("resources_discover", async () => {
|
|
254
|
+
if (!existsSync(EXTENSION_SKILLS_DIR))
|
|
255
|
+
return;
|
|
256
|
+
return { skillPaths: [EXTENSION_SKILLS_DIR] };
|
|
257
|
+
});
|
|
249
258
|
pi.on("session_start", async (_event, ctx) => {
|
|
250
259
|
await Temp.prepareExtensionTempDir(TEMP_DIR);
|
|
251
260
|
runtime.loadTools(ctx);
|
package/dist/lib/tools.js
CHANGED
|
@@ -481,6 +481,8 @@ function getRunOwnerId(ctx) {
|
|
|
481
481
|
return ctx.sessionManager?.getSessionId?.();
|
|
482
482
|
}
|
|
483
483
|
function messageBodyToRunLine(message) {
|
|
484
|
+
if (message.type !== "run.message")
|
|
485
|
+
return JSON.stringify(message);
|
|
484
486
|
if (typeof message.body === "string")
|
|
485
487
|
return message.body;
|
|
486
488
|
if (message.body === undefined)
|
|
@@ -404,26 +404,39 @@ function readText(path) {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
function
|
|
408
|
-
const title = track.split(/[\\/]/).filter(Boolean).pop() || track;
|
|
407
|
+
function emitPlayerEvent(ctx, type, summary, body = {}) {
|
|
409
408
|
writeText(
|
|
410
409
|
ctx.eventFile,
|
|
411
410
|
`${JSON.stringify({
|
|
412
|
-
body
|
|
413
|
-
data:
|
|
411
|
+
body,
|
|
412
|
+
data: body,
|
|
414
413
|
delivery: "log",
|
|
415
|
-
event:
|
|
414
|
+
event: type,
|
|
416
415
|
from: `run:${basename(ctx.stateDir)}`,
|
|
417
416
|
level: "info",
|
|
418
|
-
summary
|
|
417
|
+
summary,
|
|
419
418
|
to: "coordinator",
|
|
420
419
|
ts: new Date().toISOString(),
|
|
421
|
-
type
|
|
420
|
+
type,
|
|
422
421
|
})}\n`,
|
|
423
422
|
"a",
|
|
424
423
|
);
|
|
425
424
|
}
|
|
426
425
|
|
|
426
|
+
function emitTrackEvent(ctx, index, count, track, player) {
|
|
427
|
+
const title = track.split(/[\\/]/).filter(Boolean).pop() || track;
|
|
428
|
+
emitPlayerEvent(ctx, "player.track", `Now playing: ${title}`, {
|
|
429
|
+
count,
|
|
430
|
+
index,
|
|
431
|
+
player,
|
|
432
|
+
track,
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function emitStoppedEvent(ctx, reason = "stop") {
|
|
437
|
+
emitPlayerEvent(ctx, "player.stopped", "Music player stopped", { reason });
|
|
438
|
+
}
|
|
439
|
+
|
|
427
440
|
function writeStatus(ctx, state, index, count, track, player, pid = "") {
|
|
428
441
|
const updatedAt = new Date().toISOString();
|
|
429
442
|
writeText(
|
|
@@ -611,23 +624,27 @@ function writeInboxMessages(ctx, messages) {
|
|
|
611
624
|
);
|
|
612
625
|
}
|
|
613
626
|
|
|
627
|
+
function commandFromControlToken(token) {
|
|
628
|
+
if (CONTROL_COMMANDS.has(token)) return token;
|
|
629
|
+
if (token === "control.stop" || token === "control.cancel") return "stop";
|
|
630
|
+
const match = /^player\.(.+)$/.exec(token);
|
|
631
|
+
if (match && CONTROL_COMMANDS.has(match[1])) return match[1];
|
|
632
|
+
return undefined;
|
|
633
|
+
}
|
|
634
|
+
|
|
614
635
|
function commandFromInboxMessage(message) {
|
|
615
|
-
if (
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
636
|
+
if (typeof message.type === "string") {
|
|
637
|
+
const command = commandFromControlToken(message.type.trim());
|
|
638
|
+
if (command) return command;
|
|
639
|
+
}
|
|
640
|
+
if (typeof message.body === "string") {
|
|
641
|
+
const command = message.body.trim();
|
|
642
|
+
if (CONTROL_COMMANDS.has(command)) return command;
|
|
620
643
|
}
|
|
621
644
|
if (message.body && typeof message.body === "object") {
|
|
622
645
|
const command = String(message.body.command ?? "").trim();
|
|
623
646
|
if (CONTROL_COMMANDS.has(command)) return command;
|
|
624
647
|
}
|
|
625
|
-
if (typeof message.type === "string") {
|
|
626
|
-
if (message.type === "control.stop" || message.type === "control.cancel")
|
|
627
|
-
return "stop";
|
|
628
|
-
const match = /^player\.(.+)$/.exec(message.type);
|
|
629
|
-
if (match && CONTROL_COMMANDS.has(match[1])) return match[1];
|
|
630
|
-
}
|
|
631
648
|
return undefined;
|
|
632
649
|
}
|
|
633
650
|
|
|
@@ -895,6 +912,7 @@ async function playMain(args) {
|
|
|
895
912
|
const command = readAndClearCommand(ctx);
|
|
896
913
|
if (command === "stop") {
|
|
897
914
|
writeStatus(ctx, "stopped", index, count, track, player, "");
|
|
915
|
+
emitStoppedEvent(ctx, "message");
|
|
898
916
|
return;
|
|
899
917
|
}
|
|
900
918
|
if (command === "previous" || command === "prev") {
|
|
@@ -913,6 +931,7 @@ async function playMain(args) {
|
|
|
913
931
|
}
|
|
914
932
|
}
|
|
915
933
|
writeStatus(ctx, "stopped", index, tracks.length, "", player, "");
|
|
934
|
+
emitStoppedEvent(ctx, "complete");
|
|
916
935
|
} finally {
|
|
917
936
|
cleanup();
|
|
918
937
|
await Promise.race([controlLoop?.promise ?? Promise.resolve(), sleep(100)]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: actors
|
|
3
3
|
description: Highest-density practical guide for pi-actors. Read this skill whenever prompt and tools are not enough for spawn, message, inspect, actor runs, tools, recipes, command templates, async lifecycle, mailboxes, artifacts, and local orchestration mechanics.
|
|
4
4
|
metadata:
|
|
5
|
-
version: 0.24.
|
|
5
|
+
version: 0.24.5
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Actors (pi-actors)
|
package/index.ts
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { existsSync, readdirSync, watch, type FSWatcher } from "node:fs";
|
|
9
|
+
import { dirname, join } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
9
11
|
|
|
10
12
|
import type {
|
|
11
13
|
ExtensionAPI,
|
|
@@ -22,6 +24,8 @@ import * as Runtime from "./lib/runtime.ts";
|
|
|
22
24
|
import * as Temp from "./lib/temp.ts";
|
|
23
25
|
import * as Tools from "./lib/tools.ts";
|
|
24
26
|
|
|
27
|
+
const EXTENSION_DIR = dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
const EXTENSION_SKILLS_DIR = join(EXTENSION_DIR, "skills");
|
|
25
29
|
const CONFIG_PATH = Paths.getConfigPath();
|
|
26
30
|
const TEMP_DIR = Paths.getExtensionTmpDir();
|
|
27
31
|
const RUN_STATE_ROOT = Paths.getRunStateRoot();
|
|
@@ -299,6 +303,10 @@ export default function toolRegistryExtension(pi: ExtensionAPI) {
|
|
|
299
303
|
reservedToolNames: RESERVED_TOOL_NAMES,
|
|
300
304
|
setActiveTools: (toolNames) => pi.setActiveTools(toolNames),
|
|
301
305
|
});
|
|
306
|
+
pi.on("resources_discover", async () => {
|
|
307
|
+
if (!existsSync(EXTENSION_SKILLS_DIR)) return;
|
|
308
|
+
return { skillPaths: [EXTENSION_SKILLS_DIR] };
|
|
309
|
+
});
|
|
302
310
|
pi.on("session_start", async (_event, ctx) => {
|
|
303
311
|
await Temp.prepareExtensionTempDir(TEMP_DIR);
|
|
304
312
|
runtime.loadTools(ctx);
|
package/lib/tools.ts
CHANGED
|
@@ -593,6 +593,7 @@ function getRunOwnerId(ctx: AsyncRunToolContext): string | undefined {
|
|
|
593
593
|
}
|
|
594
594
|
|
|
595
595
|
function messageBodyToRunLine(message: ActorMessages.ActorMessage): string {
|
|
596
|
+
if (message.type !== "run.message") return JSON.stringify(message);
|
|
596
597
|
if (typeof message.body === "string") return message.body;
|
|
597
598
|
if (message.body === undefined) return message.type;
|
|
598
599
|
return JSON.stringify(message.body);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@llblab/pi-actors",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Local Actor Kernel for Pi",
|
|
6
6
|
"keywords": [
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"index.ts",
|
|
38
|
+
"dist",
|
|
38
39
|
"lib",
|
|
39
40
|
"scripts",
|
|
40
|
-
"dist",
|
|
41
41
|
"recipes",
|
|
42
42
|
"skills",
|
|
43
43
|
"README.md",
|
|
@@ -56,12 +56,10 @@
|
|
|
56
56
|
"./index.ts"
|
|
57
57
|
],
|
|
58
58
|
"skills": [
|
|
59
|
-
"./dist/skills
|
|
60
|
-
"./dist/skills/swarm/SKILL.md"
|
|
59
|
+
"./dist/skills"
|
|
61
60
|
],
|
|
62
61
|
"sourceSkills": [
|
|
63
|
-
"./skills
|
|
64
|
-
"./skills/swarm/SKILL.md"
|
|
62
|
+
"./skills"
|
|
65
63
|
],
|
|
66
64
|
"image": "https://github.com/llblab/pi-actors/raw/main/banner.jpg"
|
|
67
65
|
},
|
package/scripts/music-player.mjs
CHANGED
|
@@ -404,26 +404,39 @@ function readText(path) {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
function
|
|
408
|
-
const title = track.split(/[\\/]/).filter(Boolean).pop() || track;
|
|
407
|
+
function emitPlayerEvent(ctx, type, summary, body = {}) {
|
|
409
408
|
writeText(
|
|
410
409
|
ctx.eventFile,
|
|
411
410
|
`${JSON.stringify({
|
|
412
|
-
body
|
|
413
|
-
data:
|
|
411
|
+
body,
|
|
412
|
+
data: body,
|
|
414
413
|
delivery: "log",
|
|
415
|
-
event:
|
|
414
|
+
event: type,
|
|
416
415
|
from: `run:${basename(ctx.stateDir)}`,
|
|
417
416
|
level: "info",
|
|
418
|
-
summary
|
|
417
|
+
summary,
|
|
419
418
|
to: "coordinator",
|
|
420
419
|
ts: new Date().toISOString(),
|
|
421
|
-
type
|
|
420
|
+
type,
|
|
422
421
|
})}\n`,
|
|
423
422
|
"a",
|
|
424
423
|
);
|
|
425
424
|
}
|
|
426
425
|
|
|
426
|
+
function emitTrackEvent(ctx, index, count, track, player) {
|
|
427
|
+
const title = track.split(/[\\/]/).filter(Boolean).pop() || track;
|
|
428
|
+
emitPlayerEvent(ctx, "player.track", `Now playing: ${title}`, {
|
|
429
|
+
count,
|
|
430
|
+
index,
|
|
431
|
+
player,
|
|
432
|
+
track,
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function emitStoppedEvent(ctx, reason = "stop") {
|
|
437
|
+
emitPlayerEvent(ctx, "player.stopped", "Music player stopped", { reason });
|
|
438
|
+
}
|
|
439
|
+
|
|
427
440
|
function writeStatus(ctx, state, index, count, track, player, pid = "") {
|
|
428
441
|
const updatedAt = new Date().toISOString();
|
|
429
442
|
writeText(
|
|
@@ -611,23 +624,27 @@ function writeInboxMessages(ctx, messages) {
|
|
|
611
624
|
);
|
|
612
625
|
}
|
|
613
626
|
|
|
627
|
+
function commandFromControlToken(token) {
|
|
628
|
+
if (CONTROL_COMMANDS.has(token)) return token;
|
|
629
|
+
if (token === "control.stop" || token === "control.cancel") return "stop";
|
|
630
|
+
const match = /^player\.(.+)$/.exec(token);
|
|
631
|
+
if (match && CONTROL_COMMANDS.has(match[1])) return match[1];
|
|
632
|
+
return undefined;
|
|
633
|
+
}
|
|
634
|
+
|
|
614
635
|
function commandFromInboxMessage(message) {
|
|
615
|
-
if (
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
636
|
+
if (typeof message.type === "string") {
|
|
637
|
+
const command = commandFromControlToken(message.type.trim());
|
|
638
|
+
if (command) return command;
|
|
639
|
+
}
|
|
640
|
+
if (typeof message.body === "string") {
|
|
641
|
+
const command = message.body.trim();
|
|
642
|
+
if (CONTROL_COMMANDS.has(command)) return command;
|
|
620
643
|
}
|
|
621
644
|
if (message.body && typeof message.body === "object") {
|
|
622
645
|
const command = String(message.body.command ?? "").trim();
|
|
623
646
|
if (CONTROL_COMMANDS.has(command)) return command;
|
|
624
647
|
}
|
|
625
|
-
if (typeof message.type === "string") {
|
|
626
|
-
if (message.type === "control.stop" || message.type === "control.cancel")
|
|
627
|
-
return "stop";
|
|
628
|
-
const match = /^player\.(.+)$/.exec(message.type);
|
|
629
|
-
if (match && CONTROL_COMMANDS.has(match[1])) return match[1];
|
|
630
|
-
}
|
|
631
648
|
return undefined;
|
|
632
649
|
}
|
|
633
650
|
|
|
@@ -895,6 +912,7 @@ async function playMain(args) {
|
|
|
895
912
|
const command = readAndClearCommand(ctx);
|
|
896
913
|
if (command === "stop") {
|
|
897
914
|
writeStatus(ctx, "stopped", index, count, track, player, "");
|
|
915
|
+
emitStoppedEvent(ctx, "message");
|
|
898
916
|
return;
|
|
899
917
|
}
|
|
900
918
|
if (command === "previous" || command === "prev") {
|
|
@@ -913,6 +931,7 @@ async function playMain(args) {
|
|
|
913
931
|
}
|
|
914
932
|
}
|
|
915
933
|
writeStatus(ctx, "stopped", index, tracks.length, "", player, "");
|
|
934
|
+
emitStoppedEvent(ctx, "complete");
|
|
916
935
|
} finally {
|
|
917
936
|
cleanup();
|
|
918
937
|
await Promise.race([controlLoop?.promise ?? Promise.resolve(), sleep(100)]);
|
package/skills/actors/SKILL.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: actors
|
|
3
3
|
description: Highest-density practical guide for pi-actors. Read this skill whenever prompt and tools are not enough for spawn, message, inspect, actor runs, tools, recipes, command templates, async lifecycle, mailboxes, artifacts, and local orchestration mechanics.
|
|
4
4
|
metadata:
|
|
5
|
-
version: 0.24.
|
|
5
|
+
version: 0.24.5
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Actors (pi-actors)
|
package/skills/swarm/SKILL.md
CHANGED