@voxslopuli/teamdynamix-mcp 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,36 +1,1183 @@
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.1",
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.2.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.POST("/api/{appId}/tickets/search", {
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/{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 post = s.POST;
532
+ const { data, error } = await post("/api/{appId}/knowledgebase/search", {
533
+ params: { path: { appId } },
534
+ body: sanitizeTo(body, ARTICLE_SEARCH_KEYS)
535
+ });
536
+ if (error) {
537
+ throw new Error(`KB search failed: ${JSON.stringify(error)}`);
538
+ }
539
+ return Array.isArray(data) ? data : [];
540
+ });
541
+ }
542
+ listKbCategories(appId) {
543
+ return this.sdk().then(
544
+ (s) => s.knowledgeBase.appIdKnowledgebaseCategories({ params: { path: { appId } } })
545
+ );
546
+ }
547
+ //
548
+ // Assets
549
+ //
550
+ getAsset(appId, assetId) {
551
+ return this.sdk().then((s) => s.assets.appIdAssetsId({ params: { path: { appId, id: assetId } } }));
552
+ }
553
+ searchAssets(appId, _body) {
554
+ return this.sdk().then((s) => s.assets.appIdAssetsFeed({ params: { path: { appId } } }));
555
+ }
556
+ listAssetStatuses(appId) {
557
+ return this.sdk().then((s) => s.assets.appIdAssetsStatuses({ params: { path: { appId } } }));
558
+ }
559
+ listProductModels(appId) {
560
+ return this.sdk().then((s) => s.assets.appIdAssetsModels({ params: { path: { appId } } }));
561
+ }
562
+ listVendors(appId) {
563
+ return this.sdk().then((s) => s.cmdb.appIdAssetsVendors({ params: { path: { appId } } }));
564
+ }
565
+ //
566
+ // CMDB
567
+ //
568
+ getConfigurationItem(appId, ciId) {
569
+ return this.sdk().then((s) => s.cmdb.appIdCmdbId({ params: { path: { appId, id: ciId } } }));
570
+ }
571
+ searchConfigurationItems(appId, _body) {
572
+ return this.sdk().then((s) => s.cmdb.appIdCmdbSearches({ params: { path: { appId } } }));
573
+ }
574
+ listCiTypes(appId) {
575
+ return this.sdk().then((s) => s.cmdb.appIdCmdbTypes({ params: { path: { appId } } }));
576
+ }
577
+ listCiRelationshipTypes() {
578
+ return this.sdk().then((s) => s.cmdb.appIdCmdbRelationshiptypes());
579
+ }
580
+ //
581
+ // Services
582
+ //
583
+ listServiceCatalog(appId) {
584
+ return this.sdk().then((s) => s.services.appIdServices({ params: { path: { appId } } }));
585
+ }
586
+ getService(appId, serviceId) {
587
+ return this.sdk().then((s) => s.services.appIdServicesId({ params: { path: { appId, id: serviceId } } }));
588
+ }
589
+ searchServices(appId, body) {
590
+ const keyword = typeof body["Keyword"] === "string" ? body["Keyword"] : "";
591
+ return this.sdk().then((s) => s.services.appIdServices({ params: { path: { appId } } })).then((r) => {
592
+ if (!Array.isArray(r)) return [];
593
+ if (!keyword) return r;
594
+ const lower = keyword.toLowerCase();
595
+ return r.filter((item) => {
596
+ const text = typeof item === "object" && item !== null ? JSON.stringify(item).toLowerCase() : "";
597
+ return text.includes(lower);
598
+ });
599
+ });
600
+ }
601
+ listServiceCategories(appId) {
602
+ return this.sdk().then((s) => s.services.appIdServicesCategories({ params: { path: { appId } } }));
603
+ }
604
+ //
605
+ // Projects
606
+ //
607
+ getProject(projectId) {
608
+ return this.sdk().then((s) => s.projects.projectsId({ params: { path: { id: projectId } } }));
609
+ }
610
+ searchProjects(_body) {
611
+ return this.sdk().then((s) => s.projects.projectsFeed());
612
+ }
613
+ listProjectTypes() {
614
+ return this.sdk().then((s) => s.projects.projectsTypes());
615
+ }
616
+ getProjectPlans(projectId) {
617
+ return this.sdk().then(
618
+ (s) => s.projects.projectsProjectIDPlansPlanID({ params: { path: { id: projectId } } })
619
+ );
620
+ }
621
+ getProjectIssues(projectId) {
622
+ return this.sdk().then(
623
+ (s) => s.projects.projectsProjectIdIssuesCategories({ params: { path: { id: projectId } } })
624
+ );
625
+ }
626
+ getProjectRisks(projectId) {
627
+ return this.sdk().then(
628
+ (s) => s.projects.projectsProjectIdRisksCategories({ params: { path: { id: projectId } } })
629
+ );
630
+ }
631
+ //
632
+ // Time
633
+ //
634
+ listTimeTypes() {
635
+ return this.sdk().then((s) => s.time.timeTypes());
636
+ }
637
+ getMyTimeEntries(_startDate, _endDate) {
638
+ return this.sdk().then((s) => s.time.timeId({ params: { path: { id: 0 } } }));
639
+ }
640
+ //
641
+ // Reference Data
642
+ //
643
+ listAccounts(_appId) {
644
+ return this.sdk().then((s) => s.referenceData.accounts());
645
+ }
646
+ getAccount(accountId) {
647
+ return this.sdk().then((s) => s.referenceData.accountsId({ params: { path: { id: accountId } } }));
648
+ }
649
+ listLocations() {
650
+ return this.sdk().then((s) => s.referenceData.locations());
651
+ }
652
+ listFunctionalRoles() {
653
+ return this.sdk().then((s) => s.referenceData.securityrolesPermissions());
654
+ }
655
+ listCustomAttributes(_componentId, _appId, _associatedTypeId) {
656
+ return this.sdk().then((s) => s.referenceData.attributesCustom());
657
+ }
658
+ listTicketStatuses(appId) {
659
+ return this.sdk().then((s) => s.referenceData.appIdTicketsStatuses({ params: { path: { appId } } }));
660
+ }
661
+ //
662
+ // Mutations
663
+ //
664
+ createTicket(appId, body, _notifyRequestor, _notifyResponsible) {
665
+ return this.sdk().then((s) => s.tickets.createTicket({ appId, body }));
666
+ }
667
+ updateTicket(appId, ticketId, body, _notifyRequestor, _notifyResponsible, _comments, _isPrivate) {
668
+ return this.sdk().then((s) => s.tickets.updateTicket({ appId, ticketId, body }));
669
+ }
670
+ addTicketComment(appId, ticketId, body, _isPrivate, _notifyRequestor, _notifyResponsible) {
671
+ return this.sdk().then((s) => s.tickets.addTicketComment({ appId, ticketId, body: { Body: body } }));
672
+ }
673
+ createKbArticle(appId, body) {
674
+ return this.sdk().then((s) => s.knowledgeBase.createArticle({ appId, body }));
675
+ }
676
+ updateKbArticle(appId, articleId, body) {
677
+ return this.sdk().then((s) => s.knowledgeBase.updateArticle({ appId, articleId, body }));
678
+ }
679
+ createProjectIssue(_projectId, body) {
680
+ return this.sdk().then((s) => s.projects.createIssue({ body }));
681
+ }
682
+ createProjectRisk(_projectId, body) {
683
+ return this.sdk().then((s) => s.projects.createRisk({ body }));
684
+ }
685
+ //
686
+ // Delete mutations (confirm:true required for all)
687
+ //
688
+ deleteAsset(appId, assetId) {
689
+ return this.sdk().then((s) => s.assets.deleteAsset({ appId, assetId, confirm: true }));
690
+ }
691
+ deleteConfigurationItem(appId, ciId) {
692
+ return this.sdk().then((s) => s.cmdb.deleteConfigurationItem({ appId, configurationItemId: ciId, confirm: true }));
693
+ }
694
+ deleteService(appId, serviceId) {
695
+ return this.sdk().then((s) => s.services.deleteService({ appId, serviceId, confirm: true }));
696
+ }
697
+ deleteServiceCategory(appId, categoryId) {
698
+ return this.sdk().then((s) => s.services.deleteServiceCategory({ appId, categoryId, confirm: true }));
699
+ }
700
+ deleteTimeEntry(timeEntryId) {
701
+ return this.sdk().then((s) => s.time.deleteTimeEntry({ timeEntryId, confirm: true }));
702
+ }
703
+ };
704
+ }
705
+ });
706
+
707
+ // src/services/teamdynamix/watch.store.ts
708
+ var watch_store_exports = {};
709
+ __export(watch_store_exports, {
710
+ LEDGER_VERSION: () => LEDGER_VERSION,
711
+ LedgerCorruptError: () => LedgerCorruptError,
712
+ MAX_NOTE_LENGTH: () => MAX_NOTE_LENGTH,
713
+ MAX_OBSERVATIONS: () => MAX_OBSERVATIONS,
714
+ defaultLedgerPath: () => defaultLedgerPath,
715
+ emptyLedger: () => emptyLedger,
716
+ loadLedger: () => loadLedger,
717
+ saveLedger: () => saveLedger
718
+ });
719
+ import { promises as fs } from "fs";
720
+ import path from "path";
721
+ function defaultLedgerPath() {
722
+ return process.env["TDX_WATCH_LEDGER"] ?? path.join(process.cwd(), ".tdx-watch-ledger.json");
723
+ }
724
+ async function loadLedger(filePath) {
725
+ let raw;
726
+ try {
727
+ raw = await fs.readFile(filePath, "utf8");
728
+ } catch (cause) {
729
+ throw cause instanceof Error ? cause : new Error(String(cause));
730
+ }
731
+ try {
732
+ const parsed = JSON.parse(raw);
733
+ if (!Array.isArray(parsed.active) || !Array.isArray(parsed.archived)) {
734
+ throw new Error("missing active/archived arrays");
735
+ }
736
+ parsed.pendingTriage ??= [];
737
+ return parsed;
738
+ } catch (cause) {
739
+ throw new LedgerCorruptError(filePath, cause);
740
+ }
741
+ }
742
+ async function saveLedger(filePath, ledger) {
743
+ try {
744
+ await fs.access(filePath);
745
+ await loadLedger(filePath);
746
+ } catch (cause) {
747
+ if (cause instanceof LedgerCorruptError) throw cause;
748
+ }
749
+ ledger.version = LEDGER_VERSION;
750
+ const dir = path.dirname(filePath);
751
+ await fs.mkdir(dir, { recursive: true });
752
+ const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
753
+ await fs.writeFile(tmp, `${JSON.stringify(ledger, null, 2)}
754
+ `, "utf8");
755
+ await fs.rename(tmp, filePath);
756
+ }
757
+ function emptyLedger() {
758
+ return { active: [], archived: [], pendingTriage: [], sweepMeta: {} };
759
+ }
760
+ var LEDGER_VERSION, MAX_NOTE_LENGTH, MAX_OBSERVATIONS, LedgerCorruptError;
761
+ var init_watch_store = __esm({
762
+ "src/services/teamdynamix/watch.store.ts"() {
763
+ "use strict";
764
+ LEDGER_VERSION = 1;
765
+ MAX_NOTE_LENGTH = 4e3;
766
+ MAX_OBSERVATIONS = 20;
767
+ LedgerCorruptError = class extends Error {
768
+ constructor(path2, cause) {
769
+ super(
770
+ `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)}`
771
+ );
772
+ this.name = "LedgerCorruptError";
773
+ }
774
+ };
775
+ }
776
+ });
777
+
778
+ // src/services/teamdynamix/watch.service.ts
779
+ var watch_service_exports = {};
780
+ __export(watch_service_exports, {
781
+ WorkspaceWatchService: () => WorkspaceWatchService
782
+ });
783
+ function redact(text) {
784
+ return text.replace(/[\w.+-]+@[\w-]+\.[\w.-]+/g, "[redacted-email]").replace(/\b(?:\d{3}[-.\s]?){2}\d{4}\b/g, "[redacted-phone]");
785
+ }
786
+ function cap(text, max) {
787
+ if (text.length <= max) return text;
788
+ return `${text.slice(0, Math.max(0, max - 1))}\u2026`;
789
+ }
790
+ function sanitizeForReport(value) {
791
+ if (typeof value === "string") return cap(redact(value), TITLE_MAX_CHARS);
792
+ return value;
793
+ }
794
+ function computeHash(entries) {
795
+ const perEntryReplies = {};
796
+ let replyCount = 0;
797
+ let lastEntryId = 0;
798
+ for (const e of entries) {
799
+ const id = e.ID ?? 0;
800
+ const rc = e.RepliesCount ?? 0;
801
+ perEntryReplies[String(id)] = rc;
802
+ replyCount += rc;
803
+ lastEntryId = Math.max(lastEntryId, id);
804
+ }
805
+ return { lastEntryId, entryCount: entries.length, replyCount, perEntryReplies };
806
+ }
807
+ function hashGrewHiddenReplies(prev, entries) {
808
+ for (const e of entries) {
809
+ const id = String(e.ID ?? 0);
810
+ const now = e.RepliesCount ?? 0;
811
+ const before = prev.perEntryReplies[id];
812
+ if (before !== void 0 && now > before) return true;
813
+ }
814
+ return false;
815
+ }
816
+ var REPORT_MAX_CHARS, TITLE_MAX_CHARS, US_UIDS_ENV, GROUP_IDS_ENV, STATUS_IDS_ENV, DEFAULT_MAX_PENDING, UNASSIGNED_SENTINELS, WorkspaceWatchService;
817
+ var init_watch_service = __esm({
818
+ "src/services/teamdynamix/watch.service.ts"() {
819
+ "use strict";
820
+ init_watch_store();
821
+ init_client_factory();
822
+ REPORT_MAX_CHARS = 8e3;
823
+ TITLE_MAX_CHARS = 200;
824
+ US_UIDS_ENV = "TEAMDYNAMIX_US_UIDS";
825
+ GROUP_IDS_ENV = "TEAMDYNAMIX_TICKET_GROUP_IDS";
826
+ STATUS_IDS_ENV = "TEAMDYNAMIX_WATCH_STATUS_IDS";
827
+ DEFAULT_MAX_PENDING = 25;
828
+ UNASSIGNED_SENTINELS = /* @__PURE__ */ new Set(["", "unassigned"]);
829
+ WorkspaceWatchService = class {
830
+ constructor(ledger, ledgerPath, client, opts = {}) {
831
+ this.ledger = ledger;
832
+ this.ledgerPath = ledgerPath;
833
+ this.client = client;
834
+ const envUids = (process.env[US_UIDS_ENV] ?? "").split(/[,\s]+/).filter(Boolean);
835
+ this.usUids = /* @__PURE__ */ new Set([...envUids, ...opts.usUids ?? []]);
836
+ this.autoObserve = opts.autoObserve ?? process.env["TEAMDYNAMIX_AUTO_OBSERVE"] === "true";
837
+ }
838
+ ledger;
839
+ client;
840
+ ledgerPath;
841
+ usUids;
842
+ autoObserve;
843
+ usUidsFor() {
844
+ const ledgerUids = this.ledger.sweepMeta.usUids ?? [];
845
+ return /* @__PURE__ */ new Set([...this.usUids, ...ledgerUids]);
846
+ }
847
+ groupIds() {
848
+ return this.ledger.sweepMeta.groupIds ?? parseIdListEnv(process.env[GROUP_IDS_ENV]);
849
+ }
850
+ statusIds() {
851
+ return this.ledger.sweepMeta.statusIds ?? parseIdListEnv(process.env[STATUS_IDS_ENV]);
852
+ }
853
+ maxPending() {
854
+ return this.ledger.sweepMeta.maxPending ?? DEFAULT_MAX_PENDING;
855
+ }
856
+ pushPending(item) {
857
+ const queue = this.ledger.pendingTriage ??= [];
858
+ if (queue.some((p) => p.ticketId === item.ticketId)) return "deduped";
859
+ if (queue.length >= this.maxPending()) return "full";
860
+ queue.push(item);
861
+ return "queued";
862
+ }
863
+ /**
864
+ * Cheap sweep (stage 1 only): one queue search per app, client-side team
865
+ * filtering (GroupIDs is not applied server-side on queue searches), stateHash
866
+ * freshness, new-unassigned detection, and pendingTriage queue maintenance.
867
+ * Deep fetches / reply expansion are the agent's job via check() / triage.
868
+ */
869
+ async sweep() {
870
+ const result = {
871
+ swept: 0,
872
+ changedQueued: 0,
873
+ newUnassignedQueued: 0,
874
+ deduped: 0,
875
+ queueFull: 0,
876
+ unassigned: []
877
+ };
878
+ const rows = this.ledger.active;
879
+ const byApp = /* @__PURE__ */ new Map();
880
+ for (const row of rows) {
881
+ const list = byApp.get(row.appId) ?? [];
882
+ list.push(row);
883
+ byApp.set(row.appId, list);
884
+ }
885
+ const appIds = /* @__PURE__ */ new Set([...byApp.keys(), ...parseIdListEnv(process.env["TEAMDYNAMIX_WATCH_APP_IDS"])]);
886
+ const groupFilter = this.groupIds();
887
+ const statusFilter = this.statusIds();
888
+ const queue = this.ledger.pendingTriage ??= [];
889
+ const ledgeredIds = new Set(rows.map((r) => r.id));
890
+ for (const appId of appIds) {
891
+ const appRows = byApp.get(appId) ?? [];
892
+ let page;
893
+ try {
894
+ page = await this.client.searchTickets(appId, { MaxResults: 500 });
895
+ } catch {
896
+ continue;
897
+ }
898
+ for (const t of page) {
899
+ const id = Number(t["ID"]);
900
+ if (!Number.isFinite(id)) continue;
901
+ if (groupFilter.length > 0) {
902
+ const gid = Number(t["ResponsibleGroupID"]);
903
+ if (!groupFilter.includes(gid)) continue;
904
+ }
905
+ if (statusFilter.length > 0 && !statusFilter.includes(Number(t["StatusID"]))) continue;
906
+ result.swept += 1;
907
+ const row = appRows.find((r) => r.id === id);
908
+ const modified = String(t["ModifiedDate"] ?? "");
909
+ if (row && row.stateHash.modified !== "" && modified !== row.stateHash.modified) {
910
+ const outcome = this.pushPending({ ticketId: id, appId, reason: "changed", at: (/* @__PURE__ */ new Date()).toISOString() });
911
+ if (outcome === "queued") result.changedQueued += 1;
912
+ else if (outcome === "deduped") result.deduped += 1;
913
+ else result.queueFull += 1;
914
+ }
915
+ if (!ledgeredIds.has(id)) {
916
+ const responsible = String(t["ResponsibleUid"] ?? "").trim();
917
+ if (UNASSIGNED_SENTINELS.has(responsible.toLowerCase())) {
918
+ result.unassigned.push(id);
919
+ const outcome = this.pushPending({
920
+ ticketId: id,
921
+ appId,
922
+ reason: "new-unassigned",
923
+ at: (/* @__PURE__ */ new Date()).toISOString(),
924
+ detail: `group=${String(t["ResponsibleGroupName"] ?? "")}`
925
+ });
926
+ if (outcome === "queued") result.newUnassignedQueued += 1;
927
+ else if (outcome === "deduped") result.deduped += 1;
928
+ else result.queueFull += 1;
929
+ }
930
+ }
931
+ }
932
+ for (const row of appRows) {
933
+ const t = page.find((x) => Number(x["ID"]) === row.id);
934
+ if (t) row.stateHash.modified = String(t["ModifiedDate"] ?? row.stateHash.modified);
935
+ }
936
+ }
937
+ this.ledger.sweepMeta.lastSweep = (/* @__PURE__ */ new Date()).toISOString();
938
+ await this.persist();
939
+ return result;
940
+ }
941
+ pendingTriage() {
942
+ return this.ledger.pendingTriage ?? [];
943
+ }
944
+ async markTriaged(ticketId) {
945
+ const queue = this.ledger.pendingTriage ?? [];
946
+ const before = queue.length;
947
+ this.ledger.pendingTriage = queue.filter((p) => p.ticketId !== ticketId);
948
+ await this.persist();
949
+ return { removed: this.ledger.pendingTriage.length < before };
950
+ }
951
+ async persist() {
952
+ await saveLedger(this.ledgerPath, this.ledger);
953
+ this.ledger = await loadLedger(this.ledgerPath);
954
+ }
955
+ findRow(id) {
956
+ return this.ledger.active.find((r) => r.id === id);
957
+ }
958
+ async register(input) {
959
+ const existing = this.findRow(input.id);
960
+ if (existing) {
961
+ existing.kind = input.kind;
962
+ if (input.title !== void 0) existing.title = cap(redact(input.title), TITLE_MAX_CHARS);
963
+ if (input.district !== void 0) existing.district = input.district;
964
+ if (input.nextAction !== void 0) existing.nextAction = input.nextAction;
965
+ if (input.ball !== void 0) {
966
+ existing.ball = input.ball;
967
+ existing.ballSource = "manual";
968
+ }
969
+ await this.persist();
970
+ return existing;
971
+ }
972
+ const row = {
973
+ id: input.id,
974
+ appId: input.appId,
975
+ title: cap(redact(input.title ?? ""), TITLE_MAX_CHARS),
976
+ district: input.district ?? "",
977
+ kind: input.kind,
978
+ status: "",
979
+ stateHash: { modified: "", lastEntryId: 0, entryCount: 0, replyCount: 0, perEntryReplies: {} },
980
+ ball: input.ball ?? "us",
981
+ ballSource: input.ball !== void 0 ? "manual" : "auto",
982
+ nextAction: input.nextAction ?? "",
983
+ lastChecked: "",
984
+ memory: { notes: [], observations: [] }
985
+ };
986
+ this.ledger.active.push(row);
987
+ await this.persist();
988
+ return row;
989
+ }
990
+ async archive(input) {
991
+ const idx = this.ledger.active.findIndex((r) => r.id === input.id);
992
+ if (idx === -1) return { archived: false };
993
+ const [row] = this.ledger.active.splice(idx, 1);
994
+ this.ledger.archived.push({ ...row, outcome: input.outcome });
995
+ await this.persist();
996
+ return { archived: true };
997
+ }
998
+ async status() {
999
+ const active = this.ledger.active;
1000
+ const oldestChecked = active.map((r) => r.lastChecked).filter(Boolean).sort()[0] ?? "";
1001
+ return {
1002
+ activeCount: active.length,
1003
+ archivedCount: this.ledger.archived.length,
1004
+ ballUs: active.filter((r) => r.ball === "us").length,
1005
+ ballThem: active.filter((r) => r.ball === "them").length,
1006
+ oldestChecked
1007
+ };
1008
+ }
1009
+ async check(input = {}) {
1010
+ const report = { checked: 0, deltas: [], errors: [] };
1011
+ const rows = this.ledger.active.filter((r) => input.tickets ? input.tickets.includes(r.id) : true);
1012
+ const byApp = /* @__PURE__ */ new Map();
1013
+ for (const row of rows) {
1014
+ const list = byApp.get(row.appId) ?? [];
1015
+ list.push(row);
1016
+ byApp.set(row.appId, list);
1017
+ }
1018
+ for (const [appId, appRows] of byApp) {
1019
+ let sweep;
1020
+ try {
1021
+ sweep = await this.client.searchTickets(appId, { MaxResults: 500 });
1022
+ } catch (cause) {
1023
+ report.errors.push(`sweep failed for appId ${appId}: ${String(cause)}`);
1024
+ continue;
1025
+ }
1026
+ const sweepById = new Map(sweep.map((t) => [Number(t["ID"]), t]));
1027
+ for (const row of appRows) {
1028
+ report.checked += 1;
1029
+ const sweepTicket = sweepById.get(row.id);
1030
+ const sweepModified = sweepTicket ? String(sweepTicket["ModifiedDate"] ?? "") : "";
1031
+ const seeded = row.stateHash.modified !== "";
1032
+ const needsDeep = !seeded || sweepModified !== row.stateHash.modified;
1033
+ if (seeded && !needsDeep) continue;
1034
+ const classes = /* @__PURE__ */ new Set();
1035
+ try {
1036
+ const t = sweepTicket ?? await this.client.getTicket(appId, row.id);
1037
+ const feed = await this.client.getTicketFeed(appId, row.id);
1038
+ const modified = String(t["ModifiedDate"] ?? "");
1039
+ const status = String(t["Status"] ?? t["StatusID"] ?? "");
1040
+ const isOnHold = Boolean(t["IsOnHold"]);
1041
+ if (seeded && status !== row.status) classes.add("status");
1042
+ if (seeded && Boolean(t["IsOnHold"]) !== row.status.startsWith("hold:")) {
1043
+ }
1044
+ if (seeded && modified !== row.stateHash.modified) classes.add("new-entry");
1045
+ const prevHash = row.stateHash;
1046
+ const newHash = { modified, ...computeHash(feed) };
1047
+ if (seeded && hashGrewHiddenReplies(prevHash, feed)) classes.add("hidden-reply");
1048
+ if (seeded && newHash.entryCount > prevHash.entryCount) classes.add("new-entry");
1049
+ if (seeded && isOnHold !== row.wasOnHold) {
1050
+ classes.add("hold-window");
1051
+ }
1052
+ const slaDate = t["SlaCompleteByDate"];
1053
+ if (seeded && typeof slaDate === "string" && slaDate !== row.slaDate) {
1054
+ classes.add("sla");
1055
+ row.slaDate = slaDate;
1056
+ }
1057
+ row.wasOnHold = isOnHold;
1058
+ if (row.ballSource === "auto" && feed.length > 0) {
1059
+ const last = feed[0];
1060
+ const author = String(last?.CreatedUid ?? "");
1061
+ if (author) row.ball = this.usUidsFor().has(author) ? "them" : "us";
1062
+ }
1063
+ row.stateHash = newHash;
1064
+ row.status = status;
1065
+ if (typeof t["Title"] === "string" && row.title === "") {
1066
+ row.title = cap(redact(t["Title"]), TITLE_MAX_CHARS);
1067
+ }
1068
+ row.lastChecked = (/* @__PURE__ */ new Date()).toISOString();
1069
+ if (this.autoObserve) {
1070
+ row.memory.observations.push({ at: row.lastChecked, seen: { status, modified } });
1071
+ if (row.memory.observations.length > MAX_OBSERVATIONS) {
1072
+ row.memory.observations = row.memory.observations.slice(-MAX_OBSERVATIONS);
1073
+ }
1074
+ }
1075
+ if (classes.size > 0) {
1076
+ report.deltas.push({
1077
+ id: row.id,
1078
+ appId,
1079
+ classes: [...classes],
1080
+ status: sanitizeForReport(status),
1081
+ modified,
1082
+ ball: row.ball
1083
+ });
1084
+ }
1085
+ } catch (cause) {
1086
+ report.errors.push(`deep fetch failed for ticket ${row.id}: ${String(cause)}`);
1087
+ }
1088
+ }
1089
+ }
1090
+ this.ledger.sweepMeta.lastSweep = (/* @__PURE__ */ new Date()).toISOString();
1091
+ await this.persist();
1092
+ return this.capReport(report);
1093
+ }
1094
+ capReport(report) {
1095
+ let json = JSON.stringify(report);
1096
+ if (json.length > REPORT_MAX_CHARS) {
1097
+ report.deltas = report.deltas.slice(0, Math.max(1, Math.floor(report.deltas.length / 2)));
1098
+ json = JSON.stringify(report);
1099
+ if (json.length > REPORT_MAX_CHARS) report.deltas = [];
1100
+ }
1101
+ return report;
1102
+ }
1103
+ //
1104
+ // Notes (local-only memory; never written to TDX)
1105
+ //
1106
+ async notesAdd(input) {
1107
+ const row = this.rowForNote(input.appId, input.ticketId);
1108
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1109
+ const note = {
1110
+ id: `n-${now}-${Math.random().toString(36).slice(2, 8)}`,
1111
+ text: cap(redact(input.text), MAX_NOTE_LENGTH),
1112
+ createdAt: now,
1113
+ updatedAt: now
1114
+ };
1115
+ row.memory.notes.unshift(note);
1116
+ await this.persist();
1117
+ return note;
1118
+ }
1119
+ async notesUpdate(input) {
1120
+ const { row, note } = this.noteById(input.noteId);
1121
+ note.text = cap(redact(input.text), MAX_NOTE_LENGTH);
1122
+ note.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
1123
+ await this.persist();
1124
+ return note;
1125
+ }
1126
+ async notesDelete(input) {
1127
+ const { row } = this.noteById(input.noteId);
1128
+ row.memory.notes = row.memory.notes.filter((n) => n.id !== input.noteId);
1129
+ await this.persist();
1130
+ return { deleted: true };
1131
+ }
1132
+ async notesList(input) {
1133
+ const rows = this.ledger.active.filter(
1134
+ (r) => (input.appId === void 0 || r.appId === input.appId) && (input.ticketId === void 0 || r.id === input.ticketId)
1135
+ );
1136
+ return rows.flatMap((r) => r.memory.notes);
1137
+ }
1138
+ rowForNote(appId, ticketId) {
1139
+ const row = this.ledger.active.find((r) => r.id === ticketId && r.appId === appId);
1140
+ if (!row) throw new Error(`No active watch row for ticket ${ticketId} in app ${appId}; register it first.`);
1141
+ return row;
1142
+ }
1143
+ noteById(noteId) {
1144
+ for (const row of [...this.ledger.active, ...this.ledger.archived]) {
1145
+ const note = row.memory.notes.find((n) => n.id === noteId);
1146
+ if (note) return { row, note };
1147
+ }
1148
+ throw new Error(`Note ${noteId} not found.`);
1149
+ }
1150
+ };
1151
+ }
1152
+ });
1153
+
1154
+ // src/services/teamdynamix/client.service.ts
1155
+ var client_service_exports = {};
1156
+ __export(client_service_exports, {
1157
+ UnifiedTeamDynamixClient: () => UnifiedTeamDynamixClient,
1158
+ assertDeleteToolsEnabled: () => assertDeleteToolsEnabled,
1159
+ assertWriteToolsEnabled: () => assertWriteToolsEnabled,
1160
+ createConfiguredTeamDynamixClient: () => createConfiguredTeamDynamixClient
1161
+ });
1162
+ var init_client_service = __esm({
1163
+ "src/services/teamdynamix/client.service.ts"() {
1164
+ "use strict";
1165
+ init_client_factory();
1166
+ }
1167
+ });
25
1168
 
