@voxslopuli/teamdynamix-mcp 0.5.0 → 0.5.2

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/index.js CHANGED
@@ -1,36 +1,1182 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- WorkspaceWatchService
4
- } from "./chunk-XSNNBHPV.js";
5
- import {
6
- LedgerCorruptError,
7
- defaultLedgerPath,
8
- emptyLedger,
9
- loadLedger
10
- } from "./chunk-GTVZKRFG.js";
11
- import {
12
- CHARACTER_LIMIT,
13
- LOG_LEVEL,
14
- SERVER_NAME,
15
- SERVER_NAME_OVERRIDE,
16
- SERVER_VERSION,
17
- SERVER_VERSION_OVERRIDE,
18
- TEAMDYNAMIX_TOOL_PREFIX,
19
- assertDeleteToolsEnabled,
20
- assertWriteToolsEnabled,
21
- createConfiguredTeamDynamixClient,
22
- getTeamDynamixConfig,
23
- getTeamDynamixConfigStatus
24
- } from "./chunk-MARAUVWU.js";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __esm = (fn, res) => function __init() {
5
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
+ };
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+
12
+ // package.json
13
+ var package_default;
14
+ var init_package = __esm({
15
+ "package.json"() {
16
+ package_default = {
17
+ name: "@voxslopuli/teamdynamix-mcp",
18
+ version: "0.5.2",
19
+ private: false,
20
+ description: "A production-ready TypeScript MCP server for TeamDynamix",
21
+ keywords: [
22
+ "mcp",
23
+ "model context protocol",
24
+ "server",
25
+ "tdx",
26
+ "teamdynamix",
27
+ "typescript"
28
+ ],
29
+ homepage: "https://github.com/voxslopuli/teamdynamix-mcp",
30
+ bugs: {
31
+ url: "https://github.com/voxslopuli/teamdynamix-mcp/issues"
32
+ },
33
+ license: "MIT",
34
+ author: "Grand Slopulissimo <slopulissimo@voxslopuli.org>",
35
+ repository: {
36
+ type: "git",
37
+ url: "git+https://github.com/voxslopuli/teamdynamix-mcp.git"
38
+ },
39
+ bin: {
40
+ "tdx-watch-sweep": "dist/sweep.js",
41
+ "teamdynamix-mcp": "dist/index.js"
42
+ },
43
+ type: "module",
44
+ main: "dist/index.js",
45
+ scripts: {
46
+ build: "tsup",
47
+ postbuild: "node scripts/write-dist-package.js",
48
+ dev: "tsx watch src/index.ts",
49
+ "docs:build": "node scripts/prepare-docs-public.js && vitepress build docs",
50
+ "docs:dev": "vitepress dev docs",
51
+ "docs:preview": "vitepress preview docs",
52
+ format: "oxfmt . --write",
53
+ "format:check": "oxfmt . --check",
54
+ lint: "oxlint .",
55
+ "lint:fix": "oxlint . --fix",
56
+ prepare: "husky",
57
+ start: "node dist/index.js",
58
+ test: "vitest run",
59
+ "test:coverage": "vitest run --coverage",
60
+ typecheck: "tsc --noEmit"
61
+ },
62
+ dependencies: {
63
+ "@modelcontextprotocol/sdk": "^1.30.0",
64
+ "@voxslopuli/teamdynamix-ts": "^0.3.0",
65
+ tablemark: "^4.1.0",
66
+ zod: "^4.6.2"
67
+ },
68
+ devDependencies: {
69
+ "@octokit/rest": "^22.0.1",
70
+ "@types/node": "25.9.2",
71
+ "@vitest/coverage-v8": "^5.0.0",
72
+ husky: "^9.1.7",
73
+ "lint-staged": "^17.5.1",
74
+ ora: "^9.4.1",
75
+ oxfmt: "^0.67.0",
76
+ oxlint: "^1.82.0",
77
+ tsup: "^8.5.1",
78
+ tsx: "^4.23.13",
79
+ typescript: "6.0.3",
80
+ vite: "8.3.0",
81
+ vitepress: "^1.6.4",
82
+ vitest: "5.0.0",
83
+ zx: "^8.8.5"
84
+ },
85
+ "lint-staged": {
86
+ "*.{ts,mts,cts,js,mjs,cjs}": [
87
+ "oxlint --fix --no-error-on-unmatched-pattern",
88
+ "oxfmt --no-error-on-unmatched-pattern --write"
89
+ ],
90
+ "*.{json,yaml,yml,md}": [
91
+ "oxfmt --no-error-on-unmatched-pattern --write"
92
+ ]
93
+ },
94
+ packageManager: "pnpm@10.32.1",
95
+ pnpm: {
96
+ overrides: {
97
+ hono: ">=4.12.18",
98
+ "@hono/node-server": ">=1.19.13"
99
+ }
100
+ },
101
+ mcpName: "io.github.selfagency/teamdynamix-mcp"
102
+ };
103
+ }
104
+ });
105
+
106
+ // src/constants.ts
107
+ var SERVER_NAME, SERVER_VERSION, CHARACTER_LIMIT, TEAMDYNAMIX_TOOL_PREFIX, TEAMDYNAMIX_DEFAULT_TIMEOUT_MS, TEAMDYNAMIX_DEFAULT_MAX_RETRIES, TEAMDYNAMIX_MAX_RETRY_ATTEMPTS;
108
+ var init_constants = __esm({
109
+ "src/constants.ts"() {
110
+ "use strict";
111
+ init_package();
112
+ SERVER_NAME = "teamdynamix-mcp";
113
+ SERVER_VERSION = package_default.version;
114
+ CHARACTER_LIMIT = 25e3;
115
+ TEAMDYNAMIX_TOOL_PREFIX = "teamdynamix";
116
+ TEAMDYNAMIX_DEFAULT_TIMEOUT_MS = 3e4;
117
+ TEAMDYNAMIX_DEFAULT_MAX_RETRIES = 2;
118
+ TEAMDYNAMIX_MAX_RETRY_ATTEMPTS = 5;
119
+ }
120
+ });
121
+
122
+ // src/config.ts
123
+ import { z } from "zod";
124
+ function normalizeOptionalString(value) {
125
+ const normalized = value?.trim();
126
+ return normalized ? normalized : void 0;
127
+ }
128
+ function normalizeOptionalNumber(value) {
129
+ if (!value?.trim()) {
130
+ return void 0;
131
+ }
132
+ const parsed = Number.parseInt(value, 10);
133
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
134
+ }
135
+ function normalizeBoolean(value, defaultValue) {
136
+ if (!value) {
137
+ return defaultValue;
138
+ }
139
+ const normalized = value.trim().toLowerCase();
140
+ if (normalized === "true") return true;
141
+ if (normalized === "false") return false;
142
+ return defaultValue;
143
+ }
144
+ function normalizeNumberWithDefault(value, defaultValue, minimum) {
145
+ if (!value?.trim()) {
146
+ return defaultValue;
147
+ }
148
+ const parsed = Number.parseInt(value, 10);
149
+ return Number.isFinite(parsed) && parsed >= minimum ? parsed : defaultValue;
150
+ }
151
+ function normalizeTeamDynamixBaseUrl(value) {
152
+ const normalized = normalizeOptionalString(value);
153
+ return normalized ? normalized.replace(/\/+$/, "") : void 0;
154
+ }
155
+ function validateHttpsBaseUrl(value) {
156
+ if (!value) return void 0;
157
+ const schema = z.string().url().refine((url) => url.startsWith("https://"), {
158
+ message: "TEAMDYNAMIX_BASE_URL must be an https URL."
159
+ });
160
+ const parsed = schema.safeParse(value);
161
+ if (!parsed.success) {
162
+ throw new Error(parsed.error.issues[0]?.message ?? "Invalid TEAMDYNAMIX_BASE_URL.");
163
+ }
164
+ return value;
165
+ }
166
+ function normalizeTeamDynamixAuthMode(value) {
167
+ return value?.trim().toLowerCase() === "admin" ? "admin" : "standard";
168
+ }
169
+ function getTeamDynamixConfig() {
170
+ const baseUrl = validateHttpsBaseUrl(normalizeTeamDynamixBaseUrl(process.env["TEAMDYNAMIX_BASE_URL"]));
171
+ const maxRetries = normalizeNumberWithDefault(
172
+ process.env["TEAMDYNAMIX_MAX_RETRIES"],
173
+ TEAMDYNAMIX_DEFAULT_MAX_RETRIES,
174
+ 0
175
+ );
176
+ if (maxRetries > 5) {
177
+ throw new Error(`TEAMDYNAMIX_MAX_RETRIES must be between 0 and ${TEAMDYNAMIX_MAX_RETRY_ATTEMPTS}.`);
178
+ }
179
+ return {
180
+ baseUrl,
181
+ authMode: normalizeTeamDynamixAuthMode(process.env["TEAMDYNAMIX_AUTH_MODE"]),
182
+ username: normalizeOptionalString(process.env["TEAMDYNAMIX_USERNAME"]),
183
+ password: normalizeOptionalString(process.env["TEAMDYNAMIX_PASSWORD"]),
184
+ beid: normalizeOptionalString(process.env["TEAMDYNAMIX_BEID"]),
185
+ webServicesKey: normalizeOptionalString(process.env["TEAMDYNAMIX_WEB_SERVICES_KEY"]),
186
+ defaultTicketAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_TICKET_APP_ID"]),
187
+ defaultAssetAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_ASSET_APP_ID"]),
188
+ defaultKnowledgeBaseAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_KB_APP_ID"]),
189
+ timeoutMs: normalizeNumberWithDefault(process.env["TEAMDYNAMIX_TIMEOUT_MS"], TEAMDYNAMIX_DEFAULT_TIMEOUT_MS, 1e3),
190
+ maxRetries,
191
+ enableWriteTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_WRITE_TOOLS"], false),
192
+ enableAdminTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_ADMIN_TOOLS"], false),
193
+ enableDeleteTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_DELETE_TOOLS"], false)
194
+ };
195
+ }
196
+ function getTeamDynamixConfigStatus(config = getTeamDynamixConfig()) {
197
+ const missing = /* @__PURE__ */ new Set();
198
+ if (!config.baseUrl) {
199
+ missing.add("TEAMDYNAMIX_BASE_URL");
200
+ }
201
+ if (config.authMode === "admin") {
202
+ if (!config.beid) missing.add("TEAMDYNAMIX_BEID");
203
+ if (!config.webServicesKey) missing.add("TEAMDYNAMIX_WEB_SERVICES_KEY");
204
+ } else {
205
+ if (!config.username) missing.add("TEAMDYNAMIX_USERNAME");
206
+ if (!config.password) missing.add("TEAMDYNAMIX_PASSWORD");
207
+ }
208
+ return {
209
+ configured: missing.size === 0,
210
+ missing: [...missing],
211
+ authMode: config.authMode
212
+ };
213
+ }
214
+ var SERVER_NAME_OVERRIDE, SERVER_VERSION_OVERRIDE, validLogLevels, logLevelSchema, parsedLogLevel, LOG_LEVEL;
215
+ var init_config = __esm({
216
+ "src/config.ts"() {
217
+ "use strict";
218
+ init_constants();
219
+ SERVER_NAME_OVERRIDE = process.env["MCP_SERVER_NAME"]?.trim() || void 0;
220
+ SERVER_VERSION_OVERRIDE = process.env["MCP_SERVER_VERSION"]?.trim() || void 0;
221
+ validLogLevels = ["debug", "info", "warn", "error"];
222
+ logLevelSchema = z.enum(validLogLevels);
223
+ parsedLogLevel = logLevelSchema.safeParse(process.env["MCP_LOG_LEVEL"]?.trim());
224
+ LOG_LEVEL = parsedLogLevel.success ? parsedLogLevel.data : "info";
225
+ }
226
+ });
227
+
228
+ // src/client/sdk-client.factory.ts
229
+ import { existsSync } from "fs";
230
+ import { createRequire } from "module";
231
+ import { dirname, resolve } from "path";
232
+ import { fileURLToPath } from "url";
233
+ import { createTeamDynamixClient, loginWithPassword, loginWithServiceAccount } from "@voxslopuli/teamdynamix-ts";
234
+ function resolveSdkSpecPath() {
235
+ const override = process.env["TEAMDYNAMIX_SPEC_PATH"]?.trim();
236
+ if (override) return override;
237
+ if (cachedSpecPath) return cachedSpecPath;
238
+ try {
239
+ const require2 = createRequire(fileURLToPath(import.meta.url));
240
+ const entryPath = require2.resolve("@voxslopuli/teamdynamix-ts");
241
+ const pkgRoot = dirname(entryPath);
242
+ const candidates = [
243
+ resolve(pkgRoot, "dist/generated/openapi.json"),
244
+ resolve(pkgRoot, "generated/openapi.json"),
245
+ resolve(pkgRoot, "src/generated/openapi.json")
246
+ ];
247
+ cachedSpecPath = candidates.find((p) => existsSync(p));
248
+ return cachedSpecPath;
249
+ } catch {
250
+ return void 0;
251
+ }
252
+ }
253
+ function createTokenProvider(config, tenant) {
254
+ if (config.authMode === "admin") {
255
+ if (!config.beid || !config.webServicesKey) {
256
+ throw new Error("BEID and WebServicesKey are required for admin authentication");
257
+ }
258
+ return loginWithServiceAccount({
259
+ tenant,
260
+ baseUrl: config.baseUrl,
261
+ beid: config.beid,
262
+ webServicesKey: config.webServicesKey
263
+ });
264
+ }
265
+ if (!config.username || !config.password) {
266
+ throw new Error("Username and password are required for standard authentication");
267
+ }
268
+ return loginWithPassword({
269
+ tenant,
270
+ baseUrl: config.baseUrl,
271
+ username: config.username,
272
+ password: config.password
273
+ });
274
+ }
275
+ function extractTenant(baseUrl) {
276
+ const normalized = baseUrl.replace(/\/+$/, "").replace(/\/TDWebApi$/, "");
277
+ const withoutProtocol = normalized.replace(/^https?:\/\//, "");
278
+ const parts = withoutProtocol.split("/");
279
+ return parts[0] ?? "";
280
+ }
281
+ function buildSdkConfig(config, tenant, tokenProvider) {
282
+ return {
283
+ tenant,
284
+ tokenProvider,
285
+ environment: config.baseUrl?.includes("sandbox") ? "sandbox" : "production",
286
+ baseUrl: config.baseUrl,
287
+ timeoutMs: config.timeoutMs,
288
+ runtimeValidationMode: "fail-open",
289
+ ...resolveSdkSpecPath() ? { specPath: resolveSdkSpecPath() } : {},
290
+ retryPolicy: {
291
+ maxRetries: config.maxRetries
292
+ }
293
+ };
294
+ }
295
+ async function createMcpSdkClient(config) {
296
+ const tenant = extractTenant(config.baseUrl ?? "");
297
+ const tokenProvider = createTokenProvider(config, tenant);
298
+ const sdkConfig = buildSdkConfig(config, tenant, tokenProvider);
299
+ const { client } = await createTeamDynamixClient(sdkConfig);
300
+ return client;
301
+ }
302
+ var cachedSpecPath;
303
+ var init_sdk_client_factory = __esm({
304
+ "src/client/sdk-client.factory.ts"() {
305
+ "use strict";
306
+ }
307
+ });
308
+
309
+ // src/services/teamdynamix/client.factory.ts
310
+ function mapTicketSearchBody(body) {
311
+ const mapped = {};
312
+ for (const [key, value] of Object.entries(body)) {
313
+ if (value === void 0) continue;
314
+ mapped[TICKET_SEARCH_FIELD_MAP[key] ?? key] = value;
315
+ }
316
+ return mapped;
317
+ }
318
+ function parseIdListEnv(raw) {
319
+ return (raw ?? "").split(/[;,\s]+/).map(Number).filter((n) => Number.isFinite(n) && n > 0);
320
+ }
321
+ function sanitizeTo(body, allowed) {
322
+ const out = {};
323
+ for (const [key, value] of Object.entries(body)) {
324
+ if (allowed.has(key) && value !== void 0) out[key] = value;
325
+ }
326
+ return out;
327
+ }
328
+ function createConfiguredTeamDynamixClient() {
329
+ return new UnifiedTeamDynamixClient(getTeamDynamixConfig());
330
+ }
331
+ function assertWriteToolsEnabled(config) {
332
+ if (!config.enableWriteTools) {
333
+ throw new Error("Write tools are disabled. Set TEAMDYNAMIX_ENABLE_WRITE_TOOLS=true in your environment.");
334
+ }
335
+ }
336
+ function assertDeleteToolsEnabled(config) {
337
+ if (!config.enableDeleteTools) {
338
+ throw new Error("Delete tools are disabled. Set TEAMDYNAMIX_ENABLE_DELETE_TOOLS=true in your environment.");
339
+ }
340
+ }
341
+ var TICKET_SEARCH_FIELD_MAP, USER_SEARCH_KEYS, GROUP_SEARCH_KEYS, ARTICLE_SEARCH_KEYS, UnifiedTeamDynamixClient;
342
+ var init_client_factory = __esm({
343
+ "src/services/teamdynamix/client.factory.ts"() {
344
+ "use strict";
345
+ init_sdk_client_factory();
346
+ init_config();
347
+ TICKET_SEARCH_FIELD_MAP = {
348
+ ResponsibleGroupIDs: "ResponsibilityGroupIDs",
349
+ ResponsibleGroupID: "ResponsibilityGroupID",
350
+ ResponsibleGroups: "ResponsibilityGroupIDs"
351
+ };
352
+ USER_SEARCH_KEYS = /* @__PURE__ */ new Set([
353
+ "AccountIDs",
354
+ "AlternateID",
355
+ "AppName",
356
+ "AuthenticationUserName",
357
+ "ExternalID",
358
+ "IsActive",
359
+ "IsConfidential",
360
+ "IsEmployee",
361
+ "MaxResults",
362
+ "PhoneNumber",
363
+ "ReferenceIDs",
364
+ "SearchText",
365
+ "SecurityRoleID",
366
+ "UserName"
367
+ ]);
368
+ GROUP_SEARCH_KEYS = /* @__PURE__ */ new Set(["AssociatedAppID", "HasAppID", "HasSystemAppName", "IsActive", "NameLike"]);
369
+ ARTICLE_SEARCH_KEYS = /* @__PURE__ */ new Set([
370
+ "AuthorUID",
371
+ "CategoryID",
372
+ "CustomAttributes",
373
+ "IncludeArticleBodies",
374
+ "IncludeShortcuts",
375
+ "IsPublic",
376
+ "IsPublished",
377
+ "ReturnCount",
378
+ "SearchText",
379
+ "Status"
380
+ ]);
381
+ UnifiedTeamDynamixClient = class _UnifiedTeamDynamixClient {
382
+ constructor(config) {
383
+ this.config = config;
384
+ }
385
+ config;
386
+ sdkPromise = null;
387
+ sdk() {
388
+ this.sdkPromise ??= createMcpSdkClient(this.config);
389
+ return this.sdkPromise;
390
+ }
391
+ //
392
+ // Discovery
393
+ //
394
+ getCurrentUser() {
395
+ return this.sdk().then((s) => s.discovery.authGetuser());
396
+ }
397
+ listApplications() {
398
+ return this.sdk().then((s) => s.discovery.applications());
399
+ }
400
+ //
401
+ // Tickets
402
+ //
403
+ getTicket(appId, ticketId) {
404
+ return this.sdk().then((s) => s.tickets.appIdTicketsId({ params: { path: { appId, id: ticketId } } }));
405
+ }
406
+ searchTickets(appId, body) {
407
+ return this.sdk().then(async (s) => {
408
+ const { data, error } = await s.tickets.appIdTicketsSearch({
409
+ params: { path: { appId } },
410
+ body: mapTicketSearchBody(body)
411
+ });
412
+ if (error) {
413
+ throw new Error(`Ticket search failed: ${JSON.stringify(error)}`);
414
+ }
415
+ const results = Array.isArray(data) ? data : [];
416
+ const groupFilter = parseIdListEnv(process.env["TEAMDYNAMIX_TICKET_GROUP_IDS"]);
417
+ if (groupFilter.length === 0) return results;
418
+ return results.filter((item) => {
419
+ if (typeof item !== "object" || item === null) return false;
420
+ const gid = Number(item["ResponsibleGroupID"]);
421
+ return groupFilter.includes(gid);
422
+ });
423
+ });
424
+ }
425
+ listTicketTypes(appId) {
426
+ return this.sdk().then((s) => s.tickets.appIdTicketsTypes({ params: { path: { appId } } }));
427
+ }
428
+ listTicketPriorities(appId) {
429
+ return this.sdk().then((s) => s.tickets.appIdTicketsPriorities({ params: { path: { appId } } }));
430
+ }
431
+ listTicketUrgencies(appId) {
432
+ return this.sdk().then((s) => s.tickets.appIdTicketsUrgencies({ params: { path: { appId } } }));
433
+ }
434
+ listTicketImpacts(appId) {
435
+ return this.sdk().then((s) => s.tickets.appIdTicketsImpacts({ params: { path: { appId } } }));
436
+ }
437
+ listTicketSources(appId) {
438
+ return this.sdk().then((s) => s.tickets.appIdTicketsSources({ params: { path: { appId } } }));
439
+ }
440
+ /**
441
+ * Upper bound on feed entries we'll fetch replies for. The TDX API allows 60
442
+ * requests/60s; the feed call itself plus one fetch per entry must stay under it.
443
+ */
444
+ static DEFAULT_REPLIES_ENTRY_LIMIT = 10;
445
+ async getTicketFeed(appId, ticketId, opts = {}) {
446
+ const s = await this.sdk();
447
+ const feed = await s.tickets.appIdTicketsIdFeed({ params: { path: { appId, id: ticketId } } });
448
+ const entries = Array.isArray(feed) ? feed : [];
449
+ const limit = opts.repliesEntryLimit ?? _UnifiedTeamDynamixClient.DEFAULT_REPLIES_ENTRY_LIMIT;
450
+ const missing = entries.filter(
451
+ (e) => typeof e.RepliesCount === "number" && e.RepliesCount > 0 && (!Array.isArray(e.Replies) || e.Replies.length === 0) && typeof e.ID !== "undefined"
452
+ );
453
+ for (const entry of missing.slice(0, limit)) {
454
+ const target = entry;
455
+ const { data, error } = await s.GET(`/api/feed/${target.ID}`, {
456
+ params: { path: { id: target.ID } }
457
+ });
458
+ if (error) {
459
+ const detail = typeof error === "string" ? error : JSON.stringify(error);
460
+ throw new Error(`Failed to fetch replies for feed entry ${target.ID} (GET /api/feed/{id}): ${detail}`);
461
+ }
462
+ if (data && Array.isArray(data.Replies)) {
463
+ target.Replies = data.Replies;
464
+ }
465
+ }
466
+ return entries;
467
+ }
468
+ //
469
+ // Ticket Relationships
470
+ //
471
+ getTicketTasks(appId, ticketId) {
472
+ return this.sdk().then(
473
+ (s) => s.ticketRelationships.appIdTicketsTicketIdTasks({ params: { path: { appId, ticketId } } })
474
+ );
475
+ }
476
+ createTicketTask(appId, ticketId, body) {
477
+ return this.sdk().then((s) => s.ticketRelationships.createTicketTask({ appId, ticketId, body }));
478
+ }
479
+ listTicketAssets(appId, ticketId) {
480
+ return this.sdk().then(
481
+ (s) => s.ticketRelationships.appIdTicketsIdAssets({ params: { path: { appId, id: ticketId } } })
482
+ );
483
+ }
484
+ addTicketAsset(appId, ticketId, assetId) {
485
+ return this.sdk().then((s) => s.ticketRelationships.addTicketAsset({ appId, ticketId, assetId }));
486
+ }
487
+ removeTicketAsset(appId, ticketId, assetId) {
488
+ return this.sdk().then((s) => {
489
+ s.ticketRelationships.removeTicketAsset({ appId, ticketId, assetId, confirm: true });
490
+ });
491
+ }
492
+ getTicketContacts(appId, ticketId) {
493
+ return this.sdk().then(
494
+ (s) => s.ticketRelationships.appIdTicketsIdContacts({ params: { path: { appId, id: ticketId } } })
495
+ );
496
+ }
497
+ addTicketContact(appId, ticketId, contactUid) {
498
+ return this.sdk().then((s) => s.ticketRelationships.addTicketContact({ appId, ticketId, contactUid }));
499
+ }
500
+ removeTicketContact(appId, ticketId, contactUid) {
501
+ return this.sdk().then((s) => {
502
+ s.ticketRelationships.removeTicketContact({ appId, ticketId, contactUid, confirm: true });
503
+ });
504
+ }
505
+ //
506
+ // People
507
+ //
508
+ getUser(uid) {
509
+ return this.sdk().then((s) => s.people.peopleUid({ params: { path: { uid } } }));
510
+ }
511
+ searchUsers(body) {
512
+ return this.sdk().then((s) => s.people.postPeopleSearch({ body: sanitizeTo(body, USER_SEARCH_KEYS) }));
513
+ }
514
+ getGroup(groupId) {
515
+ return this.sdk().then((s) => s.people.groupsId({ params: { path: { id: groupId } } }));
516
+ }
517
+ searchGroups(body) {
518
+ return this.sdk().then((s) => s.people.searchGroups({ body: sanitizeTo(body, GROUP_SEARCH_KEYS) }));
519
+ }
520
+ getGroupMembers(groupId) {
521
+ return this.sdk().then((s) => s.people.groupsIdMembers({ params: { path: { id: groupId } } }));
522
+ }
523
+ //
524
+ // Knowledge Base
525
+ //
526
+ getKbArticle(appId, articleId) {
527
+ return this.sdk().then((s) => s.knowledgeBase.appIdKnowledgebaseId({ params: { path: { appId, id: articleId } } }));
528
+ }
529
+ searchKbArticles(appId, body) {
530
+ return this.sdk().then(async (s) => {
531
+ const { data, error } = await s.referenceData.appIdKnowledgebaseSearch({
532
+ params: { path: { appId } },
533
+ body: sanitizeTo(body, ARTICLE_SEARCH_KEYS)
534
+ });
535
+ if (error) {
536
+ throw new Error(`KB search failed: ${JSON.stringify(error)}`);
537
+ }
538
+ return Array.isArray(data) ? data : [];
539
+ });
540
+ }
541
+ listKbCategories(appId) {
542
+ return this.sdk().then(
543
+ (s) => s.knowledgeBase.appIdKnowledgebaseCategories({ params: { path: { appId } } })
544
+ );
545
+ }
546
+ //
547
+ // Assets
548
+ //
549
+ getAsset(appId, assetId) {
550
+ return this.sdk().then((s) => s.assets.appIdAssetsId({ params: { path: { appId, id: assetId } } }));
551
+ }
552
+ searchAssets(appId, _body) {
553
+ return this.sdk().then((s) => s.assets.appIdAssetsFeed({ params: { path: { appId } } }));
554
+ }
555
+ listAssetStatuses(appId) {
556
+ return this.sdk().then((s) => s.assets.appIdAssetsStatuses({ params: { path: { appId } } }));
557
+ }
558
+ listProductModels(appId) {
559
+ return this.sdk().then((s) => s.assets.appIdAssetsModels({ params: { path: { appId } } }));
560
+ }
561
+ listVendors(appId) {
562
+ return this.sdk().then((s) => s.cmdb.appIdAssetsVendors({ params: { path: { appId } } }));
563
+ }
564
+ //
565
+ // CMDB
566
+ //
567
+ getConfigurationItem(appId, ciId) {
568
+ return this.sdk().then((s) => s.cmdb.appIdCmdbId({ params: { path: { appId, id: ciId } } }));
569
+ }
570
+ searchConfigurationItems(appId, _body) {
571
+ return this.sdk().then((s) => s.cmdb.appIdCmdbSearches({ params: { path: { appId } } }));
572
+ }
573
+ listCiTypes(appId) {
574
+ return this.sdk().then((s) => s.cmdb.appIdCmdbTypes({ params: { path: { appId } } }));
575
+ }
576
+ listCiRelationshipTypes() {
577
+ return this.sdk().then((s) => s.cmdb.appIdCmdbRelationshiptypes());
578
+ }
579
+ //
580
+ // Services
581
+ //
582
+ listServiceCatalog(appId) {
583
+ return this.sdk().then((s) => s.services.appIdServices({ params: { path: { appId } } }));
584
+ }
585
+ getService(appId, serviceId) {
586
+ return this.sdk().then((s) => s.services.appIdServicesId({ params: { path: { appId, id: serviceId } } }));
587
+ }
588
+ searchServices(appId, body) {
589
+ const keyword = typeof body["Keyword"] === "string" ? body["Keyword"] : "";
590
+ return this.sdk().then((s) => s.services.appIdServices({ params: { path: { appId } } })).then((r) => {
591
+ if (!Array.isArray(r)) return [];
592
+ if (!keyword) return r;
593
+ const lower = keyword.toLowerCase();
594
+ return r.filter((item) => {
595
+ const text = typeof item === "object" && item !== null ? JSON.stringify(item).toLowerCase() : "";
596
+ return text.includes(lower);
597
+ });
598
+ });
599
+ }
600
+ listServiceCategories(appId) {
601
+ return this.sdk().then((s) => s.services.appIdServicesCategories({ params: { path: { appId } } }));
602
+ }
603
+ //
604
+ // Projects
605
+ //
606
+ getProject(projectId) {
607
+ return this.sdk().then((s) => s.projects.projectsId({ params: { path: { id: projectId } } }));
608
+ }
609
+ searchProjects(_body) {
610
+ return this.sdk().then((s) => s.projects.projectsFeed());
611
+ }
612
+ listProjectTypes() {
613
+ return this.sdk().then((s) => s.projects.projectsTypes());
614
+ }
615
+ getProjectPlans(projectId) {
616
+ return this.sdk().then(
617
+ (s) => s.projects.projectsProjectIDPlansPlanID({ params: { path: { id: projectId } } })
618
+ );
619
+ }
620
+ getProjectIssues(projectId) {
621
+ return this.sdk().then(
622
+ (s) => s.projects.projectsProjectIdIssuesCategories({ params: { path: { id: projectId } } })
623
+ );
624
+ }
625
+ getProjectRisks(projectId) {
626
+ return this.sdk().then(
627
+ (s) => s.projects.projectsProjectIdRisksCategories({ params: { path: { id: projectId } } })
628
+ );
629
+ }
630
+ //
631
+ // Time
632
+ //
633
+ listTimeTypes() {
634
+ return this.sdk().then((s) => s.time.timeTypes());
635
+ }
636
+ getMyTimeEntries(_startDate, _endDate) {
637
+ return this.sdk().then((s) => s.time.timeId({ params: { path: { id: 0 } } }));
638
+ }
639
+ //
640
+ // Reference Data
641
+ //
642
+ listAccounts(_appId) {
643
+ return this.sdk().then((s) => s.referenceData.accounts());
644
+ }
645
+ getAccount(accountId) {
646
+ return this.sdk().then((s) => s.referenceData.accountsId({ params: { path: { id: accountId } } }));
647
+ }
648
+ listLocations() {
649
+ return this.sdk().then((s) => s.referenceData.locations());
650
+ }
651
+ listFunctionalRoles() {
652
+ return this.sdk().then((s) => s.referenceData.securityrolesPermissions());
653
+ }
654
+ listCustomAttributes(_componentId, _appId, _associatedTypeId) {
655
+ return this.sdk().then((s) => s.referenceData.attributesCustom());
656
+ }
657
+ listTicketStatuses(appId) {
658
+ return this.sdk().then((s) => s.referenceData.appIdTicketsStatuses({ params: { path: { appId } } }));
659
+ }
660
+ //
661
+ // Mutations
662
+ //
663
+ createTicket(appId, body, _notifyRequestor, _notifyResponsible) {
664
+ return this.sdk().then((s) => s.tickets.createTicket({ appId, body }));
665
+ }
666
+ updateTicket(appId, ticketId, body, _notifyRequestor, _notifyResponsible, _comments, _isPrivate) {
667
+ return this.sdk().then((s) => s.tickets.updateTicket({ appId, ticketId, body }));
668
+ }
669
+ addTicketComment(appId, ticketId, body, _isPrivate, _notifyRequestor, _notifyResponsible) {
670
+ return this.sdk().then((s) => s.tickets.addTicketComment({ appId, ticketId, body: { Body: body } }));
671
+ }
672
+ createKbArticle(appId, body) {
673
+ return this.sdk().then((s) => s.knowledgeBase.createArticle({ appId, body }));
674
+ }
675
+ updateKbArticle(appId, articleId, body) {
676
+ return this.sdk().then((s) => s.knowledgeBase.updateArticle({ appId, articleId, body }));
677
+ }
678
+ createProjectIssue(_projectId, body) {
679
+ return this.sdk().then((s) => s.projects.createIssue({ body }));
680
+ }
681
+ createProjectRisk(_projectId, body) {
682
+ return this.sdk().then((s) => s.projects.createRisk({ body }));
683
+ }
684
+ //
685
+ // Delete mutations (confirm:true required for all)
686
+ //
687
+ deleteAsset(appId, assetId) {
688
+ return this.sdk().then((s) => s.assets.deleteAsset({ appId, assetId, confirm: true }));
689
+ }
690
+ deleteConfigurationItem(appId, ciId) {
691
+ return this.sdk().then((s) => s.cmdb.deleteConfigurationItem({ appId, configurationItemId: ciId, confirm: true }));
692
+ }
693
+ deleteService(appId, serviceId) {
694
+ return this.sdk().then((s) => s.services.deleteService({ appId, serviceId, confirm: true }));
695
+ }
696
+ deleteServiceCategory(appId, categoryId) {
697
+ return this.sdk().then((s) => s.services.deleteServiceCategory({ appId, categoryId, confirm: true }));
698
+ }
699
+ deleteTimeEntry(timeEntryId) {
700
+ return this.sdk().then((s) => s.time.deleteTimeEntry({ timeEntryId, confirm: true }));
701
+ }
702
+ };
703
+ }
704
+ });
705
+
706
+ // src/services/teamdynamix/watch.store.ts
707
+ var watch_store_exports = {};
708
+ __export(watch_store_exports, {
709
+ LEDGER_VERSION: () => LEDGER_VERSION,
710
+ LedgerCorruptError: () => LedgerCorruptError,
711
+ MAX_NOTE_LENGTH: () => MAX_NOTE_LENGTH,
712
+ MAX_OBSERVATIONS: () => MAX_OBSERVATIONS,
713
+ defaultLedgerPath: () => defaultLedgerPath,
714
+ emptyLedger: () => emptyLedger,
715
+ loadLedger: () => loadLedger,
716
+ saveLedger: () => saveLedger
717
+ });
718
+ import { promises as fs } from "fs";
719
+ import path from "path";
720
+ function defaultLedgerPath() {
721
+ return process.env["TDX_WATCH_LEDGER"] ?? path.join(process.cwd(), ".tdx-watch-ledger.json");
722
+ }
723
+ async function loadLedger(filePath) {
724
+ let raw;
725
+ try {
726
+ raw = await fs.readFile(filePath, "utf8");
727
+ } catch (cause) {
728
+ throw cause instanceof Error ? cause : new Error(String(cause));
729
+ }
730
+ try {
731
+ const parsed = JSON.parse(raw);
732
+ if (!Array.isArray(parsed.active) || !Array.isArray(parsed.archived)) {
733
+ throw new Error("missing active/archived arrays");
734
+ }
735
+ parsed.pendingTriage ??= [];
736
+ return parsed;
737
+ } catch (cause) {
738
+ throw new LedgerCorruptError(filePath, cause);
739
+ }
740
+ }
741
+ async function saveLedger(filePath, ledger) {
742
+ try {
743
+ await fs.access(filePath);
744
+ await loadLedger(filePath);
745
+ } catch (cause) {
746
+ if (cause instanceof LedgerCorruptError) throw cause;
747
+ }
748
+ ledger.version = LEDGER_VERSION;
749
+ const dir = path.dirname(filePath);
750
+ await fs.mkdir(dir, { recursive: true });
751
+ const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
752
+ await fs.writeFile(tmp, `${JSON.stringify(ledger, null, 2)}
753
+ `, "utf8");
754
+ await fs.rename(tmp, filePath);
755
+ }
756
+ function emptyLedger() {
757
+ return { active: [], archived: [], pendingTriage: [], sweepMeta: {} };
758
+ }
759
+ var LEDGER_VERSION, MAX_NOTE_LENGTH, MAX_OBSERVATIONS, LedgerCorruptError;
760
+ var init_watch_store = __esm({
761
+ "src/services/teamdynamix/watch.store.ts"() {
762
+ "use strict";
763
+ LEDGER_VERSION = 1;
764
+ MAX_NOTE_LENGTH = 4e3;
765
+ MAX_OBSERVATIONS = 20;
766
+ LedgerCorruptError = class extends Error {
767
+ constructor(path2, cause) {
768
+ super(
769
+ `Watch ledger at ${path2} is corrupt or unreadable; refusing to read or write it. Fix or remove the file manually (state preservation is deliberate). Cause: ${String(cause)}`
770
+ );
771
+ this.name = "LedgerCorruptError";
772
+ }
773
+ };
774
+ }
775
+ });
776
+
777
+ // src/services/teamdynamix/watch.service.ts
778
+ var watch_service_exports = {};
779
+ __export(watch_service_exports, {
780
+ WorkspaceWatchService: () => WorkspaceWatchService
781
+ });
782
+ function redact(text) {
783
+ return text.replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g, "[redacted-email]").replace(/\b(?:\d{3}[-.\s]?){2}\d{4}\b/g, "[redacted-phone]");
784
+ }
785
+ function cap(text, max) {
786
+ if (text.length <= max) return text;
787
+ return `${text.slice(0, Math.max(0, max - 1))}\u2026`;
788
+ }
789
+ function sanitizeForReport(value) {
790
+ if (typeof value === "string") return cap(redact(value), TITLE_MAX_CHARS);
791
+ return value;
792
+ }
793
+ function computeHash(entries) {
794
+ const perEntryReplies = {};
795
+ let replyCount = 0;
796
+ let lastEntryId = 0;
797
+ for (const e of entries) {
798
+ const id = e.ID ?? 0;
799
+ const rc = e.RepliesCount ?? 0;
800
+ perEntryReplies[String(id)] = rc;
801
+ replyCount += rc;
802
+ lastEntryId = Math.max(lastEntryId, id);
803
+ }
804
+ return { lastEntryId, entryCount: entries.length, replyCount, perEntryReplies };
805
+ }
806
+ function hashGrewHiddenReplies(prev, entries) {
807
+ for (const e of entries) {
808
+ const id = String(e.ID ?? 0);
809
+ const now = e.RepliesCount ?? 0;
810
+ const before = prev.perEntryReplies[id];
811
+ if (before !== void 0 && now > before) return true;
812
+ }
813
+ return false;
814
+ }
815
+ var REPORT_MAX_CHARS, TITLE_MAX_CHARS, US_UIDS_ENV, GROUP_IDS_ENV, STATUS_IDS_ENV, DEFAULT_MAX_PENDING, UNASSIGNED_SENTINELS, WorkspaceWatchService;
816
+ var init_watch_service = __esm({
817
+ "src/services/teamdynamix/watch.service.ts"() {
818
+ "use strict";
819
+ init_watch_store();
820
+ init_client_factory();
821
+ REPORT_MAX_CHARS = 8e3;
822
+ TITLE_MAX_CHARS = 200;
823
+ US_UIDS_ENV = "TEAMDYNAMIX_US_UIDS";
824
+ GROUP_IDS_ENV = "TEAMDYNAMIX_TICKET_GROUP_IDS";
825
+ STATUS_IDS_ENV = "TEAMDYNAMIX_WATCH_STATUS_IDS";
826
+ DEFAULT_MAX_PENDING = 25;
827
+ UNASSIGNED_SENTINELS = /* @__PURE__ */ new Set(["", "unassigned"]);
828
+ WorkspaceWatchService = class {
829
+ constructor(ledger, ledgerPath, client, opts = {}) {
830
+ this.ledger = ledger;
831
+ this.ledgerPath = ledgerPath;
832
+ this.client = client;
833
+ const envUids = (process.env[US_UIDS_ENV] ?? "").split(/[,\s]+/).filter(Boolean);
834
+ this.usUids = /* @__PURE__ */ new Set([...envUids, ...opts.usUids ?? []]);
835
+ this.autoObserve = opts.autoObserve ?? process.env["TEAMDYNAMIX_AUTO_OBSERVE"] === "true";
836
+ }
837
+ ledger;
838
+ client;
839
+ ledgerPath;
840
+ usUids;
841
+ autoObserve;
842
+ usUidsFor() {
843
+ const ledgerUids = this.ledger.sweepMeta.usUids ?? [];
844
+ return /* @__PURE__ */ new Set([...this.usUids, ...ledgerUids]);
845
+ }
846
+ groupIds() {
847
+ return this.ledger.sweepMeta.groupIds ?? parseIdListEnv(process.env[GROUP_IDS_ENV]);
848
+ }
849
+ statusIds() {
850
+ return this.ledger.sweepMeta.statusIds ?? parseIdListEnv(process.env[STATUS_IDS_ENV]);
851
+ }
852
+ maxPending() {
853
+ return this.ledger.sweepMeta.maxPending ?? DEFAULT_MAX_PENDING;
854
+ }
855
+ pushPending(item) {
856
+ const queue = this.ledger.pendingTriage ??= [];
857
+ if (queue.some((p) => p.ticketId === item.ticketId)) return "deduped";
858
+ if (queue.length >= this.maxPending()) return "full";
859
+ queue.push(item);
860
+ return "queued";
861
+ }
862
+ /**
863
+ * Cheap sweep (stage 1 only): one queue search per app, client-side team
864
+ * filtering (GroupIDs is not applied server-side on queue searches), stateHash
865
+ * freshness, new-unassigned detection, and pendingTriage queue maintenance.
866
+ * Deep fetches / reply expansion are the agent's job via check() / triage.
867
+ */
868
+ async sweep() {
869
+ const result = {
870
+ swept: 0,
871
+ changedQueued: 0,
872
+ newUnassignedQueued: 0,
873
+ deduped: 0,
874
+ queueFull: 0,
875
+ unassigned: []
876
+ };
877
+ const rows = this.ledger.active;
878
+ const byApp = /* @__PURE__ */ new Map();
879
+ for (const row of rows) {
880
+ const list = byApp.get(row.appId) ?? [];
881
+ list.push(row);
882
+ byApp.set(row.appId, list);
883
+ }
884
+ const appIds = /* @__PURE__ */ new Set([...byApp.keys(), ...parseIdListEnv(process.env["TEAMDYNAMIX_WATCH_APP_IDS"])]);
885
+ const groupFilter = this.groupIds();
886
+ const statusFilter = this.statusIds();
887
+ const queue = this.ledger.pendingTriage ??= [];
888
+ const ledgeredIds = new Set(rows.map((r) => r.id));
889
+ for (const appId of appIds) {
890
+ const appRows = byApp.get(appId) ?? [];
891
+ let page;
892
+ try {
893
+ page = await this.client.searchTickets(appId, { MaxResults: 500 });
894
+ } catch {
895
+ continue;
896
+ }
897
+ for (const t of page) {
898
+ const id = Number(t["ID"]);
899
+ if (!Number.isFinite(id)) continue;
900
+ if (groupFilter.length > 0) {
901
+ const gid = Number(t["ResponsibleGroupID"]);
902
+ if (!groupFilter.includes(gid)) continue;
903
+ }
904
+ if (statusFilter.length > 0 && !statusFilter.includes(Number(t["StatusID"]))) continue;
905
+ result.swept += 1;
906
+ const row = appRows.find((r) => r.id === id);
907
+ const modified = String(t["ModifiedDate"] ?? "");
908
+ if (row && row.stateHash.modified !== "" && modified !== row.stateHash.modified) {
909
+ const outcome = this.pushPending({ ticketId: id, appId, reason: "changed", at: (/* @__PURE__ */ new Date()).toISOString() });
910
+ if (outcome === "queued") result.changedQueued += 1;
911
+ else if (outcome === "deduped") result.deduped += 1;
912
+ else result.queueFull += 1;
913
+ }
914
+ if (!ledgeredIds.has(id)) {
915
+ const responsible = String(t["ResponsibleUid"] ?? "").trim();
916
+ if (UNASSIGNED_SENTINELS.has(responsible.toLowerCase())) {
917
+ result.unassigned.push(id);
918
+ const outcome = this.pushPending({
919
+ ticketId: id,
920
+ appId,
921
+ reason: "new-unassigned",
922
+ at: (/* @__PURE__ */ new Date()).toISOString(),
923
+ detail: `group=${String(t["ResponsibleGroupName"] ?? "")}`
924
+ });
925
+ if (outcome === "queued") result.newUnassignedQueued += 1;
926
+ else if (outcome === "deduped") result.deduped += 1;
927
+ else result.queueFull += 1;
928
+ }
929
+ }
930
+ }
931
+ for (const row of appRows) {
932
+ const t = page.find((x) => Number(x["ID"]) === row.id);
933
+ if (t) row.stateHash.modified = String(t["ModifiedDate"] ?? row.stateHash.modified);
934
+ }
935
+ }
936
+ this.ledger.sweepMeta.lastSweep = (/* @__PURE__ */ new Date()).toISOString();
937
+ await this.persist();
938
+ return result;
939
+ }
940
+ pendingTriage() {
941
+ return this.ledger.pendingTriage ?? [];
942
+ }
943
+ async markTriaged(ticketId) {
944
+ const queue = this.ledger.pendingTriage ?? [];
945
+ const before = queue.length;
946
+ this.ledger.pendingTriage = queue.filter((p) => p.ticketId !== ticketId);
947
+ await this.persist();
948
+ return { removed: this.ledger.pendingTriage.length < before };
949
+ }
950
+ async persist() {
951
+ await saveLedger(this.ledgerPath, this.ledger);
952
+ this.ledger = await loadLedger(this.ledgerPath);
953
+ }
954
+ findRow(id) {
955
+ return this.ledger.active.find((r) => r.id === id);
956
+ }
957
+ async register(input) {
958
+ const existing = this.findRow(input.id);
959
+ if (existing) {
960
+ existing.kind = input.kind;
961
+ if (input.title !== void 0) existing.title = cap(redact(input.title), TITLE_MAX_CHARS);
962
+ if (input.district !== void 0) existing.district = input.district;
963
+ if (input.nextAction !== void 0) existing.nextAction = input.nextAction;
964
+ if (input.ball !== void 0) {
965
+ existing.ball = input.ball;
966
+ existing.ballSource = "manual";
967
+ }
968
+ await this.persist();
969
+ return existing;
970
+ }
971
+ const row = {
972
+ id: input.id,
973
+ appId: input.appId,
974
+ title: cap(redact(input.title ?? ""), TITLE_MAX_CHARS),
975
+ district: input.district ?? "",
976
+ kind: input.kind,
977
+ status: "",
978
+ stateHash: { modified: "", lastEntryId: 0, entryCount: 0, replyCount: 0, perEntryReplies: {} },
979
+ ball: input.ball ?? "us",
980
+ ballSource: input.ball !== void 0 ? "manual" : "auto",
981
+ nextAction: input.nextAction ?? "",
982
+ lastChecked: "",
983
+ memory: { notes: [], observations: [] }
984
+ };
985
+ this.ledger.active.push(row);
986
+ await this.persist();
987
+ return row;
988
+ }
989
+ async archive(input) {
990
+ const idx = this.ledger.active.findIndex((r) => r.id === input.id);
991
+ if (idx === -1) return { archived: false };
992
+ const [row] = this.ledger.active.splice(idx, 1);
993
+ this.ledger.archived.push({ ...row, outcome: input.outcome });
994
+ await this.persist();
995
+ return { archived: true };
996
+ }
997
+ async status() {
998
+ const active = this.ledger.active;
999
+ const oldestChecked = active.map((r) => r.lastChecked).filter(Boolean).sort()[0] ?? "";
1000
+ return {
1001
+ activeCount: active.length,
1002
+ archivedCount: this.ledger.archived.length,
1003
+ ballUs: active.filter((r) => r.ball === "us").length,
1004
+ ballThem: active.filter((r) => r.ball === "them").length,
1005
+ oldestChecked
1006
+ };
1007
+ }
1008
+ async check(input = {}) {
1009
+ const report = { checked: 0, deltas: [], errors: [] };
1010
+ const rows = this.ledger.active.filter((r) => input.tickets ? input.tickets.includes(r.id) : true);
1011
+ const byApp = /* @__PURE__ */ new Map();
1012
+ for (const row of rows) {
1013
+ const list = byApp.get(row.appId) ?? [];
1014
+ list.push(row);
1015
+ byApp.set(row.appId, list);
1016
+ }
1017
+ for (const [appId, appRows] of byApp) {
1018
+ let sweep;
1019
+ try {
1020
+ sweep = await this.client.searchTickets(appId, { MaxResults: 500 });
1021
+ } catch (cause) {
1022
+ report.errors.push(`sweep failed for appId ${appId}: ${String(cause)}`);
1023
+ continue;
1024
+ }
1025
+ const sweepById = new Map(sweep.map((t) => [Number(t["ID"]), t]));
1026
+ for (const row of appRows) {
1027
+ report.checked += 1;
1028
+ const sweepTicket = sweepById.get(row.id);
1029
+ const sweepModified = sweepTicket ? String(sweepTicket["ModifiedDate"] ?? "") : "";
1030
+ const seeded = row.stateHash.modified !== "";
1031
+ const needsDeep = !seeded || sweepModified !== row.stateHash.modified;
1032
+ if (seeded && !needsDeep) continue;
1033
+ const classes = /* @__PURE__ */ new Set();
1034
+ try {
1035
+ const t = sweepTicket ?? await this.client.getTicket(appId, row.id);
1036
+ const feed = await this.client.getTicketFeed(appId, row.id);
1037
+ const modified = String(t["ModifiedDate"] ?? "");
1038
+ const status = String(t["Status"] ?? t["StatusID"] ?? "");
1039
+ const isOnHold = Boolean(t["IsOnHold"]);
1040
+ if (seeded && status !== row.status) classes.add("status");
1041
+ if (seeded && Boolean(t["IsOnHold"]) !== row.status.startsWith("hold:")) {
1042
+ }
1043
+ if (seeded && modified !== row.stateHash.modified) classes.add("new-entry");
1044
+ const prevHash = row.stateHash;
1045
+ const newHash = { modified, ...computeHash(feed) };
1046
+ if (seeded && hashGrewHiddenReplies(prevHash, feed)) classes.add("hidden-reply");
1047
+ if (seeded && newHash.entryCount > prevHash.entryCount) classes.add("new-entry");
1048
+ if (seeded && isOnHold !== row.wasOnHold) {
1049
+ classes.add("hold-window");
1050
+ }
1051
+ const slaDate = t["SlaCompleteByDate"];
1052
+ if (seeded && typeof slaDate === "string" && slaDate !== row.slaDate) {
1053
+ classes.add("sla");
1054
+ row.slaDate = slaDate;
1055
+ }
1056
+ row.wasOnHold = isOnHold;
1057
+ if (row.ballSource === "auto" && feed.length > 0) {
1058
+ const last = feed[0];
1059
+ const author = String(last?.CreatedUid ?? "");
1060
+ if (author) row.ball = this.usUidsFor().has(author) ? "them" : "us";
1061
+ }
1062
+ row.stateHash = newHash;
1063
+ row.status = status;
1064
+ if (typeof t["Title"] === "string" && row.title === "") {
1065
+ row.title = cap(redact(t["Title"]), TITLE_MAX_CHARS);
1066
+ }
1067
+ row.lastChecked = (/* @__PURE__ */ new Date()).toISOString();
1068
+ if (this.autoObserve) {
1069
+ row.memory.observations.push({ at: row.lastChecked, seen: { status, modified } });
1070
+ if (row.memory.observations.length > MAX_OBSERVATIONS) {
1071
+ row.memory.observations = row.memory.observations.slice(-MAX_OBSERVATIONS);
1072
+ }
1073
+ }
1074
+ if (classes.size > 0) {
1075
+ report.deltas.push({
1076
+ id: row.id,
1077
+ appId,
1078
+ classes: [...classes],
1079
+ status: sanitizeForReport(status),
1080
+ modified,
1081
+ ball: row.ball
1082
+ });
1083
+ }
1084
+ } catch (cause) {
1085
+ report.errors.push(`deep fetch failed for ticket ${row.id}: ${String(cause)}`);
1086
+ }
1087
+ }
1088
+ }
1089
+ this.ledger.sweepMeta.lastSweep = (/* @__PURE__ */ new Date()).toISOString();
1090
+ await this.persist();
1091
+ return this.capReport(report);
1092
+ }
1093
+ capReport(report) {
1094
+ let json = JSON.stringify(report);
1095
+ if (json.length > REPORT_MAX_CHARS) {
1096
+ report.deltas = report.deltas.slice(0, Math.max(1, Math.floor(report.deltas.length / 2)));
1097
+ json = JSON.stringify(report);
1098
+ if (json.length > REPORT_MAX_CHARS) report.deltas = [];
1099
+ }
1100
+ return report;
1101
+ }
1102
+ //
1103
+ // Notes (local-only memory; never written to TDX)
1104
+ //
1105
+ async notesAdd(input) {
1106
+ const row = this.rowForNote(input.appId, input.ticketId);
1107
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1108
+ const note = {
1109
+ id: `n-${now}-${Math.random().toString(36).slice(2, 8)}`,
1110
+ text: cap(redact(input.text), MAX_NOTE_LENGTH),
1111
+ createdAt: now,
1112
+ updatedAt: now
1113
+ };
1114
+ row.memory.notes.unshift(note);
1115
+ await this.persist();
1116
+ return note;
1117
+ }
1118
+ async notesUpdate(input) {
1119
+ const { row, note } = this.noteById(input.noteId);
1120
+ note.text = cap(redact(input.text), MAX_NOTE_LENGTH);
1121
+ note.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1122
+ await this.persist();
1123
+ return note;
1124
+ }
1125
+ async notesDelete(input) {
1126
+ const { row } = this.noteById(input.noteId);
1127
+ row.memory.notes = row.memory.notes.filter((n) => n.id !== input.noteId);
1128
+ await this.persist();
1129
+ return { deleted: true };
1130
+ }
1131
+ async notesList(input) {
1132
+ const rows = this.ledger.active.filter(
1133
+ (r) => (input.appId === void 0 || r.appId === input.appId) && (input.ticketId === void 0 || r.id === input.ticketId)
1134
+ );
1135
+ return rows.flatMap((r) => r.memory.notes);
1136
+ }
1137
+ rowForNote(appId, ticketId) {
1138
+ const row = this.ledger.active.find((r) => r.id === ticketId && r.appId === appId);
1139
+ if (!row) throw new Error(`No active watch row for ticket ${ticketId} in app ${appId}; register it first.`);
1140
+ return row;
1141
+ }
1142
+ noteById(noteId) {
1143
+ for (const row of [...this.ledger.active, ...this.ledger.archived]) {
1144
+ const note = row.memory.notes.find((n) => n.id === noteId);
1145
+ if (note) return { row, note };
1146
+ }
1147
+ throw new Error(`Note ${noteId} not found.`);
1148
+ }
1149
+ };
1150
+ }
1151
+ });
1152
+
1153
+ // src/services/teamdynamix/client.service.ts
1154
+ var client_service_exports = {};
1155
+ __export(client_service_exports, {
1156
+ UnifiedTeamDynamixClient: () => UnifiedTeamDynamixClient,
1157
+ assertDeleteToolsEnabled: () => assertDeleteToolsEnabled,
1158
+ assertWriteToolsEnabled: () => assertWriteToolsEnabled,
1159
+ createConfiguredTeamDynamixClient: () => createConfiguredTeamDynamixClient
1160
+ });
1161
+ var init_client_service = __esm({
1162
+ "src/services/teamdynamix/client.service.ts"() {
1163
+ "use strict";
1164
+ init_client_factory();
1165
+ }
1166
+ });
25
1167
 
