@mastra/ring-signals 0.0.0 → 0.1.0-alpha.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/LICENSE.md +32 -0
- package/README.md +38 -3
- package/dist/crypto.d.ts +35 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/index.cjs +958 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +952 -0
- package/dist/index.js.map +1 -0
- package/dist/ring-api.d.ts +45 -0
- package/dist/ring-api.d.ts.map +1 -0
- package/dist/ring-signals.d.ts +106 -0
- package/dist/ring-signals.d.ts.map +1 -0
- package/dist/types.d.ts +166 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +59 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/crypto.ts","../src/ring-api.ts","../src/ring-signals.ts"],"sourcesContent":["import { createCipheriv, createDecipheriv, createHmac, hkdfSync, timingSafeEqual } from 'node:crypto';\n\nconst ALGO_PREFIX = 'aes-256-gcm-hkdf';\nconst HKDF_INFO = 'mastra-ring-encryption';\n\n/**\n * Encrypt a string with AES-256-GCM using an HKDF-SHA256 derived key.\n * Format: `aes-256-gcm-hkdf:base64(salt):base64(iv):base64(authTag):base64(ciphertext)`\n */\nexport function encrypt(plaintext: string, key: string): string {\n const salt = Buffer.from(globalThis.crypto.getRandomValues(new Uint8Array(16)));\n const derived = Buffer.from(hkdfSync('sha256', key, salt, HKDF_INFO, 32));\n const iv = Buffer.from(globalThis.crypto.getRandomValues(new Uint8Array(12)));\n const cipher = createCipheriv('aes-256-gcm', derived, iv);\n const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);\n const authTag = cipher.getAuthTag();\n return `${ALGO_PREFIX}:${salt.toString('base64')}:${iv.toString('base64')}:${authTag.toString('base64')}:${encrypted.toString('base64')}`;\n}\n\n/**\n * Decrypt a value produced by `encrypt()`.\n */\nexport function decrypt(ciphertext: string, key: string): string {\n const [prefix, saltB64, ivB64, authTagB64, encryptedB64] = ciphertext.split(':');\n if (prefix !== ALGO_PREFIX || !saltB64 || !ivB64 || !authTagB64 || encryptedB64 === undefined) {\n throw new Error('[Ring] Invalid encrypted value');\n }\n const salt = Buffer.from(saltB64, 'base64');\n const derived = Buffer.from(hkdfSync('sha256', key, salt, HKDF_INFO, 32));\n const decipher = createDecipheriv('aes-256-gcm', derived, Buffer.from(ivB64, 'base64'));\n decipher.setAuthTag(Buffer.from(authTagB64, 'base64'));\n return Buffer.concat([decipher.update(Buffer.from(encryptedB64, 'base64')), decipher.final()]).toString('utf8');\n}\n\n/**\n * Constant-time string comparison.\n */\nexport function safeEqual(a: string, b: string): boolean {\n const left = Buffer.from(a);\n const right = Buffer.from(b);\n return left.length === right.length && timingSafeEqual(left, right);\n}\n\n/**\n * Ring account-linking nonce: `HMAC-SHA256(key, \"<time>:<accountId>\")`, URL-safe base64 without padding.\n */\nexport function computeLinkNonce(hmacKey: string, time: string, accountId: string): string {\n return createHmac('sha256', hmacKey).update(`${time}:${accountId}`).digest('base64url');\n}\n\n/**\n * Ring webhook signature: `sha256=` + hex HMAC-SHA256 of the raw request body.\n */\nexport function computeWebhookSignature(hmacKey: string, rawBody: string): string {\n return `sha256=${createHmac('sha256', hmacKey).update(rawBody).digest('hex')}`;\n}\n\n/**\n * Whether a value was produced by `encrypt()`.\n */\nexport function isEncrypted(value: string): boolean {\n return value.startsWith(`${ALGO_PREFIX}:`);\n}\n\n/**\n * Derive the key that signs media URLs from the Ring HMAC key, so the key Ring uses\n * to sign webhooks isn't also used to sign URLs that end up in thread history.\n */\nexport function deriveMediaKey(hmacKey: string): string {\n return Buffer.from(hkdfSync('sha256', hmacKey, '', 'mastra-ring-media', 32)).toString('hex');\n}\n\n/**\n * Sign a media URL path and its expiry so the media route can't be used as an open proxy to Ring.\n */\nexport function signMediaPath(mediaKey: string, path: string, expires: number): string {\n return createHmac('sha256', mediaKey).update(`media:${path}:${expires}`).digest('base64url');\n}\n","import type { RingTokens } from './types';\n\nconst API_BASE_URL = 'https://api.amazonvision.com';\nconst OAUTH_TOKEN_URL = 'https://oauth.ring.com/oauth/token';\nconst REQUEST_TIMEOUT_MS = 30_000;\n// Long enough to download a 15-minute clip.\nconst MEDIA_TIMEOUT_MS = 5 * 60_000;\n\ntype TokenResponse = {\n access_token: string;\n refresh_token: string;\n expires_in: number;\n};\n\nexport type RingApiClientOptions = {\n clientId: string;\n clientSecret: string;\n userAgent: string;\n};\n\n/** Credentials for one linked Ring account. */\nexport type RingAuth = {\n accessToken: string;\n hardwareId: string;\n};\n\nexport class RingApiError extends Error {\n constructor(\n message: string,\n readonly status: number,\n readonly body: string,\n ) {\n super(message);\n this.name = 'RingApiError';\n }\n}\n\n/**\n * Thin client for the Ring Partner API.\n * See https://developer.amazon.com/docs/ring/api-documentation.html\n */\nexport class RingApiClient {\n readonly #options: RingApiClientOptions;\n\n constructor(options: RingApiClientOptions) {\n this.#options = options;\n }\n\n /** Exchange the authorization code Ring posts to the Token Exchange URL. */\n exchangeCode(code: string): Promise<RingTokens> {\n return this.#requestTokens({ grant_type: 'authorization_code', code });\n }\n\n /** Refresh an access token. Ring rotates the refresh token on every refresh. */\n refresh(refreshToken: string): Promise<RingTokens> {\n return this.#requestTokens({ grant_type: 'refresh_token', refresh_token: refreshToken });\n }\n\n /** Get the Ring account ID for an access token. */\n async getAccountId(auth: RingAuth): Promise<string> {\n const body = (await this.#json('GET', '/v1/users/me', auth)) as { data: { id: string } };\n return body.data.id;\n }\n\n /** List the IDs of the devices the account has shared with the app. */\n async listDeviceIds(auth: RingAuth): Promise<string[]> {\n const body = (await this.#json('GET', '/v1/devices', auth)) as { data?: { id: string }[] };\n return (body.data ?? []).map(device => device.id);\n }\n\n /** Verify the link nonce and mark the integration `completed`. */\n async confirmLink(auth: RingAuth, nonce: string, accountIdentifier: string): Promise<void> {\n await this.#json('POST', '/v1/accounts/me/app-integrations', auth, {\n nonce,\n account_identifier: accountIdentifier,\n });\n await this.#json('PATCH', '/v1/accounts/me/app-integrations', auth, { status: 'completed' });\n }\n\n /**\n * Download the latest image in a time range.\n * Returns `undefined` when Ring has no image in the range or the range isn't authorized.\n */\n async downloadLatestImage(\n auth: RingAuth,\n deviceId: string,\n startTimestamp: number,\n endTimestamp: number,\n ): Promise<Buffer | undefined> {\n const response = await this.#media(auth, deviceId, 'image', {\n type: 'latest_in_range',\n start_timestamp: startTimestamp,\n end_timestamp: endTimestamp,\n image_options: { format: 'jpeg' },\n });\n if (!response.ok) return undefined;\n return Buffer.from(await response.arrayBuffer());\n }\n\n /**\n * Download a recorded clip. Returns the response so callers can retry `416` and `425`\n * while Ring finishes processing the recording.\n */\n downloadClip(\n auth: RingAuth,\n deviceId: string,\n timestamp: number,\n durationMs: number,\n audio: boolean,\n ): Promise<Response> {\n return this.#media(auth, deviceId, 'video', {\n timestamp,\n duration: durationMs,\n audio_options: { audio_enabled: audio },\n });\n }\n\n #headers(auth: RingAuth): Record<string, string> {\n return {\n Authorization: `Bearer ${auth.accessToken}`,\n 'Content-Type': 'application/json',\n 'User-Agent': this.#options.userAgent,\n Hardware_Id: auth.hardwareId,\n };\n }\n\n #media(auth: RingAuth, deviceId: string, kind: 'image' | 'video', body: object): Promise<Response> {\n return fetch(`${API_BASE_URL}/v1/devices/${encodeURIComponent(deviceId)}/media/${kind}/download`, {\n method: 'POST',\n headers: this.#headers(auth),\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(MEDIA_TIMEOUT_MS),\n });\n }\n\n async #json(method: string, path: string, auth: RingAuth, body?: object): Promise<unknown> {\n const response = await fetch(`${API_BASE_URL}${path}`, {\n method,\n headers: this.#headers(auth),\n ...(body ? { body: JSON.stringify(body) } : {}),\n signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),\n });\n const text = await response.text();\n if (!response.ok) {\n throw new RingApiError(`[Ring] ${method} ${path} failed with ${response.status}`, response.status, text);\n }\n return text ? JSON.parse(text) : undefined;\n }\n\n async #requestTokens(params: Record<string, string>): Promise<RingTokens> {\n const response = await fetch(OAUTH_TOKEN_URL, {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: new URLSearchParams({\n ...params,\n client_id: this.#options.clientId,\n client_secret: this.#options.clientSecret,\n }),\n signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),\n });\n const text = await response.text();\n if (!response.ok) {\n throw new RingApiError(\n `[Ring] ${params.grant_type} token request failed with ${response.status}`,\n response.status,\n text,\n );\n }\n const tokens = JSON.parse(text) as TokenResponse;\n return {\n accessToken: tokens.access_token,\n refreshToken: tokens.refresh_token,\n expiresAt: Date.now() + tokens.expires_in * 1000,\n };\n }\n}\n","import type { NotificationSignalAttributes } from '@mastra/core/notifications';\nimport type { InputProcessorOrWorkflow, ProcessInputStepArgs } from '@mastra/core/processors';\nimport { registerApiRoute } from '@mastra/core/server';\nimport type { ApiRoute } from '@mastra/core/server';\nimport { SignalProvider } from '@mastra/core/signals';\nimport type { SignalProviderTarget, SignalProviderWebhookRequest, SignalSubscription } from '@mastra/core/signals';\nimport type { ChannelInstallation, ChannelsStorage } from '@mastra/core/storage';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\nimport {\n computeLinkNonce,\n computeWebhookSignature,\n decrypt,\n deriveMediaKey,\n encrypt,\n isEncrypted,\n safeEqual,\n signMediaPath,\n} from './crypto';\nimport { RingApiClient, RingApiError } from './ring-api';\nimport type { RingAuth } from './ring-api';\nimport type {\n RingAccount,\n RingEventNotification,\n RingEventType,\n RingSignalsOptions,\n RingTokens,\n RingWebhookEvent,\n} from './types';\n\nconst PLATFORM = 'ring';\n\n/**\n * Guidance added to the agent's system prompt for Ring notifications, covering only the enabled tools.\n * It depends only on config, so it's the same on every request and doesn't invalidate the prompt cache.\n */\nexport const buildRingInstructions = (tools: { snapshot: boolean; clip: boolean }): string => {\n const steps = [\n ...(tools.snapshot\n ? ['Call ring_snapshot with its deviceId and timestamp, then describe who or what is at the door.']\n : []),\n ...(tools.clip ? ['Call ring_clip with the same deviceId and timestamp.'] : []),\n ];\n const lines = ['Ring events arrive as <notification source=\"ring\"> messages with deviceId and timestamp attributes.'];\n if (steps.length > 0) {\n lines.push(\n 'When a notification has type=\"button_press\":',\n ...steps.map((step, index) => `${index + 1}. ${step}`),\n \"Don't include snapshot or clip urls in your reply unless a tool result asks you to share one.\",\n );\n }\n return lines.join('\\n');\n};\n\n/**\n * Default guidance when both tools are enabled.\n */\nexport const DEFAULT_RING_INSTRUCTIONS = buildRingInstructions({ snapshot: true, clip: true });\nconst LINK_WINDOW_MS = 10 * 60 * 1000;\nconst SNAPSHOT_WINDOW_MS = 15_000;\nconst SNAPSHOT_LOOK_BACK_MS = [15 * 60_000, 60 * 60_000, 6 * 60 * 60_000, 24 * 60 * 60_000];\nconst DEFAULT_CLIP_DURATION_MS = 15_000;\nconst DEFAULT_MAX_ATTACHMENT_BYTES = 10_000_000;\nconst MEDIA_CACHE_TTL_MS = 10 * 60_000;\nconst MEDIA_CACHE_MAX_ENTRIES = 20;\nconst MAX_CLIP_DURATION_MS = 15 * 60 * 1000;\nconst DEFAULT_CLIP_PROCESSING_TIMEOUT_MS = 120_000;\nconst CLIP_RETRY_MS = 5_000;\nconst DEFAULT_MEDIA_URL_TTL_MS = 7 * 24 * 60 * 60 * 1000;\n\n/**\n * Default notification for each Ring event type. Unlisted events are disabled.\n */\nexport const DEFAULT_RING_EVENTS: Partial<Record<RingEventType, RingEventNotification>> = {\n button_press: { priority: 'high', summary: 'Doorbell was pressed.' },\n motion_detected: { priority: 'medium', summary: 'Motion was detected.' },\n};\n\nconst primitiveAttributes = (attributes: Record<string, unknown> = {}): NotificationSignalAttributes => {\n return Object.fromEntries(\n Object.entries(attributes).filter(\n ([, value]) => value === null || ['string', 'number', 'boolean'].includes(typeof value),\n ),\n ) as NotificationSignalAttributes;\n};\n\nconst mediaOutputSchema = z.object({\n mediaId: z.string(),\n url: z.string().optional(),\n attached: z.boolean(),\n shareLink: z.boolean(),\n});\n\nconst sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));\n\n/**\n * Ring signal provider.\n *\n * Links a Ring account to an agent, receives Ring webhooks, and sends each event\n * to an agent thread as a notification signal. Adds `ring_snapshot` and `ring_clip`\n * tools so the agent can fetch media for an event.\n *\n * ```ts\n * const ring = new RingSignals();\n *\n * const agent = new Agent({ signals: [ring], ... });\n *\n * export const mastra = new Mastra({ agents: { agent }, storage });\n * ```\n *\n * Mastra adds the routes from `getRoutes()` to the server when the agent is registered.\n */\nexport class RingSignals extends SignalProvider<'ring-signals'> {\n readonly id = 'ring-signals' as const;\n override readonly name = 'Ring Signals';\n\n readonly #options: RingSignalsOptions;\n readonly #api: RingApiClient;\n readonly #hmacKey: string;\n readonly #mediaKey: string;\n readonly #missingConfig: string[];\n readonly #routePrefix: string;\n readonly #events: Partial<Record<RingEventType, RingEventNotification | false>>;\n readonly #snapshots = new Map<string, string>();\n readonly #clips = new Map<string, string>();\n readonly #mediaCache = new Map<string, { data: Promise<Buffer | undefined>; expiresAt: number }>();\n #warnedPlaintext = false;\n readonly #refreshes = new Map<string, Promise<RingAccount>>();\n\n constructor(options: RingSignalsOptions = {}) {\n super();\n this.#options = options;\n const clientId = options.clientId ?? process.env.RING_CLIENT_ID ?? '';\n const clientSecret = options.clientSecret ?? process.env.RING_CLIENT_SECRET ?? '';\n this.#hmacKey = options.hmacKey ?? process.env.RING_HMAC_KEY ?? '';\n this.#mediaKey = this.#hmacKey ? deriveMediaKey(this.#hmacKey) : '';\n this.#missingConfig = [\n ...(clientId ? [] : ['clientId (RING_CLIENT_ID)']),\n ...(clientSecret ? [] : ['clientSecret (RING_CLIENT_SECRET)']),\n ...(this.#hmacKey ? [] : ['hmacKey (RING_HMAC_KEY)']),\n ];\n this.#routePrefix = (options.routePrefix ?? '/ring').replace(/\\/$/, '');\n this.#events = { ...DEFAULT_RING_EVENTS, ...options.events };\n this.#api = new RingApiClient({ clientId, clientSecret, userAgent: options.userAgent ?? 'MastraRingSignals/1.0' });\n }\n\n /**\n * Warns when credentials are missing as soon as the agent is added to Mastra.\n * Mastra registers the routes from `getRoutes()` itself.\n */\n override __registerMastra(mastra: Parameters<SignalProvider['__registerMastra']>[0]): void {\n super.__registerMastra(mastra);\n\n if (this.#missingConfig.length > 0) {\n mastra\n .getLogger()\n ?.warn(\n `[Ring] RingSignals is missing ${this.#missingConfig.join(', ')}. Account linking, webhooks and media will fail until it's set.`,\n );\n }\n }\n\n // ── Subscriptions ───────────────────────────────────────────────────\n\n /**\n * Send events from a Ring device to a specific thread.\n * Devices without a subscription use the `target` option.\n */\n subscribeThread(target: SignalProviderTarget, deviceId: string): SignalSubscription {\n return this.subscribe(target, deviceId);\n }\n\n /**\n * Stop sending events from a Ring device to a thread.\n *\n * @returns `true` if the thread was subscribed.\n */\n unsubscribeThread(target: SignalProviderTarget, deviceId: string): boolean {\n return this.unsubscribe(target, deviceId);\n }\n\n // ── Webhooks ────────────────────────────────────────────────────────\n\n /**\n * Verify and handle a Ring webhook. `body` must be the raw request body string,\n * because Ring signs the exact bytes it sent.\n */\n async handleWebhook(request: SignalProviderWebhookRequest): Promise<{ status?: number; body?: unknown }> {\n this.#assertConfigured();\n const rawBody = typeof request.body === 'string' ? request.body : JSON.stringify(request.body);\n const signature = Object.entries(request.headers).find(([name]) => name.toLowerCase() === 'x-signature')?.[1];\n\n if (!signature || !safeEqual(computeWebhookSignature(this.#hmacKey, rawBody), signature)) {\n return { status: 401, body: { error: 'invalid signature' } };\n }\n\n let event: RingWebhookEvent;\n try {\n event = JSON.parse(rawBody) as RingWebhookEvent;\n } catch {\n return { status: 400, body: { error: 'invalid JSON body' } };\n }\n await this.#handleAccountEvent(event);\n const notification = this.#events[event.data.type as RingEventType];\n\n if (!notification) {\n return { status: 200, body: { ignored: event.data.type } };\n }\n\n const targets = await this.#resolveTargets(event);\n const { source, source_type: sourceType, timestamp, sub_type: subType } = event.data.attributes;\n\n for (const target of targets) {\n await this.notify(\n {\n source: 'ring',\n kind: event.data.type,\n priority: notification.priority,\n summary: notification.summary,\n attributes: {\n ...(sourceType === 'devices' ? { deviceId: source } : {}),\n ...(timestamp !== undefined ? { timestamp } : {}),\n ...(event.data.type === 'motion_detected' && subType ? { motionType: subType } : {}),\n ...primitiveAttributes(notification.attributes?.(event)),\n },\n payload: event.data,\n dedupeKey: `ring:${event.meta.request_id}:${target.threadId}`,\n ...(notification.coalesce ? { coalesceKey: `ring:${event.data.type}:${source}` } : {}),\n },\n target,\n );\n }\n\n return { status: 200, body: { delivered: targets.length } };\n }\n\n // ── Routes ──────────────────────────────────────────────────────────\n\n /**\n * API routes for Ring account linking, webhooks and media. Mastra adds them to `server.apiRoutes` automatically.\n *\n * | Ring setting | Route |\n * | ------------------ | ----------------------------- |\n * | Account Link URL | `GET {prefix}/link` |\n * | Token Exchange URL | `POST {prefix}/token` |\n * | Webhook URL | `POST {prefix}/webhook` |\n * | App Homepage URL | `GET {prefix}/home` |\n */\n getRoutes(): ApiRoute[] {\n const prefix = this.#routePrefix;\n\n return [\n registerApiRoute(`${prefix}/token`, {\n method: 'POST',\n requiresAuth: false,\n handler: async context => {\n const { code } = await context.req.parseBody();\n try {\n await this.#exchangeCode(String(code));\n return context.json({ ok: true });\n } catch (error) {\n this.#logError('token exchange failed', error);\n return context.json({ error: 'token exchange failed' }, 500);\n }\n },\n }),\n registerApiRoute(`${prefix}/link`, {\n method: 'GET',\n requiresAuth: false,\n handler: async context => {\n const { nonce, time } = context.req.query();\n try {\n const failure = await this.#completeLink(nonce ?? '', time ?? '');\n if (failure) {\n this.#logError(`account link failed: ${failure}`);\n return context.text(`Ring account link failed: ${failure}`, 400);\n }\n return context.text('Ring account linked');\n } catch (error) {\n this.#logError('account link failed', error);\n return context.text('Ring account link failed', 500);\n }\n },\n }),\n registerApiRoute(`${prefix}/webhook`, {\n method: 'POST',\n requiresAuth: false,\n handler: async context => {\n try {\n const result = await this.handleWebhook({\n body: await context.req.text(),\n headers: Object.fromEntries(context.req.raw.headers.entries()),\n });\n return context.json(result.body ?? {}, (result.status ?? 200) as 200);\n } catch (error) {\n this.#logError('webhook failed', error);\n return context.json({ error: 'webhook failed' }, 500);\n }\n },\n }),\n registerApiRoute(`${prefix}/home`, {\n method: 'GET',\n requiresAuth: false,\n handler: async context => context.text(this.name),\n }),\n registerApiRoute(`${prefix}/media/:kind/:deviceId/:timestamp`, {\n method: 'GET',\n requiresAuth: false,\n handler: async context => {\n const { kind, deviceId, timestamp } = context.req.param();\n const path = `${kind}/${deviceId}/${timestamp}`;\n const expires = Number(context.req.query('expires'));\n const signature = context.req.query('signature') ?? '';\n\n if (!this.#mediaKey || !safeEqual(signMediaPath(this.#mediaKey, path, expires), signature)) {\n return context.text('Invalid signature', 403);\n }\n if (!(expires > Date.now())) {\n return context.text('Link expired', 403);\n }\n\n const media =\n kind === 'clip'\n ? await this.#getClip(deviceId, Number(timestamp))\n : await this.#getSnapshot(deviceId, Number(timestamp));\n\n if (!media) {\n return context.text('Not found', 404);\n }\n\n const contentType = kind === 'clip' ? 'video/mp4' : 'image/jpeg';\n const range = /^bytes=(\\d*)-(\\d*)$/.exec(context.req.header('Range') ?? '');\n\n if (range) {\n const start = range[1] ? Number(range[1]) : Math.max(media.length - Number(range[2]), 0);\n const end = range[1] && range[2] ? Math.min(Number(range[2]), media.length - 1) : media.length - 1;\n\n if (start > end || start >= media.length) {\n return context.body(null, 416, { 'Content-Range': `bytes */${media.length}` });\n }\n\n return context.body(new Uint8Array(media.subarray(start, end + 1)), 206, {\n 'Content-Type': contentType,\n 'Content-Range': `bytes ${start}-${end}/${media.length}`,\n 'Accept-Ranges': 'bytes',\n });\n }\n\n return context.body(new Uint8Array(media), 200, {\n 'Content-Type': contentType,\n 'Accept-Ranges': 'bytes',\n });\n },\n }),\n ];\n }\n\n // ── Tools ───────────────────────────────────────────────────────────\n\n getInputProcessors(): InputProcessorOrWorkflow[] {\n return [this as unknown as InputProcessorOrWorkflow];\n }\n\n /**\n * Adds the Ring guidance as a tagged system message. The text never changes, so the\n * system prompt stays identical across requests and the prompt cache stays valid.\n */\n processInputStep({ messageList }: ProcessInputStepArgs) {\n const instructions =\n this.#options.instructions ??\n buildRingInstructions({ snapshot: this.#snapshotEnabled(), clip: this.#clipOptions() !== undefined });\n if (instructions) {\n messageList.addSystem(instructions, 'ring-signals');\n }\n return messageList;\n }\n\n #snapshotEnabled(): boolean {\n return this.#options.tools?.snapshot !== false;\n }\n\n #visibleToModel(tool: 'snapshot' | 'clip'): boolean {\n const configured = this.#options.tools?.[tool];\n const visibleToModel = typeof configured === 'object' ? configured.visibleToModel : undefined;\n return visibleToModel ?? tool === 'snapshot';\n }\n\n /**\n * Whether to attach media of this size for this tool call. Function options are given the platform\n * stored on the thread by its channel, so they work for runs woken by a Ring signal too.\n */\n async #shouldAttach(\n tool: 'snapshot' | 'clip',\n threadId: string | undefined,\n size: number,\n ): Promise<{ attached: boolean; platform: string | undefined }> {\n const configured = this.#options.tools?.[tool];\n const options = typeof configured === 'object' ? configured : {};\n const platform = await this.#threadPlatform(threadId);\n\n const attachment = options.attachment ?? true;\n const attach = platform !== undefined && (Array.isArray(attachment) ? attachment.includes(platform) : attachment);\n if (!attach) return { attached: false, platform };\n\n const maxBytes =\n (typeof options.maxAttachmentBytes === 'object'\n ? options.maxAttachmentBytes[platform]\n : options.maxAttachmentBytes) ?? DEFAULT_MAX_ATTACHMENT_BYTES;\n if (size > maxBytes) {\n this.mastra\n ?.getLogger()\n ?.info(\n `[Ring] Not attaching ${tool} (${size} bytes) on ${platform ?? 'this thread'}: over the ${maxBytes} byte limit.`,\n );\n return { attached: false, platform };\n }\n return { attached: true, platform };\n }\n\n /**\n * What the model is told about a media tool result. On a channel thread the user can't see tool results,\n * so media that wasn't attached has to be shared as a link.\n */\n #mediaModelText(label: 'snapshot' | 'clip', output: { url?: string; attached: boolean; shareLink: boolean }): string {\n if (output.attached) {\n return `The ${label} was sent to the user as an attachment, so don't include its url.`;\n }\n if (!output.url) {\n return `The ${label} was fetched, but there's no link to share with the user.`;\n }\n if (output.shareLink) {\n return label === 'clip'\n ? `This chat can't show tool results, so share the clip as a link in your reply: [Watch clip](${output.url})`\n : `This chat can't show tool results, so share the snapshot as a link in your reply: [View snapshot](${output.url})`;\n }\n return `The ${label} is shown to the user from this tool result, so don't include its url.`;\n }\n\n async #threadPlatform(threadId: string | undefined): Promise<string | undefined> {\n if (!threadId) return undefined;\n const memory = await this.mastra?.getStorage()?.getStore('memory');\n const thread = await memory?.getThreadById({ threadId });\n const platform = thread?.metadata?.channel_platform;\n return typeof platform === 'string' ? platform : undefined;\n }\n\n /**\n * Writes the media as a `file` chunk. Mastra's channel layer posts `file` chunks as attachments\n * on every channel platform; other surfaces can ignore them. Returns whether a chunk was written.\n */\n async #attachFile(\n writer: { custom: (chunk: any) => Promise<void> } | undefined,\n data: Buffer,\n mimeType: string,\n filename: string,\n ): Promise<boolean> {\n if (!writer?.custom) return false;\n await writer.custom({\n type: 'file',\n runId: this.id,\n from: 'AGENT',\n payload: { data: data.toString('base64'), mimeType, filename },\n });\n return true;\n }\n\n /**\n * Resolved clip settings, or `undefined` when the clip tool is disabled.\n */\n #clipOptions(): { audio: boolean; durationMs: number; processingTimeoutMs: number } | undefined {\n const clip = this.#options.tools?.clip ?? true;\n if (clip === false) return undefined;\n const options = clip === true ? {} : clip;\n return {\n audio: options.audio ?? true,\n durationMs: Math.min(options.durationMs ?? DEFAULT_CLIP_DURATION_MS, MAX_CLIP_DURATION_MS),\n processingTimeoutMs: options.processingTimeoutMs ?? DEFAULT_CLIP_PROCESSING_TIMEOUT_MS,\n };\n }\n\n getTools() {\n const clipOptions = this.#clipOptions();\n const clipSeconds = Math.round((clipOptions?.durationMs ?? DEFAULT_CLIP_DURATION_MS) / 1000);\n\n const ringSnapshot = createTool({\n id: 'ring_snapshot',\n description:\n 'Get a still image from a Ring camera for an event. Uses the latest image after the event, or the most recent image before it if there is none.',\n inputSchema: z.object({\n deviceId: z.string().describe('The deviceId attribute from the Ring notification'),\n timestamp: z.number().describe('The timestamp attribute from the Ring notification, in epoch milliseconds'),\n }),\n outputSchema: mediaOutputSchema,\n execute: async ({ deviceId, timestamp }, context) => {\n const image = await this.#getSnapshot(deviceId, timestamp);\n if (!image) {\n throw new Error('Ring has no image for this device in the last 24 hours.');\n }\n const attachment = await this.#shouldAttach('snapshot', context?.agent?.threadId, image.length);\n const { platform } = attachment;\n const attached =\n attachment.attached &&\n (await this.#attachFile(context?.writer, image, 'image/jpeg', `snapshot-${timestamp}.jpg`));\n const url = this.#mediaUrl('snapshot', deviceId, timestamp);\n const mediaId = `snapshot:${deviceId}:${timestamp}`;\n if (this.#visibleToModel('snapshot')) {\n this.#snapshots.set(mediaId, image.toString('base64'));\n }\n return { mediaId, url, attached, shareLink: platform !== undefined && !attached && url !== undefined };\n },\n toModelOutput: output => {\n const image = this.#snapshots.get(output.mediaId);\n this.#snapshots.delete(output.mediaId);\n return {\n type: 'content',\n value: [\n {\n type: 'text',\n text: this.#mediaModelText('snapshot', output),\n },\n ...(image ? [{ type: 'image-data' as const, data: image, mediaType: 'image/jpeg' }] : []),\n ],\n };\n },\n });\n\n const ringClip = createTool({\n id: 'ring_clip',\n description: `Get a ${clipSeconds} second Ring video clip starting at an event. Waits up to ${Math.round((clipOptions?.processingTimeoutMs ?? DEFAULT_CLIP_PROCESSING_TIMEOUT_MS) / 1000)} seconds for Ring to process it.`,\n inputSchema: z.object({\n deviceId: z.string().describe('The deviceId attribute from the Ring notification'),\n timestamp: z.number().describe('The timestamp attribute from the Ring notification, in epoch milliseconds'),\n }),\n outputSchema: mediaOutputSchema,\n execute: async ({ deviceId, timestamp }, context) => {\n const clip = await this.#getClip(deviceId, timestamp);\n if (!clip) {\n throw new Error('Ring has no recording for this event.');\n }\n const attachment = await this.#shouldAttach('clip', context?.agent?.threadId, clip.length);\n const { platform } = attachment;\n const attached =\n attachment.attached && (await this.#attachFile(context?.writer, clip, 'video/mp4', `clip-${timestamp}.mp4`));\n const url = this.#mediaUrl('clip', deviceId, timestamp);\n const mediaId = `clip:${deviceId}:${timestamp}`;\n if (this.#visibleToModel('clip')) {\n this.#clips.set(mediaId, clip.toString('base64'));\n }\n return { mediaId, url, attached, shareLink: platform !== undefined && !attached && url !== undefined };\n },\n toModelOutput: output => {\n const video = this.#clips.get(output.mediaId);\n this.#clips.delete(output.mediaId);\n return {\n type: 'content',\n value: [\n {\n type: 'text',\n text: this.#mediaModelText('clip', output),\n },\n ...(video ? [{ type: 'file-data' as const, data: video, mediaType: 'video/mp4' }] : []),\n ],\n };\n },\n });\n\n return {\n ...(this.#snapshotEnabled() ? { ring_snapshot: ringSnapshot } : {}),\n ...(clipOptions ? { ring_clip: ringClip } : {}),\n };\n }\n\n // ── Routing ─────────────────────────────────────────────────────────\n\n async #resolveTargets(event: RingWebhookEvent): Promise<SignalProviderTarget[]> {\n const deviceId = event.data.attributes.source;\n const subscriptions = this.getSubscriptionsForResource(deviceId);\n\n if (subscriptions.length > 0) {\n return subscriptions.map(({ resourceId, threadId }) => ({ resourceId, threadId }));\n }\n\n const { target } = this.#options;\n const resolved =\n typeof target === 'function'\n ? await target(event)\n : (target ?? { resourceId: this.agent?.id ?? 'ring', threadId: deviceId });\n\n return resolved ? [resolved] : [];\n }\n\n // ── Account linking ─────────────────────────────────────────────────\n\n async #exchangeCode(code: string): Promise<void> {\n this.#assertConfigured();\n const tokens = await this.#api.exchangeCode(code);\n const hardwareId = this.#options.hardwareId ?? crypto.randomUUID();\n const accountId = await this.#api.getAccountId({ accessToken: tokens.accessToken, hardwareId });\n await this.#saveAccount({ accountId, hardwareId, deviceIds: [], ...tokens }, 'pending');\n }\n\n /**\n * Returns a failure reason, or `undefined` when the link completed.\n * A pending account only becomes active once its nonce checks out, so a new token exchange\n * never overwrites a working link.\n */\n async #completeLink(nonce: string, time: string): Promise<string | undefined> {\n this.#assertConfigured();\n if (!nonce || !time) return 'missing nonce or time';\n if (!(Math.abs(Date.now() - Number(time)) <= LINK_WINDOW_MS)) return 'link request expired';\n\n const pending = (await this.#listInstallations('pending')).map(installation => this.#readAccount(installation));\n if (pending.length === 0) return 'no account saved by the token exchange';\n\n const account = pending.find(candidate =>\n safeEqual(computeLinkNonce(this.#hmacKey, time, candidate.accountId), nonce),\n );\n if (!account) return 'nonce mismatch';\n\n await this.#api.confirmLink(account, nonce, account.accountId);\n const deviceIds = await this.#api.listDeviceIds(account).catch(() => []);\n await this.#saveAccount({ ...account, deviceIds }, 'active');\n await (await this.#channelsStorage()).deleteInstallation(this.#installationId(account.accountId, 'pending'));\n return undefined;\n }\n\n /**\n * Keeps stored accounts in sync with Ring: removes an account's tokens when the app is unlinked,\n * and records which account each device belongs to.\n */\n async #handleAccountEvent(event: RingWebhookEvent): Promise<void> {\n const accountId = event.meta.account_id;\n if (!accountId) return;\n\n if (event.data.type === 'app_integration_removed') {\n await this.#deleteAccount(accountId);\n this.mastra?.getLogger()?.info(`[Ring] Ring account unlinked; removed its stored tokens.`);\n return;\n }\n\n if (event.data.type === 'subscription_deactivated') {\n this.mastra\n ?.getLogger()\n ?.warn(\"[Ring] The Ring subscription was deactivated. Snapshots and clips won't be available.\");\n return;\n }\n\n const deviceId = event.data.attributes.source;\n if (event.data.attributes.source_type === 'devices' && deviceId) {\n await this.#rememberDevice(accountId, deviceId);\n }\n }\n\n #assertConfigured(): void {\n if (this.#missingConfig.length > 0) {\n throw new Error(`[Ring] RingSignals is missing ${this.#missingConfig.join(', ')}.`);\n }\n }\n\n #logError(message: string, error?: unknown) {\n const detail =\n error instanceof RingApiError ? `${error.message}: ${error.body}` : error instanceof Error ? error.message : '';\n this.mastra?.getLogger()?.error(`[Ring] ${message}${detail ? ` - ${detail}` : ''}`);\n }\n\n // ── Token storage ───────────────────────────────────────────────────\n\n /**\n * One record per linked Ring account, so several accounts can be linked to the same agent.\n * The account waiting for `/link` to confirm it is stored separately until then.\n */\n #installationId(accountId: string, status: 'active' | 'pending'): string {\n const id = `${PLATFORM}:${this.agent?.id ?? 'default'}:${accountId}`;\n return status === 'pending' ? `${id}:pending` : id;\n }\n\n async #channelsStorage(): Promise<ChannelsStorage> {\n const storage = this.mastra?.getStorage();\n const channels = storage ? ((await storage.getStore('channels')) as ChannelsStorage | undefined) : undefined;\n if (!channels) {\n throw new Error(\n '[Ring] RingSignals needs Mastra storage with channels support (e.g. LibSQLStore or PostgresStore).',\n );\n }\n return channels;\n }\n\n async #listInstallations(status: 'active' | 'pending'): Promise<ChannelInstallation[]> {\n const channels = await this.#channelsStorage();\n const agentId = this.agent?.id ?? 'default';\n return (await channels.listInstallations(PLATFORM)).filter(\n installation => installation.agentId === agentId && installation.status === status,\n );\n }\n\n async #saveAccount(account: RingAccount, status: 'active' | 'pending'): Promise<void> {\n const channels = await this.#channelsStorage();\n const id = this.#installationId(account.accountId, status);\n const existing = await channels.getInstallation(id);\n const now = new Date();\n await channels.saveInstallation({\n id,\n platform: PLATFORM,\n agentId: this.agent?.id ?? 'default',\n status,\n data: {\n accountId: account.accountId,\n hardwareId: account.hardwareId,\n deviceIds: account.deviceIds,\n accessToken: this.#encrypt(account.accessToken),\n refreshToken: this.#encrypt(account.refreshToken),\n expiresAt: account.expiresAt,\n },\n createdAt: existing?.createdAt ?? now,\n updatedAt: now,\n });\n\n if (status === 'active') {\n for (const duplicate of await this.#listInstallations('active')) {\n if (duplicate.id !== id && (duplicate.data as { accountId?: string }).accountId === account.accountId) {\n await channels.deleteInstallation(duplicate.id);\n }\n }\n }\n }\n\n async #deleteAccount(accountId: string): Promise<void> {\n const channels = await this.#channelsStorage();\n for (const status of ['active', 'pending'] as const) {\n for (const installation of await this.#listInstallations(status)) {\n if ((installation.data as { accountId?: string }).accountId === accountId) {\n await channels.deleteInstallation(installation.id);\n }\n }\n }\n }\n\n async #rememberDevice(accountId: string, deviceId: string): Promise<void> {\n // Saving the account rewrites its tokens, so let a refresh store the rotated ones first.\n await this.#refreshes.get(accountId)?.catch(() => undefined);\n const account = await this.#loadAccount(accountId);\n if (!account || account.deviceIds.includes(deviceId)) return;\n await this.#saveAccount({ ...account, deviceIds: [...account.deviceIds, deviceId] }, 'active');\n }\n\n #readAccount(installation: ChannelInstallation): RingAccount {\n const data = installation.data as RingAccount;\n return {\n accountId: data.accountId,\n hardwareId: data.hardwareId,\n deviceIds: data.deviceIds ?? [],\n accessToken: this.#decrypt(data.accessToken),\n refreshToken: this.#decrypt(data.refreshToken),\n expiresAt: data.expiresAt,\n };\n }\n\n async #loadAccount(accountId: string): Promise<RingAccount | undefined> {\n const installation = (await this.#listInstallations('active')).find(\n candidate => (candidate.data as { accountId?: string }).accountId === accountId,\n );\n return installation ? this.#readAccount(installation) : undefined;\n }\n\n /**\n * The linked account that owns a device. Falls back to the only linked account, so a single-account\n * setup works before the device has been seen in a webhook.\n */\n async #accountForDevice(deviceId: string): Promise<RingAccount> {\n const accounts = (await this.#listInstallations('active')).map(installation => this.#readAccount(installation));\n const owner =\n accounts.find(account => account.deviceIds.includes(deviceId)) ??\n (accounts.length === 1 ? accounts[0] : undefined);\n if (!owner) {\n throw new Error(\n accounts.length === 0\n ? '[Ring] No linked Ring account. Link the app from the Ring Appstore first.'\n : \"[Ring] Couldn't tell which linked Ring account owns this device.\",\n );\n }\n return owner;\n }\n\n /**\n * Fresh credentials for the account that owns a device. Ring invalidates the old refresh token on every\n * refresh, so concurrent refreshes in this process share one request, and if another process refreshed\n * first, the tokens it stored are used instead.\n */\n async #getAuth(deviceId: string): Promise<RingAuth> {\n const account = await this.#accountForDevice(deviceId);\n if (account.expiresAt - Date.now() > 60_000) {\n return account;\n }\n\n const inFlight = this.#refreshes.get(account.accountId);\n if (inFlight) return inFlight;\n\n const refresh = (async () => {\n try {\n const tokens: RingTokens = await this.#api.refresh(account.refreshToken);\n const refreshed = { ...account, ...tokens };\n await this.#saveAccount(refreshed, 'active');\n return refreshed;\n } catch (error) {\n const stored = await this.#loadAccount(account.accountId);\n if (stored && stored.refreshToken !== account.refreshToken && stored.expiresAt - Date.now() > 60_000) {\n return stored;\n }\n throw error;\n } finally {\n this.#refreshes.delete(account.accountId);\n }\n })();\n\n this.#refreshes.set(account.accountId, refresh);\n return refresh;\n }\n\n #encryptionKey(): string | undefined {\n return this.#options.encryptionKey ?? process.env.MASTRA_ENCRYPTION_KEY;\n }\n\n #encrypt(value: string): string {\n const key = this.#encryptionKey();\n if (!key && !this.#warnedPlaintext) {\n this.#warnedPlaintext = true;\n this.mastra\n ?.getLogger()\n ?.warn(\n '[Ring] Storing Ring tokens WITHOUT encryption. Set `encryptionKey` on RingSignals or MASTRA_ENCRYPTION_KEY to encrypt them at rest.',\n );\n }\n return key ? encrypt(value, key) : value;\n }\n\n #decrypt(value: string): string {\n const key = this.#encryptionKey();\n if (!isEncrypted(value)) return value;\n if (!key) {\n throw new Error(\n '[Ring] The stored Ring tokens are encrypted, but no encryption key is configured. Set `encryptionKey` on RingSignals or MASTRA_ENCRYPTION_KEY.',\n );\n }\n return decrypt(value, key);\n }\n\n // ── Media ───────────────────────────────────────────────────────────\n\n /**\n * A signed link to the media route, or `undefined` when `baseUrl` isn't set. Ring media needs the account's\n * tokens to download, so links point at this server, which fetches the media from Ring when opened.\n */\n #mediaUrl(kind: 'snapshot' | 'clip', deviceId: string, timestamp: number): string | undefined {\n this.#assertConfigured();\n const baseUrl = this.#options.baseUrl ?? process.env.RING_BASE_URL;\n if (!baseUrl) return undefined;\n const path = `${kind}/${deviceId}/${timestamp}`;\n const expires = Date.now() + (this.#options.mediaUrlTtlMs ?? DEFAULT_MEDIA_URL_TTL_MS);\n const signature = signMediaPath(this.#mediaKey, path, expires);\n return `${baseUrl.replace(/\\/$/, '')}${this.#routePrefix}/media/${path}?expires=${expires}&signature=${signature}`;\n }\n\n /**\n * Media is cached briefly so a tool call and the link it returns share one download, and so every\n * byte-range request a video player makes reads the same file instead of downloading the clip again.\n */\n #cachedMedia(key: string, download: () => Promise<Buffer | undefined>): Promise<Buffer | undefined> {\n const now = Date.now();\n for (const [cachedKey, entry] of this.#mediaCache) {\n if (entry.expiresAt <= now) this.#mediaCache.delete(cachedKey);\n }\n\n const cached = this.#mediaCache.get(key);\n if (cached) return cached.data;\n\n const data = download().then(\n media => {\n if (!media) this.#mediaCache.delete(key);\n return media;\n },\n (error: unknown) => {\n this.#mediaCache.delete(key);\n throw error;\n },\n );\n this.#mediaCache.set(key, { data, expiresAt: now + MEDIA_CACHE_TTL_MS });\n\n while (this.#mediaCache.size > MEDIA_CACHE_MAX_ENTRIES) {\n const oldest = this.#mediaCache.keys().next().value;\n if (oldest === undefined) break;\n this.#mediaCache.delete(oldest);\n }\n return data;\n }\n\n #getSnapshot(deviceId: string, timestamp: number): Promise<Buffer | undefined> {\n return this.#cachedMedia(`snapshot:${deviceId}:${timestamp}`, () => this.#downloadSnapshot(deviceId, timestamp));\n }\n\n #getClip(deviceId: string, timestamp: number): Promise<Buffer | undefined> {\n return this.#cachedMedia(`clip:${deviceId}:${timestamp}`, () => this.#downloadClip(deviceId, timestamp));\n }\n\n async #downloadSnapshot(deviceId: string, timestamp: number): Promise<Buffer | undefined> {\n const endTimestamp = Math.min(timestamp + SNAPSHOT_WINDOW_MS, Date.now() + SNAPSHOT_WINDOW_MS);\n const waitMs = endTimestamp - Date.now();\n if (waitMs > 0) await sleep(waitMs);\n\n const auth = await this.#getAuth(deviceId);\n const afterEvent = await this.#api.downloadLatestImage(auth, deviceId, timestamp, endTimestamp);\n if (afterEvent) return afterEvent;\n\n for (const lookBack of SNAPSHOT_LOOK_BACK_MS) {\n const beforeEvent = await this.#api.downloadLatestImage(auth, deviceId, timestamp - lookBack, endTimestamp);\n if (beforeEvent) return beforeEvent;\n }\n\n return undefined;\n }\n\n async #downloadClip(deviceId: string, timestamp: number): Promise<Buffer | undefined> {\n const clipOptions = this.#clipOptions() ?? {\n audio: true,\n durationMs: DEFAULT_CLIP_DURATION_MS,\n processingTimeoutMs: DEFAULT_CLIP_PROCESSING_TIMEOUT_MS,\n };\n const deadline = Date.now() + clipOptions.processingTimeoutMs;\n\n let partial: Buffer | undefined;\n\n while (true) {\n const response = await this.#api.downloadClip(\n await this.#getAuth(deviceId),\n deviceId,\n timestamp,\n clipOptions.durationMs,\n clipOptions.audio,\n );\n\n if (response.status === 200) {\n return Buffer.from(await response.arrayBuffer());\n }\n\n if (response.status === 206) {\n partial = Buffer.from(await response.arrayBuffer());\n } else if (![416, 425].includes(response.status)) {\n return partial;\n }\n\n if (Date.now() > deadline) {\n return partial;\n }\n\n await sleep(CLIP_RETRY_MS);\n }\n }\n}\n"],"mappings":";;;;;;AAEA,MAAM,cAAc;AACpB,MAAM,YAAY;;;;;AAMlB,SAAgB,QAAQ,WAAmB,KAAqB;CAC9D,MAAM,OAAO,OAAO,KAAK,WAAW,OAAO,gCAAgB,IAAI,WAAW,EAAE,CAAC,CAAC;CAC9E,MAAM,UAAU,OAAO,KAAK,SAAS,UAAU,KAAK,MAAM,WAAW,EAAE,CAAC;CACxE,MAAM,KAAK,OAAO,KAAK,WAAW,OAAO,gCAAgB,IAAI,WAAW,EAAE,CAAC,CAAC;CAC5E,MAAM,SAAS,eAAe,eAAe,SAAS,EAAE;CACxD,MAAM,YAAY,OAAO,OAAO,CAAC,OAAO,OAAO,WAAW,MAAM,GAAG,OAAO,MAAM,CAAC,CAAC;CAClF,MAAM,UAAU,OAAO,WAAW;CAClC,OAAO,GAAG,YAAY,GAAG,KAAK,SAAS,QAAQ,EAAE,GAAG,GAAG,SAAS,QAAQ,EAAE,GAAG,QAAQ,SAAS,QAAQ,EAAE,GAAG,UAAU,SAAS,QAAQ;AACxI;;;;AAKA,SAAgB,QAAQ,YAAoB,KAAqB;CAC/D,MAAM,CAAC,QAAQ,SAAS,OAAO,YAAY,gBAAgB,WAAW,MAAM,GAAG;CAC/E,IAAI,WAAW,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,cAAc,iBAAiB,KAAA,GAClF,MAAM,IAAI,MAAM,gCAAgC;CAElD,MAAM,OAAO,OAAO,KAAK,SAAS,QAAQ;CAC1C,MAAM,UAAU,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ACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { RingTokens } from './types.js';
|
|
2
|
+
export type RingApiClientOptions = {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientSecret: string;
|
|
5
|
+
userAgent: string;
|
|
6
|
+
};
|
|
7
|
+
/** Credentials for one linked Ring account. */
|
|
8
|
+
export type RingAuth = {
|
|
9
|
+
accessToken: string;
|
|
10
|
+
hardwareId: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class RingApiError extends Error {
|
|
13
|
+
readonly status: number;
|
|
14
|
+
readonly body: string;
|
|
15
|
+
constructor(message: string, status: number, body: string);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Thin client for the Ring Partner API.
|
|
19
|
+
* See https://developer.amazon.com/docs/ring/api-documentation.html
|
|
20
|
+
*/
|
|
21
|
+
export declare class RingApiClient {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(options: RingApiClientOptions);
|
|
24
|
+
/** Exchange the authorization code Ring posts to the Token Exchange URL. */
|
|
25
|
+
exchangeCode(code: string): Promise<RingTokens>;
|
|
26
|
+
/** Refresh an access token. Ring rotates the refresh token on every refresh. */
|
|
27
|
+
refresh(refreshToken: string): Promise<RingTokens>;
|
|
28
|
+
/** Get the Ring account ID for an access token. */
|
|
29
|
+
getAccountId(auth: RingAuth): Promise<string>;
|
|
30
|
+
/** List the IDs of the devices the account has shared with the app. */
|
|
31
|
+
listDeviceIds(auth: RingAuth): Promise<string[]>;
|
|
32
|
+
/** Verify the link nonce and mark the integration `completed`. */
|
|
33
|
+
confirmLink(auth: RingAuth, nonce: string, accountIdentifier: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Download the latest image in a time range.
|
|
36
|
+
* Returns `undefined` when Ring has no image in the range or the range isn't authorized.
|
|
37
|
+
*/
|
|
38
|
+
downloadLatestImage(auth: RingAuth, deviceId: string, startTimestamp: number, endTimestamp: number): Promise<Buffer | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Download a recorded clip. Returns the response so callers can retry `416` and `425`
|
|
41
|
+
* while Ring finishes processing the recording.
|
|
42
|
+
*/
|
|
43
|
+
downloadClip(auth: RingAuth, deviceId: string, timestamp: number, durationMs: number, audio: boolean): Promise<Response>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ring-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring-api.d.ts","sourceRoot":"","sources":["../src/ring-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAc1C,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,+CAA+C;AAC/C,MAAM,MAAM,QAAQ,GAAG;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,qBAAa,YAAa,SAAQ,KAAK;IAGnC,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAHvB,YACE,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAItB;CACF;AAED;;;GAGG;AACH,qBAAa,aAAa;;IAGxB,YAAY,OAAO,EAAE,oBAAoB,EAExC;IAED,4EAA4E;IAC5E,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAE9C;IAED,gFAAgF;IAChF,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAEjD;IAED,mDAAmD;IAC7C,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlD;IAED,uEAAuE;IACjE,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAGrD;IAED,kEAAkE;IAC5D,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMzF;IAED;;;OAGG;IACG,mBAAmB,CACvB,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAS7B;IAED;;;OAGG;IACH,YAAY,CACV,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,QAAQ,CAAC,CAMnB;CA4DF"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { InputProcessorOrWorkflow, ProcessInputStepArgs } from '@mastra/core/processors';
|
|
2
|
+
import type { ApiRoute } from '@mastra/core/server';
|
|
3
|
+
import { SignalProvider } from '@mastra/core/signals';
|
|
4
|
+
import type { SignalProviderTarget, SignalProviderWebhookRequest, SignalSubscription } from '@mastra/core/signals';
|
|
5
|
+
import type { RingEventNotification, RingEventType, RingSignalsOptions } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Guidance added to the agent's system prompt for Ring notifications, covering only the enabled tools.
|
|
8
|
+
* It depends only on config, so it's the same on every request and doesn't invalidate the prompt cache.
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildRingInstructions: (tools: {
|
|
11
|
+
snapshot: boolean;
|
|
12
|
+
clip: boolean;
|
|
13
|
+
}) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Default guidance when both tools are enabled.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_RING_INSTRUCTIONS: string;
|
|
18
|
+
/**
|
|
19
|
+
* Default notification for each Ring event type. Unlisted events are disabled.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_RING_EVENTS: Partial<Record<RingEventType, RingEventNotification>>;
|
|
22
|
+
/**
|
|
23
|
+
* Ring signal provider.
|
|
24
|
+
*
|
|
25
|
+
* Links a Ring account to an agent, receives Ring webhooks, and sends each event
|
|
26
|
+
* to an agent thread as a notification signal. Adds `ring_snapshot` and `ring_clip`
|
|
27
|
+
* tools so the agent can fetch media for an event.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const ring = new RingSignals();
|
|
31
|
+
*
|
|
32
|
+
* const agent = new Agent({ signals: [ring], ... });
|
|
33
|
+
*
|
|
34
|
+
* export const mastra = new Mastra({ agents: { agent }, storage });
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* Mastra adds the routes from `getRoutes()` to the server when the agent is registered.
|
|
38
|
+
*/
|
|
39
|
+
export declare class RingSignals extends SignalProvider<'ring-signals'> {
|
|
40
|
+
#private;
|
|
41
|
+
readonly id: 'ring-signals';
|
|
42
|
+
readonly name = "Ring Signals";
|
|
43
|
+
constructor(options?: RingSignalsOptions);
|
|
44
|
+
/**
|
|
45
|
+
* Warns when credentials are missing as soon as the agent is added to Mastra.
|
|
46
|
+
* Mastra registers the routes from `getRoutes()` itself.
|
|
47
|
+
*/
|
|
48
|
+
__registerMastra(mastra: Parameters<SignalProvider['__registerMastra']>[0]): void;
|
|
49
|
+
/**
|
|
50
|
+
* Send events from a Ring device to a specific thread.
|
|
51
|
+
* Devices without a subscription use the `target` option.
|
|
52
|
+
*/
|
|
53
|
+
subscribeThread(target: SignalProviderTarget, deviceId: string): SignalSubscription;
|
|
54
|
+
/**
|
|
55
|
+
* Stop sending events from a Ring device to a thread.
|
|
56
|
+
*
|
|
57
|
+
* @returns `true` if the thread was subscribed.
|
|
58
|
+
*/
|
|
59
|
+
unsubscribeThread(target: SignalProviderTarget, deviceId: string): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Verify and handle a Ring webhook. `body` must be the raw request body string,
|
|
62
|
+
* because Ring signs the exact bytes it sent.
|
|
63
|
+
*/
|
|
64
|
+
handleWebhook(request: SignalProviderWebhookRequest): Promise<{
|
|
65
|
+
status?: number;
|
|
66
|
+
body?: unknown;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* API routes for Ring account linking, webhooks and media. Mastra adds them to `server.apiRoutes` automatically.
|
|
70
|
+
*
|
|
71
|
+
* | Ring setting | Route |
|
|
72
|
+
* | ------------------ | ----------------------------- |
|
|
73
|
+
* | Account Link URL | `GET {prefix}/link` |
|
|
74
|
+
* | Token Exchange URL | `POST {prefix}/token` |
|
|
75
|
+
* | Webhook URL | `POST {prefix}/webhook` |
|
|
76
|
+
* | App Homepage URL | `GET {prefix}/home` |
|
|
77
|
+
*/
|
|
78
|
+
getRoutes(): ApiRoute[];
|
|
79
|
+
getInputProcessors(): InputProcessorOrWorkflow[];
|
|
80
|
+
/**
|
|
81
|
+
* Adds the Ring guidance as a tagged system message. The text never changes, so the
|
|
82
|
+
* system prompt stays identical across requests and the prompt cache stays valid.
|
|
83
|
+
*/
|
|
84
|
+
processInputStep({ messageList }: ProcessInputStepArgs): import("@mastra/core/agent").MessageList;
|
|
85
|
+
getTools(): {
|
|
86
|
+
ring_snapshot?: import("@mastra/core/tools").Tool<{
|
|
87
|
+
deviceId: string;
|
|
88
|
+
timestamp: number;
|
|
89
|
+
}, {
|
|
90
|
+
mediaId: string;
|
|
91
|
+
url?: string | undefined;
|
|
92
|
+
attached: boolean;
|
|
93
|
+
shareLink: boolean;
|
|
94
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "ring_snapshot", unknown> | undefined;
|
|
95
|
+
ring_clip?: import("@mastra/core/tools").Tool<{
|
|
96
|
+
deviceId: string;
|
|
97
|
+
timestamp: number;
|
|
98
|
+
}, {
|
|
99
|
+
mediaId: string;
|
|
100
|
+
url?: string | undefined;
|
|
101
|
+
attached: boolean;
|
|
102
|
+
shareLink: boolean;
|
|
103
|
+
}, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "ring_clip", unknown> | undefined;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=ring-signals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ring-signals.d.ts","sourceRoot":"","sources":["../src/ring-signals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE9F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAgBnH,OAAO,KAAK,EAEV,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAGnB,MAAM,SAAS,CAAC;AAIjB;;;GAGG;AACH,eAAO,MAAM,qBAAqB,UAAW;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,KAAG,MAgBnF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAwD,CAAC;AAa/F;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAGrF,CAAC;AAmBF;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,WAAY,SAAQ,cAAc,CAAC,cAAc,CAAC;;IAC7D,QAAQ,CAAC,EAAE,EAAG,cAAc,CAAU;IACtC,SAAkB,IAAI,kBAAkB;IAexC,YAAY,OAAO,GAAE,kBAAuB,EAe3C;IAED;;;OAGG;IACM,gBAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAUzF;IAID;;;OAGG;IACH,eAAe,CAAC,MAAM,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CAElF;IAED;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzE;IAID;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CA+CvG;IAID;;;;;;;;;OASG;IACH,SAAS,IAAI,QAAQ,EAAE,CA2GtB;IAID,kBAAkB,IAAI,wBAAwB,EAAE,CAE/C;IAED;;;OAGG;IACH,gBAAgB,CAAC,EAAE,WAAW,EAAE,EAAE,oBAAoB,4CAQrD;IAyGD,QAAQ;;;;;;;;;;;;;;;;;;;MA0FP;CAkYF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { NotificationPriority } from '@mastra/core/notifications';
|
|
2
|
+
import type { SignalProviderTarget } from '@mastra/core/signals';
|
|
3
|
+
/**
|
|
4
|
+
* Event types Ring delivers to the webhook URL.
|
|
5
|
+
* See https://developer.amazon.com/docs/ring/api-documentation.html#event-types
|
|
6
|
+
*/
|
|
7
|
+
export type RingEventType = 'button_press' | 'motion_detected' | 'device_added' | 'device_removed' | 'device_online' | 'device_offline' | 'app_integration_added' | 'app_integration_removed' | 'subscription_activated' | 'subscription_deactivated';
|
|
8
|
+
/**
|
|
9
|
+
* `sub_type` values on `motion_detected` when Smart Alerts are enabled.
|
|
10
|
+
* Without Smart Alerts, Ring sends `motion`.
|
|
11
|
+
*/
|
|
12
|
+
export type RingMotionType = 'human' | 'vehicle' | 'package_delivery' | 'other_motion' | 'motion';
|
|
13
|
+
/**
|
|
14
|
+
* `sub_type` values on `subscription_activated` and `subscription_deactivated`.
|
|
15
|
+
*/
|
|
16
|
+
export type RingSubscriptionType = 'paid' | 'trial';
|
|
17
|
+
/**
|
|
18
|
+
* A Ring webhook payload.
|
|
19
|
+
*/
|
|
20
|
+
export type RingWebhookEvent = {
|
|
21
|
+
meta: {
|
|
22
|
+
version: string;
|
|
23
|
+
time: string;
|
|
24
|
+
request_id: string;
|
|
25
|
+
account_id?: string;
|
|
26
|
+
};
|
|
27
|
+
data: {
|
|
28
|
+
id: string;
|
|
29
|
+
type: RingEventType | (string & {});
|
|
30
|
+
attributes: {
|
|
31
|
+
/** Device ID for device events, account ID for app integration events, `subscriptions` for subscription events. */
|
|
32
|
+
source: string;
|
|
33
|
+
/** Subscription ID, on subscription events. */
|
|
34
|
+
source_id?: string;
|
|
35
|
+
/** `devices` for device events, `users` for app integration events. */
|
|
36
|
+
source_type?: string;
|
|
37
|
+
/** Epoch milliseconds. Missing on subscription events. */
|
|
38
|
+
timestamp?: number;
|
|
39
|
+
/** What caused a motion event, or `paid` / `trial` on subscription events. */
|
|
40
|
+
sub_type?: RingMotionType | RingSubscriptionType | (string & {});
|
|
41
|
+
/** Cameras involved, on devices with more than one. */
|
|
42
|
+
component_ids?: string[];
|
|
43
|
+
/** Subscription plan ID, on subscription events. `null` for trials. */
|
|
44
|
+
plan_id?: string | null;
|
|
45
|
+
/** When the billing cycle or trial ends, as an ISO 8601 date, on subscription events. */
|
|
46
|
+
expires_at?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* How a Ring event becomes a notification signal. Set an event to `false` to disable it.
|
|
52
|
+
*/
|
|
53
|
+
export type RingEventNotification = {
|
|
54
|
+
priority: NotificationPriority;
|
|
55
|
+
summary: string;
|
|
56
|
+
/** Merge repeats of this event into one pending notification (counted by `coalescedCount`). */
|
|
57
|
+
coalesce?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Extra attributes the model sees on the notification, merged over the defaults
|
|
60
|
+
* (`deviceId`, `timestamp`, and `motionType` for motion events).
|
|
61
|
+
* Values that aren't strings, numbers, booleans or `null` (e.g. arrays) are dropped.
|
|
62
|
+
*/
|
|
63
|
+
attributes?: (event: RingWebhookEvent) => Record<string, unknown>;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Where a Ring event is delivered. Return a target, or `undefined` to drop the event.
|
|
67
|
+
* Can be async, e.g. to look up which user owns `event.meta.account_id`.
|
|
68
|
+
*/
|
|
69
|
+
export type RingTargetResolver = (event: RingWebhookEvent) => SignalProviderTarget | undefined | Promise<SignalProviderTarget | undefined>;
|
|
70
|
+
export type RingSignalsOptions = {
|
|
71
|
+
/** Ring app Client ID. Defaults to `RING_CLIENT_ID`. */
|
|
72
|
+
clientId?: string;
|
|
73
|
+
/** Ring app Client Secret. Defaults to `RING_CLIENT_SECRET`. */
|
|
74
|
+
clientSecret?: string;
|
|
75
|
+
/** Ring app HMAC Signature Key, used to verify link nonces and webhook signatures, and to derive the media URL signing key. Defaults to `RING_HMAC_KEY`. */
|
|
76
|
+
hmacKey?: string;
|
|
77
|
+
/** Key used to encrypt stored Ring tokens. Defaults to `MASTRA_ENCRYPTION_KEY`. When unset, tokens are stored unencrypted and a warning is logged. */
|
|
78
|
+
encryptionKey?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Public URL of your Mastra server, used to build shareable snapshot and clip links. Use `http://localhost:4111`
|
|
81
|
+
* (or a tunnel URL) in development and your deployed URL in production. Without it, the tools return no links;
|
|
82
|
+
* the agent still sees snapshots and chat channels still get attachments. Defaults to `RING_BASE_URL`.
|
|
83
|
+
*/
|
|
84
|
+
baseUrl?: string;
|
|
85
|
+
/** How long signed snapshot and clip links stay valid, in milliseconds. Defaults to 7 days. */
|
|
86
|
+
mediaUrlTtlMs?: number;
|
|
87
|
+
/** Path prefix for the Ring routes. Defaults to `/ring`. */
|
|
88
|
+
routePrefix?: string;
|
|
89
|
+
/** `User-Agent` sent to the Ring API. Defaults to `MastraRingSignals/1.0`. */
|
|
90
|
+
userAgent?: string;
|
|
91
|
+
/**
|
|
92
|
+
* `Hardware_Id` sent to the Ring API. By default a UUID is generated when an account is linked
|
|
93
|
+
* and stored with that account's tokens.
|
|
94
|
+
*/
|
|
95
|
+
hardwareId?: string;
|
|
96
|
+
/**
|
|
97
|
+
* Where events are delivered when no thread has subscribed to the device with `subscribeThread()`.
|
|
98
|
+
* Defaults to `{ resourceId: <agent id>, threadId: <device id> }`.
|
|
99
|
+
*/
|
|
100
|
+
target?: SignalProviderTarget | RingTargetResolver;
|
|
101
|
+
/** Override how each event type becomes a notification, or set it to `false` to disable it. */
|
|
102
|
+
events?: Partial<Record<RingEventType, RingEventNotification | false>>;
|
|
103
|
+
/**
|
|
104
|
+
* Guidance added to the agent's system prompt telling it how to handle Ring notifications.
|
|
105
|
+
* The text is fixed, so it doesn't invalidate the prompt cache. Set to `false` to leave it out.
|
|
106
|
+
* Defaults to `DEFAULT_RING_INSTRUCTIONS`.
|
|
107
|
+
*/
|
|
108
|
+
instructions?: string | false;
|
|
109
|
+
/**
|
|
110
|
+
* Tools added to the agent. Both tools are enabled by default. Set a tool to `false` to remove it,
|
|
111
|
+
* or to an options object to configure it.
|
|
112
|
+
*/
|
|
113
|
+
tools?: RingToolsOptions;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Whether to send the media as a file attachment in chat channels.
|
|
117
|
+
* `true` attaches on every channel platform, `false` never attaches, and a list of platform names
|
|
118
|
+
* (for example `["imessage", "slack"]`) attaches only on those. Studio, web and API threads never get attachments.
|
|
119
|
+
*/
|
|
120
|
+
export type RingAttachmentOption = boolean | string[];
|
|
121
|
+
/**
|
|
122
|
+
* Largest file to attach, in bytes. A number applies to every platform; an object sets a limit per platform
|
|
123
|
+
* (for example `{ discord: 10_000_000 }`), and unlisted platforms use the 10 MB default.
|
|
124
|
+
* Files over the limit aren't attached, and the agent shares the link instead.
|
|
125
|
+
*/
|
|
126
|
+
export type RingMaxAttachmentBytesOption = number | Record<string, number>;
|
|
127
|
+
export type RingSnapshotToolOptions = {
|
|
128
|
+
/** Send the snapshot as a file attachment in chat channels. Defaults to `true`. The `url` in the tool result is always returned. */
|
|
129
|
+
attachment?: RingAttachmentOption;
|
|
130
|
+
/** Largest snapshot to attach, in bytes. Defaults to 10 MB. */
|
|
131
|
+
maxAttachmentBytes?: RingMaxAttachmentBytesOption;
|
|
132
|
+
/** Pass the image to the model so the agent can describe it. Requires a model that accepts images. Defaults to `true`. */
|
|
133
|
+
visibleToModel?: boolean;
|
|
134
|
+
};
|
|
135
|
+
export type RingClipToolOptions = {
|
|
136
|
+
/** Send the clip as a file attachment in chat channels. Defaults to `true`. The `url` in the tool result is always returned. */
|
|
137
|
+
attachment?: RingAttachmentOption;
|
|
138
|
+
/** Largest clip to attach, in bytes. Defaults to 10 MB. */
|
|
139
|
+
maxAttachmentBytes?: RingMaxAttachmentBytesOption;
|
|
140
|
+
/** Pass the video to the model so the agent can describe it. Requires a model that accepts video, such as Gemini. Defaults to `false`. */
|
|
141
|
+
visibleToModel?: boolean;
|
|
142
|
+
/** Include audio in clips. Defaults to `true`. */
|
|
143
|
+
audio?: boolean;
|
|
144
|
+
/** Clip length in milliseconds. Defaults to 15 seconds. Capped at Ring's maximum of 15 minutes (900,000 ms). */
|
|
145
|
+
durationMs?: number;
|
|
146
|
+
/** How long to wait for Ring to finish processing the recording, in milliseconds. Defaults to 2 minutes. */
|
|
147
|
+
processingTimeoutMs?: number;
|
|
148
|
+
};
|
|
149
|
+
export type RingToolsOptions = {
|
|
150
|
+
/** `ring_snapshot`: a still image for an event. Defaults to `true`. */
|
|
151
|
+
snapshot?: boolean | RingSnapshotToolOptions;
|
|
152
|
+
/** `ring_clip`: a video clip for an event. Defaults to `true`. */
|
|
153
|
+
clip?: boolean | RingClipToolOptions;
|
|
154
|
+
};
|
|
155
|
+
export type RingTokens = {
|
|
156
|
+
accessToken: string;
|
|
157
|
+
refreshToken: string;
|
|
158
|
+
expiresAt: number;
|
|
159
|
+
};
|
|
160
|
+
export type RingAccount = RingTokens & {
|
|
161
|
+
accountId: string;
|
|
162
|
+
hardwareId: string;
|
|
163
|
+
/** Devices seen for this account, used to pick the right account's tokens for a device. */
|
|
164
|
+
deviceIds: string[];
|
|
165
|
+
};
|
|
166
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,eAAe,GACf,gBAAgB,GAChB,uBAAuB,GACvB,yBAAyB,GACzB,wBAAwB,GACxB,0BAA0B,CAAC;AAE/B;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,kBAAkB,GAAG,cAAc,GAAG,QAAQ,CAAC;AAElG;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,aAAa,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;QACpC,UAAU,EAAE;YACV,mHAAmH;YACnH,MAAM,EAAE,MAAM,CAAC;YACf,+CAA+C;YAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,uEAAuE;YACvE,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,0DAA0D;YAC1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,EAAE,OAAO,GAAG,mBAAmB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/ring-signals",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Ring doorbell and camera signal provider for Mastra agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"./package.json": "./package.json"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mastra",
|
|
26
|
+
"ring",
|
|
27
|
+
"doorbell",
|
|
28
|
+
"signals",
|
|
29
|
+
"notifications",
|
|
30
|
+
"ai-agent"
|
|
31
|
+
],
|
|
5
32
|
"license": "Apache-2.0",
|
|
6
33
|
"repository": {
|
|
7
34
|
"type": "git",
|
|
8
35
|
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
9
36
|
"directory": "signals/ring"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://mastra.ai",
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22.13.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@mastra/core": ">=1.0.0-0 <2.0.0-0",
|
|
47
|
+
"zod": ">=3.0.0 || >=4.0.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"hono": "^4.13.13",
|
|
51
|
+
"tsdown": "0.23.1",
|
|
52
|
+
"typescript": "^7.0.2",
|
|
53
|
+
"vitest": "5.1.0",
|
|
54
|
+
"zod": "^4.6.7",
|
|
55
|
+
"@internal/lint": "0.0.147",
|
|
56
|
+
"@internal/types-builder": "0.0.122",
|
|
57
|
+
"@mastra/core": "1.82.0-alpha.3"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsdown --silent --config tsdown.config.ts",
|
|
61
|
+
"build:lib": "tsdown --silent --config tsdown.config.ts",
|
|
62
|
+
"build:watch": "pnpm build:lib --watch",
|
|
63
|
+
"lint": "oxlint --type-aware .",
|
|
64
|
+
"lint:fix": "oxlint --type-aware --fix .",
|
|
65
|
+
"test": "vitest run"
|
|
10
66
|
}
|
|
11
|
-
}
|
|
67
|
+
}
|