Fern: add TypeScript code examples (#3839)

This commit is contained in:
Stanislav Novosad
2025-10-28 17:43:19 -06:00
committed by GitHub
parent 47899085cf
commit d1008959b0
5 changed files with 549 additions and 85 deletions

View File

@@ -22,18 +22,28 @@ from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType
from skyvern.forge.sdk.executor.factory import AsyncExecutorFactory from skyvern.forge.sdk.executor.factory import AsyncExecutorFactory
from skyvern.forge.sdk.models import Step from skyvern.forge.sdk.models import Step
from skyvern.forge.sdk.routes.code_samples import ( from skyvern.forge.sdk.routes.code_samples import (
CANCEL_RUN_CODE_SAMPLE, CANCEL_RUN_CODE_SAMPLE_PYTHON,
CREATE_WORKFLOW_CODE_SAMPLE, CANCEL_RUN_CODE_SAMPLE_TS,
CREATE_WORKFLOW_CODE_SAMPLE_CURL,
CREATE_WORKFLOW_CODE_SAMPLE_PYTHON, CREATE_WORKFLOW_CODE_SAMPLE_PYTHON,
DELETE_WORKFLOW_CODE_SAMPLE, CREATE_WORKFLOW_CODE_SAMPLE_TS,
GET_RUN_CODE_SAMPLE, DELETE_WORKFLOW_CODE_SAMPLE_PYTHON,
GET_RUN_TIMELINE_CODE_SAMPLE, DELETE_WORKFLOW_CODE_SAMPLE_TS,
GET_WORKFLOWS_CODE_SAMPLE, GET_RUN_CODE_SAMPLE_PYTHON,
RETRY_RUN_WEBHOOK_CODE_SAMPLE, GET_RUN_CODE_SAMPLE_TS,
RUN_TASK_CODE_SAMPLE, GET_RUN_TIMELINE_CODE_SAMPLE_PYTHON,
RUN_WORKFLOW_CODE_SAMPLE, GET_RUN_TIMELINE_CODE_SAMPLE_TS,
UPDATE_WORKFLOW_CODE_SAMPLE, GET_WORKFLOWS_CODE_SAMPLE_PYTHON,
GET_WORKFLOWS_CODE_SAMPLE_TS,
RETRY_RUN_WEBHOOK_CODE_SAMPLE_PYTHON,
RETRY_RUN_WEBHOOK_CODE_SAMPLE_TS,
RUN_TASK_CODE_SAMPLE_PYTHON,
RUN_TASK_CODE_SAMPLE_TS,
RUN_WORKFLOW_CODE_SAMPLE_PYTHON,
RUN_WORKFLOW_CODE_SAMPLE_TS,
UPDATE_WORKFLOW_CODE_SAMPLE_CURL,
UPDATE_WORKFLOW_CODE_SAMPLE_PYTHON, UPDATE_WORKFLOW_CODE_SAMPLE_PYTHON,
UPDATE_WORKFLOW_CODE_SAMPLE_TS,
) )
from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router, legacy_v2_router from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router, legacy_v2_router
from skyvern.forge.sdk.schemas.ai_suggestions import AISuggestionBase, AISuggestionRequest from skyvern.forge.sdk.schemas.ai_suggestions import AISuggestionBase, AISuggestionRequest
@@ -106,10 +116,8 @@ class AISuggestionType(str, Enum):
"x-fern-examples": [ "x-fern-examples": [
{ {
"code-samples": [ "code-samples": [
{ {"sdk": "python", "code": RUN_TASK_CODE_SAMPLE_PYTHON},
"sdk": "python", {"sdk": "typescript", "code": RUN_TASK_CODE_SAMPLE_TS},
"code": RUN_TASK_CODE_SAMPLE,
}
] ]
} }
], ],
@@ -287,10 +295,8 @@ async def run_task(
"x-fern-examples": [ "x-fern-examples": [
{ {
"code-samples": [ "code-samples": [
{ {"sdk": "python", "code": RUN_WORKFLOW_CODE_SAMPLE_PYTHON},
"sdk": "python", {"sdk": "typescript", "code": RUN_WORKFLOW_CODE_SAMPLE_TS},
"code": RUN_WORKFLOW_CODE_SAMPLE,
}
] ]
} }
], ],
@@ -375,7 +381,14 @@ async def run_workflow(
summary="Get a run by id", summary="Get a run by id",
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "get_run", "x-fern-sdk-method-name": "get_run",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": GET_RUN_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": GET_RUN_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": GET_RUN_CODE_SAMPLE_TS},
]
}
],
}, },
responses={ responses={
200: {"description": "Successfully got run"}, 200: {"description": "Successfully got run"},
@@ -407,7 +420,14 @@ async def get_run(
tags=["Agent", "Workflows"], tags=["Agent", "Workflows"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "cancel_run", "x-fern-sdk-method-name": "cancel_run",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": CANCEL_RUN_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": CANCEL_RUN_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": CANCEL_RUN_CODE_SAMPLE_TS},
]
}
],
}, },
description="Cancel a run (task or workflow)", description="Cancel a run (task or workflow)",
summary="Cancel a run by id", summary="Cancel a run by id",
@@ -478,8 +498,9 @@ async def create_workflow_legacy(
"x-fern-examples": [ "x-fern-examples": [
{ {
"code-samples": [ "code-samples": [
{"sdk": "curl", "code": CREATE_WORKFLOW_CODE_SAMPLE}, {"sdk": "curl", "code": CREATE_WORKFLOW_CODE_SAMPLE_CURL},
{"sdk": "python", "code": CREATE_WORKFLOW_CODE_SAMPLE_PYTHON}, {"sdk": "python", "code": CREATE_WORKFLOW_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": CREATE_WORKFLOW_CODE_SAMPLE_TS},
] ]
} }
], ],
@@ -695,8 +716,9 @@ async def update_workflow_legacy(
"x-fern-examples": [ "x-fern-examples": [
{ {
"code-samples": [ "code-samples": [
{"sdk": "curl", "code": UPDATE_WORKFLOW_CODE_SAMPLE}, {"sdk": "curl", "code": UPDATE_WORKFLOW_CODE_SAMPLE_CURL},
{"sdk": "python", "code": UPDATE_WORKFLOW_CODE_SAMPLE_PYTHON}, {"sdk": "python", "code": UPDATE_WORKFLOW_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": UPDATE_WORKFLOW_CODE_SAMPLE_TS},
] ]
} }
], ],
@@ -770,7 +792,14 @@ async def update_workflow(
tags=["Workflows"], tags=["Workflows"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "delete_workflow", "x-fern-sdk-method-name": "delete_workflow",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": DELETE_WORKFLOW_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": DELETE_WORKFLOW_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": DELETE_WORKFLOW_CODE_SAMPLE_TS},
]
}
],
}, },
description="Delete a workflow", description="Delete a workflow",
summary="Delete a workflow", summary="Delete a workflow",
@@ -935,7 +964,14 @@ async def get_run_artifacts(
tags=["Agent"], tags=["Agent"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "retry_run_webhook", "x-fern-sdk-method-name": "retry_run_webhook",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": RETRY_RUN_WEBHOOK_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": RETRY_RUN_WEBHOOK_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": RETRY_RUN_WEBHOOK_CODE_SAMPLE_TS},
]
}
],
}, },
description="Retry sending the webhook for a run", description="Retry sending the webhook for a run",
summary="Retry run webhook", summary="Retry run webhook",
@@ -956,7 +992,14 @@ async def retry_run_webhook(
response_model=list[WorkflowRunTimeline], response_model=list[WorkflowRunTimeline],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "get_run_timeline", "x-fern-sdk-method-name": "get_run_timeline",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": GET_RUN_TIMELINE_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": GET_RUN_TIMELINE_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": GET_RUN_TIMELINE_CODE_SAMPLE_TS},
]
}
],
}, },
description="Get timeline for a run (workflow run or task_v2 run)", description="Get timeline for a run (workflow run or task_v2 run)",
summary="Get run timeline", summary="Get run timeline",
@@ -1828,7 +1871,14 @@ async def get_workflow_run(
tags=["Workflows"], tags=["Workflows"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "get_workflows", "x-fern-sdk-method-name": "get_workflows",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": GET_WORKFLOWS_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": GET_WORKFLOWS_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": GET_WORKFLOWS_CODE_SAMPLE_TS},
]
}
],
}, },
) )
@base_router.get("/workflows/", response_model=list[Workflow], include_in_schema=False) @base_router.get("/workflows/", response_model=list[Workflow], include_in_schema=False)

