Skip to content

Commit 3dcbfe2

Browse files
improvement(api): replace workflow jobs with execution resources
1 parent e1a8a24 commit 3dcbfe2

56 files changed

Lines changed: 1325 additions & 1427 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/docs/content/docs/de/api-reference/getting-started.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,27 +109,27 @@ curl -X POST https://www.sim.ai/api/workflows/{workflowId}/execute \
109109
-d '{"inputs": {}, "async": true}'
110110
```
111111

112-
This returns immediately with a `jobId` and `statusUrl`:
112+
This returns immediately with an `executionId` and `statusUrl`:
113113

114114
```json
115115
{
116116
"success": true,
117-
"jobId": "job_abc123",
118-
"statusUrl": "https://www.sim.ai/api/jobs/job_abc123",
119-
"message": "Workflow execution started",
117+
"executionId": "c7a92e15-3f4b-4d8c-a1e6-9b0d5f2c8e74",
118+
"statusUrl": "https://www.sim.ai/api/workflows/{workflowId}/executions/c7a92e15-3f4b-4d8c-a1e6-9b0d5f2c8e74",
119+
"message": "Workflow execution queued",
120120
"async": true
121121
}
122122
```
123123

124-
Poll the [Get Job Status](/api-reference/execution/getJobStatus) endpoint until the status is `completed` or `failed`:
124+
Poll the [Get Execution Status](/api-reference/execution/getWorkflowExecution) endpoint until the status is terminal:
125125

126126
```bash
127-
curl https://www.sim.ai/api/jobs/{jobId} \
127+
curl https://www.sim.ai/api/workflows/{workflowId}/executions/{executionId}?includeOutput=true \
128128
-H "X-API-Key: YOUR_API_KEY"
129129
```
130130

131131
<Callout type="info">
132-
Job status transitions follow: `queued``processing``completed` or `failed`. The `output` field is only present when status is `completed`.
132+
Execution status transitions follow: `queued``running``completed`, `failed`, `cancelled`, or `paused`. The `finalOutput` field is populated for completed executions when `includeOutput=true`.
133133
</Callout>
134134

135135
## Response Format

apps/docs/content/docs/de/api-reference/python.mdx

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -112,30 +112,34 @@ if is_ready:
112112

113113
**Rückgabe:** `bool`
114114

115-
##### get_job_status()
115+
##### get_workflow_execution()
116116

117-
Ruft den Status einer asynchronen Job-Ausführung ab.
117+
Get the status and optional outputs of a workflow execution.
118118

119119
```python
120-
status = client.get_job_status("task-id-from-async-execution")
121-
print("Status:", status["status"]) # 'queued', 'processing', 'completed', 'failed'
120+
status = client.get_workflow_execution("workflow-id", "execution-id", include_output=True)
121+
print("Status:", status["status"]) # 'queued', 'running', 'completed', 'failed'
122122
if status["status"] == "completed":
123-
print("Output:", status["output"])
123+
print("Output:", status["finalOutput"])
124124
```
125125

126-
**Parameter:**
127-
- `task_id` (str): Die Task-ID, die von der asynchronen Ausführung zurückgegeben wurde
126+
**Parameters:**
127+
- `workflow_id` (str): The workflow ID
128+
- `execution_id` (str): The execution ID returned from async execution
129+
- `include_output` (bool, optional): Include the final output for completed executions
130+
- `selected_outputs` (list[str], optional): Block output selectors to include
128131

129-
**Rückgabe:** `Dict[str, Any]`
132+
**Returns:** `Dict[str, Any]`
130133

131-
**Antwortfelder:**
132-
- `success` (bool): Ob die Anfrage erfolgreich war
133-
- `taskId` (str): Die Task-ID
134-
- `status` (str): Einer von `'queued'`, `'processing'`, `'completed'`, `'failed'`, `'cancelled'`
135-
- `metadata` (dict): Enthält `startedAt`, `completedAt` und `duration`
136-
- `output` (any, optional): Die Workflow-Ausgabe (wenn abgeschlossen)
137-
- `error` (any, optional): Fehlerdetails (wenn fehlgeschlagen)
138-
- `estimatedDuration` (int, optional): Geschätzte Dauer in Millisekunden (wenn in Bearbeitung/in Warteschlange)
134+
**Response fields:**
135+
- `executionId` (str): The execution ID
136+
- `workflowId` (str): The workflow ID
137+
- `status` (str): One of `'queued'`, `'pending'`, `'running'`, `'paused'`, `'completed'`, `'failed'`, `'cancelled'`
138+
- `startedAt` / `endedAt` (str): Execution timestamps
139+
- `totalDurationMs` (int, optional): Duration in milliseconds
140+
- `finalOutput` (any, optional): The workflow output when requested for a completed execution
141+
- `blockOutputs` (dict, optional): Requested block outputs
142+
- `error` (str, optional): Failure details
139143

140144
##### execute_with_retry()
141145

@@ -271,10 +275,10 @@ class WorkflowExecutionResult:
271275
@dataclass
272276
class AsyncExecutionResult:
273277
success: bool
274-
task_id: str
275-
status: str # 'queued'
276-
created_at: str
277-
links: Dict[str, str] # e.g., {"status": "/api/jobs/{taskId}"}
278+
execution_id: str
279+
status_url: str
280+
message: str = ""
281+
async_execution: bool = True
278282
```
279283

