Skip to content

Commit 3313651

Browse files
fix(api): preserve legacy jobs while preferring v2 executions
1 parent df16670 commit 3313651

51 files changed

Lines changed: 1721 additions & 1141 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 an `executionId` and `statusUrl`:
112+
This returns immediately with a `jobId` and `statusUrl`:
113113

114114
```json
115115
{
116116
"success": true,
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",
117+
"jobId": "job_abc123",
118+
"statusUrl": "https://www.sim.ai/api/jobs/job_abc123",
119+
"message": "Workflow execution started",
120120
"async": true
121121
}
122122
```
123123

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

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

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

135135
## Response Format

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

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

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

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

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

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

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
126+
**Parameter:**
127+
- `task_id` (str): Die Task-ID, die von der asynchronen Ausführung zurückgegeben wurde
131128

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

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
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)
143139

144140
##### execute_with_retry()
145141

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

284280
### WorkflowStatus
@@ -493,31 +489,27 @@ def execute_async():
493489
# Start async execution
494490
result = client.execute_workflow(
495491
"workflow-id",
496-
input={"data": "large dataset"},
492+
input_data={"data": "large dataset"},
497493
async_execution=True # Execute asynchronously
498494
)
499495

500496
# Check if result is an async execution
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}")
497+
if hasattr(result, 'task_id'):
498+
print(f"Task ID: {result.task_id}")
499+
print(f"Status endpoint: {result.links['status']}")
504500

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

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

517509
if status["status"] == "completed":
518510
print("Workflow completed!")
519-
print(f"Output: {status['finalOutput']}")
520-
print(f"Duration: {status['totalDurationMs']}")
511+
print(f"Output: {status['output']}")
512+
print(f"Duration: {status['metadata']['duration']}")
521513
else:
522514
print(f"Workflow failed: {status['error']}")
523515

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

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

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

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

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

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

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
148+
**Parameter:**
149+
- `taskId` (string): Die Task-ID, die von der asynchronen Ausführung zurückgegeben wurde
155150

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

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
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)
167161

168162
##### executeWithRetry()
169163

@@ -292,10 +286,12 @@ interface WorkflowExecutionResult {
292286
```typescript
293287
interface AsyncExecutionResult {
294288
success: boolean;
295-
executionId: string;
296-
statusUrl: string;
297-
message: string;
298-
async: true;
289+
taskId: string;
290+
status: 'queued';
291+
createdAt: string;
292+
links: {
293+
status: string; // e.g., "/api/jobs/{taskId}"
294+
};
299295
}
300296
```
301297

@@ -795,32 +791,29 @@ const client = new SimStudioClient({
795791
async function executeAsync() {
796792
try {
797793
// Start async execution
798-
const result = await client.executeWorkflow('workflow-id', { data: 'large dataset' }, {
794+
const result = await client.executeWorkflow('workflow-id', {
795+
input: { data: 'large dataset' },
799796
async: true // Execute asynchronously
800797
});
801798

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

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

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

820813
if (status.status === 'completed') {
821814
console.log('Workflow completed!');
822-
console.log('Output:', status.finalOutput);
823-
console.log('Duration:', status.totalDurationMs);
815+
console.log('Output:', status.output);
816+
console.log('Duration:', status.metadata.duration);
824817
} else {
825818
console.error('Workflow failed:', status.error);
826819
}

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

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

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

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

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

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

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
126+
**Parameter:**
127+
- `task_id` (str): Die Task-ID, die von der asynchronen Ausführung zurückgegeben wurde
131128

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

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
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)
143139

144140
##### execute_with_retry()
145141

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

284280
### WorkflowStatus
@@ -493,31 +489,27 @@ def execute_async():
493489
# Start async execution
494490
result = client.execute_workflow(
495491
"workflow-id",
496-
input={"data": "large dataset"},
492+
input_data={"data": "large dataset"},
497493
async_execution=True # Execute asynchronously
498494
)
499495

500496
# Check if result is an async execution
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}")
497+
if hasattr(result, 'task_id'):
498+
print(f"Task ID: {result.task_id}")
499+
print(f"Status endpoint: {result.links['status']}")
504500

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

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

517509
if status["status"] == "completed":
518510
print("Workflow completed!")
519-
print(f"Output: {status['finalOutput']}")
520-
print(f"Duration: {status['totalDurationMs']}")
511+
print(f"Output: {status['output']}")
512+
print(f"Duration: {status['metadata']['duration']}")
521513
else:
522514
print(f"Workflow failed: {status['error']}")
523515

0 commit comments

Comments
 (0)