View File

@@ -6,10 +6,14 @@ from fastapi.responses import ORJSONResponse
from skyvern import analytics from skyvern import analytics
from skyvern.forge import app from skyvern.forge import app
from skyvern.forge.sdk.routes.code_samples import ( from skyvern.forge.sdk.routes.code_samples import (
CLOSE_BROWSER_SESSION_CODE_SAMPLE, CLOSE_BROWSER_SESSION_CODE_SAMPLE_PYTHON,
CREATE_BROWSER_SESSION_CODE_SAMPLE, CLOSE_BROWSER_SESSION_CODE_SAMPLE_TS,
GET_BROWSER_SESSION_CODE_SAMPLE, CREATE_BROWSER_SESSION_CODE_SAMPLE_PYTHON,
GET_BROWSER_SESSIONS_CODE_SAMPLE, CREATE_BROWSER_SESSION_CODE_SAMPLE_TS,
GET_BROWSER_SESSION_CODE_SAMPLE_PYTHON,
GET_BROWSER_SESSION_CODE_SAMPLE_TS,
GET_BROWSER_SESSIONS_CODE_SAMPLE_PYTHON,
GET_BROWSER_SESSIONS_CODE_SAMPLE_TS,
) )
from skyvern.forge.sdk.routes.routers import base_router from skyvern.forge.sdk.routes.routers import base_router
from skyvern.forge.sdk.schemas.organizations import Organization from skyvern.forge.sdk.schemas.organizations import Organization
@@ -56,7 +60,14 @@ async def get_browser_sessions_all(
tags=["Browser Sessions"], tags=["Browser Sessions"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "create_browser_session", "x-fern-sdk-method-name": "create_browser_session",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": CREATE_BROWSER_SESSION_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": CREATE_BROWSER_SESSION_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": CREATE_BROWSER_SESSION_CODE_SAMPLE_TS},
]
}
],
}, },
description="Create a browser session that persists across multiple runs", description="Create a browser session that persists across multiple runs",
summary="Create a session", summary="Create a session",
@@ -87,7 +98,14 @@ async def create_browser_session(
tags=["Browser Sessions"], tags=["Browser Sessions"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "close_browser_session", "x-fern-sdk-method-name": "close_browser_session",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": CLOSE_BROWSER_SESSION_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": CLOSE_BROWSER_SESSION_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": CLOSE_BROWSER_SESSION_CODE_SAMPLE_TS},
]
}
],
}, },
description="Close a session. Once closed, the session cannot be used again.", description="Close a session. Once closed, the session cannot be used again.",
summary="Close a session", summary="Close a session",
@@ -122,7 +140,14 @@ async def close_browser_session(
tags=["Browser Sessions"], tags=["Browser Sessions"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "get_browser_session", "x-fern-sdk-method-name": "get_browser_session",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": GET_BROWSER_SESSION_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": GET_BROWSER_SESSION_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": GET_BROWSER_SESSION_CODE_SAMPLE_TS},
]
}
],
}, },
description="Get details about a specific browser session, including the browser address for cdp connection.", description="Get details about a specific browser session, including the browser address for cdp connection.",
summary="Get a session", summary="Get a session",
@@ -159,7 +184,14 @@ async def get_browser_session(
tags=["Browser Sessions"], tags=["Browser Sessions"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "get_browser_sessions", "x-fern-sdk-method-name": "get_browser_sessions",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": GET_BROWSER_SESSIONS_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": GET_BROWSER_SESSIONS_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": GET_BROWSER_SESSIONS_CODE_SAMPLE_TS},
]
}
],
}, },
description="Get all active browser sessions for the organization", description="Get all active browser sessions for the organization",
summary="Get active browser sessions", summary="Get active browser sessions",

