diff --git a/apps/docs/components/icons.tsx b/apps/docs/components/icons.tsx index d62410d7f..f13fc8aa8 100644 --- a/apps/docs/components/icons.tsx +++ b/apps/docs/components/icons.tsx @@ -5483,3 +5483,37 @@ export function AgentSkillsIcon(props: SVGProps) { ) } + +export function OnePasswordIcon(props: SVGProps) { + return ( + + + + + + + ) +} diff --git a/apps/docs/components/ui/icon-mapping.ts b/apps/docs/components/ui/icon-mapping.ts index 490292c09..f02e55a8e 100644 --- a/apps/docs/components/ui/icon-mapping.ts +++ b/apps/docs/components/ui/icon-mapping.ts @@ -80,6 +80,7 @@ import { MySQLIcon, Neo4jIcon, NotionIcon, + OnePasswordIcon, OpenAIIcon, OutlookIcon, PackageSearchIcon, @@ -214,6 +215,7 @@ export const blockTypeToIconMap: Record = { neo4j: Neo4jIcon, notion_v2: NotionIcon, onedrive: MicrosoftOneDriveIcon, + onepassword: OnePasswordIcon, openai: OpenAIIcon, outlook: OutlookIcon, parallel_ai: ParallelIcon, diff --git a/apps/docs/content/docs/en/tools/airweave.mdx b/apps/docs/content/docs/en/tools/airweave.mdx index 59764a4c0..bc9cb8cb3 100644 --- a/apps/docs/content/docs/en/tools/airweave.mdx +++ b/apps/docs/content/docs/en/tools/airweave.mdx @@ -25,6 +25,7 @@ With Airweave, you can: In Sim, the Airweave integration empowers your agents to search, summarize, and extract insights from all your organization’s 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. diff --git a/apps/docs/content/docs/en/tools/jira.mdx b/apps/docs/content/docs/en/tools/jira.mdx index 812752057..179d7023a 100644 --- a/apps/docs/content/docs/en/tools/jira.mdx +++ b/apps/docs/content/docs/en/tools/jira.mdx @@ -43,7 +43,6 @@ 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. | @@ -51,13 +50,184 @@ Retrieve detailed information about a specific Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | -| `issueKey` | string | Issue key \(e.g., PROJ-123\) | +| `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` | json | Issue description content | -| `created` | string | Issue creation timestamp | -| `updated` | string | Issue last updated timestamp | -| `issue` | json | Complete issue object with all fields | +| `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 | +| `issueKey` | string | Issue key \(e.g., PROJ-123\) | +| `issue` | json | Complete raw Jira issue object from the API | ### `jira_update` @@ -68,26 +238,32 @@ 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 | -| `status` | string | No | New status for the issue | -| `priority` | string | No | New priority for the issue | -| `assignee` | string | No | New assignee 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\) | | `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 | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Updated issue key \(e.g., PROJ-123\) | | `summary` | string | Issue summary after update | ### `jira_write` -Write a Jira issue +Create a new Jira issue #### Input @@ -100,9 +276,12 @@ Write a 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\) | +| `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" \}\) | | `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\) | @@ -112,15 +291,17 @@ Write a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | +| `id` | string | Created issue ID | | `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 | -| `assigneeId` | string | Account ID of the assigned user \(if assigned\) | +| `url` | string | URL to the created issue in Jira | +| `assigneeId` | string | Account ID of the assigned user \(null if no assignee was set\) | ### `jira_bulk_read` -Retrieve multiple Jira issues in bulk +Retrieve multiple Jira issues from a project in bulk #### Input @@ -134,7 +315,30 @@ Retrieve multiple Jira issues in bulk | Parameter | Type | Description | | --------- | ---- | ----------- | -| `issues` | array | Array of Jira issues with ts, summary, description, created, and updated timestamps | +| `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 | ### `jira_delete_issue` @@ -153,7 +357,7 @@ Delete a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Deleted issue key | ### `jira_assign_issue` @@ -173,9 +377,9 @@ Assign a Jira issue to a user | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key that was assigned | -| `assigneeId` | string | Account ID of the assignee | +| `assigneeId` | string | Account ID of the assignee \(use "-1" for auto-assign, null to unassign\) | ### `jira_transition_issue` @@ -189,15 +393,20 @@ 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 | Timestamp of the operation | +| `ts` | string | ISO 8601 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` @@ -209,20 +418,77 @@ 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"\) | -| `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'\]\) | +| `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. | | `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 | 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 | +| `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\) | ### `jira_add_comment` @@ -235,16 +501,27 @@ 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 | Timestamp of the operation | +| `ts` | string | ISO 8601 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` @@ -258,16 +535,42 @@ 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 | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key | | `total` | number | Total number of comments | -| `comments` | array | Array of comments with id, author, body, created, updated | +| `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\) | ### `jira_update_comment` @@ -281,16 +584,27 @@ 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 | Timestamp of the operation | +| `ts` | string | ISO 8601 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` @@ -309,7 +623,7 @@ Delete a comment from a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key | | `commentId` | string | Deleted comment ID | @@ -329,9 +643,24 @@ Get all attachments from a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key | -| `attachments` | array | Array of attachments with id, filename, size, mimeType, created, author | +| `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 | ### `jira_add_attachment` @@ -350,10 +679,19 @@ Add attachments to a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key | -| `attachmentIds` | json | IDs of uploaded attachments | -| `files` | file[] | Uploaded attachment files | +| `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 | ### `jira_delete_attachment` @@ -371,7 +709,7 @@ Delete an attachment from a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `attachmentId` | string | Deleted attachment ID | ### `jira_add_worklog` @@ -387,16 +725,28 @@ 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 | Timestamp of the operation | +| `ts` | string | ISO 8601 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` @@ -416,10 +766,35 @@ Get all worklog entries from a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key | | `total` | number | Total number of worklogs | -| `worklogs` | array | Array of worklogs with id, author, timeSpentSeconds, timeSpent, comment, created, updated, started | +| `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 | ### `jira_update_worklog` @@ -435,15 +810,38 @@ 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 | Timestamp of the operation | +| `ts` | string | ISO 8601 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` @@ -462,7 +860,7 @@ Delete a worklog entry from a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key | | `worklogId` | string | Deleted worklog ID | @@ -485,7 +883,7 @@ Create a link relationship between two Jira issues | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `inwardIssue` | string | Inward issue key | | `outwardIssue` | string | Outward issue key | | `linkType` | string | Type of issue link | @@ -507,7 +905,7 @@ Delete a link between two Jira issues | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `linkId` | string | Deleted link ID | ### `jira_add_watcher` @@ -527,7 +925,7 @@ Add a watcher to a Jira issue to receive notifications about updates | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key | | `watcherAccountId` | string | Added watcher account ID | @@ -548,7 +946,7 @@ Remove a watcher from a Jira issue | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | +| `ts` | string | ISO 8601 timestamp of the operation | | `issueKey` | string | Issue key | | `watcherAccountId` | string | Removed watcher account ID | @@ -570,8 +968,15 @@ Get Jira users. If an account ID is provided, returns a single user. Otherwise, | Parameter | Type | Description | | --------- | ---- | ----------- | -| `ts` | string | Timestamp of the operation | -| `users` | json | Array of users with accountId, displayName, emailAddress, active status, and avatarUrls | +| `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 | | `total` | number | Total number of users returned | | `startAt` | number | Pagination start index | | `maxResults` | number | Maximum results per page | diff --git a/apps/docs/content/docs/en/tools/jira_service_management.mdx b/apps/docs/content/docs/en/tools/jira_service_management.mdx index 9cc80444e..9814f8103 100644 --- a/apps/docs/content/docs/en/tools/jira_service_management.mdx +++ b/apps/docs/content/docs/en/tools/jira_service_management.mdx @@ -46,6 +46,7 @@ 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\) | @@ -54,7 +55,14 @@ Get all service desks from Jira Service Management | Parameter | Type | Description | | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | -| `serviceDesks` | json | Array of service desks | +| `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 | | `total` | number | Total number of service desks | | `isLastPage` | boolean | Whether this is the last page | @@ -69,6 +77,9 @@ 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\) | @@ -77,7 +88,16 @@ Get request types for a service desk in Jira Service Management | Parameter | Type | Description | | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | -| `requestTypes` | json | Array of request types | +| `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 | | `total` | number | Total number of request types | | `isLastPage` | boolean | Whether this is the last page | @@ -96,6 +116,9 @@ 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 @@ -106,6 +129,9 @@ 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 | @@ -120,12 +146,33 @@ 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` @@ -139,9 +186,11 @@ 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, ORGANIZATION, ALL_REQUESTS | -| `requestStatus` | string | No | Filter by status: OPEN, CLOSED, ALL | +| `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 | | `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\) | @@ -150,8 +199,27 @@ Get multiple service requests from Jira Service Management | Parameter | Type | Description | | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | -| `requests` | json | Array of service requests | -| `total` | number | Total number of requests | +| `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 | | `isLastPage` | boolean | Whether this is the last page | ### `jsm_add_comment` @@ -177,6 +245,12 @@ 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` @@ -192,6 +266,7 @@ 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\) | @@ -201,7 +276,17 @@ Get comments for a service request in Jira Service Management | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | | `issueIdOrKey` | string | Issue ID or key | -| `comments` | json | Array of comments | +| `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\) | | `total` | number | Total number of comments | | `isLastPage` | boolean | Whether this is the last page | @@ -225,7 +310,12 @@ Get customers for a service desk in Jira Service Management | Parameter | Type | Description | | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | -| `customers` | json | Array of customers | +| `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 | | `total` | number | Total number of customers | | `isLastPage` | boolean | Whether this is the last page | @@ -240,7 +330,8 @@ 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"\) | -| `emails` | string | Yes | Comma-separated email addresses to add as customers | +| `accountIds` | string | No | Comma-separated Atlassian account IDs to add as customers | +| `emails` | string | No | Comma-separated email addresses to add as customers | #### Output @@ -269,7 +360,9 @@ Get organizations for a service desk in Jira Service Management | Parameter | Type | Description | | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | -| `organizations` | json | Array of organizations | +| `organizations` | array | List of organizations | +| ↳ `id` | string | Organization ID | +| ↳ `name` | string | Organization name | | `total` | number | Total number of organizations | | `isLastPage` | boolean | Whether this is the last page | @@ -336,7 +429,12 @@ Get queues for a service desk in Jira Service Management | Parameter | Type | Description | | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | -| `queues` | json | Array of queues | +| `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 | | `total` | number | Total number of queues | | `isLastPage` | boolean | Whether this is the last page | @@ -360,7 +458,11 @@ Get SLA information for a service request in Jira Service Management | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | | `issueIdOrKey` | string | Issue ID or key | -| `slas` | json | Array of SLA information | +| `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 | | `total` | number | Total number of SLAs | | `isLastPage` | boolean | Whether this is the last page | @@ -375,6 +477,8 @@ 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 @@ -382,7 +486,11 @@ Get available transitions for a service request in Jira Service Management | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | | `issueIdOrKey` | string | Issue ID or key | -| `transitions` | json | Array of available transitions | +| `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 | ### `jsm_transition_request` @@ -427,7 +535,11 @@ Get participants for a request in Jira Service Management | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | | `issueIdOrKey` | string | Issue ID or key | -| `participants` | json | Array of participants | +| `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 | | `total` | number | Total number of participants | | `isLastPage` | boolean | Whether this is the last page | @@ -450,7 +562,11 @@ Add participants to a request in Jira Service Management | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | | `issueIdOrKey` | string | Issue ID or key | -| `participants` | json | Array of added participants | +| `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 | | `success` | boolean | Whether the operation succeeded | ### `jsm_get_approvals` @@ -473,7 +589,20 @@ Get approvals for a request in Jira Service Management | --------- | ---- | ----------- | | `ts` | string | Timestamp of the operation | | `issueIdOrKey` | string | Issue ID or key | -| `approvals` | json | Array of approvals | +| `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 | | `total` | number | Total number of approvals | | `isLastPage` | boolean | Whether this is the last page | @@ -499,6 +628,53 @@ 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 | + diff --git a/apps/docs/content/docs/en/tools/meta.json b/apps/docs/content/docs/en/tools/meta.json index 419957f7e..f9bd3ca1f 100644 --- a/apps/docs/content/docs/en/tools/meta.json +++ b/apps/docs/content/docs/en/tools/meta.json @@ -76,6 +76,7 @@ "neo4j", "notion", "onedrive", + "onepassword", "openai", "outlook", "parallel_ai", diff --git a/apps/docs/content/docs/en/tools/onepassword.mdx b/apps/docs/content/docs/en/tools/onepassword.mdx new file mode 100644 index 000000000..7d35c55b4 --- /dev/null +++ b/apps/docs/content/docs/en/tools/onepassword.mdx @@ -0,0 +1,260 @@ +--- +title: 1Password +description: Manage secrets and items in 1Password vaults +--- + +import { BlockInfoCard } from "@/components/ui/block-info-card" + + + +{/* 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 | + + diff --git a/apps/sim/app/api/tools/jira/add-attachment/route.ts b/apps/sim/app/api/tools/jira/add-attachment/route.ts index 52b36b24a..63b031032 100644 --- a/apps/sim/app/api/tools/jira/add-attachment/route.ts +++ b/apps/sim/app/api/tools/jira/add-attachment/route.ts @@ -90,16 +90,24 @@ export async function POST(request: NextRequest) { ) } - const attachments = await response.json() - const attachmentIds = Array.isArray(attachments) - ? attachments.map((attachment) => attachment.id).filter(Boolean) - : [] + 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 ?? '', + })) return NextResponse.json({ success: true, output: { ts: new Date().toISOString(), issueKey: validatedData.issueKey, + attachments, attachmentIds, files: filesOutput, }, diff --git a/apps/sim/app/api/tools/jira/issue/route.ts b/apps/sim/app/api/tools/jira/issue/route.ts deleted file mode 100644 index 3c837de04..000000000 --- a/apps/sim/app/api/tools/jira/issue/route.ts +++ /dev/null @@ -1,111 +0,0 @@ -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 } - ) - } -} diff --git a/apps/sim/app/api/tools/jira/update/route.ts b/apps/sim/app/api/tools/jira/update/route.ts index d4ad86af6..c77dceb41 100644 --- a/apps/sim/app/api/tools/jira/update/route.ts +++ b/apps/sim/app/api/tools/jira/update/route.ts @@ -16,9 +16,16 @@ 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(), }) @@ -45,9 +52,16 @@ export async function PUT(request: NextRequest) { summary, title, description, - status, priority, assignee, + labels, + components, + duedate, + fixVersions, + environment, + customFieldId, + customFieldValue, + notifyUsers, cloudId: providedCloudId, } = validation.data @@ -64,7 +78,8 @@ export async function PUT(request: NextRequest) { return NextResponse.json({ error: issueKeyValidation.error }, { status: 400 }) } - const url = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${issueKey}` + const notifyParam = notifyUsers === false ? '?notifyUsers=false' : '' + const url = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issue/${issueKey}${notifyParam}` logger.info('Updating Jira issue at:', url) @@ -93,24 +108,65 @@ export async function PUT(request: NextRequest) { } } - if (status !== undefined && status !== null && status !== '') { - fields.status = { - name: status, - } - } - if (priority !== undefined && priority !== null && priority !== '') { - fields.priority = { - name: priority, - } + const isNumericId = /^\d+$/.test(priority) + fields.priority = isNumericId ? { id: priority } : { name: priority } } if (assignee !== undefined && assignee !== null && assignee !== '') { fields.assignee = { - id: assignee, + accountId: 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, { diff --git a/apps/sim/app/api/tools/jira/write/route.ts b/apps/sim/app/api/tools/jira/write/route.ts index 61ec34e01..cf3168e75 100644 --- a/apps/sim/app/api/tools/jira/write/route.ts +++ b/apps/sim/app/api/tools/jira/write/route.ts @@ -32,6 +32,8 @@ export async function POST(request: NextRequest) { environment, customFieldId, customFieldValue, + components, + fixVersions, } = await request.json() if (!domain) { @@ -73,10 +75,9 @@ export async function POST(request: NextRequest) { logger.info('Creating Jira issue at:', url) + const isNumericProjectId = /^\d+$/.test(projectId) const fields: Record = { - project: { - id: projectId, - }, + project: isNumericProjectId ? { id: projectId } : { key: projectId }, issuetype: { name: normalizedIssueType, }, @@ -114,13 +115,31 @@ 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 = { - id: reporter, + accountId: reporter, } } @@ -220,8 +239,10 @@ export async function POST(request: NextRequest) { success: true, output: { ts: new Date().toISOString(), + id: responseData.id || '', issueKey: issueKey, - summary: responseData.fields?.summary || 'Issue created', + self: responseData.self || '', + summary: responseData.fields?.summary || summary || 'Issue created', success: true, url: `https://${domain}/browse/${issueKey}`, ...(assigneeId && { assigneeId }), diff --git a/apps/sim/app/api/tools/jsm/approvals/route.ts b/apps/sim/app/api/tools/jsm/approvals/route.ts index 08e51725a..e579121e8 100644 --- a/apps/sim/app/api/tools/jsm/approvals/route.ts +++ b/apps/sim/app/api/tools/jsm/approvals/route.ts @@ -165,8 +165,26 @@ export async function POST(request: NextRequest) { issueIdOrKey, approvalId, decision, - success: true, + id: data.id ?? null, + name: data.name ?? null, + finalDecision: data.finalDecision ?? null, + canAnswerApproval: data.canAnswerApproval ?? null, + approvers: (data.approvers ?? []).map((a: Record) => { + const approver = a.approver as Record | 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, }, }) } diff --git a/apps/sim/app/api/tools/jsm/comment/route.ts b/apps/sim/app/api/tools/jsm/comment/route.ts index ab2e3b1e5..946a17bb2 100644 --- a/apps/sim/app/api/tools/jsm/comment/route.ts +++ b/apps/sim/app/api/tools/jsm/comment/route.ts @@ -95,6 +95,14 @@ 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, }, }) diff --git a/apps/sim/app/api/tools/jsm/comments/route.ts b/apps/sim/app/api/tools/jsm/comments/route.ts index a2ca2c47d..d68c51b8b 100644 --- a/apps/sim/app/api/tools/jsm/comments/route.ts +++ b/apps/sim/app/api/tools/jsm/comments/route.ts @@ -23,6 +23,7 @@ export async function POST(request: NextRequest) { issueIdOrKey, isPublic, internal, + expand, start, limit, } = body @@ -57,8 +58,9 @@ export async function POST(request: NextRequest) { const baseUrl = getJsmApiBaseUrl(cloudId) const params = new URLSearchParams() - if (isPublic) params.append('public', isPublic) - if (internal) params.append('internal', internal) + if (isPublic !== undefined) params.append('public', String(isPublic)) + if (internal !== undefined) params.append('internal', String(internal)) + if (expand) params.append('expand', expand) if (start) params.append('start', start) if (limit) params.append('limit', limit) diff --git a/apps/sim/app/api/tools/jsm/customers/route.ts b/apps/sim/app/api/tools/jsm/customers/route.ts index f05d39187..cf9fcf7e6 100644 --- a/apps/sim/app/api/tools/jsm/customers/route.ts +++ b/apps/sim/app/api/tools/jsm/customers/route.ts @@ -24,6 +24,7 @@ export async function POST(request: NextRequest) { query, start, limit, + accountIds, emails, } = body @@ -56,24 +57,27 @@ export async function POST(request: NextRequest) { const baseUrl = getJsmApiBaseUrl(cloudId) - const parsedEmails = emails - ? typeof emails === 'string' - ? emails + const rawIds = accountIds || emails + const parsedAccountIds = rawIds + ? typeof rawIds === 'string' + ? rawIds .split(',') - .map((email: string) => email.trim()) - .filter((email: string) => email) - : emails + .map((id: string) => id.trim()) + .filter((id: string) => id) + : Array.isArray(rawIds) + ? rawIds + : [] : [] - const isAddOperation = parsedEmails.length > 0 + const isAddOperation = parsedAccountIds.length > 0 if (isAddOperation) { const url = `${baseUrl}/servicedesk/${serviceDeskId}/customer` - logger.info('Adding customers to:', url, { emails: parsedEmails }) + logger.info('Adding customers to:', url, { accountIds: parsedAccountIds }) const requestBody: Record = { - usernames: parsedEmails, + accountIds: parsedAccountIds, } const response = await fetch(url, { diff --git a/apps/sim/app/api/tools/jsm/request/route.ts b/apps/sim/app/api/tools/jsm/request/route.ts index 92e5e9f4c..ae5b150b5 100644 --- a/apps/sim/app/api/tools/jsm/request/route.ts +++ b/apps/sim/app/api/tools/jsm/request/route.ts @@ -31,6 +31,9 @@ export async function POST(request: NextRequest) { description, raiseOnBehalfOf, requestFieldValues, + requestParticipants, + channel, + expand, } = body if (!domain) { @@ -80,6 +83,19 @@ 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', @@ -111,6 +127,21 @@ 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}`, }, @@ -126,7 +157,10 @@ export async function POST(request: NextRequest) { return NextResponse.json({ error: issueIdOrKeyValidation.error }, { status: 400 }) } - const url = `${baseUrl}/request/${issueIdOrKey}` + const params = new URLSearchParams() + if (expand) params.append('expand', expand) + + const url = `${baseUrl}/request/${issueIdOrKey}${params.toString() ? `?${params.toString()}` : ''}` logger.info('Fetching request from:', url) @@ -155,6 +189,32 @@ 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) => ({ + fieldId: fv.fieldId ?? null, + label: fv.label ?? null, + value: fv.value ?? null, + })), + url: `https://${domain}/browse/${data.issueKey}`, request: data, }, }) diff --git a/apps/sim/app/api/tools/jsm/requests/route.ts b/apps/sim/app/api/tools/jsm/requests/route.ts index f2f0dc0e7..70a4cc8ce 100644 --- a/apps/sim/app/api/tools/jsm/requests/route.ts +++ b/apps/sim/app/api/tools/jsm/requests/route.ts @@ -1,7 +1,11 @@ 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 { + validateAlphanumericId, + validateEnum, + validateJiraCloudId, +} from '@/lib/core/security/input-validation' import { getJiraCloudId, getJsmApiBaseUrl, getJsmHeaders } from '@/tools/jsm/utils' export const dynamic = 'force-dynamic' @@ -23,7 +27,9 @@ export async function POST(request: NextRequest) { serviceDeskId, requestOwnership, requestStatus, + requestTypeId, searchTerm, + expand, start, limit, } = body @@ -52,17 +58,45 @@ 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 && requestOwnership !== 'ALL_REQUESTS') { + if (requestOwnership) { params.append('requestOwnership', requestOwnership) } - if (requestStatus && requestStatus !== 'ALL') { + if (requestStatus) { 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) diff --git a/apps/sim/app/api/tools/jsm/requesttypefields/route.ts b/apps/sim/app/api/tools/jsm/requesttypefields/route.ts new file mode 100644 index 000000000..5e86337ae --- /dev/null +++ b/apps/sim/app/api/tools/jsm/requesttypefields/route.ts @@ -0,0 +1,119 @@ +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) => ({ + 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 } + ) + } +} diff --git a/apps/sim/app/api/tools/jsm/requesttypes/route.ts b/apps/sim/app/api/tools/jsm/requesttypes/route.ts index 8591f116b..9426fe847 100644 --- a/apps/sim/app/api/tools/jsm/requesttypes/route.ts +++ b/apps/sim/app/api/tools/jsm/requesttypes/route.ts @@ -16,7 +16,17 @@ export async function POST(request: NextRequest) { try { const body = await request.json() - const { domain, accessToken, cloudId: cloudIdParam, serviceDeskId, start, limit } = body + const { + domain, + accessToken, + cloudId: cloudIdParam, + serviceDeskId, + searchQuery, + groupId, + expand, + start, + limit, + } = body if (!domain) { logger.error('Missing domain in request') @@ -48,6 +58,9 @@ 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) diff --git a/apps/sim/app/api/tools/jsm/servicedesks/route.ts b/apps/sim/app/api/tools/jsm/servicedesks/route.ts index 607508a61..e6721be52 100644 --- a/apps/sim/app/api/tools/jsm/servicedesks/route.ts +++ b/apps/sim/app/api/tools/jsm/servicedesks/route.ts @@ -16,7 +16,7 @@ export async function POST(request: NextRequest) { try { const body = await request.json() - const { domain, accessToken, cloudId: cloudIdParam, start, limit } = body + const { domain, accessToken, cloudId: cloudIdParam, expand, start, limit } = body if (!domain) { logger.error('Missing domain in request') @@ -38,6 +38,7 @@ 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) diff --git a/apps/sim/app/api/tools/jsm/transitions/route.ts b/apps/sim/app/api/tools/jsm/transitions/route.ts index 5d5f2e260..d1001452f 100644 --- a/apps/sim/app/api/tools/jsm/transitions/route.ts +++ b/apps/sim/app/api/tools/jsm/transitions/route.ts @@ -16,7 +16,7 @@ export async function POST(request: NextRequest) { try { const body = await request.json() - const { domain, accessToken, cloudId: cloudIdParam, issueIdOrKey } = body + const { domain, accessToken, cloudId: cloudIdParam, issueIdOrKey, start, limit } = body if (!domain) { logger.error('Missing domain in request') @@ -47,7 +47,11 @@ export async function POST(request: NextRequest) { const baseUrl = getJsmApiBaseUrl(cloudId) - const url = `${baseUrl}/request/${issueIdOrKey}/transition` + 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()}` : ''}` logger.info('Fetching transitions from:', url) @@ -78,6 +82,8 @@ export async function POST(request: NextRequest) { ts: new Date().toISOString(), issueIdOrKey, transitions: data.values || [], + total: data.size || 0, + isLastPage: data.isLastPage ?? true, }, }) } catch (error) { diff --git a/apps/sim/app/api/tools/onepassword/create-item/route.ts b/apps/sim/app/api/tools/onepassword/create-item/route.ts new file mode 100644 index 000000000..dae8cbffa --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/create-item/route.ts @@ -0,0 +1,113 @@ +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>).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 = { + 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 }) + } +} diff --git a/apps/sim/app/api/tools/onepassword/delete-item/route.ts b/apps/sim/app/api/tools/onepassword/delete-item/route.ts new file mode 100644 index 000000000..8909adf88 --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/delete-item/route.ts @@ -0,0 +1,70 @@ +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).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 }) + } +} diff --git a/apps/sim/app/api/tools/onepassword/get-item/route.ts b/apps/sim/app/api/tools/onepassword/get-item/route.ts new file mode 100644 index 000000000..63ac2906b --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/get-item/route.ts @@ -0,0 +1,75 @@ +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 }) + } +} diff --git a/apps/sim/app/api/tools/onepassword/get-vault/route.ts b/apps/sim/app/api/tools/onepassword/get-vault/route.ts new file mode 100644 index 000000000..16343134a --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/get-vault/route.ts @@ -0,0 +1,78 @@ +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 }) + } +} diff --git a/apps/sim/app/api/tools/onepassword/list-items/route.ts b/apps/sim/app/api/tools/onepassword/list-items/route.ts new file mode 100644 index 000000000..0e9afabdc --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/list-items/route.ts @@ -0,0 +1,87 @@ +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 }) + } +} diff --git a/apps/sim/app/api/tools/onepassword/list-vaults/route.ts b/apps/sim/app/api/tools/onepassword/list-vaults/route.ts new file mode 100644 index 000000000..d1b08e781 --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/list-vaults/route.ts @@ -0,0 +1,85 @@ +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 }) + } +} diff --git a/apps/sim/app/api/tools/onepassword/replace-item/route.ts b/apps/sim/app/api/tools/onepassword/replace-item/route.ts new file mode 100644 index 000000000..3fc198d62 --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/replace-item/route.ts @@ -0,0 +1,117 @@ +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>).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>).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) => ({ + 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 }) + } +} diff --git a/apps/sim/app/api/tools/onepassword/resolve-secret/route.ts b/apps/sim/app/api/tools/onepassword/resolve-secret/route.ts new file mode 100644 index 000000000..408ac48c5 --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/resolve-secret/route.ts @@ -0,0 +1,59 @@ +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 }) + } +} diff --git a/apps/sim/app/api/tools/onepassword/update-item/route.ts b/apps/sim/app/api/tools/onepassword/update-item/route.ts new file mode 100644 index 000000000..543b5f052 --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/update-item/route.ts @@ -0,0 +1,136 @@ +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, 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] + } + } +} diff --git a/apps/sim/app/api/tools/onepassword/utils.ts b/apps/sim/app/api/tools/onepassword/utils.ts new file mode 100644 index 000000000..703b7e5ac --- /dev/null +++ b/apps/sim/app/api/tools/onepassword/utils.ts @@ -0,0 +1,357 @@ +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 = { + 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 = { + 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 = { + 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: '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 { + const base = options.serverUrl.replace(/\/$/, '') + const queryStr = options.query ? `?${options.query}` : '' + const url = `${base}${options.path}${queryStr}` + + const headers: Record = { + 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' +} diff --git a/apps/sim/blocks/blocks/jira.ts b/apps/sim/blocks/blocks/jira.ts index 263e5e363..60356a728 100644 --- a/apps/sim/blocks/blocks/jira.ts +++ b/apps/sim/blocks/blocks/jira.ts @@ -269,14 +269,32 @@ Return ONLY the description text - no explanations.`, 'Describe the issue details (e.g., "users seeing 500 error when clicking submit")...', }, }, - // Write Issue additional fields + // 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 { id: 'assignee', title: 'Assignee Account ID', type: 'short-input', placeholder: 'Assignee account ID (e.g., 5b109f2e9729b51b54dc274d)', dependsOn: ['projectId'], - condition: { field: 'operation', value: 'write' }, + condition: { field: 'operation', value: ['write', 'update'] }, }, { id: 'priority', @@ -284,7 +302,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' }, + condition: { field: 'operation', value: ['write', 'update'] }, }, { id: 'labels', @@ -292,7 +310,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' }, + condition: { field: 'operation', value: ['write', 'update'] }, }, { id: 'duedate', @@ -300,7 +318,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' }, + condition: { field: 'operation', value: ['write', 'update'] }, wandConfig: { enabled: true, prompt: `Generate a date in YYYY-MM-DD format based on the user's description. @@ -329,7 +347,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' }, + condition: { field: 'operation', value: ['write', 'update'] }, }, { id: 'customFieldId', @@ -337,7 +355,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' }, + condition: { field: 'operation', value: ['write', 'update'] }, }, { id: 'customFieldValue', @@ -345,7 +363,34 @@ 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' }, + 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' }, }, // Delete Issue fields { @@ -395,6 +440,13 @@ 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', @@ -420,6 +472,20 @@ 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', @@ -756,7 +822,9 @@ 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, @@ -768,11 +836,29 @@ 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 || '', - description: params.description || '', + 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, } return { ...baseParams, @@ -813,12 +899,14 @@ 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, } } @@ -833,6 +921,7 @@ 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, } } @@ -889,6 +978,7 @@ 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, } } @@ -966,15 +1056,19 @@ 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 operation additional inputs + // Write/Update operation additional inputs + parentIssue: { type: 'string', description: 'Parent issue key for subtasks' }, 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 @@ -985,7 +1079,13 @@ 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 @@ -1038,8 +1138,11 @@ Return ONLY the comment text - no explanations.`, id: { type: 'string', description: 'Jira issue ID' }, key: { type: 'string', description: 'Jira issue key' }, - // jira_search_issues outputs + // jira_search_issues / jira_bulk_read 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: { diff --git a/apps/sim/blocks/blocks/jira_service_management.ts b/apps/sim/blocks/blocks/jira_service_management.ts index 95679eac6..86ac86e75 100644 --- a/apps/sim/blocks/blocks/jira_service_management.ts +++ b/apps/sim/blocks/blocks/jira_service_management.ts @@ -40,6 +40,7 @@ export const JiraServiceManagementBlock: BlockConfig = { { 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', }, @@ -109,6 +110,8 @@ export const JiraServiceManagementBlock: BlockConfig = { 'get_organizations', 'add_organization', 'get_queues', + 'get_requests', + 'get_request_type_fields', ], }, }, @@ -118,7 +121,7 @@ export const JiraServiceManagementBlock: BlockConfig = { type: 'short-input', required: true, placeholder: 'Enter request type ID', - condition: { field: 'operation', value: 'create_request' }, + condition: { field: 'operation', value: ['create_request', 'get_request_type_fields'] }, }, { id: 'issueIdOrKey', @@ -188,6 +191,51 @@ 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', @@ -220,11 +268,11 @@ Return ONLY the comment text - no explanations.`, condition: { field: 'operation', value: 'add_comment' }, }, { - id: 'emails', - title: 'Email Addresses', + id: 'accountIds', + title: 'Account IDs', type: 'short-input', required: true, - placeholder: 'Comma-separated email addresses', + placeholder: 'Comma-separated Atlassian account IDs', condition: { field: 'operation', value: 'add_customer' }, }, { @@ -269,7 +317,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: 'Organization', id: 'ORGANIZATION' }, + { label: 'Approver', id: 'APPROVER' }, ], value: () => 'ALL_REQUESTS', condition: { field: 'operation', value: 'get_requests' }, @@ -279,11 +327,11 @@ Return ONLY the comment text - no explanations.`, title: 'Request Status', type: 'dropdown', options: [ - { label: 'All', id: 'ALL' }, - { label: 'Open', id: 'OPEN' }, - { label: 'Closed', id: 'CLOSED' }, + { label: 'All', id: 'ALL_REQUESTS' }, + { label: 'Open', id: 'OPEN_REQUESTS' }, + { label: 'Closed', id: 'CLOSED_REQUESTS' }, ], - value: () => 'ALL', + value: () => 'ALL_REQUESTS', condition: { field: 'operation', value: 'get_requests' }, }, { @@ -363,6 +411,9 @@ Return ONLY the comment text - no explanations.`, 'get_organizations', 'get_queues', 'get_sla', + 'get_transitions', + 'get_participants', + 'get_approvals', ], }, }, @@ -389,6 +440,7 @@ Return ONLY the comment text - no explanations.`, 'jsm_add_participants', 'jsm_get_approvals', 'jsm_answer_approval', + 'jsm_get_request_type_fields', ], config: { tool: (params) => { @@ -433,6 +485,8 @@ 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' } @@ -456,6 +510,8 @@ 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': @@ -475,6 +531,11 @@ 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) { @@ -483,6 +544,7 @@ Return ONLY the comment text - no explanations.`, return { ...baseParams, issueIdOrKey: params.issueIdOrKey, + expand: params.expand, } case 'get_requests': return { @@ -491,6 +553,7 @@ 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': @@ -513,6 +576,7 @@ 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': @@ -529,26 +593,14 @@ Return ONLY the comment text - no explanations.`, if (!params.serviceDeskId) { throw new Error('Service Desk ID is 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') + if (!params.accountIds && !params.emails) { + throw new Error('Account IDs or emails are required') } return { ...baseParams, serviceDeskId: params.serviceDeskId, - accountIds, - emails, + accountIds: params.accountIds, + emails: params.emails, } } case 'get_organizations': @@ -586,6 +638,7 @@ 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) { @@ -666,6 +719,18 @@ 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 } @@ -684,8 +749,11 @@ 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 account IDs' }, - emails: { type: 'string', description: 'Comma-separated email addresses' }, + accountIds: { type: 'string', description: 'Comma-separated Atlassian 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' }, @@ -702,6 +770,15 @@ 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' }, @@ -727,9 +804,19 @@ 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', + }, }, } diff --git a/apps/sim/blocks/blocks/onepassword.ts b/apps/sim/blocks/blocks/onepassword.ts new file mode 100644 index 000000000..7407c7f92 --- /dev/null +++ b/apps/sim/blocks/blocks/onepassword.ts @@ -0,0 +1,268 @@ +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', + }, + }, +} diff --git a/apps/sim/blocks/registry.ts b/apps/sim/blocks/registry.ts index 4d59cd866..301b7b350 100644 --- a/apps/sim/blocks/registry.ts +++ b/apps/sim/blocks/registry.ts @@ -91,6 +91,7 @@ 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' @@ -268,6 +269,7 @@ export const registry: Record = { note: NoteBlock, notion: NotionBlock, notion_v2: NotionV2Block, + onepassword: OnePasswordBlock, onedrive: OneDriveBlock, openai: OpenAIBlock, outlook: OutlookBlock, diff --git a/apps/sim/components/icons.tsx b/apps/sim/components/icons.tsx index d62410d7f..f13fc8aa8 100644 --- a/apps/sim/components/icons.tsx +++ b/apps/sim/components/icons.tsx @@ -5483,3 +5483,37 @@ export function AgentSkillsIcon(props: SVGProps) { ) } + +export function OnePasswordIcon(props: SVGProps) { + return ( + + + + + + + ) +} diff --git a/apps/sim/lib/workflows/sanitization/references.test.ts b/apps/sim/lib/workflows/sanitization/references.test.ts index 4aece4c77..83b861384 100644 --- a/apps/sim/lib/workflows/sanitization/references.test.ts +++ b/apps/sim/lib/workflows/sanitization/references.test.ts @@ -43,4 +43,13 @@ describe('isLikelyReferenceSegment', () => { it('should return false when leading content is not comparator characters', () => { expect(isLikelyReferenceSegment('')).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) + }) }) diff --git a/apps/sim/lib/workflows/sanitization/references.ts b/apps/sim/lib/workflows/sanitization/references.ts index 2290f150f..8f30762df 100644 --- a/apps/sim/lib/workflows/sanitization/references.ts +++ b/apps/sim/lib/workflows/sanitization/references.ts @@ -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 } diff --git a/apps/sim/next.config.ts b/apps/sim/next.config.ts index bbeb57c94..0a9ed16cd 100644 --- a/apps/sim/next.config.ts +++ b/apps/sim/next.config.ts @@ -77,6 +77,7 @@ const nextConfig: NextConfig = { resolveExtensions: ['.tsx', '.ts', '.jsx', '.js', '.mjs', '.json'], }, serverExternalPackages: [ + '@1password/sdk', 'unpdf', 'ffmpeg-static', 'fluent-ffmpeg', diff --git a/apps/sim/package.json b/apps/sim/package.json index 6dcc55980..73a0b0b06 100644 --- a/apps/sim/package.json +++ b/apps/sim/package.json @@ -23,6 +23,7 @@ "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", diff --git a/apps/sim/tools/jira/add_attachment.ts b/apps/sim/tools/jira/add_attachment.ts index 0fa9946e3..07b6e1d16 100644 --- a/apps/sim/tools/jira/add_attachment.ts +++ b/apps/sim/tools/jira/add_attachment.ts @@ -1,4 +1,5 @@ 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 = @@ -75,9 +76,40 @@ export const jiraAddAttachmentTool: ToolConfig = { id: 'jira_add_comment', name: 'Jira Add Comment', @@ -38,6 +55,13 @@ export const jiraAddCommentTool: ToolConfig { if (!params.cloudId) return undefined as any - return { + const payload: Record = { 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) => { - 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 payload: Record = { + 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` 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({ - body: { - type: 'doc', - version: 1, - content: [ - { - type: 'paragraph', - content: [ - { - type: 'text', - text: params?.body || '', - }, - ], - }, - ], - }, - }), + body: JSON.stringify(payload), }) if (!commentResponse.ok) { @@ -124,48 +141,46 @@ export const jiraAddCommentTool: ToolConfig = { id: 'jira_add_watcher', @@ -87,16 +72,15 @@ export const jiraAddWatcherTool: ToolConfig { if (!params?.cloudId) { const cloudId = await getJiraCloudId(params!.domain, params!.accessToken) - // 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 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) { @@ -112,14 +96,13 @@ export const jiraAddWatcherTool: ToolConfig = { + 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 = { id: 'jira_add_worklog', name: 'Jira Add Worklog', @@ -50,6 +94,13 @@ export const jiraAddWorklogTool: ToolConfig { if (!params.cloudId) return undefined as any - 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'), - } + return buildWorklogBody(params) }, }, transformResponse: async (response: Response, params?: JiraAddWorklogParams) => { - 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` + 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` 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({ - 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'), - }), + body: JSON.stringify(buildWorklogBody(params!)), }) if (!worklogResponse.ok) { @@ -152,48 +157,47 @@ export const jiraAddWorklogTool: ToolConfig = { id: 'jira_assign_issue', @@ -144,8 +129,11 @@ export const jiraAssignIssueTool: ToolConfig = { id: 'jira_bulk_read', name: 'Jira Bulk Read', - description: 'Retrieve multiple Jira issues in bulk', + description: 'Retrieve multiple Jira issues from a project in bulk', version: '1.0.0', oauth: { @@ -41,44 +43,18 @@ export const jiraBulkRetrieveTool: ToolConfig { - // Always return accessible resources endpoint; transformResponse will build search URLs - return 'https://api.atlassian.com/oauth/token/accessible-resources' - }, + url: () => '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 @@ -87,128 +63,166 @@ export const jiraBulkRetrieveTool: ToolConfig { + if (params?.cloudId) return params.cloudId const accessibleResources = await response.json() const normalizedInput = `https://${params?.domain}`.toLowerCase() const matchedResource = accessibleResources.find( (r: any) => r.url.toLowerCase() === normalizedInput ) - - 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, - })), - } + if (matchedResource) return matchedResource.id + if (Array.isArray(accessibleResources) && accessibleResources.length > 0) + return accessibleResources[0].id + throw new Error('No Jira resources found') } - // 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 cloudId = await resolveCloudId() + const projectKey = await resolveProjectKey(cloudId, params!.accessToken, params!.projectId) const jql = `project = ${projectKey} ORDER BY updated DESC` - // Always do full pagination with resolved key let collected: any[] = [] - let total = 0 - let startAt = 0 - while (startAt < MAX_TOTAL) { + let nextPageToken: string | undefined + let total: number | null = null + + while (collected.length < MAX_TOTAL) { const queryParams = new URLSearchParams({ jql, - fields: 'summary,description,created,updated', + fields: 'summary,description,status,issuetype,priority,assignee,created,updated', maxResults: String(PAGE_SIZE), }) - 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()}` + if (nextPageToken) queryParams.set('nextPageToken', nextPageToken) + + const url = `https://api.atlassian.com/ex/jira/${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 || [] - total = pageData.total || issues.length + if (pageData.total != null) total = pageData.total collected = collected.concat(issues) - if (issues.length === 0 || collected.length >= Math.min(total, MAX_TOTAL)) break - startAt += PAGE_SIZE + + if (pageData.isLast || !pageData.nextPageToken || issues.length === 0) break + nextPageToken = pageData.nextPageToken } return { success: true, - output: collected.slice(0, MAX_TOTAL).map((issue: any) => ({ + output: { ts: new Date().toISOString(), - summary: issue.fields?.summary, - description: extractDescription(issue.fields?.description), - created: issue.fields?.created, - updated: issue.fields?.updated, - })), + 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, + }, } }, 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 with ts, summary, description, created, and updated timestamps', + 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' }, + }, + }, }, + 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' }, }, } diff --git a/apps/sim/tools/jira/create_issue_link.ts b/apps/sim/tools/jira/create_issue_link.ts index 1f814cd1a..79e9f1aea 100644 --- a/apps/sim/tools/jira/create_issue_link.ts +++ b/apps/sim/tools/jira/create_issue_link.ts @@ -1,26 +1,7 @@ +import type { JiraCreateIssueLinkParams, JiraCreateIssueLinkResponse } from '@/tools/jira/types' +import { TIMESTAMP_OUTPUT } from '@/tools/jira/types' import { getJiraCloudId } from '@/tools/jira/utils' -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 - } -} +import type { ToolConfig } from '@/tools/types' export const jiraCreateIssueLinkTool: ToolConfig< JiraCreateIssueLinkParams, @@ -84,7 +65,6 @@ 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', @@ -99,10 +79,8 @@ 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`, { @@ -136,7 +114,6 @@ 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', @@ -179,21 +156,26 @@ export const jiraCreateIssueLinkTool: ToolConfig< throw new Error(message) } - // 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] + 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] + } } 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, }, @@ -201,7 +183,7 @@ export const jiraCreateIssueLinkTool: ToolConfig< }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, inwardIssue: { type: 'string', description: 'Inward issue key' }, outwardIssue: { type: 'string', description: 'Outward issue key' }, linkType: { type: 'string', description: 'Type of issue link' }, diff --git a/apps/sim/tools/jira/delete_attachment.ts b/apps/sim/tools/jira/delete_attachment.ts index fadc77911..36a879c15 100644 --- a/apps/sim/tools/jira/delete_attachment.ts +++ b/apps/sim/tools/jira/delete_attachment.ts @@ -1,20 +1,7 @@ +import type { JiraDeleteAttachmentParams, JiraDeleteAttachmentResponse } from '@/tools/jira/types' +import { TIMESTAMP_OUTPUT } from '@/tools/jira/types' import { getJiraCloudId } from '@/tools/jira/utils' -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 - } -} +import type { ToolConfig } from '@/tools/types' export const jiraDeleteAttachmentTool: ToolConfig< JiraDeleteAttachmentParams, @@ -127,7 +114,7 @@ export const jiraDeleteAttachmentTool: ToolConfig< }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, attachmentId: { type: 'string', description: 'Deleted attachment ID' }, }, } diff --git a/apps/sim/tools/jira/delete_comment.ts b/apps/sim/tools/jira/delete_comment.ts index d6b68301e..cde50ace4 100644 --- a/apps/sim/tools/jira/delete_comment.ts +++ b/apps/sim/tools/jira/delete_comment.ts @@ -1,22 +1,7 @@ +import type { JiraDeleteCommentParams, JiraDeleteCommentResponse } from '@/tools/jira/types' +import { TIMESTAMP_OUTPUT } from '@/tools/jira/types' import { getJiraCloudId } from '@/tools/jira/utils' -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 - } -} +import type { ToolConfig } from '@/tools/types' export const jiraDeleteCommentTool: ToolConfig = { @@ -135,7 +120,7 @@ export const jiraDeleteCommentTool: ToolConfig = { id: 'jira_delete_issue', @@ -170,7 +156,7 @@ export const jiraDeleteIssueTool: ToolConfig { if (!params?.cloudId) { const cloudId = await getJiraCloudId(params!.domain, params!.accessToken) - // Make the actual request with the resolved cloudId - const issueLinkUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issueLink/${params?.linkId}` + 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}`, }, }) @@ -100,13 +86,12 @@ 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 { @@ -120,14 +105,14 @@ export const jiraDeleteIssueLinkTool: ToolConfig< success: true, output: { ts: new Date().toISOString(), - linkId: params?.linkId || 'unknown', + linkId: params!.linkId || 'unknown', success: true, }, } }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, linkId: { type: 'string', description: 'Deleted link ID' }, }, } diff --git a/apps/sim/tools/jira/delete_worklog.ts b/apps/sim/tools/jira/delete_worklog.ts index 46c0fa826..260abc0c0 100644 --- a/apps/sim/tools/jira/delete_worklog.ts +++ b/apps/sim/tools/jira/delete_worklog.ts @@ -1,22 +1,7 @@ +import type { JiraDeleteWorklogParams, JiraDeleteWorklogResponse } from '@/tools/jira/types' +import { TIMESTAMP_OUTPUT } from '@/tools/jira/types' import { getJiraCloudId } from '@/tools/jira/utils' -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 - } -} +import type { ToolConfig } from '@/tools/types' export const jiraDeleteWorklogTool: ToolConfig = { @@ -83,13 +68,12 @@ export const jiraDeleteWorklogTool: ToolConfig { if (!params?.cloudId) { 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/${params?.worklogId}` + 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}`, }, }) @@ -106,14 +90,13 @@ export const jiraDeleteWorklogTool: ToolConfig { - 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 fetchAttachments = async (cloudId: string) => { + 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}`, }, }) @@ -82,60 +98,46 @@ export const jiraGetAttachmentsTool: ToolConfig< throw new Error(message) } - const data = await attachmentsResponse.json() + return attachmentsResponse.json() + } - 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', - })), - }, + 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) } + 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((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', - })), + issueKey: params?.issueKey ?? 'unknown', + attachments: (data?.fields?.attachment ?? []).map(transformAttachment), }, } }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, issueKey: { type: 'string', description: 'Issue key' }, attachments: { type: 'array', - description: 'Array of attachments with id, filename, size, mimeType, created, author', + description: 'Array of attachments', + items: { + type: 'object', + properties: ATTACHMENT_ITEM_PROPERTIES, + }, }, }, } diff --git a/apps/sim/tools/jira/get_comments.ts b/apps/sim/tools/jira/get_comments.ts index e51db0ee4..af6ec05de 100644 --- a/apps/sim/tools/jira/get_comments.ts +++ b/apps/sim/tools/jira/get_comments.ts @@ -1,27 +1,22 @@ -import { getJiraCloudId } from '@/tools/jira/utils' -import type { ToolConfig, ToolResponse } from '@/tools/types' +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' -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 - }> +/** + * 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, } } @@ -67,6 +62,13 @@ export const jiraGetCommentsTool: ToolConfig { if (params.cloudId) { - 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}` + 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}` } return 'https://api.atlassian.com/oauth/token/accessible-resources' }, @@ -95,29 +98,16 @@ export const jiraGetCommentsTool: ToolConfig { - // 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 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}` const commentsResponse = await fetch(commentsUrl, { method: 'GET', headers: { Accept: 'application/json', - Authorization: `Bearer ${params?.accessToken}`, + Authorization: `Bearer ${params!.accessToken}`, }, }) @@ -130,61 +120,52 @@ export const jiraGetCommentsTool: ToolConfig ({ - id: comment.id, - author: comment.author?.displayName || comment.author?.accountId || 'Unknown', - body: extractText(comment.body), - created: comment.created, - updated: comment.updated, - })), - }, + 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) } + 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, - 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, - })), + issueKey: params?.issueKey ?? 'unknown', + total: data.total ?? 0, + startAt: data.startAt ?? 0, + maxResults: data.maxResults ?? 0, + comments: (data.comments ?? []).map(transformComment), }, } }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, 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 with id, author, body, created, updated', + description: 'Array of comments', + items: { + type: 'object', + properties: COMMENT_ITEM_PROPERTIES, + }, }, }, } diff --git a/apps/sim/tools/jira/get_users.ts b/apps/sim/tools/jira/get_users.ts index 246ef1693..71cbae350 100644 --- a/apps/sim/tools/jira/get_users.ts +++ b/apps/sim/tools/jira/get_users.ts @@ -1,38 +1,20 @@ +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, ToolResponse } from '@/tools/types' +import type { ToolConfig } from '@/tools/types' -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 +/** + * 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, } } @@ -112,9 +94,7 @@ export const jiraGetUsersTool: ToolConfig { - if (!params?.cloudId) { - const cloudId = await getJiraCloudId(params!.domain, params!.accessToken) - + const fetchUsers = async (cloudId: string) => { let usersUrl: string if (params!.accountId) { usersUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/user?accountId=${encodeURIComponent(params!.accountId)}` @@ -144,71 +124,49 @@ export const jiraGetUsersTool: ToolConfig ({ - 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, - }, + 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) } + 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((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, - })), + users: users.map(transformUserOutput), total: params?.accountId ? 1 : users.length, - startAt: params?.startAt || 0, - maxResults: params?.maxResults || 50, + startAt: params?.startAt ?? 0, + maxResults: params?.maxResults ?? 50, }, } }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, users: { - type: 'json', - description: - 'Array of users with accountId, displayName, emailAddress, active status, and avatarUrls', + type: 'array', + description: 'Array of Jira users', + items: { + type: 'object', + properties: USER_OUTPUT_PROPERTIES, + }, }, total: { type: 'number', description: 'Total number of users returned' }, startAt: { type: 'number', description: 'Pagination start index' }, diff --git a/apps/sim/tools/jira/get_worklogs.ts b/apps/sim/tools/jira/get_worklogs.ts index e9e18c523..2818cd51a 100644 --- a/apps/sim/tools/jira/get_worklogs.ts +++ b/apps/sim/tools/jira/get_worklogs.ts @@ -1,30 +1,22 @@ -import { getJiraCloudId } from '@/tools/jira/utils' -import type { ToolConfig, ToolResponse } from '@/tools/types' +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' -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 - }> +/** + * 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 ?? '', } } @@ -82,8 +74,8 @@ export const jiraGetWorklogsTool: ToolConfig { 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' @@ -98,29 +90,15 @@ export const jiraGetWorklogsTool: ToolConfig { - // 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 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}` const worklogsResponse = await fetch(worklogsUrl, { method: 'GET', headers: { Accept: 'application/json', - Authorization: `Bearer ${params?.accessToken}`, + Authorization: `Bearer ${params!.accessToken}`, }, }) @@ -133,68 +111,52 @@ export const jiraGetWorklogsTool: ToolConfig ({ - 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, - })), - }, + 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) } + 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, - 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, - })), + issueKey: params?.issueKey ?? 'unknown', + total: data.total ?? 0, + startAt: data.startAt ?? 0, + maxResults: data.maxResults ?? 0, + worklogs: (data.worklogs ?? []).map(transformWorklog), }, } }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, 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 with id, author, timeSpentSeconds, timeSpent, comment, created, updated, started', + description: 'Array of worklogs', + items: { + type: 'object', + properties: WORKLOG_ITEM_PROPERTIES, + }, }, }, } diff --git a/apps/sim/tools/jira/remove_watcher.ts b/apps/sim/tools/jira/remove_watcher.ts index 6a66fe05f..7a8007f1f 100644 --- a/apps/sim/tools/jira/remove_watcher.ts +++ b/apps/sim/tools/jira/remove_watcher.ts @@ -1,22 +1,7 @@ +import type { JiraRemoveWatcherParams, JiraRemoveWatcherResponse } from '@/tools/jira/types' +import { TIMESTAMP_OUTPUT } from '@/tools/jira/types' import { getJiraCloudId } from '@/tools/jira/utils' -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 - } -} +import type { ToolConfig } from '@/tools/types' export const jiraRemoveWatcherTool: ToolConfig = { @@ -83,13 +68,12 @@ export const jiraRemoveWatcherTool: ToolConfig { if (!params?.cloudId) { const cloudId = await getJiraCloudId(params!.domain, params!.accessToken) - // 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 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}`, }, }) @@ -106,14 +90,13 @@ export const jiraRemoveWatcherTool: ToolConfig ({ + 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 = { id: 'jira_retrieve', name: 'Jira Retrieve', @@ -29,12 +195,6 @@ export const jiraRetrieveTool: ToolConfig { 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', @@ -70,21 +228,16 @@ export const jiraRetrieveTool: ToolConfig { if (!params?.issueKey) { - throw new Error( - 'Select a project to read issues, or provide an issue key to read a single issue.' - ) + throw new Error('Provide an issue key to retrieve a single issue.') } - // 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 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` const issueResponse = await fetch(issueUrl, { method: 'GET', headers: { Accept: 'application/json', - Authorization: `Bearer ${params?.accessToken}`, + Authorization: `Bearer ${params.accessToken}`, }, }) @@ -97,19 +250,20 @@ export const jiraRetrieveTool: ToolConfig { 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}` }, }), ]) @@ -117,124 +271,68 @@ export const jiraRetrieveTool: ToolConfig ({ + 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 = { id: 'jira_search_issues', name: 'Jira Search Issues', @@ -33,24 +99,24 @@ export const jiraSearchIssuesTool: ToolConfig 0) @@ -77,22 +143,19 @@ export const jiraSearchIssuesTool: ToolConfig 'GET', - headers: (params: JiraSearchIssuesParams) => { - return { - Accept: 'application/json', - 'Content-Type': 'application/json', - Authorization: `Bearer ${params.accessToken}`, - } - }, + headers: (params: JiraSearchIssuesParams) => ({ + Accept: 'application/json', + 'Content-Type': 'application/json', + Authorization: `Bearer ${params.accessToken}`, + }), body: () => undefined as any, }, transformResponse: async (response: Response, params?: JiraSearchIssuesParams) => { - if (!params?.cloudId) { - const cloudId = await getJiraCloudId(params!.domain, params!.accessToken) + const performSearch = async (cloudId: string) => { const query = new URLSearchParams() if (params?.jql) query.set('jql', params.jql) - if (typeof params?.startAt === 'number') query.set('startAt', String(params.startAt)) + if (params?.nextPageToken) query.set('nextPageToken', params.nextPageToken) 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(',')) @@ -103,12 +166,6 @@ export const jiraSearchIssuesTool: ToolConfig ({ - 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, - })), - }, + 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) } + 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(), - 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, - })), + issues: (data?.issues ?? []).map(transformSearchIssue), + nextPageToken: data?.nextPageToken ?? null, + isLast: data?.isLast ?? true, + total: data?.total ?? null, }, } }, outputs: { - 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' }, + ts: TIMESTAMP_OUTPUT, issues: { type: 'array', - description: 'Array of matching issues with key, summary, status, assignee, created, updated', + 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, }, }, } diff --git a/apps/sim/tools/jira/transition_issue.ts b/apps/sim/tools/jira/transition_issue.ts index f79f04090..9da0146c6 100644 --- a/apps/sim/tools/jira/transition_issue.ts +++ b/apps/sim/tools/jira/transition_issue.ts @@ -1,4 +1,5 @@ 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' @@ -48,6 +49,12 @@ 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, @@ -74,87 +81,47 @@ export const jiraTransitionIssueTool: ToolConfig< }, body: (params: JiraTransitionIssueParams) => { if (!params.cloudId) return undefined as any - 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 + return buildTransitionBody(params) }, }, transformResponse: async (response: Response, params?: JiraTransitionIssueParams) => { - 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, + 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!.comment) { - body.update = { - comment: [ - { - add: { - body: { - type: 'doc', - version: 1, - content: [ - { - type: 'paragraph', - content: [ - { - type: 'text', - text: params!.comment, - }, - ], - }, - ], - }, - }, - }, - ], + 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 } } - const transitionResponse = await fetch(transitionUrl, { + // Perform the transition + const transitionResponse = await fetch(transitionsUrl, { method: 'POST', headers: { Accept: 'application/json', 'Content-Type': 'application/json', Authorization: `Bearer ${params!.accessToken}`, }, - body: JSON.stringify(body), + body: JSON.stringify(buildTransitionBody(params!)), }) if (!transitionResponse.ok) { @@ -166,42 +133,119 @@ export const jiraTransitionIssueTool: ToolConfig< 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, - }, + 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) } - } - if (!response.ok) { - let message = `Failed to transition Jira issue (${response.status})` + // Fetch transition metadata for the response try { - const err = await response.json() - message = err?.errorMessages?.join(', ') || err?.message || message - } catch (_e) {} - throw new Error(message) + 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 {} } - // Transition endpoint returns 204 No Content on success return { success: true, output: { ts: new Date().toISOString(), - issueKey: params?.issueKey || 'unknown', - transitionId: params?.transitionId || 'unknown', + issueKey: params?.issueKey ?? 'unknown', + transitionId: params?.transitionId ?? 'unknown', + transitionName, + toStatus, success: true, }, } }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, 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 +} diff --git a/apps/sim/tools/jira/types.ts b/apps/sim/tools/jira/types.ts index 0ed2ba646..850ccb36d 100644 --- a/apps/sim/tools/jira/types.ts +++ b/apps/sim/tools/jira/types.ts @@ -1,5 +1,741 @@ import type { UserFile } from '@/executor/types' -import type { ToolFileData, ToolResponse } from '@/tools/types' +import type { OutputProperty, ToolResponse } from '@/tools/types' + +/** + * Shared output property constants for Jira tools. + * Based on Jira Cloud REST API v3 response schemas: + * @see https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/ + * @see https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-search/ + * @see https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/ + * @see https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-worklogs/ + */ + +/** + * User object properties shared across issues, comments, and worklogs. + * Based on Jira API v3 user structure (accountId-based). + */ +export const USER_OUTPUT_PROPERTIES = { + accountId: { type: 'string', description: 'Atlassian account ID of the user' }, + displayName: { type: 'string', description: 'Display name of the user' }, + active: { type: 'boolean', description: 'Whether the user account is active', optional: true }, + emailAddress: { type: 'string', description: 'Email address of the user', optional: true }, + accountType: { + type: 'string', + description: 'Type of account (e.g., atlassian, app, customer)', + optional: true, + }, + avatarUrl: { + type: 'string', + description: 'URL to the user avatar (48x48)', + optional: true, + }, + timeZone: { type: 'string', description: 'User timezone', optional: true }, +} as const satisfies Record + +/** + * User object output definition. + */ +export const USER_OUTPUT: OutputProperty = { + type: 'object', + description: 'Jira user object', + properties: USER_OUTPUT_PROPERTIES, +} + +/** + * Status object properties from Jira API v3. + * Based on IssueBean.fields.status structure. + */ +export const STATUS_OUTPUT_PROPERTIES = { + id: { type: 'string', description: 'Status ID' }, + name: { type: 'string', description: 'Status name (e.g., Open, In Progress, Done)' }, + description: { type: 'string', description: 'Status description', optional: true }, + statusCategory: { + type: 'object', + description: 'Status category grouping', + properties: { + id: { type: 'number', description: 'Status category ID' }, + key: { + type: 'string', + description: 'Status category key (e.g., new, indeterminate, done)', + }, + name: { + type: 'string', + description: 'Status category name (e.g., To Do, In Progress, Done)', + }, + colorName: { + type: 'string', + description: 'Status category color (e.g., blue-gray, yellow, green)', + }, + }, + optional: true, + }, +} as const satisfies Record + +/** + * Status object output definition. + */ +export const STATUS_OUTPUT: OutputProperty = { + type: 'object', + description: 'Issue status', + properties: STATUS_OUTPUT_PROPERTIES, +} + +/** + * Issue type object properties from Jira API v3. + * Based on IssueBean.fields.issuetype structure. + */ +export const ISSUE_TYPE_OUTPUT_PROPERTIES = { + id: { type: 'string', description: 'Issue type ID' }, + name: { type: 'string', description: 'Issue type name (e.g., Task, Bug, Story, Epic)' }, + description: { type: 'string', description: 'Issue type description', optional: true }, + subtask: { type: 'boolean', description: 'Whether this is a subtask type' }, + iconUrl: { type: 'string', description: 'URL to the issue type icon', optional: true }, +} as const satisfies Record + +/** + * Issue type object output definition. + */ +export const ISSUE_TYPE_OUTPUT: OutputProperty = { + type: 'object', + description: 'Issue type', + properties: ISSUE_TYPE_OUTPUT_PROPERTIES, +} + +/** + * Project object properties from Jira API v3. + * Based on IssueBean.fields.project structure. + */ +export const PROJECT_OUTPUT_PROPERTIES = { + id: { type: 'string', description: 'Project ID' }, + key: { type: 'string', description: 'Project key (e.g., PROJ)' }, + name: { type: 'string', description: 'Project name' }, + projectTypeKey: { + type: 'string', + description: 'Project type key (e.g., software, business)', + optional: true, + }, +} as const satisfies Record + +/** + * Project object output definition. + */ +export const PROJECT_OUTPUT: OutputProperty = { + type: 'object', + description: 'Jira project', + properties: PROJECT_OUTPUT_PROPERTIES, +} + +/** + * Priority object properties from Jira API v3. + * Based on IssueBean.fields.priority structure. + */ +export const PRIORITY_OUTPUT_PROPERTIES = { + id: { type: 'string', description: 'Priority ID' }, + name: { type: 'string', description: 'Priority name (e.g., Highest, High, Medium, Low, Lowest)' }, + iconUrl: { type: 'string', description: 'URL to the priority icon', optional: true }, +} as const satisfies Record + +/** + * Priority object output definition. + */ +export const PRIORITY_OUTPUT: OutputProperty = { + type: 'object', + description: 'Issue priority', + properties: PRIORITY_OUTPUT_PROPERTIES, +} + +/** + * Resolution object properties from Jira API v3. + * Based on IssueBean.fields.resolution structure. + */ +export const RESOLUTION_OUTPUT_PROPERTIES = { + id: { type: 'string', description: 'Resolution ID' }, + name: { type: 'string', description: "Resolution name (e.g., Fixed, Duplicate, Won't Fix)" }, + description: { type: 'string', description: 'Resolution description', optional: true }, +} as const satisfies Record + +/** + * Resolution object output definition. + */ +export const RESOLUTION_OUTPUT: OutputProperty = { + type: 'object', + description: 'Issue resolution', + properties: RESOLUTION_OUTPUT_PROPERTIES, + optional: true, +} + +/** + * Component object properties from Jira API v3. + * Based on IssueBean.fields.components structure. + */ +export const COMPONENT_OUTPUT_PROPERTIES = { + id: { type: 'string', description: 'Component ID' }, + name: { type: 'string', description: 'Component name' }, + description: { type: 'string', description: 'Component description', optional: true }, +} as const satisfies Record + +/** + * Version object properties from Jira API v3. + * Based on IssueBean.fields.fixVersions / versions structure. + */ +export const VERSION_OUTPUT_PROPERTIES = { + id: { type: 'string', description: 'Version ID' }, + name: { type: 'string', description: 'Version name' }, + released: { type: 'boolean', description: 'Whether the version is released', optional: true }, + releaseDate: { type: 'string', description: 'Release date (YYYY-MM-DD)', optional: true }, +} as const satisfies Record + +/** + * Time tracking object properties from Jira API v3. + * Based on IssueBean.fields.timetracking structure. + */ +export const TIME_TRACKING_OUTPUT_PROPERTIES = { + originalEstimate: { + type: 'string', + description: 'Original estimate in human-readable format (e.g., 1w 2d)', + optional: true, + }, + remainingEstimate: { + type: 'string', + description: 'Remaining estimate in human-readable format', + optional: true, + }, + timeSpent: { + type: 'string', + description: 'Time spent in human-readable format', + optional: true, + }, + originalEstimateSeconds: { + type: 'number', + description: 'Original estimate in seconds', + optional: true, + }, + remainingEstimateSeconds: { + type: 'number', + description: 'Remaining estimate in seconds', + optional: true, + }, + timeSpentSeconds: { + type: 'number', + description: 'Time spent in seconds', + optional: true, + }, +} as const satisfies Record + +/** + * Time tracking object output definition. + */ +export const TIME_TRACKING_OUTPUT: OutputProperty = { + type: 'object', + description: 'Time tracking information', + properties: TIME_TRACKING_OUTPUT_PROPERTIES, + optional: true, +} + +/** + * Issue link object properties from Jira API v3. + * Based on IssueBean.fields.issuelinks structure. + */ +export const ISSUE_LINK_ITEM_PROPERTIES = { + id: { type: 'string', description: 'Issue link ID' }, + type: { + type: 'object', + description: 'Link type information', + properties: { + id: { type: 'string', description: 'Link type ID' }, + name: { type: 'string', description: 'Link type name (e.g., Blocks, Relates)' }, + inward: { type: 'string', description: 'Inward description (e.g., is blocked by)' }, + outward: { type: 'string', description: 'Outward description (e.g., blocks)' }, + }, + }, + inwardIssue: { + type: 'object', + description: 'Inward linked issue', + properties: { + id: { type: 'string', description: 'Issue ID' }, + key: { type: 'string', description: 'Issue key' }, + statusName: { type: 'string', description: 'Issue status name', optional: true }, + summary: { type: 'string', description: 'Issue summary', optional: true }, + }, + optional: true, + }, + outwardIssue: { + type: 'object', + description: 'Outward linked issue', + properties: { + id: { type: 'string', description: 'Issue ID' }, + key: { type: 'string', description: 'Issue key' }, + statusName: { type: 'string', description: 'Issue status name', optional: true }, + summary: { type: 'string', description: 'Issue summary', optional: true }, + }, + optional: true, + }, +} as const satisfies Record + +/** + * Subtask item properties from Jira API v3. + */ +export const SUBTASK_ITEM_PROPERTIES = { + id: { type: 'string', description: 'Subtask issue ID' }, + key: { type: 'string', description: 'Subtask issue key' }, + summary: { type: 'string', description: 'Subtask summary' }, + statusName: { type: 'string', description: 'Subtask status name' }, + issueTypeName: { type: 'string', description: 'Subtask issue type name', optional: true }, +} as const satisfies Record + +/** + * Comment item properties from Jira API v3. + * Based on GET /rest/api/3/issue/{issueIdOrKey}/comment response. + */ +export const COMMENT_ITEM_PROPERTIES = { + id: { type: 'string', description: 'Comment ID' }, + body: { type: 'string', description: 'Comment body text (extracted from ADF)' }, + author: { + type: 'object', + description: 'Comment author', + properties: USER_OUTPUT_PROPERTIES, + }, + updateAuthor: { + type: 'object', + description: 'User who last updated the comment', + properties: USER_OUTPUT_PROPERTIES, + optional: true, + }, + 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' }, + visibility: { + type: 'object', + description: 'Comment visibility restriction', + properties: { + type: { type: 'string', description: 'Restriction type (e.g., role, group)' }, + value: { type: 'string', description: 'Restriction value (e.g., Administrators)' }, + }, + optional: true, + }, +} as const satisfies Record + +/** + * Comment object output definition. + */ +export const COMMENT_OUTPUT: OutputProperty = { + type: 'object', + description: 'Jira comment object', + properties: COMMENT_ITEM_PROPERTIES, +} + +/** + * Comments array output definition. + */ +export const COMMENTS_OUTPUT: OutputProperty = { + type: 'array', + description: 'Array of Jira comments', + items: { + type: 'object', + properties: COMMENT_ITEM_PROPERTIES, + }, +} + +/** + * Attachment item properties from Jira API v3. + * Based on IssueBean.fields.attachment structure. + */ +export const ATTACHMENT_ITEM_PROPERTIES = { + id: { type: 'string', description: 'Attachment ID' }, + filename: { type: 'string', description: 'Attachment file name' }, + mimeType: { type: 'string', description: 'MIME type of the attachment' }, + size: { type: 'number', description: 'File size in bytes' }, + content: { type: 'string', description: 'URL to download the attachment content' }, + thumbnail: { + type: 'string', + description: 'URL to the attachment thumbnail', + optional: true, + }, + author: { + type: 'object', + description: 'Attachment author', + properties: USER_OUTPUT_PROPERTIES, + optional: true, + }, + created: { type: 'string', description: 'ISO 8601 timestamp when the attachment was created' }, +} as const satisfies Record + +/** + * Attachment object output definition. + */ +export const ATTACHMENT_OUTPUT: OutputProperty = { + type: 'object', + description: 'Jira attachment object', + properties: ATTACHMENT_ITEM_PROPERTIES, +} + +/** + * Attachments array output definition. + */ +export const ATTACHMENTS_OUTPUT: OutputProperty = { + type: 'array', + description: 'Array of Jira attachments', + items: { + type: 'object', + properties: ATTACHMENT_ITEM_PROPERTIES, + }, +} + +/** + * Worklog item properties from Jira API v3. + * Based on GET /rest/api/3/issue/{issueIdOrKey}/worklog response. + */ +export const WORKLOG_ITEM_PROPERTIES = { + id: { type: 'string', description: 'Worklog ID' }, + author: { + type: 'object', + description: 'Worklog author', + properties: USER_OUTPUT_PROPERTIES, + }, + updateAuthor: { + type: 'object', + description: 'User who last updated the worklog', + properties: USER_OUTPUT_PROPERTIES, + optional: true, + }, + comment: { type: 'string', description: 'Worklog comment text', optional: true }, + started: { type: 'string', description: 'ISO 8601 timestamp when the work started' }, + timeSpent: { type: 'string', description: 'Time spent in human-readable format (e.g., 3h 20m)' }, + timeSpentSeconds: { type: 'number', description: 'Time spent in seconds' }, + created: { type: 'string', description: 'ISO 8601 timestamp when the worklog was created' }, + updated: { type: 'string', description: 'ISO 8601 timestamp when the worklog was last updated' }, +} as const satisfies Record + +/** + * Worklog object output definition. + */ +export const WORKLOG_OUTPUT: OutputProperty = { + type: 'object', + description: 'Jira worklog object', + properties: WORKLOG_ITEM_PROPERTIES, +} + +/** + * Worklogs array output definition. + */ +export const WORKLOGS_OUTPUT: OutputProperty = { + type: 'array', + description: 'Array of Jira worklogs', + items: { + type: 'object', + properties: WORKLOG_ITEM_PROPERTIES, + }, +} + +/** + * Transition object properties from Jira API v3. + * Based on GET /rest/api/3/issue/{issueIdOrKey}/transitions response. + */ +export const TRANSITION_ITEM_PROPERTIES = { + id: { type: 'string', description: 'Transition ID' }, + name: { type: 'string', description: 'Transition name (e.g., Start Progress, Done)' }, + hasScreen: { + type: 'boolean', + description: 'Whether the transition has an associated screen', + optional: true, + }, + isGlobal: { type: 'boolean', description: 'Whether the transition is global', optional: true }, + isConditional: { + type: 'boolean', + description: 'Whether the transition is conditional', + optional: true, + }, + to: { + type: 'object', + description: 'Target status after transition', + properties: STATUS_OUTPUT_PROPERTIES, + }, +} as const satisfies Record + +/** + * Full issue item properties for retrieve/search outputs. + * Based on IssueBean structure from Jira API v3. + */ +export const ISSUE_ITEM_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 (extracted from ADF)', + optional: true, + }, + status: { + type: 'object', + description: 'Issue status', + properties: STATUS_OUTPUT_PROPERTIES, + }, + issuetype: { + type: 'object', + description: 'Issue type', + properties: ISSUE_TYPE_OUTPUT_PROPERTIES, + }, + project: { + type: 'object', + description: 'Project the issue belongs to', + properties: PROJECT_OUTPUT_PROPERTIES, + }, + priority: { + type: 'object', + description: 'Issue priority', + properties: PRIORITY_OUTPUT_PROPERTIES, + optional: true, + }, + assignee: { + type: 'object', + description: 'Assigned user', + properties: USER_OUTPUT_PROPERTIES, + optional: true, + }, + reporter: { + type: 'object', + description: 'Reporter user', + properties: USER_OUTPUT_PROPERTIES, + optional: true, + }, + creator: { + type: 'object', + description: 'Issue creator', + properties: USER_OUTPUT_PROPERTIES, + optional: true, + }, + labels: { + type: 'array', + description: 'Issue labels', + items: { type: 'string' }, + }, + components: { + type: 'array', + description: 'Issue components', + items: { + type: 'object', + properties: COMPONENT_OUTPUT_PROPERTIES, + }, + optional: true, + }, + fixVersions: { + type: 'array', + description: 'Fix versions', + items: { + type: 'object', + properties: VERSION_OUTPUT_PROPERTIES, + }, + optional: true, + }, + resolution: { + type: 'object', + description: 'Issue resolution', + properties: RESOLUTION_OUTPUT_PROPERTIES, + optional: true, + }, + duedate: { type: 'string', description: 'Due date (YYYY-MM-DD)', optional: true }, + created: { type: 'string', description: 'ISO 8601 timestamp when the issue was created' }, + updated: { type: 'string', description: 'ISO 8601 timestamp when the issue was last updated' }, + resolutiondate: { + type: 'string', + description: 'ISO 8601 timestamp when the issue was resolved', + optional: true, + }, + timetracking: TIME_TRACKING_OUTPUT, + parent: { + type: 'object', + description: 'Parent issue (for subtasks)', + properties: { + id: { type: 'string', description: 'Parent issue ID' }, + key: { type: 'string', description: 'Parent issue key' }, + summary: { type: 'string', description: 'Parent issue summary', optional: true }, + }, + optional: true, + }, + issuelinks: { + type: 'array', + description: 'Linked issues', + items: { + type: 'object', + properties: ISSUE_LINK_ITEM_PROPERTIES, + }, + optional: true, + }, + subtasks: { + type: 'array', + description: 'Subtask issues', + items: { + type: 'object', + properties: SUBTASK_ITEM_PROPERTIES, + }, + optional: true, + }, + votes: { + type: 'object', + description: 'Vote information', + properties: { + votes: { type: 'number', description: 'Number of votes' }, + hasVoted: { type: 'boolean', description: 'Whether the current user has voted' }, + }, + optional: true, + }, + watches: { + type: 'object', + description: 'Watch information', + properties: { + watchCount: { type: 'number', description: 'Number of watchers' }, + isWatching: { type: 'boolean', description: 'Whether the current user is watching' }, + }, + optional: true, + }, + comments: { + type: 'array', + description: 'Issue comments (fetched separately)', + items: { + type: 'object', + properties: COMMENT_ITEM_PROPERTIES, + }, + optional: true, + }, + worklogs: { + type: 'array', + description: 'Issue worklogs (fetched separately)', + items: { + type: 'object', + properties: WORKLOG_ITEM_PROPERTIES, + }, + optional: true, + }, + attachments: { + type: 'array', + description: 'Issue attachments', + items: { + type: 'object', + properties: ATTACHMENT_ITEM_PROPERTIES, + }, + optional: true, + }, + issueKey: { type: 'string', description: 'Issue key (e.g., PROJ-123)' }, +} as const satisfies Record + +/** + * Issue object output definition. + */ +export const ISSUE_OUTPUT: OutputProperty = { + type: 'object', + description: 'Jira issue object', + properties: ISSUE_ITEM_PROPERTIES, +} + +/** + * Issues array output definition for search endpoints. + */ +export const ISSUES_OUTPUT: OutputProperty = { + type: 'array', + description: 'Array of Jira issues', + items: { + type: 'object', + properties: ISSUE_ITEM_PROPERTIES, + }, +} + +/** + * Search issue item properties (lighter than full issue for search results). + * Based on POST /rest/api/3/search/jql response. + */ +export const SEARCH_ISSUE_ITEM_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 (extracted from ADF)', + optional: true, + }, + status: { + type: 'object', + description: 'Issue status', + properties: STATUS_OUTPUT_PROPERTIES, + }, + issuetype: { + type: 'object', + description: 'Issue type', + properties: ISSUE_TYPE_OUTPUT_PROPERTIES, + }, + project: { + type: 'object', + description: 'Project the issue belongs to', + properties: PROJECT_OUTPUT_PROPERTIES, + }, + priority: { + type: 'object', + description: 'Issue priority', + properties: PRIORITY_OUTPUT_PROPERTIES, + optional: true, + }, + assignee: { + type: 'object', + description: 'Assigned user', + properties: USER_OUTPUT_PROPERTIES, + optional: true, + }, + reporter: { + type: 'object', + description: 'Reporter user', + properties: USER_OUTPUT_PROPERTIES, + optional: true, + }, + labels: { + type: 'array', + description: 'Issue labels', + items: { type: 'string' }, + }, + components: { + type: 'array', + description: 'Issue components', + items: { + type: 'object', + properties: COMPONENT_OUTPUT_PROPERTIES, + }, + optional: true, + }, + resolution: { + type: 'object', + description: 'Issue resolution', + properties: RESOLUTION_OUTPUT_PROPERTIES, + optional: true, + }, + duedate: { type: 'string', description: 'Due date (YYYY-MM-DD)', optional: true }, + created: { type: 'string', description: 'ISO 8601 timestamp when the issue was created' }, + updated: { type: 'string', description: 'ISO 8601 timestamp when the issue was last updated' }, +} as const satisfies Record + +/** + * Common timestamp output property. + */ +export const TIMESTAMP_OUTPUT: OutputProperty = { + type: 'string', + description: 'ISO 8601 timestamp of the operation', +} + +/** + * Common issue key output property. + */ +export const ISSUE_KEY_OUTPUT: OutputProperty = { + type: 'string', + description: 'Jira issue key (e.g., PROJ-123)', +} + +/** + * Common success status output property. + */ +export const SUCCESS_OUTPUT: OutputProperty = { + type: 'boolean', + description: 'Operation success status', +} + +// --- Parameter interfaces --- export interface JiraRetrieveParams { accessToken: string @@ -11,11 +747,122 @@ export interface JiraRetrieveParams { export interface JiraRetrieveResponse extends ToolResponse { output: { ts: string + id: string issueKey: string + key: string + self: string summary: string - description: string + description: string | null + status: { + id: string + name: string + description?: string + statusCategory?: { + id: number + key: string + name: string + colorName: string + } + } + issuetype: { + id: string + name: string + description?: string + subtask: boolean + iconUrl?: string + } + project: { + id: string + key: string + name: string + projectTypeKey?: string + } + priority: { + id: string + name: string + iconUrl?: string + } | null + assignee: { + accountId: string + displayName: string + active?: boolean + emailAddress?: string + avatarUrl?: string + } | null + reporter: { + accountId: string + displayName: string + active?: boolean + emailAddress?: string + avatarUrl?: string + } | null + creator: { + accountId: string + displayName: string + active?: boolean + } | null + labels: string[] + components: Array<{ id: string; name: string; description?: string }> + fixVersions: Array<{ id: string; name: string; released?: boolean; releaseDate?: string }> + resolution: { id: string; name: string; description?: string } | null + duedate: string | null created: string updated: string + resolutiondate: string | null + timetracking: { + originalEstimate?: string + remainingEstimate?: string + timeSpent?: string + originalEstimateSeconds?: number + remainingEstimateSeconds?: number + timeSpentSeconds?: number + } | null + parent: { id: string; key: string; summary?: string } | null + issuelinks: Array<{ + id: string + type: { id: string; name: string; inward: string; outward: string } + inwardIssue?: { id: string; key: string; statusName?: string; summary?: string } + outwardIssue?: { id: string; key: string; statusName?: string; summary?: string } + }> + subtasks: Array<{ + id: string + key: string + summary: string + statusName: string + issueTypeName?: string + }> + votes: { votes: number; hasVoted: boolean } | null + watches: { watchCount: number; isWatching: boolean } | null + comments: Array<{ + id: string + body: string + author: { accountId: string; displayName: string } | null + updateAuthor?: { accountId: string; displayName: string } | null + created: string + updated: string + }> + worklogs: Array<{ + id: string + author: { accountId: string; displayName: string } | null + updateAuthor?: { accountId: string; displayName: string } | null + comment?: string | null + started: string + timeSpent: string + timeSpentSeconds: number + created: string + updated: string + }> + attachments: Array<{ + id: string + filename: string + mimeType: string + size: number + content: string + thumbnail?: string | null + author: { accountId: string; displayName: string } | null + created: string + }> + issue: Record } } @@ -29,11 +876,23 @@ export interface JiraRetrieveBulkParams { export interface JiraRetrieveResponseBulk extends ToolResponse { output: { ts: string - summary: string - description: string - created: string - updated: string - }[] + total: number | null + issues: Array<{ + id: string + key: string + self: string + summary: string + description: string | null + status: { id: string; name: string } + issuetype: { id: string; name: string } + priority: { id: string; name: string } | null + assignee: { accountId: string; displayName: string } | null + created: string + updated: string + }> + nextPageToken: string | null + isLast: boolean + } } export interface JiraUpdateParams { @@ -42,11 +901,17 @@ export interface JiraUpdateParams { projectId?: string issueKey: string summary?: string - title?: string description?: string - status?: string priority?: string assignee?: string + labels?: string[] + components?: string[] + duedate?: string + fixVersions?: string[] + environment?: string + customFieldId?: string + customFieldValue?: string + notifyUsers?: boolean cloudId?: string } @@ -71,7 +936,9 @@ export interface JiraWriteParams { issueType: string parent?: { key: string } labels?: string[] + components?: string[] duedate?: string + fixVersions?: string[] reporter?: string environment?: string customFieldId?: string @@ -81,10 +948,13 @@ export interface JiraWriteParams { export interface JiraWriteResponse extends ToolResponse { output: { ts: string + id: string issueKey: string + self: string summary: string success: boolean url: string + assigneeId: string | null } } @@ -112,7 +982,6 @@ export interface JiraCloudResource { avatarUrl: string } -// Delete Issue export interface JiraDeleteIssueParams { accessToken: string domain: string @@ -129,7 +998,6 @@ export interface JiraDeleteIssueResponse extends ToolResponse { } } -// Assign Issue export interface JiraAssignIssueParams { accessToken: string domain: string @@ -147,13 +1015,13 @@ export interface JiraAssignIssueResponse extends ToolResponse { } } -// Transition Issue export interface JiraTransitionIssueParams { accessToken: string domain: string issueKey: string transitionId: string comment?: string + resolution?: string cloudId?: string } @@ -162,16 +1030,17 @@ export interface JiraTransitionIssueResponse extends ToolResponse { ts: string issueKey: string transitionId: string + transitionName: string | null + toStatus: { id: string; name: string } | null success: boolean } } -// Search Issues export interface JiraSearchIssuesParams { accessToken: string domain: string jql: string - startAt?: number + nextPageToken?: string maxResults?: number fields?: string[] cloudId?: string @@ -180,27 +1049,41 @@ export interface JiraSearchIssuesParams { export interface JiraSearchIssuesResponse extends ToolResponse { output: { ts: string - total: number - startAt: number - maxResults: number issues: Array<{ + id: string key: string + self: string summary: string - status: string - assignee?: string - priority?: string + description: string | null + status: { + id: string + name: string + statusCategory?: { id: number; key: string; name: string; colorName: string } + } + issuetype: { id: string; name: string; subtask: boolean } + project: { id: string; key: string; name: string } + priority: { id: string; name: string } | null + assignee: { accountId: string; displayName: string } | null + reporter: { accountId: string; displayName: string } | null + labels: string[] + components: Array<{ id: string; name: string }> + resolution: { id: string; name: string } | null + duedate: string | null created: string updated: string }> + nextPageToken: string | null + isLast: boolean + total: number | null } } -// Comments export interface JiraAddCommentParams { accessToken: string domain: string issueKey: string body: string + visibility?: { type: string; value: string } cloudId?: string } @@ -210,6 +1093,9 @@ export interface JiraAddCommentResponse extends ToolResponse { issueKey: string commentId: string body: string + author: { accountId: string; displayName: string } + created: string + updated: string success: boolean } } @@ -220,6 +1106,7 @@ export interface JiraGetCommentsParams { issueKey: string startAt?: number maxResults?: number + orderBy?: string cloudId?: string } @@ -228,12 +1115,16 @@ export interface JiraGetCommentsResponse extends ToolResponse { ts: string issueKey: string total: number + startAt: number + maxResults: number comments: Array<{ id: string - author: string body: string + author: { accountId: string; displayName: string; active?: boolean } + updateAuthor: { accountId: string; displayName: string } | null created: string updated: string + visibility: { type: string; value: string } | null }> } } @@ -244,6 +1135,7 @@ export interface JiraUpdateCommentParams { issueKey: string commentId: string body: string + visibility?: { type: string; value: string } cloudId?: string } @@ -253,6 +1145,9 @@ export interface JiraUpdateCommentResponse extends ToolResponse { issueKey: string commentId: string body: string + author: { accountId: string; displayName: string } + created: string + updated: string success: boolean } } @@ -274,7 +1169,6 @@ export interface JiraDeleteCommentResponse extends ToolResponse { } } -// Attachments export interface JiraGetAttachmentsParams { accessToken: string domain: string @@ -289,11 +1183,12 @@ export interface JiraGetAttachmentsResponse extends ToolResponse { attachments: Array<{ id: string filename: string - author: string - created: string - size: number mimeType: string + size: number content: string + thumbnail: string | null + author: { accountId: string; displayName: string } | null + created: string }> } } @@ -325,12 +1220,22 @@ export interface JiraAddAttachmentResponse extends ToolResponse { output: { ts: string issueKey: string + attachments: Array<{ + id: string + filename: string + mimeType: string + size: number + content: string + }> attachmentIds: string[] - files: ToolFileData[] + files: Array<{ + name: string + mimeType: string + size: number + }> } } -// Worklogs export interface JiraAddWorklogParams { accessToken: string domain: string @@ -338,6 +1243,7 @@ export interface JiraAddWorklogParams { timeSpentSeconds: number comment?: string started?: string + visibility?: { type: string; value: string } cloudId?: string } @@ -346,7 +1252,11 @@ export interface JiraAddWorklogResponse extends ToolResponse { ts: string issueKey: string worklogId: string + timeSpent: string timeSpentSeconds: number + author: { accountId: string; displayName: string } + started: string + created: string success: boolean } } @@ -365,15 +1275,18 @@ export interface JiraGetWorklogsResponse extends ToolResponse { ts: string issueKey: string total: number + startAt: number + maxResults: number worklogs: Array<{ id: string - author: string - timeSpentSeconds: number + author: { accountId: string; displayName: string } + updateAuthor: { accountId: string; displayName: string } | null + comment: string | null + started: string timeSpent: string - comment?: string + timeSpentSeconds: number created: string updated: string - started: string }> } } @@ -386,6 +1299,7 @@ export interface JiraUpdateWorklogParams { timeSpentSeconds?: number comment?: string started?: string + visibility?: { type: string; value: string } cloudId?: string } @@ -394,6 +1308,8 @@ export interface JiraUpdateWorklogResponse extends ToolResponse { ts: string issueKey: string worklogId: string + timeSpent: string | null + timeSpentSeconds: number | null success: boolean } } @@ -415,7 +1331,6 @@ export interface JiraDeleteWorklogResponse extends ToolResponse { } } -// Issue Links export interface JiraCreateIssueLinkParams { accessToken: string domain: string @@ -432,6 +1347,7 @@ export interface JiraCreateIssueLinkResponse extends ToolResponse { inwardIssue: string outwardIssue: string linkType: string + linkId: string | null success: boolean } } @@ -451,7 +1367,6 @@ export interface JiraDeleteIssueLinkResponse extends ToolResponse { } } -// Watchers export interface JiraAddWatcherParams { accessToken: string domain: string @@ -486,6 +1401,33 @@ export interface JiraRemoveWatcherResponse extends ToolResponse { } } +export interface JiraGetUsersParams { + accessToken: string + domain: string + accountId?: string + startAt?: number + maxResults?: number + cloudId?: string +} + +export interface JiraGetUsersResponse extends ToolResponse { + output: { + ts: string + users: Array<{ + accountId: string + accountType?: string + active: boolean + displayName: string + emailAddress?: string + avatarUrl?: string + timeZone?: string + }> + total: number + startAt: number + maxResults: number + } +} + export type JiraResponse = | JiraRetrieveResponse | JiraUpdateResponse @@ -510,3 +1452,4 @@ export type JiraResponse = | JiraDeleteIssueLinkResponse | JiraAddWatcherResponse | JiraRemoveWatcherResponse + | JiraGetUsersResponse diff --git a/apps/sim/tools/jira/update.ts b/apps/sim/tools/jira/update.ts index c9a656838..bf42d6cd2 100644 --- a/apps/sim/tools/jira/update.ts +++ b/apps/sim/tools/jira/update.ts @@ -1,4 +1,5 @@ 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 = { @@ -25,12 +26,6 @@ export const jiraUpdateTool: ToolConfig = 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, @@ -49,23 +44,65 @@ export const jiraUpdateTool: ToolConfig = 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 for the issue', + description: 'New priority ID or name for the issue (e.g., "High")', }, assignee: { type: 'string', required: false, visibility: 'user-or-llm', - description: 'New assignee for the issue', + 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)', }, cloudId: { type: 'string', @@ -83,17 +120,22 @@ export const jiraUpdateTool: ToolConfig = '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, } }, @@ -116,12 +158,10 @@ export const jiraUpdateTool: ToolConfig = 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 || { @@ -135,7 +175,7 @@ export const jiraUpdateTool: ToolConfig = }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, issueKey: { type: 'string', description: 'Updated issue key (e.g., PROJ-123)' }, summary: { type: 'string', description: 'Issue summary after update' }, }, diff --git a/apps/sim/tools/jira/update_comment.ts b/apps/sim/tools/jira/update_comment.ts index b469e24f0..d9c273987 100644 --- a/apps/sim/tools/jira/update_comment.ts +++ b/apps/sim/tools/jira/update_comment.ts @@ -1,7 +1,24 @@ import type { JiraUpdateCommentParams, JiraUpdateCommentResponse } from '@/tools/jira/types' -import { getJiraCloudId } from '@/tools/jira/utils' +import { TIMESTAMP_OUTPUT, USER_OUTPUT_PROPERTIES } from '@/tools/jira/types' +import { extractAdfText, getJiraCloudId, transformUser } 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 = { id: 'jira_update_comment', @@ -45,6 +62,13 @@ export const jiraUpdateCommentTool: ToolConfig { if (!params.cloudId) return undefined as any - return { + const payload: Record = { 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) => { - 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 payload: Record = { + 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}` 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({ - body: { - type: 'doc', - version: 1, - content: [ - { - type: 'paragraph', - content: [ - { - type: 'text', - text: params?.body, - }, - ], - }, - ], - }, - }), + body: JSON.stringify(payload), }) if (!commentResponse.ok) { @@ -131,48 +148,46 @@ export const jiraUpdateCommentTool: ToolConfig = { + 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 = { id: 'jira_update_worklog', @@ -57,6 +101,13 @@ export const jiraUpdateWorklogTool: ToolConfig { if (!params.cloudId) return undefined as any - 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, - } + return buildWorklogBody(params) }, }, transformResponse: async (response: Response, params?: JiraUpdateWorklogParams) => { if (!params?.cloudId) { 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/${params?.worklogId}` + 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({ - 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, - }), + body: JSON.stringify(buildWorklogBody(params!)), }) if (!worklogResponse.ok) { @@ -152,19 +162,12 @@ export const jiraUpdateWorklogTool: ToolConfig { const response = await fetch('https://api.atlassian.com/oauth/token/accessible-resources', { method: 'GET', diff --git a/apps/sim/tools/jira/write.ts b/apps/sim/tools/jira/write.ts index bf2816be0..47c8be58b 100644 --- a/apps/sim/tools/jira/write.ts +++ b/apps/sim/tools/jira/write.ts @@ -1,10 +1,11 @@ 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 = { id: 'jira_write', name: 'Jira Write', - description: 'Write a Jira issue', + description: 'Create a new Jira issue', version: '1.0.0', oauth: { @@ -65,8 +66,14 @@ export const jiraWriteTool: ToolConfig = { issueType: { type: 'string', required: true, - visibility: 'hidden', - description: 'Type of issue to create (e.g., Task, Story)', + 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" })', }, labels: { type: 'array', @@ -74,12 +81,24 @@ export const jiraWriteTool: ToolConfig = { 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, @@ -113,7 +132,6 @@ export const jiraWriteTool: ToolConfig = { 'Content-Type': 'application/json', }), body: (params) => { - // Pass all parameters to the internal API route return { domain: params.domain, accessToken: params.accessToken, @@ -126,7 +144,9 @@ export const jiraWriteTool: ToolConfig = { 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, @@ -143,39 +163,62 @@ export const jiraWriteTool: ToolConfig = { 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 data + 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, + }, + } } - // Fallback for unexpected response format return { success: data.success || false, - output: data.output || { + output: { ts: new Date().toISOString(), - issueKey: 'unknown', - summary: 'Issue created', + id: data.output?.id ?? '', + issueKey: data.output?.issueKey ?? 'unknown', + self: data.output?.self ?? '', + summary: data.output?.summary ?? 'Issue created', success: false, + url: data.output?.url ?? '', + assigneeId: data.output?.assigneeId ?? null, }, error: data.error, } }, outputs: { - ts: { type: 'string', description: 'Timestamp of the operation' }, + ts: TIMESTAMP_OUTPUT, + id: { type: 'string', description: 'Created issue ID' }, 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' }, - assigneeId: { type: 'string', description: 'Account ID of the assigned user (if assigned)' }, + 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, + }, }, } diff --git a/apps/sim/tools/jsm/add_comment.ts b/apps/sim/tools/jsm/add_comment.ts index 971836eac..e23069a13 100644 --- a/apps/sim/tools/jsm/add_comment.ts +++ b/apps/sim/tools/jsm/add_comment.ts @@ -1,4 +1,5 @@ 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 = { @@ -79,6 +80,8 @@ export const jsmAddCommentTool: ToolConfig = { @@ -107,7 +108,14 @@ export const jsmGetApprovalsTool: ToolConfig = { @@ -49,6 +50,12 @@ export const jsmGetCommentsTool: ToolConfig = { @@ -110,7 +111,14 @@ export const jsmGetCustomersTool: ToolConfig = { @@ -110,7 +111,14 @@ export const jsmGetQueuesTool: ToolConfig = { @@ -37,6 +42,13 @@ export const jsmGetRequestTool: ToolConfig = { + 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, + }, + }, + }, +} diff --git a/apps/sim/tools/jsm/get_request_types.ts b/apps/sim/tools/jsm/get_request_types.ts index 717d64239..715715a83 100644 --- a/apps/sim/tools/jsm/get_request_types.ts +++ b/apps/sim/tools/jsm/get_request_types.ts @@ -1,4 +1,5 @@ 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< @@ -40,6 +41,24 @@ 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, @@ -65,6 +84,9 @@ 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, }), @@ -106,7 +128,14 @@ export const jsmGetRequestTypesTool: ToolConfig< outputs: { ts: { type: 'string', description: 'Timestamp of the operation' }, - requestTypes: { type: 'json', description: 'Array of request types' }, + requestTypes: { + type: 'array', + description: 'List of request types', + items: { + type: 'object', + properties: REQUEST_TYPE_ITEM_PROPERTIES, + }, + }, total: { type: 'number', description: 'Total number of request types' }, isLastPage: { type: 'boolean', description: 'Whether this is the last page' }, }, diff --git a/apps/sim/tools/jsm/get_requests.ts b/apps/sim/tools/jsm/get_requests.ts index 2f769c20e..5aca92bd0 100644 --- a/apps/sim/tools/jsm/get_requests.ts +++ b/apps/sim/tools/jsm/get_requests.ts @@ -1,4 +1,5 @@ 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 = { @@ -42,13 +43,19 @@ export const jsmGetRequestsTool: ToolConfig = { @@ -106,7 +107,14 @@ export const jsmGetSlaTool: ToolConfig = { outputs: { ts: { type: 'string', description: 'Timestamp of the operation' }, issueIdOrKey: { type: 'string', description: 'Issue ID or key' }, - slas: { type: 'json', description: 'Array of SLA information' }, + slas: { + type: 'array', + description: 'List of SLA metrics', + items: { + type: 'object', + properties: SLA_ITEM_PROPERTIES, + }, + }, total: { type: 'number', description: 'Total number of SLAs' }, isLastPage: { type: 'boolean', description: 'Whether this is the last page' }, }, diff --git a/apps/sim/tools/jsm/get_transitions.ts b/apps/sim/tools/jsm/get_transitions.ts index 41a61f482..d864cf747 100644 --- a/apps/sim/tools/jsm/get_transitions.ts +++ b/apps/sim/tools/jsm/get_transitions.ts @@ -1,4 +1,5 @@ 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 = @@ -38,6 +39,18 @@ export const jsmGetTransitionsTool: ToolConfig ongoingCycle?: { startTime: { iso8601: string } @@ -115,11 +349,192 @@ 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 + 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 @@ -129,12 +544,6 @@ export interface JsmGetServiceDesksResponse extends ToolResponse { } } -export interface JsmGetRequestTypesParams extends JsmBaseParams { - serviceDeskId: string - start?: number - limit?: number -} - export interface JsmGetRequestTypesResponse extends ToolResponse { output: { ts: string @@ -144,15 +553,6 @@ export interface JsmGetRequestTypesResponse extends ToolResponse { } } -export interface JsmCreateRequestParams extends JsmBaseParams { - serviceDeskId: string - requestTypeId: string - summary: string - description?: string - requestFieldValues?: Record - raiseOnBehalfOf?: string -} - export interface JsmCreateRequestResponse extends ToolResponse { output: { ts: string @@ -160,31 +560,43 @@ 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 - request: JsmRequest + 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 } } -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 @@ -194,12 +606,6 @@ export interface JsmGetRequestsResponse extends ToolResponse { } } -export interface JsmAddCommentParams extends JsmBaseParams { - issueIdOrKey: string - body: string - isPublic: boolean -} - export interface JsmAddCommentResponse extends ToolResponse { output: { ts: string @@ -207,18 +613,12 @@ 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 @@ -229,13 +629,6 @@ 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 @@ -245,11 +638,6 @@ export interface JsmGetCustomersResponse extends ToolResponse { } } -export interface JsmAddCustomerParams extends JsmBaseParams { - serviceDeskId: string - emails: string -} - export interface JsmAddCustomerResponse extends ToolResponse { output: { ts: string @@ -258,12 +646,6 @@ export interface JsmAddCustomerResponse extends ToolResponse { } } -export interface JsmGetOrganizationsParams extends JsmBaseParams { - serviceDeskId: string - start?: number - limit?: number -} - export interface JsmGetOrganizationsResponse extends ToolResponse { output: { ts: string @@ -273,13 +655,6 @@ 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 @@ -289,12 +664,6 @@ export interface JsmGetQueuesResponse extends ToolResponse { } } -export interface JsmGetSlaParams extends JsmBaseParams { - issueIdOrKey: string - start?: number - limit?: number -} - export interface JsmGetSlaResponse extends ToolResponse { output: { ts: string @@ -305,12 +674,6 @@ export interface JsmGetSlaResponse extends ToolResponse { } } -export interface JsmTransitionRequestParams extends JsmBaseParams { - issueIdOrKey: string - transitionId: string - comment?: string -} - export interface JsmTransitionRequestResponse extends ToolResponse { output: { ts: string @@ -320,22 +683,16 @@ 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 @@ -345,11 +702,6 @@ export interface JsmCreateOrganizationResponse extends ToolResponse { } } -export interface JsmAddOrganizationParams extends JsmBaseParams { - serviceDeskId: string - organizationId: string -} - export interface JsmAddOrganizationResponse extends ToolResponse { output: { ts: string @@ -359,19 +711,6 @@ 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 @@ -382,11 +721,6 @@ export interface JsmGetParticipantsResponse extends ToolResponse { } } -export interface JsmAddParticipantsParams extends JsmBaseParams { - issueIdOrKey: string - accountIds: string -} - export interface JsmAddParticipantsResponse extends ToolResponse { output: { ts: string @@ -396,29 +730,6 @@ 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 @@ -429,22 +740,47 @@ 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 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 @@ -467,3 +803,4 @@ export type JsmResponse = | JsmAddParticipantsResponse | JsmGetApprovalsResponse | JsmAnswerApprovalResponse + | JsmGetRequestTypeFieldsResponse diff --git a/apps/sim/tools/onepassword/create_item.ts b/apps/sim/tools/onepassword/create_item.ts new file mode 100644 index 000000000..5f9b70a07 --- /dev/null +++ b/apps/sim/tools/onepassword/create_item.ts @@ -0,0 +1,104 @@ +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, +} diff --git a/apps/sim/tools/onepassword/delete_item.ts b/apps/sim/tools/onepassword/delete_item.ts new file mode 100644 index 000000000..08990a19a --- /dev/null +++ b/apps/sim/tools/onepassword/delete_item.ts @@ -0,0 +1,84 @@ +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' }, + }, +} diff --git a/apps/sim/tools/onepassword/get_item.ts b/apps/sim/tools/onepassword/get_item.ts new file mode 100644 index 000000000..8049d7260 --- /dev/null +++ b/apps/sim/tools/onepassword/get_item.ts @@ -0,0 +1,78 @@ +import type { + OnePasswordGetItemParams, + OnePasswordGetItemResponse, +} from '@/tools/onepassword/types' +import { FULL_ITEM_OUTPUTS, transformFullItem } from '@/tools/onepassword/utils' +import type { ToolConfig } from '@/tools/types' + +export const getItemTool: ToolConfig = { + id: 'onepassword_get_item', + name: '1Password Get Item', + description: 'Get full details of an item including all fields and secrets', + 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 retrieve', + }, + }, + + request: { + url: '/api/tools/onepassword/get-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: transformFullItem({}), error: data.error } + } + return { + success: true, + output: transformFullItem(data), + } + }, + + outputs: FULL_ITEM_OUTPUTS, +} diff --git a/apps/sim/tools/onepassword/get_vault.ts b/apps/sim/tools/onepassword/get_vault.ts new file mode 100644 index 000000000..cf2b63a44 --- /dev/null +++ b/apps/sim/tools/onepassword/get_vault.ts @@ -0,0 +1,107 @@ +import type { + OnePasswordGetVaultParams, + OnePasswordGetVaultResponse, +} from '@/tools/onepassword/types' +import type { ToolConfig } from '@/tools/types' + +export const getVaultTool: ToolConfig = { + id: 'onepassword_get_vault', + name: '1Password Get Vault', + description: 'Get details of a specific vault by ID', + 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', + }, + }, + + request: { + url: '/api/tools/onepassword/get-vault', + method: 'POST', + headers: () => ({ 'Content-Type': 'application/json' }), + body: (params) => ({ + connectionMode: params.connectionMode, + serviceAccountToken: params.serviceAccountToken, + serverUrl: params.serverUrl, + apiKey: params.apiKey, + vaultId: params.vaultId, + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + if (data.error) { + return { + success: false, + output: { + id: '', + name: '', + description: null, + attributeVersion: 0, + contentVersion: 0, + items: 0, + type: '', + createdAt: null, + updatedAt: null, + }, + error: data.error, + } + } + return { + success: true, + output: { + id: data.id ?? null, + name: data.name ?? null, + description: data.description ?? null, + attributeVersion: data.attributeVersion ?? 0, + contentVersion: data.contentVersion ?? 0, + items: data.items ?? 0, + type: data.type ?? null, + createdAt: data.createdAt ?? null, + updatedAt: data.updatedAt ?? null, + }, + } + }, + + outputs: { + id: { type: 'string', description: 'Vault ID' }, + name: { type: 'string', description: 'Vault name' }, + description: { type: 'string', description: 'Vault description', optional: true }, + attributeVersion: { type: 'number', description: 'Vault attribute version' }, + contentVersion: { type: 'number', description: 'Vault content version' }, + items: { type: 'number', description: 'Number of items in the vault' }, + type: { + type: 'string', + description: 'Vault type (USER_CREATED, PERSONAL, EVERYONE, TRANSFER)', + }, + createdAt: { type: 'string', description: 'Creation timestamp', optional: true }, + updatedAt: { type: 'string', description: 'Last update timestamp', optional: true }, + }, +} diff --git a/apps/sim/tools/onepassword/index.ts b/apps/sim/tools/onepassword/index.ts new file mode 100644 index 000000000..f51526b06 --- /dev/null +++ b/apps/sim/tools/onepassword/index.ts @@ -0,0 +1,19 @@ +import { createItemTool } from '@/tools/onepassword/create_item' +import { deleteItemTool } from '@/tools/onepassword/delete_item' +import { getItemTool } from '@/tools/onepassword/get_item' +import { getVaultTool } from '@/tools/onepassword/get_vault' +import { listItemsTool } from '@/tools/onepassword/list_items' +import { listVaultsTool } from '@/tools/onepassword/list_vaults' +import { replaceItemTool } from '@/tools/onepassword/replace_item' +import { resolveSecretTool } from '@/tools/onepassword/resolve_secret' +import { updateItemTool } from '@/tools/onepassword/update_item' + +export const onepasswordCreateItemTool = createItemTool +export const onepasswordDeleteItemTool = deleteItemTool +export const onepasswordGetItemTool = getItemTool +export const onepasswordGetVaultTool = getVaultTool +export const onepasswordListItemsTool = listItemsTool +export const onepasswordListVaultsTool = listVaultsTool +export const onepasswordReplaceItemTool = replaceItemTool +export const onepasswordResolveSecretTool = resolveSecretTool +export const onepasswordUpdateItemTool = updateItemTool diff --git a/apps/sim/tools/onepassword/list_items.ts b/apps/sim/tools/onepassword/list_items.ts new file mode 100644 index 000000000..4bcad6e65 --- /dev/null +++ b/apps/sim/tools/onepassword/list_items.ts @@ -0,0 +1,141 @@ +import type { + OnePasswordListItemsParams, + OnePasswordListItemsResponse, +} from '@/tools/onepassword/types' +import type { ToolConfig } from '@/tools/types' + +export const listItemsTool: ToolConfig = { + id: 'onepassword_list_items', + name: '1Password List Items', + description: 'List items in a vault. Returns summaries without field values.', + 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 list items from', + }, + filter: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'SCIM filter expression (e.g., title eq "API Key" or tag eq "production")', + }, + }, + + request: { + url: '/api/tools/onepassword/list-items', + method: 'POST', + headers: () => ({ 'Content-Type': 'application/json' }), + body: (params) => ({ + connectionMode: params.connectionMode, + serviceAccountToken: params.serviceAccountToken, + serverUrl: params.serverUrl, + apiKey: params.apiKey, + vaultId: params.vaultId, + filter: params.filter, + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + if (data.error) { + return { success: false, output: { items: [] }, error: data.error } + } + const items = Array.isArray(data) ? data : [data] + return { + success: true, + output: { + items: items.map((item: any) => ({ + id: item.id ?? null, + title: item.title ?? null, + vault: item.vault ?? null, + category: item.category ?? null, + urls: (item.urls ?? []).map((url: any) => ({ + href: url.href ?? null, + label: url.label ?? null, + primary: url.primary ?? false, + })), + favorite: item.favorite ?? false, + tags: item.tags ?? [], + version: item.version ?? 0, + state: item.state ?? null, + createdAt: item.createdAt ?? null, + updatedAt: item.updatedAt ?? null, + lastEditedBy: item.lastEditedBy ?? null, + })), + }, + } + }, + + outputs: { + items: { + type: 'array', + description: 'List of items in the vault (summaries without field values)', + items: { + type: 'object', + properties: { + id: { type: 'string', description: 'Item ID' }, + title: { type: 'string', description: 'Item title' }, + vault: { + type: 'object', + description: 'Vault reference', + properties: { + id: { type: 'string', description: 'Vault ID' }, + }, + }, + category: { type: 'string', description: 'Item category (e.g., LOGIN, API_CREDENTIAL)' }, + urls: { + type: 'array', + description: 'URLs associated with the item', + optional: true, + items: { + type: 'object', + properties: { + href: { type: 'string', description: 'URL' }, + label: { type: 'string', description: 'URL label', optional: true }, + primary: { type: 'boolean', description: 'Whether this is the primary URL' }, + }, + }, + }, + favorite: { type: 'boolean', description: 'Whether the item is favorited' }, + tags: { type: 'array', description: 'Item tags' }, + version: { type: 'number', description: 'Item version number' }, + state: { + type: 'string', + description: 'Item state (ARCHIVED or DELETED)', + optional: true, + }, + createdAt: { type: 'string', description: 'Creation timestamp', optional: true }, + updatedAt: { type: 'string', description: 'Last update timestamp', optional: true }, + lastEditedBy: { type: 'string', description: 'ID of the last editor', optional: true }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/onepassword/list_vaults.ts b/apps/sim/tools/onepassword/list_vaults.ts new file mode 100644 index 000000000..64af64ec7 --- /dev/null +++ b/apps/sim/tools/onepassword/list_vaults.ts @@ -0,0 +1,108 @@ +import type { + OnePasswordListVaultsParams, + OnePasswordListVaultsResponse, +} from '@/tools/onepassword/types' +import type { ToolConfig } from '@/tools/types' + +export const listVaultsTool: ToolConfig< + OnePasswordListVaultsParams, + OnePasswordListVaultsResponse +> = { + id: 'onepassword_list_vaults', + name: '1Password List Vaults', + description: 'List all vaults accessible by the Connect token or Service Account', + 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)', + }, + filter: { + type: 'string', + required: false, + visibility: 'user-or-llm', + description: 'SCIM filter expression (e.g., name eq "My Vault")', + }, + }, + + request: { + url: '/api/tools/onepassword/list-vaults', + method: 'POST', + headers: () => ({ 'Content-Type': 'application/json' }), + body: (params) => ({ + connectionMode: params.connectionMode, + serviceAccountToken: params.serviceAccountToken, + serverUrl: params.serverUrl, + apiKey: params.apiKey, + filter: params.filter, + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + if (data.error) { + return { success: false, output: { vaults: [] }, error: data.error } + } + const vaults = Array.isArray(data) ? data : [data] + return { + success: true, + output: { + vaults: vaults.map((vault: any) => ({ + id: vault.id ?? null, + name: vault.name ?? null, + description: vault.description ?? null, + attributeVersion: vault.attributeVersion ?? 0, + contentVersion: vault.contentVersion ?? 0, + items: vault.items ?? 0, + type: vault.type ?? null, + createdAt: vault.createdAt ?? null, + updatedAt: vault.updatedAt ?? null, + })), + }, + } + }, + + outputs: { + vaults: { + type: 'array', + description: 'List of accessible vaults', + items: { + type: 'object', + properties: { + id: { type: 'string', description: 'Vault ID' }, + name: { type: 'string', description: 'Vault name' }, + description: { type: 'string', description: 'Vault description', optional: true }, + attributeVersion: { type: 'number', description: 'Vault attribute version' }, + contentVersion: { type: 'number', description: 'Vault content version' }, + items: { type: 'number', description: 'Number of items in the vault' }, + type: { + type: 'string', + description: 'Vault type (USER_CREATED, PERSONAL, EVERYONE, TRANSFER)', + }, + createdAt: { type: 'string', description: 'Creation timestamp', optional: true }, + updatedAt: { type: 'string', description: 'Last update timestamp', optional: true }, + }, + }, + }, + }, +} diff --git a/apps/sim/tools/onepassword/replace_item.ts b/apps/sim/tools/onepassword/replace_item.ts new file mode 100644 index 000000000..4d8506fb9 --- /dev/null +++ b/apps/sim/tools/onepassword/replace_item.ts @@ -0,0 +1,89 @@ +import type { + OnePasswordReplaceItemParams, + OnePasswordReplaceItemResponse, +} from '@/tools/onepassword/types' +import { FULL_ITEM_OUTPUTS, transformFullItem } from '@/tools/onepassword/utils' +import type { ToolConfig } from '@/tools/types' + +export const replaceItemTool: ToolConfig< + OnePasswordReplaceItemParams, + OnePasswordReplaceItemResponse +> = { + id: 'onepassword_replace_item', + name: '1Password Replace Item', + description: 'Replace an entire item with new data (full update)', + 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 replace', + }, + item: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'JSON object representing the full item (e.g., {"vault":{"id":"..."},"category":"LOGIN","title":"My Item","fields":[...]})', + }, + }, + + request: { + url: '/api/tools/onepassword/replace-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, + item: params.item, + }), + }, + + 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, +} diff --git a/apps/sim/tools/onepassword/resolve_secret.ts b/apps/sim/tools/onepassword/resolve_secret.ts new file mode 100644 index 000000000..7b2820e07 --- /dev/null +++ b/apps/sim/tools/onepassword/resolve_secret.ts @@ -0,0 +1,67 @@ +import type { + OnePasswordResolveSecretParams, + OnePasswordResolveSecretResponse, +} from '@/tools/onepassword/types' +import type { ToolConfig } from '@/tools/types' + +export const resolveSecretTool: ToolConfig< + OnePasswordResolveSecretParams, + OnePasswordResolveSecretResponse +> = { + id: 'onepassword_resolve_secret', + name: '1Password Resolve Secret', + description: + 'Resolve a secret reference (op://vault/item/field) to its value. Service Account mode only.', + version: '1.0.0', + + params: { + connectionMode: { + type: 'string', + required: false, + description: 'Connection mode: must be "service_account" for this operation', + }, + serviceAccountToken: { + type: 'string', + required: true, + visibility: 'user-only', + description: '1Password Service Account token', + }, + secretReference: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'Secret reference URI (e.g., op://vault-name/item-name/field-name or op://vault-name/item-name/section-name/field-name)', + }, + }, + + request: { + url: '/api/tools/onepassword/resolve-secret', + method: 'POST', + headers: () => ({ 'Content-Type': 'application/json' }), + body: (params) => ({ + connectionMode: params.connectionMode ?? 'service_account', + serviceAccountToken: params.serviceAccountToken, + secretReference: params.secretReference, + }), + }, + + transformResponse: async (response) => { + const data = await response.json() + if (data.error) { + return { success: false, output: { value: '', reference: '' }, error: data.error } + } + return { + success: true, + output: { + value: data.value ?? '', + reference: data.reference ?? '', + }, + } + }, + + outputs: { + value: { type: 'string', description: 'The resolved secret value' }, + reference: { type: 'string', description: 'The original secret reference URI' }, + }, +} diff --git a/apps/sim/tools/onepassword/types.ts b/apps/sim/tools/onepassword/types.ts new file mode 100644 index 000000000..688a43953 --- /dev/null +++ b/apps/sim/tools/onepassword/types.ts @@ -0,0 +1,159 @@ +import type { ToolResponse } from '@/tools/types' + +/** Base params shared by all 1Password tools (credential fields). */ +export interface OnePasswordBaseParams { + connectionMode?: 'service_account' | 'connect' + serviceAccountToken?: string + apiKey?: string + serverUrl?: string +} + +export interface OnePasswordListVaultsParams extends OnePasswordBaseParams { + filter?: string +} + +export interface OnePasswordGetVaultParams extends OnePasswordBaseParams { + vaultId: string +} + +export interface OnePasswordListItemsParams extends OnePasswordBaseParams { + vaultId: string + filter?: string +} + +export interface OnePasswordGetItemParams extends OnePasswordBaseParams { + vaultId: string + itemId: string +} + +export interface OnePasswordCreateItemParams extends OnePasswordBaseParams { + vaultId: string + category: string + title?: string + tags?: string + fields?: string +} + +export interface OnePasswordUpdateItemParams extends OnePasswordBaseParams { + vaultId: string + itemId: string + operations: string +} + +export interface OnePasswordReplaceItemParams extends OnePasswordBaseParams { + vaultId: string + itemId: string + item: string +} + +export interface OnePasswordDeleteItemParams extends OnePasswordBaseParams { + vaultId: string + itemId: string +} + +export interface OnePasswordResolveSecretParams extends OnePasswordBaseParams { + secretReference: string +} + +export interface OnePasswordListVaultsResponse extends ToolResponse { + output: { + vaults: Array<{ + id: string + name: string + description: string | null + attributeVersion: number + contentVersion: number + items: number + type: string + createdAt: string | null + updatedAt: string | null + }> + } +} + +export interface OnePasswordGetVaultResponse extends ToolResponse { + output: { + id: string + name: string + description: string | null + attributeVersion: number + contentVersion: number + items: number + type: string + createdAt: string | null + updatedAt: string | null + } +} + +export interface OnePasswordListItemsResponse extends ToolResponse { + output: { + items: Array<{ + id: string + title: string + vault: { id: string } + category: string + 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: string | null + }> + } +} + +export interface OnePasswordFullItemResponse extends ToolResponse { + output: { + id: string + title: string + vault: { id: string } + category: string + urls: Array<{ href: string; label: string | null; primary: boolean }> + favorite: boolean + tags: string[] + version: number + state: string | null + fields: Array<{ + id: string + label: string | null + type: string + purpose: string + value: string | null + section: { id: string } | null + generate: boolean + recipe: { + length: number | null + characterSets: string[] + excludeCharacters: string | null + } | null + entropy: number | null + }> + sections: Array<{ + id: string + label: string | null + }> + createdAt: string | null + updatedAt: string | null + lastEditedBy: string | null + } +} + +export type OnePasswordGetItemResponse = OnePasswordFullItemResponse +export type OnePasswordCreateItemResponse = OnePasswordFullItemResponse +export type OnePasswordUpdateItemResponse = OnePasswordFullItemResponse +export type OnePasswordReplaceItemResponse = OnePasswordFullItemResponse + +export interface OnePasswordDeleteItemResponse extends ToolResponse { + output: { + success: boolean + } +} + +export interface OnePasswordResolveSecretResponse extends ToolResponse { + output: { + value: string + reference: string + } +} diff --git a/apps/sim/tools/onepassword/update_item.ts b/apps/sim/tools/onepassword/update_item.ts new file mode 100644 index 000000000..af178dc87 --- /dev/null +++ b/apps/sim/tools/onepassword/update_item.ts @@ -0,0 +1,89 @@ +import type { + OnePasswordUpdateItemParams, + OnePasswordUpdateItemResponse, +} from '@/tools/onepassword/types' +import { FULL_ITEM_OUTPUTS, transformFullItem } from '@/tools/onepassword/utils' +import type { ToolConfig } from '@/tools/types' + +export const updateItemTool: ToolConfig< + OnePasswordUpdateItemParams, + OnePasswordUpdateItemResponse +> = { + id: 'onepassword_update_item', + name: '1Password Update Item', + description: 'Update an existing item using JSON Patch operations (RFC6902)', + 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 update', + }, + operations: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: + 'JSON array of RFC6902 patch operations (e.g., [{"op":"replace","path":"/title","value":"New Title"}])', + }, + }, + + request: { + url: '/api/tools/onepassword/update-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, + operations: params.operations, + }), + }, + + 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, +} diff --git a/apps/sim/tools/onepassword/utils.ts b/apps/sim/tools/onepassword/utils.ts new file mode 100644 index 000000000..d1abbf963 --- /dev/null +++ b/apps/sim/tools/onepassword/utils.ts @@ -0,0 +1,148 @@ +import type { OutputType } from '@/tools/types' + +/** Transforms a raw FullItem API response into our standardized output. */ +export function transformFullItem(data: any) { + return { + id: data.id ?? null, + title: data.title ?? null, + vault: data.vault ?? null, + category: data.category ?? null, + urls: (data.urls ?? []).map((url: any) => ({ + href: url.href ?? null, + label: url.label ?? null, + primary: url.primary ?? false, + })), + favorite: data.favorite ?? false, + tags: data.tags ?? [], + version: data.version ?? 0, + state: data.state ?? null, + fields: (data.fields ?? []).map((field: any) => ({ + id: field.id ?? null, + label: field.label ?? null, + type: field.type ?? 'STRING', + purpose: field.purpose ?? '', + value: field.value ?? null, + section: field.section ?? null, + generate: field.generate ?? false, + recipe: field.recipe + ? { + length: field.recipe.length ?? null, + characterSets: field.recipe.characterSets ?? [], + excludeCharacters: field.recipe.excludeCharacters ?? null, + } + : null, + entropy: field.entropy ?? null, + })), + sections: (data.sections ?? []).map((section: any) => ({ + id: section.id ?? null, + label: section.label ?? null, + })), + createdAt: data.createdAt ?? null, + updatedAt: data.updatedAt ?? null, + lastEditedBy: data.lastEditedBy ?? null, + } +} + +/** Shared output schema for FullItem responses (get_item, create_item, update_item). */ +export const FULL_ITEM_OUTPUTS: Record< + string, + { + type: OutputType + description: string + optional?: boolean + properties?: Record + items?: { type: OutputType; description?: string; properties?: Record } + } +> = { + id: { type: 'string', description: 'Item ID' }, + title: { type: 'string', description: 'Item title' }, + vault: { + type: 'object', + description: 'Vault reference', + properties: { + id: { type: 'string', description: 'Vault ID' }, + }, + }, + category: { + type: 'string', + description: 'Item category (e.g., LOGIN, API_CREDENTIAL, SECURE_NOTE)', + }, + urls: { + type: 'array', + description: 'URLs associated with the item', + optional: true, + items: { + type: 'object', + properties: { + href: { type: 'string', description: 'URL' }, + label: { type: 'string', description: 'URL label', optional: true }, + primary: { type: 'boolean', description: 'Whether this is the primary URL' }, + }, + }, + }, + favorite: { type: 'boolean', description: 'Whether the item is favorited' }, + tags: { type: 'array', description: 'Item tags' }, + version: { type: 'number', description: 'Item version number' }, + state: { type: 'string', description: 'Item state (ARCHIVED or DELETED)', optional: true }, + fields: { + type: 'array', + description: 'Item fields including secrets', + items: { + type: 'object', + properties: { + id: { type: 'string', description: 'Field ID' }, + label: { type: 'string', description: 'Field label', optional: true }, + type: { + type: 'string', + description: 'Field type (STRING, EMAIL, CONCEALED, URL, TOTP, DATE, MONTH_YEAR, MENU)', + }, + purpose: { + type: 'string', + description: 'Field purpose (USERNAME, PASSWORD, NOTES, or empty)', + }, + value: { type: 'string', description: 'Field value', optional: true }, + section: { + type: 'object', + description: 'Section reference this field belongs to', + optional: true, + properties: { + id: { type: 'string', description: 'Section ID' }, + }, + }, + generate: { type: 'boolean', description: 'Whether the field value should be generated' }, + recipe: { + type: 'object', + description: 'Password generation recipe', + optional: true, + properties: { + length: { type: 'number', description: 'Generated password length', optional: true }, + characterSets: { + type: 'array', + description: 'Character sets (LETTERS, DIGITS, SYMBOLS)', + }, + excludeCharacters: { + type: 'string', + description: 'Characters to exclude', + optional: true, + }, + }, + }, + entropy: { type: 'number', description: 'Password entropy score', optional: true }, + }, + }, + }, + sections: { + type: 'array', + description: 'Item sections', + items: { + type: 'object', + properties: { + id: { type: 'string', description: 'Section ID' }, + label: { type: 'string', description: 'Section label', optional: true }, + }, + }, + }, + createdAt: { type: 'string', description: 'Creation timestamp', optional: true }, + updatedAt: { type: 'string', description: 'Last update timestamp', optional: true }, + lastEditedBy: { type: 'string', description: 'ID of the last editor', optional: true }, +} diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index b6941d4ae..7411c53c5 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -849,6 +849,7 @@ import { jsmGetQueuesTool, jsmGetRequestsTool, jsmGetRequestTool, + jsmGetRequestTypeFieldsTool, jsmGetRequestTypesTool, jsmGetServiceDesksTool, jsmGetSlaTool, @@ -1158,6 +1159,17 @@ import { onedriveListTool, onedriveUploadTool, } from '@/tools/onedrive' +import { + onepasswordCreateItemTool, + onepasswordDeleteItemTool, + onepasswordGetItemTool, + onepasswordGetVaultTool, + onepasswordListItemsTool, + onepasswordListVaultsTool, + onepasswordReplaceItemTool, + onepasswordResolveSecretTool, + onepasswordUpdateItemTool, +} from '@/tools/onepassword' import { openAIEmbeddingsTool, openAIImageTool } from '@/tools/openai' import { outlookCopyTool, @@ -1945,6 +1957,7 @@ export const tools: Record = { jira_get_users: jiraGetUsersTool, jsm_get_service_desks: jsmGetServiceDesksTool, jsm_get_request_types: jsmGetRequestTypesTool, + jsm_get_request_type_fields: jsmGetRequestTypeFieldsTool, jsm_create_request: jsmCreateRequestTool, jsm_get_request: jsmGetRequestTool, jsm_get_requests: jsmGetRequestsTool, @@ -2133,6 +2146,15 @@ export const tools: Record = { notion_create_database_v2: notionCreateDatabaseV2Tool, notion_update_page_v2: notionUpdatePageV2Tool, notion_add_database_row_v2: notionAddDatabaseRowTool, + onepassword_list_vaults: onepasswordListVaultsTool, + onepassword_get_vault: onepasswordGetVaultTool, + onepassword_list_items: onepasswordListItemsTool, + onepassword_get_item: onepasswordGetItemTool, + onepassword_create_item: onepasswordCreateItemTool, + onepassword_replace_item: onepasswordReplaceItemTool, + onepassword_update_item: onepasswordUpdateItemTool, + onepassword_delete_item: onepasswordDeleteItemTool, + onepassword_resolve_secret: onepasswordResolveSecretTool, gmail_send: gmailSendTool, gmail_send_v2: gmailSendV2Tool, gmail_read: gmailReadTool, diff --git a/bun.lock b/bun.lock index defa6c36f..31947e602 100644 --- a/bun.lock +++ b/bun.lock @@ -54,6 +54,7 @@ "name": "sim", "version": "0.1.0", "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", @@ -326,6 +327,10 @@ "react-dom": "19.2.1", }, "packages": { + "@1password/sdk": ["@1password/sdk@0.3.1", "", { "dependencies": { "@1password/sdk-core": "0.3.1" } }, "sha512-20zbQfqsjcECT0gvnAw4zONJDt3XQgNH946pZR0NV1Qxukyaz/DKB0cBnBNCCEWZg93Bah8poaR6gJCyuNX14w=="], + + "@1password/sdk-core": ["@1password/sdk-core@0.3.1", "", {}, "sha512-zFkbRznmE47kpke10OpO/9R0AF5csNWS+naFbadgXuFX1LlxY+2C28NSKbCXhLTqmcuWifBfPdZQ728GJ1i5xg=="], + "@a2a-js/sdk": ["@a2a-js/sdk@0.3.7", "", { "dependencies": { "uuid": "^11.1.0" }, "peerDependencies": { "express": "^4.21.2 || ^5.1.0" }, "optionalPeers": ["express"] }, "sha512-1WBghkOjgiKt4rPNje8jlB9VateVQXqyjlc887bY/H8yM82Hlf0+5JW8zB98BPExKAplI5XqtXVH980J6vqi+w=="], "@adobe/css-tools": ["@adobe/css-tools@4.4.4", "", {}, "sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg=="],