Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/docs/content/docs/en/tools/linear.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Fetch and filter issues from Linear

| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `teamId` | string | Yes | Linear team ID |
| `projectId` | string | Yes | Linear project ID |
| `teamId` | string | No | Linear team ID to filter by |
| `projectId` | string | No | Linear project ID to filter by |

#### Output

Expand Down Expand Up @@ -76,7 +76,7 @@ Create a new issue in Linear
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `teamId` | string | Yes | Linear team ID |
| `projectId` | string | Yes | Linear project ID |
| `projectId` | string | No | Linear project ID |
| `title` | string | Yes | Issue title |
| `description` | string | No | Issue description |

Expand Down Expand Up @@ -240,7 +240,7 @@ Edit a comment in Linear
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `commentId` | string | Yes | Comment ID to update |
| `body` | string | Yes | New comment text \(supports Markdown\) |
| `body` | string | No | New comment text \(supports Markdown\) |

#### Output

Expand Down Expand Up @@ -640,7 +640,7 @@ Add an attachment to an issue in Linear
| --------- | ---- | -------- | ----------- |
| `issueId` | string | Yes | Issue ID to attach to |
| `url` | string | Yes | URL of the attachment |
| `title` | string | No | Attachment title |
| `title` | string | Yes | Attachment title |
| `subtitle` | string | No | Attachment subtitle/description |

#### Output
Expand Down Expand Up @@ -676,7 +676,7 @@ Update an attachment metadata in Linear
| Parameter | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `attachmentId` | string | Yes | Attachment ID to update |
| `title` | string | No | New attachment title |
| `title` | string | Yes | New attachment title |
| `subtitle` | string | No | New attachment subtitle |

