@qase/mcp-server 1.1.8 → 2.0.1
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/CHANGELOG.md +38 -0
- package/README.md +75 -542
- package/build/auth/client-context.d.ts +12 -0
- package/build/auth/client-context.d.ts.map +1 -0
- package/build/auth/client-context.js +12 -0
- package/build/auth/client-context.js.map +1 -0
- package/build/auth/jwks-verifier.d.ts +15 -0
- package/build/auth/jwks-verifier.d.ts.map +1 -0
- package/build/auth/jwks-verifier.js +31 -0
- package/build/auth/jwks-verifier.js.map +1 -0
- package/build/auth/mcp-guard.d.ts +15 -0
- package/build/auth/mcp-guard.d.ts.map +1 -0
- package/build/auth/mcp-guard.js +44 -0
- package/build/auth/mcp-guard.js.map +1 -0
- package/build/auth/oauth-config.d.ts +40 -0
- package/build/auth/oauth-config.d.ts.map +1 -0
- package/build/auth/oauth-config.js +34 -0
- package/build/auth/oauth-config.js.map +1 -0
- package/build/auth/proxy-provider.d.ts +31 -0
- package/build/auth/proxy-provider.d.ts.map +1 -0
- package/build/auth/proxy-provider.js +87 -0
- package/build/auth/proxy-provider.js.map +1 -0
- package/build/auth/token-type.d.ts +7 -0
- package/build/auth/token-type.d.ts.map +1 -0
- package/build/auth/token-type.js +10 -0
- package/build/auth/token-type.js.map +1 -0
- package/build/cache/circuit-breaker.d.ts +33 -0
- package/build/cache/circuit-breaker.d.ts.map +1 -0
- package/build/cache/circuit-breaker.js +68 -0
- package/build/cache/circuit-breaker.js.map +1 -0
- package/build/cache/index.d.ts +24 -0
- package/build/cache/index.d.ts.map +1 -0
- package/build/cache/index.js +86 -0
- package/build/cache/index.js.map +1 -0
- package/build/cache/keys.d.ts +25 -0
- package/build/cache/keys.d.ts.map +1 -0
- package/build/cache/keys.js +36 -0
- package/build/cache/keys.js.map +1 -0
- package/build/cache/layered.d.ts +31 -0
- package/build/cache/layered.d.ts.map +1 -0
- package/build/cache/layered.js +88 -0
- package/build/cache/layered.js.map +1 -0
- package/build/cache/memory.d.ts +32 -0
- package/build/cache/memory.d.ts.map +1 -0
- package/build/cache/memory.js +108 -0
- package/build/cache/memory.js.map +1 -0
- package/build/cache/metrics.d.ts +31 -0
- package/build/cache/metrics.d.ts.map +1 -0
- package/build/cache/metrics.js +95 -0
- package/build/cache/metrics.js.map +1 -0
- package/build/cache/prom-format.d.ts +7 -0
- package/build/cache/prom-format.d.ts.map +1 -0
- package/build/cache/prom-format.js +16 -0
- package/build/cache/prom-format.js.map +1 -0
- package/build/cache/redis-bus.d.ts +29 -0
- package/build/cache/redis-bus.d.ts.map +1 -0
- package/build/cache/redis-bus.js +50 -0
- package/build/cache/redis-bus.js.map +1 -0
- package/build/cache/redis.d.ts +32 -0
- package/build/cache/redis.d.ts.map +1 -0
- package/build/cache/redis.js +89 -0
- package/build/cache/redis.js.map +1 -0
- package/build/cache/types.d.ts +38 -0
- package/build/cache/types.d.ts.map +1 -0
- package/build/cache/types.js +2 -0
- package/build/cache/types.js.map +1 -0
- package/build/client/index.d.ts +10 -3
- package/build/client/index.d.ts.map +1 -1
- package/build/client/index.js +75 -50
- package/build/client/index.js.map +1 -1
- package/build/http/agent.d.ts +16 -0
- package/build/http/agent.d.ts.map +1 -0
- package/build/http/agent.js +16 -0
- package/build/http/agent.js.map +1 -0
- package/build/http/dedupe.d.ts +14 -0
- package/build/http/dedupe.d.ts.map +1 -0
- package/build/http/dedupe.js +69 -0
- package/build/http/dedupe.js.map +1 -0
- package/build/http/index.d.ts +6 -0
- package/build/http/index.d.ts.map +1 -0
- package/build/http/index.js +4 -0
- package/build/http/index.js.map +1 -0
- package/build/http/retry.d.ts +18 -0
- package/build/http/retry.d.ts.map +1 -0
- package/build/http/retry.js +52 -0
- package/build/http/retry.js.map +1 -0
- package/build/index.d.ts +1 -18
- package/build/index.d.ts.map +1 -1
- package/build/index.js +95 -63
- package/build/index.js.map +1 -1
- package/build/operations-v2/composites/ci-report.d.ts +2 -0
- package/build/operations-v2/composites/ci-report.d.ts.map +1 -0
- package/build/operations-v2/composites/ci-report.js +99 -0
- package/build/operations-v2/composites/ci-report.js.map +1 -0
- package/build/operations-v2/composites/regression-run.d.ts +2 -0
- package/build/operations-v2/composites/regression-run.d.ts.map +1 -0
- package/build/operations-v2/composites/regression-run.js +81 -0
- package/build/operations-v2/composites/regression-run.js.map +1 -0
- package/build/operations-v2/composites/triage-defect.d.ts +2 -0
- package/build/operations-v2/composites/triage-defect.d.ts.map +1 -0
- package/build/operations-v2/composites/triage-defect.js +67 -0
- package/build/operations-v2/composites/triage-defect.js.map +1 -0
- package/build/operations-v2/escape/api.d.ts +2 -0
- package/build/operations-v2/escape/api.d.ts.map +1 -0
- package/build/operations-v2/escape/api.js +34 -0
- package/build/operations-v2/escape/api.js.map +1 -0
- package/build/operations-v2/index.d.ts +21 -0
- package/build/operations-v2/index.d.ts.map +1 -0
- package/build/operations-v2/index.js +27 -0
- package/build/operations-v2/index.js.map +1 -0
- package/build/operations-v2/meta/discover.d.ts +9 -0
- package/build/operations-v2/meta/discover.d.ts.map +1 -0
- package/build/operations-v2/meta/discover.js +79 -0
- package/build/operations-v2/meta/discover.js.map +1 -0
- package/build/{operations/search.d.ts → operations-v2/qql/index.d.ts} +1 -1
- package/build/operations-v2/qql/index.d.ts.map +1 -0
- package/build/{operations/search.js → operations-v2/qql/index.js} +34 -9
- package/build/operations-v2/qql/index.js.map +1 -0
- package/build/operations-v2/read/get.d.ts +2 -0
- package/build/operations-v2/read/get.d.ts.map +1 -0
- package/build/operations-v2/read/get.js +115 -0
- package/build/operations-v2/read/get.js.map +1 -0
- package/build/operations-v2/read/project-context.d.ts +2 -0
- package/build/operations-v2/read/project-context.d.ts.map +1 -0
- package/build/operations-v2/read/project-context.js +102 -0
- package/build/operations-v2/read/project-context.js.map +1 -0
- package/build/operations-v2/write/attachments.d.ts +2 -0
- package/build/operations-v2/write/attachments.d.ts.map +1 -0
- package/build/operations-v2/write/attachments.js +58 -0
- package/build/operations-v2/write/attachments.js.map +1 -0
- package/build/operations-v2/write/case-fields.d.ts +206 -0
- package/build/operations-v2/write/case-fields.d.ts.map +1 -0
- package/build/operations-v2/write/case-fields.js +79 -0
- package/build/operations-v2/write/case-fields.js.map +1 -0
- package/build/operations-v2/write/cases-bulk.d.ts +2 -0
- package/build/operations-v2/write/cases-bulk.d.ts.map +1 -0
- package/build/operations-v2/write/cases-bulk.js +54 -0
- package/build/operations-v2/write/cases-bulk.js.map +1 -0
- package/build/operations-v2/write/cases.d.ts +2 -0
- package/build/operations-v2/write/cases.d.ts.map +1 -0
- package/build/operations-v2/write/cases.js +52 -0
- package/build/operations-v2/write/cases.js.map +1 -0
- package/build/operations-v2/write/defects.d.ts +2 -0
- package/build/operations-v2/write/defects.d.ts.map +1 -0
- package/build/operations-v2/write/defects.js +81 -0
- package/build/operations-v2/write/defects.js.map +1 -0
- package/build/operations-v2/write/environments.d.ts +2 -0
- package/build/operations-v2/write/environments.d.ts.map +1 -0
- package/build/operations-v2/write/environments.js +56 -0
- package/build/operations-v2/write/environments.js.map +1 -0
- package/build/operations-v2/write/external-issues.d.ts +2 -0
- package/build/operations-v2/write/external-issues.d.ts.map +1 -0
- package/build/operations-v2/write/external-issues.js +96 -0
- package/build/operations-v2/write/external-issues.js.map +1 -0
- package/build/operations-v2/write/milestones.d.ts +2 -0
- package/build/operations-v2/write/milestones.d.ts.map +1 -0
- package/build/operations-v2/write/milestones.js +56 -0
- package/build/operations-v2/write/milestones.js.map +1 -0
- package/build/operations-v2/write/plans.d.ts +2 -0
- package/build/operations-v2/write/plans.d.ts.map +1 -0
- package/build/operations-v2/write/plans.js +55 -0
- package/build/operations-v2/write/plans.js.map +1 -0
- package/build/operations-v2/write/results.d.ts +2 -0
- package/build/operations-v2/write/results.d.ts.map +1 -0
- package/build/operations-v2/write/results.js +72 -0
- package/build/operations-v2/write/results.js.map +1 -0
- package/build/operations-v2/write/runs.d.ts +2 -0
- package/build/operations-v2/write/runs.d.ts.map +1 -0
- package/build/operations-v2/write/runs.js +84 -0
- package/build/operations-v2/write/runs.js.map +1 -0
- package/build/operations-v2/write/shared-steps.d.ts +2 -0
- package/build/operations-v2/write/shared-steps.d.ts.map +1 -0
- package/build/operations-v2/write/shared-steps.js +60 -0
- package/build/operations-v2/write/shared-steps.js.map +1 -0
- package/build/operations-v2/write/suites.d.ts +2 -0
- package/build/operations-v2/write/suites.d.ts.map +1 -0
- package/build/operations-v2/write/suites.js +63 -0
- package/build/operations-v2/write/suites.js.map +1 -0
- package/build/prompts/index.d.ts +31 -0
- package/build/prompts/index.d.ts.map +1 -0
- package/build/prompts/index.js +229 -0
- package/build/prompts/index.js.map +1 -0
- package/build/transports/sse.d.ts.map +1 -1
- package/build/transports/sse.js +6 -0
- package/build/transports/sse.js.map +1 -1
- package/build/transports/streamableHttp.d.ts +6 -1
- package/build/transports/streamableHttp.d.ts.map +1 -1
- package/build/transports/streamableHttp.js +128 -16
- package/build/transports/streamableHttp.js.map +1 -1
- package/build/utils/auth-context.d.ts +8 -0
- package/build/utils/auth-context.d.ts.map +1 -1
- package/build/utils/auth-context.js +18 -0
- package/build/utils/auth-context.js.map +1 -1
- package/build/utils/case-enums.d.ts +5 -3
- package/build/utils/case-enums.d.ts.map +1 -1
- package/build/utils/case-enums.js +77 -59
- package/build/utils/case-enums.js.map +1 -1
- package/build/utils/output-schemas.d.ts +16 -0
- package/build/utils/output-schemas.d.ts.map +1 -0
- package/build/utils/output-schemas.js +82 -0
- package/build/utils/output-schemas.js.map +1 -0
- package/build/utils/registry.d.ts +42 -9
- package/build/utils/registry.d.ts.map +1 -1
- package/build/utils/registry.js +64 -11
- package/build/utils/registry.js.map +1 -1
- package/build/utils/response-shape.d.ts +23 -0
- package/build/utils/response-shape.d.ts.map +1 -0
- package/build/utils/response-shape.js +73 -0
- package/build/utils/response-shape.js.map +1 -0
- package/build/utils/rich-response.d.ts +58 -0
- package/build/utils/rich-response.d.ts.map +1 -0
- package/build/utils/rich-response.js +93 -0
- package/build/utils/rich-response.js.map +1 -0
- package/build/utils/server-context.d.ts +65 -0
- package/build/utils/server-context.d.ts.map +1 -0
- package/build/utils/server-context.js +67 -0
- package/build/utils/server-context.js.map +1 -0
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/docs/connect.md +81 -0
- package/docs/migration.md +351 -0
- package/docs/self-run.md +270 -0
- package/docs/tools.md +111 -0
- package/docs/troubleshooting.md +144 -0
- package/package.json +11 -2
- package/server.json +8 -2
- package/build/operations/attachments.d.ts +0 -8
- package/build/operations/attachments.d.ts.map +0 -1
- package/build/operations/attachments.js +0 -146
- package/build/operations/attachments.js.map +0 -1
- package/build/operations/authors.d.ts +0 -8
- package/build/operations/authors.d.ts.map +0 -1
- package/build/operations/authors.js +0 -70
- package/build/operations/authors.js.map +0 -1
- package/build/operations/cases.d.ts +0 -8
- package/build/operations/cases.d.ts.map +0 -1
- package/build/operations/cases.js +0 -370
- package/build/operations/cases.js.map +0 -1
- package/build/operations/configurations.d.ts +0 -10
- package/build/operations/configurations.d.ts.map +0 -1
- package/build/operations/configurations.js +0 -125
- package/build/operations/configurations.js.map +0 -1
- package/build/operations/custom-fields.d.ts +0 -8
- package/build/operations/custom-fields.d.ts.map +0 -1
- package/build/operations/custom-fields.js +0 -172
- package/build/operations/custom-fields.js.map +0 -1
- package/build/operations/defects.d.ts +0 -8
- package/build/operations/defects.d.ts.map +0 -1
- package/build/operations/defects.js +0 -256
- package/build/operations/defects.js.map +0 -1
- package/build/operations/environments.d.ts +0 -8
- package/build/operations/environments.d.ts.map +0 -1
- package/build/operations/environments.js +0 -154
- package/build/operations/environments.js.map +0 -1
- package/build/operations/milestones.d.ts +0 -8
- package/build/operations/milestones.d.ts.map +0 -1
- package/build/operations/milestones.js +0 -155
- package/build/operations/milestones.js.map +0 -1
- package/build/operations/plans.d.ts +0 -8
- package/build/operations/plans.d.ts.map +0 -1
- package/build/operations/plans.js +0 -158
- package/build/operations/plans.js.map +0 -1
- package/build/operations/projects.d.ts +0 -8
- package/build/operations/projects.d.ts.map +0 -1
- package/build/operations/projects.js +0 -192
- package/build/operations/projects.js.map +0 -1
- package/build/operations/results.d.ts +0 -8
- package/build/operations/results.d.ts.map +0 -1
- package/build/operations/results.js +0 -214
- package/build/operations/results.js.map +0 -1
- package/build/operations/runs.d.ts +0 -8
- package/build/operations/runs.d.ts.map +0 -1
- package/build/operations/runs.js +0 -224
- package/build/operations/runs.js.map +0 -1
- package/build/operations/search.d.ts.map +0 -1
- package/build/operations/search.js.map +0 -1
- package/build/operations/shared-parameters.d.ts +0 -10
- package/build/operations/shared-parameters.d.ts.map +0 -1
- package/build/operations/shared-parameters.js +0 -93
- package/build/operations/shared-parameters.js.map +0 -1
- package/build/operations/shared-steps.d.ts +0 -8
- package/build/operations/shared-steps.d.ts.map +0 -1
- package/build/operations/shared-steps.js +0 -160
- package/build/operations/shared-steps.js.map +0 -1
- package/build/operations/suites.d.ts +0 -8
- package/build/operations/suites.d.ts.map +0 -1
- package/build/operations/suites.js +0 -169
- package/build/operations/suites.js.map +0 -1
- package/build/operations/system-fields.d.ts +0 -10
- package/build/operations/system-fields.d.ts.map +0 -1
- package/build/operations/system-fields.js +0 -47
- package/build/operations/system-fields.js.map +0 -1
- package/build/operations/users.d.ts +0 -10
- package/build/operations/users.d.ts.map +0 -1
- package/build/operations/users.js +0 -78
- package/build/operations/users.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { getApiClient } from '../client/index.js';
|
|
2
|
+
import { getCache, buildCacheKey, hashToken } from '../cache/index.js';
|
|
3
|
+
import { getEffectiveToken } from './auth-context.js';
|
|
2
4
|
const caseEnumFields = [
|
|
3
5
|
'priority',
|
|
4
6
|
'type',
|
|
@@ -8,85 +10,101 @@ const caseEnumFields = [
|
|
|
8
10
|
'layer',
|
|
9
11
|
'automation',
|
|
10
12
|
];
|
|
11
|
-
|
|
13
|
+
// System fields are workspace-level config (priority, severity, status options,
|
|
14
|
+
// etc.) that change on the order of hours to days when an admin reconfigures
|
|
15
|
+
// the workspace. 5 minutes balances freshness against API call frequency; do
|
|
16
|
+
// not decrease below 1 minute without measuring.
|
|
17
|
+
const SYSTEM_FIELDS_TTL_MS = 5 * 60 * 1000;
|
|
12
18
|
function normalizeEnumValue(raw, lookup) {
|
|
13
|
-
if (raw === undefined || raw === null)
|
|
19
|
+
if (raw === undefined || raw === null)
|
|
14
20
|
return undefined;
|
|
15
|
-
|
|
16
|
-
if (typeof raw === 'number') {
|
|
21
|
+
if (typeof raw === 'number')
|
|
17
22
|
return raw;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const lower = trimmed.toLowerCase();
|
|
29
|
-
if (lookup?.has(lower)) {
|
|
30
|
-
return lookup.get(lower);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
23
|
+
if (typeof raw !== 'string')
|
|
24
|
+
return undefined;
|
|
25
|
+
const trimmed = raw.trim();
|
|
26
|
+
if (trimmed === '')
|
|
27
|
+
return undefined;
|
|
28
|
+
const parsed = Number(trimmed);
|
|
29
|
+
if (Number.isInteger(parsed))
|
|
30
|
+
return parsed;
|
|
31
|
+
const lower = trimmed.toLowerCase();
|
|
32
|
+
return lookup?.[lower];
|
|
34
33
|
}
|
|
35
|
-
function
|
|
36
|
-
if (!entry.options || entry.options.length === 0)
|
|
34
|
+
function buildFieldLookup(entry) {
|
|
35
|
+
if (!entry.options || entry.options.length === 0)
|
|
37
36
|
return undefined;
|
|
37
|
+
const out = {};
|
|
38
|
+
for (const opt of entry.options) {
|
|
39
|
+
out[opt.slug.toLowerCase()] = opt.id;
|
|
40
|
+
if (opt.title)
|
|
41
|
+
out[opt.title.toLowerCase()] = opt.id;
|
|
42
|
+
out[opt.id.toString()] = opt.id;
|
|
38
43
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
function systemFieldsKey() {
|
|
47
|
+
const token = getEffectiveToken();
|
|
48
|
+
const host = process.env.QASE_API_DOMAIN || 'api.qase.io';
|
|
49
|
+
return buildCacheKey({
|
|
50
|
+
host,
|
|
51
|
+
tenantId: hashToken(token),
|
|
52
|
+
resource: 'system_fields',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function fetchSystemFieldMaps() {
|
|
56
|
+
const client = getApiClient();
|
|
57
|
+
const response = await client.systemFields.getSystemFields();
|
|
58
|
+
const map = {};
|
|
59
|
+
for (const entry of response.data.result) {
|
|
60
|
+
const slug = entry.slug.toLowerCase();
|
|
61
|
+
const lookup = buildFieldLookup(entry);
|
|
62
|
+
if (lookup)
|
|
63
|
+
map[slug] = lookup;
|
|
46
64
|
}
|
|
47
65
|
return map;
|
|
48
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Resolve system-field metadata from cache, fetching from the API on miss.
|
|
69
|
+
*
|
|
70
|
+
* Note on concurrency: this function does not coalesce concurrent cache
|
|
71
|
+
* misses. If two requests race past a cold cache simultaneously, both will
|
|
72
|
+
* hit the API. This is deliberate — the axios-level in-flight deduplication
|
|
73
|
+
* added in Task 12 of the Phase 1 plan coalesces identical GETs at the HTTP
|
|
74
|
+
* layer, which is a more general fix that also covers other metadata
|
|
75
|
+
* fetches, so there is no need to reimplement it here.
|
|
76
|
+
*/
|
|
49
77
|
async function getSystemFieldMaps() {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for (const entry of response.data.result) {
|
|
59
|
-
const normalizedSlug = entry.slug.toLowerCase();
|
|
60
|
-
const fieldMap = createFieldMap(entry);
|
|
61
|
-
if (fieldMap) {
|
|
62
|
-
map[normalizedSlug] = fieldMap;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return map;
|
|
66
|
-
})
|
|
67
|
-
.catch((error) => {
|
|
68
|
-
systemFieldCache = null;
|
|
69
|
-
throw error;
|
|
70
|
-
});
|
|
71
|
-
return systemFieldCache;
|
|
78
|
+
const cache = await getCache();
|
|
79
|
+
const key = systemFieldsKey();
|
|
80
|
+
const cached = await cache.get(key);
|
|
81
|
+
if (cached)
|
|
82
|
+
return cached;
|
|
83
|
+
const fresh = await fetchSystemFieldMaps();
|
|
84
|
+
await cache.set(key, fresh, SYSTEM_FIELDS_TTL_MS);
|
|
85
|
+
return fresh;
|
|
72
86
|
}
|
|
73
87
|
export async function normalizeCaseEnums(caseData) {
|
|
74
88
|
const normalized = { ...caseData };
|
|
75
89
|
const systemFields = await getSystemFieldMaps();
|
|
76
90
|
for (const field of caseEnumFields) {
|
|
77
|
-
const
|
|
91
|
+
const raw = normalized[field];
|
|
78
92
|
const lookup = systemFields[field];
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
normalized[field] =
|
|
93
|
+
const mapped = normalizeEnumValue(raw, lookup);
|
|
94
|
+
if (mapped !== undefined) {
|
|
95
|
+
normalized[field] = mapped;
|
|
82
96
|
}
|
|
83
97
|
}
|
|
84
98
|
return normalized;
|
|
85
99
|
}
|
|
86
|
-
|
|
87
|
-
|
|
100
|
+
/** @internal — used by tests to pre-populate the tenant-scoped shard. */
|
|
101
|
+
export async function __setCaseEnumCacheForTest(snapshot) {
|
|
102
|
+
const cache = await getCache();
|
|
103
|
+
await cache.set(systemFieldsKey(), snapshot, SYSTEM_FIELDS_TTL_MS);
|
|
88
104
|
}
|
|
89
|
-
|
|
90
|
-
|
|
105
|
+
/** @internal — used by tests to clear the tenant-scoped shard. */
|
|
106
|
+
export async function resetCaseEnumCacheForTest() {
|
|
107
|
+
const cache = await getCache();
|
|
108
|
+
await cache.delete(systemFieldsKey());
|
|
91
109
|
}
|
|
92
110
|
//# sourceMappingURL=case-enums.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"case-enums.js","sourceRoot":"","sources":["../../src/utils/case-enums.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"case-enums.js","sourceRoot":"","sources":["../../src/utils/case-enums.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAWtD,MAAM,cAAc,GAAoB;IACtC,UAAU;IACV,MAAM;IACN,UAAU;IACV,UAAU;IACV,QAAQ;IACR,OAAO;IACP,YAAY;CACb,CAAC;AAeF,gFAAgF;AAChF,6EAA6E;AAC7E,6EAA6E;AAC7E,iDAAiD;AACjD,MAAM,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3C,SAAS,kBAAkB,CAAC,GAAY,EAAE,MAA+B;IACvE,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,SAAS,CAAC;IACxD,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAE9C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,SAAS,CAAC;IAErC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IAE5C,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACpC,OAAO,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,SAAS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,QAAQ,EAAE,oBAAoB,CAAC,CAAC;AACrE,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,KAAK,UAAU,yBAAyB;IAC7C,MAAM,KAAK,GAAG,MAAM,QAAQ,EAAE,CAAC;IAC/B,MAAM,KAAK,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Schemas for MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* JSON Schema definitions describing tool output structure.
|
|
5
|
+
* Enables MCP clients to process results programmatically in a sandbox
|
|
6
|
+
* instead of passing raw JSON to the LLM (reduces token usage ~37%).
|
|
7
|
+
*/
|
|
8
|
+
import type { OutputSchema } from './registry.js';
|
|
9
|
+
export declare const CiReportOutput: OutputSchema;
|
|
10
|
+
export declare const RegressionRunOutput: OutputSchema;
|
|
11
|
+
export declare const TriageDefectOutput: OutputSchema;
|
|
12
|
+
export declare const QqlSearchOutput: OutputSchema;
|
|
13
|
+
export declare const ProjectContextOutput: OutputSchema;
|
|
14
|
+
export declare const DeleteOutput: OutputSchema;
|
|
15
|
+
export declare const DiscoverToolsOutput: OutputSchema;
|
|
16
|
+
//# sourceMappingURL=output-schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-schemas.d.ts","sourceRoot":"","sources":["../../src/utils/output-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,eAAO,MAAM,cAAc,EAAE,YAQ5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAQjC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,YAQhC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,YAO7B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,YAWlC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,YAO1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,YAkBjC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output Schemas for MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* JSON Schema definitions describing tool output structure.
|
|
5
|
+
* Enables MCP clients to process results programmatically in a sandbox
|
|
6
|
+
* instead of passing raw JSON to the LLM (reduces token usage ~37%).
|
|
7
|
+
*/
|
|
8
|
+
export const CiReportOutput = {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
run_id: { type: 'integer', description: 'Created run ID' },
|
|
12
|
+
run_status: { type: 'string', enum: ['active', 'complete', 'complete_failed'] },
|
|
13
|
+
results_recorded: { type: 'integer', description: 'Number of results recorded' },
|
|
14
|
+
},
|
|
15
|
+
required: ['run_id', 'run_status', 'results_recorded'],
|
|
16
|
+
};
|
|
17
|
+
export const RegressionRunOutput = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
run_id: { type: 'integer', description: 'Created run ID' },
|
|
21
|
+
cases_added: { type: 'integer', description: 'Number of cases added to the run' },
|
|
22
|
+
run: { type: 'object', description: 'Full run entity' },
|
|
23
|
+
},
|
|
24
|
+
required: ['run_id', 'cases_added'],
|
|
25
|
+
};
|
|
26
|
+
export const TriageDefectOutput = {
|
|
27
|
+
type: 'object',
|
|
28
|
+
properties: {
|
|
29
|
+
defect_id: { type: 'integer', description: 'Created defect ID' },
|
|
30
|
+
defect: { type: 'object', description: 'Full defect entity' },
|
|
31
|
+
linked_results: { type: 'integer', description: 'Number of linked result hashes' },
|
|
32
|
+
},
|
|
33
|
+
required: ['defect_id', 'linked_results'],
|
|
34
|
+
};
|
|
35
|
+
export const QqlSearchOutput = {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
total: { type: 'integer', description: 'Total matching entities' },
|
|
39
|
+
entities: { type: 'array', description: 'Matching entities', items: { type: 'object' } },
|
|
40
|
+
},
|
|
41
|
+
required: ['total', 'entities'],
|
|
42
|
+
};
|
|
43
|
+
export const ProjectContextOutput = {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
project: { type: 'object', description: 'Project details' },
|
|
47
|
+
suites: { type: 'object', description: 'Suites list with entities array' },
|
|
48
|
+
milestones: { type: 'object', description: 'Milestones list' },
|
|
49
|
+
environments: { type: 'object', description: 'Environments list' },
|
|
50
|
+
custom_fields: { type: 'object', description: 'Custom fields list' },
|
|
51
|
+
users: { type: 'object', description: 'Team members list' },
|
|
52
|
+
},
|
|
53
|
+
required: ['project', 'suites', 'milestones', 'environments'],
|
|
54
|
+
};
|
|
55
|
+
export const DeleteOutput = {
|
|
56
|
+
type: 'object',
|
|
57
|
+
properties: {
|
|
58
|
+
success: { type: 'boolean' },
|
|
59
|
+
id: { type: 'integer', description: 'Deleted entity ID' },
|
|
60
|
+
},
|
|
61
|
+
required: ['success'],
|
|
62
|
+
};
|
|
63
|
+
export const DiscoverToolsOutput = {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
found: { type: 'integer', description: 'Number of matching tools' },
|
|
67
|
+
activated: { type: 'integer', description: 'Number of newly activated tools' },
|
|
68
|
+
tools: {
|
|
69
|
+
type: 'array',
|
|
70
|
+
items: {
|
|
71
|
+
type: 'object',
|
|
72
|
+
properties: {
|
|
73
|
+
name: { type: 'string' },
|
|
74
|
+
description: { type: 'string' },
|
|
75
|
+
destructive: { type: 'boolean' },
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
required: ['found', 'activated', 'tools'],
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=output-schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-schemas.js","sourceRoot":"","sources":["../../src/utils/output-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,CAAC,MAAM,c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AAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,0BAA0B,EAAE;QACnE,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,iCAAiC,EAAE;QAC9E,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBAC/B,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;iBACjC;aACF;SACF;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC;CAC1C,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - Convert Zod schemas to JSON Schema automatically
|
|
7
7
|
* - Store and retrieve tool handlers
|
|
8
8
|
* - Manage tool lifecycle
|
|
9
|
+
* - Support tool discovery with core/discoverable visibility
|
|
9
10
|
*/
|
|
10
11
|
import { Tool, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
11
12
|
import { z } from 'zod';
|
|
@@ -18,24 +19,39 @@ export type ToolHandler<T = any, R = any> = (args: T) => Promise<R>;
|
|
|
18
19
|
* Tool definition for registration
|
|
19
20
|
* Contains all information needed to register a tool with the MCP server
|
|
20
21
|
*/
|
|
22
|
+
/** JSON Schema object type for outputSchema */
|
|
23
|
+
export interface OutputSchema {
|
|
24
|
+
type: 'object';
|
|
25
|
+
properties?: Record<string, object>;
|
|
26
|
+
required?: string[];
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
21
29
|
export interface ToolDefinition<T extends z.ZodType = z.ZodType> {
|
|
22
30
|
name: string;
|
|
23
31
|
description: string;
|
|
24
32
|
schema: T;
|
|
25
33
|
handler: ToolHandler;
|
|
26
34
|
annotations?: ToolAnnotations;
|
|
35
|
+
/** JSON Schema describing the tool's output — enables clients to process results programmatically */
|
|
36
|
+
outputSchema?: OutputSchema;
|
|
37
|
+
/** Tool visibility: 'core' tools are always listed, 'discoverable' tools require activation via qase_discover_tools */
|
|
38
|
+
visibility?: 'core' | 'discoverable';
|
|
27
39
|
}
|
|
28
40
|
/**
|
|
29
41
|
* Tool Registry Class
|
|
30
|
-
* Manages the lifecycle of MCP tools
|
|
42
|
+
* Manages the lifecycle of MCP tools with support for dynamic discovery
|
|
31
43
|
*/
|
|
32
44
|
export declare class ToolRegistry {
|
|
33
45
|
private tools;
|
|
34
46
|
private handlers;
|
|
47
|
+
private activeTools;
|
|
48
|
+
private toolVisibility;
|
|
49
|
+
/** Callback invoked when the active tool set changes (wired to server.sendToolListChanged) */
|
|
50
|
+
onToolsChanged?: () => void;
|
|
35
51
|
/**
|
|
36
52
|
* Register a new tool with the registry
|
|
37
53
|
*
|
|
38
|
-
* @param definition - Tool definition including name, description, schema, and
|
|
54
|
+
* @param definition - Tool definition including name, description, schema, handler, and visibility
|
|
39
55
|
*
|
|
40
56
|
* @example
|
|
41
57
|
* ```typescript
|
|
@@ -43,18 +59,33 @@ export declare class ToolRegistry {
|
|
|
43
59
|
* name: 'list_projects',
|
|
44
60
|
* description: 'Get all projects',
|
|
45
61
|
* schema: z.object({ limit: z.number().optional() }),
|
|
46
|
-
* handler: async (args) => { ... }
|
|
62
|
+
* handler: async (args) => { ... },
|
|
63
|
+
* visibility: 'discoverable', // hidden until discovered
|
|
47
64
|
* });
|
|
48
65
|
* ```
|
|
49
66
|
*/
|
|
50
67
|
register<T extends z.ZodType>(definition: ToolDefinition<T>): void;
|
|
51
68
|
/**
|
|
52
|
-
* Get
|
|
69
|
+
* Get active tools only (core + activated discoverable)
|
|
53
70
|
* Used by the ListToolsRequestSchema handler
|
|
54
|
-
*
|
|
55
|
-
* @returns Array of all registered tools
|
|
56
71
|
*/
|
|
57
72
|
getTools(): Tool[];
|
|
73
|
+
/**
|
|
74
|
+
* Get ALL registered tools regardless of activation status.
|
|
75
|
+
* Used for discovery search and testing.
|
|
76
|
+
*/
|
|
77
|
+
getAllTools(): Tool[];
|
|
78
|
+
/**
|
|
79
|
+
* Search tools by name or description (case-insensitive substring match).
|
|
80
|
+
* Searches the full catalog including inactive tools.
|
|
81
|
+
*/
|
|
82
|
+
searchTools(query: string): Tool[];
|
|
83
|
+
/**
|
|
84
|
+
* Activate tools by name, making them visible in getTools().
|
|
85
|
+
* Returns the list of newly activated tool names.
|
|
86
|
+
* Triggers onToolsChanged callback if any tools were activated.
|
|
87
|
+
*/
|
|
88
|
+
activateTools(names: string[]): string[];
|
|
58
89
|
/**
|
|
59
90
|
* Get handler function for a specific tool
|
|
60
91
|
*
|
|
@@ -62,6 +93,10 @@ export declare class ToolRegistry {
|
|
|
62
93
|
* @returns Handler function or undefined if not found
|
|
63
94
|
*/
|
|
64
95
|
getHandler(name: string): ToolHandler | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Get a specific tool definition by name
|
|
98
|
+
*/
|
|
99
|
+
getTool(name: string): Tool | undefined;
|
|
65
100
|
/**
|
|
66
101
|
* Check if a tool exists in the registry
|
|
67
102
|
*
|
|
@@ -70,9 +105,7 @@ export declare class ToolRegistry {
|
|
|
70
105
|
*/
|
|
71
106
|
hasTool(name: string): boolean;
|
|
72
107
|
/**
|
|
73
|
-
* Get the count of registered tools
|
|
74
|
-
*
|
|
75
|
-
* @returns Number of registered tools
|
|
108
|
+
* Get the count of registered tools (all, including inactive)
|
|
76
109
|
*/
|
|
77
110
|
getToolCount(): number;
|
|
78
111
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/utils/registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/utils/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,IAAI,EAAE,eAAe,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AAE;IAIlB;;;OAGG;IACH,WAAW,IAAI,IAAI,EAAE;IAIrB;;;OAGG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE;IASlC;;;;OAIG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAcxC;;;;;OAKG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAIjD;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;IAIvC;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,YAAY,IAAI,MAAM;IAItB;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQjC;;;;OAIG;IACH,KAAK,IAAI,IAAI;CAMd;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,cAAqB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,eAK5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,eAK9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,eAK9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,eAK9B,CAAC"}
|
package/build/utils/registry.js
CHANGED
|
@@ -6,19 +6,24 @@
|
|
|
6
6
|
* - Convert Zod schemas to JSON Schema automatically
|
|
7
7
|
* - Store and retrieve tool handlers
|
|
8
8
|
* - Manage tool lifecycle
|
|
9
|
+
* - Support tool discovery with core/discoverable visibility
|
|
9
10
|
*/
|
|
10
11
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
11
12
|
/**
|
|
12
13
|
* Tool Registry Class
|
|
13
|
-
* Manages the lifecycle of MCP tools
|
|
14
|
+
* Manages the lifecycle of MCP tools with support for dynamic discovery
|
|
14
15
|
*/
|
|
15
16
|
export class ToolRegistry {
|
|
16
17
|
tools = new Map();
|
|
17
18
|
handlers = new Map();
|
|
19
|
+
activeTools = new Set();
|
|
20
|
+
toolVisibility = new Map();
|
|
21
|
+
/** Callback invoked when the active tool set changes (wired to server.sendToolListChanged) */
|
|
22
|
+
onToolsChanged;
|
|
18
23
|
/**
|
|
19
24
|
* Register a new tool with the registry
|
|
20
25
|
*
|
|
21
|
-
* @param definition - Tool definition including name, description, schema, and
|
|
26
|
+
* @param definition - Tool definition including name, description, schema, handler, and visibility
|
|
22
27
|
*
|
|
23
28
|
* @example
|
|
24
29
|
* ```typescript
|
|
@@ -26,12 +31,14 @@ export class ToolRegistry {
|
|
|
26
31
|
* name: 'list_projects',
|
|
27
32
|
* description: 'Get all projects',
|
|
28
33
|
* schema: z.object({ limit: z.number().optional() }),
|
|
29
|
-
* handler: async (args) => { ... }
|
|
34
|
+
* handler: async (args) => { ... },
|
|
35
|
+
* visibility: 'discoverable', // hidden until discovered
|
|
30
36
|
* });
|
|
31
37
|
* ```
|
|
32
38
|
*/
|
|
33
39
|
register(definition) {
|
|
34
|
-
const { name, description, schema, handler, annotations } = definition;
|
|
40
|
+
const { name, description, schema, handler, annotations, outputSchema } = definition;
|
|
41
|
+
const visibility = definition.visibility ?? 'core';
|
|
35
42
|
// Convert Zod schema to JSON Schema for MCP protocol
|
|
36
43
|
// Using explicit type assertion to avoid TypeScript's deep type inference issues
|
|
37
44
|
// The zodToJsonSchema function can cause "excessively deep" type errors with complex schemas
|
|
@@ -66,21 +73,59 @@ export class ToolRegistry {
|
|
|
66
73
|
description,
|
|
67
74
|
inputSchema,
|
|
68
75
|
...(annotations && { annotations }),
|
|
76
|
+
...(outputSchema && { outputSchema }),
|
|
69
77
|
});
|
|
70
78
|
// Store handler function
|
|
71
79
|
this.handlers.set(name, handler);
|
|
80
|
+
// Track visibility and activation
|
|
81
|
+
this.toolVisibility.set(name, visibility);
|
|
82
|
+
if (visibility === 'core') {
|
|
83
|
+
this.activeTools.add(name);
|
|
84
|
+
}
|
|
72
85
|
// Log registration for debugging (to stderr)
|
|
73
|
-
console.error(`[Registry] Registered tool: ${name}`);
|
|
86
|
+
console.error(`[Registry] Registered tool: ${name} (${visibility})`);
|
|
74
87
|
}
|
|
75
88
|
/**
|
|
76
|
-
* Get
|
|
89
|
+
* Get active tools only (core + activated discoverable)
|
|
77
90
|
* Used by the ListToolsRequestSchema handler
|
|
78
|
-
*
|
|
79
|
-
* @returns Array of all registered tools
|
|
80
91
|
*/
|
|
81
92
|
getTools() {
|
|
93
|
+
return Array.from(this.tools.values()).filter((t) => this.activeTools.has(t.name));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get ALL registered tools regardless of activation status.
|
|
97
|
+
* Used for discovery search and testing.
|
|
98
|
+
*/
|
|
99
|
+
getAllTools() {
|
|
82
100
|
return Array.from(this.tools.values());
|
|
83
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Search tools by name or description (case-insensitive substring match).
|
|
104
|
+
* Searches the full catalog including inactive tools.
|
|
105
|
+
*/
|
|
106
|
+
searchTools(query) {
|
|
107
|
+
const lower = query.toLowerCase();
|
|
108
|
+
return this.getAllTools().filter((t) => t.name.toLowerCase().includes(lower) ||
|
|
109
|
+
(t.description?.toLowerCase().includes(lower) ?? false));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Activate tools by name, making them visible in getTools().
|
|
113
|
+
* Returns the list of newly activated tool names.
|
|
114
|
+
* Triggers onToolsChanged callback if any tools were activated.
|
|
115
|
+
*/
|
|
116
|
+
activateTools(names) {
|
|
117
|
+
const newlyActivated = [];
|
|
118
|
+
for (const name of names) {
|
|
119
|
+
if (this.tools.has(name) && !this.activeTools.has(name)) {
|
|
120
|
+
this.activeTools.add(name);
|
|
121
|
+
newlyActivated.push(name);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (newlyActivated.length > 0 && this.onToolsChanged) {
|
|
125
|
+
this.onToolsChanged();
|
|
126
|
+
}
|
|
127
|
+
return newlyActivated;
|
|
128
|
+
}
|
|
84
129
|
/**
|
|
85
130
|
* Get handler function for a specific tool
|
|
86
131
|
*
|
|
@@ -90,6 +135,12 @@ export class ToolRegistry {
|
|
|
90
135
|
getHandler(name) {
|
|
91
136
|
return this.handlers.get(name);
|
|
92
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Get a specific tool definition by name
|
|
140
|
+
*/
|
|
141
|
+
getTool(name) {
|
|
142
|
+
return this.tools.get(name);
|
|
143
|
+
}
|
|
93
144
|
/**
|
|
94
145
|
* Check if a tool exists in the registry
|
|
95
146
|
*
|
|
@@ -100,9 +151,7 @@ export class ToolRegistry {
|
|
|
100
151
|
return this.tools.has(name);
|
|
101
152
|
}
|
|
102
153
|
/**
|
|
103
|
-
* Get the count of registered tools
|
|
104
|
-
*
|
|
105
|
-
* @returns Number of registered tools
|
|
154
|
+
* Get the count of registered tools (all, including inactive)
|
|
106
155
|
*/
|
|
107
156
|
getToolCount() {
|
|
108
157
|
return this.tools.size;
|
|
@@ -117,6 +166,8 @@ export class ToolRegistry {
|
|
|
117
166
|
unregister(name) {
|
|
118
167
|
const hadTool = this.tools.delete(name);
|
|
119
168
|
this.handlers.delete(name);
|
|
169
|
+
this.activeTools.delete(name);
|
|
170
|
+
this.toolVisibility.delete(name);
|
|
120
171
|
return hadTool;
|
|
121
172
|
}
|
|
122
173
|
/**
|
|
@@ -127,6 +178,8 @@ export class ToolRegistry {
|
|
|
127
178
|
clear() {
|
|
128
179
|
this.tools.clear();
|
|
129
180
|
this.handlers.clear();
|
|
181
|
+
this.activeTools.clear();
|
|
182
|
+
this.toolVisibility.clear();
|
|
130
183
|
}
|
|
131
184
|
}
|
|
132
185
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/utils/registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/utils/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,E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, and empty objects
|
|
3
|
+
* from API responses before sending them to the LLM.
|
|
4
|
+
*
|
|
5
|
+
* Zero, false, and empty strings are preserved — they carry signal (e.g.
|
|
6
|
+
* `"description": ""` is different from missing description when the user
|
|
7
|
+
* asked about it).
|
|
8
|
+
*
|
|
9
|
+
* Returns `undefined` only when the input itself is `null` or `undefined`.
|
|
10
|
+
* For objects that collapse to zero kept fields, returns `{}` (an empty
|
|
11
|
+
* object) — callers should test with `Object.keys(result).length === 0` if
|
|
12
|
+
* they want to detect collapse, not `result === undefined`. Arrays that
|
|
13
|
+
* become empty are returned as `[]`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function compactResponse(value: unknown): unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Keep only the listed top-level fields on an object, or apply the same
|
|
18
|
+
* projection to each element of an array.
|
|
19
|
+
*
|
|
20
|
+
* Special case: `['*']` returns the input unchanged.
|
|
21
|
+
*/
|
|
22
|
+
export declare function projectFields<T>(value: T, fields: string[]): T;
|
|
23
|
+
//# sourceMappingURL=response-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-shape.d.ts","sourceRoot":"","sources":["../../src/utils/response-shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAyBvD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAM9D"}
|