280284
### WorkflowStatus
@@ -489,27 +493,31 @@ def execute_async():
489493
# Start async execution
490494
result = client.execute_workflow(
491495
"workflow-id",
492-
input_data={"data": "large dataset"},
496+
input={"data": "large dataset"},
493497
async_execution=True # Execute asynchronously
494498
)
495499

496500
# Check if result is an async execution
497-
if hasattr(result, 'task_id'):
498-
print(f"Task ID: {result.task_id}")
499-
print(f"Status endpoint: {result.links['status']}")
501+
if hasattr(result, 'async_execution') and result.async_execution:
502+
print(f"Execution ID: {result.execution_id}")
503+
print(f"Status endpoint: {result.status_url}")
500504

501505
# Poll for completion
502-
status = client.get_job_status(result.task_id)
506+
status = client.get_workflow_execution(
507+
"workflow-id", result.execution_id, include_output=True
508+
)
503509

504-
while status["status"] in ["queued", "processing"]:
510+
while status["status"] in ["queued", "pending", "running"]:
505511
print(f"Current status: {status['status']}")
506512
time.sleep(2) # Wait 2 seconds
507-
status = client.get_job_status(result.task_id)
513+
status = client.get_workflow_execution(
514+
"workflow-id", result.execution_id, include_output=True
515+
)
508516

509517
if status["status"] == "completed":
510518
print("Workflow completed!")
511-
print(f"Output: {status['output']}")
512-
print(f"Duration: {status['metadata']['duration']}")
519+
print(f"Output: {status['finalOutput']}")
520+
print(f"Duration: {status['totalDurationMs']}")
513521
else:
514522
print(f"Workflow failed: {status['error']}")
515523