26
1169
  // src/index.ts
1170
+ init_config();
1171
+ init_constants();
27
1172
  import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
28
1173
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
29
1174
 
30
1175
  // src/resources/teamdynamix.resources.ts
1176
+ init_config();
31
1177
  import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
32
1178
 
33
1179
  // src/services/teamdynamix/core.service.ts
1180
+ init_constants();
34
1181
  function redactTeamDynamixConfig(config) {
35
1182
  return {
36
1183
  baseUrl: config.baseUrl ?? null,
@@ -50,231 +1197,237 @@ function redactTeamDynamixConfig(config) {
50
1197
  }
51
1198
 
52
1199
  // src/tools/teamdynamix.domain-gateways.tools.ts
53
- import { z as z3 } from "zod";
1200
+ init_config();
1201
+ init_constants();
1202
+ import { z as z4 } from "zod";
54
1203
 
55
1204
  // src/schemas/teamdynamix/index.ts
56
- import { z as z2 } from "zod";
1205
+ import { z as z3 } from "zod";
57
1206
 
58
1207
  // 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.");
1208
+ import { z as z2 } from "zod";
1209
+ var ResponseFormatSchema = z2.enum(["markdown", "json"]).default("markdown").describe("Output format for the response.");
1210
+ var TextTransformModeSchema = z2.enum(["uppercase", "lowercase", "trim", "slug"]).describe("Transformation mode to apply to the input text.");
62
1211
 
63
1212
  // src/schemas/teamdynamix/index.ts
64
- var TeamDynamixAppIdSchema = z2.number().int().positive().describe("TeamDynamix application ID.");
65
- var IsoDateSchema = z2.string().regex(
1213
+ var TeamDynamixAppIdSchema = z3.number().int().positive().describe("TeamDynamix application ID.");
1214
+ var IsoDateSchema = z3.string().regex(
66
1215
  /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,
67
1216
  "Must be a valid ISO 8601 date string."
68
1217
  );
69
- var TeamDynamixGuidSchema = z2.string().uuid().describe("TeamDynamix GUID identifier.");
1218
+ var TeamDynamixGuidSchema = z3.string().uuid().describe("TeamDynamix GUID identifier.");
70
1219
  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."),
1220
+ var TicketSearchSchema = z3.object({
1221
+ Keywords: z3.string().max(500).optional().describe("Full-text search term."),
1222
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(50).describe("Maximum results to return (1\u20131000)."),
1223
+ StatusIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket status IDs."),
1224
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket type IDs."),
1225
+ PriorityIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket priority IDs."),
1226
+ UrgencyIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket urgency IDs."),
1227
+ ImpactIDs: z3.array(z3.number().int()).optional().describe("Filter by ticket impact IDs."),
1228
+ AccountIDs: z3.array(z3.number().int()).optional().describe("Filter by account/department IDs."),
1229
+ ResponsibleGroupIDs: z3.array(z3.number().int()).optional().describe("Filter by responsible group IDs."),
1230
+ ResponsibleUids: z3.array(z3.string().uuid()).optional().describe("Filter by responsible user GUIDs."),
1231
+ RequestorUids: z3.array(z3.string().uuid()).optional().describe("Filter by requestor user GUIDs."),
83
1232
  CreatedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for creation date filter."),
84
1233
  CreatedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for creation date filter."),
85
1234
  ModifiedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for last-modified filter."),
86
1235
  ModifiedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for last-modified filter."),
87
1236
  ClosedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for closed date filter."),
88
1237
  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.")
1238
+ SortBy: z3.string().max(100).optional().describe("Field name to sort results by."),
1239
+ SortOrder: z3.enum(["A", "D"]).optional().describe("Sort order: A = ascending, D = descending.")
91
1240
  });
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()
1241
+ var TicketCreateSchema = z3.object({
1242
+ TypeID: z3.number().int().positive().describe("Ticket type ID."),
1243
+ Title: z3.string().min(1).max(500).describe("Ticket title/subject."),
1244
+ AccountID: z3.number().int().positive().optional().describe("Account/department ID."),
1245
+ StatusID: z3.number().int().nonnegative().optional().describe("Initial ticket status ID."),
1246
+ PriorityID: z3.number().int().nonnegative().optional().describe("Ticket priority ID."),
1247
+ UrgencyID: z3.number().int().nonnegative().optional().describe("Ticket urgency ID."),
1248
+ ImpactID: z3.number().int().nonnegative().optional().describe("Ticket impact ID."),
1249
+ SourceID: z3.number().int().nonnegative().optional().describe("Ticket source ID."),
1250
+ Description: z3.string().max(65535).optional().describe("Full description/body of the ticket (HTML supported)."),
1251
+ RequestorUID: z3.string().uuid().optional().describe("GUID of the requestor."),
1252
+ ResponsibleUID: z3.string().uuid().optional().describe("GUID of the responsible technician."),
1253
+ ResponsibleGroupID: z3.number().int().positive().optional().describe("Responsible group ID."),
1254
+ FormID: z3.number().int().positive().optional().describe("Ticket form ID."),
1255
+ Attributes: z3.array(
1256
+ z3.object({
1257
+ ID: z3.number().int(),
1258
+ Value: z3.string()
110
1259
  })
111
1260
  ).optional().describe("Custom attribute values.")
112
1261
  });
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(
1262
+ var TicketPatchSchema = z3.object({
1263
+ TicketID: z3.number().int().positive().describe("Ticket ID to update."),
1264
+ 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
1265
  '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
1266
  ),
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.")
1267
+ NotifyRequestor: z3.boolean().optional().default(false).describe("Notify the requestor of the change."),
1268
+ NotifyResponsible: z3.boolean().optional().default(false).describe("Notify the responsible technician of the change."),
1269
+ Comments: z3.string().max(65535).optional().describe("Comment to attach to this update."),
1270
+ IsPrivate: z3.boolean().optional().default(false).describe("Whether the comment is private.")
122
1271
  });
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.")
1272
+ var TicketCommentSchema = z3.object({
1273
+ TicketID: z3.number().int().positive().describe("Ticket ID to comment on."),
1274
+ Body: z3.string().min(1).max(65535).describe("Comment body (HTML supported)."),
1275
+ IsPrivate: z3.boolean().optional().default(false).describe("Whether this comment is private."),
1276
+ NotifyRequestor: z3.boolean().optional().default(false).describe("Notify the requestor."),
1277
+ NotifyResponsible: z3.boolean().optional().default(false).describe("Notify the responsible technician.")
129
1278
  });
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.")
1279
+ var UserSearchSchema = z3.object({
1280
+ SearchText: z3.string().max(500).optional().describe("Name, username, or email to search for."),
1281
+ AccountIDs: z3.array(z3.number().int()).optional().describe("Filter by account IDs (default account only)."),
1282
+ AlternateID: z3.string().optional().describe("Filter by alternate ID."),
1283
+ AppName: z3.string().optional().describe("Filter by system-defined application name."),
1284
+ AuthenticationUserName: z3.string().optional().describe("Exact-match authentication username (max one result)."),
1285
+ ExternalID: z3.string().optional().describe("Filter by external ID."),
1286
+ IsActive: z3.boolean().optional().describe("Filter by active (true) or inactive (false) users."),
1287
+ IsConfidential: z3.boolean().optional().describe("Filter by confidential status."),
1288
+ IsEmployee: z3.boolean().optional().describe("Filter to employees only."),
1289
+ MaxResults: z3.number().int().min(1).max(1e3).optional().describe("Maximum results (1-1000)."),
1290
+ PhoneNumber: z3.string().optional().describe("Filter by phone number."),
1291
+ ReferenceIDs: z3.array(z3.string()).optional().describe("Filter by user reference IDs (GUIDs)."),
1292
+ SecurityRoleID: z3.number().int().optional().describe("Filter by security role ID."),
1293
+ UserName: z3.string().optional().describe("Filter by username.")
145
1294
  }).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.")
1295
+ var GroupSearchSchema = z3.object({
1296
+ NameLike: z3.string().max(500).optional().describe("Partial group name to search."),
1297
+ IsActive: z3.boolean().optional().describe("Filter by active (true) or inactive (false) groups."),
1298
+ AssociatedAppID: z3.number().int().positive().optional().describe("Filter by associated application ID."),
1299
+ HasAppID: z3.boolean().optional().describe("Filter to groups with (true) or without (false) an associated application."),
1300
+ HasSystemAppName: z3.boolean().optional().describe("Filter to groups with (true) or without (false) a system app name.")
152
1301
  }).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.")
1302
+ var KbArticleSearchSchema = z3.object({
1303
+ SearchText: z3.string().max(500).optional().describe("Full-text search within articles."),
1304
+ AuthorUID: z3.string().uuid().optional().describe("Filter by author GUID."),
1305
+ CategoryID: z3.number().int().positive().optional().describe("Filter by KB category ID."),
1306
+ CustomAttributes: z3.array(z3.record(z3.string(), z3.unknown())).optional().describe("Filter by custom attributes."),
1307
+ IncludeArticleBodies: z3.boolean().optional().describe("Include article bodies in results."),
1308
+ IncludeShortcuts: z3.boolean().optional().describe("Include shortcuts in results."),
1309
+ IsPublic: z3.boolean().optional().describe("Filter by public visibility."),
1310
+ IsPublished: z3.boolean().optional().describe("Filter to published articles only."),
1311
+ ReturnCount: z3.number().int().min(1).max(500).optional().describe("Maximum results (1-500)."),
1312
+ Status: z3.number().int().optional().describe("Filter by article status ID.")
164
1313
  }).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).")
1314
+ var AssetSearchSchema = z3.object({
1315
+ SerialLike: z3.string().max(200).optional().describe("Partial serial number to match."),
1316
+ TagLike: z3.string().max(200).optional().describe("Partial asset tag to match."),
1317
+ SearchText: z3.string().max(500).optional().describe("General text search across asset fields."),
1318
+ StatusIDs: z3.array(z3.number().int()).optional().describe("Filter by asset status IDs."),
1319
+ OwnerUID: z3.string().uuid().optional().describe("Filter by asset owner GUID."),
1320
+ UsingDepartmentID: z3.number().int().positive().optional().describe("Filter by using department ID."),
1321
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
173
1322
  });
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).")
1323
+ var ServiceSearchSchema = z3.object({
1324
+ SearchText: z3.string().max(500).optional().describe("Full-text search across service fields."),
1325
+ IsActive: z3.boolean().optional().describe("Filter to active services only."),
1326
+ CategoryID: z3.number().int().positive().optional().describe("Filter by service category ID."),
1327
+ MaxResults: z3.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
179
1328
  });
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).")
1329
+ var ProjectSearchSchema = z3.object({
1330
+ NameLike: z3.string().max(500).optional().describe("Partial project name to search."),
1331
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by project type IDs."),
1332
+ IsActive: z3.boolean().optional().describe("Filter to active projects."),
1333
+ ManagerUID: z3.string().uuid().optional().describe("Filter by project manager GUID."),
1334
+ MaxResults: z3.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
186
1335
  });
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."),
1336
+ var TicketTaskCreateSchema = z3.object({
1337
+ TicketID: z3.number().int().positive().describe("Parent ticket ID."),
1338
+ Title: z3.string().min(1).max(500).describe("Task title."),
1339
+ Description: z3.string().max(65535).optional().describe("Task description."),
1340
+ IsActive: z3.boolean().optional().default(true).describe("Whether the task is active."),
1341
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the assigned user."),
1342
+ AssignedGroupID: z3.number().int().positive().optional().describe("Assigned group ID."),
1343
+ EstimatedMinutes: z3.number().int().nonnegative().optional().describe("Estimated minutes to complete."),
195
1344
  StartDate: IsoDateSchema.optional().describe("Task start date (ISO 8601)."),
196
1345
  EndDate: IsoDateSchema.optional().describe("Task due date (ISO 8601).")
197
1346
  });
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.")
1347
+ var KbArticleCreateSchema = z3.object({
1348
+ Subject: z3.string().min(1).max(500).describe("Article title/subject."),
1349
+ Body: z3.string().min(1).max(5e5).describe("Article body content (HTML supported)."),
1350
+ Summary: z3.string().max(2e3).optional().describe("Short article summary."),
1351
+ CategoryID: z3.number().int().positive().optional().describe("KB category ID."),
1352
+ IsPublished: z3.boolean().optional().default(false).describe("Whether to publish the article immediately."),
1353
+ Tags: z3.string().max(1e3).optional().describe("Comma-separated tags for the article.")
205
1354
  });
