@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
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Default work type detection from prompt keywords.
3
+ *
4
+ * Scans prompt text for keywords that map to specific work types,
5
+ * constrained to the set of valid work types for the current issue status.
6
+ */
7
+ /**
8
+ * Default keywords that map to each work type.
9
+ * More specific phrases come before generic ones within each work type.
10
+ */
11
+ const DEFAULT_WORK_TYPE_KEYWORDS = {
12
+ 'backlog-creation': [
13
+ 'create backlog', 'write stories', 'create stories', 'create issues',
14
+ 'generate issues', 'make issues', 'turn into issues', 'break down',
15
+ 'break this down', 'split into issues', 'backlog writer', 'backlog-writer',
16
+ 'write backlog', 'populate backlog', 'write issues',
17
+ ],
18
+ 'research': [
19
+ 'research', 'flesh out', 'write story', 'story details',
20
+ 'analyze requirements', 'acceptance criteria',
21
+ ],
22
+ 'qa': [
23
+ 'qa ', 'test this', 'verify', 'validate', 'review the pr', 'check the pr',
24
+ ],
25
+ 'inflight': [
26
+ 'continue', 'resume', 'pick up where', 'keep going',
27
+ ],
28
+ 'acceptance': [
29
+ 'acceptance', 'final test', 'preview deploy', 'merge pr', 'merge the pr',
30
+ 'complete acceptance', 'finalize',
31
+ ],
32
+ 'refinement': [
33
+ 'refine', 'rejection', 'feedback', 'rework',
34
+ ],
35
+ 'development': [
36
+ 'implement', 'develop', 'build', 'code', 'work',
37
+ ],
38
+ 'coordination': [
39
+ 'coordinate', 'orchestrate', 'run sub-issues', 'run children',
40
+ 'run all sub-issues', 'execute sub-issues', 'work on this',
41
+ ],
42
+ 'qa-coordination': [
43
+ 'qa coordination', 'qa sub-issues', 'qa all sub-issues', 'qa this', 'qa issue',
44
+ ],
45
+ 'acceptance-coordination': [
46
+ 'acceptance coordination', 'accept sub-issues', 'accept all sub-issues',
47
+ 'perform acceptance', 'complete acceptance',
48
+ ],
49
+ 'refinement-coordination': [
50
+ 'refinement coordination', 'refine sub-issues', 'refine all sub-issues',
51
+ 'triage failures', 'route feedback',
52
+ ],
53
+ };
54
+ /**
55
+ * Priority order for work type detection.
56
+ * More specific work types come first to ensure correct matching.
57
+ */
58
+ const WORK_TYPE_PRIORITY_ORDER = [
59
+ 'coordination',
60
+ 'backlog-creation',
61
+ 'research',
62
+ 'qa-coordination',
63
+ 'qa',
64
+ 'acceptance-coordination',
65
+ 'acceptance',
66
+ 'inflight',
67
+ 'refinement',
68
+ 'development',
69
+ ];
70
+ /**
71
+ * Detect work type from prompt text, constrained to valid options.
72
+ *
73
+ * Scans the prompt for keywords and returns the first matching work type
74
+ * that is also in the set of valid work types for the current issue status.
75
+ *
76
+ * @param prompt - The prompt text to scan
77
+ * @param validWorkTypes - Work types valid for the current issue status
78
+ * @returns The detected work type, or undefined if no match
79
+ */
80
+ export function defaultDetectWorkTypeFromPrompt(prompt, validWorkTypes) {
81
+ if (!prompt || validWorkTypes.length === 0)
82
+ return undefined;
83
+ const lowerPrompt = prompt.toLowerCase();
84
+ for (const workType of WORK_TYPE_PRIORITY_ORDER) {
85
+ if (!validWorkTypes.includes(workType))
86
+ continue;
87
+ const keywords = DEFAULT_WORK_TYPE_KEYWORDS[workType];
88
+ if (keywords?.some(keyword => lowerPrompt.includes(keyword))) {
89
+ return workType;
90
+ }
91
+ }
92
+ return undefined;
93
+ }
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Base error class for Linear Agent SDK errors
3
+ */
4
+ export declare class LinearAgentError extends Error {
5
+ readonly code: string;
6
+ readonly context?: Record<string, unknown> | undefined;
7
+ constructor(message: string, code: string, context?: Record<string, unknown> | undefined);
8
+ }
9
+ /**
10
+ * Error thrown when Linear API returns an error response
11
+ */
12
+ export declare class LinearApiError extends LinearAgentError {
13
+ readonly statusCode: number;
14
+ readonly response?: unknown | undefined;
15
+ constructor(message: string, statusCode: number, response?: unknown | undefined);
16
+ }
17
+ /**
18
+ * Error thrown when all retry attempts are exhausted
19
+ */
20
+ export declare class LinearRetryExhaustedError extends LinearAgentError {
21
+ readonly attempts: number;
22
+ readonly lastError: Error;
23
+ constructor(message: string, attempts: number, lastError: Error);
24
+ }
25
+ /**
26
+ * Error thrown when session operations fail
27
+ */
28
+ export declare class LinearSessionError extends LinearAgentError {
29
+ readonly sessionId?: string | undefined;
30
+ readonly issueId?: string | undefined;
31
+ constructor(message: string, sessionId?: string | undefined, issueId?: string | undefined);
32
+ }
33
+ /**
34
+ * Error thrown when activity emission fails
35
+ */
36
+ export declare class LinearActivityError extends LinearAgentError {
37
+ readonly activityType: string;
38
+ readonly sessionId?: string | undefined;
39
+ constructor(message: string, activityType: string, sessionId?: string | undefined);
40
+ }
41
+ /**
42
+ * Error thrown when plan update fails
43
+ */
44
+ export declare class LinearPlanError extends LinearAgentError {
45
+ readonly sessionId?: string | undefined;
46
+ constructor(message: string, sessionId?: string | undefined);
47
+ }
48
+ /**
49
+ * Error thrown when issue status transition fails
50
+ */
51
+ export declare class LinearStatusTransitionError extends LinearAgentError {
52
+ readonly issueId: string;
53
+ readonly fromStatus: string;
54
+ readonly toStatus: string;
55
+ constructor(message: string, issueId: string, fromStatus: string, toStatus: string);
56
+ }
57
+ /**
58
+ * Error thrown when the circuit breaker is open.
59
+ * All API calls are blocked to prevent wasting rate limit quota.
60
+ */
61
+ export declare class CircuitOpenError extends LinearAgentError {
62
+ readonly retryAfterMs: number;
63
+ constructor(message: string, retryAfterMs: number);
64
+ }
65
+ /**
66
+ * Error thrown when agent spawning fails
67
+ */
68
+ export declare class AgentSpawnError extends LinearAgentError {
69
+ readonly issueId: string;
70
+ readonly sessionId?: string | undefined;
71
+ readonly isRetryable: boolean;
72
+ readonly cause?: Error | undefined;
73
+ constructor(message: string, issueId: string, sessionId?: string | undefined, isRetryable?: boolean, cause?: Error | undefined);
74
+ }
75
+ /**
76
+ * Type guard to check if an error is a LinearAgentError
77
+ */
78
+ export declare function isLinearAgentError(error: unknown): error is LinearAgentError;
79
+ /**
80
+ * Type guard to check if an error is an AgentSpawnError
81
+ */
82
+ export declare function isAgentSpawnError(error: unknown): error is AgentSpawnError;
83
+ /**
84
+ * Type guard to check if an error is a CircuitOpenError
85
+ */
86
+ export declare function isCircuitOpenError(error: unknown): error is CircuitOpenError;
87
+ /**
88
+ * Type guard to check if an error is retryable
89
+ */
90
+ export declare function isRetryableError(error: unknown, retryableStatusCodes?: number[]): boolean;
91
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;aAGvB,IAAI,EAAE,MAAM;aACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFjD,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAQpD;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,gBAAgB;aAGhC,UAAU,EAAE,MAAM;aAClB,QAAQ,CAAC,EAAE,OAAO;gBAFlC,OAAO,EAAE,MAAM,EACC,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,OAAO,YAAA;CAKrC;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,gBAAgB;aAG3C,QAAQ,EAAE,MAAM;aAChB,SAAS,EAAE,KAAK;gBAFhC,OAAO,EAAE,MAAM,EACC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK;CAQnC;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,g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OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,oBAAoB,GAAE,MAAM,EAA8B,GACzD,OAAO,CAkBT"}
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Base error class for Linear Agent SDK errors
3
+ */
4
+ export class LinearAgentError extends Error {
5
+ code;
6
+ context;
7
+ constructor(message, code, context) {
8
+ super(message);
9
+ this.code = code;
10
+ this.context = context;
11
+ this.name = 'LinearAgentError';
12
+ if (Error.captureStackTrace) {
13
+ Error.captureStackTrace(this, LinearAgentError);
14
+ }
15
+ }
16
+ }
17
+ /**
18
+ * Error thrown when Linear API returns an error response
19
+ */
20
+ export class LinearApiError extends LinearAgentError {
21
+ statusCode;
22
+ response;
23
+ constructor(message, statusCode, response) {
24
+ super(message, 'LINEAR_API_ERROR', { statusCode, response });
25
+ this.statusCode = statusCode;
26
+ this.response = response;
27
+ this.name = 'LinearApiError';
28
+ }
29
+ }
30
+ /**
31
+ * Error thrown when all retry attempts are exhausted
32
+ */
33
+ export class LinearRetryExhaustedError extends LinearAgentError {
34
+ attempts;
35
+ lastError;
36
+ constructor(message, attempts, lastError) {
37
+ super(message, 'RETRY_EXHAUSTED', {
38
+ attempts,
39
+ lastErrorMessage: lastError.message,
40
+ });
41
+ this.attempts = attempts;
42
+ this.lastError = lastError;
43
+ this.name = 'LinearRetryExhaustedError';
44
+ }
45
+ }
46
+ /**
47
+ * Error thrown when session operations fail
48
+ */
49
+ export class LinearSessionError extends LinearAgentError {
50
+ sessionId;
51
+ issueId;
52
+ constructor(message, sessionId, issueId) {
53
+ super(message, 'SESSION_ERROR', { sessionId, issueId });
54
+ this.sessionId = sessionId;
55
+ this.issueId = issueId;
56
+ this.name = 'LinearSessionError';
57
+ }
58
+ }
59
+ /**
60
+ * Error thrown when activity emission fails
61
+ */
62
+ export class LinearActivityError extends LinearAgentError {
63
+ activityType;
64
+ sessionId;
65
+ constructor(message, activityType, sessionId) {
66
+ super(message, 'ACTIVITY_ERROR', { activityType, sessionId });
67
+ this.activityType = activityType;
68
+ this.sessionId = sessionId;
69
+ this.name = 'LinearActivityError';
70
+ }
71
+ }
72
+ /**
73
+ * Error thrown when plan update fails
74
+ */
75
+ export class LinearPlanError extends LinearAgentError {
76
+ sessionId;
77
+ constructor(message, sessionId) {
78
+ super(message, 'PLAN_ERROR', { sessionId });
79
+ this.sessionId = sessionId;
80
+ this.name = 'LinearPlanError';
81
+ }
82
+ }
83
+ /**
84
+ * Error thrown when issue status transition fails
85
+ */
86
+ export class LinearStatusTransitionError extends LinearAgentError {
87
+ issueId;
88
+ fromStatus;
89
+ toStatus;
90
+ constructor(message, issueId, fromStatus, toStatus) {
91
+ super(message, 'STATUS_TRANSITION_ERROR', {
92
+ issueId,
93
+ fromStatus,
94
+ toStatus,
95
+ });
96
+ this.issueId = issueId;
97
+ this.fromStatus = fromStatus;
98
+ this.toStatus = toStatus;
99
+ this.name = 'LinearStatusTransitionError';
100
+ }
101
+ }
102
+ /**
103
+ * Error thrown when the circuit breaker is open.
104
+ * All API calls are blocked to prevent wasting rate limit quota.
105
+ */
106
+ export class CircuitOpenError extends LinearAgentError {
107
+ retryAfterMs;
108
+ constructor(message, retryAfterMs) {
109
+ super(message, 'CIRCUIT_OPEN', { retryAfterMs });
110
+ this.retryAfterMs = retryAfterMs;
111
+ this.name = 'CircuitOpenError';
112
+ }
113
+ }
114
+ /**
115
+ * Error thrown when agent spawning fails
116
+ */
117
+ export class AgentSpawnError extends LinearAgentError {
118
+ issueId;
119
+ sessionId;
120
+ isRetryable;
121
+ cause;
122
+ constructor(message, issueId, sessionId, isRetryable = false, cause) {
123
+ super(message, 'AGENT_SPAWN_ERROR', {
124
+ issueId,
125
+ sessionId,
126
+ isRetryable,
127
+ causeMessage: cause?.message,
128
+ });
129
+ this.issueId = issueId;
130
+ this.sessionId = sessionId;
131
+ this.isRetryable = isRetryable;
132
+ this.cause = cause;
133
+ this.name = 'AgentSpawnError';
134
+ }
135
+ }
136
+ /**
137
+ * Type guard to check if an error is a LinearAgentError
138
+ */
139
+ export function isLinearAgentError(error) {
140
+ return error instanceof LinearAgentError;
141
+ }
142
+ /**
143
+ * Type guard to check if an error is an AgentSpawnError
144
+ */
145
+ export function isAgentSpawnError(error) {
146
+ return error instanceof AgentSpawnError;
147
+ }
148
+ /**
149
+ * Type guard to check if an error is a CircuitOpenError
150
+ */
151
+ export function isCircuitOpenError(error) {
152
+ return error instanceof CircuitOpenError;
153
+ }
154
+ /**
155
+ * Type guard to check if an error is retryable
156
+ */
157
+ export function isRetryableError(error, retryableStatusCodes = [429, 500, 502, 503, 504]) {
158
+ if (error instanceof LinearApiError) {
159
+ return retryableStatusCodes.includes(error.statusCode);
160
+ }
161
+ if (error instanceof Error) {
162
+ const networkErrorPatterns = [
163
+ 'ECONNREFUSED',
164
+ 'ECONNRESET',
165
+ 'ETIMEDOUT',
166
+ 'ENOTFOUND',
167
+ 'fetch failed',
168
+ 'network error',
169
+ ];
170
+ return networkErrorPatterns.some((pattern) => error.message.toLowerCase().includes(pattern.toLowerCase()));
171
+ }
172
+ return false;
173
+ }
@@ -0,0 +1,168 @@
1
+ /**
2
+ * LinearFrontendAdapter
3
+ *
4
+ * Implements the WorkSchedulingFrontend interface (defined in @renseiai/agentfactory)
5
+ * by wrapping the LinearAgentClient. This adapter translates between abstract,
6
+ * frontend-agnostic types and Linear-specific concepts.
7
+ *
8
+ * Structural typing note: This class structurally satisfies the WorkSchedulingFrontend
9
+ * interface from @renseiai/agentfactory without an explicit `implements` clause, avoiding
10
+ * a circular package dependency (core depends on linear at runtime, linear depends on
11
+ * core only for types). Consumers who import both packages can assign this to
12
+ * WorkSchedulingFrontend.
13
+ */
14
+ import type { LinearAgentClient } from './agent-client.js';
15
+ /**
16
+ * Abstract workflow statuses that map to Linear-specific status names.
17
+ */
18
+ export type AbstractStatus = 'icebox' | 'backlog' | 'started' | 'finished' | 'delivered' | 'accepted' | 'rejected' | 'canceled';
19
+ /**
20
+ * Minimal issue representation shared across frontends.
21
+ */
22
+ export interface AbstractIssue {
23
+ id: string;
24
+ identifier: string;
25
+ title: string;
26
+ description?: string;
27
+ url: string;
28
+ status: AbstractStatus;
29
+ priority: number;
30
+ labels: string[];
31
+ parentId?: string;
32
+ project?: string;
33
+ createdAt: Date;
34
+ }
35
+ /**
36
+ * Minimal comment representation.
37
+ */
38
+ export interface AbstractComment {
39
+ id: string;
40
+ body: string;
41
+ userId?: string;
42
+ userName?: string;
43
+ createdAt: Date;
44
+ }
45
+ /**
46
+ * External URL for agent sessions.
47
+ */
48
+ export interface ExternalUrl {
49
+ label: string;
50
+ url: string;
51
+ }
52
+ /**
53
+ * Input for creating an issue.
54
+ */
55
+ export interface CreateIssueInput {
56
+ title: string;
57
+ teamId?: string;
58
+ description?: string;
59
+ projectId?: string;
60
+ status?: AbstractStatus;
61
+ labels?: string[];
62
+ parentId?: string;
63
+ priority?: number;
64
+ }
65
+ /**
66
+ * Input for creating a blocker issue.
67
+ */
68
+ export interface CreateBlockerInput {
69
+ title: string;
70
+ description?: string;
71
+ teamId?: string;
72
+ projectId?: string;
73
+ assignee?: string;
74
+ }
75
+ /**
76
+ * Input for updating an agent session.
77
+ */
78
+ export interface UpdateSessionInput {
79
+ externalUrls?: ExternalUrl[];
80
+ plan?: Array<{
81
+ content: string;
82
+ status: 'pending' | 'inProgress' | 'completed' | 'canceled';
83
+ }>;
84
+ }
85
+ /**
86
+ * Linear frontend adapter that wraps LinearAgentClient.
87
+ *
88
+ * Structurally satisfies WorkSchedulingFrontend from @renseiai/agentfactory.
89
+ */
90
+ export declare class LinearFrontendAdapter {
91
+ private readonly client;
92
+ readonly name: "linear";
93
+ constructor(client: LinearAgentClient);
94
+ /**
95
+ * Resolve an abstract status to its Linear-native name.
96
+ */
97
+ resolveStatus(abstract: AbstractStatus): string;
98
+ /**
99
+ * Map a Linear-native status name to its abstract equivalent.
100
+ * Defaults to 'backlog' for unknown statuses.
101
+ */
102
+ abstractStatus(nativeStatus: string): AbstractStatus;
103
+ /**
104
+ * Fetch an issue by ID or identifier and map to AbstractIssue.
105
+ */
106
+ getIssue(id: string): Promise<AbstractIssue>;
107
+ /**
108
+ * List issues in a project filtered by abstract status.
109
+ *
110
+ * Uses the underlying LinearClient directly since LinearAgentClient
111
+ * does not expose a project-scoped issue listing method.
112
+ */
113
+ listIssuesByStatus(project: string, status: AbstractStatus): Promise<AbstractIssue[]>;
114
+ /**
115
+ * Get comments for an issue and map to AbstractComment[].
116
+ */
117
+ getIssueComments(id: string): Promise<AbstractComment[]>;
118
+ /**
119
+ * List issues in a project filtered by abstract status, excluding
120
+ * those that are blocked by other issues (have incoming "blocks" relations).
121
+ */
122
+ getUnblockedIssues(project: string, status: AbstractStatus): Promise<AbstractIssue[]>;
123
+ /**
124
+ * Check if an issue has child issues (is a parent issue).
125
+ */
126
+ isParentIssue(id: string): Promise<boolean>;
127
+ /**
128
+ * Check if an issue has a parent (is a child/sub-issue).
129
+ */
130
+ isChildIssue(id: string): Promise<boolean>;
131
+ /**
132
+ * Get sub-issues of a parent issue, mapped to AbstractIssue[].
133
+ */
134
+ getSubIssues(id: string): Promise<AbstractIssue[]>;
135
+ /**
136
+ * Transition an issue to a new status.
137
+ */
138
+ transitionIssue(id: string, status: AbstractStatus): Promise<void>;
139
+ /**
140
+ * Create a comment on an issue.
141
+ */
142
+ createComment(id: string, body: string): Promise<void>;
143
+ /**
144
+ * Create a blocker issue that blocks the source issue.
145
+ * Creates the issue in Icebox with a "Needs Human" label (if found),
146
+ * then creates a "blocks" relation from the blocker to the source.
147
+ */
148
+ createBlockerIssue(sourceId: string, data: CreateBlockerInput): Promise<AbstractIssue>;
149
+ /**
150
+ * Create a new issue and return it as AbstractIssue.
151
+ */
152
+ createIssue(data: CreateIssueInput): Promise<AbstractIssue>;
153
+ /**
154
+ * Create an agent session on an issue.
155
+ * Returns the session ID.
156
+ */
157
+ createAgentSession(issueId: string, externalUrls?: ExternalUrl[]): Promise<string>;
158
+ /**
159
+ * Update an existing agent session.
160
+ */
161
+ updateAgentSession(sessionId: string, data: UpdateSessionInput): Promise<void>;
162
+ /**
163
+ * Create an activity on an agent session.
164
+ * Wraps the content as a ThoughtActivityContent.
165
+ */
166
+ createActivity(sessionId: string, type: string, content: string): Promise<void>;
167
+ }
168
+ //# sourceMappingURL=frontend-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontend-adapter.d.ts","sourceRoot":"","sources":["../../src/frontend-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAM1D;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,SAAS,GACT,SAAS,GACT,UAAU,GACV,WAAW,GACX,UAAU,GACV,UAAU,GACV,UAAU,CAAA;AAEd;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,cAAc,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,IAAI,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,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