chore: import upstream snapshot with attribution
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { wealthboxReadContactTool } from '@/tools/wealthbox/read_contact'
|
||||
import { wealthboxReadNoteTool } from '@/tools/wealthbox/read_note'
|
||||
import { wealthboxReadTaskTool } from '@/tools/wealthbox/read_task'
|
||||
import { wealthboxWriteContactTool } from '@/tools/wealthbox/write_contact'
|
||||
import { wealthboxWriteNoteTool } from '@/tools/wealthbox/write_note'
|
||||
import { wealthboxWriteTaskTool } from '@/tools/wealthbox/write_task'
|
||||
|
||||
export { wealthboxReadNoteTool }
|
||||
export { wealthboxWriteNoteTool }
|
||||
export { wealthboxReadContactTool }
|
||||
export { wealthboxWriteContactTool }
|
||||
export { wealthboxReadTaskTool }
|
||||
export { wealthboxWriteTaskTool }
|
||||
@@ -0,0 +1,110 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type { WealthboxReadParams, WealthboxReadResponse } from '@/tools/wealthbox/types'
|
||||
|
||||
export const wealthboxReadContactTool: ToolConfig<WealthboxReadParams, WealthboxReadResponse> = {
|
||||
id: 'wealthbox_read_contact',
|
||||
name: 'Read Wealthbox Contact',
|
||||
description: 'Read content from a Wealthbox contact',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'The access token for the Wealthbox API',
|
||||
},
|
||||
contactId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'The ID of the contact to read (e.g., "12345")',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const contactId = params.contactId?.trim()
|
||||
let url = 'https://api.crmworkspace.com/v1/contacts'
|
||||
if (contactId) {
|
||||
url = `https://api.crmworkspace.com/v1/contacts/${contactId}`
|
||||
}
|
||||
return url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
// Validate access token
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
// Format contact information into readable content
|
||||
const contact = data
|
||||
let content = `Contact: ${contact.first_name || ''} ${contact.last_name || ''}`.trim()
|
||||
|
||||
if (contact.company_name) {
|
||||
content += `\nCompany: ${contact.company_name}`
|
||||
}
|
||||
|
||||
if (contact.background_information) {
|
||||
content += `\nBackground: ${contact.background_information}`
|
||||
}
|
||||
|
||||
if (contact.email_addresses && contact.email_addresses.length > 0) {
|
||||
content += '\nEmail Addresses:'
|
||||
contact.email_addresses.forEach((email: any) => {
|
||||
content += `\n - ${email.address}${email.principal ? ' (Primary)' : ''} (${email.kind})`
|
||||
})
|
||||
}
|
||||
|
||||
if (contact.phone_numbers && contact.phone_numbers.length > 0) {
|
||||
content += '\nPhone Numbers:'
|
||||
contact.phone_numbers.forEach((phone: any) => {
|
||||
content += `\n - ${phone.address}${phone.extension ? ` ext. ${phone.extension}` : ''}${phone.principal ? ' (Primary)' : ''} (${phone.kind})`
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content,
|
||||
contact,
|
||||
metadata: {
|
||||
itemId: contact.id?.toString() ?? null,
|
||||
contactId: contact.id?.toString() ?? null,
|
||||
itemType: 'contact' as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Contact data and metadata',
|
||||
properties: {
|
||||
content: { type: 'string', description: 'Formatted contact information' },
|
||||
contact: { type: 'object', description: 'Raw contact data from Wealthbox' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Operation metadata',
|
||||
properties: {
|
||||
itemId: { type: 'string', description: 'ID of the contact', optional: true },
|
||||
contactId: { type: 'string', description: 'ID of the contact', optional: true },
|
||||
itemType: { type: 'string', description: 'Type of item (contact)' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type { WealthboxReadParams, WealthboxReadResponse } from '@/tools/wealthbox/types'
|
||||
|
||||
export const wealthboxReadNoteTool: ToolConfig<WealthboxReadParams, WealthboxReadResponse> = {
|
||||
id: 'wealthbox_read_note',
|
||||
name: 'Read Wealthbox Note',
|
||||
description: 'Read content from a Wealthbox note',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The access token for the Wealthbox API',
|
||||
visibility: 'hidden',
|
||||
},
|
||||
noteId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'The ID of the note to read (e.g., "11111")',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const noteId = params.noteId?.trim()
|
||||
let url = 'https://api.crmworkspace.com/v1/notes'
|
||||
if (noteId) {
|
||||
url = `https://api.crmworkspace.com/v1/notes/${noteId}`
|
||||
}
|
||||
return url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
// Validate access token
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
// Format note information into readable content
|
||||
const note = data
|
||||
let content = `Note Content: ${note.content || 'No content available'}`
|
||||
|
||||
if (note.created_at) {
|
||||
content += `\nCreated: ${new Date(note.created_at).toLocaleString()}`
|
||||
}
|
||||
|
||||
if (note.updated_at) {
|
||||
content += `\nUpdated: ${new Date(note.updated_at).toLocaleString()}`
|
||||
}
|
||||
|
||||
if (note.visible_to) {
|
||||
content += `\nVisible to: ${note.visible_to}`
|
||||
}
|
||||
|
||||
if (note.linked_to && note.linked_to.length > 0) {
|
||||
content += '\nLinked to:'
|
||||
note.linked_to.forEach((link: any) => {
|
||||
content += `\n - ${link.name} (${link.type})`
|
||||
})
|
||||
}
|
||||
|
||||
if (note.tags && note.tags.length > 0) {
|
||||
content += '\nTags:'
|
||||
note.tags.forEach((tag: any) => {
|
||||
content += `\n - ${tag.name}`
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content,
|
||||
note,
|
||||
metadata: {
|
||||
itemId: note.id?.toString() ?? null,
|
||||
noteId: note.id?.toString() ?? null,
|
||||
itemType: 'note' as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Note data and metadata',
|
||||
properties: {
|
||||
content: { type: 'string', description: 'Formatted note information' },
|
||||
note: { type: 'object', description: 'Raw note data from Wealthbox' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Operation metadata',
|
||||
properties: {
|
||||
itemId: { type: 'string', description: 'ID of the note', optional: true },
|
||||
noteId: { type: 'string', description: 'ID of the note', optional: true },
|
||||
itemType: { type: 'string', description: 'Type of item (note)' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type { WealthboxReadParams, WealthboxReadResponse } from '@/tools/wealthbox/types'
|
||||
|
||||
export const wealthboxReadTaskTool: ToolConfig<WealthboxReadParams, WealthboxReadResponse> = {
|
||||
id: 'wealthbox_read_task',
|
||||
name: 'Read Wealthbox Task',
|
||||
description: 'Read content from a Wealthbox task',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The access token for the Wealthbox API',
|
||||
visibility: 'hidden',
|
||||
},
|
||||
taskId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'The ID of the task to read (e.g., "67890")',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const taskId = params.taskId?.trim()
|
||||
let url = 'https://api.crmworkspace.com/v1/tasks'
|
||||
if (taskId) {
|
||||
url = `https://api.crmworkspace.com/v1/tasks/${taskId}`
|
||||
}
|
||||
return url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => {
|
||||
// Validate access token
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
// Format task information into readable content
|
||||
const task = data
|
||||
let content = `Task: ${task.name || 'Unnamed task'}`
|
||||
|
||||
if (task.due_date) {
|
||||
content += `\nDue Date: ${new Date(task.due_date).toLocaleDateString()}`
|
||||
}
|
||||
|
||||
if (task.complete !== undefined) {
|
||||
content += `\nStatus: ${task.complete ? 'Complete' : 'Incomplete'}`
|
||||
}
|
||||
|
||||
if (task.priority) {
|
||||
content += `\nPriority: ${task.priority}`
|
||||
}
|
||||
|
||||
if (task.category) {
|
||||
content += `\nCategory: ${task.category}`
|
||||
}
|
||||
|
||||
if (task.visible_to) {
|
||||
content += `\nVisible to: ${task.visible_to}`
|
||||
}
|
||||
|
||||
if (task.linked_to && task.linked_to.length > 0) {
|
||||
content += '\nLinked to:'
|
||||
task.linked_to.forEach((link: any) => {
|
||||
content += `\n - ${link.name} (${link.type})`
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content,
|
||||
task,
|
||||
metadata: {
|
||||
itemId: task.id?.toString() ?? null,
|
||||
taskId: task.id?.toString() ?? null,
|
||||
itemType: 'task' as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Task data and metadata',
|
||||
properties: {
|
||||
content: { type: 'string', description: 'Formatted task information' },
|
||||
task: { type: 'object', description: 'Raw task data from Wealthbox' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Operation metadata',
|
||||
properties: {
|
||||
itemId: { type: 'string', description: 'ID of the task', optional: true },
|
||||
taskId: { type: 'string', description: 'ID of the task', optional: true },
|
||||
itemType: { type: 'string', description: 'Type of item (task)' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
import type { ToolResponse } from '@/tools/types'
|
||||
|
||||
interface WealthboxNote {
|
||||
id: number
|
||||
creator: number
|
||||
created_at: string
|
||||
updated_at: string
|
||||
content: string
|
||||
linked_to: Array<{
|
||||
id: number
|
||||
type: string
|
||||
name: string
|
||||
}>
|
||||
visible_to: string
|
||||
tags: Array<{
|
||||
id: number
|
||||
name: string
|
||||
}>
|
||||
}
|
||||
|
||||
interface WealthboxContact {
|
||||
id: number
|
||||
first_name: string
|
||||
last_name: string
|
||||
company_name?: string
|
||||
background_information?: string
|
||||
email_addresses?: Array<{
|
||||
address: string
|
||||
principal: boolean
|
||||
kind: string
|
||||
}>
|
||||
phone_numbers?: Array<{
|
||||
address: string
|
||||
principal: boolean
|
||||
extension?: string
|
||||
kind: string
|
||||
}>
|
||||
}
|
||||
|
||||
interface WealthboxTask {
|
||||
id: number
|
||||
name: string
|
||||
due_date: string
|
||||
description?: string
|
||||
complete?: boolean
|
||||
category?: number
|
||||
priority?: 'Low' | 'Medium' | 'High'
|
||||
linked_to?: Array<{
|
||||
id: number
|
||||
type: string
|
||||
name: string
|
||||
}>
|
||||
visible_to?: string
|
||||
}
|
||||
|
||||
// Unified metadata structure
|
||||
interface WealthboxMetadata {
|
||||
itemId?: string
|
||||
noteId?: string
|
||||
contactId?: string
|
||||
taskId?: string
|
||||
itemType: 'note' | 'contact' | 'task'
|
||||
totalItems?: number
|
||||
}
|
||||
|
||||
// Unified output structure for all operations
|
||||
interface WealthboxUniformOutput {
|
||||
// Single items (for write operations and single reads)
|
||||
note?: WealthboxNote
|
||||
contact?: WealthboxContact
|
||||
task?: WealthboxTask
|
||||
|
||||
// Arrays (for bulk read operations)
|
||||
notes?: WealthboxNote[]
|
||||
contacts?: WealthboxContact[]
|
||||
tasks?: WealthboxTask[]
|
||||
|
||||
// Operation result indicators
|
||||
success?: boolean
|
||||
metadata: WealthboxMetadata
|
||||
}
|
||||
|
||||
// Both response types use identical structure
|
||||
export interface WealthboxReadResponse extends ToolResponse {
|
||||
output: WealthboxUniformOutput
|
||||
}
|
||||
|
||||
export interface WealthboxWriteResponse extends ToolResponse {
|
||||
output: WealthboxUniformOutput
|
||||
}
|
||||
|
||||
// Unified parameter types
|
||||
export interface WealthboxReadParams {
|
||||
accessToken: string
|
||||
operation: 'read_note' | 'read_contact' | 'read_task'
|
||||
noteId?: string
|
||||
contactId?: string
|
||||
taskId?: string
|
||||
}
|
||||
|
||||
export interface WealthboxWriteParams {
|
||||
accessToken: string
|
||||
operation: 'write_note' | 'write_contact' | 'write_task'
|
||||
|
||||
// IDs (optional for creating new items)
|
||||
noteId?: string
|
||||
contactId?: string
|
||||
taskId?: string
|
||||
|
||||
// Note fields
|
||||
content?: string
|
||||
linkedTo?: Array<{
|
||||
id: number
|
||||
type: string
|
||||
name: string
|
||||
}>
|
||||
visibleTo?: string
|
||||
tags?: Array<{
|
||||
id: number
|
||||
name: string
|
||||
}>
|
||||
|
||||
// Contact fields
|
||||
firstName?: string
|
||||
lastName?: string
|
||||
backgroundInformation?: string
|
||||
emailAddress?: string
|
||||
|
||||
// Task fields
|
||||
title?: string
|
||||
description?: string
|
||||
dueDate?: string
|
||||
complete?: boolean
|
||||
category?: number
|
||||
priority?: 'Low' | 'Medium' | 'High'
|
||||
}
|
||||
|
||||
export interface WealthboxTaskRequestBody {
|
||||
name: string
|
||||
due_date: string
|
||||
description?: string // Add this field
|
||||
complete?: boolean
|
||||
category?: number
|
||||
linked_to?: Array<{
|
||||
id: number
|
||||
type: string
|
||||
}>
|
||||
}
|
||||
|
||||
export type WealthboxResponse = WealthboxReadResponse | WealthboxWriteResponse
|
||||
@@ -0,0 +1,202 @@
|
||||
import type {
|
||||
WealthboxTaskRequestBody,
|
||||
WealthboxWriteParams,
|
||||
WealthboxWriteResponse,
|
||||
} from '@/tools/wealthbox/types'
|
||||
|
||||
// Utility function to safely convert to string and trim
|
||||
const safeStringify = (value: any): string => {
|
||||
if (value === null || value === undefined) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
return value
|
||||
}
|
||||
|
||||
return JSON.stringify(value)
|
||||
}
|
||||
|
||||
// Utility function to validate parameters and build contact body
|
||||
export const validateAndBuildContactBody = (params: WealthboxWriteParams): Record<string, any> => {
|
||||
// Validate required fields with safe stringification
|
||||
const firstName = safeStringify(params.firstName).trim()
|
||||
const lastName = safeStringify(params.lastName).trim()
|
||||
|
||||
if (!firstName) {
|
||||
throw new Error('First name is required')
|
||||
}
|
||||
if (!lastName) {
|
||||
throw new Error('Last name is required')
|
||||
}
|
||||
|
||||
const body: Record<string, any> = {
|
||||
first_name: firstName,
|
||||
last_name: lastName,
|
||||
}
|
||||
|
||||
// Add optional fields with safe stringification
|
||||
const emailAddress = safeStringify(params.emailAddress).trim()
|
||||
if (emailAddress) {
|
||||
body.email_addresses = [
|
||||
{
|
||||
address: emailAddress,
|
||||
kind: 'email',
|
||||
principal: true,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
const backgroundInformation = safeStringify(params.backgroundInformation).trim()
|
||||
if (backgroundInformation) {
|
||||
body.background_information = backgroundInformation
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
export // Utility function to validate parameters and build note body
|
||||
const validateAndBuildNoteBody = (params: WealthboxWriteParams): Record<string, any> => {
|
||||
// Handle content conversion - stringify if not already a string
|
||||
let content: string
|
||||
|
||||
if (params.content === null || params.content === undefined) {
|
||||
throw new Error('Note content is required')
|
||||
}
|
||||
|
||||
if (typeof params.content === 'string') {
|
||||
content = params.content
|
||||
} else {
|
||||
content = JSON.stringify(params.content)
|
||||
}
|
||||
|
||||
content = content.trim()
|
||||
|
||||
if (!content) {
|
||||
throw new Error('Note content is required')
|
||||
}
|
||||
|
||||
const body: Record<string, any> = {
|
||||
content: content,
|
||||
}
|
||||
|
||||
// Handle contact linking
|
||||
if (params.contactId?.trim()) {
|
||||
body.linked_to = [
|
||||
{
|
||||
id: Number.parseInt(params.contactId.trim()),
|
||||
type: 'Contact',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
// Utility function to handle API errors
|
||||
export const handleApiError = (response: Response, errorText: string): never => {
|
||||
throw new Error(
|
||||
`Failed to create Wealthbox note: ${response.status} ${response.statusText} - ${errorText}`
|
||||
)
|
||||
}
|
||||
|
||||
// Utility function to format note response
|
||||
export const formatNoteResponse = (data: any): WealthboxWriteResponse => {
|
||||
if (!data) {
|
||||
return {
|
||||
success: false,
|
||||
output: {
|
||||
note: undefined,
|
||||
metadata: {
|
||||
itemType: 'note' as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
note: data,
|
||||
success: true,
|
||||
metadata: {
|
||||
itemId: data.id?.toString() ?? null,
|
||||
noteId: data.id?.toString() ?? null,
|
||||
itemType: 'note' as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const formatTaskResponse = (data: any): WealthboxWriteResponse => {
|
||||
if (!data) {
|
||||
return {
|
||||
success: false,
|
||||
output: {
|
||||
task: undefined,
|
||||
metadata: {
|
||||
itemType: 'task' as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
task: data,
|
||||
success: true,
|
||||
metadata: {
|
||||
itemId: data.id?.toString() ?? null,
|
||||
taskId: data.id?.toString() ?? null,
|
||||
itemType: 'task' as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export // Utility function to validate parameters and build task body
|
||||
const validateAndBuildTaskBody = (params: WealthboxWriteParams): WealthboxTaskRequestBody => {
|
||||
// Validate required fields with safe stringification
|
||||
const title = safeStringify(params.title).trim()
|
||||
const dueDate = safeStringify(params.dueDate).trim()
|
||||
|
||||
if (!title) {
|
||||
throw new Error('Task title is required')
|
||||
}
|
||||
if (!dueDate) {
|
||||
throw new Error('Due date is required')
|
||||
}
|
||||
|
||||
const body: WealthboxTaskRequestBody = {
|
||||
name: title,
|
||||
due_date: dueDate,
|
||||
}
|
||||
|
||||
// Add optional fields with safe stringification
|
||||
const description = safeStringify(params.description).trim()
|
||||
if (description) {
|
||||
body.description = description
|
||||
}
|
||||
|
||||
if (params.complete !== undefined) {
|
||||
body.complete = params.complete
|
||||
}
|
||||
|
||||
if (params.category !== undefined) {
|
||||
body.category = params.category
|
||||
}
|
||||
|
||||
// Handle contact linking with safe stringification
|
||||
const contactId = safeStringify(params.contactId).trim()
|
||||
if (contactId) {
|
||||
body.linked_to = [
|
||||
{
|
||||
id: Number.parseInt(contactId),
|
||||
type: 'Contact',
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type { WealthboxWriteParams, WealthboxWriteResponse } from '@/tools/wealthbox/types'
|
||||
import { validateAndBuildContactBody } from '@/tools/wealthbox/utils'
|
||||
|
||||
export const wealthboxWriteContactTool: ToolConfig<WealthboxWriteParams, WealthboxWriteResponse> = {
|
||||
id: 'wealthbox_write_contact',
|
||||
name: 'Write Wealthbox Contact',
|
||||
description: 'Create a new Wealthbox contact',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The access token for the Wealthbox API',
|
||||
visibility: 'hidden',
|
||||
},
|
||||
firstName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The first name of the contact',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
lastName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The last name of the contact',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
emailAddress: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'The email address of the contact',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
backgroundInformation: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Background information about the contact',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://api.crmworkspace.com/v1/contacts',
|
||||
method: 'POST',
|
||||
headers: (params) => {
|
||||
// Validate access token
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
return validateAndBuildContactBody(params)
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
// Format contact information into readable content
|
||||
const contact = data
|
||||
let content = `Contact created: ${contact.first_name || ''} ${contact.last_name || ''}`.trim()
|
||||
|
||||
if (contact.background_information) {
|
||||
content += `\nBackground: ${contact.background_information}`
|
||||
}
|
||||
|
||||
if (contact.email_addresses && contact.email_addresses.length > 0) {
|
||||
content += '\nEmail Addresses:'
|
||||
contact.email_addresses.forEach((email: any) => {
|
||||
content += `\n - ${email.address}${email.principal ? ' (Primary)' : ''} (${email.kind})`
|
||||
})
|
||||
}
|
||||
|
||||
if (contact.phone_numbers && contact.phone_numbers.length > 0) {
|
||||
content += '\nPhone Numbers:'
|
||||
contact.phone_numbers.forEach((phone: any) => {
|
||||
content += `\n - ${phone.address}${phone.extension ? ` ext. ${phone.extension}` : ''}${phone.principal ? ' (Primary)' : ''} (${phone.kind})`
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content,
|
||||
contact,
|
||||
success: true,
|
||||
metadata: {
|
||||
itemId: contact.id?.toString() ?? null,
|
||||
contactId: contact.id?.toString() ?? null,
|
||||
itemType: 'contact' as const,
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created or updated contact data and metadata',
|
||||
properties: {
|
||||
contact: { type: 'object', description: 'Raw contact data from Wealthbox' },
|
||||
success: { type: 'boolean', description: 'Operation success indicator' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Operation metadata',
|
||||
properties: {
|
||||
itemId: {
|
||||
type: 'string',
|
||||
description: 'ID of the created/updated contact',
|
||||
optional: true,
|
||||
},
|
||||
contactId: {
|
||||
type: 'string',
|
||||
description: 'ID of the created/updated contact',
|
||||
optional: true,
|
||||
},
|
||||
itemType: { type: 'string', description: 'Type of item (contact)' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type { WealthboxWriteParams, WealthboxWriteResponse } from '@/tools/wealthbox/types'
|
||||
import { formatNoteResponse, validateAndBuildNoteBody } from '@/tools/wealthbox/utils'
|
||||
|
||||
export const wealthboxWriteNoteTool: ToolConfig<WealthboxWriteParams, WealthboxWriteResponse> = {
|
||||
id: 'wealthbox_write_note',
|
||||
name: 'Write Wealthbox Note',
|
||||
description: 'Create or update a Wealthbox note',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The access token for the Wealthbox API',
|
||||
visibility: 'hidden',
|
||||
},
|
||||
content: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The main body of the note',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
contactId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'ID of contact to link to this note (e.g., "12345")',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: 'https://api.crmworkspace.com/v1/notes',
|
||||
method: 'POST',
|
||||
headers: (params) => {
|
||||
// Validate access token
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
return validateAndBuildNoteBody(params)
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
return formatNoteResponse(data)
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created or updated note data and metadata',
|
||||
properties: {
|
||||
note: { type: 'object', description: 'Raw note data from Wealthbox' },
|
||||
success: { type: 'boolean', description: 'Operation success indicator' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Operation metadata',
|
||||
properties: {
|
||||
itemId: {
|
||||
type: 'string',
|
||||
description: 'ID of the created/updated note',
|
||||
optional: true,
|
||||
},
|
||||
noteId: {
|
||||
type: 'string',
|
||||
description: 'ID of the created/updated note',
|
||||
optional: true,
|
||||
},
|
||||
itemType: { type: 'string', description: 'Type of item (note)' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import type { WealthboxWriteParams, WealthboxWriteResponse } from '@/tools/wealthbox/types'
|
||||
import { formatTaskResponse, validateAndBuildTaskBody } from '@/tools/wealthbox/utils'
|
||||
|
||||
export const wealthboxWriteTaskTool: ToolConfig<WealthboxWriteParams, WealthboxWriteResponse> = {
|
||||
id: 'wealthbox_write_task',
|
||||
name: 'Write Wealthbox Task',
|
||||
description: 'Create or update a Wealthbox task',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The access token for the Wealthbox API',
|
||||
visibility: 'hidden',
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'The name/title of the task',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
dueDate: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
description:
|
||||
'The due date and time of the task (format: "YYYY-MM-DD HH:MM AM/PM -HHMM", e.g., "2015-05-24 11:00 AM -0400")',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
contactId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'ID of contact to link to this task (e.g., "12345")',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
description: 'Description or notes about the task',
|
||||
visibility: 'user-or-llm',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const taskId = params.taskId?.trim()
|
||||
if (taskId) {
|
||||
return `https://api.crmworkspace.com/v1/tasks/${taskId}`
|
||||
}
|
||||
return 'https://api.crmworkspace.com/v1/tasks'
|
||||
},
|
||||
method: 'POST',
|
||||
headers: (params) => {
|
||||
if (!params.accessToken) {
|
||||
throw new Error('Access token is required')
|
||||
}
|
||||
|
||||
return {
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
},
|
||||
body: (params) => {
|
||||
return validateAndBuildTaskBody(params)
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
return formatTaskResponse(data)
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created or updated task data and metadata',
|
||||
properties: {
|
||||
task: { type: 'object', description: 'Raw task data from Wealthbox' },
|
||||
success: { type: 'boolean', description: 'Operation success indicator' },
|
||||
metadata: {
|
||||
type: 'object',
|
||||
description: 'Operation metadata',
|
||||
properties: {
|
||||
itemId: {
|
||||
type: 'string',
|
||||
description: 'ID of the created/updated task',
|
||||
optional: true,
|
||||
},
|
||||
taskId: {
|
||||
type: 'string',
|
||||
description: 'ID of the created/updated task',
|
||||
optional: true,
|
||||
},
|
||||
itemType: { type: 'string', description: 'Type of item (task)' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user