Skip to content

Commit eb4aad1

Browse files
authored
[Feat]: Add subject field to messaging and update ts-sdk version (#12)
* add subject field to messaging and update sdk version * minor updates * minor updates
1 parent 2e236b6 commit eb4aad1

File tree

3 files changed

+63
-33
lines changed

3 files changed

+63
-33
lines changed

typescript/package-lock.json

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trysiren/agent-toolkit",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Agent toolkit for Siren notification platform",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -60,7 +60,7 @@
6060
"license": "MIT",
6161
"dependencies": {
6262
"@modelcontextprotocol/sdk": "^1.13.1",
63-
"@trysiren/node": "^0.1.1",
63+
"@trysiren/node": "^0.1.2",
6464
"zod": "^3.22.4",
6565
"zod-to-json-schema": "^3.22.4"
6666
},
@@ -82,15 +82,15 @@
8282
},
8383
"devDependencies": {
8484
"@types/jest": "^29.5.5",
85-
"@types/node": "^20.5.0",
85+
"@types/node": "^20.19.4",
8686
"@typescript-eslint/eslint-plugin": "^6.4.1",
8787
"@typescript-eslint/parser": "^6.4.1",
8888
"eslint": "^8.47.0",
8989
"jest": "^29.6.2",
9090
"ts-jest": "^29.1.1",
91+
"ts-node": "^10.9.2",
9192
"tsup": "^7.2.0",
92-
"typescript": "^5.1.6",
93-
"ts-node": "^10.9.2"
93+
"typescript": "^5.1.6"
9494
},
9595
"files": [
9696
"dist/**/*",
Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,42 @@
11
import { z } from 'zod';
2-
import { SirenClient, ProviderCode } from '@trysiren/node';
2+
import { SirenClient, ProviderCode, RecipientChannel } from '@trysiren/node';
33
import { Context } from '../configuration';
44
import type { Tool } from '../tools';
55

66
const sendMessageSchema = z.object({
7-
recipient_value: z.string().describe('Identifier for the recipient (e.g., Slack user ID, email address)'),
8-
channel: z.string().describe('The channel to send the message through (e.g., "SLACK", "EMAIL")'),
9-
body: z.string().optional().describe('Message body text (required if no template)'),
10-
template_name: z.string().optional().describe('Template name (required if no body)'),
11-
template_variables: z.record(z.any()).optional().describe('Template variables for template-based messages'),
7+
recipient_value: z
8+
.string()
9+
.describe(
10+
'Identifier for the recipient (e.g., Slack user ID, email address)'
11+
),
12+
channel: z
13+
.nativeEnum(RecipientChannel)
14+
.describe(
15+
'The channel to send the message through (e.g., "SLACK", "EMAIL")'
16+
),
17+
body: z
18+
.string()
19+
.optional()
20+
.describe('Message body text (required if no template)'),
21+
subject: z
22+
.string()
23+
.optional()
24+
.describe(
25+
'Subject line for the message (optional, required for email with body)'
26+
),
27+
template_name: z
28+
.string()
29+
.optional()
30+
.describe('Template name (required if no body)'),
31+
template_variables: z
32+
.record(z.any())
33+
.optional()
34+
.describe('Template variables for template-based messages'),
1235
provider_name: z.string().optional().describe('Provider integration name'),
13-
provider_code: z.nativeEnum(ProviderCode).optional().describe('Provider integration code'),
36+
provider_code: z
37+
.nativeEnum(ProviderCode)
38+
.optional()
39+
.describe('Provider integration code'),
1440
});
1541

1642
export const sendMessage = async (
@@ -19,30 +45,33 @@ export const sendMessage = async (
1945
params: z.infer<typeof sendMessageSchema>
2046
) => {
2147
try {
22-
const notificationId = await sirenClient.message.send(
23-
params.recipient_value,
24-
params.channel,
25-
params.body,
26-
params.template_name,
27-
params.template_variables,
28-
params.provider_name,
29-
params.provider_code
30-
);
31-
48+
const messagePayload = {
49+
recipientValue: params.recipient_value,
50+
channel: params.channel,
51+
body: params.body,
52+
subject: params.subject,
53+
templateName: params.template_name,
54+
templateVariables: params.template_variables,
55+
providerName: params.provider_name,
56+
providerCode: params.provider_code,
57+
};
58+
const notificationId = await sirenClient.message.send(messagePayload);
59+
3260
return { notificationId };
3361
} catch (error) {
3462
console.error('Failed to send message:', error);
3563
return {
3664
error: 'Failed to send message',
37-
details: error instanceof Error ? error.message : String(error)
65+
details: error instanceof Error ? error.message : String(error),
3866
};
3967
}
4068
};
4169

4270
const tool = (context: Context): Tool => ({
4371
method: 'send_message',
4472
name: 'Send Message',
45-
description: 'Send a message either using a template or directly to a recipient via a chosen channel',
73+
description:
74+
'Send a message either using a template or directly to a recipient via a chosen channel',
4675
parameters: sendMessageSchema,
4776
actions: {
4877
messaging: {
@@ -52,4 +81,4 @@ const tool = (context: Context): Tool => ({
5281
execute: sendMessage,
5382
});
5483

55-
export default tool;
84+
export default tool;

0 commit comments

Comments
 (0)