View File

@@ -1,31 +1,66 @@
# Agent # Agent
RUN_TASK_CODE_SAMPLE = """from skyvern import Skyvern RUN_TASK_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.run_task(prompt="What's the top post on hackernews?") await skyvern.run_task(prompt="What's the top post on hackernews?")
""" """
RUN_WORKFLOW_CODE_SAMPLE = """from skyvern import Skyvern RUN_TASK_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.runTask({
body: {
prompt: "Find the top 3 posts on Hacker News."
}
})
"""
RUN_WORKFLOW_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.run_workflow(workflow_id="wpid_123", parameters={"parameter1": "value1", "parameter2": "value2"}) await skyvern.run_workflow(workflow_id="wpid_123", parameters={"parameter1": "value1", "parameter2": "value2"})
""" """
GET_RUN_CODE_SAMPLE = """from skyvern import Skyvern RUN_WORKFLOW_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.runWorkflow({
body: {
workflow_id: "wpid_123",
parameters: { parameter1: "value1", parameter2: "value2" }
}
});
"""
GET_RUN_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
run = await skyvern.get_run(run_id="tsk_v2_123") run = await skyvern.get_run(run_id="tsk_v2_123")
print(run) print(run)
""" """
CANCEL_RUN_CODE_SAMPLE = """from skyvern import Skyvern GET_RUN_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
const run = await skyvern.getRun("tsk_v2_123");
console.log(run);
"""
CANCEL_RUN_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.cancel_run(run_id="tsk_v2_123") await skyvern.cancel_run(run_id="tsk_v2_123")
""" """
RETRY_RUN_WEBHOOK_CODE_SAMPLE = """from skyvern import Skyvern CANCEL_RUN_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.cancelRun("tsk_v2_123");
"""
RETRY_RUN_WEBHOOK_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.retry_run_webhook(run_id="tsk_v2_123") await skyvern.retry_run_webhook(run_id="tsk_v2_123")
""" """
GET_RUN_TIMELINE_CODE_SAMPLE = """from skyvern import Skyvern RETRY_RUN_WEBHOOK_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.retryRunWebhook("tsk_v2_123");
"""
GET_RUN_TIMELINE_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
# Get timeline for a workflow run # Get timeline for a workflow run
@@ -36,7 +71,18 @@ print(timeline)
timeline = await skyvern.get_run_timeline(run_id="tsk_v2_123") timeline = await skyvern.get_run_timeline(run_id="tsk_v2_123")
print(timeline) print(timeline)
""" """
LOGIN_CODE_SAMPLE_SKYVERN = """# Login with password saved in Skyvern GET_RUN_TIMELINE_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
// Get timeline for a workflow run
const timeline = await skyvern.getRunTimeline("wr_123");
console.log(timeline);
// Get timeline for a task_v2 run
const timeline2 = await skyvern.getRunTimeline("tsk_v2_123");
console.log(timeline2);
"""
LOGIN_CODE_SAMPLE_SKYVERN_PYTHON = """# Login with password saved in Skyvern
from skyvern import Skyvern from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
@@ -46,7 +92,17 @@ await skyvern.login(
credential_id="cred_123"), credential_id="cred_123"),
) )
""" """
LOGIN_CODE_SAMPLE_BITWARDEN = """# Login with password saved in Bitwarden LOGIN_CODE_SAMPLE_SKYVERN_TS = """// Login with password saved in Skyvern
import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.login({
url: "https://example.com",
credential_type: "skyvern",
credential_id: "cred_123"
});
"""
LOGIN_CODE_SAMPLE_BITWARDEN_PYTHON = """# Login with password saved in Bitwarden
from skyvern import Skyvern from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
@@ -64,7 +120,25 @@ await skyvern.login(
bitwarden_item_id="BITWARDEN ITEM ID", bitwarden_item_id="BITWARDEN ITEM ID",
) )
""" """
LOGIN_CODE_SAMPLE_ONEPASSWORD = """# Login with password saved in 1Password LOGIN_CODE_SAMPLE_BITWARDEN_TS = """// Login with password saved in Bitwarden
import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
// Login with a Bitwarden collection and website url filter
await skyvern.login({
url: "https://example.com",
credential_type: "bitwarden",
bitwarden_collection_id: "BITWARDEN COLLECTION ID"
});
// Login with a Bitwarden item
await skyvern.login({
url: "https://example.com",
credential_type: "bitwarden",
bitwarden_item_id: "BITWARDEN ITEM ID"
});
"""
LOGIN_CODE_SAMPLE_ONEPASSWORD_PYTHON = """# Login with password saved in 1Password
from skyvern import Skyvern from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
@@ -75,9 +149,20 @@ await skyvern.login(
onepassword_item_id="1PASSWORD ITEM ID", onepassword_item_id="1PASSWORD ITEM ID",
) )
""" """
LOGIN_CODE_SAMPLE_ONEPASSWORD_TS = """// Login with password saved in 1Password
import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.login({
url: "https://example.com",
credential_type: "onepassword",
onepassword_vault_id: "1PASSWORD VAULT ID",
onepassword_item_id: "1PASSWORD ITEM ID"
});
"""
# Workflows # Workflows
CREATE_WORKFLOW_CODE_SAMPLE = """curl -X POST https://api.skyvern.com/v1/workflows \ CREATE_WORKFLOW_CODE_SAMPLE_CURL = """curl -X POST https://api.skyvern.com/v1/workflows \
--header 'x-api-key: {{x-api-key}}' \ --header 'x-api-key: {{x-api-key}}' \
--header 'Content-Type: text/plain' \ --header 'Content-Type: text/plain' \
--data-raw 'title: Contact Forms --data-raw 'title: Contact Forms
@@ -245,7 +330,95 @@ skyvern = Skyvern(api_key="YOUR_API_KEY")
workflow = await skyvern.create_workflow(json_definition=workflow_definition) workflow = await skyvern.create_workflow(json_definition=workflow_definition)
print(workflow) print(workflow)
""" """
UPDATE_WORKFLOW_CODE_SAMPLE = """curl -X POST https://api.skyvern.com/v1/workflows/wpid_123 \ CREATE_WORKFLOW_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
// Create a workflow in JSON format
const workflowDefinition = {
title: "Contact Forms Workflow",
description: "Fill the contact form on the website",
proxy_location: "RESIDENTIAL",
webhook_callback_url: "https://example.com/webhook",
totp_verification_url: "https://example.com/totp",
totp_identifier: "4155555555",
model: { name: "gpt-4.1" },
workflow_definition: {
parameters: [
{
key: "website_url",
description: null,
parameter_type: "workflow",
workflow_parameter_type: "string",
default_value: null
},
{
key: "name",
description: null,
parameter_type: "workflow",
workflow_parameter_type: "string",
default_value: null
},
{
key: "additional_information",
description: null,
parameter_type: "workflow",
workflow_parameter_type: "string",
default_value: "Message: I'd love to learn more about your...\\nPhone: 123-456-7890\\nInquiry type: sales\\nOptional Subject: Hello from [Company Here]"
},
{
key: "email",
description: null,
parameter_type: "workflow",
workflow_parameter_type: "string",
default_value: null
}
],
blocks: [
{
label: "Fill_Out_Contact_Form",
continue_on_failure: true,
block_type: "navigation",
url: "{{website_url}}",
title: "Fill_Out_Contact_Form",
engine: "skyvern-1.0",
navigation_goal: "Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\\n\\nFill out required fields as best you can using the following information:\\n{{name}}\\n{{email}}\\n{{additional_information}}",
error_code_mapping: null,
max_retries: 0,
max_steps_per_run: null,
complete_on_download: false,
download_suffix: null,
parameter_keys: [],
totp_identifier: null,
totp_verification_url: null,
cache_actions: false,
complete_criterion: "",
terminate_criterion: "",
include_action_history_in_verification: false
},
{
label: "Extract_Email",
continue_on_failure: false,
block_type: "extraction",
url: "",
title: "Extract_Email",
data_extraction_goal: "Extract a company email if available ",
data_schema: null,
max_retries: 0,
max_steps_per_run: null,
parameter_keys: [],
cache_actions: false
}
]
}
};
const workflow = await skyvern.createWorkflow({
json_definition: workflowDefinition
});
console.log(workflow);
"""
UPDATE_WORKFLOW_CODE_SAMPLE_CURL = """curl -X POST https://api.skyvern.com/v1/workflows/wpid_123 \
--header 'x-api-key: {{x-api-key}}' \ --header 'x-api-key: {{x-api-key}}' \
--header 'Content-Type: text/plain' \ --header 'Content-Type: text/plain' \
--data-raw 'title: Contact Forms --data-raw 'title: Contact Forms
@@ -412,25 +585,134 @@ skyvern = Skyvern(api_key="YOUR_API_KEY")
workflow = await skyvern.update_workflow(workflow_id="wpid_123", json_definition=updated_workflow_definition) workflow = await skyvern.update_workflow(workflow_id="wpid_123", json_definition=updated_workflow_definition)
print(workflow) print(workflow)
""" """
DELETE_WORKFLOW_CODE_SAMPLE = """from skyvern import Skyvern UPDATE_WORKFLOW_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
const updatedWorkflowDefinition = {
title: "Updated Contact Forms Workflow",
description: "Fill the contact form on the website",
proxy_location: "RESIDENTIAL",
webhook_callback_url: "https://example.com/webhook",
totp_verification_url: "https://example.com/totp",
totp_identifier: "4155555555",
model: { name: "gpt-4.1" },
workflow_definition: {
parameters: [
{
key: "website_url",
description: null,
parameter_type: "workflow",
workflow_parameter_type: "string",
default_value: null
},
{
key: "name",
description: null,
parameter_type: "workflow",
workflow_parameter_type: "string",
default_value: null
},
{
key: "additional_information",
description: null,
parameter_type: "workflow",
workflow_parameter_type: "string",
default_value: "Message: I'd love to learn more about your...\\nPhone: 123-456-7890\\nInquiry type: sales\\nOptional Subject: Hello from [Company Here]"
},
{
key: "email",
description: null,
parameter_type: "workflow",
workflow_parameter_type: "string",
default_value: null
}
],
blocks: [
{
label: "Fill_Out_Contact_Form",
continue_on_failure: true,
block_type: "navigation",
url: "{{website_url}}",
title: "Fill_Out_Contact_Form",
engine: "skyvern-1.0",
navigation_goal: "Find the contact form. Fill out the contact us form and submit it. Your goal is complete when the page says your message has been sent. In the case you can't find a contact us form, terminate.\\n\\nFill out required fields as best you can using the following information:\\n{{name}}\\n{{email}}\\n{{additional_information}}",
error_code_mapping: null,
max_retries: 0,
max_steps_per_run: null,
complete_on_download: false,
download_suffix: null,
parameter_keys: [],
totp_identifier: null,
totp_verification_url: null,
cache_actions: false,
complete_criterion: "",
terminate_criterion: "",
include_action_history_in_verification: false
},
{
label: "Extract_Email",
continue_on_failure: false,
block_type: "extraction",
url: "",
title: "Extract_Email",
data_extraction_goal: "Extract a company email if available ",
data_schema: null,
max_retries: 0,
max_steps_per_run: null,
parameter_keys: [],
cache_actions: false
}
]
}
};
const workflow = await skyvern.updateWorkflow("wpid_123", {
json_definition: updatedWorkflowDefinition
});
console.log(workflow);
"""
DELETE_WORKFLOW_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.delete_workflow(workflow_id="wpid_123") await skyvern.delete_workflow(workflow_id="wpid_123")
""" """
GET_WORKFLOWS_CODE_SAMPLE = """from skyvern import Skyvern DELETE_WORKFLOW_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.deleteWorkflow("wpid_123");
"""
GET_WORKFLOWS_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
workflows = await skyvern.get_workflows() workflows = await skyvern.get_workflows()
print(workflows) print(workflows)
""" """
GET_WORKFLOWS_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
const workflows = await skyvern.getWorkflows();
console.log(workflows);
"""
# Credentials # Credentials
SEND_TOTP_CODE_CODE_SAMPLE = """from skyvern import Skyvern SEND_TOTP_CODE_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.send_totp_code(totp_code="123456") await skyvern.send_totp_code(
totp_identifier="john.doe@example.com",
content="Hello, your verification code is 123456"
)
""" """
CREATE_CREDENTIAL_CODE_SAMPLE = """from skyvern import Skyvern SEND_TOTP_CODE_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.sendTotpCode({
totp_identifier: "john.doe@example.com",
content: "Hello, your verification code is 123456"
});
"""
CREATE_CREDENTIAL_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.create_credential( await skyvern.create_credential(
@@ -439,7 +721,16 @@ await skyvern.create_credential(
credential={"username": "username", "password": "password"}, credential={"username": "username", "password": "password"},
) )
""" """
CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD = """from skyvern import Skyvern CREATE_CREDENTIAL_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.createCredential({
name: "My Credential",
credential_type: "password",
credential: { username: "username", password: "password" }
});
"""
CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.create_credential( await skyvern.create_credential(
@@ -455,46 +746,104 @@ await skyvern.create_credential(
}, },
) )
""" """
DELETE_CREDENTIAL_CODE_SAMPLE = """from skyvern import Skyvern CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.createCredential({
name: "My Credit Card",
credential_type: "credit_card",
credential: {
card_number: "4242424242424242",
card_cvv: "424",
card_exp_month: "12",
card_exp_year: "2028",
card_brand: "visa",
card_holder_name: "John Doe"
}
});
"""
DELETE_CREDENTIAL_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.delete_credential(credential_id="cred_123") await skyvern.delete_credential(credential_id="cred_123")
""" """
GET_CREDENTIAL_CODE_SAMPLE = """from skyvern import Skyvern DELETE_CREDENTIAL_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.deleteCredential("cred_123");
"""
GET_CREDENTIAL_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
credential = await skyvern.get_credential(credential_id="cred_123") credential = await skyvern.get_credential(credential_id="cred_123")
print(credential) print(credential)
""" """
GET_CREDENTIALS_CODE_SAMPLE = """from skyvern import Skyvern GET_CREDENTIAL_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
const credential = await skyvern.getCredential("cred_123");
console.log(credential);
"""
GET_CREDENTIALS_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
credentials = await skyvern.get_credentials() credentials = await skyvern.get_credentials()
print(credentials) print(credentials)
""" """
GET_CREDENTIALS_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
const credentials = await skyvern.getCredentials();
console.log(credentials);
"""
# Browser Sessions # Browser Sessions
CREATE_BROWSER_SESSION_CODE_SAMPLE = """from skyvern import Skyvern CREATE_BROWSER_SESSION_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
browser_session = await skyvern.create_browser_session(timeout=60) browser_session = await skyvern.create_browser_session(timeout=60)
print(browser_session) print(browser_session)
""" """
CLOSE_BROWSER_SESSION_CODE_SAMPLE = """from skyvern import Skyvern CREATE_BROWSER_SESSION_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
const browserSession = await skyvern.createBrowserSession({
timeout: 60
});
console.log(browserSession);
"""
CLOSE_BROWSER_SESSION_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
await skyvern.close_browser_session(browser_session_id="pbs_123") await skyvern.close_browser_session(browser_session_id="pbs_123")
""" """
GET_BROWSER_SESSION_CODE_SAMPLE = """from skyvern import Skyvern CLOSE_BROWSER_SESSION_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
await skyvern.closeBrowserSession("pbs_123");
"""
GET_BROWSER_SESSION_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
browser_session = await skyvern.get_browser_session(browser_session_id="pbs_123") browser_session = await skyvern.get_browser_session(browser_session_id="pbs_123")
print(browser_session) print(browser_session)
""" """
GET_BROWSER_SESSIONS_CODE_SAMPLE = """from skyvern import Skyvern GET_BROWSER_SESSION_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
const browserSession = await skyvern.getBrowserSession("pbs_123");
console.log(browserSession);
"""
GET_BROWSER_SESSIONS_CODE_SAMPLE_PYTHON = """from skyvern import Skyvern
skyvern = Skyvern(api_key="YOUR_API_KEY") skyvern = Skyvern(api_key="YOUR_API_KEY")
browser_sessions = await skyvern.get_browser_sessions() browser_sessions = await skyvern.get_browser_sessions()
print(browser_sessions) print(browser_sessions)
""" """
GET_BROWSER_SESSIONS_CODE_SAMPLE_TS = """import { SkyvernClient } from "@skyvern/client";
const skyvern = new SkyvernClient({ apiKey: "YOUR_API_KEY" });
const browserSessions = await skyvern.getBrowserSessions();
console.log(browserSessions);
"""