206
1355
  var KbArticleUpdateSchema = KbArticleCreateSchema.partial().extend({
207
- ArticleID: z2.number().int().positive().describe("KB article ID to update.")
1356
+ ArticleID: z3.number().int().positive().describe("KB article ID to update.")
208
1357
  });
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).")
1358
+ var CiSearchSchema = z3.object({
1359
+ SearchText: z3.string().max(500).optional().describe("Full-text search across CI fields."),
1360
+ TypeIDs: z3.array(z3.number().int()).optional().describe("Filter by CI type IDs."),
1361
+ OwnerUID: z3.string().uuid().optional().describe("Filter by owner GUID."),
1362
+ MaxResults: z3.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
214
1363
  });
215
- var CustomAttributeComponentIdSchema = z2.number().int().positive().describe(
1364
+ var CustomAttributeComponentIdSchema = z3.number().int().positive().describe(
216
1365
  "TeamDynamix component ID for the attribute context. Common values: 9 = Ticket, 27 = Asset, 63 = KB Article, 31 = Person."
217
1366
  );
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."),
1367
+ var ProjectIssueCreateSchema = z3.object({
1368
+ Title: z3.string().min(1).max(500).describe("Issue title."),
1369
+ Description: z3.string().max(65535).optional().describe("Issue description."),
1370
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the assigned user."),
1371
+ StatusID: z3.number().int().nonnegative().optional().describe("Issue status ID."),
1372
+ PriorityID: z3.number().int().nonnegative().optional().describe("Issue priority ID."),
224
1373
  DueDate: IsoDateSchema.optional().describe("Issue due date (ISO 8601).")
225
1374
  });
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)."),
1375
+ var ProjectRiskCreateSchema = z3.object({
1376
+ Title: z3.string().min(1).max(500).describe("Risk title."),
1377
+ Description: z3.string().max(65535).optional().describe("Risk description."),
1378
+ AssignedUID: z3.string().uuid().optional().describe("GUID of the risk owner."),
1379
+ StatusID: z3.number().int().nonnegative().optional().describe("Risk status ID."),
1380
+ Probability: z3.number().int().min(1).max(100).optional().describe("Probability percentage (1\u2013100)."),
1381
+ Impact: z3.number().int().min(1).max(5).optional().describe("Impact level (1 = low, 5 = critical)."),
233
1382
  DueDate: IsoDateSchema.optional().describe("Risk resolution due date (ISO 8601).")
234
1383
  });
