@mastra/factory 0.24.0-alpha.6 → 0.24.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/boards/review.d.ts.map +1 -1
- package/dist/boards/review.js +21 -1
- package/dist/boards/review.js.map +1 -1
- package/dist/boards/work-transition-policy.d.ts.map +1 -1
- package/dist/boards/work-transition-policy.js +2 -1
- package/dist/boards/work-transition-policy.js.map +1 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +103 -19
- package/dist/factory.js.map +1 -1
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +26 -22
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +2 -3
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +78 -7
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +28 -21
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/slack/integration.d.ts.map +1 -1
- package/dist/integrations/slack/integration.js +33 -6
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +25 -24
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/routes/config.d.ts +37 -2
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +83 -41
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/custom-provider-source.d.ts +8 -0
- package/dist/routes/custom-provider-source.d.ts.map +1 -1
- package/dist/routes/custom-provider-source.js +22 -1
- package/dist/routes/custom-provider-source.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +2 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +6 -2
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/surface.js +1 -1
- package/dist/routes/work-items.js +2 -2
- package/dist/rules/dispatch-errors.d.ts.map +1 -1
- package/dist/rules/dispatch-errors.js +12 -0
- package/dist/rules/dispatch-errors.js.map +1 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +42 -3
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/session/channel-reply-processor.d.ts +35 -0
- package/dist/session/channel-reply-processor.d.ts.map +1 -0
- package/dist/session/channel-reply-processor.js +46 -0
- package/dist/session/channel-reply-processor.js.map +1 -0
- package/dist/session/channel-session-link-processor.d.ts +39 -0
- package/dist/session/channel-session-link-processor.d.ts.map +1 -0
- package/dist/session/channel-session-link-processor.js +99 -0
- package/dist/session/channel-session-link-processor.js.map +1 -0
- package/dist/session/factory-session.d.ts +4 -0
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +1 -0
- package/dist/session/factory-session.js.map +1 -1
- package/dist/session/reply-credential-processor.d.ts.map +1 -1
- package/dist/session/reply-credential-processor.js +4 -6
- package/dist/session/reply-credential-processor.js.map +1 -1
- package/dist/session/run-audit.d.ts +24 -0
- package/dist/session/run-audit.d.ts.map +1 -1
- package/dist/session/run-audit.js +93 -7
- package/dist/session/run-audit.js.map +1 -1
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/storage/domains/source-control/base.d.ts +7 -0
- package/dist/storage/domains/source-control/base.d.ts.map +1 -1
- package/dist/storage/domains/source-control/base.js +12 -0
- package/dist/storage/domains/source-control/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts +4 -0
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +8 -0
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +2 -2
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +5 -0
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/tools/approval-tools.d.ts +1 -1
- package/dist/tools/approval-tools.d.ts.map +1 -1
- package/dist/tools/approval-tools.js +3 -1
- package/dist/tools/approval-tools.js.map +1 -1
- package/dist/tools/deliver.d.ts +16 -2
- package/dist/tools/deliver.d.ts.map +1 -1
- package/dist/tools/deliver.js +12 -2
- package/dist/tools/deliver.js.map +1 -1
- package/dist/tools/index.d.ts +6 -5
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +9 -12
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/messaging-tools.d.ts +1 -1
- package/dist/tools/messaging-tools.d.ts.map +1 -1
- package/dist/tools/messaging-tools.js +84 -3
- package/dist/tools/messaging-tools.js.map +1 -1
- package/dist/tools/permissions.d.ts.map +1 -1
- package/dist/tools/permissions.js +3 -0
- package/dist/tools/permissions.js.map +1 -1
- package/dist/tools/read-tools.d.ts +3 -0
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +16 -8
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/reports.d.ts.map +1 -1
- package/dist/tools/reports.js +3 -1
- package/dist/tools/reports.js.map +1 -1
- package/dist/tools/scope.d.ts +6 -0
- package/dist/tools/scope.d.ts.map +1 -1
- package/dist/tools/scope.js +10 -1
- package/dist/tools/scope.js.map +1 -1
- package/dist/tools/session-tools.d.ts +14 -2
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +69 -9
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/sessions-state-processor.d.ts +5 -1
- package/dist/tools/sessions-state-processor.d.ts.map +1 -1
- package/dist/tools/sessions-state-processor.js +32 -48
- package/dist/tools/sessions-state-processor.js.map +1 -1
- package/dist/tools/side-sessions.d.ts +53 -0
- package/dist/tools/side-sessions.d.ts.map +1 -0
- package/dist/tools/side-sessions.js +83 -0
- package/dist/tools/side-sessions.js.map +1 -0
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +46 -26
- package/dist/tools/work-item-tools.js.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-audit.js","names":[],"sources":["../../src/session/run-audit.ts"],"sourcesContent":["import type { AgentControllerEvent } from '@mastra/core/agent-controller';\nimport { z } from 'zod';\n\nimport type { AuditActorType } from '../storage/domains/audit/base.js';\nimport type { AuditRecorder } from '../storage/domains/audit/domain.js';\n\nexport const FACTORY_OPEN_RUNS_SETTING = 'factoryOpenRuns';\n\nconst factoryOpenRunSchema = z.object({\n kickoffId: z.string(),\n bindingId: z.string(),\n role: z.string(),\n startedBy: z.string(),\n orgId: z.string(),\n factoryProjectId: z.string(),\n workItemId: z.string(),\n workItemName: z.string().optional(),\n sessionId: z.string(),\n threadId: z.string(),\n branch: z.string(),\n /**\n * Which dispatcher process is watching this run, and when it last said so\n * (epoch ms). The ledger is a thread setting shared by every replica, so a\n * remote reader needs these to tell a run that is live elsewhere from one\n * that died with its process. Absent on entries written before ownership\n * was recorded; those read as stale.\n */\n ownerId: z.string().optional(),\n heartbeatAt: z.number().optional(),\n});\n\nexport type FactoryOpenRun = z.infer<typeof factoryOpenRunSchema>;\n\n/** A heartbeat older than this means the owner is gone; nothing renews it once the run's dispatcher dies. */\nexport const FACTORY_OPEN_RUN_STALE_MS = 30_000;\n\nexport function isOpenRunLiveElsewhere(run: FactoryOpenRun, ownerId: string, now = Date.now()): boolean {\n return (\n run.ownerId !== undefined &&\n run.ownerId !== ownerId &&\n run.heartbeatAt !== undefined &&\n now - run.heartbeatAt < FACTORY_OPEN_RUN_STALE_MS\n );\n}\n\nexport interface RunEndCaptureSession {\n readonly thread: {\n getSetting(args: { key: string }): Promise<unknown>;\n setSetting(args: { key: string; value: unknown }): Promise<void>;\n };\n subscribe(listener: (event: AgentControllerEvent) => void): () => void;\n}\n\ntype RunEndReason = Extract<AgentControllerEvent, { type: 'agent_end' }>['reason'];\nconst pendingWrites = new WeakMap<RunEndCaptureSession, Promise<void>>();\n\nfunction serializeRunAudit(session: RunEndCaptureSession, write: () => Promise<void>): Promise<void> {\n const pending = (pendingWrites.get(session) ?? Promise.resolve())\n .then(write)\n .catch(error => console.warn('[Factory run audit] Unable to record run lifecycle.', error));\n pendingWrites.set(session, pending);\n return pending;\n}\n\nexport async function listSessionOpenRuns(session: RunEndCaptureSession): Promise<FactoryOpenRun[]> {\n const stored = await session.thread.getSetting({ key: FACTORY_OPEN_RUNS_SETTING });\n return z.array(factoryOpenRunSchema).parse(stored ?? []);\n}\n\nexport async function waitForSessionRunAudit(session: RunEndCaptureSession): Promise<void> {\n await (pendingWrites.get(session) ?? Promise.resolve());\n}\n\nfunction runAuditInput(run: FactoryOpenRun) {\n // Ownership fields are dispatcher bookkeeping, not part of the run's audit record.\n const { orgId, factoryProjectId, workItemId, workItemName, ownerId, heartbeatAt, ...metadata } = run;\n void ownerId;\n void heartbeatAt;\n return {\n orgId,\n factoryProjectId,\n idempotencyKey: run.kickoffId,\n targets: [{ type: 'work_item', id: workItemId, ...(workItemName ? { name: workItemName } : {}) }],\n metadata,\n };\n}\n\nasync function recordRunEnds(\n session: RunEndCaptureSession,\n audit: AuditRecorder,\n reason: RunEndReason,\n kickoffId?: string,\n): Promise<void> {\n if (!reason || reason === 'suspended') return;\n const runs = await listSessionOpenRuns(session);\n if (runs.length === 0) return;\n const remaining = [];\n for (const run of runs) {\n if (kickoffId && run.kickoffId !== kickoffId) {\n remaining.push(run);\n continue;\n }\n const input = runAuditInput(run);\n const recorded = await audit.record({\n ...input,\n actorId: `agent:${run.threadId}`,\n actorType: 'agent',\n action: 'factory.run.ended',\n metadata: { ...input.metadata, reason },\n });\n if (!recorded) remaining.push(run);\n }\n await session.thread.setSetting({ key: FACTORY_OPEN_RUNS_SETTING, value: remaining });\n}\n\nexport function recordSessionRunStart(\n session: RunEndCaptureSession,\n {\n audit,\n run,\n actorType,\n observedEnd,\n }: {\n audit: AuditRecorder;\n run: FactoryOpenRun;\n actorType: AuditActorType;\n observedEnd: () => RunEndReason;\n },\n): Promise<void> {\n return serializeRunAudit(session, async () => {\n const runs = await listSessionOpenRuns(session);\n if (!runs.some(existing => existing.kickoffId === run.kickoffId)) {\n await session.thread.setSetting({ key: FACTORY_OPEN_RUNS_SETTING, value: [...runs, run] });\n }\n await audit.record({\n ...runAuditInput(run),\n actorId: run.startedBy,\n actorType,\n action: 'factory.run.started',\n });\n await recordRunEnds(session, audit, observedEnd(), run.kickoffId);\n });\n}\n\n/** Renew this process's claim on an open run so other replicas keep treating it as live. */\nexport function heartbeatSessionOpenRun(\n session: RunEndCaptureSession,\n kickoffId: string,\n at = Date.now(),\n): Promise<void> {\n return serializeRunAudit(session, async () => {\n const runs = await listSessionOpenRuns(session);\n if (!runs.some(run => run.kickoffId === kickoffId)) return;\n await session.thread.setSetting({\n key: FACTORY_OPEN_RUNS_SETTING,\n value: runs.map(run => (run.kickoffId === kickoffId ? { ...run, heartbeatAt: at } : run)),\n });\n });\n}\n\nexport function observeSessionRunEnd(session: RunEndCaptureSession, { audit }: { audit: AuditRecorder }): () => void {\n return session.subscribe(event => {\n if (event.type !== 'agent_end' || !event.reason || event.reason === 'suspended') return;\n void serializeRunAudit(session, () => recordRunEnds(session, audit, event.reason));\n });\n}\n"],"mappings":";;AAMA,MAAa,4BAA4B;AAEzC,MAAM,uBAAuB,EAAE,OAAO;CACpC,WAAW,EAAE,OAAO;CACpB,WAAW,EAAE,OAAO;CACpB,MAAM,EAAE,OAAO;CACf,WAAW,EAAE,OAAO;CACpB,OAAO,EAAE,OAAO;CAChB,kBAAkB,EAAE,OAAO;CAC3B,YAAY,EAAE,OAAO;CACrB,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS;CAClC,WAAW,EAAE,OAAO;CACpB,UAAU,EAAE,OAAO;CACnB,QAAQ,EAAE,OAAO;;;;;;;;CAQjB,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,aAAa,EAAE,OAAO,CAAC,CAAC,SA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B,eAAe,cAAc,SAAS,OAAO,MAAM,MAAM,CAAC;CACnF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"run-audit.js","names":[],"sources":["../../src/session/run-audit.ts"],"sourcesContent":["import type { AgentControllerEvent } from '@mastra/core/agent-controller';\nimport { z } from 'zod';\n\nimport type { AuditActorType } from '../storage/domains/audit/base.js';\nimport type { AuditRecorder } from '../storage/domains/audit/domain.js';\n\nexport const FACTORY_OPEN_RUNS_SETTING = 'factoryOpenRuns';\n\nconst factoryOpenRunSchema = z.object({\n kickoffId: z.string(),\n bindingId: z.string(),\n role: z.string(),\n startedBy: z.string(),\n orgId: z.string(),\n factoryProjectId: z.string(),\n workItemId: z.string(),\n workItemName: z.string().optional(),\n sessionId: z.string(),\n threadId: z.string(),\n branch: z.string(),\n /**\n * Which dispatcher process is watching this run, and when it last said so\n * (epoch ms). The ledger is a thread setting shared by every replica, so a\n * remote reader needs these to tell a run that is live elsewhere from one\n * that died with its process. Absent on entries written before ownership\n * was recorded; those read as stale.\n */\n ownerId: z.string().optional(),\n heartbeatAt: z.number().optional(),\n});\n\nexport type FactoryOpenRun = z.infer<typeof factoryOpenRunSchema>;\n\n/** A heartbeat older than this means the owner is gone; nothing renews it once the run's dispatcher dies. */\nexport const FACTORY_OPEN_RUN_STALE_MS = 30_000;\n\nexport function isOpenRunLiveElsewhere(run: FactoryOpenRun, ownerId: string, now = Date.now()): boolean {\n return (\n run.ownerId !== undefined &&\n run.ownerId !== ownerId &&\n run.heartbeatAt !== undefined &&\n now - run.heartbeatAt < FACTORY_OPEN_RUN_STALE_MS\n );\n}\n\nexport interface RunEndCaptureSession {\n readonly thread: {\n getSetting(args: { key: string }): Promise<unknown>;\n setSetting(args: { key: string; value: unknown }): Promise<void>;\n };\n subscribe(listener: (event: AgentControllerEvent) => void): () => void;\n}\n\ntype RunEndReason = Extract<AgentControllerEvent, { type: 'agent_end' }>['reason'];\ntype StepUsage = Extract<AgentControllerEvent, { type: 'usage_update' }>['usage'];\nconst pendingWrites = new WeakMap<RunEndCaptureSession, Promise<void>>();\n\n/**\n * JSON budget for the per-step entries on a run's audit record. Audit metadata\n * is capped at 4 KB as a whole and an oversized record loses all of it, so\n * later steps are dropped (and counted) instead; totals always cover every step.\n */\nexport const FACTORY_RUN_USAGE_STEPS_JSON_BUDGET = 2400;\n\nconst USAGE_FIELDS = [\n 'promptTokens',\n 'completionTokens',\n 'totalTokens',\n 'reasoningTokens',\n 'cachedInputTokens',\n 'cacheCreationInputTokens',\n 'cacheCreationInputTokens5m',\n 'cacheCreationInputTokens1h',\n] as const;\n\ntype UsageCounts = Partial<Record<(typeof USAGE_FIELDS)[number], number>>;\n\n/**\n * Token usage attached to a run's `factory.run.ended` audit record.\n * `unreported` means this process saw no usage for the run (it ran elsewhere,\n * the process restarted, or the model reported none). It is never zero spend.\n */\nexport type FactoryRunUsage =\n | {\n status: 'recorded';\n stepCount: number;\n totals: UsageCounts;\n steps: UsageCounts[];\n stepsTruncated?: number;\n /** Other runs that ended in the same agent turn; the turn's usage can't be split between them. */\n sharedWithKickoffIds?: string[];\n }\n | { status: 'unreported' };\n\nfunction usageCounts(usage: StepUsage): UsageCounts {\n const counts: UsageCounts = {};\n for (const field of USAGE_FIELDS) {\n const value = usage[field];\n if (typeof value === 'number') counts[field] = value;\n }\n return counts;\n}\n\nfunction runUsage(steps: UsageCounts[]): FactoryRunUsage {\n if (steps.length === 0) return { status: 'unreported' };\n const totals: UsageCounts = {};\n for (const step of steps) {\n for (const field of USAGE_FIELDS) {\n if (step[field] !== undefined) totals[field] = (totals[field] ?? 0) + step[field];\n }\n }\n const kept: UsageCounts[] = [];\n let length = 2;\n for (const step of steps) {\n length += JSON.stringify(step).length + 1;\n if (length > FACTORY_RUN_USAGE_STEPS_JSON_BUDGET) break;\n kept.push(step);\n }\n return {\n status: 'recorded',\n stepCount: steps.length,\n totals,\n steps: kept,\n ...(steps.length > kept.length ? { stepsTruncated: steps.length - kept.length } : {}),\n };\n}\n\ninterface EndedTurn {\n steps: UsageCounts[];\n claimed: boolean;\n}\n\ninterface SessionUsage {\n /** Steps of the turn in progress; a suspended turn keeps accumulating into its resume. */\n current: UsageCounts[];\n /** The most recently ended turn, which a run whose ledger entry lands after that end may still claim. */\n lastTurn?: EndedTurn;\n /** Usage of runs whose end record failed to persist, kept for the retry. */\n held: Map<string, FactoryRunUsage>;\n}\n\nconst sessionUsage = new WeakMap<RunEndCaptureSession, SessionUsage>();\n\nfunction usageFor(session: RunEndCaptureSession): SessionUsage {\n let usage = sessionUsage.get(session);\n if (!usage) {\n usage = { current: [], held: new Map() };\n sessionUsage.set(session, usage);\n }\n return usage;\n}\n\nfunction serializeRunAudit(session: RunEndCaptureSession, write: () => Promise<void>): Promise<void> {\n const pending = (pendingWrites.get(session) ?? Promise.resolve())\n .then(write)\n .catch(error => console.warn('[Factory run audit] Unable to record run lifecycle.', error));\n pendingWrites.set(session, pending);\n return pending;\n}\n\nexport async function listSessionOpenRuns(session: RunEndCaptureSession): Promise<FactoryOpenRun[]> {\n const stored = await session.thread.getSetting({ key: FACTORY_OPEN_RUNS_SETTING });\n return z.array(factoryOpenRunSchema).parse(stored ?? []);\n}\n\nexport async function waitForSessionRunAudit(session: RunEndCaptureSession): Promise<void> {\n await (pendingWrites.get(session) ?? Promise.resolve());\n}\n\nfunction runAuditInput(run: FactoryOpenRun) {\n // Ownership fields are dispatcher bookkeeping, not part of the run's audit record.\n const { orgId, factoryProjectId, workItemId, workItemName, ownerId, heartbeatAt, ...metadata } = run;\n void ownerId;\n void heartbeatAt;\n return {\n orgId,\n factoryProjectId,\n idempotencyKey: run.kickoffId,\n targets: [{ type: 'work_item', id: workItemId, ...(workItemName ? { name: workItemName } : {}) }],\n metadata,\n };\n}\n\nasync function recordRunEnds(\n session: RunEndCaptureSession,\n audit: AuditRecorder,\n reason: RunEndReason,\n kickoffId?: string,\n endedTurn?: EndedTurn,\n): Promise<void> {\n if (!reason || reason === 'suspended') return;\n const usage = usageFor(session);\n const runs = await listSessionOpenRuns(session);\n if (runs.length === 0) return;\n const ending = runs.filter(run => !kickoffId || run.kickoffId === kickoffId);\n // An end event bills the turn it closed. A run whose ledger entry lands after its turn ended\n // bills the latest ended turn, unless an open run already claimed it.\n const turn = endedTurn ?? usage.lastTurn;\n const steps = turn && !turn.claimed ? turn.steps : [];\n if (turn && ending.length > 0) turn.claimed = true;\n const turnUsage = runUsage(steps);\n const remaining = [];\n for (const run of runs) {\n if (!ending.includes(run)) {\n remaining.push(run);\n continue;\n }\n let runUsageRecord = usage.held.get(run.kickoffId);\n if (!runUsageRecord) {\n const shared = ending.filter(other => other !== run).map(other => other.kickoffId);\n runUsageRecord =\n turnUsage.status === 'recorded' && shared.length > 0\n ? { ...turnUsage, sharedWithKickoffIds: shared }\n : turnUsage;\n usage.held.set(run.kickoffId, runUsageRecord);\n }\n const input = runAuditInput(run);\n const recorded = await audit.record({\n ...input,\n actorId: `agent:${run.threadId}`,\n actorType: 'agent',\n action: 'factory.run.ended',\n metadata: { ...input.metadata, reason, usage: runUsageRecord },\n });\n if (recorded) {\n usage.held.delete(run.kickoffId);\n } else {\n console.warn(\n `[Factory run audit] Token usage for run ${run.kickoffId} (${run.role}) was not persisted; keeping it for the next attempt.`,\n runUsageRecord,\n );\n remaining.push(run);\n }\n }\n await session.thread.setSetting({ key: FACTORY_OPEN_RUNS_SETTING, value: remaining });\n}\n\nexport function recordSessionRunStart(\n session: RunEndCaptureSession,\n {\n audit,\n run,\n actorType,\n observedEnd,\n }: {\n audit: AuditRecorder;\n run: FactoryOpenRun;\n actorType: AuditActorType;\n observedEnd: () => RunEndReason;\n },\n): Promise<void> {\n return serializeRunAudit(session, async () => {\n const runs = await listSessionOpenRuns(session);\n if (!runs.some(existing => existing.kickoffId === run.kickoffId)) {\n await session.thread.setSetting({ key: FACTORY_OPEN_RUNS_SETTING, value: [...runs, run] });\n }\n await audit.record({\n ...runAuditInput(run),\n actorId: run.startedBy,\n actorType,\n action: 'factory.run.started',\n });\n await recordRunEnds(session, audit, observedEnd(), run.kickoffId);\n });\n}\n\n/** Renew this process's claim on an open run so other replicas keep treating it as live. */\nexport function heartbeatSessionOpenRun(\n session: RunEndCaptureSession,\n kickoffId: string,\n at = Date.now(),\n): Promise<void> {\n return serializeRunAudit(session, async () => {\n const runs = await listSessionOpenRuns(session);\n if (!runs.some(run => run.kickoffId === kickoffId)) return;\n await session.thread.setSetting({\n key: FACTORY_OPEN_RUNS_SETTING,\n value: runs.map(run => (run.kickoffId === kickoffId ? { ...run, heartbeatAt: at } : run)),\n });\n });\n}\n\nexport function observeSessionRunEnd(session: RunEndCaptureSession, { audit }: { audit: AuditRecorder }): () => void {\n const usage = usageFor(session);\n return session.subscribe(event => {\n if (event.type === 'usage_update') {\n usage.current.push(usageCounts(event.usage));\n return;\n }\n if (event.type !== 'agent_end' || !event.reason || event.reason === 'suspended') return;\n // Close the turn now so a following turn's steps never land in this run.\n const turn: EndedTurn = { steps: usage.current, claimed: false };\n usage.current = [];\n usage.lastTurn = turn;\n void serializeRunAudit(session, () => recordRunEnds(session, audit, event.reason, undefined, turn));\n });\n}\n"],"mappings":";;AAMA,MAAa,4BAA4B;AAEzC,MAAM,uBAAuB,EAAE,OAAO;CACpC,WAAW,EAAE,OAAO;CACpB,WAAW,EAAE,OAAO;CACpB,MAAM,EAAE,OAAO;CACf,WAAW,EAAE,OAAO;CACpB,OAAO,EAAE,OAAO;CAChB,kBAAkB,EAAE,OAAO;CAC3B,YAAY,EAAE,OAAO;CACrB,cAAc,EAAE,OAAO,CAAC,CAAC,SAAS;CAClC,WAAW,EAAE,OAAO;CACpB,UAAU,EAAE,OAAO;CACnB,QAAQ,EAAE,OAAO;;;;;;;;CAQjB,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS;CAC7B,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;AACnC,CAAC;;AAKD,MAAa,4BAA4B;AAEzC,SAAgB,uBAAuB,KAAqB,SAAiB,MAAM,KAAK,IAAI,GAAY;CACtG,OACE,IAA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AAG,OAAO,CAAC,gBAAgB,CAAC,CAoiB5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-control-tools.js","names":[],"sources":["../../src/session/source-control-tools.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport type { WorkspaceSandbox } from '@mastra/core/workspace';\nimport { z } from 'zod';\n\nimport { getFactoryAuthOrgId, getFactoryAuthUserFromContext, getFactoryAuthUserId } from '../auth.js';\nimport type { VersionControl } from '../capabilities/version-control.js';\nimport type { IntegrationTools } from '../integrations/base.js';\nimport {\n ensureLocalBranch,\n isCheckoutOf,\n pushRepositoryBranch,\n refreshMergeRequestCheckout,\n} from '../integrations/github/sandbox.js';\nimport { normalizedVerdictLine } from '../review-verdict.js';\nimport type { ExecutableSandbox } from '../sandbox/materialization.js';\nimport { resolveSessionWorkdir } from '../sandbox/session-sandbox.js';\nimport type { AuditAgentEmitter } from '../storage/domains/audit/domain.js';\nimport type {\n ProjectRepository,\n SourceControlRepository,\n SourceControlSession,\n SourceControlStorageHandle,\n} from '../storage/domains/source-control/base.js';\nimport { mergeRequestNumberFromBranch } from '../work-item-branch.js';\nimport { environmentSlugs, findEnvironmentRepository, resolveSessionRepositories } from './environment-repositories.js';\nimport { updateSessionEnvironmentRepository } from './environment-state-processor.js';\n\ntype RepositorySessionState = {\n factoryProjectId?: string;\n projectRepositoryId?: string;\n};\n\nexport interface SourceControlToolProvider {\n id: string;\n storage: SourceControlStorageHandle;\n versionControl: VersionControl;\n}\n\ninterface SessionTarget {\n context: AgentControllerRequestContext<RepositorySessionState>;\n provider: SourceControlToolProvider;\n session: SourceControlSession;\n projectRepository: ProjectRepository;\n repository: SourceControlRepository;\n orgId: string;\n userId: string;\n /** True when the target is the link the session is filed under, the default. */\n ownRepository: boolean;\n}\n\ntype ReviewEvent = 'approve' | 'request-changes' | 'comment';\n\n/** Returns why a review's leading `Verdict:` line contradicts the submitted event, if it does. */\nexport function verdictEventMismatch(event: ReviewEvent, body: string | undefined): string | undefined {\n const match = /^verdict: ?(approve|request changes|changes requested)\\b/.exec(normalizedVerdictLine(body) ?? '');\n if (!match) return undefined;\n const verdict = match[1] === 'approve' ? 'approve' : 'request changes';\n // GitLab has no request-changes state, so a blocking verdict is published as a comment review.\n const allowed: ReviewEvent[] = verdict === 'approve' ? ['approve'] : ['request-changes', 'comment'];\n if (allowed.includes(event)) return undefined;\n return `Review body opens with \"Verdict: ${verdict}\" but event is \"${event}\". Nothing was posted. Use event ${allowed\n .map(e => `\"${e}\"`)\n .join(' or ')} for this body, or regenerate the body for the verdict you intend.`;\n}\n\nconst REVIEWED_HEAD_LINE = /^[\\s*_>-]*reviewed head[*_]*:[*_]*\\s*(.*)$/gim;\nconst FULL_SHA = /^`?([0-9a-f]{40}|[0-9a-f]{64})`?(?:\\s|$)/i;\n\n/**\n * Returns the full SHA named by the body's `Reviewed head:` lines, `null` when any line is malformed or the lines\n * disagree, or `undefined` when absent.\n */\nexport function reviewedHeadFromBody(body: string | undefined): string | null | undefined {\n const shas = new Set(\n [...(body ?? '').matchAll(REVIEWED_HEAD_LINE)].map(\n line => FULL_SHA.exec(line[1]!.trim())?.[1]?.toLowerCase() ?? null,\n ),\n );\n if (shas.size === 0) return undefined;\n if (shas.size > 1) return null;\n return [...shas][0];\n}\n\nfunction authIdentity(requestContext: RequestContext) {\n const user = getFactoryAuthUserFromContext(requestContext);\n return { orgId: getFactoryAuthOrgId(user), userId: getFactoryAuthUserId(user) };\n}\n\nasync function resolveProviderSession(\n resourceId: string,\n providers: readonly SourceControlToolProvider[],\n): Promise<{ provider: SourceControlToolProvider; session: SourceControlSession }> {\n const matches = (\n await Promise.all(\n providers.map(async provider => ({\n provider,\n session: await provider.storage.sessions.getBySessionId(resourceId),\n })),\n )\n ).filter(\n (match): match is { provider: SourceControlToolProvider; session: SourceControlSession } => match.session !== null,\n );\n if (matches.length !== 1) {\n throw new Error(\n matches.length === 0\n ? 'The active session is not backed by a source-control repository.'\n : 'The active session is ambiguous across source-control providers.',\n );\n }\n return matches[0]!;\n}\n\nasync function resolveSessionTarget(\n requestContext: RequestContext,\n providers: readonly SourceControlToolProvider[],\n options: { repository?: string } = {},\n): Promise<SessionTarget> {\n const context = requestContext.get('controller') as AgentControllerRequestContext<RepositorySessionState> | undefined;\n const { orgId, userId } = authIdentity(requestContext);\n if (!context?.resourceId || !orgId || !userId) {\n throw new Error('Source-control tools require an authenticated repository session.');\n }\n\n const { provider, session } = await resolveProviderSession(context.resourceId, providers);\n if (session.orgId !== orgId || (session.visibility === 'private' && session.userId !== userId)) {\n throw new Error('The active source-control session is not available to the authenticated user.');\n }\n const ownRepository = session.projectRepositoryId\n ? await provider.storage.projectRepositories.get({ orgId, id: session.projectRepositoryId })\n : null;\n if (!ownRepository) throw new Error('The active project repository was not found.');\n const state = context.getState();\n if (state.projectRepositoryId && state.projectRepositoryId !== ownRepository.id) {\n throw new Error('The active source-control session does not match its controller repository.');\n }\n const ownConnection = await provider.storage.connections.get({ orgId, id: ownRepository.connectionId });\n if (!ownConnection) throw new Error('The active source-control connection was not found.');\n if (state.factoryProjectId && state.factoryProjectId !== ownConnection.factoryProjectId) {\n throw new Error('The active source-control session does not match its Factory project.');\n }\n\n if (options.repository !== undefined) {\n const candidates = await resolveSessionRepositories({ sourceControl: provider.storage, session });\n const match = findEnvironmentRepository(candidates, options.repository);\n if (!match) {\n throw new Error(\n `Repository '${options.repository}' is not in this Factory's environment. Valid repositories: ${environmentSlugs(candidates).join(', ')}.`,\n );\n }\n return {\n context,\n provider,\n session,\n projectRepository: match.link,\n repository: match.repository,\n orgId,\n userId,\n ownRepository: match.link.id === ownRepository.id,\n };\n }\n\n const repository = await provider.storage.repositories.get({ orgId, id: ownRepository.repositoryId });\n if (!repository) throw new Error('The active source-control repository was not found.');\n return {\n context,\n provider,\n session,\n projectRepository: ownRepository,\n repository,\n orgId,\n userId,\n ownRepository: true,\n };\n}\n\n/**\n * The slugs a session may target and the one it is filed under, for the tool\n * descriptions. `undefined` when the session cannot be resolved; the tools\n * then describe the default without naming it.\n */\nasync function describeSessionRepositories(\n resourceId: string,\n providers: readonly SourceControlToolProvider[],\n): Promise<{ slugs: string[]; own: string | undefined } | undefined> {\n try {\n const { provider, session } = await resolveProviderSession(resourceId, providers);\n const repositories = await resolveSessionRepositories({ sourceControl: provider.storage, session });\n const own = repositories.find(candidate => candidate.link.id === session.projectRepositoryId);\n return { slugs: environmentSlugs(repositories), own: own?.repository.slug };\n } catch {\n return undefined;\n }\n}\n\nfunction repositoryArgumentDescription(described: { slugs: string[]; own: string | undefined } | undefined): string {\n if (!described || described.slugs.length === 0) {\n return \"Optional `repository` (owner/name) selects another repository of this Factory's environment; defaults to this session's repository.\";\n }\n const fallback = described.own ? `${described.own}, this session's repository` : \"this session's repository\";\n return `Optional \\`repository\\` (owner/name) selects one of this Factory's environment repositories: ${described.slugs.join(', ')}. Defaults to ${fallback}.`;\n}\n\nfunction changeRequestId(value: string | number): string {\n return String(value);\n}\n\nfunction executableSandbox(value: unknown): WorkspaceSandbox & ExecutableSandbox {\n const sandbox = value as Partial<ExecutableSandbox> | undefined;\n if (!sandbox?.executeCommand) throw new Error('The active Factory workspace has no executable sandbox.');\n return sandbox as WorkspaceSandbox & ExecutableSandbox;\n}\n\nasync function emitAgentAudit(\n audit: AuditAgentEmitter,\n requestContext: RequestContext,\n input: Parameters<AuditAgentEmitter['emitAgent']>[0]['input'],\n): Promise<void> {\n try {\n await audit.emitAgent({ requestContext, input });\n } catch (error) {\n console.warn('[Audit] Failed to record brokered source-control action', {\n action: input.action,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n}\n\n/** Fixed server-side so an agent cannot publish under, and impersonate, another required check. */\nexport const FACTORY_TEST_CHECK_NAME = 'Factory Review / tests';\n\nconst repositorySchema = z.object({ repository: z.string().trim().min(1).optional() });\nconst changeRequestSchema = repositorySchema.extend({\n changeRequestId: z.union([z.string().trim().min(1), z.number().int().positive()]),\n});\n\nexport async function createSourceControlTools({\n requestContext,\n providers,\n audit,\n testChecksEnabled,\n selfReviewApprovedHead,\n boundChangeRequestId,\n}: {\n requestContext: RequestContext;\n providers: readonly SourceControlToolProvider[];\n audit: AuditAgentEmitter;\n /** Per-project switch for `source_control_publish_test_check`. The host decides the default; Factory projects default to off. */\n testChecksEnabled?: (input: { orgId: string; factoryProjectId: string }) => Promise<boolean>;\n /**\n * Self-review gate for opening a change request. `undefined` means the session\n * is not gated (no Work item, or its change request predates Self-review);\n * `null` means Self-review has not approved; a SHA is the approved head.\n */\n selfReviewApprovedHead?: () => Promise<string | null | undefined>;\n /**\n * The change request a Review-bound session reviews; test checks may only target it.\n * When provided, sessions that are not Review-bound (it resolves `undefined`) cannot publish.\n */\n boundChangeRequestId?: () => Promise<string | undefined>;\n}): Promise<IntegrationTools> {\n if (!requestContext || typeof (requestContext as { get?: unknown }).get !== 'function') return {};\n const controller = requestContext.get('controller') as\n | AgentControllerRequestContext<RepositorySessionState>\n | undefined;\n const identity = authIdentity(requestContext);\n if (!controller?.resourceId || !identity.orgId || !identity.userId || providers.length === 0) return {};\n\n const repositoryArgument = repositoryArgumentDescription(\n await describeSessionRepositories(controller.resourceId, providers),\n );\n const withTarget = (options?: { repository?: string }) => resolveSessionTarget(requestContext, providers, options);\n const targetFor = (input: { repository?: string }) =>\n withTarget(input.repository !== undefined ? { repository: input.repository } : undefined);\n const reference = async (target: SessionTarget) => ({\n ...(await target.provider.versionControl.getRepositoryTarget({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n })),\n actingUserId: target.userId,\n });\n\n return {\n source_control_refresh_change_request_checkout: createTool({\n id: 'source_control_refresh_change_request_checkout',\n description:\n 'Refresh the active GitLab review session checkout to its current MR head. The MR, repository, branch, and credential are resolved server-side; no provider credentials enter the agent workspace.',\n inputSchema: z.object({}),\n execute: async (_input, { workspace }) => {\n const target = await withTarget();\n const mergeRequestNumber = mergeRequestNumberFromBranch(target.session.branch);\n if (target.provider.id !== 'gitlab' || mergeRequestNumber === undefined) {\n throw new Error('Checkout refresh is only available in a bound GitLab merge-request review session.');\n }\n const ref = await reference(target);\n const mergeRequest = await target.provider.versionControl.getPullRequest({\n ...ref,\n pullRequestId: String(mergeRequestNumber),\n });\n if (!mergeRequest || mergeRequest.state !== 'open' || mergeRequest.merged) {\n throw new Error('The bound GitLab merge request is no longer open.');\n }\n const sandbox = executableSandbox(workspace?.sandbox);\n const workdir = await resolveSessionWorkdir(target.session.id, sandbox, target.repository.slug);\n const access = await target.provider.versionControl.getRepositoryAccess({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n });\n const result = await refreshMergeRequestCheckout(sandbox, workdir, {\n branch: target.session.branch,\n mergeRequestNumber,\n expectedHeadSha: mergeRequest.headSha,\n access,\n });\n return result;\n },\n }),\n source_control_push_branch: createTool({\n id: 'source_control_push_branch',\n description: `Push the active Factory session branch to its connected source-control provider. Credentials are resolved and scrubbed server-side; this tool takes no token, remote, or branch arguments. ${repositoryArgument}`,\n inputSchema: repositorySchema,\n execute: async (input, { workspace }) => {\n const target = await targetFor(input);\n const sandbox = executableSandbox(workspace?.sandbox);\n const workdir = await resolveSessionWorkdir(target.session.id, sandbox, target.repository.slug);\n const access = await target.provider.versionControl.getRepositoryAccess({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n });\n // Another environment repository's directory may not be its checkout:\n // a boot skips a link whose directory name collides with another's, and\n // a session that booted single-repository has no siblings at all.\n if (!target.ownRepository && !(await isCheckoutOf(sandbox, workdir, access.cloneUrl))) {\n throw new Error(`There is no checkout of ${target.repository.slug} in this session.`);\n }\n const branch = target.session.branch;\n // Push the local session branch, whatever is checked out. A repository\n // where it was never created gets it at HEAD first, so a later push\n // never sends some other branch's commits.\n await ensureLocalBranch(sandbox, workdir, branch);\n await pushRepositoryBranch(sandbox, workdir, branch, access, target.repository.slug);\n await target.provider.storage.sessionRepositories.upsert({\n sessionId: target.session.sessionId,\n projectRepositoryId: target.projectRepository.id,\n branch,\n });\n updateSessionEnvironmentRepository(target.session.sessionId, target.repository.slug, { branch });\n await emitAgentAudit(audit, requestContext, {\n action: 'factory.agent.push',\n targets: [{ type: 'repository', id: target.repository.slug }],\n metadata: { branch, provider: target.provider.id, repository: target.repository.slug },\n });\n return { pushed: true, branch, repository: target.repository.slug };\n },\n }),\n source_control_get_change_request: createTool({\n id: 'source_control_get_change_request',\n description: `Read a pull request or merge request in the active Factory repository by its numeric repository-local ID. ${repositoryArgument}`,\n inputSchema: changeRequestSchema,\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.getPullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n },\n }),\n source_control_list_change_request_reviews: createTool({\n id: 'source_control_list_change_request_reviews',\n description: `List submitted reviews and approvals on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listReviews({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_create_change_request: createTool({\n id: 'source_control_create_change_request',\n description: `Open a pull request or merge request from the active Factory session branch into the repository's base branch (the session's persisted base branch in its own repository, the linked or default branch elsewhere). Push the branch with source_control_push_branch first. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({\n title: z.string().trim().min(1),\n body: z.string().optional(),\n draft: z.boolean().optional(),\n }),\n execute: async (input, execution) => {\n const target = await targetFor(input);\n const approvedHead = target.ownRepository ? await selfReviewApprovedHead?.() : undefined;\n if (approvedHead === null) {\n throw new Error(\n 'Self-review has not approved this branch. Move the work item to Self-review; the change request opens after it approves.',\n );\n }\n const baseBranch = target.ownRepository\n ? target.session.baseBranch\n : (target.projectRepository.branch ?? target.repository.defaultBranch);\n const created = await target.provider.versionControl.createPullRequest({\n ...(await reference(target)),\n title: input.title,\n ...(input.body !== undefined ? { body: input.body } : {}),\n baseBranch,\n headBranch: target.session.branch,\n ...(input.draft !== undefined ? { draft: input.draft } : {}),\n });\n if (approvedHead !== undefined && created.headSha.toLowerCase() !== approvedHead.toLowerCase()) {\n await target.provider.versionControl.closePullRequest({\n ...(await reference(target)),\n pullRequestId: created.id,\n });\n throw new Error(\n `Self-review approved ${approvedHead}, but the pushed branch is at ${created.headSha}; the change request was closed. Push the approved head, or move the work item back to Self-review to review the new commits.`,\n );\n }\n await target.provider.storage.sessionRepositories.upsert({\n sessionId: target.session.sessionId,\n projectRepositoryId: target.projectRepository.id,\n // Opening a change request pushes nothing: an existing row keeps its\n // `pushedAt`; the branch only seeds a row no push wrote yet.\n fallbackBranch: target.session.branch,\n changeRequestId: changeRequestId(created.id),\n changeRequestUrl: created.url,\n });\n updateSessionEnvironmentRepository(target.session.sessionId, target.repository.slug, {\n changeRequestUrl: created.url,\n });\n await emitAgentAudit(audit, requestContext, {\n action: 'factory.agent.pr_opened',\n targets: [\n { type: 'pull_request', id: created.url },\n { type: 'repository', id: target.repository.slug },\n ],\n metadata: { url: created.url, provider: target.provider.id, repository: target.repository.slug },\n });\n return created;\n },\n }),\n source_control_update_change_request: createTool({\n id: 'source_control_update_change_request',\n description: `Update the title, body, target branch, or open/closed state of a change request. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n title: z.string().trim().min(1).optional(),\n body: z.string().nullable().optional(),\n baseBranch: z.string().trim().min(1).optional(),\n state: z.enum(['open', 'closed']).optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updatePullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.title !== undefined ? { title: input.title } : {}),\n ...(input.body !== undefined ? { body: input.body } : {}),\n ...(input.baseBranch !== undefined ? { baseBranch: input.baseBranch } : {}),\n ...(input.state !== undefined ? { state: input.state } : {}),\n });\n },\n }),\n source_control_comment_change_request: createTool({\n id: 'source_control_comment_change_request',\n description: `Add a top-level comment to a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.createComment({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n body: input.body,\n });\n },\n }),\n source_control_list_change_request_comments: createTool({\n id: 'source_control_list_change_request_comments',\n description: `List top-level comments on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listComments({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_update_change_request_comment: createTool({\n id: 'source_control_update_change_request_comment',\n description: `Edit a top-level pull-request or merge-request comment in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1), body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updateComment({\n ...(await reference(target)),\n commentId: input.commentId,\n body: input.body,\n });\n },\n }),\n source_control_delete_change_request_comment: createTool({\n id: 'source_control_delete_change_request_comment',\n description: `Delete a top-level pull-request or merge-request comment in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n await target.provider.versionControl.deleteComment({\n ...(await reference(target)),\n commentId: input.commentId,\n });\n return { deleted: true };\n },\n }),\n source_control_list_diff_comments: createTool({\n id: 'source_control_list_diff_comments',\n description: `List line-anchored review comments and discussion replies on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listReviewComments({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_create_diff_comment: createTool({\n id: 'source_control_create_diff_comment',\n description: `Create a line-anchored review comment or reply to an existing diff discussion. Use replyToId alone for a reply; otherwise provide commitId, path, line, and side. ${repositoryArgument}`,\n // A root-level union is not representable as provider function parameters, which must be\n // an object schema, so both modes share one object shape and a refinement.\n inputSchema: changeRequestSchema\n .extend({\n body: z.string().trim().min(1),\n replyToId: z.string().trim().min(1).optional(),\n commitId: z.string().trim().min(1).optional(),\n path: z.string().trim().min(1).optional(),\n line: z.number().int().positive().optional(),\n side: z.enum(['left', 'right']).optional(),\n startLine: z.number().int().positive().optional(),\n startSide: z.enum(['left', 'right']).optional(),\n })\n .refine(\n input => {\n const anchorFields = [input.commitId, input.path, input.line, input.side];\n const anchor = anchorFields.every(field => field !== undefined);\n const reply = input.replyToId !== undefined;\n return (\n (reply ? anchorFields.every(field => field === undefined) : anchor) &&\n (input.startLine === undefined) === (input.startSide === undefined)\n );\n },\n {\n message:\n 'Provide replyToId alone to reply to a diff thread, or commitId, path, line, and side to start one. startLine and startSide must be provided together.',\n },\n ),\n execute: async input => {\n const target = await targetFor(input);\n const base = {\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n body: input.body,\n };\n if (input.replyToId !== undefined) {\n return target.provider.versionControl.createReviewComment({ ...base, replyToId: input.replyToId });\n }\n if (\n input.commitId === undefined ||\n input.path === undefined ||\n input.line === undefined ||\n input.side === undefined\n ) {\n throw new Error('commitId, path, line, and side are required to start a new diff thread.');\n }\n return target.provider.versionControl.createReviewComment({\n ...base,\n commitId: input.commitId,\n path: input.path,\n line: input.line,\n side: input.side,\n ...(input.startLine !== undefined && input.startSide !== undefined\n ? { startLine: input.startLine, startSide: input.startSide }\n : {}),\n });\n },\n }),\n source_control_update_diff_comment: createTool({\n id: 'source_control_update_diff_comment',\n description: `Edit a line-anchored review comment or discussion reply in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1), body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updateReviewComment({\n ...(await reference(target)),\n commentId: input.commentId,\n body: input.body,\n });\n },\n }),\n source_control_delete_diff_comment: createTool({\n id: 'source_control_delete_diff_comment',\n description: `Delete a line-anchored review comment or discussion reply in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n await target.provider.versionControl.deleteReviewComment({\n ...(await reference(target)),\n commentId: input.commentId,\n });\n return { deleted: true };\n },\n }),\n source_control_resolve_diff_thread: createTool({\n id: 'source_control_resolve_diff_thread',\n description: `Resolve or reopen the review thread containing a diff comment. Providers without resolvable threads return an explicit limitation. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({\n commentId: z.string().trim().min(1),\n resolved: z.boolean().default(true),\n }),\n execute: async input => {\n const target = await targetFor(input);\n const resolveReviewThread = target.provider.versionControl.resolveReviewThread;\n if (!resolveReviewThread) {\n throw new Error(`${target.provider.id} does not support resolving review threads.`);\n }\n await resolveReviewThread({\n ...(await reference(target)),\n commentId: input.commentId,\n resolved: input.resolved,\n });\n return { resolved: input.resolved };\n },\n }),\n source_control_review_change_request: createTool({\n id: 'source_control_review_change_request',\n description: `Submit an approve, request-changes, or comment review to a change request. Provider limitations are returned explicitly. ${repositoryArgument}`,\n inputSchema: changeRequestSchema\n .extend({\n event: z.enum(['approve', 'request-changes', 'comment']),\n body: z.string().optional(),\n commitId: z.string().trim().min(1).optional(),\n })\n .refine(input => input.event === 'approve' || Boolean(input.body?.trim()), {\n path: ['body'],\n message: 'request-changes and comment reviews require a body.',\n })\n .superRefine((input, ctx) => {\n const mismatch = verdictEventMismatch(input.event, input.body);\n if (mismatch) ctx.addIssue({ code: 'custom', path: ['body'], message: mismatch });\n const reviewedHead = reviewedHeadFromBody(input.body);\n if (reviewedHead === null) {\n ctx.addIssue({\n code: 'custom',\n path: ['body'],\n message: 'Every \"Reviewed head:\" line must name the same full 40- or 64-character commit SHA.',\n });\n } else if (reviewedHead && input.commitId && input.commitId.toLowerCase() !== reviewedHead) {\n ctx.addIssue({\n code: 'custom',\n path: ['commitId'],\n message: `Review body says \"Reviewed head: ${reviewedHead}\" but commitId is ${input.commitId}. Nothing was posted. Re-review the current head and regenerate the body before publishing.`,\n });\n }\n }),\n execute: async input => {\n const target = await targetFor(input);\n const reviewedHead = reviewedHeadFromBody(input.body);\n if (reviewedHead) {\n const pullRequest = await target.provider.versionControl.getPullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n if (!pullRequest) {\n throw new Error(`Change request ${input.changeRequestId} was not found; nothing was posted.`);\n }\n if (pullRequest.headSha && pullRequest.headSha.toLowerCase() !== reviewedHead) {\n throw new Error(\n `Review body says \"Reviewed head: ${reviewedHead}\" but the current change-request head is ${pullRequest.headSha}. Nothing was posted. Re-review the current head and regenerate the body before publishing.`,\n );\n }\n }\n const base = {\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.commitId !== undefined\n ? { commitId: input.commitId }\n : reviewedHead\n ? { commitId: reviewedHead }\n : {}),\n };\n if (input.event === 'approve') {\n return target.provider.versionControl.createReview({\n ...base,\n event: 'approve',\n ...(input.body !== undefined ? { body: input.body } : {}),\n });\n }\n return target.provider.versionControl.createReview({ ...base, event: input.event, body: input.body! });\n },\n }),\n source_control_publish_test_check: createTool({\n id: 'source_control_publish_test_check',\n description: `Publish the Factory review test result as a \"${FACTORY_TEST_CHECK_NAME}\" commit check on the change request's current head. Publish \"in-progress\" before running the test plan and a final status after. Refused when headSha is not the current head. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n headSha: z\n .string()\n .trim()\n .regex(/^([0-9a-f]{40}|[0-9a-f]{64})$/i, 'headSha must be a full 40- or 64-character commit SHA.'),\n status: z.enum(['in-progress', 'success', 'failure', 'neutral', 'cancelled', 'skipped']),\n title: z.string().trim().min(1),\n summary: z.string().trim().min(1),\n details: z.string().optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n if (testChecksEnabled) {\n const connection = await target.provider.storage.connections.get({\n orgId: target.orgId,\n id: target.projectRepository.connectionId,\n });\n if (\n connection?.factoryProjectId &&\n !(await testChecksEnabled({ orgId: target.orgId, factoryProjectId: connection.factoryProjectId }))\n ) {\n throw new Error(\n 'Test check publishing is turned off for this Factory project; nothing was published. Report the test results in the test report comment instead.',\n );\n }\n }\n const publishCommitCheck = target.provider.versionControl.publishCommitCheck;\n if (!publishCommitCheck) {\n throw new Error(`${target.provider.id} does not support publishing commit checks; nothing was published.`);\n }\n const bound = boundChangeRequestId ? await boundChangeRequestId() : undefined;\n if (bound === undefined) {\n throw new Error(\n 'Only a Review session bound to this change request can publish test checks; nothing was published.',\n );\n }\n if (bound !== changeRequestId(input.changeRequestId)) {\n throw new Error(\n `This session reviews change request ${bound}, not ${input.changeRequestId}; nothing was published.`,\n );\n }\n const ref = await reference(target);\n const pullRequest = await target.provider.versionControl.getPullRequest({\n ...ref,\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n if (!pullRequest || pullRequest.state !== 'open') {\n throw new Error(`Change request ${input.changeRequestId} is not open; nothing was published.`);\n }\n const headSha = input.headSha.toLowerCase();\n if (pullRequest.headSha.toLowerCase() !== headSha) {\n throw new Error(\n `headSha ${headSha} is not the current change-request head ${pullRequest.headSha}. Nothing was published. Re-run the test plan on the current head.`,\n );\n }\n return publishCommitCheck({\n connection: ref.connection,\n sourceId: ref.sourceId,\n actingUserId: ref.actingUserId,\n headSha,\n ref: pullRequest.headBranch,\n name: FACTORY_TEST_CHECK_NAME,\n status: input.status,\n title: input.title,\n summary: input.summary,\n ...(input.details !== undefined ? { details: input.details } : {}),\n });\n },\n }),\n source_control_request_reviewers: createTool({\n id: 'source_control_request_reviewers',\n description: `Request individual or team reviewers on a pull request or merge request. Provider limitations are returned explicitly. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n users: z.array(z.string().trim().min(1)).default([]),\n teams: z.array(z.string().trim().min(1)).default([]),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.requestReviewers({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n users: input.users,\n teams: input.teams,\n });\n },\n }),\n source_control_merge_change_request: createTool({\n id: 'source_control_merge_change_request',\n description: `Merge a pull request or merge request using the requested provider-supported merge method. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n method: z.enum(['merge', 'squash', 'rebase']).optional(),\n commitTitle: z.string().optional(),\n commitMessage: z.string().optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.mergePullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.method !== undefined ? { method: input.method } : {}),\n ...(input.commitTitle !== undefined ? { commitTitle: input.commitTitle } : {}),\n ...(input.commitMessage !== undefined ? { commitMessage: input.commitMessage } : {}),\n });\n },\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;AAuDA,SAAgB,qBAAqB,OAAoB,MAA8C;CACrG,MAAM,QAAQ,2DAA2D,KAAK,sBAAsB,IAAI,KAAK,EAAE;CAC/G,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,MAAM,UAAU,MAAM,OAAO,YAAY,YAAY;CAErD,MAAM,UAAyB,YAAY,YAAY,CAAC,SAAS,IAAI,CAAC,mBAAmB,SAAS;CAClG,IAAI,QAAQ,SAAS,KAAK,GAAG,OAAO,KAAA;CACpC,OAAO,oCAAoC,QAAQ,kBAAkB,MAAM,mCAAmC,QAC3G,KAAI,MAAK,IAAI,EAAE,EAAE,CAAC,CAClB,KAAK,MAAM,EAAE;AAClB;AAEA,MAAM,qBAAqB;AAC3B,MAAM,WAAW;;;;;AAMjB,SAAgB,qBAAqB,MAAqD;CACxF,MAAM,OAAO,IAAI,IACf,CAAC,IAAI,QAAQ,GAAA,CAAI,SAAS,kBAAkB,C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ACvD,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;IACjC,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS;GACrC,CAAC;GACD,SAAS,OAAM,UAAS;IACtB,MAAM,SAAS,MAAM,UAAU,KAAK;IACpC,OAAO,OAAO,SAAS,eAAe,iBAAiB;KACrD,GAAI,MAAM,UAAU,MAAM;KAC1B,eAAe,gBAAgB,MAAM,eAAe;KACpD,GAAI,MAAM,WAAW,KAAA,IAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;KAC7D,GAAI,MAAM,gBAAgB,KAAA,IAAY,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;KAC5E,GAAI,MAAM,kBAAkB,KAAA,IAAY,EAAE,eAAe,MAAM,cAAc,IAAI,CAAC;IACpF,CAAC;GACH;EACF,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"source-control-tools.js","names":[],"sources":["../../src/session/source-control-tools.ts"],"sourcesContent":["import type { AgentControllerRequestContext } from '@mastra/core/agent-controller';\nimport type { RequestContext } from '@mastra/core/request-context';\nimport { createTool } from '@mastra/core/tools';\nimport type { WorkspaceSandbox } from '@mastra/core/workspace';\nimport { z } from 'zod';\n\nimport { getFactoryAuthOrgId, getFactoryAuthUserFromContext, getFactoryAuthUserId } from '../auth.js';\nimport type { VersionControl } from '../capabilities/version-control.js';\nimport type { IntegrationTools } from '../integrations/base.js';\nimport {\n ensureLocalBranch,\n isCheckoutOf,\n pushRepositoryBranch,\n refreshMergeRequestCheckout,\n} from '../integrations/github/sandbox.js';\nimport { normalizedVerdictLine } from '../review-verdict.js';\nimport type { ExecutableSandbox } from '../sandbox/materialization.js';\nimport { resolveSessionWorkdir } from '../sandbox/session-sandbox.js';\nimport type { AuditAgentEmitter } from '../storage/domains/audit/domain.js';\nimport type {\n ProjectRepository,\n SourceControlRepository,\n SourceControlSession,\n SourceControlStorageHandle,\n} from '../storage/domains/source-control/base.js';\nimport { mergeRequestNumberFromBranch } from '../work-item-branch.js';\nimport { environmentSlugs, findEnvironmentRepository, resolveSessionRepositories } from './environment-repositories.js';\nimport { updateSessionEnvironmentRepository } from './environment-state-processor.js';\n\ntype RepositorySessionState = {\n factoryProjectId?: string;\n projectRepositoryId?: string;\n};\n\nexport interface SourceControlToolProvider {\n id: string;\n storage: SourceControlStorageHandle;\n versionControl: VersionControl;\n}\n\ninterface SessionTarget {\n context: AgentControllerRequestContext<RepositorySessionState>;\n provider: SourceControlToolProvider;\n session: SourceControlSession;\n projectRepository: ProjectRepository;\n repository: SourceControlRepository;\n orgId: string;\n userId: string;\n /** True when the target is the link the session is filed under, the default. */\n ownRepository: boolean;\n}\n\ntype ReviewEvent = 'approve' | 'request-changes' | 'comment';\n\n/** Returns why a review's leading `Verdict:` line contradicts the submitted event, if it does. */\nexport function verdictEventMismatch(event: ReviewEvent, body: string | undefined): string | undefined {\n const match = /^verdict: ?(approve|request changes|changes requested)\\b/.exec(normalizedVerdictLine(body) ?? '');\n if (!match) return undefined;\n const verdict = match[1] === 'approve' ? 'approve' : 'request changes';\n // GitLab has no request-changes state, so a blocking verdict is published as a comment review.\n const allowed: ReviewEvent[] = verdict === 'approve' ? ['approve'] : ['request-changes', 'comment'];\n if (allowed.includes(event)) return undefined;\n return `Review body opens with \"Verdict: ${verdict}\" but event is \"${event}\". Nothing was posted. Use event ${allowed\n .map(e => `\"${e}\"`)\n .join(' or ')} for this body, or regenerate the body for the verdict you intend.`;\n}\n\nconst REVIEWED_HEAD_LINE = /^[\\s*_>-]*reviewed head[*_]*:[*_]*\\s*(.*)$/gim;\nconst FULL_SHA = /^`?([0-9a-f]{40}|[0-9a-f]{64})`?(?:\\s|$)/i;\n\n/**\n * Returns the full SHA named by the body's `Reviewed head:` lines, `null` when any line is malformed or the lines\n * disagree, or `undefined` when absent.\n */\nexport function reviewedHeadFromBody(body: string | undefined): string | null | undefined {\n const shas = new Set(\n [...(body ?? '').matchAll(REVIEWED_HEAD_LINE)].map(\n line => FULL_SHA.exec(line[1]!.trim())?.[1]?.toLowerCase() ?? null,\n ),\n );\n if (shas.size === 0) return undefined;\n if (shas.size > 1) return null;\n return [...shas][0];\n}\n\nfunction authIdentity(requestContext: RequestContext) {\n const user = getFactoryAuthUserFromContext(requestContext);\n return { orgId: getFactoryAuthOrgId(user), userId: getFactoryAuthUserId(user) };\n}\n\nasync function resolveProviderSession(\n resourceId: string,\n providers: readonly SourceControlToolProvider[],\n): Promise<{ provider: SourceControlToolProvider; session: SourceControlSession }> {\n const matches = (\n await Promise.all(\n providers.map(async provider => ({\n provider,\n session: await provider.storage.sessions.getBySessionId(resourceId),\n })),\n )\n ).filter(\n (match): match is { provider: SourceControlToolProvider; session: SourceControlSession } => match.session !== null,\n );\n if (matches.length !== 1) {\n throw new Error(\n matches.length === 0\n ? 'The active session is not backed by a source-control repository.'\n : 'The active session is ambiguous across source-control providers.',\n );\n }\n return matches[0]!;\n}\n\nasync function resolveSessionTarget(\n requestContext: RequestContext,\n providers: readonly SourceControlToolProvider[],\n options: { repository?: string } = {},\n): Promise<SessionTarget> {\n const context = requestContext.get('controller') as AgentControllerRequestContext<RepositorySessionState> | undefined;\n const { orgId, userId } = authIdentity(requestContext);\n if (!context?.resourceId || !orgId || !userId) {\n throw new Error('Source-control tools require an authenticated repository session.');\n }\n\n const { provider, session } = await resolveProviderSession(context.resourceId, providers);\n if (session.orgId !== orgId || (session.visibility === 'private' && session.userId !== userId)) {\n throw new Error('The active source-control session is not available to the authenticated user.');\n }\n const ownRepository = session.projectRepositoryId\n ? await provider.storage.projectRepositories.get({ orgId, id: session.projectRepositoryId })\n : null;\n if (!ownRepository) throw new Error('The active project repository was not found.');\n const state = context.getState();\n if (state.projectRepositoryId && state.projectRepositoryId !== ownRepository.id) {\n throw new Error('The active source-control session does not match its controller repository.');\n }\n const ownConnection = await provider.storage.connections.get({ orgId, id: ownRepository.connectionId });\n if (!ownConnection) throw new Error('The active source-control connection was not found.');\n if (state.factoryProjectId && state.factoryProjectId !== ownConnection.factoryProjectId) {\n throw new Error('The active source-control session does not match its Factory project.');\n }\n\n if (options.repository !== undefined) {\n const candidates = await resolveSessionRepositories({ sourceControl: provider.storage, session });\n const match = findEnvironmentRepository(candidates, options.repository);\n if (!match) {\n throw new Error(\n `Repository '${options.repository}' is not in this Factory's environment. Valid repositories: ${environmentSlugs(candidates).join(', ')}.`,\n );\n }\n return {\n context,\n provider,\n session,\n projectRepository: match.link,\n repository: match.repository,\n orgId,\n userId,\n ownRepository: match.link.id === ownRepository.id,\n };\n }\n\n const repository = await provider.storage.repositories.get({ orgId, id: ownRepository.repositoryId });\n if (!repository) throw new Error('The active source-control repository was not found.');\n return {\n context,\n provider,\n session,\n projectRepository: ownRepository,\n repository,\n orgId,\n userId,\n ownRepository: true,\n };\n}\n\n/**\n * The slugs a session may target and the one it is filed under, for the tool\n * descriptions. `undefined` when the session cannot be resolved; the tools\n * then describe the default without naming it.\n */\nasync function describeSessionRepositories(\n resourceId: string,\n providers: readonly SourceControlToolProvider[],\n): Promise<{ slugs: string[]; own: string | undefined } | undefined> {\n try {\n const { provider, session } = await resolveProviderSession(resourceId, providers);\n const repositories = await resolveSessionRepositories({ sourceControl: provider.storage, session });\n const own = repositories.find(candidate => candidate.link.id === session.projectRepositoryId);\n return { slugs: environmentSlugs(repositories), own: own?.repository.slug };\n } catch {\n return undefined;\n }\n}\n\nfunction repositoryArgumentDescription(described: { slugs: string[]; own: string | undefined } | undefined): string {\n if (!described || described.slugs.length === 0) {\n return \"Optional `repository` (owner/name) selects another repository of this Factory's environment; defaults to this session's repository.\";\n }\n const fallback = described.own ? `${described.own}, this session's repository` : \"this session's repository\";\n return `Optional \\`repository\\` (owner/name) selects one of this Factory's environment repositories: ${described.slugs.join(', ')}. Defaults to ${fallback}.`;\n}\n\nfunction changeRequestId(value: string | number): string {\n return String(value);\n}\n\nfunction executableSandbox(value: unknown): WorkspaceSandbox & ExecutableSandbox {\n const sandbox = value as Partial<ExecutableSandbox> | undefined;\n if (!sandbox?.executeCommand) throw new Error('The active Factory workspace has no executable sandbox.');\n return sandbox as WorkspaceSandbox & ExecutableSandbox;\n}\n\nasync function emitAgentAudit(\n audit: AuditAgentEmitter,\n requestContext: RequestContext,\n input: Parameters<AuditAgentEmitter['emitAgent']>[0]['input'],\n): Promise<void> {\n try {\n await audit.emitAgent({ requestContext, input });\n } catch (error) {\n console.warn('[Audit] Failed to record brokered source-control action', {\n action: input.action,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n}\n\n/** Fixed server-side so an agent cannot publish under, and impersonate, another required check. */\nexport const FACTORY_TEST_CHECK_NAME = 'Factory Review / tests';\n\nconst repositorySchema = z.object({ repository: z.string().trim().min(1).optional() });\nconst changeRequestSchema = repositorySchema.extend({\n changeRequestId: z.union([z.string().trim().min(1), z.number().int().positive()]),\n});\n\nexport async function createSourceControlTools({\n requestContext,\n providers,\n audit,\n testChecksEnabled,\n selfReviewApprovedHead,\n boundChangeRequestId,\n}: {\n requestContext: RequestContext;\n providers: readonly SourceControlToolProvider[];\n audit: AuditAgentEmitter;\n /** Per-project switch for `source_control_publish_test_check`. The host decides the default; Factory projects default to off. */\n testChecksEnabled?: (input: { orgId: string; factoryProjectId: string }) => Promise<boolean>;\n /**\n * Self-review gate for opening a change request. `undefined` means the session\n * is not gated (no Work item, or its change request predates Self-review);\n * `null` means Self-review has not approved; a SHA is the approved head.\n */\n selfReviewApprovedHead?: () => Promise<string | null | undefined>;\n /**\n * The change request a Review-bound session reviews; test checks may only target it.\n * When provided, sessions that are not Review-bound (it resolves `undefined`) cannot publish.\n */\n boundChangeRequestId?: () => Promise<string | undefined>;\n}): Promise<IntegrationTools> {\n if (!requestContext || typeof (requestContext as { get?: unknown }).get !== 'function') return {};\n const controller = requestContext.get('controller') as\n | AgentControllerRequestContext<RepositorySessionState>\n | undefined;\n const identity = authIdentity(requestContext);\n if (!controller?.resourceId || !identity.orgId || !identity.userId || providers.length === 0) return {};\n\n const repositoryArgument = repositoryArgumentDescription(\n await describeSessionRepositories(controller.resourceId, providers),\n );\n const withTarget = (options?: { repository?: string }) => resolveSessionTarget(requestContext, providers, options);\n const targetFor = (input: { repository?: string }) =>\n withTarget(input.repository !== undefined ? { repository: input.repository } : undefined);\n const reference = async (target: SessionTarget) => ({\n ...(await target.provider.versionControl.getRepositoryTarget({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n })),\n actingUserId: target.userId,\n });\n\n return {\n source_control_refresh_change_request_checkout: createTool({\n id: 'source_control_refresh_change_request_checkout',\n description:\n 'Refresh the active GitLab review session checkout to its current MR head. The MR, repository, branch, and credential are resolved server-side; no provider credentials enter the agent workspace.',\n inputSchema: z.object({}),\n execute: async (_input, { workspace }) => {\n const target = await withTarget();\n const mergeRequestNumber = mergeRequestNumberFromBranch(target.session.branch);\n if (target.provider.id !== 'gitlab' || mergeRequestNumber === undefined) {\n throw new Error('Checkout refresh is only available in a bound GitLab merge-request review session.');\n }\n const ref = await reference(target);\n const mergeRequest = await target.provider.versionControl.getPullRequest({\n ...ref,\n pullRequestId: String(mergeRequestNumber),\n });\n if (!mergeRequest || mergeRequest.state !== 'open' || mergeRequest.merged) {\n throw new Error('The bound GitLab merge request is no longer open.');\n }\n const sandbox = executableSandbox(workspace?.sandbox);\n const workdir = await resolveSessionWorkdir(target.session.id, sandbox, target.repository.slug);\n const access = await target.provider.versionControl.getRepositoryAccess({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n });\n const result = await refreshMergeRequestCheckout(sandbox, workdir, {\n branch: target.session.branch,\n mergeRequestNumber,\n expectedHeadSha: mergeRequest.headSha,\n access,\n });\n return result;\n },\n }),\n source_control_push_branch: createTool({\n id: 'source_control_push_branch',\n description: `Push the active Factory session branch to its connected source-control provider. Credentials are resolved and scrubbed server-side; this tool takes no token, remote, or branch arguments. ${repositoryArgument}`,\n inputSchema: repositorySchema,\n execute: async (input, { workspace }) => {\n const target = await targetFor(input);\n const sandbox = executableSandbox(workspace?.sandbox);\n const workdir = await resolveSessionWorkdir(target.session.id, sandbox, target.repository.slug);\n const access = await target.provider.versionControl.getRepositoryAccess({\n orgId: target.orgId,\n repositoryId: target.repository.id,\n });\n // Another environment repository's directory may not be its checkout:\n // a boot skips a link whose directory name collides with another's, and\n // a session that booted single-repository has no siblings at all.\n if (!target.ownRepository && !(await isCheckoutOf(sandbox, workdir, access.cloneUrl))) {\n throw new Error(`There is no checkout of ${target.repository.slug} in this session.`);\n }\n const branch = target.session.branch;\n // Materialize the session branch at the active HEAD without discarding\n // session-only commits, so the push includes the agent's current work.\n await ensureLocalBranch(sandbox, workdir, branch);\n await pushRepositoryBranch(sandbox, workdir, branch, access, target.repository.slug);\n await target.provider.storage.sessionRepositories.upsert({\n sessionId: target.session.sessionId,\n projectRepositoryId: target.projectRepository.id,\n branch,\n });\n updateSessionEnvironmentRepository(target.session.sessionId, target.repository.slug, { branch });\n await emitAgentAudit(audit, requestContext, {\n action: 'factory.agent.push',\n targets: [{ type: 'repository', id: target.repository.slug }],\n metadata: { branch, provider: target.provider.id, repository: target.repository.slug },\n });\n return { pushed: true, branch, repository: target.repository.slug };\n },\n }),\n source_control_get_change_request: createTool({\n id: 'source_control_get_change_request',\n description: `Read a pull request or merge request in the active Factory repository by its numeric repository-local ID. ${repositoryArgument}`,\n inputSchema: changeRequestSchema,\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.getPullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n },\n }),\n source_control_list_change_request_reviews: createTool({\n id: 'source_control_list_change_request_reviews',\n description: `List submitted reviews and approvals on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listReviews({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_create_change_request: createTool({\n id: 'source_control_create_change_request',\n description: `Open a pull request or merge request from the active Factory session branch into the repository's base branch (the session's persisted base branch in its own repository, the linked or default branch elsewhere). Push the branch with source_control_push_branch first. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({\n title: z.string().trim().min(1),\n body: z.string().optional(),\n draft: z.boolean().optional(),\n }),\n execute: async (input, execution) => {\n const target = await targetFor(input);\n const approvedHead = target.ownRepository ? await selfReviewApprovedHead?.() : undefined;\n if (approvedHead === null) {\n throw new Error(\n 'Self-review has not approved this branch. Move the work item to Self-review; the change request opens after it approves.',\n );\n }\n const baseBranch = target.ownRepository\n ? target.session.baseBranch\n : (target.projectRepository.branch ?? target.repository.defaultBranch);\n const created = await target.provider.versionControl.createPullRequest({\n ...(await reference(target)),\n title: input.title,\n ...(input.body !== undefined ? { body: input.body } : {}),\n baseBranch,\n headBranch: target.session.branch,\n ...(input.draft !== undefined ? { draft: input.draft } : {}),\n });\n if (approvedHead !== undefined && created.headSha.toLowerCase() !== approvedHead.toLowerCase()) {\n await target.provider.versionControl.closePullRequest({\n ...(await reference(target)),\n pullRequestId: created.id,\n });\n throw new Error(\n `Self-review approved ${approvedHead}, but the pushed branch is at ${created.headSha}; the change request was closed. Push the approved head, or move the work item back to Self-review to review the new commits.`,\n );\n }\n await target.provider.storage.sessionRepositories.upsert({\n sessionId: target.session.sessionId,\n projectRepositoryId: target.projectRepository.id,\n // Opening a change request pushes nothing: an existing row keeps its\n // `pushedAt`; the branch only seeds a row no push wrote yet.\n fallbackBranch: target.session.branch,\n changeRequestId: changeRequestId(created.id),\n changeRequestUrl: created.url,\n });\n updateSessionEnvironmentRepository(target.session.sessionId, target.repository.slug, {\n changeRequestUrl: created.url,\n });\n await emitAgentAudit(audit, requestContext, {\n action: 'factory.agent.pr_opened',\n targets: [\n { type: 'pull_request', id: created.url },\n { type: 'repository', id: target.repository.slug },\n ],\n metadata: { url: created.url, provider: target.provider.id, repository: target.repository.slug },\n });\n return created;\n },\n }),\n source_control_update_change_request: createTool({\n id: 'source_control_update_change_request',\n description: `Update the title, body, target branch, or open/closed state of a change request. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n title: z.string().trim().min(1).optional(),\n body: z.string().nullable().optional(),\n baseBranch: z.string().trim().min(1).optional(),\n state: z.enum(['open', 'closed']).optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updatePullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.title !== undefined ? { title: input.title } : {}),\n ...(input.body !== undefined ? { body: input.body } : {}),\n ...(input.baseBranch !== undefined ? { baseBranch: input.baseBranch } : {}),\n ...(input.state !== undefined ? { state: input.state } : {}),\n });\n },\n }),\n source_control_comment_change_request: createTool({\n id: 'source_control_comment_change_request',\n description: `Add a top-level comment to a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.createComment({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n body: input.body,\n });\n },\n }),\n source_control_list_change_request_comments: createTool({\n id: 'source_control_list_change_request_comments',\n description: `List top-level comments on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listComments({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_update_change_request_comment: createTool({\n id: 'source_control_update_change_request_comment',\n description: `Edit a top-level pull-request or merge-request comment in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1), body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updateComment({\n ...(await reference(target)),\n commentId: input.commentId,\n body: input.body,\n });\n },\n }),\n source_control_delete_change_request_comment: createTool({\n id: 'source_control_delete_change_request_comment',\n description: `Delete a top-level pull-request or merge-request comment in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n await target.provider.versionControl.deleteComment({\n ...(await reference(target)),\n commentId: input.commentId,\n });\n return { deleted: true };\n },\n }),\n source_control_list_diff_comments: createTool({\n id: 'source_control_list_diff_comments',\n description: `List line-anchored review comments and discussion replies on a pull request or merge request in the active repository. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({ cursor: z.string().trim().min(1).optional() }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.listReviewComments({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.cursor !== undefined ? { cursor: input.cursor } : {}),\n });\n },\n }),\n source_control_create_diff_comment: createTool({\n id: 'source_control_create_diff_comment',\n description: `Create a line-anchored review comment or reply to an existing diff discussion. Use replyToId alone for a reply; otherwise provide commitId, path, line, and side. ${repositoryArgument}`,\n // A root-level union is not representable as provider function parameters, which must be\n // an object schema, so both modes share one object shape and a refinement.\n inputSchema: changeRequestSchema\n .extend({\n body: z.string().trim().min(1),\n replyToId: z.string().trim().min(1).optional(),\n commitId: z.string().trim().min(1).optional(),\n path: z.string().trim().min(1).optional(),\n line: z.number().int().positive().optional(),\n side: z.enum(['left', 'right']).optional(),\n startLine: z.number().int().positive().optional(),\n startSide: z.enum(['left', 'right']).optional(),\n })\n .refine(\n input => {\n const anchorFields = [input.commitId, input.path, input.line, input.side];\n const anchor = anchorFields.every(field => field !== undefined);\n const reply = input.replyToId !== undefined;\n return (\n (reply ? anchorFields.every(field => field === undefined) : anchor) &&\n (input.startLine === undefined) === (input.startSide === undefined)\n );\n },\n {\n message:\n 'Provide replyToId alone to reply to a diff thread, or commitId, path, line, and side to start one. startLine and startSide must be provided together.',\n },\n ),\n execute: async input => {\n const target = await targetFor(input);\n const base = {\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n body: input.body,\n };\n if (input.replyToId !== undefined) {\n return target.provider.versionControl.createReviewComment({ ...base, replyToId: input.replyToId });\n }\n if (\n input.commitId === undefined ||\n input.path === undefined ||\n input.line === undefined ||\n input.side === undefined\n ) {\n throw new Error('commitId, path, line, and side are required to start a new diff thread.');\n }\n return target.provider.versionControl.createReviewComment({\n ...base,\n commitId: input.commitId,\n path: input.path,\n line: input.line,\n side: input.side,\n ...(input.startLine !== undefined && input.startSide !== undefined\n ? { startLine: input.startLine, startSide: input.startSide }\n : {}),\n });\n },\n }),\n source_control_update_diff_comment: createTool({\n id: 'source_control_update_diff_comment',\n description: `Edit a line-anchored review comment or discussion reply in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1), body: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.updateReviewComment({\n ...(await reference(target)),\n commentId: input.commentId,\n body: input.body,\n });\n },\n }),\n source_control_delete_diff_comment: createTool({\n id: 'source_control_delete_diff_comment',\n description: `Delete a line-anchored review comment or discussion reply in the active repository. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({ commentId: z.string().trim().min(1) }),\n execute: async input => {\n const target = await targetFor(input);\n await target.provider.versionControl.deleteReviewComment({\n ...(await reference(target)),\n commentId: input.commentId,\n });\n return { deleted: true };\n },\n }),\n source_control_resolve_diff_thread: createTool({\n id: 'source_control_resolve_diff_thread',\n description: `Resolve or reopen the review thread containing a diff comment. Providers without resolvable threads return an explicit limitation. ${repositoryArgument}`,\n inputSchema: repositorySchema.extend({\n commentId: z.string().trim().min(1),\n resolved: z.boolean().default(true),\n }),\n execute: async input => {\n const target = await targetFor(input);\n const resolveReviewThread = target.provider.versionControl.resolveReviewThread;\n if (!resolveReviewThread) {\n throw new Error(`${target.provider.id} does not support resolving review threads.`);\n }\n await resolveReviewThread({\n ...(await reference(target)),\n commentId: input.commentId,\n resolved: input.resolved,\n });\n return { resolved: input.resolved };\n },\n }),\n source_control_review_change_request: createTool({\n id: 'source_control_review_change_request',\n description: `Submit an approve, request-changes, or comment review to a change request. Provider limitations are returned explicitly. ${repositoryArgument}`,\n inputSchema: changeRequestSchema\n .extend({\n event: z.enum(['approve', 'request-changes', 'comment']),\n body: z.string().optional(),\n commitId: z.string().trim().min(1).optional(),\n })\n .refine(input => input.event === 'approve' || Boolean(input.body?.trim()), {\n path: ['body'],\n message: 'request-changes and comment reviews require a body.',\n })\n .superRefine((input, ctx) => {\n const mismatch = verdictEventMismatch(input.event, input.body);\n if (mismatch) ctx.addIssue({ code: 'custom', path: ['body'], message: mismatch });\n const reviewedHead = reviewedHeadFromBody(input.body);\n if (reviewedHead === null) {\n ctx.addIssue({\n code: 'custom',\n path: ['body'],\n message: 'Every \"Reviewed head:\" line must name the same full 40- or 64-character commit SHA.',\n });\n } else if (reviewedHead && input.commitId && input.commitId.toLowerCase() !== reviewedHead) {\n ctx.addIssue({\n code: 'custom',\n path: ['commitId'],\n message: `Review body says \"Reviewed head: ${reviewedHead}\" but commitId is ${input.commitId}. Nothing was posted. Re-review the current head and regenerate the body before publishing.`,\n });\n }\n }),\n execute: async input => {\n const target = await targetFor(input);\n const reviewedHead = reviewedHeadFromBody(input.body);\n if (reviewedHead) {\n const pullRequest = await target.provider.versionControl.getPullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n if (!pullRequest) {\n throw new Error(`Change request ${input.changeRequestId} was not found; nothing was posted.`);\n }\n if (pullRequest.headSha && pullRequest.headSha.toLowerCase() !== reviewedHead) {\n throw new Error(\n `Review body says \"Reviewed head: ${reviewedHead}\" but the current change-request head is ${pullRequest.headSha}. Nothing was posted. Re-review the current head and regenerate the body before publishing.`,\n );\n }\n }\n const base = {\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.commitId !== undefined\n ? { commitId: input.commitId }\n : reviewedHead\n ? { commitId: reviewedHead }\n : {}),\n };\n if (input.event === 'approve') {\n return target.provider.versionControl.createReview({\n ...base,\n event: 'approve',\n ...(input.body !== undefined ? { body: input.body } : {}),\n });\n }\n return target.provider.versionControl.createReview({ ...base, event: input.event, body: input.body! });\n },\n }),\n source_control_publish_test_check: createTool({\n id: 'source_control_publish_test_check',\n description: `Publish the Factory review test result as a \"${FACTORY_TEST_CHECK_NAME}\" commit check on the change request's current head. Publish \"in-progress\" before running the test plan and a final status after. Refused when headSha is not the current head. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n headSha: z\n .string()\n .trim()\n .regex(/^([0-9a-f]{40}|[0-9a-f]{64})$/i, 'headSha must be a full 40- or 64-character commit SHA.'),\n status: z.enum(['in-progress', 'success', 'failure', 'neutral', 'cancelled', 'skipped']),\n title: z.string().trim().min(1),\n summary: z.string().trim().min(1),\n details: z.string().optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n if (testChecksEnabled) {\n const connection = await target.provider.storage.connections.get({\n orgId: target.orgId,\n id: target.projectRepository.connectionId,\n });\n if (\n connection?.factoryProjectId &&\n !(await testChecksEnabled({ orgId: target.orgId, factoryProjectId: connection.factoryProjectId }))\n ) {\n throw new Error(\n 'Test check publishing is turned off for this Factory project; nothing was published. Report the test results in the test report comment instead.',\n );\n }\n }\n const publishCommitCheck = target.provider.versionControl.publishCommitCheck;\n if (!publishCommitCheck) {\n throw new Error(`${target.provider.id} does not support publishing commit checks; nothing was published.`);\n }\n const bound = boundChangeRequestId ? await boundChangeRequestId() : undefined;\n if (bound === undefined) {\n throw new Error(\n 'Only a Review session bound to this change request can publish test checks; nothing was published.',\n );\n }\n if (bound !== changeRequestId(input.changeRequestId)) {\n throw new Error(\n `This session reviews change request ${bound}, not ${input.changeRequestId}; nothing was published.`,\n );\n }\n const ref = await reference(target);\n const pullRequest = await target.provider.versionControl.getPullRequest({\n ...ref,\n pullRequestId: changeRequestId(input.changeRequestId),\n });\n if (!pullRequest || pullRequest.state !== 'open') {\n throw new Error(`Change request ${input.changeRequestId} is not open; nothing was published.`);\n }\n const headSha = input.headSha.toLowerCase();\n if (pullRequest.headSha.toLowerCase() !== headSha) {\n throw new Error(\n `headSha ${headSha} is not the current change-request head ${pullRequest.headSha}. Nothing was published. Re-run the test plan on the current head.`,\n );\n }\n return publishCommitCheck({\n connection: ref.connection,\n sourceId: ref.sourceId,\n actingUserId: ref.actingUserId,\n headSha,\n ref: pullRequest.headBranch,\n name: FACTORY_TEST_CHECK_NAME,\n status: input.status,\n title: input.title,\n summary: input.summary,\n ...(input.details !== undefined ? { details: input.details } : {}),\n });\n },\n }),\n source_control_request_reviewers: createTool({\n id: 'source_control_request_reviewers',\n description: `Request individual or team reviewers on a pull request or merge request. Provider limitations are returned explicitly. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n users: z.array(z.string().trim().min(1)).default([]),\n teams: z.array(z.string().trim().min(1)).default([]),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.requestReviewers({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n users: input.users,\n teams: input.teams,\n });\n },\n }),\n source_control_merge_change_request: createTool({\n id: 'source_control_merge_change_request',\n description: `Merge a pull request or merge request using the requested provider-supported merge method. ${repositoryArgument}`,\n inputSchema: changeRequestSchema.extend({\n method: z.enum(['merge', 'squash', 'rebase']).optional(),\n commitTitle: z.string().optional(),\n commitMessage: z.string().optional(),\n }),\n execute: async input => {\n const target = await targetFor(input);\n return target.provider.versionControl.mergePullRequest({\n ...(await reference(target)),\n pullRequestId: changeRequestId(input.changeRequestId),\n ...(input.method !== undefined ? { method: input.method } : {}),\n ...(input.commitTitle !== undefined ? { commitTitle: input.commitTitle } : {}),\n ...(input.commitMessage !== undefined ? { commitMessage: input.commitMessage } : {}),\n });\n },\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;AAuDA,SAAgB,qBAAqB,OAAoB,MAA8C;CACrG,MAAM,QAAQ,2DAA2D,KAAK,sBAAsB,IAAI,KAAK,EAAE;CAC/G,IAAI,CAAC,OAAO,OAAO,KAA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AI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;GACrD,CAAC;GACD,SAAS,OAAM,UAAS;IACtB,MAAM,SAAS,MAAM,UAAU,KAAK;IACpC,OAAO,OAAO,SAAS,eAAe,iBAAiB;KACrD,GAAI,MAAM,UAAU,MAAM;KAC1B,eAAe,gBAAgB,MAAM,eAAe;KACpD,OAAO,MAAM;KACb,OAAO,MAAM;IACf,CAAC;GACH;EACF,CAAC;EACD,qCAAqC,WAAW;GAC9C,IAAI;GACJ,aAAa,8FAA8F;GAC3G,aAAa,oBAAoB,OAAO;IACtC,QAAQ,EAAE,KAAK;KAAC;KAAS;KAAU;IAAQ,CAAC,CAAC,CAAC,SAAS;IACvD,aAAa,EAAE,OAAO,CAAC,CAAC,SAAS;IACjC,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS;GACrC,CAAC;GACD,SAAS,OAAM,UAAS;IACtB,MAAM,SAAS,MAAM,UAAU,KAAK;IACpC,OAAO,OAAO,SAAS,eAAe,iBAAiB;KACrD,GAAI,MAAM,UAAU,MAAM;KAC1B,eAAe,gBAAgB,MAAM,eAAe;KACpD,GAAI,MAAM,WAAW,KAAA,IAAY,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;KAC7D,GAAI,MAAM,gBAAgB,KAAA,IAAY,EAAE,aAAa,MAAM,YAAY,IAAI,CAAC;KAC5E,GAAI,MAAM,kBAAkB,KAAA,IAAY,EAAE,eAAe,MAAM,cAAc,IAAI,CAAC;IACpF,CAAC;GACH;EACF,CAAC;CACH;AACF"}
|
|
@@ -151,6 +151,8 @@ export interface SourceControlSession {
|
|
|
151
151
|
originSessionId: string | null;
|
|
152
152
|
/** The thread of `originSessionId` that started it. */
|
|
153
153
|
originThreadId: string | null;
|
|
154
|
+
/** When the origin muted this side session's reports; null while they are delivered. */
|
|
155
|
+
originMutedAt: Date | null;
|
|
154
156
|
baseBranch: string;
|
|
155
157
|
sandboxId: string | null;
|
|
156
158
|
sandboxWorkdir: string | null;
|
|
@@ -367,6 +369,11 @@ export interface SourceControlStorageHandle {
|
|
|
367
369
|
sessionId: string;
|
|
368
370
|
title: string;
|
|
369
371
|
}): Promise<void>;
|
|
372
|
+
/** Mute or unmute the side session's reports to its origin. Keyed by the controller-facing `sessionId`. */
|
|
373
|
+
setOriginMuted(args: {
|
|
374
|
+
sessionId: string;
|
|
375
|
+
muted: boolean;
|
|
376
|
+
}): Promise<void>;
|
|
370
377
|
/** Keyed by the link (today's callers) or by the factory. */
|
|
371
378
|
getForBranch(args: SessionBranchKey): Promise<SourceControlSession | null>;
|
|
372
379
|
create(input: CreateSourceControlSessionInput): Promise<SourceControlSession>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/storage/domains/source-control/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAwB,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAahF;;;;GAIG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM;gBAAjB,SAAS,EAAE,MAAM;CAIvC;AAED,qBAAa,oCAAqC,SAAQ,KAAK;;CAK9D;AAED,eAAO,MAAM,sBAAsB,EAAE,gBAAgB,EAuKpD,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpE,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,gBAAgB,EAAE,6BAA6B,C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ROL_SCHEMAS = [
|
|
|
186
186
|
type: "text",
|
|
187
187
|
nullable: true
|
|
188
188
|
},
|
|
189
|
+
origin_muted_at: {
|
|
190
|
+
type: "timestamp",
|
|
191
|
+
nullable: true
|
|
192
|
+
},
|
|
189
193
|
sandbox_id: {
|
|
190
194
|
type: "text",
|
|
191
195
|
nullable: true
|
|
@@ -356,6 +360,7 @@ function toSession(row) {
|
|
|
356
360
|
visibility: row.visibility === "private" ? "private" : "org",
|
|
357
361
|
originSessionId: row.origin_session_id ?? null,
|
|
358
362
|
originThreadId: row.origin_thread_id ?? null,
|
|
363
|
+
originMutedAt: row.origin_muted_at ?? null,
|
|
359
364
|
baseBranch: row.base_branch,
|
|
360
365
|
sandboxId: row.sandbox_id,
|
|
361
366
|
sandboxWorkdir: row.sandbox_workdir,
|
|
@@ -983,6 +988,12 @@ var SourceControlStorage = class extends FactoryStorageDomain {
|
|
|
983
988
|
updated_at: /* @__PURE__ */ new Date()
|
|
984
989
|
}));
|
|
985
990
|
},
|
|
991
|
+
setOriginMuted: async ({ sessionId, muted }) => {
|
|
992
|
+
await db().updateAtomic(SESSIONS, { session_id: sessionId }, () => ({
|
|
993
|
+
origin_muted_at: muted ? /* @__PURE__ */ new Date() : null,
|
|
994
|
+
updated_at: /* @__PURE__ */ new Date()
|
|
995
|
+
}));
|
|
996
|
+
},
|
|
986
997
|
getForBranch: async (args) => {
|
|
987
998
|
if ("factoryProjectId" in args) {
|
|
988
999
|
const row = await db().findOne(SESSIONS, {
|
|
@@ -1033,6 +1044,7 @@ var SourceControlStorage = class extends FactoryStorageDomain {
|
|
|
1033
1044
|
visibility: input.visibility ?? "org",
|
|
1034
1045
|
origin_session_id: input.origin?.sessionId ?? null,
|
|
1035
1046
|
origin_thread_id: input.origin?.threadId ?? null,
|
|
1047
|
+
origin_muted_at: null,
|
|
1036
1048
|
base_branch: input.baseBranch,
|
|
1037
1049
|
sandbox_id: null,
|
|
1038
1050
|
sandbox_workdir: null,
|