survos/ai-workflow-bundle
Composer 安装命令:
composer require survos/ai-workflow-bundle
包简介
State-bundle workflow primitives for async AI preparation, observation, analysis, and publishing.
README 文档
README
State-bundle workflow primitives for async AI work over any subject.
The bundle defines a small shared lifecycle:
new -> prepared -> observed -> analyzed -> reviewed -> published
The important split is conceptual:
prepare: make source content and context available.observe: create neutral evidence from the source. For images this is usually thumbnail observation plus optional high-resolution reads; for text it may be dense summaries, language, or structure.analyze: apply application meaning to observed evidence and context.review: app-defined approval after analysis. This can be automatic policy, human review, or another app-specific gate.publish: project the result into fields, indexes, exports, webhooks, or other app outputs.
The bundle does not decide what those transitions do. Applications provide workflow listeners, task policy, and publishing behavior.
The bundle may define reusable tasks and prompt templates. Treat those as a prompt/task repository, not app policy: applications still decide which tasks to queue, when to append follow-up tasks, and what publish means.
Core Classes
Workflow\SubjectFlow: shared state-bundle definition.Contract\WorkflowSubjectInterface: minimal subject id plus queue/lock shape for entities. Claim subject type defaults to the PHP class name.Task\TaskInterface: callable workflow task that returns claims.Task\TaskResult: claims plus optional follow-up tasks.Task\TaskRegistry: lazy task lookup by name.Task\TaskRunner: consumes one queued task and records claims throughsurvos/claims-bundle.
Task outputs are not stored as opaque JSON result blobs. They are recorded as ClaimRun and Claim rows. Apps can still denormalize claim projections onto their own entities during publish.
Queueing Tasks
Applications queue and run tasks from workflow listeners. Use task constants instead of string literals so built-in task names stay refactorable:
<?php namespace App\Workflow; use App\Entity\GalleryImage; use Doctrine\ORM\EntityManagerInterface; use Survos\AiWorkflowBundle\Task\EnrichFromThumbnailTask; use Survos\AiWorkflowBundle\Task\TaskRunner; use Survos\AiWorkflowBundle\Workflow\SubjectFlow; use Symfony\Component\Workflow\Attribute\AsTransitionListener; use Symfony\Component\Workflow\Event\TransitionEvent; final class GalleryWorkflow { public function __construct( private readonly EntityManagerInterface $entityManager, private readonly TaskRunner $taskRunner, ) { } #[AsTransitionListener(SubjectFlow::WORKFLOW_NAME, SubjectFlow::TRANSITION_PREPARE)] public function onPrepare(TransitionEvent $event): void { $image = $this->getImage($event); if ($image->getWorkflowQueue() === []) { $image->setWorkflowQueue([EnrichFromThumbnailTask::TASK]); } $this->entityManager->flush(); } #[AsTransitionListener(SubjectFlow::WORKFLOW_NAME, SubjectFlow::TRANSITION_OBSERVE)] public function onObserve(TransitionEvent $event): void { $image = $this->getImage($event); $this->taskRunner->runNext($image); $this->entityManager->flush(); } private function getImage(TransitionEvent $event): GalleryImage { $image = $event->getSubject(); \assert($image instanceof GalleryImage); return $image; } }
TaskRunner::runNext() removes one task from the queue, records claims through survos/claims-bundle, and appends any follow-up tasks returned by the task. For image workflows, EnrichFromThumbnailTask::TASK is usually the first observation task; it can append higher-resolution observation tasks such as OcrMistralTask::TASK or TranscribeHandwritingTask::TASK.
Naming
Inside Survos\AiWorkflowBundle, class names intentionally avoid the Ai prefix where the namespace already carries it:
SubjectFlowTaskInterfaceTaskRegistryTaskRunner
Failure Model
There is no failed place in the initial workflow. Failures should be recorded on task runs, claims, or app-specific fields while the subject remains at its current milestone. Apps can add a failure place later if they need one.
survos/ai-workflow-bundle 适用场景与选型建议
survos/ai-workflow-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 173 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「state」 「workflow」 「analysis」 「claims」 「ai」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 survos/ai-workflow-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 survos/ai-workflow-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 survos/ai-workflow-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Workflow for NetCommons Plugin
Doctrine implementation of the MetaborStd (Statemachine) for PHP 8.2+
The bundle for easy using json-rpc api on your project
A simple state dropdown field for SilverStripe forms
Workflow logger
A state Machine library for business processes
统计信息
- 总下载量: 173
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 50
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-11