@leitwerk-dev/server 0.1.7 → 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.
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +24 -15
- package/dist/app.js.map +1 -1
- package/dist/{chunk-GIWHTJSL.js → chunk-2ESDXLNE.js} +228 -101
- package/dist/chunk-2ESDXLNE.js.map +1 -0
- package/dist/{chunk-OO6VH4FX.js → chunk-DFHOPJRZ.js} +405 -259
- package/dist/chunk-DFHOPJRZ.js.map +1 -0
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-loader.js +14 -25
- package/dist/config/config-loader.js.map +1 -1
- package/dist/config/config-types.d.ts +5 -17
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/db/skill-repo.d.ts +2 -2
- package/dist/db/skill-repo.d.ts.map +1 -1
- package/dist/db/skill-repo.js +24 -32
- package/dist/db/skill-repo.js.map +1 -1
- package/dist/external-source-service.d.ts.map +1 -1
- package/dist/external-source-service.js +5 -2
- package/dist/external-source-service.js.map +1 -1
- package/dist/future-execution/execution.d.ts +1 -1
- package/dist/future-execution/execution.d.ts.map +1 -1
- package/dist/future-execution/execution.js +1 -13
- package/dist/future-execution/execution.js.map +1 -1
- package/dist/integration-tool-registry.js +1 -1
- package/dist/integration-tool-registry.js.map +1 -1
- package/dist/model-providers/builtin-server-adapter.d.ts.map +1 -1
- package/dist/model-providers/builtin-server-adapter.js +10 -2
- package/dist/model-providers/builtin-server-adapter.js.map +1 -1
- package/dist/process-action-registry.d.ts +2 -4
- package/dist/process-action-registry.d.ts.map +1 -1
- package/dist/process-action-registry.js +31 -28
- package/dist/process-action-registry.js.map +1 -1
- package/dist/process-engine/engine.d.ts.map +1 -1
- package/dist/process-engine/engine.js +4 -4
- package/dist/process-engine/engine.js.map +1 -1
- package/dist/process-engine/operation.d.ts +4 -0
- package/dist/process-engine/operation.d.ts.map +1 -1
- package/dist/process-engine/ops/execute-action.d.ts.map +1 -1
- package/dist/process-engine/ops/execute-action.js +0 -3
- package/dist/process-engine/ops/execute-action.js.map +1 -1
- package/dist/process-engine/ops/worker-failure.d.ts +2 -0
- package/dist/process-engine/ops/worker-failure.d.ts.map +1 -1
- package/dist/process-engine/ops/worker-failure.js +2 -0
- package/dist/process-engine/ops/worker-failure.js.map +1 -1
- package/dist/process-engine/runner.d.ts +2 -2
- package/dist/process-engine/runner.d.ts.map +1 -1
- package/dist/process-engine/runner.js +13 -1
- package/dist/process-engine/runner.js.map +1 -1
- package/dist/process-engine/types.d.ts +10 -4
- package/dist/process-engine/types.d.ts.map +1 -1
- package/dist/process-engine/writes/build-server-transition-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-server-transition-writes.js +2 -8
- package/dist/process-engine/writes/build-server-transition-writes.js.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-outcome-writes.js +1 -2
- package/dist/process-engine/writes/build-turn-outcome-writes.js.map +1 -1
- package/dist/process-engine/writes/build-turn-selection-writes.d.ts +1 -2
- package/dist/process-engine/writes/build-turn-selection-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-turn-selection-writes.js +1 -57
- package/dist/process-engine/writes/build-turn-selection-writes.js.map +1 -1
- package/dist/process-engine/writes/build-worker-failure-writes.d.ts +3 -1
- package/dist/process-engine/writes/build-worker-failure-writes.d.ts.map +1 -1
- package/dist/process-engine/writes/build-worker-failure-writes.js +2 -1
- package/dist/process-engine/writes/build-worker-failure-writes.js.map +1 -1
- package/dist/process-launch-executor.d.ts +6 -4
- package/dist/process-launch-executor.d.ts.map +1 -1
- package/dist/process-launch-executor.js +16 -1
- package/dist/process-launch-executor.js.map +1 -1
- package/dist/process-launch-plan.d.ts.map +1 -1
- package/dist/process-launch-plan.js +1 -0
- package/dist/process-launch-plan.js.map +1 -1
- package/dist/process-operator-attention.d.ts +1 -1
- package/dist/process-operator-attention.d.ts.map +1 -1
- package/dist/process-operator-attention.js +1 -1
- package/dist/process-operator-attention.js.map +1 -1
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.js +24 -3
- package/dist/process-ui-snapshot-presenter.js.map +1 -1
- package/dist/process-watcher-registry.d.ts.map +1 -1
- package/dist/process-watcher-registry.js +13 -5
- package/dist/process-watcher-registry.js.map +1 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +1 -2
- package/dist/routes/skills.js.map +1 -1
- package/dist/server-automatic-turn-drainer.d.ts.map +1 -1
- package/dist/server-automatic-turn-drainer.js +15 -0
- package/dist/server-automatic-turn-drainer.js.map +1 -1
- package/dist/server-bootstrap/build-host-capabilities.d.ts.map +1 -1
- package/dist/server-bootstrap/build-host-capabilities.js +1 -0
- package/dist/server-bootstrap/build-host-capabilities.js.map +1 -1
- package/dist/skills/skill-frontmatter.d.ts +4 -0
- package/dist/skills/skill-frontmatter.d.ts.map +1 -0
- package/dist/skills/skill-frontmatter.js +13 -0
- package/dist/skills/skill-frontmatter.js.map +1 -0
- package/dist/skills/source-importer.d.ts +2 -3
- package/dist/skills/source-importer.d.ts.map +1 -1
- package/dist/skills/source-importer.js +16 -62
- package/dist/skills/source-importer.js.map +1 -1
- package/dist/supervisor/accepted-turn-start-replay.d.ts +9 -0
- package/dist/supervisor/accepted-turn-start-replay.d.ts.map +1 -0
- package/dist/supervisor/accepted-turn-start-replay.js +23 -0
- package/dist/supervisor/accepted-turn-start-replay.js.map +1 -0
- package/dist/supervisor/ipc-handler.d.ts +9 -0
- package/dist/supervisor/ipc-handler.d.ts.map +1 -1
- package/dist/supervisor/ipc-handler.js +9 -4
- package/dist/supervisor/ipc-handler.js.map +1 -1
- package/dist/supervisor/stale-heartbeat-watchdog.d.ts +1 -1
- package/dist/supervisor/stale-heartbeat-watchdog.d.ts.map +1 -1
- package/dist/supervisor/stale-heartbeat-watchdog.js +47 -5
- package/dist/supervisor/stale-heartbeat-watchdog.js.map +1 -1
- package/dist/supervisor/worker-event-ingestor.d.ts.map +1 -1
- package/dist/supervisor/worker-event-ingestor.js +16 -0
- package/dist/supervisor/worker-event-ingestor.js.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts +2 -4
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.js +3 -1
- package/dist/supervisor/worker-start-payload-builder.js.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +4 -5
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.js +31 -0
- package/dist/supervisor/worker-supervisor.js.map +1 -1
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts +12 -3
- package/dist/supervisor/worker-turn-ipc-recorder.d.ts.map +1 -1
- package/dist/supervisor/worker-turn-ipc-recorder.js +129 -33
- package/dist/supervisor/worker-turn-ipc-recorder.js.map +1 -1
- package/dist/supervisor/worker-websocket-ipc.d.ts.map +1 -1
- package/dist/supervisor/worker-websocket-ipc.js +20 -10
- package/dist/supervisor/worker-websocket-ipc.js.map +1 -1
- package/dist/test-helpers/fake-worker-supervisor.d.ts.map +1 -1
- package/dist/test-helpers/fake-worker-supervisor.js +4 -0
- package/dist/test-helpers/fake-worker-supervisor.js.map +1 -1
- package/dist/test-helpers/ipc-handler-harness.d.ts.map +1 -1
- package/dist/test-helpers/ipc-handler-harness.js +1 -20
- package/dist/test-helpers/ipc-handler-harness.js.map +1 -1
- package/dist/test-helpers/process-fixtures.d.ts +1 -1
- package/dist/test-helpers/process-fixtures.d.ts.map +1 -1
- package/dist/test-helpers/process-fixtures.js +0 -6
- package/dist/test-helpers/process-fixtures.js.map +1 -1
- package/dist/turn-progress.d.ts +12 -0
- package/dist/turn-progress.d.ts.map +1 -0
- package/dist/turn-progress.js +108 -0
- package/dist/turn-progress.js.map +1 -0
- package/dist/{writes-DUwQe8MD.d.ts → writes-DNXpryd0.d.ts} +68 -36
- package/package.json +10 -10
- package/src/app.ts +25 -15
- package/src/config/config-loader.ts +33 -25
- package/src/config/config-types.ts +6 -13
- package/src/db/skill-repo.ts +26 -36
- package/src/external-source-service.ts +5 -2
- package/src/future-execution/execution.ts +2 -13
- package/src/integration-tool-registry.ts +1 -1
- package/src/model-providers/builtin-server-adapter.ts +10 -2
- package/src/process-action-registry.ts +48 -40
- package/src/process-engine/engine.ts +6 -4
- package/src/process-engine/operation.ts +5 -0
- package/src/process-engine/ops/execute-action.ts +0 -3
- package/src/process-engine/ops/worker-failure.ts +4 -0
- package/src/process-engine/runner.ts +13 -0
- package/src/process-engine/types.ts +14 -2
- package/src/process-engine/writes/build-server-transition-writes.ts +1 -14
- package/src/process-engine/writes/build-turn-outcome-writes.ts +1 -2
- package/src/process-engine/writes/build-turn-selection-writes.ts +0 -75
- package/src/process-engine/writes/build-worker-failure-writes.ts +4 -1
- package/src/process-launch-executor.ts +24 -15
- package/src/process-launch-plan.ts +1 -0
- package/src/process-operator-attention.ts +7 -3
- package/src/process-ui-snapshot-presenter.ts +24 -6
- package/src/process-watcher-registry.ts +15 -5
- package/src/routes/skills.ts +1 -3
- package/src/server-automatic-turn-drainer.ts +20 -1
- package/src/server-bootstrap/build-host-capabilities.ts +1 -0
- package/src/skills/skill-frontmatter.ts +13 -0
- package/src/skills/source-importer.ts +20 -82
- package/src/supervisor/accepted-turn-start-replay.ts +40 -0
- package/src/supervisor/ipc-handler.ts +18 -4
- package/src/supervisor/stale-heartbeat-watchdog.ts +55 -6
- package/src/supervisor/worker-event-ingestor.ts +15 -0
- package/src/supervisor/worker-start-payload-builder.ts +5 -2
- package/src/supervisor/worker-supervisor.ts +43 -4
- package/src/supervisor/worker-turn-ipc-recorder.ts +185 -46
- package/src/supervisor/worker-websocket-ipc.ts +28 -13
- package/src/test-helpers/fake-worker-supervisor.ts +4 -0
- package/src/test-helpers/ipc-handler-harness.ts +1 -22
- package/src/test-helpers/process-fixtures.ts +1 -6
- package/src/turn-progress.ts +114 -0
- package/dist/chunk-GIWHTJSL.js.map +0 -1
- package/dist/chunk-OO6VH4FX.js.map +0 -1
- package/dist/skills/catalog-sync.d.ts +0 -9
- package/dist/skills/catalog-sync.d.ts.map +0 -1
- package/dist/skills/catalog-sync.js +0 -7
- package/dist/skills/catalog-sync.js.map +0 -1
- package/src/skills/catalog-sync.ts +0 -13
package/src/app.ts
CHANGED
|
@@ -101,7 +101,6 @@ import { registerHttp } from "./server-bootstrap/register-http.js";
|
|
|
101
101
|
import { registerWebsocket } from "./server-bootstrap/register-websocket.js";
|
|
102
102
|
import { resolveServerTlsOptions } from "./server-topology.js";
|
|
103
103
|
import { createSkillCatalogService } from "./skills/catalog-service.js";
|
|
104
|
-
import { syncConfiguredSkillCatalog } from "./skills/catalog-sync.js";
|
|
105
104
|
import { createIpcHandler, type IpcHandler } from "./supervisor/ipc-handler.js";
|
|
106
105
|
import { startStaleHeartbeatWatchdog } from "./supervisor/stale-heartbeat-watchdog.js";
|
|
107
106
|
import { createWorkerSupervisor, type WorkerSupervisor } from "./supervisor/worker-supervisor.js";
|
|
@@ -226,6 +225,7 @@ async function createConfiguredWorkerRunnerRuntime(input: {
|
|
|
226
225
|
annotations: pod.annotations,
|
|
227
226
|
nodeSelector: pod.node_selector,
|
|
228
227
|
tolerations: pod.tolerations,
|
|
228
|
+
hostAliases: pod.host_aliases,
|
|
229
229
|
}
|
|
230
230
|
: {}),
|
|
231
231
|
},
|
|
@@ -318,12 +318,10 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
318
318
|
const repos = createAllRepos(db, {
|
|
319
319
|
...(credentialCipher ? { credentialCipher } : {}),
|
|
320
320
|
});
|
|
321
|
-
|
|
322
|
-
skills
|
|
323
|
-
|
|
324
|
-
repos,
|
|
321
|
+
repos.transaction((transactionRepos) => {
|
|
322
|
+
transactionRepos.skills.deactivateConfiguredSkills();
|
|
323
|
+
transactionRepos.skills.backfillDependencies();
|
|
325
324
|
});
|
|
326
|
-
repos.transaction((transactionRepos) => transactionRepos.skills.backfillDependencies());
|
|
327
325
|
const skillCatalog = createSkillCatalogService({
|
|
328
326
|
repositories: config.skill_repositories ?? [],
|
|
329
327
|
repos,
|
|
@@ -738,6 +736,23 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
738
736
|
: undefined,
|
|
739
737
|
},
|
|
740
738
|
{
|
|
739
|
+
onTurnTerminalRecorded(instanceId, workerId, turnRecordId) {
|
|
740
|
+
supervisor?.acknowledgeTurnTerminal(instanceId, workerId, { turnRecordId });
|
|
741
|
+
},
|
|
742
|
+
onTurnTerminalRecordingFailed(input) {
|
|
743
|
+
app.log.error(input, "Worker turn terminal recording failed");
|
|
744
|
+
baseDeps.events.create({
|
|
745
|
+
instanceId: input.instanceId,
|
|
746
|
+
eventType: "worker_terminal_recording_failed",
|
|
747
|
+
data: {
|
|
748
|
+
workerId: input.workerId,
|
|
749
|
+
turnRecordId: input.turnRecordId,
|
|
750
|
+
terminalType: input.terminalType,
|
|
751
|
+
code: input.code,
|
|
752
|
+
message: input.message,
|
|
753
|
+
},
|
|
754
|
+
});
|
|
755
|
+
},
|
|
741
756
|
onWorkerTurnStartAccepted(instanceId, workerId, payload) {
|
|
742
757
|
supervisor?.acceptTurnStart(
|
|
743
758
|
instanceId,
|
|
@@ -785,15 +800,8 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
785
800
|
},
|
|
786
801
|
resolveRepositoryCredentials: (input) => repositoryCredentials.resolveWorkerCredentials(input),
|
|
787
802
|
integrationTools,
|
|
788
|
-
resolveCredential(providerId, options)
|
|
789
|
-
|
|
790
|
-
return credential && credential.revision !== null
|
|
791
|
-
? {
|
|
792
|
-
revision: credential.revision,
|
|
793
|
-
values: credential.values,
|
|
794
|
-
}
|
|
795
|
-
: null;
|
|
796
|
-
},
|
|
803
|
+
resolveCredential: (providerId, options) =>
|
|
804
|
+
modelProviderCredentials.resolve(providerId, options),
|
|
797
805
|
});
|
|
798
806
|
|
|
799
807
|
let staleHeartbeatWatchdog: ReturnType<typeof startStaleHeartbeatWatchdog> | null = null;
|
|
@@ -853,6 +861,8 @@ export async function createAppContext(opts: AppOptions = {}): Promise<AppContex
|
|
|
853
861
|
staleHeartbeatWatchdog = startStaleHeartbeatWatchdog({
|
|
854
862
|
leases: baseDeps.leases,
|
|
855
863
|
processes: baseDeps.processes,
|
|
864
|
+
turnRecords: baseDeps.turnRecords,
|
|
865
|
+
turnStarts: baseDeps.turnStarts,
|
|
856
866
|
ipcHandler,
|
|
857
867
|
supervisor,
|
|
858
868
|
staleHeartbeatTimeout: config.workers.stale_heartbeat_timeout,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { isIP } from "node:net";
|
|
2
3
|
import { resolve } from "node:path";
|
|
3
4
|
import { parseDurationMs } from "@leitwerk-dev/watcher-utils";
|
|
4
5
|
import { createDefu } from "defu";
|
|
@@ -171,20 +172,20 @@ const authConfigSchema = v.looseObject({
|
|
|
171
172
|
});
|
|
172
173
|
|
|
173
174
|
const safeSkillIdSchema = v.pipe(v.string(), v.regex(SAFE_SKILL_ID_PATTERN));
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
175
|
+
const kubernetesHostAliasIpSchema = v.pipe(
|
|
176
|
+
v.string(),
|
|
177
|
+
v.nonEmpty(),
|
|
178
|
+
v.check((value) => isIP(value) !== 0, "Expected an IPv4 or IPv6 address"),
|
|
179
|
+
);
|
|
180
|
+
const kubernetesHostnameSchema = v.pipe(
|
|
181
|
+
v.string(),
|
|
182
|
+
v.nonEmpty(),
|
|
183
|
+
v.maxLength(253),
|
|
184
|
+
v.regex(
|
|
185
|
+
/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u,
|
|
186
|
+
"Expected a lowercase DNS hostname",
|
|
187
|
+
),
|
|
188
|
+
);
|
|
188
189
|
const skillRepositorySchema = v.strictObject({
|
|
189
190
|
id: safeSkillIdSchema,
|
|
190
191
|
label: v.optional(v.pipe(v.string(), v.nonEmpty())),
|
|
@@ -194,7 +195,6 @@ const skillRepositorySchema = v.strictObject({
|
|
|
194
195
|
});
|
|
195
196
|
|
|
196
197
|
const configSchema = v.looseObject({
|
|
197
|
-
skills: v.optional(v.array(skillSchema)),
|
|
198
198
|
skill_repositories: v.optional(v.array(skillRepositorySchema)),
|
|
199
199
|
commit_messages: v.optional(
|
|
200
200
|
v.strictObject({
|
|
@@ -357,6 +357,14 @@ const configSchema = v.looseObject({
|
|
|
357
357
|
node_selector: v.optional(v.record(v.string(), v.string())),
|
|
358
358
|
tolerations: v.optional(v.array(v.unknown())),
|
|
359
359
|
annotations: v.optional(v.record(v.string(), v.string())),
|
|
360
|
+
host_aliases: v.optional(
|
|
361
|
+
v.array(
|
|
362
|
+
v.strictObject({
|
|
363
|
+
ip: kubernetesHostAliasIpSchema,
|
|
364
|
+
hostnames: v.pipe(v.array(kubernetesHostnameSchema), v.nonEmpty()),
|
|
365
|
+
}),
|
|
366
|
+
),
|
|
367
|
+
),
|
|
360
368
|
}),
|
|
361
369
|
),
|
|
362
370
|
image_pull_secrets: v.optional(stringArraySchema),
|
|
@@ -784,6 +792,9 @@ function hasOwnKey(value: unknown, key: string): boolean {
|
|
|
784
792
|
}
|
|
785
793
|
|
|
786
794
|
function collectLegacyConfigKeyErrors(config: Record<string, unknown>): string[] {
|
|
795
|
+
const errors = Object.hasOwn(config, "skills")
|
|
796
|
+
? ["skills was removed; configure Git sources through skill_repositories"]
|
|
797
|
+
: [];
|
|
787
798
|
const legacyKeys = [
|
|
788
799
|
{
|
|
789
800
|
section: "pi",
|
|
@@ -797,9 +808,12 @@ function collectLegacyConfigKeyErrors(config: Record<string, unknown>): string[]
|
|
|
797
808
|
"local_worker.process_volume_root was removed; remove the key because local workers use storage.process_workspaces_dir and storage.tree_files_dir directly",
|
|
798
809
|
},
|
|
799
810
|
] as const;
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
811
|
+
errors.push(
|
|
812
|
+
...legacyKeys
|
|
813
|
+
.filter(({ section, key }) => hasOwnKey(config[section], key))
|
|
814
|
+
.map(({ message }) => message),
|
|
815
|
+
);
|
|
816
|
+
return errors;
|
|
803
817
|
}
|
|
804
818
|
|
|
805
819
|
function collectCommitMessageConfigErrors(config: LeitwerkConfig): string[] {
|
|
@@ -844,12 +858,7 @@ function validateResolvedConfig(config: Record<string, unknown>): string[] {
|
|
|
844
858
|
return shapeErrors;
|
|
845
859
|
}
|
|
846
860
|
const resolvedConfig = config as unknown as LeitwerkConfig;
|
|
847
|
-
const skillIds = new Set<string>();
|
|
848
861
|
const skillErrors: string[] = [];
|
|
849
|
-
for (const skill of resolvedConfig.skills ?? []) {
|
|
850
|
-
if (skillIds.has(skill.id)) skillErrors.push(`Duplicate skill id '${skill.id}' at skills`);
|
|
851
|
-
skillIds.add(skill.id);
|
|
852
|
-
}
|
|
853
862
|
const repositoryIds = new Set<string>();
|
|
854
863
|
for (const repository of resolvedConfig.skill_repositories ?? []) {
|
|
855
864
|
if (repositoryIds.has(repository.id)) {
|
|
@@ -919,7 +928,6 @@ export function sanitizeConfigForLogging(value: unknown, path: readonly string[]
|
|
|
919
928
|
|
|
920
929
|
export function getDefaultConfig(): LeitwerkConfig {
|
|
921
930
|
return {
|
|
922
|
-
skills: [],
|
|
923
931
|
skill_repositories: [],
|
|
924
932
|
commit_messages: {
|
|
925
933
|
templates: {},
|
|
@@ -1016,7 +1024,7 @@ export function getDefaultConfig(): LeitwerkConfig {
|
|
|
1016
1024
|
access_modes: ["ReadWriteOnce"],
|
|
1017
1025
|
mount_path: "/state",
|
|
1018
1026
|
},
|
|
1019
|
-
pod: { node_selector: {}, tolerations: [], annotations: {} },
|
|
1027
|
+
pod: { node_selector: {}, tolerations: [], annotations: {}, host_aliases: [] },
|
|
1020
1028
|
image_pull_secrets: [],
|
|
1021
1029
|
image_pull_secret_copies: [],
|
|
1022
1030
|
},
|
|
@@ -34,17 +34,6 @@ export type {
|
|
|
34
34
|
WorkersConfigSnapshot as WorkersConfig,
|
|
35
35
|
} from "@leitwerk-dev/protocol";
|
|
36
36
|
|
|
37
|
-
export type SkillSourceConfig =
|
|
38
|
-
| { kind: "local"; path: string }
|
|
39
|
-
| { kind: "git"; url: string; ref: string; path: string };
|
|
40
|
-
|
|
41
|
-
export interface SkillConfig {
|
|
42
|
-
id: string;
|
|
43
|
-
label?: string;
|
|
44
|
-
description?: string;
|
|
45
|
-
source: SkillSourceConfig;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
37
|
export interface SkillRepositoryConfig {
|
|
49
38
|
id: string;
|
|
50
39
|
label?: string;
|
|
@@ -141,10 +130,16 @@ export interface KubernetesProcessVolumeConfig {
|
|
|
141
130
|
mount_path: string;
|
|
142
131
|
}
|
|
143
132
|
|
|
133
|
+
export interface KubernetesHostAliasConfig {
|
|
134
|
+
ip: string;
|
|
135
|
+
hostnames: string[];
|
|
136
|
+
}
|
|
137
|
+
|
|
144
138
|
export interface KubernetesPodConfig {
|
|
145
139
|
node_selector?: Record<string, string>;
|
|
146
140
|
tolerations?: unknown[];
|
|
147
141
|
annotations?: Record<string, string>;
|
|
142
|
+
host_aliases?: KubernetesHostAliasConfig[];
|
|
148
143
|
}
|
|
149
144
|
|
|
150
145
|
export interface KubernetesImagePullSecretCopyConfig {
|
|
@@ -270,8 +265,6 @@ export interface LeitwerkConfig extends ConfigSnapshot {
|
|
|
270
265
|
worker_runtime_profiles?: Record<string, WorkerRuntimeProfileConfig>;
|
|
271
266
|
/** Server-only internal TLS for worker IPC; stripped from the worker snapshot. */
|
|
272
267
|
internal_tls?: InternalTlsConfig;
|
|
273
|
-
/** Legacy/direct server-imported, opt-in Pi skill directories. */
|
|
274
|
-
skills?: SkillConfig[];
|
|
275
268
|
/** Git repositories scanned for operator-managed skills. */
|
|
276
269
|
skill_repositories?: SkillRepositoryConfig[];
|
|
277
270
|
/** Server-owned repository-aware commit-message generation rules. */
|
package/src/db/skill-repo.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import { verifyCanonicalPiResourceBundle } from "@leitwerk-dev/worker-protocol";
|
|
12
12
|
import { and, asc, count, desc, eq, isNotNull, max, sql } from "drizzle-orm";
|
|
13
13
|
import { explicitSkillReferenceIds, referencedSkillIds } from "../skills/skill-dependencies.js";
|
|
14
|
+
import { isSkillModelInvocable } from "../skills/skill-frontmatter.js";
|
|
14
15
|
import type { ImportedRepositorySkill, ImportedSkill } from "../skills/source-importer.js";
|
|
15
16
|
import type { LeitwerkDb } from "./database.js";
|
|
16
17
|
import { generateId, now } from "./repo-helpers.js";
|
|
@@ -107,10 +108,17 @@ function candidateSummaries(db: LeitwerkDb) {
|
|
|
107
108
|
sourcePath: skillCatalogEntries.sourcePath,
|
|
108
109
|
sourceRevision: skillCatalogEntries.sourceRevision,
|
|
109
110
|
bundleDigest: skillCatalogEntries.bundleDigest,
|
|
111
|
+
bundleBytes: skillCatalogEntries.bundleBytes,
|
|
110
112
|
available: skillCatalogEntries.available,
|
|
111
113
|
})
|
|
112
114
|
.from(skillCatalogEntries)
|
|
113
|
-
.all()
|
|
115
|
+
.all()
|
|
116
|
+
.map((candidate) => ({
|
|
117
|
+
...candidate,
|
|
118
|
+
modelInvocable: isSkillModelInvocable(
|
|
119
|
+
skillMarkdown(candidate.skillId, candidate.bundleBytes, candidate.bundleDigest),
|
|
120
|
+
),
|
|
121
|
+
}));
|
|
114
122
|
}
|
|
115
123
|
|
|
116
124
|
function processUsage(db: LeitwerkDb, skillId: string): SkillUsageProcessSummary[] {
|
|
@@ -192,7 +200,6 @@ function recordRevisionDependencies(db: LeitwerkDb, revisionId: string, markdown
|
|
|
192
200
|
function activateSkill(
|
|
193
201
|
db: LeitwerkDb,
|
|
194
202
|
item: ImportedSkill,
|
|
195
|
-
registrationKind: "configuration" | "catalog",
|
|
196
203
|
timestamp: string,
|
|
197
204
|
markdown = skillMarkdown(item.skillId, item.bundle.bytes, item.bundle.digest),
|
|
198
205
|
): string {
|
|
@@ -202,7 +209,7 @@ function activateSkill(
|
|
|
202
209
|
label: item.label,
|
|
203
210
|
description: item.description,
|
|
204
211
|
activeRevisionId: null,
|
|
205
|
-
registrationKind,
|
|
212
|
+
registrationKind: "catalog",
|
|
206
213
|
createdAt: timestamp,
|
|
207
214
|
updatedAt: timestamp,
|
|
208
215
|
})
|
|
@@ -215,7 +222,7 @@ function activateSkill(
|
|
|
215
222
|
label: item.label,
|
|
216
223
|
description: item.description,
|
|
217
224
|
activeRevisionId: revisionId,
|
|
218
|
-
registrationKind,
|
|
225
|
+
registrationKind: "catalog",
|
|
219
226
|
updatedAt: timestamp,
|
|
220
227
|
})
|
|
221
228
|
.where(eq(skills.id, item.skillId))
|
|
@@ -237,18 +244,16 @@ function catalogView(db: LeitwerkDb): {
|
|
|
237
244
|
activeRevisionId: skillRevisions.id,
|
|
238
245
|
activeSourceRevision: skillRevisions.sourceRevision,
|
|
239
246
|
activeDigest: skillRevisions.bundleDigest,
|
|
240
|
-
registrationKind: skills.registrationKind,
|
|
241
247
|
})
|
|
242
248
|
.from(skills)
|
|
243
249
|
.innerJoin(skillRevisions, eq(skills.activeRevisionId, skillRevisions.id))
|
|
250
|
+
.where(eq(skills.registrationKind, "catalog"))
|
|
244
251
|
.orderBy(asc(skills.label), asc(skills.id))
|
|
245
252
|
.all();
|
|
246
253
|
const installedById = new Map(installedRows.map((row) => [row.id, row]));
|
|
247
254
|
const availableSkills = candidates.map((candidate) => {
|
|
248
255
|
const active = installedById.get(candidate.skillId);
|
|
249
|
-
const registered =
|
|
250
|
-
active?.registrationKind === "catalog" && active.activeDigest === candidate.bundleDigest,
|
|
251
|
-
);
|
|
256
|
+
const registered = active?.activeDigest === candidate.bundleDigest;
|
|
252
257
|
return {
|
|
253
258
|
repositoryId: candidate.repositoryId,
|
|
254
259
|
id: candidate.skillId,
|
|
@@ -257,11 +262,9 @@ function catalogView(db: LeitwerkDb): {
|
|
|
257
262
|
sourcePath: candidate.sourcePath,
|
|
258
263
|
sourceRevision: candidate.sourceRevision,
|
|
259
264
|
registered,
|
|
260
|
-
updateAvailable: Boolean(
|
|
261
|
-
candidate.available && active?.registrationKind === "catalog" && !registered,
|
|
262
|
-
),
|
|
263
|
-
conflict: candidate.available && active?.registrationKind === "configuration",
|
|
265
|
+
updateAvailable: Boolean(candidate.available && active && !registered),
|
|
264
266
|
stale: !candidate.available,
|
|
267
|
+
modelInvocable: candidate.modelInvocable,
|
|
265
268
|
usage: usage.get(candidate.skillId) ?? emptyUsage(),
|
|
266
269
|
};
|
|
267
270
|
});
|
|
@@ -277,17 +280,14 @@ function catalogView(db: LeitwerkDb): {
|
|
|
277
280
|
description: skill.description,
|
|
278
281
|
activeRevisionId: skill.activeRevisionId,
|
|
279
282
|
activeSourceRevision: skill.activeSourceRevision,
|
|
280
|
-
registrationKind: skill.registrationKind,
|
|
281
283
|
sourceRepositoryId:
|
|
282
284
|
matching.length === 1
|
|
283
285
|
? (matching[0]?.repositoryId ?? null)
|
|
284
286
|
: activeSource.length === 1
|
|
285
287
|
? (activeSource[0]?.repositoryId ?? null)
|
|
286
288
|
: null,
|
|
287
|
-
updateAvailable:
|
|
288
|
-
|
|
289
|
-
available.length === 1 &&
|
|
290
|
-
available[0]?.bundleDigest !== skill.activeDigest,
|
|
289
|
+
updateAvailable: available.length === 1 && available[0]?.bundleDigest !== skill.activeDigest,
|
|
290
|
+
modelInvocable: activeSource[0]?.modelInvocable ?? true,
|
|
291
291
|
usage: usage.get(skill.id) ?? emptyUsage(),
|
|
292
292
|
};
|
|
293
293
|
});
|
|
@@ -333,18 +333,13 @@ export function createSkillRepo(db: LeitwerkDb) {
|
|
|
333
333
|
for (const id of ids) add(id);
|
|
334
334
|
return [...resolved.values()];
|
|
335
335
|
},
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
.where(eq(skills.id, old.id))
|
|
344
|
-
.run();
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
for (const item of imported) activateSkill(db, item, "configuration", timestamp);
|
|
336
|
+
deactivateConfiguredSkills(): void {
|
|
337
|
+
db.update(skills)
|
|
338
|
+
.set({ activeRevisionId: null, updatedAt: now() })
|
|
339
|
+
.where(
|
|
340
|
+
and(eq(skills.registrationKind, "configuration"), isNotNull(skills.activeRevisionId)),
|
|
341
|
+
)
|
|
342
|
+
.run();
|
|
348
343
|
},
|
|
349
344
|
backfillDependencies(): void {
|
|
350
345
|
for (const revision of db.select().from(skillRevisions).all()) {
|
|
@@ -384,7 +379,7 @@ export function createSkillRepo(db: LeitwerkDb) {
|
|
|
384
379
|
label: item.label,
|
|
385
380
|
description: item.description,
|
|
386
381
|
sourcePath: item.sourcePath,
|
|
387
|
-
sourceRevision: item.sourceRevision
|
|
382
|
+
sourceRevision: item.sourceRevision,
|
|
388
383
|
bundleDigest: item.bundle.digest,
|
|
389
384
|
bundleBytes: Buffer.from(item.bundle.bytes),
|
|
390
385
|
discoveredAt: timestamp,
|
|
@@ -435,10 +430,6 @@ export function createSkillRepo(db: LeitwerkDb) {
|
|
|
435
430
|
`Remote skill '${requestedRepositoryId ? `${requestedRepositoryId}/` : ""}${id}' is no longer available`,
|
|
436
431
|
);
|
|
437
432
|
}
|
|
438
|
-
const current = db.select().from(skills).where(eq(skills.id, id)).get();
|
|
439
|
-
if (current?.activeRevisionId && current.registrationKind === "configuration") {
|
|
440
|
-
throw new Error(`Skill '${id}' is managed by configuration`);
|
|
441
|
-
}
|
|
442
433
|
visiting.add(id);
|
|
443
434
|
const markdown = skillMarkdown(id, candidate.bundleBytes, candidate.bundleDigest);
|
|
444
435
|
for (const dependencyId of referencedSkillIds(markdown, availableIds)) {
|
|
@@ -455,7 +446,6 @@ export function createSkillRepo(db: LeitwerkDb) {
|
|
|
455
446
|
bundle: { digest: candidate.bundleDigest, bytes: candidate.bundleBytes },
|
|
456
447
|
sourceRevision: candidate.sourceRevision,
|
|
457
448
|
},
|
|
458
|
-
"catalog",
|
|
459
449
|
timestamp,
|
|
460
450
|
markdown,
|
|
461
451
|
);
|
|
@@ -470,7 +460,7 @@ export function createSkillRepo(db: LeitwerkDb) {
|
|
|
470
460
|
},
|
|
471
461
|
remove(skillId: string): boolean {
|
|
472
462
|
const current = db.select().from(skills).where(eq(skills.id, skillId)).get();
|
|
473
|
-
if (!current?.activeRevisionId
|
|
463
|
+
if (!current?.activeRevisionId) return false;
|
|
474
464
|
db.update(skills)
|
|
475
465
|
.set({ activeRevisionId: null, updatedAt: now() })
|
|
476
466
|
.where(eq(skills.id, skillId))
|
|
@@ -453,10 +453,13 @@ export function createExternalSourceService(
|
|
|
453
453
|
return armed;
|
|
454
454
|
}
|
|
455
455
|
|
|
456
|
-
if (!isHumanTurnDefinition(turnDef)) {
|
|
456
|
+
if (!isHumanTurnDefinition(turnDef) && turnDef.kind !== "automatic") {
|
|
457
457
|
return [];
|
|
458
458
|
}
|
|
459
459
|
for (const [externalActionId, action] of Object.entries(turnDef.externalActions ?? {})) {
|
|
460
|
+
if (action.when && !action.when({ process, projects, params, state })) {
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
460
463
|
const id = getExternalActionArmingId({ turnId, externalActionId });
|
|
461
464
|
armed.push({
|
|
462
465
|
id,
|
|
@@ -531,7 +534,7 @@ export function createExternalSourceService(
|
|
|
531
534
|
}
|
|
532
535
|
for (const [turnId, binding] of processDef.turns) {
|
|
533
536
|
const turnDef = binding.definition;
|
|
534
|
-
if (isHumanTurnDefinition(turnDef)) {
|
|
537
|
+
if (isHumanTurnDefinition(turnDef) || turnDef.kind === "automatic") {
|
|
535
538
|
for (const [externalActionId, action] of Object.entries(turnDef.externalActions ?? {})) {
|
|
536
539
|
if (getExternalActionArmingId({ turnId, externalActionId }) === armingId) {
|
|
537
540
|
return { turnId, externalActionId, sourceKind: action.source.kind };
|
|
@@ -40,6 +40,7 @@ export interface FutureExecutionExecutorDeps
|
|
|
40
40
|
| "futureExecutions"
|
|
41
41
|
| "processes"
|
|
42
42
|
| "projects"
|
|
43
|
+
| "skills"
|
|
43
44
|
| "processSkills"
|
|
44
45
|
| "handoffDedupKeys"
|
|
45
46
|
| "transaction"
|
|
@@ -129,19 +130,7 @@ async function executeScheduledLaunch(
|
|
|
129
130
|
)
|
|
130
131
|
: planConsumeFutureExecution(execution);
|
|
131
132
|
const result = await createScheduledProcessFromLaunchPlan(
|
|
132
|
-
|
|
133
|
-
processes: deps.processes,
|
|
134
|
-
projects: deps.projects,
|
|
135
|
-
processSkills: deps.processSkills,
|
|
136
|
-
handoffDedupKeys: deps.handoffDedupKeys,
|
|
137
|
-
futureExecutions: deps.futureExecutions,
|
|
138
|
-
broadcaster: deps.broadcaster,
|
|
139
|
-
commands: deps.commands,
|
|
140
|
-
processTitles: deps.processTitles,
|
|
141
|
-
extensionHost: deps.extensionHost,
|
|
142
|
-
logger: deps.logger,
|
|
143
|
-
transaction: deps.transaction,
|
|
144
|
-
},
|
|
133
|
+
deps,
|
|
145
134
|
preparedLaunchPlan.launchPlan,
|
|
146
135
|
transitionPlan,
|
|
147
136
|
{
|
|
@@ -147,7 +147,7 @@ export function createIntegrationToolRequestService(input: {
|
|
|
147
147
|
turn.turnId,
|
|
148
148
|
);
|
|
149
149
|
if (
|
|
150
|
-
turnDefinition?.kind !== "llm" ||
|
|
150
|
+
(turnDefinition?.kind !== "llm" && turnDefinition?.kind !== "automatic") ||
|
|
151
151
|
!turnDefinition.integrationTools?.includes(payload.toolName)
|
|
152
152
|
) {
|
|
153
153
|
return fail(`Integration tool '${payload.toolName}' is not authorized for this turn`);
|
|
@@ -22,6 +22,12 @@ function requireApiKey(secrets: Readonly<Record<string, string>>): string {
|
|
|
22
22
|
return value;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
function configuredBaseUrl(config: unknown): string | undefined {
|
|
26
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) return undefined;
|
|
27
|
+
const value = (config as { baseUrl?: unknown }).baseUrl;
|
|
28
|
+
return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
/**
|
|
26
32
|
* Direct, server-only Pi AI adapter. It never reads PI_CODING_AGENT_DIR or an
|
|
27
33
|
* ambient auth file; the current credential revision is supplied per call.
|
|
@@ -34,10 +40,12 @@ export function createBuiltinPiServerAdapter(builtinProviderId: string): PiServe
|
|
|
34
40
|
`Built-in adapter '${builtinProviderId}' cannot serve provider '${input.providerId}'`,
|
|
35
41
|
);
|
|
36
42
|
}
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
43
|
+
const canonicalModel = getModel(builtinProviderId as never, input.modelId as never);
|
|
44
|
+
if (!canonicalModel) {
|
|
39
45
|
throw new Error(`Built-in Pi model '${builtinProviderId}/${input.modelId}' is unavailable`);
|
|
40
46
|
}
|
|
47
|
+
const baseUrl = configuredBaseUrl(input.config);
|
|
48
|
+
const model = baseUrl ? { ...canonicalModel, baseUrl } : canonicalModel;
|
|
41
49
|
const reasoning = resolveThinkingLevel(input.thinkingLevel);
|
|
42
50
|
const message = await completeSimple(
|
|
43
51
|
model,
|