@exaudeus/workrail 3.15.0 → 3.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application/services/workflow-service.d.ts +2 -0
- package/dist/application/services/workflow-service.js +3 -0
- package/dist/application/use-cases/raw-workflow-file-scanner.js +10 -13
- package/dist/cli/commands/index.d.ts +1 -1
- package/dist/cli/commands/index.js +2 -1
- package/dist/cli/commands/init.d.ts +10 -0
- package/dist/cli/commands/init.js +72 -0
- package/dist/cli.js +13 -1
- package/dist/config/config-file.d.ts +8 -0
- package/dist/config/config-file.js +141 -0
- package/dist/config/feature-flags.js +8 -0
- package/dist/console/assets/index-BZNM03t1.css +1 -0
- package/dist/console/assets/index-BwJelCXK.js +28 -0
- package/dist/console/index.html +2 -2
- package/dist/di/container.d.ts +1 -0
- package/dist/di/container.js +24 -7
- package/dist/infrastructure/session/HttpServer.d.ts +3 -4
- package/dist/infrastructure/session/HttpServer.js +58 -106
- package/dist/infrastructure/storage/caching-workflow-storage.d.ts +2 -0
- package/dist/infrastructure/storage/caching-workflow-storage.js +15 -6
- package/dist/infrastructure/storage/file-workflow-storage.js +3 -4
- package/dist/infrastructure/storage/schema-validating-workflow-storage.js +9 -8
- package/dist/manifest.json +303 -247
- package/dist/mcp/assert-output.d.ts +37 -0
- package/dist/mcp/assert-output.js +53 -0
- package/dist/mcp/boundary-coercion.d.ts +1 -0
- package/dist/mcp/boundary-coercion.js +44 -0
- package/dist/mcp/dev-mode.d.ts +2 -0
- package/dist/mcp/dev-mode.js +16 -0
- package/dist/mcp/handler-factory.d.ts +1 -1
- package/dist/mcp/handler-factory.js +20 -16
- package/dist/mcp/handlers/session.js +8 -9
- package/dist/mcp/handlers/shared/request-workflow-reader.d.ts +1 -0
- package/dist/mcp/handlers/shared/request-workflow-reader.js +90 -20
- package/dist/mcp/handlers/v2-advance-core/event-builders.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/event-builders.js +6 -6
- package/dist/mcp/handlers/v2-advance-core/index.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/index.js +4 -3
- package/dist/mcp/handlers/v2-advance-core/input-validation.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/input-validation.js +32 -9
- package/dist/mcp/handlers/v2-advance-core/outcome-blocked.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/outcome-blocked.js +1 -1
- package/dist/mcp/handlers/v2-advance-core/outcome-success.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/outcome-success.js +1 -1
- package/dist/mcp/handlers/v2-checkpoint.d.ts +1 -1
- package/dist/mcp/handlers/v2-checkpoint.js +5 -6
- package/dist/mcp/handlers/v2-execution/advance.d.ts +4 -2
- package/dist/mcp/handlers/v2-execution/advance.js +5 -7
- package/dist/mcp/handlers/v2-execution/continue-advance.d.ts +1 -0
- package/dist/mcp/handlers/v2-execution/continue-advance.js +59 -27
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.d.ts +2 -1
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +11 -10
- package/dist/mcp/handlers/v2-execution/index.js +2 -0
- package/dist/mcp/handlers/v2-execution/replay.d.ts +8 -4
- package/dist/mcp/handlers/v2-execution/replay.js +50 -30
- package/dist/mcp/handlers/v2-execution/start.d.ts +2 -3
- package/dist/mcp/handlers/v2-execution/start.js +58 -30
- package/dist/mcp/handlers/v2-execution/workflow-object-cache.d.ts +5 -0
- package/dist/mcp/handlers/v2-execution/workflow-object-cache.js +19 -0
- package/dist/mcp/handlers/v2-execution-helpers.d.ts +1 -0
- package/dist/mcp/handlers/v2-execution-helpers.js +23 -7
- package/dist/mcp/handlers/v2-resume.d.ts +1 -1
- package/dist/mcp/handlers/v2-resume.js +3 -4
- package/dist/mcp/handlers/v2-state-conversion.js +5 -1
- package/dist/mcp/handlers/v2-workflow.d.ts +80 -0
- package/dist/mcp/handlers/v2-workflow.js +40 -23
- package/dist/mcp/handlers/workflow.d.ts +2 -5
- package/dist/mcp/handlers/workflow.js +15 -12
- package/dist/mcp/output-schemas.d.ts +25 -27
- package/dist/mcp/output-schemas.js +7 -7
- package/dist/mcp/server.js +23 -4
- package/dist/mcp/tool-call-timing.d.ts +24 -0
- package/dist/mcp/tool-call-timing.js +85 -0
- package/dist/mcp/transports/http-entry.js +3 -2
- package/dist/mcp/transports/http-listener.d.ts +1 -0
- package/dist/mcp/transports/http-listener.js +25 -0
- package/dist/mcp/transports/shutdown-hooks.d.ts +4 -1
- package/dist/mcp/transports/shutdown-hooks.js +3 -2
- package/dist/mcp/transports/stdio-entry.js +6 -28
- package/dist/mcp/v2-response-formatter.d.ts +1 -1
- package/dist/mcp/v2-response-formatter.js +2 -5
- package/dist/mcp/validation/schema-introspection.d.ts +1 -0
- package/dist/mcp/validation/schema-introspection.js +15 -5
- package/dist/mcp/validation/suggestion-generator.js +2 -2
- package/dist/runtime/adapters/node-process-signals.d.ts +1 -0
- package/dist/runtime/adapters/node-process-signals.js +5 -0
- package/dist/runtime/adapters/noop-process-signals.d.ts +1 -0
- package/dist/runtime/adapters/noop-process-signals.js +2 -0
- package/dist/runtime/ports/process-signals.d.ts +1 -0
- package/dist/types/workflow-definition.d.ts +5 -1
- package/dist/types/workflow-definition.js +2 -0
- package/dist/types/workflow.d.ts +3 -0
- package/dist/types/workflow.js +35 -26
- package/dist/v2/durable-core/domain/context-template-resolver.js +2 -2
- package/dist/v2/durable-core/domain/function-definition-expander.js +2 -17
- package/dist/v2/durable-core/domain/prompt-renderer.d.ts +2 -0
- package/dist/v2/durable-core/domain/prompt-renderer.js +22 -18
- package/dist/v2/durable-core/domain/recap-recovery.js +23 -16
- package/dist/v2/durable-core/domain/retrieval-contract.js +13 -7
- package/dist/v2/durable-core/schemas/compiled-workflow/index.js +4 -3
- package/dist/v2/durable-core/session-index.d.ts +22 -0
- package/dist/v2/durable-core/session-index.js +58 -0
- package/dist/v2/durable-core/sorted-event-log.d.ts +6 -0
- package/dist/v2/durable-core/sorted-event-log.js +15 -0
- package/dist/v2/infra/local/fs/index.js +8 -8
- package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +2 -0
- package/dist/v2/infra/local/pinned-workflow-store/index.js +49 -0
- package/dist/v2/infra/local/remembered-roots-store/index.d.ts +3 -1
- package/dist/v2/infra/local/remembered-roots-store/index.js +6 -3
- package/dist/v2/infra/local/session-store/index.d.ts +1 -1
- package/dist/v2/infra/local/session-store/index.js +71 -61
- package/dist/v2/infra/local/session-summary-provider/index.js +9 -4
- package/dist/v2/infra/local/snapshot-store/index.js +2 -1
- package/dist/v2/infra/local/workspace-anchor/index.js +4 -2
- package/dist/v2/ports/pinned-workflow-store.port.d.ts +2 -0
- package/dist/v2/ports/session-event-log-store.port.d.ts +1 -1
- package/dist/v2/projections/assessment-consequences.d.ts +2 -1
- package/dist/v2/projections/assessment-consequences.js +0 -5
- package/dist/v2/projections/assessments.d.ts +2 -1
- package/dist/v2/projections/assessments.js +2 -4
- package/dist/v2/projections/gaps.d.ts +2 -1
- package/dist/v2/projections/gaps.js +0 -5
- package/dist/v2/projections/preferences.d.ts +2 -1
- package/dist/v2/projections/preferences.js +0 -5
- package/dist/v2/projections/run-context.d.ts +2 -2
- package/dist/v2/projections/run-context.js +0 -5
- package/dist/v2/projections/run-dag.js +7 -1
- package/dist/v2/projections/run-execution-trace.d.ts +8 -0
- package/dist/v2/projections/run-execution-trace.js +124 -0
- package/dist/v2/projections/run-status-signals.d.ts +2 -2
- package/dist/v2/usecases/console-routes.d.ts +3 -1
- package/dist/v2/usecases/console-routes.js +124 -25
- package/dist/v2/usecases/console-service.d.ts +1 -0
- package/dist/v2/usecases/console-service.js +83 -25
- package/dist/v2/usecases/console-types.d.ts +53 -0
- package/dist/v2/usecases/worktree-service.js +32 -1
- package/package.json +6 -5
- package/spec/workflow.schema.json +18 -0
- package/workflows/adaptive-ticket-creation.json +23 -16
- package/workflows/architecture-scalability-audit.json +29 -22
- package/workflows/bug-investigation.agentic.v2.json +7 -0
- package/workflows/coding-task-workflow-agentic.json +7 -0
- package/workflows/coding-task-workflow-agentic.lean.v2.json +16 -8
- package/workflows/coding-task-workflow-agentic.v2.json +7 -0
- package/workflows/cross-platform-code-conversion.v2.json +7 -0
- package/workflows/document-creation-workflow.json +15 -8
- package/workflows/documentation-update-workflow.json +15 -8
- package/workflows/intelligent-test-case-generation.json +7 -0
- package/workflows/learner-centered-course-workflow.json +9 -2
- package/workflows/mr-review-workflow.agentic.v2.json +7 -0
- package/workflows/personal-learning-materials-creation-branched.json +15 -8
- package/workflows/presentation-creation.json +12 -5
- package/workflows/production-readiness-audit.json +7 -0
- package/workflows/relocation-workflow-us.json +39 -32
- package/workflows/scoped-documentation-workflow.json +33 -26
- package/workflows/ui-ux-design-workflow.json +7 -0
- package/workflows/workflow-diagnose-environment.json +6 -0
- package/workflows/workflow-for-workflows.json +7 -0
- package/workflows/workflow-for-workflows.v2.json +23 -11
- package/workflows/wr.discovery.json +8 -1
- package/dist/console/assets/index-BZYIjrzJ.js +0 -28
- package/dist/console/assets/index-OLCKbDdm.css +0 -1
- package/dist/mcp/handlers/v2-resolve-refs-envelope.d.ts +0 -5
- package/dist/mcp/handlers/v2-resolve-refs-envelope.js +0 -17
|
@@ -8,13 +8,14 @@ exports.buildTagSummary = buildTagSummary;
|
|
|
8
8
|
exports.computeWorkflowStaleness = computeWorkflowStaleness;
|
|
9
9
|
exports.handleV2ListWorkflows = handleV2ListWorkflows;
|
|
10
10
|
exports.handleV2InspectWorkflow = handleV2InspectWorkflow;
|
|
11
|
+
exports.buildV2WorkflowListItem = buildV2WorkflowListItem;
|
|
11
12
|
const path_1 = __importDefault(require("path"));
|
|
12
13
|
const fs_1 = __importDefault(require("fs"));
|
|
13
14
|
const neverthrow_1 = require("neverthrow");
|
|
14
15
|
const types_js_1 = require("../types.js");
|
|
15
16
|
const error_mapper_js_1 = require("../error-mapper.js");
|
|
16
17
|
const v2_execution_helpers_js_1 = require("./v2-execution-helpers.js");
|
|
17
|
-
const
|
|
18
|
+
const assert_never_js_1 = require("../../runtime/assert-never.js");
|
|
18
19
|
const v1_to_v2_shim_js_1 = require("../../v2/read-only/v1-to-v2-shim.js");
|
|
19
20
|
const hashing_js_1 = require("../../v2/durable-core/canonical/hashing.js");
|
|
20
21
|
const TIMEOUT_MS = 30000;
|
|
@@ -35,8 +36,7 @@ function readCurrentSpecVersion() {
|
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
38
|
const CURRENT_SPEC_VERSION = readCurrentSpecVersion();
|
|
38
|
-
|
|
39
|
-
function shouldShowStaleness(category, devMode = DEV_STALENESS) {
|
|
39
|
+
function shouldShowStaleness(category, devMode = (0, dev_mode_js_1.isDevMode)()) {
|
|
40
40
|
if (devMode)
|
|
41
41
|
return true;
|
|
42
42
|
return category === 'personal' || category === 'rooted_sharing' || category === 'external';
|
|
@@ -96,6 +96,7 @@ function computeWorkflowStaleness(stamp, currentVersion) {
|
|
|
96
96
|
specVersionAtLastReview: stamp,
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
+
const dev_mode_js_1 = require("../dev-mode.js");
|
|
99
100
|
const with_timeout_js_1 = require("./shared/with-timeout.js");
|
|
100
101
|
const request_workflow_reader_js_1 = require("./shared/request-workflow-reader.js");
|
|
101
102
|
const remembered_roots_js_1 = require("./shared/remembered-roots.js");
|
|
@@ -135,14 +136,24 @@ async function handleV2ListWorkflows(input, ctx) {
|
|
|
135
136
|
const warnings = managedStoreError
|
|
136
137
|
? [`Managed workflow source store was temporarily unavailable (${managedStoreError}). Managed sources were not loaded.`]
|
|
137
138
|
: undefined;
|
|
138
|
-
return neverthrow_1.ResultAsync.fromPromise((0, with_timeout_js_1.withTimeout)(workflowReader.
|
|
139
|
-
.andThen((
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
return neverthrow_1.ResultAsync.fromPromise((0, with_timeout_js_1.withTimeout)(workflowReader.loadAllWorkflows(), TIMEOUT_MS, 'list_workflows'), (err) => (0, error_mapper_js_1.mapUnknownErrorToToolError)(err))
|
|
140
|
+
.andThen((allWorkflows) => {
|
|
141
|
+
const workflowMap = new Map(allWorkflows.map((w) => [w.definition.id, w]));
|
|
142
|
+
const summaries = allWorkflows.map((w) => ({
|
|
143
|
+
id: w.definition.id,
|
|
144
|
+
name: w.definition.name,
|
|
145
|
+
description: w.definition.description,
|
|
146
|
+
version: w.definition.version,
|
|
147
|
+
}));
|
|
148
|
+
return neverthrow_1.ResultAsync.combine(summaries.map((s) => neverthrow_1.ResultAsync.fromPromise(buildV2WorkflowListItem({
|
|
149
|
+
workflow: workflowMap.get(s.id) ?? null,
|
|
150
|
+
summary: s,
|
|
151
|
+
workflowReader,
|
|
152
|
+
rememberedRootRecords,
|
|
153
|
+
crypto,
|
|
154
|
+
pinnedStore,
|
|
155
|
+
}), (err) => (0, error_mapper_js_1.mapUnknownErrorToToolError)(err))));
|
|
156
|
+
})
|
|
146
157
|
.andThen((compiled) => {
|
|
147
158
|
const sortedIds = compiled.map((w) => w.workflowId).sort((a, b) => a.localeCompare(b));
|
|
148
159
|
const sortedCompiled = [...compiled].sort((a, b) => a.workflowId.localeCompare(b.workflowId));
|
|
@@ -173,35 +184,35 @@ async function handleV2ListWorkflows(input, ctx) {
|
|
|
173
184
|
: undefined;
|
|
174
185
|
if (!input.includeSources) {
|
|
175
186
|
const includeStaleRoots = !tagSummaryEntry && stalePaths.length > 0;
|
|
176
|
-
const payload =
|
|
187
|
+
const payload = {
|
|
177
188
|
workflows: tagFilteredCompiled,
|
|
178
189
|
...(tagSummaryEntry ? { tagSummary: tagSummaryEntry } : {}),
|
|
179
190
|
...(nextStepHint ? { _nextStep: nextStepHint } : {}),
|
|
180
191
|
...(includeStaleRoots ? { staleRoots: [...stalePaths] } : {}),
|
|
181
192
|
...(warnings ? { warnings } : {}),
|
|
182
|
-
}
|
|
193
|
+
};
|
|
183
194
|
return (0, neverthrow_1.okAsync)((0, types_js_1.success)(payload));
|
|
184
195
|
}
|
|
185
196
|
if (!(0, workflow_source_visibility_js_1.isCompositeWorkflowReader)(workflowReader)) {
|
|
186
|
-
const payload =
|
|
197
|
+
const payload = {
|
|
187
198
|
workflows: tagFilteredCompiled,
|
|
188
199
|
...(tagSummaryEntry ? { tagSummary: tagSummaryEntry } : {}),
|
|
189
200
|
...(nextStepHint ? { _nextStep: nextStepHint } : {}),
|
|
190
201
|
...(stalePaths.length > 0 ? { staleRoots: [...stalePaths] } : {}),
|
|
191
202
|
...(warnings ? { warnings } : {}),
|
|
192
203
|
sources: [],
|
|
193
|
-
}
|
|
204
|
+
};
|
|
194
205
|
return (0, neverthrow_1.okAsync)((0, types_js_1.success)(payload));
|
|
195
206
|
}
|
|
196
207
|
return neverthrow_1.ResultAsync.fromPromise((0, with_timeout_js_1.withTimeout)(buildSourceCatalog(workflowReader, rememberedRootRecords, managedSourceRecords, staleManagedRecords), TIMEOUT_MS, 'list_workflow_sources'), (err) => (0, error_mapper_js_1.mapUnknownErrorToToolError)(err)).map((sources) => {
|
|
197
|
-
const payload =
|
|
208
|
+
const payload = {
|
|
198
209
|
workflows: tagFilteredCompiled,
|
|
199
210
|
...(tagSummaryEntry ? { tagSummary: tagSummaryEntry } : {}),
|
|
200
211
|
...(nextStepHint ? { _nextStep: nextStepHint } : {}),
|
|
201
212
|
...(stalePaths.length > 0 ? { staleRoots: [...stalePaths] } : {}),
|
|
202
213
|
...(warnings ? { warnings } : {}),
|
|
203
|
-
sources,
|
|
204
|
-
}
|
|
214
|
+
sources: [...sources],
|
|
215
|
+
};
|
|
205
216
|
return (0, types_js_1.success)(payload);
|
|
206
217
|
});
|
|
207
218
|
})
|
|
@@ -264,7 +275,7 @@ async function handleV2InspectWorkflow(input, ctx) {
|
|
|
264
275
|
? { schemaVersion: compiled.schemaVersion, sourceKind: compiled.sourceKind, workflowId: compiled.workflowId }
|
|
265
276
|
: compiled;
|
|
266
277
|
const references = workflow.definition.references;
|
|
267
|
-
const payload =
|
|
278
|
+
const payload = {
|
|
268
279
|
workflowId: input.workflowId,
|
|
269
280
|
workflowHash,
|
|
270
281
|
mode: input.mode,
|
|
@@ -272,14 +283,14 @@ async function handleV2InspectWorkflow(input, ctx) {
|
|
|
272
283
|
...(visibility ? { visibility } : {}),
|
|
273
284
|
...(stalePaths.length > 0 ? { staleRoots: [...stalePaths] } : {}),
|
|
274
285
|
...(inspectWarnings ? { warnings: inspectWarnings } : {}),
|
|
275
|
-
...(references != null && references.length > 0 ? { references } : {}),
|
|
286
|
+
...(references != null && references.length > 0 ? { references: [...references] } : {}),
|
|
276
287
|
...(() => {
|
|
277
288
|
const staleness = shouldShowStaleness(visibility?.category)
|
|
278
289
|
? computeWorkflowStaleness(workflow.definition.validatedAgainstSpecVersion, CURRENT_SPEC_VERSION)
|
|
279
290
|
: undefined;
|
|
280
291
|
return staleness !== undefined ? { staleness } : {};
|
|
281
292
|
})(),
|
|
282
|
-
}
|
|
293
|
+
};
|
|
283
294
|
return (0, neverthrow_1.okAsync)((0, types_js_1.success)(payload));
|
|
284
295
|
}));
|
|
285
296
|
})
|
|
@@ -294,8 +305,7 @@ async function buildWorkflowVisibility(workflow, workflowReader, rememberedRootR
|
|
|
294
305
|
return (0, workflow_source_visibility_js_1.toWorkflowVisibility)(workflow, rememberedRootRecords, { migration });
|
|
295
306
|
}
|
|
296
307
|
async function buildV2WorkflowListItem(options) {
|
|
297
|
-
const { summary, workflowReader, rememberedRootRecords, crypto, pinnedStore } = options;
|
|
298
|
-
const workflow = await workflowReader.getWorkflowById(summary.id);
|
|
308
|
+
const { workflow, summary, workflowReader, rememberedRootRecords, crypto, pinnedStore } = options;
|
|
299
309
|
if (!workflow) {
|
|
300
310
|
return {
|
|
301
311
|
workflowId: summary.id,
|
|
@@ -307,6 +317,9 @@ async function buildV2WorkflowListItem(options) {
|
|
|
307
317
|
};
|
|
308
318
|
}
|
|
309
319
|
const visibility = await buildWorkflowVisibility(workflow, workflowReader, rememberedRootRecords);
|
|
320
|
+
const examples = workflow.definition.examples?.length
|
|
321
|
+
? { examples: [...workflow.definition.examples] }
|
|
322
|
+
: {};
|
|
310
323
|
const snapshot = (0, v1_to_v2_shim_js_1.compileV1WorkflowToV2PreviewSnapshot)(workflow);
|
|
311
324
|
const hashRes = (0, hashing_js_1.workflowHashForCompiledSnapshot)(snapshot, crypto);
|
|
312
325
|
if (hashRes.isErr()) {
|
|
@@ -318,6 +331,7 @@ async function buildV2WorkflowListItem(options) {
|
|
|
318
331
|
workflowHash: null,
|
|
319
332
|
kind: 'workflow',
|
|
320
333
|
visibility,
|
|
334
|
+
...examples,
|
|
321
335
|
};
|
|
322
336
|
}
|
|
323
337
|
const hash = hashRes.value;
|
|
@@ -333,6 +347,7 @@ async function buildV2WorkflowListItem(options) {
|
|
|
333
347
|
workflowHash: hash,
|
|
334
348
|
kind: 'workflow',
|
|
335
349
|
visibility,
|
|
350
|
+
...examples,
|
|
336
351
|
};
|
|
337
352
|
}
|
|
338
353
|
}
|
|
@@ -348,6 +363,7 @@ async function buildV2WorkflowListItem(options) {
|
|
|
348
363
|
kind: 'workflow',
|
|
349
364
|
visibility,
|
|
350
365
|
...(staleness !== undefined ? { staleness } : {}),
|
|
366
|
+
...examples,
|
|
351
367
|
};
|
|
352
368
|
}
|
|
353
369
|
async function buildSourceCatalog(workflowReader, rememberedRootRecords, managedSourceRecords, staleManagedRecords) {
|
|
@@ -428,6 +444,7 @@ function deriveSourceCatalogEntry(options) {
|
|
|
428
444
|
case 'plugin':
|
|
429
445
|
return { sourceKey, category: 'external', source: { kind: source.kind, displayName }, sourceMode: 'live_directory', effectiveWorkflowCount: effective, totalWorkflowCount: total, shadowedWorkflowCount: shadowed };
|
|
430
446
|
}
|
|
447
|
+
(0, assert_never_js_1.assertNever)(source);
|
|
431
448
|
}
|
|
432
449
|
function deriveSourceKey(source) {
|
|
433
450
|
switch (source.kind) {
|
|
@@ -19,11 +19,8 @@ export interface WorkflowNextOutput {
|
|
|
19
19
|
}
|
|
20
20
|
export interface WorkflowValidateJsonOutput {
|
|
21
21
|
valid: boolean;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
path?: string;
|
|
25
|
-
}>;
|
|
26
|
-
suggestions?: string[];
|
|
22
|
+
issues: string[];
|
|
23
|
+
suggestions: string[];
|
|
27
24
|
}
|
|
28
25
|
export interface WorkflowGetSchemaOutput {
|
|
29
26
|
schema: unknown;
|
|
@@ -32,21 +32,29 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.handleWorkflowList = handleWorkflowList;
|
|
37
40
|
exports.handleWorkflowGet = handleWorkflowGet;
|
|
38
41
|
exports.handleWorkflowNext = handleWorkflowNext;
|
|
39
42
|
exports.handleWorkflowValidateJson = handleWorkflowValidateJson;
|
|
40
43
|
exports.handleWorkflowGetSchema = handleWorkflowGetSchema;
|
|
44
|
+
const fs_1 = __importDefault(require("fs"));
|
|
45
|
+
const path_1 = __importDefault(require("path"));
|
|
41
46
|
const types_js_1 = require("../types.js");
|
|
42
|
-
const output_schemas_js_1 = require("../output-schemas.js");
|
|
43
47
|
const error_mapper_js_1 = require("../error-mapper.js");
|
|
44
48
|
const TIMEOUT_MS = 30000;
|
|
49
|
+
const WORKFLOW_SCHEMA = (() => {
|
|
50
|
+
const schemaPath = path_1.default.resolve(__dirname, '../../../spec/workflow.schema.json');
|
|
51
|
+
return JSON.parse(fs_1.default.readFileSync(schemaPath, 'utf-8'));
|
|
52
|
+
})();
|
|
45
53
|
const with_timeout_js_1 = require("./shared/with-timeout.js");
|
|
46
54
|
async function handleWorkflowList(_input, ctx) {
|
|
47
55
|
try {
|
|
48
56
|
const workflows = await (0, with_timeout_js_1.withTimeout)(ctx.workflowService.listWorkflowSummaries(), TIMEOUT_MS, 'workflow_list');
|
|
49
|
-
const payload =
|
|
57
|
+
const payload = { workflows };
|
|
50
58
|
return (0, types_js_1.success)(payload);
|
|
51
59
|
}
|
|
52
60
|
catch (err) {
|
|
@@ -63,7 +71,7 @@ async function handleWorkflowGet(input, ctx) {
|
|
|
63
71
|
const mapped = (0, error_mapper_js_1.mapDomainErrorToToolError)(result.error);
|
|
64
72
|
return mapped;
|
|
65
73
|
}
|
|
66
|
-
const payload =
|
|
74
|
+
const payload = { workflow: result.value };
|
|
67
75
|
return (0, types_js_1.success)(payload);
|
|
68
76
|
}
|
|
69
77
|
catch (err) {
|
|
@@ -93,7 +101,7 @@ async function handleWorkflowNext(input, ctx) {
|
|
|
93
101
|
const mapped = (0, error_mapper_js_1.mapDomainErrorToToolError)(result.error);
|
|
94
102
|
return mapped;
|
|
95
103
|
}
|
|
96
|
-
const payload =
|
|
104
|
+
const payload = result.value;
|
|
97
105
|
return (0, types_js_1.success)(payload);
|
|
98
106
|
}
|
|
99
107
|
catch (err) {
|
|
@@ -118,7 +126,7 @@ async function handleWorkflowValidateJson(input, ctx) {
|
|
|
118
126
|
const { createValidateWorkflowJson } = await Promise.resolve().then(() => __importStar(require('../../application/use-cases/validate-workflow-json.js')));
|
|
119
127
|
const validateWorkflowJsonUseCase = createValidateWorkflowJson();
|
|
120
128
|
const result = await validateWorkflowJsonUseCase(input.workflowJson);
|
|
121
|
-
const payload =
|
|
129
|
+
const payload = result;
|
|
122
130
|
return (0, types_js_1.success)(payload);
|
|
123
131
|
}
|
|
124
132
|
catch (err) {
|
|
@@ -129,11 +137,7 @@ async function handleWorkflowValidateJson(input, ctx) {
|
|
|
129
137
|
async function handleWorkflowGetSchema(_input, ctx) {
|
|
130
138
|
void ctx;
|
|
131
139
|
try {
|
|
132
|
-
const
|
|
133
|
-
const path = await Promise.resolve().then(() => __importStar(require('path')));
|
|
134
|
-
const schemaPath = path.resolve(__dirname, '../../../spec/workflow.schema.json');
|
|
135
|
-
const schemaContent = fs.readFileSync(schemaPath, 'utf-8');
|
|
136
|
-
const schema = JSON.parse(schemaContent);
|
|
140
|
+
const schema = WORKFLOW_SCHEMA;
|
|
137
141
|
const result = {
|
|
138
142
|
schema,
|
|
139
143
|
metadata: {
|
|
@@ -160,8 +164,7 @@ async function handleWorkflowGetSchema(_input, ctx) {
|
|
|
160
164
|
},
|
|
161
165
|
},
|
|
162
166
|
};
|
|
163
|
-
|
|
164
|
-
return (0, types_js_1.success)(payload);
|
|
167
|
+
return (0, types_js_1.success)(result);
|
|
165
168
|
}
|
|
166
169
|
catch (err) {
|
|
167
170
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -73,31 +73,16 @@ export declare const WorkflowNextOutputSchema: z.ZodObject<{
|
|
|
73
73
|
}>;
|
|
74
74
|
export declare const WorkflowValidateJsonOutputSchema: z.ZodObject<{
|
|
75
75
|
valid: z.ZodBoolean;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
path: z.ZodOptional<z.ZodString>;
|
|
79
|
-
}, "strip", z.ZodTypeAny, {
|
|
80
|
-
message: string;
|
|
81
|
-
path?: string | undefined;
|
|
82
|
-
}, {
|
|
83
|
-
message: string;
|
|
84
|
-
path?: string | undefined;
|
|
85
|
-
}>, "many">>;
|
|
86
|
-
suggestions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
76
|
+
issues: z.ZodArray<z.ZodString, "many">;
|
|
77
|
+
suggestions: z.ZodArray<z.ZodString, "many">;
|
|
87
78
|
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
issues: string[];
|
|
88
80
|
valid: boolean;
|
|
89
|
-
suggestions
|
|
90
|
-
errors?: {
|
|
91
|
-
message: string;
|
|
92
|
-
path?: string | undefined;
|
|
93
|
-
}[] | undefined;
|
|
81
|
+
suggestions: string[];
|
|
94
82
|
}, {
|
|
83
|
+
issues: string[];
|
|
95
84
|
valid: boolean;
|
|
96
|
-
suggestions
|
|
97
|
-
errors?: {
|
|
98
|
-
message: string;
|
|
99
|
-
path?: string | undefined;
|
|
100
|
-
}[] | undefined;
|
|
85
|
+
suggestions: string[];
|
|
101
86
|
}>;
|
|
102
87
|
export declare const WorkflowGetSchemaOutputSchema: z.ZodObject<{
|
|
103
88
|
schema: z.ZodType<JsonValue, z.ZodTypeDef, JsonValue>;
|
|
@@ -262,6 +247,7 @@ export declare const V2WorkflowListItemSchema: z.ZodObject<{
|
|
|
262
247
|
reason: string;
|
|
263
248
|
specVersionAtLastReview?: number | undefined;
|
|
264
249
|
}>>;
|
|
250
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
265
251
|
}, "strip", z.ZodTypeAny, {
|
|
266
252
|
kind: "workflow";
|
|
267
253
|
name: string;
|
|
@@ -269,6 +255,7 @@ export declare const V2WorkflowListItemSchema: z.ZodObject<{
|
|
|
269
255
|
version: string;
|
|
270
256
|
workflowId: string;
|
|
271
257
|
workflowHash: string | null;
|
|
258
|
+
examples?: string[] | undefined;
|
|
272
259
|
visibility?: {
|
|
273
260
|
source: {
|
|
274
261
|
kind: "custom" | "bundled" | "user" | "project" | "git" | "remote" | "plugin";
|
|
@@ -299,6 +286,7 @@ export declare const V2WorkflowListItemSchema: z.ZodObject<{
|
|
|
299
286
|
version: string;
|
|
300
287
|
workflowId: string;
|
|
301
288
|
workflowHash: string | null;
|
|
289
|
+
examples?: string[] | undefined;
|
|
302
290
|
visibility?: {
|
|
303
291
|
source: {
|
|
304
292
|
kind: "custom" | "bundled" | "user" | "project" | "git" | "remote" | "plugin";
|
|
@@ -439,14 +427,14 @@ export declare const TagSummaryItemSchema: z.ZodObject<{
|
|
|
439
427
|
}, "strip", z.ZodTypeAny, {
|
|
440
428
|
id: string;
|
|
441
429
|
when: string[];
|
|
442
|
-
displayName: string;
|
|
443
430
|
examples: string[];
|
|
431
|
+
displayName: string;
|
|
444
432
|
count: number;
|
|
445
433
|
}, {
|
|
446
434
|
id: string;
|
|
447
435
|
when: string[];
|
|
448
|
-
displayName: string;
|
|
449
436
|
examples: string[];
|
|
437
|
+
displayName: string;
|
|
450
438
|
count: number;
|
|
451
439
|
}>;
|
|
452
440
|
export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
@@ -546,6 +534,7 @@ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
|
546
534
|
reason: string;
|
|
547
535
|
specVersionAtLastReview?: number | undefined;
|
|
548
536
|
}>>;
|
|
537
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
549
538
|
}, "strip", z.ZodTypeAny, {
|
|
550
539
|
kind: "workflow";
|
|
551
540
|
name: string;
|
|
@@ -553,6 +542,7 @@ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
|
553
542
|
version: string;
|
|
554
543
|
workflowId: string;
|
|
555
544
|
workflowHash: string | null;
|
|
545
|
+
examples?: string[] | undefined;
|
|
556
546
|
visibility?: {
|
|
557
547
|
source: {
|
|
558
548
|
kind: "custom" | "bundled" | "user" | "project" | "git" | "remote" | "plugin";
|
|
@@ -583,6 +573,7 @@ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
|
583
573
|
version: string;
|
|
584
574
|
workflowId: string;
|
|
585
575
|
workflowHash: string | null;
|
|
576
|
+
examples?: string[] | undefined;
|
|
586
577
|
visibility?: {
|
|
587
578
|
source: {
|
|
588
579
|
kind: "custom" | "bundled" | "user" | "project" | "git" | "remote" | "plugin";
|
|
@@ -616,14 +607,14 @@ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
|
616
607
|
}, "strip", z.ZodTypeAny, {
|
|
617
608
|
id: string;
|
|
618
609
|
when: string[];
|
|
619
|
-
displayName: string;
|
|
620
610
|
examples: string[];
|
|
611
|
+
displayName: string;
|
|
621
612
|
count: number;
|
|
622
613
|
}, {
|
|
623
614
|
id: string;
|
|
624
615
|
when: string[];
|
|
625
|
-
displayName: string;
|
|
626
616
|
examples: string[];
|
|
617
|
+
displayName: string;
|
|
627
618
|
count: number;
|
|
628
619
|
}>, "many">>;
|
|
629
620
|
_nextStep: z.ZodOptional<z.ZodString>;
|
|
@@ -744,6 +735,7 @@ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
|
744
735
|
version: string;
|
|
745
736
|
workflowId: string;
|
|
746
737
|
workflowHash: string | null;
|
|
738
|
+
examples?: string[] | undefined;
|
|
747
739
|
visibility?: {
|
|
748
740
|
source: {
|
|
749
741
|
kind: "custom" | "bundled" | "user" | "project" | "git" | "remote" | "plugin";
|
|
@@ -799,8 +791,8 @@ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
|
799
791
|
tagSummary?: {
|
|
800
792
|
id: string;
|
|
801
793
|
when: string[];
|
|
802
|
-
displayName: string;
|
|
803
794
|
examples: string[];
|
|
795
|
+
displayName: string;
|
|
804
796
|
count: number;
|
|
805
797
|
}[] | undefined;
|
|
806
798
|
_nextStep?: string | undefined;
|
|
@@ -813,6 +805,7 @@ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
|
813
805
|
version: string;
|
|
814
806
|
workflowId: string;
|
|
815
807
|
workflowHash: string | null;
|
|
808
|
+
examples?: string[] | undefined;
|
|
816
809
|
visibility?: {
|
|
817
810
|
source: {
|
|
818
811
|
kind: "custom" | "bundled" | "user" | "project" | "git" | "remote" | "plugin";
|
|
@@ -868,8 +861,8 @@ export declare const V2WorkflowListOutputSchema: z.ZodObject<{
|
|
|
868
861
|
tagSummary?: {
|
|
869
862
|
id: string;
|
|
870
863
|
when: string[];
|
|
871
|
-
displayName: string;
|
|
872
864
|
examples: string[];
|
|
865
|
+
displayName: string;
|
|
873
866
|
count: number;
|
|
874
867
|
}[] | undefined;
|
|
875
868
|
_nextStep?: string | undefined;
|
|
@@ -2450,6 +2443,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2450
2443
|
tool: "continue_workflow";
|
|
2451
2444
|
}>>;
|
|
2452
2445
|
staleRoots: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2446
|
+
warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
2453
2447
|
}, "strip", z.ZodTypeAny, {
|
|
2454
2448
|
pending: {
|
|
2455
2449
|
stepId: string;
|
|
@@ -2469,6 +2463,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2469
2463
|
};
|
|
2470
2464
|
tool: "continue_workflow";
|
|
2471
2465
|
} | null;
|
|
2466
|
+
warnings?: string[] | undefined;
|
|
2472
2467
|
continueToken?: string | undefined;
|
|
2473
2468
|
checkpointToken?: string | undefined;
|
|
2474
2469
|
staleRoots?: string[] | undefined;
|
|
@@ -2491,6 +2486,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2491
2486
|
};
|
|
2492
2487
|
tool: "continue_workflow";
|
|
2493
2488
|
} | null;
|
|
2489
|
+
warnings?: string[] | undefined;
|
|
2494
2490
|
continueToken?: string | undefined;
|
|
2495
2491
|
checkpointToken?: string | undefined;
|
|
2496
2492
|
staleRoots?: string[] | undefined;
|
|
@@ -2513,6 +2509,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2513
2509
|
};
|
|
2514
2510
|
tool: "continue_workflow";
|
|
2515
2511
|
} | null;
|
|
2512
|
+
warnings?: string[] | undefined;
|
|
2516
2513
|
continueToken?: string | undefined;
|
|
2517
2514
|
checkpointToken?: string | undefined;
|
|
2518
2515
|
staleRoots?: string[] | undefined;
|
|
@@ -2535,6 +2532,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
2535
2532
|
};
|
|
2536
2533
|
tool: "continue_workflow";
|
|
2537
2534
|
} | null;
|
|
2535
|
+
warnings?: string[] | undefined;
|
|
2538
2536
|
continueToken?: string | undefined;
|
|
2539
2537
|
checkpointToken?: string | undefined;
|
|
2540
2538
|
staleRoots?: string[] | undefined;
|
|
@@ -27,13 +27,8 @@ exports.WorkflowNextOutputSchema = zod_1.z.object({
|
|
|
27
27
|
});
|
|
28
28
|
exports.WorkflowValidateJsonOutputSchema = zod_1.z.object({
|
|
29
29
|
valid: zod_1.z.boolean(),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
message: zod_1.z.string(),
|
|
33
|
-
path: zod_1.z.string().optional(),
|
|
34
|
-
}))
|
|
35
|
-
.optional(),
|
|
36
|
-
suggestions: zod_1.z.array(zod_1.z.string()).optional(),
|
|
30
|
+
issues: zod_1.z.array(zod_1.z.string()),
|
|
31
|
+
suggestions: zod_1.z.array(zod_1.z.string()),
|
|
37
32
|
});
|
|
38
33
|
exports.WorkflowGetSchemaOutputSchema = zod_1.z.object({
|
|
39
34
|
schema: exports.JsonValueSchema,
|
|
@@ -79,6 +74,9 @@ exports.V2WorkflowListItemSchema = zod_1.z.object({
|
|
|
79
74
|
}).optional(),
|
|
80
75
|
}).optional(),
|
|
81
76
|
staleness: exports.StalenessSummarySchema.optional(),
|
|
77
|
+
examples: zod_1.z.array(zod_1.z.string().min(10).max(120)).min(1).max(6).optional().describe('Short illustrative goal strings showing what this workflow is used for. ' +
|
|
78
|
+
'Present when the workflow author has provided examples. ' +
|
|
79
|
+
'Use these to help users understand what goals to provide when starting this workflow.'),
|
|
82
80
|
});
|
|
83
81
|
exports.V2WorkflowSourceCatalogEntrySchema = zod_1.z.object({
|
|
84
82
|
sourceKey: zod_1.z.string().min(1).describe('Stable identifier for this source. Format: "{kind}:{absolutePath}" for filesystem sources (e.g. "project:/path/to/workflows", "custom:/path/to/.workrail/workflows"), or "built_in" for bundled sources.'),
|
|
@@ -394,6 +392,8 @@ exports.V2StartWorkflowOutputSchema = zod_1.z.object({
|
|
|
394
392
|
staleRoots: zod_1.z.array(zod_1.z.string()).optional().describe('Workflow source paths that were inaccessible during discovery (missing remembered roots or missing managed source directories). ' +
|
|
395
393
|
'Workflows from these paths were not included in this response. ' +
|
|
396
394
|
'These paths will be rechecked on the next call.'),
|
|
395
|
+
warnings: zod_1.z.array(zod_1.z.string()).optional().describe('Non-fatal warnings about workflow source availability. ' +
|
|
396
|
+
'The workflow was started successfully but some sources may have been unavailable (e.g., managed source store temporarily inaccessible).'),
|
|
397
397
|
}).refine((data) => (data.pending ? data.continueToken != null : true), { message: 'continueToken is required when a pending step exists' });
|
|
398
398
|
exports.CreateSessionOutputSchema = zod_1.z.object({
|
|
399
399
|
sessionId: zod_1.z.string().min(1),
|
package/dist/mcp/server.js
CHANGED
|
@@ -47,6 +47,8 @@ const workspace_roots_manager_js_1 = require("./workspace-roots-manager.js");
|
|
|
47
47
|
const index_js_2 = require("../v2/infra/local/directory-listing/index.js");
|
|
48
48
|
const index_js_3 = require("../v2/infra/local/session-summary-provider/index.js");
|
|
49
49
|
const tool_factory_js_1 = require("./tool-factory.js");
|
|
50
|
+
const dev_mode_js_1 = require("./dev-mode.js");
|
|
51
|
+
const tool_call_timing_js_1 = require("./tool-call-timing.js");
|
|
50
52
|
const handler_factory_js_1 = require("./handler-factory.js");
|
|
51
53
|
const workflow_tool_edition_selector_js_1 = require("./workflow-tool-edition-selector.js");
|
|
52
54
|
const tools_js_1 = require("./tools.js");
|
|
@@ -159,8 +161,9 @@ function toMcpTool(tool) {
|
|
|
159
161
|
};
|
|
160
162
|
}
|
|
161
163
|
async function composeServer() {
|
|
162
|
-
await (0, container_js_1.bootstrap)(
|
|
164
|
+
await (0, container_js_1.bootstrap)();
|
|
163
165
|
const ctx = await createToolContext();
|
|
166
|
+
const timingRingBuffer = new tool_call_timing_js_1.ToolCallTimingRingBuffer(tool_call_timing_js_1.DEFAULT_RING_BUFFER_CAPACITY);
|
|
164
167
|
if (ctx.v2 && ctx.httpServer && ctx.v2.dataDir && ctx.v2.directoryListing) {
|
|
165
168
|
const { ConsoleService } = await Promise.resolve().then(() => __importStar(require('../v2/usecases/console-service.js')));
|
|
166
169
|
const { mountConsoleRoutes } = await Promise.resolve().then(() => __importStar(require('../v2/usecases/console-routes.js')));
|
|
@@ -171,7 +174,7 @@ async function composeServer() {
|
|
|
171
174
|
snapshotStore: ctx.v2.snapshotStore,
|
|
172
175
|
pinnedWorkflowStore: ctx.v2.pinnedStore,
|
|
173
176
|
});
|
|
174
|
-
ctx.httpServer.mountRoutes((app) => mountConsoleRoutes(app, consoleService));
|
|
177
|
+
ctx.httpServer.mountRoutes((app) => mountConsoleRoutes(app, consoleService, ctx.workflowService, timingRingBuffer));
|
|
175
178
|
console.error('[Console] v2 Console API routes mounted at /api/v2/');
|
|
176
179
|
}
|
|
177
180
|
ctx.httpServer?.finalize();
|
|
@@ -214,19 +217,35 @@ async function composeServer() {
|
|
|
214
217
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
215
218
|
tools,
|
|
216
219
|
}));
|
|
220
|
+
const devMode = (0, dev_mode_js_1.isDevMode)();
|
|
221
|
+
const timingSink = devMode
|
|
222
|
+
? (0, tool_call_timing_js_1.composeSinks)((0, tool_call_timing_js_1.createRingBufferSink)(timingRingBuffer), (0, tool_call_timing_js_1.createDevPerfSink)())
|
|
223
|
+
: (0, tool_call_timing_js_1.createRingBufferSink)(timingRingBuffer);
|
|
224
|
+
if (devMode) {
|
|
225
|
+
console.error('[PerfTrace] WORKRAIL_DEV=1 -- tool call timing active');
|
|
226
|
+
}
|
|
217
227
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
218
228
|
const { name, arguments: args } = request.params;
|
|
229
|
+
const handlerStartMs = Date.now();
|
|
230
|
+
const handlerStartHr = performance.now();
|
|
219
231
|
const handler = handlers[name];
|
|
220
232
|
if (!handler) {
|
|
221
|
-
|
|
233
|
+
const unknownResult = {
|
|
222
234
|
content: [{ type: 'text', text: `Unknown tool: ${name}` }],
|
|
223
235
|
isError: true,
|
|
224
236
|
};
|
|
237
|
+
const durationMs = Math.round((performance.now() - handlerStartHr) * 100) / 100;
|
|
238
|
+
try {
|
|
239
|
+
timingSink({ toolName: name ?? '(unknown)', startedAtMs: handlerStartMs, durationMs, outcome: 'unknown_tool' });
|
|
240
|
+
}
|
|
241
|
+
catch {
|
|
242
|
+
}
|
|
243
|
+
return unknownResult;
|
|
225
244
|
}
|
|
226
245
|
const requestCtx = ctx.v2
|
|
227
246
|
? { ...ctx, v2: { ...ctx.v2, resolvedRootUris: rootsManager.getCurrentRootUris() } }
|
|
228
247
|
: ctx;
|
|
229
|
-
return handler(args ?? {}, requestCtx);
|
|
248
|
+
return (0, tool_call_timing_js_1.withToolCallTiming)(name, () => handler(args ?? {}, requestCtx), timingSink);
|
|
230
249
|
});
|
|
231
250
|
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
232
251
|
resources: [
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type ToolCallOutcome = 'success' | 'error' | 'unknown_tool';
|
|
2
|
+
export interface ToolCallTiming {
|
|
3
|
+
readonly toolName: string;
|
|
4
|
+
readonly startedAtMs: number;
|
|
5
|
+
readonly durationMs: number;
|
|
6
|
+
readonly outcome: ToolCallOutcome;
|
|
7
|
+
}
|
|
8
|
+
export type ToolCallTimingSink = (timing: ToolCallTiming) => void;
|
|
9
|
+
export declare const noopToolCallTimingSink: ToolCallTimingSink;
|
|
10
|
+
export declare class ToolCallTimingRingBuffer {
|
|
11
|
+
private readonly capacity;
|
|
12
|
+
private readonly buffer;
|
|
13
|
+
private head;
|
|
14
|
+
private count;
|
|
15
|
+
constructor(capacity: number);
|
|
16
|
+
push(timing: ToolCallTiming): void;
|
|
17
|
+
recent(limit?: number): readonly ToolCallTiming[];
|
|
18
|
+
get size(): number;
|
|
19
|
+
}
|
|
20
|
+
export declare const DEFAULT_RING_BUFFER_CAPACITY = 100;
|
|
21
|
+
export declare function createRingBufferSink(buffer: ToolCallTimingRingBuffer): ToolCallTimingSink;
|
|
22
|
+
export declare function createDevPerfSink(): ToolCallTimingSink;
|
|
23
|
+
export declare function composeSinks(...sinks: ToolCallTimingSink[]): ToolCallTimingSink;
|
|
24
|
+
export declare function withToolCallTiming<T>(toolName: string, handler: () => Promise<T>, sink: ToolCallTimingSink): Promise<T>;
|