6bf8bebf51
CI / Test and Build (push) Failing after 1s
CI / Migrate Dev DB (push) Has been skipped
CI / Migrate DB (push) Has been skipped
CodeQL / Analyze actions (push) Has been cancelled
CodeQL / Analyze javascript-typescript (push) Has been cancelled
CI / Detect Version (push) Has been cancelled
CI / Detect Desktop Changes (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/cron.Dockerfile, ubuntu-latest, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build AMD64 (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build AMD64 (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/cron.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/cron) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/db.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/pii.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-4vcpu-ubuntu-2404-arm, ./docker/realtime.Dockerfile, ubuntu-24.04-arm, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (blacksmith-8vcpu-ubuntu-2404-arm, ./docker/app.Dockerfile, linux-arm64-8-core, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
Helm Chart / Lint, test, and validate chart (push) Has been cancelled
Helm Chart / Chart version bumped (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Build Dev ECR (blacksmith-8vcpu-ubuntu-2404, ./docker/app.Dockerfile, ECR_APP, linux-x64-8-core) (push) Has been cancelled
CI / Promote Images (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/cron) (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 / Build Dev ECR (blacksmith-2vcpu-ubuntu-2404, ./docker/db.Dockerfile, ECR_MIGRATIONS, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/pii.Dockerfile, ECR_PII, ubuntu-latest) (push) Has been cancelled
CI / Build Dev ECR (blacksmith-4vcpu-ubuntu-2404, ./docker/realtime.Dockerfile, ECR_REALTIME, ubuntu-latest) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Check Desktop Signing Secrets (push) Has been cancelled
CI / Desktop Release (push) Has been cancelled
CI / Create Desktop Prerelease (push) Has been cancelled
CI / Desktop Prerelease Build (push) Has been cancelled
CI / Publish Desktop Prerelease (push) Has been cancelled
CI / Prune Desktop Prereleases (push) Has been cancelled
Helm Chart / Install on kind and run helm test (push) Has been cancelled
142 lines
4.6 KiB
TypeScript
142 lines
4.6 KiB
TypeScript
import type { HexRunProjectParams, HexRunProjectResponse } from '@/tools/hex/types'
|
|
import { HEX_RUN_OUTPUT_PROPERTIES } from '@/tools/hex/types'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const runProjectTool: ToolConfig<HexRunProjectParams, HexRunProjectResponse> = {
|
|
id: 'hex_run_project',
|
|
name: 'Hex Run Project',
|
|
description:
|
|
'Execute a published Hex project. Optionally pass input parameters and control caching behavior.',
|
|
version: '1.0.0',
|
|
|
|
params: {
|
|
apiKey: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Hex API token (Personal or Workspace)',
|
|
},
|
|
projectId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'The UUID of the Hex project to run',
|
|
},
|
|
inputParams: {
|
|
type: 'json',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'JSON object of input parameters for the project (e.g., {"date": "2024-01-01"})',
|
|
},
|
|
dryRun: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'If true, perform a dry run without executing the project',
|
|
},
|
|
updateCache: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: '(Deprecated) If true, update the cached results after execution',
|
|
},
|
|
updatePublishedResults: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'If true, update the published app results after execution',
|
|
},
|
|
useCachedSqlResults: {
|
|
type: 'boolean',
|
|
required: false,
|
|
visibility: 'user-only',
|
|
description: 'If true, use cached SQL results instead of re-running queries',
|
|
},
|
|
viewId: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Optional SavedView ID to use for the project run',
|
|
},
|
|
notifications: {
|
|
type: 'json',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'JSON array of notification details to deliver once the run completes (e.g., [{"type": "FAILURE", "slackChannelIds": ["C0123456789"], "userIds": [], "groupIds": [], "includeSuccessScreenshot": false}]). type is ALL, SUCCESS, or FAILURE.',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params) => `https://app.hex.tech/api/v1/projects/${params.projectId.trim()}/runs`,
|
|
method: 'POST',
|
|
headers: (params) => ({
|
|
Authorization: `Bearer ${params.apiKey}`,
|
|
'Content-Type': 'application/json',
|
|
}),
|
|
body: (params) => {
|
|
const body: Record<string, unknown> = {}
|
|
|
|
if (params.inputParams) {
|
|
try {
|
|
body.inputParams =
|
|
typeof params.inputParams === 'string'
|
|
? JSON.parse(params.inputParams)
|
|
: params.inputParams
|
|
} catch {
|
|
throw new Error('inputParams must be valid JSON')
|
|
}
|
|
}
|
|
if (params.dryRun !== undefined) body.dryRun = params.dryRun
|
|
if (params.updateCache !== undefined) body.updateCache = params.updateCache
|
|
if (params.updatePublishedResults !== undefined)
|
|
body.updatePublishedResults = params.updatePublishedResults
|
|
if (params.useCachedSqlResults !== undefined)
|
|
body.useCachedSqlResults = params.useCachedSqlResults
|
|
if (params.viewId) body.viewId = params.viewId.trim()
|
|
if (params.notifications) {
|
|
let notifications: unknown
|
|
try {
|
|
notifications =
|
|
typeof params.notifications === 'string'
|
|
? JSON.parse(params.notifications)
|
|
: params.notifications
|
|
} catch {
|
|
throw new Error('notifications must be a valid JSON array')
|
|
}
|
|
if (!Array.isArray(notifications)) {
|
|
throw new Error('notifications must be a valid JSON array')
|
|
}
|
|
body.notifications = notifications
|
|
}
|
|
|
|
return body
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
projectId: data.projectId ?? null,
|
|
runId: data.runId ?? null,
|
|
runUrl: data.runUrl ?? null,
|
|
runStatusUrl: data.runStatusUrl ?? null,
|
|
traceId: data.traceId ?? null,
|
|
projectVersion: data.projectVersion ?? null,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
projectId: HEX_RUN_OUTPUT_PROPERTIES.projectId,
|
|
runId: HEX_RUN_OUTPUT_PROPERTIES.runId,
|
|
runUrl: HEX_RUN_OUTPUT_PROPERTIES.runUrl,
|
|
runStatusUrl: HEX_RUN_OUTPUT_PROPERTIES.runStatusUrl,
|
|
traceId: HEX_RUN_OUTPUT_PROPERTIES.traceId,
|
|
projectVersion: HEX_RUN_OUTPUT_PROPERTIES.projectVersion,
|
|
},
|
|
}
|