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

This commit is contained in:
wehub-resource-sync
2026-07-13 13:20:55 +08:00
commit d25d482dc2
13754 changed files with 4996608 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
export { upstashRedisCommandTool } from '@/tools/upstash/redis_command'
export { upstashRedisDeleteTool } from '@/tools/upstash/redis_delete'
export { upstashRedisExistsTool } from '@/tools/upstash/redis_exists'
export { upstashRedisExpireTool } from '@/tools/upstash/redis_expire'
export { upstashRedisGetTool } from '@/tools/upstash/redis_get'
export { upstashRedisHGetTool } from '@/tools/upstash/redis_hget'
export { upstashRedisHGetAllTool } from '@/tools/upstash/redis_hgetall'
export { upstashRedisHSetTool } from '@/tools/upstash/redis_hset'
export { upstashRedisIncrTool } from '@/tools/upstash/redis_incr'
export { upstashRedisIncrbyTool } from '@/tools/upstash/redis_incrby'
export { upstashRedisKeysTool } from '@/tools/upstash/redis_keys'
export { upstashRedisLPushTool } from '@/tools/upstash/redis_lpush'
export { upstashRedisLRangeTool } from '@/tools/upstash/redis_lrange'
export { upstashRedisSetTool } from '@/tools/upstash/redis_set'
export { upstashRedisSetnxTool } from '@/tools/upstash/redis_setnx'
export { upstashRedisTtlTool } from '@/tools/upstash/redis_ttl'
+76
View File
@@ -0,0 +1,76 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisCommandParams, UpstashRedisCommandResponse } from '@/tools/upstash/types'
export const upstashRedisCommandTool: ToolConfig<
UpstashRedisCommandParams,
UpstashRedisCommandResponse
> = {
id: 'upstash_redis_command',
name: 'Upstash Redis Command',
description:
'Execute an arbitrary Redis command against Upstash Redis. Pass the full command as a JSON array (e.g., ["HSET", "myhash", "field1", "value1"]).',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
command: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description:
'Redis command as a JSON array (e.g., ["HSET", "myhash", "field1", "value1"]) or a simple command string (e.g., "PING")',
},
},
request: {
url: (params) => params.restUrl,
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
'Content-Type': 'application/json',
}),
body: (params) => {
try {
const parsed = JSON.parse(params.command)
if (Array.isArray(parsed)) {
return parsed
}
return [String(parsed)]
} catch {
return params.command.trim().split(/\s+/)
}
},
},
transformResponse: async (response: Response, params?: UpstashRedisCommandParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to execute Redis command')
}
return {
success: true,
output: {
command: params?.command ?? '',
result: data.result ?? null,
},
}
},
outputs: {
command: { type: 'string', description: 'The command that was executed' },
result: { type: 'json', description: 'The result of the Redis command' },
},
}
+65
View File
@@ -0,0 +1,65 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisDeleteParams, UpstashRedisDeleteResponse } from '@/tools/upstash/types'
export const upstashRedisDeleteTool: ToolConfig<
UpstashRedisDeleteParams,
UpstashRedisDeleteResponse
> = {
id: 'upstash_redis_delete',
name: 'Upstash Redis Delete',
description: 'Delete a key from Upstash Redis.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to delete',
},
},
request: {
url: (params) => `${params.restUrl}/del/${encodeURIComponent(params.key)}`,
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisDeleteParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to delete key from Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
deletedCount: data.result ?? 0,
},
}
},
outputs: {
key: { type: 'string', description: 'The key that was deleted' },
deletedCount: {
type: 'number',
description: 'Number of keys deleted (0 if key did not exist, 1 if deleted)',
},
},
}
+63
View File
@@ -0,0 +1,63 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisExistsParams, UpstashRedisExistsResponse } from '@/tools/upstash/types'
export const upstashRedisExistsTool: ToolConfig<
UpstashRedisExistsParams,
UpstashRedisExistsResponse
> = {
id: 'upstash_redis_exists',
name: 'Upstash Redis EXISTS',
description:
'Check if a key exists in Upstash Redis. Returns true if the key exists, false otherwise.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to check',
},
},
request: {
url: (params) => `${params.restUrl}/exists/${encodeURIComponent(params.key)}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisExistsParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to check key existence in Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
exists: data.result === 1,
},
}
},
outputs: {
key: { type: 'string', description: 'The key that was checked' },
exists: { type: 'boolean', description: 'Whether the key exists (true) or not (false)' },
},
}
+71
View File
@@ -0,0 +1,71 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisExpireParams, UpstashRedisExpireResponse } from '@/tools/upstash/types'
export const upstashRedisExpireTool: ToolConfig<
UpstashRedisExpireParams,
UpstashRedisExpireResponse
> = {
id: 'upstash_redis_expire',
name: 'Upstash Redis EXPIRE',
description: 'Set a timeout on a key in Upstash Redis. After the timeout, the key is deleted.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to set expiration on',
},
seconds: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'Timeout in seconds',
},
},
request: {
url: (params) => `${params.restUrl}/expire/${encodeURIComponent(params.key)}/${params.seconds}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisExpireParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to EXPIRE in Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
result: data.result ?? 0,
},
}
},
outputs: {
key: { type: 'string', description: 'The key that expiration was set on' },
result: {
type: 'number',
description: '1 if the timeout was set, 0 if the key does not exist',
},
},
}
+59
View File
@@ -0,0 +1,59 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisGetParams, UpstashRedisGetResponse } from '@/tools/upstash/types'
export const upstashRedisGetTool: ToolConfig<UpstashRedisGetParams, UpstashRedisGetResponse> = {
id: 'upstash_redis_get',
name: 'Upstash Redis Get',
description: 'Get the value of a key from Upstash Redis.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to retrieve',
},
},
request: {
url: (params) => `${params.restUrl}/get/${encodeURIComponent(params.key)}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisGetParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to get key from Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
value: data.result ?? null,
},
}
},
outputs: {
key: { type: 'string', description: 'The key that was retrieved' },
value: { type: 'json', description: 'The value of the key (string), or null if not found' },
},
}
+71
View File
@@ -0,0 +1,71 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisHGetParams, UpstashRedisHGetResponse } from '@/tools/upstash/types'
export const upstashRedisHGetTool: ToolConfig<UpstashRedisHGetParams, UpstashRedisHGetResponse> = {
id: 'upstash_redis_hget',
name: 'Upstash Redis HGET',
description: 'Get the value of a field in a hash stored at a key in Upstash Redis.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The hash key',
},
field: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The field name to retrieve',
},
},
request: {
url: (params) =>
`${params.restUrl}/hget/${encodeURIComponent(params.key)}/${encodeURIComponent(params.field)}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisHGetParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to HGET from Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
field: params?.field ?? '',
value: data.result ?? null,
},
}
},
outputs: {
key: { type: 'string', description: 'The hash key' },
field: { type: 'string', description: 'The field that was retrieved' },
value: {
type: 'json',
description: 'The value of the hash field (string), or null if not found',
},
},
}
+73
View File
@@ -0,0 +1,73 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisHGetAllParams, UpstashRedisHGetAllResponse } from '@/tools/upstash/types'
export const upstashRedisHGetAllTool: ToolConfig<
UpstashRedisHGetAllParams,
UpstashRedisHGetAllResponse
> = {
id: 'upstash_redis_hgetall',
name: 'Upstash Redis HGETALL',
description: 'Get all fields and values of a hash stored at a key in Upstash Redis.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The hash key',
},
},
request: {
url: (params) => `${params.restUrl}/hgetall/${encodeURIComponent(params.key)}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisHGetAllParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to HGETALL from Upstash Redis')
}
const result = data.result ?? []
const fields: Record<string, string> = {}
for (let i = 0; i < result.length; i += 2) {
fields[result[i]] = result[i + 1] ?? null
}
return {
success: true,
output: {
key: params?.key ?? '',
fields,
fieldCount: Object.keys(fields).length,
},
}
},
outputs: {
key: { type: 'string', description: 'The hash key' },
fields: {
type: 'object',
description: 'All field-value pairs in the hash, keyed by field name',
},
fieldCount: { type: 'number', description: 'Number of fields in the hash' },
},
}
+79
View File
@@ -0,0 +1,79 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisHSetParams, UpstashRedisHSetResponse } from '@/tools/upstash/types'
export const upstashRedisHSetTool: ToolConfig<UpstashRedisHSetParams, UpstashRedisHSetResponse> = {
id: 'upstash_redis_hset',
name: 'Upstash Redis HSET',
description: 'Set a field in a hash stored at a key in Upstash Redis.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The hash key',
},
field: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The field name within the hash',
},
value: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The value to store in the hash field',
},
},
request: {
url: (params) =>
`${params.restUrl}/hset/${encodeURIComponent(params.key)}/${encodeURIComponent(params.field)}`,
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
'Content-Type': 'text/plain',
}),
body: (params) => params.value,
},
transformResponse: async (response: Response, params?: UpstashRedisHSetParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to HSET in Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
field: params?.field ?? '',
result: data.result ?? 0,
},
}
},
outputs: {
key: { type: 'string', description: 'The hash key' },
field: { type: 'string', description: 'The field that was set' },
result: {
type: 'number',
description: 'Number of new fields added (0 if field was updated, 1 if new)',
},
},
}
+60
View File
@@ -0,0 +1,60 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisIncrParams, UpstashRedisIncrResponse } from '@/tools/upstash/types'
export const upstashRedisIncrTool: ToolConfig<UpstashRedisIncrParams, UpstashRedisIncrResponse> = {
id: 'upstash_redis_incr',
name: 'Upstash Redis INCR',
description:
'Atomically increment the integer value of a key by one in Upstash Redis. If the key does not exist, it is set to 0 before incrementing.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to increment',
},
},
request: {
url: (params) => `${params.restUrl}/incr/${encodeURIComponent(params.key)}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisIncrParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to INCR in Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
value: data.result ?? 0,
},
}
},
outputs: {
key: { type: 'string', description: 'The key that was incremented' },
value: { type: 'number', description: 'The new value after incrementing' },
},
}
+70
View File
@@ -0,0 +1,70 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisIncrbyParams, UpstashRedisIncrbyResponse } from '@/tools/upstash/types'
export const upstashRedisIncrbyTool: ToolConfig<
UpstashRedisIncrbyParams,
UpstashRedisIncrbyResponse
> = {
id: 'upstash_redis_incrby',
name: 'Upstash Redis INCRBY',
description:
'Increment the integer value of a key by a given amount. Use a negative value to decrement. If the key does not exist, it is set to 0 before the operation.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to increment',
},
increment: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'Amount to increment by (use negative value to decrement)',
},
},
request: {
url: (params) =>
`${params.restUrl}/incrby/${encodeURIComponent(params.key)}/${params.increment}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisIncrbyParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to INCRBY in Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
value: data.result ?? 0,
},
}
},
outputs: {
key: { type: 'string', description: 'The key that was incremented' },
value: { type: 'number', description: 'The new value after incrementing' },
},
}
+70
View File
@@ -0,0 +1,70 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisKeysParams, UpstashRedisKeysResponse } from '@/tools/upstash/types'
export const upstashRedisKeysTool: ToolConfig<UpstashRedisKeysParams, UpstashRedisKeysResponse> = {
id: 'upstash_redis_keys',
name: 'Upstash Redis Keys',
description: 'List keys matching a pattern in Upstash Redis. Defaults to listing all keys (*).',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
pattern: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Pattern to match keys (e.g., "user:*"). Defaults to "*" for all keys.',
},
},
request: {
url: (params) => {
const pattern = params.pattern || '*'
return `${params.restUrl}/keys/${encodeURIComponent(pattern)}`
},
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisKeysParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to list keys from Upstash Redis')
}
const keys = data.result ?? []
return {
success: true,
output: {
pattern: params?.pattern || '*',
keys,
count: keys.length,
},
}
},
outputs: {
pattern: { type: 'string', description: 'The pattern used to match keys' },
keys: {
type: 'array',
description: 'List of keys matching the pattern',
items: { type: 'string', description: 'A Redis key' },
},
count: { type: 'number', description: 'Number of keys found' },
},
}
+69
View File
@@ -0,0 +1,69 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisLPushParams, UpstashRedisLPushResponse } from '@/tools/upstash/types'
export const upstashRedisLPushTool: ToolConfig<UpstashRedisLPushParams, UpstashRedisLPushResponse> =
{
id: 'upstash_redis_lpush',
name: 'Upstash Redis LPUSH',
description:
'Prepend a value to the beginning of a list in Upstash Redis. Creates the list if it does not exist.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The list key',
},
value: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The value to prepend to the list',
},
},
request: {
url: (params) => `${params.restUrl}/lpush/${encodeURIComponent(params.key)}`,
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
'Content-Type': 'text/plain',
}),
body: (params) => params.value,
},
transformResponse: async (response: Response, params?: UpstashRedisLPushParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to LPUSH in Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
length: data.result ?? 0,
},
}
},
outputs: {
key: { type: 'string', description: 'The list key' },
length: { type: 'number', description: 'The length of the list after the push' },
},
}
+84
View File
@@ -0,0 +1,84 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisLRangeParams, UpstashRedisLRangeResponse } from '@/tools/upstash/types'
export const upstashRedisLRangeTool: ToolConfig<
UpstashRedisLRangeParams,
UpstashRedisLRangeResponse
> = {
id: 'upstash_redis_lrange',
name: 'Upstash Redis LRANGE',
description:
'Get a range of elements from a list in Upstash Redis. Use 0 and -1 for start and stop to get all elements.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The list key',
},
start: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'Start index (0-based, negative values count from end)',
},
stop: {
type: 'number',
required: true,
visibility: 'user-or-llm',
description: 'Stop index (inclusive, -1 for last element)',
},
},
request: {
url: (params) =>
`${params.restUrl}/lrange/${encodeURIComponent(params.key)}/${params.start}/${params.stop}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisLRangeParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to LRANGE from Upstash Redis')
}
const values = data.result ?? []
return {
success: true,
output: {
key: params?.key ?? '',
values,
count: values.length,
},
}
},
outputs: {
key: { type: 'string', description: 'The list key' },
values: {
type: 'array',
description: 'List of elements in the specified range',
items: { type: 'string', description: 'A list element' },
},
count: { type: 'number', description: 'Number of elements returned' },
},
}
+80
View File
@@ -0,0 +1,80 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisSetParams, UpstashRedisSetResponse } from '@/tools/upstash/types'
export const upstashRedisSetTool: ToolConfig<UpstashRedisSetParams, UpstashRedisSetResponse> = {
id: 'upstash_redis_set',
name: 'Upstash Redis Set',
description:
'Set the value of a key in Upstash Redis with an optional expiration time in seconds.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to set',
},
value: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The value to store',
},
ex: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Expiration time in seconds (optional)',
},
},
request: {
url: (params) => {
const base = `${params.restUrl}/set/${encodeURIComponent(params.key)}`
if (params.ex) {
return `${base}?EX=${params.ex}`
}
return base
},
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
'Content-Type': 'text/plain',
}),
body: (params) => params.value,
},
transformResponse: async (response: Response, params?: UpstashRedisSetParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to set key in Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
result: data.result ?? 'OK',
},
}
},
outputs: {
key: { type: 'string', description: 'The key that was set' },
result: { type: 'string', description: 'The result of the SET operation (typically "OK")' },
},
}
+72
View File
@@ -0,0 +1,72 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisSetnxParams, UpstashRedisSetnxResponse } from '@/tools/upstash/types'
export const upstashRedisSetnxTool: ToolConfig<UpstashRedisSetnxParams, UpstashRedisSetnxResponse> =
{
id: 'upstash_redis_setnx',
name: 'Upstash Redis SETNX',
description:
'Set the value of a key only if it does not already exist. Returns true if the key was set, false if it already existed.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to set',
},
value: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The value to store if the key does not exist',
},
},
request: {
url: (params) => `${params.restUrl}/setnx/${encodeURIComponent(params.key)}`,
method: 'POST',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
'Content-Type': 'text/plain',
}),
body: (params) => params.value,
},
transformResponse: async (response: Response, params?: UpstashRedisSetnxParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to SETNX in Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
wasSet: data.result === 1,
},
}
},
outputs: {
key: { type: 'string', description: 'The key that was attempted to set' },
wasSet: {
type: 'boolean',
description: 'Whether the key was set (true) or already existed (false)',
},
},
}
+64
View File
@@ -0,0 +1,64 @@
import type { ToolConfig } from '@/tools/types'
import type { UpstashRedisTtlParams, UpstashRedisTtlResponse } from '@/tools/upstash/types'
export const upstashRedisTtlTool: ToolConfig<UpstashRedisTtlParams, UpstashRedisTtlResponse> = {
id: 'upstash_redis_ttl',
name: 'Upstash Redis TTL',
description:
'Get the remaining time to live of a key in Upstash Redis. Returns -1 if the key has no expiration, -2 if the key does not exist.',
version: '1.0.0',
params: {
restUrl: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST URL',
},
restToken: {
type: 'string',
required: true,
visibility: 'user-only',
description: 'Upstash Redis REST Token',
},
key: {
type: 'string',
required: true,
visibility: 'user-or-llm',
description: 'The key to check TTL for',
},
},
request: {
url: (params) => `${params.restUrl}/ttl/${encodeURIComponent(params.key)}`,
method: 'GET',
headers: (params) => ({
Authorization: `Bearer ${params.restToken}`,
}),
},
transformResponse: async (response: Response, params?: UpstashRedisTtlParams) => {
const data = await response.json()
if (!response.ok) {
throw new Error(data.error || 'Failed to get TTL from Upstash Redis')
}
return {
success: true,
output: {
key: params?.key ?? '',
ttl: data.result ?? -2,
},
}
},
outputs: {
key: { type: 'string', description: 'The key checked' },
ttl: {
type: 'number',
description:
'Remaining TTL in seconds. Positive integer if the key has a TTL set, -1 if the key exists with no expiration, -2 if the key does not exist.',
},
},
}
+198
View File
@@ -0,0 +1,198 @@
import type { ToolResponse } from '@/tools/types'
interface UpstashRedisBaseParams {
restUrl: string
restToken: string
}
export interface UpstashRedisGetParams extends UpstashRedisBaseParams {
key: string
}
export interface UpstashRedisSetParams extends UpstashRedisBaseParams {
key: string
value: string
ex?: number
}
export interface UpstashRedisDeleteParams extends UpstashRedisBaseParams {
key: string
}
export interface UpstashRedisKeysParams extends UpstashRedisBaseParams {
pattern?: string
}
export interface UpstashRedisCommandParams extends UpstashRedisBaseParams {
command: string
}
export interface UpstashRedisHSetParams extends UpstashRedisBaseParams {
key: string
field: string
value: string
}
export interface UpstashRedisHGetParams extends UpstashRedisBaseParams {
key: string
field: string
}
export interface UpstashRedisHGetAllParams extends UpstashRedisBaseParams {
key: string
}
export interface UpstashRedisIncrParams extends UpstashRedisBaseParams {
key: string
}
export interface UpstashRedisExpireParams extends UpstashRedisBaseParams {
key: string
seconds: number
}
export interface UpstashRedisTtlParams extends UpstashRedisBaseParams {
key: string
}
export interface UpstashRedisLPushParams extends UpstashRedisBaseParams {
key: string
value: string
}
export interface UpstashRedisLRangeParams extends UpstashRedisBaseParams {
key: string
start: number
stop: number
}
export interface UpstashRedisGetResponse extends ToolResponse {
output: {
key: string
value: string | null
}
}
export interface UpstashRedisSetResponse extends ToolResponse {
output: {
key: string
result: string
}
}
export interface UpstashRedisDeleteResponse extends ToolResponse {
output: {
key: string
deletedCount: number
}
}
export interface UpstashRedisKeysResponse extends ToolResponse {
output: {
pattern: string
keys: string[]
count: number
}
}
export interface UpstashRedisCommandResponse extends ToolResponse {
output: {
command: string
result: unknown
}
}
export interface UpstashRedisHSetResponse extends ToolResponse {
output: {
key: string
field: string
result: number
}
}
export interface UpstashRedisHGetResponse extends ToolResponse {
output: {
key: string
field: string
value: string | null
}
}
export interface UpstashRedisHGetAllResponse extends ToolResponse {
output: {
key: string
fields: Record<string, string>
fieldCount: number
}
}
export interface UpstashRedisIncrResponse extends ToolResponse {
output: {
key: string
value: number
}
}
export interface UpstashRedisExpireResponse extends ToolResponse {
output: {
key: string
result: number
}
}
export interface UpstashRedisTtlResponse extends ToolResponse {
output: {
key: string
ttl: number
}
}
export interface UpstashRedisLPushResponse extends ToolResponse {
output: {
key: string
length: number
}
}
export interface UpstashRedisLRangeResponse extends ToolResponse {
output: {
key: string
values: string[]
count: number
}
}
export interface UpstashRedisExistsParams extends UpstashRedisBaseParams {
key: string
}
export interface UpstashRedisExistsResponse extends ToolResponse {
output: {
key: string
exists: boolean
}
}
export interface UpstashRedisSetnxParams extends UpstashRedisBaseParams {
key: string
value: string
}
export interface UpstashRedisSetnxResponse extends ToolResponse {
output: {
key: string
wasSet: boolean
}
}
export interface UpstashRedisIncrbyParams extends UpstashRedisBaseParams {
key: string
increment: number
}
export interface UpstashRedisIncrbyResponse extends ToolResponse {
output: {
key: string
value: number
}
}