@dahrk/linear 0.1.0 → 0.2.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/README.md +24 -12
- package/dist/batch-source.d.ts +63 -0
- package/dist/batch-source.d.ts.map +1 -0
- package/dist/batch-source.js +149 -0
- package/dist/batch-source.js.map +1 -0
- package/dist/comments.d.ts +36 -0
- package/dist/comments.d.ts.map +1 -0
- package/dist/comments.js +104 -0
- package/dist/comments.js.map +1 -0
- package/dist/documents.d.ts +1 -15
- package/dist/documents.d.ts.map +1 -1
- package/dist/documents.js +37 -27
- package/dist/documents.js.map +1 -1
- package/dist/format-action.d.ts +25 -0
- package/dist/format-action.d.ts.map +1 -0
- package/dist/format-action.js +250 -0
- package/dist/format-action.js.map +1 -0
- package/dist/index.d.ts +119 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +231 -59
- package/dist/index.js.map +1 -1
- package/dist/issue-graph.d.ts +37 -0
- package/dist/issue-graph.d.ts.map +1 -0
- package/dist/issue-graph.js +125 -0
- package/dist/issue-graph.js.map +1 -0
- package/dist/issues.d.ts +27 -2
- package/dist/issues.d.ts.map +1 -1
- package/dist/issues.js +33 -10
- package/dist/issues.js.map +1 -1
- package/dist/labels.d.ts +48 -1
- package/dist/labels.d.ts.map +1 -1
- package/dist/labels.js +72 -24
- package/dist/labels.js.map +1 -1
- package/dist/linear-client.d.ts +51 -0
- package/dist/linear-client.d.ts.map +1 -1
- package/dist/linear-client.js +233 -34
- package/dist/linear-client.js.map +1 -1
- package/dist/oauth.d.ts +52 -12
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +91 -34
- package/dist/oauth.js.map +1 -1
- package/dist/recording-client.d.ts +20 -2
- package/dist/recording-client.d.ts.map +1 -1
- package/dist/recording-client.js +39 -1
- package/dist/recording-client.js.map +1 -1
- package/dist/responding-client.d.ts +49 -0
- package/dist/responding-client.d.ts.map +1 -0
- package/dist/responding-client.js +47 -0
- package/dist/responding-client.js.map +1 -0
- package/dist/teams.d.ts +20 -0
- package/dist/teams.d.ts.map +1 -0
- package/dist/teams.js +32 -0
- package/dist/teams.js.map +1 -0
- package/package.json +8 -10
- package/src/batch-source.ts +208 -0
- package/src/comments.ts +126 -0
- package/src/documents.ts +162 -0
- package/src/format-action.ts +279 -0
- package/src/index.ts +617 -0
- package/src/issue-graph.ts +169 -0
- package/src/issues.ts +142 -0
- package/src/labels.ts +254 -0
- package/src/linear-client.ts +448 -0
- package/src/oauth.ts +255 -0
- package/src/recording-client.ts +141 -0
- package/src/responding-client.ts +106 -0
- package/src/teams.ts +44 -0
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format a tool call into Linear's action-activity vocabulary (DHK-382): a human verb in
|
|
3
|
+
* `action` and a clean, humanised input in `parameter`. Linear renders these as
|
|
4
|
+
* "<action> · <parameter>" (e.g. "Ran · grep -rn ..."), so the agent session reads as a
|
|
5
|
+
* sequence of verbs instead of a wall of `ToolName {raw JSON args}`.
|
|
6
|
+
*
|
|
7
|
+
* `inputText` is the edge's bounded preview of the tool input: normally a JSON object string
|
|
8
|
+
* (`clip(JSON.stringify(input))`), but it may be TRUNCATED (over the edge's ~500-char cap) or
|
|
9
|
+
* otherwise malformed. Parsing is defensive: a preview that will not parse never throws and
|
|
10
|
+
* never falls through to raw JSON. Known single-field tools still salvage their primary field
|
|
11
|
+
* from a truncated preview; anything unrecoverable degrades to the bare verb.
|
|
12
|
+
*/
|
|
13
|
+
/** Keep a parameter readable on one line; the edge already caps the input at ~500 chars. */
|
|
14
|
+
const MAX_PARAM = 400;
|
|
15
|
+
/** Collapse whitespace to a single line and clip with an ellipsis so the parameter never wraps. */
|
|
16
|
+
function clip(s, max = MAX_PARAM) {
|
|
17
|
+
const t = s.replace(/\s+/g, " ").trim();
|
|
18
|
+
return t.length <= max ? t : `${t.slice(0, max - 1).trimEnd()}…`;
|
|
19
|
+
}
|
|
20
|
+
/** The final path segment (e.g. "packages/hub/src/config-server.ts" -> "config-server.ts"). */
|
|
21
|
+
function basename(p) {
|
|
22
|
+
const trimmed = p.replace(/\/+$/, "");
|
|
23
|
+
const i = trimmed.lastIndexOf("/");
|
|
24
|
+
return i >= 0 ? trimmed.slice(i + 1) : trimmed;
|
|
25
|
+
}
|
|
26
|
+
/** Humanise a tool name for display: split separators and camelCase, then Title Case
|
|
27
|
+
* (e.g. "WebFetch" -> "Web Fetch", "create_issue" -> "Create Issue"). */
|
|
28
|
+
function humaniseToolName(name) {
|
|
29
|
+
return (name
|
|
30
|
+
.replace(/[_-]+/g, " ")
|
|
31
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
32
|
+
.trim()
|
|
33
|
+
.replace(/\b\w/g, (c) => c.toUpperCase()) || "Tool");
|
|
34
|
+
}
|
|
35
|
+
/** A parsed tool-input object, or undefined when the preview is missing/truncated/not an object. */
|
|
36
|
+
function parseInput(text) {
|
|
37
|
+
const t = text?.trim();
|
|
38
|
+
if (!t || !t.startsWith("{"))
|
|
39
|
+
return undefined;
|
|
40
|
+
try {
|
|
41
|
+
const parsed = JSON.parse(t);
|
|
42
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed)
|
|
43
|
+
? parsed
|
|
44
|
+
: undefined;
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** A scalar field as a trimmed string, or undefined when absent/empty/non-scalar. */
|
|
51
|
+
function scalarField(input, key) {
|
|
52
|
+
const v = input?.[key];
|
|
53
|
+
const s = typeof v === "string" ? v : typeof v === "number" || typeof v === "boolean" ? String(v) : undefined;
|
|
54
|
+
return s && s.trim() !== "" ? s : undefined;
|
|
55
|
+
}
|
|
56
|
+
/** Best-effort extraction of a string field straight from the raw preview, so a TRUNCATED JSON
|
|
57
|
+
* (a long command clipped mid-value) still yields its primary field rather than an empty verb. */
|
|
58
|
+
function looseField(text, key) {
|
|
59
|
+
if (!text)
|
|
60
|
+
return undefined;
|
|
61
|
+
const m = new RegExp(`"${key}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)`).exec(text);
|
|
62
|
+
if (!m?.[1])
|
|
63
|
+
return undefined;
|
|
64
|
+
const decoded = m[1]
|
|
65
|
+
.replace(/\\"/g, '"')
|
|
66
|
+
.replace(/\\[nt]/g, " ")
|
|
67
|
+
.replace(/\\\\/g, "\\")
|
|
68
|
+
.replace(/\\$/, "");
|
|
69
|
+
return decoded.trim() !== "" ? decoded : undefined;
|
|
70
|
+
}
|
|
71
|
+
/** A known string field, preferring the parsed value and salvaging a truncated one from the raw text. */
|
|
72
|
+
function stringField(input, text, key) {
|
|
73
|
+
return scalarField(input, key) ?? looseField(text, key);
|
|
74
|
+
}
|
|
75
|
+
/** The first scalar argument of an unknown tool's input, for a best-guess parameter. */
|
|
76
|
+
function firstScalar(input) {
|
|
77
|
+
for (const key of Object.keys(input ?? {})) {
|
|
78
|
+
const s = scalarField(input, key);
|
|
79
|
+
if (s !== undefined)
|
|
80
|
+
return s;
|
|
81
|
+
}
|
|
82
|
+
return "";
|
|
83
|
+
}
|
|
84
|
+
/** A `Read`/inspection line-range suffix (":440-520" or ":440") from numeric offset/limit. */
|
|
85
|
+
function lineRange(input) {
|
|
86
|
+
const offset = input?.offset;
|
|
87
|
+
const limit = input?.limit;
|
|
88
|
+
if (typeof offset !== "number")
|
|
89
|
+
return "";
|
|
90
|
+
return typeof limit === "number" ? `:${offset}-${offset + limit}` : `:${offset}`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Map a `(toolName, inputPreview)` pair to a verb plus a clean parameter. Total and defensive:
|
|
94
|
+
* every branch returns a `{ action, parameter }`, and the parameter is only ever a humanised
|
|
95
|
+
* field value (never the raw JSON), so a malformed or oversized preview degrades to the bare verb.
|
|
96
|
+
*/
|
|
97
|
+
export function formatToolAction(tool, inputText) {
|
|
98
|
+
const name = (tool ?? "").trim();
|
|
99
|
+
const input = parseInput(inputText);
|
|
100
|
+
const field = (key) => stringField(input, inputText, key);
|
|
101
|
+
switch (name) {
|
|
102
|
+
case "Bash":
|
|
103
|
+
return { action: "Ran", parameter: clip(field("command") ?? "") };
|
|
104
|
+
case "Read": {
|
|
105
|
+
const path = field("file_path");
|
|
106
|
+
return { action: "Read", parameter: path ? clip(basename(path) + lineRange(input)) : "" };
|
|
107
|
+
}
|
|
108
|
+
case "Grep": {
|
|
109
|
+
const pattern = field("pattern");
|
|
110
|
+
const path = field("path");
|
|
111
|
+
const where = pattern ? `"${pattern}"${path ? ` in ${path}` : ""}` : "";
|
|
112
|
+
return { action: "Searched", parameter: clip(where) };
|
|
113
|
+
}
|
|
114
|
+
case "Glob": {
|
|
115
|
+
const pattern = field("pattern");
|
|
116
|
+
const path = field("path");
|
|
117
|
+
const where = pattern ? `${pattern}${path ? ` in ${path}` : ""}` : "";
|
|
118
|
+
return { action: "Searched", parameter: clip(where) };
|
|
119
|
+
}
|
|
120
|
+
case "Edit":
|
|
121
|
+
case "MultiEdit": {
|
|
122
|
+
const path = field("file_path");
|
|
123
|
+
return { action: "Edited", parameter: path ? clip(basename(path)) : "" };
|
|
124
|
+
}
|
|
125
|
+
case "Write": {
|
|
126
|
+
const path = field("file_path");
|
|
127
|
+
return { action: "Wrote", parameter: path ? clip(basename(path)) : "" };
|
|
128
|
+
}
|
|
129
|
+
case "ToolSearch":
|
|
130
|
+
return { action: "Loaded tools", parameter: clip(field("query") ?? "") };
|
|
131
|
+
default:
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
// MCP tools arrive as `mcp__<server>__<tool>`; show the humanised tool segment.
|
|
135
|
+
if (name.startsWith("mcp__")) {
|
|
136
|
+
const segments = name.split("__").filter(Boolean);
|
|
137
|
+
const toolSegment = segments[segments.length - 1] ?? name;
|
|
138
|
+
return { action: humaniseToolName(toolSegment), parameter: clip(firstScalar(input)) };
|
|
139
|
+
}
|
|
140
|
+
// Unknown tool: a title-cased name plus its first scalar argument.
|
|
141
|
+
return { action: humaniseToolName(name), parameter: clip(firstScalar(input)) };
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Render a completed tool's output as the markdown `result` of its action activity (DHK-386). This
|
|
145
|
+
* is the companion to formatToolAction: the verb + parameter describe the call, this shapes the
|
|
146
|
+
* outcome per tool - `Bash` as a fenced block, `Grep` as a match-count summary, `Edit`/`Write` as a
|
|
147
|
+
* diff stat, `Read` as how much was read - so the session reads richly instead of dumping raw text.
|
|
148
|
+
*
|
|
149
|
+
* `output` is the tool's full (untruncated) observation output. Total and defensive like its
|
|
150
|
+
* companion: it never throws, bounds every long output with a clear elision so a noisy tool can
|
|
151
|
+
* never flood the session, and degrades any unrecognised tool or shape to a bounded first line. An
|
|
152
|
+
* empty output yields an empty string, so no `result` is folded onto the action.
|
|
153
|
+
*/
|
|
154
|
+
/** Caps for a rendered result: keep the outcome glanceable. Long output shows a head and tail with
|
|
155
|
+
* a "… (N more lines)" marker between, never the whole wall. */
|
|
156
|
+
const RESULT_MAX_LINES = 12;
|
|
157
|
+
const RESULT_HEAD_LINES = 8;
|
|
158
|
+
const RESULT_TAIL_LINES = 3;
|
|
159
|
+
const RESULT_MAX_CHARS = 1800;
|
|
160
|
+
const RESULT_TOP_HITS = 5;
|
|
161
|
+
/** Clip a multi-line block to a character budget, marking the cut with an ellipsis line. */
|
|
162
|
+
function clipBlock(s, max = RESULT_MAX_CHARS) {
|
|
163
|
+
return s.length <= max ? s : `${s.slice(0, max).trimEnd()}\n…`;
|
|
164
|
+
}
|
|
165
|
+
/** Bound a block of lines: keep it whole when short, else show the head and tail with a
|
|
166
|
+
* "… (N more lines)" elision marker between them so long output never becomes a wall of text. */
|
|
167
|
+
function elideLines(lines) {
|
|
168
|
+
if (lines.length <= RESULT_MAX_LINES)
|
|
169
|
+
return lines.join("\n");
|
|
170
|
+
const head = lines.slice(0, RESULT_HEAD_LINES);
|
|
171
|
+
const tail = lines.slice(-RESULT_TAIL_LINES);
|
|
172
|
+
const omitted = lines.length - head.length - tail.length;
|
|
173
|
+
return [...head, `… (${omitted} more lines)`, ...tail].join("\n");
|
|
174
|
+
}
|
|
175
|
+
/** A fenced code block, the standard rendering for verbatim command/file output. */
|
|
176
|
+
function codeFence(body) {
|
|
177
|
+
return "```\n" + body + "\n```";
|
|
178
|
+
}
|
|
179
|
+
/** The first non-empty line, collapsed and clipped - the safe fallback for MCP and unknown tools. */
|
|
180
|
+
function firstLine(output) {
|
|
181
|
+
return clip(output.split("\n").find((l) => l.trim() !== "") ?? "");
|
|
182
|
+
}
|
|
183
|
+
/** English pluralisation for a count, e.g. `plural(2, "match", "matches")`. */
|
|
184
|
+
function plural(n, one, many) {
|
|
185
|
+
return `${n} ${n === 1 ? one : many}`;
|
|
186
|
+
}
|
|
187
|
+
/** `Bash`: the stdout/stderr in a fenced code block, bounded head + tail. */
|
|
188
|
+
function renderBashResult(output) {
|
|
189
|
+
return codeFence(clipBlock(elideLines(output.split("\n"))));
|
|
190
|
+
}
|
|
191
|
+
/** A `path:line` grep hit parsed from a `path:line:content` or `path:line` output row. */
|
|
192
|
+
function grepHit(row) {
|
|
193
|
+
const m = /^(.+?):(\d+)(?::|$)/.exec(row);
|
|
194
|
+
return m ? { path: m[1], line: m[2] } : undefined;
|
|
195
|
+
}
|
|
196
|
+
/** `Grep`: an "N matches in M files" summary plus the first few ``path:line`` hits. Falls back to a
|
|
197
|
+
* plain match count and the first rows when the output is not the `path:line` shape (e.g. a
|
|
198
|
+
* files-with-matches listing of bare paths). */
|
|
199
|
+
function renderGrepResult(output) {
|
|
200
|
+
const rows = output.split("\n").map((r) => r.trim()).filter(Boolean);
|
|
201
|
+
const hits = rows.map(grepHit).filter((h) => h !== undefined);
|
|
202
|
+
if (hits.length === 0) {
|
|
203
|
+
const listed = rows.slice(0, RESULT_TOP_HITS).map((r) => `- ${r}`);
|
|
204
|
+
const more = rows.length > RESULT_TOP_HITS ? [`… (${rows.length - RESULT_TOP_HITS} more)`] : [];
|
|
205
|
+
return [plural(rows.length, "match", "matches"), ...listed, ...more].join("\n");
|
|
206
|
+
}
|
|
207
|
+
const files = new Set(hits.map((h) => h.path)).size;
|
|
208
|
+
const summary = `${plural(hits.length, "match", "matches")} in ${plural(files, "file", "files")}`;
|
|
209
|
+
const top = hits.slice(0, RESULT_TOP_HITS).map((h) => `- \`${h.path}:${h.line}\``);
|
|
210
|
+
const more = hits.length > RESULT_TOP_HITS ? [`… (${hits.length - RESULT_TOP_HITS} more)`] : [];
|
|
211
|
+
return [summary, ...top, ...more].join("\n");
|
|
212
|
+
}
|
|
213
|
+
/** `Read`: how much was read; the file content itself is not worth echoing into the session. */
|
|
214
|
+
function renderReadResult(output) {
|
|
215
|
+
return `Read ${plural(output.split("\n").length, "line", "lines")}.`;
|
|
216
|
+
}
|
|
217
|
+
/** `Edit`/`Write`: a `+added / −removed` diff stat when the output is a unified diff, else the tool's
|
|
218
|
+
* one-line confirmation. Ignores the `+++`/`---` file headers so they are not counted as changes. */
|
|
219
|
+
function renderEditResult(output) {
|
|
220
|
+
let added = 0;
|
|
221
|
+
let removed = 0;
|
|
222
|
+
for (const line of output.split("\n")) {
|
|
223
|
+
if (line.startsWith("+") && !line.startsWith("+++"))
|
|
224
|
+
added += 1;
|
|
225
|
+
else if (line.startsWith("-") && !line.startsWith("---"))
|
|
226
|
+
removed += 1;
|
|
227
|
+
}
|
|
228
|
+
return added > 0 || removed > 0 ? `\`+${added} / −${removed}\`` : firstLine(output);
|
|
229
|
+
}
|
|
230
|
+
export function formatToolResult(tool, output) {
|
|
231
|
+
const text = (output ?? "").trimEnd();
|
|
232
|
+
if (text.trim() === "")
|
|
233
|
+
return "";
|
|
234
|
+
switch ((tool ?? "").trim()) {
|
|
235
|
+
case "Bash":
|
|
236
|
+
return renderBashResult(text);
|
|
237
|
+
case "Grep":
|
|
238
|
+
return renderGrepResult(text);
|
|
239
|
+
case "Read":
|
|
240
|
+
return renderReadResult(text);
|
|
241
|
+
case "Edit":
|
|
242
|
+
case "MultiEdit":
|
|
243
|
+
case "Write":
|
|
244
|
+
return renderEditResult(text);
|
|
245
|
+
default:
|
|
246
|
+
// MCP and unknown tools: a short, safe summary rather than a raw dump.
|
|
247
|
+
return firstLine(text);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=format-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-action.js","sourceRoot":"","sources":["../src/format-action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAQH,4FAA4F;AAC5F,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,mGAAmG;AACnG,SAAS,IAAI,CAAC,CAAS,EAAE,GAAG,GAAG,SAAS;IACtC,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,OAAO,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC;AACnE,CAAC;AAED,+FAA+F;AAC/F,SAAS,QAAQ,CAAC,CAAS;IACzB,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACtC,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AACjD,CAAC;AAED;0EAC0E;AAC1E,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO,CACL,IAAI;SACD,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;SACtB,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,IAAI,EAAE;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tF,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAwB,EAAE,MAA0B;IACnF,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IACtC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAElC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC5B,KAAK,MAAM;YACT,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC,KAAK,MAAM;YACT,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC,KAAK,MAAM;YACT,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC,KAAK,MAAM,CAAC;QACZ,KAAK,WAAW,CAAC;QACjB,KAAK,OAAO;YACV,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAChC;YACE,uEAAuE;YACvE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dahrk/linear - the Linear-native control surface (build spec section 14).
|
|
3
|
+
*
|
|
4
|
+
* Two responsibilities:
|
|
5
|
+
* 1. Intake-side (used by the hub): verify the webhook signature, and normalise a
|
|
6
|
+
* raw Linear webhook into the internal LinearEvent. tenantId/workspaceId are
|
|
7
|
+
* resolved from the authenticated connection, never from the payload.
|
|
8
|
+
* 2. Session-side (used by hub + edge): drive the Agent Session API natively -
|
|
9
|
+
* post activities (thought/action/response), render the stage graph as the
|
|
10
|
+
* agent-plan checklist, raise elicitation gates, take prompted-drive turns,
|
|
11
|
+
* handle the stop signal, set externalUrls.
|
|
12
|
+
*
|
|
13
|
+
* Re-implemented directly against the Agent Session API; cyrus's posting code is a
|
|
14
|
+
* reference, not a dependency. Intended runtime dep: the Linear TypeScript SDK
|
|
15
|
+
* (added at M2/M5).
|
|
16
|
+
*/
|
|
1
17
|
import type { LinearEvent } from "@dahrk/contracts";
|
|
18
|
+
import type { LinearWebhookPayload } from "@linear/sdk/webhooks";
|
|
2
19
|
/**
|
|
3
|
-
* Verify a Linear webhook signature and return the parsed
|
|
4
|
-
*
|
|
5
|
-
*
|
|
20
|
+
* Verify a Linear webhook signature and timestamp freshness, then return the parsed
|
|
21
|
+
* payload, or throw. Delegates to LinearWebhookClient.parseData which uses
|
|
22
|
+
* HMAC-SHA256 + timingSafeEqual. The webhookTimestamp field is extracted from the
|
|
23
|
+
* raw body so the SDK's built-in ±60 s replay window applies; a missing or
|
|
24
|
+
* non-numeric timestamp skips the freshness check. Throws "Invalid webhook
|
|
25
|
+
* signature" on bad HMAC and "Invalid webhook timestamp" on a stale delivery.
|
|
6
26
|
*/
|
|
7
27
|
export declare function verifyWebhook(rawBody: Buffer, signature: string, secret: string): unknown;
|
|
8
28
|
/**
|
|
@@ -11,16 +31,49 @@ export declare function verifyWebhook(rawBody: Buffer, signature: string, secret
|
|
|
11
31
|
* connection's registered set. `tenantId` is supplied by the caller from the owning
|
|
12
32
|
* Connection (the single source of truth for a workspace's tenant), never inferred here.
|
|
13
33
|
*/
|
|
14
|
-
export declare function normalise(payload:
|
|
34
|
+
export declare function normalise(payload: LinearWebhookPayload, connectionId: string, tenantId: string): LinearEvent;
|
|
15
35
|
/** A Linear agent-session state, mirrored from the engine's run-state (build spec section 14). */
|
|
16
36
|
export type SessionState = "active" | "awaitingInput" | "complete" | "error";
|
|
17
37
|
/** An activity kind posted to the session. `error` rides the same surface as a thought. */
|
|
18
38
|
export type ActivityType = "thought" | "action" | "response" | "error";
|
|
39
|
+
/** The result of `startIssue`, so a caller can SEE a no-op/failed state move rather than have it
|
|
40
|
+
* silently swallowed (a silent no-op is why the ticket sat in Backlog for a whole run). `moved`
|
|
41
|
+
* is true only when the issue was actually transitioned into a working state; otherwise `reason`
|
|
42
|
+
* says why not (a benign skip like `already-active` vs a real failure like `no-started-state`). */
|
|
43
|
+
export type StartIssueOutcome = {
|
|
44
|
+
moved: true;
|
|
45
|
+
stateName: string;
|
|
46
|
+
} | {
|
|
47
|
+
moved: false;
|
|
48
|
+
reason: StartIssueSkip;
|
|
49
|
+
};
|
|
50
|
+
/** Why `startIssue` did not move the issue. The first two are benign (nothing to do); the rest are
|
|
51
|
+
* failures a caller should surface. */
|
|
52
|
+
export type StartIssueSkip = "no-issue" | "already-active" | "no-team" | "no-started-state" | "update-failed";
|
|
53
|
+
/** The result of `moveIssueToReview` (DHK-283), so a caller can SEE a no-op instead of the ticket
|
|
54
|
+
* silently sitting In Progress. `moved` is true only when the issue was actually transitioned into a
|
|
55
|
+
* review state; otherwise `reason` says why not - benign (`already-there`, e.g. a closed issue or one
|
|
56
|
+
* already in the review state) vs a real gap (`no-review-state`: this team has no state named
|
|
57
|
+
* review/in review/qa and `DAHRK_REVIEW_STATE_NAME` is unset/unmatched). */
|
|
58
|
+
export type MoveToReviewOutcome = {
|
|
59
|
+
moved: true;
|
|
60
|
+
stateName: string;
|
|
61
|
+
} | {
|
|
62
|
+
moved: false;
|
|
63
|
+
reason: MoveToReviewSkip;
|
|
64
|
+
};
|
|
65
|
+
/** Why `moveIssueToReview` did not move the issue. `no-issue`/`already-there` are benign; the rest are
|
|
66
|
+
* gaps a caller should surface as a visible thought. */
|
|
67
|
+
export type MoveToReviewSkip = "no-issue" | "already-there" | "no-team" | "no-review-state" | "update-failed";
|
|
19
68
|
export interface Activity {
|
|
20
69
|
type: ActivityType;
|
|
21
70
|
text: string;
|
|
22
71
|
/** For `action` activities, the tool name. */
|
|
23
72
|
tool?: string;
|
|
73
|
+
/** For `action` activities, the tool's outcome folded under the call (markdown, DHK-385). Set once
|
|
74
|
+
* the call completes so the step reads as one self-contained activity: verb + parameter on top,
|
|
75
|
+
* result underneath. Ignored for non-action types. */
|
|
76
|
+
result?: string;
|
|
24
77
|
/** thought/action only: a transient state, replaced in the UI by the next activity. */
|
|
25
78
|
ephemeral?: boolean;
|
|
26
79
|
}
|
|
@@ -55,6 +108,26 @@ export interface AuthRequest {
|
|
|
55
108
|
userId?: string;
|
|
56
109
|
providerName?: string;
|
|
57
110
|
}
|
|
111
|
+
/** A Linear workflow-state category. Mirrors the `type` field on a `WorkflowState`. */
|
|
112
|
+
export type IssueStateType = "triage" | "backlog" | "unstarted" | "started" | "completed" | "canceled";
|
|
113
|
+
/** The disengagement ground truth for one Linear issue, read live off the API (DHK-*: stuck
|
|
114
|
+
* awaitingInput backstop). Only the fields the disengagement predicate needs are carried; an issue
|
|
115
|
+
* ABSENT from a `readIssueEngagement` result (hard-deleted) is represented by the map having no
|
|
116
|
+
* entry, not by a value here, so `present` is always true when an `IssueEngagement` exists. */
|
|
117
|
+
export interface IssueEngagement {
|
|
118
|
+
/** Always true for a returned issue; the "not present" (deleted) case is a missing map entry. */
|
|
119
|
+
present: boolean;
|
|
120
|
+
/** The issue has been archived (soft-deleted). Read from `archivedAt`; archived issues are still
|
|
121
|
+
* returned because the read requests `includeArchived`. */
|
|
122
|
+
archived: boolean;
|
|
123
|
+
/** The issue's current workflow-state category (`state.type`), when known. */
|
|
124
|
+
stateType?: IssueStateType;
|
|
125
|
+
/** The current assignee's user id, when set. */
|
|
126
|
+
assigneeId?: string;
|
|
127
|
+
/** The current delegated agent-user id (`delegateId`), when set. For an agent, engagement is
|
|
128
|
+
* delegation, not assignment, so this is the primary identity to test against the app user. */
|
|
129
|
+
delegateId?: string;
|
|
130
|
+
}
|
|
58
131
|
/** A pull request to attach to the session's issue (idempotent by `url`). */
|
|
59
132
|
export interface PrAttachment {
|
|
60
133
|
url: string;
|
|
@@ -105,12 +178,16 @@ export interface AgentSessionClient {
|
|
|
105
178
|
addIssueLabel(issueId: string, name: string): Promise<void>;
|
|
106
179
|
/** Raise an account-linking elicitation carrying the `auth` signal (credential-plane seam). */
|
|
107
180
|
requestAuth(sessionId: string, prompt: string, auth: AuthRequest): Promise<void>;
|
|
108
|
-
/** Move the session's issue
|
|
109
|
-
|
|
181
|
+
/** Move the session's issue into its team's working (`started`, non-review) state and self-delegate
|
|
182
|
+
* (best practice on delegation). Returns an outcome so a caller can surface a no-op/failed move
|
|
183
|
+
* instead of it vanishing (see `StartIssueOutcome`). */
|
|
184
|
+
startIssue(sessionId: string): Promise<StartIssueOutcome>;
|
|
110
185
|
/** Move the session's issue to a review-named state on run completion (configurable via
|
|
111
|
-
* `
|
|
112
|
-
* auto-completes, so a human keeps iterating and can re-summon @
|
|
113
|
-
|
|
186
|
+
* `DAHRK_REVIEW_STATE_NAME`). Leaves it unchanged when no such state exists - never
|
|
187
|
+
* auto-completes, so a human keeps iterating and can re-summon @Dahrk on the same PR. Returns an
|
|
188
|
+
* outcome so a caller can surface a no-op (no matching state) rather than have the ticket silently
|
|
189
|
+
* stay In Progress (see `MoveToReviewOutcome`). */
|
|
190
|
+
moveIssueToReview(sessionId: string): Promise<MoveToReviewOutcome>;
|
|
114
191
|
/** Post a normal top-level comment on the session's issue (not an agent activity), so a run
|
|
115
192
|
* summary lands in the issue's comment thread rather than only in the agent session panel. */
|
|
116
193
|
commentOnIssue(sessionId: string, body: string): Promise<void>;
|
|
@@ -125,16 +202,43 @@ export interface AgentSessionClient {
|
|
|
125
202
|
setExternalUrls(sessionId: string, urls: ExternalUrl[]): Promise<void>;
|
|
126
203
|
/** Mirror the run-state to the Linear session state. */
|
|
127
204
|
setState(sessionId: string, state: SessionState): Promise<void>;
|
|
205
|
+
/** Read disengagement ground truth for a batch of issues in one query (rate-limit friendly; the
|
|
206
|
+
* read includes archived issues). The result maps issue id -> `IssueEngagement`; an issue id that
|
|
207
|
+
* is absent from the result was not returned by Linear (hard-deleted). Used by the disengagement
|
|
208
|
+
* sweep and webhook path to decide whether @Dahrk is still engaged on an issue. */
|
|
209
|
+
readIssueEngagement(issueIds: string[]): Promise<Map<string, IssueEngagement>>;
|
|
210
|
+
/** The app user's own id (`viewer.id`) - the id @Dahrk self-delegates to on `startIssue`. Cached.
|
|
211
|
+
* This is the identity a run's issue must still delegate/assign to for the agent to be "engaged". */
|
|
212
|
+
appUserId(): Promise<string>;
|
|
213
|
+
/** Proactively create an agent session ON an issue (DHK-63): the hub was neither delegated nor
|
|
214
|
+
* @mentioned but has useful work to do (a triage/SLA pre-brief). Returns the new session id so the
|
|
215
|
+
* caller can bind a run to it. Wraps Linear's `agentSessionCreateOnIssue`. */
|
|
216
|
+
createSessionOnIssue(issueId: string): Promise<string>;
|
|
217
|
+
/** Proactively create an agent session ON a comment (DHK-63): the comment analogue of
|
|
218
|
+
* `createSessionOnIssue`. Returns the new session id. Wraps `agentSessionCreateOnComment`. */
|
|
219
|
+
createSessionOnComment(commentId: string): Promise<string>;
|
|
128
220
|
}
|
|
221
|
+
export type { LinearWebhookPayload } from "@linear/sdk/webhooks";
|
|
129
222
|
export { createRecordingClient } from "./recording-client.js";
|
|
130
|
-
export type { RecordingClient, RecordedCall } from "./recording-client.js";
|
|
223
|
+
export type { RecordingClient, RecordedCall, RecordingClientOptions } from "./recording-client.js";
|
|
224
|
+
export { createRespondingLinearClient } from "./responding-client.js";
|
|
225
|
+
export type { RespondingClient, RespondingClientOptions, SessionProjection, GateDecision, } from "./responding-client.js";
|
|
131
226
|
export { createLinearClient } from "./linear-client.js";
|
|
132
|
-
export {
|
|
227
|
+
export { formatToolAction, formatToolResult, type ToolAction } from "./format-action.js";
|
|
228
|
+
export { authorizeUrl, exchangeCode, refreshTokens, revokeToken, mintAppToken, fetchOrganizationId, probeToken, DEFAULT_AGENT_SCOPES } from "./oauth.js";
|
|
133
229
|
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 {
|
|
137
|
-
export type {
|
|
230
|
+
export { provisionLabels, provisionWorkflowLabels, provisionRepoLabels, linearLabelApi, projectLabelApi, fetchIssueProjectRepoLabels, fetchIssueChildCount, fetchOpenBlockers, isBlockerSettled, REPO_LABEL_GROUP, } from "./labels.js";
|
|
231
|
+
export type { LabelApi, ProvisionOptions, OpenBlocker } from "./labels.js";
|
|
232
|
+
export { linearTeamsApi, listWorkspaceTeams } from "./teams.js";
|
|
233
|
+
export type { Team, TeamsApi } from "./teams.js";
|
|
234
|
+
export { linearTriageApi, linearClientAuth, linearCaptureApi } from "./issues.js";
|
|
235
|
+
export type { TriageApi, CaptureLinearApi, CaptureIssueResult } from "./issues.js";
|
|
138
236
|
export { fetchAttachedDocuments, collectAttachedDocuments, linearDocumentSource, documentSlugFromUrl, documentSlug, } from "./documents.js";
|
|
139
237
|
export type { DocumentSource, RawDocument } from "./documents.js";
|
|
238
|
+
export { fetchIssueComments, collectIssueComments, linearCommentSource } from "./comments.js";
|
|
239
|
+
export type { CommentSource, RawComment } from "./comments.js";
|
|
240
|
+
export { fetchRelatedIssues, collectRelatedIssues, linearIssueGraphSource, MAX_RELATED_ISSUES, } from "./issue-graph.js";
|
|
241
|
+
export type { IssueGraphSource, RawEdge, RawRelatedIssue } from "./issue-graph.js";
|
|
242
|
+
export { fetchParentBatchSource, collectParentBatchSource, linearParentBatchSource, MAX_BATCH_CHILDREN, } from "./batch-source.js";
|
|
243
|
+
export type { ParentBatchSource, ParentBatchSnapshot, RawChild, RawBlocker, ExternalBlocker, } from "./batch-source.js";
|
|
140
244
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OA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