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
76 lines
2.7 KiB
TypeScript
76 lines
2.7 KiB
TypeScript
import {
|
|
normalizeWorkflowExecutorInput,
|
|
WORKFLOW_EXECUTOR_INPUT_PROVENANCE_KEY,
|
|
} from '@/lib/workflows/executor/input-secret-provenance'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
import type { WorkflowExecutorParams, WorkflowExecutorResponse } from '@/tools/workflow/types'
|
|
|
|
/**
|
|
* Tool for executing workflows as blocks within other workflows.
|
|
* This tool is used by the WorkflowBlockHandler to provide the execution capability.
|
|
*/
|
|
export const workflowExecutorTool: ToolConfig<
|
|
WorkflowExecutorParams,
|
|
WorkflowExecutorResponse['output']
|
|
> = {
|
|
id: 'workflow_executor',
|
|
name: 'Workflow Executor',
|
|
description:
|
|
'Execute another workflow as a sub-workflow. Pass inputs as a JSON object with field names matching the child workflow\'s input format. Example: if child expects "name" and "email", pass {"name": "John", "email": "john@example.com"}',
|
|
version: '1.0.0',
|
|
params: {
|
|
workflowId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'The ID of the workflow to execute',
|
|
},
|
|
inputMapping: {
|
|
type: 'object',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'JSON object with keys matching the child workflow\'s input field names. Each key should map to the value you want to pass for that input field. Example: {"fieldName": "value", "otherField": 123}',
|
|
},
|
|
},
|
|
request: {
|
|
url: (params: WorkflowExecutorParams) => `/api/workflows/${params.workflowId}/execute`,
|
|
method: 'POST',
|
|
headers: () => ({ 'Content-Type': 'application/json' }),
|
|
secretProvenance: {
|
|
request: (params) => [
|
|
{
|
|
key: WORKFLOW_EXECUTOR_INPUT_PROVENANCE_KEY,
|
|
inputPaths: [['inputMapping']],
|
|
},
|
|
],
|
|
response: { incomplete: 'reject' },
|
|
},
|
|
body: (params: WorkflowExecutorParams) => {
|
|
const inputData = normalizeWorkflowExecutorInput(params.inputMapping)
|
|
const isDeployedContext = params._context?.isDeployedContext
|
|
const parentWorkspaceId = params._context?.workspaceId
|
|
return {
|
|
input: inputData,
|
|
triggerType: 'workflow',
|
|
useDraftState: !isDeployedContext,
|
|
...(parentWorkspaceId ? { parentWorkspaceId } : {}),
|
|
}
|
|
},
|
|
},
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
const outputData = data?.output ?? {}
|
|
|
|
return {
|
|
success: data?.success ?? false,
|
|
duration: data?.metadata?.duration ?? 0,
|
|
childWorkflowId: data?.workflowId ?? '',
|
|
childWorkflowName: data?.workflowName ?? '',
|
|
output: outputData, // For OpenAI provider
|
|
result: outputData, // For backwards compatibility
|
|
error: data?.error,
|
|
}
|
|
},
|
|
}
|