apps/docs/content/docs/de/api-reference/typescript.mdx

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -133,31 +133,37 @@ if (isReady) {
133133

134134
**Rückgabewert:** `Promise<boolean>`
135135

136-
##### getJobStatus()
136+
##### getWorkflowExecution()
137137

138-
Den Status einer asynchronen Job-Ausführung abrufen.
138+
Get the status and optional outputs of a workflow execution.
139139

140140
```typescript
141-
const status = await client.getJobStatus('task-id-from-async-execution');
142-
console.log('Status:', status.status); // 'queued', 'processing', 'completed', 'failed'
141+
const status = await client.getWorkflowExecution('workflow-id', 'execution-id', {
142+
includeOutput: true
143+
});
144+
console.log('Status:', status.status); // 'queued', 'running', 'completed', 'failed'
143145
if (status.status === 'completed') {
144-
console.log('Output:', status.output);
146+
console.log('Output:', status.finalOutput);
145147
}
146148
```
147149

148-
**Parameter:**
149-
- `taskId` (string): Die Task-ID, die von der asynchronen Ausführung zurückgegeben wurde
150+
**Parameters:**
151+
- `workflowId` (string): The workflow ID
152+
- `executionId` (string): The execution ID returned from async execution
153+
- `options.includeOutput` (boolean, optional): Include the final output for completed executions
154+
- `options.selectedOutputs` (string[], optional): Block output selectors to include
150155

151-
**Rückgabewert:** `Promise<JobStatus>`
156+
**Returns:** `Promise<WorkflowExecutionStatus>`
152157

153-
**Antwortfelder:**
154-
- `success` (boolean): Ob die Anfrage erfolgreich war
155-
- `taskId` (string): Die Task-ID
156-
- `status` (string): Einer der Werte `'queued'`, `'processing'`, `'completed'`, `'failed'`, `'cancelled'`
157-
- `metadata` (object): Enthält `startedAt`, `completedAt` und `duration`
158-
- `output` (any, optional): Die Workflow-Ausgabe (wenn abgeschlossen)
159-
- `error` (any, optional): Fehlerdetails (wenn fehlgeschlagen)
160-
- `estimatedDuration` (number, optional): Geschätzte Dauer in Millisekunden (wenn in Bearbeitung/in der Warteschlange)
158+
**Response fields:**
159+
- `executionId` (string): The execution ID
160+
- `workflowId` (string): The workflow ID
161+
- `status` (string): One of `'queued'`, `'pending'`, `'running'`, `'paused'`, `'completed'`, `'failed'`, `'cancelled'`
162+
- `startedAt` / `endedAt` (string): Execution timestamps
163+
- `totalDurationMs` (number, nullable): Duration in milliseconds
164+
- `finalOutput` (any, nullable): The workflow output when requested for a completed execution
165+
- `blockOutputs` (object, nullable): Requested block outputs
166+
- `error` (string, nullable): Failure details
161167

162168
##### executeWithRetry()
163169

@@ -286,12 +292,10 @@ interface WorkflowExecutionResult {
286292
```typescript
287293
interface AsyncExecutionResult {
288294
success: boolean;
289-
taskId: string;
290-
status: 'queued';
291-
createdAt: string;
292-
links: {
293-
status: string; // e.g., "/api/jobs/{taskId}"
294-
};
295+
executionId: string;
296+
statusUrl: string;
297+
message: string;
298+
async: true;
295299
}
296300
```
297301

@@ -791,29 +795,32 @@ const client = new SimStudioClient({
791795
async function executeAsync() {
792796
try {
793797
// Start async execution
794-
const result = await client.executeWorkflow('workflow-id', {
795-
input: { data: 'large dataset' },
798+
const result = await client.executeWorkflow('workflow-id', { data: 'large dataset' }, {
796799
async: true // Execute asynchronously
797800
});
798801

799802
// Check if result is an async execution
800-
if ('taskId' in result) {
801-
console.log('Task ID:', result.taskId);
802-
console.log('Status endpoint:', result.links.status);
803+
if ('async' in result && result.async) {
804+
console.log('Execution ID:', result.executionId);
805+
console.log('Status endpoint:', result.statusUrl);
803806

804807
// Poll for completion
805-
let status = await client.getJobStatus(result.taskId);
808+
let status = await client.getWorkflowExecution('workflow-id', result.executionId, {
809+
includeOutput: true
810+
});
806811

807-
while (status.status === 'queued' || status.status === 'processing') {
812+
while (status.status === 'queued' || status.status === 'pending' || status.status === 'running') {
808813
console.log('Current status:', status.status);
809814
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 2 seconds
810-
status = await client.getJobStatus(result.taskId);
815+
status = await client.getWorkflowExecution('workflow-id', result.executionId, {
816+
includeOutput: true
817+
});
811818
}
812819

813820
if (status.status === 'completed') {
814821
console.log('Workflow completed!');
815-
console.log('Output:', status.output);
816-
console.log('Duration:', status.metadata.duration);
822+
console.log('Output:', status.finalOutput);
823+
console.log('Duration:', status.totalDurationMs);
817824
} else {
818825
console.error('Workflow failed:', status.error);
819826
}

apps/docs/content/docs/de/sdks/python.mdx

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -112,30 +112,34 @@ if is_ready:
112112

113113
**Rückgabe:** `bool`
114114

115-
##### get_job_status()
115+
##### get_workflow_execution()
116116

117-
Ruft den Status einer asynchronen Job-Ausführung ab.
117+
Get the status and optional outputs of a workflow execution.
118118

119119
```python
120-
status = client.get_job_status("task-id-from-async-execution")
121-
print("Status:", status["status"]) # 'queued', 'processing', 'completed', 'failed'
120+
status = client.get_workflow_execution("workflow-id", "execution-id", include_output=True)
121+
print("Status:", status["status"]) # 'queued', 'running', 'completed', 'failed'
122122
if status["status"] == "completed":
123-
print("Output:", status["output"])
123+
print("Output:", status["finalOutput"])
124124
```
125125

126-
**Parameter:**
127-
- `task_id` (str): Die Task-ID, die von der asynchronen Ausführung zurückgegeben wurde
126+
**Parameters:**
127+
- `workflow_id` (str): The workflow ID
128+
- `execution_id` (str): The execution ID returned from async execution
129+
- `include_output` (bool, optional): Include the final output for completed executions
130+
- `selected_outputs` (list[str], optional): Block output selectors to include
128131

129-
**Rückgabe:** `Dict[str, Any]`
132+
**Returns:** `Dict[str, Any]`
130133

131-
**Antwortfelder:**
132-
- `success` (bool): Ob die Anfrage erfolgreich war
133-
- `taskId` (str): Die Task-ID
134-
- `status` (str): Einer von `'queued'`, `'processing'`, `'completed'`, `'failed'`, `'cancelled'`
135-
- `metadata` (dict): Enthält `startedAt`, `completedAt` und `duration`
136-
- `output` (any, optional): Die Workflow-Ausgabe (wenn abgeschlossen)
137-
- `error` (any, optional): Fehlerdetails (wenn fehlgeschlagen)
138-
- `estimatedDuration` (int, optional): Geschätzte Dauer in Millisekunden (wenn in Bearbeitung/in Warteschlange)
134+
**Response fields:**
135+
- `executionId` (str): The execution ID
136+
- `workflowId` (str): The workflow ID
137+
- `status` (str): One of `'queued'`, `'pending'`, `'running'`, `'paused'`, `'completed'`, `'failed'`, `'cancelled'`
138+
- `startedAt` / `endedAt` (str): Execution timestamps
139+
- `totalDurationMs` (int, optional): Duration in milliseconds
140+
- `finalOutput` (any, optional): The workflow output when requested for a completed execution
141+
- `blockOutputs` (dict, optional): Requested block outputs
142+
- `error` (str, optional): Failure details
139143

140144
##### execute_with_retry()
141145

@@ -271,10 +275,10 @@ class WorkflowExecutionResult:
271275
@dataclass
272276
class AsyncExecutionResult:
273277
success: bool
274-
task_id: str
275-
status: str # 'queued'
276-
created_at: str
277-
links: Dict[str, str] # e.g., {"status": "/api/jobs/{taskId}"}
278+
execution_id: str
279+
status_url: str
280+
message: str = ""
281+
async_execution: bool = True
278282
```
279283

280284
### WorkflowStatus
@@ -489,27 +493,31 @@ def execute_async():
489493
# Start async execution
490494
result = client.execute_workflow(
491495
"workflow-id",
492-
input_data={"data": "large dataset"},
496+
input={"data": "large dataset"},
493497
async_execution=True # Execute asynchronously
494498
)
495499

496500
# Check if result is an async execution
497-
if hasattr(result, 'task_id'):
498-
print(f"Task ID: {result.task_id}")
499-
print(f"Status endpoint: {result.links['status']}")
501+
if hasattr(result, 'async_execution') and result.async_execution:
502+
print(f"Execution ID: {result.execution_id}")
503+
print(f"Status endpoint: {result.status_url}")
500504

501505
# Poll for completion
502-
status = client.get_job_status(result.task_id)
506+
status = client.get_workflow_execution(
507+
"workflow-id", result.execution_id, include_output=True
508+
)
503509

504-
while status["status"] in ["queued", "processing"]:
510+
while status["status"] in ["queued", "pending", "running"]:
505511
print(f"Current status: {status['status']}")
506512
time.sleep(2) # Wait 2 seconds
507-
status = client.get_job_status(result.task_id)
513+
status = client.get_workflow_execution(
514+
"workflow-id", result.execution_id, include_output=True
515+
)
508516

509517
if status["status"] == "completed":
510518
print("Workflow completed!")
511-
print(f"Output: {status['output']}")
512-
print(f"Duration: {status['metadata']['duration']}")
519+
print(f"Output: {status['finalOutput']}")
520+
print(f"Duration: {status['totalDurationMs']}")
513521
else:
514522
print(f"Workflow failed: {status['error']}")
515523

0 commit comments

Comments
 (0)