235
- var TimeEntryQuerySchema = z2.object({
1384
+ var TimeEntryQuerySchema = z3.object({
236
1385
  StartDate: IsoDateSchema.describe("Start date for time entries query (ISO 8601 date, e.g. 2026-01-01)."),
237
1386
  EndDate: IsoDateSchema.describe("End date for time entries query (ISO 8601 date, e.g. 2026-01-31).")
238
1387
  });
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");
1388
+ var TeamDynamixEntitySchema = z3.record(z3.string(), z3.unknown()).describe("Base TeamDynamix entity with flexible additional fields");
1389
+ var TeamDynamixNamedEntitySchema = z3.object({
1390
+ ID: z3.number().int().positive("ID must be a positive integer"),
1391
+ Name: z3.string().optional()
1392
+ }).catchall(z3.unknown()).describe("TeamDynamix entity with ID and optional Name");
244
1393
  var TeamDynamixApplicationSchema = TeamDynamixNamedEntitySchema.extend({
245
- Name: z2.string().optional()
1394
+ Name: z3.string().optional()
246
1395
  }).describe("TeamDynamix Application entity");
247
1396
  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()
1397
+ Title: z3.string().optional(),
1398
+ Description: z3.string().optional(),
1399
+ StatusID: z3.number().int().optional(),
1400
+ TypeID: z3.number().int().optional()
252
1401
  }).describe("TeamDynamix Ticket entity");
