mirror of
https://github.com/langgenius/dify.git
synced 2026-05-13 08:57:28 +08:00
Resolve the full dependency chain to enable all previously disabled controllers: Enabled routes: - sandbox_files: sandbox file browser API - sandbox_providers: sandbox provider management API - app_asset: app asset management API - skills: skill extraction API - CLI API blueprint: DifyCli callback endpoints (/cli/api/*) Dependencies extracted (64 files, ~8000 lines): - models/sandbox.py, models/app_asset.py: DB models - core/zip_sandbox/: zip-based sandbox execution - core/session/: CLI API session management - core/memory/: base memory + node token buffer - core/helper/creators.py: helper utilities - core/llm_generator/: context models, output models, utils - core/workflow/nodes/command/: command node type - core/workflow/nodes/file_upload/: file upload node type - core/app/entities/: app_asset_entities, app_bundle_entities, llm_generation_entities - services/: asset_content, skill, workflow_collaboration, workflow_comment - controllers/console/app/error.py: AppAsset error classes - core/tools/utils/system_encryption.py Import fixes: - dify_graph.enums -> graphon.enums in skill_service.py - get_signed_file_url_for_plugin -> get_signed_file_url in cli_api.py All 5 controllers verified: import OK, Flask starts successfully. 46 existing tests still pass. Made-with: Cursor
31 lines
969 B
Python
31 lines
969 B
Python
import secrets
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from configs import dify_config
|
|
from core.skill.entities import ToolAccessPolicy
|
|
|
|
from .session import BaseSession, SessionManager
|
|
|
|
|
|
class CliApiSession(BaseSession):
|
|
secret: str = Field(default_factory=lambda: secrets.token_urlsafe(32))
|
|
|
|
|
|
class CliContext(BaseModel):
|
|
tool_access: ToolAccessPolicy | None = Field(default=None, description="Tool access policy")
|
|
|
|
|
|
class CliApiSessionManager(SessionManager[CliApiSession]):
|
|
def __init__(self, ttl: int | None = None):
|
|
super().__init__(
|
|
key_prefix="cli_api_session",
|
|
session_class=CliApiSession,
|
|
ttl=ttl or dify_config.WORKFLOW_MAX_EXECUTION_TIME,
|
|
)
|
|
|
|
def create(self, tenant_id: str, user_id: str, context: CliContext) -> CliApiSession:
|
|
session = CliApiSession(tenant_id=tenant_id, user_id=user_id, context=context.model_dump(mode="json"))
|
|
self.save(session)
|
|
return session
|