@leitwerk-dev/server 0.1.6 → 0.1.7
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 +29 -31
- package/dist/app.js.map +1 -1
- package/dist/auth/auth-client.d.ts +25 -0
- package/dist/auth/auth-client.d.ts.map +1 -0
- package/dist/auth/auth-client.js +19 -0
- package/dist/auth/auth-client.js.map +1 -0
- package/dist/auth/auth-config.d.ts +8 -2
- package/dist/auth/auth-config.d.ts.map +1 -1
- package/dist/auth/auth-config.js +17 -7
- package/dist/auth/auth-config.js.map +1 -1
- package/dist/auth/auth-service.d.ts +2 -0
- package/dist/auth/auth-service.d.ts.map +1 -1
- package/dist/auth/auth-service.js +9 -5
- package/dist/auth/auth-service.js.map +1 -1
- package/dist/auth/auth-test-helpers.js +2 -2
- package/dist/auth/auth-test-helpers.js.map +1 -1
- package/dist/auth/github-oauth-client.d.ts +20 -0
- package/dist/auth/github-oauth-client.d.ts.map +1 -0
- package/dist/auth/github-oauth-client.js +79 -0
- package/dist/auth/github-oauth-client.js.map +1 -0
- package/dist/auth/oidc-client.d.ts +4 -4
- package/dist/{chunk-G4PCN46L.js → chunk-GIWHTJSL.js} +18 -93
- package/dist/chunk-GIWHTJSL.js.map +1 -0
- package/dist/{chunk-KVHAK5UR.js → chunk-OO6VH4FX.js} +515 -400
- package/dist/chunk-OO6VH4FX.js.map +1 -0
- package/dist/config/config-loader.d.ts.map +1 -1
- package/dist/config/config-loader.js +13 -88
- package/dist/config/config-loader.js.map +1 -1
- package/dist/config/config-types.d.ts +13 -3
- package/dist/config/config-types.d.ts.map +1 -1
- package/dist/domain-logic/outcome-tools.d.ts +2 -2
- package/dist/domain-logic/outcome-tools.d.ts.map +1 -1
- package/dist/domain-logic/outcome-tools.js +1 -1
- package/dist/domain-logic/outcome-tools.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integration-tool-registry.d.ts +23 -0
- package/dist/integration-tool-registry.d.ts.map +1 -0
- package/dist/integration-tool-registry.js +140 -0
- package/dist/integration-tool-registry.js.map +1 -0
- package/dist/process-ui-snapshot-presenter.d.ts.map +1 -1
- package/dist/process-ui-snapshot-presenter.js +0 -2
- package/dist/process-ui-snapshot-presenter.js.map +1 -1
- package/dist/process-watcher-registry.d.ts +3 -31
- package/dist/process-watcher-registry.d.ts.map +1 -1
- package/dist/process-watcher-registry.js +96 -97
- package/dist/process-watcher-registry.js.map +1 -1
- package/dist/routes/watchers.d.ts.map +1 -1
- package/dist/routes/watchers.js +14 -50
- package/dist/routes/watchers.js.map +1 -1
- package/dist/semantic-state-json.d.ts +1 -2
- package/dist/semantic-state-json.d.ts.map +1 -1
- package/dist/semantic-state-json.js +1 -2
- package/dist/semantic-state-json.js.map +1 -1
- package/dist/supervisor/ipc-handler.d.ts +4 -1
- package/dist/supervisor/ipc-handler.d.ts.map +1 -1
- package/dist/supervisor/ipc-handler.js +18 -0
- package/dist/supervisor/ipc-handler.js.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.d.ts +3 -0
- package/dist/supervisor/worker-start-payload-builder.d.ts.map +1 -1
- package/dist/supervisor/worker-start-payload-builder.js +9 -0
- package/dist/supervisor/worker-start-payload-builder.js.map +1 -1
- package/dist/supervisor/worker-supervisor.d.ts +3 -1
- package/dist/supervisor/worker-supervisor.d.ts.map +1 -1
- package/dist/supervisor/worker-supervisor.js +6 -0
- package/dist/supervisor/worker-supervisor.js.map +1 -1
- package/dist/test-helpers/fake-worker-supervisor.d.ts.map +1 -1
- package/dist/test-helpers/fake-worker-supervisor.js +1 -0
- package/dist/test-helpers/fake-worker-supervisor.js.map +1 -1
- package/dist/test-helpers/ipc-handler-harness.d.ts +1 -0
- package/dist/test-helpers/ipc-handler-harness.d.ts.map +1 -1
- package/dist/test-helpers/ipc-handler-harness.js +4 -3
- package/dist/test-helpers/ipc-handler-harness.js.map +1 -1
- package/dist/test-helpers/process-fixtures.js +3 -3
- package/dist/test-helpers/process-fixtures.js.map +1 -1
- package/dist/{writes-irEq9SlA.d.ts → writes-DUwQe8MD.d.ts} +22 -4
- package/package.json +10 -10
- package/src/app.ts +34 -35
- package/src/auth/auth-client.ts +40 -0
- package/src/auth/auth-config.ts +34 -9
- package/src/auth/auth-service.ts +11 -5
- package/src/auth/auth-test-helpers.ts +2 -2
- package/src/auth/github-oauth-client.ts +111 -0
- package/src/auth/oidc-client.ts +5 -5
- package/src/config/config-loader.ts +18 -102
- package/src/config/config-types.ts +15 -3
- package/src/domain-logic/outcome-tools.ts +3 -3
- package/src/index.ts +1 -4
- package/src/integration-tool-registry.ts +186 -0
- package/src/process-ui-snapshot-presenter.ts +0 -2
- package/src/process-watcher-registry.ts +124 -167
- package/src/routes/watchers.ts +14 -50
- package/src/semantic-state-json.ts +0 -2
- package/src/supervisor/ipc-handler.ts +35 -0
- package/src/supervisor/worker-start-payload-builder.ts +19 -0
- package/src/supervisor/worker-supervisor.ts +13 -0
- package/src/test-helpers/fake-worker-supervisor.ts +1 -0
- package/src/test-helpers/ipc-handler-harness.ts +7 -3
- package/src/test-helpers/process-fixtures.ts +3 -3
- package/dist/chunk-G4PCN46L.js.map +0 -1
- package/dist/chunk-KVHAK5UR.js.map +0 -1
- package/dist/domain-logic/idempotency.d.ts +0 -3
- package/dist/domain-logic/idempotency.d.ts.map +0 -1
- package/dist/domain-logic/idempotency.js +0 -3
- package/dist/domain-logic/idempotency.js.map +0 -1
- package/dist/domain-logic/index.d.ts +0 -7
- package/dist/domain-logic/index.d.ts.map +0 -1
- package/dist/domain-logic/index.js +0 -6
- package/dist/domain-logic/index.js.map +0 -1
- package/dist/domain-logic/input-sequencer.d.ts +0 -16
- package/dist/domain-logic/input-sequencer.d.ts.map +0 -1
- package/dist/domain-logic/input-sequencer.js +0 -2
- package/dist/domain-logic/input-sequencer.js.map +0 -1
- package/dist/domain-logic/string-normalize.d.ts +0 -2
- package/dist/domain-logic/string-normalize.d.ts.map +0 -1
- package/dist/domain-logic/string-normalize.js +0 -2
- package/dist/domain-logic/string-normalize.js.map +0 -1
- package/dist/filesystem-process-watchers.d.ts +0 -22
- package/dist/filesystem-process-watchers.d.ts.map +0 -1
- package/dist/filesystem-process-watchers.js +0 -79
- package/dist/filesystem-process-watchers.js.map +0 -1
- package/dist/test-helpers/in-process-worker.d.ts +0 -2
- package/dist/test-helpers/in-process-worker.d.ts.map +0 -1
- package/dist/test-helpers/in-process-worker.js +0 -2
- package/dist/test-helpers/in-process-worker.js.map +0 -1
- package/dist/test-helpers/leaf-outcome-fixtures.d.ts +0 -37
- package/dist/test-helpers/leaf-outcome-fixtures.d.ts.map +0 -1
- package/dist/test-helpers/leaf-outcome-fixtures.js +0 -81
- package/dist/test-helpers/leaf-outcome-fixtures.js.map +0 -1
- package/src/domain-logic/idempotency.ts +0 -3
- package/src/domain-logic/index.ts +0 -31
- package/src/domain-logic/input-sequencer.ts +0 -18
- package/src/domain-logic/string-normalize.ts +0 -1
- package/src/filesystem-process-watchers.ts +0 -147
- package/src/test-helpers/in-process-worker.ts +0 -2
- package/src/test-helpers/leaf-outcome-fixtures.ts +0 -140
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
snapshotLiveTurnProjection,
|
|
72
72
|
truncateTextAtWordBoundary,
|
|
73
73
|
validateConfig
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-GIWHTJSL.js";
|
|
75
75
|
|
|
76
76
|
// src/extension-ui/catalog.ts
|
|
77
77
|
import { readFile, stat } from "fs/promises";
|
|
@@ -2743,17 +2743,13 @@ function buildTurnFailedWrites(input) {
|
|
|
2743
2743
|
}
|
|
2744
2744
|
|
|
2745
2745
|
// src/domain-logic/outcome-tools.ts
|
|
2746
|
+
import { normalizeStringArray, trimString } from "@leitwerk-dev/domain";
|
|
2746
2747
|
import {
|
|
2747
2748
|
isAutomaticTurnDefinition,
|
|
2748
2749
|
isLlmTurnDefinition,
|
|
2749
2750
|
isServerAutomaticTurnDefinition
|
|
2750
2751
|
} from "@leitwerk-dev/process-sdk";
|
|
2751
2752
|
import * as v2 from "valibot";
|
|
2752
|
-
|
|
2753
|
-
// src/domain-logic/string-normalize.ts
|
|
2754
|
-
import { normalizeStringArray, trimString, trimToNull } from "@leitwerk-dev/domain";
|
|
2755
|
-
|
|
2756
|
-
// src/domain-logic/outcome-tools.ts
|
|
2757
2753
|
function validationFailure(code, message) {
|
|
2758
2754
|
return { ok: false, code, message };
|
|
2759
2755
|
}
|
|
@@ -3107,7 +3103,6 @@ function resolveProductTurnResultMarkdown(input) {
|
|
|
3107
3103
|
// src/semantic-state-json.ts
|
|
3108
3104
|
import {
|
|
3109
3105
|
parseProcessStateJsonStrict,
|
|
3110
|
-
parseSemanticEntryRefsFromStateJsonStrict,
|
|
3111
3106
|
parseSemanticEntryRefsStrict
|
|
3112
3107
|
} from "@leitwerk-dev/domain";
|
|
3113
3108
|
var parseProcessStateJsonRecord = parseProcessStateJsonStrict;
|
|
@@ -7362,7 +7357,7 @@ import {
|
|
|
7362
7357
|
createAgentSessionServices,
|
|
7363
7358
|
SessionManager
|
|
7364
7359
|
} from "@earendil-works/pi-coding-agent";
|
|
7365
|
-
import { trimToNull
|
|
7360
|
+
import { trimToNull } from "@leitwerk-dev/domain";
|
|
7366
7361
|
import { expandPiAgentDir } from "@leitwerk-dev/process-sdk/pi-config";
|
|
7367
7362
|
import { createDurableWsFrame as createDurableWsFrame4, parseFutureLaunchPayloadJson } from "@leitwerk-dev/protocol";
|
|
7368
7363
|
import { parseDurationMs } from "@leitwerk-dev/watcher-utils";
|
|
@@ -7388,7 +7383,7 @@ function getFutureExecutionTitleJobTarget(job) {
|
|
|
7388
7383
|
};
|
|
7389
7384
|
}
|
|
7390
7385
|
function normalizeProcessTitle(value) {
|
|
7391
|
-
const trimmed =
|
|
7386
|
+
const trimmed = trimToNull(value);
|
|
7392
7387
|
if (!trimmed) {
|
|
7393
7388
|
return null;
|
|
7394
7389
|
}
|
|
@@ -7400,7 +7395,7 @@ function normalizeProcessTitle(value) {
|
|
|
7400
7395
|
return normalizeProcessTitleInput(withoutQuotes);
|
|
7401
7396
|
}
|
|
7402
7397
|
function normalizeSourceValue(value) {
|
|
7403
|
-
const trimmed =
|
|
7398
|
+
const trimmed = trimToNull(value);
|
|
7404
7399
|
if (!trimmed) {
|
|
7405
7400
|
return null;
|
|
7406
7401
|
}
|
|
@@ -7413,7 +7408,7 @@ function buildProcessTitleSourceFields(launchPlan) {
|
|
|
7413
7408
|
if (normalized.length >= MAX_SOURCE_FIELDS) {
|
|
7414
7409
|
break;
|
|
7415
7410
|
}
|
|
7416
|
-
const label =
|
|
7411
|
+
const label = trimToNull(field.label) ?? `Field ${normalized.length + 1}`;
|
|
7417
7412
|
const value = normalizeSourceValue(field.value);
|
|
7418
7413
|
if (!value) {
|
|
7419
7414
|
continue;
|
|
@@ -7593,7 +7588,7 @@ var DefaultProcessTitleGenerator = class {
|
|
|
7593
7588
|
this.runtime = runtime;
|
|
7594
7589
|
this.extensionHost = extensionHost;
|
|
7595
7590
|
this.futureExecutionTitleApplier = futureExecutionTitleApplier;
|
|
7596
|
-
this.configuredProfileId =
|
|
7591
|
+
this.configuredProfileId = trimToNull(config.pi.process_title_generation.model_profile);
|
|
7597
7592
|
this.retryPolicy = buildProcessTitleRetryPolicy(config);
|
|
7598
7593
|
this.expandedAgentDir = expandPiAgentDir(config.pi.agent_dir);
|
|
7599
7594
|
this.pollIntervalMs = Math.max(1, Math.trunc(runtime.pollIntervalMs));
|
|
@@ -8066,42 +8061,41 @@ function buildLaunchPlan(watcher, launchConfig, commitMessages) {
|
|
|
8066
8061
|
launcherId: `${watcher.processId}.${watcher.definition.id}`,
|
|
8067
8062
|
metadataAdditions: {
|
|
8068
8063
|
processWatcherId: watcher.definition.id,
|
|
8069
|
-
|
|
8064
|
+
processWatcherSourceId: watcher.definition.source.id,
|
|
8070
8065
|
processWatcherConfigPath: watcher.configPath
|
|
8071
8066
|
},
|
|
8072
8067
|
errorSubject: `Process watcher '${watcher.definition.id}'`,
|
|
8073
8068
|
commitMessages
|
|
8074
8069
|
});
|
|
8075
8070
|
}
|
|
8076
|
-
function
|
|
8077
|
-
|
|
8078
|
-
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
8084
|
-
|
|
8085
|
-
|
|
8086
|
-
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
}
|
|
8103
|
-
|
|
8104
|
-
return `${processId}:${watcherId}`;
|
|
8071
|
+
function parseConfiguredWatcher(input) {
|
|
8072
|
+
try {
|
|
8073
|
+
const parsed = input.definition.source.parseConfig(input.rawConfig);
|
|
8074
|
+
if (typeof parsed.enabled !== "boolean") {
|
|
8075
|
+
throw new Error("parseConfig() must return a boolean enabled value");
|
|
8076
|
+
}
|
|
8077
|
+
const presentation = input.definition.source.presentConfig(parsed.config);
|
|
8078
|
+
if (presentation.targetSummary.trim() === "") {
|
|
8079
|
+
throw new Error("presentConfig() must return a non-empty targetSummary");
|
|
8080
|
+
}
|
|
8081
|
+
return {
|
|
8082
|
+
processId: input.processId,
|
|
8083
|
+
processDisplayName: input.processDisplayName,
|
|
8084
|
+
processDef: input.processDef,
|
|
8085
|
+
definition: input.definition,
|
|
8086
|
+
config: parsed.config,
|
|
8087
|
+
enabled: parsed.enabled,
|
|
8088
|
+
presentation,
|
|
8089
|
+
configPath: input.configPath,
|
|
8090
|
+
launchModelConfig: parsed.launchModelConfig ?? {
|
|
8091
|
+
defaultModelProfileId: null,
|
|
8092
|
+
turnConfigs: {}
|
|
8093
|
+
}
|
|
8094
|
+
};
|
|
8095
|
+
} catch (error) {
|
|
8096
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
8097
|
+
throw new Error(`${input.configPath}: ${message}`, { cause: error });
|
|
8098
|
+
}
|
|
8105
8099
|
}
|
|
8106
8100
|
function validateWatcherLaunchModelConfig(processId, modelConfig, policy) {
|
|
8107
8101
|
const errors = [];
|
|
@@ -8114,102 +8108,92 @@ function validateWatcherLaunchModelConfig(processId, modelConfig, policy) {
|
|
|
8114
8108
|
}
|
|
8115
8109
|
return errors;
|
|
8116
8110
|
}
|
|
8117
|
-
function
|
|
8111
|
+
function collectConfiguredProcessWatchers(input) {
|
|
8112
|
+
const watchers = [];
|
|
8118
8113
|
const errors = [];
|
|
8119
8114
|
for (const [processId, processConfig] of Object.entries(input.config.process_configs ?? {})) {
|
|
8120
|
-
if (!input.catalog.processes.has(processId)) {
|
|
8121
|
-
continue;
|
|
8122
|
-
}
|
|
8123
8115
|
const processDef = input.catalog.processes.get(processId);
|
|
8124
|
-
if (!processDef)
|
|
8125
|
-
|
|
8126
|
-
}
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
if (!watcherDef) {
|
|
8132
|
-
errors.push(
|
|
8133
|
-
`Unknown watcher '${watcherId}' at process_configs.${processId}.watchers.${watcherId}`
|
|
8134
|
-
);
|
|
8116
|
+
if (!processDef) continue;
|
|
8117
|
+
const definitions = collectProcessWatchers(processDef);
|
|
8118
|
+
for (const [watcherId, rawConfig] of Object.entries(processConfig.watchers ?? {})) {
|
|
8119
|
+
const configPath = `process_configs.${processId}.watchers.${watcherId}`;
|
|
8120
|
+
const definition = definitions.get(watcherId);
|
|
8121
|
+
if (!definition) {
|
|
8122
|
+
errors.push(`Unknown watcher '${watcherId}' at ${configPath}`);
|
|
8135
8123
|
continue;
|
|
8136
8124
|
}
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8125
|
+
try {
|
|
8126
|
+
const watcher = parseConfiguredWatcher({
|
|
8127
|
+
processId,
|
|
8128
|
+
processDisplayName: processDef.displayName,
|
|
8129
|
+
processDef,
|
|
8130
|
+
definition,
|
|
8131
|
+
rawConfig,
|
|
8132
|
+
configPath
|
|
8133
|
+
});
|
|
8134
|
+
watchers.push(watcher);
|
|
8135
|
+
if (input.processModelPolicy) {
|
|
8136
|
+
errors.push(
|
|
8137
|
+
...validateWatcherLaunchModelConfig(
|
|
8138
|
+
processId,
|
|
8139
|
+
watcher.launchModelConfig,
|
|
8140
|
+
input.processModelPolicy
|
|
8141
|
+
)
|
|
8142
|
+
);
|
|
8143
|
+
}
|
|
8144
|
+
} catch (error) {
|
|
8145
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
8150
8146
|
}
|
|
8151
8147
|
}
|
|
8152
8148
|
}
|
|
8153
|
-
return errors;
|
|
8149
|
+
return { watchers, errors };
|
|
8154
8150
|
}
|
|
8155
8151
|
function buildProcessWatcherRegistry(catalog, config, options = {}) {
|
|
8156
|
-
const watchers
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
}
|
|
8165
|
-
watchers.set(watcherKey(processId, watcherId), {
|
|
8166
|
-
processId,
|
|
8167
|
-
processDisplayName: processDef.displayName,
|
|
8168
|
-
processDef,
|
|
8169
|
-
definition: watcherDef,
|
|
8170
|
-
config: watcherConfig,
|
|
8171
|
-
configPath: `process_configs.${processId}.watchers.${watcherId}`,
|
|
8172
|
-
launchModelConfig: buildWatcherLaunchModelConfig(watcherConfig.launch)
|
|
8173
|
-
});
|
|
8174
|
-
}
|
|
8152
|
+
const { watchers, errors } = collectConfiguredProcessWatchers({
|
|
8153
|
+
catalog,
|
|
8154
|
+
config,
|
|
8155
|
+
processModelPolicy: options.processModelPolicy
|
|
8156
|
+
});
|
|
8157
|
+
if (errors.length > 0) {
|
|
8158
|
+
throw new Error(`Invalid process watcher config:
|
|
8159
|
+
${errors.join("\n")}`);
|
|
8175
8160
|
}
|
|
8176
8161
|
const getDefaultModelProfilesForProcess = (processId) => options.getModelProfilesForProcess?.(processId) ?? options.modelProfiles ?? [];
|
|
8177
8162
|
const createWatcherContext = (processId, ctx = {}) => ({
|
|
8178
8163
|
...ctx,
|
|
8179
8164
|
modelProfiles: ctx.modelProfiles ?? getDefaultModelProfilesForProcess(processId)
|
|
8180
8165
|
});
|
|
8181
|
-
const
|
|
8166
|
+
const registrations = watchers.sort((a, b) => {
|
|
8182
8167
|
const processCompare = a.processDisplayName.localeCompare(b.processDisplayName);
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
}
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
const matches = await watcher.definition.matches(payload, watcherContext);
|
|
8203
|
-
if (!matches) {
|
|
8168
|
+
return processCompare !== 0 ? processCompare : a.definition.label.localeCompare(b.definition.label);
|
|
8169
|
+
}).map((watcher) => ({
|
|
8170
|
+
source: watcher.definition.source,
|
|
8171
|
+
view: {
|
|
8172
|
+
processId: watcher.processId,
|
|
8173
|
+
processDisplayName: watcher.processDisplayName,
|
|
8174
|
+
watcherId: watcher.definition.id,
|
|
8175
|
+
watcherLabel: watcher.definition.label,
|
|
8176
|
+
watcherDescription: watcher.definition.description,
|
|
8177
|
+
sourceId: watcher.definition.source.id,
|
|
8178
|
+
sourceLabel: watcher.definition.source.label,
|
|
8179
|
+
enabled: watcher.enabled,
|
|
8180
|
+
configPath: watcher.configPath,
|
|
8181
|
+
config: structuredClone(watcher.config),
|
|
8182
|
+
presentation: structuredClone(watcher.presentation),
|
|
8183
|
+
launchModelConfig: structuredClone(watcher.launchModelConfig),
|
|
8184
|
+
async resolveLaunch(event, ctx = {}) {
|
|
8185
|
+
const watcherContext = createWatcherContext(watcher.processId, ctx);
|
|
8186
|
+
if (watcher.definition.matches && !await watcher.definition.matches(event, watcherContext)) {
|
|
8204
8187
|
return null;
|
|
8205
8188
|
}
|
|
8189
|
+
const launchConfig = await watcher.definition.resolveLaunchConfig(event, watcherContext);
|
|
8190
|
+
return buildLaunchPlan(watcher, launchConfig, config.commit_messages);
|
|
8206
8191
|
}
|
|
8207
|
-
const launchConfig = await watcher.definition.resolveLaunchConfig(payload, watcherContext);
|
|
8208
|
-
return {
|
|
8209
|
-
watcher: buildRegistrationView(watcher),
|
|
8210
|
-
launchPlan: buildLaunchPlan(watcher, launchConfig, config.commit_messages)
|
|
8211
|
-
};
|
|
8212
8192
|
}
|
|
8193
|
+
}));
|
|
8194
|
+
return {
|
|
8195
|
+
listAll: () => registrations.map(({ view }) => view),
|
|
8196
|
+
listBySource: (source) => registrations.filter((watcher) => watcher.source === source).map(({ view }) => view)
|
|
8213
8197
|
};
|
|
8214
8198
|
}
|
|
8215
8199
|
|
|
@@ -8359,56 +8343,20 @@ function summarizeLaunchModelConfig(modelConfig) {
|
|
|
8359
8343
|
}
|
|
8360
8344
|
function buildWatcherSummary(watcher) {
|
|
8361
8345
|
const launchModel = summarizeLaunchModelConfig(watcher.launchModelConfig);
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
|
|
8367
|
-
|
|
8368
|
-
|
|
8369
|
-
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
project: watcher.config.project,
|
|
8377
|
-
labels: watcher.config.labels,
|
|
8378
|
-
targetBranchLabelPrefix: watcher.config.target_branch_label_prefix
|
|
8379
|
-
};
|
|
8380
|
-
case "gitlab_mr":
|
|
8381
|
-
return {
|
|
8382
|
-
processId: watcher.processId,
|
|
8383
|
-
processDisplayName: watcher.processDisplayName,
|
|
8384
|
-
watcherId: watcher.watcherId,
|
|
8385
|
-
label: watcher.watcherLabel,
|
|
8386
|
-
description: watcher.watcherDescription,
|
|
8387
|
-
type: "gitlab_mr",
|
|
8388
|
-
enabled: watcher.enabled,
|
|
8389
|
-
pollInterval: watcher.pollInterval,
|
|
8390
|
-
configPath: watcher.configPath,
|
|
8391
|
-
launchModel,
|
|
8392
|
-
targetSummary: `GitLab group ${watcher.config.group} \xB7 trigger ${watcher.config.labels.trigger}`,
|
|
8393
|
-
group: watcher.config.group,
|
|
8394
|
-
labels: watcher.config.labels
|
|
8395
|
-
};
|
|
8396
|
-
case "filesystem":
|
|
8397
|
-
return {
|
|
8398
|
-
processId: watcher.processId,
|
|
8399
|
-
processDisplayName: watcher.processDisplayName,
|
|
8400
|
-
watcherId: watcher.watcherId,
|
|
8401
|
-
label: watcher.watcherLabel,
|
|
8402
|
-
description: watcher.watcherDescription,
|
|
8403
|
-
type: "filesystem",
|
|
8404
|
-
enabled: watcher.enabled,
|
|
8405
|
-
pollInterval: watcher.pollInterval,
|
|
8406
|
-
configPath: watcher.configPath,
|
|
8407
|
-
launchModel,
|
|
8408
|
-
targetSummary: `File ${watcher.config.file_path}`,
|
|
8409
|
-
filePath: watcher.config.file_path
|
|
8410
|
-
};
|
|
8411
|
-
}
|
|
8346
|
+
return {
|
|
8347
|
+
processId: watcher.processId,
|
|
8348
|
+
processDisplayName: watcher.processDisplayName,
|
|
8349
|
+
watcherId: watcher.watcherId,
|
|
8350
|
+
label: watcher.watcherLabel,
|
|
8351
|
+
description: watcher.watcherDescription,
|
|
8352
|
+
sourceId: watcher.sourceId,
|
|
8353
|
+
sourceLabel: watcher.sourceLabel,
|
|
8354
|
+
enabled: watcher.enabled,
|
|
8355
|
+
configPath: watcher.configPath,
|
|
8356
|
+
launchModel,
|
|
8357
|
+
targetSummary: watcher.presentation.targetSummary,
|
|
8358
|
+
details: [...watcher.presentation.details ?? []]
|
|
8359
|
+
};
|
|
8412
8360
|
}
|
|
8413
8361
|
function registerWatcherRoutes(app, deps) {
|
|
8414
8362
|
app.get("/api/watchers", async () => {
|
|
@@ -8797,6 +8745,22 @@ function createIpcHandler(deps, callbacks) {
|
|
|
8797
8745
|
{ instanceId, workerId, observation, reason }
|
|
8798
8746
|
);
|
|
8799
8747
|
switch (msg.type) {
|
|
8748
|
+
case "worker.integration_tool_cancel": {
|
|
8749
|
+
deps.handleIntegrationToolCancel?.(instanceId, msg.payload);
|
|
8750
|
+
break;
|
|
8751
|
+
}
|
|
8752
|
+
case "worker.integration_tool_request": {
|
|
8753
|
+
if (!deps.handleIntegrationToolRequest) break;
|
|
8754
|
+
void deps.handleIntegrationToolRequest(instanceId, msg.payload).then((payload) => callbacks.onIntegrationToolResult?.(instanceId, workerId, payload)).catch(
|
|
8755
|
+
() => callbacks.onIntegrationToolResult?.(instanceId, workerId, {
|
|
8756
|
+
turnRecordId: msg.payload.turnRecordId,
|
|
8757
|
+
toolCallId: msg.payload.toolCallId,
|
|
8758
|
+
ok: false,
|
|
8759
|
+
error: "Integration tool execution failed"
|
|
8760
|
+
})
|
|
8761
|
+
);
|
|
8762
|
+
break;
|
|
8763
|
+
}
|
|
8800
8764
|
case "worker.credential_update": {
|
|
8801
8765
|
const result = deps.updateCredential?.(msg.payload) ?? {
|
|
8802
8766
|
accepted: false,
|
|
@@ -9672,6 +9636,15 @@ function createWorkerStartPayloadBuilder(deps) {
|
|
|
9672
9636
|
projects: deps.projects.listByInstance(process2.id)
|
|
9673
9637
|
}) ?? [];
|
|
9674
9638
|
const bootstrap = resolveBootstrap(start, deps);
|
|
9639
|
+
const selectedTurn = deps.processActionRegistry.getTurnDefinition(
|
|
9640
|
+
process2.processId,
|
|
9641
|
+
start.turnId
|
|
9642
|
+
);
|
|
9643
|
+
const integrationToolNames = selectedTurn?.kind === "llm" ? selectedTurn.integrationTools ?? [] : [];
|
|
9644
|
+
const integrationTools = integrationToolNames.length > 0 ? deps.integrationTools?.declarations(integrationToolNames) : void 0;
|
|
9645
|
+
if (integrationToolNames.length > 0 && !integrationTools) {
|
|
9646
|
+
throw new Error(`Integration tools are unavailable for turn '${start.turnId}'`);
|
|
9647
|
+
}
|
|
9675
9648
|
const payloadBase = {
|
|
9676
9649
|
...contextSnapshot,
|
|
9677
9650
|
workerLeaseId: lease.id,
|
|
@@ -9685,7 +9658,8 @@ function createWorkerStartPayloadBuilder(deps) {
|
|
|
9685
9658
|
resume: treePaths.resume,
|
|
9686
9659
|
workerRuntimeSettings: buildWorkerRuntimeSettingsSnapshot(deps.config),
|
|
9687
9660
|
...treePaths.resume ? { resumeLeafEntryId } : {},
|
|
9688
|
-
...repositoryCredentials.length > 0 ? { repositoryCredentials } : {}
|
|
9661
|
+
...repositoryCredentials.length > 0 ? { repositoryCredentials } : {},
|
|
9662
|
+
...integrationTools && integrationTools.length > 0 ? { integrationTools } : {}
|
|
9689
9663
|
};
|
|
9690
9664
|
const payload = bootstrap.kind === "llm" ? {
|
|
9691
9665
|
...payloadBase,
|
|
@@ -10559,6 +10533,12 @@ function createWorkerSupervisor(deps) {
|
|
|
10559
10533
|
questionResponse(instanceId, workerId, payload) {
|
|
10560
10534
|
sendToCurrentWorker(instanceId, workerId, { type: "worker.question_response", payload });
|
|
10561
10535
|
},
|
|
10536
|
+
integrationToolResult(instanceId, workerId, payload) {
|
|
10537
|
+
sendToCurrentWorker(instanceId, workerId, {
|
|
10538
|
+
type: "worker.integration_tool_result",
|
|
10539
|
+
payload
|
|
10540
|
+
});
|
|
10541
|
+
},
|
|
10562
10542
|
credentialUpdateResult(instanceId, workerId, payload) {
|
|
10563
10543
|
sendToCurrentWorker(instanceId, workerId, {
|
|
10564
10544
|
type: "worker.credential_update_accepted",
|
|
@@ -10615,63 +10595,86 @@ import {
|
|
|
10615
10595
|
} from "@leitwerk-dev/worker-runners";
|
|
10616
10596
|
import Fastify from "fastify";
|
|
10617
10597
|
|
|
10618
|
-
// src/auth/
|
|
10619
|
-
import {
|
|
10620
|
-
var
|
|
10621
|
-
var
|
|
10622
|
-
var
|
|
10623
|
-
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
|
|
10627
|
-
|
|
10628
|
-
redirect_uri: provider.redirect_uri ?? new URL("/auth/callback", serverBaseUrl).toString(),
|
|
10629
|
-
scopes: provider.scopes ?? ["openid", "profile", "email"],
|
|
10630
|
-
identity_claim: provider.identity_claim ?? "preferred_username"
|
|
10631
|
-
}));
|
|
10632
|
-
const sessionCookieName = auth?.session?.cookie_name ?? DEFAULT_SESSION_COOKIE_NAME;
|
|
10598
|
+
// src/auth/github-oauth-client.ts
|
|
10599
|
+
import { randomBytes as randomBytes2 } from "crypto";
|
|
10600
|
+
var GITHUB_AUTHORIZE_URL = "https://github.com/login/oauth/authorize";
|
|
10601
|
+
var GITHUB_TOKEN_URL = "https://github.com/login/oauth/access_token";
|
|
10602
|
+
var GITHUB_API_URL = "https://api.github.com";
|
|
10603
|
+
var GITHUB_API_VERSION = "2022-11-28";
|
|
10604
|
+
function opaqueValue() {
|
|
10605
|
+
return randomBytes2(32).toString("base64url");
|
|
10606
|
+
}
|
|
10607
|
+
function githubHeaders(accessToken) {
|
|
10633
10608
|
return {
|
|
10634
|
-
|
|
10635
|
-
|
|
10636
|
-
|
|
10637
|
-
|
|
10638
|
-
auth?.session?.ttl ?? DEFAULT_SESSION_TTL,
|
|
10639
|
-
7 * 24 * 60 * 60 * 1e3,
|
|
10640
|
-
{
|
|
10641
|
-
allowHours: true
|
|
10642
|
-
}
|
|
10643
|
-
),
|
|
10644
|
-
loginFlowTtlMs: DEFAULT_LOGIN_FLOW_TTL_MS,
|
|
10645
|
-
secureCookies: serverBaseUrl.protocol === "https:",
|
|
10646
|
-
appBaseOrigin: serverBaseUrl.origin,
|
|
10647
|
-
providers,
|
|
10648
|
-
allowlist: new Set(auth?.allowlist ?? [])
|
|
10609
|
+
Accept: "application/vnd.github+json",
|
|
10610
|
+
"X-GitHub-Api-Version": GITHUB_API_VERSION,
|
|
10611
|
+
"User-Agent": "leitwerk-server",
|
|
10612
|
+
...accessToken ? { Authorization: `Bearer ${accessToken}` } : {}
|
|
10649
10613
|
};
|
|
10650
10614
|
}
|
|
10651
|
-
function
|
|
10652
|
-
if (!
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
|
|
10656
|
-
return false;
|
|
10657
|
-
}
|
|
10658
|
-
if (!auth.providers.some((provider) => provider.id === actor.provider)) {
|
|
10659
|
-
return false;
|
|
10615
|
+
async function jsonObject(response, errorMessage3) {
|
|
10616
|
+
if (!response.ok) throw new Error(errorMessage3);
|
|
10617
|
+
const value = await response.json();
|
|
10618
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
10619
|
+
throw new Error(errorMessage3);
|
|
10660
10620
|
}
|
|
10661
|
-
|
|
10662
|
-
return actor.id.startsWith(prefix) && auth.allowlist.has(actor.id.slice(prefix.length));
|
|
10663
|
-
}
|
|
10664
|
-
|
|
10665
|
-
// src/auth/auth-tokens.ts
|
|
10666
|
-
import { createHash as createHash3, randomBytes as randomBytes2 } from "crypto";
|
|
10667
|
-
function generateOpaqueToken(byteLength = 32) {
|
|
10668
|
-
return randomBytes2(byteLength).toString("base64url");
|
|
10669
|
-
}
|
|
10670
|
-
function hashOpaqueToken(token) {
|
|
10671
|
-
return createHash3("sha256").update(token, "utf8").digest("base64url");
|
|
10621
|
+
return value;
|
|
10672
10622
|
}
|
|
10673
|
-
function
|
|
10674
|
-
return
|
|
10623
|
+
function createGithubOauthClient(fetchImpl = fetch) {
|
|
10624
|
+
return {
|
|
10625
|
+
async createAuthorizationRequest(provider) {
|
|
10626
|
+
const state = opaqueValue();
|
|
10627
|
+
const redirectUrl = new URL(GITHUB_AUTHORIZE_URL);
|
|
10628
|
+
redirectUrl.searchParams.set("client_id", provider.client_id);
|
|
10629
|
+
redirectUrl.searchParams.set("redirect_uri", provider.redirect_uri);
|
|
10630
|
+
redirectUrl.searchParams.set("scope", provider.scopes.join(" "));
|
|
10631
|
+
redirectUrl.searchParams.set("state", state);
|
|
10632
|
+
return {
|
|
10633
|
+
provider,
|
|
10634
|
+
state,
|
|
10635
|
+
// The persisted login-flow schema requires a verifier. GitHub OAuth Apps
|
|
10636
|
+
// authenticate this confidential client with its secret instead of PKCE.
|
|
10637
|
+
pkceVerifier: opaqueValue(),
|
|
10638
|
+
redirectUrl: redirectUrl.toString()
|
|
10639
|
+
};
|
|
10640
|
+
},
|
|
10641
|
+
async exchangeCallback({ provider, callbackUrl }) {
|
|
10642
|
+
const code = callbackUrl.searchParams.get("code");
|
|
10643
|
+
if (!code) throw new Error("GitHub OAuth callback did not include a code");
|
|
10644
|
+
const tokenResponse = await fetchImpl(GITHUB_TOKEN_URL, {
|
|
10645
|
+
method: "POST",
|
|
10646
|
+
headers: { ...githubHeaders(), "Content-Type": "application/x-www-form-urlencoded" },
|
|
10647
|
+
body: new URLSearchParams({
|
|
10648
|
+
client_id: provider.client_id,
|
|
10649
|
+
client_secret: provider.client_secret,
|
|
10650
|
+
code,
|
|
10651
|
+
redirect_uri: provider.redirect_uri
|
|
10652
|
+
}).toString()
|
|
10653
|
+
});
|
|
10654
|
+
const token = await jsonObject(tokenResponse, "GitHub OAuth token exchange failed");
|
|
10655
|
+
const accessToken = typeof token.access_token === "string" ? token.access_token : "";
|
|
10656
|
+
if (!accessToken) throw new Error("GitHub OAuth token exchange failed");
|
|
10657
|
+
const userResponse = await fetchImpl(`${GITHUB_API_URL}/user`, {
|
|
10658
|
+
headers: githubHeaders(accessToken)
|
|
10659
|
+
});
|
|
10660
|
+
const user = await jsonObject(userResponse, "GitHub user lookup failed");
|
|
10661
|
+
const login = typeof user.login === "string" ? user.login.trim().toLowerCase() : "";
|
|
10662
|
+
if (!login) throw new Error("GitHub user lookup failed");
|
|
10663
|
+
const organization = encodeURIComponent(provider.organization);
|
|
10664
|
+
const membershipResponse = await fetchImpl(
|
|
10665
|
+
`${GITHUB_API_URL}/user/memberships/orgs/${organization}`,
|
|
10666
|
+
{ headers: githubHeaders(accessToken) }
|
|
10667
|
+
);
|
|
10668
|
+
const membership = await jsonObject(
|
|
10669
|
+
membershipResponse,
|
|
10670
|
+
"GitHub organization membership is not active"
|
|
10671
|
+
);
|
|
10672
|
+
if (membership.state !== "active") {
|
|
10673
|
+
throw new Error("GitHub organization membership is not active");
|
|
10674
|
+
}
|
|
10675
|
+
return { claims: { ...user, login } };
|
|
10676
|
+
}
|
|
10677
|
+
};
|
|
10675
10678
|
}
|
|
10676
10679
|
|
|
10677
10680
|
// src/auth/oidc-client.ts
|
|
@@ -10752,6 +10755,88 @@ function createOpenIdClient() {
|
|
|
10752
10755
|
};
|
|
10753
10756
|
}
|
|
10754
10757
|
|
|
10758
|
+
// src/auth/auth-client.ts
|
|
10759
|
+
function createAuthClient(input) {
|
|
10760
|
+
const oidc = input?.oidc ?? createOpenIdClient();
|
|
10761
|
+
const github = input?.github ?? createGithubOauthClient();
|
|
10762
|
+
return {
|
|
10763
|
+
createAuthorizationRequest(provider) {
|
|
10764
|
+
return provider.kind === "oidc" ? oidc.createAuthorizationRequest(provider) : github.createAuthorizationRequest(provider);
|
|
10765
|
+
},
|
|
10766
|
+
exchangeCallback(request) {
|
|
10767
|
+
return request.provider.kind === "oidc" ? oidc.exchangeCallback({ ...request, provider: request.provider }) : github.exchangeCallback({ ...request, provider: request.provider });
|
|
10768
|
+
}
|
|
10769
|
+
};
|
|
10770
|
+
}
|
|
10771
|
+
|
|
10772
|
+
// src/auth/auth-config.ts
|
|
10773
|
+
import { parseDurationMs as parseDurationMs4 } from "@leitwerk-dev/watcher-utils";
|
|
10774
|
+
var DEFAULT_SESSION_COOKIE_NAME = "leitwerk_session";
|
|
10775
|
+
var DEFAULT_SESSION_TTL = "7d";
|
|
10776
|
+
var DEFAULT_LOGIN_FLOW_TTL_MS = 10 * 60 * 1e3;
|
|
10777
|
+
function resolveAuthConfig(config) {
|
|
10778
|
+
const auth = config.auth;
|
|
10779
|
+
const serverBaseUrl = new URL(config.server.base_url);
|
|
10780
|
+
const providers = (auth?.providers ?? []).map(
|
|
10781
|
+
(provider) => provider.kind === "oidc" ? {
|
|
10782
|
+
...provider,
|
|
10783
|
+
redirect_uri: provider.redirect_uri ?? new URL("/auth/callback", serverBaseUrl).toString(),
|
|
10784
|
+
scopes: provider.scopes ?? ["openid", "profile", "email"],
|
|
10785
|
+
identity_claim: provider.identity_claim ?? "preferred_username"
|
|
10786
|
+
} : {
|
|
10787
|
+
...provider,
|
|
10788
|
+
redirect_uri: provider.redirect_uri ?? new URL("/auth/callback", serverBaseUrl).toString(),
|
|
10789
|
+
scopes: ["read:org"],
|
|
10790
|
+
identity_claim: "login"
|
|
10791
|
+
}
|
|
10792
|
+
);
|
|
10793
|
+
const sessionCookieName = auth?.session?.cookie_name ?? DEFAULT_SESSION_COOKIE_NAME;
|
|
10794
|
+
return {
|
|
10795
|
+
enabled: auth?.enabled === true && providers.length > 0,
|
|
10796
|
+
sessionCookieName,
|
|
10797
|
+
loginFlowCookieName: `${sessionCookieName}_login`,
|
|
10798
|
+
sessionTtlMs: parseDurationMs4(
|
|
10799
|
+
auth?.session?.ttl ?? DEFAULT_SESSION_TTL,
|
|
10800
|
+
7 * 24 * 60 * 60 * 1e3,
|
|
10801
|
+
{
|
|
10802
|
+
allowHours: true
|
|
10803
|
+
}
|
|
10804
|
+
),
|
|
10805
|
+
loginFlowTtlMs: DEFAULT_LOGIN_FLOW_TTL_MS,
|
|
10806
|
+
secureCookies: serverBaseUrl.protocol === "https:",
|
|
10807
|
+
appBaseOrigin: serverBaseUrl.origin,
|
|
10808
|
+
providers,
|
|
10809
|
+
allowlist: new Set(auth?.allowlist ?? [])
|
|
10810
|
+
};
|
|
10811
|
+
}
|
|
10812
|
+
function isActorAllowedByConfig(actor, auth) {
|
|
10813
|
+
if (!auth.enabled) {
|
|
10814
|
+
return true;
|
|
10815
|
+
}
|
|
10816
|
+
if (actor.kind !== "user" || actor.provider === null) {
|
|
10817
|
+
return false;
|
|
10818
|
+
}
|
|
10819
|
+
if (!auth.providers.some((provider2) => provider2.id === actor.provider)) {
|
|
10820
|
+
return false;
|
|
10821
|
+
}
|
|
10822
|
+
const prefix = `${actor.provider}:`;
|
|
10823
|
+
if (!actor.id.startsWith(prefix)) return false;
|
|
10824
|
+
const provider = auth.providers.find((candidate) => candidate.id === actor.provider);
|
|
10825
|
+
return provider?.kind === "oauth2" || auth.allowlist.has(actor.id.slice(prefix.length));
|
|
10826
|
+
}
|
|
10827
|
+
|
|
10828
|
+
// src/auth/auth-tokens.ts
|
|
10829
|
+
import { createHash as createHash3, randomBytes as randomBytes3 } from "crypto";
|
|
10830
|
+
function generateOpaqueToken(byteLength = 32) {
|
|
10831
|
+
return randomBytes3(byteLength).toString("base64url");
|
|
10832
|
+
}
|
|
10833
|
+
function hashOpaqueToken(token) {
|
|
10834
|
+
return createHash3("sha256").update(token, "utf8").digest("base64url");
|
|
10835
|
+
}
|
|
10836
|
+
function isoFromNow(ms, now2 = /* @__PURE__ */ new Date()) {
|
|
10837
|
+
return new Date(now2.getTime() + ms).toISOString();
|
|
10838
|
+
}
|
|
10839
|
+
|
|
10755
10840
|
// src/auth/auth-service.ts
|
|
10756
10841
|
function pickDisplayName(claims, identity) {
|
|
10757
10842
|
for (const key of ["name", "preferred_username", "email"]) {
|
|
@@ -10786,7 +10871,9 @@ function consumeValidFlow(repos, cookieValue) {
|
|
|
10786
10871
|
}
|
|
10787
10872
|
function createAuthService(input) {
|
|
10788
10873
|
const auth = resolveAuthConfig(input.config);
|
|
10789
|
-
const
|
|
10874
|
+
const authClient = input.authClient ?? createAuthClient({
|
|
10875
|
+
oidc: input.oidcClient ?? createOpenIdClient()
|
|
10876
|
+
});
|
|
10790
10877
|
const sweepExpiredAuthState = () => ({
|
|
10791
10878
|
sessions: input.repos.authSessions.deleteExpired(),
|
|
10792
10879
|
loginFlows: input.repos.authLoginFlows.deleteExpired()
|
|
@@ -10800,7 +10887,7 @@ function createAuthService(input) {
|
|
|
10800
10887
|
throw new Error("Authentication is not enabled");
|
|
10801
10888
|
}
|
|
10802
10889
|
const provider = auth.providers[0];
|
|
10803
|
-
const login = await
|
|
10890
|
+
const login = await authClient.createAuthorizationRequest(provider);
|
|
10804
10891
|
const cookieValue = generateOpaqueToken();
|
|
10805
10892
|
const expiresAt = isoFromNow(auth.loginFlowTtlMs);
|
|
10806
10893
|
input.repos.authLoginFlows.create({
|
|
@@ -10826,9 +10913,9 @@ function createAuthService(input) {
|
|
|
10826
10913
|
throw new Error("Login provider is no longer configured");
|
|
10827
10914
|
}
|
|
10828
10915
|
if (callbackUrl.searchParams.get("state") !== flow.state) {
|
|
10829
|
-
throw new Error("Invalid
|
|
10916
|
+
throw new Error("Invalid authentication state");
|
|
10830
10917
|
}
|
|
10831
|
-
const exchanged = await
|
|
10918
|
+
const exchanged = await authClient.exchangeCallback({
|
|
10832
10919
|
provider,
|
|
10833
10920
|
callbackUrl,
|
|
10834
10921
|
state: flow.state,
|
|
@@ -10836,7 +10923,7 @@ function createAuthService(input) {
|
|
|
10836
10923
|
});
|
|
10837
10924
|
const actor = actorFromOidcClaims({ provider, claims: exchanged.claims });
|
|
10838
10925
|
if (!actor) {
|
|
10839
|
-
throw new Error(`
|
|
10926
|
+
throw new Error(`Authentication identity claim ${provider.identity_claim} was not present`);
|
|
10840
10927
|
}
|
|
10841
10928
|
if (!isActorAllowedByConfig(actor, auth)) {
|
|
10842
10929
|
throw new Error("Authenticated user is not allowlisted");
|
|
@@ -11941,13 +12028,41 @@ function createExternalSourceService(deps) {
|
|
|
11941
12028
|
};
|
|
11942
12029
|
}
|
|
11943
12030
|
|
|
11944
|
-
// src/
|
|
12031
|
+
// src/future-execution/lifecycle.ts
|
|
12032
|
+
import {
|
|
12033
|
+
normalizeLaunchModelConfigInput,
|
|
12034
|
+
SYSTEM_ACTOR as SYSTEM_ACTOR4
|
|
12035
|
+
} from "@leitwerk-dev/domain";
|
|
11945
12036
|
import {
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
|
|
11949
|
-
|
|
11950
|
-
|
|
12037
|
+
parseFutureActionPayloadJson as parseFutureActionPayloadJson3,
|
|
12038
|
+
parseFutureLaunchPayloadJson as parseFutureLaunchPayloadJson4,
|
|
12039
|
+
serializeFutureActionPayload,
|
|
12040
|
+
serializeFutureLaunchPayload,
|
|
12041
|
+
validateScheduleRequestInput
|
|
12042
|
+
} from "@leitwerk-dev/protocol";
|
|
12043
|
+
|
|
12044
|
+
// src/domain-logic/cron.ts
|
|
12045
|
+
import { CronExpressionParser } from "cron-parser";
|
|
12046
|
+
var CRON_FIELD_COUNT = 5;
|
|
12047
|
+
function splitCronFields(expression) {
|
|
12048
|
+
return expression.trim().split(/\s+/).filter((field) => field.length > 0);
|
|
12049
|
+
}
|
|
12050
|
+
function nextCronOccurrenceUtc(expression, after = /* @__PURE__ */ new Date()) {
|
|
12051
|
+
const fields = splitCronFields(expression);
|
|
12052
|
+
if (fields.length !== CRON_FIELD_COUNT) {
|
|
12053
|
+
throw new Error("Cron expression must have exactly 5 fields: minute hour day month weekday");
|
|
12054
|
+
}
|
|
12055
|
+
const next = CronExpressionParser.parse(expression, {
|
|
12056
|
+
currentDate: after,
|
|
12057
|
+
tz: "UTC",
|
|
12058
|
+
strict: false
|
|
12059
|
+
}).next();
|
|
12060
|
+
const nextIso = next.toISOString();
|
|
12061
|
+
if (!nextIso) {
|
|
12062
|
+
throw new Error("Couldn't compute the next cron occurrence");
|
|
12063
|
+
}
|
|
12064
|
+
return nextIso;
|
|
12065
|
+
}
|
|
11951
12066
|
|
|
11952
12067
|
// src/process-launch-executor.ts
|
|
11953
12068
|
function mapLaunchStartFailure(result) {
|
|
@@ -12248,139 +12363,6 @@ async function createProcessFromLaunchPlanWithDisposition(deps, launchPlan, opts
|
|
|
12248
12363
|
}
|
|
12249
12364
|
}
|
|
12250
12365
|
|
|
12251
|
-
// src/filesystem-process-watchers.ts
|
|
12252
|
-
function createFilesystemProcessWatchersService(args) {
|
|
12253
|
-
const watchers = args.processWatchers.listByType(
|
|
12254
|
-
"filesystem"
|
|
12255
|
-
);
|
|
12256
|
-
const loops = watchers.map(
|
|
12257
|
-
(watcher) => createPollLoop({
|
|
12258
|
-
pollInterval: () => watcher.pollInterval,
|
|
12259
|
-
isEnabled: () => watcher.enabled,
|
|
12260
|
-
defaultIntervalMs: 1e3,
|
|
12261
|
-
async pollOnce() {
|
|
12262
|
-
const result = emptyPollResult();
|
|
12263
|
-
if (watcher.config.type !== "filesystem") {
|
|
12264
|
-
return result;
|
|
12265
|
-
}
|
|
12266
|
-
const file = await readTriggerFile(watcher.config.file_path);
|
|
12267
|
-
if (!file.exists) {
|
|
12268
|
-
return result;
|
|
12269
|
-
}
|
|
12270
|
-
const content = file.content.trim();
|
|
12271
|
-
if (content.length === 0) {
|
|
12272
|
-
return result;
|
|
12273
|
-
}
|
|
12274
|
-
const resolved = await args.processWatchers.resolveLaunch(
|
|
12275
|
-
watcher.processId,
|
|
12276
|
-
watcher.watcherId,
|
|
12277
|
-
{ filePath: watcher.config.file_path, content }
|
|
12278
|
-
);
|
|
12279
|
-
if (!resolved) {
|
|
12280
|
-
result.skipped.push(`${watcher.processId}:${watcher.watcherId}`);
|
|
12281
|
-
return result;
|
|
12282
|
-
}
|
|
12283
|
-
const prepared = await args.launchPlans.prepare(resolved.launchPlan, {
|
|
12284
|
-
modelConfig: watcher.launchModelConfig,
|
|
12285
|
-
invalidModelConfig: "omit"
|
|
12286
|
-
});
|
|
12287
|
-
if (!prepared.ok) {
|
|
12288
|
-
result.errors.push(
|
|
12289
|
-
...prepared.errors.map(
|
|
12290
|
-
(error) => `${watcher.processId}:${watcher.watcherId}:${error.code}`
|
|
12291
|
-
)
|
|
12292
|
-
);
|
|
12293
|
-
args.logger?.warn(
|
|
12294
|
-
{
|
|
12295
|
-
processId: watcher.processId,
|
|
12296
|
-
watcherId: watcher.watcherId,
|
|
12297
|
-
filePath: watcher.config.file_path,
|
|
12298
|
-
errors: prepared.errors
|
|
12299
|
-
},
|
|
12300
|
-
"Filesystem process watcher launch plan preparation failed"
|
|
12301
|
-
);
|
|
12302
|
-
return result;
|
|
12303
|
-
}
|
|
12304
|
-
const created = await createProcessFromLaunchPlan(
|
|
12305
|
-
args.launchExecutorDeps,
|
|
12306
|
-
prepared.launchPlan
|
|
12307
|
-
);
|
|
12308
|
-
const durableProcess = created.ok ? created.process : created.stage === "post_commit" ? created.process : null;
|
|
12309
|
-
if (durableProcess) {
|
|
12310
|
-
await consumeTriggerFile(watcher.config.file_path);
|
|
12311
|
-
result.created.push(durableProcess.id);
|
|
12312
|
-
}
|
|
12313
|
-
if (!created.ok) {
|
|
12314
|
-
result.errors.push(
|
|
12315
|
-
`${watcher.processId}:${watcher.watcherId}:${created.status}:${String(created.body.error ?? "launch_failed")}`
|
|
12316
|
-
);
|
|
12317
|
-
args.logger?.warn(
|
|
12318
|
-
{
|
|
12319
|
-
processId: watcher.processId,
|
|
12320
|
-
watcherId: watcher.watcherId,
|
|
12321
|
-
filePath: watcher.config.file_path,
|
|
12322
|
-
status: created.status,
|
|
12323
|
-
body: created.body,
|
|
12324
|
-
durableProcessId: durableProcess?.id ?? null
|
|
12325
|
-
},
|
|
12326
|
-
"Filesystem process watcher launch failed"
|
|
12327
|
-
);
|
|
12328
|
-
return result;
|
|
12329
|
-
}
|
|
12330
|
-
return result;
|
|
12331
|
-
}
|
|
12332
|
-
})
|
|
12333
|
-
);
|
|
12334
|
-
return {
|
|
12335
|
-
start() {
|
|
12336
|
-
for (const loop of loops) {
|
|
12337
|
-
loop.start();
|
|
12338
|
-
}
|
|
12339
|
-
},
|
|
12340
|
-
stop() {
|
|
12341
|
-
for (const loop of loops) {
|
|
12342
|
-
loop.stop();
|
|
12343
|
-
}
|
|
12344
|
-
}
|
|
12345
|
-
};
|
|
12346
|
-
}
|
|
12347
|
-
|
|
12348
|
-
// src/future-execution/lifecycle.ts
|
|
12349
|
-
import {
|
|
12350
|
-
normalizeLaunchModelConfigInput,
|
|
12351
|
-
SYSTEM_ACTOR as SYSTEM_ACTOR4
|
|
12352
|
-
} from "@leitwerk-dev/domain";
|
|
12353
|
-
import {
|
|
12354
|
-
parseFutureActionPayloadJson as parseFutureActionPayloadJson3,
|
|
12355
|
-
parseFutureLaunchPayloadJson as parseFutureLaunchPayloadJson4,
|
|
12356
|
-
serializeFutureActionPayload,
|
|
12357
|
-
serializeFutureLaunchPayload,
|
|
12358
|
-
validateScheduleRequestInput
|
|
12359
|
-
} from "@leitwerk-dev/protocol";
|
|
12360
|
-
|
|
12361
|
-
// src/domain-logic/cron.ts
|
|
12362
|
-
import { CronExpressionParser } from "cron-parser";
|
|
12363
|
-
var CRON_FIELD_COUNT = 5;
|
|
12364
|
-
function splitCronFields(expression) {
|
|
12365
|
-
return expression.trim().split(/\s+/).filter((field) => field.length > 0);
|
|
12366
|
-
}
|
|
12367
|
-
function nextCronOccurrenceUtc(expression, after = /* @__PURE__ */ new Date()) {
|
|
12368
|
-
const fields = splitCronFields(expression);
|
|
12369
|
-
if (fields.length !== CRON_FIELD_COUNT) {
|
|
12370
|
-
throw new Error("Cron expression must have exactly 5 fields: minute hour day month weekday");
|
|
12371
|
-
}
|
|
12372
|
-
const next = CronExpressionParser.parse(expression, {
|
|
12373
|
-
currentDate: after,
|
|
12374
|
-
tz: "UTC",
|
|
12375
|
-
strict: false
|
|
12376
|
-
}).next();
|
|
12377
|
-
const nextIso = next.toISOString();
|
|
12378
|
-
if (!nextIso) {
|
|
12379
|
-
throw new Error("Couldn't compute the next cron occurrence");
|
|
12380
|
-
}
|
|
12381
|
-
return nextIso;
|
|
12382
|
-
}
|
|
12383
|
-
|
|
12384
12366
|
// src/process-launch-plan-model-config.ts
|
|
12385
12367
|
function clearLaunchPlanModelConfig(launchPlan) {
|
|
12386
12368
|
return {
|
|
@@ -13830,6 +13812,143 @@ function startFutureExecutionScheduler(lifecycle, options = {}) {
|
|
|
13830
13812
|
};
|
|
13831
13813
|
}
|
|
13832
13814
|
|
|
13815
|
+
// src/integration-tool-registry.ts
|
|
13816
|
+
import {
|
|
13817
|
+
RESERVED_INTEGRATION_TOOL_NAMES
|
|
13818
|
+
} from "@leitwerk-dev/process-sdk";
|
|
13819
|
+
var TOOL_NAME = /^[a-z][a-z0-9_]{0,63}$/;
|
|
13820
|
+
var RESERVED_TOOL_NAMES = new Set(RESERVED_INTEGRATION_TOOL_NAMES);
|
|
13821
|
+
function parseToolArgs(value) {
|
|
13822
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
13823
|
+
throw new Error("Integration tool arguments must be an object");
|
|
13824
|
+
}
|
|
13825
|
+
return value;
|
|
13826
|
+
}
|
|
13827
|
+
var IntegrationToolRegistry = class {
|
|
13828
|
+
tools = /* @__PURE__ */ new Map();
|
|
13829
|
+
executions = /* @__PURE__ */ new Map();
|
|
13830
|
+
register(definition) {
|
|
13831
|
+
const name = definition.name;
|
|
13832
|
+
if (!TOOL_NAME.test(name)) {
|
|
13833
|
+
throw new Error(`Integration tool '${definition.name}' must match ${TOOL_NAME}`);
|
|
13834
|
+
}
|
|
13835
|
+
if (RESERVED_TOOL_NAMES.has(name)) {
|
|
13836
|
+
throw new Error(`Integration tool '${name}' uses a reserved tool name`);
|
|
13837
|
+
}
|
|
13838
|
+
if (definition.description.trim() === "") {
|
|
13839
|
+
throw new Error(`Integration tool '${name}' requires a description`);
|
|
13840
|
+
}
|
|
13841
|
+
if (this.tools.has(name)) throw new Error(`Duplicate integration tool '${name}'`);
|
|
13842
|
+
this.tools.set(name, definition);
|
|
13843
|
+
}
|
|
13844
|
+
declarations(names) {
|
|
13845
|
+
return names.map((name) => {
|
|
13846
|
+
const definition = this.tools.get(name);
|
|
13847
|
+
if (!definition) throw new Error(`Unknown integration tool '${name}'`);
|
|
13848
|
+
return {
|
|
13849
|
+
name: definition.name,
|
|
13850
|
+
description: definition.description,
|
|
13851
|
+
parameters: definition.parameters
|
|
13852
|
+
};
|
|
13853
|
+
});
|
|
13854
|
+
}
|
|
13855
|
+
execute(name, args, ctx) {
|
|
13856
|
+
const definition = this.tools.get(name);
|
|
13857
|
+
if (!definition) return Promise.reject(new Error(`Unknown integration tool '${name}'`));
|
|
13858
|
+
const existing = this.executions.get(ctx.idempotencyKey);
|
|
13859
|
+
if (existing) return existing.promise;
|
|
13860
|
+
const controller = new AbortController();
|
|
13861
|
+
const promise = Promise.resolve().then(() => {
|
|
13862
|
+
if (controller.signal.aborted) {
|
|
13863
|
+
throw new Error("Integration tool execution cancelled");
|
|
13864
|
+
}
|
|
13865
|
+
return definition.execute(
|
|
13866
|
+
{ ...ctx, signal: controller.signal },
|
|
13867
|
+
definition.parse?.(args) ?? parseToolArgs(args)
|
|
13868
|
+
);
|
|
13869
|
+
}).finally(() => this.executions.delete(ctx.idempotencyKey));
|
|
13870
|
+
this.executions.set(ctx.idempotencyKey, { controller, promise });
|
|
13871
|
+
return promise;
|
|
13872
|
+
}
|
|
13873
|
+
cancel(idempotencyKey) {
|
|
13874
|
+
const execution = this.executions.get(idempotencyKey);
|
|
13875
|
+
if (!execution) return false;
|
|
13876
|
+
execution.controller.abort();
|
|
13877
|
+
return true;
|
|
13878
|
+
}
|
|
13879
|
+
};
|
|
13880
|
+
function integrationToolIdempotencyKey(input) {
|
|
13881
|
+
return `${input.instanceId}:${input.turnRecordId}:${input.toolCallId}:${input.toolName}`;
|
|
13882
|
+
}
|
|
13883
|
+
function createIntegrationToolRequestService(input) {
|
|
13884
|
+
return {
|
|
13885
|
+
cancel(instanceId, payload) {
|
|
13886
|
+
return input.registry.cancel(
|
|
13887
|
+
integrationToolIdempotencyKey({
|
|
13888
|
+
instanceId,
|
|
13889
|
+
turnRecordId: payload.turnRecordId,
|
|
13890
|
+
toolCallId: payload.toolCallId,
|
|
13891
|
+
toolName: payload.toolName
|
|
13892
|
+
})
|
|
13893
|
+
);
|
|
13894
|
+
},
|
|
13895
|
+
async handle(instanceId, payload) {
|
|
13896
|
+
const fail = (error) => ({
|
|
13897
|
+
turnRecordId: payload.turnRecordId,
|
|
13898
|
+
toolCallId: payload.toolCallId,
|
|
13899
|
+
ok: false,
|
|
13900
|
+
error
|
|
13901
|
+
});
|
|
13902
|
+
const process2 = input.repos.processes.getById(instanceId);
|
|
13903
|
+
const turn = input.repos.turnRecords.getById(payload.turnRecordId);
|
|
13904
|
+
if (!process2 || !turn || turn.instanceId !== instanceId || turn.status !== "running") {
|
|
13905
|
+
return fail("Integration tool call does not belong to the active running turn");
|
|
13906
|
+
}
|
|
13907
|
+
const currentStart = process2.currentExecution?.kind === "worker_start" ? input.repos.turnStarts.getById(process2.currentExecution.id) : null;
|
|
13908
|
+
const expectedTurnRecordId = currentStart?.state.kind === "accepted" ? currentStart.state.turnRecordId : null;
|
|
13909
|
+
if (expectedTurnRecordId !== payload.turnRecordId) {
|
|
13910
|
+
return fail("Integration tool call targets a stale turn record");
|
|
13911
|
+
}
|
|
13912
|
+
if (process2.selectedTurnId !== turn.turnId) {
|
|
13913
|
+
return fail("Integration tool call targets a stale turn");
|
|
13914
|
+
}
|
|
13915
|
+
const turnDefinition = input.processActionRegistry.getTurnDefinition(
|
|
13916
|
+
process2.processId,
|
|
13917
|
+
turn.turnId
|
|
13918
|
+
);
|
|
13919
|
+
if (turnDefinition?.kind !== "llm" || !turnDefinition.integrationTools?.includes(payload.toolName)) {
|
|
13920
|
+
return fail(`Integration tool '${payload.toolName}' is not authorized for this turn`);
|
|
13921
|
+
}
|
|
13922
|
+
const projects = input.repos.projects.listByInstance(instanceId);
|
|
13923
|
+
const projectKey = typeof payload.args.projectKey === "string" ? payload.args.projectKey : null;
|
|
13924
|
+
const project = projectKey ? projects.find((candidate) => candidate.key === projectKey) ?? null : null;
|
|
13925
|
+
if (projectKey && !project) return fail(`Unknown process project '${projectKey}'`);
|
|
13926
|
+
try {
|
|
13927
|
+
const result = await input.registry.execute(payload.toolName, payload.args, {
|
|
13928
|
+
process: process2,
|
|
13929
|
+
projects,
|
|
13930
|
+
turn,
|
|
13931
|
+
project,
|
|
13932
|
+
idempotencyKey: integrationToolIdempotencyKey({
|
|
13933
|
+
instanceId,
|
|
13934
|
+
turnRecordId: payload.turnRecordId,
|
|
13935
|
+
toolCallId: payload.toolCallId,
|
|
13936
|
+
toolName: payload.toolName
|
|
13937
|
+
})
|
|
13938
|
+
});
|
|
13939
|
+
return {
|
|
13940
|
+
turnRecordId: payload.turnRecordId,
|
|
13941
|
+
toolCallId: payload.toolCallId,
|
|
13942
|
+
ok: true,
|
|
13943
|
+
result
|
|
13944
|
+
};
|
|
13945
|
+
} catch (error) {
|
|
13946
|
+
return fail(error instanceof Error ? error.message : "Integration tool execution failed");
|
|
13947
|
+
}
|
|
13948
|
+
}
|
|
13949
|
+
};
|
|
13950
|
+
}
|
|
13951
|
+
|
|
13833
13952
|
// src/launcher-model-config-service.ts
|
|
13834
13953
|
import {
|
|
13835
13954
|
findUiLauncherById
|
|
@@ -14421,7 +14540,7 @@ async function reconcilePersistedProcessModelIntegrity(input) {
|
|
|
14421
14540
|
}
|
|
14422
14541
|
|
|
14423
14542
|
// src/process-model-selection.ts
|
|
14424
|
-
import { trimToNull as
|
|
14543
|
+
import { trimToNull as trimToNull2 } from "@leitwerk-dev/domain";
|
|
14425
14544
|
import {
|
|
14426
14545
|
isLlmTurnDefinition as isLlmTurnDefinition5
|
|
14427
14546
|
} from "@leitwerk-dev/process-sdk";
|
|
@@ -14587,7 +14706,7 @@ function createProcessModelSelection(deps) {
|
|
|
14587
14706
|
return {
|
|
14588
14707
|
kind: "not_applicable",
|
|
14589
14708
|
turnId,
|
|
14590
|
-
description:
|
|
14709
|
+
description: trimToNull2(candidateTurnDef?.description) ?? turnId
|
|
14591
14710
|
};
|
|
14592
14711
|
}
|
|
14593
14712
|
const policyResult = deps.processModelPolicy.evaluate({
|
|
@@ -14619,7 +14738,7 @@ function createProcessModelSelection(deps) {
|
|
|
14619
14738
|
return {
|
|
14620
14739
|
kind: "llm_turn",
|
|
14621
14740
|
turnId,
|
|
14622
|
-
description:
|
|
14741
|
+
description: trimToNull2(candidateTurnDef.description) ?? turnId,
|
|
14623
14742
|
resolvedModel: nextTurnModel.resolvedModel,
|
|
14624
14743
|
warmPromptCache: nextTurnModel.warmPromptCache
|
|
14625
14744
|
};
|
|
@@ -17433,6 +17552,7 @@ ${configErrors.join("\n")}`);
|
|
|
17433
17552
|
const processOperations = createProcessOperationCoordinator();
|
|
17434
17553
|
const processGraphs = extensionCatalog.processes;
|
|
17435
17554
|
const processActionRegistry = buildProcessActionRegistry(extensionCatalog);
|
|
17555
|
+
const integrationTools = new IntegrationToolRegistry();
|
|
17436
17556
|
const processUiRegistry = buildProcessUiRegistry(extensionCatalog);
|
|
17437
17557
|
const processModelPolicy = createServerProcessModelPolicy({
|
|
17438
17558
|
config,
|
|
@@ -17469,18 +17589,10 @@ ${configErrors.join("\n")}`);
|
|
|
17469
17589
|
commitMessages: config.commit_messages,
|
|
17470
17590
|
getModelProfilesForProcess
|
|
17471
17591
|
});
|
|
17472
|
-
const processWatcherConfigErrors = validateConfiguredProcessWatchersAgainstCatalog({
|
|
17473
|
-
config,
|
|
17474
|
-
catalog: extensionCatalog,
|
|
17475
|
-
processModelPolicy
|
|
17476
|
-
});
|
|
17477
|
-
if (processWatcherConfigErrors.length > 0) {
|
|
17478
|
-
throw new Error(`Invalid process watcher config:
|
|
17479
|
-
${processWatcherConfigErrors.join("\n")}`);
|
|
17480
|
-
}
|
|
17481
17592
|
const processWatcherService = buildProcessWatcherRegistry(extensionCatalog, config, {
|
|
17482
17593
|
modelProfiles: launcherModelProfiles,
|
|
17483
|
-
getModelProfilesForProcess
|
|
17594
|
+
getModelProfilesForProcess,
|
|
17595
|
+
processModelPolicy
|
|
17484
17596
|
});
|
|
17485
17597
|
const workerWebSocketIpc = createWorkerWebSocketIpcManager();
|
|
17486
17598
|
workerWebSocketIpc.setUnknownWorkerConnectionsRetryable(true);
|
|
@@ -17736,6 +17848,11 @@ ${processWatcherConfigErrors.join("\n")}`);
|
|
|
17736
17848
|
)
|
|
17737
17849
|
)
|
|
17738
17850
|
});
|
|
17851
|
+
const integrationToolRequests = createIntegrationToolRequestService({
|
|
17852
|
+
registry: integrationTools,
|
|
17853
|
+
repos: baseDeps,
|
|
17854
|
+
processActionRegistry
|
|
17855
|
+
});
|
|
17739
17856
|
const ipcHandler = createIpcHandler(
|
|
17740
17857
|
{
|
|
17741
17858
|
processes: baseDeps.processes,
|
|
@@ -17744,6 +17861,8 @@ ${processWatcherConfigErrors.join("\n")}`);
|
|
|
17744
17861
|
events: baseDeps.events,
|
|
17745
17862
|
leases: baseDeps.leases,
|
|
17746
17863
|
turnRecords: baseDeps.turnRecords,
|
|
17864
|
+
handleIntegrationToolRequest: (instanceId, payload) => integrationToolRequests.handle(instanceId, payload),
|
|
17865
|
+
handleIntegrationToolCancel: (instanceId, payload) => void integrationToolRequests.cancel(instanceId, payload),
|
|
17747
17866
|
processQuestions,
|
|
17748
17867
|
broadcaster,
|
|
17749
17868
|
commands: processEngine,
|
|
@@ -17778,6 +17897,9 @@ ${processWatcherConfigErrors.join("\n")}`);
|
|
|
17778
17897
|
},
|
|
17779
17898
|
onCredentialUpdateResult(instanceId, workerId, payload) {
|
|
17780
17899
|
supervisor?.credentialUpdateResult(instanceId, workerId, payload);
|
|
17900
|
+
},
|
|
17901
|
+
onIntegrationToolResult(instanceId, workerId, payload) {
|
|
17902
|
+
supervisor?.integrationToolResult(instanceId, workerId, payload);
|
|
17781
17903
|
}
|
|
17782
17904
|
}
|
|
17783
17905
|
);
|
|
@@ -17810,6 +17932,7 @@ ${processWatcherConfigErrors.join("\n")}`);
|
|
|
17810
17932
|
return piResourceBundles.get(digest);
|
|
17811
17933
|
},
|
|
17812
17934
|
resolveRepositoryCredentials: (input) => repositoryCredentials.resolveWorkerCredentials(input),
|
|
17935
|
+
integrationTools,
|
|
17813
17936
|
resolveCredential(providerId, options) {
|
|
17814
17937
|
const credential = modelProviderCredentials.resolve(providerId, options);
|
|
17815
17938
|
return credential && credential.revision !== null ? {
|
|
@@ -17948,27 +18071,6 @@ ${processWatcherConfigErrors.join("\n")}`);
|
|
|
17948
18071
|
broadcaster,
|
|
17949
18072
|
logger: app.log
|
|
17950
18073
|
});
|
|
17951
|
-
const filesystemProcessWatchers = createFilesystemProcessWatchersService({
|
|
17952
|
-
processWatchers: processWatcherService,
|
|
17953
|
-
launchPlans,
|
|
17954
|
-
launchExecutorDeps: {
|
|
17955
|
-
commitMessages: config.commit_messages,
|
|
17956
|
-
processes: baseDeps.processes,
|
|
17957
|
-
projects: baseDeps.projects,
|
|
17958
|
-
processSkills: baseDeps.processSkills,
|
|
17959
|
-
handoffDedupKeys: baseDeps.handoffDedupKeys,
|
|
17960
|
-
futureExecutions: baseDeps.futureExecutions,
|
|
17961
|
-
transaction: baseDeps.transaction,
|
|
17962
|
-
broadcaster,
|
|
17963
|
-
commands: processEngine,
|
|
17964
|
-
processTitles,
|
|
17965
|
-
extensionHost,
|
|
17966
|
-
logger: app.log
|
|
17967
|
-
},
|
|
17968
|
-
logger: app.log
|
|
17969
|
-
});
|
|
17970
|
-
startHooks.push(() => filesystemProcessWatchers.start());
|
|
17971
|
-
stopHooks.push(() => filesystemProcessWatchers.stop());
|
|
17972
18074
|
const processActionListDeps = {
|
|
17973
18075
|
projects: baseDeps.projects,
|
|
17974
18076
|
futureExecutions: baseDeps.futureExecutions,
|
|
@@ -18023,6 +18125,7 @@ ${processWatcherConfigErrors.join("\n")}`);
|
|
|
18023
18125
|
provide: hostCapabilities.provide.bind(hostCapabilities),
|
|
18024
18126
|
get: hostCapabilities.get.bind(hostCapabilities),
|
|
18025
18127
|
require: hostCapabilities.require.bind(hostCapabilities),
|
|
18128
|
+
tool: (definition) => integrationTools.register(definition),
|
|
18026
18129
|
onStart(handler) {
|
|
18027
18130
|
startHooks.push(handler);
|
|
18028
18131
|
},
|
|
@@ -18032,6 +18135,19 @@ ${processWatcherConfigErrors.join("\n")}`);
|
|
|
18032
18135
|
},
|
|
18033
18136
|
(id) => config.extensions?.[id]
|
|
18034
18137
|
);
|
|
18138
|
+
for (const process2 of extensionCatalog.processes.values()) {
|
|
18139
|
+
for (const [turnId, binding] of process2.turns) {
|
|
18140
|
+
const definition = binding.definition;
|
|
18141
|
+
if (definition.kind !== "llm" || !definition.integrationTools?.length) continue;
|
|
18142
|
+
try {
|
|
18143
|
+
integrationTools.declarations(definition.integrationTools);
|
|
18144
|
+
} catch (error) {
|
|
18145
|
+
throw new Error(
|
|
18146
|
+
`Invalid integration tools for process '${process2.id}' turn '${turnId}': ${error instanceof Error ? error.message : String(error)}`
|
|
18147
|
+
);
|
|
18148
|
+
}
|
|
18149
|
+
}
|
|
18150
|
+
}
|
|
18035
18151
|
markStartup("server_extensions");
|
|
18036
18152
|
const deps = {
|
|
18037
18153
|
...baseDeps,
|
|
@@ -18160,7 +18276,6 @@ export {
|
|
|
18160
18276
|
buildProcessTitleSourceFields,
|
|
18161
18277
|
buildProcessTitlePrompt,
|
|
18162
18278
|
createProcessTitleGenerator,
|
|
18163
|
-
validateConfiguredProcessWatchersAgainstCatalog,
|
|
18164
18279
|
buildProcessWatcherRegistry,
|
|
18165
18280
|
ResultImageStore,
|
|
18166
18281
|
registerUiRendererRoutes,
|
|
@@ -18174,4 +18289,4 @@ export {
|
|
|
18174
18289
|
createApp,
|
|
18175
18290
|
createAppContext
|
|
18176
18291
|
};
|
|
18177
|
-
//# sourceMappingURL=chunk-
|
|
18292
|
+
//# sourceMappingURL=chunk-OO6VH4FX.js.map
|