@renseiai/agentfactory-linear 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +91 -0
  3. package/dist/src/agent-client-project-repo.test.d.ts +2 -0
  4. package/dist/src/agent-client-project-repo.test.d.ts.map +1 -0
  5. package/dist/src/agent-client-project-repo.test.js +153 -0
  6. package/dist/src/agent-client.d.ts +261 -0
  7. package/dist/src/agent-client.d.ts.map +1 -0
  8. package/dist/src/agent-client.js +902 -0
  9. package/dist/src/agent-session.d.ts +303 -0
  10. package/dist/src/agent-session.d.ts.map +1 -0
  11. package/dist/src/agent-session.js +969 -0
  12. package/dist/src/checkbox-utils.d.ts +88 -0
  13. package/dist/src/checkbox-utils.d.ts.map +1 -0
  14. package/dist/src/checkbox-utils.js +120 -0
  15. package/dist/src/circuit-breaker.d.ts +76 -0
  16. package/dist/src/circuit-breaker.d.ts.map +1 -0
  17. package/dist/src/circuit-breaker.js +229 -0
  18. package/dist/src/circuit-breaker.test.d.ts +2 -0
  19. package/dist/src/circuit-breaker.test.d.ts.map +1 -0
  20. package/dist/src/circuit-breaker.test.js +292 -0
  21. package/dist/src/constants.d.ts +87 -0
  22. package/dist/src/constants.d.ts.map +1 -0
  23. package/dist/src/constants.js +101 -0
  24. package/dist/src/defaults/auto-trigger.d.ts +35 -0
  25. package/dist/src/defaults/auto-trigger.d.ts.map +1 -0
  26. package/dist/src/defaults/auto-trigger.js +36 -0
  27. package/dist/src/defaults/index.d.ts +12 -0
  28. package/dist/src/defaults/index.d.ts.map +1 -0
  29. package/dist/src/defaults/index.js +11 -0
  30. package/dist/src/defaults/priority.d.ts +20 -0
  31. package/dist/src/defaults/priority.d.ts.map +1 -0
  32. package/dist/src/defaults/priority.js +37 -0
  33. package/dist/src/defaults/prompts.d.ts +42 -0
  34. package/dist/src/defaults/prompts.d.ts.map +1 -0
  35. package/dist/src/defaults/prompts.js +310 -0
  36. package/dist/src/defaults/prompts.test.d.ts +2 -0
  37. package/dist/src/defaults/prompts.test.d.ts.map +1 -0
  38. package/dist/src/defaults/prompts.test.js +263 -0
  39. package/dist/src/defaults/work-type-detection.d.ts +19 -0
  40. package/dist/src/defaults/work-type-detection.d.ts.map +1 -0
  41. package/dist/src/defaults/work-type-detection.js +93 -0
  42. package/dist/src/errors.d.ts +91 -0
  43. package/dist/src/errors.d.ts.map +1 -0
  44. package/dist/src/errors.js +173 -0
  45. package/dist/src/frontend-adapter.d.ts +168 -0
  46. package/dist/src/frontend-adapter.d.ts.map +1 -0
  47. package/dist/src/frontend-adapter.js +314 -0
  48. package/dist/src/frontend-adapter.test.d.ts +2 -0
  49. package/dist/src/frontend-adapter.test.d.ts.map +1 -0
  50. package/dist/src/frontend-adapter.test.js +545 -0
  51. package/dist/src/index.d.ts +28 -0
  52. package/dist/src/index.d.ts.map +1 -0
  53. package/dist/src/index.js +30 -0
  54. package/dist/src/issue-tracker-proxy.d.ts +140 -0
  55. package/dist/src/issue-tracker-proxy.d.ts.map +1 -0
  56. package/dist/src/issue-tracker-proxy.js +10 -0
  57. package/dist/src/platform-adapter.d.ts +132 -0
  58. package/dist/src/platform-adapter.d.ts.map +1 -0
  59. package/dist/src/platform-adapter.js +260 -0
  60. package/dist/src/platform-adapter.test.d.ts +2 -0
  61. package/dist/src/platform-adapter.test.d.ts.map +1 -0
  62. package/dist/src/platform-adapter.test.js +468 -0
  63. package/dist/src/proxy-client.d.ts +103 -0
  64. package/dist/src/proxy-client.d.ts.map +1 -0
  65. package/dist/src/proxy-client.js +191 -0
  66. package/dist/src/rate-limiter.d.ts +64 -0
  67. package/dist/src/rate-limiter.d.ts.map +1 -0
  68. package/dist/src/rate-limiter.js +163 -0
  69. package/dist/src/rate-limiter.test.d.ts +2 -0
  70. package/dist/src/rate-limiter.test.d.ts.map +1 -0
  71. package/dist/src/rate-limiter.test.js +217 -0
  72. package/dist/src/retry.d.ts +59 -0
  73. package/dist/src/retry.d.ts.map +1 -0
  74. package/dist/src/retry.js +82 -0
  75. package/dist/src/types.d.ts +492 -0
  76. package/dist/src/types.d.ts.map +1 -0
  77. package/dist/src/types.js +143 -0
  78. package/dist/src/utils.d.ts +52 -0
  79. package/dist/src/utils.d.ts.map +1 -0
  80. package/dist/src/utils.js +277 -0
  81. package/dist/src/webhook-types.d.ts +308 -0
  82. package/dist/src/webhook-types.d.ts.map +1 -0
  83. package/dist/src/webhook-types.js +46 -0
  84. package/package.json +70 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Rensei AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # @renseiai/agentfactory-linear
