@supaku/agentfactory-linear 0.1.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.
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Checkbox Utilities
3
+ *
4
+ * Parse and update markdown checkboxes in Linear issue descriptions.
5
+ * Checkboxes follow the standard markdown format:
6
+ * - [ ] Unchecked item
7
+ * - [x] Checked item
8
+ */
9
+ /**
10
+ * Represents a checkbox item parsed from markdown
11
+ */
12
+ export interface CheckboxItem {
13
+ /** Zero-based index among all checkboxes in the document */
14
+ index: number;
15
+ /** Line number in the markdown (zero-based) */
16
+ line: number;
17
+ /** Whether the checkbox is checked */
18
+ checked: boolean;
19
+ /** The text content after the checkbox */
20
+ text: string;
21
+ /** Indentation level (number of leading spaces) */
22
+ indentLevel: number;
23
+ /** The raw line text */
24
+ raw: string;
25
+ }
26
+ /**
27
+ * Checkbox update specification
28
+ */
29
+ export interface CheckboxUpdate {
30
+ /** Update checkbox by its index */
31
+ index?: number;
32
+ /** Update checkbox by matching text pattern */
33
+ textPattern?: string | RegExp;
34
+ /** New checked state */
35
+ checked: boolean;
36
+ }
37
+ /**
38
+ * Parse markdown and extract checkbox items
39
+ *
40
+ * @param markdown - The markdown content to parse
41
+ * @returns Array of checkbox items found in the markdown
42
+ */
43
+ export declare function parseCheckboxes(markdown: string): CheckboxItem[];
44
+ /**
45
+ * Update a checkbox by its index
46
+ *
47
+ * @param markdown - The markdown content
48
+ * @param index - The checkbox index to update
49
+ * @param checked - The new checked state
50
+ * @returns The updated markdown, or the original if checkbox not found
51
+ */
52
+ export declare function updateCheckbox(markdown: string, index: number, checked: boolean): string;
53
+ /**
54
+ * Update a checkbox by matching its text content
55
+ *
56
+ * @param markdown - The markdown content
57
+ * @param textPattern - String or regex to match against checkbox text
58
+ * @param checked - The new checked state
59
+ * @returns The updated markdown, or the original if no match found
60
+ */
61
+ export declare function updateCheckboxByText(markdown: string, textPattern: string | RegExp, checked: boolean): string;
62
+ /**
63
+ * Apply multiple checkbox updates at once
64
+ *
65
+ * @param markdown - The markdown content
66
+ * @param updates - Array of updates to apply
67
+ * @returns The updated markdown
68
+ */
69
+ export declare function updateCheckboxes(markdown: string, updates: CheckboxUpdate[]): string;
70
+ /**
71
+ * Check if markdown contains any checkboxes
72
+ *
73
+ * @param markdown - The markdown content to check
74
+ * @returns True if at least one checkbox is found
75
+ */
76
+ export declare function hasCheckboxes(markdown: string): boolean;
77
+ /**
78
+ * Get summary of checkbox states
79
+ *
80
+ * @param markdown - The markdown content
81
+ * @returns Object with counts of checked and unchecked items
82
+ */
83
+ export declare function getCheckboxSummary(markdown: string): {
84
+ total: number;
85
+ checked: number;
86
+ unchecked: number;
87
+ };
88
+ //# sourceMappingURL=checkbox-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkbox-utils.d.ts","sourceRoot":"","sources":["../../src/checkbox-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAA;IACb,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAA;IACZ,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAA;IAChB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAA;IACnB,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAA;CACZ;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC7B,wBAAwB;IACxB,OAAO,EAAE,OAAO,CAAA;CACjB;AAMD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,EAAE,CAuBhE;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,GACf,MAAM,CAaR;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAAG,MAAM,EAC5B,OAAO,EAAE,OAAO,GACf,MAAM,CAeR;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,cAAc,EAAE,GACxB,MAAM,CAYR;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACpD,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CASA"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Checkbox Utilities
3
+ *
4
+ * Parse and update markdown checkboxes in Linear issue descriptions.
5
+ * Checkboxes follow the standard markdown format:
6
+ * - [ ] Unchecked item
7
+ * - [x] Checked item
8
+ */
9
+ // Regex to match markdown checkbox lines
10
+ // Captures: (leading whitespace)(checkbox mark)(text content)
11
+ const CHECKBOX_REGEX = /^(\s*)- \[([ xX])\] (.*)$/;
12
+ /**
13
+ * Parse markdown and extract checkbox items
14
+ *
15
+ * @param markdown - The markdown content to parse
16
+ * @returns Array of checkbox items found in the markdown
17
+ */
18
+ export function parseCheckboxes(markdown) {
19
+ const lines = markdown.split('\n');
20
+ const checkboxes = [];
21
+ let checkboxIndex = 0;
22
+ for (let lineNum = 0; lineNum < lines.length; lineNum++) {
23
+ const line = lines[lineNum];
24
+ const match = line.match(CHECKBOX_REGEX);
25
+ if (match) {
26
+ const [, indent, mark, text] = match;
27
+ checkboxes.push({
28
+ index: checkboxIndex++,
29
+ line: lineNum,
30
+ indentLevel: indent.length,
31
+ checked: mark.toLowerCase() === 'x',
32
+ text: text.trim(),
33
+ raw: line,
34
+ });
35
+ }
36
+ }
37
+ return checkboxes;
38
+ }
39
+ /**
40
+ * Update a checkbox by its index
41
+ *
42
+ * @param markdown - The markdown content
43
+ * @param index - The checkbox index to update
44
+ * @param checked - The new checked state
45
+ * @returns The updated markdown, or the original if checkbox not found
46
+ */
47
+ export function updateCheckbox(markdown, index, checked) {
48
+ const checkboxes = parseCheckboxes(markdown);
49
+ const checkbox = checkboxes.find((c) => c.index === index);
50
+ if (!checkbox) {
51
+ return markdown;
52
+ }
53
+ const lines = markdown.split('\n');
54
+ const newCheckmark = checked ? 'x' : ' ';
55
+ lines[checkbox.line] = checkbox.raw.replace(/\[([ xX])\]/, `[${newCheckmark}]`);
56
+ return lines.join('\n');
57
+ }
58
+ /**
59
+ * Update a checkbox by matching its text content
60
+ *
61
+ * @param markdown - The markdown content
62
+ * @param textPattern - String or regex to match against checkbox text
63
+ * @param checked - The new checked state
64
+ * @returns The updated markdown, or the original if no match found
65
+ */
66
+ export function updateCheckboxByText(markdown, textPattern, checked) {
67
+ const checkboxes = parseCheckboxes(markdown);
68
+ const pattern = typeof textPattern === 'string'
69
+ ? new RegExp(textPattern, 'i')
70
+ : textPattern;
71
+ const checkbox = checkboxes.find((c) => pattern.test(c.text));
72
+ if (!checkbox) {
73
+ return markdown;
74
+ }
75
+ return updateCheckbox(markdown, checkbox.index, checked);
76
+ }
77
+ /**
78
+ * Apply multiple checkbox updates at once
79
+ *
80
+ * @param markdown - The markdown content
81
+ * @param updates - Array of updates to apply
82
+ * @returns The updated markdown
83
+ */
84
+ export function updateCheckboxes(markdown, updates) {
85
+ let result = markdown;
86
+ for (const update of updates) {
87
+ if (update.index !== undefined) {
88
+ result = updateCheckbox(result, update.index, update.checked);
89
+ }
90
+ else if (update.textPattern) {
91
+ result = updateCheckboxByText(result, update.textPattern, update.checked);
92
+ }
93
+ }
94
+ return result;
95
+ }
96
+ /**
97
+ * Check if markdown contains any checkboxes
98
+ *
99
+ * @param markdown - The markdown content to check
100
+ * @returns True if at least one checkbox is found
101
+ */
102
+ export function hasCheckboxes(markdown) {
103
+ const lines = markdown.split('\n');
104
+ return lines.some((line) => CHECKBOX_REGEX.test(line));
105
+ }
106
+ /**
107
+ * Get summary of checkbox states
108
+ *
109
+ * @param markdown - The markdown content
110
+ * @returns Object with counts of checked and unchecked items
111
+ */
112
+ export function getCheckboxSummary(markdown) {
113
+ const checkboxes = parseCheckboxes(markdown);
114
+ const checked = checkboxes.filter((c) => c.checked).length;
115
+ return {
116
+ total: checkboxes.length,
117
+ checked,
118
+ unchecked: checkboxes.length - checked,
119
+ };
120
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Linear API Constants
3
+ *
4
+ * Contains API limits, well-known IDs, and configuration values.
5
+ * All workspace-specific IDs must be provided via environment variables.
6
+ */
7
+ /**
8
+ * Maximum length for comment body.
9
+ * Linear doesn't publicly document this limit, but testing shows ~10k is safe.
10
+ * We use a conservative limit to avoid truncation issues.
11
+ */
12
+ export declare const LINEAR_COMMENT_MAX_LENGTH = 10000;
13
+ /**
14
+ * Marker appended when content is truncated
15
+ */
16
+ export declare const TRUNCATION_MARKER = "\n\n... (content truncated)";
17
+ /**
18
+ * Maximum number of comments for a single completion (safety limit)
19
+ */
20
+ export declare const MAX_COMPLETION_COMMENTS = 10;
21
+ /**
22
+ * Characters reserved for part markers and overhead
23
+ */
24
+ export declare const COMMENT_OVERHEAD = 100;
25
+ /**
26
+ * Continuation marker for multi-part comments
27
+ */
28
+ export declare const CONTINUATION_MARKER = "\n\n*...continued in next comment*";
29
+ /**
30
+ * Default team UUID
31
+ * Must be set via LINEAR_TEAM_ID env var
32
+ */
33
+ export declare const DEFAULT_TEAM_ID: string;
34
+ /**
35
+ * Project IDs — must be set via env vars:
36
+ * - LINEAR_PROJECT_AGENT
37
+ * - LINEAR_PROJECT_SOCIAL
38
+ * - LINEAR_PROJECT_TEST
39
+ */
40
+ export declare const LINEAR_PROJECTS: {
41
+ readonly AGENT: string;
42
+ readonly SOCIAL: string;
43
+ /** Test project for E2E testing of orchestrator */
44
+ readonly TEST: string;
45
+ };
46
+ /**
47
+ * Label IDs for issue classification
48
+ * Must be set via env vars:
49
+ * - LINEAR_LABEL_BUG
50
+ * - LINEAR_LABEL_FEATURE
51
+ * - LINEAR_LABEL_CHORE
52
+ */
53
+ export declare const LINEAR_LABELS: {
54
+ readonly BUG: string;
55
+ readonly FEATURE: string;
56
+ readonly CHORE: string;
57
+ };
58
+ export declare const TEST_LABEL_NAMES: {
59
+ /** Mark issues as test fixtures (not for manual processing) */
60
+ readonly TEST_FIXTURE: "test-fixture";
61
+ /** Identify issues created by E2E tests */
62
+ readonly E2E_TEST: "e2e-test";
63
+ };
64
+ /**
65
+ * Categories of environment issues that agents can report
66
+ */
67
+ export declare const ENVIRONMENT_ISSUE_TYPES: {
68
+ readonly PERMISSION: "permission";
69
+ readonly NETWORK: "network";
70
+ readonly SANDBOX: "sandbox";
71
+ readonly LINEAR_CLI: "linear-cli";
72
+ readonly DEPENDENCY: "dependency";
73
+ readonly TIMEOUT: "timeout";
74
+ readonly TOOL: "tool";
75
+ };
76
+ export type EnvironmentIssueType = (typeof ENVIRONMENT_ISSUE_TYPES)[keyof typeof ENVIRONMENT_ISSUE_TYPES];
77
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,QAAQ,CAAA;AAE9C;;GAEG;AACH,eAAO,MAAM,iBAAiB,gCAAgC,CAAA;AAE9D;;GAEG;AACH,eAAO,MAAM,uBAAuB,KAAK,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,gBAAgB,MAAM,CAAA;AAEnC;;GAEG;AACH,eAAO,MAAM,mBAAmB,uCAAuC,CAAA;AAQvE;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAmC,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,eAAe;;;IAG1B,mDAAmD;;CAE3C,CAAA;AAEV;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;CAIhB,CAAA;AAGV,eAAO,MAAM,gBAAgB;IAC3B,+DAA+D;;IAE/D,2CAA2C;;CAEnC,CAAA;AAMV;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;CAQ1B,CAAA;AAEV,MAAM,MAAM,oBAAoB,GAC9B,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAA"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Linear API Constants
3
+ *
4
+ * Contains API limits, well-known IDs, and configuration values.
5
+ * All workspace-specific IDs must be provided via environment variables.
6
+ */
7
+ // ============================================================================
8
+ // LINEAR API LIMITS
9
+ // ============================================================================
10
+ /**
11
+ * Maximum length for comment body.
12
+ * Linear doesn't publicly document this limit, but testing shows ~10k is safe.
13
+ * We use a conservative limit to avoid truncation issues.
14
+ */
15
+ export const LINEAR_COMMENT_MAX_LENGTH = 10000;
16
+ /**
17
+ * Marker appended when content is truncated
18
+ */
19
+ export const TRUNCATION_MARKER = '\n\n... (content truncated)';
20
+ /**
21
+ * Maximum number of comments for a single completion (safety limit)
22
+ */
23
+ export const MAX_COMPLETION_COMMENTS = 10;
24
+ /**
25
+ * Characters reserved for part markers and overhead
26
+ */
27
+ export const COMMENT_OVERHEAD = 100;
28
+ /**
29
+ * Continuation marker for multi-part comments
30
+ */
31
+ export const CONTINUATION_MARKER = '\n\n*...continued in next comment*';
32
+ // ============================================================================
33
+ // WELL-KNOWN LINEAR IDs
34
+ // All workspace-specific IDs are loaded from environment variables.
35
+ // No hardcoded fallback UUIDs — configure via env vars.
36
+ // ============================================================================
37
+ /**
38
+ * Default team UUID
39
+ * Must be set via LINEAR_TEAM_ID env var
40
+ */
41
+ export const DEFAULT_TEAM_ID = process.env.LINEAR_TEAM_ID ?? '';
42
+ /**
43
+ * Project IDs — must be set via env vars:
44
+ * - LINEAR_PROJECT_AGENT
45
+ * - LINEAR_PROJECT_SOCIAL
46
+ * - LINEAR_PROJECT_TEST
47
+ */
48
+ export const LINEAR_PROJECTS = {
49
+ get AGENT() { return process.env.LINEAR_PROJECT_AGENT ?? ''; },
50
+ get SOCIAL() { return process.env.LINEAR_PROJECT_SOCIAL ?? ''; },
51
+ /** Test project for E2E testing of orchestrator */
52
+ get TEST() { return process.env.LINEAR_PROJECT_TEST ?? ''; },
53
+ };
54
+ /**
55
+ * Label IDs for issue classification
56
+ * Must be set via env vars:
57
+ * - LINEAR_LABEL_BUG
58
+ * - LINEAR_LABEL_FEATURE
59
+ * - LINEAR_LABEL_CHORE
60
+ */
61
+ export const LINEAR_LABELS = {
62
+ get BUG() { return process.env.LINEAR_LABEL_BUG ?? ''; },
63
+ get FEATURE() { return process.env.LINEAR_LABEL_FEATURE ?? ''; },
64
+ get CHORE() { return process.env.LINEAR_LABEL_CHORE ?? ''; },
65
+ };
66
+ // Test-related labels (created dynamically, not hardcoded IDs)
67
+ export const TEST_LABEL_NAMES = {
68
+ /** Mark issues as test fixtures (not for manual processing) */
69
+ TEST_FIXTURE: 'test-fixture',
70
+ /** Identify issues created by E2E tests */
71
+ E2E_TEST: 'e2e-test',
72
+ };
73
+ // ============================================================================
74
+ // ENVIRONMENT ISSUE REPORTING
75
+ // ============================================================================
76
+ /**
77
+ * Categories of environment issues that agents can report
78
+ */
79
+ export const ENVIRONMENT_ISSUE_TYPES = {
80
+ PERMISSION: 'permission',
81
+ NETWORK: 'network',
82
+ SANDBOX: 'sandbox',
83
+ LINEAR_CLI: 'linear-cli',
84
+ DEPENDENCY: 'dependency',
85
+ TIMEOUT: 'timeout',
86
+ TOOL: 'tool',
87
+ };
@@ -0,0 +1,79 @@
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 agent spawning fails
59
+ */
60
+ export declare class AgentSpawnError extends LinearAgentError {
61
+ readonly issueId: string;
62
+ readonly sessionId?: string | undefined;
63
+ readonly isRetryable: boolean;
64
+ readonly cause?: Error | undefined;
65
+ constructor(message: string, issueId: string, sessionId?: string | undefined, isRetryable?: boolean, cause?: Error | undefined);
66
+ }
67
+ /**
68
+ * Type guard to check if an error is a LinearAgentError
69
+ */
70
+ export declare function isLinearAgentError(error: unknown): error is LinearAgentError;
71
+ /**
72
+ * Type guard to check if an error is an AgentSpawnError
73
+ */
74
+ export declare function isAgentSpawnError(error: unknown): error is AgentSpawnError;
75
+ /**
76
+ * Type guard to check if an error is retryable
77
+ */
78
+ export declare function isRetryableError(error: unknown, retryableStatusCodes?: number[]): boolean;
79
+ //# 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,gBAAgB;aAGpC,SAAS,CAAC,EAAE,MAAM;aAClB,OAAO,CAAC,EAAE,MAAM;gBAFhC,OAAO,EAAE,MAAM,EACC,SAAS,CAAC,EAAE,MAAM,YAAA,EAClB,OAAO,CAAC,EAAE,MAAM,YAAA;CAKnC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,gBAAgB;aAGrC,YAAY,EAAE,MAAM;aACpB,SAAS,CAAC,EAAE,MAAM;gBAFlC,OAAO,EAAE,MAAM,EACC,YAAY,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,YAAA;CAKrC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,gBAAgB;aACN,SAAS,CAAC,EAAE,MAAM;gBAAnD,OAAO,EAAE,MAAM,EAAkB,SAAS,CAAC,EAAE,MAAM,YAAA;CAIhE;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,gBAAgB;aAG7C,OAAO,EAAE,MAAM;aACf,UAAU,EAAE,MAAM;aAClB,QAAQ,EAAE,MAAM;gBAHhC,OAAO,EAAE,MAAM,EACC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM;CASnC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,gBAAgB;aAGjC,OAAO,EAAE,MAAM;aACf,SAAS,CAAC,EAAE,MAAM;aAClB,WAAW,EAAE,OAAO;aACpB,KAAK,CAAC,EAAE,KAAK;gBAJ7B,OAAO,EAAE,MAAM,EACC,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,MAAM,YAAA,EAClB,WAAW,GAAE,OAAe,EAC5B,KAAK,CAAC,EAAE,KAAK,YAAA;CAUhC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,OAAO,EACd,oBAAoB,GAAE,MAAM,EAA8B,GACzD,OAAO,CAkBT"}
@@ -0,0 +1,155 @@
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 agent spawning fails
104
+ */
105
+ export class AgentSpawnError extends LinearAgentError {
106
+ issueId;
107
+ sessionId;
108
+ isRetryable;
109
+ cause;
110
+ constructor(message, issueId, sessionId, isRetryable = false, cause) {
111
+ super(message, 'AGENT_SPAWN_ERROR', {
112
+ issueId,
113
+ sessionId,
114
+ isRetryable,
115
+ causeMessage: cause?.message,
116
+ });
117
+ this.issueId = issueId;
118
+ this.sessionId = sessionId;
119
+ this.isRetryable = isRetryable;
120
+ this.cause = cause;
121
+ this.name = 'AgentSpawnError';
122
+ }
123
+ }
124
+ /**
125
+ * Type guard to check if an error is a LinearAgentError
126
+ */
127
+ export function isLinearAgentError(error) {
128
+ return error instanceof LinearAgentError;
129
+ }
130
+ /**
131
+ * Type guard to check if an error is an AgentSpawnError
132
+ */
133
+ export function isAgentSpawnError(error) {
134
+ return error instanceof AgentSpawnError;
135
+ }
136
+ /**
137
+ * Type guard to check if an error is retryable
138
+ */
139
+ export function isRetryableError(error, retryableStatusCodes = [429, 500, 502, 503, 504]) {
140
+ if (error instanceof LinearApiError) {
141
+ return retryableStatusCodes.includes(error.statusCode);
142
+ }
143
+ if (error instanceof Error) {
144
+ const networkErrorPatterns = [
145
+ 'ECONNREFUSED',
146
+ 'ECONNRESET',
147
+ 'ETIMEDOUT',
148
+ 'ENOTFOUND',
149
+ 'fetch failed',
150
+ 'network error',
151
+ ];
152
+ return networkErrorPatterns.some((pattern) => error.message.toLowerCase().includes(pattern.toLowerCase()));
153
+ }
154
+ return false;
155
+ }
@@ -0,0 +1,15 @@
1
+ export type { AgentSessionState, AgentActivityType, AgentActivitySignal, AgentActivityContent, AgentActivityContentPayload, ThoughtActivityContent, ActionActivityContent, ResponseActivityContent, ElicitationActivityContent, ErrorActivityContent, PromptActivityContent, AgentActivityCreateInput, AgentActivityResult, CreateActivityOptions, AgentPlanItemState, AgentPlanItem, AgentPlan, AgentSignals, LinearAgentClientConfig, RetryConfig, LinearWorkflowStatus, StatusMapping, AgentSessionConfig, SessionOperationResult, AgentSessionExternalUrl, AgentSessionUpdateInput, AgentSessionUpdateResult, AgentSessionCreateOnIssueInput, AgentSessionCreateResult, AgentWorkType, IssueRelationType, IssueRelationCreateInput, IssueRelationResult, IssueRelationBatchResult, IssueRelationInfo, IssueRelationsResult, SubIssueGraphNode, SubIssueGraph, SubIssueStatus, } from './types';
2
+ export { STATUS_WORK_TYPE_MAP, WORK_TYPE_START_STATUS, WORK_TYPE_COMPLETE_STATUS, WORK_TYPE_FAIL_STATUS, WORK_TYPE_ALLOWED_STATUSES, STATUS_VALID_WORK_TYPES, TERMINAL_STATUSES, validateWorkTypeForStatus, getValidWorkTypesForStatus, } from './types';
3
+ export type { WorkTypeValidationResult } from './types';
4
+ export { LinearAgentError, LinearApiError, LinearRetryExhaustedError, LinearSessionError, LinearActivityError, LinearPlanError, LinearStatusTransitionError, AgentSpawnError, isLinearAgentError, isRetryableError, isAgentSpawnError, } from './errors';
5
+ export { DEFAULT_RETRY_CONFIG, sleep, calculateDelay, withRetry, createRetryWrapper, } from './retry';
6
+ export type { RetryContext, RetryCallback, WithRetryOptions } from './retry';
7
+ export { LINEAR_COMMENT_MAX_LENGTH, TRUNCATION_MARKER, MAX_COMPLETION_COMMENTS, COMMENT_OVERHEAD, CONTINUATION_MARKER, DEFAULT_TEAM_ID, LINEAR_PROJECTS, LINEAR_LABELS, ENVIRONMENT_ISSUE_TYPES, } from './constants';
8
+ export type { EnvironmentIssueType } from './constants';
9
+ export { truncateText, buildCompletionComment, splitContentIntoComments, buildCompletionComments, } from './utils';
10
+ export type { CommentChunk } from './utils';
11
+ export { parseCheckboxes, updateCheckbox, updateCheckboxByText, updateCheckboxes, hasCheckboxes, getCheckboxSummary, } from './checkbox-utils';
12
+ export type { CheckboxItem, CheckboxUpdate } from './checkbox-utils';
13
+ export { LinearAgentClient, createLinearAgentClient } from './agent-client';
14
+ export { AgentSession, createAgentSession } from './agent-session';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,uBAAuB,EACvB,WAAW,EACX,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,8BAA8B,EAC9B,wBAAwB,EACxB,aAAa,EAEb,iBAAiB,EACjB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,iBAAiB,EACjB,oBAAoB,EAEpB,iBAAiB,EACjB,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAA;AAGhB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,EACvB,iBAAiB,EACjB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,SAAS,CAAA;AAEhB,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAA;AAGvD,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,UAAU,CAAA;AAGjB,OAAO,EACL,oBAAoB,EACpB,KAAK,EACL,cAAc,EACd,SAAS,EACT,kBAAkB,GACnB,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG5E,OAAO,EACL,yBAAyB,EACzB,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,aAAa,EACb,uBAAuB,GACxB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAGvD,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAG3C,OAAO,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,aAAa,EACb,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAGpE,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAG3E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,16 @@
1
+ // Work type mappings for status-based routing
2
+ export { STATUS_WORK_TYPE_MAP, WORK_TYPE_START_STATUS, WORK_TYPE_COMPLETE_STATUS, WORK_TYPE_FAIL_STATUS, WORK_TYPE_ALLOWED_STATUSES, STATUS_VALID_WORK_TYPES, TERMINAL_STATUSES, validateWorkTypeForStatus, getValidWorkTypesForStatus, } from './types';
3
+ // Errors
4
+ export { LinearAgentError, LinearApiError, LinearRetryExhaustedError, LinearSessionError, LinearActivityError, LinearPlanError, LinearStatusTransitionError, AgentSpawnError, isLinearAgentError, isRetryableError, isAgentSpawnError, } from './errors';
5
+ // Retry utilities
6
+ export { DEFAULT_RETRY_CONFIG, sleep, calculateDelay, withRetry, createRetryWrapper, } from './retry';
7
+ // Constants
8
+ export { LINEAR_COMMENT_MAX_LENGTH, TRUNCATION_MARKER, MAX_COMPLETION_COMMENTS, COMMENT_OVERHEAD, CONTINUATION_MARKER, DEFAULT_TEAM_ID, LINEAR_PROJECTS, LINEAR_LABELS, ENVIRONMENT_ISSUE_TYPES, } from './constants';
9
+ // Utilities
10
+ export { truncateText, buildCompletionComment, splitContentIntoComments, buildCompletionComments, } from './utils';
11
+ // Checkbox utilities
12
+ export { parseCheckboxes, updateCheckbox, updateCheckboxByText, updateCheckboxes, hasCheckboxes, getCheckboxSummary, } from './checkbox-utils';
13
+ // Client
14
+ export { LinearAgentClient, createLinearAgentClient } from './agent-client';
15
+ // Session
16
+ export { AgentSession, createAgentSession } from './agent-session';