253
1402
  var TeamDynamixKbArticleSchema = TeamDynamixNamedEntitySchema.extend({
254
- Subject: z2.string().optional(),
255
- Body: z2.string().optional(),
256
- IsPublished: z2.boolean().optional()
1403
+ Subject: z3.string().optional(),
1404
+ Body: z3.string().optional(),
1405
+ IsPublished: z3.boolean().optional()
257
1406
  }).describe("TeamDynamix Knowledge Base Article entity");
258
1407
  var TeamDynamixAssetSchema = TeamDynamixNamedEntitySchema.extend({
259
- Tag: z2.string().optional(),
260
- StatusID: z2.number().int().optional()
1408
+ Tag: z3.string().optional(),
1409
+ StatusID: z3.number().int().optional()
261
1410
  }).describe("TeamDynamix Asset entity");
262
1411
  var TeamDynamixProjectSchema = TeamDynamixNamedEntitySchema.extend({
263
- Status: z2.string().optional()
1412
+ Status: z3.string().optional()
264
1413
  }).describe("TeamDynamix Project entity");
265
1414
  var TeamDynamixGroupSchema = TeamDynamixNamedEntitySchema.extend({
266
- Description: z2.string().optional()
1415
+ Description: z3.string().optional()
267
1416
  }).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");
1417
+ var TeamDynamixUserSchema = z3.object({
1418
+ UID: z3.string({ error: "User UID is required" }),
1419
+ FullName: z3.string().optional(),
1420
+ Email: z3.string().email().optional(),
1421
+ IsActive: z3.boolean().optional()
1422
+ }).catchall(z3.unknown()).describe("TeamDynamix User entity");
1423
+ var TeamDynamixListResponseSchema = z3.array(z3.record(z3.string(), z3.unknown())).describe("Array of TeamDynamix entities");
1424
+ var TeamDynamixSingleResponseSchema = z3.record(z3.string(), z3.unknown()).describe("Single TeamDynamix entity response");
1425
+
1426
+ // src/tools/teamdynamix.domain-gateways.tools.ts
1427
+ init_client_factory();
276
1428
 
277
1429
  // src/services/teamdynamix/render.service.ts
1430
+ init_constants();
278
1431
  import { tablemark } from "tablemark";