26
1168
  // src/index.ts
1169
+ init_config();
1170
+ init_constants();
27
1171
  import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
28
1172
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
29
1173
 
30
1174
  // src/resources/teamdynamix.resources.ts
1175
+ init_config();
31
1176
  import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
32
1177
 
33
1178
  // src/services/teamdynamix/core.service.ts
1179
+ init_constants();
34
1180
  function redactTeamDynamixConfig(config) {
35
1181
  return {
36
1182
  baseUrl: config.baseUrl ?? null,
@@ -50,231 +1196,237 @@ function redactTeamDynamixConfig(config) {
50
1196
  }
51
1197
 
52
1198
  // src/tools/teamdynamix.domain-gateways.tools.ts
53
- import { z as z3 } from "zod";
1199
+ init_config();
1200
+ init_constants();
1201
+ import { z as z4 } from "zod";
54
1202
 
55
1203
  // src/schemas/teamdynamix/index.ts
56
- import { z as z2 } from "zod";
1204
+ import { z as z3 } from "zod";
57
1205
 
58
1206
  // src/schemas/index.ts
59
- import { z } from "zod";
60
- var ResponseFormatSchema = z.enum(["markdown", "json"]).default("markdown").describe("Output format for the response.");
61
- var TextTransformModeSchema = z.enum(["uppercase", "lowercase", "trim", "slug"]).describe("Transformation mode to apply to the input text.");
1207
+ import { z as z2 } from "zod";
1208
+ var ResponseFormatSchema = z2.enum(["markdown", "json"]).default("markdown").describe("Output format for the response.");
1209
+ var TextTransformModeSchema = z2.enum(["uppercase", "lowercase", "trim", "slug"]).describe("Transformation mode to apply to the input text.");
62
1210
 
63
1211
  // src/schemas/teamdynamix/index.ts
64
- var TeamDynamixAppIdSchema = z2.number().int().positive().describe("TeamDynamix application ID.");
65
- var IsoDateSchema = z2.string().regex(
1212
+ var TeamDynamixAppIdSchema = z3.number().int().positive().describe("TeamDynamix application ID.");
1213
+ var IsoDateSchema = z3.string().regex(
66
1214
  /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,
67
1215
  "Must be a valid ISO 8601 date string."
68
1216
  );
69
- var TeamDynamixGuidSchema = z2.string().uuid().describe("TeamDynamix GUID identifier.");
1217
+ var TeamDynamixGuidSchema = z3.string().uuid().describe("TeamDynamix GUID identifier.");
70
1218
  var TeamDynamixResponseFormatSchema = ResponseFormatSchema;
71
- var TicketSearchSchema = z2.object({
72
- Keywords: z2.string().max(500).optional().describe("Full-text search term."),
73
- MaxResults: z2.number().int().min(1).max(1e3).optional().default(50).describe("Maximum results to return (1\u20131000)."),
74
- StatusIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket status IDs."),
75
- TypeIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket type IDs."),
76
- PriorityIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket priority IDs."),
77
- UrgencyIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket urgency IDs."),
78
- ImpactIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket impact IDs."),
79
- AccountIDs: z2.array(z2.number().int()).optional().describe("Filter by account/department IDs."),
80
- ResponsibleGroupIDs: z2.array(z2.number().int()).optional().describe("Filter by responsible group IDs."),
81
- ResponsibleUids: z2.array(z2.string().uuid()).optional().describe("Filter by responsible user GUIDs."),
82
- RequestorUids: z2.array(z2.string().uuid()).optional().describe("Filter by requestor user GUIDs."),
1219
+ var TicketSearchSchema = z3.object({
1220
+ Keywords: z3.string().max(500).optional().describe("Full-text search term."),
1221
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(50).describe("Maximum results to return (1\u20131000)."),
1222
+ StatusIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket status IDs."),
1223
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket type IDs."),
1224
+ PriorityIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket priority IDs."),
1225
+ UrgencyIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket urgency IDs."),
1226
+ ImpactIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket impact IDs."),
1227
+ AccountIDs: z3.array(z3.number().int()).optional().describe("Filter by account/department IDs."),
1228
+ ResponsibleGroupIDs: z3.array(z3.number().int()).optional().describe("Filter by responsible group IDs."),
1229
+ ResponsibleUids: z3.array(z3.string().uuid()).optional().describe("Filter by responsible user GUIDs."),
1230
+ RequestorUids: z3.array(z3.string().uuid()).optional().describe("Filter by requestor user GUIDs."),
83
1231
  CreatedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for creation date filter."),
84
1232
  CreatedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for creation date filter."),
85
1233
  ModifiedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for last-modified filter."),
86
1234
  ModifiedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for last-modified filter."),
87
1235
  ClosedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for closed date filter."),
88
1236
  ClosedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for closed date filter."),
89
- SortBy: z2.string().max(100).optional().describe("Field name to sort results by."),
90
- SortOrder: z2.enum(["A", "D"]).optional().describe("Sort order: A = ascending, D = descending.")
1237
+ SortBy: z3.string().max(100).optional().describe("Field name to sort results by."),
1238
+ SortOrder: z3.enum(["A", "D"]).optional().describe("Sort order: A = ascending, D = descending.")
91
1239
  });
92
- var TicketCreateSchema = z2.object({
93
- TypeID: z2.number().int().positive().describe("Ticket type ID."),
94
- Title: z2.string().min(1).max(500).describe("Ticket title/subject."),
95
- AccountID: z2.number().int().positive().optional().describe("Account/department ID."),
96
- StatusID: z2.number().int().nonnegative().optional().describe("Initial ticket status ID."),
97
- PriorityID: z2.number().int().nonnegative().optional().describe("Ticket priority ID."),
98
- UrgencyID: z2.number().int().nonnegative().optional().describe("Ticket urgency ID."),
99
- ImpactID: z2.number().int().nonnegative().optional().describe("Ticket impact ID."),
100
- SourceID: z2.number().int().nonnegative().optional().describe("Ticket source ID."),
101
- Description: z2.string().max(65535).optional().describe("Full description/body of the ticket (HTML supported)."),
102
- RequestorUID: z2.string().uuid().optional().describe("GUID of the requestor."),
103
- ResponsibleUID: z2.string().uuid().optional().describe("GUID of the responsible technician."),
104
- ResponsibleGroupID: z2.number().int().positive().optional().describe("Responsible group ID."),
105
- FormID: z2.number().int().positive().optional().describe("Ticket form ID."),
106
- Attributes: z2.array(
107
- z2.object({
108
- ID: z2.number().int(),
109
- Value: z2.string()
1240
+ var TicketCreateSchema = z3.object({
1241
+ TypeID: z3.number().int().positive().describe("Ticket type ID."),
1242
+ Title: z3.string().min(1).max(500).describe("Ticket title/subject."),
1243
+ AccountID: z3.number().int().positive().optional().describe("Account/department ID."),
1244
+ StatusID: z3.number().int().nonnegative().optional().describe("Initial ticket status ID."),
1245
+ PriorityID: z3.number().int().nonnegative().optional().describe("Ticket priority ID."),
1246
+ UrgencyID: z3.number().int().nonnegative().optional().describe("Ticket urgency ID."),
1247
+ ImpactID: z3.number().int().nonnegative().optional().describe("Ticket impact ID."),
1248
+ SourceID: z3.number().int().nonnegative().optional().describe("Ticket source ID."),
1249
+ Description: z3.string().max(65535).optional().describe("Full description/body of the ticket (HTML supported)."),
1250
+ RequestorUID: z3.string().uuid().optional().describe("GUID of the requestor."),
1251
+ ResponsibleUID: z3.string().uuid().optional().describe("GUID of the responsible technician."),
1252
+ ResponsibleGroupID: z3.number().int().positive().optional().describe("Responsible group ID."),
1253
+ FormID: z3.number().int().positive().optional().describe("Ticket form ID."),
1254
+ Attributes: z3.array(
1255
+ z3.object({
1256
+ ID: z3.number().int(),
1257
+ Value: z3.string()
110
1258
  })
111
1259
  ).optional().describe("Custom attribute values.")
112
1260
  });
113
- var TicketPatchSchema = z2.object({
114
- TicketID: z2.number().int().positive().describe("Ticket ID to update."),
115
- Attributes: z2.record(z2.string().max(100), z2.string().max(65535)).refine((obj) => Object.keys(obj).length <= 50, { message: "Attributes may contain at most 50 fields per update." }).describe(
1261
+ var TicketPatchSchema = z3.object({
1262
+ TicketID: z3.number().int().positive().describe("Ticket ID to update."),
1263
+ Attributes: z3.record(z3.string().max(100), z3.string().max(65535)).refine((obj) => Object.keys(obj).length <= 50, { message: "Attributes may contain at most 50 fields per update." }).describe(
116
1264
  'Fields to update as key/value pairs. Keys must be valid ticket field names (e.g. "StatusID", "Title", "ResponsibleUID"). Maximum 50 fields per update.'
117
1265
  ),
118
- NotifyRequestor: z2.boolean().optional().default(false).describe("Notify the requestor of the change."),
119
- NotifyResponsible: z2.boolean().optional().default(false).describe("Notify the responsible technician of the change."),
120
- Comments: z2.string().max(65535).optional().describe("Comment to attach to this update."),
121
- IsPrivate: z2.boolean().optional().default(false).describe("Whether the comment is private.")
1266
+ NotifyRequestor: z3.boolean().optional().default(false).describe("Notify the requestor of the change."),
1267
+ NotifyResponsible: z3.boolean().optional().default(false).describe("Notify the responsible technician of the change."),
1268
+ Comments: z3.string().max(65535).optional().describe("Comment to attach to this update."),
1269
+ IsPrivate: z3.boolean().optional().default(false).describe("Whether the comment is private.")
122
1270
  });
123
- var TicketCommentSchema = z2.object({
124
- TicketID: z2.number().int().positive().describe("Ticket ID to comment on."),
125
- Body: z2.string().min(1).max(65535).describe("Comment body (HTML supported)."),
126
- IsPrivate: z2.boolean().optional().default(false).describe("Whether this comment is private."),
127
- NotifyRequestor: z2.boolean().optional().default(false).describe("Notify the requestor."),
128
- NotifyResponsible: z2.boolean().optional().default(false).describe("Notify the responsible technician.")
1271
+ var TicketCommentSchema = z3.object({
1272
+ TicketID: z3.number().int().positive().describe("Ticket ID to comment on."),
1273
+ Body: z3.string().min(1).max(65535).describe("Comment body (HTML supported)."),
1274
+ IsPrivate: z3.boolean().optional().default(false).describe("Whether this comment is private."),
1275
+ NotifyRequestor: z3.boolean().optional().default(false).describe("Notify the requestor."),
1276
+ NotifyResponsible: z3.boolean().optional().default(false).describe("Notify the responsible technician.")
129
1277
  });
130
- var UserSearchSchema = z2.object({
131
- SearchText: z2.string().max(500).optional().describe("Name, username, or email to search for."),
132
- AccountIDs: z2.array(z2.number().int()).optional().describe("Filter by account IDs (default account only)."),
133
- AlternateID: z2.string().optional().describe("Filter by alternate ID."),
134
- AppName: z2.string().optional().describe("Filter by system-defined application name."),
135
- AuthenticationUserName: z2.string().optional().describe("Exact-match authentication username (max one result)."),
136
- ExternalID: z2.string().optional().describe("Filter by external ID."),
137
- IsActive: z2.boolean().optional().describe("Filter by active (true) or inactive (false) users."),
138
- IsConfidential: z2.boolean().optional().describe("Filter by confidential status."),
139
- IsEmployee: z2.boolean().optional().describe("Filter to employees only."),
140
- MaxResults: z2.number().int().min(1).max(1e3).optional().describe("Maximum results (1-1000)."),
141
- PhoneNumber: z2.string().optional().describe("Filter by phone number."),
142
- ReferenceIDs: z2.array(z2.string()).optional().describe("Filter by user reference IDs (GUIDs)."),
143
- SecurityRoleID: z2.number().int().optional().describe("Filter by security role ID."),
144
- UserName: z2.string().optional().describe("Filter by username.")
1278
+ var UserSearchSchema = z3.object({
1279
+ SearchText: z3.string().max(500).optional().describe("Name, username, or email to search for."),
1280
+ AccountIDs: z3.array(z3.number().int()).optional().describe("Filter by account IDs (default account only)."),
1281
+ AlternateID: z3.string().optional().describe("Filter by alternate ID."),
1282
+ AppName: z3.string().optional().describe("Filter by system-defined application name."),
1283
+ AuthenticationUserName: z3.string().optional().describe("Exact-match authentication username (max one result)."),
1284
+ ExternalID: z3.string().optional().describe("Filter by external ID."),
1285
+ IsActive: z3.boolean().optional().describe("Filter by active (true) or inactive (false) users."),
1286
+ IsConfidential: z3.boolean().optional().describe("Filter by confidential status."),
1287
+ IsEmployee: z3.boolean().optional().describe("Filter to employees only."),
1288
+ MaxResults: z3.number().int().min(1).max(1e3).optional().describe("Maximum results (1-1000)."),
1289
+ PhoneNumber: z3.string().optional().describe("Filter by phone number."),
1290
+ ReferenceIDs: z3.array(z3.string()).optional().describe("Filter by user reference IDs (GUIDs)."),
1291
+ SecurityRoleID: z3.number().int().optional().describe("Filter by security role ID."),
1292
+ UserName: z3.string().optional().describe("Filter by username.")
145
1293
  }).strict();
146
- var GroupSearchSchema = z2.object({
147
- NameLike: z2.string().max(500).optional().describe("Partial group name to search."),
148
- IsActive: z2.boolean().optional().describe("Filter by active (true) or inactive (false) groups."),
149
- AssociatedAppID: z2.number().int().positive().optional().describe("Filter by associated application ID."),
150
- HasAppID: z2.boolean().optional().describe("Filter to groups with (true) or without (false) an associated application."),
151
- HasSystemAppName: z2.boolean().optional().describe("Filter to groups with (true) or without (false) a system app name.")
1294
+ var GroupSearchSchema = z3.object({
1295
+ NameLike: z3.string().max(500).optional().describe("Partial group name to search."),
1296
+ IsActive: z3.boolean().optional().describe("Filter by active (true) or inactive (false) groups."),
1297
+ AssociatedAppID: z3.number().int().positive().optional().describe("Filter by associated application ID."),
1298
+ HasAppID: z3.boolean().optional().describe("Filter to groups with (true) or without (false) an associated application."),
1299
+ HasSystemAppName: z3.boolean().optional().describe("Filter to groups with (true) or without (false) a system app name.")
152
1300
  }).strict();
153
- var KbArticleSearchSchema = z2.object({
154
- SearchText: z2.string().max(500).optional().describe("Full-text search within articles."),
155
- AuthorUID: z2.string().uuid().optional().describe("Filter by author GUID."),
156
- CategoryID: z2.number().int().positive().optional().describe("Filter by KB category ID."),
157
- CustomAttributes: z2.array(z2.record(z2.string(), z2.unknown())).optional().describe("Filter by custom attributes."),
158
- IncludeArticleBodies: z2.boolean().optional().describe("Include article bodies in results."),
159
- IncludeShortcuts: z2.boolean().optional().describe("Include shortcuts in results."),
160
- IsPublic: z2.boolean().optional().describe("Filter by public visibility."),
161
- IsPublished: z2.boolean().optional().describe("Filter to published articles only."),
162
- ReturnCount: z2.number().int().min(1).max(500).optional().describe("Maximum results (1-500)."),
163
- Status: z2.number().int().optional().describe("Filter by article status ID.")
1301
+ var KbArticleSearchSchema = z3.object({
1302
+ SearchText: z3.string().max(500).optional().describe("Full-text search within articles."),
1303
+ AuthorUID: z3.string().uuid().optional().describe("Filter by author GUID."),
1304
+ CategoryID: z3.number().int().positive().optional().describe("Filter by KB category ID."),
1305
+ CustomAttributes: z3.array(z3.record(z3.string(), z3.unknown())).optional().describe("Filter by custom attributes."),
1306
+ IncludeArticleBodies: z3.boolean().optional().describe("Include article bodies in results."),
1307
+ IncludeShortcuts: z3.boolean().optional().describe("Include shortcuts in results."),
1308
+ IsPublic: z3.boolean().optional().describe("Filter by public visibility."),
1309
+ IsPublished: z3.boolean().optional().describe("Filter to published articles only."),
1310
+ ReturnCount: z3.number().int().min(1).max(500).optional().describe("Maximum results (1-500)."),
1311
+ Status: z3.number().int().optional().describe("Filter by article status ID.")
164
1312
  }).strict();
165
- var AssetSearchSchema = z2.object({
166
- SerialLike: z2.string().max(200).optional().describe("Partial serial number to match."),
167
- TagLike: z2.string().max(200).optional().describe("Partial asset tag to match."),
168
- SearchText: z2.string().max(500).optional().describe("General text search across asset fields."),
169
- StatusIDs: z2.array(z2.number().int()).optional().describe("Filter by asset status IDs."),
170
- OwnerUID: z2.string().uuid().optional().describe("Filter by asset owner GUID."),
171
- UsingDepartmentID: z2.number().int().positive().optional().describe("Filter by using department ID."),
172
- MaxResults: z2.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
1313
+ var AssetSearchSchema = z3.object({
1314
+ SerialLike: z3.string().max(200).optional().describe("Partial serial number to match."),
1315
+ TagLike: z3.string().max(200).optional().describe("Partial asset tag to match."),
1316
+ SearchText: z3.string().max(500).optional().describe("General text search across asset fields."),
1317
+ StatusIDs: z3.array(z3.number().int()).optional().describe("Filter by asset status IDs."),
1318
+ OwnerUID: z3.string().uuid().optional().describe("Filter by asset owner GUID."),
1319
+ UsingDepartmentID: z3.number().int().positive().optional().describe("Filter by using department ID."),
1320
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
173
1321
  });
174
- var ServiceSearchSchema = z2.object({
175
- SearchText: z2.string().max(500).optional().describe("Full-text search across service fields."),
176
- IsActive: z2.boolean().optional().describe("Filter to active services only."),
177
- CategoryID: z2.number().int().positive().optional().describe("Filter by service category ID."),
178
- MaxResults: z2.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
1322
+ var ServiceSearchSchema = z3.object({
1323
+ SearchText: z3.string().max(500).optional().describe("Full-text search across service fields."),
1324
+ IsActive: z3.boolean().optional().describe("Filter to active services only."),
1325
+ CategoryID: z3.number().int().positive().optional().describe("Filter by service category ID."),
1326
+ MaxResults: z3.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
179
1327
  });
180
- var ProjectSearchSchema = z2.object({
181
- NameLike: z2.string().max(500).optional().describe("Partial project name to search."),
182
- TypeIDs: z2.array(z2.number().int()).optional().describe("Filter by project type IDs."),
183
- IsActive: z2.boolean().optional().describe("Filter to active projects."),
184
- ManagerUID: z2.string().uuid().optional().describe("Filter by project manager GUID."),
185
- MaxResults: z2.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
1328
+ var ProjectSearchSchema = z3.object({
1329
+ NameLike: z3.string().max(500).optional().describe("Partial project name to search."),
1330
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by project type IDs."),
1331
+ IsActive: z3.boolean().optional().describe("Filter to active projects."),
1332
+ ManagerUID: z3.string().uuid().optional().describe("Filter by project manager GUID."),
1333
+ MaxResults: z3.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
186
1334
  });
187
- var TicketTaskCreateSchema = z2.object({
188
- TicketID: z2.number().int().positive().describe("Parent ticket ID."),
189
- Title: z2.string().min(1).max(500).describe("Task title."),
190
- Description: z2.string().max(65535).optional().describe("Task description."),
191
- IsActive: z2.boolean().optional().default(true).describe("Whether the task is active."),
192
- AssignedUID: z2.string().uuid().optional().describe("GUID of the assigned user."),
193
- AssignedGroupID: z2.number().int().positive().optional().describe("Assigned group ID."),
194
- EstimatedMinutes: z2.number().int().nonnegative().optional().describe("Estimated minutes to complete."),
1335
+ var TicketTaskCreateSchema = z3.object({
1336
+ TicketID: z3.number().int().positive().describe("Parent ticket ID."),
1337
+ Title: z3.string().min(1).max(500).describe("Task title."),
1338
+ Description: z3.string().max(65535).optional().describe("Task description."),
1339
+ IsActive: z3.boolean().optional().default(true).describe("Whether the task is active."),
1340
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the assigned user."),
1341
+ AssignedGroupID: z3.number().int().positive().optional().describe("Assigned group ID."),
1342
+ EstimatedMinutes: z3.number().int().nonnegative().optional().describe("Estimated minutes to complete."),
195
1343
  StartDate: IsoDateSchema.optional().describe("Task start date (ISO 8601)."),
196
1344
  EndDate: IsoDateSchema.optional().describe("Task due date (ISO 8601).")
197
1345
  });
198
- var KbArticleCreateSchema = z2.object({
199
- Subject: z2.string().min(1).max(500).describe("Article title/subject."),
200
- Body: z2.string().min(1).max(5e5).describe("Article body content (HTML supported)."),
201
- Summary: z2.string().max(2e3).optional().describe("Short article summary."),
202
- CategoryID: z2.number().int().positive().optional().describe("KB category ID."),
203
- IsPublished: z2.boolean().optional().default(false).describe("Whether to publish the article immediately."),
204
- Tags: z2.string().max(1e3).optional().describe("Comma-separated tags for the article.")
1346
+ var KbArticleCreateSchema = z3.object({
1347
+ Subject: z3.string().min(1).max(500).describe("Article title/subject."),
1348
+ Body: z3.string().min(1).max(5e5).describe("Article body content (HTML supported)."),
1349
+ Summary: z3.string().max(2e3).optional().describe("Short article summary."),
1350
+ CategoryID: z3.number().int().positive().optional().describe("KB category ID."),
1351
+ IsPublished: z3.boolean().optional().default(false).describe("Whether to publish the article immediately."),
1352
+ Tags: z3.string().max(1e3).optional().describe("Comma-separated tags for the article.")
205
1353
  });
206
1354
  var KbArticleUpdateSchema = KbArticleCreateSchema.partial().extend({
207
- ArticleID: z2.number().int().positive().describe("KB article ID to update.")
1355
+ ArticleID: z3.number().int().positive().describe("KB article ID to update.")
208
1356
  });
209
- var CiSearchSchema = z2.object({
210
- SearchText: z2.string().max(500).optional().describe("Full-text search across CI fields."),
211
- TypeIDs: z2.array(z2.number().int()).optional().describe("Filter by CI type IDs."),
212
- OwnerUID: z2.string().uuid().optional().describe("Filter by owner GUID."),
213
- MaxResults: z2.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
1357
+ var CiSearchSchema = z3.object({
1358
+ SearchText: z3.string().max(500).optional().describe("Full-text search across CI fields."),
1359
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by CI type IDs."),
1360
+ OwnerUID: z3.string().uuid().optional().describe("Filter by owner GUID."),
1361
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
214
1362
  });
215
- var CustomAttributeComponentIdSchema = z2.number().int().positive().describe(
1363
+ var CustomAttributeComponentIdSchema = z3.number().int().positive().describe(
216
1364
  "TeamDynamix component ID for the attribute context. Common values: 9 = Ticket, 27 = Asset, 63 = KB Article, 31 = Person."
217
1365
  );
218
- var ProjectIssueCreateSchema = z2.object({
219
- Title: z2.string().min(1).max(500).describe("Issue title."),
220
- Description: z2.string().max(65535).optional().describe("Issue description."),
221
- AssignedUID: z2.string().uuid().optional().describe("GUID of the assigned user."),
222
- StatusID: z2.number().int().nonnegative().optional().describe("Issue status ID."),
223
- PriorityID: z2.number().int().nonnegative().optional().describe("Issue priority ID."),
1366
+ var ProjectIssueCreateSchema = z3.object({
1367
+ Title: z3.string().min(1).max(500).describe("Issue title."),
1368
+ Description: z3.string().max(65535).optional().describe("Issue description."),
1369
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the assigned user."),
1370
+ StatusID: z3.number().int().nonnegative().optional().describe("Issue status ID."),
1371
+ PriorityID: z3.number().int().nonnegative().optional().describe("Issue priority ID."),
224
1372
  DueDate: IsoDateSchema.optional().describe("Issue due date (ISO 8601).")
225
1373
  });
226
- var ProjectRiskCreateSchema = z2.object({
227
- Title: z2.string().min(1).max(500).describe("Risk title."),
228
- Description: z2.string().max(65535).optional().describe("Risk description."),
229
- AssignedUID: z2.string().uuid().optional().describe("GUID of the risk owner."),
230
- StatusID: z2.number().int().nonnegative().optional().describe("Risk status ID."),
231
- Probability: z2.number().int().min(1).max(100).optional().describe("Probability percentage (1\u2013100)."),
232
- Impact: z2.number().int().min(1).max(5).optional().describe("Impact level (1 = low, 5 = critical)."),
1374
+ var ProjectRiskCreateSchema = z3.object({
1375
+ Title: z3.string().min(1).max(500).describe("Risk title."),
1376
+ Description: z3.string().max(65535).optional().describe("Risk description."),
1377
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the risk owner."),
1378
+ StatusID: z3.number().int().nonnegative().optional().describe("Risk status ID."),
1379
+ Probability: z3.number().int().min(1).max(100).optional().describe("Probability percentage (1\u2013100)."),
1380
+ Impact: z3.number().int().min(1).max(5).optional().describe("Impact level (1 = low, 5 = critical)."),
233
1381
  DueDate: IsoDateSchema.optional().describe("Risk resolution due date (ISO 8601).")
234
1382
  });
235
- var TimeEntryQuerySchema = z2.object({
1383
+ var TimeEntryQuerySchema = z3.object({
236
1384
  StartDate: IsoDateSchema.describe("Start date for time entries query (ISO 8601 date, e.g. 2026-01-01)."),
237
1385
  EndDate: IsoDateSchema.describe("End date for time entries query (ISO 8601 date, e.g. 2026-01-31).")
238
1386
  });
239
- var TeamDynamixEntitySchema = z2.record(z2.string(), z2.unknown()).describe("Base TeamDynamix entity with flexible additional fields");
240
- var TeamDynamixNamedEntitySchema = z2.object({
241
- ID: z2.number().int().positive("ID must be a positive integer"),
242
- Name: z2.string().optional()
243
- }).catchall(z2.unknown()).describe("TeamDynamix entity with ID and optional Name");
1387
+ var TeamDynamixEntitySchema = z3.record(z3.string(), z3.unknown()).describe("Base TeamDynamix entity with flexible additional fields");
1388
+ var TeamDynamixNamedEntitySchema = z3.object({
1389
+ ID: z3.number().int().positive("ID must be a positive integer"),
1390
+ Name: z3.string().optional()
1391
+ }).catchall(z3.unknown()).describe("TeamDynamix entity with ID and optional Name");
244
1392
  var TeamDynamixApplicationSchema = TeamDynamixNamedEntitySchema.extend({
245
- Name: z2.string().optional()
1393
+ Name: z3.string().optional()
246
1394
  }).describe("TeamDynamix Application entity");
247
1395
  var TeamDynamixTicketSchema = TeamDynamixNamedEntitySchema.extend({
248
- Title: z2.string().optional(),
249
- Description: z2.string().optional(),
250
- StatusID: z2.number().int().optional(),
251
- TypeID: z2.number().int().optional()
1396
+ Title: z3.string().optional(),
1397
+ Description: z3.string().optional(),
1398
+ StatusID: z3.number().int().optional(),
1399
+ TypeID: z3.number().int().optional()
252
1400
  }).describe("TeamDynamix Ticket entity");
253
1401
  var TeamDynamixKbArticleSchema = TeamDynamixNamedEntitySchema.extend({
254
- Subject: z2.string().optional(),
255
- Body: z2.string().optional(),
256
- IsPublished: z2.boolean().optional()
1402
+ Subject: z3.string().optional(),
1403
+ Body: z3.string().optional(),
1404
+ IsPublished: z3.boolean().optional()
257
1405
  }).describe("TeamDynamix Knowledge Base Article entity");
258
1406
  var TeamDynamixAssetSchema = TeamDynamixNamedEntitySchema.extend({
259
- Tag: z2.string().optional(),
260
- StatusID: z2.number().int().optional()
1407
+ Tag: z3.string().optional(),
1408
+ StatusID: z3.number().int().optional()
261
1409
  }).describe("TeamDynamix Asset entity");
262
1410
  var TeamDynamixProjectSchema = TeamDynamixNamedEntitySchema.extend({
263
- Status: z2.string().optional()
1411
+ Status: z3.string().optional()
264
1412
  }).describe("TeamDynamix Project entity");
265
1413
  var TeamDynamixGroupSchema = TeamDynamixNamedEntitySchema.extend({
266
- Description: z2.string().optional()
1414
+ Description: z3.string().optional()
267
1415
  }).describe("TeamDynamix Group entity");
268
- var TeamDynamixUserSchema = z2.object({
269
- UID: z2.string({ error: "User UID is required" }),
270
- FullName: z2.string().optional(),
271
- Email: z2.string().email().optional(),
272
- IsActive: z2.boolean().optional()
273
- }).catchall(z2.unknown()).describe("TeamDynamix User entity");
274
- var TeamDynamixListResponseSchema = z2.array(z2.record(z2.string(), z2.unknown())).describe("Array of TeamDynamix entities");
275
- var TeamDynamixSingleResponseSchema = z2.record(z2.string(), z2.unknown()).describe("Single TeamDynamix entity response");
1416
+ var TeamDynamixUserSchema = z3.object({
1417
+ UID: z3.string({ error: "User UID is required" }),
1418
+ FullName: z3.string().optional(),
1419
+ Email: z3.string().email().optional(),
1420
+ IsActive: z3.boolean().optional()
1421
+ }).catchall(z3.unknown()).describe("TeamDynamix User entity");
1422
+ var TeamDynamixListResponseSchema = z3.array(z3.record(z3.string(), z3.unknown())).describe("Array of TeamDynamix entities");
1423
+ var TeamDynamixSingleResponseSchema = z3.record(z3.string(), z3.unknown()).describe("Single TeamDynamix entity response");
1424
+
1425
+ // src/tools/teamdynamix.domain-gateways.tools.ts
1426
+ init_client_factory();
276
1427
 
277
1428
  // src/services/teamdynamix/render.service.ts
1429
+ init_constants();
278
1430
  import { tablemark } from "tablemark";
279
1431
  function render(payload, responseFormat, characterLimit = CHARACTER_LIMIT) {
280
1432
  if (responseFormat === "json") {
@@ -386,13 +1538,13 @@ function truncateMarkdown(markdown, limit) {
386
1538
  }
387
1539
 
388
1540
  // src/tools/teamdynamix.domain-gateways.tools.ts
389
- var teamdynamixDiscoveryActionSchema = z3.enum([
1541
+ var teamdynamixDiscoveryActionSchema = z4.enum([
390
1542
  "server_status",
391
1543
  "get_current_user",
392
1544
  "list_applications",
393
1545
  "list_ticket_statuses"
394
1546
  ]);
395
- var teamdynamixTicketActionSchema = z3.enum([
1547
+ var teamdynamixTicketActionSchema = z4.enum([
396
1548
  "list_ticket_types",
397
1549
  "list_ticket_priorities",
398
1550
  "list_ticket_urgencies",
@@ -405,7 +1557,7 @@ var teamdynamixTicketActionSchema = z3.enum([
405
1557
  "add_ticket_comment",
406
1558
  "get_ticket_feed"
407
1559
  ]);
408
- var teamdynamixTicketRelationshipActionSchema = z3.enum([
1560
+ var teamdynamixTicketRelationshipActionSchema = z4.enum([
409
1561
  "get_ticket_tasks",
410
1562
  "create_ticket_task",
411
1563
  "list_ticket_assets",
@@ -415,28 +1567,28 @@ var teamdynamixTicketRelationshipActionSchema = z3.enum([
415
1567
  "add_ticket_contact",
416
1568
  "remove_ticket_contact"
417
1569
  ]);
418
- var teamdynamixPeopleActionSchema = z3.enum([
1570
+ var teamdynamixPeopleActionSchema = z4.enum([
419
1571
  "get_user",
420
1572
  "search_users",
421
1573
  "get_group",
422
1574
  "search_groups",
423
1575
  "get_group_members"
424
1576
  ]);
425
- var teamdynamixKnowledgeBaseActionSchema = z3.enum([
1577
+ var teamdynamixKnowledgeBaseActionSchema = z4.enum([
426
1578
  "get_kb_article",
427
1579
  "search_kb_articles",
428
1580
  "list_kb_categories",
429
1581
  "create_kb_article",
430
1582
  "update_kb_article"
431
1583
  ]);
432
- var teamdynamixAssetsActionSchema = z3.enum([
1584
+ var teamdynamixAssetsActionSchema = z4.enum([
433
1585
  "get_asset",
434
1586
  "search_assets",
435
1587
  "list_asset_statuses",
436
1588
  "list_product_models",
437
1589
  "delete_asset"
438
1590
  ]);
439
- var teamdynamixCmdbActionSchema = z3.enum([
1591
+ var teamdynamixCmdbActionSchema = z4.enum([
440
1592
  "get_ci",
441
1593
  "search_cis",
442
1594
  "list_ci_types",
@@ -444,7 +1596,7 @@ var teamdynamixCmdbActionSchema = z3.enum([
444
1596
  "list_vendors",
445
1597
  "delete_ci"
446
1598
  ]);
447
- var teamdynamixServicesActionSchema = z3.enum([
1599
+ var teamdynamixServicesActionSchema = z4.enum([
448
1600
  "list_services",
449
1601
  "get_service",
450
1602
  "search_services",
@@ -452,7 +1604,7 @@ var teamdynamixServicesActionSchema = z3.enum([
452
1604
  "delete_service",
453
1605
  "delete_service_category"
454
1606
  ]);
455
- var teamdynamixProjectsActionSchema = z3.enum([
1607
+ var teamdynamixProjectsActionSchema = z4.enum([
456
1608
  "get_project",
457
1609
  "search_projects",
458
1610
  "list_project_types",
@@ -462,15 +1614,15 @@ var teamdynamixProjectsActionSchema = z3.enum([
462
1614
  "create_project_issue",
463
1615
  "create_project_risk"
464
1616
  ]);
465
- var teamdynamixTimeActionSchema = z3.enum(["list_time_types", "get_my_time_entries"]);
466
- var teamdynamixReferenceDataActionSchema = z3.enum([
1617
+ var teamdynamixTimeActionSchema = z4.enum(["list_time_types", "get_my_time_entries"]);
1618
+ var teamdynamixReferenceDataActionSchema = z4.enum([
467
1619
  "list_accounts",
468
1620
  "get_account",
469
1621
  "list_locations",
470
1622
  "list_functional_roles",
471
1623
  "list_custom_attributes"
472
1624
  ]);
473
- var gatewayPayloadSchema = z3.record(z3.string(), z3.unknown()).default({});
1625
+ var gatewayPayloadSchema = z4.record(z4.string(), z4.unknown()).default({});
474
1626
  function messageFromError(error) {
475
1627
  return error instanceof Error ? error.message : String(error);
476
1628
  }
@@ -615,7 +1767,7 @@ function registerTeamDynamixDiscoveryGateway(server2) {
615
1767
  return toSuccessResponse({ count: applications.length, applications }, response_format);
616
1768
  }
617
1769
  case "list_ticket_statuses": {
618
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
1770
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
619
1771
  const config = getTeamDynamixConfig();
620
1772
  const effectiveAppId = parsed.app_id ?? config.defaultTicketAppId;
621
1773
  if (!effectiveAppId) {
@@ -651,33 +1803,33 @@ function registerTeamDynamixTicketsGateway(server2) {
651
1803
  const client = createConfiguredTeamDynamixClient();
652
1804
  switch (action) {
653
1805
  case "list_ticket_types": {
654
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1806
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
655
1807
  const types = await client.listTicketTypes(parsed.app_id);
656
1808
  return toSuccessResponse({ appId: parsed.app_id, types }, response_format);
657
1809
  }
658
1810
  case "list_ticket_priorities": {
659
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1811
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
660
1812
  const priorities = await client.listTicketPriorities(parsed.app_id);
661
1813
  return toSuccessResponse({ appId: parsed.app_id, priorities }, response_format);
662
1814
  }
663
1815
  case "list_ticket_urgencies": {
664
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1816
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
665
1817
  const urgencies = await client.listTicketUrgencies(parsed.app_id);
666
1818
  return toSuccessResponse({ appId: parsed.app_id, urgencies }, response_format);
667
1819
  }
668
1820
  case "list_ticket_impacts": {
669
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1821
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
670
1822
  const impacts = await client.listTicketImpacts(parsed.app_id);
671
1823
  return toSuccessResponse({ appId: parsed.app_id, impacts }, response_format);
672
1824
  }
673
1825
  case "list_ticket_sources": {
674
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1826
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
675
1827
  const sources = await client.listTicketSources(parsed.app_id);
676
1828
  return toSuccessResponse({ appId: parsed.app_id, sources }, response_format);
677
1829
  }
678
1830
  case "get_ticket": {
679
1831
  const parsed = parsePayload(
680
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
1832
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
681
1833
  payload,
682
1834
  action
683
1835
  );
@@ -686,7 +1838,7 @@ function registerTeamDynamixTicketsGateway(server2) {
686
1838
  }
687
1839
  case "search_tickets": {
688
1840
  const parsed = parsePayload(
689
- z3.object({ app_id: TeamDynamixAppIdSchema, search: TicketSearchSchema }),
1841
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: TicketSearchSchema }),
690
1842
  payload,
691
1843
  action
692
1844
  );
@@ -695,11 +1847,11 @@ function registerTeamDynamixTicketsGateway(server2) {
695
1847
  }
696
1848
  case "create_ticket": {
697
1849
  const parsed = parsePayload(
698
- z3.object({
1850
+ z4.object({
699
1851
  app_id: TeamDynamixAppIdSchema,
700
1852
  ticket: TicketCreateSchema,
701
- notify_requestor: z3.boolean().optional().default(false),
702
- notify_responsible: z3.boolean().optional().default(false)
1853
+ notify_requestor: z4.boolean().optional().default(false),
1854
+ notify_responsible: z4.boolean().optional().default(false)
703
1855
  }),
704
1856
  payload,
705
1857
  action
@@ -715,7 +1867,7 @@ function registerTeamDynamixTicketsGateway(server2) {
715
1867
  }
716
1868
  case "update_ticket": {
717
1869
  const parsed = parsePayload(
718
- z3.object({ app_id: TeamDynamixAppIdSchema, patch: TicketPatchSchema }),
1870
+ z4.object({ app_id: TeamDynamixAppIdSchema, patch: TicketPatchSchema }),
719
1871
  payload,
720
1872
  action
721
1873
  );
@@ -733,7 +1885,7 @@ function registerTeamDynamixTicketsGateway(server2) {
733
1885
  }
734
1886
  case "add_ticket_comment": {
735
1887
  const parsed = parsePayload(
736
- z3.object({ app_id: TeamDynamixAppIdSchema, comment: TicketCommentSchema }),
1888
+ z4.object({ app_id: TeamDynamixAppIdSchema, comment: TicketCommentSchema }),
737
1889
  payload,
738
1890
  action
739
1891
  );
@@ -750,7 +1902,7 @@ function registerTeamDynamixTicketsGateway(server2) {
750
1902
  }
751
1903
  case "get_ticket_feed": {
752
1904
  const parsed = parsePayload(
753
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
1905
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
754
1906
  payload,
755
1907
  action
756
1908
  );
@@ -786,7 +1938,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
786
1938
  switch (action) {
787
1939
  case "get_ticket_tasks": {
788
1940
  const parsed = parsePayload(
789
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
1941
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
790
1942
  payload,
791
1943
  action
792
1944
  );
@@ -798,7 +1950,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
798
1950
  }
799
1951
  case "create_ticket_task": {
800
1952
  const parsed = parsePayload(
801
- z3.object({ app_id: TeamDynamixAppIdSchema, task: TicketTaskCreateSchema }),
1953
+ z4.object({ app_id: TeamDynamixAppIdSchema, task: TicketTaskCreateSchema }),
802
1954
  payload,
803
1955
  action
804
1956
  );
@@ -812,7 +1964,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
812
1964
  }
813
1965
  case "list_ticket_assets": {
814
1966
  const parsed = parsePayload(
815
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
1967
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
816
1968
  payload,
817
1969
  action
818
1970
  );
@@ -824,10 +1976,10 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
824
1976
  }
825
1977
  case "add_ticket_asset": {
826
1978
  const parsed = parsePayload(
827
- z3.object({
1979
+ z4.object({
828
1980
  app_id: TeamDynamixAppIdSchema,
829
- ticket_id: z3.number().int().positive(),
830
- asset_id: z3.number().int().positive()
1981
+ ticket_id: z4.number().int().positive(),
1982
+ asset_id: z4.number().int().positive()
831
1983
  }),
832
1984
  payload,
833
1985
  action
@@ -838,11 +1990,11 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
838
1990
  }
839
1991
  case "remove_ticket_asset": {
840
1992
  const parsed = parsePayload(
841
- z3.object({
1993
+ z4.object({
842
1994
  app_id: TeamDynamixAppIdSchema,
843
- ticket_id: z3.number().int().positive(),
844
- asset_id: z3.number().int().positive(),
845
- confirm: z3.literal(true)
1995
+ ticket_id: z4.number().int().positive(),
1996
+ asset_id: z4.number().int().positive(),
1997
+ confirm: z4.literal(true)
846
1998
  }),
847
1999
  payload,
848
2000
  action
@@ -861,7 +2013,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
861
2013
  }
862
2014
  case "get_ticket_contacts": {
863
2015
  const parsed = parsePayload(
864
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
2016
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
865
2017
  payload,
866
2018
  action
867
2019
  );
@@ -873,9 +2025,9 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
873
2025
  }
874
2026
  case "add_ticket_contact": {
875
2027
  const parsed = parsePayload(
876
- z3.object({
2028
+ z4.object({
877
2029
  app_id: TeamDynamixAppIdSchema,
878
- ticket_id: z3.number().int().positive(),
2030
+ ticket_id: z4.number().int().positive(),
879
2031
  contact_uid: TeamDynamixGuidSchema
880
2032
  }),
881
2033
  payload,
@@ -887,11 +2039,11 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
887
2039
  }
888
2040
  case "remove_ticket_contact": {
889
2041
  const parsed = parsePayload(
890
- z3.object({
2042
+ z4.object({
891
2043
  app_id: TeamDynamixAppIdSchema,
892
- ticket_id: z3.number().int().positive(),
2044
+ ticket_id: z4.number().int().positive(),
893
2045
  contact_uid: TeamDynamixGuidSchema,
894
- confirm: z3.literal(true)
2046
+ confirm: z4.literal(true)
895
2047
  }),
896
2048
  payload,
897
2049
  action
@@ -933,27 +2085,27 @@ function registerTeamDynamixPeopleGateway(server2) {
933
2085
  const client = createConfiguredTeamDynamixClient();
934
2086
  switch (action) {
935
2087
  case "get_user": {
936
- const parsed = parsePayload(z3.object({ uid: TeamDynamixGuidSchema }), payload, action);
2088
+ const parsed = parsePayload(z4.object({ uid: TeamDynamixGuidSchema }), payload, action);
937
2089
  const user = await client.getUser(parsed.uid);
938
2090
  return toSuccessResponse(user, response_format);
939
2091
  }
940
2092
  case "search_users": {
941
- const parsed = parsePayload(z3.object({ search: UserSearchSchema }), payload, action);
2093
+ const parsed = parsePayload(z4.object({ search: UserSearchSchema }), payload, action);
942
2094
  const users = await client.searchUsers(parsed.search);
943
2095
  return toSuccessResponse({ count: users.length, users }, response_format);
944
2096
  }
945
2097
  case "get_group": {
946
- const parsed = parsePayload(z3.object({ group_id: z3.number().int().positive() }), payload, action);
2098
+ const parsed = parsePayload(z4.object({ group_id: z4.number().int().positive() }), payload, action);
947
2099
  const group = await client.getGroup(parsed.group_id);
948
2100
  return toSuccessResponse(group, response_format);
949
2101
  }
950
2102
  case "search_groups": {
951
- const parsed = parsePayload(z3.object({ search: GroupSearchSchema }), payload, action);
2103
+ const parsed = parsePayload(z4.object({ search: GroupSearchSchema }), payload, action);
952
2104
  const groups = await client.searchGroups(parsed.search);
953
2105
  return toSuccessResponse({ count: groups.length, groups }, response_format);
954
2106
  }
955
2107
  case "get_group_members": {
956
- const parsed = parsePayload(z3.object({ group_id: z3.number().int().positive() }), payload, action);
2108
+ const parsed = parsePayload(z4.object({ group_id: z4.number().int().positive() }), payload, action);
957
2109
  const members = await client.getGroupMembers(parsed.group_id);
958
2110
  return toSuccessResponse({ groupId: parsed.group_id, count: members.length, members }, response_format);
959
2111
  }
@@ -983,7 +2135,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
983
2135
  switch (action) {
984
2136
  case "get_kb_article": {
985
2137
  const parsed = parsePayload(
986
- z3.object({ app_id: TeamDynamixAppIdSchema, article_id: z3.number().int().positive() }),
2138
+ z4.object({ app_id: TeamDynamixAppIdSchema, article_id: z4.number().int().positive() }),
987
2139
  payload,
988
2140
  action
989
2141
  );
@@ -992,7 +2144,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
992
2144
  }
993
2145
  case "search_kb_articles": {
994
2146
  const parsed = parsePayload(
995
- z3.object({ app_id: TeamDynamixAppIdSchema, search: KbArticleSearchSchema }),
2147
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: KbArticleSearchSchema }),
996
2148
  payload,
997
2149
  action
998
2150
  );
@@ -1000,13 +2152,13 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
1000
2152
  return toSuccessResponse({ appId: parsed.app_id, count: articles.length, articles }, response_format);
1001
2153
  }
1002
2154
  case "list_kb_categories": {
1003
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2155
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1004
2156
  const categories = await client.listKbCategories(parsed.app_id);
1005
2157
  return toSuccessResponse({ appId: parsed.app_id, count: categories.length, categories }, response_format);
1006
2158
  }
1007
2159
  case "create_kb_article": {
1008
2160
  const parsed = parsePayload(
1009
- z3.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleCreateSchema }),
2161
+ z4.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleCreateSchema }),
1010
2162
  payload,
1011
2163
  action
1012
2164
  );
@@ -1016,7 +2168,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
1016
2168
  }
1017
2169
  case "update_kb_article": {
1018
2170
  const parsed = parsePayload(
1019
- z3.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleUpdateSchema }),
2171
+ z4.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleUpdateSchema }),
1020
2172
  payload,
1021
2173
  action
1022
2174
  );
@@ -1051,7 +2203,7 @@ function registerTeamDynamixAssetsGateway(server2) {
1051
2203
  switch (action) {
1052
2204
  case "get_asset": {
1053
2205
  const parsed = parsePayload(
1054
- z3.object({ app_id: TeamDynamixAppIdSchema, asset_id: z3.number().int().positive() }),
2206
+ z4.object({ app_id: TeamDynamixAppIdSchema, asset_id: z4.number().int().positive() }),
1055
2207
  payload,
1056
2208
  action
1057
2209
  );
@@ -1060,7 +2212,7 @@ function registerTeamDynamixAssetsGateway(server2) {
1060
2212
  }
1061
2213
  case "search_assets": {
1062
2214
  const parsed = parsePayload(
1063
- z3.object({ app_id: TeamDynamixAppIdSchema, search: AssetSearchSchema }),
2215
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: AssetSearchSchema }),
1064
2216
  payload,
1065
2217
  action
1066
2218
  );
@@ -1068,21 +2220,21 @@ function registerTeamDynamixAssetsGateway(server2) {
1068
2220
  return toSuccessResponse({ appId: parsed.app_id, count: assets.length, assets }, response_format);
1069
2221
  }
1070
2222
  case "list_asset_statuses": {
1071
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2223
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1072
2224
  const statuses = await client.listAssetStatuses(parsed.app_id);
1073
2225
  return toSuccessResponse({ appId: parsed.app_id, count: statuses.length, statuses }, response_format);
1074
2226
  }
1075
2227
  case "list_product_models": {
1076
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2228
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1077
2229
  const models = await client.listProductModels(parsed.app_id);
1078
2230
  return toSuccessResponse({ appId: parsed.app_id, count: models.length, models }, response_format);
1079
2231
  }
1080
2232
  case "delete_asset": {
1081
2233
  const parsed = parsePayload(
1082
- z3.object({
2234
+ z4.object({
1083
2235
  app_id: TeamDynamixAppIdSchema,
1084
- asset_id: z3.number().int().positive(),
1085
- confirm: z3.literal(true)
2236
+ asset_id: z4.number().int().positive(),
2237
+ confirm: z4.literal(true)
1086
2238
  }),
1087
2239
  payload,
1088
2240
  action
@@ -1120,7 +2272,7 @@ function registerTeamDynamixCmdbGateway(server2) {
1120
2272
  switch (action) {
1121
2273
  case "get_ci": {
1122
2274
  const parsed = parsePayload(
1123
- z3.object({ app_id: TeamDynamixAppIdSchema, ci_id: z3.number().int().positive() }),
2275
+ z4.object({ app_id: TeamDynamixAppIdSchema, ci_id: z4.number().int().positive() }),
1124
2276
  payload,
1125
2277
  action
1126
2278
  );
@@ -1129,7 +2281,7 @@ function registerTeamDynamixCmdbGateway(server2) {
1129
2281
  }
1130
2282
  case "search_cis": {
1131
2283
  const parsed = parsePayload(
1132
- z3.object({ app_id: TeamDynamixAppIdSchema, search: CiSearchSchema }),
2284
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: CiSearchSchema }),
1133
2285
  payload,
1134
2286
  action
1135
2287
  );
@@ -1140,7 +2292,7 @@ function registerTeamDynamixCmdbGateway(server2) {
1140
2292
  return toSuccessResponse({ appId: parsed.app_id, count: results.length, results }, response_format);
1141
2293
  }
1142
2294
  case "list_ci_types": {
1143
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2295
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1144
2296
  const types = await client.listCiTypes(parsed.app_id);
1145
2297
  return toSuccessResponse({ appId: parsed.app_id, count: types.length, types }, response_format);
1146
2298
  }
@@ -1149,16 +2301,16 @@ function registerTeamDynamixCmdbGateway(server2) {
1149
2301
  return toSuccessResponse({ count: types.length, types }, response_format);
1150
2302
  }
1151
2303
  case "list_vendors": {
1152
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2304
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1153
2305
  const vendors = await client.listVendors(parsed.app_id);
1154
2306
  return toSuccessResponse({ appId: parsed.app_id, count: vendors.length, vendors }, response_format);
1155
2307
  }
1156
2308
  case "delete_ci": {
1157
2309
  const parsed = parsePayload(
1158
- z3.object({
2310
+ z4.object({
1159
2311
  app_id: TeamDynamixAppIdSchema,
1160
- ci_id: z3.number().int().positive(),
1161
- confirm: z3.literal(true)
2312
+ ci_id: z4.number().int().positive(),
2313
+ confirm: z4.literal(true)
1162
2314
  }),
1163
2315
  payload,
1164
2316
  action
@@ -1192,13 +2344,13 @@ function registerTeamDynamixServicesGateway(server2) {
1192
2344
  const client = createConfiguredTeamDynamixClient();
1193
2345
  switch (action) {
1194
2346
  case "list_services": {
1195
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2347
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1196
2348
  const services = await client.listServiceCatalog(parsed.app_id);
1197
2349
  return toSuccessResponse({ appId: parsed.app_id, count: services.length, services }, response_format);
1198
2350
  }
1199
2351
  case "get_service": {
1200
2352
  const parsed = parsePayload(
1201
- z3.object({ app_id: TeamDynamixAppIdSchema, service_id: z3.number().int().positive() }),
2353
+ z4.object({ app_id: TeamDynamixAppIdSchema, service_id: z4.number().int().positive() }),
1202
2354
  payload,
1203
2355
  action
1204
2356
  );
@@ -1207,7 +2359,7 @@ function registerTeamDynamixServicesGateway(server2) {
1207
2359
  }
1208
2360
  case "search_services": {
1209
2361
  const parsed = parsePayload(
1210
- z3.object({ app_id: TeamDynamixAppIdSchema, search: ServiceSearchSchema }),
2362
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: ServiceSearchSchema }),
1211
2363
  payload,
1212
2364
  action
1213
2365
  );
@@ -1215,16 +2367,16 @@ function registerTeamDynamixServicesGateway(server2) {
1215
2367
  return toSuccessResponse({ appId: parsed.app_id, count: services.length, services }, response_format);
1216
2368
  }
1217
2369
  case "list_service_categories": {
1218
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2370
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1219
2371
  const categories = await client.listServiceCategories(parsed.app_id);
1220
2372
  return toSuccessResponse({ appId: parsed.app_id, count: categories.length, categories }, response_format);
1221
2373
  }
1222
2374
  case "delete_service": {
1223
2375
  const parsed = parsePayload(
1224
- z3.object({
2376
+ z4.object({
1225
2377
  app_id: TeamDynamixAppIdSchema,
1226
- service_id: z3.number().int().positive(),
1227
- confirm: z3.literal(true)
2378
+ service_id: z4.number().int().positive(),
2379
+ confirm: z4.literal(true)
1228
2380
  }),
1229
2381
  payload,
1230
2382
  action
@@ -1238,10 +2390,10 @@ function registerTeamDynamixServicesGateway(server2) {
1238
2390
  }
1239
2391
  case "delete_service_category": {
1240
2392
  const parsed = parsePayload(
1241
- z3.object({
2393
+ z4.object({
1242
2394
  app_id: TeamDynamixAppIdSchema,
1243
- category_id: z3.number().int().positive(),
1244
- confirm: z3.literal(true)
2395
+ category_id: z4.number().int().positive(),
2396
+ confirm: z4.literal(true)
1245
2397
  }),
1246
2398
  payload,
1247
2399
  action
@@ -1278,12 +2430,12 @@ function registerTeamDynamixProjectsGateway(server2) {
1278
2430
  const client = createConfiguredTeamDynamixClient();
1279
2431
  switch (action) {
1280
2432
  case "get_project": {
1281
- const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
2433
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1282
2434
  const project = await client.getProject(parsed.project_id);
1283
2435
  return toSuccessResponse(project, response_format);
1284
2436
  }
1285
2437
  case "search_projects": {
1286
- const parsed = parsePayload(z3.object({ search: ProjectSearchSchema }), payload, action);
2438
+ const parsed = parsePayload(z4.object({ search: ProjectSearchSchema }), payload, action);
1287
2439
  const projects = await client.searchProjects(parsed.search);
1288
2440
  return toSuccessResponse({ count: projects.length, projects }, response_format);
1289
2441
  }
@@ -1292,23 +2444,23 @@ function registerTeamDynamixProjectsGateway(server2) {
1292
2444
  return toSuccessResponse({ count: types.length, types }, response_format);
1293
2445
  }
1294
2446
  case "get_project_plans": {
1295
- const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
2447
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1296
2448
  const plans = await client.getProjectPlans(parsed.project_id);
1297
2449
  return toSuccessResponse({ projectId: parsed.project_id, count: plans.length, plans }, response_format);
1298
2450
  }
1299
2451
  case "get_project_issues": {
1300
- const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
2452
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1301
2453
  const issues = await client.getProjectIssues(parsed.project_id);
1302
2454
  return toSuccessResponse({ projectId: parsed.project_id, count: issues.length, issues }, response_format);
1303
2455
  }
1304
2456
  case "get_project_risks": {
1305
- const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
2457
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1306
2458
  const risks = await client.getProjectRisks(parsed.project_id);
1307
2459
  return toSuccessResponse({ projectId: parsed.project_id, count: risks.length, risks }, response_format);
1308
2460
  }
1309
2461
  case "create_project_issue": {
1310
2462
  const parsed = parsePayload(
1311
- z3.object({ project_id: z3.number().int().positive(), issue: ProjectIssueCreateSchema }),
2463
+ z4.object({ project_id: z4.number().int().positive(), issue: ProjectIssueCreateSchema }),
1312
2464
  payload,
1313
2465
  action
1314
2466
  );
@@ -1318,7 +2470,7 @@ function registerTeamDynamixProjectsGateway(server2) {
1318
2470
  }
1319
2471
  case "create_project_risk": {
1320
2472
  const parsed = parsePayload(
1321
- z3.object({ project_id: z3.number().int().positive(), risk: ProjectRiskCreateSchema }),
2473
+ z4.object({ project_id: z4.number().int().positive(), risk: ProjectRiskCreateSchema }),
1322
2474
  payload,
1323
2475
  action
1324
2476
  );
@@ -1355,7 +2507,7 @@ function registerTeamDynamixTimeGateway(server2) {
1355
2507
  return toSuccessResponse({ count: types.length, types }, response_format);
1356
2508
  }
1357
2509
  case "get_my_time_entries": {
1358
- const parsed = parsePayload(z3.object({ query: TimeEntryQuerySchema }), payload, action);
2510
+ const parsed = parsePayload(z4.object({ query: TimeEntryQuerySchema }), payload, action);
1359
2511
  const entries = await client.getMyTimeEntries(parsed.query.StartDate, parsed.query.EndDate);
1360
2512
  return toSuccessResponse({ count: entries.length, entries }, response_format);
1361
2513
  }
@@ -1384,12 +2536,12 @@ function registerTeamDynamixReferenceDataGateway(server2) {
1384
2536
  const client = createConfiguredTeamDynamixClient();
1385
2537
  switch (action) {
1386
2538
  case "list_accounts": {
1387
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
2539
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
1388
2540
  const accounts = await client.listAccounts(parsed.app_id);
1389
2541
  return toSuccessResponse({ count: accounts.length, accounts }, response_format);
1390
2542
  }
1391
2543
  case "get_account": {
1392
- const parsed = parsePayload(z3.object({ account_id: z3.number().int().positive() }), payload, action);
2544
+ const parsed = parsePayload(z4.object({ account_id: z4.number().int().positive() }), payload, action);
1393
2545
  const account = await client.getAccount(parsed.account_id);
1394
2546
  return toSuccessResponse(account, response_format);
1395
2547
  }
@@ -1403,10 +2555,10 @@ function registerTeamDynamixReferenceDataGateway(server2) {
1403
2555
  }
1404
2556
  case "list_custom_attributes": {
1405
2557
  const parsed = parsePayload(
1406
- z3.object({
2558
+ z4.object({
1407
2559
  component_id: CustomAttributeComponentIdSchema,
1408
2560
  app_id: TeamDynamixAppIdSchema.optional(),
1409
- associated_type_id: z3.number().int().positive().optional()
2561
+ associated_type_id: z4.number().int().positive().optional()
1410
2562
  }),
1411
2563
  payload,
1412
2564
  action
@@ -1512,9 +2664,13 @@ function registerTeamDynamixResources(server2) {
1512
2664
  }
1513
2665
 
1514
2666
  // src/tools/teamdynamix.watch.tools.ts
1515
- import { z as z4 } from "zod";
1516
- var WatchKindSchema = z4.enum(["mine", "watching", "waiting-on-others"]);
1517
- var BallSchema = z4.enum(["us", "them"]);
2667
+ init_constants();
2668
+ import { z as z5 } from "zod";
2669
+ init_client_factory();
2670
+ init_watch_store();
2671
+ init_watch_service();
2672
+ var WatchKindSchema = z5.enum(["mine", "watching", "waiting-on-others"]);
2673
+ var BallSchema = z5.enum(["us", "them"]);
1518
2674
  function messageFromError2(error) {
1519
2675
  return error instanceof Error ? error.message : String(error);
1520
2676
  }
@@ -1547,7 +2703,7 @@ function registerTeamDynamixWatchTools(server2) {
1547
2703
  title: "Watch Check",
1548
2704
  description: "Diff pass over the watch ledger: sweeps queue searches per app, deep-fetches only changed tickets, and returns classified deltas (status, new-entry, hidden-reply, ownership, sla, hold-window).",
1549
2705
  inputSchema: {
1550
- tickets: z4.array(z4.number().int().positive()).optional().describe("Restrict the check to these ticket IDs."),
2706
+ tickets: z5.array(z5.number().int().positive()).optional().describe("Restrict the check to these ticket IDs."),
1551
2707
  response_format: TeamDynamixResponseFormatSchema
1552
2708
  },
1553
2709
  annotations: { ...readOnly }
@@ -1583,8 +2739,8 @@ function registerTeamDynamixWatchTools(server2) {
1583
2739
  title: "Watch Triage Queue",
1584
2740
  description: "Local triage queue (never calls TDX). op=queue lists pending tickets needing background triage; op=done removes a ticket after the agent has reviewed it and updated notes.",
1585
2741
  inputSchema: {
1586
- op: z4.enum(["queue", "done"]),
1587
- ticket_id: z4.number().int().positive().optional().describe("Required for op=done."),
2742
+ op: z5.enum(["queue", "done"]),
2743
+ ticket_id: z5.number().int().positive().optional().describe("Required for op=done."),
1588
2744
  response_format: TeamDynamixResponseFormatSchema
1589
2745
  },
1590
2746
  annotations: { ...readOnly, openWorldHint: false }
@@ -1605,13 +2761,13 @@ function registerTeamDynamixWatchTools(server2) {
1605
2761
  title: "Watch Register",
1606
2762
  description: "Add/update a ledger row when a ticket is claimed, re-scoped, or swept in. Never calls TDX.",
1607
2763
  inputSchema: {
1608
- app_id: z4.number().int().positive().describe("Ticketing application ID."),
1609
- id: z4.number().int().positive().describe("Ticket ID."),
2764
+ app_id: z5.number().int().positive().describe("Ticketing application ID."),
2765
+ id: z5.number().int().positive().describe("Ticket ID."),
1610
2766
  kind: WatchKindSchema.describe("Lane: mine, watching, or waiting-on-others."),
1611
- title: z4.string().max(200).optional().describe("Short title (stored locally only)."),
1612
- district: z4.string().max(100).optional().describe("District/lane label."),
2767
+ title: z5.string().max(200).optional().describe("Short title (stored locally only)."),
2768
+ district: z5.string().max(100).optional().describe("District/lane label."),
1613
2769
  ball: BallSchema.optional().describe("Manual ball-in-court override (survives auto-inference)."),
1614
- next_action: z4.string().max(500).optional().describe("Next action note."),
2770
+ next_action: z5.string().max(500).optional().describe("Next action note."),
1615
2771
  response_format: TeamDynamixResponseFormatSchema
1616
2772
  },
1617
2773
  annotations: { ...readOnly, openWorldHint: false }
@@ -1636,8 +2792,8 @@ function registerTeamDynamixWatchTools(server2) {
1636
2792
  title: "Watch Archive",
1637
2793
  description: "Move a confirmed-closed row to the archive section. Memory (notes) is preserved. Never calls TDX.",
1638
2794
  inputSchema: {
1639
- id: z4.number().int().positive().describe("Ticket ID."),
1640
- outcome: z4.string().max(200).optional().describe("Resolution outcome label."),
2795
+ id: z5.number().int().positive().describe("Ticket ID."),
2796
+ outcome: z5.string().max(200).optional().describe("Resolution outcome label."),
1641
2797
  response_format: TeamDynamixResponseFormatSchema
1642
2798
  },
1643
2799
  annotations: { ...readOnly, openWorldHint: false }
@@ -1650,11 +2806,11 @@ function registerTeamDynamixWatchTools(server2) {
1650
2806
  title: "Watch Notes",
1651
2807
  description: "Local-only notes attached to ledgered tickets \u2014 the server's own memory. Never written to TDX. op: add | update | delete | list.",
1652
2808
  inputSchema: {
1653
- op: z4.enum(["add", "update", "delete", "list"]),
1654
- app_id: z4.number().int().positive().optional(),
1655
- ticket_id: z4.number().int().positive().optional(),
1656
- note_id: z4.string().optional(),
1657
- text: z4.string().max(4e3).optional(),
2809
+ op: z5.enum(["add", "update", "delete", "list"]),
2810
+ app_id: z5.number().int().positive().optional(),
2811
+ ticket_id: z5.number().int().positive().optional(),
2812
+ note_id: z5.string().optional(),
2813
+ text: z5.string().max(4e3).optional(),
1658
2814
  response_format: TeamDynamixResponseFormatSchema
1659
2815
  },
1660
2816
  annotations: { ...readOnly, openWorldHint: false }
@@ -1708,9 +2864,9 @@ function startWatchSweepTimer() {
1708
2864
  const secs = Number(process.env["TEAMDYNAMIX_WATCH_SWEEP_SECS"] ?? 0);
1709
2865
  if (!Number.isFinite(secs) || secs <= 0) return;
1710
2866
  const timer = setInterval(() => {
1711
- import("./watch.store-TMX6RTON.js").then(async ({ loadLedger: loadLedger2, saveLedger, emptyLedger: emptyLedger2, defaultLedgerPath: defaultLedgerPath2, LedgerCorruptError: LedgerCorruptError2 }) => {
1712
- const { createConfiguredTeamDynamixClient: createConfiguredTeamDynamixClient2 } = await import("./client.service-B22MXWP4.js");
1713
- const { WorkspaceWatchService: WorkspaceWatchService2 } = await import("./watch.service-D367V6RC.js");
2867
+ Promise.resolve().then(() => (init_watch_store(), watch_store_exports)).then(async ({ loadLedger: loadLedger2, saveLedger: saveLedger2, emptyLedger: emptyLedger2, defaultLedgerPath: defaultLedgerPath2, LedgerCorruptError: LedgerCorruptError2 }) => {
2868
+ const { createConfiguredTeamDynamixClient: createConfiguredTeamDynamixClient2 } = await Promise.resolve().then(() => (init_client_service(), client_service_exports));
2869
+ const { WorkspaceWatchService: WorkspaceWatchService2 } = await Promise.resolve().then(() => (init_watch_service(), watch_service_exports));
1714
2870
  const ledgerPath = defaultLedgerPath2();
1715
2871
  let ledger;
1716
2872
  try {