@frogbotai/piece-linear 0.28.0 → 0.30.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/dist/actions/createComment.js +23 -7
- package/dist/actions/createComment.js.map +1 -1
- package/dist/actions/createIssue.js +12 -6
- package/dist/actions/createIssue.js.map +1 -1
- package/dist/actions/createProject.js +20 -7
- package/dist/actions/createProject.js.map +1 -1
- package/dist/actions/options.js +35 -18
- package/dist/actions/options.js.map +1 -1
- package/dist/actions/rawGraphqlQuery.js +4 -3
- package/dist/actions/rawGraphqlQuery.js.map +1 -1
- package/dist/actions/updateIssue.js +12 -6
- package/dist/actions/updateIssue.js.map +1 -1
- package/dist/actions/updateProject.js +21 -7
- package/dist/actions/updateProject.js.map +1 -1
- package/dist/adapter.js +6 -3
- package/dist/adapter.js.map +1 -1
- package/dist/client.js +6 -3
- package/dist/client.js.map +1 -1
- package/dist/config.js +29 -17
- package/dist/config.js.map +1 -1
- package/dist/define.js +1 -0
- package/dist/define.js.map +1 -1
- package/dist/index.js +55 -23
- package/dist/index.js.map +1 -1
- package/dist/questions/elicitation.js +45 -34
- package/dist/questions/elicitation.js.map +1 -1
- package/dist/questions/index.js +2 -1
- package/dist/questions/index.js.map +1 -1
- package/dist/questions/linearThread.js +8 -6
- package/dist/questions/linearThread.js.map +1 -1
- package/dist/questions/notify.js +23 -10
- package/dist/questions/notify.js.map +1 -1
- package/dist/questions/parse.js +118 -61
- package/dist/questions/parse.js.map +1 -1
- package/dist/questions/render.js +23 -5
- package/dist/questions/render.js.map +1 -1
- package/dist/questions/settled.js +4 -4
- package/dist/questions/settled.js.map +1 -1
- package/dist/questions/supports.js +2 -1
- package/dist/questions/supports.js.map +1 -1
- package/dist/triggers/commentCreated.js +3 -6
- package/dist/triggers/commentCreated.js.map +1 -1
- package/dist/triggers/issueCreated.js +4 -1
- package/dist/triggers/issueCreated.js.map +1 -1
- package/dist/triggers/issueRemoved.js +4 -1
- package/dist/triggers/issueRemoved.js.map +1 -1
- package/dist/triggers/issueUpdated.js +4 -1
- package/dist/triggers/issueUpdated.js.map +1 -1
- package/dist/triggers/projectCreated.js +2 -1
- package/dist/triggers/projectCreated.js.map +1 -1
- package/dist/triggers/projectRemoved.js +2 -1
- package/dist/triggers/projectRemoved.js.map +1 -1
- package/dist/triggers/projectUpdated.js +3 -4
- package/dist/triggers/projectUpdated.js.map +1 -1
- package/dist/triggers/webhook.js +24 -24
- package/dist/triggers/webhook.js.map +1 -1
- package/dist/webhook.js +11 -17
- package/dist/webhook.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ export const linearActions = [
|
|
|
23
23
|
'createProject',
|
|
24
24
|
'updateProject',
|
|
25
25
|
'createComment',
|
|
26
|
-
'rawGraphqlQuery'
|
|
26
|
+
'rawGraphqlQuery'
|
|
27
27
|
];
|
|
28
28
|
export const linearTriggers = [
|
|
29
29
|
'commentCreated',
|
|
@@ -32,66 +32,90 @@ export const linearTriggers = [
|
|
|
32
32
|
'issueRemoved',
|
|
33
33
|
'projectCreated',
|
|
34
34
|
'projectUpdated',
|
|
35
|
-
'projectRemoved'
|
|
35
|
+
'projectRemoved'
|
|
36
36
|
];
|
|
37
37
|
export const linearScopes = [];
|
|
38
38
|
export const linearOAuth = {
|
|
39
39
|
authorizationUrl: 'https://linear.app/oauth/authorize',
|
|
40
40
|
tokenUrl: 'https://api.linear.app/oauth/token',
|
|
41
|
-
scopes: [
|
|
41
|
+
scopes: [
|
|
42
|
+
'read',
|
|
43
|
+
'write',
|
|
44
|
+
'comments:create',
|
|
45
|
+
'issues:create',
|
|
46
|
+
'app:mentionable'
|
|
47
|
+
],
|
|
42
48
|
scopeSeparator: ',',
|
|
43
|
-
params: {
|
|
44
|
-
|
|
49
|
+
params: {
|
|
50
|
+
actor: 'app'
|
|
51
|
+
},
|
|
52
|
+
toAuth ({ tokens }) {
|
|
45
53
|
if (!tokens.access_token?.trim()) {
|
|
46
54
|
throw new Error('Linear OAuth did not return an access token.');
|
|
47
55
|
}
|
|
48
|
-
return {
|
|
56
|
+
return {
|
|
57
|
+
accessToken: tokens.access_token
|
|
58
|
+
};
|
|
49
59
|
},
|
|
50
|
-
async account({ client }) {
|
|
60
|
+
async account ({ client }) {
|
|
51
61
|
const viewer = await client.viewer;
|
|
52
62
|
if (!viewer.email?.trim()) {
|
|
53
63
|
throw new Error('Linear did not return an account email address.');
|
|
54
64
|
}
|
|
55
|
-
return {
|
|
56
|
-
|
|
65
|
+
return {
|
|
66
|
+
id: viewer.id,
|
|
67
|
+
label: viewer.name,
|
|
68
|
+
email: viewer.email
|
|
69
|
+
};
|
|
70
|
+
}
|
|
57
71
|
};
|
|
58
72
|
const linearChannel = {
|
|
59
|
-
adapter({ auth, options }) {
|
|
73
|
+
adapter ({ auth, options }) {
|
|
60
74
|
if (!options.webhookSecret) {
|
|
61
75
|
throw new Error('Linear channels require a webhookSecret option.');
|
|
62
76
|
}
|
|
63
77
|
return new LinearChannelAdapter({
|
|
64
|
-
...
|
|
78
|
+
...'apiKey' in auth ? {
|
|
79
|
+
apiKey: auth.apiKey
|
|
80
|
+
} : {
|
|
81
|
+
accessToken: auth.accessToken
|
|
82
|
+
},
|
|
65
83
|
webhookSecret: options.webhookSecret,
|
|
66
84
|
mode: options.channelMode,
|
|
67
|
-
userName: options.botUsername
|
|
85
|
+
userName: options.botUsername
|
|
68
86
|
});
|
|
69
87
|
},
|
|
70
|
-
async identity({ author, client, req }) {
|
|
88
|
+
async identity ({ author, client, req }) {
|
|
71
89
|
const account = await client.user(author.userId);
|
|
72
90
|
const email = account.email?.trim().toLowerCase();
|
|
73
|
-
if (!email)
|
|
74
|
-
return null;
|
|
91
|
+
if (!email) return null;
|
|
75
92
|
const config = await req.frogbot.config;
|
|
76
93
|
const payloadConfig = await config._internal.payloadConfig;
|
|
77
94
|
const result = await req.frogbot.find({
|
|
78
95
|
collection: payloadConfig.admin.user,
|
|
79
|
-
where: {
|
|
96
|
+
where: {
|
|
97
|
+
email: {
|
|
98
|
+
equals: email
|
|
99
|
+
}
|
|
100
|
+
},
|
|
80
101
|
limit: 1,
|
|
81
102
|
overrideAccess: true,
|
|
82
|
-
req
|
|
103
|
+
req
|
|
83
104
|
});
|
|
84
105
|
const match = result.docs[0];
|
|
85
|
-
return match ? {
|
|
106
|
+
return match ? {
|
|
107
|
+
...match,
|
|
108
|
+
collection: payloadConfig.admin.user
|
|
109
|
+
} : null;
|
|
86
110
|
},
|
|
87
|
-
questions: linearQuestions
|
|
111
|
+
questions: linearQuestions
|
|
88
112
|
};
|
|
89
113
|
export const createLinear = definePiece({
|
|
90
114
|
slug: 'linear',
|
|
91
115
|
label: 'Linear',
|
|
92
116
|
admin: {
|
|
93
117
|
description: 'Manage Linear issues, projects, comments, and webhooks',
|
|
94
|
-
group: 'Productivity'
|
|
118
|
+
group: 'Productivity'
|
|
95
119
|
},
|
|
96
120
|
auth: linearAuth,
|
|
97
121
|
options: linearOptions,
|
|
@@ -99,7 +123,14 @@ export const createLinear = definePiece({
|
|
|
99
123
|
client: createLinearClient,
|
|
100
124
|
webhook: linearWebhook,
|
|
101
125
|
channel: linearChannel,
|
|
102
|
-
actions: [
|
|
126
|
+
actions: [
|
|
127
|
+
createIssue,
|
|
128
|
+
updateIssue,
|
|
129
|
+
createProject,
|
|
130
|
+
updateProject,
|
|
131
|
+
createComment,
|
|
132
|
+
rawGraphqlQuery
|
|
133
|
+
],
|
|
103
134
|
triggers: [
|
|
104
135
|
commentCreated,
|
|
105
136
|
issueCreated,
|
|
@@ -107,7 +138,8 @@ export const createLinear = definePiece({
|
|
|
107
138
|
issueRemoved,
|
|
108
139
|
projectCreated,
|
|
109
140
|
projectUpdated,
|
|
110
|
-
projectRemoved
|
|
111
|
-
]
|
|
141
|
+
projectRemoved
|
|
142
|
+
]
|
|
112
143
|
});
|
|
144
|
+
|
|
113
145
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["definePiece","createComment","createIssue","createProject","rawGraphqlQuery","updateIssue","updateProject","LinearChannelAdapter","createLinearClient","linearAuth","linearOptions","linearQuestions","commentCreated","issueCreated","issueRemoved","issueUpdated","projectCreated","projectRemoved","projectUpdated","linearWebhook","linearActions","linearTriggers","linearScopes","linearOAuth","authorizationUrl","tokenUrl","scopes","scopeSeparator","params","actor","toAuth","tokens","access_token","trim","Error","accessToken","account","client","viewer","email","id","label","name","linearChannel","adapter","auth","options","webhookSecret","apiKey","mode","channelMode","userName","botUsername","identity","author","req","user","userId","toLowerCase","config","frogbot","payloadConfig","_internal","result","find","collection","admin","where","equals","limit","overrideAccess","match","docs","questions","createLinear","slug","description","group","oauth","webhook","channel","actions","triggers"],"mappings":"AAAA,SAASA,WAAW,QAAkD,iBAAiB;AAGvF,SAASC,aAAa,QAAQ,6BAA6B;AAC3D,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,aAAa,QAAQ,6BAA6B;AAC3D,SAASC,eAAe,QAAQ,+BAA+B;AAC/D,SAASC,WAAW,QAAQ,2BAA2B;AACvD,SAASC,aAAa,QAAQ,6BAA6B;AAC3D,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,kBAAkB,QAAqB,cAAc;AAC9D,SAASC,UAAU,EAAEC,aAAa,QAAQ,cAAc;AACxD,SAASC,eAAe,QAAQ,uBAAuB;AACvD,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SAASC,aAAa,QAAQ,eAAe;AAE7C,OAAO,MAAMC,gBAAgB;IAC3B;IACA;IACA;IACA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MAAMlB,QAAQH,QAAQG,KAAK,EAAEN,OAAOyB;QAEpC,IAAI,CAACnB,OAAO,OAAO;QAEnB,MAAMoB,SAAS,MAAMJ,IAAIK,OAAO,CAACD,MAAM;QACvC,MAAME,gBAAgB,MAAMF,OAAOG,SAAS,CAACD,aAAa;QAC1D,MAAME,SAAS,MAAMR,IAAIK,OAAO,CAACI,IAAI,CAAC;YACpCC,YAAYJ,cAAcK,KAAK,CAACV,IAAI;YACpCW,OAAO;gBAAE5B,OAAO;oBAAE6B,QAAQ7B;gBAAM;YAAE;YAClC8B,OAAO;YACPC,gBAAgB;YAChBf;QACF;QACA,MAAMgB,QAAQR,OAAOS,IAAI,CAAC,EAAE;QAE5B,OAAOD,QAAQ;YAAE,GAAGA,KAAK;YAAEN,YAAYJ,cAAcK,KAAK,CAACV,IAAI;QAAC,IAAI;IACtE;IACAiB,WAAW9D;AACb;AAEA,OAAO,MAAM+D,eAAe1E,YAAY;IACtC2E,MAAM;IACNlC,OAAO;IACPyB,OAAO;QACLU,aAAa;QACbC,OAAO;IACT;IACAhC,MAAMpC;IACNqC,SAASpC;IACToE,OAAOvD;IACPc,QAAQ7B;IACRuE,SAAS5D;IACT6D,SAASrC;IACTsC,SAAS;QAAC/E;QAAaG;QAAaF;QAAeG;QAAeL;QAAeG;KAAgB;IACjG8E,UAAU;QACRtE;QACAC;QACAE;QACAD;QACAE;QACAE;QACAD;KACD;AACH,GAAG","file":"index.js"}
|
|
@@ -4,67 +4,78 @@ export function isSelectQuestion(input) {
|
|
|
4
4
|
const [item] = input.questions;
|
|
5
5
|
return input.questions.length === 1 && !item.multiple && item.options.length <= SELECT_OPTIONS;
|
|
6
6
|
}
|
|
7
|
-
export function elicitation({ call, notice
|
|
7
|
+
export function elicitation({ call, notice }) {
|
|
8
8
|
const { input } = call;
|
|
9
9
|
const select = isSelectQuestion(input);
|
|
10
10
|
const sections = select ? selectSections(input.questions[0]) : listSections(input);
|
|
11
|
-
const body = [
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const body = [
|
|
12
|
+
...notice ? [
|
|
13
|
+
`> ${notice}`
|
|
14
|
+
] : [],
|
|
15
|
+
...sections
|
|
16
|
+
].join('\n\n');
|
|
17
|
+
if (!select) return {
|
|
18
|
+
content: {
|
|
19
|
+
type: AgentActivityType.Elicitation,
|
|
20
|
+
body
|
|
21
|
+
}
|
|
22
|
+
};
|
|
14
23
|
return {
|
|
15
|
-
content: {
|
|
24
|
+
content: {
|
|
25
|
+
type: AgentActivityType.Elicitation,
|
|
26
|
+
body
|
|
27
|
+
},
|
|
16
28
|
signal: AgentActivitySignal.Select,
|
|
17
29
|
signalMetadata: {
|
|
18
|
-
options: input.questions[0].options.map(({ label })
|
|
19
|
-
|
|
30
|
+
options: input.questions[0].options.map(({ label })=>({
|
|
31
|
+
label,
|
|
32
|
+
value: label
|
|
33
|
+
}))
|
|
34
|
+
}
|
|
20
35
|
};
|
|
21
36
|
}
|
|
22
37
|
export function response(body) {
|
|
23
|
-
return {
|
|
38
|
+
return {
|
|
39
|
+
content: {
|
|
40
|
+
type: AgentActivityType.Response,
|
|
41
|
+
body
|
|
42
|
+
}
|
|
43
|
+
};
|
|
24
44
|
}
|
|
25
45
|
export function replyHint({ item, numbered }) {
|
|
26
46
|
const header = `“${escapeMarkdown(item.header)}”`;
|
|
27
|
-
if (item.custom)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return `Reply to ${header} with option numbers or labels, such as \`1, 3\`.`;
|
|
31
|
-
return numbered
|
|
32
|
-
? `Reply to ${header} with one option number or label.`
|
|
33
|
-
: `Reply to ${header} with one of the options.`;
|
|
47
|
+
if (item.custom) return `Reply to ${header} with an option or your own answer.`;
|
|
48
|
+
if (item.multiple) return `Reply to ${header} with option numbers or labels, such as \`1, 3\`.`;
|
|
49
|
+
return numbered ? `Reply to ${header} with one option number or label.` : `Reply to ${header} with one of the options.`;
|
|
34
50
|
}
|
|
35
51
|
export function escapeMarkdown(text) {
|
|
36
|
-
return text
|
|
37
|
-
.replace(/[\\`*_[\]<>#|~]/g, '\\$&')
|
|
38
|
-
.replace(/^[-+]/, '\\$&')
|
|
39
|
-
.replace(/^(\d+)([.)])/, '$1\\$2');
|
|
52
|
+
return text.replace(/[\\`*_[\]<>#|~]/g, '\\$&').replace(/^[-+]/, '\\$&').replace(/^(\d+)([.)])/, '$1\\$2');
|
|
40
53
|
}
|
|
41
54
|
function selectSections(item) {
|
|
42
|
-
const options = item.options.map(({ label, description })
|
|
55
|
+
const options = item.options.map(({ label, description })=>`- **${escapeMarkdown(label)}**${description ? ` — ${description}` : ''}`);
|
|
43
56
|
return [
|
|
44
57
|
prompt(item),
|
|
45
58
|
options.join('\n'),
|
|
46
|
-
item.custom ? 'Choose an option, or reply with your own answer.' : 'Choose one of the options.'
|
|
59
|
+
item.custom ? 'Choose an option, or reply with your own answer.' : 'Choose one of the options.'
|
|
47
60
|
];
|
|
48
61
|
}
|
|
49
62
|
function listSections(input) {
|
|
50
|
-
const questions = input.questions.map((item)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
: questions;
|
|
63
|
+
const questions = input.questions.map((item)=>[
|
|
64
|
+
prompt(item),
|
|
65
|
+
item.options.map(({ label, description }, index)=>`${index + 1}. ${escapeMarkdown(label)}${description ? ` — ${description}` : ''}`).join('\n'),
|
|
66
|
+
`_${optionsHint(item)}_`
|
|
67
|
+
].join('\n\n'));
|
|
68
|
+
return input.questions.length > 1 ? [
|
|
69
|
+
...questions,
|
|
70
|
+
'Reply with one line per question, in the order shown.'
|
|
71
|
+
] : questions;
|
|
60
72
|
}
|
|
61
73
|
function optionsHint(item) {
|
|
62
|
-
const choose = item.multiple
|
|
63
|
-
? 'Choose one or more: reply with option numbers or labels, separated by commas (`1, 3`)'
|
|
64
|
-
: 'Choose one: reply with an option number or label';
|
|
74
|
+
const choose = item.multiple ? 'Choose one or more: reply with option numbers or labels, separated by commas (`1, 3`)' : 'Choose one: reply with an option number or label';
|
|
65
75
|
return item.custom ? `${choose}, or type your own answer.` : `${choose}.`;
|
|
66
76
|
}
|
|
67
77
|
function prompt({ header, question }) {
|
|
68
78
|
return `**${escapeMarkdown(header)}**\n${question}`;
|
|
69
79
|
}
|
|
80
|
+
|
|
70
81
|
//# sourceMappingURL=elicitation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/questions/elicitation.ts"],"names":["AgentActivitySignal","AgentActivityType","SELECT_OPTIONS","isSelectQuestion","input","item","questions","length","multiple","options","elicitation","call","notice","select","sections","selectSections","listSections","body","join","content","type","Elicitation","signal","Select","signalMetadata","map","label","value","response","Response","replyHint","numbered","header","escapeMarkdown","custom","text","replace","description","prompt","index","optionsHint","choose","question"],"mappings":"AAAA,SAASA,mBAAmB,EAAEC,iBAAiB,QAAQ,cAAc;AAKrE,OAAO,MAAMC,iBAAiB,GAAG;AAIjC,OAAO,SAASC,iBAAiBC,KAAoB;IACnD,MAAM,CAACC,KAAK,GAAGD,MAAME,SAAS;IAE9B,OAAOF,MAAME,SAAS,CAACC,MAAM,KAAK,KAAK,CAACF,KAAMG,QAAQ,IAAIH,KAAMI,OAAO,CAACF,MAAM,IAAIL;AACpF;AAEA,OAAO,SAASQ,YAAY,EAC1BC,IAAI,EACJC,MAAM,EAIP;IACC,MAAM,EAAER,KAAK,EAAE,GAAGO;IAClB,MAAME,SAASV,iBAAiBC;IAChC,MAAMU,WAAWD,SAASE,eAAeX,MAAME,SAAS,CAAC,EAAE,IAAKU,aAAaZ;IAC7E,MAAMa,OAAO;WAAKL,SAAS;YAAC,CAAC,EAAE,EAAEA,QAAQ;SAAC,GAAG,EAAE;WAAME;KAAS,CAACI,IAAI,CAAC;IAEpE,IAAI,CAACL,QAAQ,OAAO;QAAEM,SAAS;YAAEC,MAAMnB,kBAAkBoB,WAAW;YAAEJ;QAAK;IAAE;IAE7E,OAAO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AAqD;KACpE;AACH;AAEA,SAASlB,aAAaZ,KAAoB;IACxC,MAAME,YAAYF,MAAME,SAAS,CAACmB,GAAG,CAAC,CAACpB,OACrC;YACEiC,OAAOjC;YACPA,KAAKI,OAAO,CACTgB,GAAG,CACF,CAAC,EAAEC,KAAK,EAAEW,WAAW,EAAE,EAAEE,QACvB,GAAGA,QAAQ,EAAE,EAAE,EAAEN,eAAeP,SAASW,cAAc,CAAC,GAAG,EAAEA,aAAa,GAAG,IAAI,EAEpFnB,IAAI,CAAC;YACR,CAAC,CAAC,EAAEsB,YAAYnC,MAAM,CAAC,CAAC;SACzB,CAACa,IAAI,CAAC;IAGT,OAAOd,MAAME,SAAS,CAACC,MAAM,GAAG,IAC5B;WAAID;QAAW;KAAwD,GACvEA;AACN;AAEA,SAASkC,YAAYnC,IAAkB;IACrC,MAAMoC,SAASpC,KAAKG,QAAQ,GACxB,0FACA;IAEJ,OAAOH,KAAK6B,MAAM,GAAG,GAAGO,OAAO,0BAA0B,CAAC,GAAG,GAAGA,OAAO,CAAC,CAAC;AAC3E;AAEA,SAASH,OAAO,EAAEN,MAAM,EAAEU,QAAQ,EAAgB;IAChD,OAAO,CAAC,EAAE,EAAET,eAAeD,QAAQ,IAAI,EAAEU,UAAU;AACrD","file":"elicitation.js"}
|
package/dist/questions/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/questions/index.ts"],"names":["denyLinearQuestion","rejectLinearQuestion","staleLinearQuestion","parseLinearQuestion","renderLinearQuestion","settleLinearQuestion","supportsLinearQuestion","linearQuestions","supports","render","parse","settled","rejected","denied","stale"],"mappings":"AAGA,SAASA,kBAAkB,EAAEC,oBAAoB,EAAEC,mBAAmB,QAAQ,cAAc;AAC5F,SAASC,mBAAmB,QAAQ,aAAa;AACjD,SAASC,oBAAoB,QAAQ,cAAc;AACnD,SAASC,oBAAoB,QAAQ,eAAe;AACpD,SAASC,sBAAsB,QAAQ,gBAAgB;AAEvD,OAAO,MAAMC,kBAAiD;IAC5DC,UAAUF;IACVG,QAAQL;IACRM,OAAOP;IACPQ,SAASN;IACTO,UAAUX;IACVY,QAAQb;IACRc,OAAOZ;AACT,EAAE","file":"index.js"}
|
|
@@ -4,20 +4,22 @@ export function agentSessionId(threadId) {
|
|
|
4
4
|
return SESSION_THREAD.exec(threadId)?.[1];
|
|
5
5
|
}
|
|
6
6
|
export function stopRequested(interaction) {
|
|
7
|
-
if (interaction.type !== 'message')
|
|
8
|
-
return false;
|
|
7
|
+
if (interaction.type !== 'message') return false;
|
|
9
8
|
const raw = interaction.message.raw;
|
|
10
9
|
return raw?.agentActivitySignal === AgentActivitySignal.Stop;
|
|
11
10
|
}
|
|
12
|
-
export async function postActivity({ activity, client, threadId
|
|
11
|
+
export async function postActivity({ activity, client, threadId }) {
|
|
13
12
|
const sessionId = agentSessionId(threadId);
|
|
14
|
-
if (!sessionId)
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
if (!sessionId) throw new Error(`Linear thread '${threadId}' is not an agent session.`);
|
|
14
|
+
const result = await client.createAgentActivity({
|
|
15
|
+
...activity,
|
|
16
|
+
agentSessionId: sessionId
|
|
17
|
+
});
|
|
17
18
|
const id = result.agentActivityId;
|
|
18
19
|
if (!result.success || !id) {
|
|
19
20
|
throw new Error(`Linear did not create the agent activity in session '${sessionId}'.`);
|
|
20
21
|
}
|
|
21
22
|
return id;
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
//# sourceMappingURL=linearThread.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/questions/linearThread.ts"],"names":["AgentActivitySignal","SESSION_THREAD","agentSessionId","threadId","exec","stopRequested","interaction","type","raw","message","agentActivitySignal","Stop","postActivity","activity","client","sessionId","Error","result","createAgentActivity","id","agentActivityId","success"],"mappings":"AAAA,SAASA,mBAAmB,QAA6B,cAAc;AAMvE,MAAMC,iBAAiB;AAIvB,OAAO,SAASC,eAAeC,QAAgB;IAC7C,OAAOF,eAAeG,IAAI,CAACD,WAAW,CAAC,EAAE;AAC3C;AAEA,OAAO,SAASE,cAAcC,WAAgC;IAC5D,IAAIA,YAAYC,IAAI,KAAK,WAAW,OAAO;IAE3C,MAAMC,MAAMF,YAAYG,OAAO,CAACD,GAAG;IAEnC,OAAOA,KAAKE,wBAAwBV,oBAAoBW,IAAI;AAC9D;AAEA,OAAO,eAAeC,aAAa,EACjCC,QAAQ,EACRC,MAAM,EACNX,QAAQ,EAKT;IACC,MAAMY,YAAYb,eAAeC;IAEjC,IAAI,CAACY,WAAW,MAAM,IAAIC,MAAM,CAAC,eAAe,EAAEb,SAAS,0BAA0B,CAAC;IAEtF,MAAMc,SAAS,MAAMH,OAAOI,mBAAmB,CAAC;QAAE,GAAGL,QAAQ;QAAEX,gBAAgBa;IAAU;IACzF,MAAMI,KAAKF,OAAOG,eAAe;IAEjC,IAAI,CAACH,OAAOI,OAAO,IAAI,CAACF,IAAI;QAC1B,MAAM,IAAIH,MAAM,CAAC,qDAAqD,EAAED,UAAU,EAAE,CAAC;IACvF;IAEA,OAAOI;AACT","file":"linearThread.js"}
|
package/dist/questions/notify.js
CHANGED
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
import { elicitation, escapeMarkdown, response } from './elicitation.js';
|
|
2
2
|
import { postActivity, stopRequested } from './linearThread.js';
|
|
3
|
-
export const denyLinearQuestion = async ({ call, client, interaction, thread
|
|
3
|
+
export const denyLinearQuestion = async ({ call, client, interaction, thread })=>{
|
|
4
4
|
const notice = `${authorName(interaction)} can't answer this question without access to this agent. It is still open.`;
|
|
5
|
-
await postActivity({
|
|
5
|
+
await postActivity({
|
|
6
|
+
activity: elicitation({
|
|
7
|
+
call,
|
|
8
|
+
notice
|
|
9
|
+
}),
|
|
10
|
+
client,
|
|
11
|
+
threadId: thread.id
|
|
12
|
+
});
|
|
6
13
|
};
|
|
7
|
-
export const rejectLinearQuestion = async ({ call, client, reason, thread
|
|
14
|
+
export const rejectLinearQuestion = async ({ call, client, reason, thread })=>{
|
|
8
15
|
await postActivity({
|
|
9
|
-
activity: elicitation({
|
|
16
|
+
activity: elicitation({
|
|
17
|
+
call,
|
|
18
|
+
notice: reason
|
|
19
|
+
}),
|
|
10
20
|
client,
|
|
11
|
-
threadId: thread.id
|
|
21
|
+
threadId: thread.id
|
|
12
22
|
});
|
|
13
23
|
};
|
|
14
|
-
export const staleLinearQuestion = async ({ client, interaction, thread
|
|
15
|
-
const body = stopRequested(interaction)
|
|
16
|
-
|
|
17
|
-
:
|
|
18
|
-
|
|
24
|
+
export const staleLinearQuestion = async ({ client, interaction, thread })=>{
|
|
25
|
+
const body = stopRequested(interaction) ? 'This question was already answered. A stop request only dismisses an open question.' : 'This question was already answered.';
|
|
26
|
+
await postActivity({
|
|
27
|
+
activity: response(body),
|
|
28
|
+
client,
|
|
29
|
+
threadId: thread.id
|
|
30
|
+
});
|
|
19
31
|
};
|
|
20
32
|
function authorName(interaction) {
|
|
21
33
|
const author = interaction.type === 'message' ? interaction.message.author : interaction.event.user;
|
|
22
34
|
const name = author.fullName || author.userName;
|
|
23
35
|
return name ? escapeMarkdown(name) : 'This participant';
|
|
24
36
|
}
|
|
37
|
+
|
|
25
38
|
//# sourceMappingURL=notify.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/questions/notify.ts"],"names":["elicitation","escapeMarkdown","response","postActivity","stopRequested","denyLinearQuestion","call","client","interaction","thread","notice","authorName","activity","threadId","id","rejectLinearQuestion","reason","staleLinearQuestion","body","author","type","message","event","user","name","fullName","userName"],"mappings":"AAGA,SAASA,WAAW,EAAEC,cAAc,EAAEC,QAAQ,QAAQ,mBAAmB;AACzE,SAASC,YAAY,EAAEC,aAAa,QAAQ,oBAAoB;AAIhE,OAAO,MAAMC,qBAAgD,OAAO,EAClEC,IAAI,EACJC,MAAM,EACNC,WAAW,EACXC,MAAM,EACP;IACC,MAAMC,SAAS,GAAGC,WAAWH,aAAa,2EAA2E,CAAC;IAEtH,MAAML,aAAa;QAAES,UAAUZ,YAAY;YAAEM;YAAMI;QAAO;QAAIH;QAAQM,UAAUJ,OAAOK,EAAE;IAAC;AAC5F,EAAE;AAEF,OAAO,MAAMC,uBAAoD,OAAO,EACtET,IAAI,EACJC,MAAM,EACNS,MAAM,EACNP,MAAM,EACP;IACC,MAAMN,aAAa;QACjBS,UAAUZ,YAAY;YAAEM;YAAMI,QAAQM;QAAO;QAC7CT;QACAM,UAAUJ,OAAOK,EAAE;IACrB;AACF,EAAE;AAEF,OAAO,MAAMG,sBAAgD,OAAO,EAClEV,MAAM,EACNC,WAAW,EACXC,MAAM,EACP;IACC,MAAMS,OAAOd,cAAcI,eACvB,wFACA;IAEJ,MAAML,aAAa;QAAES,UAAUV,SAASgB;QAAOX;QAAQM,UAAUJ,OAAOK,EAAE;IAAC;AAC7E,EAAE;AAEF,SAASH,WAAWH,WAAgC;IAClD,MAAMW,SACJX,YAAYY,IAAI,KAAK,YAAYZ,YAAYa,OAAO,CAACF,MAAM,GAAGX,YAAYc,KAAK,CAACC,IAAI;IACtF,MAAMC,OAAOL,OAAOM,QAAQ,IAAIN,OAAOO,QAAQ;IAE/C,OAAOF,OAAOvB,eAAeuB,QAAQ;AACvC","file":"notify.js"}
|