@elyracode/youtrack 0.9.55 → 0.9.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.57] - 2026-11-10
4
+
5
+ ### Fixed
6
+
7
+ - Tool failures were returned as normal results (`isError` on the return value is ignored) and the model saw them as successes; they now throw so the result is marked as an error
8
+
9
+ ## [0.9.56] - 2026-11-01
10
+
3
11
  ## [0.9.55] - 2026-10-21
4
12
 
5
13
  ## [0.9.54] - 2026-10-14
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import type { ExtensionAPI } from "@elyracode/coding-agent";
3
+ import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
4
4
  import { Type } from "typebox";
5
5
 
6
6
  // ── Configuration ───────────────────────────────────────────────────────────
@@ -70,22 +70,21 @@ async function ytFetch(
70
70
  }
71
71
 
72
72
  function ok(text: string) {
73
- return { content: [{ type: "text" as const, text }] };
73
+ return { content: [{ type: "text" as const, text }], details: undefined };
74
74
  }
75
75
 
76
- function err(text: string) {
77
- return { content: [{ type: "text" as const, text }], isError: true as const };
78
- }
79
-
80
- function noConfig() {
81
- return err("YouTrack not configured. Set YOUTRACK_BASE_URL and YOUTRACK_TOKEN in environment or .env file.");
76
+ function noConfig(): Error {
77
+ return new Error("YouTrack not configured. Set YOUTRACK_BASE_URL and YOUTRACK_TOKEN in environment or .env file.");
82
78
  }
83
79
 
84
80
  // ── Formatters ──────────────────────────────────────────────────────────────
85
81
 
86
82
  function formatTimestamp(ms: number | null | undefined): string {
87
83
  if (!ms) return "—";
88
- return new Date(ms).toISOString().replace("T", " ").replace(/\.\d+Z$/, " UTC");
84
+ return new Date(ms)
85
+ .toISOString()
86
+ .replace("T", " ")
87
+ .replace(/\.\d+Z$/, " UTC");
89
88
  }
90
89
 
91
90
  function formatCustomFields(fields: Array<{ name?: string; value?: unknown }>): string {
@@ -183,7 +182,8 @@ export default function (elyra: ExtensionAPI): void {
183
182
 
184
183
  const getCwd = () => cwd;
185
184
 
186
- const ISSUE_FIELDS = "id,idReadable,summary,description,project(id,name,shortName),reporter(login,fullName),created,updated,resolved,tags(id,name),votes,customFields(id,name,projectCustomField(field(name)),value(id,name,login,fullName,minutes))";
185
+ const ISSUE_FIELDS =
186
+ "id,idReadable,summary,description,project(id,name,shortName),reporter(login,fullName),created,updated,resolved,tags(id,name),votes,customFields(id,name,projectCustomField(field(name)),value(id,name,login,fullName,minutes))";
187
187
  const ISSUE_LIST_FIELDS = "id,idReadable,summary,resolved,customFields(name,value(name,login,fullName))";
188
188
 
189
189
  // ── youtrack_search_issues ───────────────────────────────────────────
@@ -194,19 +194,25 @@ export default function (elyra: ExtensionAPI): void {
194
194
  description:
195
195
  "Search for issues using YouTrack query language. Supports filters like 'for: me', '#Unresolved', 'project: {Name}', 'Priority: Critical', 'Type: Bug', and free text. Returns issue ID, summary, state, assignee, and priority.",
196
196
  parameters: Type.Object({
197
- query: Type.String({ description: "YouTrack search query (e.g. 'for: me #Unresolved', 'project: Backend Type: Bug')" }),
197
+ query: Type.String({
198
+ description: "YouTrack search query (e.g. 'for: me #Unresolved', 'project: Backend Type: Bug')",
199
+ }),
198
200
  limit: Type.Optional(Type.Integer({ description: "Max results to return. Default 25, max 100." })),
199
201
  offset: Type.Optional(Type.Integer({ description: "Number of results to skip for pagination." })),
200
202
  }),
201
203
  promptSnippet: "Search YouTrack issues",
202
- async execute(_id, params) {
204
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
203
205
  const config = getConfig(getCwd());
204
- if (!config) return noConfig();
206
+ if (!config) throw noConfig();
205
207
  const top = Math.min(params.limit ?? 25, 100);
206
208
  const skip = params.offset ?? 0;
207
209
  const q = encodeURIComponent(params.query);
208
- const res = await ytFetch(config, "GET", `/api/issues?fields=${ISSUE_LIST_FIELDS}&query=${q}&$top=${top}&$skip=${skip}`);
209
- if (!res.ok) return err(`Search failed (${res.status}): ${res.text}`);
210
+ const res = await ytFetch(
211
+ config,
212
+ "GET",
213
+ `/api/issues?fields=${ISSUE_LIST_FIELDS}&query=${q}&$top=${top}&$skip=${skip}`,
214
+ );
215
+ if (!res.ok) throw new Error(`Search failed (${res.status}): ${res.text}`);
210
216
  return ok(formatIssueList(res.data as Array<Record<string, unknown>>));
211
217
  },
212
218
  });
@@ -222,11 +228,15 @@ export default function (elyra: ExtensionAPI): void {
222
228
  issue_id: Type.String({ description: "Issue ID (e.g. 'PROJ-123')" }),
223
229
  }),
224
230
  promptSnippet: "Get YouTrack issue details",
225
- async execute(_id, params) {
231
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
226
232
  const config = getConfig(getCwd());
227
- if (!config) return noConfig();
228
- const res = await ytFetch(config, "GET", `/api/issues/${encodeURIComponent(params.issue_id)}?fields=${ISSUE_FIELDS}`);
229
- if (!res.ok) return err(`Failed to get issue (${res.status}): ${res.text}`);
233
+ if (!config) throw noConfig();
234
+ const res = await ytFetch(
235
+ config,
236
+ "GET",
237
+ `/api/issues/${encodeURIComponent(params.issue_id)}?fields=${ISSUE_FIELDS}`,
238
+ );
239
+ if (!res.ok) throw new Error(`Failed to get issue (${res.status}): ${res.text}`);
230
240
  return ok(formatIssue(res.data as Record<string, unknown>));
231
241
  },
232
242
  });
