@dahrk/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.
- package/LICENSE +201 -0
- package/README.md +19 -0
- package/dist/documents.d.ts +56 -0
- package/dist/documents.d.ts.map +1 -0
- package/dist/documents.js +127 -0
- package/dist/documents.js.map +1 -0
- package/dist/index.d.ts +140 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/issues.d.ts +48 -0
- package/dist/issues.d.ts.map +1 -0
- package/dist/issues.js +64 -0
- package/dist/issues.js.map +1 -0
- package/dist/labels.d.ts +62 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/labels.js +160 -0
- package/dist/labels.js.map +1 -0
- package/dist/linear-client.d.ts +3 -0
- package/dist/linear-client.d.ts.map +1 -0
- package/dist/linear-client.js +198 -0
- package/dist/linear-client.js.map +1 -0
- package/dist/oauth.d.ts +81 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +127 -0
- package/dist/oauth.js.map +1 -0
- package/dist/recording-client.d.ts +68 -0
- package/dist/recording-client.d.ts.map +1 -0
- package/dist/recording-client.js +52 -0
- package/dist/recording-client.js.map +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Skakel Labs
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @dahrk/linear
|
|
2
|
+
|
|
3
|
+
**Confidentiality:** Internal
|
|
4
|
+
**Status:** DRAFT - UNREVIEWED
|
|
5
|
+
|
|
6
|
+
The Linear-native control surface and webhook verification. Linear is the substrate and the only
|
|
7
|
+
source; this package is how Dahrk speaks to it.
|
|
8
|
+
|
|
9
|
+
- **Intake-side:** verify webhook signatures; normalise to the internal `LinearEvent`.
|
|
10
|
+
- **Session-side:** the Agent Session API - activities, the agent-plan checklist, `elicitation`
|
|
11
|
+
gates, the `prompted` drive, the `stop` signal, `externalUrls`.
|
|
12
|
+
|
|
13
|
+
Used by both `hub` (intake + session) and `edge` (session, while a stage runs). Re-implemented
|
|
14
|
+
against the API directly; cyrus is a reference. Intended runtime dependency: the Linear TypeScript
|
|
15
|
+
SDK. See `../../docs/01-build-spec.md` section 14.
|
|
16
|
+
|
|
17
|
+
## Sources
|
|
18
|
+
|
|
19
|
+
- `../../docs/01-build-spec.md`, the design's doc 05 (Linear feature coverage).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch the Linear Documents attached to an issue, so the hub can snapshot their content into a run
|
|
3
|
+
* and surface it to the agent (the harness was webhook-payload-only before, so a document reached the
|
|
4
|
+
* agent only as a URL, never as content). This is a read against the same per-connection Linear token
|
|
5
|
+
* the hub already uses to post back; fetching content is data assembly, not control flow.
|
|
6
|
+
*
|
|
7
|
+
* Two sources, de-duped by document id:
|
|
8
|
+
* 1. Documents directly associated with the issue (`issue.documents`).
|
|
9
|
+
* 2. Documents linked via the issue's attachments whose `url` is a Linear document URL
|
|
10
|
+
* (`https://linear.app/<ws>/document/<...>-<slug>`), resolved through `document(id:)`.
|
|
11
|
+
*
|
|
12
|
+
* The `DocumentSource` seam keeps the assembly pure and unit-testable: the live source
|
|
13
|
+
* (`linearDocumentSource`) speaks GraphQL, while tests inject a fake.
|
|
14
|
+
*/
|
|
15
|
+
import type { AttachedDocument } from "@dahrk/contracts";
|
|
16
|
+
/** A document as returned by Linear before slug normalisation (slugId is Linear's URL-safe slug). */
|
|
17
|
+
export interface RawDocument {
|
|
18
|
+
id: string;
|
|
19
|
+
slugId?: string;
|
|
20
|
+
title?: string;
|
|
21
|
+
url?: string;
|
|
22
|
+
content?: string;
|
|
23
|
+
}
|
|
24
|
+
/** The read seam the assembly depends on; the live impl wraps GraphQL, tests inject a fake. */
|
|
25
|
+
export interface DocumentSource {
|
|
26
|
+
/** Documents directly associated with the issue. */
|
|
27
|
+
issueDocuments(issueId: string): Promise<RawDocument[]>;
|
|
28
|
+
/** The issue's attachment URLs (only the `url` is needed to spot Linear document links). */
|
|
29
|
+
issueAttachmentUrls(issueId: string): Promise<string[]>;
|
|
30
|
+
/** Resolve a Linear document by the slug taken from its URL; null when it does not resolve. */
|
|
31
|
+
documentBySlug(slug: string): Promise<RawDocument | null>;
|
|
32
|
+
}
|
|
33
|
+
/** The Linear-document slug from an attachment URL, or null when the URL is not a Linear document
|
|
34
|
+
* link. Linear document URLs look like `https://linear.app/<ws>/document/<title-slug>-<slugId>`;
|
|
35
|
+
* the canonical slug Linear's `document(id:)` accepts is the trailing token (the slugId), which is
|
|
36
|
+
* the substring after the final `-`. Falls back to the whole segment when there is no `-`. */
|
|
37
|
+
export declare function documentSlugFromUrl(url: string): string | null;
|
|
38
|
+
/** A filesystem- and URL-safe slug for the scratch filename: prefer Linear's slugId, else slugify the
|
|
39
|
+
* title, else the id. Bounded length so a long title cannot produce an unwieldy path. */
|
|
40
|
+
export declare function documentSlug(doc: RawDocument): string;
|
|
41
|
+
/**
|
|
42
|
+
* Collect the issue's attached documents from a source, de-duped by id (issue documents first, then
|
|
43
|
+
* attachment-linked documents). Pure of any network: the source does the I/O. Best-effort - an
|
|
44
|
+
* attachment whose document does not resolve is skipped, never fatal.
|
|
45
|
+
*/
|
|
46
|
+
export declare function collectAttachedDocuments(source: DocumentSource, issueId: string): Promise<AttachedDocument[]>;
|
|
47
|
+
/** The live `DocumentSource`, backed by a Linear bearer token. Plain fetch, no SDK. */
|
|
48
|
+
export declare function linearDocumentSource(token: string): DocumentSource;
|
|
49
|
+
/**
|
|
50
|
+
* Fetch the documents attached to a Linear issue as contract `AttachedDocument`s, ready to snapshot
|
|
51
|
+
* into a run. The single entry point the hub calls; resolves the source from the token and runs the
|
|
52
|
+
* pure assembly. Never throws on a single bad document link (best-effort), but a hard failure (auth,
|
|
53
|
+
* network) propagates so the caller can log and proceed with none.
|
|
54
|
+
*/
|
|
55
|
+
export declare function fetchAttachedDocuments(token: string, issueId: string): Promise<AttachedDocument[]>;
|
|
56
|
+
//# sourceMappingURL=documents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAIzD,qGAAqG;AACrG,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,+FAA+F;AAC/F,MAAM,WAAW,cAAc;IAC7B,oDAAoD;IACpD,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACxD,4FAA4F;IAC5F,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,+FAA+F;IAC/F,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC3D;AAED;;;+FAG+F;AAC/F,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc9D;AAED;0FAC0F;AAC1F,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAQrD;AAeD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAuB7B;AAqBD,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAgClE;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAE7B"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
const GRAPHQL_URL = "https://api.linear.app/graphql";
|
|
2
|
+
/** The Linear-document slug from an attachment URL, or null when the URL is not a Linear document
|
|
3
|
+
* link. Linear document URLs look like `https://linear.app/<ws>/document/<title-slug>-<slugId>`;
|
|
4
|
+
* the canonical slug Linear's `document(id:)` accepts is the trailing token (the slugId), which is
|
|
5
|
+
* the substring after the final `-`. Falls back to the whole segment when there is no `-`. */
|
|
6
|
+
export function documentSlugFromUrl(url) {
|
|
7
|
+
const m = /\/document\/([^/?#]+)/.exec(url);
|
|
8
|
+
if (!m?.[1])
|
|
9
|
+
return null;
|
|
10
|
+
// The URL is attacker-influenceable (anyone who can attach a link to the issue). A malformed
|
|
11
|
+
// percent-escape makes decodeURIComponent throw; swallow it and skip this link rather than let it
|
|
12
|
+
// abort the whole fetch (which would discard the issue's other documents too).
|
|
13
|
+
let segment;
|
|
14
|
+
try {
|
|
15
|
+
segment = decodeURIComponent(m[1]);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const dash = segment.lastIndexOf("-");
|
|
21
|
+
return dash >= 0 && dash < segment.length - 1 ? segment.slice(dash + 1) : segment;
|
|
22
|
+
}
|
|
23
|
+
/** A filesystem- and URL-safe slug for the scratch filename: prefer Linear's slugId, else slugify the
|
|
24
|
+
* title, else the id. Bounded length so a long title cannot produce an unwieldy path. */
|
|
25
|
+
export function documentSlug(doc) {
|
|
26
|
+
if (doc.slugId && doc.slugId.trim())
|
|
27
|
+
return doc.slugId.trim();
|
|
28
|
+
const fromTitle = (doc.title ?? "")
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
31
|
+
.replace(/^-+|-+$/g, "")
|
|
32
|
+
.slice(0, 60);
|
|
33
|
+
return fromTitle || doc.id;
|
|
34
|
+
}
|
|
35
|
+
/** Normalise a RawDocument into the contract shape, dropping ones with no usable content. */
|
|
36
|
+
function toAttached(doc) {
|
|
37
|
+
const content = doc.content ?? "";
|
|
38
|
+
if (!content.trim())
|
|
39
|
+
return null;
|
|
40
|
+
return {
|
|
41
|
+
id: doc.id,
|
|
42
|
+
slug: documentSlug(doc),
|
|
43
|
+
title: (doc.title ?? "").trim() || "Untitled document",
|
|
44
|
+
url: doc.url ?? "",
|
|
45
|
+
content,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Collect the issue's attached documents from a source, de-duped by id (issue documents first, then
|
|
50
|
+
* attachment-linked documents). Pure of any network: the source does the I/O. Best-effort - an
|
|
51
|
+
* attachment whose document does not resolve is skipped, never fatal.
|
|
52
|
+
*/
|
|
53
|
+
export async function collectAttachedDocuments(source, issueId) {
|
|
54
|
+
const out = [];
|
|
55
|
+
const seen = new Set();
|
|
56
|
+
const add = (doc) => {
|
|
57
|
+
if (!doc || seen.has(doc.id))
|
|
58
|
+
return;
|
|
59
|
+
const attached = toAttached(doc);
|
|
60
|
+
if (!attached)
|
|
61
|
+
return;
|
|
62
|
+
seen.add(doc.id);
|
|
63
|
+
out.push(attached);
|
|
64
|
+
};
|
|
65
|
+
for (const doc of await source.issueDocuments(issueId))
|
|
66
|
+
add(doc);
|
|
67
|
+
const urls = await source.issueAttachmentUrls(issueId);
|
|
68
|
+
const slugs = [...new Set(urls.map(documentSlugFromUrl).filter((s) => s !== null))];
|
|
69
|
+
for (const slug of slugs) {
|
|
70
|
+
try {
|
|
71
|
+
add(await source.documentBySlug(slug));
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// best-effort: a deleted/unauthorised document link is skipped, not fatal.
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
79
|
+
/** Run one GraphQL query against Linear with a bearer token; throws on transport or GraphQL errors. */
|
|
80
|
+
async function gql(token, query, variables) {
|
|
81
|
+
const res = await fetch(GRAPHQL_URL, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
headers: { "content-type": "application/json", authorization: token },
|
|
84
|
+
body: JSON.stringify({ query, variables }),
|
|
85
|
+
});
|
|
86
|
+
if (!res.ok)
|
|
87
|
+
throw new Error(`linear graphql ${res.status}`);
|
|
88
|
+
const json = (await res.json().catch(() => ({})));
|
|
89
|
+
if (json.errors?.length)
|
|
90
|
+
throw new Error(json.errors.map((e) => e.message).join("; "));
|
|
91
|
+
if (!json.data)
|
|
92
|
+
throw new Error("linear graphql: empty response");
|
|
93
|
+
return json.data;
|
|
94
|
+
}
|
|
95
|
+
const DOC_FIELDS = "id slugId title url content";
|
|
96
|
+
/** The live `DocumentSource`, backed by a Linear bearer token. Plain fetch, no SDK. */
|
|
97
|
+
export function linearDocumentSource(token) {
|
|
98
|
+
return {
|
|
99
|
+
async issueDocuments(issueId) {
|
|
100
|
+
// Bounded, unpaginated cap: an issue with more than 50 attached documents (or 100 attachments
|
|
101
|
+
// below) silently drops the overflow. That is a deliberate limit, not a bug; revisit with cursor
|
|
102
|
+
// pagination if real issues approach it.
|
|
103
|
+
const data = await gql(token, `query($id: String!){ issue(id:$id){ documents(first:50){ nodes{ ${DOC_FIELDS} } } } }`, { id: issueId });
|
|
104
|
+
return data.issue?.documents?.nodes ?? [];
|
|
105
|
+
},
|
|
106
|
+
async issueAttachmentUrls(issueId) {
|
|
107
|
+
const data = await gql(token, `query($id: String!){ issue(id:$id){ attachments(first:100){ nodes{ url } } } }`, { id: issueId });
|
|
108
|
+
return (data.issue?.attachments?.nodes ?? [])
|
|
109
|
+
.map((a) => a.url)
|
|
110
|
+
.filter((u) => typeof u === "string" && u.length > 0);
|
|
111
|
+
},
|
|
112
|
+
async documentBySlug(slug) {
|
|
113
|
+
const data = await gql(token, `query($id: String!){ document(id:$id){ ${DOC_FIELDS} } }`, { id: slug });
|
|
114
|
+
return data.document ?? null;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Fetch the documents attached to a Linear issue as contract `AttachedDocument`s, ready to snapshot
|
|
120
|
+
* into a run. The single entry point the hub calls; resolves the source from the token and runs the
|
|
121
|
+
* pure assembly. Never throws on a single bad document link (best-effort), but a hard failure (auth,
|
|
122
|
+
* network) propagates so the caller can log and proceed with none.
|
|
123
|
+
*/
|
|
124
|
+
export async function fetchAttachedDocuments(token, issueId) {
|
|
125
|
+
return collectAttachedDocuments(linearDocumentSource(token), issueId);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,GAAG,gCAAgC,CAAC;AAqBrD;;;+FAG+F;AAC/F,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,CAAC,GAAG,uBAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,6FAA6F;IAC7F,kGAAkG;IAClG,+EAA+E;IAC/E,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAA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AI,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC;iBAC1C,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;iBACjB,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,KAAK,CAAC,cAAc,CAAC,IAAI;YACvB,MAAM,IAAI,GAAG,MAAM,GAAG,CACpB,KAAK,EACL,0CAA0C,UAAU,MAAM,EAC1D,EAAE,EAAE,EAAE,IAAI,EAAE,CACb,CAAC;YACF,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;QAC/B,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,KAAa,EACb,OAAe;IAEf,OAAO,wBAAwB,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { LinearEvent } from "@dahrk/contracts";
|
|
2
|
+
/**
|
|
3
|
+
* Verify a Linear webhook signature and return the parsed payload, or throw.
|
|
4
|
+
* Linear signs the raw request body with HMAC-SHA256 (hex) under the connection's
|
|
5
|
+
* webhook secret; we recompute and compare in constant time over the raw bytes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function verifyWebhook(rawBody: Buffer, signature: string, secret: string): unknown;
|
|
8
|
+
/**
|
|
9
|
+
* Normalise a verified webhook into the internal LinearEvent. `workspaceId` is read
|
|
10
|
+
* from the payload but only trusted once `authenticate` checks it against the
|
|
11
|
+
* connection's registered set. `tenantId` is supplied by the caller from the owning
|
|
12
|
+
* Connection (the single source of truth for a workspace's tenant), never inferred here.
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalise(payload: unknown, connectionId: string, tenantId: string): LinearEvent;
|
|
15
|
+
/** A Linear agent-session state, mirrored from the engine's run-state (build spec section 14). */
|
|
16
|
+
export type SessionState = "active" | "awaitingInput" | "complete" | "error";
|
|
17
|
+
/** An activity kind posted to the session. `error` rides the same surface as a thought. */
|
|
18
|
+
export type ActivityType = "thought" | "action" | "response" | "error";
|
|
19
|
+
export interface Activity {
|
|
20
|
+
type: ActivityType;
|
|
21
|
+
text: string;
|
|
22
|
+
/** For `action` activities, the tool name. */
|
|
23
|
+
tool?: string;
|
|
24
|
+
/** thought/action only: a transient state, replaced in the UI by the next activity. */
|
|
25
|
+
ephemeral?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface PlanItem {
|
|
28
|
+
stageId: string;
|
|
29
|
+
status: "pending" | "inProgress" | "completed" | "canceled";
|
|
30
|
+
/** Human-readable label shown in Linear's checklist; falls back to `stageId` when absent. */
|
|
31
|
+
title?: string;
|
|
32
|
+
}
|
|
33
|
+
/** An elicitation choice: a bare value, or a labelled value (the label is what the user sees). */
|
|
34
|
+
export type ElicitOption = string | {
|
|
35
|
+
label?: string;
|
|
36
|
+
value: string;
|
|
37
|
+
};
|
|
38
|
+
/** A candidate repository the agent already has access to, handed to Linear's
|
|
39
|
+
* `issueRepositorySuggestions` so it can rank them. `hostname` is the git host
|
|
40
|
+
* (e.g. "github.com"); `repositoryFullName` is "owner/name". */
|
|
41
|
+
export interface RepoCandidate {
|
|
42
|
+
hostname?: string;
|
|
43
|
+
repositoryFullName: string;
|
|
44
|
+
}
|
|
45
|
+
/** One ranked suggestion Linear returns for an issue: a candidate plus a confidence score. The order
|
|
46
|
+
* (and the score) is advisory only - it orders a human pick-list and NEVER decides routing. */
|
|
47
|
+
export interface RepoSuggestion {
|
|
48
|
+
repositoryFullName: string;
|
|
49
|
+
hostname?: string;
|
|
50
|
+
confidence: number;
|
|
51
|
+
}
|
|
52
|
+
/** Account-linking parameters for the `auth` signal (the credential-plane seam). */
|
|
53
|
+
export interface AuthRequest {
|
|
54
|
+
url: string;
|
|
55
|
+
userId?: string;
|
|
56
|
+
providerName?: string;
|
|
57
|
+
}
|
|
58
|
+
/** A pull request to attach to the session's issue (idempotent by `url`). */
|
|
59
|
+
export interface PrAttachment {
|
|
60
|
+
url: string;
|
|
61
|
+
title: string;
|
|
62
|
+
subtitle?: string;
|
|
63
|
+
iconUrl?: string;
|
|
64
|
+
}
|
|
65
|
+
/** A Linear Document to create and link to the session's issue (the `attach-document` action). */
|
|
66
|
+
export interface DocumentInput {
|
|
67
|
+
title: string;
|
|
68
|
+
/** The document body as markdown. */
|
|
69
|
+
content: string;
|
|
70
|
+
}
|
|
71
|
+
/** The created Linear Document, returned so the caller can surface its link. */
|
|
72
|
+
export interface DocumentRef {
|
|
73
|
+
id: string;
|
|
74
|
+
url: string;
|
|
75
|
+
}
|
|
76
|
+
/** A labelled external link on a session (the run dashboard, the eventual PR, a document). The label
|
|
77
|
+
* is what Linear shows on the "Open" affordance; the URL must be unique within the session's array. */
|
|
78
|
+
export interface ExternalUrl {
|
|
79
|
+
url: string;
|
|
80
|
+
label: string;
|
|
81
|
+
}
|
|
82
|
+
/** Keep only the externalUrls Linear accepts: http(s) URLs (internal `skakel://` refs are dropped),
|
|
83
|
+
* with empty/blank URLs removed and duplicates collapsed by `url` (first wins, since Linear requires
|
|
84
|
+
* each URL to be unique within the array). Pure, so it is unit-tested directly. */
|
|
85
|
+
export declare function filterExternalUrls(urls: ExternalUrl[]): ExternalUrl[];
|
|
86
|
+
/**
|
|
87
|
+
* The session-side control surface: drive one Linear agent session. The hub holds the
|
|
88
|
+
* Connection's token and calls this; the edge never does. Two implementations: a
|
|
89
|
+
* credential-free recording client (tests + the offline harness) and the real
|
|
90
|
+
* `@linear/sdk`-backed client (live). See ./recording-client.ts and ./linear-client.ts.
|
|
91
|
+
*/
|
|
92
|
+
export interface AgentSessionClient {
|
|
93
|
+
/** Post a progress activity (thought / action / response / error). */
|
|
94
|
+
postActivity(sessionId: string, activity: Activity): Promise<void>;
|
|
95
|
+
/** Render or update the agent-plan checklist (the workflow stage graph). */
|
|
96
|
+
setPlan(sessionId: string, items: PlanItem[]): Promise<void>;
|
|
97
|
+
/** Raise an elicitation gate (optionally with `select` choices; labels render in the UI). */
|
|
98
|
+
raiseElicitation(sessionId: string, prompt: string, options?: ElicitOption[]): Promise<void>;
|
|
99
|
+
/** Rank candidate repositories for an issue via Linear's `issueRepositorySuggestions`. The returned
|
|
100
|
+
* order is advisory: it only orders the repo pick-list, and never decides routing (the determinism
|
|
101
|
+
* boundary). Returns `[]` when Linear has no opinion, so the caller falls back to registry order. */
|
|
102
|
+
suggestRepositories(issueId: string, candidates: RepoCandidate[]): Promise<RepoSuggestion[]>;
|
|
103
|
+
/** Idempotently stamp an issue with a label by NAME (get-or-create the label, then attach it). Used
|
|
104
|
+
* to record the chosen `repo:<name>` so future events for the issue route deterministically. */
|
|
105
|
+
addIssueLabel(issueId: string, name: string): Promise<void>;
|
|
106
|
+
/** Raise an account-linking elicitation carrying the `auth` signal (credential-plane seam). */
|
|
107
|
+
requestAuth(sessionId: string, prompt: string, auth: AuthRequest): Promise<void>;
|
|
108
|
+
/** Move the session's issue to its team's first `started` state and self-delegate (best practice). */
|
|
109
|
+
startIssue(sessionId: string): Promise<void>;
|
|
110
|
+
/** Move the session's issue to a review-named state on run completion (configurable via
|
|
111
|
+
* `SKAKEL_REVIEW_STATE_NAME`). Leaves it unchanged when no such state exists - never
|
|
112
|
+
* auto-completes, so a human keeps iterating and can re-summon @Skakel on the same PR. */
|
|
113
|
+
moveIssueToReview(sessionId: string): Promise<void>;
|
|
114
|
+
/** Post a normal top-level comment on the session's issue (not an agent activity), so a run
|
|
115
|
+
* summary lands in the issue's comment thread rather than only in the agent session panel. */
|
|
116
|
+
commentOnIssue(sessionId: string, body: string): Promise<void>;
|
|
117
|
+
/** Attach a pull request to the session's issue (idempotent by URL) in addition to externalUrls. */
|
|
118
|
+
attachPr(sessionId: string, pr: PrAttachment): Promise<void>;
|
|
119
|
+
/** Create a Linear Document linked to the session's issue (the `attach-document` action's output),
|
|
120
|
+
* returning its id and URL. The deterministic engine calls this; the LLM never does. */
|
|
121
|
+
createDocument(sessionId: string, doc: DocumentInput): Promise<DocumentRef>;
|
|
122
|
+
/** Set external links on the session (run logs/dashboard, the eventual PR), each with a label. The
|
|
123
|
+
* full array is replaced wholesale, so the caller passes the complete desired set; non-http(s)
|
|
124
|
+
* URLs are filtered out before the call. */
|
|
125
|
+
setExternalUrls(sessionId: string, urls: ExternalUrl[]): Promise<void>;
|
|
126
|
+
/** Mirror the run-state to the Linear session state. */
|
|
127
|
+
setState(sessionId: string, state: SessionState): Promise<void>;
|
|
128
|
+
}
|
|
129
|
+
export { createRecordingClient } from "./recording-client.js";
|
|
130
|
+
export type { RecordingClient, RecordedCall } from "./recording-client.js";
|
|
131
|
+
export { createLinearClient } from "./linear-client.js";
|
|
132
|
+
export { authorizeUrl, exchangeCode, refreshTokens, mintAppToken, fetchOrganizationId, probeToken, DEFAULT_AGENT_SCOPES } from "./oauth.js";
|
|
133
|
+
export type { LinearTokens, LinearProbe } from "./oauth.js";
|
|
134
|
+
export { provisionLabels, provisionWorkflowLabels, provisionRepoLabels, linearLabelApi, projectLabelApi, fetchIssueProjectRepoLabels, REPO_LABEL_GROUP, } from "./labels.js";
|
|
135
|
+
export type { LabelApi, ProvisionOptions } from "./labels.js";
|
|
136
|
+
export { linearTriageApi, linearClientAuth } from "./issues.js";
|
|
137
|
+
export type { TriageApi } from "./issues.js";
|
|
138
|
+
export { fetchAttachedDocuments, collectAttachedDocuments, linearDocumentSource, documentSlugFromUrl, documentSlug, } from "./documents.js";
|
|
139
|
+
export type { DocumentSource, RawDocument } from "./documents.js";
|
|
140
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,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