Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions components/skyvern/actions/create-run-task/create-run-task.mjs
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;
},
};
26 changes: 26 additions & 0 deletions components/skyvern/actions/get-workflow/get-workflow.mjs
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",
],
},
},
async run({ $ }) {
const response = await this.skyvern.getWorkflowRunDetails({
$,
workflowId: this.workflowId,
});
$.export("$summary", `Successfully retrieved run details for workflow: ${this.workflowId}`);
return response;
},
};
46 changes: 46 additions & 0 deletions components/skyvern/actions/run-workflow/run-workflow.mjs
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;
},
};
24 changes: 24 additions & 0 deletions components/skyvern/common/utils.mjs
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;
};
7 changes: 5 additions & 2 deletions components/skyvern/package.json
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": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
111 changes: 106 additions & 5 deletions components/skyvern/skyvern.app.mjs
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);
},
},
};
};
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);
},
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),
});
}
},
},
hooks: {
async deploy() {
await this.emitEvent(25);
},
},
async run() {
await this.emitEvent();
},
sampleEmit,
};
Loading
Loading