reachai-onboarding
Integrate Java business systems with ReachAI SDK registration, SDK instance heartbeat, gateway/embed access, and optional API Management handoff. Use when asked to connect a Spring Boot service to Rea
Files24
View on GitHubSKILL.mdreachai-control-service/src/main/resources/ai-assist/skills/reachai-onboarding/SKILL.md
GitHubReachAI Onboarding
Operating Rules
Treat the current business repository as the source of truth. Inspect its language, project layout, runtime version, configuration, existing controller/service boundaries, and test commands before editing. For Java inspect Maven and Spring Boot; for C# inspect .NET/ASP.NET Core projects and their authentication setup.
For a PROJECT_ONBOARDING task, the reachai_ai_coding_task_context response contains project details, domainContext.sdkArtifacts, domainContext.gatewayChecklist, and domainContext.implementationGuidance. Use those task-scoped fields wherever the instructions below refer to the onboarding manifest. Independently authenticated project-key flows may use their supplied manifest instead.
For a C# ASP.NET Core project, use references/dotnet-sdk-access.md and identify the csharp artifact by its language/packageName. Independently authenticated project-key flows may request the manifest with ?language=csharp. Follow the C# reference for backend installation, configuration, identity and capability declaration. Steps 3–6 and Spring-specific details in steps 7–8 below apply only to Java; follow the language-neutral gateway, browser, verification and reporting requirements for both languages. Do not add Maven dependencies or Spring configuration to a C# project.
For a Python FastAPI project, read references/python-sdk-access.md and select the Python artifact from the task context. Independently authenticated project-key flows may request the manifest with ?language=python. Steps 3–6 and Spring-specific details in steps 7–8 apply only to Java; retain the shared browser, gateway, verification and reporting requirements. Do not add Maven or ASP.NET dependencies to a Python application.
For a Node.js Express project, read references/node-sdk-access.md and select the Node artifact from the task context. Independently authenticated project-key flows may request the manifest with ?language=node. Use the verified Node artifact and the business system’s authenticated session and authorization; do not add Spring or ASP.NET dependencies. Shared gateway, browser, verification and reporting requirements still apply.
For a Go application, read references/go-sdk-access.md and select the Go artifact from the task context. Independently authenticated project-key flows may request the manifest with ?language=go. Install the verified source archive by a local module replacement, not by guessing a public Go module proxy or requiring a ReachAI checkout. Use the business system's authenticated session and authorization. Shared gateway, browser, verification and reporting requirements still apply.
For a PHP application (native PHP, Laravel or ThinkPHP), read references/php-sdk-access.md and select the PHP artifact from the task context. Independently authenticated project-key flows may request the manifest with ?language=php. Install the verified zip through a Composer artifact repository, not by guessing a Packagist package. PHP-FPM has no background thread: registration and heartbeat run from the CLI (cron or a supervised loop), not inside web requests. Use the business system's authenticated session and authorization. Shared gateway, browser, verification and reporting requirements still apply.
凡是写入 ReachAI 或展示给业务用户的名称、标题、描述、说明、System Prompt、节点名称、审计原因、进度和结果,默认使用清晰的简体中文。不要仅因 API、Schema 或字段名为英文就生成英文业务文案。Token、MCP、AI、Agent、Supervisor、Workflow、Tool、API、SDK 等熟知专业术语,以及 keySlug、toolName、代码、路径、枚举值、协议字段和技术标识可保留英文;必要时使用“中文名称(英文术语)”。不要翻译或改写技术标识。
Never paste, print, or commit the registry app secret. Use the environment variable named by the manifest: normally REACHAI_REGISTRY_APP_SECRET for Java, ReachAI__AppSecret for C# ASP.NET Core, and REACHAI_APP_SECRET for Python, Node, Go or PHP when directly injecting credentials. Enrollment may instead use the relevant SDK's protected credential store.
For a PROJECT_ONBOARDING task, use the connected ReachAI platform MCP. Call reachai_project_onboarding_start for an authorized registered project, then reachai_ai_coding_task_context for the returned task. The connection and task binding stay with ReachAI; do not request, print, persist, or pass a task token or activation code.
Separate project/Workflow AI Coding APIs under /api/ai-coding/projects/** and /api/workflows/**/ai-coding/** can still use the explicit project aiCodingKey when the user independently supplies one. Send it as X-ReachAI-AiCoding-Key; never put it in a URL, browser bundle, task artifact, or progress event.
Prefer minimal, reviewable changes:
- Add ReachAI dependencies only to the modules that need them.
- Put
reachai-spring-boot2-starterin the runnable Spring Boot application module. - Put
reachai-capability-sdkin modules that declare@ReachCapabilitymethods or DTO field metadata. @ReachCapabilityis method-level,@ReachParamis parameter/field-level, and@ReachOutputis field-only on response DTO fields. Do not put@ReachOutputon methods.- Do not use the ReachAI platform base URL as a Maven repository or npm registry. Manifest/skill/self-check URLs are not Maven/npm repositories.
- Unique recommended Java SDK install (no ReachAI source checkout): with Node.js 18+, a JDK and Maven available, read the absolute Java entries in the onboarding manifest's
sdkArtifacts, expand{skillExtractDir}in eachinstallCommandTemplate, and runreachai-capability-sdkbeforereachai-spring-boot2-starter. The cross-platformscripts/install-java-sdk.mjsdownloads the declared JAR and standalone consumer POM, verifies both declared SHA-256 values, and installs them into the business system's Maven local repository. Fail if a URL or hash is absent or mismatched; do not guess another URL and do not require access to the ReachAI repository. - Unique recommended Embed SDK install (no ReachAI source checkout): read
sdkArtifactsfor@reachai/embed-chat, extract this Skill zip anywhere, then run the expandedinstallCommandTemplatefrom the business frontend directory that containspackage.json. The bundledscripts/install-embed-chat.mjsverifiesintegritySha256, copies the tgz to the stable repo-localvendor/reachai/directory, replaces the exact installed package directory, and records.reachai-artifact-sha256. Re-run this installer whenever a SNAPSHOT artifact checksum changes;npm install --forcealone does not prove that a same-version file dependency was refreshed.reachai-doctor --mode staticreportsEMBED_SDK_ARTIFACT_MATCH. Never runnpm installdirectly against a temporary Skill extract path, and never leave%TEMP%,.cursor,.traeor another machine-specific absolute path inpackage.json/ lockfiles. AuthenticateddownloadUrlneeds auth headers that npm cannot send, so prefer this Skill-bundled installer. - Do not invent dependency download paths such as
/repository/**,/maven/**,/repository/maven/**,/api/embed/sdk, or/npm/**. Do not usecd ai-admin-front && npm run build:sdkas the business-project install path. - Gateway checklist is a top-level
gatewayChecklistobject list on the onboarding manifest (id,description,required,verificationHint,failureImpact). Seereferences/java-sdk-access.md. - Avoid changing unrelated business logic, package structure, formatting, or dependency versions.
- SDK onboarding must not scan or sync business APIs on application startup. After compile, registration and heartbeat succeed, an active
PROJECT_ONBOARDINGtask may explicitly trigger an audited sync by callingreachai_ai_coding_task_verifywith its taskId andverificationKey=SDK_SYNC. Console users trigger SDK sync from the project's 业务能力 → 接入与变更. Restrict both paths to business-owned packages and exclude framework, platform, third-party, starter, and shared infrastructure controllers.
Workflow
- For an onboarding task, call
reachai_ai_coding_task_contextbefore scanning or editing, follow its required resources and task state, and use the connected MCP for task operations. For a standalone project-key flow, read the explicitly supplied onboarding manifest URL. - Download this skill package if it is not already installed, then read the reference files only as needed.
- Detect the project layout:
- Maven root and child modules.
- Java source level.
- Spring Boot version.
- Runnable application module.
- Business-owned Java base packages from application classes, controllers, services, and module names, as the explicit SDK sync boundary.
- Framework/platform packages that must be excluded from task-scoped or console SDK sync.
- Existing
application.yml,bootstrap.yml, profile-specific config, or config-center conventions. - Existing Spring Security, Sa-Token, Shiro, custom login interceptors, CSRF rules, gateway routes, and ingress/firewall boundaries that can affect the inbound SDK sync callback.
- Resolve and add dependencies using the manifest
sdkArtifacts,references/java-sdk-access.md, andtemplates/pom-dependencies.xml. Platform artifact links are the default when no corporate Maven publication exists. - Add configuration using
templates/application-reachai.yml. Do not add any capability startup-sync setting. Replace package placeholders only when preparing the explicit SDK sync boundary. Setreachai.project.base-urlto an address reachable from the ReachAI server; uselocalhost,127.0.0.1, or::1only when ReachAI and the business service actually share the same host or network namespace. - Do not scan or sync APIs at application startup. Only when the user explicitly asks to prepare API metadata, select one or two low-risk query-style business methods and annotate them with
@ReachCapability/@ReachParam. Usetemplates/reach-capability-example.javaonly as a style example. - Inspect the business gateway boundary before declaring onboarding complete:
- Spring Cloud Gateway, Nginx, backend-for-frontend, or front-end dev proxy configuration.
- Existing authentication headers and current-user extraction.
- Whether a server-side token broker already exists.
- Whether ReachAI can send
POST /reachai/registry/capabilities/syncto the Starter service through the configuredbase-urlandcontext-path.
- Add or update the gateway route/token broker:
- Route ReachAI capability traffic to the business service and preserve
X-ReachAI-Invocation-Token,X-ReachAI-Trace-Id,X-ReachAI-Run-Id, and the business identity headers required by the service. - If
reachai.project.base-urlpoints to a gateway or ingress, route/reachai/registry/**to the business service that containsreachai-spring-boot2-starter. PreserveX-ReachAI-App-Key,X-ReachAI-Timestamp,X-ReachAI-Nonce, andX-ReachAI-Signature. - Let
POST /reachai/registry/capabilities/syncbypass normal business login/JWT filters and CSRF so the request reaches the Starter controller. Apply the equivalent exclusion for Spring Security, Sa-Token, Shiro, or custom interceptors. Do not remove authentication from the endpoint: the Starter must still validate the ReachAI registry signature and return 401 for invalid requests. - Treat this callback as server-to-server traffic. CORS is irrelevant; restrict network exposure to the ReachAI service or trusted network when infrastructure supports it.
- Expose a front-end token endpoint such as
/api/reachai/embed-token. - Implement the token endpoint server-side with the Starter-provided
ReachAiEmbedTokenClient. Business code maps the current authenticated user toReachAiEmbedPrincipaland forwards the SDK-owned page identity; the client owns project signing, transport, and wrappeddata.tokenparsing. - Keep
/api/reachai/embed-tokenon the normal business login token path. It reads the current business user and exchanges that identity for a ReachAI embed token. - Add the gateway authentication whitelist or dedicated security chain for
/api/reachai/embed/**. This path carries ReachAI embed tokens, so business OAuth/JWT filters must not validate it as a business login token; forwardAuthorization: Bearer <embedToken>unchanged to ReachAI. - In Spring Security WebFlux / OAuth2 Resource Server,
permitAll()on/api/reachai/embed/**is not enough by itself: the resource server can still try to authenticate theBearer <embedToken>before routing and return 401. Add a higher-prioritySecurityWebFilterChainwithsecurityMatcher(ServerWebExchangeMatchers.pathMatchers("/api/reachai/embed/**"))that permits all and does not enableoauth2ResourceServer()for that matcher. - Inspect whitelist/anonymous filters that remove or rewrite JWT headers, such as
IgnoreUrlsRemoveJwtFilter,RemoveJwtFilter,RemoveRequestHeader=Authorization, or security filters that callmutate().header("Authorization", ""). Do not apply that header-clearing behavior to/api/reachai/embed/**; skipping business authentication must still preserve the embed tokenAuthorizationheader. - If Spring Cloud Gateway proxies
/api/reachai/embed/**, dedupe duplicate CORS response headers when both the gateway and ReachAI write them. A typical route filter isDedupeResponseHeader=Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_FIRST. - For a PROJECT_ONBOARDING task, use
domainContext.implementationGuidance.projectCopilotKeySlugas the front-endagentId. Verify the project Agent is available before browser acceptance; report any missing provisioning. Do not request or embed a project-level AI Coding key. - For an independently authenticated manifest flow,
manifest.agentProvisioning.provisionAgentUrlremains available to an AI coding tool, local shell, or server-side integration. It reuses an existing ACTIVE config and initializes defaults only when no config exists. An unpublished draft without an ACTIVE config returns 409: read and review the draft through Agent AI Coding instead of overwriting or automatically publishing it. After a timeout or failed publication, read current state before any retry; identity creation, config save and publication are separate steps. It does not create a placeholder Workflow. - When the user asks for another project Agent, Supervisor changes, or Skill binding, download
manifest.agentSupervisor.endpoints.skillPackageUrland follow theagent-ai-codingSkill. Use only the project-key endpoints in that manifest; never call console/api/agents/**or/api/skills/**with an AI Coding key. - Write only the supplied project copilot key slug into browser configuration. Never write an internal Agent id or any credential.
- Create Workflow drafts only for real business capabilities. Validate and publish each Workflow before adding it through
manifest.agentSupervisor.endpoints.workflowToolAttachUrlTemplate; the attach operation publishes the next Agent config version containing that Workflow-as-Tool. - Workflow attachment is additive by default because one page may legitimately expose several independent tools. To supersede one predecessor, first read the currently attached catalog and send its exact id as
replaceWorkflowId; ReachAI removes only that entry and preserves every other Workflow. Never infer replacement from pageKey, name, or display order. - If a project needs both page operations and explicit API-only queries, publish and attach two tools: a
PAGE_ASSISTANTfor page behavior and a read-onlyGENERALWorkflow for the API chain. Agent risk is declared per attached Workflow, not per branch inside one mixed graph. - Before generic Workflow attachment, read the provisioned Agent context. Send an explicit
agentIdoragentKeySlugplus itsbaseRevisionwithworkflowId. Do not omit the target or reuse a Workflow revision. OnAGENT_DRAFT_CHANGED, re-read and review changes instead of blindly retrying; read Agent context again after success. - Do not call provisioning from browser runtime code, and do not expose
aiCodingKeyto the business front end. - Do not ask the business user to manually create, choose, or configure the page copilot Agent during SDK onboarding.
- Treat that Agent as the single embedded page copilot entry. AgentScope Supervisor uses the conversation plus page context to select zero, one, or multiple published Workflows from the Agent config's Workflow-as-Tool allow-list.
- Never move
appSecretinto browser code.
- Route ReachAI capability traffic to the business service and preserve
- Add or update the business front-end integration:
- Add the ReachAI chat/embed entry in a real business page or shared shell, not only in documentation.
- Mount the launcher only after the authenticated application shell is ready. Do not initialize it on login, logout, silent-refresh, OAuth callback, or public routes. If authentication is lost, destroy the chat client before redirecting; an unauthenticated Token Broker request from an auth page is a defect, not runtime proof.
- Do not call
manifest.agentProvisioning.provisionAgentUrlfrom browser runtime code. Use the already provisioned bare JSONagent.keySlugasagentId(notdata.agent.keySlug). - Use
@reachai/embed-chatfor browser embedding when available. ConfigureapiBaseas the ReachAI platform origin by default; if the browser uses a gateway prefix, setembedPathPrefixsuch as/api/reachai/embed, or setapiBasedirectly to a recognized embed root such as/api/reachai/embed. - Configure
projectCode,agentId, and atokenProviderthat calls the business gateway token broker. Use the already provisioned page copilot AgentkeySlugforagentId. - Read
pageKey,pageInstanceId,route, andoriginfrom the@reachai/embed-chattokenProvidercontext and forward them unchanged through the business token broker. The SDK reuses the same Page Bridge identity for Chat Session creation and page actions. - For an SPA whose Page Workflow can target another registered page, configure the documented
createEafPageBridge({ onNavigate })adapter. Validate the requested target against the business route registry, use the normal router to navigate, then callchat.rebindPage({ bridge, page })from the target page only after its actions are registered. Do not register or hard-code the reserved navigation action key, session id, or navigation request id; the public SDK owns those details. - Never generate a fallback
pageInstanceIdin the token provider or business broker. A replacement UUID may make token exchange pass while causing Chat Session or Page Action identity mismatch. - Import
@reachai/embed-chat/style.css, mount one visible global launcher, and keep the SDK's visible-first Token state: Token Broker pending/failure must remain visible and retryable instead of being replaced by a business-side hidden failure. - Do not reuse the business login token for ReachAI chat session or message calls. Use the broker-returned short-lived embed token for
/api/reachai/embed/**,/api/embed/chat/sessions, and message APIs. - Chat message calls must use
POST /api/embed/chat/sessions/{sessionId}/messagesor the/messages/streamvariant with body{ "message": "..." }. - Do not send ReachAI chat requests as
{ "content": "..." },{ "text": "..." }, or{ "question": "..." }; map any business UI field tomessageat the ReachAI API boundary. - Chat responses are wrapped ApiResult objects. Top-level
code/messagedescribe transport status only; never render top-levelmessage: "success"as the assistant reply. Renderdata.answerfirst, with old-shape fallback only underdata.reply,data.message, ordata.content. - Embed SSE ends with
message.completed; there is nodoneevent. - See
references/platform-apis.mdfor ApiResult vs bare JSON response shapes andapiBaserules. - Treat
data.metadata.pageActionQueueas the preferred UI/Page Action queue. Treatdata.uiRequestanddata.uiRequest.extension.pageActionRequestas compatible single-action instructions. Execute them through the page bridge and report each request id back to/api/embed/chat/sessions/{sessionId}/page-actions/{requestId}/result; do not only renderdata.answer. - When the selected business page needs Page Actions, read
references/page-action-contract.md. For Angular, reusereferences/angular-page-action.mdandtemplates/angular/rather than inventing a second bridge protocol. - The optional helper can scaffold the Angular bridge without overwriting existing files:
powershell -File scripts/reachai-page-actions.ps1 -Mode scaffold-angular -FrontendRoot <frontend> -PageKey <pageKey>. Adapt the generated registry example to the page's real component methods. Scaffolding is not runtime verification. - Verify static alignment of the bridge, page key and expected action keys. On Windows the optional helper is
powershell -File scripts/reachai-page-actions.ps1 -Mode verify-static -FrontendRoot <frontend> -PageKey <pageKey> -ActionKeys <keys>; on other systems inspect the same source registrations with available search tools instead. A static PASS proves only source alignment; use an authenticated browser and a fresh Embed session before reporting runtime PASS. Use only an existing authorized business-system test session or account supplied outside ReachAI. If none is available, keepbrowserVerificationnull and report browser acceptance asNOT RUN; never fabricate evidence or place login credentials in task artifacts. - Cache embed tokens only until before their
expiresInboundary. If a session or message request returnsembed token is expired, clear the cached embed token, call the broker again, and retry once.
- Run the smallest meaningful verification commands for the touched backend, gateway, and front-end modules.
- After local compile/config succeeds, use
reachai_business_system_sdk_access_checkwith the project ID for a platform check, or explain why a live check cannot run. In an independently authenticated manifest flow, the manifest'ssdkAccessCheckUrlremains available.
- Interpret the platform SDK self-check separately:
CODE_READYrequires observed Starter registration,RUNTIME_READYrequires a fresh instance heartbeat, andSDK_CALLBACK_READYrequires a successful signed callback plus a received capability snapshot. - For an active onboarding task, after
CODE_READYandRUNTIME_READYare observed, callreachai_ai_coding_task_verifywith the taskId andverificationKey=SDK_SYNC. It is project-scoped, requires a RUNNING task, and records a verification event. - For a non-task manifest flow, use manual SDK sync in the project's 业务能力 → 接入与变更; do not invent project-key or public trigger endpoints.
- The SDK self-check does not prove browser acceptance. Task readiness
E2E_READYremains pending until ReachAI observes an authorized Embed session, user message and assistant reply created after the current task started. The session may come from the real browser SDK or fromreachai-doctor --mode e2eusing a business-supplied test Authorization/Cookie; doctor never mints or mocks the business identity. This proves only the authorized conversation protocol: declared Workflow capability nodes and Page Actions need their own exact-Trace / real-browser evidence in the Page Workbench. Final launcher visibility and interaction quality remain user acceptance items. - A computed SDK sync callback target is not proof of connectivity. The actual task-scoped or console sync must distinguish unreachable host/timeout, business-auth or CSRF 401/403, route/context-path 404/405, and Starter signature rejection.
- Follow
protocolGuide.eventStateRulesand usereachai_ai_coding_task_eventfor real STARTED and PROGRESS events. In WAITING_USER, PROGRESS preserves the state and open questions. Usereachai_ai_coding_task_askfor blocking ambiguities andreachai_ai_coding_task_questionsto read answers; send RESUMED only after all answers. Validate against the task-context JSON Schema, then submit exactly one logical result throughreachai_ai_coding_task_artifactwith its declared contract, artifact key and client event ID. Do not invent success evidence. - Report changed files, commands run, results, SDK sync verification status, the observed SDK sync callback target, its route/login/CSRF handling, optional scan package choices, gateway route/token broker status, front-end integration status, and whether the user-scoped secret still needs to be configured.
References
- For exact Java SDK signatures, read
references/java-sdk-api-reference.md; then usereferences/java-sdk-access.mdfor placement, configuration and runtime boundaries. - For C# ASP.NET Core, use
references/dotnet-sdk-access.mdand thecsharpartifact in the manifest. - For Python FastAPI, use
references/python-sdk-access.mdand thepythonartifact in the manifest. - For Node.js Express, use
references/node-sdk-access.mdand thenodeartifact in the manifest. - For platform API contracts, read
references/platform-apis.md. - For browser SDK public types and the minimal integration, read
references/embed-chat-quick-reference.md. - For Spring Cloud Gateway, Nginx and Kong authentication boundaries, read
references/gateway-examples.mdand reuse the copy-ready files underexamples/gateway/. - For credential handling and prompt safety, read
references/security.md. - For Page Bridge and action safety, read
references/page-action-contract.md. - For Angular Page Action integration, read
references/angular-page-action.md. - For ready-to-copy snippets, use files under
templates/. - For an optional local verification helper, run
scripts/verify-reachai-access.py. - For layered static/runtime onboarding diagnostics, run
node scripts/reachai-doctor.mjs --mode static --business-root <repo>and thennode scripts/reachai-doctor.mjs --mode runtime --manifest-url <onboardingManifestUrl>after services are available. For/api/ai-coding/projects/**, put the project AI Coding key in the current process environment variableREACHAI_AI_CODING_KEY; never pass the key as a command-line argument. Use--ai-coding-key-env <name>only when the repository already uses another secret environment variable name. - For non-interactive authorized conversation verification, let the business system provision a least-privilege test account/token outside ReachAI. Put the complete business Authorization value in
REACHAI_E2E_AUTHORIZATIONor the business Cookie header inREACHAI_E2E_COOKIE, then runnode scripts/reachai-doctor.mjs --mode e2e --broker-url <business-origin>/api/reachai/embed-token --embed-api-base <business-origin>/api/reachai/embed --agent-id <provisioned-key-slug> --page-key <page-key> --route <route>. Never put authorization values on the command line or into task events/artifacts.EMBED_CONVERSATION_E2E=PASSproves only the authorized broker/proxy/session/message protocol; doctor deliberately leavesWORKFLOW_CAPABILITY_E2EandPAGE_ACTION_BROWSER_E2EasPENDINGuntil real intent and real browser evidence are available. It does not prove launcher visibility. - On Windows,
scripts/set-reachai-registry-secret.ps1optionally stores a hidden-input secret in the current user's environment without printing it; start a new terminal/process before launching the business service. On other systems, use the business system's secret manager or protected runtime environment without printing or committing the value. - For optional Angular Page Action scaffolding/static alignment, run
scripts/reachai-page-actions.ps1.
Output Contract
End with:
- Files changed.
- Dependency/configuration summary.
- Gateway route and embed token broker summary.
- Front-end embed/chat integration summary.
- SDK sync verification, current business method/API source status, and capability declarations prepared.
- Verification commands and results.
- Whether
REACHAI_REGISTRY_APP_SECRETstill needs to be configured outside the repository. - Task id, whether progress/questions were written back, and the submitted artifact key.