@leitwerk-dev/server 0.1.8 → 0.1.9

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 (187) hide show
  1. package/dist/app.d.ts.map +1 -1
  2. package/dist/app.js +22 -6
  3. package/dist/app.js.map +1 -1
  4. package/dist/{chunk-ES5RBLAT.js → chunk-2ESDXLNE.js} +199 -95
  5. package/dist/chunk-2ESDXLNE.js.map +1 -0
  6. package/dist/{chunk-UC3OOEQ3.js → chunk-DFHOPJRZ.js} +393 -249
  7. package/dist/chunk-DFHOPJRZ.js.map +1 -0
  8. package/dist/config/config-loader.d.ts.map +1 -1
  9. package/dist/config/config-loader.js +6 -24
  10. package/dist/config/config-loader.js.map +1 -1
  11. package/dist/config/config-types.d.ts +0 -17
  12. package/dist/config/config-types.d.ts.map +1 -1
  13. package/dist/db/skill-repo.d.ts +2 -2
  14. package/dist/db/skill-repo.d.ts.map +1 -1
  15. package/dist/db/skill-repo.js +24 -32
  16. package/dist/db/skill-repo.js.map +1 -1
  17. package/dist/external-source-service.d.ts.map +1 -1
  18. package/dist/external-source-service.js +5 -2
  19. package/dist/external-source-service.js.map +1 -1
  20. package/dist/future-execution/execution.d.ts +1 -1
  21. package/dist/future-execution/execution.d.ts.map +1 -1
  22. package/dist/future-execution/execution.js +1 -13
  23. package/dist/future-execution/execution.js.map +1 -1
  24. package/dist/integration-tool-registry.js +1 -1
  25. package/dist/integration-tool-registry.js.map +1 -1
  26. package/dist/process-action-registry.d.ts +2 -4
  27. package/dist/process-action-registry.d.ts.map +1 -1
  28. package/dist/process-action-registry.js +31 -28
  29. package/dist/process-action-registry.js.map +1 -1
  30. package/dist/process-engine/engine.d.ts.map +1 -1
  31. package/dist/process-engine/engine.js +4 -4
  32. package/dist/process-engine/engine.js.map +1 -1
  33. package/dist/process-engine/operation.d.ts +4 -0
  34. package/dist/process-engine/operation.d.ts.map +1 -1
  35. package/dist/process-engine/ops/execute-action.d.ts.map +1 -1
  36. package/dist/process-engine/ops/execute-action.js +0 -3
  37. package/dist/process-engine/ops/execute-action.js.map +1 -1
  38. package/dist/process-engine/ops/worker-failure.d.ts +2 -0
  39. package/dist/process-engine/ops/worker-failure.d.ts.map +1 -1
  40. package/dist/process-engine/ops/worker-failure.js +2 -0
  41. package/dist/process-engine/ops/worker-failure.js.map +1 -1
  42. package/dist/process-engine/runner.d.ts +2 -2
  43. package/dist/process-engine/runner.d.ts.map +1 -1
  44. package/dist/process-engine/runner.js +13 -1
  45. package/dist/process-engine/runner.js.map +1 -1
  46. package/dist/process-engine/types.d.ts +10 -4
  47. package/dist/process-engine/types.d.ts.map +1 -1
  48. package/dist/process-engine/writes/build-server-transition-writes.d.ts.map +1 -1
  49. package/dist/process-engine/writes/build-server-transition-writes.js +2 -8
  50. package/dist/process-engine/writes/build-server-transition-writes.js.map +1 -1
  51. package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
  52. package/dist/process-engine/writes/build-turn-outcome-writes.js +1 -2
  53. package/dist/process-engine/writes/build-turn-outcome-writes.js.map +1 -1
  54. package/dist/process-engine/writes/build-turn-selection-writes.d.ts +1 -2
  55. package/dist/process-engine/writes/build-turn-selection-writes.d.ts.map +1 -1
  56. package/dist/process-engine/writes/build-turn-selection-writes.js +1 -57
  57. package/dist/process-engine/writes/build-turn-selection-writes.js.map +1 -1
  58. package/dist/process-engine/writes/build-worker-failure-writes.d.ts +3 -1
  59. package/dist/process-engine/writes/build-worker-failure-writes.d.ts.map +1 -1
  60. package/dist/process-engine/writes/build-worker-failure-writes.js +2 -1
  61. package/dist/process-engine/writes/build-worker-failure-writes.js.map +1 -1
  62. package/dist/process-launch-executor.d.ts +6 -4
  63. package/dist/process-launch-executor.d.ts.map +1 -1
  64. package/dist/process-launch-executor.js +16 -1
  65. package/dist/process-launch-executor.js.map +1 -1
  66. package/dist/process-launch-plan.d.ts.map +1 -1
  67. package/dist/process-launch-plan.js +1 -0
  68. package/dist/process-launch-plan.js.map +1 -1
  69. package/dist/process-operator-attention.d.ts +1 -1
  70. package/dist/process-operator-attention.d.ts.map +1 -1
  71. package/dist/process-operator-attention.js +1 -1
  72. package/dist/process-operator-attention.js.map +1 -1
  73. package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
  74. package/dist/process-ui-snapshot-presenter.js +24 -3
  75. package/dist/process-ui-snapshot-presenter.js.map +1 -1
  76. package/dist/process-watcher-registry.d.ts.map +1 -1
  77. package/dist/process-watcher-registry.js +13 -5
  78. package/dist/process-watcher-registry.js.map +1 -1
  79. package/dist/routes/skills.d.ts.map +1 -1
  80. package/dist/routes/skills.js +1 -2
  81. package/dist/routes/skills.js.map +1 -1
  82. package/dist/server-automatic-turn-drainer.d.ts.map +1 -1
  83. package/dist/server-automatic-turn-drainer.js +15 -0
  84. package/dist/server-automatic-turn-drainer.js.map +1 -1
  85. package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
  86. package/dist/server-bootstrap/build-host-capabilities.js +1 -0
  87. package/dist/server-bootstrap/build-host-capabilities.js.map +1 -1
  88. package/dist/skills/skill-frontmatter.d.ts +4 -0
  89. package/dist/skills/skill-frontmatter.d.ts.map +1 -0
  90. package/dist/skills/skill-frontmatter.js +13 -0
  91. package/dist/skills/skill-frontmatter.js.map +1 -0
  92. package/dist/skills/source-importer.d.ts +2 -3
  93. package/dist/skills/source-importer.d.ts.map +1 -1
  94. package/dist/skills/source-importer.js +16 -62
  95. package/dist/skills/source-importer.js.map +1 -1
  96. package/dist/supervisor/accepted-turn-start-replay.d.ts +9 -0
  97. package/dist/supervisor/accepted-turn-start-replay.d.ts.map +1 -0
  98. package/dist/supervisor/accepted-turn-start-replay.js +23 -0
  99. package/dist/supervisor/accepted-turn-start-replay.js.map +1 -0
  100. package/dist/supervisor/ipc-handler.d.ts +9 -0
  101. package/dist/supervisor/ipc-handler.d.ts.map +1 -1
  102. package/dist/supervisor/ipc-handler.js +9 -4
  103. package/dist/supervisor/ipc-handler.js.map +1 -1
  104. package/dist/supervisor/stale-heartbeat-watchdog.d.ts +1 -1
  105. package/dist/supervisor/stale-heartbeat-watchdog.d.ts.map +1 -1
  106. package/dist/supervisor/stale-heartbeat-watchdog.js +47 -5
  107. package/dist/supervisor/stale-heartbeat-watchdog.js.map +1 -1
  108. package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
  109. package/dist/supervisor/worker-event-ingestor.js +16 -0
  110. package/dist/supervisor/worker-event-ingestor.js.map +1 -1
  111. package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
  112. package/dist/supervisor/worker-start-payload-builder.js +3 -1
  113. package/dist/supervisor/worker-start-payload-builder.js.map +1 -1
  114. package/dist/supervisor/worker-supervisor.d.ts +3 -1
  115. package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
  116. package/dist/supervisor/worker-supervisor.js +31 -0
  117. package/dist/supervisor/worker-supervisor.js.map +1 -1
  118. package/dist/supervisor/worker-turn-ipc-recorder.d.ts +12 -3
  119. package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
  120. package/dist/supervisor/worker-turn-ipc-recorder.js +129 -33
  121. package/dist/supervisor/worker-turn-ipc-recorder.js.map +1 -1
  122. package/dist/supervisor/worker-websocket-ipc.d.ts.map +1 -1
  123. package/dist/supervisor/worker-websocket-ipc.js +20 -10
  124. package/dist/supervisor/worker-websocket-ipc.js.map +1 -1
  125. package/dist/test-helpers/fake-worker-supervisor.d.ts.map +1 -1
  126. package/dist/test-helpers/fake-worker-supervisor.js +4 -0
  127. package/dist/test-helpers/fake-worker-supervisor.js.map +1 -1
  128. package/dist/test-helpers/ipc-handler-harness.d.ts.map +1 -1
  129. package/dist/test-helpers/ipc-handler-harness.js +1 -20
  130. package/dist/test-helpers/ipc-handler-harness.js.map +1 -1
  131. package/dist/test-helpers/process-fixtures.d.ts +1 -1
  132. package/dist/test-helpers/process-fixtures.d.ts.map +1 -1
  133. package/dist/test-helpers/process-fixtures.js +0 -6
  134. package/dist/test-helpers/process-fixtures.js.map +1 -1
  135. package/dist/turn-progress.d.ts +12 -0
  136. package/dist/turn-progress.d.ts.map +1 -0
  137. package/dist/turn-progress.js +108 -0
  138. package/dist/turn-progress.js.map +1 -0
  139. package/dist/{writes-CVXLCYce.d.ts → writes-DNXpryd0.d.ts} +29 -27
  140. package/package.json +10 -10
  141. package/src/app.ts +22 -6
  142. package/src/config/config-loader.ts +9 -24
  143. package/src/config/config-types.ts +0 -13
  144. package/src/db/skill-repo.ts +26 -36
  145. package/src/external-source-service.ts +5 -2
  146. package/src/future-execution/execution.ts +2 -13
  147. package/src/integration-tool-registry.ts +1 -1
  148. package/src/process-action-registry.ts +48 -40
  149. package/src/process-engine/engine.ts +6 -4
  150. package/src/process-engine/operation.ts +5 -0
  151. package/src/process-engine/ops/execute-action.ts +0 -3
  152. package/src/process-engine/ops/worker-failure.ts +4 -0
  153. package/src/process-engine/runner.ts +13 -0
  154. package/src/process-engine/types.ts +14 -2
  155. package/src/process-engine/writes/build-server-transition-writes.ts +1 -14
  156. package/src/process-engine/writes/build-turn-outcome-writes.ts +1 -2
  157. package/src/process-engine/writes/build-turn-selection-writes.ts +0 -75
  158. package/src/process-engine/writes/build-worker-failure-writes.ts +4 -1
  159. package/src/process-launch-executor.ts +24 -15
  160. package/src/process-launch-plan.ts +1 -0
  161. package/src/process-operator-attention.ts +7 -3
  162. package/src/process-ui-snapshot-presenter.ts +24 -6
  163. package/src/process-watcher-registry.ts +15 -5
  164. package/src/routes/skills.ts +1 -3
  165. package/src/server-automatic-turn-drainer.ts +20 -1
  166. package/src/server-bootstrap/build-host-capabilities.ts +1 -0
  167. package/src/skills/skill-frontmatter.ts +13 -0
  168. package/src/skills/source-importer.ts +20 -82
  169. package/src/supervisor/accepted-turn-start-replay.ts +40 -0
  170. package/src/supervisor/ipc-handler.ts +18 -4
  171. package/src/supervisor/stale-heartbeat-watchdog.ts +55 -6
  172. package/src/supervisor/worker-event-ingestor.ts +15 -0
  173. package/src/supervisor/worker-start-payload-builder.ts +3 -1
  174. package/src/supervisor/worker-supervisor.ts +42 -0
  175. package/src/supervisor/worker-turn-ipc-recorder.ts +185 -46
  176. package/src/supervisor/worker-websocket-ipc.ts +28 -13
  177. package/src/test-helpers/fake-worker-supervisor.ts +4 -0
  178. package/src/test-helpers/ipc-handler-harness.ts +1 -22
  179. package/src/test-helpers/process-fixtures.ts +1 -6
  180. package/src/turn-progress.ts +114 -0
  181. package/dist/chunk-ES5RBLAT.js.map +0 -1
  182. package/dist/chunk-UC3OOEQ3.js.map +0 -1
  183. package/dist/skills/catalog-sync.d.ts +0 -9
  184. package/dist/skills/catalog-sync.d.ts.map +0 -1
  185. package/dist/skills/catalog-sync.js +0 -7
  186. package/dist/skills/catalog-sync.js.map +0 -1
  187. package/src/skills/catalog-sync.ts +0 -13
