Compare commits

..

4 Commits

Author SHA1 Message Date
Vikhyath Mondreti
2ffdcb4e6c address greptile comments 2026-02-09 19:07:52 -08:00
Vikhyath Mondreti
b32d4e4e48 remove unused code 2026-02-09 19:04:32 -08:00
Vikhyath Mondreti
606f0f3b8c address bugbot comments 2026-02-09 17:25:55 -08:00
Vikhyath Mondreti
089b8dfc93 improvement(schema): centralize derivation of block schemas 2026-02-09 17:05:41 -08:00
112 changed files with 2028 additions and 8395 deletions

View File

@@ -5483,37 +5483,3 @@ export function AgentSkillsIcon(props: SVGProps<SVGSVGElement>) {
</svg>
)
}
export function OnePasswordIcon(props: SVGProps<SVGSVGElement>) {
return (
<svg {...props} viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg' fill='none'>
<circle
cx='24'
cy='24'
r='21.5'
stroke='#000000'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M28.083,17.28a7.8633,7.8633,0,0,1,0,13.44'
stroke='#000000'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M19.917,30.72a7.8633,7.8633,0,0,1,0-13.44'
stroke='#000000'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M26.067,10.43H21.933a2.0172,2.0172,0,0,0-2.016,2.016v6.36c2.358,1.281,2.736,2.562,0,3.843V35.574a2.0169,2.0169,0,0,0,2.016,2.015h4.134a2.0169,2.0169,0,0,0,2.016-2.015V29.213c-2.358-1.281-2.736-2.562,0-3.842V12.446A2.0172,2.0172,0,0,0,26.067,10.43Z'
fill='#000000'
stroke='#000000'
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
)
}

View File

@@ -80,7 +80,6 @@ import {
MySQLIcon,
Neo4jIcon,
NotionIcon,
OnePasswordIcon,
OpenAIIcon,
OutlookIcon,
PackageSearchIcon,
@@ -215,7 +214,6 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
neo4j: Neo4jIcon,
notion_v2: NotionIcon,
onedrive: MicrosoftOneDriveIcon,
onepassword: OnePasswordIcon,
openai: OpenAIIcon,
outlook: OutlookIcon,
parallel_ai: ParallelIcon,

View File

@@ -25,7 +25,6 @@ With Airweave, you can:
In Sim, the Airweave integration empowers your agents to search, summarize, and extract insights from all your organizations data via a single tool. Use Airweave to drive rich, contextual knowledge retrieval within your workflows—whether answering questions, generating summaries, or supporting dynamic decision-making.
{/* MANUAL-CONTENT-END */}
## Usage Instructions
Search across your synced data sources using Airweave. Supports semantic search with hybrid, neural, or keyword retrieval strategies. Optionally generate AI-powered answers from search results.

View File

@@ -43,6 +43,7 @@ Retrieve detailed information about a specific Jira issue
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `projectId` | string | No | Jira project key \(e.g., PROJ\). Optional when retrieving a single issue. |
| `issueKey` | string | Yes | Jira issue key to retrieve \(e.g., PROJ-123\) |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
@@ -50,184 +51,13 @@ Retrieve detailed information about a specific Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `id` | string | Issue ID |
| `key` | string | Issue key \(e.g., PROJ-123\) |
| `self` | string | REST API URL for this issue |
| `summary` | string | Issue summary |
| `description` | string | Issue description text \(extracted from ADF\) |
| `status` | object | Issue status |
| ↳ `id` | string | Status ID |
| ↳ `name` | string | Status name \(e.g., Open, In Progress, Done\) |
| ↳ `description` | string | Status description |
| ↳ `statusCategory` | object | Status category grouping |
| ↳ `id` | number | Status category ID |
| ↳ `key` | string | Status category key \(e.g., new, indeterminate, done\) |
| ↳ `name` | string | Status category name \(e.g., To Do, In Progress, Done\) |
| ↳ `colorName` | string | Status category color \(e.g., blue-gray, yellow, green\) |
| `issuetype` | object | Issue type |
| ↳ `id` | string | Issue type ID |
| ↳ `name` | string | Issue type name \(e.g., Task, Bug, Story, Epic\) |
| ↳ `description` | string | Issue type description |
| ↳ `subtask` | boolean | Whether this is a subtask type |
| ↳ `iconUrl` | string | URL to the issue type icon |
| `project` | object | Project the issue belongs to |
| ↳ `id` | string | Project ID |
| ↳ `key` | string | Project key \(e.g., PROJ\) |
| ↳ `name` | string | Project name |
| ↳ `projectTypeKey` | string | Project type key \(e.g., software, business\) |
| `priority` | object | Issue priority |
| ↳ `id` | string | Priority ID |
| ↳ `name` | string | Priority name \(e.g., Highest, High, Medium, Low, Lowest\) |
| ↳ `iconUrl` | string | URL to the priority icon |
| `assignee` | object | Assigned user |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `reporter` | object | Reporter user |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `creator` | object | Issue creator |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `labels` | array | Issue labels |
| `components` | array | Issue components |
| ↳ `id` | string | Component ID |
| ↳ `name` | string | Component name |
| ↳ `description` | string | Component description |
| `fixVersions` | array | Fix versions |
| ↳ `id` | string | Version ID |
| ↳ `name` | string | Version name |
| ↳ `released` | boolean | Whether the version is released |
| ↳ `releaseDate` | string | Release date \(YYYY-MM-DD\) |
| `resolution` | object | Issue resolution |
| ↳ `id` | string | Resolution ID |
| ↳ `name` | string | Resolution name \(e.g., Fixed, Duplicate, Won't Fix\) |
| ↳ `description` | string | Resolution description |
| `duedate` | string | Due date \(YYYY-MM-DD\) |
| `created` | string | ISO 8601 timestamp when the issue was created |
| `updated` | string | ISO 8601 timestamp when the issue was last updated |
| `resolutiondate` | string | ISO 8601 timestamp when the issue was resolved |
| `timetracking` | object | Time tracking information |
| ↳ `originalEstimate` | string | Original estimate in human-readable format \(e.g., 1w 2d\) |
| ↳ `remainingEstimate` | string | Remaining estimate in human-readable format |
| ↳ `timeSpent` | string | Time spent in human-readable format |
| ↳ `originalEstimateSeconds` | number | Original estimate in seconds |
| ↳ `remainingEstimateSeconds` | number | Remaining estimate in seconds |
| ↳ `timeSpentSeconds` | number | Time spent in seconds |
| `parent` | object | Parent issue \(for subtasks\) |
| ↳ `id` | string | Parent issue ID |
| ↳ `key` | string | Parent issue key |
| ↳ `summary` | string | Parent issue summary |
| `issuelinks` | array | Linked issues |
| ↳ `id` | string | Issue link ID |
| ↳ `type` | object | Link type information |
| ↳ `id` | string | Link type ID |
| ↳ `name` | string | Link type name \(e.g., Blocks, Relates\) |
| ↳ `inward` | string | Inward description \(e.g., is blocked by\) |
| ↳ `outward` | string | Outward description \(e.g., blocks\) |
| ↳ `inwardIssue` | object | Inward linked issue |
| ↳ `id` | string | Issue ID |
| ↳ `key` | string | Issue key |
| ↳ `statusName` | string | Issue status name |
| ↳ `summary` | string | Issue summary |
| ↳ `outwardIssue` | object | Outward linked issue |
| ↳ `id` | string | Issue ID |
| ↳ `key` | string | Issue key |
| ↳ `statusName` | string | Issue status name |
| ↳ `summary` | string | Issue summary |
| `subtasks` | array | Subtask issues |
| ↳ `id` | string | Subtask issue ID |
| ↳ `key` | string | Subtask issue key |
| ↳ `summary` | string | Subtask summary |
| ↳ `statusName` | string | Subtask status name |
| ↳ `issueTypeName` | string | Subtask issue type name |
| `votes` | object | Vote information |
| ↳ `votes` | number | Number of votes |
| ↳ `hasVoted` | boolean | Whether the current user has voted |
| `watches` | object | Watch information |
| ↳ `watchCount` | number | Number of watchers |
| ↳ `isWatching` | boolean | Whether the current user is watching |
| `comments` | array | Issue comments \(fetched separately\) |
| ↳ `id` | string | Comment ID |
| ↳ `body` | string | Comment body text \(extracted from ADF\) |
| ↳ `author` | object | Comment author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `updateAuthor` | object | User who last updated the comment |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `created` | string | ISO 8601 timestamp when the comment was created |
| ↳ `updated` | string | ISO 8601 timestamp when the comment was last updated |
| ↳ `visibility` | object | Comment visibility restriction |
| ↳ `type` | string | Restriction type \(e.g., role, group\) |
| ↳ `value` | string | Restriction value \(e.g., Administrators\) |
| `worklogs` | array | Issue worklogs \(fetched separately\) |
| ↳ `id` | string | Worklog ID |
| ↳ `author` | object | Worklog author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `updateAuthor` | object | User who last updated the worklog |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `comment` | string | Worklog comment text |
| ↳ `started` | string | ISO 8601 timestamp when the work started |
| ↳ `timeSpent` | string | Time spent in human-readable format \(e.g., 3h 20m\) |
| ↳ `timeSpentSeconds` | number | Time spent in seconds |
| ↳ `created` | string | ISO 8601 timestamp when the worklog was created |
| ↳ `updated` | string | ISO 8601 timestamp when the worklog was last updated |
| `attachments` | array | Issue attachments |
| ↳ `id` | string | Attachment ID |
| ↳ `filename` | string | Attachment file name |
| ↳ `mimeType` | string | MIME type of the attachment |
| ↳ `size` | number | File size in bytes |
| ↳ `content` | string | URL to download the attachment content |
| ↳ `thumbnail` | string | URL to the attachment thumbnail |
| ↳ `author` | object | Attachment author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `created` | string | ISO 8601 timestamp when the attachment was created |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key \(e.g., PROJ-123\) |
| `issue` | json | Complete raw Jira issue object from the API |
| `summary` | string | Issue summary |
| `description` | json | Issue description content |
| `created` | string | Issue creation timestamp |
| `updated` | string | Issue last updated timestamp |
| `issue` | json | Complete issue object with all fields |
### `jira_update`
@@ -238,32 +68,26 @@ Update a Jira issue
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `projectId` | string | No | Jira project key \(e.g., PROJ\). Optional when updating a single issue. |
| `issueKey` | string | Yes | Jira issue key to update \(e.g., PROJ-123\) |
| `summary` | string | No | New summary for the issue |
| `description` | string | No | New description for the issue |
| `priority` | string | No | New priority ID or name for the issue \(e.g., "High"\) |
| `assignee` | string | No | New assignee account ID for the issue |
| `labels` | json | No | Labels to set on the issue \(array of label name strings\) |
| `components` | json | No | Components to set on the issue \(array of component name strings\) |
| `duedate` | string | No | Due date for the issue \(format: YYYY-MM-DD\) |
| `fixVersions` | json | No | Fix versions to set \(array of version name strings\) |
| `environment` | string | No | Environment information for the issue |
| `customFieldId` | string | No | Custom field ID to update \(e.g., customfield_10001\) |
| `customFieldValue` | string | No | Value for the custom field |
| `notifyUsers` | boolean | No | Whether to send email notifications about this update \(default: true\) |
| `status` | string | No | New status for the issue |
| `priority` | string | No | New priority for the issue |
| `assignee` | string | No | New assignee for the issue |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Updated issue key \(e.g., PROJ-123\) |
| `summary` | string | Issue summary after update |
### `jira_write`
Create a new Jira issue
Write a Jira issue
#### Input
@@ -276,12 +100,9 @@ Create a new Jira issue
| `priority` | string | No | Priority ID or name for the issue \(e.g., "10000" or "High"\) |
| `assignee` | string | No | Assignee account ID for the issue |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
| `issueType` | string | Yes | Type of issue to create \(e.g., Task, Story, Bug, Epic, Sub-task\) |
| `parent` | json | No | Parent issue key for creating subtasks \(e.g., \{ "key": "PROJ-123" \}\) |
| `issueType` | string | Yes | Type of issue to create \(e.g., Task, Story\) |
| `labels` | array | No | Labels for the issue \(array of label names\) |
| `components` | array | No | Components for the issue \(array of component names\) |
| `duedate` | string | No | Due date for the issue \(format: YYYY-MM-DD\) |
| `fixVersions` | array | No | Fix versions for the issue \(array of version names\) |
| `reporter` | string | No | Reporter account ID for the issue |
| `environment` | string | No | Environment information for the issue |
| `customFieldId` | string | No | Custom field ID \(e.g., customfield_10001\) |
@@ -291,17 +112,15 @@ Create a new Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `id` | string | Created issue ID |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Created issue key \(e.g., PROJ-123\) |
| `self` | string | REST API URL for the created issue |
| `summary` | string | Issue summary |
| `url` | string | URL to the created issue in Jira |
| `assigneeId` | string | Account ID of the assigned user \(null if no assignee was set\) |
| `url` | string | URL to the created issue |
| `assigneeId` | string | Account ID of the assigned user \(if assigned\) |
### `jira_bulk_read`
Retrieve multiple Jira issues from a project in bulk
Retrieve multiple Jira issues in bulk
#### Input
@@ -315,30 +134,7 @@ Retrieve multiple Jira issues from a project in bulk
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `total` | number | Total number of issues in the project \(may not always be available\) |
| `issues` | array | Array of Jira issues |
| ↳ `id` | string | Issue ID |
| ↳ `key` | string | Issue key \(e.g., PROJ-123\) |
| ↳ `self` | string | REST API URL for this issue |
| ↳ `summary` | string | Issue summary |
| ↳ `description` | string | Issue description text |
| ↳ `status` | object | Issue status |
| ↳ `id` | string | Status ID |
| ↳ `name` | string | Status name |
| ↳ `issuetype` | object | Issue type |
| ↳ `id` | string | Issue type ID |
| ↳ `name` | string | Issue type name |
| ↳ `priority` | object | Issue priority |
| ↳ `id` | string | Priority ID |
| ↳ `name` | string | Priority name |
| ↳ `assignee` | object | Assigned user |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | Display name |
| ↳ `created` | string | ISO 8601 creation timestamp |
| ↳ `updated` | string | ISO 8601 last updated timestamp |
| `nextPageToken` | string | Cursor token for the next page. Null when no more results. |
| `isLast` | boolean | Whether this is the last page of results |
| `issues` | array | Array of Jira issues with ts, summary, description, created, and updated timestamps |
### `jira_delete_issue`
@@ -357,7 +153,7 @@ Delete a Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Deleted issue key |
### `jira_assign_issue`
@@ -377,9 +173,9 @@ Assign a Jira issue to a user
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key that was assigned |
| `assigneeId` | string | Account ID of the assignee \(use "-1" for auto-assign, null to unassign\) |
| `assigneeId` | string | Account ID of the assignee |
### `jira_transition_issue`
@@ -393,20 +189,15 @@ Move a Jira issue between workflow statuses (e.g., To Do -> In Progress)
| `issueKey` | string | Yes | Jira issue key to transition \(e.g., PROJ-123\) |
| `transitionId` | string | Yes | ID of the transition to execute \(e.g., "11" for "To Do", "21" for "In Progress"\) |
| `comment` | string | No | Optional comment to add when transitioning the issue |
| `resolution` | string | No | Resolution name to set during transition \(e.g., "Fixed", "Won\'t Fix"\) |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key that was transitioned |
| `transitionId` | string | Applied transition ID |
| `transitionName` | string | Applied transition name |
| `toStatus` | object | Target status after transition |
| ↳ `id` | string | Status ID |
| ↳ `name` | string | Status name |
### `jira_search_issues`
@@ -418,77 +209,20 @@ Search for Jira issues using JQL (Jira Query Language)
| --------- | ---- | -------- | ----------- |
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `jql` | string | Yes | JQL query string to search for issues \(e.g., "project = PROJ AND status = Open"\) |
| `nextPageToken` | string | No | Cursor token for the next page of results. Omit for the first page. |
| `maxResults` | number | No | Maximum number of results to return per page \(default: 50\) |
| `fields` | array | No | Array of field names to return \(default: all navigable\). Use "*all" for every field. |
| `startAt` | number | No | The index of the first result to return \(for pagination\) |
| `maxResults` | number | No | Maximum number of results to return \(default: 50\) |
| `fields` | array | No | Array of field names to return \(default: \['summary', 'status', 'assignee', 'created', 'updated'\]\) |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `issues` | array | Array of matching issues |
| ↳ `id` | string | Issue ID |
| ↳ `key` | string | Issue key \(e.g., PROJ-123\) |
| ↳ `self` | string | REST API URL for this issue |
| ↳ `summary` | string | Issue summary |
| ↳ `description` | string | Issue description text \(extracted from ADF\) |
| ↳ `status` | object | Issue status |
| ↳ `id` | string | Status ID |
| ↳ `name` | string | Status name \(e.g., Open, In Progress, Done\) |
| ↳ `description` | string | Status description |
| ↳ `statusCategory` | object | Status category grouping |
| ↳ `id` | number | Status category ID |
| ↳ `key` | string | Status category key \(e.g., new, indeterminate, done\) |
| ↳ `name` | string | Status category name \(e.g., To Do, In Progress, Done\) |
| ↳ `colorName` | string | Status category color \(e.g., blue-gray, yellow, green\) |
| ↳ `issuetype` | object | Issue type |
| ↳ `id` | string | Issue type ID |
| ↳ `name` | string | Issue type name \(e.g., Task, Bug, Story, Epic\) |
| ↳ `description` | string | Issue type description |
| ↳ `subtask` | boolean | Whether this is a subtask type |
| ↳ `iconUrl` | string | URL to the issue type icon |
| ↳ `project` | object | Project the issue belongs to |
| ↳ `id` | string | Project ID |
| ↳ `key` | string | Project key \(e.g., PROJ\) |
| ↳ `name` | string | Project name |
| ↳ `projectTypeKey` | string | Project type key \(e.g., software, business\) |
| ↳ `priority` | object | Issue priority |
| ↳ `id` | string | Priority ID |
| ↳ `name` | string | Priority name \(e.g., Highest, High, Medium, Low, Lowest\) |
| ↳ `iconUrl` | string | URL to the priority icon |
| ↳ `assignee` | object | Assigned user |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `reporter` | object | Reporter user |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `labels` | array | Issue labels |
| ↳ `components` | array | Issue components |
| ↳ `id` | string | Component ID |
| ↳ `name` | string | Component name |
| ↳ `description` | string | Component description |
| ↳ `resolution` | object | Issue resolution |
| ↳ `id` | string | Resolution ID |
| ↳ `name` | string | Resolution name \(e.g., Fixed, Duplicate, Won't Fix\) |
| ↳ `description` | string | Resolution description |
| ↳ `duedate` | string | Due date \(YYYY-MM-DD\) |
| ↳ `created` | string | ISO 8601 timestamp when the issue was created |
| ↳ `updated` | string | ISO 8601 timestamp when the issue was last updated |
| `nextPageToken` | string | Cursor token for the next page. Null when no more results. |
| `isLast` | boolean | Whether this is the last page of results |
| `total` | number | Total number of matching issues \(may not always be available\) |
| `ts` | string | Timestamp of the operation |
| `total` | number | Total number of matching issues |
| `startAt` | number | Pagination start index |
| `maxResults` | number | Maximum results per page |
| `issues` | array | Array of matching issues with key, summary, status, assignee, created, updated |
### `jira_add_comment`
@@ -501,27 +235,16 @@ Add a comment to a Jira issue
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `issueKey` | string | Yes | Jira issue key to add comment to \(e.g., PROJ-123\) |
| `body` | string | Yes | Comment body text |
| `visibility` | json | No | Restrict comment visibility. Object with "type" \("role" or "group"\) and "value" \(role/group name\). |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key the comment was added to |
| `commentId` | string | Created comment ID |
| `body` | string | Comment text content |
| `author` | object | Comment author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `created` | string | ISO 8601 timestamp when the comment was created |
| `updated` | string | ISO 8601 timestamp when the comment was last updated |
### `jira_get_comments`
@@ -535,42 +258,16 @@ Get all comments from a Jira issue
| `issueKey` | string | Yes | Jira issue key to get comments from \(e.g., PROJ-123\) |
| `startAt` | number | No | Index of the first comment to return \(default: 0\) |
| `maxResults` | number | No | Maximum number of comments to return \(default: 50\) |
| `orderBy` | string | No | Sort order for comments: "-created" for newest first, "created" for oldest first |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `total` | number | Total number of comments |
| `startAt` | number | Pagination start index |
| `maxResults` | number | Maximum results per page |
| `comments` | array | Array of comments |
| ↳ `id` | string | Comment ID |
| ↳ `body` | string | Comment body text \(extracted from ADF\) |
| ↳ `author` | object | Comment author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `updateAuthor` | object | User who last updated the comment |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `created` | string | ISO 8601 timestamp when the comment was created |
| ↳ `updated` | string | ISO 8601 timestamp when the comment was last updated |
| ↳ `visibility` | object | Comment visibility restriction |
| ↳ `type` | string | Restriction type \(e.g., role, group\) |
| ↳ `value` | string | Restriction value \(e.g., Administrators\) |
| `comments` | array | Array of comments with id, author, body, created, updated |
### `jira_update_comment`
@@ -584,27 +281,16 @@ Update an existing comment on a Jira issue
| `issueKey` | string | Yes | Jira issue key containing the comment \(e.g., PROJ-123\) |
| `commentId` | string | Yes | ID of the comment to update |
| `body` | string | Yes | Updated comment text |
| `visibility` | json | No | Restrict comment visibility. Object with "type" \("role" or "group"\) and "value" \(role/group name\). |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `commentId` | string | Updated comment ID |
| `body` | string | Updated comment text |
| `author` | object | Comment author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `created` | string | ISO 8601 timestamp when the comment was created |
| `updated` | string | ISO 8601 timestamp when the comment was last updated |
### `jira_delete_comment`
@@ -623,7 +309,7 @@ Delete a comment from a Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `commentId` | string | Deleted comment ID |
@@ -643,24 +329,9 @@ Get all attachments from a Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `attachments` | array | Array of attachments |
| ↳ `id` | string | Attachment ID |
| ↳ `filename` | string | Attachment file name |
| ↳ `mimeType` | string | MIME type of the attachment |
| ↳ `size` | number | File size in bytes |
| ↳ `content` | string | URL to download the attachment content |
| ↳ `thumbnail` | string | URL to the attachment thumbnail |
| ↳ `author` | object | Attachment author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `created` | string | ISO 8601 timestamp when the attachment was created |
| `attachments` | array | Array of attachments with id, filename, size, mimeType, created, author |
### `jira_add_attachment`
@@ -679,19 +350,10 @@ Add attachments to a Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `attachments` | array | Uploaded attachments |
| ↳ `id` | string | Attachment ID |
| ↳ `filename` | string | Attachment file name |
| ↳ `mimeType` | string | MIME type |
| ↳ `size` | number | File size in bytes |
| ↳ `content` | string | URL to download the attachment |
| `attachmentIds` | array | Array of attachment IDs |
| `files` | array | Uploaded file metadata |
| ↳ `name` | string | File name |
| ↳ `mimeType` | string | MIME type |
| ↳ `size` | number | File size in bytes |
| `attachmentIds` | json | IDs of uploaded attachments |
| `files` | file[] | Uploaded attachment files |
### `jira_delete_attachment`
@@ -709,7 +371,7 @@ Delete an attachment from a Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `attachmentId` | string | Deleted attachment ID |
### `jira_add_worklog`
@@ -725,28 +387,16 @@ Add a time tracking worklog entry to a Jira issue
| `timeSpentSeconds` | number | Yes | Time spent in seconds |
| `comment` | string | No | Optional comment for the worklog entry |
| `started` | string | No | Optional start time in ISO format \(defaults to current time\) |
| `visibility` | json | No | Restrict worklog visibility. Object with "type" \("role" or "group"\) and "value" \(role/group name\). |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key the worklog was added to |
| `worklogId` | string | Created worklog ID |
| `timeSpent` | string | Time spent in human-readable format \(e.g., 3h 20m\) |
| `timeSpentSeconds` | number | Time spent in seconds |
| `author` | object | Worklog author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `started` | string | ISO 8601 timestamp when the work started |
| `created` | string | ISO 8601 timestamp when the worklog was created |
### `jira_get_worklogs`
@@ -766,35 +416,10 @@ Get all worklog entries from a Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `total` | number | Total number of worklogs |
| `startAt` | number | Pagination start index |
| `maxResults` | number | Maximum results per page |
| `worklogs` | array | Array of worklogs |
| ↳ `id` | string | Worklog ID |
| ↳ `author` | object | Worklog author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `updateAuthor` | object | User who last updated the worklog |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| ↳ `comment` | string | Worklog comment text |
| ↳ `started` | string | ISO 8601 timestamp when the work started |
| ↳ `timeSpent` | string | Time spent in human-readable format \(e.g., 3h 20m\) |
| ↳ `timeSpentSeconds` | number | Time spent in seconds |
| ↳ `created` | string | ISO 8601 timestamp when the worklog was created |
| ↳ `updated` | string | ISO 8601 timestamp when the worklog was last updated |
| `worklogs` | array | Array of worklogs with id, author, timeSpentSeconds, timeSpent, comment, created, updated, started |
### `jira_update_worklog`
@@ -810,38 +435,15 @@ Update an existing worklog entry on a Jira issue
| `timeSpentSeconds` | number | No | Time spent in seconds |
| `comment` | string | No | Optional comment for the worklog entry |
| `started` | string | No | Optional start time in ISO format |
| `visibility` | json | No | Restrict worklog visibility. Object with "type" \("role" or "group"\) and "value" \(role/group name\). |
| `cloudId` | string | No | Jira Cloud ID for the instance. If not provided, it will be fetched using the domain. |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `worklogId` | string | Updated worklog ID |
| `timeSpent` | string | Human-readable time spent \(e.g., "3h 20m"\) |
| `timeSpentSeconds` | number | Time spent in seconds |
| `comment` | string | Worklog comment text |
| `author` | object | Worklog author |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `updateAuthor` | object | User who last updated the worklog |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `started` | string | Worklog start time in ISO format |
| `created` | string | Worklog creation time |
| `updated` | string | Worklog last update time |
### `jira_delete_worklog`
@@ -860,7 +462,7 @@ Delete a worklog entry from a Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `worklogId` | string | Deleted worklog ID |
@@ -883,7 +485,7 @@ Create a link relationship between two Jira issues
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `inwardIssue` | string | Inward issue key |
| `outwardIssue` | string | Outward issue key |
| `linkType` | string | Type of issue link |
@@ -905,7 +507,7 @@ Delete a link between two Jira issues
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `linkId` | string | Deleted link ID |
### `jira_add_watcher`
@@ -925,7 +527,7 @@ Add a watcher to a Jira issue to receive notifications about updates
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `watcherAccountId` | string | Added watcher account ID |
@@ -946,7 +548,7 @@ Remove a watcher from a Jira issue
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `ts` | string | Timestamp of the operation |
| `issueKey` | string | Issue key |
| `watcherAccountId` | string | Removed watcher account ID |
@@ -968,15 +570,8 @@ Get Jira users. If an account ID is provided, returns a single user. Otherwise,
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | ISO 8601 timestamp of the operation |
| `users` | array | Array of Jira users |
| ↳ `accountId` | string | Atlassian account ID of the user |
| ↳ `displayName` | string | Display name of the user |
| ↳ `active` | boolean | Whether the user account is active |
| ↳ `emailAddress` | string | Email address of the user |
| ↳ `accountType` | string | Type of account \(e.g., atlassian, app, customer\) |
| ↳ `avatarUrl` | string | URL to the user avatar \(48x48\) |
| ↳ `timeZone` | string | User timezone |
| `ts` | string | Timestamp of the operation |
| `users` | json | Array of users with accountId, displayName, emailAddress, active status, and avatarUrls |
| `total` | number | Total number of users returned |
| `startAt` | number | Pagination start index |
| `maxResults` | number | Maximum results per page |

View File

@@ -46,7 +46,6 @@ Get all service desks from Jira Service Management
| --------- | ---- | -------- | ----------- |
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `cloudId` | string | No | Jira Cloud ID for the instance |
| `expand` | string | No | Comma-separated fields to expand in the response |
| `start` | number | No | Start index for pagination \(e.g., 0, 50, 100\) |
| `limit` | number | No | Maximum results to return \(e.g., 10, 25, 50\) |
@@ -55,14 +54,7 @@ Get all service desks from Jira Service Management
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `serviceDesks` | array | List of service desks |
| ↳ `id` | string | Service desk ID |
| ↳ `projectId` | string | Associated Jira project ID |
| ↳ `projectName` | string | Associated project name |
| ↳ `projectKey` | string | Associated project key |
| ↳ `name` | string | Service desk name |
| ↳ `description` | string | Service desk description |
| ↳ `leadDisplayName` | string | Project lead display name |
| `serviceDesks` | json | Array of service desks |
| `total` | number | Total number of service desks |
| `isLastPage` | boolean | Whether this is the last page |
@@ -77,9 +69,6 @@ Get request types for a service desk in Jira Service Management
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `cloudId` | string | No | Jira Cloud ID for the instance |
| `serviceDeskId` | string | Yes | Service Desk ID \(e.g., "1", "2"\) |
| `searchQuery` | string | No | Filter request types by name |
| `groupId` | string | No | Filter by request type group ID |
| `expand` | string | No | Comma-separated fields to expand in the response |
| `start` | number | No | Start index for pagination \(e.g., 0, 50, 100\) |
| `limit` | number | No | Maximum results to return \(e.g., 10, 25, 50\) |
@@ -88,16 +77,7 @@ Get request types for a service desk in Jira Service Management
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `requestTypes` | array | List of request types |
| ↳ `id` | string | Request type ID |
| ↳ `name` | string | Request type name |
| ↳ `description` | string | Request type description |
| ↳ `helpText` | string | Help text for customers |
| ↳ `issueTypeId` | string | Associated Jira issue type ID |
| ↳ `serviceDeskId` | string | Parent service desk ID |
| ↳ `groupIds` | json | Groups this request type belongs to |
| ↳ `icon` | json | Request type icon with id and links |
| ↳ `restrictionStatus` | string | OPEN or RESTRICTED |
| `requestTypes` | json | Array of request types |
| `total` | number | Total number of request types |
| `isLastPage` | boolean | Whether this is the last page |
@@ -116,9 +96,6 @@ Create a new service request in Jira Service Management
| `summary` | string | Yes | Summary/title for the service request |
| `description` | string | No | Description for the service request |
| `raiseOnBehalfOf` | string | No | Account ID of customer to raise request on behalf of |
| `requestFieldValues` | json | No | Custom field values as key-value pairs \(overrides summary/description if provided\) |
| `requestParticipants` | string | No | Comma-separated account IDs to add as request participants |
| `channel` | string | No | Channel the request originates from \(e.g., portal, email\) |
#### Output
@@ -129,9 +106,6 @@ Create a new service request in Jira Service Management
| `issueKey` | string | Created request issue key \(e.g., SD-123\) |
| `requestTypeId` | string | Request type ID |
| `serviceDeskId` | string | Service desk ID |
| `createdDate` | json | Creation date with iso8601, friendly, epochMillis |
| `currentStatus` | json | Current status with status name and category |
| `reporter` | json | Reporter user with accountId, displayName, emailAddress |
| `success` | boolean | Whether the request was created successfully |
| `url` | string | URL to the created request |
@@ -146,33 +120,12 @@ Get a single service request from Jira Service Management
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `cloudId` | string | No | Jira Cloud ID for the instance |
| `issueIdOrKey` | string | Yes | Issue ID or key \(e.g., SD-123\) |
| `expand` | string | No | Comma-separated fields to expand: participant, status, sla, requestType, serviceDesk, attachment, comment, action |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `issueId` | string | Jira issue ID |
| `issueKey` | string | Issue key \(e.g., SD-123\) |
| `requestTypeId` | string | Request type ID |
| `serviceDeskId` | string | Service desk ID |
| `createdDate` | json | Creation date with iso8601, friendly, epochMillis |
| `currentStatus` | object | Current request status |
| ↳ `status` | string | Status name |
| ↳ `statusCategory` | string | Status category \(NEW, INDETERMINATE, DONE\) |
| ↳ `statusDate` | json | Status change date with iso8601, friendly, epochMillis |
| `reporter` | object | Reporter user details |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | User display name |
| ↳ `emailAddress` | string | User email address |
| ↳ `active` | boolean | Whether the account is active |
| `requestFieldValues` | array | Request field values |
| ↳ `fieldId` | string | Field identifier |
| ↳ `label` | string | Human-readable field label |
| ↳ `value` | json | Field value |
| ↳ `renderedValue` | json | HTML-rendered field value |
| `url` | string | URL to the request |
| `request` | json | The service request object |
### `jsm_get_requests`
@@ -186,11 +139,9 @@ Get multiple service requests from Jira Service Management
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `cloudId` | string | No | Jira Cloud ID for the instance |
| `serviceDeskId` | string | No | Filter by service desk ID \(e.g., "1", "2"\) |
| `requestOwnership` | string | No | Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, APPROVER, ALL_REQUESTS |
| `requestStatus` | string | No | Filter by status: OPEN_REQUESTS, CLOSED_REQUESTS, ALL_REQUESTS |
| `requestTypeId` | string | No | Filter by request type ID |
| `requestOwnership` | string | No | Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, ORGANIZATION, ALL_REQUESTS |
| `requestStatus` | string | No | Filter by status: OPEN, CLOSED, ALL |
| `searchTerm` | string | No | Search term to filter requests \(e.g., "password reset", "laptop"\) |
| `expand` | string | No | Comma-separated fields to expand: participant, status, sla, requestType, serviceDesk, attachment, comment, action |
| `start` | number | No | Start index for pagination \(e.g., 0, 50, 100\) |
| `limit` | number | No | Maximum results to return \(e.g., 10, 25, 50\) |
@@ -199,27 +150,8 @@ Get multiple service requests from Jira Service Management
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `requests` | array | List of service requests |
| ↳ `issueId` | string | Jira issue ID |
| ↳ `issueKey` | string | Issue key \(e.g., SD-123\) |
| ↳ `requestTypeId` | string | Request type ID |
| ↳ `serviceDeskId` | string | Service desk ID |
| ↳ `createdDate` | json | Creation date with iso8601, friendly, epochMillis |
| ↳ `currentStatus` | object | Current request status |
| ↳ `status` | string | Status name |
| ↳ `statusCategory` | string | Status category \(NEW, INDETERMINATE, DONE\) |
| ↳ `statusDate` | json | Status change date with iso8601, friendly, epochMillis |
| ↳ `reporter` | object | Reporter user details |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | User display name |
| ↳ `emailAddress` | string | User email address |
| ↳ `active` | boolean | Whether the account is active |
| ↳ `requestFieldValues` | array | Request field values |
| ↳ `fieldId` | string | Field identifier |
| ↳ `label` | string | Human-readable field label |
| ↳ `value` | json | Field value |
| ↳ `renderedValue` | json | HTML-rendered field value |
| `total` | number | Total number of requests in current page |
| `requests` | json | Array of service requests |
| `total` | number | Total number of requests |
| `isLastPage` | boolean | Whether this is the last page |
### `jsm_add_comment`
@@ -245,12 +177,6 @@ Add a comment (public or internal) to a service request in Jira Service Manageme
| `commentId` | string | Created comment ID |
| `body` | string | Comment body text |
| `isPublic` | boolean | Whether the comment is public |
| `author` | object | Comment author |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | User display name |
| ↳ `emailAddress` | string | User email address |
| ↳ `active` | boolean | Whether the account is active |
| `createdDate` | json | Comment creation date with iso8601, friendly, epochMillis |
| `success` | boolean | Whether the comment was added successfully |
### `jsm_get_comments`
@@ -266,7 +192,6 @@ Get comments for a service request in Jira Service Management
| `issueIdOrKey` | string | Yes | Issue ID or key \(e.g., SD-123\) |
| `isPublic` | boolean | No | Filter to only public comments \(true/false\) |
| `internal` | boolean | No | Filter to only internal comments \(true/false\) |
| `expand` | string | No | Comma-separated fields to expand: renderedBody, attachment |
| `start` | number | No | Start index for pagination \(e.g., 0, 50, 100\) |
| `limit` | number | No | Maximum results to return \(e.g., 10, 25, 50\) |
@@ -276,17 +201,7 @@ Get comments for a service request in Jira Service Management
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `issueIdOrKey` | string | Issue ID or key |
| `comments` | array | List of comments |
| ↳ `id` | string | Comment ID |
| ↳ `body` | string | Comment body text |
| ↳ `public` | boolean | Whether the comment is public |
| ↳ `author` | object | Comment author |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | User display name |
| ↳ `emailAddress` | string | User email address |
| ↳ `active` | boolean | Whether the account is active |
| ↳ `created` | json | Creation date with iso8601, friendly, epochMillis |
| ↳ `renderedBody` | json | HTML-rendered comment body \(when expand=renderedBody\) |
| `comments` | json | Array of comments |
| `total` | number | Total number of comments |
| `isLastPage` | boolean | Whether this is the last page |
@@ -310,12 +225,7 @@ Get customers for a service desk in Jira Service Management
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `customers` | array | List of customers |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | Display name |
| ↳ `emailAddress` | string | Email address |
| ↳ `active` | boolean | Whether the account is active |
| ↳ `timeZone` | string | User timezone |
| `customers` | json | Array of customers |
| `total` | number | Total number of customers |
| `isLastPage` | boolean | Whether this is the last page |
@@ -330,8 +240,7 @@ Add customers to a service desk in Jira Service Management
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `cloudId` | string | No | Jira Cloud ID for the instance |
| `serviceDeskId` | string | Yes | Service Desk ID \(e.g., "1", "2"\) |
| `accountIds` | string | No | Comma-separated Atlassian account IDs to add as customers |
| `emails` | string | No | Comma-separated email addresses to add as customers |
| `emails` | string | Yes | Comma-separated email addresses to add as customers |
#### Output
@@ -360,9 +269,7 @@ Get organizations for a service desk in Jira Service Management
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `organizations` | array | List of organizations |
| ↳ `id` | string | Organization ID |
| ↳ `name` | string | Organization name |
| `organizations` | json | Array of organizations |
| `total` | number | Total number of organizations |
| `isLastPage` | boolean | Whether this is the last page |
@@ -429,12 +336,7 @@ Get queues for a service desk in Jira Service Management
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `queues` | array | List of queues |
| ↳ `id` | string | Queue ID |
| ↳ `name` | string | Queue name |
| ↳ `jql` | string | JQL filter for the queue |
| ↳ `fields` | json | Fields displayed in the queue |
| ↳ `issueCount` | number | Number of issues in the queue |
| `queues` | json | Array of queues |
| `total` | number | Total number of queues |
| `isLastPage` | boolean | Whether this is the last page |
@@ -458,11 +360,7 @@ Get SLA information for a service request in Jira Service Management
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `issueIdOrKey` | string | Issue ID or key |
| `slas` | array | List of SLA metrics |
| ↳ `id` | string | SLA metric ID |
| ↳ `name` | string | SLA metric name |
| ↳ `completedCycles` | json | Completed SLA cycles with startTime, stopTime, breachTime, breached, goalDuration, elapsedTime, remainingTime \(each time as DateDTO, durations as DurationDTO\) |
| ↳ `ongoingCycle` | json | Ongoing SLA cycle with startTime, breachTime, breached, paused, withinCalendarHours, goalDuration, elapsedTime, remainingTime |
| `slas` | json | Array of SLA information |
| `total` | number | Total number of SLAs |
| `isLastPage` | boolean | Whether this is the last page |
@@ -477,8 +375,6 @@ Get available transitions for a service request in Jira Service Management
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `cloudId` | string | No | Jira Cloud ID for the instance |
| `issueIdOrKey` | string | Yes | Issue ID or key \(e.g., SD-123\) |
| `start` | number | No | Start index for pagination \(e.g., 0, 50, 100\) |
| `limit` | number | No | Maximum results to return \(e.g., 10, 25, 50\) |
#### Output
@@ -486,11 +382,7 @@ Get available transitions for a service request in Jira Service Management
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `issueIdOrKey` | string | Issue ID or key |
| `transitions` | array | List of available transitions |
| ↳ `id` | string | Transition ID |
| ↳ `name` | string | Transition name |
| `total` | number | Total number of transitions |
| `isLastPage` | boolean | Whether this is the last page |
| `transitions` | json | Array of available transitions |
### `jsm_transition_request`
@@ -535,11 +427,7 @@ Get participants for a request in Jira Service Management
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `issueIdOrKey` | string | Issue ID or key |
| `participants` | array | List of participants |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | Display name |
| ↳ `emailAddress` | string | Email address |
| ↳ `active` | boolean | Whether the account is active |
| `participants` | json | Array of participants |
| `total` | number | Total number of participants |
| `isLastPage` | boolean | Whether this is the last page |
@@ -562,11 +450,7 @@ Add participants to a request in Jira Service Management
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `issueIdOrKey` | string | Issue ID or key |
| `participants` | array | List of added participants |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | Display name |
| ↳ `emailAddress` | string | Email address |
| ↳ `active` | boolean | Whether the account is active |
| `participants` | json | Array of added participants |
| `success` | boolean | Whether the operation succeeded |
### `jsm_get_approvals`
@@ -589,20 +473,7 @@ Get approvals for a request in Jira Service Management
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `issueIdOrKey` | string | Issue ID or key |
| `approvals` | array | List of approvals |
| ↳ `id` | string | Approval ID |
| ↳ `name` | string | Approval description |
| ↳ `finalDecision` | string | Final decision: pending, approved, or declined |
| ↳ `canAnswerApproval` | boolean | Whether current user can respond |
| ↳ `approvers` | array | List of approvers with their decisions |
| ↳ `approver` | object | Approver user details |
| ↳ `accountId` | string | Atlassian account ID |
| ↳ `displayName` | string | User display name |
| ↳ `emailAddress` | string | User email address |
| ↳ `active` | boolean | Whether the account is active |
| ↳ `approverDecision` | string | Decision: pending, approved, or declined |
| ↳ `createdDate` | json | Creation date |
| ↳ `completedDate` | json | Completion date |
| `approvals` | json | Array of approvals |
| `total` | number | Total number of approvals |
| `isLastPage` | boolean | Whether this is the last page |
@@ -628,53 +499,6 @@ Approve or decline an approval request in Jira Service Management
| `issueIdOrKey` | string | Issue ID or key |
| `approvalId` | string | Approval ID |
| `decision` | string | Decision made \(approve/decline\) |
| `id` | string | Approval ID from response |
| `name` | string | Approval description |
| `finalDecision` | string | Final approval decision: pending, approved, or declined |
| `canAnswerApproval` | boolean | Whether the current user can still respond |
| `approvers` | array | Updated list of approvers with decisions |
| ↳ `approver` | object | Approver user details |
| ↳ `accountId` | string | Approver account ID |
| ↳ `displayName` | string | Approver display name |
| ↳ `emailAddress` | string | Approver email |
| ↳ `active` | boolean | Whether the account is active |
| ↳ `approverDecision` | string | Individual approver decision |
| `createdDate` | json | Approval creation date |
| `completedDate` | json | Approval completion date |
| `approval` | json | The approval object |
| `success` | boolean | Whether the operation succeeded |
### `jsm_get_request_type_fields`
Get the fields required to create a request of a specific type in Jira Service Management
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `cloudId` | string | No | Jira Cloud ID for the instance |
| `serviceDeskId` | string | Yes | Service Desk ID \(e.g., "1", "2"\) |
| `requestTypeId` | string | Yes | Request Type ID \(e.g., "10", "15"\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `ts` | string | Timestamp of the operation |
| `serviceDeskId` | string | Service desk ID |
| `requestTypeId` | string | Request type ID |
| `canAddRequestParticipants` | boolean | Whether participants can be added to requests of this type |
| `canRaiseOnBehalfOf` | boolean | Whether requests can be raised on behalf of another user |
| `requestTypeFields` | array | List of fields for this request type |
| ↳ `fieldId` | string | Field identifier \(e.g., summary, description, customfield_10010\) |
| ↳ `name` | string | Human-readable field name |
| ↳ `description` | string | Help text for the field |
| ↳ `required` | boolean | Whether the field is required |
| ↳ `visible` | boolean | Whether the field is visible |
| ↳ `validValues` | json | Allowed values for select fields |
| ↳ `presetValues` | json | Pre-populated values |
| ↳ `defaultValues` | json | Default values for the field |
| ↳ `jiraSchema` | json | Jira field schema with type, system, custom, customId |

View File

@@ -76,7 +76,6 @@
"neo4j",
"notion",
"onedrive",
"onepassword",
"openai",
"outlook",
"parallel_ai",

View File

@@ -1,260 +0,0 @@
---
title: 1Password
description: Manage secrets and items in 1Password vaults
---
import { BlockInfoCard } from "@/components/ui/block-info-card"
<BlockInfoCard
type="onepassword"
color="#E0E0E0"
/>
{/* MANUAL-CONTENT-START:intro */}
[1Password](https://1password.com) is a widely trusted password manager and secrets vault solution, allowing individuals and teams to securely store, access, and share passwords, API credentials, and sensitive information. With robust encryption, granular access controls, and seamless syncing across devices, 1Password supports teams and organizations in managing secrets efficiently and securely.
The [1Password Connect API](https://developer.1password.com/docs/connect/) allows programmatic access to vaults and items within an organization's 1Password account. This integration in Sim lets you automate secret retrieval, onboarding workflows, secret rotation, vault audits, and more, all in a secure and auditable manner.
With 1Password in your Sim workflow, you can:
- **List, search, and retrieve vaults**: Access metadata or browse available vaults for organizing secrets by project or purpose
- **Fetch items and secrets**: Get credentials, API keys, or custom secrets in real time to power your workflows securely
- **Create, update, or delete secrets**: Automate secret management, provisioning, and rotation for enhanced security practices
- **Integrate with CI/CD and automation**: Fetch credentials or tokens only when needed, reducing manual work and reducing risk
- **Ensure access controls**: Leverage role-based access and fine-grained permissions to control which agents or users can access specific secrets
By connecting Sim with 1Password, you empower your agents to securely manage secrets, reduce manual overhead, and maintain best practices for security automation, incident response, and DevOps workflows—all while ensuring secrets never leave a controlled environment.
{/* MANUAL-CONTENT-END */}
## Usage Instructions
Access and manage secrets stored in 1Password vaults using the Connect API or Service Account SDK. List vaults, retrieve items with their fields and secrets, create new items, update existing ones, delete items, and resolve secret references.
## Tools
### `onepassword_list_vaults`
List all vaults accessible by the Connect token or Service Account
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: "service_account" or "connect" |
| `serviceAccountToken` | string | No | 1Password Service Account token \(for Service Account mode\) |
| `apiKey` | string | No | 1Password Connect API token \(for Connect Server mode\) |
| `serverUrl` | string | No | 1Password Connect server URL \(for Connect Server mode\) |
| `filter` | string | No | SCIM filter expression \(e.g., name eq "My Vault"\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `vaults` | array | List of accessible vaults |
| ↳ `id` | string | Vault ID |
| ↳ `name` | string | Vault name |
| ↳ `description` | string | Vault description |
| ↳ `attributeVersion` | number | Vault attribute version |
| ↳ `contentVersion` | number | Vault content version |
| ↳ `type` | string | Vault type \(USER_CREATED, PERSONAL, EVERYONE, TRANSFER\) |
| ↳ `createdAt` | string | Creation timestamp |
| ↳ `updatedAt` | string | Last update timestamp |
### `onepassword_get_vault`
Get details of a specific vault by ID
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: "service_account" or "connect" |
| `serviceAccountToken` | string | No | 1Password Service Account token \(for Service Account mode\) |
| `apiKey` | string | No | 1Password Connect API token \(for Connect Server mode\) |
| `serverUrl` | string | No | 1Password Connect server URL \(for Connect Server mode\) |
| `vaultId` | string | Yes | The vault UUID |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `id` | string | Vault ID |
| `name` | string | Vault name |
| `description` | string | Vault description |
| `attributeVersion` | number | Vault attribute version |
| `contentVersion` | number | Vault content version |
| `items` | number | Number of items in the vault |
| `type` | string | Vault type \(USER_CREATED, PERSONAL, EVERYONE, TRANSFER\) |
| `createdAt` | string | Creation timestamp |
| `updatedAt` | string | Last update timestamp |
### `onepassword_list_items`
List items in a vault. Returns summaries without field values.
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: "service_account" or "connect" |
| `serviceAccountToken` | string | No | 1Password Service Account token \(for Service Account mode\) |
| `apiKey` | string | No | 1Password Connect API token \(for Connect Server mode\) |
| `serverUrl` | string | No | 1Password Connect server URL \(for Connect Server mode\) |
| `vaultId` | string | Yes | The vault UUID to list items from |
| `filter` | string | No | SCIM filter expression \(e.g., title eq "API Key" or tag eq "production"\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `items` | array | List of items in the vault \(summaries without field values\) |
| ↳ `id` | string | Item ID |
| ↳ `title` | string | Item title |
| ↳ `vault` | object | Vault reference |
| ↳ `id` | string | Vault ID |
| ↳ `category` | string | Item category \(e.g., LOGIN, API_CREDENTIAL\) |
| ↳ `urls` | array | URLs associated with the item |
| ↳ `href` | string | URL |
| ↳ `label` | string | URL label |
| ↳ `primary` | boolean | Whether this is the primary URL |
| ↳ `favorite` | boolean | Whether the item is favorited |
| ↳ `tags` | array | Item tags |
| ↳ `version` | number | Item version number |
| ↳ `state` | string | Item state \(ARCHIVED or DELETED\) |
| ↳ `createdAt` | string | Creation timestamp |
| ↳ `updatedAt` | string | Last update timestamp |
| ↳ `lastEditedBy` | string | ID of the last editor |
### `onepassword_get_item`
Get full details of an item including all fields and secrets
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: "service_account" or "connect" |
| `serviceAccountToken` | string | No | 1Password Service Account token \(for Service Account mode\) |
| `apiKey` | string | No | 1Password Connect API token \(for Connect Server mode\) |
| `serverUrl` | string | No | 1Password Connect server URL \(for Connect Server mode\) |
| `vaultId` | string | Yes | The vault UUID |
| `itemId` | string | Yes | The item UUID to retrieve |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `response` | json | Operation response data |
### `onepassword_create_item`
Create a new item in a vault
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: "service_account" or "connect" |
| `serviceAccountToken` | string | No | 1Password Service Account token \(for Service Account mode\) |
| `apiKey` | string | No | 1Password Connect API token \(for Connect Server mode\) |
| `serverUrl` | string | No | 1Password Connect server URL \(for Connect Server mode\) |
| `vaultId` | string | Yes | The vault UUID to create the item in |
| `category` | string | Yes | Item category \(e.g., LOGIN, PASSWORD, API_CREDENTIAL, SECURE_NOTE, SERVER, DATABASE\) |
| `title` | string | No | Item title |
| `tags` | string | No | Comma-separated list of tags |
| `fields` | string | No | JSON array of field objects \(e.g., \[\{"label":"username","value":"admin","type":"STRING","purpose":"USERNAME"\}\]\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `response` | json | Operation response data |
### `onepassword_replace_item`
Replace an entire item with new data (full update)
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: "service_account" or "connect" |
| `serviceAccountToken` | string | No | 1Password Service Account token \(for Service Account mode\) |
| `apiKey` | string | No | 1Password Connect API token \(for Connect Server mode\) |
| `serverUrl` | string | No | 1Password Connect server URL \(for Connect Server mode\) |
| `vaultId` | string | Yes | The vault UUID |
| `itemId` | string | Yes | The item UUID to replace |
| `item` | string | Yes | JSON object representing the full item \(e.g., \{"vault":\{"id":"..."\},"category":"LOGIN","title":"My Item","fields":\[...\]\}\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `response` | json | Operation response data |
### `onepassword_update_item`
Update an existing item using JSON Patch operations (RFC6902)
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: "service_account" or "connect" |
| `serviceAccountToken` | string | No | 1Password Service Account token \(for Service Account mode\) |
| `apiKey` | string | No | 1Password Connect API token \(for Connect Server mode\) |
| `serverUrl` | string | No | 1Password Connect server URL \(for Connect Server mode\) |
| `vaultId` | string | Yes | The vault UUID |
| `itemId` | string | Yes | The item UUID to update |
| `operations` | string | Yes | JSON array of RFC6902 patch operations \(e.g., \[\{"op":"replace","path":"/title","value":"New Title"\}\]\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `response` | json | Operation response data |
### `onepassword_delete_item`
Delete an item from a vault
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: "service_account" or "connect" |
| `serviceAccountToken` | string | No | 1Password Service Account token \(for Service Account mode\) |
| `apiKey` | string | No | 1Password Connect API token \(for Connect Server mode\) |
| `serverUrl` | string | No | 1Password Connect server URL \(for Connect Server mode\) |
| `vaultId` | string | Yes | The vault UUID |
| `itemId` | string | Yes | The item UUID to delete |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `success` | boolean | Whether the item was successfully deleted |
### `onepassword_resolve_secret`
Resolve a secret reference (op://vault/item/field) to its value. Service Account mode only.
#### Input
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `connectionMode` | string | No | Connection mode: must be "service_account" for this operation |
| `serviceAccountToken` | string | Yes | 1Password Service Account token |
| `secretReference` | string | Yes | Secret reference URI \(e.g., op://vault-name/item-name/field-name or op://vault-name/item-name/section-name/field-name\) |
#### Output
| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `value` | string | The resolved secret value |
| `reference` | string | The original secret reference URI |

View File

@@ -90,24 +90,16 @@ export async function POST(request: NextRequest) {
)
}
const jiraAttachments = await response.json()
const attachmentsList = Array.isArray(jiraAttachments) ? jiraAttachments : []
const attachmentIds = attachmentsList.map((att: any) => att.id).filter(Boolean)
const attachments = attachmentsList.map((att: any) => ({
id: att.id ?? '',
filename: att.filename ?? '',
mimeType: att.mimeType ?? '',
size: att.size ?? 0,
content: att.content ?? '',
}))
const attachments = await response.json()
const attachmentIds = Array.isArray(attachments)
? attachments.map((attachment) => attachment.id).filter(Boolean)
: []
return NextResponse.json({
success: true,
output: {
ts: new Date().toISOString(),
issueKey: validatedData.issueKey,
attachments,
attachmentIds,
files: filesOutput,
},

View File

@@ -0,0 +1,111 @@
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
import { validateJiraCloudId, validateJiraIssueKey } from '@/lib/core/security/input-validation'
import { getJiraCloudId } from '@/tools/jira/utils'
export const dynamic = 'force-dynamic'
const logger = createLogger('JiraIssueAPI')
export async function POST(request: NextRequest) {
try {
const auth = await checkSessionOrInternalAuth(request)
if (!auth.success || !auth.userId) {
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
const { domain, accessToken, issueId, cloudId: providedCloudId } = await request.json()
if (!domain) {
logger.error('Missing domain in request')
return NextResponse.json({ error: 'Domain is required' }, { status: 400 })
}
if (!accessToken) {
logger.error('Missing access token in request')
return NextResponse.json({ error: 'Access token is required' }, { status: 400 })
}
if (!issueId) {
logger.error('Missing issue ID in request')
return NextResponse.json({ error: 'Issue ID is required' }, { status: 400 })
}
const cloudId = providedCloudId || (await getJiraCloudId(domain, accessToken))
logger.info('Using cloud ID:', cloudId)
const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
if (!cloudIdValidation.isValid) {
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
}
const issueIdValidation = validateJiraIssueKey(issueId, 'issueId')
if (!issueIdValidation.isValid) {
return NextResponse.json({ error: issueIdValidation.error }, { status: 400 })
}
const url = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${issueId}`
logger.info('Fetching Jira issue from:', url)
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${accessToken}`,
Accept: 'application/json',
},
})
if (!response.ok) {
logger.error('Jira API error:', {
status: response.status,
statusText: response.statusText,
})
let errorMessage
try {
const errorData = await response.json()
logger.error('Error details:', errorData)
errorMessage = errorData.message || `Failed to fetch issue (${response.status})`
} catch (_e) {
errorMessage = `Failed to fetch issue: ${response.status} ${response.statusText}`
}
return NextResponse.json({ error: errorMessage }, { status: response.status })
}
const data = await response.json()
logger.info('Successfully fetched issue:', data.key)
const issueInfo: any = {
id: data.key,
name: data.fields.summary,
mimeType: 'jira/issue',
url: `https://${domain}/browse/${data.key}`,
modifiedTime: data.fields.updated,
webViewLink: `https://${domain}/browse/${data.key}`,
status: data.fields.status?.name,
description: data.fields.description,
priority: data.fields.priority?.name,
assignee: data.fields.assignee?.displayName,
reporter: data.fields.reporter?.displayName,
project: {
key: data.fields.project?.key,
name: data.fields.project?.name,
},
}
return NextResponse.json({
issue: issueInfo,
cloudId,
})
} catch (error) {
logger.error('Error processing request:', error)
return NextResponse.json(
{
error: 'Failed to retrieve Jira issue',
details: (error as Error).message,
},
{ status: 500 }
)
}
}

View File

@@ -16,16 +16,9 @@ const jiraUpdateSchema = z.object({
summary: z.string().optional(),
title: z.string().optional(),
description: z.string().optional(),
status: z.string().optional(),
priority: z.string().optional(),
assignee: z.string().optional(),
labels: z.array(z.string()).optional(),
components: z.array(z.string()).optional(),
duedate: z.string().optional(),
fixVersions: z.array(z.string()).optional(),
environment: z.string().optional(),
customFieldId: z.string().optional(),
customFieldValue: z.string().optional(),
notifyUsers: z.boolean().optional(),
cloudId: z.string().optional(),
})
@@ -52,16 +45,9 @@ export async function PUT(request: NextRequest) {
summary,
title,
description,
status,
priority,
assignee,
labels,
components,
duedate,
fixVersions,
environment,
customFieldId,
customFieldValue,
notifyUsers,
cloudId: providedCloudId,
} = validation.data
@@ -78,8 +64,7 @@ export async function PUT(request: NextRequest) {
return NextResponse.json({ error: issueKeyValidation.error }, { status: 400 })
}
const notifyParam = notifyUsers === false ? '?notifyUsers=false' : ''
const url = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${issueKey}${notifyParam}`
const url = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${issueKey}`
logger.info('Updating Jira issue at:', url)
@@ -108,65 +93,24 @@ export async function PUT(request: NextRequest) {
}
}
if (status !== undefined && status !== null && status !== '') {
fields.status = {
name: status,
}
}
if (priority !== undefined && priority !== null && priority !== '') {
const isNumericId = /^\d+$/.test(priority)
fields.priority = isNumericId ? { id: priority } : { name: priority }
fields.priority = {
name: priority,
}
}
if (assignee !== undefined && assignee !== null && assignee !== '') {
fields.assignee = {
accountId: assignee,
id: assignee,
}
}
if (labels !== undefined && labels !== null && labels.length > 0) {
fields.labels = labels
}
if (components !== undefined && components !== null && components.length > 0) {
fields.components = components.map((name) => ({ name }))
}
if (duedate !== undefined && duedate !== null && duedate !== '') {
fields.duedate = duedate
}
if (fixVersions !== undefined && fixVersions !== null && fixVersions.length > 0) {
fields.fixVersions = fixVersions.map((name) => ({ name }))
}
if (environment !== undefined && environment !== null && environment !== '') {
fields.environment = {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: environment,
},
],
},
],
}
}
if (
customFieldId !== undefined &&
customFieldId !== null &&
customFieldId !== '' &&
customFieldValue !== undefined &&
customFieldValue !== null &&
customFieldValue !== ''
) {
const fieldId = customFieldId.startsWith('customfield_')
? customFieldId
: `customfield_${customFieldId}`
fields[fieldId] = customFieldValue
}
const requestBody = { fields }
const response = await fetch(url, {

View File

@@ -32,8 +32,6 @@ export async function POST(request: NextRequest) {
environment,
customFieldId,
customFieldValue,
components,
fixVersions,
} = await request.json()
if (!domain) {
@@ -75,9 +73,10 @@ export async function POST(request: NextRequest) {
logger.info('Creating Jira issue at:', url)
const isNumericProjectId = /^\d+$/.test(projectId)
const fields: Record<string, any> = {
project: isNumericProjectId ? { id: projectId } : { key: projectId },
project: {
id: projectId,
},
issuetype: {
name: normalizedIssueType,
},
@@ -115,31 +114,13 @@ export async function POST(request: NextRequest) {
fields.labels = labels
}
if (
components !== undefined &&
components !== null &&
Array.isArray(components) &&
components.length > 0
) {
fields.components = components.map((name: string) => ({ name }))
}
if (duedate !== undefined && duedate !== null && duedate !== '') {
fields.duedate = duedate
}
if (
fixVersions !== undefined &&
fixVersions !== null &&
Array.isArray(fixVersions) &&
fixVersions.length > 0
) {
fields.fixVersions = fixVersions.map((name: string) => ({ name }))
}
if (reporter !== undefined && reporter !== null && reporter !== '') {
fields.reporter = {
accountId: reporter,
id: reporter,
}
}
@@ -239,10 +220,8 @@ export async function POST(request: NextRequest) {
success: true,
output: {
ts: new Date().toISOString(),
id: responseData.id || '',
issueKey: issueKey,
self: responseData.self || '',
summary: responseData.fields?.summary || summary || 'Issue created',
summary: responseData.fields?.summary || 'Issue created',
success: true,
url: `https://${domain}/browse/${issueKey}`,
...(assigneeId && { assigneeId }),

View File

@@ -165,26 +165,8 @@ export async function POST(request: NextRequest) {
issueIdOrKey,
approvalId,
decision,
id: data.id ?? null,
name: data.name ?? null,
finalDecision: data.finalDecision ?? null,
canAnswerApproval: data.canAnswerApproval ?? null,
approvers: (data.approvers ?? []).map((a: Record<string, unknown>) => {
const approver = a.approver as Record<string, unknown> | undefined
return {
approver: {
accountId: approver?.accountId ?? null,
displayName: approver?.displayName ?? null,
emailAddress: approver?.emailAddress ?? null,
active: approver?.active ?? null,
},
approverDecision: a.approverDecision ?? null,
}
}),
createdDate: data.createdDate ?? null,
completedDate: data.completedDate ?? null,
approval: data,
success: true,
approval: data,
},
})
}

View File

@@ -95,14 +95,6 @@ export async function POST(request: NextRequest) {
commentId: data.id,
body: data.body,
isPublic: data.public,
author: data.author
? {
accountId: data.author.accountId ?? null,
displayName: data.author.displayName ?? null,
emailAddress: data.author.emailAddress ?? null,
}
: null,
createdDate: data.created ?? null,
success: true,
},
})

View File

@@ -23,7 +23,6 @@ export async function POST(request: NextRequest) {
issueIdOrKey,
isPublic,
internal,
expand,
start,
limit,
} = body
@@ -58,9 +57,8 @@ export async function POST(request: NextRequest) {
const baseUrl = getJsmApiBaseUrl(cloudId)
const params = new URLSearchParams()
if (isPublic !== undefined) params.append('public', String(isPublic))
if (internal !== undefined) params.append('internal', String(internal))
if (expand) params.append('expand', expand)
if (isPublic) params.append('public', isPublic)
if (internal) params.append('internal', internal)
if (start) params.append('start', start)
if (limit) params.append('limit', limit)

View File

@@ -24,7 +24,6 @@ export async function POST(request: NextRequest) {
query,
start,
limit,
accountIds,
emails,
} = body
@@ -57,27 +56,24 @@ export async function POST(request: NextRequest) {
const baseUrl = getJsmApiBaseUrl(cloudId)
const rawIds = accountIds || emails
const parsedAccountIds = rawIds
? typeof rawIds === 'string'
? rawIds
const parsedEmails = emails
? typeof emails === 'string'
? emails
.split(',')
.map((id: string) => id.trim())
.filter((id: string) => id)
: Array.isArray(rawIds)
? rawIds
: []
.map((email: string) => email.trim())
.filter((email: string) => email)
: emails
: []
const isAddOperation = parsedAccountIds.length > 0
const isAddOperation = parsedEmails.length > 0
if (isAddOperation) {
const url = `${baseUrl}/servicedesk/${serviceDeskId}/customer`
logger.info('Adding customers to:', url, { accountIds: parsedAccountIds })
logger.info('Adding customers to:', url, { emails: parsedEmails })
const requestBody: Record<string, unknown> = {
accountIds: parsedAccountIds,
usernames: parsedEmails,
}
const response = await fetch(url, {

View File

@@ -31,9 +31,6 @@ export async function POST(request: NextRequest) {
description,
raiseOnBehalfOf,
requestFieldValues,
requestParticipants,
channel,
expand,
} = body
if (!domain) {
@@ -83,19 +80,6 @@ export async function POST(request: NextRequest) {
if (raiseOnBehalfOf) {
requestBody.raiseOnBehalfOf = raiseOnBehalfOf
}
if (requestParticipants) {
requestBody.requestParticipants = Array.isArray(requestParticipants)
? requestParticipants
: typeof requestParticipants === 'string'
? requestParticipants
.split(',')
.map((id: string) => id.trim())
.filter(Boolean)
: []
}
if (channel) {
requestBody.channel = channel
}
const response = await fetch(url, {
method: 'POST',
@@ -127,21 +111,6 @@ export async function POST(request: NextRequest) {
issueKey: data.issueKey,
requestTypeId: data.requestTypeId,
serviceDeskId: data.serviceDeskId,
createdDate: data.createdDate ?? null,
currentStatus: data.currentStatus
? {
status: data.currentStatus.status ?? null,
statusCategory: data.currentStatus.statusCategory ?? null,
statusDate: data.currentStatus.statusDate ?? null,
}
: null,
reporter: data.reporter
? {
accountId: data.reporter.accountId ?? null,
displayName: data.reporter.displayName ?? null,
emailAddress: data.reporter.emailAddress ?? null,
}
: null,
success: true,
url: `https://${domain}/browse/${data.issueKey}`,
},
@@ -157,10 +126,7 @@ export async function POST(request: NextRequest) {
return NextResponse.json({ error: issueIdOrKeyValidation.error }, { status: 400 })
}
const params = new URLSearchParams()
if (expand) params.append('expand', expand)
const url = `${baseUrl}/request/${issueIdOrKey}${params.toString() ? `?${params.toString()}` : ''}`
const url = `${baseUrl}/request/${issueIdOrKey}`
logger.info('Fetching request from:', url)
@@ -189,32 +155,6 @@ export async function POST(request: NextRequest) {
success: true,
output: {
ts: new Date().toISOString(),
issueId: data.issueId ?? null,
issueKey: data.issueKey ?? null,
requestTypeId: data.requestTypeId ?? null,
serviceDeskId: data.serviceDeskId ?? null,
createdDate: data.createdDate ?? null,
currentStatus: data.currentStatus
? {
status: data.currentStatus.status ?? null,
statusCategory: data.currentStatus.statusCategory ?? null,
statusDate: data.currentStatus.statusDate ?? null,
}
: null,
reporter: data.reporter
? {
accountId: data.reporter.accountId ?? null,
displayName: data.reporter.displayName ?? null,
emailAddress: data.reporter.emailAddress ?? null,
active: data.reporter.active ?? true,
}
: null,
requestFieldValues: (data.requestFieldValues ?? []).map((fv: Record<string, unknown>) => ({
fieldId: fv.fieldId ?? null,
label: fv.label ?? null,
value: fv.value ?? null,
})),
url: `https://${domain}/browse/${data.issueKey}`,
request: data,
},
})

View File

@@ -1,11 +1,7 @@
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import {
validateAlphanumericId,
validateEnum,
validateJiraCloudId,
} from '@/lib/core/security/input-validation'
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
import { getJiraCloudId, getJsmApiBaseUrl, getJsmHeaders } from '@/tools/jsm/utils'
export const dynamic = 'force-dynamic'
@@ -27,9 +23,7 @@ export async function POST(request: NextRequest) {
serviceDeskId,
requestOwnership,
requestStatus,
requestTypeId,
searchTerm,
expand,
start,
limit,
} = body
@@ -58,45 +52,17 @@ export async function POST(request: NextRequest) {
}
}
const VALID_REQUEST_OWNERSHIP = [
'OWNED_REQUESTS',
'PARTICIPATED_REQUESTS',
'APPROVER',
'ALL_REQUESTS',
] as const
const VALID_REQUEST_STATUS = ['OPEN_REQUESTS', 'CLOSED_REQUESTS', 'ALL_REQUESTS'] as const
if (requestOwnership) {
const ownershipValidation = validateEnum(
requestOwnership,
VALID_REQUEST_OWNERSHIP,
'requestOwnership'
)
if (!ownershipValidation.isValid) {
return NextResponse.json({ error: ownershipValidation.error }, { status: 400 })
}
}
if (requestStatus) {
const statusValidation = validateEnum(requestStatus, VALID_REQUEST_STATUS, 'requestStatus')
if (!statusValidation.isValid) {
return NextResponse.json({ error: statusValidation.error }, { status: 400 })
}
}
const baseUrl = getJsmApiBaseUrl(cloudId)
const params = new URLSearchParams()
if (serviceDeskId) params.append('serviceDeskId', serviceDeskId)
if (requestOwnership) {
if (requestOwnership && requestOwnership !== 'ALL_REQUESTS') {
params.append('requestOwnership', requestOwnership)
}
if (requestStatus) {
if (requestStatus && requestStatus !== 'ALL') {
params.append('requestStatus', requestStatus)
}
if (requestTypeId) params.append('requestTypeId', requestTypeId)
if (searchTerm) params.append('searchTerm', searchTerm)
if (expand) params.append('expand', expand)
if (start) params.append('start', start)
if (limit) params.append('limit', limit)

View File

@@ -1,119 +0,0 @@
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
import { getJiraCloudId, getJsmApiBaseUrl, getJsmHeaders } from '@/tools/jsm/utils'
export const dynamic = 'force-dynamic'
const logger = createLogger('JsmRequestTypeFieldsAPI')
export async function POST(request: NextRequest) {
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const { domain, accessToken, cloudId: cloudIdParam, serviceDeskId, requestTypeId } = body
if (!domain) {
logger.error('Missing domain in request')
return NextResponse.json({ error: 'Domain is required' }, { status: 400 })
}
if (!accessToken) {
logger.error('Missing access token in request')
return NextResponse.json({ error: 'Access token is required' }, { status: 400 })
}
if (!serviceDeskId) {
logger.error('Missing serviceDeskId in request')
return NextResponse.json({ error: 'Service Desk ID is required' }, { status: 400 })
}
if (!requestTypeId) {
logger.error('Missing requestTypeId in request')
return NextResponse.json({ error: 'Request Type ID is required' }, { status: 400 })
}
const cloudId = cloudIdParam || (await getJiraCloudId(domain, accessToken))
const cloudIdValidation = validateJiraCloudId(cloudId, 'cloudId')
if (!cloudIdValidation.isValid) {
return NextResponse.json({ error: cloudIdValidation.error }, { status: 400 })
}
const serviceDeskIdValidation = validateAlphanumericId(serviceDeskId, 'serviceDeskId')
if (!serviceDeskIdValidation.isValid) {
return NextResponse.json({ error: serviceDeskIdValidation.error }, { status: 400 })
}
const requestTypeIdValidation = validateAlphanumericId(requestTypeId, 'requestTypeId')
if (!requestTypeIdValidation.isValid) {
return NextResponse.json({ error: requestTypeIdValidation.error }, { status: 400 })
}
const baseUrl = getJsmApiBaseUrl(cloudId)
const url = `${baseUrl}/servicedesk/${serviceDeskId}/requesttype/${requestTypeId}/field`
logger.info('Fetching request type fields from:', url)
const response = await fetch(url, {
method: 'GET',
headers: getJsmHeaders(accessToken),
})
if (!response.ok) {
const errorText = await response.text()
logger.error('JSM API error:', {
status: response.status,
statusText: response.statusText,
error: errorText,
})
return NextResponse.json(
{ error: `JSM API error: ${response.status} ${response.statusText}`, details: errorText },
{ status: response.status }
)
}
const data = await response.json()
return NextResponse.json({
success: true,
output: {
ts: new Date().toISOString(),
serviceDeskId,
requestTypeId,
canAddRequestParticipants: data.canAddRequestParticipants ?? false,
canRaiseOnBehalfOf: data.canRaiseOnBehalfOf ?? false,
requestTypeFields: (data.requestTypeFields ?? []).map((field: Record<string, unknown>) => ({
fieldId: field.fieldId ?? null,
name: field.name ?? null,
description: field.description ?? null,
required: field.required ?? false,
visible: field.visible ?? true,
validValues: field.validValues ?? [],
presetValues: field.presetValues ?? [],
defaultValues: field.defaultValues ?? [],
jiraSchema: field.jiraSchema ?? null,
})),
},
})
} catch (error) {
logger.error('Error fetching request type fields:', {
error: error instanceof Error ? error.message : String(error),
stack: error instanceof Error ? error.stack : undefined,
})
return NextResponse.json(
{
error: error instanceof Error ? error.message : 'Internal server error',
success: false,
},
{ status: 500 }
)
}
}

View File

@@ -16,17 +16,7 @@ export async function POST(request: NextRequest) {
try {
const body = await request.json()
const {
domain,
accessToken,
cloudId: cloudIdParam,
serviceDeskId,
searchQuery,
groupId,
expand,
start,
limit,
} = body
const { domain, accessToken, cloudId: cloudIdParam, serviceDeskId, start, limit } = body
if (!domain) {
logger.error('Missing domain in request')
@@ -58,9 +48,6 @@ export async function POST(request: NextRequest) {
const baseUrl = getJsmApiBaseUrl(cloudId)
const params = new URLSearchParams()
if (searchQuery) params.append('searchQuery', searchQuery)
if (groupId) params.append('groupId', groupId)
if (expand) params.append('expand', expand)
if (start) params.append('start', start)
if (limit) params.append('limit', limit)

View File

@@ -16,7 +16,7 @@ export async function POST(request: NextRequest) {
try {
const body = await request.json()
const { domain, accessToken, cloudId: cloudIdParam, expand, start, limit } = body
const { domain, accessToken, cloudId: cloudIdParam, start, limit } = body
if (!domain) {
logger.error('Missing domain in request')
@@ -38,7 +38,6 @@ export async function POST(request: NextRequest) {
const baseUrl = getJsmApiBaseUrl(cloudId)
const params = new URLSearchParams()
if (expand) params.append('expand', expand)
if (start) params.append('start', start)
if (limit) params.append('limit', limit)

View File

@@ -16,7 +16,7 @@ export async function POST(request: NextRequest) {
try {
const body = await request.json()
const { domain, accessToken, cloudId: cloudIdParam, issueIdOrKey, start, limit } = body
const { domain, accessToken, cloudId: cloudIdParam, issueIdOrKey } = body
if (!domain) {
logger.error('Missing domain in request')
@@ -47,11 +47,7 @@ export async function POST(request: NextRequest) {
const baseUrl = getJsmApiBaseUrl(cloudId)
const params = new URLSearchParams()
if (start) params.append('start', start)
if (limit) params.append('limit', limit)
const url = `${baseUrl}/request/${issueIdOrKey}/transition${params.toString() ? `?${params.toString()}` : ''}`
const url = `${baseUrl}/request/${issueIdOrKey}/transition`
logger.info('Fetching transitions from:', url)
@@ -82,8 +78,6 @@ export async function POST(request: NextRequest) {
ts: new Date().toISOString(),
issueIdOrKey,
transitions: data.values || [],
total: data.size || 0,
isLastPage: data.isLastPage ?? true,
},
})
} catch (error) {

View File

@@ -1,113 +0,0 @@
import { randomUUID } from 'crypto'
import type { ItemCreateParams } from '@1password/sdk'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import {
connectRequest,
createOnePasswordClient,
normalizeSdkItem,
resolveCredentials,
toSdkCategory,
toSdkFieldType,
} from '../utils'
const logger = createLogger('OnePasswordCreateItemAPI')
const CreateItemSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
vaultId: z.string().min(1, 'Vault ID is required'),
category: z.string().min(1, 'Category is required'),
title: z.string().nullish(),
tags: z.string().nullish(),
fields: z.string().nullish(),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password create-item attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = CreateItemSchema.parse(body)
const creds = resolveCredentials(params)
logger.info(`[${requestId}] Creating item in vault ${params.vaultId} (${creds.mode} mode)`)
if (creds.mode === 'service_account') {
const client = await createOnePasswordClient(creds.serviceAccountToken!)
const parsedTags = params.tags
? params.tags
.split(',')
.map((t) => t.trim())
.filter(Boolean)
: undefined
const parsedFields = params.fields
? (JSON.parse(params.fields) as Array<Record<string, any>>).map((f) => ({
id: f.id || randomUUID().slice(0, 8),
title: f.label || f.title || '',
fieldType: toSdkFieldType(f.type || 'STRING'),
value: f.value || '',
sectionId: f.section?.id ?? f.sectionId,
}))
: undefined
const item = await client.items.create({
vaultId: params.vaultId,
category: toSdkCategory(params.category),
title: params.title || '',
tags: parsedTags,
fields: parsedFields,
} as ItemCreateParams)
return NextResponse.json(normalizeSdkItem(item))
}
const connectBody: Record<string, unknown> = {
vault: { id: params.vaultId },
category: params.category,
}
if (params.title) connectBody.title = params.title
if (params.tags) connectBody.tags = params.tags.split(',').map((t) => t.trim())
if (params.fields) connectBody.fields = JSON.parse(params.fields)
const response = await connectRequest({
serverUrl: creds.serverUrl!,
apiKey: creds.apiKey!,
path: `/v1/vaults/${params.vaultId}/items`,
method: 'POST',
body: connectBody,
})
const data = await response.json()
if (!response.ok) {
return NextResponse.json(
{ error: data.message || 'Failed to create item' },
{ status: response.status }
)
}
return NextResponse.json(data)
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] Create item failed:`, error)
return NextResponse.json({ error: `Failed to create item: ${message}` }, { status: 500 })
}
}

View File

@@ -1,70 +0,0 @@
import { randomUUID } from 'crypto'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import { connectRequest, createOnePasswordClient, resolveCredentials } from '../utils'
const logger = createLogger('OnePasswordDeleteItemAPI')
const DeleteItemSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
vaultId: z.string().min(1, 'Vault ID is required'),
itemId: z.string().min(1, 'Item ID is required'),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password delete-item attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = DeleteItemSchema.parse(body)
const creds = resolveCredentials(params)
logger.info(
`[${requestId}] Deleting item ${params.itemId} from vault ${params.vaultId} (${creds.mode} mode)`
)
if (creds.mode === 'service_account') {
const client = await createOnePasswordClient(creds.serviceAccountToken!)
await client.items.delete(params.vaultId, params.itemId)
return NextResponse.json({ success: true })
}
const response = await connectRequest({
serverUrl: creds.serverUrl!,
apiKey: creds.apiKey!,
path: `/v1/vaults/${params.vaultId}/items/${params.itemId}`,
method: 'DELETE',
})
if (!response.ok) {
const data = await response.json().catch(() => ({}))
return NextResponse.json(
{ error: (data as Record<string, string>).message || 'Failed to delete item' },
{ status: response.status }
)
}
return NextResponse.json({ success: true })
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] Delete item failed:`, error)
return NextResponse.json({ error: `Failed to delete item: ${message}` }, { status: 500 })
}
}

View File

@@ -1,75 +0,0 @@
import { randomUUID } from 'crypto'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import {
connectRequest,
createOnePasswordClient,
normalizeSdkItem,
resolveCredentials,
} from '../utils'
const logger = createLogger('OnePasswordGetItemAPI')
const GetItemSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
vaultId: z.string().min(1, 'Vault ID is required'),
itemId: z.string().min(1, 'Item ID is required'),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password get-item attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = GetItemSchema.parse(body)
const creds = resolveCredentials(params)
logger.info(
`[${requestId}] Getting item ${params.itemId} from vault ${params.vaultId} (${creds.mode} mode)`
)
if (creds.mode === 'service_account') {
const client = await createOnePasswordClient(creds.serviceAccountToken!)
const item = await client.items.get(params.vaultId, params.itemId)
return NextResponse.json(normalizeSdkItem(item))
}
const response = await connectRequest({
serverUrl: creds.serverUrl!,
apiKey: creds.apiKey!,
path: `/v1/vaults/${params.vaultId}/items/${params.itemId}`,
method: 'GET',
})
const data = await response.json()
if (!response.ok) {
return NextResponse.json(
{ error: data.message || 'Failed to get item' },
{ status: response.status }
)
}
return NextResponse.json(data)
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] Get item failed:`, error)
return NextResponse.json({ error: `Failed to get item: ${message}` }, { status: 500 })
}
}

View File

@@ -1,78 +0,0 @@
import { randomUUID } from 'crypto'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import {
connectRequest,
createOnePasswordClient,
normalizeSdkVault,
resolveCredentials,
} from '../utils'
const logger = createLogger('OnePasswordGetVaultAPI')
const GetVaultSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
vaultId: z.string().min(1, 'Vault ID is required'),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password get-vault attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = GetVaultSchema.parse(body)
const creds = resolveCredentials(params)
logger.info(`[${requestId}] Getting 1Password vault ${params.vaultId} (${creds.mode} mode)`)
if (creds.mode === 'service_account') {
const client = await createOnePasswordClient(creds.serviceAccountToken!)
const vaults = await client.vaults.list()
const vault = vaults.find((v) => v.id === params.vaultId)
if (!vault) {
return NextResponse.json({ error: 'Vault not found' }, { status: 404 })
}
return NextResponse.json(normalizeSdkVault(vault))
}
const response = await connectRequest({
serverUrl: creds.serverUrl!,
apiKey: creds.apiKey!,
path: `/v1/vaults/${params.vaultId}`,
method: 'GET',
})
const data = await response.json()
if (!response.ok) {
return NextResponse.json(
{ error: data.message || 'Failed to get vault' },
{ status: response.status }
)
}
return NextResponse.json(data)
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] Get vault failed:`, error)
return NextResponse.json({ error: `Failed to get vault: ${message}` }, { status: 500 })
}
}

View File

@@ -1,87 +0,0 @@
import { randomUUID } from 'crypto'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import {
connectRequest,
createOnePasswordClient,
normalizeSdkItemOverview,
resolveCredentials,
} from '../utils'
const logger = createLogger('OnePasswordListItemsAPI')
const ListItemsSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
vaultId: z.string().min(1, 'Vault ID is required'),
filter: z.string().nullish(),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password list-items attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = ListItemsSchema.parse(body)
const creds = resolveCredentials(params)
logger.info(`[${requestId}] Listing items in vault ${params.vaultId} (${creds.mode} mode)`)
if (creds.mode === 'service_account') {
const client = await createOnePasswordClient(creds.serviceAccountToken!)
const items = await client.items.list(params.vaultId)
const normalized = items.map(normalizeSdkItemOverview)
if (params.filter) {
const filterLower = params.filter.toLowerCase()
const filtered = normalized.filter(
(item) =>
item.title?.toLowerCase().includes(filterLower) ||
item.id?.toLowerCase().includes(filterLower)
)
return NextResponse.json(filtered)
}
return NextResponse.json(normalized)
}
const query = params.filter ? `filter=${encodeURIComponent(params.filter)}` : undefined
const response = await connectRequest({
serverUrl: creds.serverUrl!,
apiKey: creds.apiKey!,
path: `/v1/vaults/${params.vaultId}/items`,
method: 'GET',
query,
})
const data = await response.json()
if (!response.ok) {
return NextResponse.json(
{ error: data.message || 'Failed to list items' },
{ status: response.status }
)
}
return NextResponse.json(data)
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] List items failed:`, error)
return NextResponse.json({ error: `Failed to list items: ${message}` }, { status: 500 })
}
}

View File

@@ -1,85 +0,0 @@
import { randomUUID } from 'crypto'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import {
connectRequest,
createOnePasswordClient,
normalizeSdkVault,
resolveCredentials,
} from '../utils'
const logger = createLogger('OnePasswordListVaultsAPI')
const ListVaultsSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
filter: z.string().nullish(),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password list-vaults attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = ListVaultsSchema.parse(body)
const creds = resolveCredentials(params)
logger.info(`[${requestId}] Listing 1Password vaults (${creds.mode} mode)`)
if (creds.mode === 'service_account') {
const client = await createOnePasswordClient(creds.serviceAccountToken!)
const vaults = await client.vaults.list()
const normalized = vaults.map(normalizeSdkVault)
if (params.filter) {
const filterLower = params.filter.toLowerCase()
const filtered = normalized.filter(
(v) =>
v.name?.toLowerCase().includes(filterLower) || v.id?.toLowerCase().includes(filterLower)
)
return NextResponse.json(filtered)
}
return NextResponse.json(normalized)
}
const query = params.filter ? `filter=${encodeURIComponent(params.filter)}` : undefined
const response = await connectRequest({
serverUrl: creds.serverUrl!,
apiKey: creds.apiKey!,
path: '/v1/vaults',
method: 'GET',
query,
})
const data = await response.json()
if (!response.ok) {
return NextResponse.json(
{ error: data.message || 'Failed to list vaults' },
{ status: response.status }
)
}
return NextResponse.json(data)
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] List vaults failed:`, error)
return NextResponse.json({ error: `Failed to list vaults: ${message}` }, { status: 500 })
}
}

View File

@@ -1,117 +0,0 @@
import { randomUUID } from 'crypto'
import type { Item } from '@1password/sdk'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import {
connectRequest,
createOnePasswordClient,
normalizeSdkItem,
resolveCredentials,
toSdkCategory,
toSdkFieldType,
} from '../utils'
const logger = createLogger('OnePasswordReplaceItemAPI')
const ReplaceItemSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
vaultId: z.string().min(1, 'Vault ID is required'),
itemId: z.string().min(1, 'Item ID is required'),
item: z.string().min(1, 'Item JSON is required'),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password replace-item attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = ReplaceItemSchema.parse(body)
const creds = resolveCredentials(params)
const itemData = JSON.parse(params.item)
logger.info(
`[${requestId}] Replacing item ${params.itemId} in vault ${params.vaultId} (${creds.mode} mode)`
)
if (creds.mode === 'service_account') {
const client = await createOnePasswordClient(creds.serviceAccountToken!)
const existing = await client.items.get(params.vaultId, params.itemId)
const sdkItem = {
...existing,
id: params.itemId,
title: itemData.title || existing.title,
category: itemData.category ? toSdkCategory(itemData.category) : existing.category,
vaultId: params.vaultId,
fields: itemData.fields
? (itemData.fields as Array<Record<string, any>>).map((f) => ({
id: f.id || randomUUID().slice(0, 8),
title: f.label || f.title || '',
fieldType: toSdkFieldType(f.type || 'STRING'),
value: f.value || '',
sectionId: f.section?.id ?? f.sectionId,
}))
: existing.fields,
sections: itemData.sections
? (itemData.sections as Array<Record<string, any>>).map((s) => ({
id: s.id || '',
title: s.label || s.title || '',
}))
: existing.sections,
notes: itemData.notes ?? existing.notes,
tags: itemData.tags ?? existing.tags,
websites:
itemData.urls || itemData.websites
? (itemData.urls ?? itemData.websites ?? []).map((u: Record<string, any>) => ({
url: u.href || u.url || '',
label: u.label || '',
autofillBehavior: 'AnywhereOnWebsite' as const,
}))
: existing.websites,
} as Item
const result = await client.items.put(sdkItem)
return NextResponse.json(normalizeSdkItem(result))
}
const response = await connectRequest({
serverUrl: creds.serverUrl!,
apiKey: creds.apiKey!,
path: `/v1/vaults/${params.vaultId}/items/${params.itemId}`,
method: 'PUT',
body: itemData,
})
const data = await response.json()
if (!response.ok) {
return NextResponse.json(
{ error: data.message || 'Failed to replace item' },
{ status: response.status }
)
}
return NextResponse.json(data)
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] Replace item failed:`, error)
return NextResponse.json({ error: `Failed to replace item: ${message}` }, { status: 500 })
}
}

View File

@@ -1,59 +0,0 @@
import { randomUUID } from 'crypto'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import { createOnePasswordClient, resolveCredentials } from '../utils'
const logger = createLogger('OnePasswordResolveSecretAPI')
const ResolveSecretSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
secretReference: z.string().min(1, 'Secret reference is required'),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password resolve-secret attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = ResolveSecretSchema.parse(body)
const creds = resolveCredentials(params)
if (creds.mode !== 'service_account') {
return NextResponse.json(
{ error: 'Resolve Secret is only available in Service Account mode' },
{ status: 400 }
)
}
logger.info(`[${requestId}] Resolving secret reference (service_account mode)`)
const client = await createOnePasswordClient(creds.serviceAccountToken!)
const secret = await client.secrets.resolve(params.secretReference)
return NextResponse.json({
value: secret,
reference: params.secretReference,
})
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] Resolve secret failed:`, error)
return NextResponse.json({ error: `Failed to resolve secret: ${message}` }, { status: 500 })
}
}

View File

@@ -1,136 +0,0 @@
import { randomUUID } from 'crypto'
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import { checkInternalAuth } from '@/lib/auth/hybrid'
import {
connectRequest,
createOnePasswordClient,
normalizeSdkItem,
resolveCredentials,
} from '../utils'
const logger = createLogger('OnePasswordUpdateItemAPI')
const UpdateItemSchema = z.object({
connectionMode: z.enum(['service_account', 'connect']).nullish(),
serviceAccountToken: z.string().nullish(),
serverUrl: z.string().nullish(),
apiKey: z.string().nullish(),
vaultId: z.string().min(1, 'Vault ID is required'),
itemId: z.string().min(1, 'Item ID is required'),
operations: z.string().min(1, 'Patch operations are required'),
})
export async function POST(request: NextRequest) {
const requestId = randomUUID().slice(0, 8)
const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
logger.warn(`[${requestId}] Unauthorized 1Password update-item attempt`)
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}
try {
const body = await request.json()
const params = UpdateItemSchema.parse(body)
const creds = resolveCredentials(params)
const ops = JSON.parse(params.operations) as JsonPatchOperation[]
logger.info(
`[${requestId}] Updating item ${params.itemId} in vault ${params.vaultId} (${creds.mode} mode)`
)
if (creds.mode === 'service_account') {
const client = await createOnePasswordClient(creds.serviceAccountToken!)
const item = await client.items.get(params.vaultId, params.itemId)
for (const op of ops) {
applyPatch(item, op)
}
const result = await client.items.put(item)
return NextResponse.json(normalizeSdkItem(result))
}
const response = await connectRequest({
serverUrl: creds.serverUrl!,
apiKey: creds.apiKey!,
path: `/v1/vaults/${params.vaultId}/items/${params.itemId}`,
method: 'PATCH',
body: ops,
})
const data = await response.json()
if (!response.ok) {
return NextResponse.json(
{ error: data.message || 'Failed to update item' },
{ status: response.status }
)
}
return NextResponse.json(data)
} catch (error) {
if (error instanceof z.ZodError) {
return NextResponse.json(
{ error: 'Invalid request data', details: error.errors },
{ status: 400 }
)
}
const message = error instanceof Error ? error.message : 'Unknown error'
logger.error(`[${requestId}] Update item failed:`, error)
return NextResponse.json({ error: `Failed to update item: ${message}` }, { status: 500 })
}
}
interface JsonPatchOperation {
op: 'add' | 'remove' | 'replace'
path: string
value?: unknown
}
/** Apply a single RFC6902 JSON Patch operation to a mutable object. */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function applyPatch(item: Record<string, any>, op: JsonPatchOperation) {
const segments = op.path.split('/').filter(Boolean)
if (segments.length === 1) {
const key = segments[0]
if (op.op === 'replace' || op.op === 'add') {
item[key] = op.value
} else if (op.op === 'remove') {
delete item[key]
}
return
}
let target = item
for (let i = 0; i < segments.length - 1; i++) {
const seg = segments[i]
if (Array.isArray(target)) {
target = target[Number(seg)]
} else {
target = target[seg]
}
if (target === undefined || target === null) return
}
const lastSeg = segments[segments.length - 1]
if (op.op === 'replace' || op.op === 'add') {
if (Array.isArray(target) && lastSeg === '-') {
target.push(op.value)
} else if (Array.isArray(target)) {
target[Number(lastSeg)] = op.value
} else {
target[lastSeg] = op.value
}
} else if (op.op === 'remove') {
if (Array.isArray(target)) {
target.splice(Number(lastSeg), 1)
} else {
delete target[lastSeg]
}
}
}

View File

@@ -1,357 +0,0 @@
import type {
Item,
ItemCategory,
ItemField,
ItemFieldType,
ItemOverview,
ItemSection,
VaultOverview,
Website,
} from '@1password/sdk'
/** Connect-format field type strings returned by normalization. */
type ConnectFieldType =
| 'STRING'
| 'CONCEALED'
| 'EMAIL'
| 'URL'
| 'OTP'
| 'PHONE'
| 'DATE'
| 'MONTH_YEAR'
| 'MENU'
| 'ADDRESS'
| 'REFERENCE'
| 'SSHKEY'
| 'CREDIT_CARD_NUMBER'
| 'CREDIT_CARD_TYPE'
/** Connect-format category strings returned by normalization. */
type ConnectCategory =
| 'LOGIN'
| 'PASSWORD'
| 'API_CREDENTIAL'
| 'SECURE_NOTE'
| 'SERVER'
| 'DATABASE'
| 'CREDIT_CARD'
| 'IDENTITY'
| 'SSH_KEY'
| 'DOCUMENT'
| 'SOFTWARE_LICENSE'
| 'EMAIL_ACCOUNT'
| 'MEMBERSHIP'
| 'PASSPORT'
| 'REWARD_PROGRAM'
| 'DRIVER_LICENSE'
| 'BANK_ACCOUNT'
| 'MEDICAL_RECORD'
| 'OUTDOOR_LICENSE'
| 'WIRELESS_ROUTER'
| 'SOCIAL_SECURITY_NUMBER'
| 'CUSTOM'
/** Normalized vault shape matching the Connect API response. */
export interface NormalizedVault {
id: string
name: string
description: null
attributeVersion: number
contentVersion: number
items: number
type: string
createdAt: string | null
updatedAt: string | null
}
/** Normalized item overview shape matching the Connect API response. */
export interface NormalizedItemOverview {
id: string
title: string
vault: { id: string }
category: ConnectCategory
urls: Array<{ href: string; label: string | null; primary: boolean }>
favorite: boolean
tags: string[]
version: number
state: string | null
createdAt: string | null
updatedAt: string | null
lastEditedBy: null
}
/** Normalized field shape matching the Connect API response. */
export interface NormalizedField {
id: string
label: string
type: ConnectFieldType
purpose: string
value: string | null
section: { id: string } | null
generate: boolean
recipe: null
entropy: null
}
/** Normalized full item shape matching the Connect API response. */
export interface NormalizedItem extends NormalizedItemOverview {
fields: NormalizedField[]
sections: Array<{ id: string; label: string }>
}
/**
* SDK field type string values → Connect field type mapping.
* Uses string literals instead of enum imports to avoid loading the WASM module at build time.
*/
const SDK_TO_CONNECT_FIELD_TYPE: Record<string, ConnectFieldType> = {
Text: 'STRING',
Concealed: 'CONCEALED',
Email: 'EMAIL',
Url: 'URL',
Totp: 'OTP',
Phone: 'PHONE',
Date: 'DATE',
MonthYear: 'MONTH_YEAR',
Menu: 'MENU',
Address: 'ADDRESS',
Reference: 'REFERENCE',
SshKey: 'SSHKEY',
CreditCardNumber: 'CREDIT_CARD_NUMBER',
CreditCardType: 'CREDIT_CARD_TYPE',
}
/** SDK category string values → Connect category mapping. */
const SDK_TO_CONNECT_CATEGORY: Record<string, ConnectCategory> = {
Login: 'LOGIN',
Password: 'PASSWORD',
ApiCredentials: 'API_CREDENTIAL',
SecureNote: 'SECURE_NOTE',
Server: 'SERVER',
Database: 'DATABASE',
CreditCard: 'CREDIT_CARD',
Identity: 'IDENTITY',
SshKey: 'SSH_KEY',
Document: 'DOCUMENT',
SoftwareLicense: 'SOFTWARE_LICENSE',
Email: 'EMAIL_ACCOUNT',
Membership: 'MEMBERSHIP',
Passport: 'PASSPORT',
Rewards: 'REWARD_PROGRAM',
DriverLicense: 'DRIVER_LICENSE',
BankAccount: 'BANK_ACCOUNT',
MedicalRecord: 'MEDICAL_RECORD',
OutdoorLicense: 'OUTDOOR_LICENSE',
Router: 'WIRELESS_ROUTER',
SocialSecurityNumber: 'SOCIAL_SECURITY_NUMBER',
CryptoWallet: 'CUSTOM',
Person: 'CUSTOM',
Unsupported: 'CUSTOM',
}
/** Connect category → SDK category string mapping. */
const CONNECT_TO_SDK_CATEGORY: Record<string, `${ItemCategory}`> = {
LOGIN: 'Login',
PASSWORD: 'Password',
API_CREDENTIAL: 'ApiCredentials',
SECURE_NOTE: 'SecureNote',
SERVER: 'Server',
DATABASE: 'Database',
CREDIT_CARD: 'CreditCard',
IDENTITY: 'Identity',
SSH_KEY: 'SshKey',
DOCUMENT: 'Document',
SOFTWARE_LICENSE: 'SoftwareLicense',
EMAIL_ACCOUNT: 'Email',
MEMBERSHIP: 'Membership',
PASSPORT: 'Passport',
REWARD_PROGRAM: 'Rewards',
DRIVER_LICENSE: 'DriverLicense',
BANK_ACCOUNT: 'BankAccount',
MEDICAL_RECORD: 'MedicalRecord',
OUTDOOR_LICENSE: 'OutdoorLicense',
WIRELESS_ROUTER: 'Router',
SOCIAL_SECURITY_NUMBER: 'SocialSecurityNumber',
}
/** Connect field type → SDK field type string mapping. */
const CONNECT_TO_SDK_FIELD_TYPE: Record<string, `${ItemFieldType}`> = {
STRING: 'Text',
CONCEALED: 'Concealed',
EMAIL: 'Email',
URL: 'Url',
OTP: 'Totp',
TOTP: 'Totp',
PHONE: 'Phone',
DATE: 'Date',
MONTH_YEAR: 'MonthYear',
MENU: 'Menu',
ADDRESS: 'Address',
REFERENCE: 'Reference',
SSHKEY: 'SshKey',
CREDIT_CARD_NUMBER: 'CreditCardNumber',
CREDIT_CARD_TYPE: 'CreditCardType',
}
export type ConnectionMode = 'service_account' | 'connect'
export interface CredentialParams {
connectionMode?: ConnectionMode | null
serviceAccountToken?: string | null
serverUrl?: string | null
apiKey?: string | null
}
export interface ResolvedCredentials {
mode: ConnectionMode
serviceAccountToken?: string
serverUrl?: string
apiKey?: string
}
/** Determine which backend to use based on provided credentials. */
export function resolveCredentials(params: CredentialParams): ResolvedCredentials {
const mode = params.connectionMode ?? (params.serviceAccountToken ? 'service_account' : 'connect')
if (mode === 'service_account') {
if (!params.serviceAccountToken) {
throw new Error('Service Account token is required for Service Account mode')
}
return { mode, serviceAccountToken: params.serviceAccountToken }
}
if (!params.serverUrl || !params.apiKey) {
throw new Error('Server URL and Connect token are required for Connect Server mode')
}
return { mode, serverUrl: params.serverUrl, apiKey: params.apiKey }
}
/**
* Create a 1Password SDK client from a service account token.
* Uses dynamic import to avoid loading the WASM module at build time.
*/
export async function createOnePasswordClient(serviceAccountToken: string) {
const { createClient } = await import('@1password/sdk')
return createClient({
auth: serviceAccountToken,
integrationName: 'Sim Studio',
integrationVersion: '1.0.0',
})
}
/** Proxy a request to the 1Password Connect Server. */
export async function connectRequest(options: {
serverUrl: string
apiKey: string
path: string
method: string
body?: unknown
query?: string
}): Promise<Response> {
const base = options.serverUrl.replace(/\/$/, '')
const queryStr = options.query ? `?${options.query}` : ''
const url = `${base}${options.path}${queryStr}`
const headers: Record<string, string> = {
Authorization: `Bearer ${options.apiKey}`,
}
if (options.body) {
headers['Content-Type'] = 'application/json'
}
return fetch(url, {
method: options.method,
headers,
body: options.body ? JSON.stringify(options.body) : undefined,
})
}
/** Normalize an SDK VaultOverview to match Connect API vault shape. */
export function normalizeSdkVault(vault: VaultOverview): NormalizedVault {
return {
id: vault.id,
name: vault.title,
description: null,
attributeVersion: 0,
contentVersion: 0,
items: 0,
type: 'USER_CREATED',
createdAt:
vault.createdAt instanceof Date ? vault.createdAt.toISOString() : (vault.createdAt ?? null),
updatedAt:
vault.updatedAt instanceof Date ? vault.updatedAt.toISOString() : (vault.updatedAt ?? null),
}
}
/** Normalize an SDK ItemOverview to match Connect API item summary shape. */
export function normalizeSdkItemOverview(item: ItemOverview): NormalizedItemOverview {
return {
id: item.id,
title: item.title,
vault: { id: item.vaultId },
category: SDK_TO_CONNECT_CATEGORY[item.category] ?? 'CUSTOM',
urls: (item.websites ?? []).map((w: Website) => ({
href: w.url,
label: w.label ?? null,
primary: false,
})),
favorite: false,
tags: item.tags ?? [],
version: 0,
state: item.state === 'archived' ? 'ARCHIVED' : null,
createdAt:
item.createdAt instanceof Date ? item.createdAt.toISOString() : (item.createdAt ?? null),
updatedAt:
item.updatedAt instanceof Date ? item.updatedAt.toISOString() : (item.updatedAt ?? null),
lastEditedBy: null,
}
}
/** Normalize a full SDK Item to match Connect API FullItem shape. */
export function normalizeSdkItem(item: Item): NormalizedItem {
return {
id: item.id,
title: item.title,
vault: { id: item.vaultId },
category: SDK_TO_CONNECT_CATEGORY[item.category] ?? 'CUSTOM',
urls: (item.websites ?? []).map((w: Website) => ({
href: w.url,
label: w.label ?? null,
primary: false,
})),
favorite: false,
tags: item.tags ?? [],
version: item.version ?? 0,
state: null,
fields: (item.fields ?? []).map((field: ItemField) => ({
id: field.id,
label: field.title,
type: SDK_TO_CONNECT_FIELD_TYPE[field.fieldType] ?? 'STRING',
purpose: '',
value: field.value ?? null,
section: field.sectionId ? { id: field.sectionId } : null,
generate: false,
recipe: null,
entropy: null,
})),
sections: (item.sections ?? []).map((section: ItemSection) => ({
id: section.id,
label: section.title,
})),
createdAt:
item.createdAt instanceof Date ? item.createdAt.toISOString() : (item.createdAt ?? null),
updatedAt:
item.updatedAt instanceof Date ? item.updatedAt.toISOString() : (item.updatedAt ?? null),
lastEditedBy: null,
}
}
/** Convert a Connect-style category string to the SDK category string. */
export function toSdkCategory(category: string): `${ItemCategory}` {
return CONNECT_TO_SDK_CATEGORY[category] ?? 'Login'
}
/** Convert a Connect-style field type string to the SDK field type string. */
export function toSdkFieldType(type: string): `${ItemFieldType}` {
return CONNECT_TO_SDK_FIELD_TYPE[type] ?? 'Text'
}

View File

@@ -4,11 +4,7 @@ import type React from 'react'
import { useMemo } from 'react'
import { RepeatIcon, SplitIcon } from 'lucide-react'
import { Combobox, type ComboboxOptionGroup } from '@/components/emcn'
import {
extractFieldsFromSchema,
parseResponseFormatSafely,
} from '@/lib/core/utils/response-format'
import { getToolOutputs } from '@/lib/workflows/blocks/block-outputs'
import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
import { getBlock } from '@/blocks'
import { useWorkflowDiffStore } from '@/stores/workflow-diff/store'
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
@@ -124,42 +120,25 @@ export function OutputSelect({
: `block-${block.id}`
const blockConfig = getBlock(block.type)
const responseFormatValue =
shouldUseBaseline && baselineWorkflow
? baselineWorkflow.blocks?.[block.id]?.subBlocks?.responseFormat?.value
: subBlockValues?.[block.id]?.responseFormat
const responseFormat = parseResponseFormatSafely(responseFormatValue, block.id)
let outputsToProcess: Record<string, unknown> = {}
if (responseFormat) {
const schemaFields = extractFieldsFromSchema(responseFormat)
if (schemaFields.length > 0) {
schemaFields.forEach((field) => {
outputsToProcess[field.name] = { type: field.type }
})
} else {
outputsToProcess = blockConfig?.outputs || {}
const rawSubBlockValues =
shouldUseBaseline && baselineWorkflow
? baselineWorkflow.blocks?.[block.id]?.subBlocks
: subBlockValues?.[block.id]
const subBlocks: Record<string, { value: unknown }> = {}
if (rawSubBlockValues && typeof rawSubBlockValues === 'object') {
for (const [key, val] of Object.entries(rawSubBlockValues)) {
// Handle both { value: ... } and raw value formats
subBlocks[key] = val && typeof val === 'object' && 'value' in val ? val : { value: val }
}
} else {
// Build subBlocks object for tool selector
const rawSubBlockValues =
shouldUseBaseline && baselineWorkflow
? baselineWorkflow.blocks?.[block.id]?.subBlocks
: subBlockValues?.[block.id]
const subBlocks: Record<string, { value: unknown }> = {}
if (rawSubBlockValues && typeof rawSubBlockValues === 'object') {
for (const [key, val] of Object.entries(rawSubBlockValues)) {
// Handle both { value: ... } and raw value formats
subBlocks[key] = val && typeof val === 'object' && 'value' in val ? val : { value: val }
}
}
const toolOutputs = blockConfig ? getToolOutputs(blockConfig, subBlocks) : {}
outputsToProcess =
Object.keys(toolOutputs).length > 0 ? toolOutputs : blockConfig?.outputs || {}
}
outputsToProcess = getEffectiveBlockOutputs(block.type, subBlocks, {
triggerMode: Boolean(block.triggerMode),
preferToolOutputs: !block.triggerMode,
}) as Record<string, unknown>
if (Object.keys(outputsToProcess).length === 0) return
const addOutput = (path: string, outputObj: unknown, prefix = '') => {

View File

@@ -61,8 +61,6 @@ function ConnectionItem({
blockId: connection.id,
blockType: connection.type,
mergedSubBlocks,
responseFormat: connection.responseFormat,
operation: connection.operation,
triggerMode: sourceBlock?.triggerMode,
})
const hasFields = fields.length > 0

View File

@@ -14,15 +14,9 @@ import {
} from '@/components/emcn'
import { cn } from '@/lib/core/utils/cn'
import {
extractFieldsFromSchema,
parseResponseFormatSafely,
} from '@/lib/core/utils/response-format'
import {
getBlockOutputPaths,
getBlockOutputType,
getEffectiveBlockOutputPaths,
getEffectiveBlockOutputType,
getOutputPathsFromSchema,
getToolOutputPaths,
getToolOutputType,
} from '@/lib/workflows/blocks/block-outputs'
import { TRIGGER_TYPES } from '@/lib/workflows/triggers/triggers'
import { KeyboardNavigationHandler } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/components/keyboard-navigation-handler'
@@ -214,43 +208,18 @@ const getOutputTypeForPath = (
outputPath: string,
mergedSubBlocksOverride?: Record<string, any>
): string => {
if (block?.triggerMode && blockConfig?.triggers?.enabled) {
return getBlockOutputType(block.type, outputPath, mergedSubBlocksOverride, true)
}
if (block?.type === 'starter') {
const startWorkflowValue =
mergedSubBlocksOverride?.startWorkflow?.value ?? getSubBlockValue(blockId, 'startWorkflow')
if (startWorkflowValue === 'chat') {
const chatModeTypes: Record<string, string> = {
input: 'string',
conversationId: 'string',
files: 'file[]',
}
return chatModeTypes[outputPath] || 'any'
}
const inputFormatValue =
mergedSubBlocksOverride?.inputFormat?.value ?? getSubBlockValue(blockId, 'inputFormat')
if (inputFormatValue && Array.isArray(inputFormatValue)) {
const field = inputFormatValue.find(
(f: { name?: string; type?: string }) => f.name === outputPath
)
if (field?.type) return field.type
}
} else if (blockConfig?.category === 'triggers') {
const blockState = useWorkflowStore.getState().blocks[blockId]
const subBlocks = mergedSubBlocksOverride ?? (blockState?.subBlocks || {})
return getBlockOutputType(block.type, outputPath, subBlocks)
} else if (blockConfig?.tools?.config?.tool) {
const blockState = useWorkflowStore.getState().blocks[blockId]
const subBlocks = mergedSubBlocksOverride ?? (blockState?.subBlocks || {})
return getToolOutputType(blockConfig, subBlocks, outputPath)
if (block?.type === 'variables') {
return 'any'
}
const subBlocks =
mergedSubBlocksOverride ?? useWorkflowStore.getState().blocks[blockId]?.subBlocks
const triggerMode = block?.triggerMode && blockConfig?.triggers?.enabled
return getBlockOutputType(block?.type ?? '', outputPath, subBlocks, triggerMode)
const triggerMode = Boolean(block?.triggerMode && blockConfig?.triggers?.enabled)
return getEffectiveBlockOutputType(block?.type ?? '', outputPath, subBlocks, {
triggerMode,
preferToolOutputs: !triggerMode,
})
}
/**
@@ -1088,24 +1057,9 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
const normalizedBlockName = normalizeName(blockName)
const mergedSubBlocks = getMergedSubBlocks(activeSourceBlockId)
const responseFormatValue = mergedSubBlocks?.responseFormat?.value
const responseFormat = parseResponseFormatSafely(responseFormatValue, activeSourceBlockId)
let blockTags: string[]
if (sourceBlock.type === 'evaluator') {
const metricsValue = getSubBlockValue(activeSourceBlockId, 'metrics')
if (metricsValue && Array.isArray(metricsValue) && metricsValue.length > 0) {
const validMetrics = metricsValue.filter((metric: { name?: string }) => metric?.name)
blockTags = validMetrics.map(
(metric: { name: string }) => `${normalizedBlockName}.${metric.name.toLowerCase()}`
)
} else {
const outputPaths = getBlockOutputPaths(sourceBlock.type, mergedSubBlocks)
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
}
} else if (sourceBlock.type === 'variables') {
if (sourceBlock.type === 'variables') {
const variablesValue = getSubBlockValue(activeSourceBlockId, 'variables')
if (variablesValue && Array.isArray(variablesValue) && variablesValue.length > 0) {
@@ -1119,106 +1073,21 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
} else {
blockTags = [normalizedBlockName]
}
} else if (responseFormat) {
const schemaFields = extractFieldsFromSchema(responseFormat)
if (schemaFields.length > 0) {
blockTags = schemaFields.map((field) => `${normalizedBlockName}.${field.name}`)
} else {
const outputPaths = getBlockOutputPaths(
sourceBlock.type,
mergedSubBlocks,
sourceBlock.triggerMode
)
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
}
} else if (!blockConfig.outputs || Object.keys(blockConfig.outputs).length === 0) {
if (sourceBlock.type === 'starter') {
const startWorkflowValue = mergedSubBlocks?.startWorkflow?.value
if (startWorkflowValue === 'chat') {
blockTags = [
`${normalizedBlockName}.input`,
`${normalizedBlockName}.conversationId`,
`${normalizedBlockName}.files`,
]
} else {
const inputFormatValue = mergedSubBlocks?.inputFormat?.value
if (
inputFormatValue &&
Array.isArray(inputFormatValue) &&
inputFormatValue.length > 0
) {
blockTags = inputFormatValue
.filter((field: { name?: string }) => field.name && field.name.trim() !== '')
.map((field: { name: string }) => `${normalizedBlockName}.${field.name}`)
} else {
blockTags = [normalizedBlockName]
}
}
} else if (sourceBlock.type === 'api_trigger' || sourceBlock.type === 'input_trigger') {
const inputFormatValue = mergedSubBlocks?.inputFormat?.value
if (inputFormatValue && Array.isArray(inputFormatValue) && inputFormatValue.length > 0) {
blockTags = inputFormatValue
.filter((field: { name?: string }) => field.name && field.name.trim() !== '')
.map((field: { name: string }) => `${normalizedBlockName}.${field.name}`)
} else {
blockTags = []
}
} else {
blockTags = [normalizedBlockName]
}
} else {
if (blockConfig.category === 'triggers' || sourceBlock.type === 'starter') {
const dynamicOutputs = getBlockOutputPaths(sourceBlock.type, mergedSubBlocks)
if (dynamicOutputs.length > 0) {
blockTags = dynamicOutputs.map((path) => `${normalizedBlockName}.${path}`)
} else if (sourceBlock.type === 'starter') {
blockTags = [normalizedBlockName]
} else if (sourceBlock.type === TRIGGER_TYPES.GENERIC_WEBHOOK) {
blockTags = [normalizedBlockName]
} else {
blockTags = []
}
} else if (sourceBlock?.triggerMode && blockConfig.triggers?.enabled) {
const dynamicOutputs = getBlockOutputPaths(sourceBlock.type, mergedSubBlocks, true)
if (dynamicOutputs.length > 0) {
blockTags = dynamicOutputs.map((path) => `${normalizedBlockName}.${path}`)
} else {
const outputPaths = getBlockOutputPaths(sourceBlock.type, mergedSubBlocks, true)
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
}
} else if (sourceBlock.type === 'human_in_the_loop') {
const dynamicOutputs = getBlockOutputPaths(sourceBlock.type, mergedSubBlocks)
const outputPaths = getEffectiveBlockOutputPaths(sourceBlock.type, mergedSubBlocks, {
triggerMode: Boolean(sourceBlock.triggerMode),
preferToolOutputs: !sourceBlock.triggerMode,
})
const allTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
const isSelfReference = activeSourceBlockId === blockId
if (dynamicOutputs.length > 0) {
const allTags = dynamicOutputs.map((path) => `${normalizedBlockName}.${path}`)
blockTags = isSelfReference
? allTags.filter((tag) => tag.endsWith('.url') || tag.endsWith('.resumeEndpoint'))
: allTags
} else {
const outputPaths = getBlockOutputPaths(sourceBlock.type, mergedSubBlocks)
const allTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
blockTags = isSelfReference
? allTags.filter((tag) => tag.endsWith('.url') || tag.endsWith('.resumeEndpoint'))
: allTags
}
if (sourceBlock.type === 'human_in_the_loop' && activeSourceBlockId === blockId) {
blockTags = allTags.filter(
(tag) => tag.endsWith('.url') || tag.endsWith('.resumeEndpoint')
)
} else if (allTags.length === 0) {
blockTags = [normalizedBlockName]
} else {
const toolOutputPaths = getToolOutputPaths(blockConfig, mergedSubBlocks)
if (toolOutputPaths.length > 0) {
blockTags = toolOutputPaths.map((path) => `${normalizedBlockName}.${path}`)
} else {
const outputPaths = getBlockOutputPaths(
sourceBlock.type,
mergedSubBlocks,
sourceBlock.triggerMode
)
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
}
blockTags = allTags
}
}
@@ -1432,45 +1301,10 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
const normalizedBlockName = normalizeName(blockName)
const mergedSubBlocks = getMergedSubBlocks(accessibleBlockId)
const responseFormatValue = mergedSubBlocks?.responseFormat?.value
const responseFormat = parseResponseFormatSafely(responseFormatValue, accessibleBlockId)
let blockTags: string[]
if (blockConfig.category === 'triggers' || accessibleBlock.type === 'starter') {
const dynamicOutputs = getBlockOutputPaths(accessibleBlock.type, mergedSubBlocks)
if (dynamicOutputs.length > 0) {
blockTags = dynamicOutputs.map((path) => `${normalizedBlockName}.${path}`)
} else if (accessibleBlock.type === 'starter') {
const startWorkflowValue = mergedSubBlocks?.startWorkflow?.value
if (startWorkflowValue === 'chat') {
blockTags = [
`${normalizedBlockName}.input`,
`${normalizedBlockName}.conversationId`,
`${normalizedBlockName}.files`,
]
} else {
blockTags = [normalizedBlockName]
}
} else if (accessibleBlock.type === TRIGGER_TYPES.GENERIC_WEBHOOK) {
blockTags = [normalizedBlockName]
} else {
blockTags = []
}
} else if (accessibleBlock.type === 'evaluator') {
const metricsValue = getSubBlockValue(accessibleBlockId, 'metrics')
if (metricsValue && Array.isArray(metricsValue) && metricsValue.length > 0) {
const validMetrics = metricsValue.filter((metric: { name?: string }) => metric?.name)
blockTags = validMetrics.map(
(metric: { name: string }) => `${normalizedBlockName}.${metric.name.toLowerCase()}`
)
} else {
const outputPaths = getBlockOutputPaths(accessibleBlock.type, mergedSubBlocks)
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
}
} else if (accessibleBlock.type === 'variables') {
if (accessibleBlock.type === 'variables') {
const variablesValue = getSubBlockValue(accessibleBlockId, 'variables')
if (variablesValue && Array.isArray(variablesValue) && variablesValue.length > 0) {
@@ -1484,57 +1318,21 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
} else {
blockTags = [normalizedBlockName]
}
} else if (responseFormat) {
const schemaFields = extractFieldsFromSchema(responseFormat)
if (schemaFields.length > 0) {
blockTags = schemaFields.map((field) => `${normalizedBlockName}.${field.name}`)
} else {
const outputPaths = getBlockOutputPaths(
accessibleBlock.type,
mergedSubBlocks,
accessibleBlock.triggerMode
)
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
}
} else if (!blockConfig.outputs || Object.keys(blockConfig.outputs).length === 0) {
blockTags = [normalizedBlockName]
} else {
const blockState = blocks[accessibleBlockId]
if (blockState?.triggerMode && blockConfig.triggers?.enabled) {
const dynamicOutputs = getBlockOutputPaths(accessibleBlock.type, mergedSubBlocks, true)
if (dynamicOutputs.length > 0) {
blockTags = dynamicOutputs.map((path) => `${normalizedBlockName}.${path}`)
} else {
const outputPaths = getBlockOutputPaths(accessibleBlock.type, mergedSubBlocks, true)
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
}
} else if (accessibleBlock.type === 'human_in_the_loop') {
const dynamicOutputs = getBlockOutputPaths(accessibleBlock.type, mergedSubBlocks)
const outputPaths = getEffectiveBlockOutputPaths(accessibleBlock.type, mergedSubBlocks, {
triggerMode: Boolean(accessibleBlock.triggerMode),
preferToolOutputs: !accessibleBlock.triggerMode,
})
const allTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
const isSelfReference = accessibleBlockId === blockId
if (dynamicOutputs.length > 0) {
const allTags = dynamicOutputs.map((path) => `${normalizedBlockName}.${path}`)
blockTags = isSelfReference
? allTags.filter((tag) => tag.endsWith('.url') || tag.endsWith('.resumeEndpoint'))
: allTags
} else {
blockTags = [`${normalizedBlockName}.url`, `${normalizedBlockName}.resumeEndpoint`]
}
if (accessibleBlock.type === 'human_in_the_loop' && accessibleBlockId === blockId) {
blockTags = allTags.filter(
(tag) => tag.endsWith('.url') || tag.endsWith('.resumeEndpoint')
)
} else if (allTags.length === 0) {
blockTags = [normalizedBlockName]
} else {
const toolOutputPaths = getToolOutputPaths(blockConfig, mergedSubBlocks)
if (toolOutputPaths.length > 0) {
blockTags = toolOutputPaths.map((path) => `${normalizedBlockName}.${path}`)
} else {
const outputPaths = getBlockOutputPaths(
accessibleBlock.type,
mergedSubBlocks,
accessibleBlock.triggerMode
)
blockTags = outputPaths.map((path) => `${normalizedBlockName}.${path}`)
}
blockTags = allTags
}
}

View File

@@ -1,9 +1,5 @@
import { useShallow } from 'zustand/react/shallow'
import {
extractFieldsFromSchema,
parseResponseFormatSafely,
} from '@/lib/core/utils/response-format'
import { getBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
import { BlockPathCalculator } from '@/lib/workflows/blocks/block-path-calculator'
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
@@ -20,18 +16,7 @@ export interface ConnectedBlock {
type: string
outputType: string | string[]
name: string
responseFormat?: {
// Support both formats
fields?: Field[]
name?: string
schema?: {
type: string
properties: Record<string, any>
required?: string[]
}
}
outputs?: Record<string, any>
operation?: string
}
export function useBlockConnections(blockId: string) {
@@ -103,46 +88,28 @@ export function useBlockConnections(blockId: string) {
// Get merged subblocks for this source block
const mergedSubBlocks = getMergedSubBlocks(sourceId)
// Get the response format from the subblock store
const responseFormatValue = useSubBlockStore.getState().getValue(sourceId, 'responseFormat')
const blockOutputs = getEffectiveBlockOutputs(sourceBlock.type, mergedSubBlocks, {
triggerMode: Boolean(sourceBlock.triggerMode),
preferToolOutputs: !sourceBlock.triggerMode,
})
// Safely parse response format with proper error handling
const responseFormat = parseResponseFormatSafely(responseFormatValue, sourceId)
// Get operation value for tool-based blocks
const operationValue = useSubBlockStore.getState().getValue(sourceId, 'operation')
// Use getBlockOutputs to properly handle dynamic outputs from inputFormat
const blockOutputs = getBlockOutputs(
sourceBlock.type,
mergedSubBlocks,
sourceBlock.triggerMode
)
// Extract fields from the response format if available, otherwise use block outputs
let outputFields: Field[]
if (responseFormat) {
outputFields = extractFieldsFromSchema(responseFormat)
} else {
// Convert block outputs to field format
outputFields = Object.entries(blockOutputs).map(([key, value]: [string, any]) => ({
const outputFields: Field[] = Object.entries(blockOutputs).map(
([key, value]: [string, any]) => ({
name: key,
type: value && typeof value === 'object' && 'type' in value ? value.type : 'string',
description:
value && typeof value === 'object' && 'description' in value
? value.description
: undefined,
}))
}
})
)
return {
id: sourceBlock.id,
type: sourceBlock.type,
outputType: outputFields.map((field: Field) => field.name),
name: sourceBlock.name,
responseFormat,
outputs: blockOutputs,
operation: operationValue,
distance: nodeDistances.get(sourceId) || Number.POSITIVE_INFINITY,
}
})

View File

@@ -1,13 +1,7 @@
'use client'
import { useMemo } from 'react'
import { extractFieldsFromSchema } from '@/lib/core/utils/response-format'
import {
getBlockOutputPaths,
getBlockOutputs,
getToolOutputs,
} from '@/lib/workflows/blocks/block-outputs'
import { TRIGGER_TYPES } from '@/lib/workflows/triggers/triggers'
import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
import type { SchemaField } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/connection-blocks/components/field-item/field-item'
import { getBlock } from '@/blocks'
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
@@ -76,11 +70,7 @@ const extractNestedFields = (properties: Record<string, any>): SchemaField[] =>
/**
* Creates a schema field from an output definition
*/
const createFieldFromOutput = (
name: string,
output: any,
responseFormatFields?: SchemaField[]
): SchemaField => {
const createFieldFromOutput = (name: string, output: any): SchemaField => {
const hasExplicitType = isObject(output) && typeof output.type === 'string'
const type = hasExplicitType ? output.type : isObject(output) ? 'object' : 'string'
@@ -90,11 +80,7 @@ const createFieldFromOutput = (
description: isObject(output) && 'description' in output ? output.description : undefined,
}
if (name === 'data' && responseFormatFields && responseFormatFields.length > 0) {
field.children = responseFormatFields
} else {
field.children = extractChildFields(output)
}
field.children = extractChildFields(output)
return field
}
@@ -103,8 +89,6 @@ interface UseBlockOutputFieldsParams {
blockId: string
blockType: string
mergedSubBlocks?: Record<string, any>
responseFormat?: any
operation?: string
triggerMode?: boolean
}
@@ -116,8 +100,6 @@ export function useBlockOutputFields({
blockId,
blockType,
mergedSubBlocks,
responseFormat,
operation,
triggerMode,
}: UseBlockOutputFieldsParams): SchemaField[] {
return useMemo(() => {
@@ -138,21 +120,6 @@ export function useBlockOutputFields({
return []
}
// Handle evaluator blocks - use metrics if available
if (blockType === 'evaluator') {
const metricsValue = mergedSubBlocks?.metrics?.value ?? getSubBlockValue(blockId, 'metrics')
if (metricsValue && Array.isArray(metricsValue) && metricsValue.length > 0) {
const validMetrics = metricsValue.filter((metric: { name?: string }) => metric?.name)
return validMetrics.map((metric: { name: string }) => ({
name: metric.name.toLowerCase(),
type: 'number',
description: `Metric: ${metric.name}`,
}))
}
// Fall through to use blockConfig.outputs
}
// Handle variables blocks - use variable assignments if available
if (blockType === 'variables') {
const variablesValue =
@@ -172,123 +139,14 @@ export function useBlockOutputFields({
return []
}
// Get base outputs using getBlockOutputs (handles triggers, starter, approval, etc.)
let baseOutputs: Record<string, any> = {}
if (blockConfig.category === 'triggers' || blockType === 'starter') {
// Use getBlockOutputPaths to get dynamic outputs, then reconstruct the structure
const outputPaths = getBlockOutputPaths(blockType, mergedSubBlocks, triggerMode)
if (outputPaths.length > 0) {
// Reconstruct outputs structure from paths
// This is a simplified approach - we'll use the paths to build the structure
baseOutputs = getBlockOutputs(blockType, mergedSubBlocks, triggerMode)
} else if (blockType === 'starter') {
const startWorkflowValue = mergedSubBlocks?.startWorkflow?.value
if (startWorkflowValue === 'chat') {
baseOutputs = {
input: { type: 'string', description: 'User message' },
conversationId: { type: 'string', description: 'Conversation ID' },
files: { type: 'file[]', description: 'Uploaded files' },
}
} else {
const inputFormatValue = mergedSubBlocks?.inputFormat?.value
if (inputFormatValue && Array.isArray(inputFormatValue) && inputFormatValue.length > 0) {
baseOutputs = {}
inputFormatValue.forEach((field: { name?: string; type?: string }) => {
if (field.name && field.name.trim() !== '') {
baseOutputs[field.name] = {
type: field.type || 'string',
description: `Field from input format`,
}
}
})
}
}
} else if (blockType === TRIGGER_TYPES.GENERIC_WEBHOOK) {
// Generic webhook returns the whole payload
baseOutputs = {}
} else {
baseOutputs = {}
}
} else if (triggerMode && blockConfig.triggers?.enabled) {
// Trigger mode enabled
const dynamicOutputs = getBlockOutputPaths(blockType, mergedSubBlocks, true)
if (dynamicOutputs.length > 0) {
baseOutputs = getBlockOutputs(blockType, mergedSubBlocks, true)
} else {
baseOutputs = blockConfig.outputs || {}
}
} else if (blockType === 'approval') {
// Approval block uses dynamic outputs from inputFormat
baseOutputs = getBlockOutputs(blockType, mergedSubBlocks)
} else {
// For tool-based blocks, try to get tool outputs first
const toolOutputs = blockConfig ? getToolOutputs(blockConfig, mergedSubBlocks) : {}
if (Object.keys(toolOutputs).length > 0) {
baseOutputs = toolOutputs
} else {
baseOutputs = getBlockOutputs(blockType, mergedSubBlocks, triggerMode)
}
}
// Handle responseFormat
const responseFormatFields = responseFormat ? extractFieldsFromSchema(responseFormat) : []
// If responseFormat exists and has fields, merge with base outputs
if (responseFormatFields.length > 0) {
// If base outputs is empty, use responseFormat fields directly
if (Object.keys(baseOutputs).length === 0) {
return responseFormatFields.map((field) => ({
name: field.name,
type: field.type,
description: field.description,
children: undefined, // ResponseFormat fields are flat
}))
}
// Otherwise, merge: responseFormat takes precedence for 'data' field
const fields: SchemaField[] = []
const responseFormatFieldNames = new Set(responseFormatFields.map((f) => f.name))
// Add base outputs, replacing 'data' with responseFormat fields if present
for (const [name, output] of Object.entries(baseOutputs)) {
if (name === 'data' && responseFormatFields.length > 0) {
fields.push(
createFieldFromOutput(
name,
output,
responseFormatFields.map((f) => ({
name: f.name,
type: f.type,
description: f.description,
}))
)
)
} else if (!responseFormatFieldNames.has(name)) {
fields.push(createFieldFromOutput(name, output))
}
}
// Add responseFormat fields that aren't in base outputs
for (const field of responseFormatFields) {
if (!baseOutputs[field.name]) {
fields.push({
name: field.name,
type: field.type,
description: field.description,
})
}
}
return fields
}
// No responseFormat, just use base outputs
const baseOutputs = getEffectiveBlockOutputs(blockType, mergedSubBlocks, {
triggerMode: Boolean(triggerMode),
preferToolOutputs: !triggerMode,
}) as Record<string, any>
if (Object.keys(baseOutputs).length === 0) {
return []
}
return Object.entries(baseOutputs).map(([name, output]) => createFieldFromOutput(name, output))
}, [blockId, blockType, mergedSubBlocks, responseFormat, operation, triggerMode])
}, [blockId, blockType, mergedSubBlocks, triggerMode])
}

View File

@@ -269,32 +269,14 @@ Return ONLY the description text - no explanations.`,
'Describe the issue details (e.g., "users seeing 500 error when clicking submit")...',
},
},
// Write Issue type and parent
{
id: 'issueType',
title: 'Issue Type',
type: 'short-input',
placeholder: 'Issue type (e.g., Task, Story, Bug, Epic)',
dependsOn: ['projectId'],
condition: { field: 'operation', value: 'write' },
value: () => 'Task',
},
{
id: 'parentIssue',
title: 'Parent Issue Key',
type: 'short-input',
placeholder: 'Parent issue key for subtasks (e.g., PROJ-123)',
dependsOn: ['projectId'],
condition: { field: 'operation', value: 'write' },
},
// Write/Update Issue additional fields
// Write Issue additional fields
{
id: 'assignee',
title: 'Assignee Account ID',
type: 'short-input',
placeholder: 'Assignee account ID (e.g., 5b109f2e9729b51b54dc274d)',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
condition: { field: 'operation', value: 'write' },
},
{
id: 'priority',
@@ -302,7 +284,7 @@ Return ONLY the description text - no explanations.`,
type: 'short-input',
placeholder: 'Priority ID or name (e.g., "10000" or "High")',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
condition: { field: 'operation', value: 'write' },
},
{
id: 'labels',
@@ -310,7 +292,7 @@ Return ONLY the description text - no explanations.`,
type: 'short-input',
placeholder: 'Comma-separated labels (e.g., bug, urgent)',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
condition: { field: 'operation', value: 'write' },
},
{
id: 'duedate',
@@ -318,7 +300,7 @@ Return ONLY the description text - no explanations.`,
type: 'short-input',
placeholder: 'YYYY-MM-DD (e.g., 2024-12-31)',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
condition: { field: 'operation', value: 'write' },
wandConfig: {
enabled: true,
prompt: `Generate a date in YYYY-MM-DD format based on the user's description.
@@ -347,7 +329,7 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
type: 'long-input',
placeholder: 'Environment information (e.g., Production, Staging)',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
condition: { field: 'operation', value: 'write' },
},
{
id: 'customFieldId',
@@ -355,7 +337,7 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
type: 'short-input',
placeholder: 'e.g., customfield_10001 or 10001',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
condition: { field: 'operation', value: 'write' },
},
{
id: 'customFieldValue',
@@ -363,34 +345,7 @@ Return ONLY the date string in YYYY-MM-DD format - no explanations, no quotes, n
type: 'short-input',
placeholder: 'Value for the custom field',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
},
{
id: 'components',
title: 'Components',
type: 'short-input',
placeholder: 'Comma-separated component names',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
},
{
id: 'fixVersions',
title: 'Fix Versions',
type: 'short-input',
placeholder: 'Comma-separated fix version names',
dependsOn: ['projectId'],
condition: { field: 'operation', value: ['write', 'update'] },
},
{
id: 'notifyUsers',
title: 'Notify Users',
type: 'dropdown',
options: [
{ label: 'Yes', id: 'true' },
{ label: 'No', id: 'false' },
],
value: () => 'true',
condition: { field: 'operation', value: 'update' },
condition: { field: 'operation', value: 'write' },
},
// Delete Issue fields
{
@@ -440,13 +395,6 @@ Return ONLY the comment text - no explanations.`,
placeholder: 'Describe the transition reason (e.g., "fixed bug", "ready for QA review")...',
},
},
{
id: 'resolution',
title: 'Resolution',
type: 'short-input',
placeholder: 'Resolution name (e.g., "Fixed", "Won\'t Fix")',
condition: { field: 'operation', value: 'transition' },
},
// Search Issues fields
{
id: 'jql',
@@ -472,20 +420,6 @@ Return ONLY the JQL query - no explanations or markdown formatting.`,
generationType: 'sql-query',
},
},
{
id: 'nextPageToken',
title: 'Next Page Token',
type: 'short-input',
placeholder: 'Cursor token for next page (omit for first page)',
condition: { field: 'operation', value: 'search' },
},
{
id: 'startAt',
title: 'Start At',
type: 'short-input',
placeholder: 'Pagination start index (default: 0)',
condition: { field: 'operation', value: ['get_comments', 'get_worklogs'] },
},
{
id: 'maxResults',
title: 'Max Results',
@@ -822,9 +756,7 @@ Return ONLY the comment text - no explanations.`,
assignee: params.assignee || undefined,
priority: params.priority || undefined,
labels: parseCommaSeparated(params.labels),
components: parseCommaSeparated(params.components),
duedate: params.duedate || undefined,
fixVersions: parseCommaSeparated(params.fixVersions),
reporter: params.reporter || undefined,
environment: params.environment || undefined,
customFieldId: params.customFieldId || undefined,
@@ -836,29 +768,11 @@ Return ONLY the comment text - no explanations.`,
}
}
case 'update': {
const parseCommaSeparated = (value: string | undefined): string[] | undefined => {
if (!value || value.trim() === '') return undefined
return value
.split(',')
.map((item) => item.trim())
.filter((item) => item !== '')
}
const updateParams = {
projectId: effectiveProjectId,
issueKey: effectiveIssueKey,
summary: params.summary || undefined,
description: params.description || undefined,
assignee: params.assignee || undefined,
priority: params.priority || undefined,
labels: parseCommaSeparated(params.labels),
components: parseCommaSeparated(params.components),
duedate: params.duedate || undefined,
fixVersions: parseCommaSeparated(params.fixVersions),
environment: params.environment || undefined,
customFieldId: params.customFieldId || undefined,
customFieldValue: params.customFieldValue || undefined,
notifyUsers: params.notifyUsers === 'false' ? false : undefined,
summary: params.summary || '',
description: params.description || '',
}
return {
...baseParams,
@@ -899,14 +813,12 @@ Return ONLY the comment text - no explanations.`,
issueKey: effectiveIssueKey,
transitionId: params.transitionId,
comment: params.transitionComment,
resolution: params.resolution || undefined,
}
}
case 'search': {
return {
...baseParams,
jql: params.jql,
nextPageToken: params.nextPageToken || undefined,
maxResults: params.maxResults ? Number.parseInt(params.maxResults) : undefined,
}
}
@@ -921,7 +833,6 @@ Return ONLY the comment text - no explanations.`,
return {
...baseParams,
issueKey: effectiveIssueKey,
startAt: params.startAt ? Number.parseInt(params.startAt) : undefined,
maxResults: params.maxResults ? Number.parseInt(params.maxResults) : undefined,
}
}
@@ -978,7 +889,6 @@ Return ONLY the comment text - no explanations.`,
return {
...baseParams,
issueKey: effectiveIssueKey,
startAt: params.startAt ? Number.parseInt(params.startAt) : undefined,
maxResults: params.maxResults ? Number.parseInt(params.maxResults) : undefined,
}
}
@@ -1056,19 +966,15 @@ Return ONLY the comment text - no explanations.`,
summary: { type: 'string', description: 'Issue summary' },
description: { type: 'string', description: 'Issue description' },
issueType: { type: 'string', description: 'Issue type' },
// Write/Update operation additional inputs
parentIssue: { type: 'string', description: 'Parent issue key for subtasks' },
// Write operation additional inputs
assignee: { type: 'string', description: 'Assignee account ID' },
priority: { type: 'string', description: 'Priority ID or name' },
labels: { type: 'string', description: 'Comma-separated labels for the issue' },
components: { type: 'string', description: 'Comma-separated component names' },
duedate: { type: 'string', description: 'Due date in YYYY-MM-DD format' },
fixVersions: { type: 'string', description: 'Comma-separated fix version names' },
reporter: { type: 'string', description: 'Reporter account ID' },
environment: { type: 'string', description: 'Environment information' },
customFieldId: { type: 'string', description: 'Custom field ID (e.g., customfield_10001)' },
customFieldValue: { type: 'string', description: 'Value for the custom field' },
notifyUsers: { type: 'string', description: 'Whether to send notifications on update' },
// Delete operation inputs
deleteSubtasks: { type: 'string', description: 'Whether to delete subtasks (true/false)' },
// Assign/Watcher operation inputs
@@ -1079,13 +985,7 @@ Return ONLY the comment text - no explanations.`,
// Transition operation inputs
transitionId: { type: 'string', description: 'Transition ID for workflow status changes' },
transitionComment: { type: 'string', description: 'Optional comment for transition' },
resolution: { type: 'string', description: 'Resolution name for transition (e.g., "Fixed")' },
// Search operation inputs
nextPageToken: {
type: 'string',
description: 'Cursor token for the next page of search results',
},
startAt: { type: 'string', description: 'Pagination start index' },
jql: { type: 'string', description: 'JQL (Jira Query Language) search query' },
maxResults: { type: 'string', description: 'Maximum number of results to return' },
// Comment operation inputs
@@ -1138,11 +1038,8 @@ Return ONLY the comment text - no explanations.`,
id: { type: 'string', description: 'Jira issue ID' },
key: { type: 'string', description: 'Jira issue key' },
// jira_search_issues / jira_bulk_read outputs
// jira_search_issues outputs
total: { type: 'number', description: 'Total number of matching issues' },
nextPageToken: { type: 'string', description: 'Cursor token for the next page of results' },
isLast: { type: 'boolean', description: 'Whether this is the last page of results' },
// Shared pagination outputs (get_comments, get_worklogs, get_users)
startAt: { type: 'number', description: 'Pagination start index' },
maxResults: { type: 'number', description: 'Maximum results per page' },
issues: {

View File

@@ -40,7 +40,6 @@ export const JiraServiceManagementBlock: BlockConfig<JsmResponse> = {
{ label: 'Add Participants', id: 'add_participants' },
{ label: 'Get Approvals', id: 'get_approvals' },
{ label: 'Answer Approval', id: 'answer_approval' },
{ label: 'Get Request Type Fields', id: 'get_request_type_fields' },
],
value: () => 'get_service_desks',
},
@@ -110,8 +109,6 @@ export const JiraServiceManagementBlock: BlockConfig<JsmResponse> = {
'get_organizations',
'add_organization',
'get_queues',
'get_requests',
'get_request_type_fields',
],
},
},
@@ -121,7 +118,7 @@ export const JiraServiceManagementBlock: BlockConfig<JsmResponse> = {
type: 'short-input',
required: true,
placeholder: 'Enter request type ID',
condition: { field: 'operation', value: ['create_request', 'get_request_type_fields'] },
condition: { field: 'operation', value: 'create_request' },
},
{
id: 'issueIdOrKey',
@@ -191,51 +188,6 @@ Return ONLY the description text - no explanations.`,
placeholder: 'Account ID to raise request on behalf of',
condition: { field: 'operation', value: 'create_request' },
},
{
id: 'requestParticipants',
title: 'Request Participants',
type: 'short-input',
placeholder: 'Comma-separated account IDs to add as participants',
condition: { field: 'operation', value: 'create_request' },
},
{
id: 'channel',
title: 'Channel',
type: 'short-input',
placeholder: 'Channel (e.g., portal, email)',
condition: { field: 'operation', value: 'create_request' },
},
{
id: 'requestFieldValues',
title: 'Custom Field Values',
type: 'long-input',
placeholder: 'JSON object of custom field values (e.g., {"customfield_10010": "value"})',
condition: { field: 'operation', value: 'create_request' },
},
{
id: 'searchQuery',
title: 'Search Query',
type: 'short-input',
placeholder: 'Filter request types by name',
condition: { field: 'operation', value: 'get_request_types' },
},
{
id: 'groupId',
title: 'Group ID',
type: 'short-input',
placeholder: 'Filter by request type group',
condition: { field: 'operation', value: 'get_request_types' },
},
{
id: 'expand',
title: 'Expand',
type: 'short-input',
placeholder: 'Comma-separated fields to expand',
condition: {
field: 'operation',
value: ['get_request', 'get_requests', 'get_comments'],
},
},
{
id: 'commentBody',
title: 'Comment',
@@ -268,11 +220,11 @@ Return ONLY the comment text - no explanations.`,
condition: { field: 'operation', value: 'add_comment' },
},
{
id: 'accountIds',
title: 'Account IDs',
id: 'emails',
title: 'Email Addresses',
type: 'short-input',
required: true,
placeholder: 'Comma-separated Atlassian account IDs',
placeholder: 'Comma-separated email addresses',
condition: { field: 'operation', value: 'add_customer' },
},
{
@@ -317,7 +269,7 @@ Return ONLY the comment text - no explanations.`,
{ label: 'All Requests', id: 'ALL_REQUESTS' },
{ label: 'My Requests', id: 'OWNED_REQUESTS' },
{ label: 'Participated', id: 'PARTICIPATED_REQUESTS' },
{ label: 'Approver', id: 'APPROVER' },
{ label: 'Organization', id: 'ORGANIZATION' },
],
value: () => 'ALL_REQUESTS',
condition: { field: 'operation', value: 'get_requests' },
@@ -327,11 +279,11 @@ Return ONLY the comment text - no explanations.`,
title: 'Request Status',
type: 'dropdown',
options: [
{ label: 'All', id: 'ALL_REQUESTS' },
{ label: 'Open', id: 'OPEN_REQUESTS' },
{ label: 'Closed', id: 'CLOSED_REQUESTS' },
{ label: 'All', id: 'ALL' },
{ label: 'Open', id: 'OPEN' },
{ label: 'Closed', id: 'CLOSED' },
],
value: () => 'ALL_REQUESTS',
value: () => 'ALL',
condition: { field: 'operation', value: 'get_requests' },
},
{
@@ -411,9 +363,6 @@ Return ONLY the comment text - no explanations.`,
'get_organizations',
'get_queues',
'get_sla',
'get_transitions',
'get_participants',
'get_approvals',
],
},
},
@@ -440,7 +389,6 @@ Return ONLY the comment text - no explanations.`,
'jsm_add_participants',
'jsm_get_approvals',
'jsm_answer_approval',
'jsm_get_request_type_fields',
],
config: {
tool: (params) => {
@@ -485,8 +433,6 @@ Return ONLY the comment text - no explanations.`,
return 'jsm_get_approvals'
case 'answer_approval':
return 'jsm_answer_approval'
case 'get_request_type_fields':
return 'jsm_get_request_type_fields'
default:
return 'jsm_get_service_desks'
}
@@ -510,8 +456,6 @@ Return ONLY the comment text - no explanations.`,
return {
...baseParams,
serviceDeskId: params.serviceDeskId,
searchQuery: params.searchQuery,
groupId: params.groupId,
limit: params.maxResults ? Number.parseInt(params.maxResults) : undefined,
}
case 'create_request':
@@ -531,11 +475,6 @@ Return ONLY the comment text - no explanations.`,
summary: params.summary,
description: params.description,
raiseOnBehalfOf: params.raiseOnBehalfOf,
requestParticipants: params.requestParticipants,
channel: params.channel,
requestFieldValues: params.requestFieldValues
? JSON.parse(params.requestFieldValues)
: undefined,
}
case 'get_request':
if (!params.issueIdOrKey) {
@@ -544,7 +483,6 @@ Return ONLY the comment text - no explanations.`,
return {
...baseParams,
issueIdOrKey: params.issueIdOrKey,
expand: params.expand,
}
case 'get_requests':
return {
@@ -553,7 +491,6 @@ Return ONLY the comment text - no explanations.`,
requestOwnership: params.requestOwnership,
requestStatus: params.requestStatus,
searchTerm: params.searchTerm,
expand: params.expand,
limit: params.maxResults ? Number.parseInt(params.maxResults) : undefined,
}
case 'add_comment':
@@ -576,7 +513,6 @@ Return ONLY the comment text - no explanations.`,
return {
...baseParams,
issueIdOrKey: params.issueIdOrKey,
expand: params.expand,
limit: params.maxResults ? Number.parseInt(params.maxResults) : undefined,
}
case 'get_customers':
@@ -593,14 +529,26 @@ Return ONLY the comment text - no explanations.`,
if (!params.serviceDeskId) {
throw new Error('Service Desk ID is required')
}
if (!params.accountIds && !params.emails) {
throw new Error('Account IDs or emails are required')
const accountIds = params.accountIds
? params.accountIds
.split(',')
.map((id: string) => id.trim())
.filter((id: string) => id)
: undefined
const emails = params.emails
? params.emails
.split(',')
.map((email: string) => email.trim())
.filter((email: string) => email)
: undefined
if ((!accountIds || accountIds.length === 0) && (!emails || emails.length === 0)) {
throw new Error('At least one account ID or email is required')
}
return {
...baseParams,
serviceDeskId: params.serviceDeskId,
accountIds: params.accountIds,
emails: params.emails,
accountIds,
emails,
}
}
case 'get_organizations':
@@ -638,7 +586,6 @@ Return ONLY the comment text - no explanations.`,
return {
...baseParams,
issueIdOrKey: params.issueIdOrKey,
limit: params.maxResults ? Number.parseInt(params.maxResults) : undefined,
}
case 'transition_request':
if (!params.issueIdOrKey) {
@@ -719,18 +666,6 @@ Return ONLY the comment text - no explanations.`,
approvalId: params.approvalId,
decision: params.approvalDecision,
}
case 'get_request_type_fields':
if (!params.serviceDeskId) {
throw new Error('Service Desk ID is required')
}
if (!params.requestTypeId) {
throw new Error('Request Type ID is required')
}
return {
...baseParams,
serviceDeskId: params.serviceDeskId,
requestTypeId: params.requestTypeId,
}
default:
return baseParams
}
@@ -749,11 +684,8 @@ Return ONLY the comment text - no explanations.`,
raiseOnBehalfOf: { type: 'string', description: 'Account ID to raise request on behalf of' },
commentBody: { type: 'string', description: 'Comment text' },
isPublic: { type: 'string', description: 'Whether comment is public or internal' },
accountIds: { type: 'string', description: 'Comma-separated Atlassian account IDs' },
emails: {
type: 'string',
description: 'Comma-separated email addresses',
},
accountIds: { type: 'string', description: 'Comma-separated account IDs' },
emails: { type: 'string', description: 'Comma-separated email addresses' },
customerQuery: { type: 'string', description: 'Customer search query' },
transitionId: { type: 'string', description: 'Transition ID' },
transitionComment: { type: 'string', description: 'Transition comment' },
@@ -770,15 +702,6 @@ Return ONLY the comment text - no explanations.`,
},
approvalId: { type: 'string', description: 'Approval ID' },
approvalDecision: { type: 'string', description: 'Approval decision (approve/decline)' },
requestParticipants: {
type: 'string',
description: 'Comma-separated account IDs for request participants',
},
channel: { type: 'string', description: 'Channel (e.g., portal, email)' },
requestFieldValues: { type: 'string', description: 'JSON object of custom field values' },
searchQuery: { type: 'string', description: 'Filter request types by name' },
groupId: { type: 'string', description: 'Filter by request type group ID' },
expand: { type: 'string', description: 'Comma-separated fields to expand' },
},
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
@@ -804,19 +727,9 @@ Return ONLY the comment text - no explanations.`,
transitionId: { type: 'string', description: 'Applied transition ID' },
participants: { type: 'json', description: 'Array of participants' },
approvals: { type: 'json', description: 'Array of approvals' },
approval: { type: 'json', description: 'Approval object' },
approvalId: { type: 'string', description: 'Approval ID' },
decision: { type: 'string', description: 'Approval decision' },
total: { type: 'number', description: 'Total count' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
requestTypeFields: { type: 'json', description: 'Array of request type fields' },
canAddRequestParticipants: {
type: 'boolean',
description: 'Whether participants can be added to this request type',
},
canRaiseOnBehalfOf: {
type: 'boolean',
description: 'Whether requests can be raised on behalf of another user',
},
},
}

View File

@@ -1,268 +0,0 @@
import { OnePasswordIcon } from '@/components/icons'
import { AuthMode, type BlockConfig } from '@/blocks/types'
export const OnePasswordBlock: BlockConfig = {
type: 'onepassword',
name: '1Password',
description: 'Manage secrets and items in 1Password vaults',
longDescription:
'Access and manage secrets stored in 1Password vaults using the Connect API or Service Account SDK. List vaults, retrieve items with their fields and secrets, create new items, update existing ones, delete items, and resolve secret references.',
docsLink: 'https://docs.sim.ai/tools/onepassword',
category: 'tools',
bgColor: '#E0E0E0',
icon: OnePasswordIcon,
authMode: AuthMode.ApiKey,
subBlocks: [
{
id: 'operation',
title: 'Operation',
type: 'dropdown',
options: [
{ label: 'List Vaults', id: 'list_vaults' },
{ label: 'Get Vault', id: 'get_vault' },
{ label: 'List Items', id: 'list_items' },
{ label: 'Get Item', id: 'get_item' },
{ label: 'Create Item', id: 'create_item' },
{ label: 'Replace Item', id: 'replace_item' },
{ label: 'Update Item', id: 'update_item' },
{ label: 'Delete Item', id: 'delete_item' },
{ label: 'Resolve Secret', id: 'resolve_secret' },
],
value: () => 'get_item',
},
{
id: 'connectionMode',
title: 'Connection Mode',
type: 'dropdown',
options: [
{ label: 'Service Account', id: 'service_account' },
{ label: 'Connect Server', id: 'connect' },
],
value: () => 'service_account',
},
{
id: 'serviceAccountToken',
title: 'Service Account Token',
type: 'short-input',
placeholder: 'Enter your 1Password Service Account token',
password: true,
required: { field: 'connectionMode', value: 'service_account' },
condition: { field: 'connectionMode', value: 'service_account' },
},
{
id: 'serverUrl',
title: 'Server URL',
type: 'short-input',
placeholder: 'http://localhost:8080',
required: { field: 'connectionMode', value: 'connect' },
condition: { field: 'connectionMode', value: 'connect' },
},
{
id: 'apiKey',
title: 'Connect Token',
type: 'short-input',
placeholder: 'Enter your 1Password Connect token',
password: true,
required: { field: 'connectionMode', value: 'connect' },
condition: { field: 'connectionMode', value: 'connect' },
},
{
id: 'secretReference',
title: 'Secret Reference',
type: 'short-input',
placeholder: 'op://vault-name-or-id/item-name-or-id/field-name',
required: { field: 'operation', value: 'resolve_secret' },
condition: { field: 'operation', value: 'resolve_secret' },
wandConfig: {
enabled: true,
prompt: `Generate a 1Password secret reference URI based on the user's description.
The format is: op://vault-name-or-id/item-name-or-id/field-name
You can also use: op://vault/item/section/field for fields inside sections.
Examples:
- op://Development/AWS/access-key
- op://Production/Database/password
- op://MyVault/Stripe/API Keys/secret-key
Return ONLY the op:// URI - no explanations, no quotes, no markdown.`,
},
},
{
id: 'vaultId',
title: 'Vault ID',
type: 'short-input',
placeholder: 'Enter vault UUID',
password: true,
required: {
field: 'operation',
value: [
'get_vault',
'list_items',
'get_item',
'create_item',
'replace_item',
'update_item',
'delete_item',
],
},
condition: {
field: 'operation',
value: ['list_vaults', 'resolve_secret'],
not: true,
},
},
{
id: 'itemId',
title: 'Item ID',
type: 'short-input',
placeholder: 'Enter item UUID',
required: {
field: 'operation',
value: ['get_item', 'replace_item', 'update_item', 'delete_item'],
},
condition: {
field: 'operation',
value: ['get_item', 'replace_item', 'update_item', 'delete_item'],
},
},
{
id: 'filter',
title: 'Filter',
type: 'short-input',
placeholder: 'SCIM filter (e.g., name eq "My Vault")',
condition: { field: 'operation', value: ['list_vaults', 'list_items'] },
},
{
id: 'category',
title: 'Category',
type: 'dropdown',
options: [
{ label: 'Login', id: 'LOGIN' },
{ label: 'Password', id: 'PASSWORD' },
{ label: 'API Credential', id: 'API_CREDENTIAL' },
{ label: 'Secure Note', id: 'SECURE_NOTE' },
{ label: 'Server', id: 'SERVER' },
{ label: 'Database', id: 'DATABASE' },
{ label: 'Credit Card', id: 'CREDIT_CARD' },
{ label: 'Identity', id: 'IDENTITY' },
{ label: 'SSH Key', id: 'SSH_KEY' },
],
value: () => 'LOGIN',
required: { field: 'operation', value: 'create_item' },
condition: { field: 'operation', value: 'create_item' },
},
{
id: 'title',
title: 'Title',
type: 'short-input',
placeholder: 'Item title',
condition: { field: 'operation', value: 'create_item' },
},
{
id: 'tags',
title: 'Tags',
type: 'short-input',
placeholder: 'Comma-separated tags (e.g., production, api)',
condition: { field: 'operation', value: 'create_item' },
},
{
id: 'fields',
title: 'Fields',
type: 'code',
placeholder:
'[\n {\n "label": "username",\n "value": "admin",\n "type": "STRING",\n "purpose": "USERNAME"\n }\n]',
condition: { field: 'operation', value: 'create_item' },
wandConfig: {
enabled: true,
prompt: `Generate a 1Password item fields JSON array based on the user's description.
Each field object can have: label, value, type (STRING, CONCEALED, EMAIL, URL, TOTP, DATE), purpose (USERNAME, PASSWORD, NOTES, or empty).
Examples:
- [{"label":"username","value":"admin","type":"STRING","purpose":"USERNAME"},{"label":"password","value":"secret123","type":"CONCEALED","purpose":"PASSWORD"}]
- [{"label":"API Key","value":"sk-abc123","type":"CONCEALED"}]
Return ONLY valid JSON - no explanations, no markdown code blocks.`,
},
},
{
id: 'item',
title: 'Item (JSON)',
type: 'code',
placeholder:
'{\n "vault": {"id": "..."},\n "category": "LOGIN",\n "title": "My Item",\n "fields": []\n}',
required: { field: 'operation', value: 'replace_item' },
condition: { field: 'operation', value: 'replace_item' },
wandConfig: {
enabled: true,
prompt: `Generate a full 1Password item JSON object based on the user's description.
The object must include vault.id, category, and optionally title, tags, fields, and sections.
Categories: LOGIN, PASSWORD, API_CREDENTIAL, SECURE_NOTE, SERVER, DATABASE, CREDIT_CARD, IDENTITY, SSH_KEY.
Field types: STRING, CONCEALED, EMAIL, URL, TOTP, DATE. Purposes: USERNAME, PASSWORD, NOTES, or empty.
Example: {"vault":{"id":"abc123"},"category":"LOGIN","title":"My Login","fields":[{"label":"username","value":"admin","type":"STRING","purpose":"USERNAME"}]}
Return ONLY valid JSON - no explanations, no markdown code blocks.`,
},
},
{
id: 'operations',
title: 'Patch Operations (JSON)',
type: 'code',
placeholder:
'[\n {\n "op": "replace",\n "path": "/title",\n "value": "New Title"\n }\n]',
required: { field: 'operation', value: 'update_item' },
condition: { field: 'operation', value: 'update_item' },
wandConfig: {
enabled: true,
prompt: `Generate a JSON array of RFC6902 patch operations for a 1Password item based on the user's description.
Each operation has: op (add, remove, replace), path (JSON pointer), and value.
Examples:
- [{"op":"replace","path":"/title","value":"New Title"}]
- [{"op":"replace","path":"/fields/username/value","value":"newuser"}]
- [{"op":"add","path":"/tags/-","value":"production"}]
Return ONLY valid JSON - no explanations, no markdown code blocks.`,
},
},
],
tools: {
access: [
'onepassword_list_vaults',
'onepassword_get_vault',
'onepassword_list_items',
'onepassword_get_item',
'onepassword_create_item',
'onepassword_replace_item',
'onepassword_update_item',
'onepassword_delete_item',
'onepassword_resolve_secret',
],
config: {
tool: (params) => `onepassword_${params.operation}`,
},
},
inputs: {
operation: { type: 'string', description: 'Operation to perform' },
connectionMode: { type: 'string', description: 'Connection mode: service_account or connect' },
serviceAccountToken: { type: 'string', description: '1Password Service Account token' },
serverUrl: { type: 'string', description: '1Password Connect server URL' },
apiKey: { type: 'string', description: '1Password Connect token' },
secretReference: { type: 'string', description: 'Secret reference URI (op://...)' },
vaultId: { type: 'string', description: 'Vault UUID' },
itemId: { type: 'string', description: 'Item UUID' },
filter: { type: 'string', description: 'SCIM filter expression' },
category: { type: 'string', description: 'Item category' },
title: { type: 'string', description: 'Item title' },
tags: { type: 'string', description: 'Comma-separated tags' },
fields: { type: 'string', description: 'JSON array of field objects' },
item: { type: 'string', description: 'Full item JSON for replacement' },
operations: { type: 'string', description: 'JSON array of patch operations' },
},
outputs: {
response: {
type: 'json',
description: 'Operation response data',
},
},
}

View File

@@ -91,7 +91,6 @@ import { Neo4jBlock } from '@/blocks/blocks/neo4j'
import { NoteBlock } from '@/blocks/blocks/note'
import { NotionBlock, NotionV2Block } from '@/blocks/blocks/notion'
import { OneDriveBlock } from '@/blocks/blocks/onedrive'
import { OnePasswordBlock } from '@/blocks/blocks/onepassword'
import { OpenAIBlock } from '@/blocks/blocks/openai'
import { OutlookBlock } from '@/blocks/blocks/outlook'
import { ParallelBlock } from '@/blocks/blocks/parallel'
@@ -269,7 +268,6 @@ export const registry: Record<string, BlockConfig> = {
note: NoteBlock,
notion: NotionBlock,
notion_v2: NotionV2Block,
onepassword: OnePasswordBlock,
onedrive: OneDriveBlock,
openai: OpenAIBlock,
outlook: OutlookBlock,

View File

@@ -5483,37 +5483,3 @@ export function AgentSkillsIcon(props: SVGProps<SVGSVGElement>) {
</svg>
)
}
export function OnePasswordIcon(props: SVGProps<SVGSVGElement>) {
return (
<svg {...props} viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg' fill='none'>
<circle
cx='24'
cy='24'
r='21.5'
stroke='#000000'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M28.083,17.28a7.8633,7.8633,0,0,1,0,13.44'
stroke='#000000'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M19.917,30.72a7.8633,7.8633,0,0,1,0-13.44'
stroke='#000000'
strokeLinecap='round'
strokeLinejoin='round'
/>
<path
d='M26.067,10.43H21.933a2.0172,2.0172,0,0,0-2.016,2.016v6.36c2.358,1.281,2.736,2.562,0,3.843V35.574a2.0169,2.0169,0,0,0,2.016,2.015h4.134a2.0169,2.0169,0,0,0,2.016-2.015V29.213c-2.358-1.281-2.736-2.562,0-3.842V12.446A2.0172,2.0172,0,0,0,26.067,10.43Z'
fill='#000000'
stroke='#000000'
strokeLinecap='round'
strokeLinejoin='round'
/>
</svg>
)
}

View File

@@ -1,8 +1,4 @@
import {
extractFieldsFromSchema,
parseResponseFormatSafely,
} from '@/lib/core/utils/response-format'
import { normalizeInputFormatValue } from '@/lib/workflows/input-format'
import { getEffectiveBlockOutputs } from '@/lib/workflows/blocks/block-outputs'
import { isTriggerBehavior, normalizeName } from '@/executor/constants'
import type { ExecutionContext } from '@/executor/types'
import type { OutputSchema } from '@/executor/utils/block-reference'
@@ -12,8 +8,6 @@ import {
isBranchNodeId,
} from '@/executor/utils/subflow-utils'
import type { SerializedBlock } from '@/serializer/types'
import type { ToolConfig } from '@/tools/types'
import { getTool } from '@/tools/utils'
export interface BlockDataCollection {
blockData: Record<string, unknown>
@@ -21,118 +15,42 @@ export interface BlockDataCollection {
blockOutputSchemas: Record<string, OutputSchema>
}
/**
* Block types where inputFormat fields should be merged into outputs schema.
* These are blocks where users define custom fields via inputFormat that become
* valid output paths (e.g., <start.myField>, <webhook1.customField>, <hitl1.resumeField>).
*
* Note: This includes non-trigger blocks like 'starter' and 'human_in_the_loop' which
* have category 'blocks' but still need their inputFormat exposed as outputs.
*/
const BLOCKS_WITH_INPUT_FORMAT_OUTPUTS = [
'start_trigger',
'starter',
'api_trigger',
'input_trigger',
'generic_webhook',
'human_in_the_loop',
] as const
function getInputFormatFields(block: SerializedBlock): OutputSchema {
const inputFormat = normalizeInputFormatValue(block.config?.params?.inputFormat)
if (inputFormat.length === 0) {
return {}
}
const schema: OutputSchema = {}
for (const field of inputFormat) {
if (!field.name) continue
schema[field.name] = { type: field.type || 'any' }
}
return schema
interface SubBlockWithValue {
value?: unknown
}
function getEvaluatorMetricsSchema(block: SerializedBlock): OutputSchema | undefined {
if (block.metadata?.id !== 'evaluator') return undefined
function paramsToSubBlocks(
params: Record<string, unknown> | undefined
): Record<string, SubBlockWithValue> {
if (!params) return {}
const metrics = block.config?.params?.metrics
if (!Array.isArray(metrics) || metrics.length === 0) return undefined
const validMetrics = metrics.filter(
(m: { name?: string }) => m?.name && typeof m.name === 'string'
)
if (validMetrics.length === 0) return undefined
const schema: OutputSchema = { ...(block.outputs as OutputSchema) }
for (const metric of validMetrics) {
schema[metric.name.toLowerCase()] = { type: 'number' }
const subBlocks: Record<string, SubBlockWithValue> = {}
for (const [key, value] of Object.entries(params)) {
subBlocks[key] = { value }
}
return schema
return subBlocks
}
function getResponseFormatSchema(block: SerializedBlock): OutputSchema | undefined {
const responseFormatValue = block.config?.params?.responseFormat
if (!responseFormatValue) return undefined
const parsed = parseResponseFormatSafely(responseFormatValue, block.id)
if (!parsed) return undefined
const fields = extractFieldsFromSchema(parsed)
if (fields.length === 0) return undefined
const schema: OutputSchema = {}
for (const field of fields) {
schema[field.name] = { type: field.type || 'any' }
}
return schema
}
export function getBlockSchema(
block: SerializedBlock,
toolConfig?: ToolConfig
): OutputSchema | undefined {
function getRegistrySchema(block: SerializedBlock): OutputSchema | undefined {
const blockType = block.metadata?.id
if (!blockType) return undefined
if (
blockType &&
BLOCKS_WITH_INPUT_FORMAT_OUTPUTS.includes(
blockType as (typeof BLOCKS_WITH_INPUT_FORMAT_OUTPUTS)[number]
)
) {
const baseOutputs = (block.outputs as OutputSchema) || {}
const inputFormatFields = getInputFormatFields(block)
const merged = { ...baseOutputs, ...inputFormatFields }
if (Object.keys(merged).length > 0) {
return merged
}
const subBlocks = paramsToSubBlocks(block.config?.params)
const triggerMode = isTriggerBehavior(block)
const outputs = getEffectiveBlockOutputs(blockType, subBlocks, {
triggerMode,
preferToolOutputs: !triggerMode,
includeHidden: true,
}) as OutputSchema
if (!outputs || Object.keys(outputs).length === 0) {
return undefined
}
return outputs
}
const evaluatorSchema = getEvaluatorMetricsSchema(block)
if (evaluatorSchema) {
return evaluatorSchema
}
const responseFormatSchema = getResponseFormatSchema(block)
if (responseFormatSchema) {
return responseFormatSchema
}
const isTrigger = isTriggerBehavior(block)
if (isTrigger && block.outputs && Object.keys(block.outputs).length > 0) {
return block.outputs as OutputSchema
}
if (toolConfig?.outputs && Object.keys(toolConfig.outputs).length > 0) {
return toolConfig.outputs as OutputSchema
}
if (block.outputs && Object.keys(block.outputs).length > 0) {
return block.outputs as OutputSchema
}
return undefined
export function getBlockSchema(block: SerializedBlock): OutputSchema | undefined {
return getRegistrySchema(block)
}
export function collectBlockData(
@@ -170,9 +88,7 @@ export function collectBlockData(
blockNameMapping[normalizeName(block.metadata.name)] = id
}
const toolId = block.config?.tool
const toolConfig = toolId ? getTool(toolId) : undefined
const schema = getBlockSchema(block, toolConfig)
const schema = getBlockSchema(block)
if (schema && Object.keys(schema).length > 0) {
blockOutputSchemas[id] = schema
}

View File

@@ -6,10 +6,6 @@ import type { ResolutionContext } from './reference'
vi.mock('@sim/logger', () => loggerMock)
vi.mock('@/lib/workflows/blocks/block-outputs', () => ({
getBlockOutputs: vi.fn(() => ({})),
}))
function createTestWorkflow(
blocks: Array<{
id: string
@@ -144,34 +140,22 @@ describe('BlockResolver', () => {
expect(resolver.resolve('<source.nonexistent>', ctx)).toBeUndefined()
})
it.concurrent('should throw error for path not in output schema', async () => {
const { getBlockOutputs } = await import('@/lib/workflows/blocks/block-outputs')
const mockGetBlockOutputs = vi.mocked(getBlockOutputs)
const customOutputs = {
validField: { type: 'string', description: 'A valid field' },
nested: {
child: { type: 'number', description: 'Nested child' },
},
}
mockGetBlockOutputs.mockReturnValue(customOutputs as any)
it.concurrent('should throw error for path not in output schema', () => {
const workflow = createTestWorkflow([
{
id: 'source',
outputs: customOutputs,
type: 'start_trigger',
},
])
const resolver = new BlockResolver(workflow)
const ctx = createTestContext('current', {
source: { validField: 'value', nested: { child: 42 } },
source: { input: 'value' },
})
expect(() => resolver.resolve('<source.invalidField>', ctx)).toThrow(
/"invalidField" doesn't exist on block "source"/
)
expect(() => resolver.resolve('<source.invalidField>', ctx)).toThrow(/Available fields:/)
mockGetBlockOutputs.mockReturnValue({})
})
it.concurrent('should return undefined for path in schema but missing in data', () => {
@@ -193,6 +177,59 @@ describe('BlockResolver', () => {
expect(resolver.resolve('<source.optionalField>', ctx)).toBeUndefined()
})
it.concurrent(
'should allow hiddenFromDisplay fields for pre-execution schema validation',
() => {
const workflow = createTestWorkflow([
{
id: 'workflow-block',
name: 'Workflow',
type: 'workflow',
},
])
const resolver = new BlockResolver(workflow)
const ctx = createTestContext('current', {})
expect(resolver.resolve('<workflow.childTraceSpans>', ctx)).toBeUndefined()
}
)
it.concurrent(
'should allow hiddenFromDisplay fields for workflow_input pre-execution schema validation',
() => {
const workflow = createTestWorkflow([
{
id: 'workflow-input-block',
name: 'Workflow Input',
type: 'workflow_input',
},
])
const resolver = new BlockResolver(workflow)
const ctx = createTestContext('current', {})
expect(resolver.resolve('<workflowinput.childTraceSpans>', ctx)).toBeUndefined()
}
)
it.concurrent(
'should allow hiddenFromDisplay fields for HITL pre-execution schema validation',
() => {
const workflow = createTestWorkflow([
{
id: 'hitl-block',
name: 'HITL',
type: 'human_in_the_loop',
},
])
const resolver = new BlockResolver(workflow)
const ctx = createTestContext('current', {})
expect(resolver.resolve('<hitl.response>', ctx)).toBeUndefined()
expect(resolver.resolve('<hitl.submission>', ctx)).toBeUndefined()
expect(resolver.resolve('<hitl.resumeInput>', ctx)).toBeUndefined()
}
)
it.concurrent('should return undefined for non-existent block', () => {
const workflow = createTestWorkflow([{ id: 'existing' }])
const resolver = new BlockResolver(workflow)

View File

@@ -17,7 +17,6 @@ import {
type Resolver,
} from '@/executor/variables/resolvers/reference'
import type { SerializedBlock, SerializedWorkflow } from '@/serializer/types'
import { getTool } from '@/tools/utils'
export class BlockResolver implements Resolver {
private nameToBlockId: Map<string, string>
@@ -68,9 +67,7 @@ export class BlockResolver implements Resolver {
blockData[blockId] = output
}
const toolId = block.config?.tool
const toolConfig = toolId ? getTool(toolId) : undefined
const outputSchema = getBlockSchema(block, toolConfig)
const outputSchema = getBlockSchema(block)
if (outputSchema && Object.keys(outputSchema).length > 0) {
blockOutputSchemas[blockId] = outputSchema

View File

@@ -1,9 +1,4 @@
import {
extractFieldsFromSchema,
parseResponseFormatSafely,
} from '@/lib/core/utils/response-format'
import { getBlockOutputPaths } from '@/lib/workflows/blocks/block-outputs'
import { getBlock } from '@/blocks'
import { getEffectiveBlockOutputPaths } from '@/lib/workflows/blocks/block-outputs'
import { normalizeName } from '@/executor/constants'
import { useVariablesStore } from '@/stores/panel/variables/store'
import type { Variable } from '@/stores/panel/variables/types'
@@ -92,7 +87,6 @@ export function getSubflowInsidePaths(
export function computeBlockOutputPaths(block: BlockState, ctx: WorkflowContext): string[] {
const { blocks, loops, parallels, subBlockValues } = ctx
const blockConfig = getBlock(block.type)
const mergedSubBlocks = getMergedSubBlocks(blocks, subBlockValues, block.id)
if (block.type === 'loop' || block.type === 'parallel') {
@@ -100,15 +94,6 @@ export function computeBlockOutputPaths(block: BlockState, ctx: WorkflowContext)
return ['results', ...insidePaths]
}
if (block.type === 'evaluator') {
const metricsValue = getSubBlockValue(blocks, subBlockValues, block.id, 'metrics')
if (metricsValue && Array.isArray(metricsValue) && metricsValue.length > 0) {
const validMetrics = metricsValue.filter((metric: { name?: string }) => metric?.name)
return validMetrics.map((metric: { name: string }) => metric.name.toLowerCase())
}
return getBlockOutputPaths(block.type, mergedSubBlocks)
}
if (block.type === 'variables') {
const variablesValue = getSubBlockValue(blocks, subBlockValues, block.id, 'variables')
if (variablesValue && Array.isArray(variablesValue) && variablesValue.length > 0) {
@@ -122,18 +107,10 @@ export function computeBlockOutputPaths(block: BlockState, ctx: WorkflowContext)
return []
}
if (blockConfig) {
const responseFormatValue = mergedSubBlocks?.responseFormat?.value
const responseFormat = parseResponseFormatSafely(responseFormatValue, block.id)
if (responseFormat) {
const schemaFields = extractFieldsFromSchema(responseFormat)
if (schemaFields.length > 0) {
return schemaFields.map((field) => field.name)
}
}
}
return getBlockOutputPaths(block.type, mergedSubBlocks, block.triggerMode)
return getEffectiveBlockOutputPaths(block.type, mergedSubBlocks, {
triggerMode: Boolean(block.triggerMode),
preferToolOutputs: !block.triggerMode,
})
}
export function formatOutputsWithPrefix(paths: string[], blockName: string): string[] {

View File

@@ -233,7 +233,11 @@ export const getBlocksMetadataServerTool: BaseServerTool<
const resolvedToolId = resolveToolIdForOperation(blockConfig, opId)
const toolCfg = resolvedToolId ? toolsRegistry[resolvedToolId] : undefined
const toolParams: Record<string, any> = toolCfg?.params || {}
const toolOutputs: Record<string, any> = toolCfg?.outputs || {}
const toolOutputs: Record<string, any> = toolCfg?.outputs
? Object.fromEntries(
Object.entries(toolCfg.outputs).filter(([_, def]) => !isHiddenFromDisplay(def))
)
: {}
const filteredToolParams: Record<string, any> = {}
for (const [k, v] of Object.entries(toolParams)) {
if (!(k in blockInputs)) filteredToolParams[k] = v

View File

@@ -0,0 +1,73 @@
import { describe, expect, it } from 'vitest'
import {
getEffectiveBlockOutputPaths,
getEffectiveBlockOutputs,
getEffectiveBlockOutputType,
} from '@/lib/workflows/blocks/block-outputs'
type SubBlocks = Record<string, { value: unknown }>
function rootPaths(paths: string[]): string[] {
return [...new Set(paths.map((path) => path.split('.')[0]).filter(Boolean))].sort()
}
describe('block outputs parity', () => {
it.concurrent('keeps evaluator tag paths and types aligned', () => {
const subBlocks: SubBlocks = {
metrics: {
value: [
{
name: 'Accuracy',
description: 'How accurate the answer is',
range: { min: 0, max: 1 },
},
{
name: 'Relevance',
description: 'How relevant the answer is',
range: { min: 0, max: 1 },
},
],
},
}
const options = { triggerMode: false, preferToolOutputs: true }
const outputs = getEffectiveBlockOutputs('evaluator', subBlocks, options)
const paths = getEffectiveBlockOutputPaths('evaluator', subBlocks, options)
expect(rootPaths(paths)).toEqual(Object.keys(outputs).sort())
expect(paths).toContain('accuracy')
expect(paths).toContain('relevance')
expect(getEffectiveBlockOutputType('evaluator', 'accuracy', subBlocks, options)).toBe('number')
expect(getEffectiveBlockOutputType('evaluator', 'relevance', subBlocks, options)).toBe('number')
})
it.concurrent('keeps agent responseFormat tag paths and types aligned', () => {
const subBlocks: SubBlocks = {
responseFormat: {
value: {
name: 'calculator_output',
schema: {
type: 'object',
properties: {
min: { type: 'number' },
max: { type: 'number' },
},
required: ['min', 'max'],
additionalProperties: false,
},
strict: true,
},
},
}
const options = { triggerMode: false, preferToolOutputs: true }
const outputs = getEffectiveBlockOutputs('agent', subBlocks, options)
const paths = getEffectiveBlockOutputPaths('agent', subBlocks, options)
expect(rootPaths(paths)).toEqual(Object.keys(outputs).sort())
expect(paths).toContain('min')
expect(paths).toContain('max')
expect(getEffectiveBlockOutputType('agent', 'min', subBlocks, options)).toBe('number')
expect(getEffectiveBlockOutputType('agent', 'max', subBlocks, options)).toBe('number')
})
})

View File

@@ -33,6 +33,12 @@ interface SubBlockWithValue {
value?: unknown
}
interface EffectiveOutputOptions {
triggerMode?: boolean
preferToolOutputs?: boolean
includeHidden?: boolean
}
type ConditionValue = string | number | boolean
/**
@@ -96,12 +102,13 @@ function evaluateOutputCondition(
*/
function filterOutputsByCondition(
outputs: OutputDefinition,
subBlocks: Record<string, SubBlockWithValue> | undefined
subBlocks: Record<string, SubBlockWithValue> | undefined,
includeHidden = false
): OutputDefinition {
const filtered: OutputDefinition = {}
for (const [key, value] of Object.entries(outputs)) {
if (isHiddenFromDisplay(value)) continue
if (!includeHidden && isHiddenFromDisplay(value)) continue
if (!value || typeof value !== 'object' || !('condition' in value)) {
filtered[key] = value
@@ -112,8 +119,13 @@ function filterOutputsByCondition(
const passes = !condition || evaluateOutputCondition(condition, subBlocks)
if (passes) {
const { condition: _, hiddenFromDisplay: __, ...rest } = value
filtered[key] = rest
if (includeHidden) {
const { condition: _, ...rest } = value
filtered[key] = rest
} else {
const { condition: _, hiddenFromDisplay: __, ...rest } = value
filtered[key] = rest
}
}
}
@@ -243,8 +255,10 @@ function applyInputFormatToOutputs(
export function getBlockOutputs(
blockType: string,
subBlocks?: Record<string, SubBlockWithValue>,
triggerMode?: boolean
triggerMode?: boolean,
options?: { includeHidden?: boolean }
): OutputDefinition {
const includeHidden = options?.includeHidden ?? false
const blockConfig = getBlock(blockType)
if (!blockConfig) return {}
@@ -269,7 +283,8 @@ export function getBlockOutputs(
// Start with block config outputs (respects hiddenFromDisplay via filterOutputsByCondition)
const baseOutputs = filterOutputsByCondition(
{ ...(blockConfig.outputs || {}) } as OutputDefinition,
subBlocks
subBlocks,
includeHidden
)
// Add inputFormat fields (resume form fields)
@@ -292,29 +307,111 @@ export function getBlockOutputs(
return getLegacyStarterOutputs(subBlocks)
}
if (blockType === 'agent') {
const responseFormatValue = subBlocks?.responseFormat?.value
if (responseFormatValue) {
const parsed = parseResponseFormatSafely(responseFormatValue, 'agent')
if (parsed) {
const fields = extractFieldsFromSchema(parsed)
if (fields.length > 0) {
const outputs: OutputDefinition = {}
for (const field of fields) {
outputs[field.name] = {
type: (field.type || 'any') as any,
description: field.description || `Field from Agent: ${field.name}`,
}
}
return outputs
}
}
const baseOutputs = { ...(blockConfig.outputs || {}) }
const filteredOutputs = filterOutputsByCondition(baseOutputs, subBlocks, includeHidden)
return applyInputFormatToOutputs(blockType, blockConfig, subBlocks, filteredOutputs)
}
export function getResponseFormatOutputs(
subBlocks?: Record<string, SubBlockWithValue>,
blockId = 'block'
): OutputDefinition | undefined {
const responseFormatValue = subBlocks?.responseFormat?.value
if (!responseFormatValue) return undefined
const parsed = parseResponseFormatSafely(responseFormatValue, blockId)
if (!parsed) return undefined
const fields = extractFieldsFromSchema(parsed)
if (fields.length === 0) return undefined
const outputs: OutputDefinition = {}
for (const field of fields) {
outputs[field.name] = {
type: (field.type || 'any') as any,
description: field.description || `Field from Agent: ${field.name}`,
}
}
const baseOutputs = { ...(blockConfig.outputs || {}) }
const filteredOutputs = filterOutputsByCondition(baseOutputs, subBlocks)
return applyInputFormatToOutputs(blockType, blockConfig, subBlocks, filteredOutputs)
return outputs
}
export function getEvaluatorMetricOutputs(
subBlocks?: Record<string, SubBlockWithValue>
): OutputDefinition | undefined {
const metricsValue = subBlocks?.metrics?.value
if (!metricsValue || !Array.isArray(metricsValue) || metricsValue.length === 0) return undefined
const validMetrics = metricsValue.filter((metric: { name?: string }) => metric?.name)
if (validMetrics.length === 0) return undefined
const outputs: OutputDefinition = {}
for (const metric of validMetrics as Array<{ name: string }>) {
outputs[metric.name.toLowerCase()] = {
type: 'number',
description: `Metric score: ${metric.name}`,
}
}
return outputs
}
export function getEffectiveBlockOutputs(
blockType: string,
subBlocks?: Record<string, SubBlockWithValue>,
options?: EffectiveOutputOptions
): OutputDefinition {
const triggerMode = options?.triggerMode ?? false
const preferToolOutputs = options?.preferToolOutputs ?? !triggerMode
const includeHidden = options?.includeHidden ?? false
if (blockType === 'agent') {
const responseFormatOutputs = getResponseFormatOutputs(subBlocks, 'agent')
if (responseFormatOutputs) return responseFormatOutputs
}
let baseOutputs: OutputDefinition
if (triggerMode) {
baseOutputs = getBlockOutputs(blockType, subBlocks, true, { includeHidden })
} else if (preferToolOutputs) {
const blockConfig = getBlock(blockType)
const toolOutputs = blockConfig
? (getToolOutputs(blockConfig, subBlocks, { includeHidden }) as OutputDefinition)
: {}
baseOutputs =
toolOutputs && Object.keys(toolOutputs).length > 0
? toolOutputs
: getBlockOutputs(blockType, subBlocks, false, { includeHidden })
} else {
baseOutputs = getBlockOutputs(blockType, subBlocks, false, { includeHidden })
}
if (blockType === 'evaluator') {
const metricOutputs = getEvaluatorMetricOutputs(subBlocks)
if (metricOutputs) {
return { ...baseOutputs, ...metricOutputs }
}
}
return baseOutputs
}
export function getEffectiveBlockOutputPaths(
blockType: string,
subBlocks?: Record<string, SubBlockWithValue>,
options?: EffectiveOutputOptions
): string[] {
const outputs = getEffectiveBlockOutputs(blockType, subBlocks, options)
const paths = generateOutputPaths(outputs)
if (blockType === TRIGGER_TYPES.START) {
return paths.filter((path) => {
const key = path.split('.')[0]
return !shouldFilterReservedField(blockType, key, '', subBlocks)
})
}
return paths
}
function shouldFilterReservedField(
@@ -352,24 +449,6 @@ function isFileOutputDefinition(value: unknown): value is { type: FileOutputType
return type === 'file' || type === 'file[]'
}
export function getBlockOutputPaths(
blockType: string,
subBlocks?: Record<string, SubBlockWithValue>,
triggerMode?: boolean
): string[] {
const outputs = getBlockOutputs(blockType, subBlocks, triggerMode)
const paths = generateOutputPaths(outputs)
if (blockType === TRIGGER_TYPES.START) {
return paths.filter((path) => {
const key = path.split('.')[0]
return !shouldFilterReservedField(blockType, key, '', subBlocks)
})
}
return paths
}
function getFilePropertyType(outputs: OutputDefinition, pathParts: string[]): string | null {
const lastPart = pathParts[pathParts.length - 1]
if (!lastPart || !USER_FILE_PROPERTY_TYPES[lastPart as keyof typeof USER_FILE_PROPERTY_TYPES]) {
@@ -453,13 +532,13 @@ function extractType(value: unknown): string {
return typeof value === 'string' ? value : 'any'
}
export function getBlockOutputType(
export function getEffectiveBlockOutputType(
blockType: string,
outputPath: string,
subBlocks?: Record<string, SubBlockWithValue>,
triggerMode?: boolean
options?: EffectiveOutputOptions
): string {
const outputs = getBlockOutputs(blockType, subBlocks, triggerMode)
const outputs = getEffectiveBlockOutputs(blockType, subBlocks, options)
const cleanPath = outputPath.replace(/\[(\d+)\]/g, '')
const pathParts = cleanPath.split('.').filter(Boolean)
@@ -531,60 +610,6 @@ function generateOutputPaths(outputs: Record<string, any>, prefix = ''): string[
return paths
}
/**
* Recursively generates all output paths with their types from an outputs schema.
*
* @param outputs - The outputs schema object
* @param prefix - Current path prefix for recursion
* @returns Array of objects containing path and type for each output field
*/
function generateOutputPathsWithTypes(
outputs: Record<string, any>,
prefix = ''
): Array<{ path: string; type: string }> {
const paths: Array<{ path: string; type: string }> = []
for (const [key, value] of Object.entries(outputs)) {
const currentPath = prefix ? `${prefix}.${key}` : key
if (typeof value === 'string') {
paths.push({ path: currentPath, type: value })
} else if (typeof value === 'object' && value !== null) {
if ('type' in value && typeof value.type === 'string') {
if (isFileOutputDefinition(value)) {
paths.push({ path: currentPath, type: value.type })
for (const prop of USER_FILE_ACCESSIBLE_PROPERTIES) {
paths.push({
path: `${currentPath}.${prop}`,
type: USER_FILE_PROPERTY_TYPES[prop as keyof typeof USER_FILE_PROPERTY_TYPES],
})
}
continue
}
if (value.type === 'array' && value.items?.properties) {
paths.push({ path: currentPath, type: 'array' })
const subPaths = generateOutputPathsWithTypes(value.items.properties, currentPath)
paths.push(...subPaths)
} else if ((value.type === 'object' || value.type === 'json') && value.properties) {
paths.push({ path: currentPath, type: value.type })
const subPaths = generateOutputPathsWithTypes(value.properties, currentPath)
paths.push(...subPaths)
} else {
paths.push({ path: currentPath, type: value.type })
}
} else {
const subPaths = generateOutputPathsWithTypes(value, currentPath)
paths.push(...subPaths)
}
} else {
paths.push({ path: currentPath, type: 'any' })
}
}
return paths
}
/**
* Gets the tool outputs for a block operation.
*
@@ -594,8 +619,10 @@ function generateOutputPathsWithTypes(
*/
export function getToolOutputs(
blockConfig: BlockConfig,
subBlocks?: Record<string, SubBlockWithValue>
subBlocks?: Record<string, SubBlockWithValue>,
options?: { includeHidden?: boolean }
): Record<string, any> {
const includeHidden = options?.includeHidden ?? false
if (!blockConfig?.tools?.config?.tool) return {}
try {
@@ -613,49 +640,18 @@ export function getToolOutputs(
const toolConfig = getTool(toolId)
if (!toolConfig?.outputs) return {}
return toolConfig.outputs
if (includeHidden) {
return toolConfig.outputs
}
return Object.fromEntries(
Object.entries(toolConfig.outputs).filter(([_, def]) => !isHiddenFromDisplay(def))
)
} catch (error) {
logger.warn('Failed to get tool outputs', { error })
return {}
}
}
export function getToolOutputPaths(
blockConfig: BlockConfig,
subBlocks?: Record<string, SubBlockWithValue>
): string[] {
const outputs = getToolOutputs(blockConfig, subBlocks)
if (!outputs || Object.keys(outputs).length === 0) return []
if (subBlocks && blockConfig.outputs) {
const filteredOutputs: Record<string, any> = {}
for (const [key, value] of Object.entries(outputs)) {
const blockOutput = blockConfig.outputs[key]
if (!blockOutput || typeof blockOutput !== 'object') {
filteredOutputs[key] = value
continue
}
const condition = 'condition' in blockOutput ? blockOutput.condition : undefined
if (condition) {
if (evaluateOutputCondition(condition, subBlocks)) {
filteredOutputs[key] = value
}
} else {
filteredOutputs[key] = value
}
}
return generateOutputPaths(filteredOutputs)
}
return generateOutputPaths(outputs)
}
/**
* Generates output paths from a schema definition.
*
@@ -665,24 +661,3 @@ export function getToolOutputPaths(
export function getOutputPathsFromSchema(outputs: Record<string, any>): string[] {
return generateOutputPaths(outputs)
}
/**
* Gets the output type for a specific path in a tool's outputs.
*
* @param blockConfig - The block configuration containing tools config
* @param subBlocks - SubBlock values for tool selection
* @param path - The dot-separated path to the output field
* @returns The type of the output field, or 'any' if not found
*/
export function getToolOutputType(
blockConfig: BlockConfig,
subBlocks: Record<string, SubBlockWithValue> | undefined,
path: string
): string {
const outputs = getToolOutputs(blockConfig, subBlocks)
if (!outputs || Object.keys(outputs).length === 0) return 'any'
const pathsWithTypes = generateOutputPathsWithTypes(outputs)
const matchingPath = pathsWithTypes.find((p) => p.path === path)
return matchingPath?.type || 'any'
}

View File

@@ -43,13 +43,4 @@ describe('isLikelyReferenceSegment', () => {
it('should return false when leading content is not comparator characters', () => {
expect(isLikelyReferenceSegment('<foo<bar>')).toBe(false)
})
it('should return true for references starting with a digit', () => {
expect(isLikelyReferenceSegment('<1password1>')).toBe(true)
expect(isLikelyReferenceSegment('<1password1.secret>')).toBe(true)
})
it('should return false for purely numeric references', () => {
expect(isLikelyReferenceSegment('<123>')).toBe(false)
})
})

View File

@@ -70,7 +70,7 @@ export function isLikelyReferenceSegment(segment: string): boolean {
if (INVALID_REFERENCE_CHARS.test(beforeDot) || INVALID_REFERENCE_CHARS.test(afterDot)) {
return false
}
} else if (INVALID_REFERENCE_CHARS.test(inner) || inner.match(/^\d+$/) || inner.match(/\s\d/)) {
} else if (INVALID_REFERENCE_CHARS.test(inner) || inner.match(/^\d/) || inner.match(/\s\d/)) {
return false
}

View File

@@ -77,7 +77,6 @@ const nextConfig: NextConfig = {
resolveExtensions: ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.json'],
},
serverExternalPackages: [
'@1password/sdk',
'unpdf',
'ffmpeg-static',
'fluent-ffmpeg',

View File

@@ -23,7 +23,6 @@
"generate-docs": "bun run ../../scripts/generate-docs.ts"
},
"dependencies": {
"@1password/sdk": "0.3.1",
"@a2a-js/sdk": "0.3.7",
"@anthropic-ai/sdk": "0.71.2",
"@aws-sdk/client-bedrock-runtime": "3.940.0",

View File

@@ -1,5 +1,4 @@
import type { JiraAddAttachmentParams, JiraAddAttachmentResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import type { ToolConfig } from '@/tools/types'
export const jiraAddAttachmentTool: ToolConfig<JiraAddAttachmentParams, JiraAddAttachmentResponse> =
@@ -76,40 +75,9 @@ export const jiraAddAttachmentTool: ToolConfig<JiraAddAttachmentParams, JiraAddA
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
attachments: {
type: 'array',
description: 'Uploaded attachments',
items: {
type: 'object',
properties: {
id: { type: 'string', description: 'Attachment ID' },
filename: { type: 'string', description: 'Attachment file name' },
mimeType: { type: 'string', description: 'MIME type' },
size: { type: 'number', description: 'File size in bytes' },
content: { type: 'string', description: 'URL to download the attachment' },
},
},
},
attachmentIds: {
type: 'array',
description: 'Array of attachment IDs',
items: { type: 'string' },
optional: true,
},
files: {
type: 'array',
description: 'Uploaded file metadata',
items: {
type: 'object',
properties: {
name: { type: 'string', description: 'File name' },
mimeType: { type: 'string', description: 'MIME type' },
size: { type: 'number', description: 'File size in bytes' },
},
},
optional: true,
},
attachmentIds: { type: 'json', description: 'IDs of uploaded attachments' },
files: { type: 'file[]', description: 'Uploaded attachment files' },
},
}

View File

@@ -1,24 +1,7 @@
import type { JiraAddCommentParams, JiraAddCommentResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT, USER_OUTPUT_PROPERTIES } from '@/tools/jira/types'
import { extractAdfText, getJiraCloudId, transformUser } from '@/tools/jira/utils'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
/**
* Transforms an add comment API response into typed output.
*/
function transformCommentResponse(data: any, params: JiraAddCommentParams) {
return {
ts: new Date().toISOString(),
issueKey: params.issueKey ?? 'unknown',
commentId: data?.id ?? 'unknown',
body: data?.body ? (extractAdfText(data.body) ?? params.body ?? '') : (params.body ?? ''),
author: transformUser(data?.author) ?? { accountId: '', displayName: '' },
created: data?.created ?? '',
updated: data?.updated ?? '',
success: true,
}
}
export const jiraAddCommentTool: ToolConfig<JiraAddCommentParams, JiraAddCommentResponse> = {
id: 'jira_add_comment',
name: 'Jira Add Comment',
@@ -55,13 +38,6 @@ export const jiraAddCommentTool: ToolConfig<JiraAddCommentParams, JiraAddComment
visibility: 'user-or-llm',
description: 'Comment body text',
},
visibility: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description:
'Restrict comment visibility. Object with "type" ("role" or "group") and "value" (role/group name).',
},
cloudId: {
type: 'string',
required: false,
@@ -88,48 +64,55 @@ export const jiraAddCommentTool: ToolConfig<JiraAddCommentParams, JiraAddComment
},
body: (params: JiraAddCommentParams) => {
if (!params.cloudId) return undefined as any
const payload: Record<string, any> = {
return {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: params.body ?? '' }],
content: [
{
type: 'text',
text: params?.body || '',
},
],
},
],
},
}
if (params.visibility) payload.visibility = params.visibility
return payload
},
},
transformResponse: async (response: Response, params?: JiraAddCommentParams) => {
const payload: Record<string, any> = {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: params?.body ?? '' }],
},
],
},
}
if (params?.visibility) payload.visibility = params.visibility
const makeRequest = async (cloudId: string) => {
const commentUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/comment`
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
// Make the actual request with the resolved cloudId
const commentUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/comment`
const commentResponse = await fetch(commentUrl, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
body: JSON.stringify(payload),
body: JSON.stringify({
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params?.body || '',
},
],
},
],
},
}),
})
if (!commentResponse.ok) {
@@ -141,46 +124,48 @@ export const jiraAddCommentTool: ToolConfig<JiraAddCommentParams, JiraAddComment
throw new Error(message)
}
return commentResponse.json()
}
const data = await commentResponse.json()
let data: any
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
data = await makeRequest(cloudId)
} else {
if (!response.ok) {
let message = `Failed to add comment to Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
commentId: data?.id || 'unknown',
body: params?.body || '',
success: true,
},
}
data = await response.json()
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to add comment to Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
return {
success: true,
output: transformCommentResponse(data, params!),
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
commentId: data?.id || 'unknown',
body: params?.body || '',
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key the comment was added to' },
commentId: { type: 'string', description: 'Created comment ID' },
body: { type: 'string', description: 'Comment text content' },
author: {
type: 'object',
description: 'Comment author',
properties: USER_OUTPUT_PROPERTIES,
},
created: { type: 'string', description: 'ISO 8601 timestamp when the comment was created' },
updated: {
type: 'string',
description: 'ISO 8601 timestamp when the comment was last updated',
},
},
}

View File

@@ -1,7 +1,22 @@
import type { JiraAddWatcherParams, JiraAddWatcherResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraAddWatcherParams {
accessToken: string
domain: string
issueKey: string
accountId: string
cloudId?: string
}
export interface JiraAddWatcherResponse extends ToolResponse {
output: {
ts: string
issueKey: string
watcherAccountId: string
success: boolean
}
}
export const jiraAddWatcherTool: ToolConfig<JiraAddWatcherParams, JiraAddWatcherResponse> = {
id: 'jira_add_watcher',
@@ -72,15 +87,16 @@ export const jiraAddWatcherTool: ToolConfig<JiraAddWatcherParams, JiraAddWatcher
transformResponse: async (response: Response, params?: JiraAddWatcherParams) => {
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
const watcherUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/watchers`
// Make the actual request with the resolved cloudId
const watcherUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/watchers`
const watcherResponse = await fetch(watcherUrl, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
body: JSON.stringify(params!.accountId),
body: JSON.stringify(params?.accountId),
})
if (!watcherResponse.ok) {
@@ -96,13 +112,14 @@ export const jiraAddWatcherTool: ToolConfig<JiraAddWatcherParams, JiraAddWatcher
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params!.issueKey || 'unknown',
watcherAccountId: params!.accountId || 'unknown',
issueKey: params?.issueKey || 'unknown',
watcherAccountId: params?.accountId || 'unknown',
success: true,
},
}
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to add watcher to Jira issue (${response.status})`
try {
@@ -116,15 +133,15 @@ export const jiraAddWatcherTool: ToolConfig<JiraAddWatcherParams, JiraAddWatcher
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params!.issueKey || 'unknown',
watcherAccountId: params!.accountId || 'unknown',
issueKey: params?.issueKey || 'unknown',
watcherAccountId: params?.accountId || 'unknown',
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
watcherAccountId: { type: 'string', description: 'Added watcher account ID' },
},

View File

@@ -1,51 +1,7 @@
import type { JiraAddWorklogParams, JiraAddWorklogResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT, USER_OUTPUT_PROPERTIES } from '@/tools/jira/types'
import { getJiraCloudId, transformUser } from '@/tools/jira/utils'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
/**
* Builds the worklog request body per Jira API v3.
*/
function buildWorklogBody(params: JiraAddWorklogParams) {
const body: Record<string, any> = {
timeSpentSeconds: Number(params.timeSpentSeconds),
comment: params.comment
? {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: params.comment }],
},
],
}
: undefined,
started:
(params.started ? params.started.replace(/Z$/, '+0000') : undefined) ||
new Date().toISOString().replace(/Z$/, '+0000'),
}
if (params.visibility) body.visibility = params.visibility
return body
}
/**
* Transforms a worklog API response into typed output.
*/
function transformWorklogResponse(data: any, params: JiraAddWorklogParams) {
return {
ts: new Date().toISOString(),
issueKey: params.issueKey ?? 'unknown',
worklogId: data?.id ?? 'unknown',
timeSpent: data?.timeSpent ?? '',
timeSpentSeconds: data?.timeSpentSeconds ?? Number(params.timeSpentSeconds) ?? 0,
author: transformUser(data?.author) ?? { accountId: '', displayName: '' },
started: data?.started ?? '',
created: data?.created ?? '',
success: true,
}
}
export const jiraAddWorklogTool: ToolConfig<JiraAddWorklogParams, JiraAddWorklogResponse> = {
id: 'jira_add_worklog',
name: 'Jira Add Worklog',
@@ -94,13 +50,6 @@ export const jiraAddWorklogTool: ToolConfig<JiraAddWorklogParams, JiraAddWorklog
visibility: 'user-or-llm',
description: 'Optional start time in ISO format (defaults to current time)',
},
visibility: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description:
'Restrict worklog visibility. Object with "type" ("role" or "group") and "value" (role/group name).',
},
cloudId: {
type: 'string',
required: false,
@@ -127,25 +76,71 @@ export const jiraAddWorklogTool: ToolConfig<JiraAddWorklogParams, JiraAddWorklog
},
body: (params: JiraAddWorklogParams) => {
if (!params.cloudId) return undefined as any
return buildWorklogBody(params)
return {
timeSpentSeconds: Number(params.timeSpentSeconds),
comment: params.comment
? {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params.comment,
},
],
},
],
}
: undefined,
started:
(params.started ? params.started.replace(/Z$/, '+0000') : undefined) ||
new Date().toISOString().replace(/Z$/, '+0000'),
}
},
},
transformResponse: async (response: Response, params?: JiraAddWorklogParams) => {
if (!params?.timeSpentSeconds || params.timeSpentSeconds <= 0) {
throw new Error('timeSpentSeconds is required and must be greater than 0')
}
const makeRequest = async (cloudId: string) => {
const worklogUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/worklog`
if (!params?.cloudId) {
if (!params?.timeSpentSeconds || params.timeSpentSeconds <= 0) {
throw new Error('timeSpentSeconds is required and must be greater than 0')
}
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
// Make the actual request with the resolved cloudId
const worklogUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/worklog`
const worklogResponse = await fetch(worklogUrl, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
body: JSON.stringify(buildWorklogBody(params!)),
body: JSON.stringify({
timeSpentSeconds: params?.timeSpentSeconds ? Number(params.timeSpentSeconds) : 0,
comment: params?.comment
? {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params.comment,
},
],
},
],
}
: undefined,
// Preserve milliseconds and convert trailing Z to +0000 as required by Jira examples
started:
(params?.started ? params.started.replace(/Z$/, '+0000') : undefined) ||
new Date().toISOString().replace(/Z$/, '+0000'),
}),
})
if (!worklogResponse.ok) {
@@ -157,47 +152,48 @@ export const jiraAddWorklogTool: ToolConfig<JiraAddWorklogParams, JiraAddWorklog
throw new Error(message)
}
return worklogResponse.json()
}
const data = await worklogResponse.json()
let data: any
if (!params.cloudId) {
const cloudId = await getJiraCloudId(params.domain, params.accessToken)
data = await makeRequest(cloudId)
} else {
if (!response.ok) {
let message = `Failed to add worklog to Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
worklogId: data?.id || 'unknown',
timeSpentSeconds: params?.timeSpentSeconds ? Number(params.timeSpentSeconds) : 0 || 0,
success: true,
},
}
data = await response.json()
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to add worklog to Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
return {
success: true,
output: transformWorklogResponse(data, params),
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
worklogId: data?.id || 'unknown',
timeSpentSeconds: params?.timeSpentSeconds ? Number(params.timeSpentSeconds) : 0 || 0,
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key the worklog was added to' },
worklogId: { type: 'string', description: 'Created worklog ID' },
timeSpent: {
type: 'string',
description: 'Time spent in human-readable format (e.g., 3h 20m)',
},
timeSpentSeconds: { type: 'number', description: 'Time spent in seconds' },
author: {
type: 'object',
description: 'Worklog author',
properties: USER_OUTPUT_PROPERTIES,
},
started: { type: 'string', description: 'ISO 8601 timestamp when the work started' },
created: { type: 'string', description: 'ISO 8601 timestamp when the worklog was created' },
},
}

View File

@@ -1,7 +1,22 @@
import type { JiraAssignIssueParams, JiraAssignIssueResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraAssignIssueParams {
accessToken: string
domain: string
issueKey: string
accountId: string
cloudId?: string
}
export interface JiraAssignIssueResponse extends ToolResponse {
output: {
ts: string
issueKey: string
assigneeId: string
success: boolean
}
}
export const jiraAssignIssueTool: ToolConfig<JiraAssignIssueParams, JiraAssignIssueResponse> = {
id: 'jira_assign_issue',
@@ -129,11 +144,8 @@ export const jiraAssignIssueTool: ToolConfig<JiraAssignIssueParams, JiraAssignIs
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key that was assigned' },
assigneeId: {
type: 'string',
description: 'Account ID of the assignee (use "-1" for auto-assign, null to unassign)',
},
assigneeId: { type: 'string', description: 'Account ID of the assignee' },
},
}

View File

@@ -1,12 +1,10 @@
import type { JiraRetrieveBulkParams, JiraRetrieveResponseBulk } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { extractAdfText } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
export const jiraBulkRetrieveTool: ToolConfig<JiraRetrieveBulkParams, JiraRetrieveResponseBulk> = {
id: 'jira_bulk_read',
name: 'Jira Bulk Read',
description: 'Retrieve multiple Jira issues from a project in bulk',
description: 'Retrieve multiple Jira issues in bulk',
version: '1.0.0',
oauth: {
@@ -43,18 +41,44 @@ export const jiraBulkRetrieveTool: ToolConfig<JiraRetrieveBulkParams, JiraRetrie
},
request: {
url: () => 'https://api.atlassian.com/oauth/token/accessible-resources',
url: (params: JiraRetrieveBulkParams) => {
// Always return accessible resources endpoint; transformResponse will build search URLs
return 'https://api.atlassian.com/oauth/token/accessible-resources'
},
method: 'GET',
headers: (params: JiraRetrieveBulkParams) => ({
Authorization: `Bearer ${params.accessToken}`,
Accept: 'application/json',
}),
body: (params: JiraRetrieveBulkParams) =>
params.cloudId
? {
jql: '', // Will be set in transformResponse when we know the resolved project key
startAt: 0,
maxResults: 100,
fields: ['summary', 'description', 'created', 'updated'],
}
: {},
},
transformResponse: async (response: Response, params?: JiraRetrieveBulkParams) => {
const MAX_TOTAL = 1000
const PAGE_SIZE = 100
// Helper to extract description text safely (ADF can be nested)
const extractDescription = (desc: any): string => {
try {
return (
desc?.content?.[0]?.content?.[0]?.text ||
desc?.content?.flatMap((c: any) => c?.content || [])?.find((c: any) => c?.text)?.text ||
''
)
} catch (_e) {
return ''
}
}
// Helper to resolve a project reference (id or key) to its canonical key
const resolveProjectKey = async (cloudId: string, accessToken: string, ref: string) => {
const refTrimmed = (ref || '').trim()
if (!refTrimmed) return refTrimmed
@@ -63,166 +87,128 @@ export const jiraBulkRetrieveTool: ToolConfig<JiraRetrieveBulkParams, JiraRetrie
method: 'GET',
headers: { Authorization: `Bearer ${accessToken}`, Accept: 'application/json' },
})
if (!resp.ok) return refTrimmed
if (!resp.ok) {
// If can't resolve, fall back to original ref (JQL can still work with id or key)
return refTrimmed
}
const project = await resp.json()
return project?.key || refTrimmed
}
const resolveCloudId = async () => {
if (params?.cloudId) return params.cloudId
// If we don't have a cloudId, look it up first
if (!params?.cloudId) {
const accessibleResources = await response.json()
const normalizedInput = `https://${params?.domain}`.toLowerCase()
const matchedResource = accessibleResources.find(
(r: any) => r.url.toLowerCase() === normalizedInput
)
if (matchedResource) return matchedResource.id
if (Array.isArray(accessibleResources) && accessibleResources.length > 0)
return accessibleResources[0].id
throw new Error('No Jira resources found')
const projectKey = await resolveProjectKey(
matchedResource.id,
params!.accessToken,
params!.projectId
)
const jql = `project = ${projectKey} ORDER BY updated DESC`
let startAt = 0
let collected: any[] = []
let total = 0
while (startAt < MAX_TOTAL) {
const queryParams = new URLSearchParams({
jql,
fields: 'summary,description,created,updated',
maxResults: String(PAGE_SIZE),
})
if (startAt > 0) {
queryParams.set('startAt', String(startAt))
}
const url = `https://api.atlassian.com/ex/jira/${matchedResource.id}/rest/api/3/search/jql?${queryParams.toString()}`
const pageResponse = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${params?.accessToken}`,
Accept: 'application/json',
},
})
const pageData = await pageResponse.json()
const issues = pageData.issues || []
total = pageData.total || issues.length
collected = collected.concat(issues)
if (collected.length >= Math.min(total, MAX_TOTAL) || issues.length === 0) break
startAt += PAGE_SIZE
}
return {
success: true,
output: collected.slice(0, MAX_TOTAL).map((issue: any) => ({
ts: new Date().toISOString(),
summary: issue.fields?.summary,
description: extractDescription(issue.fields?.description),
created: issue.fields?.created,
updated: issue.fields?.updated,
})),
}
}
const cloudId = await resolveCloudId()
const projectKey = await resolveProjectKey(cloudId, params!.accessToken, params!.projectId)
// cloudId present: resolve project and paginate using the Search API
// Resolve to canonical project key for consistent JQL
const projectKey = await resolveProjectKey(
params!.cloudId!,
params!.accessToken,
params!.projectId
)
const jql = `project = ${projectKey} ORDER BY updated DESC`
// Always do full pagination with resolved key
let collected: any[] = []
let nextPageToken: string | undefined
let total: number | null = null
while (collected.length < MAX_TOTAL) {
let total = 0
let startAt = 0
while (startAt < MAX_TOTAL) {
const queryParams = new URLSearchParams({
jql,
fields: 'summary,description,status,issuetype,priority,assignee,created,updated',
fields: 'summary,description,created,updated',
maxResults: String(PAGE_SIZE),
})
if (nextPageToken) queryParams.set('nextPageToken', nextPageToken)
const url = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/search/jql?${queryParams.toString()}`
if (startAt > 0) {
queryParams.set('startAt', String(startAt))
}
const url = `https://api.atlassian.com/ex/jira/${params?.cloudId}/rest/api/3/search/jql?${queryParams.toString()}`
const pageResponse = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
Accept: 'application/json',
},
})
if (!pageResponse.ok) {
let message = `Failed to bulk read Jira issues (${pageResponse.status})`
try {
const err = await pageResponse.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const pageData = await pageResponse.json()
const issues = pageData.issues || []
if (pageData.total != null) total = pageData.total
total = pageData.total || issues.length
collected = collected.concat(issues)
if (pageData.isLast || !pageData.nextPageToken || issues.length === 0) break
nextPageToken = pageData.nextPageToken
if (issues.length === 0 || collected.length >= Math.min(total, MAX_TOTAL)) break
startAt += PAGE_SIZE
}
return {
success: true,
output: {
output: collected.slice(0, MAX_TOTAL).map((issue: any) => ({
ts: new Date().toISOString(),
total,
issues: collected.slice(0, MAX_TOTAL).map((issue: any) => ({
id: issue.id ?? '',
key: issue.key ?? '',
self: issue.self ?? '',
summary: issue.fields?.summary ?? '',
description: extractAdfText(issue.fields?.description),
status: {
id: issue.fields?.status?.id ?? '',
name: issue.fields?.status?.name ?? '',
},
issuetype: {
id: issue.fields?.issuetype?.id ?? '',
name: issue.fields?.issuetype?.name ?? '',
},
priority: issue.fields?.priority
? { id: issue.fields.priority.id ?? '', name: issue.fields.priority.name ?? '' }
: null,
assignee: issue.fields?.assignee
? {
accountId: issue.fields.assignee.accountId ?? '',
displayName: issue.fields.assignee.displayName ?? '',
}
: null,
created: issue.fields?.created ?? '',
updated: issue.fields?.updated ?? '',
})),
nextPageToken: nextPageToken ?? null,
isLast: !nextPageToken || collected.length >= MAX_TOTAL,
},
summary: issue.fields?.summary,
description: extractDescription(issue.fields?.description),
created: issue.fields?.created,
updated: issue.fields?.updated,
})),
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
total: {
type: 'number',
description: 'Total number of issues in the project (may not always be available)',
optional: true,
},
issues: {
type: 'array',
description: 'Array of Jira issues',
items: {
type: 'object',
properties: {
id: { type: 'string', description: 'Issue ID' },
key: { type: 'string', description: 'Issue key (e.g., PROJ-123)' },
self: { type: 'string', description: 'REST API URL for this issue' },
summary: { type: 'string', description: 'Issue summary' },
description: { type: 'string', description: 'Issue description text', optional: true },
status: {
type: 'object',
description: 'Issue status',
properties: {
id: { type: 'string', description: 'Status ID' },
name: { type: 'string', description: 'Status name' },
},
},
issuetype: {
type: 'object',
description: 'Issue type',
properties: {
id: { type: 'string', description: 'Issue type ID' },
name: { type: 'string', description: 'Issue type name' },
},
},
priority: {
type: 'object',
description: 'Issue priority',
properties: {
id: { type: 'string', description: 'Priority ID' },
name: { type: 'string', description: 'Priority name' },
},
optional: true,
},
assignee: {
type: 'object',
description: 'Assigned user',
properties: {
accountId: { type: 'string', description: 'Atlassian account ID' },
displayName: { type: 'string', description: 'Display name' },
},
optional: true,
},
created: { type: 'string', description: 'ISO 8601 creation timestamp' },
updated: { type: 'string', description: 'ISO 8601 last updated timestamp' },
},
},
description:
'Array of Jira issues with ts, summary, description, created, and updated timestamps',
},
nextPageToken: {
type: 'string',
description: 'Cursor token for the next page. Null when no more results.',
optional: true,
},
isLast: { type: 'boolean', description: 'Whether this is the last page of results' },
},
}

View File

@@ -1,7 +1,26 @@
import type { JiraCreateIssueLinkParams, JiraCreateIssueLinkResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraCreateIssueLinkParams {
accessToken: string
domain: string
inwardIssueKey: string
outwardIssueKey: string
linkType: string
comment?: string
cloudId?: string
}
export interface JiraCreateIssueLinkResponse extends ToolResponse {
output: {
ts: string
inwardIssue: string
outwardIssue: string
linkType: string
linkId?: string
success: boolean
}
}
export const jiraCreateIssueLinkTool: ToolConfig<
JiraCreateIssueLinkParams,
@@ -65,6 +84,7 @@ export const jiraCreateIssueLinkTool: ToolConfig<
request: {
url: (_params: JiraCreateIssueLinkParams) => {
// Always discover first; actual POST happens in transformResponse
return 'https://api.atlassian.com/oauth/token/accessible-resources'
},
method: () => 'GET',
@@ -79,8 +99,10 @@ export const jiraCreateIssueLinkTool: ToolConfig<
},
transformResponse: async (response: Response, params?: JiraCreateIssueLinkParams) => {
// Resolve cloudId
const cloudId = params?.cloudId || (await getJiraCloudId(params!.domain, params!.accessToken))
// Fetch and resolve link type by id/name/inward/outward (case-insensitive)
const typesResp = await fetch(
`https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issueLinkType`,
{
@@ -114,6 +136,7 @@ export const jiraCreateIssueLinkTool: ToolConfig<
throw new Error(`Unknown issue link type "${params!.linkType}". Available: ${available}`)
}
// Create issue link
const linkUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issueLink`
const linkResponse = await fetch(linkUrl, {
method: 'POST',
@@ -156,26 +179,21 @@ export const jiraCreateIssueLinkTool: ToolConfig<
throw new Error(message)
}
let linkId: string | null = null
try {
const linkData = await linkResponse.json()
if (linkData?.id) linkId = String(linkData.id)
} catch {
const location = linkResponse.headers.get('location') || linkResponse.headers.get('Location')
if (location) {
const match = location.match(/\/issueLink\/(\d+)/)
if (match) linkId = match[1]
}
// Try to extract the newly created link ID from the Location header
const location = linkResponse.headers.get('location') || linkResponse.headers.get('Location')
let linkId: string | undefined
if (location) {
const match = location.match(/\/issueLink\/(\d+)/)
if (match) linkId = match[1]
}
return {
success: true,
output: {
ts: new Date().toISOString(),
inwardIssue: params!.inwardIssueKey || 'unknown',
outwardIssue: params!.outwardIssueKey || 'unknown',
linkType: params!.linkType || 'unknown',
inwardIssue: params?.inwardIssueKey || 'unknown',
outwardIssue: params?.outwardIssueKey || 'unknown',
linkType: params?.linkType || 'unknown',
linkId,
success: true,
},
@@ -183,7 +201,7 @@ export const jiraCreateIssueLinkTool: ToolConfig<
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
inwardIssue: { type: 'string', description: 'Inward issue key' },
outwardIssue: { type: 'string', description: 'Outward issue key' },
linkType: { type: 'string', description: 'Type of issue link' },

View File

@@ -1,7 +1,20 @@
import type { JiraDeleteAttachmentParams, JiraDeleteAttachmentResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraDeleteAttachmentParams {
accessToken: string
domain: string
attachmentId: string
cloudId?: string
}
export interface JiraDeleteAttachmentResponse extends ToolResponse {
output: {
ts: string
attachmentId: string
success: boolean
}
}
export const jiraDeleteAttachmentTool: ToolConfig<
JiraDeleteAttachmentParams,
@@ -114,7 +127,7 @@ export const jiraDeleteAttachmentTool: ToolConfig<
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
attachmentId: { type: 'string', description: 'Deleted attachment ID' },
},
}

View File

@@ -1,7 +1,22 @@
import type { JiraDeleteCommentParams, JiraDeleteCommentResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraDeleteCommentParams {
accessToken: string
domain: string
issueKey: string
commentId: string
cloudId?: string
}
export interface JiraDeleteCommentResponse extends ToolResponse {
output: {
ts: string
issueKey: string
commentId: string
success: boolean
}
}
export const jiraDeleteCommentTool: ToolConfig<JiraDeleteCommentParams, JiraDeleteCommentResponse> =
{
@@ -120,7 +135,7 @@ export const jiraDeleteCommentTool: ToolConfig<JiraDeleteCommentParams, JiraDele
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
commentId: { type: 'string', description: 'Deleted comment ID' },
},

View File

@@ -1,7 +1,21 @@
import type { JiraDeleteIssueParams, JiraDeleteIssueResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraDeleteIssueParams {
accessToken: string
domain: string
issueKey: string
cloudId?: string
deleteSubtasks?: boolean
}
export interface JiraDeleteIssueResponse extends ToolResponse {
output: {
ts: string
issueKey: string
success: boolean
}
}
export const jiraDeleteIssueTool: ToolConfig<JiraDeleteIssueParams, JiraDeleteIssueResponse> = {
id: 'jira_delete_issue',
@@ -156,7 +170,7 @@ export const jiraDeleteIssueTool: ToolConfig<JiraDeleteIssueParams, JiraDeleteIs
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Deleted issue key' },
},
}

View File

@@ -1,7 +1,20 @@
import type { JiraDeleteIssueLinkParams, JiraDeleteIssueLinkResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraDeleteIssueLinkParams {
accessToken: string
domain: string
linkId: string
cloudId?: string
}
export interface JiraDeleteIssueLinkResponse extends ToolResponse {
output: {
ts: string
linkId: string
success: boolean
}
}
export const jiraDeleteIssueLinkTool: ToolConfig<
JiraDeleteIssueLinkParams,
@@ -64,12 +77,13 @@ export const jiraDeleteIssueLinkTool: ToolConfig<
transformResponse: async (response: Response, params?: JiraDeleteIssueLinkParams) => {
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
const issueLinkUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issueLink/${params!.linkId}`
// Make the actual request with the resolved cloudId
const issueLinkUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issueLink/${params?.linkId}`
const issueLinkResponse = await fetch(issueLinkUrl, {
method: 'DELETE',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
})
@@ -86,12 +100,13 @@ export const jiraDeleteIssueLinkTool: ToolConfig<
success: true,
output: {
ts: new Date().toISOString(),
linkId: params!.linkId || 'unknown',
linkId: params?.linkId || 'unknown',
success: true,
},
}
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to delete issue link (${response.status})`
try {
@@ -105,14 +120,14 @@ export const jiraDeleteIssueLinkTool: ToolConfig<
success: true,
output: {
ts: new Date().toISOString(),
linkId: params!.linkId || 'unknown',
linkId: params?.linkId || 'unknown',
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
linkId: { type: 'string', description: 'Deleted link ID' },
},
}

View File

@@ -1,7 +1,22 @@
import type { JiraDeleteWorklogParams, JiraDeleteWorklogResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraDeleteWorklogParams {
accessToken: string
domain: string
issueKey: string
worklogId: string
cloudId?: string
}
export interface JiraDeleteWorklogResponse extends ToolResponse {
output: {
ts: string
issueKey: string
worklogId: string
success: boolean
}
}
export const jiraDeleteWorklogTool: ToolConfig<JiraDeleteWorklogParams, JiraDeleteWorklogResponse> =
{
@@ -68,12 +83,13 @@ export const jiraDeleteWorklogTool: ToolConfig<JiraDeleteWorklogParams, JiraDele
transformResponse: async (response: Response, params?: JiraDeleteWorklogParams) => {
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
const worklogUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/worklog/${params!.worklogId}`
// Make the actual request with the resolved cloudId
const worklogUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/worklog/${params?.worklogId}`
const worklogResponse = await fetch(worklogUrl, {
method: 'DELETE',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
})
@@ -90,13 +106,14 @@ export const jiraDeleteWorklogTool: ToolConfig<JiraDeleteWorklogParams, JiraDele
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params!.issueKey || 'unknown',
worklogId: params!.worklogId || 'unknown',
issueKey: params?.issueKey || 'unknown',
worklogId: params?.worklogId || 'unknown',
success: true,
},
}
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to delete worklog from Jira issue (${response.status})`
try {
@@ -110,15 +127,15 @@ export const jiraDeleteWorklogTool: ToolConfig<JiraDeleteWorklogParams, JiraDele
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params!.issueKey || 'unknown',
worklogId: params!.worklogId || 'unknown',
issueKey: params?.issueKey || 'unknown',
worklogId: params?.worklogId || 'unknown',
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
worklogId: { type: 'string', description: 'Deleted worklog ID' },
},

View File

@@ -1,25 +1,7 @@
import type { JiraGetAttachmentsParams, JiraGetAttachmentsResponse } from '@/tools/jira/types'
import { ATTACHMENT_ITEM_PROPERTIES, TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId, transformUser } from '@/tools/jira/utils'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
/**
* Transforms a raw Jira attachment object into typed output.
*/
function transformAttachment(att: any) {
return {
id: att.id ?? '',
filename: att.filename ?? '',
mimeType: att.mimeType ?? '',
size: att.size ?? 0,
content: att.content ?? '',
thumbnail: att.thumbnail ?? null,
author: transformUser(att.author),
created:
typeof att.created === 'number' ? new Date(att.created).toISOString() : (att.created ?? ''),
}
}
export const jiraGetAttachmentsTool: ToolConfig<
JiraGetAttachmentsParams,
JiraGetAttachmentsResponse
@@ -79,13 +61,15 @@ export const jiraGetAttachmentsTool: ToolConfig<
},
transformResponse: async (response: Response, params?: JiraGetAttachmentsParams) => {
const fetchAttachments = async (cloudId: string) => {
const attachmentsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}?fields=attachment`
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
// Make the actual request with the resolved cloudId
const attachmentsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}?fields=attachment`
const attachmentsResponse = await fetch(attachmentsUrl, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
})
@@ -98,46 +82,60 @@ export const jiraGetAttachmentsTool: ToolConfig<
throw new Error(message)
}
return attachmentsResponse.json()
}
const data = await attachmentsResponse.json()
let data: any
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
data = await fetchAttachments(cloudId)
} else {
if (!response.ok) {
let message = `Failed to get attachments from Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
attachments: (data?.fields?.attachment || []).map((att: any) => ({
id: att.id,
filename: att.filename,
size: att.size,
mimeType: att.mimeType,
created: att.created,
author: att.author?.displayName || att.author?.accountId || 'Unknown',
})),
},
}
data = await response.json()
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to get attachments from Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey ?? 'unknown',
attachments: (data?.fields?.attachment ?? []).map(transformAttachment),
issueKey: params?.issueKey || 'unknown',
attachments: (data?.fields?.attachment || []).map((att: any) => ({
id: att.id,
filename: att.filename,
size: att.size,
mimeType: att.mimeType,
created: att.created,
author: att.author?.displayName || att.author?.accountId || 'Unknown',
})),
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
attachments: {
type: 'array',
description: 'Array of attachments',
items: {
type: 'object',
properties: ATTACHMENT_ITEM_PROPERTIES,
},
description: 'Array of attachments with id, filename, size, mimeType, created, author',
},
},
}

View File

@@ -1,22 +1,27 @@
import type { JiraGetCommentsParams, JiraGetCommentsResponse } from '@/tools/jira/types'
import { COMMENT_ITEM_PROPERTIES, TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { extractAdfText, getJiraCloudId, transformUser } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig, ToolResponse } from '@/tools/types'
/**
* Transforms a raw Jira comment object into typed output.
*/
function transformComment(comment: any) {
return {
id: comment.id ?? '',
body: extractAdfText(comment.body) ?? '',
author: transformUser(comment.author) ?? { accountId: '', displayName: '' },
updateAuthor: transformUser(comment.updateAuthor),
created: comment.created ?? '',
updated: comment.updated ?? '',
visibility: comment.visibility
? { type: comment.visibility.type ?? '', value: comment.visibility.value ?? '' }
: null,
export interface JiraGetCommentsParams {
accessToken: string
domain: string
issueKey: string
startAt?: number
maxResults?: number
cloudId?: string
}
export interface JiraGetCommentsResponse extends ToolResponse {
output: {
ts: string
issueKey: string
total: number
comments: Array<{
id: string
author: string
body: string
created: string
updated: string
}>
}
}
@@ -62,13 +67,6 @@ export const jiraGetCommentsTool: ToolConfig<JiraGetCommentsParams, JiraGetComme
visibility: 'user-or-llm',
description: 'Maximum number of comments to return (default: 50)',
},
orderBy: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Sort order for comments: "-created" for newest first, "created" for oldest first',
},
cloudId: {
type: 'string',
required: false,
@@ -81,10 +79,9 @@ export const jiraGetCommentsTool: ToolConfig<JiraGetCommentsParams, JiraGetComme
request: {
url: (params: JiraGetCommentsParams) => {
if (params.cloudId) {
const startAt = params.startAt ?? 0
const maxResults = params.maxResults ?? 50
const orderBy = params.orderBy ?? '-created'
return `https://api.atlassian.com/ex/jira/${params.cloudId}/rest/api/3/issue/${params.issueKey}/comment?startAt=${startAt}&maxResults=${maxResults}&orderBy=${orderBy}`
const startAt = params.startAt || 0
const maxResults = params.maxResults || 50
return `https://api.atlassian.com/ex/jira/${params.cloudId}/rest/api/3/issue/${params.issueKey}/comment?startAt=${startAt}&maxResults=${maxResults}`
}
return 'https://api.atlassian.com/oauth/token/accessible-resources'
},
@@ -98,16 +95,29 @@ export const jiraGetCommentsTool: ToolConfig<JiraGetCommentsParams, JiraGetComme
},
transformResponse: async (response: Response, params?: JiraGetCommentsParams) => {
const fetchComments = async (cloudId: string) => {
const startAt = params?.startAt ?? 0
const maxResults = params?.maxResults ?? 50
const orderBy = params?.orderBy ?? '-created'
const commentsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/comment?startAt=${startAt}&maxResults=${maxResults}&orderBy=${orderBy}`
// Extract text from Atlassian Document Format
const extractText = (content: any): string => {
if (!content) return ''
if (typeof content === 'string') return content
if (Array.isArray(content)) {
return content.map(extractText).join(' ')
}
if (content.type === 'text') return content.text || ''
if (content.content) return extractText(content.content)
return ''
}
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
// Make the actual request with the resolved cloudId
const startAt = params?.startAt || 0
const maxResults = params?.maxResults || 50
const commentsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/comment?startAt=${startAt}&maxResults=${maxResults}`
const commentsResponse = await fetch(commentsUrl, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
})
@@ -120,52 +130,61 @@ export const jiraGetCommentsTool: ToolConfig<JiraGetCommentsParams, JiraGetComme
throw new Error(message)
}
return commentsResponse.json()
}
const data = await commentsResponse.json()
let data: any
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
data = await fetchComments(cloudId)
} else {
if (!response.ok) {
let message = `Failed to get comments from Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
total: data.total || 0,
comments: (data.comments || []).map((comment: any) => ({
id: comment.id,
author: comment.author?.displayName || comment.author?.accountId || 'Unknown',
body: extractText(comment.body),
created: comment.created,
updated: comment.updated,
})),
},
}
data = await response.json()
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to get comments from Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey ?? 'unknown',
total: data.total ?? 0,
startAt: data.startAt ?? 0,
maxResults: data.maxResults ?? 0,
comments: (data.comments ?? []).map(transformComment),
issueKey: params?.issueKey || 'unknown',
total: data.total || 0,
comments: (data.comments || []).map((comment: any) => ({
id: comment.id,
author: comment.author?.displayName || comment.author?.accountId || 'Unknown',
body: extractText(comment.body),
created: comment.created,
updated: comment.updated,
})),
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
total: { type: 'number', description: 'Total number of comments' },
startAt: { type: 'number', description: 'Pagination start index' },
maxResults: { type: 'number', description: 'Maximum results per page' },
comments: {
type: 'array',
description: 'Array of comments',
items: {
type: 'object',
properties: COMMENT_ITEM_PROPERTIES,
},
description: 'Array of comments with id, author, body, created, updated',
},
},
}

View File

@@ -1,20 +1,38 @@
import type { JiraGetUsersParams, JiraGetUsersResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT, USER_OUTPUT_PROPERTIES } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
/**
* Transforms a raw Jira user API object into typed output.
*/
function transformUserOutput(user: any) {
return {
accountId: user.accountId ?? '',
accountType: user.accountType ?? null,
active: user.active ?? false,
displayName: user.displayName ?? '',
emailAddress: user.emailAddress ?? null,
avatarUrl: user.avatarUrls?.['48x48'] ?? null,
timeZone: user.timeZone ?? null,
export interface JiraGetUsersParams {
accessToken: string
domain: string
accountId?: string
startAt?: number
maxResults?: number
cloudId?: string
}
export interface JiraUser {
accountId: string
accountType?: string
active: boolean
displayName: string
emailAddress?: string
avatarUrls?: {
'16x16'?: string
'24x24'?: string
'32x32'?: string
'48x48'?: string
}
timeZone?: string
self?: string
}
export interface JiraGetUsersResponse extends ToolResponse {
output: {
ts: string
users: JiraUser[]
total?: number
startAt?: number
maxResults?: number
}
}
@@ -94,7 +112,9 @@ export const jiraGetUsersTool: ToolConfig<JiraGetUsersParams, JiraGetUsersRespon
},
transformResponse: async (response: Response, params?: JiraGetUsersParams) => {
const fetchUsers = async (cloudId: string) => {
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
let usersUrl: string
if (params!.accountId) {
usersUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/user?accountId=${encodeURIComponent(params!.accountId)}`
@@ -124,49 +144,71 @@ export const jiraGetUsersTool: ToolConfig<JiraGetUsersParams, JiraGetUsersRespon
throw new Error(message)
}
return usersResponse.json()
}
const data = await usersResponse.json()
let data: any
const users = params!.accountId ? [data] : data
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
data = await fetchUsers(cloudId)
} else {
if (!response.ok) {
let message = `Failed to get Jira users (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
return {
success: true,
output: {
ts: new Date().toISOString(),
users: users.map((user: any) => ({
accountId: user.accountId,
accountType: user.accountType,
active: user.active,
displayName: user.displayName,
emailAddress: user.emailAddress,
avatarUrls: user.avatarUrls,
timeZone: user.timeZone,
self: user.self,
})),
total: params!.accountId ? 1 : users.length,
startAt: params!.startAt || 0,
maxResults: params!.maxResults || 50,
},
}
data = await response.json()
}
if (!response.ok) {
let message = `Failed to get Jira users (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
const users = params?.accountId ? [data] : data
return {
success: true,
output: {
ts: new Date().toISOString(),
users: users.map(transformUserOutput),
users: users.map((user: any) => ({
accountId: user.accountId,
accountType: user.accountType,
active: user.active,
displayName: user.displayName,
emailAddress: user.emailAddress,
avatarUrls: user.avatarUrls,
timeZone: user.timeZone,
self: user.self,
})),
total: params?.accountId ? 1 : users.length,
startAt: params?.startAt ?? 0,
maxResults: params?.maxResults ?? 50,
startAt: params?.startAt || 0,
maxResults: params?.maxResults || 50,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
users: {
type: 'array',
description: 'Array of Jira users',
items: {
type: 'object',
properties: USER_OUTPUT_PROPERTIES,
},
type: 'json',
description:
'Array of users with accountId, displayName, emailAddress, active status, and avatarUrls',
},
total: { type: 'number', description: 'Total number of users returned' },
startAt: { type: 'number', description: 'Pagination start index' },

View File

@@ -1,22 +1,30 @@
import type { JiraGetWorklogsParams, JiraGetWorklogsResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT, WORKLOG_ITEM_PROPERTIES } from '@/tools/jira/types'
import { extractAdfText, getJiraCloudId, transformUser } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig, ToolResponse } from '@/tools/types'
/**
* Transforms a raw Jira worklog object into typed output.
*/
function transformWorklog(worklog: any) {
return {
id: worklog.id ?? '',
author: transformUser(worklog.author) ?? { accountId: '', displayName: '' },
updateAuthor: transformUser(worklog.updateAuthor),
comment: worklog.comment ? (extractAdfText(worklog.comment) ?? null) : null,
started: worklog.started ?? '',
timeSpent: worklog.timeSpent ?? '',
timeSpentSeconds: worklog.timeSpentSeconds ?? 0,
created: worklog.created ?? '',
updated: worklog.updated ?? '',
export interface JiraGetWorklogsParams {
accessToken: string
domain: string
issueKey: string
startAt?: number
maxResults?: number
cloudId?: string
}
export interface JiraGetWorklogsResponse extends ToolResponse {
output: {
ts: string
issueKey: string
total: number
worklogs: Array<{
id: string
author: string
timeSpentSeconds: number
timeSpent: string
comment?: string
created: string
updated: string
started: string
}>
}
}
@@ -74,8 +82,8 @@ export const jiraGetWorklogsTool: ToolConfig<JiraGetWorklogsParams, JiraGetWorkl
request: {
url: (params: JiraGetWorklogsParams) => {
if (params.cloudId) {
const startAt = params.startAt ?? 0
const maxResults = params.maxResults ?? 50
const startAt = params.startAt || 0
const maxResults = params.maxResults || 50
return `https://api.atlassian.com/ex/jira/${params.cloudId}/rest/api/3/issue/${params.issueKey}/worklog?startAt=${startAt}&maxResults=${maxResults}`
}
return 'https://api.atlassian.com/oauth/token/accessible-resources'
@@ -90,15 +98,29 @@ export const jiraGetWorklogsTool: ToolConfig<JiraGetWorklogsParams, JiraGetWorkl
},
transformResponse: async (response: Response, params?: JiraGetWorklogsParams) => {
const fetchWorklogs = async (cloudId: string) => {
const startAt = params?.startAt ?? 0
const maxResults = params?.maxResults ?? 50
const worklogsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/worklog?startAt=${startAt}&maxResults=${maxResults}`
// Extract text from Atlassian Document Format
const extractText = (content: any): string => {
if (!content) return ''
if (typeof content === 'string') return content
if (Array.isArray(content)) {
return content.map(extractText).join(' ')
}
if (content.type === 'text') return content.text || ''
if (content.content) return extractText(content.content)
return ''
}
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
// Make the actual request with the resolved cloudId
const startAt = params?.startAt || 0
const maxResults = params?.maxResults || 50
const worklogsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/worklog?startAt=${startAt}&maxResults=${maxResults}`
const worklogsResponse = await fetch(worklogsUrl, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
})
@@ -111,52 +133,68 @@ export const jiraGetWorklogsTool: ToolConfig<JiraGetWorklogsParams, JiraGetWorkl
throw new Error(message)
}
return worklogsResponse.json()
}
const data = await worklogsResponse.json()
let data: any
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
data = await fetchWorklogs(cloudId)
} else {
if (!response.ok) {
let message = `Failed to get worklogs from Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
total: data.total || 0,
worklogs: (data.worklogs || []).map((worklog: any) => ({
id: worklog.id,
author: worklog.author?.displayName || worklog.author?.accountId || 'Unknown',
timeSpentSeconds: worklog.timeSpentSeconds,
timeSpent: worklog.timeSpent,
comment: worklog.comment ? extractText(worklog.comment) : undefined,
created: worklog.created,
updated: worklog.updated,
started: worklog.started,
})),
},
}
data = await response.json()
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to get worklogs from Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey ?? 'unknown',
total: data.total ?? 0,
startAt: data.startAt ?? 0,
maxResults: data.maxResults ?? 0,
worklogs: (data.worklogs ?? []).map(transformWorklog),
issueKey: params?.issueKey || 'unknown',
total: data.total || 0,
worklogs: (data.worklogs || []).map((worklog: any) => ({
id: worklog.id,
author: worklog.author?.displayName || worklog.author?.accountId || 'Unknown',
timeSpentSeconds: worklog.timeSpentSeconds,
timeSpent: worklog.timeSpent,
comment: worklog.comment ? extractText(worklog.comment) : undefined,
created: worklog.created,
updated: worklog.updated,
started: worklog.started,
})),
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
total: { type: 'number', description: 'Total number of worklogs' },
startAt: { type: 'number', description: 'Pagination start index' },
maxResults: { type: 'number', description: 'Maximum results per page' },
worklogs: {
type: 'array',
description: 'Array of worklogs',
items: {
type: 'object',
properties: WORKLOG_ITEM_PROPERTIES,
},
description:
'Array of worklogs with id, author, timeSpentSeconds, timeSpent, comment, created, updated, started',
},
},
}

View File

@@ -1,7 +1,22 @@
import type { JiraRemoveWatcherParams, JiraRemoveWatcherResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
import type { ToolConfig, ToolResponse } from '@/tools/types'
export interface JiraRemoveWatcherParams {
accessToken: string
domain: string
issueKey: string
accountId: string
cloudId?: string
}
export interface JiraRemoveWatcherResponse extends ToolResponse {
output: {
ts: string
issueKey: string
watcherAccountId: string
success: boolean
}
}
export const jiraRemoveWatcherTool: ToolConfig<JiraRemoveWatcherParams, JiraRemoveWatcherResponse> =
{
@@ -68,12 +83,13 @@ export const jiraRemoveWatcherTool: ToolConfig<JiraRemoveWatcherParams, JiraRemo
transformResponse: async (response: Response, params?: JiraRemoveWatcherParams) => {
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
const watcherUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/watchers?accountId=${params!.accountId}`
// Make the actual request with the resolved cloudId
const watcherUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/watchers?accountId=${params?.accountId}`
const watcherResponse = await fetch(watcherUrl, {
method: 'DELETE',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
})
@@ -90,13 +106,14 @@ export const jiraRemoveWatcherTool: ToolConfig<JiraRemoveWatcherParams, JiraRemo
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params!.issueKey || 'unknown',
watcherAccountId: params!.accountId || 'unknown',
issueKey: params?.issueKey || 'unknown',
watcherAccountId: params?.accountId || 'unknown',
success: true,
},
}
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to remove watcher from Jira issue (${response.status})`
try {
@@ -110,15 +127,15 @@ export const jiraRemoveWatcherTool: ToolConfig<JiraRemoveWatcherParams, JiraRemo
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params!.issueKey || 'unknown',
watcherAccountId: params!.accountId || 'unknown',
issueKey: params?.issueKey || 'unknown',
watcherAccountId: params?.accountId || 'unknown',
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
watcherAccountId: { type: 'string', description: 'Removed watcher account ID' },
},

View File

@@ -1,176 +1,10 @@
import { createLogger } from '@sim/logger'
import type { JiraRetrieveParams, JiraRetrieveResponse } from '@/tools/jira/types'
import { ISSUE_ITEM_PROPERTIES, TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { extractAdfText, getJiraCloudId, transformUser } from '@/tools/jira/utils'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
const logger = createLogger('JiraRetrieveTool')
/**
* Transforms a raw Jira API issue response into a fully typed output.
*/
function transformIssueData(data: any) {
const fields = data?.fields ?? {}
return {
id: data?.id ?? '',
issueKey: data?.key ?? '',
key: data?.key ?? '',
self: data?.self ?? '',
summary: fields.summary ?? '',
description: extractAdfText(fields.description),
status: {
id: fields.status?.id ?? '',
name: fields.status?.name ?? '',
description: fields.status?.description ?? null,
statusCategory: fields.status?.statusCategory
? {
id: fields.status.statusCategory.id,
key: fields.status.statusCategory.key ?? '',
name: fields.status.statusCategory.name ?? '',
colorName: fields.status.statusCategory.colorName ?? '',
}
: undefined,
},
issuetype: {
id: fields.issuetype?.id ?? '',
name: fields.issuetype?.name ?? '',
description: fields.issuetype?.description ?? null,
subtask: fields.issuetype?.subtask ?? false,
iconUrl: fields.issuetype?.iconUrl ?? null,
},
project: {
id: fields.project?.id ?? '',
key: fields.project?.key ?? '',
name: fields.project?.name ?? '',
projectTypeKey: fields.project?.projectTypeKey ?? null,
},
priority: fields.priority
? {
id: fields.priority.id ?? '',
name: fields.priority.name ?? '',
iconUrl: fields.priority.iconUrl ?? null,
}
: null,
assignee: transformUser(fields.assignee),
reporter: transformUser(fields.reporter),
creator: transformUser(fields.creator),
labels: fields.labels ?? [],
components: (fields.components ?? []).map((c: any) => ({
id: c.id ?? '',
name: c.name ?? '',
description: c.description ?? null,
})),
fixVersions: (fields.fixVersions ?? []).map((v: any) => ({
id: v.id ?? '',
name: v.name ?? '',
released: v.released ?? null,
releaseDate: v.releaseDate ?? null,
})),
resolution: fields.resolution
? {
id: fields.resolution.id ?? '',
name: fields.resolution.name ?? '',
description: fields.resolution.description ?? null,
}
: null,
duedate: fields.duedate ?? null,
created: fields.created ?? '',
updated: fields.updated ?? '',
resolutiondate: fields.resolutiondate ?? null,
timetracking: fields.timetracking
? {
originalEstimate: fields.timetracking.originalEstimate ?? null,
remainingEstimate: fields.timetracking.remainingEstimate ?? null,
timeSpent: fields.timetracking.timeSpent ?? null,
originalEstimateSeconds: fields.timetracking.originalEstimateSeconds ?? null,
remainingEstimateSeconds: fields.timetracking.remainingEstimateSeconds ?? null,
timeSpentSeconds: fields.timetracking.timeSpentSeconds ?? null,
}
: null,
parent: fields.parent
? {
id: fields.parent.id ?? '',
key: fields.parent.key ?? '',
summary: fields.parent.fields?.summary ?? null,
}
: null,
issuelinks: (fields.issuelinks ?? []).map((link: any) => ({
id: link.id ?? '',
type: {
id: link.type?.id ?? '',
name: link.type?.name ?? '',
inward: link.type?.inward ?? '',
outward: link.type?.outward ?? '',
},
inwardIssue: link.inwardIssue
? {
id: link.inwardIssue.id ?? '',
key: link.inwardIssue.key ?? '',
statusName: link.inwardIssue.fields?.status?.name ?? null,
summary: link.inwardIssue.fields?.summary ?? null,
}
: null,
outwardIssue: link.outwardIssue
? {
id: link.outwardIssue.id ?? '',
key: link.outwardIssue.key ?? '',
statusName: link.outwardIssue.fields?.status?.name ?? null,
summary: link.outwardIssue.fields?.summary ?? null,
}
: null,
})),
subtasks: (fields.subtasks ?? []).map((sub: any) => ({
id: sub.id ?? '',
key: sub.key ?? '',
summary: sub.fields?.summary ?? '',
statusName: sub.fields?.status?.name ?? '',
issueTypeName: sub.fields?.issuetype?.name ?? null,
})),
votes: fields.votes
? {
votes: fields.votes.votes ?? 0,
hasVoted: fields.votes.hasVoted ?? false,
}
: null,
watches:
(fields.watches ?? fields.watcher)
? {
watchCount: (fields.watches ?? fields.watcher)?.watchCount ?? 0,
isWatching: (fields.watches ?? fields.watcher)?.isWatching ?? false,
}
: null,
comments: ((fields.comment?.comments ?? fields.comment) || []).map((c: any) => ({
id: c.id ?? '',
body: extractAdfText(c.body) ?? '',
author: transformUser(c.author),
updateAuthor: transformUser(c.updateAuthor),
created: c.created ?? '',
updated: c.updated ?? '',
})),
worklogs: ((fields.worklog?.worklogs ?? fields.worklog) || []).map((w: any) => ({
id: w.id ?? '',
author: transformUser(w.author),
updateAuthor: transformUser(w.updateAuthor),
comment: w.comment ? (extractAdfText(w.comment) ?? null) : null,
started: w.started ?? '',
timeSpent: w.timeSpent ?? '',
timeSpentSeconds: w.timeSpentSeconds ?? 0,
created: w.created ?? '',
updated: w.updated ?? '',
})),
attachments: (fields.attachment ?? []).map((att: any) => ({
id: att.id ?? '',
filename: att.filename ?? '',
mimeType: att.mimeType ?? '',
size: att.size ?? 0,
content: att.content ?? '',
thumbnail: att.thumbnail ?? null,
author: transformUser(att.author),
created: att.created ?? '',
})),
}
}
export const jiraRetrieveTool: ToolConfig<JiraRetrieveParams, JiraRetrieveResponse> = {
id: 'jira_retrieve',
name: 'Jira Retrieve',
@@ -195,6 +29,12 @@ export const jiraRetrieveTool: ToolConfig<JiraRetrieveParams, JiraRetrieveRespon
visibility: 'user-only',
description: 'Your Jira domain (e.g., yourcompany.atlassian.net)',
},
projectId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Jira project key (e.g., PROJ). Optional when retrieving a single issue.',
},
issueKey: {
type: 'string',
required: true,
@@ -213,8 +53,10 @@ export const jiraRetrieveTool: ToolConfig<JiraRetrieveParams, JiraRetrieveRespon
request: {
url: (params: JiraRetrieveParams) => {
if (params.cloudId) {
// Request with broad expands; additional endpoints fetched in transform for completeness
return `https://api.atlassian.com/ex/jira/${params.cloudId}/rest/api/3/issue/${params.issueKey}?expand=renderedFields,names,schema,transitions,operations,editmeta,changelog,versionedRepresentations`
}
// If no cloudId, use the accessible resources endpoint
return 'https://api.atlassian.com/oauth/token/accessible-resources'
},
method: 'GET',
@@ -228,16 +70,21 @@ export const jiraRetrieveTool: ToolConfig<JiraRetrieveParams, JiraRetrieveRespon
transformResponse: async (response: Response, params?: JiraRetrieveParams) => {
if (!params?.issueKey) {
throw new Error('Provide an issue key to retrieve a single issue.')
throw new Error(
'Select a project to read issues, or provide an issue key to read a single issue.'
)
}
const fetchIssue = async (cloudId: string) => {
const issueUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params.issueKey}?expand=renderedFields,names,schema,transitions,operations,editmeta,changelog,versionedRepresentations`
// If we don't have a cloudId, resolve it robustly using the Jira utils helper
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
// Now fetch the actual issue with the found cloudId
const issueUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}?expand=renderedFields,names,schema,transitions,operations,editmeta,changelog,versionedRepresentations`
const issueResponse = await fetch(issueUrl, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
})
@@ -250,20 +97,19 @@ export const jiraRetrieveTool: ToolConfig<JiraRetrieveParams, JiraRetrieveRespon
throw new Error(message)
}
return issueResponse.json()
}
const data = await issueResponse.json()
const fetchSupplementary = async (cloudId: string, data: any) => {
// Fetch additional resources for a comprehensive view
const base = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params.issueKey}`
const [commentsResp, worklogResp, watchersResp] = await Promise.all([
fetch(`${base}/comment?maxResults=100&orderBy=-created`, {
headers: { Accept: 'application/json', Authorization: `Bearer ${params.accessToken}` },
headers: { Accept: 'application/json', Authorization: `Bearer ${params!.accessToken}` },
}),
fetch(`${base}/worklog?maxResults=100`, {
headers: { Accept: 'application/json', Authorization: `Bearer ${params.accessToken}` },
headers: { Accept: 'application/json', Authorization: `Bearer ${params!.accessToken}` },
}),
fetch(`${base}/watchers`, {
headers: { Accept: 'application/json', Authorization: `Bearer ${params.accessToken}` },
headers: { Accept: 'application/json', Authorization: `Bearer ${params!.accessToken}` },
}),
])
@@ -271,68 +117,124 @@ export const jiraRetrieveTool: ToolConfig<JiraRetrieveParams, JiraRetrieveRespon
if (commentsResp.ok) {
const commentsData = await commentsResp.json()
if (data?.fields) data.fields.comment = commentsData?.comments || data.fields.comment
} else {
logger.debug?.('Failed to fetch comments', { status: commentsResp.status })
}
} catch {
logger.debug?.('Failed to fetch comments')
}
} catch {}
try {
if (worklogResp.ok) {
const worklogData = await worklogResp.json()
if (data?.fields) data.fields.worklog = worklogData || data.fields.worklog
} else {
logger.debug?.('Failed to fetch worklog', { status: worklogResp.status })
}
} catch {
logger.debug?.('Failed to fetch worklog')
}
} catch {}
try {
if (watchersResp.ok) {
const watchersData = await watchersResp.json()
if (data?.fields) {
data.fields.watches = watchersData
// Provide both common keys for compatibility
;(data.fields as any).watcher = watchersData
;(data.fields as any).watches = watchersData
}
} else {
logger.debug?.('Failed to fetch watchers', { status: watchersResp.status })
}
} catch {
logger.debug?.('Failed to fetch watchers')
} catch {}
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: data?.key,
summary: data?.fields?.summary,
description: data?.fields?.description,
created: data?.fields?.created,
updated: data?.fields?.updated,
issue: data,
},
}
}
let data: any
// If we have a cloudId, this response is the issue data
if (!response.ok) {
let message = `Failed to fetch Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.message || err?.errorMessages?.[0] || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
// When cloudId was provided up-front, fetch additional data too
try {
const url = new URL(response.url)
const match = url.pathname.match(/\/ex\/jira\/([^/]+)/)
const cloudId = match?.[1]
if (cloudId) {
const base = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params.issueKey}`
const [commentsResp, worklogResp, watchersResp] = await Promise.all([
fetch(`${base}/comment?maxResults=100&orderBy=-created`, {
headers: { Accept: 'application/json', Authorization: `Bearer ${params!.accessToken}` },
}),
fetch(`${base}/worklog?maxResults=100`, {
headers: { Accept: 'application/json', Authorization: `Bearer ${params!.accessToken}` },
}),
fetch(`${base}/watchers`, {
headers: { Accept: 'application/json', Authorization: `Bearer ${params!.accessToken}` },
}),
])
if (!params.cloudId) {
const cloudId = await getJiraCloudId(params.domain, params.accessToken)
data = await fetchIssue(cloudId)
await fetchSupplementary(cloudId, data)
} else {
if (!response.ok) {
let message = `Failed to fetch Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.message || err?.errorMessages?.[0] || message
} catch (_e) {}
throw new Error(message)
if (commentsResp.ok) {
const commentsData = await commentsResp.json()
if (data?.fields) data.fields.comment = commentsData?.comments || data.fields.comment
}
} catch {}
try {
if (worklogResp.ok) {
const worklogData = await worklogResp.json()
if (data?.fields) data.fields.worklog = worklogData || data.fields.worklog
}
} catch {}
try {
if (watchersResp.ok) {
const watchersData = await watchersResp.json()
if (data?.fields) {
;(data.fields as any).watcher = watchersData
;(data.fields as any).watches = watchersData
}
}
} catch {}
}
data = await response.json()
await fetchSupplementary(params.cloudId, data)
}
} catch {}
return {
success: true,
output: {
ts: new Date().toISOString(),
...transformIssueData(data),
issueKey: data?.key,
summary: data?.fields?.summary,
description: data?.fields?.description,
created: data?.fields?.created,
updated: data?.fields?.updated,
issue: data,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
...ISSUE_ITEM_PROPERTIES,
issue: {
type: 'json',
description: 'Complete raw Jira issue object from the API',
optional: true,
},
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key (e.g., PROJ-123)' },
summary: { type: 'string', description: 'Issue summary' },
description: { type: 'json', description: 'Issue description content' },
created: { type: 'string', description: 'Issue creation timestamp' },
updated: { type: 'string', description: 'Issue last updated timestamp' },
issue: { type: 'json', description: 'Complete issue object with all fields' },
},
}

View File

@@ -1,73 +1,7 @@
import type { JiraSearchIssuesParams, JiraSearchIssuesResponse } from '@/tools/jira/types'
import { SEARCH_ISSUE_ITEM_PROPERTIES, TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { extractAdfText, getJiraCloudId, transformUser } from '@/tools/jira/utils'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
/**
* Transforms a raw Jira search result issue into typed output.
*/
function transformSearchIssue(issue: any) {
const fields = issue?.fields ?? {}
return {
id: issue.id ?? '',
key: issue.key ?? '',
self: issue.self ?? '',
summary: fields.summary ?? '',
description: extractAdfText(fields.description),
status: {
id: fields.status?.id ?? '',
name: fields.status?.name ?? '',
description: fields.status?.description ?? null,
statusCategory: fields.status?.statusCategory
? {
id: fields.status.statusCategory.id,
key: fields.status.statusCategory.key ?? '',
name: fields.status.statusCategory.name ?? '',
colorName: fields.status.statusCategory.colorName ?? '',
}
: null,
},
issuetype: {
id: fields.issuetype?.id ?? '',
name: fields.issuetype?.name ?? '',
description: fields.issuetype?.description ?? null,
subtask: fields.issuetype?.subtask ?? false,
iconUrl: fields.issuetype?.iconUrl ?? null,
},
project: {
id: fields.project?.id ?? '',
key: fields.project?.key ?? '',
name: fields.project?.name ?? '',
projectTypeKey: fields.project?.projectTypeKey ?? null,
},
priority: fields.priority
? {
id: fields.priority.id ?? '',
name: fields.priority.name ?? '',
iconUrl: fields.priority.iconUrl ?? null,
}
: null,
assignee: transformUser(fields.assignee),
reporter: transformUser(fields.reporter),
labels: fields.labels ?? [],
components: (fields.components ?? []).map((c: any) => ({
id: c.id ?? '',
name: c.name ?? '',
description: c.description ?? null,
})),
resolution: fields.resolution
? {
id: fields.resolution.id ?? '',
name: fields.resolution.name ?? '',
description: fields.resolution.description ?? null,
}
: null,
duedate: fields.duedate ?? null,
created: fields.created ?? '',
updated: fields.updated ?? '',
}
}
export const jiraSearchIssuesTool: ToolConfig<JiraSearchIssuesParams, JiraSearchIssuesResponse> = {
id: 'jira_search_issues',
name: 'Jira Search Issues',
@@ -99,24 +33,24 @@ export const jiraSearchIssuesTool: ToolConfig<JiraSearchIssuesParams, JiraSearch
description:
'JQL query string to search for issues (e.g., "project = PROJ AND status = Open")',
},
nextPageToken: {
type: 'string',
startAt: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Cursor token for the next page of results. Omit for the first page.',
description: 'The index of the first result to return (for pagination)',
},
maxResults: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Maximum number of results to return per page (default: 50)',
description: 'Maximum number of results to return (default: 50)',
},
fields: {
type: 'array',
required: false,
visibility: 'user-or-llm',
description:
'Array of field names to return (default: all navigable). Use "*all" for every field.',
"Array of field names to return (default: ['summary', 'status', 'assignee', 'created', 'updated'])",
},
cloudId: {
type: 'string',
@@ -132,7 +66,7 @@ export const jiraSearchIssuesTool: ToolConfig<JiraSearchIssuesParams, JiraSearch
if (params.cloudId) {
const query = new URLSearchParams()
if (params.jql) query.set('jql', params.jql)
if (params.nextPageToken) query.set('nextPageToken', params.nextPageToken)
if (typeof params.startAt === 'number') query.set('startAt', String(params.startAt))
if (typeof params.maxResults === 'number')
query.set('maxResults', String(params.maxResults))
if (Array.isArray(params.fields) && params.fields.length > 0)
@@ -143,19 +77,22 @@ export const jiraSearchIssuesTool: ToolConfig<JiraSearchIssuesParams, JiraSearch
return 'https://api.atlassian.com/oauth/token/accessible-resources'
},
method: () => 'GET',
headers: (params: JiraSearchIssuesParams) => ({
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params.accessToken}`,
}),
headers: (params: JiraSearchIssuesParams) => {
return {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params.accessToken}`,
}
},
body: () => undefined as any,
},
transformResponse: async (response: Response, params?: JiraSearchIssuesParams) => {
const performSearch = async (cloudId: string) => {
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
const query = new URLSearchParams()
if (params?.jql) query.set('jql', params.jql)
if (params?.nextPageToken) query.set('nextPageToken', params.nextPageToken)
if (typeof params?.startAt === 'number') query.set('startAt', String(params.startAt))
if (typeof params?.maxResults === 'number') query.set('maxResults', String(params.maxResults))
if (Array.isArray(params?.fields) && params.fields.length > 0)
query.set('fields', params.fields.join(','))
@@ -166,6 +103,12 @@ export const jiraSearchIssuesTool: ToolConfig<JiraSearchIssuesParams, JiraSearch
Accept: 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
},
body: JSON.stringify({
jql: params?.jql,
startAt: params?.startAt ? Number(params.startAt) : 0,
maxResults: params?.maxResults ? Number(params.maxResults) : 50,
fields: params?.fields || ['summary', 'status', 'assignee', 'created', 'updated'],
}),
})
if (!searchResponse.ok) {
@@ -177,58 +120,65 @@ export const jiraSearchIssuesTool: ToolConfig<JiraSearchIssuesParams, JiraSearch
throw new Error(message)
}
return searchResponse.json()
}
const data = await searchResponse.json()
let data: any
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
data = await performSearch(cloudId)
} else {
if (!response.ok) {
let message = `Failed to search Jira issues (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
return {
success: true,
output: {
ts: new Date().toISOString(),
total: data?.total || 0,
startAt: data?.startAt || 0,
maxResults: data?.maxResults || 0,
issues: (data?.issues || []).map((issue: any) => ({
key: issue.key,
summary: issue.fields?.summary,
status: issue.fields?.status?.name,
assignee: issue.fields?.assignee?.displayName || issue.fields?.assignee?.accountId,
created: issue.fields?.created,
updated: issue.fields?.updated,
})),
},
}
data = await response.json()
}
if (!response.ok) {
let message = `Failed to search Jira issues (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
return {
success: true,
output: {
ts: new Date().toISOString(),
issues: (data?.issues ?? []).map(transformSearchIssue),
nextPageToken: data?.nextPageToken ?? null,
isLast: data?.isLast ?? true,
total: data?.total ?? null,
total: data?.total || 0,
startAt: data?.startAt || 0,
maxResults: data?.maxResults || 0,
issues: (data?.issues || []).map((issue: any) => ({
key: issue.key,
summary: issue.fields?.summary,
status: issue.fields?.status?.name,
assignee: issue.fields?.assignee?.displayName || issue.fields?.assignee?.accountId,
created: issue.fields?.created,
updated: issue.fields?.updated,
})),
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
total: { type: 'number', description: 'Total number of matching issues' },
startAt: { type: 'number', description: 'Pagination start index' },
maxResults: { type: 'number', description: 'Maximum results per page' },
issues: {
type: 'array',
description: 'Array of matching issues',
items: {
type: 'object',
properties: SEARCH_ISSUE_ITEM_PROPERTIES,
},
},
nextPageToken: {
type: 'string',
description: 'Cursor token for the next page. Null when no more results.',
optional: true,
},
isLast: { type: 'boolean', description: 'Whether this is the last page of results' },
total: {
type: 'number',
description: 'Total number of matching issues (may not always be available)',
optional: true,
description: 'Array of matching issues with key, summary, status, assignee, created, updated',
},
},
}

View File

@@ -1,5 +1,4 @@
import type { JiraTransitionIssueParams, JiraTransitionIssueResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
@@ -49,12 +48,6 @@ export const jiraTransitionIssueTool: ToolConfig<
visibility: 'user-or-llm',
description: 'Optional comment to add when transitioning the issue',
},
resolution: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Resolution name to set during transition (e.g., "Fixed", "Won\'t Fix")',
},
cloudId: {
type: 'string',
required: false,
@@ -81,47 +74,87 @@ export const jiraTransitionIssueTool: ToolConfig<
},
body: (params: JiraTransitionIssueParams) => {
if (!params.cloudId) return undefined as any
return buildTransitionBody(params)
const body: any = {
transition: {
id: params.transitionId,
},
}
if (params.comment) {
body.update = {
comment: [
{
add: {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params.comment,
},
],
},
],
},
},
},
],
}
}
return body
},
},
transformResponse: async (response: Response, params?: JiraTransitionIssueParams) => {
const performTransition = async (cloudId: string) => {
// First, fetch available transitions to get the name and target status
const transitionsUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/transitions`
const transitionsResp = await fetch(transitionsUrl, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
const transitionUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/transitions`
const body: any = {
transition: {
id: params!.transitionId,
},
})
}
let transitionName: string | null = null
let toStatus: { id: string; name: string } | null = null
if (transitionsResp.ok) {
const transitionsData = await transitionsResp.json()
const transition = (transitionsData?.transitions ?? []).find(
(t: any) => String(t.id) === String(params!.transitionId)
)
if (transition) {
transitionName = transition.name ?? null
toStatus = transition.to
? { id: transition.to.id ?? '', name: transition.to.name ?? '' }
: null
if (params!.comment) {
body.update = {
comment: [
{
add: {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params!.comment,
},
],
},
],
},
},
},
],
}
}
// Perform the transition
const transitionResponse = await fetch(transitionsUrl, {
const transitionResponse = await fetch(transitionUrl, {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
},
body: JSON.stringify(buildTransitionBody(params!)),
body: JSON.stringify(body),
})
if (!transitionResponse.ok) {
@@ -133,119 +166,42 @@ export const jiraTransitionIssueTool: ToolConfig<
throw new Error(message)
}
return { transitionName, toStatus }
}
let transitionName: string | null = null
let toStatus: { id: string; name: string } | null = null
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
const result = await performTransition(cloudId)
transitionName = result.transitionName
toStatus = result.toStatus
} else {
// When cloudId was provided, the initial request was the POST transition.
// We need to fetch transition metadata separately.
if (!response.ok) {
let message = `Failed to transition Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
// Transition endpoint returns 204 No Content on success
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params!.issueKey,
transitionId: params!.transitionId,
success: true,
},
}
// Fetch transition metadata for the response
try {
const transitionsUrl = `https://api.atlassian.com/ex/jira/${params.cloudId}/rest/api/3/issue/${params.issueKey}/transitions`
const transitionsResp = await fetch(transitionsUrl, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: `Bearer ${params.accessToken}`,
},
})
if (transitionsResp.ok) {
const transitionsData = await transitionsResp.json()
const transition = (transitionsData?.transitions ?? []).find(
(t: any) => String(t.id) === String(params.transitionId)
)
if (transition) {
transitionName = transition.name ?? null
toStatus = transition.to
? { id: transition.to.id ?? '', name: transition.to.name ?? '' }
: null
}
}
} catch {}
}
if (!response.ok) {
let message = `Failed to transition Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
// Transition endpoint returns 204 No Content on success
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey ?? 'unknown',
transitionId: params?.transitionId ?? 'unknown',
transitionName,
toStatus,
issueKey: params?.issueKey || 'unknown',
transitionId: params?.transitionId || 'unknown',
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key that was transitioned' },
transitionId: { type: 'string', description: 'Applied transition ID' },
transitionName: { type: 'string', description: 'Applied transition name', optional: true },
toStatus: {
type: 'object',
description: 'Target status after transition',
properties: {
id: { type: 'string', description: 'Status ID' },
name: { type: 'string', description: 'Status name' },
},
optional: true,
},
},
}
/**
* Builds the transition request body per Jira API v3.
*/
function buildTransitionBody(params: JiraTransitionIssueParams) {
const body: any = {
transition: { id: params.transitionId },
}
if (params.resolution) {
body.fields = {
...body.fields,
resolution: { name: params.resolution },
}
}
if (params.comment) {
body.update = {
comment: [
{
add: {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: params.comment }],
},
],
},
},
},
],
}
}
return body
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,4 @@
import type { JiraUpdateParams, JiraUpdateResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import type { ToolConfig } from '@/tools/types'
export const jiraUpdateTool: ToolConfig<JiraUpdateParams, JiraUpdateResponse> = {
@@ -26,6 +25,12 @@ export const jiraUpdateTool: ToolConfig<JiraUpdateParams, JiraUpdateResponse> =
visibility: 'user-only',
description: 'Your Jira domain (e.g., yourcompany.atlassian.net)',
},
projectId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Jira project key (e.g., PROJ). Optional when updating a single issue.',
},
issueKey: {
type: 'string',
required: true,
@@ -44,65 +49,23 @@ export const jiraUpdateTool: ToolConfig<JiraUpdateParams, JiraUpdateResponse> =
visibility: 'user-or-llm',
description: 'New description for the issue',
},
status: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'New status for the issue',
},
priority: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'New priority ID or name for the issue (e.g., "High")',
description: 'New priority for the issue',
},
assignee: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'New assignee account ID for the issue',
},
labels: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Labels to set on the issue (array of label name strings)',
},
components: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Components to set on the issue (array of component name strings)',
},
duedate: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Due date for the issue (format: YYYY-MM-DD)',
},
fixVersions: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Fix versions to set (array of version name strings)',
},
environment: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Environment information for the issue',
},
customFieldId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Custom field ID to update (e.g., customfield_10001)',
},
customFieldValue: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Value for the custom field',
},
notifyUsers: {
type: 'boolean',
required: false,
visibility: 'user-or-llm',
description: 'Whether to send email notifications about this update (default: true)',
description: 'New assignee for the issue',
},
cloudId: {
type: 'string',
@@ -120,22 +83,17 @@ export const jiraUpdateTool: ToolConfig<JiraUpdateParams, JiraUpdateResponse> =
'Content-Type': 'application/json',
}),
body: (params) => {
// Pass all parameters to the internal API route
return {
domain: params.domain,
accessToken: params.accessToken,
issueKey: params.issueKey,
summary: params.summary,
title: params.title, // Support both for backwards compatibility
description: params.description,
status: params.status,
priority: params.priority,
assignee: params.assignee,
labels: params.labels,
components: params.components,
duedate: params.duedate,
fixVersions: params.fixVersions,
environment: params.environment,
customFieldId: params.customFieldId,
customFieldValue: params.customFieldValue,
notifyUsers: params.notifyUsers,
cloudId: params.cloudId,
}
},
@@ -158,10 +116,12 @@ export const jiraUpdateTool: ToolConfig<JiraUpdateParams, JiraUpdateResponse> =
const data = JSON.parse(responseText)
// The internal API route already returns the correct format
if (data.success && data.output) {
return data
}
// Fallback for unexpected response format
return {
success: data.success || false,
output: data.output || {
@@ -175,7 +135,7 @@ export const jiraUpdateTool: ToolConfig<JiraUpdateParams, JiraUpdateResponse> =
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Updated issue key (e.g., PROJ-123)' },
summary: { type: 'string', description: 'Issue summary after update' },
},

View File

@@ -1,24 +1,7 @@
import type { JiraUpdateCommentParams, JiraUpdateCommentResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT, USER_OUTPUT_PROPERTIES } from '@/tools/jira/types'
import { extractAdfText, getJiraCloudId, transformUser } from '@/tools/jira/utils'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
/**
* Transforms an update comment API response into typed output.
*/
function transformUpdateCommentResponse(data: any, params: JiraUpdateCommentParams) {
return {
ts: new Date().toISOString(),
issueKey: params.issueKey ?? 'unknown',
commentId: data?.id ?? params.commentId ?? 'unknown',
body: data?.body ? (extractAdfText(data.body) ?? params.body ?? '') : (params.body ?? ''),
author: transformUser(data?.author) ?? { accountId: '', displayName: '' },
created: data?.created ?? '',
updated: data?.updated ?? '',
success: true,
}
}
export const jiraUpdateCommentTool: ToolConfig<JiraUpdateCommentParams, JiraUpdateCommentResponse> =
{
id: 'jira_update_comment',
@@ -62,13 +45,6 @@ export const jiraUpdateCommentTool: ToolConfig<JiraUpdateCommentParams, JiraUpda
visibility: 'user-or-llm',
description: 'Updated comment text',
},
visibility: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description:
'Restrict comment visibility. Object with "type" ("role" or "group") and "value" (role/group name).',
},
cloudId: {
type: 'string',
required: false,
@@ -95,48 +71,55 @@ export const jiraUpdateCommentTool: ToolConfig<JiraUpdateCommentParams, JiraUpda
},
body: (params: JiraUpdateCommentParams) => {
if (!params.cloudId) return undefined as any
const payload: Record<string, any> = {
return {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: params.body }],
content: [
{
type: 'text',
text: params.body,
},
],
},
],
},
}
if (params.visibility) payload.visibility = params.visibility
return payload
},
},
transformResponse: async (response: Response, params?: JiraUpdateCommentParams) => {
const payload: Record<string, any> = {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: params?.body ?? '' }],
},
],
},
}
if (params?.visibility) payload.visibility = params.visibility
const makeRequest = async (cloudId: string) => {
const commentUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/comment/${params!.commentId}`
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
// Make the actual request with the resolved cloudId
const commentUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/comment/${params?.commentId}`
const commentResponse = await fetch(commentUrl, {
method: 'PUT',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
body: JSON.stringify(payload),
body: JSON.stringify({
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params?.body,
},
],
},
],
},
}),
})
if (!commentResponse.ok) {
@@ -148,46 +131,48 @@ export const jiraUpdateCommentTool: ToolConfig<JiraUpdateCommentParams, JiraUpda
throw new Error(message)
}
return commentResponse.json()
}
const data = await commentResponse.json()
let data: any
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
data = await makeRequest(cloudId)
} else {
if (!response.ok) {
let message = `Failed to update comment on Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
return {
success: true,
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
commentId: data?.id || params?.commentId || 'unknown',
body: params?.body || '',
success: true,
},
}
data = await response.json()
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to update comment on Jira issue (${response.status})`
try {
const err = await response.json()
message = err?.errorMessages?.join(', ') || err?.message || message
} catch (_e) {}
throw new Error(message)
}
const data = await response.json()
return {
success: true,
output: transformUpdateCommentResponse(data, params!),
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
commentId: data?.id || params?.commentId || 'unknown',
body: params?.body || '',
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
commentId: { type: 'string', description: 'Updated comment ID' },
body: { type: 'string', description: 'Updated comment text' },
author: {
type: 'object',
description: 'Comment author',
properties: USER_OUTPUT_PROPERTIES,
},
created: { type: 'string', description: 'ISO 8601 timestamp when the comment was created' },
updated: {
type: 'string',
description: 'ISO 8601 timestamp when the comment was last updated',
},
},
}

View File

@@ -1,51 +1,7 @@
import type { JiraUpdateWorklogParams, JiraUpdateWorklogResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT, USER_OUTPUT_PROPERTIES } from '@/tools/jira/types'
import { extractAdfText, getJiraCloudId, transformUser } from '@/tools/jira/utils'
import { getJiraCloudId } from '@/tools/jira/utils'
import type { ToolConfig } from '@/tools/types'
function buildWorklogBody(params: JiraUpdateWorklogParams) {
const body: Record<string, any> = {
timeSpentSeconds: params.timeSpentSeconds ? Number(params.timeSpentSeconds) : undefined,
comment: params.comment
? {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params.comment,
},
],
},
],
}
: undefined,
started: params.started ? params.started.replace(/Z$/, '+0000') : undefined,
}
if (params.visibility) body.visibility = params.visibility
return body
}
function transformWorklogResponse(data: any, params: JiraUpdateWorklogParams) {
return {
ts: new Date().toISOString(),
issueKey: params.issueKey || 'unknown',
worklogId: data?.id || params.worklogId || 'unknown',
timeSpent: data?.timeSpent ?? null,
timeSpentSeconds: data?.timeSpentSeconds ?? null,
comment: data?.comment ? extractAdfText(data.comment) : null,
author: data?.author ? transformUser(data.author) : null,
updateAuthor: data?.updateAuthor ? transformUser(data.updateAuthor) : null,
started: data?.started || null,
created: data?.created || null,
updated: data?.updated || null,
success: true,
}
}
export const jiraUpdateWorklogTool: ToolConfig<JiraUpdateWorklogParams, JiraUpdateWorklogResponse> =
{
id: 'jira_update_worklog',
@@ -101,13 +57,6 @@ export const jiraUpdateWorklogTool: ToolConfig<JiraUpdateWorklogParams, JiraUpda
visibility: 'user-or-llm',
description: 'Optional start time in ISO format',
},
visibility: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description:
'Restrict worklog visibility. Object with "type" ("role" or "group") and "value" (role/group name).',
},
cloudId: {
type: 'string',
required: false,
@@ -134,22 +83,63 @@ export const jiraUpdateWorklogTool: ToolConfig<JiraUpdateWorklogParams, JiraUpda
},
body: (params: JiraUpdateWorklogParams) => {
if (!params.cloudId) return undefined as any
return buildWorklogBody(params)
return {
timeSpentSeconds: Number(params.timeSpentSeconds),
comment: params.comment
? {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params.comment,
},
],
},
],
}
: undefined,
started: params.started,
}
},
},
transformResponse: async (response: Response, params?: JiraUpdateWorklogParams) => {
if (!params?.cloudId) {
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
const worklogUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params!.issueKey}/worklog/${params!.worklogId}`
// Make the actual request with the resolved cloudId
const worklogUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${params?.issueKey}/worklog/${params?.worklogId}`
const worklogResponse = await fetch(worklogUrl, {
method: 'PUT',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${params!.accessToken}`,
Authorization: `Bearer ${params?.accessToken}`,
},
body: JSON.stringify(buildWorklogBody(params!)),
body: JSON.stringify({
timeSpentSeconds: params?.timeSpentSeconds ? Number(params.timeSpentSeconds) : 0,
comment: params?.comment
? {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: params.comment,
},
],
},
],
}
: undefined,
started: params?.started,
}),
})
if (!worklogResponse.ok) {
@@ -162,12 +152,19 @@ export const jiraUpdateWorklogTool: ToolConfig<JiraUpdateWorklogParams, JiraUpda
}
const data = await worklogResponse.json()
return {
success: true,
output: transformWorklogResponse(data, params!),
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
worklogId: data?.id || params?.worklogId || 'unknown',
success: true,
},
}
}
// If cloudId was provided, process the response
if (!response.ok) {
let message = `Failed to update worklog on Jira issue (${response.status})`
try {
@@ -178,31 +175,21 @@ export const jiraUpdateWorklogTool: ToolConfig<JiraUpdateWorklogParams, JiraUpda
}
const data = await response.json()
return {
success: true,
output: transformWorklogResponse(data, params!),
output: {
ts: new Date().toISOString(),
issueKey: params?.issueKey || 'unknown',
worklogId: data?.id || params?.worklogId || 'unknown',
success: true,
},
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Issue key' },
worklogId: { type: 'string', description: 'Updated worklog ID' },
timeSpent: { type: 'string', description: 'Human-readable time spent (e.g., "3h 20m")' },
timeSpentSeconds: { type: 'number', description: 'Time spent in seconds' },
comment: { type: 'string', description: 'Worklog comment text' },
author: {
type: 'object',
description: 'Worklog author',
properties: USER_OUTPUT_PROPERTIES,
},
updateAuthor: {
type: 'object',
description: 'User who last updated the worklog',
properties: USER_OUTPUT_PROPERTIES,
},
started: { type: 'string', description: 'Worklog start time in ISO format' },
created: { type: 'string', description: 'Worklog creation time' },
updated: { type: 'string', description: 'Worklog last update time' },
},
}

View File

@@ -1,43 +1,3 @@
/**
* Extracts plain text from Atlassian Document Format (ADF) content.
* Returns null if content is falsy.
*/
export function extractAdfText(content: any): string | null {
if (!content) return null
if (typeof content === 'string') return content
if (Array.isArray(content)) {
return content.map(extractAdfText).filter(Boolean).join(' ')
}
if (content.type === 'text') return content.text || ''
if (content.content) return extractAdfText(content.content)
return ''
}
/**
* Transforms a raw Jira API user object into a typed user output.
* Returns null if user data is falsy.
*/
export function transformUser(user: any): {
accountId: string
displayName: string
active?: boolean
emailAddress?: string
avatarUrl?: string
accountType?: string
timeZone?: string
} | null {
if (!user) return null
return {
accountId: user.accountId ?? '',
displayName: user.displayName ?? '',
active: user.active ?? null,
emailAddress: user.emailAddress ?? null,
avatarUrl: user.avatarUrls?.['48x48'] ?? null,
accountType: user.accountType ?? null,
timeZone: user.timeZone ?? null,
}
}
export async function getJiraCloudId(domain: string, accessToken: string): Promise<string> {
const response = await fetch('https://api.atlassian.com/oauth/token/accessible-resources', {
method: 'GET',

View File

@@ -1,11 +1,10 @@
import type { JiraWriteParams, JiraWriteResponse } from '@/tools/jira/types'
import { TIMESTAMP_OUTPUT } from '@/tools/jira/types'
import type { ToolConfig } from '@/tools/types'
export const jiraWriteTool: ToolConfig<JiraWriteParams, JiraWriteResponse> = {
id: 'jira_write',
name: 'Jira Write',
description: 'Create a new Jira issue',
description: 'Write a Jira issue',
version: '1.0.0',
oauth: {
@@ -66,14 +65,8 @@ export const jiraWriteTool: ToolConfig<JiraWriteParams, JiraWriteResponse> = {
issueType: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Type of issue to create (e.g., Task, Story, Bug, Epic, Sub-task)',
},
parent: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description: 'Parent issue key for creating subtasks (e.g., { "key": "PROJ-123" })',
visibility: 'hidden',
description: 'Type of issue to create (e.g., Task, Story)',
},
labels: {
type: 'array',
@@ -81,24 +74,12 @@ export const jiraWriteTool: ToolConfig<JiraWriteParams, JiraWriteResponse> = {
visibility: 'user-or-llm',
description: 'Labels for the issue (array of label names)',
},
components: {
type: 'array',
required: false,
visibility: 'user-or-llm',
description: 'Components for the issue (array of component names)',
},
duedate: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Due date for the issue (format: YYYY-MM-DD)',
},
fixVersions: {
type: 'array',
required: false,
visibility: 'user-or-llm',
description: 'Fix versions for the issue (array of version names)',
},
reporter: {
type: 'string',
required: false,
@@ -132,6 +113,7 @@ export const jiraWriteTool: ToolConfig<JiraWriteParams, JiraWriteResponse> = {
'Content-Type': 'application/json',
}),
body: (params) => {
// Pass all parameters to the internal API route
return {
domain: params.domain,
accessToken: params.accessToken,
@@ -144,9 +126,7 @@ export const jiraWriteTool: ToolConfig<JiraWriteParams, JiraWriteResponse> = {
issueType: params.issueType,
parent: params.parent,
labels: params.labels,
components: params.components,
duedate: params.duedate,
fixVersions: params.fixVersions,
reporter: params.reporter,
environment: params.environment,
customFieldId: params.customFieldId,
@@ -163,62 +143,39 @@ export const jiraWriteTool: ToolConfig<JiraWriteParams, JiraWriteResponse> = {
success: true,
output: {
ts: new Date().toISOString(),
id: '',
issueKey: 'unknown',
self: '',
summary: 'Issue created successfully',
success: true,
url: '',
assigneeId: null,
},
}
}
const data = JSON.parse(responseText)
// The internal API route already returns the correct format
if (data.success && data.output) {
return {
success: data.success,
output: {
ts: data.output.ts ?? new Date().toISOString(),
id: data.output.id ?? '',
issueKey: data.output.issueKey ?? 'unknown',
self: data.output.self ?? '',
summary: data.output.summary ?? '',
success: data.output.success ?? true,
url: data.output.url ?? '',
assigneeId: data.output.assigneeId ?? null,
},
}
return data
}
// Fallback for unexpected response format
return {
success: data.success || false,
output: {
output: data.output || {
ts: new Date().toISOString(),
id: data.output?.id ?? '',
issueKey: data.output?.issueKey ?? 'unknown',
self: data.output?.self ?? '',
summary: data.output?.summary ?? 'Issue created',
issueKey: 'unknown',
summary: 'Issue created',
success: false,
url: data.output?.url ?? '',
assigneeId: data.output?.assigneeId ?? null,
},
error: data.error,
}
},
outputs: {
ts: TIMESTAMP_OUTPUT,
id: { type: 'string', description: 'Created issue ID' },
ts: { type: 'string', description: 'Timestamp of the operation' },
issueKey: { type: 'string', description: 'Created issue key (e.g., PROJ-123)' },
self: { type: 'string', description: 'REST API URL for the created issue' },
summary: { type: 'string', description: 'Issue summary' },
url: { type: 'string', description: 'URL to the created issue in Jira' },
assigneeId: {
type: 'string',
description: 'Account ID of the assigned user (null if no assignee was set)',
optional: true,
},
url: { type: 'string', description: 'URL to the created issue' },
assigneeId: { type: 'string', description: 'Account ID of the assigned user (if assigned)' },
},
}

View File

@@ -1,5 +1,4 @@
import type { JsmAddCommentParams, JsmAddCommentResponse } from '@/tools/jsm/types'
import { USER_OUTPUT_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmAddCommentTool: ToolConfig<JsmAddCommentParams, JsmAddCommentResponse> = {
@@ -80,8 +79,6 @@ export const jsmAddCommentTool: ToolConfig<JsmAddCommentParams, JsmAddCommentRes
commentId: '',
body: '',
isPublic: false,
author: null,
createdDate: null,
success: false,
},
error: 'Empty response from API',
@@ -102,8 +99,6 @@ export const jsmAddCommentTool: ToolConfig<JsmAddCommentParams, JsmAddCommentRes
commentId: '',
body: '',
isPublic: false,
author: null,
createdDate: null,
success: false,
},
error: data.error,
@@ -116,17 +111,6 @@ export const jsmAddCommentTool: ToolConfig<JsmAddCommentParams, JsmAddCommentRes
commentId: { type: 'string', description: 'Created comment ID' },
body: { type: 'string', description: 'Comment body text' },
isPublic: { type: 'boolean', description: 'Whether the comment is public' },
author: {
type: 'object',
description: 'Comment author',
properties: USER_OUTPUT_PROPERTIES,
optional: true,
},
createdDate: {
type: 'json',
description: 'Comment creation date with iso8601, friendly, epochMillis',
optional: true,
},
success: { type: 'boolean', description: 'Whether the comment was added successfully' },
},
}

View File

@@ -37,15 +37,9 @@ export const jsmAddCustomerTool: ToolConfig<JsmAddCustomerParams, JsmAddCustomer
visibility: 'user-or-llm',
description: 'Service Desk ID (e.g., "1", "2")',
},
accountIds: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Comma-separated Atlassian account IDs to add as customers',
},
emails: {
type: 'string',
required: false,
required: true,
visibility: 'user-or-llm',
description: 'Comma-separated email addresses to add as customers',
},
@@ -62,7 +56,6 @@ export const jsmAddCustomerTool: ToolConfig<JsmAddCustomerParams, JsmAddCustomer
accessToken: params.accessToken,
cloudId: params.cloudId,
serviceDeskId: params.serviceDeskId,
accountIds: params.accountIds,
emails: params.emails,
}),
},

View File

@@ -1,5 +1,4 @@
import type { JsmAddParticipantsParams, JsmAddParticipantsResponse } from '@/tools/jsm/types'
import { PARTICIPANT_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmAddParticipantsTool: ToolConfig<
@@ -102,14 +101,7 @@ export const jsmAddParticipantsTool: ToolConfig<
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
issueIdOrKey: { type: 'string', description: 'Issue ID or key' },
participants: {
type: 'array',
description: 'List of added participants',
items: {
type: 'object',
properties: PARTICIPANT_ITEM_PROPERTIES,
},
},
participants: { type: 'json', description: 'Array of added participants' },
success: { type: 'boolean', description: 'Whether the operation succeeded' },
},
}

View File

@@ -80,8 +80,6 @@ export const jsmAnswerApprovalTool: ToolConfig<JsmAnswerApprovalParams, JsmAnswe
issueIdOrKey: '',
approvalId: '',
decision: '',
finalDecision: null,
approvers: null,
success: false,
},
error: 'Empty response from API',
@@ -101,8 +99,6 @@ export const jsmAnswerApprovalTool: ToolConfig<JsmAnswerApprovalParams, JsmAnswe
issueIdOrKey: '',
approvalId: '',
decision: '',
finalDecision: null,
approvers: null,
success: false,
},
error: data.error,
@@ -114,50 +110,6 @@ export const jsmAnswerApprovalTool: ToolConfig<JsmAnswerApprovalParams, JsmAnswe
issueIdOrKey: { type: 'string', description: 'Issue ID or key' },
approvalId: { type: 'string', description: 'Approval ID' },
decision: { type: 'string', description: 'Decision made (approve/decline)' },
id: { type: 'string', description: 'Approval ID from response', optional: true },
name: { type: 'string', description: 'Approval description', optional: true },
finalDecision: {
type: 'string',
description: 'Final approval decision: pending, approved, or declined',
optional: true,
},
canAnswerApproval: {
type: 'boolean',
description: 'Whether the current user can still respond',
optional: true,
},
approvers: {
type: 'array',
description: 'Updated list of approvers with decisions',
items: {
type: 'object',
properties: {
approver: {
type: 'object',
description: 'Approver user details',
properties: {
accountId: { type: 'string', description: 'Approver account ID' },
displayName: { type: 'string', description: 'Approver display name' },
emailAddress: { type: 'string', description: 'Approver email', optional: true },
active: {
type: 'boolean',
description: 'Whether the account is active',
optional: true,
},
},
},
approverDecision: { type: 'string', description: 'Individual approver decision' },
},
},
optional: true,
},
createdDate: { type: 'json', description: 'Approval creation date', optional: true },
completedDate: { type: 'json', description: 'Approval completion date', optional: true },
approval: {
type: 'json',
description: 'The approval object',
optional: true,
},
success: { type: 'boolean', description: 'Whether the operation succeeded' },
},
}

View File

@@ -61,25 +61,6 @@ export const jsmCreateRequestTool: ToolConfig<JsmCreateRequestParams, JsmCreateR
visibility: 'user-or-llm',
description: 'Account ID of customer to raise request on behalf of',
},
requestFieldValues: {
type: 'json',
required: false,
visibility: 'user-or-llm',
description:
'Custom field values as key-value pairs (overrides summary/description if provided)',
},
requestParticipants: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Comma-separated account IDs to add as request participants',
},
channel: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Channel the request originates from (e.g., portal, email)',
},
},
request: {
@@ -98,8 +79,6 @@ export const jsmCreateRequestTool: ToolConfig<JsmCreateRequestParams, JsmCreateR
description: params.description,
raiseOnBehalfOf: params.raiseOnBehalfOf,
requestFieldValues: params.requestFieldValues,
requestParticipants: params.requestParticipants,
channel: params.channel,
}),
},
@@ -115,9 +94,6 @@ export const jsmCreateRequestTool: ToolConfig<JsmCreateRequestParams, JsmCreateR
issueKey: '',
requestTypeId: '',
serviceDeskId: '',
createdDate: null,
currentStatus: null,
reporter: null,
success: false,
url: '',
},
@@ -139,9 +115,6 @@ export const jsmCreateRequestTool: ToolConfig<JsmCreateRequestParams, JsmCreateR
issueKey: '',
requestTypeId: '',
serviceDeskId: '',
createdDate: null,
currentStatus: null,
reporter: null,
success: false,
url: '',
},
@@ -155,21 +128,6 @@ export const jsmCreateRequestTool: ToolConfig<JsmCreateRequestParams, JsmCreateR
issueKey: { type: 'string', description: 'Created request issue key (e.g., SD-123)' },
requestTypeId: { type: 'string', description: 'Request type ID' },
serviceDeskId: { type: 'string', description: 'Service desk ID' },
createdDate: {
type: 'json',
description: 'Creation date with iso8601, friendly, epochMillis',
optional: true,
},
currentStatus: {
type: 'json',
description: 'Current status with status name and category',
optional: true,
},
reporter: {
type: 'json',
description: 'Reporter user with accountId, displayName, emailAddress',
optional: true,
},
success: { type: 'boolean', description: 'Whether the request was created successfully' },
url: { type: 'string', description: 'URL to the created request' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetApprovalsParams, JsmGetApprovalsResponse } from '@/tools/jsm/types'
import { APPROVAL_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetApprovalsTool: ToolConfig<JsmGetApprovalsParams, JsmGetApprovalsResponse> = {
@@ -108,14 +107,7 @@ export const jsmGetApprovalsTool: ToolConfig<JsmGetApprovalsParams, JsmGetApprov
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
issueIdOrKey: { type: 'string', description: 'Issue ID or key' },
approvals: {
type: 'array',
description: 'List of approvals',
items: {
type: 'object',
properties: APPROVAL_ITEM_PROPERTIES,
},
},
approvals: { type: 'json', description: 'Array of approvals' },
total: { type: 'number', description: 'Total number of approvals' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetCommentsParams, JsmGetCommentsResponse } from '@/tools/jsm/types'
import { COMMENT_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetCommentsTool: ToolConfig<JsmGetCommentsParams, JsmGetCommentsResponse> = {
@@ -50,12 +49,6 @@ export const jsmGetCommentsTool: ToolConfig<JsmGetCommentsParams, JsmGetComments
visibility: 'user-or-llm',
description: 'Filter to only internal comments (true/false)',
},
expand: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Comma-separated fields to expand: renderedBody, attachment',
},
start: {
type: 'number',
required: false,
@@ -83,7 +76,6 @@ export const jsmGetCommentsTool: ToolConfig<JsmGetCommentsParams, JsmGetComments
issueIdOrKey: params.issueIdOrKey,
isPublic: params.isPublic,
internal: params.internal,
expand: params.expand,
start: params.start,
limit: params.limit,
}),
@@ -128,14 +120,7 @@ export const jsmGetCommentsTool: ToolConfig<JsmGetCommentsParams, JsmGetComments
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
issueIdOrKey: { type: 'string', description: 'Issue ID or key' },
comments: {
type: 'array',
description: 'List of comments',
items: {
type: 'object',
properties: COMMENT_ITEM_PROPERTIES,
},
},
comments: { type: 'json', description: 'Array of comments' },
total: { type: 'number', description: 'Total number of comments' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetCustomersParams, JsmGetCustomersResponse } from '@/tools/jsm/types'
import { CUSTOMER_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetCustomersTool: ToolConfig<JsmGetCustomersParams, JsmGetCustomersResponse> = {
@@ -111,14 +110,7 @@ export const jsmGetCustomersTool: ToolConfig<JsmGetCustomersParams, JsmGetCustom
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
customers: {
type: 'array',
description: 'List of customers',
items: {
type: 'object',
properties: CUSTOMER_ITEM_PROPERTIES,
},
},
customers: { type: 'json', description: 'Array of customers' },
total: { type: 'number', description: 'Total number of customers' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetOrganizationsParams, JsmGetOrganizationsResponse } from '@/tools/jsm/types'
import { ORGANIZATION_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetOrganizationsTool: ToolConfig<
@@ -107,14 +106,7 @@ export const jsmGetOrganizationsTool: ToolConfig<
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
organizations: {
type: 'array',
description: 'List of organizations',
items: {
type: 'object',
properties: ORGANIZATION_ITEM_PROPERTIES,
},
},
organizations: { type: 'json', description: 'Array of organizations' },
total: { type: 'number', description: 'Total number of organizations' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetParticipantsParams, JsmGetParticipantsResponse } from '@/tools/jsm/types'
import { PARTICIPANT_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetParticipantsTool: ToolConfig<
@@ -111,14 +110,7 @@ export const jsmGetParticipantsTool: ToolConfig<
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
issueIdOrKey: { type: 'string', description: 'Issue ID or key' },
participants: {
type: 'array',
description: 'List of participants',
items: {
type: 'object',
properties: PARTICIPANT_ITEM_PROPERTIES,
},
},
participants: { type: 'json', description: 'Array of participants' },
total: { type: 'number', description: 'Total number of participants' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetQueuesParams, JsmGetQueuesResponse } from '@/tools/jsm/types'
import { QUEUE_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetQueuesTool: ToolConfig<JsmGetQueuesParams, JsmGetQueuesResponse> = {
@@ -111,14 +110,7 @@ export const jsmGetQueuesTool: ToolConfig<JsmGetQueuesParams, JsmGetQueuesRespon
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
queues: {
type: 'array',
description: 'List of queues',
items: {
type: 'object',
properties: QUEUE_ITEM_PROPERTIES,
},
},
queues: { type: 'json', description: 'Array of queues' },
total: { type: 'number', description: 'Total number of queues' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,9 +1,4 @@
import type { JsmGetRequestParams, JsmGetRequestResponse } from '@/tools/jsm/types'
import {
REQUEST_FIELD_VALUE_PROPERTIES,
REQUEST_STATUS_PROPERTIES,
USER_OUTPUT_PROPERTIES,
} from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetRequestTool: ToolConfig<JsmGetRequestParams, JsmGetRequestResponse> = {
@@ -42,13 +37,6 @@ export const jsmGetRequestTool: ToolConfig<JsmGetRequestParams, JsmGetRequestRes
visibility: 'user-or-llm',
description: 'Issue ID or key (e.g., SD-123)',
},
expand: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Comma-separated fields to expand: participant, status, sla, requestType, serviceDesk, attachment, comment, action',
},
},
request: {
@@ -62,7 +50,6 @@ export const jsmGetRequestTool: ToolConfig<JsmGetRequestParams, JsmGetRequestRes
accessToken: params.accessToken,
cloudId: params.cloudId,
issueIdOrKey: params.issueIdOrKey,
expand: params.expand,
}),
},
@@ -74,15 +61,7 @@ export const jsmGetRequestTool: ToolConfig<JsmGetRequestParams, JsmGetRequestRes
success: false,
output: {
ts: new Date().toISOString(),
issueId: '',
issueKey: '',
requestTypeId: '',
serviceDeskId: '',
createdDate: null,
currentStatus: null,
reporter: null,
requestFieldValues: [],
url: '',
request: null,
},
error: 'Empty response from API',
}
@@ -98,15 +77,7 @@ export const jsmGetRequestTool: ToolConfig<JsmGetRequestParams, JsmGetRequestRes
success: data.success || false,
output: data.output || {
ts: new Date().toISOString(),
issueId: '',
issueKey: '',
requestTypeId: '',
serviceDeskId: '',
createdDate: null,
currentStatus: null,
reporter: null,
requestFieldValues: [],
url: '',
request: null,
},
error: data.error,
}
@@ -114,39 +85,6 @@ export const jsmGetRequestTool: ToolConfig<JsmGetRequestParams, JsmGetRequestRes
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
issueId: { type: 'string', description: 'Jira issue ID' },
issueKey: { type: 'string', description: 'Issue key (e.g., SD-123)' },
requestTypeId: { type: 'string', description: 'Request type ID' },
serviceDeskId: { type: 'string', description: 'Service desk ID' },
createdDate: {
type: 'json',
description: 'Creation date with iso8601, friendly, epochMillis',
optional: true,
},
currentStatus: {
type: 'object',
description: 'Current request status',
properties: REQUEST_STATUS_PROPERTIES,
optional: true,
},
reporter: {
type: 'object',
description: 'Reporter user details',
properties: USER_OUTPUT_PROPERTIES,
optional: true,
},
requestFieldValues: {
type: 'array',
description: 'Request field values',
items: {
type: 'object',
properties: REQUEST_FIELD_VALUE_PROPERTIES,
},
},
url: { type: 'string', description: 'URL to the request' },
request: {
type: 'json',
description: 'The service request object',
},
request: { type: 'json', description: 'The service request object' },
},
}

View File

@@ -1,130 +0,0 @@
import type {
JsmGetRequestTypeFieldsParams,
JsmGetRequestTypeFieldsResponse,
} from '@/tools/jsm/types'
import { REQUEST_TYPE_FIELD_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetRequestTypeFieldsTool: ToolConfig<
JsmGetRequestTypeFieldsParams,
JsmGetRequestTypeFieldsResponse
> = {
id: 'jsm_get_request_type_fields',
name: 'JSM Get Request Type Fields',
description:
'Get the fields required to create a request of a specific type in Jira Service Management',
version: '1.0.0',
oauth: {
required: true,
provider: 'jira',
},
params: {
accessToken: {
type: 'string',
required: true,
visibility: 'hidden',
description: 'OAuth access token for Jira Service Management',
},
domain: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Your Jira domain (e.g., yourcompany.atlassian.net)',
},
cloudId: {
type: 'string',
required: false,
visibility: 'hidden',
description: 'Jira Cloud ID for the instance',
},
serviceDeskId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Service Desk ID (e.g., "1", "2")',
},
requestTypeId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'Request Type ID (e.g., "10", "15")',
},
},
request: {
url: '/api/tools/jsm/requesttypefields',
method: 'POST',
headers: () => ({
'Content-Type': 'application/json',
}),
body: (params) => ({
domain: params.domain,
accessToken: params.accessToken,
cloudId: params.cloudId,
serviceDeskId: params.serviceDeskId,
requestTypeId: params.requestTypeId,
}),
},
transformResponse: async (response: Response) => {
const responseText = await response.text()
if (!responseText) {
return {
success: false,
output: {
ts: new Date().toISOString(),
serviceDeskId: '',
requestTypeId: '',
canAddRequestParticipants: false,
canRaiseOnBehalfOf: false,
requestTypeFields: [],
},
error: 'Empty response from API',
}
}
const data = JSON.parse(responseText)
if (data.success && data.output) {
return data
}
return {
success: data.success || false,
output: data.output || {
ts: new Date().toISOString(),
serviceDeskId: '',
requestTypeId: '',
canAddRequestParticipants: false,
canRaiseOnBehalfOf: false,
requestTypeFields: [],
},
error: data.error,
}
},
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
serviceDeskId: { type: 'string', description: 'Service desk ID' },
requestTypeId: { type: 'string', description: 'Request type ID' },
canAddRequestParticipants: {
type: 'boolean',
description: 'Whether participants can be added to requests of this type',
},
canRaiseOnBehalfOf: {
type: 'boolean',
description: 'Whether requests can be raised on behalf of another user',
},
requestTypeFields: {
type: 'array',
description: 'List of fields for this request type',
items: {
type: 'object',
properties: REQUEST_TYPE_FIELD_PROPERTIES,
},
},
},
}

View File

@@ -1,5 +1,4 @@
import type { JsmGetRequestTypesParams, JsmGetRequestTypesResponse } from '@/tools/jsm/types'
import { REQUEST_TYPE_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetRequestTypesTool: ToolConfig<
@@ -41,24 +40,6 @@ export const jsmGetRequestTypesTool: ToolConfig<
visibility: 'user-or-llm',
description: 'Service Desk ID (e.g., "1", "2")',
},
searchQuery: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Filter request types by name',
},
groupId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Filter by request type group ID',
},
expand: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Comma-separated fields to expand in the response',
},
start: {
type: 'number',
required: false,
@@ -84,9 +65,6 @@ export const jsmGetRequestTypesTool: ToolConfig<
accessToken: params.accessToken,
cloudId: params.cloudId,
serviceDeskId: params.serviceDeskId,
searchQuery: params.searchQuery,
groupId: params.groupId,
expand: params.expand,
start: params.start,
limit: params.limit,
}),
@@ -128,14 +106,7 @@ export const jsmGetRequestTypesTool: ToolConfig<
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
requestTypes: {
type: 'array',
description: 'List of request types',
items: {
type: 'object',
properties: REQUEST_TYPE_ITEM_PROPERTIES,
},
},
requestTypes: { type: 'json', description: 'Array of request types' },
total: { type: 'number', description: 'Total number of request types' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetRequestsParams, JsmGetRequestsResponse } from '@/tools/jsm/types'
import { REQUEST_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequestsResponse> = {
@@ -43,19 +42,13 @@ export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequests
required: false,
visibility: 'user-or-llm',
description:
'Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, APPROVER, ALL_REQUESTS',
'Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, ORGANIZATION, ALL_REQUESTS',
},
requestStatus: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Filter by status: OPEN_REQUESTS, CLOSED_REQUESTS, ALL_REQUESTS',
},
requestTypeId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Filter by request type ID',
description: 'Filter by status: OPEN, CLOSED, ALL',
},
searchTerm: {
type: 'string',
@@ -63,13 +56,6 @@ export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequests
visibility: 'user-or-llm',
description: 'Search term to filter requests (e.g., "password reset", "laptop")',
},
expand: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Comma-separated fields to expand: participant, status, sla, requestType, serviceDesk, attachment, comment, action',
},
start: {
type: 'number',
required: false,
@@ -97,9 +83,7 @@ export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequests
serviceDeskId: params.serviceDeskId,
requestOwnership: params.requestOwnership,
requestStatus: params.requestStatus,
requestTypeId: params.requestTypeId,
searchTerm: params.searchTerm,
expand: params.expand,
start: params.start,
limit: params.limit,
}),
@@ -141,15 +125,8 @@ export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequests
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
requests: {
type: 'array',
description: 'List of service requests',
items: {
type: 'object',
properties: REQUEST_ITEM_PROPERTIES,
},
},
total: { type: 'number', description: 'Total number of requests in current page' },
requests: { type: 'json', description: 'Array of service requests' },
total: { type: 'number', description: 'Total number of requests' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},
}

View File

@@ -1,5 +1,4 @@
import type { JsmGetServiceDesksParams, JsmGetServiceDesksResponse } from '@/tools/jsm/types'
import { SERVICE_DESK_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetServiceDesksTool: ToolConfig<
@@ -35,12 +34,6 @@ export const jsmGetServiceDesksTool: ToolConfig<
visibility: 'hidden',
description: 'Jira Cloud ID for the instance',
},
expand: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Comma-separated fields to expand in the response',
},
start: {
type: 'number',
required: false,
@@ -65,7 +58,6 @@ export const jsmGetServiceDesksTool: ToolConfig<
domain: params.domain,
accessToken: params.accessToken,
cloudId: params.cloudId,
expand: params.expand,
start: params.start,
limit: params.limit,
}),
@@ -107,14 +99,7 @@ export const jsmGetServiceDesksTool: ToolConfig<
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
serviceDesks: {
type: 'array',
description: 'List of service desks',
items: {
type: 'object',
properties: SERVICE_DESK_ITEM_PROPERTIES,
},
},
serviceDesks: { type: 'json', description: 'Array of service desks' },
total: { type: 'number', description: 'Total number of service desks' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetSlaParams, JsmGetSlaResponse } from '@/tools/jsm/types'
import { SLA_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetSlaTool: ToolConfig<JsmGetSlaParams, JsmGetSlaResponse> = {
@@ -107,14 +106,7 @@ export const jsmGetSlaTool: ToolConfig<JsmGetSlaParams, JsmGetSlaResponse> = {
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
issueIdOrKey: { type: 'string', description: 'Issue ID or key' },
slas: {
type: 'array',
description: 'List of SLA metrics',
items: {
type: 'object',
properties: SLA_ITEM_PROPERTIES,
},
},
slas: { type: 'json', description: 'Array of SLA information' },
total: { type: 'number', description: 'Total number of SLAs' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
},

View File

@@ -1,5 +1,4 @@
import type { JsmGetTransitionsParams, JsmGetTransitionsResponse } from '@/tools/jsm/types'
import { TRANSITION_ITEM_PROPERTIES } from '@/tools/jsm/types'
import type { ToolConfig } from '@/tools/types'
export const jsmGetTransitionsTool: ToolConfig<JsmGetTransitionsParams, JsmGetTransitionsResponse> =
@@ -39,18 +38,6 @@ export const jsmGetTransitionsTool: ToolConfig<JsmGetTransitionsParams, JsmGetTr
visibility: 'user-or-llm',
description: 'Issue ID or key (e.g., SD-123)',
},
start: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Start index for pagination (e.g., 0, 50, 100)',
},
limit: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Maximum results to return (e.g., 10, 25, 50)',
},
},
request: {
@@ -64,8 +51,6 @@ export const jsmGetTransitionsTool: ToolConfig<JsmGetTransitionsParams, JsmGetTr
accessToken: params.accessToken,
cloudId: params.cloudId,
issueIdOrKey: params.issueIdOrKey,
start: params.start,
limit: params.limit,
}),
},
@@ -79,8 +64,6 @@ export const jsmGetTransitionsTool: ToolConfig<JsmGetTransitionsParams, JsmGetTr
ts: new Date().toISOString(),
issueIdOrKey: '',
transitions: [],
total: 0,
isLastPage: true,
},
error: 'Empty response from API',
}
@@ -98,8 +81,6 @@ export const jsmGetTransitionsTool: ToolConfig<JsmGetTransitionsParams, JsmGetTr
ts: new Date().toISOString(),
issueIdOrKey: '',
transitions: [],
total: 0,
isLastPage: true,
},
error: data.error,
}
@@ -108,15 +89,6 @@ export const jsmGetTransitionsTool: ToolConfig<JsmGetTransitionsParams, JsmGetTr
outputs: {
ts: { type: 'string', description: 'Timestamp of the operation' },
issueIdOrKey: { type: 'string', description: 'Issue ID or key' },
transitions: {
type: 'array',
description: 'List of available transitions',
items: {
type: 'object',
properties: TRANSITION_ITEM_PROPERTIES,
},
},
total: { type: 'number', description: 'Total number of transitions' },
isLastPage: { type: 'boolean', description: 'Whether this is the last page' },
transitions: { type: 'json', description: 'Array of available transitions' },
},
}

View File

@@ -12,7 +12,6 @@ import { jsmGetOrganizationsTool } from '@/tools/jsm/get_organizations'
import { jsmGetParticipantsTool } from '@/tools/jsm/get_participants'
import { jsmGetQueuesTool } from '@/tools/jsm/get_queues'
import { jsmGetRequestTool } from '@/tools/jsm/get_request'
import { jsmGetRequestTypeFieldsTool } from '@/tools/jsm/get_request_type_fields'
import { jsmGetRequestTypesTool } from '@/tools/jsm/get_request_types'
import { jsmGetRequestsTool } from '@/tools/jsm/get_requests'
import { jsmGetServiceDesksTool } from '@/tools/jsm/get_service_desks'
@@ -35,7 +34,6 @@ export {
jsmGetParticipantsTool,
jsmGetQueuesTool,
jsmGetRequestTool,
jsmGetRequestTypeFieldsTool,
jsmGetRequestsTool,
jsmGetRequestTypesTool,
jsmGetServiceDesksTool,

View File

@@ -1,231 +1,5 @@
import type { ToolResponse } from '@/tools/types'
// ---------------------------------------------------------------------------
// Shared output property constants for JSM tools (following Confluence pattern)
// ---------------------------------------------------------------------------
/** Reusable date output properties with ISO 8601, friendly, and epoch formats */
export const DATE_OUTPUT_PROPERTIES = {
iso8601: { type: 'string', description: 'ISO 8601 formatted date' },
friendly: { type: 'string', description: 'Human-readable date' },
epochMillis: { type: 'number', description: 'Unix epoch milliseconds' },
} as const
/** Reusable user output properties */
export const USER_OUTPUT_PROPERTIES = {
accountId: { type: 'string', description: 'Atlassian account ID' },
displayName: { type: 'string', description: 'User display name' },
emailAddress: { type: 'string', description: 'User email address', optional: true },
active: { type: 'boolean', description: 'Whether the account is active' },
} as const
/** Output properties for a service desk item */
export const SERVICE_DESK_ITEM_PROPERTIES = {
id: { type: 'string', description: 'Service desk ID' },
projectId: { type: 'string', description: 'Associated Jira project ID' },
projectName: { type: 'string', description: 'Associated project name' },
projectKey: { type: 'string', description: 'Associated project key' },
name: { type: 'string', description: 'Service desk name' },
description: { type: 'string', description: 'Service desk description', optional: true },
leadDisplayName: { type: 'string', description: 'Project lead display name', optional: true },
} as const
/** Output properties for a request type item */
export const REQUEST_TYPE_ITEM_PROPERTIES = {
id: { type: 'string', description: 'Request type ID' },
name: { type: 'string', description: 'Request type name' },
description: { type: 'string', description: 'Request type description' },
helpText: { type: 'string', description: 'Help text for customers', optional: true },
issueTypeId: { type: 'string', description: 'Associated Jira issue type ID' },
serviceDeskId: { type: 'string', description: 'Parent service desk ID' },
groupIds: { type: 'json', description: 'Groups this request type belongs to' },
icon: { type: 'json', description: 'Request type icon with id and links', optional: true },
restrictionStatus: { type: 'string', description: 'OPEN or RESTRICTED', optional: true },
} as const
/** Output properties for a request field value */
export const REQUEST_FIELD_VALUE_PROPERTIES = {
fieldId: { type: 'string', description: 'Field identifier' },
label: { type: 'string', description: 'Human-readable field label' },
value: { type: 'json', description: 'Field value' },
renderedValue: { type: 'json', description: 'HTML-rendered field value', optional: true },
} as const
/** Output properties for a request status */
export const REQUEST_STATUS_PROPERTIES = {
status: { type: 'string', description: 'Status name' },
statusCategory: { type: 'string', description: 'Status category (NEW, INDETERMINATE, DONE)' },
statusDate: {
type: 'json',
description: 'Status change date with iso8601, friendly, epochMillis',
},
} as const
/** Output properties for a request (ticket) item */
export const REQUEST_ITEM_PROPERTIES = {
issueId: { type: 'string', description: 'Jira issue ID' },
issueKey: { type: 'string', description: 'Issue key (e.g., SD-123)' },
requestTypeId: { type: 'string', description: 'Request type ID' },
serviceDeskId: { type: 'string', description: 'Service desk ID' },
createdDate: {
type: 'json',
description: 'Creation date with iso8601, friendly, epochMillis',
},
currentStatus: {
type: 'object',
description: 'Current request status',
properties: REQUEST_STATUS_PROPERTIES,
},
reporter: {
type: 'object',
description: 'Reporter user details',
properties: USER_OUTPUT_PROPERTIES,
},
requestFieldValues: {
type: 'array',
description: 'Request field values',
items: {
type: 'object',
properties: REQUEST_FIELD_VALUE_PROPERTIES,
},
},
} as const
/** Output properties for a comment item */
export const COMMENT_ITEM_PROPERTIES = {
id: { type: 'string', description: 'Comment ID' },
body: { type: 'string', description: 'Comment body text' },
public: { type: 'boolean', description: 'Whether the comment is public' },
author: {
type: 'object',
description: 'Comment author',
properties: USER_OUTPUT_PROPERTIES,
},
created: {
type: 'json',
description: 'Creation date with iso8601, friendly, epochMillis',
},
renderedBody: {
type: 'json',
description: 'HTML-rendered comment body (when expand=renderedBody)',
optional: true,
},
} as const
/** Output properties for a queue item */
export const QUEUE_ITEM_PROPERTIES = {
id: { type: 'string', description: 'Queue ID' },
name: { type: 'string', description: 'Queue name' },
jql: { type: 'string', description: 'JQL filter for the queue' },
fields: { type: 'json', description: 'Fields displayed in the queue' },
issueCount: { type: 'number', description: 'Number of issues in the queue' },
} as const
/** Output properties for an SLA item */
export const SLA_ITEM_PROPERTIES = {
id: { type: 'string', description: 'SLA metric ID' },
name: { type: 'string', description: 'SLA metric name' },
completedCycles: {
type: 'json',
description:
'Completed SLA cycles with startTime, stopTime, breachTime, breached, goalDuration, elapsedTime, remainingTime (each time as DateDTO, durations as DurationDTO)',
},
ongoingCycle: {
type: 'json',
description:
'Ongoing SLA cycle with startTime, breachTime, breached, paused, withinCalendarHours, goalDuration, elapsedTime, remainingTime',
optional: true,
},
} as const
/** Output properties for a transition item */
export const TRANSITION_ITEM_PROPERTIES = {
id: { type: 'string', description: 'Transition ID' },
name: { type: 'string', description: 'Transition name' },
} as const
/** Output properties for a participant item */
export const PARTICIPANT_ITEM_PROPERTIES = {
accountId: { type: 'string', description: 'Atlassian account ID' },
displayName: { type: 'string', description: 'Display name' },
emailAddress: { type: 'string', description: 'Email address', optional: true },
active: { type: 'boolean', description: 'Whether the account is active' },
} as const
/** Output properties for an organization item */
export const ORGANIZATION_ITEM_PROPERTIES = {
id: { type: 'string', description: 'Organization ID' },
name: { type: 'string', description: 'Organization name' },
} as const
/** Output properties for a customer item */
export const CUSTOMER_ITEM_PROPERTIES = {
accountId: { type: 'string', description: 'Atlassian account ID' },
displayName: { type: 'string', description: 'Display name' },
emailAddress: { type: 'string', description: 'Email address' },
active: { type: 'boolean', description: 'Whether the account is active' },
timeZone: { type: 'string', description: 'User timezone', optional: true },
} as const
/** Output properties for an approver item */
export const APPROVER_ITEM_PROPERTIES = {
approver: {
type: 'object',
description: 'Approver user details',
properties: USER_OUTPUT_PROPERTIES,
},
approverDecision: { type: 'string', description: 'Decision: pending, approved, or declined' },
} as const
/** Output properties for an approval item */
export const APPROVAL_ITEM_PROPERTIES = {
id: { type: 'string', description: 'Approval ID' },
name: { type: 'string', description: 'Approval description' },
finalDecision: { type: 'string', description: 'Final decision: pending, approved, or declined' },
canAnswerApproval: { type: 'boolean', description: 'Whether current user can respond' },
approvers: {
type: 'array',
description: 'List of approvers with their decisions',
items: {
type: 'object',
properties: APPROVER_ITEM_PROPERTIES,
},
},
createdDate: {
type: 'json',
description: 'Creation date',
optional: true,
},
completedDate: {
type: 'json',
description: 'Completion date',
optional: true,
},
} as const
/** Output properties for a request type field */
export const REQUEST_TYPE_FIELD_PROPERTIES = {
fieldId: {
type: 'string',
description: 'Field identifier (e.g., summary, description, customfield_10010)',
},
name: { type: 'string', description: 'Human-readable field name' },
description: { type: 'string', description: 'Help text for the field', optional: true },
required: { type: 'boolean', description: 'Whether the field is required' },
visible: { type: 'boolean', description: 'Whether the field is visible' },
validValues: { type: 'json', description: 'Allowed values for select fields' },
presetValues: { type: 'json', description: 'Pre-populated values', optional: true },
defaultValues: { type: 'json', description: 'Default values for the field', optional: true },
jiraSchema: {
type: 'json',
description: 'Jira field schema with type, system, custom, customId',
},
} as const
// ---------------------------------------------------------------------------
// Data model interfaces
// ---------------------------------------------------------------------------
/** Common parameters for all JSM API calls */
export interface JsmBaseParams {
accessToken: string
@@ -239,9 +13,6 @@ export interface JsmServiceDesk {
projectId: string
projectName: string
projectKey: string
name: string
description?: string
leadDisplayName?: string
}
/** Request Type representation */
@@ -250,7 +21,6 @@ export interface JsmRequestType {
name: string
description: string
helpText?: string
issueTypeId?: string
serviceDeskId: string
groupIds: string[]
icon: {
@@ -290,13 +60,9 @@ export interface JsmSla {
id: string
name: string
completedCycles: Array<{
startTime: { iso8601: string; friendly: string; epochMillis: number }
stopTime: { iso8601: string; friendly: string; epochMillis: number }
breachTime?: { iso8601: string; friendly: string; epochMillis: number }
startTime: { iso8601: string }
stopTime: { iso8601: string }
breached: boolean
goalDuration?: { millis: number; friendly: string }
elapsedTime?: { millis: number; friendly: string }
remainingTime?: { millis: number; friendly: string }
}>
ongoingCycle?: {
startTime: { iso8601: string }
@@ -349,192 +115,11 @@ export interface JsmTransition {
name: string
}
/** Participant representation */
export interface JsmParticipant {
accountId: string
displayName: string
emailAddress?: string
active: boolean
}
/** Approver representation */
export interface JsmApprover {
accountId: string
displayName: string
emailAddress?: string
approverDecision: 'pending' | 'approved' | 'declined'
}
/** Approval representation */
export interface JsmApproval {
id: string
name: string
finalDecision: 'pending' | 'approved' | 'declined'
canAnswerApproval: boolean
approvers: JsmApprover[]
createdDate?: { iso8601: string; friendly: string }
completedDate?: { iso8601: string; friendly: string }
}
/** Request type field representation */
export interface JsmRequestTypeField {
fieldId: string
name: string
description?: string
required: boolean
visible?: boolean
validValues: Array<{ value: string; label: string; children?: unknown[] }>
presetValues?: unknown[]
defaultValues?: unknown[]
jiraSchema: { type: string; system?: string; custom?: string; customId?: number }
}
// ---------------------------------------------------------------------------
// Params interfaces
// ---------------------------------------------------------------------------
export interface JsmGetServiceDesksParams extends JsmBaseParams {
expand?: string
start?: number
limit?: number
}
export interface JsmGetRequestTypesParams extends JsmBaseParams {
serviceDeskId: string
searchQuery?: string
groupId?: string
expand?: string
start?: number
limit?: number
}
export interface JsmCreateRequestParams extends JsmBaseParams {
serviceDeskId: string
requestTypeId: string
summary: string
description?: string
requestFieldValues?: Record<string, unknown>
raiseOnBehalfOf?: string
requestParticipants?: string[]
channel?: string
}
export interface JsmGetRequestParams extends JsmBaseParams {
issueIdOrKey: string
expand?: string
}
export interface JsmGetRequestsParams extends JsmBaseParams {
serviceDeskId?: string
requestOwnership?: 'OWNED_REQUESTS' | 'PARTICIPATED_REQUESTS' | 'APPROVER' | 'ALL_REQUESTS'
requestStatus?: 'OPEN_REQUESTS' | 'CLOSED_REQUESTS' | 'ALL_REQUESTS'
requestTypeId?: string
searchTerm?: string
expand?: string
start?: number
limit?: number
}
export interface JsmAddCommentParams extends JsmBaseParams {
issueIdOrKey: string
body: string
isPublic: boolean
}
export interface JsmGetCommentsParams extends JsmBaseParams {
issueIdOrKey: string
isPublic?: boolean
internal?: boolean
expand?: string
start?: number
limit?: number
}
export interface JsmGetCustomersParams extends JsmBaseParams {
serviceDeskId: string
query?: string
start?: number
limit?: number
}
export interface JsmAddCustomerParams extends JsmBaseParams {
serviceDeskId: string
accountIds?: string
emails?: string
}
export interface JsmGetOrganizationsParams extends JsmBaseParams {
serviceDeskId: string
start?: number
limit?: number
}
export interface JsmGetQueuesParams extends JsmBaseParams {
serviceDeskId: string
includeCount?: boolean
start?: number
limit?: number
}
export interface JsmGetSlaParams extends JsmBaseParams {
issueIdOrKey: string
start?: number
limit?: number
}
export interface JsmTransitionRequestParams extends JsmBaseParams {
issueIdOrKey: string
transitionId: string
comment?: string
}
export interface JsmGetTransitionsParams extends JsmBaseParams {
issueIdOrKey: string
start?: number
limit?: number
}
export interface JsmCreateOrganizationParams extends JsmBaseParams {
name: string
}
export interface JsmAddOrganizationParams extends JsmBaseParams {
serviceDeskId: string
organizationId: string
}
export interface JsmGetParticipantsParams extends JsmBaseParams {
issueIdOrKey: string
start?: number
limit?: number
}
export interface JsmAddParticipantsParams extends JsmBaseParams {
issueIdOrKey: string
accountIds: string
}
export interface JsmGetApprovalsParams extends JsmBaseParams {
issueIdOrKey: string
start?: number
limit?: number
}
export interface JsmAnswerApprovalParams extends JsmBaseParams {
issueIdOrKey: string
approvalId: string
decision: 'approve' | 'decline'
}
export interface JsmGetRequestTypeFieldsParams extends JsmBaseParams {
serviceDeskId: string
requestTypeId: string
}
// ---------------------------------------------------------------------------
// Response interfaces
// ---------------------------------------------------------------------------
export interface JsmGetServiceDesksResponse extends ToolResponse {
output: {
ts: string
@@ -544,6 +129,12 @@ export interface JsmGetServiceDesksResponse extends ToolResponse {
}
}
export interface JsmGetRequestTypesParams extends JsmBaseParams {
serviceDeskId: string
start?: number
limit?: number
}
export interface JsmGetRequestTypesResponse extends ToolResponse {
output: {
ts: string
@@ -553,6 +144,15 @@ export interface JsmGetRequestTypesResponse extends ToolResponse {
}
}
export interface JsmCreateRequestParams extends JsmBaseParams {
serviceDeskId: string
requestTypeId: string
summary: string
description?: string
requestFieldValues?: Record<string, unknown>
raiseOnBehalfOf?: string
}
export interface JsmCreateRequestResponse extends ToolResponse {
output: {
ts: string
@@ -560,43 +160,31 @@ export interface JsmCreateRequestResponse extends ToolResponse {
issueKey: string
requestTypeId: string
serviceDeskId: string
createdDate: { iso8601: string; friendly: string; epochMillis: number } | null
currentStatus: {
status: string
statusCategory: string
statusDate?: { iso8601: string; friendly: string }
} | null
reporter: { accountId: string; displayName: string; emailAddress?: string } | null
success: boolean
url: string
}
}
export interface JsmGetRequestParams extends JsmBaseParams {
issueIdOrKey: string
}
export interface JsmGetRequestResponse extends ToolResponse {
output: {
ts: string
issueId: string
issueKey: string
requestTypeId: string
serviceDeskId: string
createdDate: { iso8601: string; friendly: string; epochMillis: number } | null
currentStatus: {
status: string
statusCategory: string
statusDate: { iso8601: string; friendly: string }
} | null
reporter: {
accountId: string
displayName: string
emailAddress?: string
active: boolean
} | null
requestFieldValues: Array<{ fieldId: string; label: string; value: unknown }>
url: string
request?: Record<string, unknown>
request: JsmRequest
}
}
export interface JsmGetRequestsParams extends JsmBaseParams {
serviceDeskId?: string
requestOwnership?: 'OWNED_REQUESTS' | 'PARTICIPATED_REQUESTS' | 'ORGANIZATION' | 'ALL_REQUESTS'
requestStatus?: 'OPEN' | 'CLOSED' | 'ALL'
searchTerm?: string
start?: number
limit?: number
}
export interface JsmGetRequestsResponse extends ToolResponse {
output: {
ts: string
@@ -606,6 +194,12 @@ export interface JsmGetRequestsResponse extends ToolResponse {
}
}
export interface JsmAddCommentParams extends JsmBaseParams {
issueIdOrKey: string
body: string
isPublic: boolean
}
export interface JsmAddCommentResponse extends ToolResponse {
output: {
ts: string
@@ -613,12 +207,18 @@ export interface JsmAddCommentResponse extends ToolResponse {
commentId: string
body: string
isPublic: boolean
author: { accountId: string; displayName: string; emailAddress?: string } | null
createdDate: { iso8601: string; friendly: string } | null
success: boolean
}
}
export interface JsmGetCommentsParams extends JsmBaseParams {
issueIdOrKey: string
isPublic?: boolean
internal?: boolean
start?: number
limit?: number
}
export interface JsmGetCommentsResponse extends ToolResponse {
output: {
ts: string
@@ -629,6 +229,13 @@ export interface JsmGetCommentsResponse extends ToolResponse {
}
}
export interface JsmGetCustomersParams extends JsmBaseParams {
serviceDeskId: string
query?: string
start?: number
limit?: number
}
export interface JsmGetCustomersResponse extends ToolResponse {
output: {
ts: string
@@ -638,6 +245,11 @@ export interface JsmGetCustomersResponse extends ToolResponse {
}
}
export interface JsmAddCustomerParams extends JsmBaseParams {
serviceDeskId: string
emails: string
}
export interface JsmAddCustomerResponse extends ToolResponse {
output: {
ts: string
@@ -646,6 +258,12 @@ export interface JsmAddCustomerResponse extends ToolResponse {
}
}
export interface JsmGetOrganizationsParams extends JsmBaseParams {
serviceDeskId: string
start?: number
limit?: number
}
export interface JsmGetOrganizationsResponse extends ToolResponse {
output: {
ts: string
@@ -655,6 +273,13 @@ export interface JsmGetOrganizationsResponse extends ToolResponse {
}
}
export interface JsmGetQueuesParams extends JsmBaseParams {
serviceDeskId: string
includeCount?: boolean
start?: number
limit?: number
}
export interface JsmGetQueuesResponse extends ToolResponse {
output: {
ts: string
@@ -664,6 +289,12 @@ export interface JsmGetQueuesResponse extends ToolResponse {
}
}
export interface JsmGetSlaParams extends JsmBaseParams {
issueIdOrKey: string
start?: number
limit?: number
}
export interface JsmGetSlaResponse extends ToolResponse {
output: {
ts: string
@@ -674,6 +305,12 @@ export interface JsmGetSlaResponse extends ToolResponse {
}
}
export interface JsmTransitionRequestParams extends JsmBaseParams {
issueIdOrKey: string
transitionId: string
comment?: string
}
export interface JsmTransitionRequestResponse extends ToolResponse {
output: {
ts: string
@@ -683,16 +320,22 @@ export interface JsmTransitionRequestResponse extends ToolResponse {
}
}
export interface JsmGetTransitionsParams extends JsmBaseParams {
issueIdOrKey: string
}
export interface JsmGetTransitionsResponse extends ToolResponse {
output: {
ts: string
issueIdOrKey: string
transitions: JsmTransition[]
total: number
isLastPage: boolean
}
}
export interface JsmCreateOrganizationParams extends JsmBaseParams {
name: string
}
export interface JsmCreateOrganizationResponse extends ToolResponse {
output: {
ts: string
@@ -702,6 +345,11 @@ export interface JsmCreateOrganizationResponse extends ToolResponse {
}
}
export interface JsmAddOrganizationParams extends JsmBaseParams {
serviceDeskId: string
organizationId: string
}
export interface JsmAddOrganizationResponse extends ToolResponse {
output: {
ts: string
@@ -711,6 +359,19 @@ export interface JsmAddOrganizationResponse extends ToolResponse {
}
}
export interface JsmParticipant {
accountId: string
displayName: string
emailAddress?: string
active: boolean
}
export interface JsmGetParticipantsParams extends JsmBaseParams {
issueIdOrKey: string
start?: number
limit?: number
}
export interface JsmGetParticipantsResponse extends ToolResponse {
output: {
ts: string
@@ -721,6 +382,11 @@ export interface JsmGetParticipantsResponse extends ToolResponse {
}
}
export interface JsmAddParticipantsParams extends JsmBaseParams {
issueIdOrKey: string
accountIds: string
}
export interface JsmAddParticipantsResponse extends ToolResponse {
output: {
ts: string
@@ -730,6 +396,29 @@ export interface JsmAddParticipantsResponse extends ToolResponse {
}
}
export interface JsmApprover {
accountId: string
displayName: string
emailAddress?: string
approverDecision: 'pending' | 'approved' | 'declined'
}
export interface JsmApproval {
id: string
name: string
finalDecision: 'pending' | 'approved' | 'declined'
canAnswerApproval: boolean
approvers: JsmApprover[]
createdDate?: { iso8601: string; friendly: string }
completedDate?: { iso8601: string; friendly: string }
}
export interface JsmGetApprovalsParams extends JsmBaseParams {
issueIdOrKey: string
start?: number
limit?: number
}
export interface JsmGetApprovalsResponse extends ToolResponse {
output: {
ts: string
@@ -740,47 +429,22 @@ export interface JsmGetApprovalsResponse extends ToolResponse {
}
}
export interface JsmAnswerApprovalParams extends JsmBaseParams {
issueIdOrKey: string
approvalId: string
decision: 'approve' | 'decline'
}
export interface JsmAnswerApprovalResponse extends ToolResponse {
output: {
ts: string
issueIdOrKey: string
approvalId: string
decision: string
id: string | null
name: string | null
finalDecision: string | null
canAnswerApproval: boolean | null
approvers: Array<{
approver: {
accountId: string
displayName: string
emailAddress?: string
active?: boolean
}
approverDecision: string
}> | null
createdDate: { iso8601: string; friendly: string; epochMillis: number } | null
completedDate: { iso8601: string; friendly: string; epochMillis: number } | null
approval?: Record<string, unknown>
success: boolean
}
}
export interface JsmGetRequestTypeFieldsResponse extends ToolResponse {
output: {
ts: string
serviceDeskId: string
requestTypeId: string
canAddRequestParticipants: boolean
canRaiseOnBehalfOf: boolean
requestTypeFields: JsmRequestTypeField[]
}
}
// ---------------------------------------------------------------------------
// Union type for all JSM responses
// ---------------------------------------------------------------------------
/** Union type for all JSM responses */
export type JsmResponse =
| JsmGetServiceDesksResponse
@@ -803,4 +467,3 @@ export type JsmResponse =
| JsmAddParticipantsResponse
| JsmGetApprovalsResponse
| JsmAnswerApprovalResponse
| JsmGetRequestTypeFieldsResponse

View File

@@ -1,104 +0,0 @@
import type {
OnePasswordCreateItemParams,
OnePasswordCreateItemResponse,
} from '@/tools/onepassword/types'
import { FULL_ITEM_OUTPUTS, transformFullItem } from '@/tools/onepassword/utils'
import type { ToolConfig } from '@/tools/types'
export const createItemTool: ToolConfig<
OnePasswordCreateItemParams,
OnePasswordCreateItemResponse
> = {
id: 'onepassword_create_item',
name: '1Password Create Item',
description: 'Create a new item in a vault',
version: '1.0.0',
params: {
connectionMode: {
type: 'string',
required: false,
description: 'Connection mode: "service_account" or "connect"',
},
serviceAccountToken: {
type: 'string',
required: false,
visibility: 'user-only',
description: '1Password Service Account token (for Service Account mode)',
},
apiKey: {
type: 'string',
required: false,
visibility: 'user-only',
description: '1Password Connect API token (for Connect Server mode)',
},
serverUrl: {
type: 'string',
required: false,
visibility: 'user-only',
description: '1Password Connect server URL (for Connect Server mode)',
},
vaultId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The vault UUID to create the item in',
},
category: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Item category (e.g., LOGIN, PASSWORD, API_CREDENTIAL, SECURE_NOTE, SERVER, DATABASE)',
},
title: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Item title',
},
tags: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Comma-separated list of tags',
},
fields: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'JSON array of field objects (e.g., [{"label":"username","value":"admin","type":"STRING","purpose":"USERNAME"}])',
},
},
request: {
url: '/api/tools/onepassword/create-item',
method: 'POST',
headers: () => ({ 'Content-Type': 'application/json' }),
body: (params) => ({
connectionMode: params.connectionMode,
serviceAccountToken: params.serviceAccountToken,
serverUrl: params.serverUrl,
apiKey: params.apiKey,
vaultId: params.vaultId,
category: params.category,
title: params.title,
tags: params.tags,
fields: params.fields,
}),
},
transformResponse: async (response) => {
const data = await response.json()
if (data.error) {
return { success: false, output: transformFullItem({}), error: data.error }
}
return {
success: true,
output: transformFullItem(data),
}
},
outputs: FULL_ITEM_OUTPUTS,
}

View File

@@ -1,84 +0,0 @@
import type {
OnePasswordDeleteItemParams,
OnePasswordDeleteItemResponse,
} from '@/tools/onepassword/types'
import type { ToolConfig } from '@/tools/types'
export const deleteItemTool: ToolConfig<
OnePasswordDeleteItemParams,
OnePasswordDeleteItemResponse
> = {
id: 'onepassword_delete_item',
name: '1Password Delete Item',
description: 'Delete an item from a vault',
version: '1.0.0',
params: {
connectionMode: {
type: 'string',
required: false,
description: 'Connection mode: "service_account" or "connect"',
},
serviceAccountToken: {
type: 'string',
required: false,
visibility: 'user-only',
description: '1Password Service Account token (for Service Account mode)',
},
apiKey: {
type: 'string',
required: false,
visibility: 'user-only',
description: '1Password Connect API token (for Connect Server mode)',
},
serverUrl: {
type: 'string',
required: false,
visibility: 'user-only',
description: '1Password Connect server URL (for Connect Server mode)',
},
vaultId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The vault UUID',
},
itemId: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The item UUID to delete',
},
},
request: {
url: '/api/tools/onepassword/delete-item',
method: 'POST',
headers: () => ({ 'Content-Type': 'application/json' }),
body: (params) => ({
connectionMode: params.connectionMode,
serviceAccountToken: params.serviceAccountToken,
serverUrl: params.serverUrl,
apiKey: params.apiKey,
vaultId: params.vaultId,
itemId: params.itemId,
}),
},
transformResponse: async (response) => {
const data = await response.json()
if (data.error) {
return { success: false, output: { success: false }, error: data.error }
}
return {
success: true,
output: {
success: true,
},
}
},
outputs: {
success: { type: 'boolean', description: 'Whether the item was successfully deleted' },
},
}

Some files were not shown because too many files have changed in this diff Show More