-
Notifications
You must be signed in to change notification settings - Fork 4
Added endpoint for sending SMS (Depends of Catalyst change) #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds Sms.send(req, ctx, to, message, from?) with Twilio auth validation, OpenTelemetry spans, and POSTs to /sms/send; augments Sms.sendReply to use its own tracing span and child context; adds an SmsApi implementing SMSService and exposes Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Agent as Agent Handler
participant IO as src/io/sms.ts
participant API as src/apis/sms.ts
participant Tracer as OpenTelemetry
participant Backend as Agentuity SMS Backend
Client->>Agent: request to send SMS
Agent->>IO: call send(req, ctx, to, message, from)
IO->>IO: validate twilio-auth-token (throw if missing)
IO->>Tracer: start span "agentuity.twilio.send"
IO->>API: delegate POST /sms/send (agentId, from, to, message.text)
API->>Backend: HTTP POST /sms/send (JSON, Content-Type, timeout)
alt 200 OK
Backend-->>API: 200 OK
API->>Tracer: set span OK
API-->>IO: success
else non-200
Backend-->>API: error response
API->>Tracer: recordException, set error status
API-->>IO: throw with response details
end
API->>Tracer: end span
IO->>Tracer: end span
Note right of IO: sendReply creates child span "agentuity.twilio.reply", swaps to/from, sets X-Agentuity-Message-Id header, POSTs to /sms/twilio/reply
Estimated code review effortπ― 3 (Moderate) | β±οΈ ~25 minutes
Poem
Pre-merge checks and finishing touchesβ Passed checks (2 passed)
β¨ Finishing touches
π§ͺ Generate unit tests (beta)
π Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro π Files selected for processing (1)
π§ Files skipped from review as they are similar to previous changes (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
Caution
Some comments are outside the diff and canβt be posted inline due to platform limitations.
β οΈ Outside diff range comments (2)
src/io/sms.ts (1)
167-176: Docs: βemailβ wording in SMS codeUpdate comments to reflect SMS, not email.
-/** - * Parse an email from a buffer and return an Email object. - */ +/** + * Parse an SMS from a buffer and return an Sms object. + */Also update the SmsReply comment at Lines 15β23 similarly.
src/types.ts (1)
575-586: Remove embedded diff markers from interface definition β file will not compileThe file contains literal diff markers embedded as text within the
VectorSearchParamsinterface (lines 576β577), which creates invalid TypeScript syntax. This truncates the first interface and prevents compilation.Fix: Remove lines 576β577 entirely (the diff markers with
-and+prefixes), and apply the generic constraint directly to the original interface declaration at line 543:-export interface VectorSearchParams<T = unknown> { +export interface VectorSearchParams<T extends JsonObject = JsonObject> {The interface should then continue with all its properties (
query,limit,similarity,metadata) without the embedded diff syntax.
π§Ή Nitpick comments (1)
src/io/sms.ts (1)
111-161: Add explicit return type and timeout to sendReply() for consistency with send()The interface already defines
sendReply(): Promise<void>, so adding the explicit return type annotation is good practice. Bothsend()andsendReply()currently passundefinedas the timeout parameter toPOST(). Adding a 15-second timeout tosendReply()improves reliability; consider applying the same timeout tosend()for true parity.Note: The suggestion to return a provider message ID conflicts with the interface definition (
Promise<void>); verify if the interface should be updated instead.- async sendReply(req: AgentRequest, ctx: AgentContext, reply: string) { + async sendReply( + req: AgentRequest, + ctx: AgentContext, + reply: string + ): Promise<void> { + const timeoutMs = 15_000; @@ - const resp = await POST( + const resp = await POST( '/sms/twilio/reply', safeStringify({ to: this.from, from: this.to, reply: reply, agentId: ctx.agent.id, }), { 'Content-Type': 'application/json', 'X-Agentuity-Message-Id': this.messageId, }, - undefined, + timeoutMs, authToken );
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (2)
src/io/sms.ts(2 hunks)src/types.ts(4 hunks)
π§° Additional context used
π Path-based instructions (2)
{src,test}/**/!(*.d).ts
π CodeRabbit inference engine (AGENT.md)
{src,test}/**/!(*.d).ts: Use strict TypeScript and prefer unknown over any
Use ESM import/export syntax; avoid CommonJS require/module.exports
Use relative imports for internal modules
Keep imports organized (sorted, no unused imports)
Use tabs with a visual width of 2 spaces
Limit lines to a maximum of 80 characters
Use single quotes for strings
Use proper Error types; do not throw strings
Prefer template literals over string concatenation
Files:
src/types.tssrc/io/sms.ts
src/io/**
π CodeRabbit inference engine (AGENT.md)
I/O handlers (Discord, Slack, Email, SMS, Telegram) live under src/io/
Files:
src/io/sms.ts
𧬠Code graph analysis (2)
src/types.ts (2)
src/io/sms.ts (2)
to(46-48)from(49-51)src/io/email.ts (1)
to(291-302)
src/io/sms.ts (4)
src/types.ts (2)
AgentRequest(1085-1105)AgentContext(957-1080)src/router/router.ts (2)
getTracer(61-66)recordException(108-128)src/apis/api.ts (1)
POST(253-270)src/server/util.ts (1)
safeStringify(17-28)
π Additional comments (1)
src/types.ts (1)
1071-1075: AgentContext.sms exposureLooks good and aligns with the new service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (2)
src/apis/sms.ts(1 hunks)src/server/server.ts(3 hunks)
π§° Additional context used
π Path-based instructions (5)
src/apis/**
π CodeRabbit inference engine (AGENT.md)
Place core API implementations under src/apis/ (email, discord, keyvalue, vector, objectstore)
Files:
src/apis/sms.ts
{src,test}/**/!(*.d).ts
π CodeRabbit inference engine (AGENT.md)
{src,test}/**/!(*.d).ts: Use strict TypeScript and prefer unknown over any
Use ESM import/export syntax; avoid CommonJS require/module.exports
Use relative imports for internal modules
Keep imports organized (sorted, no unused imports)
Use tabs with a visual width of 2 spaces
Limit lines to a maximum of 80 characters
Use single quotes for strings
Use proper Error types; do not throw strings
Prefer template literals over string concatenation
Files:
src/apis/sms.tssrc/server/server.ts
src/apis/**/*.ts
π CodeRabbit inference engine (.cursor/rules/code-generation.mdc)
src/apis/**/*.ts: Do not hardcode generated prompt content (e.g., copyWriter) in source files; load it dynamically
Avoid overly complex TypeScript generics for generated content; prefer simple, maintainable types
Maintain type safety for dynamically loaded content by generating and referencing TypeScript definitions, with proper annotations for require() results
Do not use relative imports to generated artifacts; resolve via absolute node_modules paths or the package entry
Generated content is loaded at runtime, not build time; avoid static imports of generated modules
Prefer bracket notation for accessing slug-named properties with hyphens (e.g., prompts['slug-name'])
Avoid relative require('./generated/_index.js'); resolve absolute paths from process.cwd() into node_modules for generated assets
Files:
src/apis/sms.ts
src/server/{server,bun,node,agents}.ts
π CodeRabbit inference engine (AGENT.md)
Server components live in src/server/ as server.ts, bun.ts, node.ts, and agents.ts
Files:
src/server/server.ts
src/server/*.ts
π CodeRabbit inference engine (.cursor/rules/code-generation.mdc)
src/server/*.ts: Load generated content during server context creation and provide fallbacks when signatures or content are missing
In compile helpers, prefer using generated signature functions when present and provide a manual compilation fallback when absent
Files:
src/server/server.ts
𧬠Code graph analysis (2)
src/apis/sms.ts (4)
src/types.ts (3)
SMSService(723-744)AgentRequest(1087-1107)AgentContext(959-1082)src/io/sms.ts (2)
SmsReply(18-23)from(49-51)src/router/router.ts (2)
getTracer(61-66)recordException(108-128)src/apis/api.ts (1)
POST(253-270)
src/server/server.ts (1)
src/router/data.ts (1)
sms(255-261)
π Additional comments (1)
src/server/server.ts (1)
186-228: Sms service wiring looks good.The singleton registration mirrors the other API clients and cleanly exposes
ctx.smsto agents.
Summary by CodeRabbit
New Features
Updates