clinkx 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/clinkx-workflows/dist/clink-client.js +35 -10
- package/clinkx-workflows/dist/clink-client.js.map +1 -1
- package/clinkx-workflows/dist/config.d.ts +10 -0
- package/clinkx-workflows/dist/config.js +18 -0
- package/clinkx-workflows/dist/config.js.map +1 -1
- package/clinkx-workflows/dist/council-expander.d.ts +43 -0
- package/clinkx-workflows/dist/council-expander.js +330 -0
- package/clinkx-workflows/dist/council-expander.js.map +1 -0
- package/clinkx-workflows/dist/index.d.ts +14 -0
- package/clinkx-workflows/dist/index.js +264 -16
- package/clinkx-workflows/dist/index.js.map +1 -1
- package/clinkx-workflows/dist/server.d.ts +8 -1
- package/clinkx-workflows/dist/server.js +87 -1
- package/clinkx-workflows/dist/server.js.map +1 -1
- package/clinkx-workflows/dist/shutdown.d.ts +5 -9
- package/clinkx-workflows/dist/shutdown.js +6 -23
- package/clinkx-workflows/dist/shutdown.js.map +1 -1
- package/clinkx-workflows/dist/state.d.ts +13 -0
- package/clinkx-workflows/dist/state.js +198 -2
- package/clinkx-workflows/dist/state.js.map +1 -1
- package/clinkx-workflows/dist/transport.js +24 -8
- package/clinkx-workflows/dist/transport.js.map +1 -1
- package/clinkx-workflows/dist/workflow-tools.d.ts +14 -1
- package/clinkx-workflows/dist/workflow-tools.js +173 -12
- package/clinkx-workflows/dist/workflow-tools.js.map +1 -1
- package/clinkx-workflows/dist/workflows/index.d.ts +4 -3
- package/clinkx-workflows/dist/workflows/index.js +4 -3
- package/clinkx-workflows/dist/workflows/index.js.map +1 -1
- package/clinkx-workflows/templates/council/answer-chairman.txt +49 -0
- package/clinkx-workflows/templates/council/answer-cross-reviewer.txt +37 -0
- package/clinkx-workflows/templates/council/answer-specialist.txt +40 -0
- package/clinkx-workflows/templates/council/chairman.txt +59 -0
- package/clinkx-workflows/templates/council/code-review-chairman.txt +57 -0
- package/clinkx-workflows/templates/council/code-review-cross-reviewer.txt +43 -0
- package/clinkx-workflows/templates/council/code-review-reviewer.txt +39 -0
- package/clinkx-workflows/templates/council/debug-chairman.txt +57 -0
- package/clinkx-workflows/templates/council/debug-cross-reviewer.txt +41 -0
- package/clinkx-workflows/templates/council/debug-debugger.txt +46 -0
- package/clinkx-workflows/templates/council/discover-analyst.txt +38 -0
- package/clinkx-workflows/templates/council/discover-chairman.txt +51 -0
- package/clinkx-workflows/templates/council/discover-cross-reviewer.txt +40 -0
- package/clinkx-workflows/templates/council/member.txt +48 -0
- package/clinkx-workflows/templates/council/reviewer.txt +57 -0
- package/clinkx-workflows/workflows/council-answer.yaml +147 -0
- package/clinkx-workflows/workflows/council-code-review.yaml +152 -0
- package/clinkx-workflows/workflows/council-debug.yaml +152 -0
- package/clinkx-workflows/workflows/council-default.yaml +147 -0
- package/clinkx-workflows/workflows/council-discover.yaml +147 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +246 -14
- package/dist/index.js.map +1 -1
- package/dist/pipeline.d.ts +1 -1
- package/dist/pipeline.js +29 -5
- package/dist/pipeline.js.map +1 -1
- package/dist/runner.d.ts +2 -2
- package/dist/runner.js +24 -3
- package/dist/runner.js.map +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/package.json +5 -2
- package/clinkx-workflows/dist/workflows/council-default.d.ts +0 -123
- package/clinkx-workflows/dist/workflows/council-default.js +0 -141
- package/clinkx-workflows/dist/workflows/council-default.js.map +0 -1
|
@@ -11,32 +11,280 @@
|
|
|
11
11
|
* for in-process integration (Option C).
|
|
12
12
|
*/
|
|
13
13
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
+
import { serializeMessage } from "@modelcontextprotocol/sdk/shared/stdio.js";
|
|
15
|
+
import { realpathSync } from "node:fs";
|
|
16
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
14
17
|
import { createWorkflowServer } from "./server.js";
|
|
15
18
|
import { logger, assertStderrLogger } from "./logger.js";
|
|
19
|
+
import { shutdownCoordinator } from "./shutdown.js";
|
|
16
20
|
export { registerWorkflowTools, getWorkflowToolDefinitions, handleWorkflowToolCall, WORKFLOW_TOOL_NAMES, } from "./workflow-tools.js";
|
|
17
21
|
export { createWorkflowServer } from "./server.js";
|
|
22
|
+
const SHUTDOWN_DEADLINE_MS = 10_000;
|
|
23
|
+
const SEND_TIMEOUT_MS = 30_000;
|
|
24
|
+
const patchedTransports = new WeakSet();
|
|
25
|
+
function serializeError(err) {
|
|
26
|
+
return err instanceof Error ? err.message : String(err);
|
|
27
|
+
}
|
|
28
|
+
function toError(err) {
|
|
29
|
+
return err instanceof Error ? err : new Error(String(err));
|
|
30
|
+
}
|
|
31
|
+
function extractRpcMeta(msg) {
|
|
32
|
+
if ("method" in msg) {
|
|
33
|
+
return "id" in msg && msg.id !== undefined ? { id: msg.id, method: msg.method } : { method: msg.method };
|
|
34
|
+
}
|
|
35
|
+
if ("id" in msg && msg.id !== undefined)
|
|
36
|
+
return { id: msg.id };
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
export function patchTransportSend(transport, stdout = process.stdout, onBrokenStdout) {
|
|
40
|
+
if (patchedTransports.has(transport))
|
|
41
|
+
return;
|
|
42
|
+
patchedTransports.add(transport);
|
|
43
|
+
let brokenError;
|
|
44
|
+
let sendChain = Promise.resolve();
|
|
45
|
+
const pendingRejects = [];
|
|
46
|
+
let shuttingDown = false;
|
|
47
|
+
function markBroken(err) {
|
|
48
|
+
brokenError ??= err;
|
|
49
|
+
const rejects = pendingRejects.splice(0);
|
|
50
|
+
for (const reject of rejects) {
|
|
51
|
+
reject(brokenError);
|
|
52
|
+
}
|
|
53
|
+
if (!shuttingDown) {
|
|
54
|
+
shuttingDown = true;
|
|
55
|
+
stdout.off("error", onError);
|
|
56
|
+
onBrokenStdout?.();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function onError(err) {
|
|
60
|
+
markBroken(err);
|
|
61
|
+
}
|
|
62
|
+
stdout.on("error", onError);
|
|
63
|
+
function sendOne(message) {
|
|
64
|
+
if (brokenError !== undefined) {
|
|
65
|
+
return Promise.reject(brokenError);
|
|
66
|
+
}
|
|
67
|
+
const json = serializeMessage(message);
|
|
68
|
+
const payloadBytes = Buffer.byteLength(json, "utf8");
|
|
69
|
+
const { id: rpcId, method: rpcMethod } = extractRpcMeta(message);
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
if (brokenError !== undefined) {
|
|
72
|
+
reject(brokenError);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
let settled = false;
|
|
76
|
+
let drainAttached = false;
|
|
77
|
+
let drainStartedAt = 0;
|
|
78
|
+
const timeout = setTimeout(() => {
|
|
79
|
+
logger.error({ rpcId, rpcMethod, payloadBytes }, "transport:send:timeout");
|
|
80
|
+
markBroken(new Error(`stdout write timed out after ${SEND_TIMEOUT_MS}ms`));
|
|
81
|
+
}, SEND_TIMEOUT_MS);
|
|
82
|
+
timeout.unref();
|
|
83
|
+
function cleanup() {
|
|
84
|
+
clearTimeout(timeout);
|
|
85
|
+
const index = pendingRejects.indexOf(onStdoutError);
|
|
86
|
+
if (index !== -1) {
|
|
87
|
+
pendingRejects.splice(index, 1);
|
|
88
|
+
}
|
|
89
|
+
if (drainAttached) {
|
|
90
|
+
stdout.off("drain", onDrain);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function settleResolve() {
|
|
94
|
+
if (settled)
|
|
95
|
+
return;
|
|
96
|
+
settled = true;
|
|
97
|
+
const drainMs = drainStartedAt === 0 ? 0 : Date.now() - drainStartedAt;
|
|
98
|
+
cleanup();
|
|
99
|
+
logger.debug({ rpcId, rpcMethod, payloadBytes, drainMs }, "transport:send:ok");
|
|
100
|
+
resolve();
|
|
101
|
+
}
|
|
102
|
+
function settleReject(err) {
|
|
103
|
+
if (settled)
|
|
104
|
+
return;
|
|
105
|
+
settled = true;
|
|
106
|
+
cleanup();
|
|
107
|
+
reject(err);
|
|
108
|
+
}
|
|
109
|
+
function onStdoutError(err) {
|
|
110
|
+
settleReject(err);
|
|
111
|
+
}
|
|
112
|
+
function onDrain() {
|
|
113
|
+
settleResolve();
|
|
114
|
+
}
|
|
115
|
+
pendingRejects.push(onStdoutError);
|
|
116
|
+
try {
|
|
117
|
+
logger.debug({ rpcId, rpcMethod, payloadBytes, writableLength: stdout.writableLength }, "transport:send:start");
|
|
118
|
+
if (stdout.write(json)) {
|
|
119
|
+
settleResolve();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
drainAttached = true;
|
|
123
|
+
drainStartedAt = Date.now();
|
|
124
|
+
stdout.once("drain", onDrain);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
const error = toError(err);
|
|
129
|
+
const nodeError = error;
|
|
130
|
+
logger.error({
|
|
131
|
+
rpcId,
|
|
132
|
+
rpcMethod,
|
|
133
|
+
payloadBytes,
|
|
134
|
+
errCode: nodeError.code,
|
|
135
|
+
errSyscall: nodeError.syscall,
|
|
136
|
+
}, "transport:send:error");
|
|
137
|
+
markBroken(error);
|
|
138
|
+
settleReject(error);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
transport.send = (message) => {
|
|
143
|
+
const send = sendChain.then(() => sendOne(message), () => sendOne(message));
|
|
144
|
+
sendChain = send.catch(() => undefined);
|
|
145
|
+
return send;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export function createShutdownOnce(server, options = {}) {
|
|
149
|
+
let shutdownStarted = false;
|
|
150
|
+
const cleanup = options.cleanup ?? (() => Promise.resolve());
|
|
151
|
+
const exit = options.exit ?? process.exit.bind(process);
|
|
152
|
+
return async function shutdownOnce(reason, exitCode) {
|
|
153
|
+
if (shutdownStarted) {
|
|
154
|
+
logger.warn({ reason }, "duplicate shutdown event ignored");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
shutdownStarted = true;
|
|
158
|
+
logger.info({ reason, exit_code: exitCode, pid: process.pid, writableLength: process.stdout.writableLength }, "clinkx-workflows:shutdown");
|
|
159
|
+
const deadline = new Promise((_, reject) => {
|
|
160
|
+
setTimeout(() => reject(new Error("shutdown deadline exceeded")), SHUTDOWN_DEADLINE_MS).unref();
|
|
161
|
+
});
|
|
162
|
+
try {
|
|
163
|
+
await Promise.race([
|
|
164
|
+
(async () => {
|
|
165
|
+
let effectiveExitCode = exitCode;
|
|
166
|
+
logger.info({ reason, exit_code: exitCode }, "shutdown requested");
|
|
167
|
+
try {
|
|
168
|
+
await cleanup(reason);
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
effectiveExitCode = 1;
|
|
172
|
+
logger.error({ reason, err: serializeError(err) }, "shutdown cleanup failed");
|
|
173
|
+
}
|
|
174
|
+
try {
|
|
175
|
+
await server.close();
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
effectiveExitCode = 1;
|
|
179
|
+
logger.error({ reason, err: serializeError(err) }, "server close failed during shutdown");
|
|
180
|
+
}
|
|
181
|
+
if (process.stdout.writableLength > 0 && process.stdout.writable) {
|
|
182
|
+
await new Promise((resolve) => {
|
|
183
|
+
const onDrain = () => {
|
|
184
|
+
clearTimeout(timer);
|
|
185
|
+
resolve();
|
|
186
|
+
};
|
|
187
|
+
const timer = setTimeout(() => {
|
|
188
|
+
process.stdout.off("drain", onDrain);
|
|
189
|
+
resolve();
|
|
190
|
+
}, 2_000);
|
|
191
|
+
timer.unref();
|
|
192
|
+
process.stdout.once("drain", onDrain);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
exit(effectiveExitCode);
|
|
196
|
+
})(),
|
|
197
|
+
deadline,
|
|
198
|
+
]);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
try {
|
|
202
|
+
logger.error({ reason }, "shutdown deadline exceeded, forcing exit");
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// Logger may be unavailable during stream failures.
|
|
206
|
+
}
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
export function installShutdownHandlers(shutdownOnce, targetProcess = process) {
|
|
212
|
+
const runShutdown = (reason, exitCode) => {
|
|
213
|
+
void shutdownOnce(reason, exitCode).catch((err) => {
|
|
214
|
+
try {
|
|
215
|
+
logger.fatal({ reason, err: serializeError(err) }, "shutdown failed");
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// Logger may be unavailable during stream failures.
|
|
219
|
+
}
|
|
220
|
+
targetProcess.exit(1);
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
targetProcess.once("SIGTERM", () => runShutdown("SIGTERM", 0));
|
|
224
|
+
targetProcess.once("SIGINT", () => runShutdown("SIGINT", 0));
|
|
225
|
+
targetProcess.once("SIGHUP", () => runShutdown("SIGHUP", 0));
|
|
226
|
+
targetProcess.stdin.once("end", () => runShutdown("stdin:end", 0));
|
|
227
|
+
targetProcess.stdin.once("close", () => runShutdown("stdin:close", 0));
|
|
228
|
+
targetProcess.stdin.once("error", () => runShutdown("stdin:error", 1));
|
|
229
|
+
targetProcess.stderr.on("error", () => runShutdown("stderr:error", 0));
|
|
230
|
+
targetProcess.on("uncaughtException", (err) => {
|
|
231
|
+
try {
|
|
232
|
+
logger.fatal({ err }, "uncaught exception");
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
// Logger may be unavailable during fatal shutdown.
|
|
236
|
+
}
|
|
237
|
+
runShutdown("uncaughtException", 1);
|
|
238
|
+
});
|
|
239
|
+
targetProcess.on("unhandledRejection", (reason) => {
|
|
240
|
+
try {
|
|
241
|
+
logger.fatal({ err: reason }, "unhandled rejection");
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
// Logger may be unavailable during fatal shutdown.
|
|
245
|
+
}
|
|
246
|
+
runShutdown("unhandledRejection", 1);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
18
249
|
async function main() {
|
|
19
250
|
assertStderrLogger();
|
|
20
251
|
const server = createWorkflowServer();
|
|
21
252
|
const transport = new StdioServerTransport();
|
|
22
253
|
logger.info("clinkx-workflows MCP server starting (STDIO transport)");
|
|
254
|
+
logger.info({ pid: process.pid, ppid: process.ppid }, "clinkx-workflows:startup");
|
|
255
|
+
const shutdownOnce = createShutdownOnce(server, {
|
|
256
|
+
cleanup: (reason) => shutdownCoordinator.shutdown(reason),
|
|
257
|
+
});
|
|
258
|
+
patchTransportSend(transport, process.stdout, () => {
|
|
259
|
+
void shutdownOnce("stdout:error", 1).catch((err) => {
|
|
260
|
+
try {
|
|
261
|
+
logger.fatal({ reason: "stdout:error", err: serializeError(err) }, "shutdown failed");
|
|
262
|
+
}
|
|
263
|
+
catch {
|
|
264
|
+
// Logger may be unavailable during stream failures.
|
|
265
|
+
}
|
|
266
|
+
process.exit(1);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
installShutdownHandlers(shutdownOnce);
|
|
23
270
|
await server.connect(transport);
|
|
24
|
-
// Graceful shutdown: coordinate with any in-flight workflow,
|
|
25
|
-
// then close the server and exit.
|
|
26
|
-
const shutdown = async (signal) => {
|
|
27
|
-
logger.info({ signal }, "shutdown signal received");
|
|
28
|
-
// ShutdownCoordinator handles in-flight workflow cancellation,
|
|
29
|
-
// state persistence, and child termination via its own signal handlers.
|
|
30
|
-
// We just need to close the MCP server transport cleanly.
|
|
31
|
-
await server.close();
|
|
32
|
-
process.exit(0);
|
|
33
|
-
};
|
|
34
|
-
process.once("SIGTERM", () => void shutdown("SIGTERM").catch(() => process.exit(1)));
|
|
35
|
-
process.once("SIGINT", () => void shutdown("SIGINT").catch(() => process.exit(1)));
|
|
36
271
|
logger.info("clinkx-workflows MCP server connected and ready");
|
|
37
272
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
273
|
+
function isCliEntrypoint() {
|
|
274
|
+
const entry = process.argv[1];
|
|
275
|
+
if (entry == null)
|
|
276
|
+
return false;
|
|
277
|
+
try {
|
|
278
|
+
return realpathSync(entry) === realpathSync(fileURLToPath(import.meta.url));
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
return import.meta.url === pathToFileURL(entry).href;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (isCliEntrypoint()) {
|
|
285
|
+
main().catch((err) => {
|
|
286
|
+
logger.fatal({ err }, "clinkx-workflows failed to start");
|
|
287
|
+
process.exitCode = 1;
|
|
288
|
+
});
|
|
289
|
+
}
|
|
42
290
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAKzD,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,KAAK,UAAU,IAAI;IACjB,kBAAkB,EAAE,CAAC;IAErB,MAAM,MAAM,GAAG,oBAAoB,EAAE,CAAC;IACtC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;IAEtE,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,6DAA6D;IAC7D,kCAAkC;IAClC,MAAM,QAAQ,GAAG,KAAK,EAAE,MAAc,EAAE,EAAE;QACxC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,0BAA0B,CAAC,CAAC;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ACH,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC;AACH,CAAC;AAED,IAAI,eAAe,EAAE,EAAE,CAAC;IACtB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QAC5B,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,kCAAkC,CAAC,CAAC;QAC1D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -12,5 +12,12 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
12
12
|
* Registers three tools: run_workflow, resume_workflow, list_workflows.
|
|
13
13
|
* Uses ClinkSession (child process) as the backend.
|
|
14
14
|
* Does NOT connect transport — caller is responsible.
|
|
15
|
+
*
|
|
16
|
+
* When `availableCliNames` is not explicitly provided, attempts to
|
|
17
|
+
* discover adapter names from the child config path. This gives the
|
|
18
|
+
* standalone server schema enum injection and parse-time validation
|
|
19
|
+
* without requiring the caller to wire discovery manually.
|
|
15
20
|
*/
|
|
16
|
-
export declare function createWorkflowServer(
|
|
21
|
+
export declare function createWorkflowServer(options?: {
|
|
22
|
+
availableCliNames?: readonly string[];
|
|
23
|
+
}): Server;
|
|
@@ -5,10 +5,84 @@
|
|
|
5
5
|
* ClinkSession child process. For in-process integration, use
|
|
6
6
|
* registerWorkflowTools() from workflow-tools.ts directly.
|
|
7
7
|
*/
|
|
8
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
9
|
+
import { join, extname } from "node:path";
|
|
8
10
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
11
|
+
import { getChildConfigPath } from "./config.js";
|
|
12
|
+
import { logger } from "./logger.js";
|
|
9
13
|
import { ClinkSession } from "./transport.js";
|
|
10
14
|
import { registerWorkflowTools } from "./workflow-tools.js";
|
|
11
15
|
// ---------------------------------------------------------------------------
|
|
16
|
+
// Adapter name discovery
|
|
17
|
+
// ---------------------------------------------------------------------------
|
|
18
|
+
/**
|
|
19
|
+
* Best-effort adapter name discovery from child config path.
|
|
20
|
+
*
|
|
21
|
+
* Reads CLINKX_WORKFLOWS_CHILD_CONFIG_PATH — supports both directory
|
|
22
|
+
* (scan for .json files) and single-file paths, mirroring the path-
|
|
23
|
+
* resolution behavior of AdapterRegistry.loadFromPath.
|
|
24
|
+
*
|
|
25
|
+
* This performs lightweight structural validation (requires `name` +
|
|
26
|
+
* `command` fields) rather than full CliAdapterConfigSchema parsing,
|
|
27
|
+
* which lives in the root package and cannot be imported without
|
|
28
|
+
* creating a circular dependency. Runtime validation in the child
|
|
29
|
+
* process remains the authoritative gate. Returns undefined when no
|
|
30
|
+
* config path is set or no valid adapters are found.
|
|
31
|
+
*/
|
|
32
|
+
function discoverChildAdapterNames() {
|
|
33
|
+
const configPath = getChildConfigPath();
|
|
34
|
+
if (configPath == null)
|
|
35
|
+
return undefined;
|
|
36
|
+
try {
|
|
37
|
+
const stat = statSync(configPath);
|
|
38
|
+
const names = [];
|
|
39
|
+
if (stat.isFile()) {
|
|
40
|
+
// Single-file config path
|
|
41
|
+
const name = extractAdapterName(configPath);
|
|
42
|
+
if (name != null)
|
|
43
|
+
names.push(name);
|
|
44
|
+
}
|
|
45
|
+
else if (stat.isDirectory()) {
|
|
46
|
+
// Directory config path — scan for .json files
|
|
47
|
+
const files = readdirSync(configPath).filter((f) => extname(f) === ".json");
|
|
48
|
+
for (const file of files) {
|
|
49
|
+
const name = extractAdapterName(join(configPath, file));
|
|
50
|
+
if (name != null)
|
|
51
|
+
names.push(name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (names.length > 0) {
|
|
55
|
+
logger.debug({ names, configPath }, "discovered child adapter names for standalone server");
|
|
56
|
+
return names;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
logger.debug({ configPath, err }, "could not enumerate child config path");
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Extract the adapter name from a config JSON file.
|
|
66
|
+
*
|
|
67
|
+
* Requires both `name` (string) and `command` (string) fields to be
|
|
68
|
+
* present — the two mandatory fields in any valid adapter config.
|
|
69
|
+
* Skips files that don't meet this minimum bar.
|
|
70
|
+
*/
|
|
71
|
+
function extractAdapterName(filePath) {
|
|
72
|
+
try {
|
|
73
|
+
const raw = readFileSync(filePath, "utf-8");
|
|
74
|
+
const parsed = JSON.parse(raw);
|
|
75
|
+
if (typeof parsed["name"] === "string" && parsed["name"] !== "" &&
|
|
76
|
+
typeof parsed["command"] === "string" && parsed["command"] !== "") {
|
|
77
|
+
return parsed["name"];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
// Malformed config file — non-fatal
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
12
86
|
// Server factory
|
|
13
87
|
// ---------------------------------------------------------------------------
|
|
14
88
|
/**
|
|
@@ -17,16 +91,28 @@ import { registerWorkflowTools } from "./workflow-tools.js";
|
|
|
17
91
|
* Registers three tools: run_workflow, resume_workflow, list_workflows.
|
|
18
92
|
* Uses ClinkSession (child process) as the backend.
|
|
19
93
|
* Does NOT connect transport — caller is responsible.
|
|
94
|
+
*
|
|
95
|
+
* When `availableCliNames` is not explicitly provided, attempts to
|
|
96
|
+
* discover adapter names from the child config path. This gives the
|
|
97
|
+
* standalone server schema enum injection and parse-time validation
|
|
98
|
+
* without requiring the caller to wire discovery manually.
|
|
20
99
|
*/
|
|
21
|
-
export function createWorkflowServer() {
|
|
100
|
+
export function createWorkflowServer(options) {
|
|
22
101
|
const server = new Server({ name: "clinkx-workflows", version: "0.1.0" }, {
|
|
23
102
|
capabilities: { tools: {} },
|
|
24
103
|
instructions: "Orchestrates multi-stage workflows by delegating calls to CLI subagents via ClinkX. " +
|
|
25
104
|
"Use run_workflow to start a new workflow, resume_workflow to continue a failed run, " +
|
|
26
105
|
"or list_workflows to see available workflows.",
|
|
27
106
|
});
|
|
107
|
+
// Normalize empty arrays to undefined — an empty list would suppress schema
|
|
108
|
+
// hints while still enabling validation (rejecting all adapter names).
|
|
109
|
+
const explicit = options?.availableCliNames;
|
|
110
|
+
const cliNames = (explicit != null && explicit.length > 0)
|
|
111
|
+
? explicit
|
|
112
|
+
: discoverChildAdapterNames();
|
|
28
113
|
registerWorkflowTools(server, {
|
|
29
114
|
createBackend: (runId) => new ClinkSession({ runId }),
|
|
115
|
+
...(cliNames != null ? { availableCliNames: cliNames } : {}),
|
|
30
116
|
});
|
|
31
117
|
return server;
|
|
32
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,8EAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO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AAI,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACxD,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,yBAAyB,EAAE,CAAC;IAEhC,qBAAqB,CAAC,MAAM,EAAE;QAC5B,aAAa,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;QAC7D,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7D,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Shutdown coordinator for clinkx-workflows.
|
|
3
3
|
*
|
|
4
4
|
* Handles:
|
|
5
|
-
* -
|
|
6
|
-
* terminate child
|
|
5
|
+
* - process shutdown: cancel in-flight calls, persist state (best-effort),
|
|
6
|
+
* terminate child
|
|
7
7
|
* - MCP cancellation: propagate AbortSignal, cancel calls, persist cancelled,
|
|
8
8
|
* no response
|
|
9
9
|
*
|
|
@@ -17,9 +17,6 @@ type StatePersister = () => Promise<void>;
|
|
|
17
17
|
export declare class ShutdownCoordinator {
|
|
18
18
|
private state;
|
|
19
19
|
private shuttingDown;
|
|
20
|
-
private signalHandlersInstalled;
|
|
21
|
-
private readonly boundHandleSignal;
|
|
22
|
-
constructor();
|
|
23
20
|
/**
|
|
24
21
|
* Register the active session and abort controller for this run.
|
|
25
22
|
* Call at the start of each workflow run.
|
|
@@ -41,13 +38,12 @@ export declare class ShutdownCoordinator {
|
|
|
41
38
|
*/
|
|
42
39
|
cancelRun(): Promise<void>;
|
|
43
40
|
/**
|
|
44
|
-
* Handle
|
|
45
|
-
* Cancel, persist, terminate
|
|
41
|
+
* Handle process shutdown.
|
|
42
|
+
* Cancel, persist, and terminate. The entrypoint owns process.exit.
|
|
46
43
|
*/
|
|
47
|
-
|
|
44
|
+
shutdown(signal: string): Promise<void>;
|
|
48
45
|
private safePersistState;
|
|
49
46
|
private safeTerminateSession;
|
|
50
|
-
private installSignalHandlers;
|
|
51
47
|
}
|
|
52
48
|
/** Singleton shutdown coordinator. */
|
|
53
49
|
export declare const shutdownCoordinator: ShutdownCoordinator;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Shutdown coordinator for clinkx-workflows.
|
|
3
3
|
*
|
|
4
4
|
* Handles:
|
|
5
|
-
* -
|
|
6
|
-
* terminate child
|
|
5
|
+
* - process shutdown: cancel in-flight calls, persist state (best-effort),
|
|
6
|
+
* terminate child
|
|
7
7
|
* - MCP cancellation: propagate AbortSignal, cancel calls, persist cancelled,
|
|
8
8
|
* no response
|
|
9
9
|
*
|
|
@@ -20,13 +20,6 @@ export class ShutdownCoordinator {
|
|
|
20
20
|
persistState: null,
|
|
21
21
|
};
|
|
22
22
|
shuttingDown = false;
|
|
23
|
-
signalHandlersInstalled = false;
|
|
24
|
-
boundHandleSignal;
|
|
25
|
-
constructor() {
|
|
26
|
-
this.boundHandleSignal = (signal) => {
|
|
27
|
-
void this.handleSignalShutdown(signal);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
23
|
/**
|
|
31
24
|
* Register the active session and abort controller for this run.
|
|
32
25
|
* Call at the start of each workflow run.
|
|
@@ -34,7 +27,6 @@ export class ShutdownCoordinator {
|
|
|
34
27
|
register(session, controller, persistState) {
|
|
35
28
|
this.state = { session, controller, persistState };
|
|
36
29
|
this.shuttingDown = false;
|
|
37
|
-
this.installSignalHandlers();
|
|
38
30
|
}
|
|
39
31
|
/**
|
|
40
32
|
* Unregister the current run (on normal completion).
|
|
@@ -67,10 +59,10 @@ export class ShutdownCoordinator {
|
|
|
67
59
|
await this.safeTerminateSession();
|
|
68
60
|
}
|
|
69
61
|
/**
|
|
70
|
-
* Handle
|
|
71
|
-
* Cancel, persist, terminate
|
|
62
|
+
* Handle process shutdown.
|
|
63
|
+
* Cancel, persist, and terminate. The entrypoint owns process.exit.
|
|
72
64
|
*/
|
|
73
|
-
async
|
|
65
|
+
async shutdown(signal) {
|
|
74
66
|
if (this.shuttingDown) {
|
|
75
67
|
logger.warn({ signal }, "duplicate shutdown signal ignored");
|
|
76
68
|
return;
|
|
@@ -83,9 +75,7 @@ export class ShutdownCoordinator {
|
|
|
83
75
|
await this.safePersistState();
|
|
84
76
|
// 3. Terminate child session
|
|
85
77
|
await this.safeTerminateSession();
|
|
86
|
-
|
|
87
|
-
logger.info({ signal }, "shutdown complete, exiting");
|
|
88
|
-
process.exit(0);
|
|
78
|
+
logger.info({ signal }, "shutdown cleanup complete");
|
|
89
79
|
}
|
|
90
80
|
async safePersistState() {
|
|
91
81
|
if (this.state.persistState == null)
|
|
@@ -107,13 +97,6 @@ export class ShutdownCoordinator {
|
|
|
107
97
|
logger.error({ err: err instanceof Error ? err.message : String(err) }, "failed to terminate child session during shutdown");
|
|
108
98
|
}
|
|
109
99
|
}
|
|
110
|
-
installSignalHandlers() {
|
|
111
|
-
if (this.signalHandlersInstalled)
|
|
112
|
-
return;
|
|
113
|
-
this.signalHandlersInstalled = true;
|
|
114
|
-
process.on("SIGTERM", () => this.boundHandleSignal("SIGTERM"));
|
|
115
|
-
process.on("SIGINT", () => this.boundHandleSignal("SIGINT"));
|
|
116
|
-
}
|
|
117
100
|
}
|
|
118
101
|
/** Singleton shutdown coordinator. */
|
|
119
102
|
export const shutdownCoordinator = new ShutdownCoordinator();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shutdown.js","sourceRoot":"","sources":["../src/shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAWrC;;GAEG;AACH,MAAM,OAAO,mBAAmB;IACtB,KAAK,GAAkB;QAC7B,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;KACnB,CAAC;IACM,YAAY,GAAG,KAAK,CAAC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,MAAM,CAAC,KAAK,CACV,EAAE,GAAG,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EACzD,mDAAmD,CACpD,CAAC;QACJ,CAAC;IACH,CAAC;CAEF;AAED,sCAAsC;AACtC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC"}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { EngineHooks, EngineResumeState } from "./engine.js";
|
|
2
2
|
import type { NormalizedWorkflowDefinition } from "./definition-normalizer.js";
|
|
3
3
|
import type { RunState } from "./state-schema.js";
|
|
4
|
+
export type RunDirectoryClassification = "failed" | "cancelled" | "debug_kept" | "active_locked" | "running_or_pending" | "unknown";
|
|
5
|
+
export interface PruneRunDirectoriesOptions {
|
|
6
|
+
readonly retainFailedDays?: number | undefined;
|
|
7
|
+
readonly retainCancelledDays?: number | undefined;
|
|
8
|
+
readonly retainDebugDays?: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface PruneRunDirectoriesResult {
|
|
11
|
+
readonly pruned: number;
|
|
12
|
+
readonly skipped: number;
|
|
13
|
+
readonly errors: number;
|
|
14
|
+
}
|
|
4
15
|
export interface CreateWorkflowStateOptions {
|
|
5
16
|
readonly runId: string;
|
|
6
17
|
readonly definition: NormalizedWorkflowDefinition;
|
|
@@ -13,6 +24,8 @@ export interface ResumeWorkflowStateOptions {
|
|
|
13
24
|
readonly runDir?: string | undefined;
|
|
14
25
|
readonly debugKeepArtifacts?: boolean | undefined;
|
|
15
26
|
}
|
|
27
|
+
export declare function classifyRunDirectory(runDirPath: string): RunDirectoryClassification;
|
|
28
|
+
export declare function pruneRunDirectories(runsRootDir: string, options?: PruneRunDirectoriesOptions): Promise<PruneRunDirectoriesResult>;
|
|
16
29
|
export declare class WorkflowStateStore {
|
|
17
30
|
readonly runDir: string;
|
|
18
31
|
readonly definition: NormalizedWorkflowDefinition;
|