Files
simstudioai--sim/apps/sim/tools/file/manage-sharing.ts
T
wehub-resource-sync d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:20:55 +08:00

98 lines
3.1 KiB
TypeScript

import type { ShareAuthType } from '@/lib/api/contracts/public-shares'
import type { ToolConfig, ToolResponse, WorkflowToolExecutionContext } from '@/tools/types'
interface FileManageSharingParams {
fileId?: string
fileInput?: unknown
isActive: boolean
authType?: ShareAuthType
password?: string
allowedEmails?: string[]
workspaceId?: string
_context?: WorkflowToolExecutionContext
}
export const fileManageSharingTool: ToolConfig<FileManageSharingParams, ToolResponse> = {
id: 'file_manage_sharing',
name: 'Manage Sharing',
description:
'Enable or disable the public share link for a workspace file, and set its access mode (public, password, email, or SSO). Idempotent: the public link stays stable across changes.',
version: '1.0.0',
params: {
fileId: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'Canonical ID of the workspace file to update sharing for.',
},
fileInput: {
type: 'file',
required: false,
visibility: 'user-only',
description: 'Selected workspace file object (from the file picker).',
},
isActive: {
type: 'boolean',
required: true,
visibility: 'user-or-llm',
description: 'Whether the public link is enabled. Set to false to make the file private.',
},
authType: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Access mode for the link: "public", "password", "email", or "sso". Defaults to "public".',
},
password: {
type: 'string',
required: false,
visibility: 'user-only',
description: 'Password to protect the link. Required when authType is "password".',
},
allowedEmails: {
type: 'array',
required: false,
visibility: 'user-or-llm',
description:
'Allowed emails or "@domain" patterns. Required when authType is "email" or "sso".',
},
},
request: {
url: '/api/tools/file/manage',
method: 'POST',
headers: () => ({ 'Content-Type': 'application/json' }),
body: (params) => ({
operation: 'manage_sharing',
fileId: params.fileId,
fileInput: params.fileInput,
isActive: params.isActive,
authType: params.authType,
password: params.password,
allowedEmails: params.allowedEmails,
workspaceId: params.workspaceId || params._context?.workspaceId,
}),
},
transformResponse: async (response) => {
const data = await response.json()
if (!response.ok || !data.success) {
return { success: false, output: {}, error: data.error || 'Failed to update file sharing' }
}
return { success: true, output: data.data.share }
},
outputs: {
url: { type: 'string', description: 'Public share URL for the file' },
isActive: { type: 'boolean', description: 'Whether the public link is enabled' },
authType: { type: 'string', description: 'Access mode: public, password, email, or sso' },
hasPassword: { type: 'boolean', description: 'Whether the share is password-protected' },
allowedEmails: {
type: 'array',
description: 'Allowed emails/domains for email or SSO access',
},
},
}