#### Output
Expand Down
50 changes: 49 additions & 1 deletion apps/sim/blocks/blocks/linear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
placeholder: 'Select a team',
dependsOn: ['credential'],
mode: 'basic',
required: {
field: 'operation',
value: [
'linear_create_issue',
'linear_create_project',
'linear_list_workflow_states',
'linear_create_workflow_state',
'linear_create_cycle',
'linear_get_active_cycle',
],
},
condition: {
field: 'operation',
value: [
Expand All @@ -172,6 +183,17 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
canonicalParamId: 'teamId',
placeholder: 'Enter Linear team ID',
mode: 'advanced',
required: {
field: 'operation',
value: [
'linear_create_issue',
'linear_create_project',
'linear_list_workflow_states',
'linear_create_workflow_state',
'linear_create_cycle',
'linear_get_active_cycle',
],
},
condition: {
field: 'operation',
value: [
Expand Down Expand Up @@ -201,6 +223,16 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
placeholder: 'Select a project',
dependsOn: ['credential', 'teamId'],
mode: 'basic',
required: {
field: 'operation',
value: [
'linear_get_project',
'linear_update_project',
'linear_archive_project',
'linear_delete_project',
'linear_list_project_updates',
],
},
condition: {
field: 'operation',
value: [
Expand All @@ -223,6 +255,18 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
canonicalParamId: 'projectId',
placeholder: 'Enter Linear project ID',
mode: 'advanced',
required: {
field: 'operation',
value: [
'linear_get_project',
'linear_update_project',
'linear_archive_project',
'linear_delete_project',
'linear_create_project_update',
'linear_list_project_updates',
'linear_create_project_link',
],
},
condition: {
field: 'operation',
value: [
Expand Down Expand Up @@ -299,7 +343,10 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
title: 'Comment',
type: 'long-input',
placeholder: 'Enter comment text',
required: true,
required: {
field: 'operation',
value: ['linear_create_comment', 'linear_create_project_update'],
},
condition: {
field: 'operation',
value: ['linear_create_comment', 'linear_update_comment', 'linear_create_project_update'],
Expand Down Expand Up @@ -505,6 +552,7 @@ export const LinearBlock: BlockConfig<LinearResponse> = {
title: 'Title',
type: 'short-input',
placeholder: 'Enter attachment title',
required: true,
condition: {
field: 'operation',
value: ['linear_create_attachment', 'linear_update_attachment'],
Expand Down
15 changes: 12 additions & 3 deletions apps/sim/tools/linear/archive_project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,20 @@ export const linearArchiveProjectTool: ToolConfig<
}
}

const result = data.data.projectArchive
if (!result.success) {
return {
success: false,
error: 'Project archive was not successful',
output: {},
}
}

return {
success: data.data.projectArchive.success,
success: true,
output: {
success: data.data.projectArchive.success,
projectId: response.ok ? data.data.projectArchive.success : '',
success: result.success,
projectId: result.entity?.id || '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: result.entity?.id will always be undefined since the GraphQL query on line 40-45 doesn't request the entity field. Either add entity { id } to the query or use params.projectId here instead.

Suggested change
projectId: result.entity?.id || '',
projectId: params.projectId,
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/linear/archive_project.ts
Line: 77:77

Comment:
**logic:** `result.entity?.id` will always be undefined since the GraphQL query on line 40-45 doesn't request the `entity` field. Either add `entity { id }` to the query or use `params.projectId` here instead.

```suggestion
        projectId: params.projectId,
```

How can I resolve this? If you propose a fix, please make it concise.

},
}
},
Expand Down
5 changes: 2 additions & 3 deletions apps/sim/tools/linear/create_attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const linearCreateAttachmentTool: ToolConfig<
},
title: {
type: 'string',
required: false,
required: true,
visibility: 'user-or-llm',
description: 'Attachment title',
},
Expand Down Expand Up @@ -61,10 +61,9 @@ export const linearCreateAttachmentTool: ToolConfig<
const input: Record<string, any> = {
issueId: params.issueId,
url: params.url,
title: params.title,
}

if (params.title !== undefined && params.title !== null && params.title !== '')
input.title = params.title
if (params.subtitle !== undefined && params.subtitle !== null && params.subtitle !== '')
input.subtitle = params.subtitle

Expand Down
10 changes: 9 additions & 1 deletion apps/sim/tools/linear/create_customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,16 @@ export const linearCreateCustomerTool: ToolConfig<
}

const result = data.data.customerCreate
if (!result.success) {
return {
success: false,
error: 'Customer creation was not successful',
output: {},
}
}

return {
success: result.success,
success: true,
output: {
customer: result.customer,
},
Expand Down
10 changes: 9 additions & 1 deletion apps/sim/tools/linear/create_customer_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,16 @@ export const linearCreateCustomerRequestTool: ToolConfig<
}

const result = data.data.customerNeedCreate
if (!result.success) {
return {
success: false,
error: 'Customer request creation was not successful',
output: {},
}
}

return {
success: result.success,
success: true,
output: {
customerNeed: result.need,
},
Expand Down
10 changes: 9 additions & 1 deletion apps/sim/tools/linear/create_customer_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,16 @@ export const linearCreateCustomerStatusTool: ToolConfig<
}

const result = data.data.customerStatusCreate
if (!result.success) {
return {
success: false,
error: 'Customer status creation was not successful',
output: {},
}
}

return {
success: result.success,
success: true,
output: {
customerStatus: result.status,
},
Expand Down
10 changes: 9 additions & 1 deletion apps/sim/tools/linear/create_customer_tier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,16 @@ export const linearCreateCustomerTierTool: ToolConfig<
}

const result = data.data.customerTierCreate
if (!result.success) {
return {
success: false,
error: 'Customer tier creation was not successful',
output: {},
}
}

return {
success: result.success,
success: true,
output: {
customerTier: result.customerTier,
},
Expand Down
61 changes: 44 additions & 17 deletions apps/sim/tools/linear/create_issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const linearCreateIssueTool: ToolConfig<LinearCreateIssueParams, LinearCr
},
projectId: {
type: 'string',
required: true,
required: false,
visibility: 'user-only',
description: 'Linear project ID',
},
Expand Down Expand Up @@ -56,17 +56,31 @@ export const linearCreateIssueTool: ToolConfig<LinearCreateIssueParams, LinearCr
if (!params.title || !params.title.trim()) {
throw new Error('Title is required to create a Linear issue')
}

const input: Record<string, any> = {
teamId: params.teamId,
title: params.title,
}

if (
params.projectId !== undefined &&
params.projectId !== null &&
params.projectId !== ''
) {
input.projectId = params.projectId
}
if (
params.description !== undefined &&
params.description !== null &&
params.description !== ''
) {
input.description = params.description
}

return {
query: `
mutation CreateIssue($teamId: String!, $projectId: String!, $title: String!, $description: String) {
issueCreate(
input: {
teamId: $teamId
projectId: $projectId
title: $title
description: $description
}
) {
mutation CreateIssue($input: IssueCreateInput!) {
issueCreate(input: $input) {
issue {
id
title
Expand All @@ -79,20 +93,33 @@ export const linearCreateIssueTool: ToolConfig<LinearCreateIssueParams, LinearCr
}
`,
variables: {
teamId: params.teamId,
projectId: params.projectId,
title: params.title,
...(params.description !== undefined &&
params.description !== null &&
params.description !== '' && { description: params.description }),
input,
},
}
},
},

transformResponse: async (response) => {
const data = await response.json()
const issue = data.data.issueCreate.issue

if (data.errors) {
return {
success: false,
error: data.errors[0]?.message || 'Failed to create issue',
output: {},
}
}

const result = data.data?.issueCreate
if (!result) {
return {
success: false,
error: 'Issue creation was not successful',
output: {},
}
}

const issue = result.issue
return {
success: true,
output: {
Expand Down
28 changes: 23 additions & 5 deletions apps/sim/tools/linear/create_project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,29 @@ export const linearCreateProjectTool: ToolConfig<
name: params.name,
}

if (params.description !== undefined) input.description = params.description
if (params.leadId !== undefined) input.leadId = params.leadId
if (params.startDate !== undefined) input.startDate = params.startDate
if (params.targetDate !== undefined) input.targetDate = params.targetDate
if (params.priority !== undefined) input.priority = Number(params.priority)
if (
params.description !== undefined &&
params.description !== null &&
params.description !== ''
) {
input.description = params.description
}
if (params.leadId !== undefined && params.leadId !== null && params.leadId !== '') {
input.leadId = params.leadId
}
if (params.startDate !== undefined && params.startDate !== null && params.startDate !== '') {
input.startDate = params.startDate
}
if (
params.targetDate !== undefined &&
params.targetDate !== null &&
params.targetDate !== ''
) {
input.targetDate = params.targetDate
}
if (params.priority !== undefined && params.priority !== null) {
input.priority = Number(params.priority)
}

return {
query: `
Expand Down
10 changes: 9 additions & 1 deletion apps/sim/tools/linear/create_project_label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,16 @@ export const linearCreateProjectLabelTool: ToolConfig<
}

const result = data.data.projectLabelCreate
if (!result.success) {
return {
success: false,
error: 'Project label creation was not successful',
output: {},
}
}

return {
success: result.success,
success: true,
output: {
projectLabel: result.projectLabel,
},
Expand Down
Loading