Files
simstudioai--sim/apps/sim/tools/dagster/list_jobs.ts
T
wehub-resource-sync d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

105 lines
2.6 KiB
TypeScript

import type { DagsterBaseParams, DagsterListJobsResponse } from '@/tools/dagster/types'
import {
dagsterGraphqlUrl,
dagsterRequestHeaders,
dagsterUnionErrorMessage,
parseDagsterGraphqlResponse,
} from '@/tools/dagster/utils'
import type { ToolConfig } from '@/tools/types'
const LIST_JOBS_QUERY = `
query ListJobNames {
repositoriesOrError {
... on RepositoryConnection {
nodes {
name
jobs {
name
}
}
}
... on RepositoryNotFoundError {
__typename
message
}
... on PythonError {
__typename
message
}
}
}
`
export const listJobsTool: ToolConfig<DagsterBaseParams, DagsterListJobsResponse> = {
id: 'dagster_list_jobs',
name: 'Dagster List Jobs',
description: 'List all jobs across repositories in a Dagster instance.',
version: '1.0.0',
params: {
host: {
type: 'string',
required: true,
visibility: 'user-only',
description:
'Dagster host URL (e.g., https://myorg.dagster.cloud/prod or http://localhost:3001)',
},
apiKey: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Dagster+ API token (leave blank for OSS / self-hosted)',
},
},
request: {
url: (params) => dagsterGraphqlUrl(params.host),
method: 'POST',
headers: (params) => dagsterRequestHeaders(params),
body: () => ({
query: LIST_JOBS_QUERY,
variables: {},
}),
},
transformResponse: async (response: Response) => {
const data = await parseDagsterGraphqlResponse<{ repositoriesOrError?: unknown }>(response)
const result = data.data?.repositoriesOrError as
| { nodes?: Array<{ name: string; jobs?: Array<{ name: string }> }>; message?: string }
| undefined
if (!result) throw new Error('Unexpected response from Dagster')
if (!Array.isArray(result.nodes)) {
throw new Error(dagsterUnionErrorMessage(result, 'List jobs failed'))
}
const jobs: Array<{ name: string; repositoryName: string }> = []
for (const repo of result.nodes) {
for (const job of repo.jobs ?? []) {
jobs.push({
name: job.name,
repositoryName: repo.name,
})
}
}
return {
success: true,
output: { jobs },
}
},
outputs: {
jobs: {
type: 'json',
description: 'Array of jobs with name and repositoryName',
properties: {
name: { type: 'string', description: 'Job name' },
repositoryName: { type: 'string', description: 'Repository name' },
},
},
},
}