posipaki 0.16.2 → 0.16.3

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.
@@ -0,0 +1,18 @@
1
+ import { s as ActorPlugin } from "../hooks-Czj67zNB.js";
2
+
3
+ //#region src/plugins/tree-introspection.d.ts
4
+ /** A node in the process tree. */
5
+ interface TreeNode {
6
+ /** Actor name (tree-prefixed, e.g. "openai:connector"). */
7
+ pname: string;
8
+ /** Parent actor name, or null for the root. */
9
+ parentName: string | null;
10
+ /** Child subtrees (recursive). */
11
+ children: TreeNode[];
12
+ /** Actor status. */
13
+ status: 'running' | 'no introspection';
14
+ }
15
+ declare function inspect(): ActorPlugin;
16
+ //#endregion
17
+ export { TreeNode, inspect };
18
+ //# sourceMappingURL=tree-introspection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-introspection.d.ts","names":[],"sources":["../../src/plugins/tree-introspection.ts"],"mappings":";;;;UAiCiB,QAAA;EAAA;EAEf,KAAA;;EAEA,UAAA;EAFA;EAIA,QAAA,EAAU,QAAQ;EAAlB;EAEA,MAAA;AAAA;AAAA,iBAKc,OAAA,IAAW,WAAW"}
@@ -0,0 +1,42 @@
1
+ //#region src/plugins/tree-introspection.ts
2
+ function inspect() {
3
+ return {
4
+ name: "inspect",
5
+ install(self) {
6
+ self.reflection.register("getTree", async function(prefix) {
7
+ const children = [];
8
+ for (const child of Object.values(this.$child)) {
9
+ const childRefl = child.$reflection;
10
+ if (typeof childRefl["inspect.getTree"] === "function") {
11
+ const sub = await childRefl["inspect.getTree"](prefix);
12
+ if (!prefix || sub.pname.startsWith(prefix)) children.push(sub);
13
+ } else {
14
+ const name = child.pname;
15
+ if (!prefix || name.startsWith(prefix)) children.push({
16
+ pname: name,
17
+ parentName: this.name,
18
+ children: [],
19
+ status: "no introspection"
20
+ });
21
+ }
22
+ }
23
+ return {
24
+ pname: this.name,
25
+ parentName: this.ctx.parentName,
26
+ children,
27
+ status: "running"
28
+ };
29
+ });
30
+ self.reflection.register("getState", function() {
31
+ return this.state;
32
+ });
33
+ self.reflection.register("stop", function() {
34
+ this.agreeToStop();
35
+ });
36
+ }
37
+ };
38
+ }
39
+ //#endregion
40
+ export { inspect };
41
+
42
+ //# sourceMappingURL=tree-introspection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-introspection.js","names":[],"sources":["../../src/plugins/tree-introspection.ts"],"sourcesContent":["// ── inspect Plugin ───────────────────────────────────────────────────────\n//\n// Registers reflection methods for actor tree introspection.\n// Built on the Actor Reflection RPC mechanism.\n//\n// Usage:\n//\n// import { inspect } from 'posipaki/plugins/tree-introspection';\n// const MyActor = defineActor({\n// plugins: [inspect()],\n// ...\n// });\n//\n// Access via proc.$reflection:\n//\n// const tree = await rootProc.$reflection['inspect.getTree']();\n// // TreeNode { pname, parentName, children: TreeNode[], status }\n//\n// const state = await proc.$reflection['inspect.getState']();\n//\n// await proc.$reflection['inspect.stop']();\n//\n// Filtering:\n//\n// const subtree = await proc.$reflection['inspect.getTree']('openai:');\n// // Only includes nodes whose pname starts with 'openai:'\n//\n\nimport type { ActorPlugin } from '../hooks.js';\n\n// ── types ────────────────────────────────────────────────────────────────\n\n/** A node in the process tree. */\nexport interface TreeNode {\n /** Actor name (tree-prefixed, e.g. \"openai:connector\"). */\n pname: string;\n /** Parent actor name, or null for the root. */\n parentName: string | null;\n /** Child subtrees (recursive). */\n children: TreeNode[];\n /** Actor status. */\n status: 'running' | 'no introspection';\n}\n\n// ── plugin ───────────────────────────────────────────────────────────────\n\nexport function inspect(): ActorPlugin {\n return {\n name: 'inspect',\n install(self) {\n self.reflection.register('getTree', async function (prefix?: string) {\n const children: TreeNode[] = [];\n for (const child of Object.values(this.$child)) {\n const childRefl = (child.$reflection as Record<string, Function>);\n if (typeof childRefl['inspect.getTree'] === 'function') {\n const sub = await childRefl['inspect.getTree'](prefix) as TreeNode;\n if (!prefix || sub.pname.startsWith(prefix)) {\n children.push(sub);\n }\n } else {\n const name = child.pname;\n if (!prefix || name.startsWith(prefix)) {\n children.push({\n pname: name,\n parentName: this.name,\n children: [],\n status: 'no introspection',\n });\n }\n }\n }\n return {\n pname: this.name,\n parentName: this.ctx.parentName,\n children,\n status: 'running' as const,\n } satisfies TreeNode;\n });\n\n self.reflection.register('getState', function () {\n return this.state;\n });\n\n self.reflection.register('stop', function () {\n this.agreeToStop();\n });\n },\n };\n}\n"],"mappings":";AA8CA,SAAgB,UAAuB;CACrC,OAAO;EACL,MAAM;EACN,QAAQ,MAAM;GACZ,KAAK,WAAW,SAAS,WAAW,eAAgB,QAAiB;IACnE,MAAM,WAAuB,CAAC;IAC9B,KAAK,MAAM,SAAS,OAAO,OAAO,KAAK,MAAM,GAAG;KAC9C,MAAM,YAAa,MAAM;KACzB,IAAI,OAAO,UAAU,uBAAuB,YAAY;MACtD,MAAM,MAAM,MAAM,UAAU,mBAAmB,MAAM;MACrD,IAAI,CAAC,UAAU,IAAI,MAAM,WAAW,MAAM,GACxC,SAAS,KAAK,GAAG;KAErB,OAAO;MACL,MAAM,OAAO,MAAM;MACnB,IAAI,CAAC,UAAU,KAAK,WAAW,MAAM,GACnC,SAAS,KAAK;OACZ,OAAO;OACP,YAAY,KAAK;OACjB,UAAU,CAAC;OACX,QAAQ;MACV,CAAC;KAEL;IACF;IACA,OAAO;KACL,OAAO,KAAK;KACZ,YAAY,KAAK,IAAI;KACrB;KACA,QAAQ;IACV;GACF,CAAC;GAED,KAAK,WAAW,SAAS,YAAY,WAAY;IAC/C,OAAO,KAAK;GACd,CAAC;GAED,KAAK,WAAW,SAAS,QAAQ,WAAY;IAC3C,KAAK,YAAY;GACnB,CAAC;EACH;CACF;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "posipaki",
4
- "version": "0.16.2",
4
+ "version": "0.16.3",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "files": [
@@ -41,6 +41,10 @@
41
41
  "types": "./dist/plugins/rbac.d.ts",
42
42
  "default": "./dist/plugins/rbac.js"
43
43
  },
44
+ "./plugins/tree-introspection": {
45
+ "types": "./dist/plugins/tree-introspection.d.ts",
46
+ "default": "./dist/plugins/tree-introspection.js"
47
+ },
44
48
  "./hooks": {
45
49
  "types": "./dist/hooks.d.ts",
46
50
  "default": "./dist/hooks.js"