patchwork-os 0.2.0-alpha.21 → 0.2.0-alpha.23
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 +26 -12
- package/deploy/bootstrap-vps.sh +184 -0
- package/dist/approvalHttp.js +6 -1
- package/dist/approvalHttp.js.map +1 -1
- package/dist/automation.d.ts +20 -0
- package/dist/automation.js +35 -0
- package/dist/automation.js.map +1 -1
- package/dist/bridge.js +22 -4
- package/dist/bridge.js.map +1 -1
- package/dist/bridgeToken.js +57 -19
- package/dist/bridgeToken.js.map +1 -1
- package/dist/commands/recipe.d.ts +256 -0
- package/dist/commands/recipe.js +1313 -0
- package/dist/commands/recipe.js.map +1 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +9 -0
- package/dist/config.js.map +1 -1
- package/dist/connectors/baseConnector.d.ts +117 -0
- package/dist/connectors/baseConnector.js +213 -0
- package/dist/connectors/baseConnector.js.map +1 -0
- package/dist/connectors/confluence.d.ts +111 -0
- package/dist/connectors/confluence.js +406 -0
- package/dist/connectors/confluence.js.map +1 -0
- package/dist/connectors/fixtureLibrary.d.ts +21 -0
- package/dist/connectors/fixtureLibrary.js +70 -0
- package/dist/connectors/fixtureLibrary.js.map +1 -0
- package/dist/connectors/fixtureRecorder.d.ts +1 -0
- package/dist/connectors/fixtureRecorder.js +35 -0
- package/dist/connectors/fixtureRecorder.js.map +1 -0
- package/dist/connectors/github.js +2 -11
- package/dist/connectors/github.js.map +1 -1
- package/dist/connectors/gmail.js +23 -7
- package/dist/connectors/gmail.js.map +1 -1
- package/dist/connectors/googleCalendar.js +23 -7
- package/dist/connectors/googleCalendar.js.map +1 -1
- package/dist/connectors/jira.d.ts +98 -0
- package/dist/connectors/jira.js +379 -0
- package/dist/connectors/jira.js.map +1 -0
- package/dist/connectors/linear.js +2 -11
- package/dist/connectors/linear.js.map +1 -1
- package/dist/connectors/mcpOAuth.d.ts +1 -0
- package/dist/connectors/mcpOAuth.js +30 -4
- package/dist/connectors/mcpOAuth.js.map +1 -1
- package/dist/connectors/mockConnector.d.ts +28 -0
- package/dist/connectors/mockConnector.js +81 -0
- package/dist/connectors/mockConnector.js.map +1 -0
- package/dist/connectors/notion.d.ts +143 -0
- package/dist/connectors/notion.js +424 -0
- package/dist/connectors/notion.js.map +1 -0
- package/dist/connectors/sentry.js +2 -11
- package/dist/connectors/sentry.js.map +1 -1
- package/dist/connectors/slack.js +50 -15
- package/dist/connectors/slack.js.map +1 -1
- package/dist/connectors/tokenStorage.d.ts +35 -0
- package/dist/connectors/tokenStorage.js +394 -0
- package/dist/connectors/tokenStorage.js.map +1 -0
- package/dist/connectors/zendesk.d.ts +104 -0
- package/dist/connectors/zendesk.js +424 -0
- package/dist/connectors/zendesk.js.map +1 -0
- package/dist/featureFlags.d.ts +73 -0
- package/dist/featureFlags.js +203 -0
- package/dist/featureFlags.js.map +1 -0
- package/dist/fp/automationInterpreter.js +1 -0
- package/dist/fp/automationInterpreter.js.map +1 -1
- package/dist/fp/automationProgram.d.ts +1 -1
- package/dist/fp/automationProgram.js.map +1 -1
- package/dist/fp/policyParser.js +17 -0
- package/dist/fp/policyParser.js.map +1 -1
- package/dist/index.js +508 -36
- package/dist/index.js.map +1 -1
- package/dist/oauth.d.ts +4 -1
- package/dist/oauth.js +50 -14
- package/dist/oauth.js.map +1 -1
- package/dist/recipes/chainedRunner.d.ts +104 -0
- package/dist/recipes/chainedRunner.js +359 -0
- package/dist/recipes/chainedRunner.js.map +1 -0
- package/dist/recipes/dependencyGraph.d.ts +39 -0
- package/dist/recipes/dependencyGraph.js +199 -0
- package/dist/recipes/dependencyGraph.js.map +1 -0
- package/dist/recipes/legacyRecipeCompat.d.ts +1 -0
- package/dist/recipes/legacyRecipeCompat.js +97 -0
- package/dist/recipes/legacyRecipeCompat.js.map +1 -0
- package/dist/recipes/nestedRecipeStep.d.ts +58 -0
- package/dist/recipes/nestedRecipeStep.js +95 -0
- package/dist/recipes/nestedRecipeStep.js.map +1 -0
- package/dist/recipes/outputRegistry.d.ts +28 -0
- package/dist/recipes/outputRegistry.js +52 -0
- package/dist/recipes/outputRegistry.js.map +1 -0
- package/dist/recipes/schemaGenerator.d.ts +28 -0
- package/dist/recipes/schemaGenerator.js +484 -0
- package/dist/recipes/schemaGenerator.js.map +1 -0
- package/dist/recipes/templateEngine.d.ts +62 -0
- package/dist/recipes/templateEngine.js +182 -0
- package/dist/recipes/templateEngine.js.map +1 -0
- package/dist/recipes/toolRegistry.d.ts +181 -0
- package/dist/recipes/toolRegistry.js +300 -0
- package/dist/recipes/toolRegistry.js.map +1 -0
- package/dist/recipes/tools/calendar.d.ts +6 -0
- package/dist/recipes/tools/calendar.js +61 -0
- package/dist/recipes/tools/calendar.js.map +1 -0
- package/dist/recipes/tools/confluence.d.ts +6 -0
- package/dist/recipes/tools/confluence.js +254 -0
- package/dist/recipes/tools/confluence.js.map +1 -0
- package/dist/recipes/tools/diagnostics.d.ts +6 -0
- package/dist/recipes/tools/diagnostics.js +36 -0
- package/dist/recipes/tools/diagnostics.js.map +1 -0
- package/dist/recipes/tools/file.d.ts +6 -0
- package/dist/recipes/tools/file.js +170 -0
- package/dist/recipes/tools/file.js.map +1 -0
- package/dist/recipes/tools/git.d.ts +6 -0
- package/dist/recipes/tools/git.js +63 -0
- package/dist/recipes/tools/git.js.map +1 -0
- package/dist/recipes/tools/github.d.ts +6 -0
- package/dist/recipes/tools/github.js +91 -0
- package/dist/recipes/tools/github.js.map +1 -0
- package/dist/recipes/tools/gmail.d.ts +6 -0
- package/dist/recipes/tools/gmail.js +210 -0
- package/dist/recipes/tools/gmail.js.map +1 -0
- package/dist/recipes/tools/index.d.ts +18 -0
- package/dist/recipes/tools/index.js +21 -0
- package/dist/recipes/tools/index.js.map +1 -0
- package/dist/recipes/tools/linear.d.ts +6 -0
- package/dist/recipes/tools/linear.js +83 -0
- package/dist/recipes/tools/linear.js.map +1 -0
- package/dist/recipes/tools/notion.d.ts +6 -0
- package/dist/recipes/tools/notion.js +278 -0
- package/dist/recipes/tools/notion.js.map +1 -0
- package/dist/recipes/tools/slack.d.ts +6 -0
- package/dist/recipes/tools/slack.js +72 -0
- package/dist/recipes/tools/slack.js.map +1 -0
- package/dist/recipes/tools/zendesk.d.ts +6 -0
- package/dist/recipes/tools/zendesk.js +245 -0
- package/dist/recipes/tools/zendesk.js.map +1 -0
- package/dist/recipes/yamlRunner.d.ts +71 -7
- package/dist/recipes/yamlRunner.js +406 -439
- package/dist/recipes/yamlRunner.js.map +1 -1
- package/dist/riskTier.js +1 -0
- package/dist/riskTier.js.map +1 -1
- package/dist/runLog.d.ts +18 -0
- package/dist/runLog.js +5 -0
- package/dist/runLog.js.map +1 -1
- package/dist/server.d.ts +4 -0
- package/dist/server.js +224 -0
- package/dist/server.js.map +1 -1
- package/dist/streamableHttp.js +2 -0
- package/dist/streamableHttp.js.map +1 -1
- package/dist/tools/github/actions.js +4 -2
- package/dist/tools/github/actions.js.map +1 -1
- package/dist/tools/github/composite.d.ts +339 -0
- package/dist/tools/github/composite.js +343 -0
- package/dist/tools/github/composite.js.map +1 -0
- package/dist/tools/github/index.d.ts +1 -0
- package/dist/tools/github/index.js +1 -0
- package/dist/tools/github/index.js.map +1 -1
- package/dist/tools/github/issues.js +8 -4
- package/dist/tools/github/issues.js.map +1 -1
- package/dist/tools/github/pr.js +14 -7
- package/dist/tools/github/pr.js.map +1 -1
- package/dist/tools/index.js +10 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/searchTools.js +1 -1
- package/dist/tools/searchTools.js.map +1 -1
- package/dist/transport.d.ts +7 -1
- package/dist/transport.js +85 -11
- package/dist/transport.js.map +1 -1
- package/package.json +1 -1
- package/templates/automation-policies/recipe-authoring.json +25 -0
- package/templates/automation-policy.example.json +6 -0
- package/templates/recipes/lint-on-save.yaml +1 -2
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub tools — github.list_issues, github.list_prs
|
|
3
|
+
*
|
|
4
|
+
* Self-registering tool module for the recipe tool registry.
|
|
5
|
+
*/
|
|
6
|
+
import { CommonSchemas, registerTool } from "../toolRegistry.js";
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// github.list_issues
|
|
9
|
+
// ============================================================================
|
|
10
|
+
registerTool({
|
|
11
|
+
id: "github.list_issues",
|
|
12
|
+
namespace: "github",
|
|
13
|
+
description: "List GitHub issues assigned to a user or matching filters.",
|
|
14
|
+
paramsSchema: {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
repo: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "Repository in 'owner/repo' format (omit for all accessible repos)",
|
|
20
|
+
},
|
|
21
|
+
assignee: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "User to filter by (use '@me' for current user)",
|
|
24
|
+
default: "@me",
|
|
25
|
+
},
|
|
26
|
+
max: CommonSchemas.max,
|
|
27
|
+
into: CommonSchemas.into,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
outputSchema: {
|
|
31
|
+
type: "object",
|
|
32
|
+
properties: {
|
|
33
|
+
count: { type: "number" },
|
|
34
|
+
issues: { type: "array" },
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
riskDefault: "low",
|
|
38
|
+
isWrite: false,
|
|
39
|
+
isConnector: true,
|
|
40
|
+
execute: async ({ params }) => {
|
|
41
|
+
const { listIssues } = await import("../../connectors/github.js");
|
|
42
|
+
const repo = params.repo ? String(params.repo) : undefined;
|
|
43
|
+
const assignee = params.assignee ? String(params.assignee) : "@me";
|
|
44
|
+
const limit = typeof params.max === "number" ? params.max : 20;
|
|
45
|
+
const issues = await listIssues({ repo, assignee, limit });
|
|
46
|
+
return JSON.stringify({ count: issues.length, issues });
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
// ============================================================================
|
|
50
|
+
// github.list_prs
|
|
51
|
+
// ============================================================================
|
|
52
|
+
registerTool({
|
|
53
|
+
id: "github.list_prs",
|
|
54
|
+
namespace: "github",
|
|
55
|
+
description: "List GitHub pull requests authored by or involving a user.",
|
|
56
|
+
paramsSchema: {
|
|
57
|
+
type: "object",
|
|
58
|
+
properties: {
|
|
59
|
+
repo: {
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "Repository in 'owner/repo' format (omit for all accessible repos)",
|
|
62
|
+
},
|
|
63
|
+
author: {
|
|
64
|
+
type: "string",
|
|
65
|
+
description: "Author to filter by (use '@me' for current user)",
|
|
66
|
+
default: "@me",
|
|
67
|
+
},
|
|
68
|
+
max: CommonSchemas.max,
|
|
69
|
+
into: CommonSchemas.into,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
outputSchema: {
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
count: { type: "number" },
|
|
76
|
+
prs: { type: "array" },
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
riskDefault: "low",
|
|
80
|
+
isWrite: false,
|
|
81
|
+
isConnector: true,
|
|
82
|
+
execute: async ({ params }) => {
|
|
83
|
+
const { listPRs } = await import("../../connectors/github.js");
|
|
84
|
+
const repo = params.repo ? String(params.repo) : undefined;
|
|
85
|
+
const author = params.author ? String(params.author) : "@me";
|
|
86
|
+
const limit = typeof params.max === "number" ? params.max : 20;
|
|
87
|
+
const prs = await listPRs({ repo, author, limit });
|
|
88
|
+
return JSON.stringify({ count: prs.length, prs });
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","sourceRoot":"","sources":["../../../src/recipes/tools/github.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjE,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,YAAY,CAAC;IACX,EAAE,EAAE,oBAAoB;IACxB,SAAS,EAAE,QAAQ;IACnB,WAAW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AAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QACnD,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IACpD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gmail tools — gmail.fetch_unread, gmail.search, gmail.fetch_thread
|
|
3
|
+
*
|
|
4
|
+
* Self-registering tool module for the recipe tool registry.
|
|
5
|
+
*/
|
|
6
|
+
import { CommonSchemas, registerTool } from "../toolRegistry.js";
|
|
7
|
+
async function gmailSearch(query, max, deps) {
|
|
8
|
+
const errorResult = (msg) => JSON.stringify({ count: 0, messages: [], error: msg });
|
|
9
|
+
let token;
|
|
10
|
+
try {
|
|
11
|
+
if (!deps.getGmailToken) {
|
|
12
|
+
return errorResult("Gmail not connected");
|
|
13
|
+
}
|
|
14
|
+
token = await deps.getGmailToken();
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
return errorResult(err instanceof Error ? err.message : "Gmail not connected");
|
|
18
|
+
}
|
|
19
|
+
const fetch = deps.fetchFn || globalThis.fetch;
|
|
20
|
+
try {
|
|
21
|
+
// 1. List messages
|
|
22
|
+
const listUrl = `https://www.googleapis.com/gmail/v1/users/me/messages?q=${encodeURIComponent(query)}&maxResults=${max}`;
|
|
23
|
+
const listRes = await fetch(listUrl, {
|
|
24
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
25
|
+
});
|
|
26
|
+
if (!listRes.ok) {
|
|
27
|
+
return errorResult("Gmail API error");
|
|
28
|
+
}
|
|
29
|
+
const listJson = (await listRes.json());
|
|
30
|
+
const ids = listJson.messages ?? [];
|
|
31
|
+
// 2. Fetch details for each message
|
|
32
|
+
const messages = await Promise.all(ids.slice(0, max).map(async (m) => {
|
|
33
|
+
const detailUrl = `https://www.googleapis.com/gmail/v1/users/me/messages/${m.id}?format=metadata&metadataHeaders=Subject,From,Date`;
|
|
34
|
+
const detailRes = await fetch(detailUrl, {
|
|
35
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
36
|
+
});
|
|
37
|
+
if (!detailRes.ok) {
|
|
38
|
+
return { id: m.id, subject: "", from: "", date: "", snippet: "" };
|
|
39
|
+
}
|
|
40
|
+
const detail = (await detailRes.json());
|
|
41
|
+
const hdrs = detail.payload?.headers ?? [];
|
|
42
|
+
return {
|
|
43
|
+
id: detail.id,
|
|
44
|
+
subject: getHeader(hdrs, "Subject"),
|
|
45
|
+
from: getHeader(hdrs, "From"),
|
|
46
|
+
date: getHeader(hdrs, "Date"),
|
|
47
|
+
snippet: cleanSnippet(detail.snippet ?? ""),
|
|
48
|
+
};
|
|
49
|
+
}));
|
|
50
|
+
return JSON.stringify({ count: messages.length, messages });
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return errorResult("Gmail fetch failed");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function getHeader(headers, name) {
|
|
57
|
+
return (headers.find((h) => h.name.toLowerCase() === name.toLowerCase())?.value ??
|
|
58
|
+
"");
|
|
59
|
+
}
|
|
60
|
+
function cleanSnippet(raw) {
|
|
61
|
+
return raw
|
|
62
|
+
.replace(/[\u00AD\u200B-\u200F\u2060\uFEFF]/g, "")
|
|
63
|
+
.replace(/(\s)\s+/g, "$1")
|
|
64
|
+
.trim()
|
|
65
|
+
.slice(0, 200);
|
|
66
|
+
}
|
|
67
|
+
async function gmailFetchThread(id, deps) {
|
|
68
|
+
const errorResult = (msg) => JSON.stringify({ subject: "", messages: [], error: msg });
|
|
69
|
+
let token;
|
|
70
|
+
try {
|
|
71
|
+
if (!deps.getGmailToken) {
|
|
72
|
+
return errorResult("Gmail not connected");
|
|
73
|
+
}
|
|
74
|
+
token = await deps.getGmailToken();
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
return errorResult(err instanceof Error ? err.message : "Gmail not connected");
|
|
78
|
+
}
|
|
79
|
+
const fetch = deps.fetchFn || globalThis.fetch;
|
|
80
|
+
const res = await fetch(`https://www.googleapis.com/gmail/v1/users/me/threads/${id}?format=metadata`, { headers: { Authorization: `Bearer ${token}` } });
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
return errorResult(`Gmail API error`);
|
|
83
|
+
}
|
|
84
|
+
const data = await res.json();
|
|
85
|
+
const headers = data.messages?.[0]?.payload?.headers ?? [];
|
|
86
|
+
const subject = headers.find((h) => h.name === "Subject")?.value ?? "";
|
|
87
|
+
return JSON.stringify({
|
|
88
|
+
subject,
|
|
89
|
+
messages: data.messages ?? [],
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function sinceToGmailQuery(since) {
|
|
93
|
+
if (since.includes("d")) {
|
|
94
|
+
return `${since.replace("d", "")}d`;
|
|
95
|
+
}
|
|
96
|
+
if (since.includes("h")) {
|
|
97
|
+
return `${since.replace("h", "")}h`;
|
|
98
|
+
}
|
|
99
|
+
return "1d";
|
|
100
|
+
}
|
|
101
|
+
// ============================================================================
|
|
102
|
+
// gmail.fetch_unread
|
|
103
|
+
// ============================================================================
|
|
104
|
+
registerTool({
|
|
105
|
+
id: "gmail.fetch_unread",
|
|
106
|
+
namespace: "gmail",
|
|
107
|
+
description: "Fetch unread Gmail messages since a time expression.",
|
|
108
|
+
paramsSchema: {
|
|
109
|
+
type: "object",
|
|
110
|
+
properties: {
|
|
111
|
+
since: CommonSchemas.since,
|
|
112
|
+
max: {
|
|
113
|
+
...CommonSchemas.max,
|
|
114
|
+
maximum: 50,
|
|
115
|
+
},
|
|
116
|
+
into: CommonSchemas.into,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
outputSchema: {
|
|
120
|
+
type: "object",
|
|
121
|
+
properties: {
|
|
122
|
+
count: { type: "number" },
|
|
123
|
+
messages: { type: "array" },
|
|
124
|
+
error: { type: "string" },
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
riskDefault: "low",
|
|
128
|
+
isWrite: false,
|
|
129
|
+
isConnector: true,
|
|
130
|
+
execute: async ({ params, deps }) => {
|
|
131
|
+
const since = String(params.since ?? "24h");
|
|
132
|
+
const max = Math.min(typeof params.max === "number" ? params.max : 20, 50);
|
|
133
|
+
const query = `is:unread newer_than:${sinceToGmailQuery(since)}`;
|
|
134
|
+
return gmailSearch(query, max, deps);
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
// ============================================================================
|
|
138
|
+
// gmail.search
|
|
139
|
+
// ============================================================================
|
|
140
|
+
registerTool({
|
|
141
|
+
id: "gmail.search",
|
|
142
|
+
namespace: "gmail",
|
|
143
|
+
description: "Search Gmail with a custom query string.",
|
|
144
|
+
paramsSchema: {
|
|
145
|
+
type: "object",
|
|
146
|
+
properties: {
|
|
147
|
+
query: {
|
|
148
|
+
type: "string",
|
|
149
|
+
description: "Gmail search query (same syntax as Gmail search bar)",
|
|
150
|
+
},
|
|
151
|
+
max: {
|
|
152
|
+
...CommonSchemas.max,
|
|
153
|
+
maximum: 50,
|
|
154
|
+
},
|
|
155
|
+
into: CommonSchemas.into,
|
|
156
|
+
},
|
|
157
|
+
required: ["query"],
|
|
158
|
+
},
|
|
159
|
+
outputSchema: {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: {
|
|
162
|
+
count: { type: "number" },
|
|
163
|
+
messages: { type: "array" },
|
|
164
|
+
error: { type: "string" },
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
riskDefault: "low",
|
|
168
|
+
isWrite: false,
|
|
169
|
+
isConnector: true,
|
|
170
|
+
execute: async ({ params, deps }) => {
|
|
171
|
+
const query = String(params.query ?? "");
|
|
172
|
+
const max = Math.min(typeof params.max === "number" ? params.max : 10, 50);
|
|
173
|
+
return gmailSearch(query, max, deps);
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
// ============================================================================
|
|
177
|
+
// gmail.fetch_thread
|
|
178
|
+
// ============================================================================
|
|
179
|
+
registerTool({
|
|
180
|
+
id: "gmail.fetch_thread",
|
|
181
|
+
namespace: "gmail",
|
|
182
|
+
description: "Fetch a specific Gmail thread by ID.",
|
|
183
|
+
paramsSchema: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: {
|
|
186
|
+
id: {
|
|
187
|
+
type: "string",
|
|
188
|
+
description: "Gmail thread ID",
|
|
189
|
+
},
|
|
190
|
+
into: CommonSchemas.into,
|
|
191
|
+
},
|
|
192
|
+
required: ["id"],
|
|
193
|
+
},
|
|
194
|
+
outputSchema: {
|
|
195
|
+
type: "object",
|
|
196
|
+
properties: {
|
|
197
|
+
subject: { type: "string" },
|
|
198
|
+
messages: { type: "array" },
|
|
199
|
+
error: { type: "string" },
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
riskDefault: "low",
|
|
203
|
+
isWrite: false,
|
|
204
|
+
isConnector: true,
|
|
205
|
+
execute: async ({ params, deps }) => {
|
|
206
|
+
const id = String(params.id ?? "");
|
|
207
|
+
return gmailFetchThread(id, deps);
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
//# sourceMappingURL=gmail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gmail.js","sourceRoot":"","sources":["../../../src/recipes/tools/gmail.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjE,KAAK,UAAU,WAAW,CACxB,KAAa,EACb,GAAW,EACX,IAGC;IAED,MAAM,WAAW,GAAG,CAAC,GAAW,EAAU,EAAE,CAC1C,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAEzD,IAAI,K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IAAI,EAAE,CAAC,CAAC;QACnC,OAAO,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool registry loader — imports all tool modules to trigger self-registration.
|
|
3
|
+
*
|
|
4
|
+
* Import this file before using the registry to ensure all tools are registered.
|
|
5
|
+
*/
|
|
6
|
+
import "./file.js";
|
|
7
|
+
import "./git.js";
|
|
8
|
+
import "./diagnostics.js";
|
|
9
|
+
import "./gmail.js";
|
|
10
|
+
import "./github.js";
|
|
11
|
+
import "./linear.js";
|
|
12
|
+
import "./calendar.js";
|
|
13
|
+
import "./slack.js";
|
|
14
|
+
import "./notion.js";
|
|
15
|
+
import "./confluence.js";
|
|
16
|
+
import "./zendesk.js";
|
|
17
|
+
export type { RegisteredTool, ToolContext, ToolExecute, ToolMetadata, } from "../toolRegistry.js";
|
|
18
|
+
export { CommonOutputSchemas, CommonSchemas, clearRegistry, executeTool, getNamespaces, getTool, hasTool, listTools, registerTool, } from "../toolRegistry.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool registry loader — imports all tool modules to trigger self-registration.
|
|
3
|
+
*
|
|
4
|
+
* Import this file before using the registry to ensure all tools are registered.
|
|
5
|
+
*/
|
|
6
|
+
// Core tools
|
|
7
|
+
import "./file.js";
|
|
8
|
+
import "./git.js";
|
|
9
|
+
import "./diagnostics.js";
|
|
10
|
+
// Connector-based tools
|
|
11
|
+
import "./gmail.js";
|
|
12
|
+
import "./github.js";
|
|
13
|
+
import "./linear.js";
|
|
14
|
+
import "./calendar.js";
|
|
15
|
+
import "./slack.js";
|
|
16
|
+
import "./notion.js";
|
|
17
|
+
import "./confluence.js";
|
|
18
|
+
import "./zendesk.js";
|
|
19
|
+
// Re-export registry for convenience
|
|
20
|
+
export { CommonOutputSchemas, CommonSchemas, clearRegistry, executeTool, getNamespaces, getTool, hasTool, listTools, registerTool, } from "../toolRegistry.js";
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/recipes/tools/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,aAAa;AACb,OAAO,WAAW,CAAC;AACnB,OAAO,UAAU,CAAC;AAClB,OAAO,kBAAkB,CAAC;AAE1B,wBAAwB;AACxB,OAAO,YAAY,CAAC;AACpB,OAAO,aAAa,CAAC;AACrB,OAAO,aAAa,CAAC;AACrB,OAAO,eAAe,CAAC;AACvB,OAAO,YAAY,CAAC;AACpB,OAAO,aAAa,CAAC;AACrB,OAAO,iBAAiB,CAAC;AACzB,OAAO,cAAc,CAAC;AAQtB,qCAAqC;AACrC,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,aAAa,EACb,WAAW,EACX,aAAa,EACb,OAAO,EACP,OAAO,EACP,SAAS,EACT,YAAY,GACb,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Linear tools — linear.list_issues
|
|
3
|
+
*
|
|
4
|
+
* Self-registering tool module for the recipe tool registry.
|
|
5
|
+
*/
|
|
6
|
+
import { CommonSchemas, registerTool } from "../toolRegistry.js";
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// linear.list_issues
|
|
9
|
+
// ============================================================================
|
|
10
|
+
registerTool({
|
|
11
|
+
id: "linear.list_issues",
|
|
12
|
+
namespace: "linear",
|
|
13
|
+
description: "List Linear issues assigned to the current user, optionally filtered by team and state.",
|
|
14
|
+
paramsSchema: {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
team: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "Team key to filter by (e.g., 'ENG', 'PROD')",
|
|
20
|
+
},
|
|
21
|
+
assignee: {
|
|
22
|
+
type: "string",
|
|
23
|
+
description: "Use '@me' for current user (default), or omit for all assignees",
|
|
24
|
+
default: "@me",
|
|
25
|
+
},
|
|
26
|
+
state: {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Comma-separated state names (e.g., 'started,unstarted')",
|
|
29
|
+
default: "started,unstarted",
|
|
30
|
+
},
|
|
31
|
+
max: CommonSchemas.max,
|
|
32
|
+
into: CommonSchemas.into,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
outputSchema: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
count: { type: "number" },
|
|
39
|
+
issues: { type: "array" },
|
|
40
|
+
error: { type: "string" },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
riskDefault: "low",
|
|
44
|
+
isWrite: false,
|
|
45
|
+
isConnector: true,
|
|
46
|
+
execute: async ({ params }) => {
|
|
47
|
+
const { loadTokens, listIssues: listLinearIssues } = await import("../../connectors/linear.js");
|
|
48
|
+
if (!loadTokens()) {
|
|
49
|
+
return JSON.stringify({
|
|
50
|
+
count: 0,
|
|
51
|
+
issues: [],
|
|
52
|
+
error: "Linear not connected",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const teamKey = params.team ? String(params.team) : undefined;
|
|
56
|
+
const assigneeMe = params.assignee === "@me" || params.assignee === undefined;
|
|
57
|
+
const stateFilter = params.state
|
|
58
|
+
? String(params.state)
|
|
59
|
+
: "started,unstarted";
|
|
60
|
+
const limit = typeof params.max === "number" ? params.max : 20;
|
|
61
|
+
const states = stateFilter
|
|
62
|
+
.split(",")
|
|
63
|
+
.map((s) => s.trim())
|
|
64
|
+
.filter(Boolean);
|
|
65
|
+
try {
|
|
66
|
+
const issues = await listLinearIssues({
|
|
67
|
+
team: teamKey,
|
|
68
|
+
assigneeMe,
|
|
69
|
+
states,
|
|
70
|
+
limit,
|
|
71
|
+
});
|
|
72
|
+
return JSON.stringify({ count: issues.length, issues });
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
return JSON.stringify({
|
|
76
|
+
count: 0,
|
|
77
|
+
issues: [],
|
|
78
|
+
error: err instanceof Error ? err.message : String(err),
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=linear.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linear.js","sourceRoot":"","sources":["../../../src/recipes/tools/linear.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjE,+EAA+E;AAC/E,qBAAqB;AACrB,+EAA+E;AAE/E,YAAY,CAAC;IACX,EAAE,EAAE,oBAAoB;IACxB,SAAS,EAAE,QAAQ;IACnB,WAAW,EACT,yFAAyF;IAC3F,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6CAA6C;aAC3D;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EACT,iEAAiE;gBACnE,OAAO,EAAE,KAAK;aACf;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yDAAyD;gBACtE,OAAO,EAAE,mBAAmB;aAC7B;YACD,GAAG,EAAE,aAAa,CAAC,GAAG;YACtB,IAAI,EAAE,aAAa,CAAC,IAAI;SACzB;KACF;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;YACzB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;KACF;IACD,WAAW,EAAE,KAAK;IAClB,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,IAAI;IACjB,OAAO,EAAE,KAAK,EAAE,EA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