@llblab/pi-actors 0.22.5 → 0.24.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.
Files changed (180) hide show
  1. package/AGENTS.md +125 -59
  2. package/BACKLOG.md +88 -403
  3. package/CHANGELOG.md +39 -0
  4. package/README.md +14 -1
  5. package/dist/fixtures/protocol/actor-message-branch.json +13 -0
  6. package/dist/fixtures/protocol/artifact-manifest.json +9 -0
  7. package/dist/fixtures/protocol/mailbox-contract.json +15 -0
  8. package/dist/fixtures/protocol/recipe-summary.json +16 -0
  9. package/dist/fixtures/protocol/room-message.json +11 -0
  10. package/dist/fixtures/protocol/room-roster.json +11 -0
  11. package/dist/fixtures/protocol/run-inbox-message.json +9 -0
  12. package/dist/fixtures/protocol/run-outbox-event.json +9 -0
  13. package/dist/fixtures/protocol/run-state.json +10 -0
  14. package/dist/index.js +18 -2
  15. package/dist/lib/actor-inspector-tui.d.ts +4 -0
  16. package/dist/lib/actor-inspector-tui.js +58 -44
  17. package/dist/lib/actor-rooms.d.ts +16 -0
  18. package/dist/lib/actor-rooms.js +123 -28
  19. package/dist/lib/actor-worker.d.ts +13 -0
  20. package/dist/lib/actor-worker.js +86 -0
  21. package/dist/lib/async-runner.d.ts +5 -0
  22. package/dist/lib/async-runner.js +134 -0
  23. package/dist/lib/async-runs.d.ts +34 -2
  24. package/dist/lib/async-runs.js +224 -50
  25. package/dist/lib/build-dist.d.ts +5 -0
  26. package/dist/lib/build-dist.js +24 -0
  27. package/dist/lib/command-templates.js +5 -5
  28. package/dist/lib/conformance.d.ts +12 -0
  29. package/dist/lib/conformance.js +28 -0
  30. package/dist/lib/coordinator.d.ts +5 -0
  31. package/dist/lib/coordinator.js +557 -0
  32. package/dist/lib/limits.d.ts +11 -0
  33. package/dist/lib/limits.js +11 -0
  34. package/dist/lib/locker.d.ts +5 -0
  35. package/dist/lib/locker.js +310 -0
  36. package/dist/lib/mailbox-loop.d.ts +41 -0
  37. package/dist/lib/mailbox-loop.js +62 -0
  38. package/dist/lib/observability.d.ts +2 -2
  39. package/dist/lib/observability.js +57 -57
  40. package/dist/lib/output.js +4 -5
  41. package/dist/lib/prompts.d.ts +1 -1
  42. package/dist/lib/prompts.js +1 -1
  43. package/dist/lib/recipe-discovery.js +1 -0
  44. package/dist/lib/recipe-references.d.ts +11 -2
  45. package/dist/lib/recipe-references.js +29 -4
  46. package/dist/lib/recipe-usage.d.ts +2 -1
  47. package/dist/lib/recipe-usage.js +15 -3
  48. package/dist/lib/recipe-utils.d.ts +5 -0
  49. package/dist/lib/recipe-utils.js +385 -0
  50. package/dist/lib/runtime-notifier.js +3 -7
  51. package/dist/lib/runtime.js +12 -2
  52. package/dist/lib/state-readers.d.ts +21 -0
  53. package/dist/lib/state-readers.js +74 -0
  54. package/dist/lib/tools.js +198 -39
  55. package/dist/lib/validate-recipe.d.ts +6 -0
  56. package/dist/lib/validate-recipe.js +104 -0
  57. package/dist/recipes/actor-worker.json +35 -0
  58. package/dist/recipes/coordinator-locker.json +45 -0
  59. package/dist/recipes/lens-swarm.json +66 -0
  60. package/dist/recipes/locker.json +45 -0
  61. package/dist/recipes/music-player.json +38 -0
  62. package/dist/recipes/pipeline-architect-coordinator.json +95 -0
  63. package/dist/recipes/pipeline-artifact-bundle.json +100 -0
  64. package/dist/recipes/pipeline-artifact-report.json +58 -0
  65. package/dist/recipes/pipeline-artifact-write.json +72 -0
  66. package/dist/recipes/pipeline-async-run-ops.json +70 -0
  67. package/dist/recipes/pipeline-checkpoint-continuation.json +67 -0
  68. package/dist/recipes/pipeline-development-tasking.json +81 -0
  69. package/dist/recipes/pipeline-docs-maintenance.json +80 -0
  70. package/dist/recipes/pipeline-media-library.json +59 -0
  71. package/dist/recipes/pipeline-quorum-review.json +79 -0
  72. package/dist/recipes/pipeline-release-readiness.json +110 -0
  73. package/dist/recipes/pipeline-release-summary.json +88 -0
  74. package/dist/recipes/pipeline-repo-health.json +89 -0
  75. package/dist/recipes/pipeline-research-synthesis.json +94 -0
  76. package/dist/recipes/pipeline-review-readiness.json +54 -0
  77. package/dist/recipes/pipeline-room-swarm.json +50 -0
  78. package/dist/recipes/subagent-artifact.json +32 -0
  79. package/dist/recipes/subagent-checkpoint.json +33 -0
  80. package/dist/recipes/subagent-conflict-report.json +32 -0
  81. package/dist/recipes/subagent-contradiction-map.json +33 -0
  82. package/dist/recipes/subagent-critic.json +35 -0
  83. package/dist/recipes/subagent-evidence-map.json +33 -0
  84. package/dist/recipes/subagent-followup.json +33 -0
  85. package/dist/recipes/subagent-judge.json +33 -0
  86. package/dist/recipes/subagent-merge.json +33 -0
  87. package/dist/recipes/subagent-message.json +34 -0
  88. package/dist/recipes/subagent-normalize.json +31 -0
  89. package/dist/recipes/subagent-plan.json +33 -0
  90. package/dist/recipes/subagent-prompt.json +28 -0
  91. package/dist/recipes/subagent-quorum.json +43 -0
  92. package/dist/recipes/subagent-review-coordinator.json +114 -0
  93. package/dist/recipes/subagent-review.json +37 -0
  94. package/dist/recipes/subagent-task-card.json +35 -0
  95. package/dist/recipes/subagent-tools.json +27 -0
  96. package/dist/recipes/subagent-verify.json +34 -0
  97. package/dist/recipes/subagents-prompts.json +51 -0
  98. package/dist/recipes/utility-actor-message.json +23 -0
  99. package/dist/recipes/utility-artifact-manifest.json +16 -0
  100. package/dist/recipes/utility-artifact-write.json +16 -0
  101. package/dist/recipes/utility-changelog-head.json +11 -0
  102. package/dist/recipes/utility-changelog-section.json +13 -0
  103. package/dist/recipes/utility-coordinator-lock-snapshot.json +13 -0
  104. package/dist/recipes/utility-git-log.json +11 -0
  105. package/dist/recipes/utility-git-status.json +9 -0
  106. package/dist/recipes/utility-jsonl-tail.json +10 -0
  107. package/dist/recipes/utility-markdown-index.json +14 -0
  108. package/dist/recipes/utility-package-summary.json +11 -0
  109. package/dist/recipes/utility-playlist-build.json +17 -0
  110. package/dist/recipes/utility-playlist-scan.json +11 -0
  111. package/dist/recipes/utility-run-ops-snapshot.json +17 -0
  112. package/dist/recipes/utility-run-state-files.json +13 -0
  113. package/dist/recipes/utility-run-summary.json +11 -0
  114. package/dist/recipes/utility-skill-summary.json +13 -0
  115. package/dist/recipes/utility-validate-recipe.json +13 -0
  116. package/dist/recipes/utility-validation-wrapper.json +13 -0
  117. package/dist/scripts/actor-worker.mjs +31 -0
  118. package/dist/scripts/async-runner.mjs +31 -0
  119. package/dist/scripts/build-dist.mjs +25 -0
  120. package/dist/scripts/conformance.mjs +33 -0
  121. package/dist/scripts/coordinator.mjs +31 -0
  122. package/dist/scripts/locker.mjs +33 -0
  123. package/dist/scripts/music-player.mjs +964 -0
  124. package/dist/scripts/recipe-utils.mjs +31 -0
  125. package/dist/scripts/validate-recipe.mjs +34 -0
  126. package/dist/skills/actors/SKILL.md +375 -0
  127. package/dist/skills/swarm/SKILL.md +467 -0
  128. package/dist/skills/swarm/references/development-swarm.md +596 -0
  129. package/docs/actor-messages.md +2 -2
  130. package/docs/async-runs.md +13 -1
  131. package/docs/template-recipes.md +2 -2
  132. package/docs/tool-registry.md +0 -1
  133. package/fixtures/protocol/actor-message-branch.json +13 -0
  134. package/fixtures/protocol/artifact-manifest.json +9 -0
  135. package/fixtures/protocol/mailbox-contract.json +15 -0
  136. package/fixtures/protocol/recipe-summary.json +16 -0
  137. package/fixtures/protocol/room-message.json +11 -0
  138. package/fixtures/protocol/room-roster.json +11 -0
  139. package/fixtures/protocol/run-inbox-message.json +9 -0
  140. package/fixtures/protocol/run-outbox-event.json +9 -0
  141. package/fixtures/protocol/run-state.json +10 -0
  142. package/index.ts +21 -0
  143. package/lib/actor-inspector-tui.ts +138 -59
  144. package/lib/actor-rooms.ts +241 -60
  145. package/lib/actor-worker.ts +118 -0
  146. package/lib/async-runner.ts +173 -0
  147. package/lib/async-runs.ts +302 -53
  148. package/lib/build-dist.ts +30 -0
  149. package/lib/command-templates.ts +5 -5
  150. package/lib/conformance.ts +46 -0
  151. package/lib/coordinator.ts +649 -0
  152. package/lib/limits.ts +12 -0
  153. package/lib/locker.ts +340 -0
  154. package/lib/mailbox-loop.ts +148 -0
  155. package/lib/observability.ts +34 -23
  156. package/lib/output.ts +4 -6
  157. package/lib/prompts.ts +1 -1
  158. package/lib/recipe-discovery.ts +1 -0
  159. package/lib/recipe-references.ts +57 -6
  160. package/lib/recipe-usage.ts +31 -4
  161. package/lib/recipe-utils.ts +486 -0
  162. package/lib/runtime-notifier.ts +4 -6
  163. package/lib/runtime.ts +31 -7
  164. package/lib/state-readers.ts +93 -0
  165. package/lib/tools.ts +297 -58
  166. package/lib/validate-recipe.ts +110 -0
  167. package/package.json +11 -2
  168. package/recipes/actor-worker.json +35 -0
  169. package/recipes/pipeline-quorum-review.json +12 -7
  170. package/scripts/actor-worker.mjs +31 -0
  171. package/scripts/async-runner.mjs +11 -195
  172. package/scripts/build-dist.mjs +25 -0
  173. package/scripts/conformance.mjs +33 -0
  174. package/scripts/coordinator.mjs +19 -616
  175. package/scripts/locker.mjs +23 -322
  176. package/scripts/music-player.mjs +21 -2
  177. package/scripts/recipe-utils.mjs +20 -467
  178. package/scripts/validate-recipe.mjs +23 -113
  179. package/skills/actors/SKILL.md +7 -4
  180. package/skills/swarm/SKILL.md +3 -1