@@ -239,22 +249,33 @@ export default function (elyra: ExtensionAPI): void {
239
249
  description:
240
250
  "Create a new issue in a project. Requires project ID and summary. Use youtrack_get_issue_fields_schema first to discover required custom fields and valid values.",
241
251
  parameters: Type.Object({
242
- project_id: Type.String({ description: "Project database ID (e.g. '0-3'). Use youtrack_find_projects to discover IDs." }),
252
+ project_id: Type.String({
253
+ description: "Project database ID (e.g. '0-3'). Use youtrack_find_projects to discover IDs.",
254
+ }),
243
255
  summary: Type.String({ description: "Issue summary/title" }),
244
256
  description: Type.Optional(Type.String({ description: "Issue description (supports Markdown)" })),
245
- custom_fields: Type.Optional(Type.Array(
246
- Type.Object({
247
- name: Type.String({ description: "Custom field name (e.g. 'Priority', 'Type', 'State')" }),
248
- value: Type.Unknown({ description: "Field value — object like {name: 'Critical'} or array for multi-value fields" }),
249
- $type: Type.Optional(Type.String({ description: "Field type (e.g. 'SingleEnumIssueCustomField'). Get from schema." })),
250
- }),
251
- { description: "Custom field values. Use youtrack_get_issue_fields_schema to discover valid fields and values." },
252
- )),
257
+ custom_fields: Type.Optional(
258
+ Type.Array(
259
+ Type.Object({
260
+ name: Type.String({ description: "Custom field name (e.g. 'Priority', 'Type', 'State')" }),
261
+ value: Type.Unknown({
262
+ description: "Field value — object like {name: 'Critical'} or array for multi-value fields",
263
+ }),
264
+ $type: Type.Optional(
265
+ Type.String({ description: "Field type (e.g. 'SingleEnumIssueCustomField'). Get from schema." }),
266
+ ),
267
+ }),
268
+ {
269
+ description:
270
+ "Custom field values. Use youtrack_get_issue_fields_schema to discover valid fields and values.",
271
+ },
272
+ ),
273
+ ),
253
274
  }),
254
275
  promptSnippet: "Create a YouTrack issue",
255
- async execute(_id, params) {
276
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
256
277
  const config = getConfig(getCwd());
257
- if (!config) return noConfig();
278
+ if (!config) throw noConfig();
258
279
  const body: Record<string, unknown> = {
259
280
  summary: params.summary,
260
281
  project: { id: params.project_id },
@@ -262,9 +283,11 @@ export default function (elyra: ExtensionAPI): void {
262
283
  if (params.description) body.description = params.description;
263
284
  if (params.custom_fields) body.customFields = params.custom_fields;
264
285
  const res = await ytFetch(config, "POST", `/api/issues?fields=idReadable,id`, body);
265
- if (!res.ok) return err(`Failed to create issue (${res.status}): ${res.text}`);
286
+ if (!res.ok) throw new Error(`Failed to create issue (${res.status}): ${res.text}`);
266
287
  const data = res.data as { idReadable?: string; id?: string };
267
- return ok(`Created issue ${data.idReadable || data.id}\nURL: ${config.baseUrl}/issue/${data.idReadable || data.id}`);
288
+ return ok(
289
+ `Created issue ${data.idReadable || data.id}\nURL: ${config.baseUrl}/issue/${data.idReadable || data.id}`,
290
+ );
268
291
  },
269
292
  });
270
293
 
@@ -279,24 +302,31 @@ export default function (elyra: ExtensionAPI): void {
279
302
  issue_id: Type.String({ description: "Issue ID (e.g. 'PROJ-123')" }),
280
303
  summary: Type.Optional(Type.String({ description: "New summary" })),
281
304
  description: Type.Optional(Type.String({ description: "New description" })),
282
- custom_fields: Type.Optional(Type.Array(
283
- Type.Object({
284
- name: Type.String({ description: "Custom field name" }),
285
- value: Type.Unknown({ description: "New value" }),
286
- $type: Type.Optional(Type.String({ description: "Field type" })),
287
- }),
288
- )),
305
+ custom_fields: Type.Optional(
306
+ Type.Array(
307
+ Type.Object({
308
+ name: Type.String({ description: "Custom field name" }),
309
+ value: Type.Unknown({ description: "New value" }),
310
+ $type: Type.Optional(Type.String({ description: "Field type" })),
311
+ }),
312
+ ),
313
+ ),
289
314
  }),
