Skip to content

Automate browser based workflows with AI

feat(SKY-11092): 1Password item picker for credential inputs (#6651)

Suchintand940e36fdb35
diff --git a/docs/pr-screenshots/onepassword-credentials-passwords-tab.png b/docs/pr-screenshots/onepassword-credentials-passwords-tab.png
new file mode 100644
index 000000000..43ebabcfe
Binary files /dev/null and b/docs/pr-screenshots/onepassword-credentials-passwords-tab.png differ
diff --git a/docs/pr-screenshots/onepassword-custom-value.png b/docs/pr-screenshots/onepassword-custom-value.png
new file mode 100644
index 000000000..42d589391
Binary files /dev/null and b/docs/pr-screenshots/onepassword-custom-value.png differ
diff --git a/docs/pr-screenshots/onepassword-item-picker-open.png b/docs/pr-screenshots/onepassword-item-picker-open.png
new file mode 100644
index 000000000..2f856c3f9
Binary files /dev/null and b/docs/pr-screenshots/onepassword-item-picker-open.png differ
diff --git a/docs/pr-screenshots/onepassword-item-picker.png b/docs/pr-screenshots/onepassword-item-picker.png
new file mode 100644
index 000000000..b302738d0
Binary files /dev/null and b/docs/pr-screenshots/onepassword-item-picker.png differ
diff --git a/skyvern-frontend/src/api/types.ts b/skyvern-frontend/src/api/types.ts
index 259519f7e..ff130d6db 100644
--- a/skyvern-frontend/src/api/types.ts
+++ b/skyvern-frontend/src/api/types.ts
@@ -249,6 +249,20 @@ export type OnePasswordTokenApiResponse = {
valid: boolean;
};
+export type OnePasswordItemApiResponse = {
+ item_id: string;
+ title: string;
+ vault_id: string;
+ vault_name: string;
+ category: string;
+ url?: string | null;
+};
+
+export type OnePasswordItemsApiResponse = {
+ configured: boolean;
+ items: Array<OnePasswordItemApiResponse>;
+};
+
export type CreateOnePasswordTokenRequest = {
token: string;
};
diff --git a/skyvern-frontend/src/hooks/useClearOrganizationAuthToken.ts b/skyvern-frontend/src/hooks/useClearOrganizationAuthToken.ts
index 13ac66d0b..43801e044 100644
--- a/skyvern-frontend/src/hooks/useClearOrganizationAuthToken.ts
+++ b/skyvern-frontend/src/hooks/useClearOrganizationAuthToken.ts
@@ -7,6 +7,7 @@ import { useCredentialGetter } from "./useCredentialGetter";
type ClearOrganizationAuthTokenOptions = {
providerPath: string;
queryKey: string;
+ invalidateQueryKeys?: string[];
successDescription: string;
errorDescription: string;
};
@@ -14,6 +15,7 @@ type ClearOrganizationAuthTokenOptions = {
export function useClearOrganizationAuthToken({
providerPath,
queryKey,
+ invalidateQueryKeys,
successDescription,
errorDescription,
}: ClearOrganizationAuthTokenOptions) {
@@ -33,6 +35,9 @@ export function useClearOrganizationAuthToken({
onSuccess: () => {
queryClient.setQueryData([queryKey], null);
queryClient.invalidateQueries({ queryKey: [queryKey] });
+ (invalidateQueryKeys ?? []).forEach((key) => {
+ queryClient.invalidateQueries({ queryKey: [key] });
+ });
toast({
title: "Success",
description: successDescription,
diff --git a/skyvern-frontend/src/hooks/useOnePasswordToken.ts b/skyvern-frontend/src/hooks/useOnePasswordToken.ts
index aa288a399..ed27524a5 100644
--- a/skyvern-frontend/src/hooks/useOnePasswordToken.ts
+++ b/skyvern-frontend/src/hooks/useOnePasswordToken.ts
@@ -35,6 +35,7 @@ export function useOnePasswordToken() {
},
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: ["onePasswordToken"] });
+ void queryClient.invalidateQueries({ queryKey: ["onepasswordItems"] });
toast({
title: "Success",
description: "1Password service account token updated successfully",
@@ -57,6 +58,7 @@ export function useOnePasswordToken() {
const clearTokenMutation = useClearOrganizationAuthToken({
providerPath: "onepassword",
queryKey: "onePasswordToken",
+ invalidateQueryKeys: ["onepasswordItems"],
successDescription: "1Password service account token cleared successfully",
errorDescription: "Failed to clear 1Password token",
});
diff --git a/skyvern-frontend/src/routes/credentials/CredentialsPage.tsx b/skyvern-frontend/src/routes/credentials/CredentialsPage.tsx
index 8cc621798..5a5e41453 100644
--- a/skyvern-frontend/src/routes/credentials/CredentialsPage.tsx
+++ b/skyvern-frontend/src/routes/credentials/CredentialsPage.tsx
@@ -9,6 +9,7 @@ import {
} from "./useCredentialModalState";
import { CredentialsModal } from "./CredentialsModal";
import { CredentialsList } from "./CredentialsList";
+import { OnePasswordCredentialsList } from "./OnePasswordCredentialsList";
import { useBackgroundCredentialTest } from "./useBackgroundCredentialTest";
import {
DropdownMenu,
@@ -317,6 +318,10 @@ function CredentialsPage() {
isResolvingFolder={isResolvingFolder}
onStartBackgroundTest={startBackgroundTest}
/>
+ <OnePasswordCredentialsList
+ search={debouncedSearch}
+ folderId={selectedFolderId}
+ />
</TabsContent>
<TabsContent value="creditCards" className="space-y-4">
diff --git a/skyvern-frontend/src/routes/credentials/OnePasswordCredentialsList.tsx b/skyvern-frontend/src/routes/credentials/OnePasswordCredentialsList.tsx
new file mode 100644
index 000000000..f9a79f275
--- /dev/null
+++ b/skyvern-frontend/src/routes/credentials/OnePasswordCredentialsList.tsx
@@ -0,0 +1,121 @@
+import type { OnePasswordItemApiResponse } from "@/api/types";
+import { OnePasswordIcon } from "@/components/icons/OnePasswordIcon";
+import { getHostname } from "@/util/getHostname";
+import { useOnePasswordItemsQuery } from "@/routes/workflows/hooks/useOnePasswordItemsQuery";
+import { useMemo } from "react";
+
+type Props = {
+ search?: string;
+ folderId?: string | null;
+};
+
+function isPasswordItem(item: OnePasswordItemApiResponse) {
+ const category = item.category.toLowerCase();
+ return category.includes("login") || category.includes("password");
+}
+
+function OnePasswordCredentialsList({ search, folderId }: Props) {
+ const { data, isLoading, isError } = useOnePasswordItemsQuery();
+ const normalizedSearch = search?.trim().toLowerCase() ?? "";
+
+ const filteredItems = useMemo(() => {
+ return (data?.items ?? []).filter((item) => {
+ if (!isPasswordItem(item)) {
+ return false;
+ }
+
+ if (!normalizedSearch) {
+ return true;
+ }
+
+ return item.title.toLowerCase().includes(normalizedSearch);
+ });
+ }, [data?.items, normalizedSearch]);
+
+ const header = (
+ <div className="flex items-center gap-2">
+ <OnePasswordIcon className="size-5 shrink-0" />
+ <div className="min-w-0 space-y-1">
+ <p className="text-sm font-medium">1Password</p>
+ <p className="text-sm text-neutral-600 dark:text-slate-400">
+ Read-only — managed in your 1Password account
+ </p>
+ </div>
+ </div>
+ );
+
+ if (folderId || isLoading) {
+ return null;
+ }
+
+ if (isError) {
+ return (
+ <div className="space-y-4">
+ {header}
+ <div className="rounded-lg bg-slate-elevation2 p-4 text-sm text-neutral-600 dark:text-slate-400">
+ Couldn&apos;t load 1Password items.
+ </div>
+ </div>
+ );
+ }
+
+ if (!data?.configured || filteredItems.length === 0) {
+ return null;
+ }
+
+ return (
+ <div className="space-y-4">
+ {header}
+ <div className="space-y-5">
+ {filteredItems.map((item) => (
+ <div
+ className="flex gap-5 rounded-lg bg-slate-elevation2 p-4"
+ key={`${item.vault_id}:${item.item_id}`}
+ >
+ <div className="flex w-48 items-center gap-2">
+ <OnePasswordIcon className="size-5 shrink-0" />
+ <div className="min-w-0 space-y-1">
+ <p className="truncate" title={item.title}>
+ {item.title}
+ </p>
+ <p className="text-sm text-neutral-600 dark:text-slate-400">
+ {item.vault_name}
+ </p>
+ </div>
+ </div>
+ <div className="flex gap-5 border-l pl-5">
+ <div className="shrink-0 space-y-2">
+ {item.url && (
+ <p className="text-sm text-neutral-600 dark:text-slate-400">
+ Website
+ </p>
+ )}
+ <p className="text-sm text-neutral-600 dark:text-slate-400">
+ Vault ID
+ </p>
+ <p className="text-sm text-neutral-600 dark:text-slate-400">
+ Item ID
+ </p>
+ </div>
+ <div className="min-w-0 space-y-2">
+ {item.url && (
+ <p className="truncate text-sm" title={item.url}>
+ {getHostname(item.url) ?? item.url}
+ </p>
+ )}
+ <p className="truncate text-sm" title={item.vault_id}>
+ {item.vault_id}
+ </p>
+ <p className="truncate text-sm" title={item.item_id}>
+ {item.item_id}
+ </p>
+ </div>
+ </div>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+export { OnePasswordCredentialsList };
diff --git a/skyvern-frontend/src/routes/workflows/components/OnePasswordItemSelector.tsx b/skyvern-frontend/src/routes/workflows/components/OnePasswordItemSelector.tsx
new file mode 100644
index 000000000..b754ba37b
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/components/OnePasswordItemSelector.tsx
@@ -0,0 +1,136 @@
+import { OnePasswordIcon } from "@/components/icons/OnePasswordIcon";
+import {
+ CustomSelectItem,
+ Select,
+ SelectContent,
+ SelectItemText,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Skeleton } from "@/components/ui/skeleton";
+import { useMemo } from "react";
+import { useOnePasswordItemsQuery } from "../hooks/useOnePasswordItemsQuery";
+
+type Props = {
+ vaultId: string;
+ itemId: string;
+ onSelect: (vaultId: string, itemId: string) => void;
+ credentialDataType: "password" | "secret" | "creditCard";
+};
+
+function itemValue(vaultId: string, itemId: string) {
+ return `${vaultId}:${itemId}`;
+}
+
+function OnePasswordItemSelector({
+ vaultId,
+ itemId,
+ onSelect,
+ credentialDataType,
+}: Props) {
+ const { data, isLoading, isError } = useOnePasswordItemsQuery();
+
+ const filteredItems = useMemo(() => {
+ const items = data?.items ?? [];
+ const filtered = items.filter((item) => {
+ const category = item.category.toLowerCase();
+
+ if (credentialDataType === "password") {
+ return category.includes("login") || category.includes("password");
+ }
+
+ if (credentialDataType === "creditCard") {
+ return category.includes("card");
+ }
+
+ return true;
+ });
+
+ return filtered;
+ }, [credentialDataType, data?.items]);
+
+ // Always include the currently-selected item so a saved selection renders even when the
+ // category filter would otherwise hide it (otherwise the picker shows blank while the IDs persist).
+ const visibleItems = useMemo(() => {
+ const items = data?.items ?? [];
+ const current = items.find(
+ (item) => item.vault_id === vaultId && item.item_id === itemId,
+ );
+ if (
+ current &&
+ !filteredItems.some(
+ (item) => item.vault_id === vaultId && item.item_id === itemId,
+ )
+ ) {
+ return [current, ...filteredItems];
+ }
+ return filteredItems;
+ }, [filteredItems, data?.items, vaultId, itemId]);
+
+ if (isLoading) {
+ return <Skeleton className="h-10 w-full" />;
+ }
+
+ const currentValue = itemValue(vaultId, itemId);
+ const selectedValue = visibleItems.some(
+ (item) => itemValue(item.vault_id, item.item_id) === currentValue,
+ )
+ ? currentValue
+ : "";
+
+ return (
+ <Select
+ value={selectedValue}
+ onValueChange={(value) => {
+ const separatorIndex = value.indexOf(":");
+ if (separatorIndex === -1) {
+ return;
+ }
+
+ onSelect(
+ value.slice(0, separatorIndex),
+ value.slice(separatorIndex + 1),
+ );
+ }}
+ >
+ <SelectTrigger>
+ <SelectValue placeholder="Select a 1Password item" />
+ </SelectTrigger>
+ <SelectContent>
+ {isError && (
+ <div className="px-2 py-1.5 text-xs text-slate-400">
+ Couldn&apos;t load 1Password items. Enter a value manually instead.
+ </div>
+ )}
+ {!isError && !data?.configured && (
+ <div className="px-2 py-1.5 text-xs text-slate-400">
+ Connect 1Password in Settings to list items
+ </div>
+ )}
+ {!isError && data?.configured && visibleItems.length === 0 && (
+ <div className="px-2 py-1.5 text-xs text-slate-400">
+ No 1Password items found
+ </div>
+ )}
+ {visibleItems.map((item) => (
+ <CustomSelectItem
+ key={itemValue(item.vault_id, item.item_id)}
+ value={itemValue(item.vault_id, item.item_id)}
+ >
+ <div className="flex min-w-0 items-center gap-2">
+ <OnePasswordIcon className="size-4" />
+ <span className="min-w-0 flex-1 truncate text-sm font-medium">
+ <SelectItemText>{item.title}</SelectItemText>
+ </span>
+ <span className="shrink-0 rounded bg-slate-800 px-1.5 py-0.5 text-[10px] text-slate-400">
+ {item.vault_name}
+ </span>
+ </div>
+ </CustomSelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ );
+}
+
+export { OnePasswordItemSelector };
diff --git a/skyvern-frontend/src/routes/workflows/editor/panels/WorkflowParameterEditPanel.tsx b/skyvern-frontend/src/routes/workflows/editor/panels/WorkflowParameterEditPanel.tsx
index 92368a815..f59ef9187 100644
--- a/skyvern-frontend/src/routes/workflows/editor/panels/WorkflowParameterEditPanel.tsx
+++ b/skyvern-frontend/src/routes/workflows/editor/panels/WorkflowParameterEditPanel.tsx
@@ -12,11 +12,14 @@ import {
SelectValue,
} from "@/components/ui/select";
import { toast } from "@/components/ui/use-toast";
+import { cn } from "@/util/utils";
import CloudContext from "@/store/CloudContext";
-import { Cross2Icon } from "@radix-ui/react-icons";
-import { useContext, useState } from "react";
+import { CodeIcon, Cross2Icon } from "@radix-ui/react-icons";
+import { useContext, useEffect, useRef, useState } from "react";
import { CredentialParameterSourceSelector } from "../../components/CredentialParameterSourceSelector";
+import { OnePasswordItemSelector } from "../../components/OnePasswordItemSelector";
import { SourceParameterKeySelector } from "../../components/SourceParameterKeySelector";
+import { useOnePasswordItemsQuery } from "../../hooks/useOnePasswordItemsQuery";
import {
WorkflowEditorParameterType,
WorkflowParameterValueType,
@@ -253,6 +256,15 @@ function WorkflowParameterEditPanel({
const [opItemId, setOpItemId] = useState(
isOnePasswordCredential ? initialValues.itemId : "",
);
+ const [opManualEntry, setOpManualEntry] = useState(
+ isOnePasswordCredential &&
+ (initialValues.vaultId.includes("{{") ||
+ initialValues.itemId.includes("{{")),
+ );
+ const opEditModeInitializedRef = useRef(false);
+ const opUserTouchedRef = useRef(false);
+ const savedOpVaultId = isOnePasswordCredential ? initialValues.vaultId : "";
+ const savedOpItemId = isOnePasswordCredential ? initialValues.itemId : "";
const [bitwardenLoginCredentialItemId, setBitwardenLoginCredentialItemId] =
useState(isBitwardenCredential ? (initialValues?.itemId ?? "") : "");
@@ -273,6 +285,8 @@ function WorkflowParameterEditPanel({
// Handle credential data type change - reset source to first available
const handleCredentialDataTypeChange = (newDataType: CredentialDataType) => {
setCredentialDataType(newDataType);
+ setOpVaultId("");
+ setOpItemId("");
const availableSources = getAvailableSourcesForDataType(
newDataType,
isCloud,
@@ -315,6 +329,45 @@ function WorkflowParameterEditPanel({
showCredentialFields &&
credentialSource === "custom" &&
hasCustomCredentialService;
+ const onePasswordItemsQuery = useOnePasswordItemsQuery({
+ enabled: showOnePasswordFields,
+ });
+
+ useEffect(() => {
+ if (
+ !showOnePasswordFields ||
+ !isOnePasswordCredential ||
+ opEditModeInitializedRef.current ||
+ opUserTouchedRef.current
+ ) {
+ return;
+ }
+
+ // Keep the saved vault/item IDs visible (manual mode) when the item list can't load.
+ if (onePasswordItemsQuery.isError) {
+ opEditModeInitializedRef.current = true;
+ setOpManualEntry(true);
+ return;
+ }
+
+ if (!onePasswordItemsQuery.data) {
+ return;
+ }
+
+ opEditModeInitializedRef.current = true;
+ const savedItemExists = onePasswordItemsQuery.data.items.some(
+ (item) =>
+ item.vault_id === savedOpVaultId && item.item_id === savedOpItemId,
+ );
+ setOpManualEntry(!savedItemExists);
+ }, [
+ isOnePasswordCredential,
+ onePasswordItemsQuery.data,
+ onePasswordItemsQuery.isError,
+ savedOpItemId,
+ savedOpVaultId,
+ showOnePasswordFields,
+ ]);
return (
<ScrollArea>
@@ -653,28 +706,94 @@ function WorkflowParameterEditPanel({
{showOnePasswordFields && (
<>
<div className="space-y-1">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 1Password Vault ID
- </Label>
- <HelpTooltip content="Find this in the 1Password vault URL. Supports agent inputs." />
- </div>
- <Input
- value={opVaultId}
- onChange={(e) => setOpVaultId(e.target.value)}
- />
- </div>
- <div className="space-y-1">
- <div className="flex gap-2">
- <Label className="text-xs text-slate-300">
- 1Password Item ID
- </Label>
- <HelpTooltip content="Find this in the 1Password item URL. Supports agent inputs." />
+ <div className="flex items-center justify-between gap-2">
+ <div className="flex items-center gap-2">
+ <Label className="text-xs text-slate-300">
+ 1Password Item
+ </Label>
+ <HelpTooltip
+ content={
+ "Pick an item from your connected 1Password account. Click the </> button to pass in a custom value instead — for example a dynamic {{ input }} reference or a raw vault/item ID."
+ }
+ />
+ </div>
+ <button
+ type="button"
+ aria-pressed={opManualEntry}
+ title={
+ opManualEntry
+ ? "Pick from your 1Password items"
+ : "Enter a custom value"
+ }
+ className={cn(
+ "rounded p-1 text-slate-400 transition-colors hover:text-slate-200",
+ opManualEntry && "bg-slate-700 text-slate-100",
+ )}
+ onClick={() => {
+ opUserTouchedRef.current = true;
+ if (opManualEntry) {
+ const items = onePasswordItemsQuery.data?.items ?? [];
+ const matches = items.some(
+ (item) =>
+ item.vault_id === opVaultId &&
+ item.item_id === opItemId,
+ );
+ if (!matches) {
+ setOpVaultId("");
+ setOpItemId("");
+ }
+ }
+ setOpManualEntry((prev) => !prev);
+ }}
+ >
+ <CodeIcon className="size-4" />
+ </button>
</div>
- <Input
- value={opItemId}
- onChange={(e) => setOpItemId(e.target.value)}
- />
+ {opManualEntry ? (
+ <div className="space-y-3">
+ <div className="space-y-1">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 1Password Vault ID
+ </Label>
+ <HelpTooltip content="Find this in the 1Password vault URL. Supports dynamic agent inputs like {{ my_input }}." />
+ </div>
+ <Input
+ value={opVaultId}
+ onChange={(e) => {
+ opUserTouchedRef.current = true;
+ setOpVaultId(e.target.value);
+ }}
+ />
+ </div>
+ <div className="space-y-1">
+ <div className="flex gap-2">
+ <Label className="text-xs text-slate-300">
+ 1Password Item ID
+ </Label>
+ <HelpTooltip content="Find this in the 1Password item URL. Supports dynamic agent inputs like {{ my_input }}." />
+ </div>
+ <Input
+ value={opItemId}
+ onChange={(e) => {
+ opUserTouchedRef.current = true;
+ setOpItemId(e.target.value);
+ }}
+ />
+ </div>
+ </div>
+ ) : (
+ <OnePasswordItemSelector
+ vaultId={opVaultId}
+ itemId={opItemId}
+ credentialDataType={credentialDataType}
+ onSelect={(vaultId, itemId) => {
+ opUserTouchedRef.current = true;
+ setOpVaultId(vaultId);
+ setOpItemId(itemId);
+ }}
+ />
+ )}
</div>
{credentialDataType === "creditCard" && (
<div className="rounded-md bg-slate-800 p-2">
diff --git a/skyvern-frontend/src/routes/workflows/hooks/useOnePasswordItemsQuery.ts b/skyvern-frontend/src/routes/workflows/hooks/useOnePasswordItemsQuery.ts
new file mode 100644
index 000000000..bef1ef4a2
--- /dev/null
+++ b/skyvern-frontend/src/routes/workflows/hooks/useOnePasswordItemsQuery.ts
@@ -0,0 +1,32 @@
+import { getClient } from "@/api/AxiosClient";
+import { OnePasswordItemsApiResponse } from "@/api/types";
+import { useCredentialGetter } from "@/hooks/useCredentialGetter";
+import { useWorkflowScopeReadOnly } from "@/routes/workflows/editor/WorkflowScopeContext";
+import { useQuery } from "@tanstack/react-query";
+
+type QueryReturnType = OnePasswordItemsApiResponse;
+type UseQueryOptions = Omit<
+ Parameters<typeof useQuery<QueryReturnType>>[0],
+ "queryKey" | "queryFn"
+>;
+
+function useOnePasswordItemsQuery(props: UseQueryOptions = {}) {
+ const credentialGetter = useCredentialGetter();
+ const scopeReadOnly = useWorkflowScopeReadOnly();
+
+ return useQuery<OnePasswordItemsApiResponse>({
+ queryKey: ["onepasswordItems"],
+ queryFn: async () => {
+ const client = await getClient(credentialGetter, "sans-api-v1");
+ return client
+ .get("/credentials/onepassword/items")
+ .then((res) => res.data as OnePasswordItemsApiResponse);
+ },
+ // 1Password items change rarely; avoid refetching every time the panel remounts.
+ staleTime: 60_000,
+ ...props,
+ enabled: props.enabled !== false && !scopeReadOnly,
+ });
+}
+
+export { useOnePasswordItemsQuery };
diff --git a/skyvern/forge/sdk/routes/credentials.py b/skyvern/forge/sdk/routes/credentials.py
index ff59214a3..57209e931 100644
--- a/skyvern/forge/sdk/routes/credentials.py
+++ b/skyvern/forge/sdk/routes/credentials.py
@@ -31,6 +31,7 @@ from typing import Annotated
import structlog
from fastapi import BackgroundTasks, Body, Depends, Header, HTTPException, Path, Query
+from onepassword.client import Client as OnePasswordClient
from skyvern.config import settings
from skyvern.exceptions import HttpException as SkyvernHttpException
@@ -68,6 +69,8 @@ from skyvern.forge.sdk.schemas.credentials import (
CredentialVaultType,
CreditCardCredentialResponse,
NonEmptyPasswordCredential,
+ OnePasswordItemOverview,
+ OnePasswordItemsResponse,
PasswordCredentialResponse,
SecretCredentialResponse,
TestCredentialRequest,
@@ -1837,6 +1840,83 @@ async def get_onepassword_token(
)
+@base_router.get(
+ "/credentials/onepassword/items",
+ response_model=OnePasswordItemsResponse,
+ summary="List 1Password item metadata",
+ description="Lists 1Password item metadata for the current organization.",
+ include_in_schema=False,
+)
+@base_router.get(
+ "/credentials/onepassword/items/",
+ response_model=OnePasswordItemsResponse,
+ include_in_schema=False,
+)
+async def list_onepassword_items(
+ current_org: Organization = Depends(org_auth_service.get_current_org),
+) -> OnePasswordItemsResponse:
+ org_auth_token = await app.DATABASE.organizations.get_valid_org_auth_token(
+ current_org.organization_id,
+ OrganizationAuthTokenType.onepassword_service_account.value,
+ )
+ # Org-scoped only: never fall back to the global OP_SERVICE_ACCOUNT_TOKEN here. In a shared
+ # deployment that would let any org without its own token browse the instance/global account's
+ # 1Password item metadata. (Runtime resolution may still use the global token for an item the
+ # org explicitly configured by vault/item id; listing must not.)
+ if not org_auth_token:
+ return OnePasswordItemsResponse(configured=False, items=[])
+ token = org_auth_token.token
+
+ try:
+ client = await OnePasswordClient.authenticate(
+ auth=token,
+ integration_name="Skyvern",
+ integration_version="v1.0.0",
+ )
+ vaults = await client.vaults.list()
+ # Skip vaults the service-account token can't read instead of failing the whole listing.
+ vault_items_by_vault = await asyncio.wait_for(
+ asyncio.gather(
+ *(client.items.list(vault.id) for vault in vaults),
+ return_exceptions=True,
+ ),
+ timeout=20.0,
+ )
+
+ items: list[OnePasswordItemOverview] = []
+ for vault, vault_items in zip(vaults, vault_items_by_vault, strict=True):
+ if isinstance(vault_items, BaseException):
+ LOG.warning(
+ "Skipping inaccessible 1Password vault while listing items",
+ organization_id=current_org.organization_id,
+ vault_id=vault.id,
+ error=str(vault_items),
+ )
+ continue
+ # Metadata only: never fetch item field values.
+ for item in vault_items:
+ items.append(
+ OnePasswordItemOverview(
+ item_id=item.id,
+ title=item.title,
+ vault_id=vault.id,
+ vault_name=vault.title,
+ category=item.category.value,
+ url=item.websites[0].url if item.websites else None,
+ )
+ )
+
+ return OnePasswordItemsResponse(configured=True, items=items)
+ except Exception as e:
+ LOG.error(
+ "Failed to list 1Password items",
+ organization_id=current_org.organization_id,
+ error=str(e),
+ exc_info=True,
+ )
+ raise HTTPException(status_code=502, detail="Failed to list 1Password items") from e
+
+
@base_router.post(
"/credentials/onepassword/create",
response_model=CreateOnePasswordTokenResponse,
diff --git a/skyvern/forge/sdk/schemas/credentials.py b/skyvern/forge/sdk/schemas/credentials.py
index 5fe1b3d26..45292743e 100644
--- a/skyvern/forge/sdk/schemas/credentials.py
+++ b/skyvern/forge/sdk/schemas/credentials.py
@@ -203,6 +203,24 @@ class CredentialResponse(BaseModel):
)
+class OnePasswordItemOverview(BaseModel):
+ """Response model for 1Password item metadata."""
+
+ item_id: str = Field(..., description="The 1Password item ID")
+ title: str = Field(..., description="The 1Password item title")
+ vault_id: str = Field(..., description="The ID of the vault containing the item")
+ vault_name: str = Field(..., description="The name of the vault containing the item")
+ category: str = Field(..., description="The 1Password item category")
+ url: str | None = Field(default=None, description="The primary website URL associated with the item, if any")
+
+
+class OnePasswordItemsResponse(BaseModel):
+ """Response model for listing 1Password item metadata."""
+
+ configured: bool = Field(..., description="Whether a 1Password service account token is configured")
+ items: list[OnePasswordItemOverview] = Field(..., description="The available 1Password item metadata")
+
+
class Credential(BaseModel):
"""Database model for credentials."""