@@ -204,20 +204,6 @@ var kubernetesHostnameSchema = v.pipe(
204
204
  "Expected a lowercase DNS hostname"
205
205
  )
206
206
  );
207
- var skillSchema = v.strictObject({
208
- id: safeSkillIdSchema,
209
- label: v.optional(v.pipe(v.string(), v.nonEmpty())),
210
- description: v.optional(v.pipe(v.string(), v.nonEmpty())),
211
- source: v.variant("kind", [
212
- v.strictObject({ kind: v.literal("local"), path: v.pipe(v.string(), v.nonEmpty()) }),
213
- v.strictObject({
214
- kind: v.literal("git"),
215
- url: v.pipe(v.string(), v.nonEmpty()),
216
- ref: v.pipe(v.string(), v.nonEmpty()),
217
- path: v.pipe(v.string(), v.nonEmpty())
218
- })
219
- ])
220
- });
221
207
  var skillRepositorySchema = v.strictObject({
222
208
  id: safeSkillIdSchema,
223
209
  label: v.optional(v.pipe(v.string(), v.nonEmpty())),
@@ -226,7 +212,6 @@ var skillRepositorySchema = v.strictObject({
226
212
  path: v.optional(v.pipe(v.string(), v.nonEmpty()))
227
213
  });
228
214
  var configSchema = v.looseObject({
229
- skills: v.optional(v.array(skillSchema)),
230
215
  skill_repositories: v.optional(v.array(skillRepositorySchema)),
231
216
  commit_messages: v.optional(
232
217
  v.strictObject({
@@ -768,6 +753,7 @@ function hasOwnKey(value, key) {
768
753
  return typeof value === "object" && value !== null && !Array.isArray(value) && Object.hasOwn(value, key);
769
754
  }
770
755
  function collectLegacyConfigKeyErrors(config) {
756
+ const errors = Object.hasOwn(config, "skills") ? ["skills was removed; configure Git sources through skill_repositories"] : [];
771
757
  const legacyKeys = [
772
758
  {
773
759
  section: "pi",
@@ -780,7 +766,10 @@ function collectLegacyConfigKeyErrors(config) {
780
766
  message: "local_worker.process_volume_root was removed; remove the key because local workers use storage.process_workspaces_dir and storage.tree_files_dir directly"
781
767
  }
782
768
  ];
783
- return legacyKeys.filter(({ section, key }) => hasOwnKey(config[section], key)).map(({ message }) => message);
769
+ errors.push(
770
+ ...legacyKeys.filter(({ section, key }) => hasOwnKey(config[section], key)).map(({ message }) => message)
771
+ );
772
+ return errors;
784
773
  }
785
774
  function collectCommitMessageConfigErrors(config) {
786
775
  const section = config.commit_messages;
@@ -823,12 +812,7 @@ function validateResolvedConfig(config) {
823
812
  return shapeErrors;
824
813
  }
825
814
  const resolvedConfig = config;
826
- const skillIds = /* @__PURE__ */ new Set();
827
815
  const skillErrors = [];
828
- for (const skill of resolvedConfig.skills ?? []) {
829
- if (skillIds.has(skill.id)) skillErrors.push(`Duplicate skill id '${skill.id}' at skills`);
830
- skillIds.add(skill.id);
831
- }
832
816
  const repositoryIds = /* @__PURE__ */ new Set();
833
817
  for (const repository of resolvedConfig.skill_repositories ?? []) {
834
818
  if (repositoryIds.has(repository.id)) {
@@ -892,7 +876,6 @@ function sanitizeConfigForLogging(value, path2 = []) {
892
876
  }
893
877
  function getDefaultConfig() {
894
878
  return {
895
- skills: [],
896
879
  skill_repositories: [],
897
880
  commit_messages: {
898
881
  templates: {},
@@ -3974,6 +3957,19 @@ function referencedSkillIds(markdown, availableSkillIds) {
3974
3957
  return explicitSkillReferenceIds(markdown).filter((id) => availableSkillIds.has(id));
3975
3958
  }
3976
3959
 
3960
+ // src/skills/skill-frontmatter.ts
3961
+ import { parseFrontmatter } from "@earendil-works/pi-coding-agent";
3962
+ function skillFrontmatter(markdown) {
3963
+ try {
3964
+ return parseFrontmatter(markdown).frontmatter;
3965
+ } catch {
3966
+ return {};
3967
+ }
3968
+ }
3969
+ function isSkillModelInvocable(markdown) {
3970
+ return skillFrontmatter(markdown)["disable-model-invocation"] !== true;
3971
+ }
3972
+
3977
3973
  // src/db/skill-repo.ts
3978
3974
  function revisionForBundle(db, item, timestamp) {
3979
3975
  const existing = db.select({ id: skillRevisions.id }).from(skillRevisions).where(
@@ -4039,8 +4035,14 @@ function candidateSummaries(db) {
4039
4035
  sourcePath: skillCatalogEntries.sourcePath,
4040
4036
  sourceRevision: skillCatalogEntries.sourceRevision,
4041
4037
  bundleDigest: skillCatalogEntries.bundleDigest,
4038
+ bundleBytes: skillCatalogEntries.bundleBytes,
4042
4039
  available: skillCatalogEntries.available
4043
- }).from(skillCatalogEntries).all();
4040
+ }).from(skillCatalogEntries).all().map((candidate2) => ({
4041
+ ...candidate2,
4042
+ modelInvocable: isSkillModelInvocable(
4043
+ skillMarkdown(candidate2.skillId, candidate2.bundleBytes, candidate2.bundleDigest)
4044
+ )
4045
+ }));
4044
4046
  }
4045
4047
  function processUsage(db, skillId) {
4046
4048
  return db.select({
@@ -4092,13 +4094,13 @@ function recordRevisionDependencies(db, revisionId, markdown) {
4092
4094
  db.insert(skillRevisionDependencies).values({ skillRevisionId: revisionId, dependencySkillId, position }).run();
4093
4095
  }
4094
4096
  }
4095
- function activateSkill(db, item, registrationKind, timestamp, markdown = skillMarkdown(item.skillId, item.bundle.bytes, item.bundle.digest)) {
4097
+ function activateSkill(db, item, timestamp, markdown = skillMarkdown(item.skillId, item.bundle.bytes, item.bundle.digest)) {
4096
4098
  db.insert(skills).values({
4097
4099
  id: item.skillId,
4098
4100
  label: item.label,
4099
4101
  description: item.description,
4100
4102
  activeRevisionId: null,
4101
- registrationKind,
4103
+ registrationKind: "catalog",
4102
4104
  createdAt: timestamp,
4103
4105
  updatedAt: timestamp
4104
4106
  }).onConflictDoNothing().run();
@@ -4108,7 +4110,7 @@ function activateSkill(db, item, registrationKind, timestamp, markdown = skillMa
4108
4110
  label: item.label,
4109
4111
  description: item.description,
4110
4112
  activeRevisionId: revisionId,
4111
- registrationKind,
4113
+ registrationKind: "catalog",
4112
4114
  updatedAt: timestamp
4113
4115
  }).where(eq18(skills.id, item.skillId)).run();
4114
4116
  return revisionId;
@@ -4122,15 +4124,12 @@ function catalogView(db) {
4122
4124
  description: skills.description,
4123
4125
  activeRevisionId: skillRevisions.id,
4124
4126
  activeSourceRevision: skillRevisions.sourceRevision,
4125
- activeDigest: skillRevisions.bundleDigest,
4126
- registrationKind: skills.registrationKind
4127
- }).from(skills).innerJoin(skillRevisions, eq18(skills.activeRevisionId, skillRevisions.id)).orderBy(asc12(skills.label), asc12(skills.id)).all();
4127
+ activeDigest: skillRevisions.bundleDigest
4128
+ }).from(skills).innerJoin(skillRevisions, eq18(skills.activeRevisionId, skillRevisions.id)).where(eq18(skills.registrationKind, "catalog")).orderBy(asc12(skills.label), asc12(skills.id)).all();
4128
4129
  const installedById = new Map(installedRows.map((row) => [row.id, row]));
4129
4130
  const availableSkills = candidates.map((candidate2) => {
4130
4131
  const active = installedById.get(candidate2.skillId);
4131
- const registered = Boolean(
4132
- active?.registrationKind === "catalog" && active.activeDigest === candidate2.bundleDigest
4133
- );
4132
+ const registered = active?.activeDigest === candidate2.bundleDigest;
4134
4133
  return {
4135
4134
  repositoryId: candidate2.repositoryId,
4136
4135
  id: candidate2.skillId,
@@ -4139,11 +4138,9 @@ function catalogView(db) {
4139
4138
  sourcePath: candidate2.sourcePath,
4140
4139
  sourceRevision: candidate2.sourceRevision,
4141
4140
  registered,
4142
- updateAvailable: Boolean(
4143
- candidate2.available && active?.registrationKind === "catalog" && !registered
4144
- ),
4145
- conflict: candidate2.available && active?.registrationKind === "configuration",
4141
+ updateAvailable: Boolean(candidate2.available && active && !registered),
4146
4142
  stale: !candidate2.available,
4143
+ modelInvocable: candidate2.modelInvocable,
4147
4144
  usage: usage.get(candidate2.skillId) ?? emptyUsage()
4148
4145
  };
4149
4146
  });
@@ -4159,9 +4156,9 @@ function catalogView(db) {
4159
4156
  description: skill.description,
4160
4157
  activeRevisionId: skill.activeRevisionId,
4161
4158
  activeSourceRevision: skill.activeSourceRevision,
4162
- registrationKind: skill.registrationKind,
4163
4159
  sourceRepositoryId: matching.length === 1 ? matching[0]?.repositoryId ?? null : activeSource.length === 1 ? activeSource[0]?.repositoryId ?? null : null,
4164
- updateAvailable: skill.registrationKind === "catalog" && available.length === 1 && available[0]?.bundleDigest !== skill.activeDigest,
4160
+ updateAvailable: available.length === 1 && available[0]?.bundleDigest !== skill.activeDigest,
4161
+ modelInvocable: activeSource[0]?.modelInvocable ?? true,
4165
4162
  usage: usage.get(skill.id) ?? emptyUsage()
4166
4163
  };
4167
4164
  });
@@ -4197,15 +4194,10 @@ function createSkillRepo(db) {
4197
4194
  for (const id of ids) add(id);
4198
4195
  return [...resolved.values()];
4199
4196
  },
4200
- reconcile(imported) {
4201
- const timestamp = now();
4202
- const configured = new Set(imported.map((item) => item.skillId));
4203
- for (const old of db.select().from(skills).all()) {
4204
- if (old.registrationKind === "configuration" && !configured.has(old.id)) {
4205
- db.update(skills).set({ activeRevisionId: null, updatedAt: timestamp }).where(eq18(skills.id, old.id)).run();
4206
- }
4207
- }
4208
- for (const item of imported) activateSkill(db, item, "configuration", timestamp);
4197
+ deactivateConfiguredSkills() {
4198
+ db.update(skills).set({ activeRevisionId: null, updatedAt: now() }).where(
4199
+ and14(eq18(skills.registrationKind, "configuration"), isNotNull(skills.activeRevisionId))
4200
+ ).run();
4209
4201
  },
4210
4202
  backfillDependencies() {
4211
4203
  for (const revision of db.select().from(skillRevisions).all()) {
@@ -4235,7 +4227,7 @@ function createSkillRepo(db) {
4235
4227
  label: item.label,
4236
4228
  description: item.description,
4237
4229
  sourcePath: item.sourcePath,
4238
- sourceRevision: item.sourceRevision ?? "",
4230
+ sourceRevision: item.sourceRevision,
4239
4231
  bundleDigest: item.bundle.digest,
4240
4232
  bundleBytes: Buffer.from(item.bundle.bytes),
4241
4233
  discoveredAt: timestamp,
@@ -4269,10 +4261,6 @@ function createSkillRepo(db) {
4269
4261
  `Remote skill '${requestedRepositoryId ? `${requestedRepositoryId}/` : ""}${id}' is no longer available`
4270
4262
  );
4271
4263
  }
4272
- const current = db.select().from(skills).where(eq18(skills.id, id)).get();
4273
- if (current?.activeRevisionId && current.registrationKind === "configuration") {
4274
- throw new Error(`Skill '${id}' is managed by configuration`);
4275
- }
4276
4264
  visiting.add(id);
4277
4265
  const markdown = skillMarkdown(id, candidate2.bundleBytes, candidate2.bundleDigest);
4278
4266
  for (const dependencyId of referencedSkillIds(markdown, availableIds)) {
@@ -4288,7 +4276,6 @@ function createSkillRepo(db) {
4288
4276
  bundle: { digest: candidate2.bundleDigest, bytes: candidate2.bundleBytes },
4289
4277
  sourceRevision: candidate2.sourceRevision
4290
4278
  },
4291
- "catalog",
4292
4279
  timestamp,
4293
4280
  markdown
4294
4281
  );
@@ -4302,7 +4289,7 @@ function createSkillRepo(db) {
4302
4289
  },
4303
4290
  remove(skillId) {
4304
4291
  const current = db.select().from(skills).where(eq18(skills.id, skillId)).get();
4305
- if (!current?.activeRevisionId || current.registrationKind !== "catalog") return false;
4292
+ if (!current?.activeRevisionId) return false;
4306
4293
  db.update(skills).set({ activeRevisionId: null, updatedAt: now() }).where(eq18(skills.id, skillId)).run();
4307
4294
  return true;
4308
4295
  },
@@ -4549,7 +4536,9 @@ function createAllRepos(db, options = {}) {
4549
4536
  // src/process-action-registry.ts
4550
4537
  import {
4551
4538
  createServerProcessBuilder,
4539
+ getExternalActionArmingId,
4552
4540
  getExternalSourceTransitionId,
4541
+ isAutomaticTurnDefinition,
4553
4542
  isExternalTurnDefinition,
4554
4543
  isHumanTurnDefinition,
4555
4544
  resolveHumanTurnView,
@@ -4566,15 +4555,6 @@ function resolveProcessContextData(processDef, process2) {
4566
4555
  function getTurnReviewSemanticRef(turnDef) {
4567
4556
  return "reviewSemanticRef" in turnDef ? turnDef.reviewSemanticRef ?? null : null;
4568
4557
  }
4569
- function getTurnReviewSubject(turnDef) {
4570
- if (isHumanTurnDefinition(turnDef)) {
4571
- return turnDef.reviewSubject ?? null;
4572
- }
4573
- if (isExternalTurnDefinition(turnDef)) {
4574
- return turnDef.reviewSubject ?? null;
4575
- }
4576
- return turnDef.reviewSubject ?? null;
4577
- }
4578
4558
  function getProcessTurnBinding(processDef, turnId) {
4579
4559
  return processDef?.turns.get(turnId);
4580
4560
  }
@@ -4586,18 +4566,9 @@ function resolveCurrentTurnForProcess(processDef, process2) {
4586
4566
  if (!selectedTurn) {
4587
4567
  return null;
4588
4568
  }
4589
- const selectedTurnReviewSubject = getTurnReviewSubject(selectedTurn);
4590
- if (!selectedTurnReviewSubject) {
4591
- return { turnId: process2.selectedTurnId, turnDef: selectedTurn };
4592
- }
4593
- const { state } = resolveProcessContextData(processDef, process2);
4594
- const currentReviewSubject = state.reviewSubject ?? null;
4595
- if (!currentReviewSubject || currentReviewSubject.kind === selectedTurnReviewSubject.kind) {
4596
- return { turnId: process2.selectedTurnId, turnDef: selectedTurn };
4597
- }
4598
- return null;
4569
+ return { turnId: process2.selectedTurnId, turnDef: selectedTurn };
4599
4570
  }
4600
- function listExternalTriggers(turnId, turnDef) {
4571
+ function listExternalTriggers(turnId, turnDef, ctx) {
4601
4572
  if (isHumanTurnDefinition(turnDef)) {
4602
4573
  const view = resolveHumanTurnView({ turnId, turn: turnDef });
4603
4574
  return [
@@ -4607,7 +4578,10 @@ function listExternalTriggers(turnId, turnDef) {
4607
4578
  label: trigger.label,
4608
4579
  description: trigger.description
4609
4580
  })),
4610
- ...view.externalActions.map((action) => ({
4581
+ ...view.externalActions.filter((action) => {
4582
+ const definition = turnDef.externalActions?.[action.externalActionId];
4583
+ return !definition?.when || definition.when(ctx);
4584
+ }).map((action) => ({
4611
4585
  id: action.id,
4612
4586
  externalActionId: action.externalActionId,
4613
4587
  kind: action.sourceKind,
@@ -4625,6 +4599,16 @@ function listExternalTriggers(turnId, turnDef) {
4625
4599
  description: transition.source.description ?? null
4626
4600
  }));
4627
4601
  }
4602
+ if (isAutomaticTurnDefinition(turnDef) && ctx.process.lifecycleStatus === "waiting") {
4603
+ return Object.entries(turnDef.externalActions ?? {}).filter(([, action]) => !action.when || action.when(ctx)).map(([externalActionId, action]) => ({
4604
+ id: getExternalActionArmingId({ turnId, externalActionId }),
4605
+ externalActionId,
4606
+ kind: action.source.kind,
4607
+ sourceKind: action.source.kind,
4608
+ label: action.label ?? action.source.label ?? null,
4609
+ description: action.description ?? action.source.description ?? null
4610
+ }));
4611
+ }
4628
4612
  return [];
4629
4613
  }
4630
4614
  function resolveCurrentVisibleActionForProcess(processDef, process2, actionId) {
@@ -4649,17 +4633,23 @@ function isTurnScopedActionForProcess(processDef, actionId) {
4649
4633
  }
4650
4634
  return false;
4651
4635
  }
4652
- function buildSelectedTurnSummaryForProcess(processDef, process2) {
4636
+ function buildSelectedTurnSummaryForProcess(processDef, process2, projects = []) {
4653
4637
  const currentTurn = resolveCurrentTurnForProcess(processDef, process2);
4654
4638
  if (!currentTurn) {
4655
4639
  return null;
4656
4640
  }
4641
+ const { params, state } = resolveProcessContextData(processDef, process2);
4657
4642
  return {
4658
4643
  turnId: currentTurn.turnId,
4659
4644
  kind: currentTurn.turnDef.kind,
4660
4645
  description: currentTurn.turnDef.description,
4661
4646
  commentary: isHumanTurnDefinition(currentTurn.turnDef) ? currentTurn.turnDef.commentary ?? null : null,
4662
- externalTriggers: listExternalTriggers(currentTurn.turnId, currentTurn.turnDef)
4647
+ externalTriggers: listExternalTriggers(currentTurn.turnId, currentTurn.turnDef, {
4648
+ process: process2,
4649
+ projects,
4650
+ params,
4651
+ state
4652
+ })
4663
4653
  };
4664
4654
  }
4665
4655
  function resolvePreviewDefinitionForProcess(processDef, process2, action, actionId) {
@@ -4772,7 +4762,6 @@ function resolveTurnScopedActionForProcess(processDef, process2, actionId, sourc
4772
4762
  kind: "ui_human_action",
4773
4763
  turnId: currentTurn.turnId,
4774
4764
  turnType: "human",
4775
- reviewSubject: currentTurn.turnDef.reviewSubject ?? null,
4776
4765
  semanticEntryRefKey: getTurnReviewSemanticRef(currentTurn.turnDef),
4777
4766
  acceptanceState: turnAction.acceptanceState
4778
4767
  };
@@ -4789,7 +4778,6 @@ function resolveTurnScopedActionForProcess(processDef, process2, actionId, sourc
4789
4778
  kind: "external_human_trigger",
4790
4779
  turnId: currentTurn.turnId,
4791
4780
  turnType: "external",
4792
- reviewSubject: currentTurn.turnDef.reviewSubject ?? null,
4793
4781
  semanticEntryRefKey: getTurnReviewSemanticRef(currentTurn.turnDef),
4794
4782
  acceptanceState: matchingVisibleAction.acceptanceState,
4795
4783
  externalTrigger: {
@@ -4850,8 +4838,8 @@ function buildProcessActionRegistry(catalog) {
4850
4838
  }
4851
4839
  return visible;
4852
4840
  },
4853
- getSelectedTurnSummary(processId, process2) {
4854
- return buildSelectedTurnSummaryForProcess(processDefs.get(processId), process2);
4841
+ getSelectedTurnSummary(processId, process2, projects) {
4842
+ return buildSelectedTurnSummaryForProcess(processDefs.get(processId), process2, projects);
4855
4843
  },
4856
4844
  getServerDefinition(processId) {
4857
4845
  return serverDefs.get(processId);
@@ -4978,9 +4966,9 @@ function extractToolResultValue(message) {
4978
4966
  if ("details" in message && message.details !== void 0) {
4979
4967
  return message.details;
4980
4968
  }
4981
- const text2 = extractPiSessionMessageText(message.content).trim();
4982
- if (text2 !== "") {
4983
- return text2;
4969
+ const text3 = extractPiSessionMessageText(message.content).trim();
4970
+ if (text3 !== "") {
4971
+ return text3;
4984
4972
  }
4985
4973
  return message.content ?? null;
4986
4974
  }
@@ -5403,7 +5391,6 @@ import {
5403
5391
  CONTINUE_PROMPT_METADATA_KEY,
5404
5392
  DEFAULT_CONTINUE_PROMPT,
5405
5393
  isProcessTurnType,
5406
- isWorkerOwnedTurnType,
5407
5394
  normalizeContinuePrompt,
5408
5395
  readFailedTurnRecoveryContext
5409
5396
  } from "@leitwerk-dev/domain";
@@ -5740,7 +5727,11 @@ function getSelectedTurnSummaryForProcess(deps, process2) {
5740
5727
  if (!deps.processActionRegistry) {
5741
5728
  return null;
5742
5729
  }
5743
- return deps.processActionRegistry.getSelectedTurnSummary(process2.processId, process2);
5730
+ return deps.processActionRegistry.getSelectedTurnSummary(
5731
+ process2.processId,
5732
+ process2,
5733
+ deps.projects.listByInstance(process2.id)
5734
+ );
5744
5735
  }
5745
5736
  function getSelectedTurnDescription(deps, process2) {
5746
5737
  const selectedTurnSummary = getSelectedTurnSummaryForProcess(deps, process2);
@@ -6872,6 +6863,100 @@ var ProcessPrimaryPathAssembler = class {
6872
6863
  }
6873
6864
  };
6874
6865
 
6866
+ // src/turn-progress.ts
6867
+ import { createDurableWsFrame } from "@leitwerk-dev/protocol";
6868
+ var STEP_STATUSES = /* @__PURE__ */ new Set([
6869
+ "incomplete",
6870
+ "in_progress",
6871
+ "completed",
6872
+ "failed"
6873
+ ]);
6874
+ var LINK_KINDS = /* @__PURE__ */ new Set(["pull_request", "merge_request", "commit", "pipeline", "other"]);
6875
+ function text2(value, max2) {
6876
+ return typeof value === "string" ? value.trim().slice(0, max2) : "";
6877
+ }
6878
+ function safeExternalUrl(value) {
6879
+ const candidate2 = text2(value, 2e3);
6880
+ try {
6881
+ const url = new URL(candidate2);
6882
+ return (url.protocol === "https:" || url.protocol === "http:") && !url.username && !url.password ? url.toString() : "";
6883
+ } catch {
6884
+ return "";
6885
+ }
6886
+ }
6887
+ function normalizeTurnProgressReport(value) {
6888
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
6889
+ const raw = value;
6890
+ const title = text2(raw.title, 160);
6891
+ if (!title || !Array.isArray(raw.steps) || raw.steps.length > 50) return null;
6892
+ const ids = /* @__PURE__ */ new Set();
6893
+ const steps = raw.steps.flatMap((value2) => {
6894
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return [];
6895
+ const step = value2;
6896
+ const id = text2(step.id, 80);
6897
+ const label = text2(step.label, 240);
6898
+ const status = step.status;
6899
+ const detail = text2(step.detail, 1e3);
6900
+ if (!id || ids.has(id) || !label || !STEP_STATUSES.has(status)) {
6901
+ return [];
6902
+ }
6903
+ ids.add(id);
6904
+ return [
6905
+ {
6906
+ id,
6907
+ label,
6908
+ status,
6909
+ ...detail ? { detail } : {}
6910
+ }
6911
+ ];
6912
+ });
6913
+ if (steps.length !== raw.steps.length || steps.length === 0) return null;
6914
+ const linkIds = /* @__PURE__ */ new Set();
6915
+ const rawLinks = raw.links === void 0 ? [] : raw.links;
6916
+ if (!Array.isArray(rawLinks) || rawLinks.length > 20) return null;
6917
+ const links = rawLinks.flatMap((value2) => {
6918
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return [];
6919
+ const link = value2;
6920
+ const id = text2(link.id, 80);
6921
+ const label = text2(link.label, 240);
6922
+ const url = safeExternalUrl(link.url);
6923
+ const kind = text2(link.kind, 40);
6924
+ if (!id || linkIds.has(id) || !label || !url) return [];
6925
+ if (kind && !LINK_KINDS.has(kind)) return [];
6926
+ linkIds.add(id);
6927
+ return [
6928
+ {
6929
+ id,
6930
+ label,
6931
+ url,
6932
+ ...kind ? { kind } : {}
6933
+ }
6934
+ ];
6935
+ });
6936
+ if (links.length !== rawLinks.length) return null;
6937
+ return { title, steps, ...links.length > 0 ? { links } : {} };
6938
+ }
6939
+ function recordTurnProgress(deps, input) {
6940
+ const process2 = deps.processes.getById(input.instanceId);
6941
+ const turnRecord = deps.turnRecords.getById(input.turnRecordId);
6942
+ const report = normalizeTurnProgressReport(input.report);
6943
+ if (!process2 || !turnRecord || turnRecord.instanceId !== input.instanceId || turnRecord.status !== "running" || process2.selectedTurnId !== turnRecord.turnId || !report)
6944
+ return false;
6945
+ deps.events.create({
6946
+ instanceId: input.instanceId,
6947
+ eventType: "turn.progress",
6948
+ data: { turnRecordId: input.turnRecordId, report }
6949
+ });
6950
+ deps.broadcaster.broadcast(
6951
+ createDurableWsFrame({
6952
+ type: "process.event",
6953
+ instanceId: input.instanceId,
6954
+ payload: { eventType: "turn_progress", level: "info", message: "Turn progress updated" }
6955
+ })
6956
+ );
6957
+ return true;
6958
+ }
6959
+
6875
6960
  // src/process-ui-snapshot-presenter.ts
6876
6961
  var COMPACT_DETAIL_EVENT_TYPES = [
6877
6962
  "turn_outcome_recorded",
@@ -6893,9 +6978,10 @@ function sortEventsAscending(events) {
6893
6978
  });
6894
6979
  }
6895
6980
  function compactDetailEvents(deps, instanceId) {
6896
- return sortEventsAscending(
6897
- deps.events.listByInstanceEventTypes(instanceId, COMPACT_DETAIL_EVENT_TYPES, 1e3)
6898
- );
6981
+ return sortEventsAscending([
6982
+ ...deps.events.listByInstanceEventTypes(instanceId, COMPACT_DETAIL_EVENT_TYPES, 1e3),
6983
+ ...deps.events.listByInstanceEventTypes(instanceId, ["turn.progress"], 1e4)
6984
+ ]);
6899
6985
  }
6900
6986
  function compactPrimaryPathSnapshot(snapshot) {
6901
6987
  return {
@@ -7060,6 +7146,16 @@ function annotationOutput(annotation) {
7060
7146
  ${value}` : "";
7061
7147
  }).filter(Boolean).join("\n\n");
7062
7148
  }
7149
+ function buildTurnProgressIndex(events) {
7150
+ const index2 = /* @__PURE__ */ new Map();
7151
+ for (const event of events) {
7152
+ if (event.eventType !== "turn.progress") continue;
7153
+ const turnRecordId = stringValue(event.data.turnRecordId);
7154
+ const report = normalizeTurnProgressReport(event.data.report);
7155
+ if (turnRecordId && report) index2.set(turnRecordId, report);
7156
+ }
7157
+ return index2;
7158
+ }
7063
7159
  function actionSourceFromAnnotation(annotation) {
7064
7160
  const source = annotation.payload.actionSource;
7065
7161
  return source === "ui" || source === "external" || source === "scheduled" ? source : null;
@@ -7130,11 +7226,13 @@ function createCompletedTurnRecord(args) {
7130
7226
  status: "completed",
7131
7227
  modelProfileId: args.turnRecord.modelProfileId ?? null,
7132
7228
  actionSource: args.actionSource,
7229
+ progress: args.progress,
7133
7230
  ...durableTurnLineage(args.turnRecord)
7134
7231
  };
7135
7232
  }
7136
7233
  function presentProcessTimelineTurns(input) {
7137
7234
  const outcomeEventsByTurnRecordId = createTurnOutcomeEventMap(input.events);
7235
+ const progressByTurnRecordId = buildTurnProgressIndex(input.events);
7138
7236
  const milestoneAnnotationsByTurnRecordId = createTurnAnnotationMap(
7139
7237
  input.turnAnnotations,
7140
7238
  "turn_milestone"
@@ -7178,6 +7276,7 @@ function presentProcessTimelineTurns(input) {
7178
7276
  status: "in_progress",
7179
7277
  modelProfileId: turnRecord.modelProfileId ?? null,
7180
7278
  actionSource: actionSourceByTurnRecordId.get(turnRecord.id) ?? null,
7279
+ progress: progressByTurnRecordId.get(turnRecord.id) ?? null,
7181
7280
  ...durableTurnLineage(turnRecord)
7182
7281
  });
7183
7282
  continue;
@@ -7233,7 +7332,8 @@ function presentProcessTimelineTurns(input) {
7233
7332
  ...presentation,
7234
7333
  turnRecord,
7235
7334
  turnResultMarkdown,
7236
- actionSource: actionSourceByTurnRecordId.get(turnRecord.id) ?? null
7335
+ actionSource: actionSourceByTurnRecordId.get(turnRecord.id) ?? null,
7336
+ progress: progressByTurnRecordId.get(turnRecord.id) ?? null
7237
7337
  })
7238
7338
  );
7239
7339
  }
@@ -7266,7 +7366,8 @@ function presentProcessTimelineTurns(input) {
7266
7366
  parentTurnRecordId: null,
7267
7367
  startedAt: input.process.updatedAt,
7268
7368
  endedAt: null,
7269
- actionSource: null
7369
+ actionSource: null,
7370
+ progress: null
7270
7371
  });
7271
7372
  }
7272
7373
  return turns;
@@ -7420,7 +7521,7 @@ function buildCurrentTurnRecovery(input) {
7420
7521
  const failedTurnRecord = input.turnRecords.find(
7421
7522
  (turnRecord) => turnRecord.id === failedTurnRecordId
7422
7523
  );
7423
- if (!failedTurnRecord || failedTurnRecord.status !== "failed" || !isWorkerOwnedTurnType(failedTurnRecord.turnType) || failedTurnRecord.turnId !== input.process.selectedTurnId) {
7524
+ if (!failedTurnRecord || failedTurnRecord.status !== "failed" || failedTurnRecord.turnId !== input.process.selectedTurnId) {
7424
7525
  return null;
7425
7526
  }
7426
7527
  const recoveryContext = readFailedTurnRecoveryContext(
@@ -7441,6 +7542,7 @@ function buildCurrentTurnRecovery(input) {
7441
7542
  technicalDetail: presentation.technicalDetail,
7442
7543
  defaultContinuePrompt: resolveTurnContinuationUserPrompt(input.piEntries, failedTurnRecord, continuationBounds) ?? normalizeContinuePrompt(input.process.metadata?.[CONTINUE_PROMPT_METADATA_KEY]) ?? recoveryContext?.suggestedContinuePrompt ?? DEFAULT_CONTINUE_PROMPT,
7443
7544
  canContinue,
7545
+ supportsModelOverride: failedTurnRecord.turnType === "llm",
7444
7546
  defaultModelProfileId: acceptedLlmStart?.model.profileId ?? failedTurnRecord.modelProfileId,
7445
7547
  providerOptions: acceptedLlmStart ? { ...acceptedLlmStart.providerOptions } : {}
7446
7548
  };
@@ -7685,7 +7787,7 @@ var ProcessUiSnapshotAssembler = class {
7685
7787
 
7686
7788
  // src/ws/broadcast.ts
7687
7789
  import {
7688
- createDurableWsFrame,
7790
+ createDurableWsFrame as createDurableWsFrame2,
7689
7791
  createEphemeralWsFrame as createEphemeralWsFrame2
7690
7792
  } from "@leitwerk-dev/protocol";
7691
7793
  function createBroadcaster() {
@@ -7703,7 +7805,7 @@ function createBroadcaster() {
7703
7805
  }
7704
7806
  }
7705
7807
  function sendDurable(type, payload, instanceId) {
7706
- const frame = createDurableWsFrame({
7808
+ const frame = createDurableWsFrame2({
7707
7809
  type,
7708
7810
  payload,
7709
7811
  instanceId
@@ -8615,6 +8717,7 @@ export {
8615
8717
  createProcessTurnAnnotationRepo,
8616
8718
  createProcessTurnRecordRepo,
8617
8719
  createProviderCredentialRepo,
8720
+ skillFrontmatter,
8618
8721
  createSkillRepo,
8619
8722
  createTurnStartRecordRepo,
8620
8723
  createWorkerLeaseRepo,
@@ -8642,6 +8745,7 @@ export {
8642
8745
  listVisibleActionsForProcess,
8643
8746
  getSelectedTurnSummaryForProcess,
8644
8747
  broadcastProcessAttentionToast,
8748
+ recordTurnProgress,
8645
8749
  createProcessOperationCoordinator,
8646
8750
  authenticateRequest,
8647
8751
  requireApiActor,
@@ -8682,4 +8786,4 @@ export {
8682
8786
  ProcessUiSnapshotAssembler,
8683
8787
  createBroadcaster
8684
8788
  };
8685
- //# sourceMappingURL=chunk-ES5RBLAT.js.map
8789
+ //# sourceMappingURL=chunk-2ESDXLNE.js.map