290
315
  promptSnippet: "Update a YouTrack issue",
291
- async execute(_id, params) {
316
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
292
317
  const config = getConfig(getCwd());
293
- if (!config) return noConfig();
318
+ if (!config) throw noConfig();
294
319
  const body: Record<string, unknown> = {};
295
320
  if (params.summary) body.summary = params.summary;
296
321
  if (params.description !== undefined) body.description = params.description;
297
322
  if (params.custom_fields) body.customFields = params.custom_fields;
298
- const res = await ytFetch(config, "POST", `/api/issues/${encodeURIComponent(params.issue_id)}?fields=idReadable,id`, body);
299
- if (!res.ok) return err(`Failed to update issue (${res.status}): ${res.text}`);
323
+ const res = await ytFetch(
324
+ config,
325
+ "POST",
326
+ `/api/issues/${encodeURIComponent(params.issue_id)}?fields=idReadable,id`,
327
+ body,
328
+ );
329
+ if (!res.ok) throw new Error(`Failed to update issue (${res.status}): ${res.text}`);
300
330
  return ok(`Updated issue ${params.issue_id}`);
301
331
  },
302
332
  });
@@ -306,25 +336,31 @@ export default function (elyra: ExtensionAPI): void {
306
336
  elyra.registerTool({
307
337
  name: "youtrack_change_assignee",
308
338
  label: "YouTrack Change Assignee",
309
- description:
310
- "Change the assignee of an issue. Provide the issue ID and the new assignee's login username.",
339
+ description: "Change the assignee of an issue. Provide the issue ID and the new assignee's login username.",
311
340
  parameters: Type.Object({
312
341
  issue_id: Type.String({ description: "Issue ID (e.g. 'PROJ-123')" }),
313
342
  assignee: Type.String({ description: "Username (login) of the new assignee" }),
314
343
  }),
315
344
  promptSnippet: "Change YouTrack issue assignee",
316
- async execute(_id, params) {
345
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
317
346
  const config = getConfig(getCwd());
318
- if (!config) return noConfig();
347
+ if (!config) throw noConfig();
319
348
  const body = {
320
- customFields: [{
321
- name: "Assignee",
322
- $type: "SingleUserIssueCustomField",
323
- value: { login: params.assignee },
324
- }],
349
+ customFields: [
350
+ {
351
+ name: "Assignee",
352
+ $type: "SingleUserIssueCustomField",
353
+ value: { login: params.assignee },
354
+ },
355
+ ],
325
356
  };
326
- const res = await ytFetch(config, "POST", `/api/issues/${encodeURIComponent(params.issue_id)}?fields=idReadable`, body);
327
- if (!res.ok) return err(`Failed to change assignee (${res.status}): ${res.text}`);
357
+ const res = await ytFetch(
358
+ config,
359
+ "POST",
360
+ `/api/issues/${encodeURIComponent(params.issue_id)}?fields=idReadable`,
361
+ body,
362
+ );
363
+ if (!res.ok) throw new Error(`Failed to change assignee (${res.status}): ${res.text}`);
328
364
  return ok(`Assigned ${params.issue_id} to @${params.assignee}`);
329
365
  },
330
366
  });
@@ -334,18 +370,22 @@ export default function (elyra: ExtensionAPI): void {
334
370
  elyra.registerTool({
335
371
  name: "youtrack_add_comment",
336
372
  label: "YouTrack Add Comment",
337
- description:
338
- "Add a comment to an issue. Supports Markdown formatting.",
373
+ description: "Add a comment to an issue. Supports Markdown formatting.",
339
374
  parameters: Type.Object({
340
375
  issue_id: Type.String({ description: "Issue ID (e.g. 'PROJ-123')" }),
341
376
  text: Type.String({ description: "Comment text (supports Markdown)" }),
342
377
  }),
343
378
  promptSnippet: "Add a comment to a YouTrack issue",
344
- async execute(_id, params) {
379
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
345
380
  const config = getConfig(getCwd());
346
- if (!config) return noConfig();
347
- const res = await ytFetch(config, "POST", `/api/issues/${encodeURIComponent(params.issue_id)}/comments?fields=id,created`, { text: params.text });
348
- if (!res.ok) return err(`Failed to add comment (${res.status}): ${res.text}`);
381
+ if (!config) throw noConfig();
382
+ const res = await ytFetch(
383
+ config,
384
+ "POST",
385
+ `/api/issues/${encodeURIComponent(params.issue_id)}/comments?fields=id,created`,
386
+ { text: params.text },
387
+ );
388
+ if (!res.ok) throw new Error(`Failed to add comment (${res.status}): ${res.text}`);
349
389
  return ok(`Comment added to ${params.issue_id}`);
350
390
  },
351
391
  });
@@ -355,22 +395,30 @@ export default function (elyra: ExtensionAPI): void {
355
395
  elyra.registerTool({
356
396
  name: "youtrack_get_comments",
357
397
  label: "YouTrack Get Comments",
358
- description:
359
- "Get all comments for an issue, including author, timestamp, and text.",
398
+ description: "Get all comments for an issue, including author, timestamp, and text.",
360
399
  parameters: Type.Object({
361
400
  issue_id: Type.String({ description: "Issue ID (e.g. 'PROJ-123')" }),
362
401
  limit: Type.Optional(Type.Integer({ description: "Max comments. Default 25." })),
363
402
  offset: Type.Optional(Type.Integer({ description: "Skip N comments for pagination." })),
364
403
  }),
365
404
  promptSnippet: "Get comments for a YouTrack issue",
366
- async execute(_id, params) {
405
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
367
406
  const config = getConfig(getCwd());
368
- if (!config) return noConfig();
407
+ if (!config) throw noConfig();
369
408
  const top = Math.min(params.limit ?? 25, 100);
370
409
  const skip = params.offset ?? 0;
371
- const res = await ytFetch(config, "GET", `/api/issues/${encodeURIComponent(params.issue_id)}/comments?fields=id,text,created,author(login,fullName)&$top=${top}&$skip=${skip}`);
372
- if (!res.ok) return err(`Failed to get comments (${res.status}): ${res.text}`);
373
- const comments = res.data as Array<{ id?: string; text?: string; created?: number; author?: { login?: string; fullName?: string } }>;
410
+ const res = await ytFetch(
411
+ config,
412
+ "GET",
413
+ `/api/issues/${encodeURIComponent(params.issue_id)}/comments?fields=id,text,created,author(login,fullName)&$top=${top}&$skip=${skip}`,
414
+ );
415
+ if (!res.ok) throw new Error(`Failed to get comments (${res.status}): ${res.text}`);
416
+ const comments = res.data as Array<{
417
+ id?: string;
418
+ text?: string;
419
+ created?: number;
420
+ author?: { login?: string; fullName?: string };
421
+ }>;
374
422
  if (comments.length === 0) return ok("No comments on this issue.");
375
423
  const lines: string[] = [`${comments.length} comment(s):\n`];
376
424
  for (const c of comments) {
@@ -388,30 +436,42 @@ export default function (elyra: ExtensionAPI): void {
388
436
  elyra.registerTool({
389
437
  name: "youtrack_manage_tags",
390
438
  label: "YouTrack Manage Tags",
391
- description:
392
- "Add or remove a tag from an issue. If adding by name, the first matching tag is used.",
439
+ description: "Add or remove a tag from an issue. If adding by name, the first matching tag is used.",
393
440
  parameters: Type.Object({
394
441
  issue_id: Type.String({ description: "Issue ID (e.g. 'PROJ-123')" }),
395
442
  tag: Type.String({ description: "Tag name or ID" }),
396
443
  action: Type.Union([Type.Literal("add"), Type.Literal("remove")], { description: "'add' or 'remove'" }),
397
444
  }),
398
445
  promptSnippet: "Add or remove a tag on a YouTrack issue",
399
- async execute(_id, params) {
446
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
400
447
  const config = getConfig(getCwd());
401
- if (!config) return noConfig();
448
+ if (!config) throw noConfig();
402
449
  if (params.action === "add") {
403
- const res = await ytFetch(config, "POST", `/api/issues/${encodeURIComponent(params.issue_id)}/tags?fields=id,name`, { name: params.tag });
404
- if (!res.ok) return err(`Failed to add tag (${res.status}): ${res.text}`);
450
+ const res = await ytFetch(
451
+ config,
452
+ "POST",
453
+ `/api/issues/${encodeURIComponent(params.issue_id)}/tags?fields=id,name`,
454
+ { name: params.tag },
455
+ );
456
+ if (!res.ok) throw new Error(`Failed to add tag (${res.status}): ${res.text}`);
405
457
  return ok(`Added tag "${params.tag}" to ${params.issue_id}`);
406
458
  }
407
459
  // Remove: first find the tag ID
408
- const tagsRes = await ytFetch(config, "GET", `/api/issues/${encodeURIComponent(params.issue_id)}?fields=tags(id,name)`);
409
- if (!tagsRes.ok) return err(`Failed to get tags (${tagsRes.status}): ${tagsRes.text}`);
460
+ const tagsRes = await ytFetch(
461
+ config,
462
+ "GET",
463
+ `/api/issues/${encodeURIComponent(params.issue_id)}?fields=tags(id,name)`,
464
+ );
465
+ if (!tagsRes.ok) throw new Error(`Failed to get tags (${tagsRes.status}): ${tagsRes.text}`);
410
466
  const issue = tagsRes.data as { tags?: Array<{ id: string; name: string }> };
411
467
  const tag = issue.tags?.find((t) => t.name.toLowerCase() === params.tag.toLowerCase() || t.id === params.tag);
412
- if (!tag) return err(`Tag "${params.tag}" not found on ${params.issue_id}`);
413
- const res = await ytFetch(config, "DELETE", `/api/issues/${encodeURIComponent(params.issue_id)}/tags/${tag.id}`);
414
- if (!res.ok) return err(`Failed to remove tag (${res.status}): ${res.text}`);
468
+ if (!tag) throw new Error(`Tag "${params.tag}" not found on ${params.issue_id}`);
469
+ const res = await ytFetch(
470
+ config,
471
+ "DELETE",
472
+ `/api/issues/${encodeURIComponent(params.issue_id)}/tags/${tag.id}`,
473
+ );
474
+ if (!res.ok) throw new Error(`Failed to remove tag (${res.status}): ${res.text}`);
415
475
  return ok(`Removed tag "${params.tag}" from ${params.issue_id}`);
416
476
  },
417
477
  });
@@ -429,15 +489,20 @@ export default function (elyra: ExtensionAPI): void {
429
489
  link_type: Type.String({ description: "Link type name (e.g. 'relates to', 'depends on', 'parent for')" }),
430
490
  }),
431
491
  promptSnippet: "Link two YouTrack issues",
432
- async execute(_id, params) {
492
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
433
493
  const config = getConfig(getCwd());
434
- if (!config) return noConfig();
494
+ if (!config) throw noConfig();
435
495
  const body = {
436
496
  issues: [{ idReadable: params.target_issue_id }],
437
497
  linkType: { name: params.link_type },
438
498
  };
439
- const res = await ytFetch(config, "POST", `/api/issues/${encodeURIComponent(params.issue_id)}/links?fields=id`, body);
440
- if (!res.ok) return err(`Failed to link issues (${res.status}): ${res.text}`);
499
+ const res = await ytFetch(
500
+ config,
501
+ "POST",
502
+ `/api/issues/${encodeURIComponent(params.issue_id)}/links?fields=id`,
503
+ body,
504
+ );
505
+ if (!res.ok) throw new Error(`Failed to link issues (${res.status}): ${res.text}`);
441
506
  return ok(`Linked ${params.issue_id} → ${params.target_issue_id} (${params.link_type})`);
442
507
  },
443
508
  });
@@ -447,21 +512,24 @@ export default function (elyra: ExtensionAPI): void {
447
512
  elyra.registerTool({
448
513
  name: "youtrack_find_projects",
449
514
  label: "YouTrack Find Projects",
450
- description:
451
- "Search for projects by name. Returns project ID, name, and short name.",
515
+ description: "Search for projects by name. Returns project ID, name, and short name.",
452
516
  parameters: Type.Object({
453
- query: Type.Optional(Type.String({ description: "Project name substring to search for (case-insensitive). Returns all projects if omitted." })),
517
+ query: Type.Optional(
518
+ Type.String({
519
+ description: "Project name substring to search for (case-insensitive). Returns all projects if omitted.",
520
+ }),
521
+ ),
454
522
  limit: Type.Optional(Type.Integer({ description: "Max results. Default 25." })),
455
523
  }),
456
524
  promptSnippet: "Find YouTrack projects",
457
- async execute(_id, params) {
525
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
458
526
  const config = getConfig(getCwd());
459
- if (!config) return noConfig();
527
+ if (!config) throw noConfig();
460
528
  const top = Math.min(params.limit ?? 25, 100);
461
529
  let path = `/api/admin/projects?fields=id,name,shortName&$top=${top}`;
462
530
  if (params.query) path += `&query=${encodeURIComponent(params.query)}`;
463
531
  const res = await ytFetch(config, "GET", path);
464
- if (!res.ok) return err(`Failed to find projects (${res.status}): ${res.text}`);
532
+ if (!res.ok) throw new Error(`Failed to find projects (${res.status}): ${res.text}`);
465
533
  const projects = res.data as Array<{ id: string; name: string; shortName: string }>;
466
534
  if (projects.length === 0) return ok("No projects found.");
467
535
  const lines = projects.map((p) => `${p.shortName} (${p.id}): ${p.name}`);
@@ -474,17 +542,20 @@ export default function (elyra: ExtensionAPI): void {
474
542
  elyra.registerTool({
475
543
  name: "youtrack_get_project",
476
544
  label: "YouTrack Get Project",
477
- description:
478
- "Get full details for a project including name, description, leader, and creation date.",
545
+ description: "Get full details for a project including name, description, leader, and creation date.",
479
546
  parameters: Type.Object({
480
547
  project_id: Type.String({ description: "Project ID (database ID like '0-3' or short name like 'PROJ')" }),
481
548
  }),
482
549
  promptSnippet: "Get YouTrack project details",
483
- async execute(_id, params) {
550
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
484
551
  const config = getConfig(getCwd());
485
- if (!config) return noConfig();
486
- const res = await ytFetch(config, "GET", `/api/admin/projects/${encodeURIComponent(params.project_id)}?fields=id,name,shortName,description,leader(login,fullName),createdBy(login,fullName),archived,fromEmail,replyToEmail`);
487
- if (!res.ok) return err(`Failed to get project (${res.status}): ${res.text}`);
552
+ if (!config) throw noConfig();
553
+ const res = await ytFetch(
554
+ config,
555
+ "GET",
556
+ `/api/admin/projects/${encodeURIComponent(params.project_id)}?fields=id,name,shortName,description,leader(login,fullName),createdBy(login,fullName),archived,fromEmail,replyToEmail`,
557
+ );
558
+ if (!res.ok) throw new Error(`Failed to get project (${res.status}): ${res.text}`);
488
559
  const p = res.data as Record<string, unknown>;
489
560
  const lines: string[] = [];
490
561
  lines.push(`${p.shortName} (${p.id}): ${p.name}`);
@@ -509,11 +580,15 @@ export default function (elyra: ExtensionAPI): void {
509
580
  project_id: Type.String({ description: "Project ID (database ID like '0-3' or short name like 'PROJ')" }),
510
581
  }),
511
582
  promptSnippet: "Get YouTrack custom field schema for a project",
512
- async execute(_id, params) {
583
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
513
584
  const config = getConfig(getCwd());
514
- if (!config) return noConfig();
515
- const res = await ytFetch(config, "GET", `/api/admin/projects/${encodeURIComponent(params.project_id)}/customFields?fields=id,field(name,fieldType(id)),canBeEmpty,emptyFieldText,bundle(id,values(name,login,fullName))`);
516
- if (!res.ok) return err(`Failed to get schema (${res.status}): ${res.text}`);
585
+ if (!config) throw noConfig();
586
+ const res = await ytFetch(
587
+ config,
588
+ "GET",
589
+ `/api/admin/projects/${encodeURIComponent(params.project_id)}/customFields?fields=id,field(name,fieldType(id)),canBeEmpty,emptyFieldText,bundle(id,values(name,login,fullName))`,
590
+ );
591
+ if (!res.ok) throw new Error(`Failed to get schema (${res.status}): ${res.text}`);
517
592
  const fields = res.data as Array<{
518
593
  id: string;
519
594
  field: { name: string; fieldType?: { id?: string } };
@@ -541,18 +616,27 @@ export default function (elyra: ExtensionAPI): void {
541
616
  elyra.registerTool({
542
617
  name: "youtrack_find_user",
543
618
  label: "YouTrack Find User",
544
- description:
545
- "Find a user by username, full name, or email. Returns profile data.",
619
+ description: "Find a user by username, full name, or email. Returns profile data.",
546
620
  parameters: Type.Object({
547
621
  query: Type.String({ description: "Username, full name, or email to search for" }),
548
622
  }),
549
623
  promptSnippet: "Find a YouTrack user",
550
- async execute(_id, params) {
624
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
551
625
  const config = getConfig(getCwd());
552
- if (!config) return noConfig();
553
- const res = await ytFetch(config, "GET", `/api/users?fields=id,login,fullName,email,banned&query=${encodeURIComponent(params.query)}&$top=10`);
554
- if (!res.ok) return err(`Failed to find user (${res.status}): ${res.text}`);
555
- const users = res.data as Array<{ id: string; login: string; fullName?: string; email?: string; banned?: boolean }>;
626
+ if (!config) throw noConfig();
627
+ const res = await ytFetch(
628
+ config,
629
+ "GET",
630
+ `/api/users?fields=id,login,fullName,email,banned&query=${encodeURIComponent(params.query)}&$top=10`,
631
+ );
632
+ if (!res.ok) throw new Error(`Failed to find user (${res.status}): ${res.text}`);
633
+ const users = res.data as Array<{
634
+ id: string;
635
+ login: string;
636
+ fullName?: string;
637
+ email?: string;
638
+ banned?: boolean;
639
+ }>;
556
640
  if (users.length === 0) return ok("No users found.");
557
641
  const lines = users.map((u) => {
558
642
  const parts = [`@${u.login}`];
@@ -570,15 +654,14 @@ export default function (elyra: ExtensionAPI): void {
570
654
  elyra.registerTool({
571
655
  name: "youtrack_get_current_user",
572
656
  label: "YouTrack Current User",
573
- description:
574
- "Get details about the currently authenticated user — username, email, full name.",
657
+ description: "Get details about the currently authenticated user — username, email, full name.",
575
658
  parameters: Type.Object({}),
576
659
  promptSnippet: "Get current YouTrack user info",
577
- async execute() {
660
+ async execute(): Promise<AgentToolResult<undefined>> {
578
661
  const config = getConfig(getCwd());
579
- if (!config) return noConfig();
662
+ if (!config) throw noConfig();
580
663
  const res = await ytFetch(config, "GET", "/api/users/me?fields=id,login,fullName,email,avatarUrl");
581
- if (!res.ok) return err(`Failed to get user (${res.status}): ${res.text}`);
664
+ if (!res.ok) throw new Error(`Failed to get user (${res.status}): ${res.text}`);
582
665
  const u = res.data as { login?: string; fullName?: string; email?: string };
583
666
  const lines: string[] = [];
584
667
  if (u.fullName) lines.push(`Name: ${u.fullName}`);
@@ -593,25 +676,36 @@ export default function (elyra: ExtensionAPI): void {
593
676
  elyra.registerTool({
594
677
  name: "youtrack_search_articles",
595
678
  label: "YouTrack Search Articles",
596
- description:
597
- "Search for knowledge base articles using YouTrack query language.",
679
+ description: "Search for knowledge base articles using YouTrack query language.",
598
680
  parameters: Type.Object({
599
681
  query: Type.String({ description: "Search query for articles" }),
600
682
  limit: Type.Optional(Type.Integer({ description: "Max results. Default 25." })),
601
683
  offset: Type.Optional(Type.Integer({ description: "Skip N results." })),
602
684
  }),
603
685
  promptSnippet: "Search YouTrack knowledge base articles",
604
- async execute(_id, params) {
686
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
605
687
  const config = getConfig(getCwd());
606
- if (!config) return noConfig();
688
+ if (!config) throw noConfig();
607
689
  const top = Math.min(params.limit ?? 25, 100);
608
690
  const skip = params.offset ?? 0;
609
691
  const q = encodeURIComponent(params.query);
610
- const res = await ytFetch(config, "GET", `/api/articles?fields=id,idReadable,summary,project(name)&query=${q}&$top=${top}&$skip=${skip}`);
611
- if (!res.ok) return err(`Failed to search articles (${res.status}): ${res.text}`);
612
- const articles = res.data as Array<{ id: string; idReadable?: string; summary?: string; project?: { name?: string } }>;
692
+ const res = await ytFetch(
693
+ config,
694
+ "GET",
695
+ `/api/articles?fields=id,idReadable,summary,project(name)&query=${q}&$top=${top}&$skip=${skip}`,
696
+ );
697
+ if (!res.ok) throw new Error(`Failed to search articles (${res.status}): ${res.text}`);
698
+ const articles = res.data as Array<{
699
+ id: string;
700
+ idReadable?: string;
701
+ summary?: string;
702
+ project?: { name?: string };
703
+ }>;
613
704
  if (articles.length === 0) return ok("No articles found.");
614
- const lines = articles.map((a) => `${a.idReadable || a.id}: ${a.summary || "(no title)"}${a.project?.name ? ` [${a.project.name}]` : ""}`);
705
+ const lines = articles.map(
706
+ (a) =>
707
+ `${a.idReadable || a.id}: ${a.summary || "(no title)"}${a.project?.name ? ` [${a.project.name}]` : ""}`,
708
+ );
615
709
  return ok(`${articles.length} article(s):\n${lines.join("\n")}`);
616
710
  },
617
711
  });
@@ -621,17 +715,20 @@ export default function (elyra: ExtensionAPI): void {
621
715
  elyra.registerTool({
622
716
  name: "youtrack_get_article",
623
717
  label: "YouTrack Get Article",
624
- description:
625
- "Get full content of a knowledge base article including title, content, and sub-articles.",
718
+ description: "Get full content of a knowledge base article including title, content, and sub-articles.",
626
719
  parameters: Type.Object({
627
720
  article_id: Type.String({ description: "Article ID (e.g. 'PROJ-A-1')" }),
628
721
  }),
629
722
  promptSnippet: "Get a YouTrack knowledge base article",
630
- async execute(_id, params) {
723
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
631
724
  const config = getConfig(getCwd());
632
- if (!config) return noConfig();
633
- const res = await ytFetch(config, "GET", `/api/articles/${encodeURIComponent(params.article_id)}?fields=id,idReadable,summary,content,project(name),reporter(login,fullName),created,updated,childArticles(id,idReadable,summary)`);
634
- if (!res.ok) return err(`Failed to get article (${res.status}): ${res.text}`);
725
+ if (!config) throw noConfig();
726
+ const res = await ytFetch(
727
+ config,
728
+ "GET",
729
+ `/api/articles/${encodeURIComponent(params.article_id)}?fields=id,idReadable,summary,content,project(name),reporter(login,fullName),created,updated,childArticles(id,idReadable,summary)`,
730
+ );
731
+ if (!res.ok) throw new Error(`Failed to get article (${res.status}): ${res.text}`);
635
732
  const a = res.data as Record<string, unknown>;
636
733
  const lines: string[] = [];
637
734
  lines.push(`# ${a.summary || "(no title)"}`);
@@ -660,8 +757,7 @@ export default function (elyra: ExtensionAPI): void {
660
757
  elyra.registerTool({
661
758
  name: "youtrack_create_article",
662
759
  label: "YouTrack Create Article",
663
- description:
664
- "Create a new knowledge base article in a project.",
760
+ description: "Create a new knowledge base article in a project.",
665
761
  parameters: Type.Object({
666
762
  project_id: Type.String({ description: "Project ID" }),
667
763
  summary: Type.String({ description: "Article title" }),
@@ -669,9 +765,9 @@ export default function (elyra: ExtensionAPI): void {
669
765
  parent_article_id: Type.Optional(Type.String({ description: "Parent article ID to nest under" })),
670
766
  }),
671
767
  promptSnippet: "Create a YouTrack knowledge base article",
672
- async execute(_id, params) {
768
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
673
769
  const config = getConfig(getCwd());
674
- if (!config) return noConfig();
770
+ if (!config) throw noConfig();
675
771
  const body: Record<string, unknown> = {
676
772
  summary: params.summary,
677
773
  content: params.content,
@@ -679,9 +775,11 @@ export default function (elyra: ExtensionAPI): void {
679
775
  };
680
776
  if (params.parent_article_id) body.parentArticle = { id: params.parent_article_id };
681
777
  const res = await ytFetch(config, "POST", "/api/articles?fields=id,idReadable", body);
682
- if (!res.ok) return err(`Failed to create article (${res.status}): ${res.text}`);
778
+ if (!res.ok) throw new Error(`Failed to create article (${res.status}): ${res.text}`);
683
779
  const data = res.data as { idReadable?: string; id?: string };
684
- return ok(`Created article ${data.idReadable || data.id}\nURL: ${config.baseUrl}/articles/${data.idReadable || data.id}`);
780
+ return ok(
781
+ `Created article ${data.idReadable || data.id}\nURL: ${config.baseUrl}/articles/${data.idReadable || data.id}`,
782
+ );
685
783
  },
686
784
  });
687
785
 
@@ -690,27 +788,36 @@ export default function (elyra: ExtensionAPI): void {
690
788
  elyra.registerTool({
691
789
  name: "youtrack_log_work",
692
790
  label: "YouTrack Log Work",
693
- description:
694
- "Log time spent on an issue. Specify duration in minutes.",
791
+ description: "Log time spent on an issue. Specify duration in minutes.",
695
792
  parameters: Type.Object({
696
793
  issue_id: Type.String({ description: "Issue ID (e.g. 'PROJ-123')" }),
697
794
  minutes: Type.Integer({ description: "Duration in minutes" }),
698
795
  description: Type.Optional(Type.String({ description: "Work item description" })),
699
796
  date: Type.Optional(Type.String({ description: "Date (ISO 8601, e.g. '2026-05-27'). Defaults to today." })),
700
- work_type: Type.Optional(Type.String({ description: "Work type name (e.g. 'Development', 'Testing'). Use youtrack_get_project to see available work types." })),
797
+ work_type: Type.Optional(
798
+ Type.String({
799
+ description:
800
+ "Work type name (e.g. 'Development', 'Testing'). Use youtrack_get_project to see available work types.",
801
+ }),
802
+ ),
701
803
  }),
702
804
  promptSnippet: "Log work time on a YouTrack issue",
703
- async execute(_id, params) {
805
+ async execute(_id, params): Promise<AgentToolResult<undefined>> {
704
806
  const config = getConfig(getCwd());
705
- if (!config) return noConfig();
807
+ if (!config) throw noConfig();
706
808
  const body: Record<string, unknown> = {
707
809
  duration: { minutes: params.minutes },
708
810
  };
709
811
  if (params.description) body.text = params.description;
710
812
  if (params.date) body.date = new Date(params.date).getTime();
711
813
  if (params.work_type) body.type = { name: params.work_type };
712
- const res = await ytFetch(config, "POST", `/api/issues/${encodeURIComponent(params.issue_id)}/timeTracking/workItems?fields=id`, body);
713
- if (!res.ok) return err(`Failed to log work (${res.status}): ${res.text}`);
814
+ const res = await ytFetch(
815
+ config,
816
+ "POST",
817
+ `/api/issues/${encodeURIComponent(params.issue_id)}/timeTracking/workItems?fields=id`,
818
+ body,
819
+ );
820
+ if (!res.ok) throw new Error(`Failed to log work (${res.status}): ${res.text}`);
714
821
  return ok(`Logged ${params.minutes} minutes on ${params.issue_id}`);
715
822
  },
716
823
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/youtrack",
3
- "version": "0.9.55",
3
+ "version": "0.9.57",
4
4
  "description": "YouTrack integration for Elyra -- search issues, manage assignments, comments, projects, and more",
5
5
  "type": "module",
6
6
  "keywords": [