2
+
3
+ Linear issue tracker integration for [AgentFactory](https://github.com/renseiai/agentfactory). Provides the Linear API client, agent sessions, status transitions, activity streaming, and work type routing.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @renseiai/agentfactory-linear
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### Linear Client
14
+
15
+ ```typescript
16
+ import { createLinearAgentClient } from '@renseiai/agentfactory-linear'
17
+
18
+ const client = createLinearAgentClient({ apiKey: process.env.LINEAR_API_KEY! })
19
+
20
+ const issue = await client.getIssue('PROJ-123')
21
+ await client.updateIssueStatus('PROJ-123', 'Started')
22
+ await client.createComment(issue.id, 'Work in progress...')
23
+ ```
24
+
25
+ ### Agent Sessions
26
+
27
+ Manage the lifecycle of an agent working on an issue:
28
+
29
+ ```typescript
30
+ import { createAgentSession } from '@renseiai/agentfactory-linear'
31
+
32
+ const session = createAgentSession({
33
+ client: linearClient.linearClient,
34
+ issueId: 'issue-uuid',
35
+ autoTransition: true,
36
+ workType: 'development',
37
+ })
38
+
39
+ await session.start() // Status -> Started
40
+ await session.emitThought('Analyzing requirements...')
41
+ await session.updatePlan([
42
+ { title: 'Read code', state: 'completed' },
43
+ { title: 'Implement feature', state: 'inProgress' },
44
+ { title: 'Write tests', state: 'pending' },
45
+ ])
46
+ await session.complete('Feature implemented') // Status -> Finished
47
+ ```
48
+
49
+ ### Work Type Routing
50
+
51
+ Issues are automatically routed to work types based on their Linear status:
52
+
53
+ | Status | Work Type | Agent Role |
54
+ |--------|-----------|------------|
55
+ | Backlog | `development` | Implement the feature/fix |
56
+ | Started | `inflight` | Continue in-progress work |
57
+ | Finished | `qa` | Validate implementation |
58
+ | Delivered | `acceptance` | Final acceptance testing |
59
+ | Rejected | `refinement` | Address feedback |
60
+
61
+ ### Default Prompt Templates
62
+
63
+ Sensible defaults for new projects — override per work type as needed:
64
+
65
+ ```typescript
66
+ import {
67
+ defaultGeneratePrompt,
68
+ defaultDetectWorkTypeFromPrompt,
69
+ defaultGetPriority,
70
+ } from '@renseiai/agentfactory-linear'
71
+ ```
72
+
73
+ ## Key Exports
74
+
75
+ - `LinearAgentClient` / `createLinearAgentClient` — Linear API client with retry logic
76
+ - `AgentSession` / `createAgentSession` — agent lifecycle management
77
+ - `defaultGeneratePrompt` — default prompt generation
78
+ - `defaultDetectWorkTypeFromPrompt` — work type detection from free text
79
+ - `defaultGetPriority` — priority mapping for work types
80
+ - Work type constants, error types, webhook event types
81
+
82
+ ## Related Packages
83
+
84
+ | Package | Description |
85
+ |---------|-------------|
86
+ | [@renseiai/agentfactory](https://www.npmjs.com/package/@renseiai/agentfactory) | Core orchestrator |
87
+ | [@renseiai/agentfactory-nextjs](https://www.npmjs.com/package/@renseiai/agentfactory-nextjs) | Next.js webhook server |
88
+
89
+ ## License
90
+
91
+ MIT
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agent-client-project-repo.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-client-project-repo.test.d.ts","sourceRoot":"","sources":["../../src/agent-client-project-repo.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,153 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { LinearAgentClient } from './agent-client.js';
3
+ import { TokenBucket } from './rate-limiter.js';
4
+ import { CircuitBreaker } from './circuit-breaker.js';
5
+ // ---------------------------------------------------------------------------
6
+ // Mock helpers
7
+ // ---------------------------------------------------------------------------
8
+ /**
9
+ * Create a mock project with configurable external links and description.
10
+ */
11
+ function mockProject(overrides = {}) {
12
+ const { id = 'project-1', description = null, externalLinks = [], } = overrides;
13
+ return {
14
+ id,
15
+ description,
16
+ externalLinks: () => Promise.resolve({ nodes: externalLinks }),
17
+ };
18
+ }
19
+ /**
20
+ * Create a LinearAgentClient with a mocked LinearClient.
21
+ */
22
+ function createClientWithProject(project) {
23
+ const mockLinearClient = {
24
+ project: vi.fn().mockResolvedValue(project),
25
+ };
26
+ // Construct client bypassing the constructor by setting private fields directly
27
+ const client = Object.create(LinearAgentClient.prototype);
28
+ Object.defineProperty(client, 'client', { value: mockLinearClient, writable: false });
29
+ Object.defineProperty(client, 'retryConfig', {
30
+ value: { maxRetries: 0, baseDelay: 0, maxDelay: 0 },
31
+ writable: false,
32
+ });
33
+ Object.defineProperty(client, 'rateLimiter', { value: new TokenBucket(), writable: false });
34
+ Object.defineProperty(client, 'circuitBreaker', { value: new CircuitBreaker(), writable: false });
35
+ Object.defineProperty(client, 'statusCache', { value: new Map(), writable: false });
36
+ return client;
37
+ }
38
+ // ---------------------------------------------------------------------------
39
+ // Tests
40
+ // ---------------------------------------------------------------------------
41
+ describe('LinearAgentClient.getProjectRepositoryUrl', () => {
42
+ it('returns URL from project external link with "Repository" label', async () => {
43
+ const project = mockProject({
44
+ externalLinks: [
45
+ { label: 'Repository', url: 'https://github.com/org/repo' },
46
+ ],
47
+ });
48
+ const client = createClientWithProject(project);
49
+ const result = await client.getProjectRepositoryUrl('project-1');
50
+ expect(result).toBe('https://github.com/org/repo');
51
+ });
52
+ it('returns URL from project external link with "GitHub" label (case-insensitive)', async () => {
53
+ const project = mockProject({
54
+ externalLinks: [
55
+ { label: 'github', url: 'https://github.com/org/another-repo' },
56
+ ],
57
+ });
58
+ const client = createClientWithProject(project);
59
+ const result = await client.getProjectRepositoryUrl('project-1');
60
+ expect(result).toBe('https://github.com/org/another-repo');
61
+ });
62
+ it('returns URL from project external link with "REPOSITORY" label (uppercase)', async () => {
63
+ const project = mockProject({
64
+ externalLinks: [
65
+ { label: 'REPOSITORY', url: 'https://github.com/org/upper-repo' },
66
+ ],
67
+ });
68
+ const client = createClientWithProject(project);
69
+ const result = await client.getProjectRepositoryUrl('project-1');
70
+ expect(result).toBe('https://github.com/org/upper-repo');
71
+ });
72
+ it('returns URL from project description fallback', async () => {
73
+ const project = mockProject({
74
+ description: 'This is a project.\nRepository: https://github.com/org/desc-repo\nMore info.',
75
+ externalLinks: [],
76
+ });
77
+ const client = createClientWithProject(project);
78
+ const result = await client.getProjectRepositoryUrl('project-1');
79
+ expect(result).toBe('https://github.com/org/desc-repo');
80
+ });
81
+ it('returns URL from project description with case-insensitive matching', async () => {
82
+ const project = mockProject({
83
+ description: 'repository: github.com/org/lower-desc-repo',
84
+ externalLinks: [],
85
+ });
86
+ const client = createClientWithProject(project);
87
+ const result = await client.getProjectRepositoryUrl('project-1');
88
+ expect(result).toBe('github.com/org/lower-desc-repo');
89
+ });
90
+ it('prefers external link over description when both are present', async () => {
91
+ const project = mockProject({
92
+ description: 'Repository: https://github.com/org/desc-repo',
93
+ externalLinks: [
94
+ { label: 'Repository', url: 'https://github.com/org/link-repo' },
95
+ ],
96
+ });
97
+ const client = createClientWithProject(project);
98
+ const result = await client.getProjectRepositoryUrl('project-1');
99
+ expect(result).toBe('https://github.com/org/link-repo');
100
+ });
101
+ it('returns null when no link or description match', async () => {
102
+ const project = mockProject({
103
+ description: 'This project has no repo URL.',
104
+ externalLinks: [
105
+ { label: 'Documentation', url: 'https://docs.example.com' },
106
+ ],
107
+ });
108
+ const client = createClientWithProject(project);
109
+ const result = await client.getProjectRepositoryUrl('project-1');
110
+ expect(result).toBeNull();
111
+ });
112
+ it('returns null when project has no links and no description', async () => {
113
+ const project = mockProject({
114
+ description: null,
115
+ externalLinks: [],
116
+ });
117
+ const client = createClientWithProject(project);
118
+ const result = await client.getProjectRepositoryUrl('project-1');
119
+ expect(result).toBeNull();
120
+ });
121
+ it('handles projects with empty external links gracefully', async () => {
122
+ const project = mockProject({
123
+ description: null,
124
+ externalLinks: [],
125
+ });
126
+ const client = createClientWithProject(project);
127
+ const result = await client.getProjectRepositoryUrl('project-1');
128
+ expect(result).toBeNull();
129
+ });
130
+ it('skips links without a label', async () => {
131
+ const project = mockProject({
132
+ externalLinks: [
133
+ { url: 'https://github.com/org/no-label-repo' },
134
+ ],
135
+ });
136
+ const client = createClientWithProject(project);
137
+ const result = await client.getProjectRepositoryUrl('project-1');
138
+ expect(result).toBeNull();
139
+ });
140
+ it('finds the matching link among multiple external links', async () => {
141
+ const project = mockProject({
142
+ externalLinks: [
143
+ { label: 'Documentation', url: 'https://docs.example.com' },
144
+ { label: 'Figma', url: 'https://figma.com/project' },
145
+ { label: 'GitHub', url: 'https://github.com/org/found-repo' },
146
+ { label: 'Slack', url: 'https://slack.com/channel' },
147
+ ],
148
+ });
149
+ const client = createClientWithProject(project);
150
+ const result = await client.getProjectRepositoryUrl('project-1');
151
+ expect(result).toBe('https://github.com/org/found-repo');
152
+ });
153
+ });
@@ -0,0 +1,261 @@
1
+ import { LinearClient } from '@linear/sdk';
2
+ import type { Issue, Comment } from '@linear/sdk';
3
+ import type { LinearAgentClientConfig, LinearWorkflowStatus, StatusMapping, AgentActivityCreateInput, AgentActivityResult, AgentSessionUpdateInput, AgentSessionUpdateResult, AgentSessionCreateOnIssueInput, AgentSessionCreateResult, IssueRelationCreateInput, IssueRelationResult, IssueRelationBatchResult, IssueRelationsResult, IssueRelationType, SubIssueGraph, SubIssueStatus } from './types.js';
4
+ /**
5
+ * Core Linear Agent Client
6
+ * Wraps @linear/sdk with retry logic and helper methods
7
+ */
8
+ export declare class LinearAgentClient {
9
+ private readonly client;
10
+ private readonly retryConfig;
11
+ private readonly rateLimiter;
12
+ private readonly circuitBreaker;
13
+ private readonly onApiResponse?;
14
+ private statusCache;
15
+ private _apiCallCount;
16
+ constructor(config: LinearAgentClientConfig);
17
+ /** Number of successful API calls since last reset */
18
+ get apiCallCount(): number;
19
+ /** Reset the API call counter (typically called at the start of each scan) */
20
+ resetApiCallCount(): void;
21
+ /**
22
+ * Get the underlying LinearClient instance
23
+ */
24
+ get linearClient(): LinearClient;
25
+ /**
26
+ * Execute an operation with circuit breaker, rate limiting, and retry logic.
27
+ *
28
+ * Order of operations:
29
+ * 1. Check circuit breaker — if open, throw CircuitOpenError (zero quota consumed)
30
+ * 2. Acquire rate limit token
31
+ * 3. Execute the operation
32
+ * 4. On success: record success on circuit breaker
33
+ * 5. On auth error: record failure on circuit breaker (may trip it)
34
+ * 6. On retryable error: retry with exponential backoff
35
+ */
36
+ private withRetry;
37
+ /**
38
+ * Fetch an issue by ID or identifier (e.g., "SUP-50")
39
+ */
40
+ getIssue(issueIdOrIdentifier: string): Promise<Issue>;
41
+ /**
42
+ * Update an issue's properties
43
+ */
44
+ updateIssue(issueId: string, data: {
45
+ title?: string;
46
+ description?: string;
47
+ stateId?: string;
48
+ assigneeId?: string | null;
49
+ priority?: number;
50
+ labelIds?: string[];
51
+ }): Promise<Issue>;
52
+ /**
53
+ * Remove the assignee from an issue (unassign)
54
+ * Used when agent completes work to enable clean handoff visibility
55
+ */
56
+ unassignIssue(issueId: string): Promise<Issue>;
57
+ /**
58
+ * Get workflow states for a team (cached)
59
+ */
60
+ getTeamStatuses(teamId: string): Promise<StatusMapping>;
61
+ /**
62
+ * Update issue status by name (e.g., "Started", "Finished")
63
+ */
64
+ updateIssueStatus(issueId: string, statusName: LinearWorkflowStatus): Promise<Issue>;
65
+ /**
66
+ * Create a comment on an issue
67
+ */
68
+ createComment(issueId: string, body: string): Promise<Comment>;
69
+ /**
70
+ * Get comments for an issue
71
+ */
72
+ getIssueComments(issueId: string): Promise<Comment[]>;
73
+ /**
74
+ * Create a new issue
75
+ */
76
+ createIssue(input: {
77
+ title: string;
78
+ description?: string;
79
+ teamId: string;
80
+ projectId?: string;
81
+ stateId?: string;
82
+ labelIds?: string[];
83
+ parentId?: string;
84
+ priority?: number;
85
+ }): Promise<Issue>;
86
+ /**
87
+ * Get the authenticated user (the agent)
88
+ */
89
+ getViewer(): Promise<import("@linear/sdk").User>;
90
+ /**
91
+ * Get a team by ID, key, or display name
92
+ */
93
+ getTeam(teamIdOrKeyOrName: string): Promise<import("@linear/sdk").Team>;
94
+ /**
95
+ * Create an agent activity using the native Linear Agent API
96
+ *
97
+ * @param input - The activity input containing session ID, content, and options
98
+ * @returns Result indicating success and the created activity ID
99
+ */
100
+ createAgentActivity(input: AgentActivityCreateInput): Promise<AgentActivityResult>;
101
+ /**
102
+ * Update an agent session
103
+ *
104
+ * Use this to set the externalUrl (linking to agent dashboard/logs)
105
+ * within 10 seconds of receiving a webhook to avoid appearing unresponsive.
106
+ *
107
+ * @param input - The session update input containing sessionId and updates
108
+ * @returns Result indicating success and the session ID
109
+ */
110
+ updateAgentSession(input: AgentSessionUpdateInput): Promise<AgentSessionUpdateResult>;
111
+ /**
112
+ * Create an agent session on an issue
113
+ *
114
+ * Use this to programmatically create a Linear AgentSession when status transitions
115
+ * occur without explicit agent mention/delegation (e.g., Icebox -> Backlog).
116
+ *
117
+ * This enables the Linear Agent Session UI to show real-time activities even when
118
+ * the agent work is triggered by status changes rather than user mentions.
119
+ *
120
+ * @param input - The session creation input containing issueId and optional external URLs
121
+ * @returns Result indicating success and the created session ID
122
+ */
123
+ createAgentSessionOnIssue(input: AgentSessionCreateOnIssueInput): Promise<AgentSessionCreateResult>;
124
+ /**
125
+ * Create a relation between two issues
126
+ *
127
+ * @param input - The relation input containing issue IDs and relation type
128
+ * @returns Result indicating success and the created relation ID
129
+ *
130
+ * Relation types:
131
+ * - 'related': General association between issues
132
+ * - 'blocks': Source issue blocks the related issue from progressing
133
+ * - 'duplicate': Source issue is a duplicate of the related issue
134
+ */
135
+ createIssueRelation(input: IssueRelationCreateInput): Promise<IssueRelationResult>;
136
+ /**
137
+ * Create multiple relations from a source issue to multiple target issues
138
+ *
139
+ * @param input - Batch input containing source issue, target issues, and relation type
140
+ * @returns Batch result with successful relation IDs and any errors
141
+ */
142
+ createIssueRelationsBatch(input: {
143
+ sourceIssueId: string;
144
+ targetIssueIds: string[];
145
+ type: IssueRelationType;
146
+ }): Promise<IssueRelationBatchResult>;
147
+ /**
148
+ * Get all relations for an issue (both outgoing and incoming)
149
+ *
150
+ * Uses a single raw GraphQL query instead of N+1 lazy-loaded SDK calls.
151
+ *
152
+ * @param issueId - The issue ID or identifier (e.g., "SUP-123")
153
+ * @returns Relations result with both directions of relationships
154
+ */
155
+ getIssueRelations(issueId: string): Promise<IssueRelationsResult>;
156
+ /**
157
+ * Delete an issue relation
158
+ *
159
+ * @param relationId - The relation ID to delete
160
+ * @returns Result indicating success
161
+ */
162
+ deleteIssueRelation(relationId: string): Promise<{
163
+ success: boolean;
164
+ }>;
165
+ /**
166
+ * Fetch all child issues (sub-issues) of a parent issue
167
+ *
168
+ * @param issueIdOrIdentifier - The parent issue ID or identifier (e.g., "SUP-100")
169
+ * @returns Array of child issues
170
+ */
171
+ getSubIssues(issueIdOrIdentifier: string): Promise<Issue[]>;
172
+ /**
173
+ * Check if an issue has a parent (is a child/sub-issue)
174
+ *
175
+ * @param issueIdOrIdentifier - The issue ID or identifier
176
+ * @returns True if the issue has a parent issue
177
+ */
178
+ isChildIssue(issueIdOrIdentifier: string): Promise<boolean>;
179
+ /**
180
+ * Fetch all non-terminal issues in a project using a single GraphQL query.
181
+ *
182
+ * Replaces the N+1 pattern of fetching issues then lazy-loading state/labels/parent/project
183
+ * for each one. Returns pre-resolved data suitable for GovernorIssue construction.
184
+ *
185
+ * @param project - Linear project name
186
+ * @returns Array of issue data with childCount for parent detection
187
+ */
188
+ listProjectIssues(project: string): Promise<Array<{
189
+ id: string;
190
+ identifier: string;
191
+ title: string;
192
+ description?: string;
193
+ status: string;
194
+ labels: string[];
195
+ createdAt: number;
196
+ parentId?: string;
197
+ project?: string;
198
+ childCount: number;
199
+ }>>;
200
+ /**
201
+ * Check if an issue has child issues (is a parent issue)
202
+ *
203
+ * @param issueIdOrIdentifier - The issue ID or identifier
204
+ * @returns True if the issue has at least one child issue
205
+ */
206
+ isParentIssue(issueIdOrIdentifier: string): Promise<boolean>;
207
+ /**
208
+ * Check if any sub-issues have been worked on (moved beyond unworked states).
209
+ *
210
+ * Used to decide whether to use acceptance-coordination (for parent issues
211
+ * whose sub-issues were actually worked) vs regular acceptance (for parent
212
+ * issues with only unworked sub-issues).
213
+ *
214
+ * @param issueId - The parent issue ID or identifier
215
+ * @returns True if at least one sub-issue has moved beyond Backlog/Icebox/Triage
216
+ */
217
+ hasWorkedSubIssues(issueId: string): Promise<boolean>;
218
+ /**
219
+ * Get lightweight sub-issue statuses (no blocking relations)
220
+ *
221
+ * Uses a single raw GraphQL query instead of N+1 lazy-loaded SDK calls.
222
+ * Returns identifier, title, and status for each sub-issue.
223
+ * Used by QA and acceptance agents to validate sub-issue completion
224
+ * without the overhead of fetching the full dependency graph.
225
+ *
226
+ * @param issueIdOrIdentifier - The parent issue ID or identifier
227
+ * @returns Array of sub-issue statuses
228
+ */
229
+ getSubIssueStatuses(issueIdOrIdentifier: string): Promise<SubIssueStatus[]>;
230
+ /**
231
+ * Get the repository URL associated with a project via its links or description
232
+ *
233
+ * Checks project links for a link with label matching 'Repository' or 'GitHub'
234
+ * (case-insensitive). Falls back to parsing the project description for a
235
+ * "Repository: <url>" pattern.
236
+ *
237
+ * @param projectId - The project ID
238
+ * @returns The repository URL if found, null otherwise
239
+ */
240
+ getProjectRepositoryUrl(projectId: string): Promise<string | null>;
241
+ /**
242
+ * Get sub-issues with their blocking relations for dependency graph building
243
+ *
244
+ * Uses a single raw GraphQL query instead of N+1 lazy-loaded SDK calls.
245
+ * Previous implementation made 2 + 4N + M API calls (where N = children,
246
+ * M = total relations). This version makes exactly 1 API call.
247
+ *
248
+ * Builds a complete dependency graph of a parent issue's children, including
249
+ * which sub-issues block which other sub-issues. This is used by the coordinator
250
+ * agent to determine execution order.
251
+ *
252
+ * @param issueIdOrIdentifier - The parent issue ID or identifier
253
+ * @returns The sub-issue dependency graph
254
+ */
255
+ getSubIssueGraph(issueIdOrIdentifier: string): Promise<SubIssueGraph>;
256
+ }
257
+ /**
258
+ * Create a configured LinearAgentClient instance
259
+ */
260
+ export declare function createLinearAgentClient(config: LinearAgentClientConfig): LinearAgentClient;
261
+ //# sourceMappingURL=agent-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-client.d.ts","sourceRoot":"","sources":["../../src/agent-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAGb,MAAM,aAAa,CAAA;AACpB,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EACV,uBAAuB,EAEvB,oBAAoB,EACpB,aAAa,EAEb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