@grovina/brian 0.2.2 → 0.2.4
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/agent.js +57 -13
- package/dist/agent.js.map +1 -1
- package/dist/channels/slack-tools.js +96 -0
- package/dist/channels/slack-tools.js.map +1 -0
- package/dist/channels/slack.js +44 -3
- package/dist/channels/slack.js.map +1 -1
- package/dist/channels/telegram-tools.js +60 -0
- package/dist/channels/telegram-tools.js.map +1 -0
- package/dist/channels/telegram.js +58 -5
- package/dist/channels/telegram.js.map +1 -1
- package/dist/client.js +15 -2
- package/dist/client.js.map +1 -1
- package/dist/downloads/resolve.js +21 -0
- package/dist/downloads/resolve.js.map +1 -0
- package/dist/downloads/save.js +36 -0
- package/dist/downloads/save.js.map +1 -0
- package/dist/downloads/ttl.js +39 -0
- package/dist/downloads/ttl.js.map +1 -0
- package/dist/model.js +73 -10
- package/dist/model.js.map +1 -1
- package/dist/start.js +63 -23
- package/dist/start.js.map +1 -1
- package/dist/tools/channel-history-tool.js +38 -0
- package/dist/tools/channel-history-tool.js.map +1 -0
- package/dist/tools/channel-router.js +2 -0
- package/dist/tools/channel-router.js.map +1 -0
- package/dist/tools/mcp.js +149 -0
- package/dist/tools/mcp.js.map +1 -0
- package/dist/tools/read-image.js +50 -0
- package/dist/tools/read-image.js.map +1 -0
- package/dist/tools/registry.js +23 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/wait.js +25 -2
- package/dist/tools/wait.js.map +1 -1
- package/dist/tools/web.js +237 -0
- package/dist/tools/web.js.map +1 -0
- package/dist/web/playwright-session.js +59 -0
- package/dist/web/playwright-session.js.map +1 -0
- package/dist/web/url-policy.js +117 -0
- package/dist/web/url-policy.js.map +1 -0
- package/package.json +6 -2
- package/dist/tools/communication.js +0 -132
- package/dist/tools/communication.js.map +0 -1
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
function parseHostAllowlist(raw) {
|
|
2
|
+
return raw
|
|
3
|
+
.split(',')
|
|
4
|
+
.map((s) => s.trim().toLowerCase())
|
|
5
|
+
.filter(Boolean);
|
|
6
|
+
}
|
|
7
|
+
export function webPolicyFromModuleConfig(config) {
|
|
8
|
+
const allowRaw = typeof config.hostAllowlist === 'string' ? config.hostAllowlist : '';
|
|
9
|
+
const localhostRaw = typeof config.allowLocalhostHttp === 'string' ? config.allowLocalhostHttp.trim().toLowerCase() : 'false';
|
|
10
|
+
return {
|
|
11
|
+
hostAllowlist: parseHostAllowlist(allowRaw),
|
|
12
|
+
allowLocalhostHttp: localhostRaw === 'true' || localhostRaw === '1' || localhostRaw === 'yes',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function isPrivateIPv4(parts) {
|
|
16
|
+
const [a, b] = parts;
|
|
17
|
+
if (a === 10)
|
|
18
|
+
return true;
|
|
19
|
+
if (a === 127)
|
|
20
|
+
return true;
|
|
21
|
+
if (a === 0)
|
|
22
|
+
return true;
|
|
23
|
+
if (a === 169 && b === 254)
|
|
24
|
+
return true;
|
|
25
|
+
if (a === 172 && b >= 16 && b <= 31)
|
|
26
|
+
return true;
|
|
27
|
+
if (a === 192 && b === 168)
|
|
28
|
+
return true;
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
function ipv4HostBlocked(host) {
|
|
32
|
+
const m = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(host);
|
|
33
|
+
if (!m)
|
|
34
|
+
return false;
|
|
35
|
+
const parts = [1, 2, 3, 4].map((i) => Number(m[i]));
|
|
36
|
+
if (parts.some((n) => n > 255))
|
|
37
|
+
return true;
|
|
38
|
+
return isPrivateIPv4(parts);
|
|
39
|
+
}
|
|
40
|
+
function ipv6HostBlocked(host) {
|
|
41
|
+
const h = host.replace(/^\[|\]$/g, '').toLowerCase();
|
|
42
|
+
if (h === '::1')
|
|
43
|
+
return true;
|
|
44
|
+
if (h.startsWith('fc') || h.startsWith('fd'))
|
|
45
|
+
return true;
|
|
46
|
+
if (h.startsWith('fe80:'))
|
|
47
|
+
return true;
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
function hostMatchesAllowlist(hostname, rules) {
|
|
51
|
+
const h = hostname.toLowerCase();
|
|
52
|
+
for (const rule of rules) {
|
|
53
|
+
if (rule.startsWith('*.')) {
|
|
54
|
+
const suffix = rule.slice(2);
|
|
55
|
+
if (h === suffix || h.endsWith(`.${suffix}`))
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
else if (h === rule) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const BLOCKED_HOSTNAMES = new Set([
|
|
65
|
+
'metadata.google.internal',
|
|
66
|
+
'metadata',
|
|
67
|
+
'gce.internal',
|
|
68
|
+
]);
|
|
69
|
+
/**
|
|
70
|
+
* Returns an error message if the URL must not be loaded, otherwise null.
|
|
71
|
+
*/
|
|
72
|
+
export function assertUrlAllowed(urlString, policy) {
|
|
73
|
+
let url;
|
|
74
|
+
try {
|
|
75
|
+
url = new URL(urlString);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return 'Invalid URL.';
|
|
79
|
+
}
|
|
80
|
+
if (url.username || url.password)
|
|
81
|
+
return 'URLs with embedded credentials are not allowed.';
|
|
82
|
+
const protocol = url.protocol.toLowerCase();
|
|
83
|
+
const hostname = url.hostname.toLowerCase();
|
|
84
|
+
if (BLOCKED_HOSTNAMES.has(hostname))
|
|
85
|
+
return `Host "${hostname}" is blocked.`;
|
|
86
|
+
const loopback = hostname === 'localhost' ||
|
|
87
|
+
hostname === '127.0.0.1' ||
|
|
88
|
+
hostname === '::1' ||
|
|
89
|
+
hostname === '[::1]';
|
|
90
|
+
if (protocol === 'https:') {
|
|
91
|
+
// continue
|
|
92
|
+
}
|
|
93
|
+
else if (protocol === 'http:') {
|
|
94
|
+
if (!policy.allowLocalhostHttp || !loopback) {
|
|
95
|
+
return policy.allowLocalhostHttp
|
|
96
|
+
? 'HTTP is only allowed for localhost / 127.0.0.1 / ::1 when enabled in the Web module.'
|
|
97
|
+
: 'Only HTTPS is allowed. Enable "Allow HTTP to localhost" for local HTTP.';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return `Protocol "${url.protocol}" is not allowed.`;
|
|
102
|
+
}
|
|
103
|
+
const skipPrivateCheck = policy.allowLocalhostHttp && loopback;
|
|
104
|
+
if (!skipPrivateCheck) {
|
|
105
|
+
if (hostname.includes(':')) {
|
|
106
|
+
if (ipv6HostBlocked(hostname))
|
|
107
|
+
return 'IPv6 address is not allowed.';
|
|
108
|
+
}
|
|
109
|
+
else if (ipv4HostBlocked(hostname))
|
|
110
|
+
return 'Private or local IPv4 addresses are not allowed.';
|
|
111
|
+
}
|
|
112
|
+
if (policy.hostAllowlist.length > 0 && !hostMatchesAllowlist(hostname, policy.hostAllowlist)) {
|
|
113
|
+
return `Host "${hostname}" is not in the Web module allowlist.`;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=url-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-policy.js","sourceRoot":"","sources":["../../src/web/url-policy.ts"],"names":[],"mappings":"AAKA,SAAS,kBAAkB,CAAC,GAAW;IACrC,OAAO,GAAG;SACP,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;SAClC,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,MAA+B;IACvE,MAAM,QAAQ,GAAG,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,MAAM,YAAY,GAChB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,QAAQ,CAAC;YAAE,OAAO,kDAAkD,CAAC;IAClG,CAAC;IAED,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QAC7F,OAAO,SAAS,QAAQ,uCAAuC,CAAC;IAClE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grovina/brian",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Brian runtime worker for Grovina agents",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
+
"postinstall": "playwright install chromium",
|
|
18
19
|
"build": "tsc && chmod +x dist/cli/self.js dist/start.js",
|
|
19
20
|
"start": "node dist/start.js",
|
|
20
21
|
"typecheck": "tsc --noEmit",
|
|
@@ -24,7 +25,10 @@
|
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@anthropic-ai/sdk": "latest",
|
|
26
27
|
"@google/genai": "latest",
|
|
27
|
-
"@
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
29
|
+
"@slack/web-api": "latest",
|
|
30
|
+
"playwright": "^1.50.0",
|
|
31
|
+
"sharp": "^0.34.0"
|
|
28
32
|
},
|
|
29
33
|
"devDependencies": {
|
|
30
34
|
"@types/node": "^22.19.1",
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
export function communicationTools(router, options) {
|
|
2
|
-
const tools = [];
|
|
3
|
-
if (router.getAdapter('telegram')) {
|
|
4
|
-
tools.push({
|
|
5
|
-
name: 'telegram_send',
|
|
6
|
-
definition: {
|
|
7
|
-
name: 'telegram_send',
|
|
8
|
-
description: 'Send a Telegram message. Use source_event_id to reply to an inbound event, or chat_id to send directly to a chat (DM or group).',
|
|
9
|
-
parameters: {
|
|
10
|
-
type: 'object',
|
|
11
|
-
properties: {
|
|
12
|
-
text: { type: 'string', description: 'Message text to send' },
|
|
13
|
-
source_event_id: {
|
|
14
|
-
type: 'string',
|
|
15
|
-
description: 'Inbound Telegram event id to reply to',
|
|
16
|
-
},
|
|
17
|
-
chat_id: {
|
|
18
|
-
type: 'string',
|
|
19
|
-
description: 'Target Telegram chat id for direct send',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
required: ['text'],
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
async execute(input) {
|
|
26
|
-
const { text, source_event_id, chat_id } = input;
|
|
27
|
-
const hasSourceEvent = typeof source_event_id === 'string' && source_event_id.trim().length > 0;
|
|
28
|
-
const hasChatId = typeof chat_id === 'string' && chat_id.trim().length > 0;
|
|
29
|
-
if (hasSourceEvent === hasChatId) {
|
|
30
|
-
throw new Error('Provide exactly one of source_event_id or chat_id');
|
|
31
|
-
}
|
|
32
|
-
const telegramAdapter = router.getAdapter('telegram');
|
|
33
|
-
if (!telegramAdapter || !telegramAdapter.sendToConversation) {
|
|
34
|
-
throw new Error('Telegram channel is not configured');
|
|
35
|
-
}
|
|
36
|
-
if (hasSourceEvent) {
|
|
37
|
-
const route = router.getByEventId(source_event_id);
|
|
38
|
-
if (!route) {
|
|
39
|
-
throw new Error(`Unknown source_event_id: ${source_event_id}`);
|
|
40
|
-
}
|
|
41
|
-
if (route.message.channel !== 'telegram') {
|
|
42
|
-
throw new Error(`source_event_id is not from Telegram: ${source_event_id}`);
|
|
43
|
-
}
|
|
44
|
-
await route.adapter.sendReply(route.message, text);
|
|
45
|
-
return 'Sent';
|
|
46
|
-
}
|
|
47
|
-
await telegramAdapter.sendToConversation(chat_id, text);
|
|
48
|
-
return 'Sent';
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
if (router.getAdapter('slack')) {
|
|
53
|
-
tools.push({
|
|
54
|
-
name: 'channel_react',
|
|
55
|
-
definition: {
|
|
56
|
-
name: 'channel_react',
|
|
57
|
-
description: 'Add a reaction to a message on a channel (Slack only).',
|
|
58
|
-
parameters: {
|
|
59
|
-
type: 'object',
|
|
60
|
-
properties: {
|
|
61
|
-
source_event_id: {
|
|
62
|
-
type: 'string',
|
|
63
|
-
description: 'Event id of the message to react to',
|
|
64
|
-
},
|
|
65
|
-
emoji: {
|
|
66
|
-
type: 'string',
|
|
67
|
-
description: 'Reaction emoji name (without colons, e.g. "thumbsup")',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
required: ['source_event_id', 'emoji'],
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
async execute(input) {
|
|
74
|
-
const { source_event_id, emoji } = input;
|
|
75
|
-
const route = router.getByEventId(source_event_id);
|
|
76
|
-
if (!route) {
|
|
77
|
-
throw new Error(`Unknown source_event_id: ${source_event_id}`);
|
|
78
|
-
}
|
|
79
|
-
if (!route.adapter.addReaction) {
|
|
80
|
-
throw new Error('Reactions are not supported on this channel');
|
|
81
|
-
}
|
|
82
|
-
await route.adapter.addReaction(route.message, emoji);
|
|
83
|
-
return 'Reacted';
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
const { historyChannels } = options;
|
|
88
|
-
if (historyChannels.length > 0) {
|
|
89
|
-
tools.push({
|
|
90
|
-
name: 'channel_history',
|
|
91
|
-
concurrencySafe: true,
|
|
92
|
-
definition: {
|
|
93
|
-
name: 'channel_history',
|
|
94
|
-
description: 'Read recent message history from a channel conversation. Useful for catching up on context.',
|
|
95
|
-
parameters: {
|
|
96
|
-
type: 'object',
|
|
97
|
-
properties: {
|
|
98
|
-
channel: {
|
|
99
|
-
type: 'string',
|
|
100
|
-
enum: historyChannels,
|
|
101
|
-
description: 'Channel to read from',
|
|
102
|
-
},
|
|
103
|
-
conversation_id: {
|
|
104
|
-
type: 'string',
|
|
105
|
-
description: 'Conversation identifier',
|
|
106
|
-
},
|
|
107
|
-
limit: {
|
|
108
|
-
type: 'number',
|
|
109
|
-
description: 'Max messages to return (default 20)',
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
required: ['channel', 'conversation_id'],
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
async execute(input) {
|
|
116
|
-
const { channel, conversation_id, limit } = input;
|
|
117
|
-
const adapter = router.getAdapter(channel);
|
|
118
|
-
if (!adapter || !adapter.getHistory) {
|
|
119
|
-
throw new Error(`History reading not supported for channel: ${channel}`);
|
|
120
|
-
}
|
|
121
|
-
const messages = await adapter.getHistory(conversation_id, limit ?? 20);
|
|
122
|
-
if (messages.length === 0)
|
|
123
|
-
return 'No recent messages.';
|
|
124
|
-
return messages
|
|
125
|
-
.map((m) => `[${m.ts}] ${m.userId}: ${m.text}`)
|
|
126
|
-
.join('\n');
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
return tools;
|
|
131
|
-
}
|
|
132
|
-
//# sourceMappingURL=communication.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"communication.js","sourceRoot":"","sources":["../../src/tools/communication.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,kBAAkB,CAChC,MAAqB,EACrB,OAA2C;IAE3C,MAAM,KAAK,GAAW,EAAE,CAAC;IAEzB,IAAI,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC;YACT,IAAI,EAAE,eAAe;YACrB,UAAU,EAAE;gBACV,IAAI,EAAE,eAAe;gBACrB,WAAW,EACT,iIAAiI;gBACnI,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;wBAC7D,eAAe,EAAE;4BACf,IAAI,EAAE,QAAQ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