View File

@@ -5,12 +5,18 @@ from skyvern.config import settings
from skyvern.forge import app from skyvern.forge import app
from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType from skyvern.forge.sdk.db.enums import OrganizationAuthTokenType
from skyvern.forge.sdk.routes.code_samples import ( from skyvern.forge.sdk.routes.code_samples import (
CREATE_CREDENTIAL_CODE_SAMPLE, CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD_PYTHON,
CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD, CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD_TS,
DELETE_CREDENTIAL_CODE_SAMPLE, CREATE_CREDENTIAL_CODE_SAMPLE_PYTHON,
GET_CREDENTIAL_CODE_SAMPLE, CREATE_CREDENTIAL_CODE_SAMPLE_TS,
GET_CREDENTIALS_CODE_SAMPLE, DELETE_CREDENTIAL_CODE_SAMPLE_PYTHON,
SEND_TOTP_CODE_CODE_SAMPLE, DELETE_CREDENTIAL_CODE_SAMPLE_TS,
GET_CREDENTIAL_CODE_SAMPLE_PYTHON,
GET_CREDENTIAL_CODE_SAMPLE_TS,
GET_CREDENTIALS_CODE_SAMPLE_PYTHON,
GET_CREDENTIALS_CODE_SAMPLE_TS,
SEND_TOTP_CODE_CODE_SAMPLE_PYTHON,
SEND_TOTP_CODE_CODE_SAMPLE_TS,
) )
from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router from skyvern.forge.sdk.routes.routers import base_router, legacy_base_router
from skyvern.forge.sdk.schemas.credentials import ( from skyvern.forge.sdk.schemas.credentials import (
@@ -60,7 +66,14 @@ async def fetch_credential_item_background(item_id: str) -> None:
tags=["Credentials"], tags=["Credentials"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "send_totp_code", "x-fern-sdk-method-name": "send_totp_code",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": SEND_TOTP_CODE_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": SEND_TOTP_CODE_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": SEND_TOTP_CODE_CODE_SAMPLE_TS},
]
}
],
}, },
) )
@base_router.post( @base_router.post(
@@ -125,8 +138,10 @@ async def send_totp_code(
"x-fern-examples": [ "x-fern-examples": [
{ {
"code-samples": [ "code-samples": [
{"sdk": "python", "code": CREATE_CREDENTIAL_CODE_SAMPLE}, {"sdk": "python", "code": CREATE_CREDENTIAL_CODE_SAMPLE_PYTHON},
{"sdk": "python", "code": CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD}, {"sdk": "python", "code": CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD_PYTHON},
{"sdk": "typescript", "code": CREATE_CREDENTIAL_CODE_SAMPLE_TS},
{"sdk": "typescript", "code": CREATE_CREDENTIAL_CODE_SAMPLE_CREDIT_CARD_TS},
] ]
} }
], ],
@@ -196,7 +211,14 @@ async def create_credential(
tags=["Credentials"], tags=["Credentials"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "delete_credential", "x-fern-sdk-method-name": "delete_credential",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": DELETE_CREDENTIAL_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": DELETE_CREDENTIAL_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": DELETE_CREDENTIAL_CODE_SAMPLE_TS},
]
}
],
}, },
) )
@base_router.post( @base_router.post(
@@ -243,7 +265,14 @@ async def delete_credential(
tags=["Credentials"], tags=["Credentials"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "get_credential", "x-fern-sdk-method-name": "get_credential",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": GET_CREDENTIAL_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": GET_CREDENTIAL_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": GET_CREDENTIAL_CODE_SAMPLE_TS},
]
}
],
}, },
) )
@base_router.get( @base_router.get(
@@ -275,7 +304,14 @@ async def get_credential(
tags=["Credentials"], tags=["Credentials"],
openapi_extra={ openapi_extra={
"x-fern-sdk-method-name": "get_credentials", "x-fern-sdk-method-name": "get_credentials",
"x-fern-examples": [{"code-samples": [{"sdk": "python", "code": GET_CREDENTIALS_CODE_SAMPLE}]}], "x-fern-examples": [
{
"code-samples": [
{"sdk": "python", "code": GET_CREDENTIALS_CODE_SAMPLE_PYTHON},
{"sdk": "typescript", "code": GET_CREDENTIALS_CODE_SAMPLE_TS},
]
}
],
}, },
) )
@base_router.get( @base_router.get(

View File

@@ -8,9 +8,12 @@ from skyvern.exceptions import MissingBrowserAddressError
from skyvern.forge import app from skyvern.forge import app
from skyvern.forge.sdk.core import skyvern_context from skyvern.forge.sdk.core import skyvern_context
from skyvern.forge.sdk.routes.code_samples import ( from skyvern.forge.sdk.routes.code_samples import (
LOGIN_CODE_SAMPLE_BITWARDEN, LOGIN_CODE_SAMPLE_BITWARDEN_PYTHON,
LOGIN_CODE_SAMPLE_ONEPASSWORD, LOGIN_CODE_SAMPLE_BITWARDEN_TS,
LOGIN_CODE_SAMPLE_SKYVERN, LOGIN_CODE_SAMPLE_ONEPASSWORD_PYTHON,
LOGIN_CODE_SAMPLE_ONEPASSWORD_TS,
LOGIN_CODE_SAMPLE_SKYVERN_PYTHON,
LOGIN_CODE_SAMPLE_SKYVERN_TS,
) )
from skyvern.forge.sdk.routes.routers import base_router from skyvern.forge.sdk.routes.routers import base_router
from skyvern.forge.sdk.schemas.organizations import Organization from skyvern.forge.sdk.schemas.organizations import Organization
@@ -49,18 +52,12 @@ If login is completed, you're successful."""
"x-fern-examples": [ "x-fern-examples": [
{ {
"code-samples": [ "code-samples": [
{ {"sdk": "python", "code": LOGIN_CODE_SAMPLE_SKYVERN_PYTHON},
"sdk": "python", {"sdk": "python", "code": LOGIN_CODE_SAMPLE_BITWARDEN_PYTHON},
"code": LOGIN_CODE_SAMPLE_SKYVERN, {"sdk": "python", "code": LOGIN_CODE_SAMPLE_ONEPASSWORD_PYTHON},
}, {"sdk": "typescript", "code": LOGIN_CODE_SAMPLE_SKYVERN_TS},
{ {"sdk": "typescript", "code": LOGIN_CODE_SAMPLE_BITWARDEN_TS},
"sdk": "python", {"sdk": "typescript", "code": LOGIN_CODE_SAMPLE_ONEPASSWORD_TS},
"code": LOGIN_CODE_SAMPLE_BITWARDEN,
},
{
"sdk": "python",
"code": LOGIN_CODE_SAMPLE_ONEPASSWORD,
},
] ]
} }
], ],