import type { RequestContext } from '@mastra/core/request-context'; import type { IntegrationTools } from '../integrations/base.js'; import type { WorkItemsStorage } from '../storage/domains/work-items/base.js'; import type { FactorySessionSourceLookup } from './binding-context.js'; export interface ReviewSourceOutput { /** * Browser-facing deep-link back to the Factory session that produced this * review — the only field a review body publishes. Everything else on this * shape is an input to in-run cross-checks and the session handoff, never a * published field, so the GitHub/GitLab audience never sees the upstream * Linear/Jira slug through the review comment. */ sessionUrl: string; /** * PR/MR author recorded on the review card at intake — for GitHub this is * `pullRequest.user.login`, for GitLab it is the GitLab username. The skill * cross-checks it against the same REST field of the reviewed PR * (`gh api repos///pulls/ --jq .user.login`; `gh pr view` * formats App authors as `app/` instead of `[bot]`) or the * equivalent MR fetch; a mismatch means the session is bound to a different * PR/MR than the one being reviewed. */ triggeredBy: string | null; /** * The externalSource recorded on the review card itself — the PR/MR the * session was intake-bound to. The skill cross-checks the reviewed PR/MR * against this shape so a review can never quietly land on the wrong target. */ reviewTarget: { integrationId: string; type: string; externalId: string; url: string | null; } | null; /** * Repository identity stamped on the review card at intake — the * binding-side value for the null-`url` cross-check fallback. The skill must * compare this against an identity resolved independently of the card (e.g. * `gh api repos// --jq .id` — the numeric REST id — for the * session checkout's repository); * comparing two values derived from the same checkout proves nothing. * `null` when intake recorded no repository identity — in that case there * is no verifiable bound repository and the fallback must not publish. */ boundRepository: { provider: 'github'; repositoryId: number; } | { provider: 'gitlab'; host: string | null; projectId: number; } | null; } /** * Normalize the operator-provided browser-facing UI origin (the * `MASTRACODE_PUBLIC_URL` env var) into the `uiOrigin` the tool accepts. * * Blank counts as unset: `mastracode/web/.env.schema` ships * `MASTRACODE_PUBLIC_URL=` as the operator-facing line, so an empty or * whitespace-only value is the expected "not configured" state — it must map * to `null` (tool omitted) rather than register the tool and publish a * hostless `sessionUrl` into a public review body. */ export declare function resolveReviewSourceUiOrigin(raw: string | undefined): string | null; /** * `factory_review_source` — read the routing facts behind the current review * session (session deep-link, PR/MR author, the review target) so the review * agent can attribute its verdict to a concrete originating run and detect a * mis-targeted review before it publishes. * * The tool exists to make cross-PR misattribution detectable both in-run and * after the fact: a review lands on GitHub/GitLab with the Factory session URL * that produced it, and the human who investigates a suspicious review can * jump straight to the run. * * All fields are derived server-side from the bound work item — nothing enters * from the agent's tool arguments — so the session URL always points at the * caller's own session, never one it was asked to name. * * The tool is intentionally omitted (returns `{}`) whenever it cannot produce * a complete, correct provenance shape: no resolvable session address, no * active binding, a non-review-role binding, no bound work item, or no * configured browser-facing UI origin. Skills treat tool-absent identically to * tool-failed: stop-don't-publish. */ export declare function createReviewSourceTool(options: { requestContext: RequestContext; storage: Pick; sessions?: FactorySessionSourceLookup; /** * Browser-facing UI origin, no trailing slash. In a separate-SPA deployment * (API host distinct from UI host) this is the UI host — the origin the * emitted session link opens in. `MastraFactoryConfig.publicUrl` is the API * origin and must not be used here; the caller resolves the UI origin (see * `factory.ts`) via the `MASTRACODE_PUBLIC_URL` env var. * * `null` means no browser-facing origin is configured. Match the Slack * session-link surface (`integrations/slack/slack.ts:168-171`, `:809-812`), * which omits the deep-link entirely rather than publishing an API/localhost * URL into a public body: the tool is dropped from the toolset, and the * skill's tool-not-available branch stops publication. */ uiOrigin: string | null; }): Promise; //# sourceMappingURL=review-source-tool.d.ts.map