279
1432
  function render(payload, responseFormat, characterLimit = CHARACTER_LIMIT) {
280
1433
  if (responseFormat === "json") {
@@ -386,13 +1539,13 @@ function truncateMarkdown(markdown, limit) {
386
1539
  }
387
1540
 
388
1541
  // src/tools/teamdynamix.domain-gateways.tools.ts
389
- var teamdynamixDiscoveryActionSchema = z3.enum([
1542
+ var teamdynamixDiscoveryActionSchema = z4.enum([
390
1543
  "server_status",
391
1544
  "get_current_user",
392
1545
  "list_applications",
393
1546
  "list_ticket_statuses"
394
1547
  ]);
395
- var teamdynamixTicketActionSchema = z3.enum([
1548
+ var teamdynamixTicketActionSchema = z4.enum([
396
1549
  "list_ticket_types",
397
1550
  "list_ticket_priorities",
398
1551
  "list_ticket_urgencies",
@@ -405,7 +1558,7 @@ var teamdynamixTicketActionSchema = z3.enum([
405
1558
  "add_ticket_comment",
406
1559
  "get_ticket_feed"
407
1560
  ]);
408
- var teamdynamixTicketRelationshipActionSchema = z3.enum([
1561
+ var teamdynamixTicketRelationshipActionSchema = z4.enum([
409
1562
  "get_ticket_tasks",
410
1563
  "create_ticket_task",
411
1564
  "list_ticket_assets",
@@ -415,28 +1568,28 @@ var teamdynamixTicketRelationshipActionSchema = z3.enum([
415
1568
  "add_ticket_contact",
416
1569
  "remove_ticket_contact"
417
1570
  ]);
418
- var teamdynamixPeopleActionSchema = z3.enum([
1571
+ var teamdynamixPeopleActionSchema = z4.enum([
419
1572
  "get_user",
420
1573
  "search_users",
421
1574
  "get_group",
422
1575
  "search_groups",
423
1576
  "get_group_members"
424
1577
  ]);
425
- var teamdynamixKnowledgeBaseActionSchema = z3.enum([
1578
+ var teamdynamixKnowledgeBaseActionSchema = z4.enum([
426
1579
  "get_kb_article",
427
1580
  "search_kb_articles",
428
1581
  "list_kb_categories",
429
1582
  "create_kb_article",
430
1583
  "update_kb_article"
431
1584
  ]);
432
- var teamdynamixAssetsActionSchema = z3.enum([
1585
+ var teamdynamixAssetsActionSchema = z4.enum([
433
1586
  "get_asset",
434
1587
  "search_assets",
435
1588
  "list_asset_statuses",
436
1589
  "list_product_models",
437
1590
  "delete_asset"
438
1591
  ]);
439
- var teamdynamixCmdbActionSchema = z3.enum([
1592
+ var teamdynamixCmdbActionSchema = z4.enum([
440
1593
  "get_ci",
441
1594
  "search_cis",
442
1595
  "list_ci_types",
@@ -444,7 +1597,7 @@ var teamdynamixCmdbActionSchema = z3.enum([
444
1597
  "list_vendors",
445
1598
  "delete_ci"
446
1599
  ]);
447
- var teamdynamixServicesActionSchema = z3.enum([
1600
+ var teamdynamixServicesActionSchema = z4.enum([
448
1601
  "list_services",
449
1602
  "get_service",
450
1603
  "search_services",
@@ -452,7 +1605,7 @@ var teamdynamixServicesActionSchema = z3.enum([
452
1605
  "delete_service",
453
1606
  "delete_service_category"
454
1607
  ]);
455
- var teamdynamixProjectsActionSchema = z3.enum([
1608
+ var teamdynamixProjectsActionSchema = z4.enum([
456
1609
  "get_project",
457
1610
  "search_projects",
458
1611
  "list_project_types",
@@ -462,15 +1615,15 @@ var teamdynamixProjectsActionSchema = z3.enum([
462
1615
  "create_project_issue",
463
1616
  "create_project_risk"
464
1617
  ]);
465
- var teamdynamixTimeActionSchema = z3.enum(["list_time_types", "get_my_time_entries"]);
466
- var teamdynamixReferenceDataActionSchema = z3.enum([
1618
+ var teamdynamixTimeActionSchema = z4.enum(["list_time_types", "get_my_time_entries"]);
1619
+ var teamdynamixReferenceDataActionSchema = z4.enum([
467
1620
  "list_accounts",
468
1621
  "get_account",
469
1622
  "list_locations",
470
1623
  "list_functional_roles",
471
1624
  "list_custom_attributes"
472
1625
  ]);
473
- var gatewayPayloadSchema = z3.record(z3.string(), z3.unknown()).default({});
1626
+ var gatewayPayloadSchema = z4.record(z4.string(), z4.unknown()).default({});
474
1627
  function messageFromError(error) {
475
1628
  return error instanceof Error ? error.message : String(error);
476
1629
  }
@@ -615,7 +1768,7 @@ function registerTeamDynamixDiscoveryGateway(server2) {
615
1768
  return toSuccessResponse({ count: applications.length, applications }, response_format);
616
1769
  }
617
1770
  case "list_ticket_statuses": {
618
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
1771
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
619
1772
  const config = getTeamDynamixConfig();
620
1773
  const effectiveAppId = parsed.app_id ?? config.defaultTicketAppId;
621
1774
  if (!effectiveAppId) {
@@ -651,33 +1804,33 @@ function registerTeamDynamixTicketsGateway(server2) {
651
1804
  const client = createConfiguredTeamDynamixClient();
652
1805
  switch (action) {
653
1806
  case "list_ticket_types": {
654
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1807
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
655
1808
  const types = await client.listTicketTypes(parsed.app_id);
656
1809
  return toSuccessResponse({ appId: parsed.app_id, types }, response_format);
657
1810
  }
658
1811
  case "list_ticket_priorities": {
659
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1812
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
660
1813
  const priorities = await client.listTicketPriorities(parsed.app_id);
661
1814
  return toSuccessResponse({ appId: parsed.app_id, priorities }, response_format);
662
1815
  }
663
1816
  case "list_ticket_urgencies": {
664
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1817
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
665
1818
  const urgencies = await client.listTicketUrgencies(parsed.app_id);
666
1819
  return toSuccessResponse({ appId: parsed.app_id, urgencies }, response_format);
667
1820
  }
668
1821
  case "list_ticket_impacts": {
669
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1822
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
670
1823
  const impacts = await client.listTicketImpacts(parsed.app_id);
671
1824
  return toSuccessResponse({ appId: parsed.app_id, impacts }, response_format);
672
1825
  }
673
1826
  case "list_ticket_sources": {
674
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1827
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
675
1828
  const sources = await client.listTicketSources(parsed.app_id);
676
1829
  return toSuccessResponse({ appId: parsed.app_id, sources }, response_format);
677
1830
  }
678
1831
  case "get_ticket": {
679
1832
  const parsed = parsePayload(
680
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
1833
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
681
1834
  payload,
682
1835
  action
683
1836
  );
@@ -686,7 +1839,7 @@ function registerTeamDynamixTicketsGateway(server2) {
686
1839
  }
687
1840
  case "search_tickets": {
688
1841
  const parsed = parsePayload(
689
- z3.object({ app_id: TeamDynamixAppIdSchema, search: TicketSearchSchema }),
1842
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: TicketSearchSchema }),
690
1843
  payload,
691
1844
  action
692
1845
  );
@@ -695,11 +1848,11 @@ function registerTeamDynamixTicketsGateway(server2) {
695
1848
  }
696
1849
  case "create_ticket": {
697
1850
  const parsed = parsePayload(
698
- z3.object({
1851
+ z4.object({
699
1852
  app_id: TeamDynamixAppIdSchema,
700
1853
  ticket: TicketCreateSchema,
701
- notify_requestor: z3.boolean().optional().default(false),
702
- notify_responsible: z3.boolean().optional().default(false)
1854
+ notify_requestor: z4.boolean().optional().default(false),
1855
+ notify_responsible: z4.boolean().optional().default(false)
703
1856
  }),
704
1857
  payload,
705
1858
  action
@@ -715,7 +1868,7 @@ function registerTeamDynamixTicketsGateway(server2) {
715
1868
  }
716
1869
  case "update_ticket": {
717
1870
  const parsed = parsePayload(
718
- z3.object({ app_id: TeamDynamixAppIdSchema, patch: TicketPatchSchema }),
1871
+ z4.object({ app_id: TeamDynamixAppIdSchema, patch: TicketPatchSchema }),
719
1872
  payload,
720
1873
  action
721
1874
  );
@@ -733,7 +1886,7 @@ function registerTeamDynamixTicketsGateway(server2) {
733
1886
  }
734
1887
  case "add_ticket_comment": {
735
1888
  const parsed = parsePayload(
736
- z3.object({ app_id: TeamDynamixAppIdSchema, comment: TicketCommentSchema }),
1889
+ z4.object({ app_id: TeamDynamixAppIdSchema, comment: TicketCommentSchema }),
737
1890
  payload,
738
1891
  action
739
1892
  );
@@ -750,7 +1903,7 @@ function registerTeamDynamixTicketsGateway(server2) {
750
1903
  }
751
1904
  case "get_ticket_feed": {
752
1905
  const parsed = parsePayload(
753
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
1906
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
754
1907
  payload,
755
1908
  action
756
1909
  );
@@ -786,7 +1939,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
786
1939
  switch (action) {
787
1940
  case "get_ticket_tasks": {
788
1941
  const parsed = parsePayload(
789
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
1942
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
790
1943
  payload,
791
1944
  action
792
1945
  );
@@ -798,7 +1951,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
798
1951
  }
799
1952
  case "create_ticket_task": {
800
1953
  const parsed = parsePayload(
801
- z3.object({ app_id: TeamDynamixAppIdSchema, task: TicketTaskCreateSchema }),
1954
+ z4.object({ app_id: TeamDynamixAppIdSchema, task: TicketTaskCreateSchema }),
802
1955
  payload,
803
1956
  action
804
1957
  );
@@ -812,7 +1965,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
812
1965
  }
813
1966
  case "list_ticket_assets": {
814
1967
  const parsed = parsePayload(
815
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
1968
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
816
1969
  payload,
817
1970
  action
818
1971
  );
@@ -824,10 +1977,10 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
824
1977
  }
825
1978
  case "add_ticket_asset": {
826
1979
  const parsed = parsePayload(
827
- z3.object({
1980
+ z4.object({
828
1981
  app_id: TeamDynamixAppIdSchema,
829
- ticket_id: z3.number().int().positive(),
830
- asset_id: z3.number().int().positive()
1982
+ ticket_id: z4.number().int().positive(),
1983
+ asset_id: z4.number().int().positive()
831
1984
  }),
832
1985
  payload,
833
1986
  action
@@ -838,11 +1991,11 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
838
1991
  }
839
1992
  case "remove_ticket_asset": {
840
1993
  const parsed = parsePayload(
841
- z3.object({
1994
+ z4.object({
842
1995
  app_id: TeamDynamixAppIdSchema,
843
- ticket_id: z3.number().int().positive(),
844
- asset_id: z3.number().int().positive(),
845
- confirm: z3.literal(true)
1996
+ ticket_id: z4.number().int().positive(),
1997
+ asset_id: z4.number().int().positive(),
1998
+ confirm: z4.literal(true)
846
1999
  }),
847
2000
  payload,
848
2001
  action
@@ -861,7 +2014,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
861
2014
  }
862
2015
  case "get_ticket_contacts": {
863
2016
  const parsed = parsePayload(
864
- z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
2017
+ z4.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z4.number().int().positive() }),
865
2018
  payload,
866
2019
  action
867
2020
  );
@@ -873,9 +2026,9 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
873
2026
  }
874
2027
  case "add_ticket_contact": {
875
2028
  const parsed = parsePayload(
876
- z3.object({
2029
+ z4.object({
877
2030
  app_id: TeamDynamixAppIdSchema,
878
- ticket_id: z3.number().int().positive(),
2031
+ ticket_id: z4.number().int().positive(),
879
2032
  contact_uid: TeamDynamixGuidSchema
880
2033
  }),
881
2034
  payload,
@@ -887,11 +2040,11 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
887
2040
  }
888
2041
  case "remove_ticket_contact": {
889
2042
  const parsed = parsePayload(
890
- z3.object({
2043
+ z4.object({
891
2044
  app_id: TeamDynamixAppIdSchema,
892
- ticket_id: z3.number().int().positive(),
2045
+ ticket_id: z4.number().int().positive(),
893
2046
  contact_uid: TeamDynamixGuidSchema,
894
- confirm: z3.literal(true)
2047
+ confirm: z4.literal(true)
895
2048
  }),
896
2049
  payload,
897
2050
  action
@@ -933,27 +2086,27 @@ function registerTeamDynamixPeopleGateway(server2) {
933
2086
  const client = createConfiguredTeamDynamixClient();
934
2087
  switch (action) {
935
2088
  case "get_user": {
936
- const parsed = parsePayload(z3.object({ uid: TeamDynamixGuidSchema }), payload, action);
2089
+ const parsed = parsePayload(z4.object({ uid: TeamDynamixGuidSchema }), payload, action);
937
2090
  const user = await client.getUser(parsed.uid);
938
2091
  return toSuccessResponse(user, response_format);
939
2092
  }
940
2093
  case "search_users": {
941
- const parsed = parsePayload(z3.object({ search: UserSearchSchema }), payload, action);
2094
+ const parsed = parsePayload(z4.object({ search: UserSearchSchema }), payload, action);
942
2095
  const users = await client.searchUsers(parsed.search);
943
2096
  return toSuccessResponse({ count: users.length, users }, response_format);
944
2097
  }
945
2098
  case "get_group": {
946
- const parsed = parsePayload(z3.object({ group_id: z3.number().int().positive() }), payload, action);
2099
+ const parsed = parsePayload(z4.object({ group_id: z4.number().int().positive() }), payload, action);
947
2100
  const group = await client.getGroup(parsed.group_id);
948
2101
  return toSuccessResponse(group, response_format);
949
2102
  }
950
2103
  case "search_groups": {
951
- const parsed = parsePayload(z3.object({ search: GroupSearchSchema }), payload, action);
2104
+ const parsed = parsePayload(z4.object({ search: GroupSearchSchema }), payload, action);
952
2105
  const groups = await client.searchGroups(parsed.search);
953
2106
  return toSuccessResponse({ count: groups.length, groups }, response_format);
954
2107
  }
955
2108
  case "get_group_members": {
956
- const parsed = parsePayload(z3.object({ group_id: z3.number().int().positive() }), payload, action);
2109
+ const parsed = parsePayload(z4.object({ group_id: z4.number().int().positive() }), payload, action);
957
2110
  const members = await client.getGroupMembers(parsed.group_id);
958
2111
  return toSuccessResponse({ groupId: parsed.group_id, count: members.length, members }, response_format);
959
2112
  }
@@ -983,7 +2136,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
983
2136
  switch (action) {
984
2137
  case "get_kb_article": {
985
2138
  const parsed = parsePayload(
986
- z3.object({ app_id: TeamDynamixAppIdSchema, article_id: z3.number().int().positive() }),
2139
+ z4.object({ app_id: TeamDynamixAppIdSchema, article_id: z4.number().int().positive() }),
987
2140
  payload,
988
2141
  action
989
2142
  );
@@ -992,7 +2145,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
992
2145
  }
993
2146
  case "search_kb_articles": {
994
2147
  const parsed = parsePayload(
995
- z3.object({ app_id: TeamDynamixAppIdSchema, search: KbArticleSearchSchema }),
2148
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: KbArticleSearchSchema }),
996
2149
  payload,
997
2150
  action
998
2151
  );
@@ -1000,13 +2153,13 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
1000
2153
  return toSuccessResponse({ appId: parsed.app_id, count: articles.length, articles }, response_format);
1001
2154
  }
1002
2155
  case "list_kb_categories": {
1003
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2156
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1004
2157
  const categories = await client.listKbCategories(parsed.app_id);
1005
2158
  return toSuccessResponse({ appId: parsed.app_id, count: categories.length, categories }, response_format);
1006
2159
  }
1007
2160
  case "create_kb_article": {
1008
2161
  const parsed = parsePayload(
1009
- z3.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleCreateSchema }),
2162
+ z4.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleCreateSchema }),
1010
2163
  payload,
1011
2164
  action
1012
2165
  );
@@ -1016,7 +2169,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
1016
2169
  }
1017
2170
  case "update_kb_article": {
1018
2171
  const parsed = parsePayload(
1019
- z3.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleUpdateSchema }),
2172
+ z4.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleUpdateSchema }),
1020
2173
  payload,
1021
2174
  action
1022
2175
  );
@@ -1051,7 +2204,7 @@ function registerTeamDynamixAssetsGateway(server2) {
1051
2204
  switch (action) {
1052
2205
  case "get_asset": {
1053
2206
  const parsed = parsePayload(
1054
- z3.object({ app_id: TeamDynamixAppIdSchema, asset_id: z3.number().int().positive() }),
2207
+ z4.object({ app_id: TeamDynamixAppIdSchema, asset_id: z4.number().int().positive() }),
1055
2208
  payload,
1056
2209
  action
1057
2210
  );
@@ -1060,7 +2213,7 @@ function registerTeamDynamixAssetsGateway(server2) {
1060
2213
  }
1061
2214
  case "search_assets": {
1062
2215
  const parsed = parsePayload(
1063
- z3.object({ app_id: TeamDynamixAppIdSchema, search: AssetSearchSchema }),
2216
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: AssetSearchSchema }),
1064
2217
  payload,
1065
2218
  action
1066
2219
  );
@@ -1068,21 +2221,21 @@ function registerTeamDynamixAssetsGateway(server2) {
1068
2221
  return toSuccessResponse({ appId: parsed.app_id, count: assets.length, assets }, response_format);
1069
2222
  }
1070
2223
  case "list_asset_statuses": {
1071
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2224
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1072
2225
  const statuses = await client.listAssetStatuses(parsed.app_id);
1073
2226
  return toSuccessResponse({ appId: parsed.app_id, count: statuses.length, statuses }, response_format);
1074
2227
  }
1075
2228
  case "list_product_models": {
1076
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2229
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1077
2230
  const models = await client.listProductModels(parsed.app_id);
1078
2231
  return toSuccessResponse({ appId: parsed.app_id, count: models.length, models }, response_format);
1079
2232
  }
1080
2233
  case "delete_asset": {
1081
2234
  const parsed = parsePayload(
1082
- z3.object({
2235
+ z4.object({
1083
2236
  app_id: TeamDynamixAppIdSchema,
1084
- asset_id: z3.number().int().positive(),
1085
- confirm: z3.literal(true)
2237
+ asset_id: z4.number().int().positive(),
2238
+ confirm: z4.literal(true)
1086
2239
  }),
1087
2240
  payload,
1088
2241
  action
@@ -1120,7 +2273,7 @@ function registerTeamDynamixCmdbGateway(server2) {
1120
2273
  switch (action) {
1121
2274
  case "get_ci": {
1122
2275
  const parsed = parsePayload(
1123
- z3.object({ app_id: TeamDynamixAppIdSchema, ci_id: z3.number().int().positive() }),
2276
+ z4.object({ app_id: TeamDynamixAppIdSchema, ci_id: z4.number().int().positive() }),
1124
2277
  payload,
1125
2278
  action
1126
2279
  );
@@ -1129,7 +2282,7 @@ function registerTeamDynamixCmdbGateway(server2) {
1129
2282
  }
1130
2283
  case "search_cis": {
1131
2284
  const parsed = parsePayload(
1132
- z3.object({ app_id: TeamDynamixAppIdSchema, search: CiSearchSchema }),
2285
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: CiSearchSchema }),
1133
2286
  payload,
1134
2287
  action
1135
2288
  );
@@ -1140,7 +2293,7 @@ function registerTeamDynamixCmdbGateway(server2) {
1140
2293
  return toSuccessResponse({ appId: parsed.app_id, count: results.length, results }, response_format);
1141
2294
  }
1142
2295
  case "list_ci_types": {
1143
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2296
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1144
2297
  const types = await client.listCiTypes(parsed.app_id);
1145
2298
  return toSuccessResponse({ appId: parsed.app_id, count: types.length, types }, response_format);
1146
2299
  }
@@ -1149,16 +2302,16 @@ function registerTeamDynamixCmdbGateway(server2) {
1149
2302
  return toSuccessResponse({ count: types.length, types }, response_format);
1150
2303
  }
1151
2304
  case "list_vendors": {
1152
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2305
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1153
2306
  const vendors = await client.listVendors(parsed.app_id);
1154
2307
  return toSuccessResponse({ appId: parsed.app_id, count: vendors.length, vendors }, response_format);
1155
2308
  }
1156
2309
  case "delete_ci": {
1157
2310
  const parsed = parsePayload(
1158
- z3.object({
2311
+ z4.object({
1159
2312
  app_id: TeamDynamixAppIdSchema,
1160
- ci_id: z3.number().int().positive(),
1161
- confirm: z3.literal(true)
2313
+ ci_id: z4.number().int().positive(),
2314
+ confirm: z4.literal(true)
1162
2315
  }),
1163
2316
  payload,
1164
2317
  action
@@ -1192,13 +2345,13 @@ function registerTeamDynamixServicesGateway(server2) {
1192
2345
  const client = createConfiguredTeamDynamixClient();
1193
2346
  switch (action) {
1194
2347
  case "list_services": {
1195
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2348
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1196
2349
  const services = await client.listServiceCatalog(parsed.app_id);
1197
2350
  return toSuccessResponse({ appId: parsed.app_id, count: services.length, services }, response_format);
1198
2351
  }
1199
2352
  case "get_service": {
1200
2353
  const parsed = parsePayload(
1201
- z3.object({ app_id: TeamDynamixAppIdSchema, service_id: z3.number().int().positive() }),
2354
+ z4.object({ app_id: TeamDynamixAppIdSchema, service_id: z4.number().int().positive() }),
1202
2355
  payload,
1203
2356
  action
1204
2357
  );
@@ -1207,7 +2360,7 @@ function registerTeamDynamixServicesGateway(server2) {
1207
2360
  }
1208
2361
  case "search_services": {
1209
2362
  const parsed = parsePayload(
1210
- z3.object({ app_id: TeamDynamixAppIdSchema, search: ServiceSearchSchema }),
2363
+ z4.object({ app_id: TeamDynamixAppIdSchema, search: ServiceSearchSchema }),
1211
2364
  payload,
1212
2365
  action
1213
2366
  );
@@ -1215,16 +2368,16 @@ function registerTeamDynamixServicesGateway(server2) {
1215
2368
  return toSuccessResponse({ appId: parsed.app_id, count: services.length, services }, response_format);
1216
2369
  }
1217
2370
  case "list_service_categories": {
1218
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
2371
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
1219
2372
  const categories = await client.listServiceCategories(parsed.app_id);
1220
2373
  return toSuccessResponse({ appId: parsed.app_id, count: categories.length, categories }, response_format);
1221
2374
  }
1222
2375
  case "delete_service": {
1223
2376
  const parsed = parsePayload(
1224
- z3.object({
2377
+ z4.object({
1225
2378
  app_id: TeamDynamixAppIdSchema,
1226
- service_id: z3.number().int().positive(),
1227
- confirm: z3.literal(true)
2379
+ service_id: z4.number().int().positive(),
2380
+ confirm: z4.literal(true)
1228
2381
  }),
1229
2382
  payload,
1230
2383
  action
@@ -1238,10 +2391,10 @@ function registerTeamDynamixServicesGateway(server2) {
1238
2391
  }
1239
2392
  case "delete_service_category": {
1240
2393
  const parsed = parsePayload(
1241
- z3.object({
2394
+ z4.object({
1242
2395
  app_id: TeamDynamixAppIdSchema,
1243
- category_id: z3.number().int().positive(),
1244
- confirm: z3.literal(true)
2396
+ category_id: z4.number().int().positive(),
2397
+ confirm: z4.literal(true)
1245
2398
  }),
1246
2399
  payload,
1247
2400
  action
@@ -1278,12 +2431,12 @@ function registerTeamDynamixProjectsGateway(server2) {
1278
2431
  const client = createConfiguredTeamDynamixClient();
1279
2432
  switch (action) {
1280
2433
  case "get_project": {
1281
- const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
2434
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1282
2435
  const project = await client.getProject(parsed.project_id);
1283
2436
  return toSuccessResponse(project, response_format);
1284
2437
  }
1285
2438
  case "search_projects": {
1286
- const parsed = parsePayload(z3.object({ search: ProjectSearchSchema }), payload, action);
2439
+ const parsed = parsePayload(z4.object({ search: ProjectSearchSchema }), payload, action);
1287
2440
  const projects = await client.searchProjects(parsed.search);
1288
2441
  return toSuccessResponse({ count: projects.length, projects }, response_format);
1289
2442
  }
@@ -1292,23 +2445,23 @@ function registerTeamDynamixProjectsGateway(server2) {
1292
2445
  return toSuccessResponse({ count: types.length, types }, response_format);
1293
2446
  }
1294
2447
  case "get_project_plans": {
1295
- const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
2448
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1296
2449
  const plans = await client.getProjectPlans(parsed.project_id);
1297
2450
  return toSuccessResponse({ projectId: parsed.project_id, count: plans.length, plans }, response_format);
1298
2451
  }
1299
2452
  case "get_project_issues": {
1300
- const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
2453
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1301
2454
  const issues = await client.getProjectIssues(parsed.project_id);
1302
2455
  return toSuccessResponse({ projectId: parsed.project_id, count: issues.length, issues }, response_format);
1303
2456
  }
1304
2457
  case "get_project_risks": {
1305
- const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
2458
+ const parsed = parsePayload(z4.object({ project_id: z4.number().int().positive() }), payload, action);
1306
2459
  const risks = await client.getProjectRisks(parsed.project_id);
1307
2460
  return toSuccessResponse({ projectId: parsed.project_id, count: risks.length, risks }, response_format);
1308
2461
  }
1309
2462
  case "create_project_issue": {
1310
2463
  const parsed = parsePayload(
1311
- z3.object({ project_id: z3.number().int().positive(), issue: ProjectIssueCreateSchema }),
2464
+ z4.object({ project_id: z4.number().int().positive(), issue: ProjectIssueCreateSchema }),
1312
2465
  payload,
1313
2466
  action
1314
2467
  );
@@ -1318,7 +2471,7 @@ function registerTeamDynamixProjectsGateway(server2) {
1318
2471
  }
1319
2472
  case "create_project_risk": {
1320
2473
  const parsed = parsePayload(
1321
- z3.object({ project_id: z3.number().int().positive(), risk: ProjectRiskCreateSchema }),
2474
+ z4.object({ project_id: z4.number().int().positive(), risk: ProjectRiskCreateSchema }),
1322
2475
  payload,
1323
2476
  action
1324
2477
  );
@@ -1355,7 +2508,7 @@ function registerTeamDynamixTimeGateway(server2) {
1355
2508
  return toSuccessResponse({ count: types.length, types }, response_format);
1356
2509
  }
1357
2510
  case "get_my_time_entries": {
1358
- const parsed = parsePayload(z3.object({ query: TimeEntryQuerySchema }), payload, action);
2511
+ const parsed = parsePayload(z4.object({ query: TimeEntryQuerySchema }), payload, action);
1359
2512
  const entries = await client.getMyTimeEntries(parsed.query.StartDate, parsed.query.EndDate);
1360
2513
  return toSuccessResponse({ count: entries.length, entries }, response_format);
1361
2514
  }
@@ -1384,12 +2537,12 @@ function registerTeamDynamixReferenceDataGateway(server2) {
1384
2537
  const client = createConfiguredTeamDynamixClient();
1385
2538
  switch (action) {
1386
2539
  case "list_accounts": {
1387
- const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
2540
+ const parsed = parsePayload(z4.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
1388
2541
  const accounts = await client.listAccounts(parsed.app_id);
1389
2542
  return toSuccessResponse({ count: accounts.length, accounts }, response_format);
1390
2543
  }
1391
2544
  case "get_account": {
1392
- const parsed = parsePayload(z3.object({ account_id: z3.number().int().positive() }), payload, action);
2545
+ const parsed = parsePayload(z4.object({ account_id: z4.number().int().positive() }), payload, action);
1393
2546
  const account = await client.getAccount(parsed.account_id);
1394
2547
  return toSuccessResponse(account, response_format);
1395
2548
  }
@@ -1403,10 +2556,10 @@ function registerTeamDynamixReferenceDataGateway(server2) {
1403
2556
  }
1404
2557
  case "list_custom_attributes": {
1405
2558
  const parsed = parsePayload(
1406
- z3.object({
2559
+ z4.object({
1407
2560
  component_id: CustomAttributeComponentIdSchema,
1408
2561
  app_id: TeamDynamixAppIdSchema.optional(),
1409
- associated_type_id: z3.number().int().positive().optional()
2562
+ associated_type_id: z4.number().int().positive().optional()
1410
2563
  }),
1411
2564
  payload,
1412
2565
  action
@@ -1512,9 +2665,13 @@ function registerTeamDynamixResources(server2) {
1512
2665
  }
1513
2666
 
1514
2667
  // 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"]);
2668
+ init_constants();
2669
+ import { z as z5 } from "zod";
2670
+ init_client_factory();
2671
+ init_watch_store();
2672
+ init_watch_service();
2673
+ var WatchKindSchema = z5.enum(["mine", "watching", "waiting-on-others"]);
2674
+ var BallSchema = z5.enum(["us", "them"]);
1518
2675
  function messageFromError2(error) {
1519
2676
  return error instanceof Error ? error.message : String(error);
1520
2677
  }
@@ -1547,7 +2704,7 @@ function registerTeamDynamixWatchTools(server2) {
1547
2704
  title: "Watch Check",
1548
2705
  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
2706
  inputSchema: {
1550
- tickets: z4.array(z4.number().int().positive()).optional().describe("Restrict the check to these ticket IDs."),
2707
+ tickets: z5.array(z5.number().int().positive()).optional().describe("Restrict the check to these ticket IDs."),
1551
2708
  response_format: TeamDynamixResponseFormatSchema
1552
2709
  },
1553
2710
  annotations: { ...readOnly }
@@ -1583,8 +2740,8 @@ function registerTeamDynamixWatchTools(server2) {
1583
2740
  title: "Watch Triage Queue",
1584
2741
  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
2742
  inputSchema: {
1586
- op: z4.enum(["queue", "done"]),
1587
- ticket_id: z4.number().int().positive().optional().describe("Required for op=done."),
2743
+ op: z5.enum(["queue", "done"]),
2744
+ ticket_id: z5.number().int().positive().optional().describe("Required for op=done."),
1588
2745
  response_format: TeamDynamixResponseFormatSchema
1589
2746
  },
1590
2747
  annotations: { ...readOnly, openWorldHint: false }
@@ -1605,13 +2762,13 @@ function registerTeamDynamixWatchTools(server2) {
1605
2762
  title: "Watch Register",
1606
2763
  description: "Add/update a ledger row when a ticket is claimed, re-scoped, or swept in. Never calls TDX.",
1607
2764
  inputSchema: {
1608
- app_id: z4.number().int().positive().describe("Ticketing application ID."),
1609
- id: z4.number().int().positive().describe("Ticket ID."),
2765
+ app_id: z5.number().int().positive().describe("Ticketing application ID."),
2766
+ id: z5.number().int().positive().describe("Ticket ID."),
1610
2767
  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."),
2768
+ title: z5.string().max(200).optional().describe("Short title (stored locally only)."),
2769
+ district: z5.string().max(100).optional().describe("District/lane label."),
1613
2770
  ball: BallSchema.optional().describe("Manual ball-in-court override (survives auto-inference)."),
1614
- next_action: z4.string().max(500).optional().describe("Next action note."),
2771
+ next_action: z5.string().max(500).optional().describe("Next action note."),
1615
2772
  response_format: TeamDynamixResponseFormatSchema
1616
2773
  },
1617
2774
  annotations: { ...readOnly, openWorldHint: false }
@@ -1636,8 +2793,8 @@ function registerTeamDynamixWatchTools(server2) {
1636
2793
  title: "Watch Archive",
1637
2794
  description: "Move a confirmed-closed row to the archive section. Memory (notes) is preserved. Never calls TDX.",
1638
2795
  inputSchema: {
1639
- id: z4.number().int().positive().describe("Ticket ID."),
1640
- outcome: z4.string().max(200).optional().describe("Resolution outcome label."),
2796
+ id: z5.number().int().positive().describe("Ticket ID."),
2797
+ outcome: z5.string().max(200).optional().describe("Resolution outcome label."),
1641
2798
  response_format: TeamDynamixResponseFormatSchema
1642
2799
  },
1643
2800
  annotations: { ...readOnly, openWorldHint: false }
@@ -1650,11 +2807,11 @@ function registerTeamDynamixWatchTools(server2) {
1650
2807
  title: "Watch Notes",
1651
2808
  description: "Local-only notes attached to ledgered tickets \u2014 the server's own memory. Never written to TDX. op: add | update | delete | list.",
1652
2809
  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(),
2810
+ op: z5.enum(["add", "update", "delete", "list"]),
2811
+ app_id: z5.number().int().positive().optional(),
2812
+ ticket_id: z5.number().int().positive().optional(),
2813
+ note_id: z5.string().optional(),
2814
+ text: z5.string().max(4e3).optional(),
1658
2815
  response_format: TeamDynamixResponseFormatSchema
1659
2816
  },
1660
2817
  annotations: { ...readOnly, openWorldHint: false }
@@ -1708,9 +2865,9 @@ function startWatchSweepTimer() {
1708
2865
  const secs = Number(process.env["TEAMDYNAMIX_WATCH_SWEEP_SECS"] ?? 0);
1709
2866
  if (!Number.isFinite(secs) || secs <= 0) return;
1710
2867
  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");
2868
+ Promise.resolve().then(() => (init_watch_store(), watch_store_exports)).then(async ({ loadLedger: loadLedger2, saveLedger: saveLedger2, emptyLedger: emptyLedger2, defaultLedgerPath: defaultLedgerPath2, LedgerCorruptError: LedgerCorruptError2 }) => {
2869
+ const { createConfiguredTeamDynamixClient: createConfiguredTeamDynamixClient2 } = await Promise.resolve().then(() => (init_client_service(), client_service_exports));
2870
+ const { WorkspaceWatchService: WorkspaceWatchService2 } = await Promise.resolve().then(() => (init_watch_service(), watch_service_exports));
1714
2871
  const ledgerPath = defaultLedgerPath2();
1715
2872
  let ledger;
1716
2873
  try {