package/lib/runtime.ts CHANGED
@@ -98,9 +98,27 @@ export function createAutoToolsRuntime(
98
98
  runtimeTools.add(cfg.name);
99
99
  runtimeToolFingerprints.set(cfg.name, fingerprint);
100
100
  }
101
+ function isStartupActionableRegistryWarning(warning: string): boolean {
102
+ if (
103
+ warning.includes("invokes bash;") &&
104
+ warning.includes("trusted executable content")
105
+ )
106
+ return false;
107
+ if (
108
+ warning.includes("invokes bash;") &&
109
+ warning.includes("shell scripts are trusted executable content")
110
+ )
111
+ return false;
112
+ return true;
113
+ }
114
+
101
115
  function formatRecipeToolWarnings(warnings: string[]): string {
102
- const shadowed = warnings.filter((warning) => warning.includes(" shadows "));
103
- const skipped = warnings.filter((warning) => warning.includes(" could not be exposed as a tool:"));
116
+ const shadowed = warnings.filter((warning) =>
117
+ warning.includes(" shadows "),
118
+ );
119
+ const skipped = warnings.filter((warning) =>
120
+ warning.includes(" could not be exposed as a tool:"),
121
+ );
104
122
  const other = warnings.filter(
105
123
  (warning) => !shadowed.includes(warning) && !skipped.includes(warning),
106
124
  );
@@ -122,7 +140,8 @@ export function createAutoToolsRuntime(
122
140
  function loadTools(ctx: RuntimeContext) {
123
141
  const warnings: string[] = [];
124
142
  const recipeRoot = deps.recipeRoot ?? Paths.getRecipeRoot();
125
- const packagedRecipeRoot = deps.packagedRecipeRoot ?? Paths.getPackagedRecipeRoot();
143
+ const packagedRecipeRoot =
144
+ deps.packagedRecipeRoot ?? Paths.getPackagedRecipeRoot();
126
145
  const migration = RecipeMigration.migrateLegacyToolRegistry({
127
146
  configPath: deps.configPath,
128
147
  recipeRoot,
@@ -130,9 +149,13 @@ export function createAutoToolsRuntime(
130
149
  });
131
150
  warnings.push(...migration.warnings);
132
151
  if (migration.conflicts.length > 0)
133
- warnings.push(`Recipe migration conflicts: ${migration.conflicts.join(", ")}`);
152
+ warnings.push(
153
+ `Recipe migration conflicts: ${migration.conflicts.join(", ")}`,
154
+ );
134
155
  if (migration.invalid.length > 0)
135
- warnings.push(`Recipe migration invalid entries: ${migration.invalid.join(", ")}`);
156
+ warnings.push(
157
+ `Recipe migration invalid entries: ${migration.invalid.join(", ")}`,
158
+ );
136
159
  const discovered = RecipeDiscovery.discoverRecipeSources([
137
160
  { root: recipeRoot, defaultTool: true, mutableUsage: true },
138
161
  { root: packagedRecipeRoot },
@@ -158,8 +181,9 @@ export function createAutoToolsRuntime(
158
181
  }
159
182
  registerRuntimeTool(cfg);
160
183
  }
161
- if (warnings.length > 0) {
162
- notify(ctx, formatRecipeToolWarnings(warnings), "warning");
184
+ const startupWarnings = warnings.filter(isStartupActionableRegistryWarning);
185
+ if (startupWarnings.length > 0) {
186
+ notify(ctx, formatRecipeToolWarnings(startupWarnings), "warning");
163
187
  }
164
188
  }
165
189
  return {
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Resilient state readers.
3
+ * Zones: file-backed actor state, JSON/JSONL diagnostics, inspect safety
4
+ * Owns best-effort JSON and JSONL parsing helpers for operator-facing state reads.
5
+ */
6
+
7
+ import { readFileSync } from "node:fs";
8
+
9
+ export interface StateReadDiagnostic {
10
+ line?: number;
11
+ message: string;
12
+ path: string;
13
+ }
14
+
15
+ export interface JsonReadResult<T> {
16
+ diagnostics: StateReadDiagnostic[];
17
+ value: T;
18
+ }
19
+
20
+ export interface JsonlReadResult<T> {
21
+ diagnostics: StateReadDiagnostic[];
22
+ records: T[];
23
+ }
24
+
25
+ function isEnoent(error: unknown): boolean {
26
+ return (error as NodeJS.ErrnoException).code === "ENOENT";
27
+ }
28
+
29
+ function diagnosticMessage(error: unknown): string {
30
+ return error instanceof Error ? error.message : String(error);
31
+ }
32
+
33
+ export function readJsonFileResilient<T>(path: string, fallback: T): JsonReadResult<T> {
34
+ try {
35
+ return {
36
+ diagnostics: [],
37
+ value: JSON.parse(readFileSync(path, "utf8")) as T,
38
+ };
39
+ } catch (error) {
40
+ if (isEnoent(error)) return { diagnostics: [], value: fallback };
41
+ return {
42
+ diagnostics: [
43
+ {
44
+ message: diagnosticMessage(error),
45
+ path,
46
+ },
47
+ ],
48
+ value: fallback,
49
+ };
50
+ }
51
+ }
52
+
53
+ export function readJsonlFileResilient<T>(path: string): JsonlReadResult<T> {
54
+ try {
55
+ const records: T[] = [];
56
+ const diagnostics: StateReadDiagnostic[] = [];
57
+ const lines = readFileSync(path, "utf8").split("\n");
58
+ for (const [index, line] of lines.entries()) {
59
+ if (!line.trim()) continue;
60
+ try {
61
+ records.push(JSON.parse(line) as T);
62
+ } catch (error) {
63
+ diagnostics.push({
64
+ line: index + 1,
65
+ message: diagnosticMessage(error),
66
+ path,
67
+ });
68
+ }
69
+ }
70
+ return { diagnostics, records };
71
+ } catch (error) {
72
+ if (isEnoent(error)) return { diagnostics: [], records: [] };
73
+ return {
74
+ diagnostics: [
75
+ {
76
+ message: diagnosticMessage(error),
77
+ path,
78
+ },
79
+ ],
80
+ records: [],
81
+ };
82
+ }
83
+ }
84
+
85
+ export function formatStateReadDiagnostics(
86
+ diagnostics: StateReadDiagnostic[],
87
+ limit = 5,
88
+ ): string[] {
89
+ return diagnostics.slice(0, limit).map((diagnostic) => {
90
+ const line = diagnostic.line === undefined ? "" : `:${diagnostic.line}`;
91
+ return `${diagnostic.path}${line}: ${diagnostic.message}`;
92
+ });
93
+ }