-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - skyvern #14629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - skyvern #14629
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
components/skyvern/actions/create-run-task/create-run-task.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import skyvern from "../../skyvern.app.mjs"; | ||
|
||
export default { | ||
key: "skyvern-create-run-task", | ||
name: "Create and Run Task", | ||
description: "Create a new task and run it instantly in Skyvern. Useful for one-off automations. [See the documentation](https://docs.skyvern.com/)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
skyvern, | ||
url: { | ||
type: "string", | ||
label: "URL", | ||
description: "It must be a http or https URL.", | ||
}, | ||
navigationGoal: { | ||
type: "string", | ||
label: "Navigation Goal", | ||
description: "The prompt that tells the agent what the user-facing goal is. This is the guiding light for the LLM as it navigates a particular website / sitemap to achieve this specified goal.", | ||
optional: true, | ||
}, | ||
dataExtractionGoal: { | ||
type: "string", | ||
label: "Data Extraction Goal", | ||
description: "The prompt that instructs the agent to extract information once the agent has achieved its **User Goal**.", | ||
optional: true, | ||
}, | ||
navigationPayload: { | ||
type: "object", | ||
label: "Navigation Payload", | ||
description: "JSON-formatted payload with any \"facts\" or information that would help the agent perform its job. In the case of navigating an insurance quote, this payload would include any user information to help fill out the insurance flow such as date of birth, or age they got their license, and so on. This can include nested information, and the formatting isn't validated.", | ||
optional: true, | ||
}, | ||
webhookCallbackUrl: { | ||
propDefinition: [ | ||
skyvern, | ||
"webhookCallbackUrl", | ||
], | ||
description: "The callback URL once our system is finished processing this async task.", | ||
optional: true, | ||
}, | ||
extractedInformationSchema: { | ||
type: "object", | ||
label: "Extracted Information Schema", | ||
description: "Used to enforce a JSON schema spec to be enforced in the data_extraction_goal. Similar to [https://json-schema.org/](https://json-schema.org/) definition.", | ||
optional: true, | ||
}, | ||
totpVerificationUrl: { | ||
type: "string", | ||
label: "TOTP Verification URL", | ||
description: "The URL of your TOTP endpoint. If this field is provided, Skyvern will call the URL to fetch the TOTP/2FA/MFA code when needed.", | ||
optional: true, | ||
}, | ||
totpIdentifier: { | ||
type: "string", | ||
label: "TOTP Identifier", | ||
description: "The email address or the phone number which receives the TOTP/2FA/MFA code. If this field is provided, Skyvern will fetch the code that is pushed to [Skyvern's TOTP API](https://docs.skyvern.com/running-tasks/advanced-features#push-code-to-skyvern).", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.skyvern.createAndRunTask({ | ||
$, | ||
data: { | ||
url: this.url, | ||
navigation_goal: this.navigationGoal, | ||
data_extraction_goal: this.dataExtractionGoal, | ||
navigation_payload: parseObject(this.navigationPayload), | ||
webhook_callback_url: this.webhookCallbackUrl, | ||
proxyLocation: "RESIDENTIAL", | ||
extracted_information_schema: parseObject(this.extractedInformationSchema), | ||
totp_verification_url: this.totpVerificationUrl, | ||
totp_identifier: this.totpIdentifier, | ||
}, | ||
}); | ||
$.export("$summary", `Created and ran task with ID ${response.task_id}`); | ||
return response; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import skyvern from "../../skyvern.app.mjs"; | ||
|
||
export default { | ||
key: "skyvern-get-workflow", | ||
name: "Get Workflow Run Details", | ||
description: "Retrieve details of runs of a specific Skyvern workflow. Useful for checking the status and result of a run. [See the documentation](https://docs.skyvern.com/workflows/getting-workflows)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
skyvern, | ||
workflowId: { | ||
propDefinition: [ | ||
skyvern, | ||
"workflowId", | ||
], | ||
}, | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
async run({ $ }) { | ||
const response = await this.skyvern.getWorkflowRunDetails({ | ||
$, | ||
workflowId: this.workflowId, | ||
}); | ||
$.export("$summary", `Successfully retrieved run details for workflow: ${this.workflowId}`); | ||
return response; | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import skyvern from "../../skyvern.app.mjs"; | ||
|
||
export default { | ||
key: "skyvern-run-workflow", | ||
name: "Run Workflow", | ||
description: "Trigger a predefined workflow in Skyvern, allowing the execution of complex routines from Pipedream. [See the documentation](https://docs.skyvern.com/workflows/running-workflows)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
skyvern, | ||
workflowId: { | ||
propDefinition: [ | ||
skyvern, | ||
"workflowId", | ||
], | ||
}, | ||
data: { | ||
type: "object", | ||
label: "Data", | ||
description: "The data field is used to pass in required and optional parameters that a workflow accepts. [See the documentation](https://docs.skyvern.com/workflows/running-workflows) for further information.", | ||
optional: true, | ||
}, | ||
webhookCallbackUrl: { | ||
propDefinition: [ | ||
skyvern, | ||
"webhookCallbackUrl", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.skyvern.triggerWorkflow({ | ||
$, | ||
workflowId: this.workflowId, | ||
data: { | ||
data: parseObject(this.data), | ||
proxyLocation: "RESIDENTIAL", | ||
webhookCallbackUrl: this.webhookCallbackUrl, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully triggered workflow with ID ${response.workflow_id}`); | ||
return response; | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export const parseObject = (obj) => { | ||
if (!obj) return undefined; | ||
|
||
if (Array.isArray(obj)) { | ||
return obj.map((item) => { | ||
if (typeof item === "string") { | ||
try { | ||
return JSON.parse(item); | ||
} catch (e) { | ||
return item; | ||
} | ||
} | ||
return item; | ||
}); | ||
} | ||
if (typeof obj === "string") { | ||
try { | ||
return JSON.parse(obj); | ||
} catch (e) { | ||
return obj; | ||
} | ||
} | ||
return obj; | ||
}; | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/skyvern", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Skyvern Components", | ||
"main": "skyvern.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.3" | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,112 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "skyvern", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
workflowId: { | ||
type: "string", | ||
label: "Workflow ID", | ||
description: "The unique identifier for a workflow", | ||
async options({ page }) { | ||
const workflows = await this.listWorkflows({ | ||
params: { | ||
page: page + 1, | ||
}, | ||
}); | ||
return workflows.map(({ | ||
workflow_permanent_id: value, title: label, | ||
}) => ({ | ||
label, | ||
value, | ||
})); | ||
}, | ||
}, | ||
webhookCallbackUrl: { | ||
type: "string", | ||
label: "Webhook Callback URL", | ||
description: "URL where system will send callback once it finishes executing the workflow run.", | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return "https://api.skyvern.com/api/v1"; | ||
}, | ||
_headers() { | ||
return { | ||
"x-api-key": this.$auth.api_key, | ||
}; | ||
}, | ||
_makeRequest({ | ||
$ = this, path, ...opts | ||
}) { | ||
return axios($, { | ||
url: this._baseUrl() + path, | ||
headers: this._headers(), | ||
...opts, | ||
}); | ||
}, | ||
listWorkflows({ | ||
params, ...opts | ||
}) { | ||
return this._makeRequest({ | ||
path: "/workflows", | ||
params: { | ||
...params, | ||
only_workflows: true, | ||
}, | ||
...opts, | ||
}); | ||
}, | ||
getWorkflowRunDetails({ | ||
workflowId, ...opts | ||
}) { | ||
const path = `/workflows/${workflowId}/runs`; | ||
return this._makeRequest({ | ||
path, | ||
...opts, | ||
}); | ||
}, | ||
triggerWorkflow({ | ||
workflowId, ...opts | ||
}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: `/workflows/${workflowId}/run`, | ||
...opts, | ||
}); | ||
}, | ||
createAndRunTask(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/tasks", | ||
...opts, | ||
}); | ||
}, | ||
async *paginate({ | ||
fn, params = {}, maxResults = null, ...opts | ||
}) { | ||
let hasMore = false; | ||
let count = 0; | ||
let page = 0; | ||
|
||
do { | ||
params.page = ++page; | ||
const data = await fn({ | ||
params, | ||
...opts, | ||
}); | ||
for (const d of data) { | ||
yield d; | ||
|
||
if (maxResults && ++count === maxResults) { | ||
return count; | ||
} | ||
} | ||
|
||
hasMore = data.length; | ||
|
||
} while (hasMore); | ||
}, | ||
}, | ||
}; | ||
}; |
67 changes: 67 additions & 0 deletions
67
components/skyvern/sources/new-or-updated-workflow/new-or-updated-workflow.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
import skyvern from "../../skyvern.app.mjs"; | ||
import sampleEmit from "./test-event.mjs"; | ||
|
||
export default { | ||
key: "skyvern-new-or-updated-workflow", | ||
name: "New or Updated Workflow", | ||
description: "Emit new event when a workflow is created or updated in Skyvern.", | ||
version: "0.0.1", | ||
type: "source", | ||
dedupe: "unique", | ||
props: { | ||
skyvern, | ||
db: "$.service.db", | ||
timer: { | ||
type: "$.interface.timer", | ||
default: { | ||
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
_getLastDate() { | ||
return this.db.get("lastDate") || 0; | ||
}, | ||
_setLastDate(lastDate) { | ||
this.db.set("lastDate", lastDate); | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
async emitEvent(maxResults = false) { | ||
const lastDate = this._getLastDate(); | ||
|
||
const response = this.skyvern.paginate({ | ||
fn: this.skyvern.listWorkflows, | ||
maxResults, | ||
}); | ||
|
||
let responseArray = []; | ||
for await (const item of response) { | ||
if (Date.parse(item.modified_at) <= lastDate) break; | ||
responseArray.push(item); | ||
} | ||
|
||
if (responseArray.length) { | ||
this._setLastDate(responseArray[0].modified_at); | ||
} | ||
|
||
for (const item of responseArray.reverse()) { | ||
this.$emit(item, { | ||
id: `${item.modified_at}-${item.workflow_permanent_id}`, | ||
summary: `New Workflow ${item.version === 1 | ||
? "Created" | ||
: "Updated"}: ${item.title}`, | ||
ts: Date.parse(item.modified_at), | ||
}); | ||
} | ||
}, | ||
luancazarine marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
hooks: { | ||
async deploy() { | ||
await this.emitEvent(25); | ||
}, | ||
}, | ||
async run() { | ||
await this.emitEvent(); | ||
}, | ||
sampleEmit, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.