life-sciences-fieldsalesrep-coordinate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLife Sciences Cloud End-to-End Orchestrator
Life Sciences Cloud端到端编排器
Runs the complete Life Sciences Cloud setup workflow as five stages in strict sequence, gating each on the success of the previous stage. Each stage delegates to a child skill or a reference workflow, organized internally into phases and steps (defined under Execution Order below).
按严格顺序运行完整的Life Sciences Cloud设置工作流,包含五个Stage,每个Stage的启动以上一Stage成功为前提。每个Stage会委托给子skill或参考工作流,内部划分为Phase和Step(定义见下方“执行顺序”)。
Scope Guard (evaluate FIRST)
范围校验(优先执行)
Serve only requests for the full end-to-end LSC setup. A single stage/phase/step is never invokable here — never silently expand a partial ask into the whole flow. Before any work:
- Unrelated to LSC setup (at start or mid-run) → do not attempt it. Tell the user you did not understand the request and show what you can help with (full end-to-end LSC setup, or standalone /
life-sciences-prerequisites-validate); stop.life-sciences-territory-configure - Stage with its own standalone skill — prerequisites (Stage 1) or territory config (Stage 3) → redirect to /
life-sciences-prerequisites-validate; stop.life-sciences-territory-configure - Stage with no standalone skill — config deploy (2), user provisioning (4), visit creation (5) → explain these run only as part of the full flow, not on their own; stop. Do not launch the full flow unless the user then asks for it.
Continue only for the complete end-to-end setup: orchestrating the full flow (prerequisites → config deploy → territory → user provisioning → visit creation) in order with gates. Each stage's actual work is delegated to child skills / reference files.
仅处理完整端到端LSC设置的请求。单个Stage/Phase/Step绝不在此处调用——切勿将部分请求自动扩展为完整流程。开始任何工作前:
- 与LSC设置无关(无论在流程开头还是中途)→ 请勿尝试处理。告知用户无法理解请求,并说明可提供的帮助(完整端到端LSC设置,或独立的/
life-sciences-prerequisites-validate);终止流程。life-sciences-territory-configure - 拥有独立skill的Stage——先决条件(Stage 1)或区域配置(Stage 3)→ 重定向至/
life-sciences-prerequisites-validate;终止流程。life-sciences-territory-configure - 无独立skill的Stage——配置部署(2)、用户配置(4)、拜访创建(5)→ 说明这些仅能作为完整流程的一部分运行,无法单独执行;终止流程。除非用户随后明确请求完整流程,否则请勿启动完整流程。
仅在用户请求完整端到端设置时继续:按顺序编排完整流程(先决条件→配置部署→区域设置→用户配置→拜访创建),并设置阶段准入条件。每个Stage的实际工作由子skill或参考文件完成。
Required Inputs
必要输入
Gather before proceeding:
- Target org: The org to deploy to — selected by the user from the list of connected orgs, or a freshly authenticated org (see Phase 0). Never assume a default org silently; always have the user confirm or select the target org before any stage runs.
开始前需收集:
- 目标组织:要部署的组织——由用户从已连接组织列表中选择,或新认证的组织(见Phase 0)。切勿默认使用任何组织;必须在任何Stage运行前让用户确认或选择目标组织。
Execution Order (MANDATORY)
执行顺序(强制要求)
Terminology: Stage = one of the 5 units of work (1–5), each delegated to a child skill or a reference workflow; Phase = a named group of work inside a stage; Step = an atomic action inside a phase. So "Stage 2 › Phase 1 › Step 3" reads top-to-bottom.
Run in this order, each gated on the previous (see the full dependency diagram in ):
references/orchestration-flow.md| # | Stage | Runs | Gate (must pass to advance) | Output |
|---|---|---|---|---|
| — | Setup: download | — | Folder present (MANDATORY — hard stop) | Shared source folder in CWD |
| 1 | Prerequisites Validation | | All prerequisites PASS | Org confirmed ready |
| 2 | Starter Config Deploy | | All 13 deploy steps succeed | LSC Custom Profile exists |
| 3 | Territory Configuration | | Territory model Active + L3 territory | Level-3 territory ID + name |
| 4 | User Provisioning | | User created, permsets + territory assigned | Rep username |
| 5 | Sample Visit Creation | | Visit + supporting records created; metadata cache generated | — |
术语定义:Stage = 5个工作单元之一(1–5),每个委托给子skill或参考工作流;Phase = Stage内的一组命名工作;Step = Phase内的原子操作。例如“Stage 2 › Phase 1 › Step 3”从上到下读取。
按以下顺序运行,每个Stage以上一Stage通过准入条件为前提(完整依赖图见):
references/orchestration-flow.md| # | Stage | 执行内容 | 准入条件(必须通过才能推进) | 输出结果 |
|---|---|---|---|---|
| — | 准备工作:下载 | — | 文件夹存在(强制要求——未满足则终止) | 当前工作目录中的共享源文件夹 |
| 1 | 先决条件验证 | | 所有先决条件通过 | 确认组织已就绪 |
| 2 | 初始配置部署 | | 全部13个部署步骤成功 | LSC Custom Profile已存在 |
| 3 | 区域配置 | | 区域模型已激活 + 存在L3级区域 | L3级区域ID及名称 |
| 4 | 用户配置 | | 用户已创建,权限集 + 区域已分配 | 销售代表用户名 |
| 5 | 样本拜访创建 | | 拜访及支持记录已创建;元数据缓存已生成 | — |
Workflow
工作流
Phase 0 — Org Selection (MANDATORY, runs first)
Phase 0 — 组织选择(强制要求,优先运行)
Before presenting the workflow, establish which org to use. Do this every time the user asks to set up Life Sciences Cloud — do not silently reuse the current default org.
-
List connected orgs:bash
sf org list --jsonParse the result and present the authenticated orgs (non-expired) to the user as a numbered list — include alias, username, org type (Dev Hub / Sandbox / Scratch / Production), and the default marker if any:textConnected Orgs — select the target for Life Sciences Cloud setup ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. ls-dev alice@example.com (Dev Hub) [default] 2. ls-sandbox alice@example.com.sandbox (Sandbox) 3. partial-scr test-xyz@example.com (Scratch) N. Log in to a fresh org (opens a browser to authenticate a new org) -
Ask the user to choose: "Which org would you like to use? Enter a number, or choose N to log in to a fresh org."
-
Handle the selection:
-
Existing org chosen → capture its username/alias as the target org for all subsequent steps.
-
Fresh org chosen (option N) → authenticate a new org interactively: ask for the login URL (My Domain / instance URL, e.g.;
https://mydomain.my.salesforce.comfor production,https://login.salesforce.comfor a sandbox) and an alias (e.g.https://test.salesforce.com), then run the login command yourself:ls-setupbashsf org login web --instance-url <user-supplied-url> --alias <user-supplied-alias> --set-defaultDo not hand the command to the user to run — execute it directly. It opens a browser on the user's machine for them to complete the web login interactively; the command then returns. After it finishes, re-runto confirm the new org, then use it as the target org.sf org list --json
-
-
Confirm the target org back to the user before proceeding: "Using <alias> (<username>) as the target org for Life Sciences Cloud setup." Store this in.
OrchestrationState.targetOrg
Ifreturns no authenticated orgs, go straight to the fresh-org login flow (option N) — there is nothing to select from.sf org list
展示工作流前,先确定要使用的组织。每次用户请求设置Life Sciences Cloud时都需执行此步骤——切勿默认复用当前组织。
-
列出已连接组织:bash
sf org list --json解析结果,并将已认证(未过期)的组织以编号列表形式展示给用户——包含别名、用户名、组织类型(Dev Hub / Sandbox / Scratch / Production),以及默认标记(如有):text已连接组织 — 选择Life Sciences Cloud设置的目标组织 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. ls-dev alice@example.com (Dev Hub) [默认] 2. ls-sandbox alice@example.com.sandbox (Sandbox) 3. partial-scr test-xyz@example.com (Scratch) N. 登录新组织(打开浏览器认证新组织) -
请求用户选择:“您想要使用哪个组织?请输入编号,或选择N登录新组织。”
-
处理选择:
-
选择现有组织 → 捕获其用户名/别名作为后续所有步骤的目标组织。
-
选择新组织(选项N) → 交互式认证新组织:请求登录URL(自定义域名/实例URL,例如;生产环境为
https://mydomain.my.salesforce.com,沙箱环境为https://login.salesforce.com)和别名(例如https://test.salesforce.com),然后自行运行登录命令:ls-setupbashsf org login web --instance-url <user-supplied-url> --alias <user-supplied-alias> --set-default切勿将命令交给用户运行——直接执行。该命令会在用户机器上打开浏览器,供用户完成交互式网页登录;命令完成后返回。执行完成后,重新运行确认新组织,然后将其作为目标组织。sf org list --json
-
-
向用户确认目标组织后再继续:“将**<别名>**(<用户名>)作为Life Sciences Cloud设置的目标组织。” 将此信息存储在中。
OrchestrationState.targetOrg
如果未返回任何已认证组织,直接进入新组织登录流程(选项N)——无组织可供选择。sf org list
Phase 1 — Introduction and Confirmation
Phase 1 — 介绍与确认
-
Present the workflow to the user:text
Life Sciences Cloud — Full Setup Workflow ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ This will execute 5 stages in sequence. Each stage is internally organized into phases and steps. Stage 1: Validate Prerequisites Checks org settings, permissions, and features Stage 2: Deploy Starter Configuration Deploys objects, profiles, config records, layouts, flexipages Stage 3: Configure Territories Creates territory type, model, and 3-level hierarchy Stage 4: Provision Field Sales Rep User Creates user, assigns profile/permsets, assigns to territory Stage 5: Create Sample Visit Logs in as the rep, creates account/provider/visit records, generates the mobile metadata cache Target org: <org> -
Ask for confirmation: "Ready to begin the full Life Sciences Cloud setup? (yes/no)"
-
Download the shared source folder ONCE (MANDATORY — hard gate, before any stage). Both Stage 2 (Starter Config Deploy — metadata + config records) and Stage 5 (Sample Visit Creation — Data CSVs) read from; those stages do NOT download or delete it — the orchestrator owns a single download here and a single delete in Phase 8. Sparse-checkout only that subtree (the repo is large) into the CWD:
.lsc-starter-config/LSStarterConfig/bashgit clone --no-checkout --depth 1 --filter=blob:none \ https://github.com/SalesforceLabs/LSStarterConfig.git lsstarter-tmp cd lsstarter-tmp && git sparse-checkout init --cone \ && git sparse-checkout set Codey/LSStarterConfig && git checkout && cd .. mv lsstarter-tmp/Codey ./.lsc-starter-config && rm -rf lsstarter-tmpcontains its own.lsc-starter-config/LSStarterConfig/(pinssfdx-project.json) — the deploy step (Phase 3) must run from inside it. If the folder already exists in the CWD (from a prior run), reuse it (skip the download).sourceApiVersion: 65.0 -
Download gate — verify the folder exists before proceeding. Confirm the download succeeded by checking thatand
.lsc-starter-config/LSStarterConfig/sfdx-project.jsonare present (e.g..lsc-starter-config/LSStarterConfig/Data/).ls .lsc-starter-config/LSStarterConfig/sfdx-project.json .lsc-starter-config/LSStarterConfig/Data-
If present → setin
sourceFolderDownloaded: trueand proceed to Phase 2.OrchestrationState -
If the download failed or the folder/contents are missing → STOP. Do NOT proceed to any stage — every stage depends on this folder. Report the failure and stop:text
STOP: Setup cannot start — source download failed Could not download .lsc-starter-config/LSStarterConfig from https://github.com/SalesforceLabs/LSStarterConfig.git Likely: no network / GitHub unreachable, git < 2.25 (no sparse-checkout), or insufficient disk space / write permission in the CWD. Mandatory prerequisite — no stage can run without it. Fix the cause and re-run, or download the folder manually into the CWD, then re-run.Leaveand do not advance the workflow.sourceFolderDownloaded: false
-
-
向用户展示工作流:text
Life Sciences Cloud — 完整设置工作流 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 此工作流将按顺序执行5个Stage。每个Stage内部划分为Phase和Step。 Stage 1: 验证先决条件 检查组织设置、权限及功能 Stage 2: 部署初始配置 部署对象、配置文件、配置记录、布局、Flexipage Stage 3: 配置区域 创建区域类型、模型及三级层级 Stage 4: 配置外勤销售代表用户 创建用户,分配配置文件/权限集,分配至区域 Stage 5: 创建样本拜访 以销售代表身份登录,创建客户/医疗服务商/拜访记录, 生成移动元数据缓存 目标组织: <org> -
请求确认:“是否准备开始完整的Life Sciences Cloud设置?(是/否)”
-
仅下载一次共享源文件夹(强制要求——硬准入条件,在任何Stage之前)。Stage 2(初始配置部署——元数据+配置记录)和Stage 5(样本拜访创建——数据CSV)均读取;这些Stage不会下载或删除该文件夹——编排器仅在此处下载一次,并在Phase 8删除一次。仅将该子树(仓库较大)稀疏检出到当前工作目录:
.lsc-starter-config/LSStarterConfig/bashgit clone --no-checkout --depth 1 --filter=blob:none \ https://github.com/SalesforceLabs/LSStarterConfig.git lsstarter-tmp cd lsstarter-tmp && git sparse-checkout init --cone \ && git sparse-checkout set Codey/LSStarterConfig && git checkout && cd .. mv lsstarter-tmp/Codey ./.lsc-starter-config && rm -rf lsstarter-tmp包含自身的.lsc-starter-config/LSStarterConfig/(固定sfdx-project.json)——部署步骤(Phase 3)必须在该文件夹内运行。如果当前工作目录中已存在该文件夹(来自之前的运行),则复用(跳过下载)。sourceApiVersion: 65.0 -
下载准入条件——继续前验证文件夹是否存在。通过检查和
.lsc-starter-config/LSStarterConfig/sfdx-project.json是否存在来确认下载成功(例如运行.lsc-starter-config/LSStarterConfig/Data/)。ls .lsc-starter-config/LSStarterConfig/sfdx-project.json .lsc-starter-config/LSStarterConfig/Data-
如果存在 → 在中设置
OrchestrationState,并继续至Phase 2。sourceFolderDownloaded: true -
如果下载失败或文件夹/内容缺失 → 终止流程。请勿进入任何Stage——所有Stage都依赖此文件夹。报告失败并终止:text
终止:设置无法启动——源文件下载失败 无法从 https://github.com/SalesforceLabs/LSStarterConfig.git 下载.lsc-starter-config/LSStarterConfig 可能原因:无网络/GitHub无法访问、git版本低于2.25(无稀疏检出功能)、 或当前工作目录磁盘空间不足/无写入权限。 这是强制先决条件——无此文件夹任何Stage都无法运行。修复问题后重新运行, 或手动将文件夹下载至当前工作目录后重新运行。将保留为false,不推进工作流。sourceFolderDownloaded: false
-
Phase 2 — Execute Stage 1: Prerequisites Validation
Phase 2 — 执行Stage 1:先决条件验证
-
Run the prerequisites validation following theskill workflow exactly.
life-sciences-prerequisites-validate -
Gate check: Review the results.
- If ALL prerequisites pass → proceed to Stage 2
- If ANY prerequisite fails → stop and present the failure report
textSTOP: Stage 1 FAILED — Prerequisites not met <show the prerequisite failure table> Please resolve the failed prerequisites and re-run this workflow.Ask the user: "Would you like to continue anyway (skip failed prerequisites), or stop and fix them first?"- If user says stop → end the workflow
- If user says continue → proceed with a warning that later stages may fail
-
严格按照skill工作流运行先决条件验证。
life-sciences-prerequisites-validate -
准入条件检查:查看结果。
- 如果所有先决条件通过 → 继续至Stage 2
- 如果任何先决条件失败 → 终止流程并展示失败报告
text终止:Stage 1失败——未满足先决条件 <展示先决条件失败表格> 请解决失败的先决条件后重新运行此工作流。询问用户:“您想要继续执行(跳过失败的先决条件),还是终止流程先修复问题?”- 如果用户选择终止 → 结束工作流
- 如果用户选择继续 → 继续执行并警告后续Stage可能失败
Phase 3 — Execute Stage 2: Starter Config Deploy
Phase 3 — 执行Stage 2:初始配置部署
-
Run the starter config deployment followingexactly (all 13 steps in order); read its own reference files as directed.
references/stage-2-starter-config-overview.md -
Gate check: Verify the LSC Custom Profile exists:bash
sf data query --query "SELECT Id, Name FROM Profile WHERE Name = 'LSC Custom Profile'" --target-org <org> --json- If profile exists → proceed to Stage 3
- If profile not found → stop and report deployment failure
-
严格按照运行初始配置部署(按顺序执行全部13个步骤);按指示读取其参考文件。
references/stage-2-starter-config-overview.md -
准入条件检查:验证LSC Custom Profile是否存在:bash
sf data query --query "SELECT Id, Name FROM Profile WHERE Name = 'LSC Custom Profile'" --target-org <org> --json- 如果配置文件存在 → 继续至Stage 3
- 如果未找到配置文件 → 终止流程并报告部署失败
Phase 4 — Execute Stage 3: Territory Configuration
Phase 4 — 执行Stage 3:区域配置
-
Run the territory configuration following theskill workflow exactly.
life-sciences-territory-configure -
Gate check: Verify the territory model is Active and level-3 territory exists:
bash
sf data query --query "SELECT Id, Name, DeveloperName, Territory2Model.State FROM Territory2 WHERE ParentTerritory2.ParentTerritory2Id != null AND Territory2Model.State = 'Active'" --target-org <org> --json- If level-3 territory found with Active model → capture the territory ID and name, proceed to Stage 4
- If not found → stop and report the issue
-
严格按照skill工作流运行区域配置。
life-sciences-territory-configure -
准入条件检查:验证区域模型已激活且存在L3级区域:
bash
sf data query --query "SELECT Id, Name, DeveloperName, Territory2Model.State FROM Territory2 WHERE ParentTerritory2.ParentTerritory2Id != null AND Territory2Model.State = 'Active'" --target-org <org> --json- 如果找到已激活模型下的L3级区域 → 捕获区域ID和名称,继续至Stage 4
- 如果未找到 → 终止流程并报告问题
Phase 5 — Execute Stage 4: User Provisioning
Phase 5 — 执行Stage 4:用户配置
-
Run the user provisioning followingexactly; read its own reference file as directed. Pass the territory information captured from Stage 3.
references/stage-4-user-provisioning-overview.md -
Gate check: Verify the user exists, has the correct profile, all 4 permission sets, and territory assignment. Capture the rep username — Stage 5 logs in as this user.STOP-GATE (Stage 4 completeness). Do NOT accept "user created" as passing this gate — verify all four facets and STOP if any is short:bash
sf data query --query "SELECT COUNT(Id) c FROM PermissionSetAssignment WHERE AssigneeId = '<newUserId>' AND PermissionSet.IsOwnedByProfile = false" --target-org <org> --jsonThe permset count MUST be 4 ({LifeSciencesCore, LifeSciencesFieldSalesRepresentative, HealthCloudStarter, LifeSciencesKeyAccountManager}); the user MUST beon theIsActive=true; and aLSC Custom Profileto the level-3 territory MUST exist. If the permset count is < 4 or any facet is missing, Stage 4 did not fully complete — re-run the missing part ofUserTerritory2Association(its own Phase 4/5 stop-gates cover this) before advancing to Stage 5. A rep missing a permset silently fails visit creation downstream with confusing permission errors.references/stage-4-user-provisioning-overview.md
-
严格按照运行用户配置;按指示读取其参考文件。传入从Stage 3捕获的区域信息。
references/stage-4-user-provisioning-overview.md -
准入条件检查:验证用户已存在、拥有正确的配置文件、全部4个权限集,且已分配区域。捕获销售代表用户名——Stage 5将以此用户身份登录。终止准入条件(Stage 4完整性)。仅“用户已创建”不满足通过条件——必须验证全部四个方面,如有缺失则终止流程:bash
sf data query --query "SELECT COUNT(Id) c FROM PermissionSetAssignment WHERE AssigneeId = '<newUserId>' AND PermissionSet.IsOwnedByProfile = false" --target-org <org> --json权限集数量必须为4({LifeSciencesCore, LifeSciencesFieldSalesRepresentative, HealthCloudStarter, LifeSciencesKeyAccountManager});用户必须在下处于LSC Custom Profile状态;且必须存在与L3级区域关联的IsActive=true。如果权限集数量小于4或任何方面缺失,说明Stage 4未完全完成——在推进至Stage 5前,重新运行UserTerritory2Association中缺失的部分(其自身的Phase 4/5终止准入条件已覆盖此情况)。销售代表缺失权限集将导致后续拜访创建因权限错误失败,且错误信息难以排查。references/stage-4-user-provisioning-overview.md
Phase 6 — Execute Stage 5: Sample Visit Creation
Phase 6 — 执行Stage 5:样本拜访创建
-
Run the visit creation followingexactly; read its own reference files as directed. Pass the rep username captured from Stage 4. This stage:
references/stage-5-visit-creation-overview.md- Logs in as the rep user () and creates account, healthcare provider, and visit records (rep-owned), plus territory associations and product master data (admin-owned).
sf org login web - Generates the mobile metadata cache via the Connect API (admin-owned).
This stage uses two identities — the rep user (from Stage 4) for visit records and the admin for product master data and metadata cache generation. Follow the child skill's rep/admin split exactly. - Logs in as the rep user (
-
Gate check: Verify at least one Visit record was created:bash
sf data query --query "SELECT Id, Name, AccountId FROM Visit ORDER BY CreatedDate DESC LIMIT 1" --target-org <org> --json- If a Visit exists → proceed to the final summary
- If no Visit found → stop and report the visit-creation failure
-
严格按照运行拜访创建;按指示读取其参考文件。传入从Stage 4捕获的销售代表用户名。此Stage:
references/stage-5-visit-creation-overview.md- 以销售代表用户身份登录()并创建客户、医疗服务商和拜访记录(归销售代表所有),以及区域关联和产品主数据(归管理员所有)。
sf org login web - 通过Connect API生成移动元数据缓存(归管理员所有)。
此Stage使用两个身份——销售代表用户(来自Stage 4)用于创建拜访记录,管理员用于产品主数据和元数据缓存生成。严格遵循子skill的身份划分规则。 - 以销售代表用户身份登录(
-
准入条件检查:验证至少已创建一条拜访记录:bash
sf data query --query "SELECT Id, Name, AccountId FROM Visit ORDER BY CreatedDate DESC LIMIT 1" --target-org <org> --json- 如果存在拜访记录 → 继续至最终总结
- 如果未找到拜访记录 → 终止流程并报告拜访创建失败
Phase 7 — Final Summary
Phase 7 — 最终总结
-
Display the complete workflow summary — a "Life Sciences Cloud Setup Complete" header followed by one block per stage (substitute actual values from the run):
- Stage 1: all org prerequisites confirmed.
- Stage 2: objects/profiles/config records deployed, layouts +
<N>flexipages deployed, 28 trigger handlers activated.<N> - Stage 3: Territory Model (Active); Level-3 Territory
<model name>.<territory name> - Stage 4: User (
<firstName> <lastName>); Profile<username>; permission sets Life Sciences Core, Life Sciences Field Sales Representative, Health Cloud Starter, Life Sciences Key Account Management; TerritoryLSC Custom Profile; admin also assigned to the territory.<territory name> - Stage 5: Account + Healthcare Provider created; Visit (Territory
<subject>); product detailing/discussion records; mobile metadata cache generated (Connect API).<territory name>
Close with: "The org is ready for Life Sciences Cloud field sales workflows."
-
展示完整工作流总结——以“Life Sciences Cloud设置完成”为标题,每个Stage对应一个区块(替换为本次运行的实际值):
- Stage 1:所有组织先决条件已确认。
- Stage 2:已部署对象/配置文件/配置记录,已部署个布局 +
<N>个Flexipage,已激活28个触发器处理程序。<N> - Stage 3:区域模型(已激活);L3级区域
<model name>。<territory name> - Stage 4:用户(
<firstName> <lastName>);配置文件<username>;权限集Life Sciences Core、Life Sciences Field Sales Representative、Health Cloud Starter、Life Sciences Key Account Management;区域LSC Custom Profile;管理员也已分配至该区域。<territory name> - Stage 5:已创建客户 + 医疗服务商;拜访(区域
<subject>);产品展示/讨论记录;已生成移动元数据缓存(通过Connect API)。<territory name>
结尾:“该组织已就绪,可运行Life Sciences Cloud外勤销售工作流。”
Phase 8 — Cleanup (delete the shared source folder ONCE)
Phase 8 — 清理(仅删除一次共享源文件夹)
-
After the final summary (all 5 stages complete), delete thefolder downloaded in Phase 1 to leave the working directory clean. Run from the CWD (the parent of
.lsc-starter-config):.lsc-starter-config/bashrm -rf .lsc-starter-configDo this silently — do NOT print a cleanup line or mention the folder deletion in the final output. Skip if the workflow stopped on a failure and the user may resume — keep the folder until the flow completes so a resumed stage can still read it. This is the single deletion for the whole flow; the child skills never delete it.
-
在最终总结后(所有5个Stage完成),删除Phase 1中下载的文件夹,保持工作目录整洁。从当前工作目录(
.lsc-starter-config的父目录)运行:.lsc-starter-config/bashrm -rf .lsc-starter-config此操作静默执行——请勿在最终输出中打印清理信息或提及文件夹删除。如果工作流因失败终止且用户可能恢复流程,则跳过此步骤——保留文件夹直到流程完成,以便恢复的Stage仍可读取。这是整个流程中唯一的删除操作;子skill绝不会删除该文件夹。
State Tracking
状态跟踪
Maintain overall orchestration state:
text
OrchestrationState = {
targetOrg: string,
sourceFolderDownloaded: boolean, // .lsc-starter-config/LSStarterConfig downloaded in Phase 1, deleted in Phase 8
stages: [
{ name: "Prerequisites", status: "pending|running|passed|failed|skipped" },
{ name: "StarterConfig", status: "pending|running|passed|failed" },
{ name: "TerritorySetup", status: "pending|running|passed|failed", territoryId?: string, territoryName?: string },
{ name: "UserProvisioning", status: "pending|running|passed|failed", userId?: string, username?: string },
{ name: "VisitCreation", status: "pending|running|passed|failed", visitId?: string }
]
}维护整体编排状态:
text
OrchestrationState = {
targetOrg: string,
sourceFolderDownloaded: boolean, // .lsc-starter-config/LSStarterConfig在Phase 1下载,在Phase 8删除
stages: [
{ name: "Prerequisites", status: "pending|running|passed|failed|skipped" },
{ name: "StarterConfig", status: "pending|running|passed|failed" },
{ name: "TerritorySetup", status: "pending|running|passed|failed", territoryId?: string, territoryName?: string },
{ name: "UserProvisioning", status: "pending|running|passed|failed", userId?: string, username?: string },
{ name: "VisitCreation", status: "pending|running|passed|failed", visitId?: string }
]
}Idempotent Stage Transitions & Mid-Flow Changes
幂等Stage转换与流程中途变更
Stages are not re-entrant. Before executing any stage, check its in : → reply "Stage N is already in progress" and take no action; → ask for explicit confirmation before re-running; → re-run (intentional recovery); → advance. Transition status to at execution start (not on user input) so accidental double-confirms never run a stage twice.
statusOrchestrationStaterunningpassedfailedpendingrunningIf the user requests a change to an earlier stage's inputs while a later stage is in progress or pending, run an impact assessment first: acknowledge without applying, identify affected vs. unaffected stages, present options (re-run affected / apply going forward only / cancel), and wait for the decision. Surface destructive-change warnings (an activated territory model can't be deleted; an existing user/records remain).
The full behavior matrix, impact-assessment template, per-change impact mapping, and destructive-change warnings are in .
references/state-machine-and-changes.mdStage不可重入。执行任何Stage前,检查中的: → 回复“Stage N正在执行中”且不执行任何操作; → 重新运行前需获得明确确认; → 重新运行(主动恢复); → 推进流程。在执行开始时将状态转换为(而非用户输入时),避免因重复确认导致Stage被运行两次。
OrchestrationStatestatusrunningpassedfailedpendingrunning如果用户在后续Stage执行中或待执行时请求修改早期Stage的输入,先进行影响评估:确认收到请求但暂不应用,识别受影响和未受影响的Stage,提供选项(重新运行受影响Stage/仅应用于后续流程/取消),等待用户决策。需提示破坏性变更警告(已激活的区域模型无法删除;现有用户/记录将保留)。
完整行为矩阵、影响评估模板、变更影响映射及破坏性变更警告见。
references/state-machine-and-changes.mdRules / Constraints
规则/约束
| Constraint | Rationale |
|---|---|
| Always run Phase 0 org selection first; list connected orgs and let the user pick or log in to a fresh org | User must explicitly choose the target org; never silently reuse the default |
Download | Both child skills read from the shared folder — proceeding without it guarantees downstream failures |
| Execute stages strictly in order 1→5, gating each on prior success | Each stage depends on outputs from previous stages; prevents cascading failures |
| Never skip Stages 2 or 3, or Stage 4 before Stage 5 | User provisioning depends on profile + territory; visit creation logs in as the Stage-4 rep |
| Follow each child skill's workflow exactly; capture outputs (IDs, names) for later stages | Child skills have their own confirmations; avoids redundant re-queries |
Never re-execute a | Race-free idempotency against duplicate "Proceed" messages |
| Perform impact assessment before applying mid-flow changes | User must see what will break/redo before committing to a change |
| 约束 | 理由 |
|---|---|
| 始终优先运行Phase 0组织选择;列出已连接组织并让用户选择或登录新组织 | 用户必须明确选择目标组织;切勿默认复用当前组织 |
仅下载一次 | 两个子skill均读取共享文件夹——无此文件夹将导致后续流程必然失败 |
| 严格按1→5顺序执行Stage,每个Stage以上一Stage成功为前提 | 每个Stage依赖前一Stage的输出;避免级联失败 |
| 切勿跳过Stage 2或3,或在Stage 4前执行Stage 5 | 用户配置依赖配置文件+区域;拜访创建需以Stage 4的销售代表身份登录 |
| 严格遵循每个子skill的工作流;捕获输出(ID、名称)供后续Stage使用 | 子skill有自身的确认逻辑;避免重复查询 |
未经明确确认,切勿重新执行 | 避免因重复“继续”消息导致的竞态问题,保证幂等性 |
| 应用流程中途变更前先进行影响评估 | 用户必须了解变更将破坏/重做的内容,再确认提交 |
Gotchas
常见问题
| Issue | Resolution |
|---|---|
| Source download fails in Phase 1 (network/git/disk) | Hard stop — do NOT run any stage. Report the failure (see Phase 1 download gate); fix the cause or download |
| No connected orgs found | |
| Fresh-org / rep login needs a browser | Run |
| Artifacts exist from a prior run (profile, territory, user, config) | The child skills are idempotent/upsert-safe and detect existing records — query the org to confirm, then skip or re-run safely |
| Visit creation uses two identities (rep + admin) | Product master data and metadata cache are admin-owned; follow the child skill's rep/admin split |
| Stage re-triggered, or user changes an earlier input mid-flow | See the transition matrix and impact assessment in |
| 问题 | 解决方案 |
|---|---|
| Phase 1中源文件下载失败(网络/git/磁盘问题) | 硬终止——切勿运行任何Stage。报告失败(见Phase 1下载准入条件);修复问题或手动将 |
| 未找到已连接组织 | |
| 新组织/销售代表登录需要浏览器 | 自行运行 |
| 存在之前运行的遗留工件(配置文件、区域、用户、配置) | 子skill支持幂等/更新安全操作,可检测现有记录——查询组织确认后,安全跳过或重新运行 |
| 拜访创建使用两个身份(销售代表+管理员) | 产品主数据和元数据缓存归管理员所有;严格遵循子skill的身份划分规则 |
| Stage被重新触发,或用户在流程中途修改早期输入 | 见 |
Resume / Partial Re-run
恢复/部分重运行
If the user may have already completed some stages (e.g. from a prior session), ask which, then verify each claimed-complete stage by querying the org (Stage 1 = ask; 2 = ; 3 = active model + L3 territory; 4 = user with correct profile/permsets; 5 = a record). Skip verified stages and resume from the first incomplete one. Exact detection queries per stage are in → Resume Logic.
LSC Custom ProfileVisitreferences/orchestration-flow.md如果用户可能已完成部分Stage(例如来自之前的会话),询问已完成的Stage,然后通过查询组织验证每个声称已完成的Stage(Stage 1 = 询问;2 = 存在;3 = 已激活模型+L3级区域;4 = 用户拥有正确配置文件/权限集;5 = 存在记录)。跳过已验证的Stage,从第一个未完成的Stage恢复。每个Stage的具体检测查询见 → 恢复逻辑。
LSC Custom ProfileVisitreferences/orchestration-flow.mdOutput Expectations
输出预期
Deliverables:
- folder downloaded once (Phase 1) and removed once (Phase 8) — both done silently; not reported in the final summary
.lsc-starter-config/LSStarterConfig - All 5 stages executed successfully (or user-acknowledged skips)
- Full summary of what was created/configured
- Org ready for Life Sciences Cloud field sales workflows
交付成果:
- 文件夹仅下载一次(Phase 1)并仅删除一次(Phase 8)——均静默执行;不会在最终总结中报告
.lsc-starter-config/LSStarterConfig - 所有5个Stage已成功执行(或用户确认跳过)
- 已创建/配置内容的完整总结
- 组织已就绪,可运行Life Sciences Cloud外勤销售工作流
Reference File Index
参考文件索引
| File | When to read |
|---|---|
| At start — the dependency diagram, per-stage gate verification queries, resume-detection queries, and timing expectations |
| When a stage is re-triggered or the user changes an earlier input mid-flow — the full transition behavior matrix, impact-assessment template + mapping, and destructive-change warnings |
| During Stage 2 (Phase 3) — the full 13-step starter-config deploy workflow; it points to its own sibling references as needed |
| During Stage 4 (Phase 5) — the full field-sales-rep user provisioning workflow; it points to its own sibling reference as needed |
| During Stage 5 (Phase 6) — the full sample-visit creation workflow; it points to its own sibling references as needed |
| 文件 | 读取时机 |
|---|---|
| 流程开始时——依赖图、每个Stage的准入验证查询、恢复检测查询及时间预期 |
| Stage被重新触发或用户在流程中途修改早期输入时——完整转换行为矩阵、影响评估模板+映射及破坏性变更警告 |
| Stage 2执行期间(Phase 3)——完整的13步初始配置部署工作流;会指向自身的同级参考文件 |
| Stage 4执行期间(Phase 5)——完整的外勤销售代表用户配置工作流;会指向自身的同级参考文件 |
| Stage 5执行期间(Phase 6)——完整的样本拜访创建工作流;会指向自身的同级参考文件 |