@mastra/factory 0.27.0-alpha.2 → 0.27.0
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/README.md +94 -47
- package/dist/boards/card-facts.d.ts +4 -2
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +7 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/define-board.d.ts +2 -0
- package/dist/boards/define-board.d.ts.map +1 -1
- package/dist/boards/define-board.js +1 -0
- package/dist/boards/define-board.js.map +1 -1
- package/dist/boards/intake-routing.d.ts +2 -2
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/phase-automation.d.ts +4 -4
- package/dist/boards/phase-automation.d.ts.map +1 -1
- package/dist/boards/phase-automation.js.map +1 -1
- package/dist/boards/pull-request-review.d.ts +0 -7
- package/dist/boards/pull-request-review.d.ts.map +1 -1
- package/dist/boards/pull-request-review.js +15 -14
- package/dist/boards/pull-request-review.js.map +1 -1
- package/dist/boards/relocate.d.ts +4 -4
- package/dist/boards/relocate.d.ts.map +1 -1
- package/dist/boards/relocate.js +1 -1
- package/dist/boards/relocate.js.map +1 -1
- package/dist/boards/review.d.ts.map +1 -1
- package/dist/boards/review.js +1 -2
- package/dist/boards/review.js.map +1 -1
- package/dist/boards/semantics.d.ts +8 -8
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/transition-policy.d.ts +7 -0
- package/dist/boards/transition-policy.d.ts.map +1 -1
- package/dist/boards/transition-policy.js.map +1 -1
- package/dist/boards/work.d.ts +6 -0
- package/dist/boards/work.d.ts.map +1 -1
- package/dist/boards/work.js +71 -25
- package/dist/boards/work.js.map +1 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +6 -15
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/integrations/github/acceptance-labels.d.ts +2 -2
- package/dist/integrations/github/acceptance-labels.d.ts.map +1 -1
- package/dist/integrations/github/acceptance-labels.js +2 -2
- package/dist/integrations/github/acceptance-labels.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +5 -11
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +6 -22
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +6 -4
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/provenance.d.ts +2 -2
- package/dist/integrations/github/provenance.d.ts.map +1 -1
- package/dist/integrations/github/provenance.js.map +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +46 -1
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +3 -3
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +43 -39
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts +2 -9
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +2 -19
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.js +2 -2
- package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js +11 -11
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +2 -1
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +1 -0
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/issue-reconciler.d.ts +7 -7
- package/dist/integrations/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/issue-reconciler.js +11 -14
- package/dist/integrations/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +1 -0
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +2 -2
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +1 -1
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +2 -1
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/slack/feed-publisher.d.ts +2 -2
- package/dist/integrations/slack/feed-publisher.d.ts.map +1 -1
- package/dist/integrations/slack/feed-publisher.js.map +1 -1
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/packages/_internals/workspace/dist/index.js +1 -1
- package/dist/routes/attention-activity.js +1 -1
- package/dist/routes/attention-activity.js.map +1 -1
- package/dist/routes/attention-parked.js.map +1 -1
- package/dist/routes/attention-providers.d.ts +4 -4
- package/dist/routes/attention-providers.d.ts.map +1 -1
- package/dist/routes/attention-providers.js +2 -2
- package/dist/routes/attention-providers.js.map +1 -1
- package/dist/routes/contracts.d.ts +33 -5
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +13 -4
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +1 -1
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/projects.js +3 -2
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/surface.js +4 -4
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +9 -3
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.js +1 -1
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/decision-applicability.d.ts +2 -2
- package/dist/rules/decision-applicability.d.ts.map +1 -1
- package/dist/rules/decision-applicability.js +1 -1
- package/dist/rules/decision-applicability.js.map +1 -1
- package/dist/rules/dispatcher.d.ts +2 -7
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +13 -17
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/processor.d.ts +2 -2
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +4 -2
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/review-source-tool.d.ts.map +1 -1
- package/dist/rules/review-source-tool.js +2 -4
- package/dist/rules/review-source-tool.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +5 -2
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.d.ts.map +1 -1
- package/dist/rules/tools.js +7 -10
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +8 -16
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +19 -21
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +9 -3
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +2 -2
- package/dist/rules/types.js.map +1 -1
- package/dist/session/resource-migration.d.ts +3 -3
- package/dist/session/resource-migration.d.ts.map +1 -1
- package/dist/session/resource-migration.js.map +1 -1
- package/dist/session/work-item-repository.d.ts +4 -2
- package/dist/session/work-item-repository.d.ts.map +1 -1
- package/dist/session/work-item-repository.js +2 -2
- package/dist/session/work-item-repository.js.map +1 -1
- package/dist/skills/catalog.js +1 -1
- package/dist/storage/domains/comments/base.d.ts.map +1 -1
- package/dist/storage/domains/comments/base.js +15 -8
- package/dist/storage/domains/comments/base.js.map +1 -1
- package/dist/storage/domains/comments/domain.d.ts +2 -2
- package/dist/storage/domains/comments/domain.d.ts.map +1 -1
- package/dist/storage/domains/comments/domain.js +1 -1
- package/dist/storage/domains/comments/domain.js.map +1 -1
- package/dist/storage/domains/comments/feed-sync.d.ts +2 -2
- package/dist/storage/domains/comments/feed-sync.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +0 -3
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +0 -3
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +99 -35
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +318 -170
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/board-version.d.ts +2 -2
- package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
- package/dist/storage/domains/work-items/board-version.js +16 -5
- package/dist/storage/domains/work-items/board-version.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +57 -0
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -0
- package/dist/storage/domains/work-items/cards.js +290 -0
- package/dist/storage/domains/work-items/cards.js.map +1 -0
- package/dist/storage/domains/work-items/metrics.d.ts +2 -2
- package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
- package/dist/storage/domains/work-items/metrics.js.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.d.ts +117 -0
- package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -0
- package/dist/storage/domains/work-items/work-item-schema.js +300 -0
- package/dist/storage/domains/work-items/work-item-schema.js.map +1 -0
- package/dist/tools/read-tools.d.ts +4 -4
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +19 -9
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/side-sessions.d.ts +2 -2
- package/dist/tools/side-sessions.d.ts.map +1 -1
- package/dist/tools/side-sessions.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +12 -17
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/work-items/create-work-item.d.ts +4 -4
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +65 -27
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/providers/base.d.ts +22 -0
- package/dist/work-items/providers/base.d.ts.map +1 -0
- package/dist/work-items/providers/base.js +44 -0
- package/dist/work-items/providers/base.js.map +1 -0
- package/dist/work-items/providers/factory.d.ts +4 -0
- package/dist/work-items/providers/factory.d.ts.map +1 -0
- package/dist/work-items/providers/factory.js +13 -0
- package/dist/work-items/providers/factory.js.map +1 -0
- package/dist/work-items/providers/github.d.ts +3 -0
- package/dist/work-items/providers/github.d.ts.map +1 -0
- package/dist/work-items/providers/github.js +30 -0
- package/dist/work-items/providers/github.js.map +1 -0
- package/dist/work-items/providers/gitlab.d.ts +3 -0
- package/dist/work-items/providers/gitlab.d.ts.map +1 -0
- package/dist/work-items/providers/gitlab.js +35 -0
- package/dist/work-items/providers/gitlab.js.map +1 -0
- package/dist/work-items/providers/incidentio.d.ts +3 -0
- package/dist/work-items/providers/incidentio.d.ts.map +1 -0
- package/dist/work-items/providers/incidentio.js +23 -0
- package/dist/work-items/providers/incidentio.js.map +1 -0
- package/dist/work-items/providers/index.d.ts +8 -0
- package/dist/work-items/providers/index.d.ts.map +1 -0
- package/dist/work-items/providers/index.js +34 -0
- package/dist/work-items/providers/index.js.map +1 -0
- package/dist/work-items/providers/jira.d.ts +3 -0
- package/dist/work-items/providers/jira.d.ts.map +1 -0
- package/dist/work-items/providers/jira.js +16 -0
- package/dist/work-items/providers/jira.js.map +1 -0
- package/dist/work-items/providers/linear.d.ts +3 -0
- package/dist/work-items/providers/linear.d.ts.map +1 -0
- package/dist/work-items/providers/linear.js +24 -0
- package/dist/work-items/providers/linear.js.map +1 -0
- package/dist/work-items/providers/metadata-keys.d.ts +24 -0
- package/dist/work-items/providers/metadata-keys.d.ts.map +1 -0
- package/dist/work-items/providers/metadata-keys.js +84 -0
- package/dist/work-items/providers/metadata-keys.js.map +1 -0
- package/dist/work-items/providers/slack.d.ts +6 -0
- package/dist/work-items/providers/slack.d.ts.map +1 -0
- package/dist/work-items/providers/slack.js +15 -0
- package/dist/work-items/providers/slack.js.map +1 -0
- package/dist/work-items/providers/types.d.ts +23 -0
- package/dist/work-items/providers/types.d.ts.map +1 -0
- package/dist/work-items/providers/types.js +1 -0
- package/dist/work-items/split-migration.d.ts +51 -0
- package/dist/work-items/split-migration.d.ts.map +1 -0
- package/dist/work-items/split-migration.js +293 -0
- package/dist/work-items/split-migration.js.map +1 -0
- package/factory-skills/configure-factory-rules/SKILL.md +12 -16
- package/factory-skills/factory-self-review/SKILL.md +1 -1
- package/factory-skills/factory-triage/SKILL.md +3 -3
- package/package.json +15 -15
- package/dist/boards/work-transition-policy.d.ts +0 -3
- package/dist/boards/work-transition-policy.d.ts.map +0 -1
- package/dist/boards/work-transition-policy.js +0 -78
- package/dist/boards/work-transition-policy.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-item-tools.js","names":[],"sources":["../../src/tools/work-item-tools.ts"],"sourcesContent":["/**\n * Factory tools that change work items: file one, move it, settle its\n * decisions, and follow it. They act as the session's person (a human actor),\n * through the same code the board's routes use.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { boardForWorkItem } from '../boards/index.js';\nimport type { BoardRegistry } from '../boards/index.js';\nimport type { IntakeRoutesReader } from '../boards/intake-routing.js';\nimport { toBoardSource } from '../boards/project-boards.js';\nimport type { ProjectBoardSource } from '../boards/project-boards.js';\nimport type { IntegrationTools } from '../integrations/base.js';\nimport { factoryWorkItemUrl } from '../links.js';\nimport { transitionBodySchema } from '../routes/contracts.js';\nimport type { FactoryTransitionService } from '../rules/transition-service.js';\nimport type { SourceControlSessionLookup } from '../session/factory-session.js';\nimport { resolveWorkItemRepository } from '../session/work-item-repository.js';\nimport type { AuditRecorder } from '../storage/domains/audit/domain.js';\nimport type { CommentsDomain } from '../storage/domains/comments/domain.js';\nimport { WorkItemRelationError } from '../storage/domains/work-items/base.js';\nimport type { UpdateWorkItemInput, WorkItemRow, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { createFactoryWorkItem } from '../work-items/create-work-item.js';\nimport type { FactoryAuditEmit } from '../work-items/create-work-item.js';\nimport {\n dismissFactoryDecision,\n resolveFactoryProposal,\n retryFactoryDecision,\n} from '../work-items/decision-actions.js';\nimport type { FactoryDecisionActionResult } from '../work-items/decision-actions.js';\nimport {\n MAX_TEXT,\n findWorkItem,\n workItemRefSchema,\n truncate,\n workItemNotFound,\n workItemNumber,\n workItemStage,\n} from './read-tools.js';\nimport { requirePerson } from './scope.js';\nimport type { FactoryToolScope } from './scope.js';\n\nexport interface FactoryWorkItemToolDependencies {\n workItems: WorkItemsStorage;\n /** A fixed registry, or the per-project boards. */\n boards: BoardRegistry | ProjectBoardSource;\n /** The project's intake routes, which place a filed card. */\n intakeRoutes?: IntakeRoutesReader;\n /** Governed stage moves; filing and moving items refuse while it is unavailable. */\n transitionService: Pick<FactoryTransitionService, 'transition'> | undefined;\n /** Writes audit rows with an explicit actor; tool calls have no HTTP request to read one from. */\n auditRecorder: AuditRecorder;\n /** The feed's front door: validates, touches open boards and mirrors to linked channels. */\n feed: Pick<CommentsDomain, 'createComment'>;\n /** Finds the caller session's source-control provider, whose linked repositories a card can name. */\n sessions: Pick<SourceControlSessionLookup, 'getSourceControlBySessionId'>;\n}\n\nconst repositorySchema = z\n .string()\n .trim()\n .min(3)\n .max(200)\n .regex(/^[^/\\s]+\\/[^/\\s]+$/, 'Use the owner/name form, e.g. \"mastra-ai/mastra\".')\n .describe('A repository linked to this Factory, as owner/name.');\n\nconst decisionId = z.string().trim().uuid().describe('Decision id, from factory_list_attention or inspect.');\n\nfunction briefItem(item: WorkItemRow) {\n return {\n id: item.id,\n number: workItemNumber(item),\n title: truncate(item.title, MAX_TEXT),\n stage: workItemStage(item),\n url:\n factoryWorkItemUrl({\n factoryProjectId: item.factoryProjectId,\n board: boardForWorkItem(item),\n workItemId: item.id,\n }) ?? null,\n };\n}\n\nfunction settled(result: FactoryDecisionActionResult) {\n if (!result.ok) throw new Error(result.message);\n const { decision } = result;\n return { decisionId: decision.id, status: decision.status, workItemId: decision.workItemId };\n}\n\n/** The work-item write and subscription tools for one user session's turn. */\nexport function createFactoryWorkItemTools(\n scope: FactoryToolScope,\n deps: FactoryWorkItemToolDependencies,\n): IntegrationTools {\n const project = { orgId: scope.orgId, factoryProjectId: scope.factoryProjectId };\n const audit: FactoryAuditEmit = async input => {\n await deps.auditRecorder.record({\n orgId: scope.orgId,\n // Turns nobody signed in started are recorded as this session's agent, as their moves are.\n actorId: scope.interactive ? scope.userId : `agent:session:${scope.sessionId}`,\n actorType: scope.interactive ? 'human' : 'agent',\n ...(scope.actorProfile ? { actorProfile: scope.actorProfile } : {}),\n ...input,\n });\n };\n const requireItem = async (ref: string) => {\n const item = await findWorkItem(deps.workItems, scope, ref);\n if (!item) throw workItemNotFound(ref);\n return item;\n };\n /**\n * Check `slug` is a repository linked to this Factory and that a card with\n * `metadata` would run in it (a card synced from an issue follows the\n * issue's repository, which a slug can't override).\n */\n const requireRepository = async (slug: string, metadata: Record<string, unknown> | null = null) => {\n const sourceControl = await deps.sessions.getSourceControlBySessionId(scope.sessionId);\n if (!sourceControl) throw new Error('This session has no source-control provider to look repositories up in.');\n const resolve = (repository?: string) =>\n resolveWorkItemRepository({\n sourceControl,\n ...project,\n item: { metadata: repository ? { ...metadata, repository } : metadata },\n });\n const resolution = await resolve(slug);\n if (resolution.status === 'resolved' && resolution.slug === slug) return;\n if (resolution.status === 'resolved') {\n throw new Error(`This card runs in ${resolution.slug}, which comes from its linked issue and can't be changed.`);\n }\n const linked = await resolve();\n const candidates =\n linked.status === 'ambiguous' ? linked.candidates : linked.status === 'resolved' ? [linked.slug] : [];\n throw new Error(\n candidates.length > 0\n ? `${slug} is not linked to this Factory. Linked repositories: ${candidates.join(', ')}.`\n : `${slug} is not linked to this Factory, and it has no linked repositories.`,\n );\n };\n const follow = (item: WorkItemRow, reason: 'created' | 'subscribed') =>\n deps.workItems.subscribeToWorkItem({\n ...project,\n workItemId: item.id,\n sessionId: scope.sessionId,\n threadId: scope.threadId,\n resourceId: scope.resourceId,\n userId: scope.userId,\n reason,\n });\n\n return {\n factory_create_work_item: createTool({\n id: 'factory_create_work_item',\n description:\n \"File a new work item on this Factory's Work board (or wherever the project's intake routes send it) for the person you are working with. It enters its board's first phase, or the phase an intake route names, and this session follows it. Check factory_list_work_items for an existing item first. Name the repository when the Factory links more than one; runs refuse to start on a card that doesn't say which.\",\n inputSchema: z\n .object({\n title: z.string().trim().min(1).max(512).describe('Short title, as it should read on the card.'),\n brief: z\n .string()\n .trim()\n .min(1)\n .max(8000)\n .describe('What needs doing and why; posted as the first comment on the card.'),\n repository: repositorySchema.optional(),\n })\n .strict(),\n execute: async ({ title, brief, repository }) => {\n if (repository) await requireRepository(repository);\n const created = await createFactoryWorkItem({\n workItems: deps.workItems,\n boards: await toBoardSource(deps.boards).load(project),\n transitionService: deps.transitionService,\n intakeRoutes: deps.intakeRoutes,\n audit,\n ...project,\n userId: scope.userId,\n ...(scope.actorProfile ? { origin: { actorProfile: scope.actorProfile } } : {}),\n input: { title, ...(repository ? { metadata: { repository } } : {}) },\n });\n if (created.status === 'refused') throw new Error(created.message);\n if (created.status === 'rejected') throw new Error(`The board refused the new item: ${created.reason}`);\n const { item } = created;\n // The card exists from here on: report follow-up failures alongside it\n // rather than failing the call, so the agent doesn't file it twice.\n const warnings: string[] = [];\n try {\n const comment = await deps.feed.createComment({\n orgId: scope.orgId,\n workItemId: item.id,\n author: { kind: 'user', id: scope.userId },\n body: brief,\n });\n if (comment.status !== 'created') {\n warnings.push(\n `The brief was not posted (${comment.status === 'invalid' ? comment.message : comment.status}).`,\n );\n }\n } catch (error) {\n warnings.push(`The brief was not posted: ${error instanceof Error ? error.message : String(error)}`);\n }\n try {\n await follow(item, 'created');\n } catch (error) {\n warnings.push(\n `This session does not follow it yet: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n return warnings.length ? { ...briefItem(item), warnings } : briefItem(item);\n },\n }),\n\n factory_transition_work_item: createTool({\n id: 'factory_transition_work_item',\n description:\n \"Move a work item to another stage of its board, as the person you are working with. The board's rules decide whether the move is allowed and what it starts.\",\n inputSchema: z\n .object({\n workItem: workItemRefSchema,\n stage: z.string().trim().min(1).max(64).describe('Destination stage, e.g. \"planning\" or \"done\".'),\n })\n .strict(),\n execute: async ({ workItem, stage }) => {\n if (!deps.transitionService) throw new Error('Factory stage transitions are not available right now.');\n const item = await requireItem(workItem);\n const parsed = transitionBodySchema.safeParse({\n board: boardForWorkItem(item),\n stage,\n expectedRevision: item.revision,\n requestId: randomUUID(),\n cause: 'factory_tools',\n });\n if (!parsed.success) throw new Error(`\"${stage}\" is not a valid stage name.`);\n const result = await deps.transitionService.transition({\n ...parsed.data,\n ...project,\n workItemId: item.id,\n ...(scope.interactive\n ? {\n actor: { type: 'human' as const, id: scope.userId },\n ...(scope.actorProfile ? { actorProfile: scope.actorProfile } : {}),\n ingress: { ...parsed.data.ingress, identity: `human:${scope.userId}:${parsed.data.ingress.identity}` },\n }\n : {\n // Nobody signed in started this turn: move as this session's agent, so the\n // plan gate and the agent's done gates apply and the move arms no runs.\n actor: { type: 'agent' as const, bindingId: `session:${scope.sessionId}`, role: 'session' },\n ingress: {\n type: 'agent' as const,\n identity: `session:${scope.sessionId}:${parsed.data.ingress.identity}`,\n },\n }),\n });\n if (result.status === 'rejected') throw new Error(`The move was refused (${result.code}): ${result.reason}`);\n return { workItemId: item.id, stage: result.stage, revision: result.revision };\n },\n }),\n\n factory_update_work_item: createTool({\n id: 'factory_update_work_item',\n description:\n \"Edit a work item's fields as the person you are working with: its title, the repository its runs use, its parent item, or pre-approving its plans. Move stages with factory_transition_work_item and start roles with factory_start_session; post to the card's feed for anything else.\",\n inputSchema: z\n .object({\n workItem: workItemRefSchema,\n title: z.string().trim().min(1).max(500).optional().describe('New card title.'),\n repository: repositorySchema.optional(),\n parentWorkItem: workItemRefSchema\n .nullable()\n .optional()\n .describe('Parent work item (id or #number), or null to detach it from its parent.'),\n plansPreapproved: z\n .literal(true)\n .optional()\n .describe(\n \"Pre-approve the item's plans, so its runs no longer stop for plan approval. Can't be undone here.\",\n ),\n })\n .strict()\n .refine(input => Object.keys(input).some(key => key !== 'workItem'), 'Pass at least one field to change.'),\n execute: async ({ workItem, title, repository, parentWorkItem, plansPreapproved }) => {\n // Pre-approval drops the plan-approval gate for good, so it is the person's call.\n if (plansPreapproved) requirePerson(scope, 'pre-approve plans');\n const item = await requireItem(workItem);\n if (repository) await requireRepository(repository, item.metadata);\n let parentWorkItemId: string | null | undefined;\n if (parentWorkItem === null) parentWorkItemId = null;\n else if (parentWorkItem !== undefined) parentWorkItemId = (await requireItem(parentWorkItem)).id;\n const patch: UpdateWorkItemInput = {\n ...(title !== undefined ? { title } : {}),\n ...(repository ? { metadata: { repository } } : {}),\n ...(parentWorkItemId !== undefined ? { parentWorkItemId } : {}),\n ...(plansPreapproved ? { plansPreapproved } : {}),\n };\n let updated: Awaited<ReturnType<WorkItemsStorage['update']>>;\n try {\n updated = await deps.workItems.update({ orgId: scope.orgId, id: item.id, userId: scope.userId, patch });\n } catch (error) {\n if (error instanceof WorkItemRelationError) throw new Error(`The parent was refused: ${error.message}`);\n throw error;\n }\n if (!updated) throw workItemNotFound(workItem);\n const fields = [\n ...(title !== undefined ? ['title'] : []),\n ...(repository ? ['metadata'] : []),\n ...(parentWorkItemId !== undefined ? ['parentWorkItemId'] : []),\n ...(plansPreapproved ? ['plansPreapproved'] : []),\n ];\n await audit({\n action: 'factory.work_item.updated',\n factoryProjectId: scope.factoryProjectId,\n targets: [{ type: 'work_item', id: updated.item.id, name: updated.item.title }],\n metadata: { fields, cause: 'factory_tools' },\n });\n const metadata = updated.item.metadata ?? {};\n return {\n workItem: briefItem(updated.item),\n updated: fields.map(field => (field === 'metadata' ? 'repository' : field)),\n repository: typeof metadata.repository === 'string' ? metadata.repository : null,\n parentWorkItemId: updated.item.parentWorkItemId,\n plansPreapproved: updated.item.plansPreapprovedAt !== null,\n };\n },\n }),\n\n factory_retry_decision: createTool({\n id: 'factory_retry_decision',\n description:\n 'Retry one failed Factory run once its cause is fixed. Refused when the failure cannot be fixed by retrying or the item has moved on.',\n inputSchema: z.object({ decisionId }).strict(),\n execute: async ({ decisionId }) =>\n settled(\n await retryFactoryDecision({\n workItems: deps.workItems,\n boards: await toBoardSource(deps.boards).load(project),\n ...project,\n decisionId,\n }),\n ),\n }),\n\n factory_dismiss_decision: createTool({\n id: 'factory_dismiss_decision',\n description: 'Dismiss one proposed Factory run that is no longer wanted.',\n inputSchema: z.object({ decisionId }).strict(),\n execute: async ({ decisionId }) => {\n requirePerson(scope, 'dismiss a proposed run');\n return settled(\n await dismissFactoryDecision({\n workItems: deps.workItems,\n audit,\n ...project,\n userId: scope.userId,\n decisionId,\n }),\n );\n },\n }),\n\n factory_resolve_proposal: createTool({\n id: 'factory_resolve_proposal',\n description:\n \"Approve or dismiss one proposed Factory run. Approving starts the run and lets the item's later runs start without asking.\",\n inputSchema: z.object({ decisionId, action: z.enum(['approve', 'dismiss']) }).strict(),\n execute: async ({ decisionId, action }) => {\n requirePerson(scope, 'approve or dismiss a proposed run');\n return settled(\n await resolveFactoryProposal({\n workItems: deps.workItems,\n audit,\n ...project,\n userId: scope.userId,\n decisionId,\n action,\n }),\n );\n },\n }),\n\n factory_subscribe_work_item: createTool({\n id: 'factory_subscribe_work_item',\n description:\n 'Follow a work item from this session, so you hear about its progress and its sessions report to you. Items you file or start are followed already.',\n inputSchema: z.object({ workItem: workItemRefSchema }).strict(),\n execute: async ({ workItem }) => {\n const item = await requireItem(workItem);\n const subscription = await follow(item, 'subscribed');\n return { workItem: briefItem(item), subscribed: true, reason: subscription.reason };\n },\n }),\n\n factory_unsubscribe_work_item: createTool({\n id: 'factory_unsubscribe_work_item',\n description: 'Stop following a work item from this session.',\n inputSchema: z.object({ workItem: workItemRefSchema }).strict(),\n execute: async ({ workItem }) => {\n const item = await requireItem(workItem);\n const removed = await deps.workItems.unsubscribeFromWorkItem({\n orgId: scope.orgId,\n workItemId: item.id,\n sessionId: scope.sessionId,\n });\n return { workItem: briefItem(item), subscribed: false, wasSubscribed: removed };\n },\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,mBAAmB,EACtB,OAAO,CAAC,CACR,KAAK,CAAC,CACN,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,MAAM,sBAAsB,qDAAmD,CAAC,CAChF,SAAS,qDAAqD;AAEjE,MAAM,aAAa,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,sDAAsD;AAE3G,SAAS,UAAU,MAAmB;CACpC,OAAO;EACL,IAAI,KAAK;EACT,QAAQ,eAAe,IAAI;EAC3B,OAAO,SAAS,KAAK,OAAA,GAAe;EACpC,OAAO,cAAc,IAAI;EACzB,KACE,mBAAmB;GACjB,kBAAkB,KAAK;GACvB,OAAO,iBAAiB,IAAI;GAC5B,YAAY,KAAK;EACnB,CAAC,KAAK;CACV;AACF;AAEA,SAAS,QAAQ,QAAqC;CACpD,IAAI,CAAC,OAAO,IAAI,MAAM,IAAI,MAAM,OAAO,OAAO;CAC9C,MAAM,EAAE,aAAa;CACrB,OAAO;EAAE,YAAY,SAAS;EAAI,QAAQ,SAAS;EAAQ,YAAY,SAAS;CAAW;AAC7F;;AAGA,SAAgB,2BACd,OACA,MACkB;CAClB,MAAM,UAAU;EAAE,OAAO,MAAM;EAAO,kBAAkB,MAAM;CAAiB;CAC/E,MAAM,QAA0B,OAAM,UAAS;EAC7C,MAAM,KAAK,cAAc,OAAO;GAC9B,OAAO,MAAM;GAEb,SAAS,MAAM,cA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AAM,UAAU,MAAM,KAAK,UAAU,wBAAwB;KAC3D,OAAO,MAAM;KACb,YAAY,KAAK;KACjB,WAAW,MAAM;IACnB,CAAC;IACD,OAAO;KAAE,UAAU,UAAU,IAAI;KAAG,YAAY;KAAO,eAAe;IAAQ;GAChF;EACF,CAAC;CACH;AACF"}
|
|
1
|
+
{"version":3,"file":"work-item-tools.js","names":[],"sources":["../../src/tools/work-item-tools.ts"],"sourcesContent":["/**\n * Factory tools that change work items: file one, move it, settle its\n * decisions, and follow it. They act as the session's person (a human actor),\n * through the same code the board's routes use.\n */\n\nimport { randomUUID } from 'node:crypto';\nimport { createTool } from '@mastra/core/tools';\nimport { z } from 'zod';\n\nimport { boardForWorkItem } from '../boards/index.js';\nimport type { BoardRegistry } from '../boards/index.js';\nimport type { IntakeRoutesReader } from '../boards/intake-routing.js';\nimport { toBoardSource } from '../boards/project-boards.js';\nimport type { ProjectBoardSource } from '../boards/project-boards.js';\nimport type { IntegrationTools } from '../integrations/base.js';\nimport { factoryWorkItemUrl } from '../links.js';\nimport { transitionBodySchema } from '../routes/contracts.js';\nimport type { FactoryTransitionService } from '../rules/transition-service.js';\nimport type { SourceControlSessionLookup } from '../session/factory-session.js';\nimport { resolveWorkItemRepository } from '../session/work-item-repository.js';\nimport type { AuditRecorder } from '../storage/domains/audit/domain.js';\nimport type { CommentsDomain } from '../storage/domains/comments/domain.js';\nimport { WorkItemRelationError } from '../storage/domains/work-items/base.js';\nimport type { UpdateWorkItemInput, Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\nimport { createFactoryWorkItem } from '../work-items/create-work-item.js';\nimport type { FactoryAuditEmit } from '../work-items/create-work-item.js';\nimport {\n dismissFactoryDecision,\n resolveFactoryProposal,\n retryFactoryDecision,\n} from '../work-items/decision-actions.js';\nimport type { FactoryDecisionActionResult } from '../work-items/decision-actions.js';\nimport {\n MAX_TEXT,\n findWorkItem,\n workItemRefSchema,\n truncate,\n workItemNotFound,\n workItemNumber,\n workItemStage,\n} from './read-tools.js';\nimport { requirePerson } from './scope.js';\nimport type { FactoryToolScope } from './scope.js';\n\nexport interface FactoryWorkItemToolDependencies {\n workItems: WorkItemsStorage;\n /** A fixed registry, or the per-project boards. */\n boards: BoardRegistry | ProjectBoardSource;\n /** The project's intake routes, which place a filed card. */\n intakeRoutes?: IntakeRoutesReader;\n /** Governed stage moves; filing and moving items refuse while it is unavailable. */\n transitionService: Pick<FactoryTransitionService, 'transition'> | undefined;\n /** Writes audit rows with an explicit actor; tool calls have no HTTP request to read one from. */\n auditRecorder: AuditRecorder;\n /** The feed's front door: validates, touches open boards and mirrors to linked channels. */\n feed: Pick<CommentsDomain, 'createComment'>;\n /** Finds the caller session's source-control provider, whose linked repositories a card can name. */\n sessions: Pick<SourceControlSessionLookup, 'getSourceControlBySessionId'>;\n}\n\nconst repositorySchema = z\n .string()\n .trim()\n .min(3)\n .max(200)\n .regex(/^[^/\\s]+\\/[^/\\s]+$/, 'Use the owner/name form, e.g. \"mastra-ai/mastra\".')\n .describe('A repository linked to this Factory, as owner/name.');\n\nconst decisionId = z.string().trim().uuid().describe('Decision id, from factory_list_attention or inspect.');\n\nfunction briefItem(item: Card) {\n return {\n id: item.id,\n number: workItemNumber(item),\n title: truncate(item.title, MAX_TEXT),\n stage: workItemStage(item),\n url:\n factoryWorkItemUrl({\n factoryProjectId: item.factoryProjectId,\n board: boardForWorkItem(item),\n workItemId: item.id,\n }) ?? null,\n };\n}\n\nfunction settled(result: FactoryDecisionActionResult) {\n if (!result.ok) throw new Error(result.message);\n const { decision } = result;\n return { decisionId: decision.id, status: decision.status, workItemId: decision.workItemId };\n}\n\n/** The work-item write and subscription tools for one user session's turn. */\nexport function createFactoryWorkItemTools(\n scope: FactoryToolScope,\n deps: FactoryWorkItemToolDependencies,\n): IntegrationTools {\n const project = { orgId: scope.orgId, factoryProjectId: scope.factoryProjectId };\n const audit: FactoryAuditEmit = async input => {\n await deps.auditRecorder.record({\n orgId: scope.orgId,\n // Turns nobody signed in started are recorded as this session's agent, as their moves are.\n actorId: scope.interactive ? scope.userId : `agent:session:${scope.sessionId}`,\n actorType: scope.interactive ? 'human' : 'agent',\n ...(scope.actorProfile ? { actorProfile: scope.actorProfile } : {}),\n ...input,\n });\n };\n const requireItem = async (ref: string) => {\n const item = await findWorkItem(deps.workItems, scope, ref);\n if (!item) throw workItemNotFound(ref);\n return item;\n };\n /**\n * Check `slug` is a repository linked to this Factory and that a card with\n * `metadata` would run in it (a card synced from an issue follows the\n * issue's repository, which a slug can't override).\n */\n const requireRepository = async (slug: string, item?: Pick<Card, 'metadata' | 'workItem'>) => {\n const sourceControl = await deps.sessions.getSourceControlBySessionId(scope.sessionId);\n if (!sourceControl) throw new Error('This session has no source-control provider to look repositories up in.');\n const resolve = (repository?: string) =>\n resolveWorkItemRepository({\n sourceControl,\n ...project,\n item: {\n metadata: repository ? { repository } : (item?.metadata ?? null),\n workItem: item?.workItem ?? { metadata: null },\n },\n });\n const resolution = await resolve(slug);\n if (resolution.status === 'resolved' && resolution.slug === slug) return;\n if (resolution.status === 'resolved') {\n throw new Error(`This card runs in ${resolution.slug}, which comes from its linked issue and can't be changed.`);\n }\n const linked = await resolve();\n const candidates =\n linked.status === 'ambiguous' ? linked.candidates : linked.status === 'resolved' ? [linked.slug] : [];\n throw new Error(\n candidates.length > 0\n ? `${slug} is not linked to this Factory. Linked repositories: ${candidates.join(', ')}.`\n : `${slug} is not linked to this Factory, and it has no linked repositories.`,\n );\n };\n const follow = (item: Card, reason: 'created' | 'subscribed') =>\n deps.workItems.subscribeToWorkItem({\n ...project,\n workItemId: item.id,\n sessionId: scope.sessionId,\n threadId: scope.threadId,\n resourceId: scope.resourceId,\n userId: scope.userId,\n reason,\n });\n\n return {\n factory_create_work_item: createTool({\n id: 'factory_create_work_item',\n description:\n \"File a new work item on this Factory's Work board (or wherever the project's intake routes send it) for the person you are working with. It enters its board's first phase, or the phase an intake route names, and this session follows it. Check factory_list_work_items for an existing item first. Name the repository when the Factory links more than one; runs refuse to start on a card that doesn't say which.\",\n inputSchema: z\n .object({\n title: z.string().trim().min(1).max(512).describe('Short title, as it should read on the card.'),\n brief: z\n .string()\n .trim()\n .min(1)\n .max(8000)\n .describe('What needs doing and why; posted as the first comment on the card.'),\n repository: repositorySchema.optional(),\n })\n .strict(),\n execute: async ({ title, brief, repository }) => {\n if (repository) await requireRepository(repository);\n const created = await createFactoryWorkItem({\n workItems: deps.workItems,\n boards: await toBoardSource(deps.boards).load(project),\n transitionService: deps.transitionService,\n intakeRoutes: deps.intakeRoutes,\n audit,\n ...project,\n userId: scope.userId,\n ...(scope.actorProfile ? { origin: { actorProfile: scope.actorProfile } } : {}),\n input: { title, ...(repository ? { metadata: { repository } } : {}) },\n });\n if (created.status === 'refused') throw new Error(created.message);\n if (created.status === 'rejected') throw new Error(`The board refused the new item: ${created.reason}`);\n const { item } = created;\n // The card exists from here on: report follow-up failures alongside it\n // rather than failing the call, so the agent doesn't file it twice.\n const warnings: string[] = [];\n try {\n const comment = await deps.feed.createComment({\n orgId: scope.orgId,\n workItemId: item.id,\n author: { kind: 'user', id: scope.userId },\n body: brief,\n });\n if (comment.status !== 'created') {\n warnings.push(\n `The brief was not posted (${comment.status === 'invalid' ? comment.message : comment.status}).`,\n );\n }\n } catch (error) {\n warnings.push(`The brief was not posted: ${error instanceof Error ? error.message : String(error)}`);\n }\n try {\n await follow(item, 'created');\n } catch (error) {\n warnings.push(\n `This session does not follow it yet: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n return warnings.length ? { ...briefItem(item), warnings } : briefItem(item);\n },\n }),\n\n factory_transition_work_item: createTool({\n id: 'factory_transition_work_item',\n description:\n \"Move a work item to another stage of its board, as the person you are working with. The board's rules decide whether the move is allowed and what it starts.\",\n inputSchema: z\n .object({\n workItem: workItemRefSchema,\n stage: z.string().trim().min(1).max(64).describe('Destination stage, e.g. \"planning\" or \"done\".'),\n })\n .strict(),\n execute: async ({ workItem, stage }) => {\n if (!deps.transitionService) throw new Error('Factory stage transitions are not available right now.');\n const item = await requireItem(workItem);\n const parsed = transitionBodySchema.safeParse({\n board: boardForWorkItem(item),\n stage,\n expectedRevision: item.revision,\n requestId: randomUUID(),\n cause: 'factory_tools',\n });\n if (!parsed.success) throw new Error(`\"${stage}\" is not a valid stage name.`);\n const result = await deps.transitionService.transition({\n ...parsed.data,\n ...project,\n workItemId: item.id,\n ...(scope.interactive\n ? {\n actor: { type: 'human' as const, id: scope.userId },\n ...(scope.actorProfile ? { actorProfile: scope.actorProfile } : {}),\n ingress: { ...parsed.data.ingress, identity: `human:${scope.userId}:${parsed.data.ingress.identity}` },\n }\n : {\n // Nobody signed in started this turn: move as this session's agent, so the\n // plan gate and the agent's done gates apply and the move arms no runs.\n actor: { type: 'agent' as const, bindingId: `session:${scope.sessionId}`, role: 'session' },\n ingress: {\n type: 'agent' as const,\n identity: `session:${scope.sessionId}:${parsed.data.ingress.identity}`,\n },\n }),\n });\n if (result.status === 'rejected') throw new Error(`The move was refused (${result.code}): ${result.reason}`);\n return { workItemId: item.id, stage: result.stage, revision: result.revision };\n },\n }),\n\n factory_update_work_item: createTool({\n id: 'factory_update_work_item',\n description:\n \"Edit a work item's fields as the person you are working with: its title, the repository its runs use, its parent item, or pre-approving its plans. Move stages with factory_transition_work_item and start roles with factory_start_session; post to the card's feed for anything else.\",\n inputSchema: z\n .object({\n workItem: workItemRefSchema,\n title: z.string().trim().min(1).max(500).optional().describe('New card title.'),\n repository: repositorySchema.optional(),\n parentWorkItem: workItemRefSchema\n .nullable()\n .optional()\n .describe('Parent work item (id or #number), or null to detach it from its parent.'),\n })\n .strict()\n .refine(input => Object.keys(input).some(key => key !== 'workItem'), 'Pass at least one field to change.'),\n execute: async ({ workItem, title, repository, parentWorkItem }) => {\n const item = await requireItem(workItem);\n if (repository) await requireRepository(repository, item);\n let parentWorkItemId: string | null | undefined;\n if (parentWorkItem === null) parentWorkItemId = null;\n else if (parentWorkItem !== undefined) parentWorkItemId = (await requireItem(parentWorkItem)).id;\n const patch: UpdateWorkItemInput = {\n ...(title !== undefined ? { title } : {}),\n ...(repository ? { metadata: { repository } } : {}),\n ...(parentWorkItemId !== undefined ? { parentWorkItemId } : {}),\n };\n let updated: Awaited<ReturnType<WorkItemsStorage['update']>>;\n try {\n updated = await deps.workItems.update({ orgId: scope.orgId, id: item.id, userId: scope.userId, patch });\n } catch (error) {\n if (error instanceof WorkItemRelationError) throw new Error(`The parent was refused: ${error.message}`);\n throw error;\n }\n if (!updated) throw workItemNotFound(workItem);\n const fields = [\n ...(title !== undefined ? ['title'] : []),\n ...(repository ? ['metadata'] : []),\n ...(parentWorkItemId !== undefined ? ['parentWorkItemId'] : []),\n ];\n await audit({\n action: 'factory.work_item.updated',\n factoryProjectId: scope.factoryProjectId,\n targets: [{ type: 'work_item', id: updated.item.id, name: updated.item.title }],\n metadata: { fields, cause: 'factory_tools' },\n });\n const metadata = updated.item.metadata ?? {};\n return {\n workItem: briefItem(updated.item),\n updated: fields.map(field => (field === 'metadata' ? 'repository' : field)),\n repository: typeof metadata.repository === 'string' ? metadata.repository : null,\n parentWorkItemId: updated.item.parentWorkItemId,\n };\n },\n }),\n\n factory_retry_decision: createTool({\n id: 'factory_retry_decision',\n description:\n 'Retry one failed Factory run once its cause is fixed. Refused when the failure cannot be fixed by retrying or the item has moved on.',\n inputSchema: z.object({ decisionId }).strict(),\n execute: async ({ decisionId }) =>\n settled(\n await retryFactoryDecision({\n workItems: deps.workItems,\n boards: await toBoardSource(deps.boards).load(project),\n ...project,\n decisionId,\n }),\n ),\n }),\n\n factory_dismiss_decision: createTool({\n id: 'factory_dismiss_decision',\n description: 'Dismiss one proposed Factory run that is no longer wanted.',\n inputSchema: z.object({ decisionId }).strict(),\n execute: async ({ decisionId }) => {\n requirePerson(scope, 'dismiss a proposed run');\n return settled(\n await dismissFactoryDecision({\n workItems: deps.workItems,\n audit,\n ...project,\n userId: scope.userId,\n decisionId,\n }),\n );\n },\n }),\n\n factory_resolve_proposal: createTool({\n id: 'factory_resolve_proposal',\n description:\n \"Approve or dismiss one proposed Factory run. Approving starts the run and lets the item's later runs start without asking.\",\n inputSchema: z.object({ decisionId, action: z.enum(['approve', 'dismiss']) }).strict(),\n execute: async ({ decisionId, action }) => {\n requirePerson(scope, 'approve or dismiss a proposed run');\n return settled(\n await resolveFactoryProposal({\n workItems: deps.workItems,\n audit,\n ...project,\n userId: scope.userId,\n decisionId,\n action,\n }),\n );\n },\n }),\n\n factory_subscribe_work_item: createTool({\n id: 'factory_subscribe_work_item',\n description:\n 'Follow a work item from this session, so you hear about its progress and its sessions report to you. Items you file or start are followed already.',\n inputSchema: z.object({ workItem: workItemRefSchema }).strict(),\n execute: async ({ workItem }) => {\n const item = await requireItem(workItem);\n const subscription = await follow(item, 'subscribed');\n return { workItem: briefItem(item), subscribed: true, reason: subscription.reason };\n },\n }),\n\n factory_unsubscribe_work_item: createTool({\n id: 'factory_unsubscribe_work_item',\n description: 'Stop following a work item from this session.',\n inputSchema: z.object({ workItem: workItemRefSchema }).strict(),\n execute: async ({ workItem }) => {\n const item = await requireItem(workItem);\n const removed = await deps.workItems.unsubscribeFromWorkItem({\n orgId: scope.orgId,\n workItemId: item.id,\n sessionId: scope.sessionId,\n });\n return { workItem: briefItem(item), subscribed: false, wasSubscribed: removed };\n },\n }),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6DA,MAAM,mBAAmB,EACtB,OAAO,CAAC,CACR,KAAK,CAAC,CACN,IAAI,CAAC,CAAC,CACN,IAAI,GAAG,CAAC,CACR,MAAM,sBAAsB,qDAAmD,CAAC,CAChF,SAAS,qDAAqD;AAEjE,MAAM,aAAa,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,sDAAsD;AAE3G,SAAS,UAAU,MAAY;CAC7B,OAAO;EACL,IAAI,KAAK;EACT,QAAQ,eAAe,IAAI;EAC3B,OAAO,SAAS,KAAK,OAAA,GAAe;EACpC,OAAO,cAAc,IAAI;EACzB,KACE,mB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AO;KAAE,UAAU,UAAU,IAAI;KAAG,YAAY;KAAM,QAAQ,aAAa;IAAO;GACpF;EACF,CAAC;EAED,+BAA+B,WAAW;GACxC,IAAI;GACJ,aAAa;GACb,aAAa,EAAE,OAAO,EAAE,UAAU,kBAAkB,CAAC,CAAC,CAAC,OAAO;GAC9D,SAAS,OAAO,EAAE,eAAe;IAC/B,MAAM,OAAO,MAAM,YAAY,QAAQ;IACvC,MAAM,UAAU,MAAM,KAAK,UAAU,wBAAwB;KAC3D,OAAO,MAAM;KACb,YAAY,KAAK;KACjB,WAAW,MAAM;IACnB,CAAC;IACD,OAAO;KAAE,UAAU,UAAU,IAAI;KAAG,YAAY;KAAO,eAAe;IAAQ;GAChF;EACF,CAAC;CACH;AACF"}
|
|
@@ -6,7 +6,7 @@ import type { BoardRegistry } from '../boards/index.js';
|
|
|
6
6
|
import type { IntakeRoutesReader } from '../boards/intake-routing.js';
|
|
7
7
|
import type { FactoryTransitionRequest, FactoryTransitionService } from '../rules/transition-service.js';
|
|
8
8
|
import type { EmitAuditInput } from '../storage/domains/audit/domain.js';
|
|
9
|
-
import type { CreateWorkItemInput,
|
|
9
|
+
import type { CreateWorkItemInput, Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';
|
|
10
10
|
/** Records one audit event for the caller; routes bind it to the request, tools to the session's person. */
|
|
11
11
|
export type FactoryAuditEmit = (input: EmitAuditInput) => Promise<void>;
|
|
12
12
|
type TransitionResult = Awaited<ReturnType<FactoryTransitionService['transition']>>;
|
|
@@ -14,18 +14,18 @@ export type CreateFactoryWorkItemResult =
|
|
|
14
14
|
/** A new card, entered into its board's first phase and audited. */
|
|
15
15
|
{
|
|
16
16
|
status: 'created';
|
|
17
|
-
item:
|
|
17
|
+
item: Card;
|
|
18
18
|
}
|
|
19
19
|
/** The source key matched an existing card, which was updated instead (the caller audits the patch). */
|
|
20
20
|
| {
|
|
21
21
|
status: 'reused';
|
|
22
|
-
item:
|
|
22
|
+
item: Card;
|
|
23
23
|
} | {
|
|
24
24
|
status: 'refused';
|
|
25
25
|
code: 'invalid_board' | 'governed_transition_required' | 'factory_transitions_unavailable';
|
|
26
26
|
message: string;
|
|
27
27
|
}
|
|
28
|
-
/** The first phase's entry rules (or the move to an intake route's phase) refused the card; it was removed again. */
|
|
28
|
+
/** The first phase's entry rules (or the move to an intake route's phase) refused the card; it was removed again unless a concurrent create had already reused it. */
|
|
29
29
|
| {
|
|
30
30
|
status: 'rejected';
|
|
31
31
|
code: Extract<TransitionResult, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-work-item.d.ts","sourceRoot":"","sources":["../../src/work-items/create-work-item.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AACzG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"create-work-item.d.ts","sourceRoot":"","sources":["../../src/work-items/create-work-item.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AACzG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzG,4GAA4G;AAC5G,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAExE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M,EACN,gBAAgB,EAChB,KAAK,EACL,YAAY,EACZ,MAAM,GACP,EAAE,yBAAyB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAqJlE"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { WorkItemUpdateConflictError } from "../storage/domains/work-items/base.js";
|
|
1
2
|
import { cardRuleFacts } from "../boards/card-facts.js";
|
|
2
3
|
import "../boards/index.js";
|
|
3
|
-
import { resolveIntakePlacement } from "../boards/intake-routing.js";
|
|
4
|
+
import { INTAKE_ROUTE_METADATA_KEY, resolveIntakePlacement } from "../boards/intake-routing.js";
|
|
4
5
|
// src/work-items/create-work-item.ts
|
|
5
6
|
/**
|
|
6
7
|
* Filing a work item, shared by the board's create route and the Factory tools
|
|
7
8
|
* so a card filed from a session goes through exactly what "New card" does.
|
|
8
9
|
*/
|
|
10
|
+
/** Attempts at each step after the upsert before a card that keeps changing under its creator is left as is. */
|
|
11
|
+
const STEP_ATTEMPTS = 3;
|
|
9
12
|
/**
|
|
10
13
|
* Upserts the card into its board's first phase, enters that phase as the
|
|
11
14
|
* person (rolling the card back if its entry rules refuse it), then audits
|
|
@@ -49,31 +52,71 @@ async function createFactoryWorkItem({ workItems, boards, transitionService, aud
|
|
|
49
52
|
status: "reused",
|
|
50
53
|
item: result.item
|
|
51
54
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const id = result.item.id;
|
|
56
|
+
let revision = result.item.revision;
|
|
57
|
+
let updatedAt = result.item.updatedAt;
|
|
58
|
+
let contended = false;
|
|
59
|
+
const reread = async () => {
|
|
60
|
+
contended = true;
|
|
61
|
+
revision = (await workItems.getForProject(orgId, factoryProjectId, id))?.revision;
|
|
62
|
+
};
|
|
63
|
+
const rollBack = async () => {
|
|
64
|
+
if (contended || revision === void 0) return;
|
|
60
65
|
await workItems.delete({
|
|
61
66
|
orgId,
|
|
62
|
-
id
|
|
67
|
+
id,
|
|
68
|
+
expectedRevision: revision,
|
|
69
|
+
expectedUpdatedAt: updatedAt
|
|
63
70
|
});
|
|
71
|
+
};
|
|
72
|
+
const notFound = {
|
|
73
|
+
status: "rejected",
|
|
74
|
+
code: "invalid_transition",
|
|
75
|
+
reason: "Work item not found."
|
|
76
|
+
};
|
|
77
|
+
if (placement) {
|
|
78
|
+
for (let attempt = 1; revision !== void 0; attempt++) try {
|
|
79
|
+
const stamped = await workItems.update({
|
|
80
|
+
orgId,
|
|
81
|
+
id,
|
|
82
|
+
userId,
|
|
83
|
+
patch: { metadata: { [INTAKE_ROUTE_METADATA_KEY]: placement.routeId } },
|
|
84
|
+
expectedRevision: revision
|
|
85
|
+
});
|
|
86
|
+
revision = stamped?.item.revision;
|
|
87
|
+
if (stamped) updatedAt = stamped.item.updatedAt;
|
|
88
|
+
break;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (!(error instanceof WorkItemUpdateConflictError && error.reason === "revision") || attempt >= STEP_ATTEMPTS) throw error;
|
|
91
|
+
await reread();
|
|
92
|
+
}
|
|
93
|
+
if (revision === void 0) return notFound;
|
|
94
|
+
}
|
|
95
|
+
if (!transitionService) {
|
|
96
|
+
await rollBack();
|
|
64
97
|
return {
|
|
65
98
|
status: "refused",
|
|
66
99
|
code: "factory_transitions_unavailable",
|
|
67
100
|
message: "Factory stage transitions are not available right now."
|
|
68
101
|
};
|
|
69
102
|
}
|
|
70
|
-
const
|
|
103
|
+
const transition = async (request) => {
|
|
104
|
+
for (let attempt = 1; revision !== void 0; attempt++) {
|
|
105
|
+
const transitioned = await transitionService.transition({
|
|
106
|
+
...request,
|
|
107
|
+
expectedRevision: revision
|
|
108
|
+
});
|
|
109
|
+
if (transitioned.status === "accepted") revision = transitioned.revision;
|
|
110
|
+
if (transitioned.status !== "rejected" || transitioned.code !== "stale" || attempt >= STEP_ATTEMPTS) return transitioned;
|
|
111
|
+
await reread();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const entered = await transition({
|
|
71
115
|
orgId,
|
|
72
116
|
factoryProjectId,
|
|
73
|
-
workItemId:
|
|
117
|
+
workItemId: id,
|
|
74
118
|
board: boardId,
|
|
75
119
|
stage: board.initialPhase,
|
|
76
|
-
expectedRevision: created.revision,
|
|
77
120
|
actor: {
|
|
78
121
|
type: "human",
|
|
79
122
|
id: userId
|
|
@@ -81,16 +124,14 @@ async function createFactoryWorkItem({ workItems, boards, transitionService, aud
|
|
|
81
124
|
...origin,
|
|
82
125
|
ingress: {
|
|
83
126
|
type: "human",
|
|
84
|
-
identity: `work-item:${
|
|
127
|
+
identity: `work-item:${id}:initial-entry`
|
|
85
128
|
},
|
|
86
129
|
cause: "work_item_created",
|
|
87
130
|
initialEntry: true
|
|
88
131
|
});
|
|
132
|
+
if (!entered) return notFound;
|
|
89
133
|
if (entered.status === "rejected") {
|
|
90
|
-
await
|
|
91
|
-
orgId,
|
|
92
|
-
id: created.id
|
|
93
|
-
});
|
|
134
|
+
await rollBack();
|
|
94
135
|
return {
|
|
95
136
|
status: "rejected",
|
|
96
137
|
code: entered.code,
|
|
@@ -98,28 +139,25 @@ async function createFactoryWorkItem({ workItems, boards, transitionService, aud
|
|
|
98
139
|
};
|
|
99
140
|
}
|
|
100
141
|
if (placement && placement.phase !== board.initialPhase) {
|
|
101
|
-
const moved = await
|
|
142
|
+
const moved = await transition({
|
|
102
143
|
orgId,
|
|
103
144
|
factoryProjectId,
|
|
104
|
-
workItemId:
|
|
145
|
+
workItemId: id,
|
|
105
146
|
board: boardId,
|
|
106
147
|
stage: placement.phase,
|
|
107
|
-
expectedRevision: entered.revision,
|
|
108
148
|
actor: {
|
|
109
149
|
type: "system",
|
|
110
150
|
id: "factory-intake-route"
|
|
111
151
|
},
|
|
112
152
|
ingress: {
|
|
113
153
|
type: "rule",
|
|
114
|
-
identity: `work-item:${
|
|
154
|
+
identity: `work-item:${id}:intake-route`
|
|
115
155
|
},
|
|
116
156
|
cause: "work_item_created"
|
|
117
157
|
});
|
|
158
|
+
if (!moved) return notFound;
|
|
118
159
|
if (moved.status === "rejected") {
|
|
119
|
-
await
|
|
120
|
-
orgId,
|
|
121
|
-
id: created.id
|
|
122
|
-
});
|
|
160
|
+
await rollBack();
|
|
123
161
|
return {
|
|
124
162
|
status: "rejected",
|
|
125
163
|
code: moved.code,
|
|
@@ -127,7 +165,7 @@ async function createFactoryWorkItem({ workItems, boards, transitionService, aud
|
|
|
127
165
|
};
|
|
128
166
|
}
|
|
129
167
|
}
|
|
130
|
-
const item = await workItems.getForProject(orgId, factoryProjectId,
|
|
168
|
+
const item = await workItems.getForProject(orgId, factoryProjectId, id) ?? result.item;
|
|
131
169
|
await audit({
|
|
132
170
|
action: "factory.work_item.created",
|
|
133
171
|
factoryProjectId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-work-item.js","names":[],"sources":["../../src/work-items/create-work-item.ts"],"sourcesContent":["/**\n * Filing a work item, shared by the board's create route and the Factory tools\n * so a card filed from a session goes through exactly what \"New card\" does.\n */\n\nimport { cardRuleFacts } from '../boards/index.js';\nimport type { BoardRegistry } from '../boards/index.js';\nimport { INTAKE_ROUTE_METADATA_KEY, resolveIntakePlacement } from '../boards/intake-routing.js';\nimport type { IntakeRoutesReader } from '../boards/intake-routing.js';\nimport type { FactoryTransitionRequest, FactoryTransitionService } from '../rules/transition-service.js';\nimport type { EmitAuditInput } from '../storage/domains/audit/domain.js';\nimport type { CreateWorkItemInput, WorkItemRow, WorkItemsStorage } from '../storage/domains/work-items/base.js';\n\n/** Records one audit event for the caller; routes bind it to the request, tools to the session's person. */\nexport type FactoryAuditEmit = (input: EmitAuditInput) => Promise<void>;\n\ntype TransitionResult = Awaited<ReturnType<FactoryTransitionService['transition']>>;\n\nexport type CreateFactoryWorkItemResult =\n /** A new card, entered into its board's first phase and audited. */\n | { status: 'created'; item: WorkItemRow }\n /** The source key matched an existing card, which was updated instead (the caller audits the patch). */\n | { status: 'reused'; item: WorkItemRow }\n | {\n status: 'refused';\n code: 'invalid_board' | 'governed_transition_required' | 'factory_transitions_unavailable';\n message: string;\n }\n /** The first phase's entry rules (or the move to an intake route's phase) refused the card; it was removed again. */\n | { status: 'rejected'; code: Extract<TransitionResult, { status: 'rejected' }>['code']; reason: string };\n\nexport interface CreateFactoryWorkItemArgs {\n workItems: WorkItemsStorage;\n boards: BoardRegistry;\n transitionService: Pick<FactoryTransitionService, 'transition'> | undefined;\n audit: FactoryAuditEmit;\n orgId: string;\n /** Who files the card; becomes its `created_by` and the human actor of its first phase entry. */\n userId: string;\n factoryProjectId: string;\n input: CreateWorkItemInput;\n /** The project's intake routes; they place a card filed without a board or stages. */\n intakeRoutes?: IntakeRoutesReader;\n /** Where a browser request came from; a session's tool call carries none. */\n origin?: Pick<FactoryTransitionRequest, 'actorProfile' | 'context'>;\n}\n\n/**\n * Upserts the card into its board's first phase, enters that phase as the\n * person (rolling the card back if its entry rules refuse it), then audits\n * `factory.work_item.created`. Throws `WorkItemRelationError` for a bad parent.\n */\nexport async function createFactoryWorkItem({\n workItems,\n boards,\n transitionService,\n audit,\n orgId,\n userId,\n factoryProjectId,\n input,\n intakeRoutes,\n origin,\n}: CreateFactoryWorkItemArgs): Promise<CreateFactoryWorkItemResult> {\n // A card filed without a board or stages goes where the project's intake routes say; one\n // that names either went where the person chose.\n const placement =\n intakeRoutes && input.board === undefined && input.stages === undefined\n ? resolveIntakePlacement(\n await intakeRoutes.listIntakeRoutes({ orgId, factoryProjectId }),\n cardRuleFacts({\n title: input.title,\n metadata: input.metadata ?? null,\n externalSource: input.externalSource ?? null,\n }),\n boards,\n )\n : undefined;\n const boardId = placement?.board ?? input.board ?? 'work';\n const board = boards.get(boardId);\n if (!board) return { status: 'refused', code: 'invalid_board', message: `Board '${boardId}' is not installed.` };\n const initialStages = input.stages ?? [board.initialPhase];\n if (initialStages.length !== 1 || initialStages[0] !== board.initialPhase) {\n return {\n status: 'refused',\n code: 'governed_transition_required',\n message: `New work items must enter through the '${board.initialPhase}' phase of board '${boardId}'.`,\n };\n }\n\n await workItems.ensureReady();\n const result = await workItems.upsert({\n orgId,\n userId,\n factoryProjectId,\n input: {\n ...input,\n board: boardId,\n stages: initialStages,\n },\n reuseMode: 'non-stage',\n });\n // A reused card keeps its own placement, so only a card this call created records the route.\n if (!result.created) return { status: 'reused', item: result.item };\n\n const created = placement\n ? ((\n await workItems.update({\n orgId,\n id: result.item.id,\n userId,\n patch: { metadata: { [INTAKE_ROUTE_METADATA_KEY]: placement.routeId } },\n expectedRevision: result.item.revision,\n })\n )?.item ?? result.item)\n : result.item;\n if (!transitionService) {\n await workItems.delete({ orgId, id: created.id });\n return {\n status: 'refused',\n code: 'factory_transitions_unavailable',\n message: 'Factory stage transitions are not available right now.',\n };\n }\n const entered = await transitionService.transition({\n orgId,\n factoryProjectId,\n workItemId: created.id,\n board: boardId,\n stage: board.initialPhase,\n expectedRevision: created.revision,\n actor: { type: 'human', id: userId },\n ...origin,\n ingress: { type: 'human', identity: `work-item:${created.id}:initial-entry` },\n cause: 'work_item_created',\n initialEntry: true,\n });\n if (entered.status === 'rejected') {\n await workItems.delete({ orgId, id: created.id });\n return { status: 'rejected', code: entered.code, reason: entered.reason };\n }\n if (placement && placement.phase !== board.initialPhase) {\n const moved = await transitionService.transition({\n orgId,\n factoryProjectId,\n workItemId: created.id,\n board: boardId,\n stage: placement.phase,\n expectedRevision: entered.revision,\n // The route moves the card, not the person: a run it starts still needs their consent.\n actor: { type: 'system', id: 'factory-intake-route' },\n ingress: { type: 'rule', identity: `work-item:${created.id}:intake-route` },\n cause: 'work_item_created',\n });\n if (moved.status === 'rejected') {\n await workItems.delete({ orgId, id: created.id });\n return { status: 'rejected', code: moved.code, reason: moved.reason };\n }\n }\n const item = (await workItems.getForProject(orgId, factoryProjectId, created.id)) ?? created;\n await audit({\n action: 'factory.work_item.created',\n factoryProjectId,\n targets: [{ type: 'work_item', id: item.id, name: item.title }],\n metadata: { externalSource: item.externalSource, stages: item.stages },\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AO;EAAE,QAAQ;EAAW;CAAK;AACnC"}
|
|
1
|
+
{"version":3,"file":"create-work-item.js","names":[],"sources":["../../src/work-items/create-work-item.ts"],"sourcesContent":["/**\n * Filing a work item, shared by the board's create route and the Factory tools\n * so a card filed from a session goes through exactly what \"New card\" does.\n */\n\nimport { cardRuleFacts } from '../boards/index.js';\nimport type { BoardRegistry } from '../boards/index.js';\nimport { INTAKE_ROUTE_METADATA_KEY, resolveIntakePlacement } from '../boards/intake-routing.js';\nimport type { IntakeRoutesReader } from '../boards/intake-routing.js';\nimport type { FactoryTransitionRequest, FactoryTransitionService } from '../rules/transition-service.js';\nimport type { EmitAuditInput } from '../storage/domains/audit/domain.js';\nimport { WorkItemUpdateConflictError } from '../storage/domains/work-items/base.js';\nimport type { CreateWorkItemInput, Card, WorkItemsStorage } from '../storage/domains/work-items/base.js';\n\n/** Records one audit event for the caller; routes bind it to the request, tools to the session's person. */\nexport type FactoryAuditEmit = (input: EmitAuditInput) => Promise<void>;\n\ntype TransitionResult = Awaited<ReturnType<FactoryTransitionService['transition']>>;\n\n/** Attempts at each step after the upsert before a card that keeps changing under its creator is left as is. */\nconst STEP_ATTEMPTS = 3;\n\nexport type CreateFactoryWorkItemResult =\n /** A new card, entered into its board's first phase and audited. */\n | { status: 'created'; item: Card }\n /** The source key matched an existing card, which was updated instead (the caller audits the patch). */\n | { status: 'reused'; item: Card }\n | {\n status: 'refused';\n code: 'invalid_board' | 'governed_transition_required' | 'factory_transitions_unavailable';\n message: string;\n }\n /** The first phase's entry rules (or the move to an intake route's phase) refused the card; it was removed again unless a concurrent create had already reused it. */\n | { status: 'rejected'; code: Extract<TransitionResult, { status: 'rejected' }>['code']; reason: string };\n\nexport interface CreateFactoryWorkItemArgs {\n workItems: WorkItemsStorage;\n boards: BoardRegistry;\n transitionService: Pick<FactoryTransitionService, 'transition'> | undefined;\n audit: FactoryAuditEmit;\n orgId: string;\n /** Who files the card; becomes its `created_by` and the human actor of its first phase entry. */\n userId: string;\n factoryProjectId: string;\n input: CreateWorkItemInput;\n /** The project's intake routes; they place a card filed without a board or stages. */\n intakeRoutes?: IntakeRoutesReader;\n /** Where a browser request came from; a session's tool call carries none. */\n origin?: Pick<FactoryTransitionRequest, 'actorProfile' | 'context'>;\n}\n\n/**\n * Upserts the card into its board's first phase, enters that phase as the\n * person (rolling the card back if its entry rules refuse it), then audits\n * `factory.work_item.created`. Throws `WorkItemRelationError` for a bad parent.\n */\nexport async function createFactoryWorkItem({\n workItems,\n boards,\n transitionService,\n audit,\n orgId,\n userId,\n factoryProjectId,\n input,\n intakeRoutes,\n origin,\n}: CreateFactoryWorkItemArgs): Promise<CreateFactoryWorkItemResult> {\n // A card filed without a board or stages goes where the project's intake routes say; one\n // that names either went where the person chose.\n const placement =\n intakeRoutes && input.board === undefined && input.stages === undefined\n ? resolveIntakePlacement(\n await intakeRoutes.listIntakeRoutes({ orgId, factoryProjectId }),\n cardRuleFacts({\n title: input.title,\n metadata: input.metadata ?? null,\n externalSource: input.externalSource ?? null,\n }),\n boards,\n )\n : undefined;\n const boardId = placement?.board ?? input.board ?? 'work';\n const board = boards.get(boardId);\n if (!board) return { status: 'refused', code: 'invalid_board', message: `Board '${boardId}' is not installed.` };\n const initialStages = input.stages ?? [board.initialPhase];\n if (initialStages.length !== 1 || initialStages[0] !== board.initialPhase) {\n return {\n status: 'refused',\n code: 'governed_transition_required',\n message: `New work items must enter through the '${board.initialPhase}' phase of board '${boardId}'.`,\n };\n }\n\n await workItems.ensureReady();\n const result = await workItems.upsert({\n orgId,\n userId,\n factoryProjectId,\n input: {\n ...input,\n board: boardId,\n stages: initialStages,\n },\n reuseMode: 'non-stage',\n });\n // A reused card keeps its own placement, so only a card this call created records the route.\n if (!result.created) return { status: 'reused', item: result.item };\n\n const id = result.item.id;\n // A concurrent create for the same source can reuse this card at any step below. That caller\n // has already returned it as `reused`, so a step that loses the revision race is retried at the\n // current revision, and the card is never rolled back once anyone else has touched it. A reuse\n // that only refreshes source facts keeps the revision but moves `updatedAt`, so the rollback\n // deletes only while both still match this call's last write.\n let revision: number | undefined = result.item.revision;\n let updatedAt = result.item.updatedAt;\n let contended = false;\n const reread = async () => {\n contended = true;\n revision = (await workItems.getForProject(orgId, factoryProjectId, id))?.revision;\n };\n const rollBack = async () => {\n if (contended || revision === undefined) return;\n await workItems.delete({ orgId, id, expectedRevision: revision, expectedUpdatedAt: updatedAt });\n };\n const notFound = { status: 'rejected', code: 'invalid_transition', reason: 'Work item not found.' } as const;\n\n if (placement) {\n for (let attempt = 1; revision !== undefined; attempt++) {\n try {\n const stamped = await workItems.update({\n orgId,\n id,\n userId,\n patch: { metadata: { [INTAKE_ROUTE_METADATA_KEY]: placement.routeId } },\n expectedRevision: revision,\n });\n revision = stamped?.item.revision;\n if (stamped) updatedAt = stamped.item.updatedAt;\n break;\n } catch (error) {\n const stale = error instanceof WorkItemUpdateConflictError && error.reason === 'revision';\n if (!stale || attempt >= STEP_ATTEMPTS) throw error;\n await reread();\n }\n }\n if (revision === undefined) return notFound;\n }\n if (!transitionService) {\n await rollBack();\n return {\n status: 'refused',\n code: 'factory_transitions_unavailable',\n message: 'Factory stage transitions are not available right now.',\n };\n }\n const transition = async (\n request: Omit<FactoryTransitionRequest, 'expectedRevision'>,\n ): Promise<TransitionResult | undefined> => {\n for (let attempt = 1; revision !== undefined; attempt++) {\n const transitioned = await transitionService.transition({ ...request, expectedRevision: revision });\n // The result carries no timestamp, so `updatedAt` stays at the last write this call saw; the\n // commit has moved the card past it, so a later rollback keeps the card instead of guessing.\n if (transitioned.status === 'accepted') revision = transitioned.revision;\n if (transitioned.status !== 'rejected' || transitioned.code !== 'stale' || attempt >= STEP_ATTEMPTS) {\n return transitioned;\n }\n await reread();\n }\n return undefined;\n };\n\n const entered = await transition({\n orgId,\n factoryProjectId,\n workItemId: id,\n board: boardId,\n stage: board.initialPhase,\n actor: { type: 'human', id: userId },\n ...origin,\n ingress: { type: 'human', identity: `work-item:${id}:initial-entry` },\n cause: 'work_item_created',\n initialEntry: true,\n });\n if (!entered) return notFound;\n if (entered.status === 'rejected') {\n await rollBack();\n return { status: 'rejected', code: entered.code, reason: entered.reason };\n }\n if (placement && placement.phase !== board.initialPhase) {\n const moved = await transition({\n orgId,\n factoryProjectId,\n workItemId: id,\n board: boardId,\n stage: placement.phase,\n // The route moves the card, not the person: a run it starts still needs their consent.\n actor: { type: 'system', id: 'factory-intake-route' },\n ingress: { type: 'rule', identity: `work-item:${id}:intake-route` },\n cause: 'work_item_created',\n });\n if (!moved) return notFound;\n if (moved.status === 'rejected') {\n await rollBack();\n return { status: 'rejected', code: moved.code, reason: moved.reason };\n }\n }\n const item = (await workItems.getForProject(orgId, factoryProjectId, id)) ?? result.item;\n await audit({\n action: 'factory.work_item.created',\n factoryProjectId,\n targets: [{ type: 'work_item', id: item.id, name: item.title }],\n metadata: { externalSource: item.externalSource, stages: item.stages },\n });\n return { status: 'created', item };\n}\n"],"mappings":";;;;;;;;;;AAoBA,MAAM,gBAAgB;;;;;;AAoCtB,eAAsB,sBAAsB,EAC1C,WACA,QACA,mBACA,OACA,OACA,QACA,kBACA,OACA,cACA,UACkE;CAGlE,MAAM,YACJ,gBAAgB,MAAM,UAAU,KAAA,KAAa,MAAM,WAAW,KAAA,IAC1D,uBACE,MAAM,aAAa,iBAAiB;EAAE;EAAO;CAAiB,CAAC,GAC/D,cAAc;EACZ,OAAO,MAAM;EACb,UAAU,MAAM,YAAY;EAC5B,gBAAgB,MAAM,kBAAkB;CAC1C,CAAC,GACD,MACF,IACA,KAAA;CACN,MAAM,UAAU,WAAW,SAAS,MAAM,SAAS;CACnD,MAAM,QAAQ,OAAO,IAAI,OAAO;CAChC,IAAI,CAAC,OAAO,OAAO;EAAE,QAAQ;EAAW,MAAM;EAAiB,SAAS,UAAU,QAAQ;CAAqB;CAC/G,MAAM,gBAAgB,MAAM,UAAU,CAAC,MAAM,YAAY;CACzD,IAAI,cAAc,WAAW,KAAK,cAAc,OAAO,MAAM,cAC3D,OAAO;EACL,QA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AAI,KAAK;GAAI,MAAM,KAAK;EAAM,CAAC;EAC9D,UAAU;GAAE,gBAAgB,KAAK;GAAgB,QAAQ,KAAK;EAAO;CACvE,CAAC;CACD,OAAO;EAAE,QAAQ;EAAW;CAAK;AACnC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ExternalWorkItemSource } from '../../storage/domains/work-items/base.js';
|
|
2
|
+
import type { WorkItemProvider } from '../../storage/domains/work-items/work-item-schema.js';
|
|
3
|
+
import type { WorkItemProviderAdapter } from './types.js';
|
|
4
|
+
export interface ExternalAdapterSpec {
|
|
5
|
+
/** Take the provider from the source's integration id (chat adapters, custom integrations). */
|
|
6
|
+
providerFromSource?: boolean;
|
|
7
|
+
/** Keys this provider owns beyond {@link SHARED_PROVIDER_METADATA_KEYS}. */
|
|
8
|
+
providerMetadataKeys: readonly string[];
|
|
9
|
+
key(source: ExternalWorkItemSource, metadata: Record<string, unknown>): string | null;
|
|
10
|
+
state?(source: ExternalWorkItemSource, metadata: Record<string, unknown>): string | null;
|
|
11
|
+
author?(metadata: Record<string, unknown>): string | null;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The id unique per project and provider. It is the legacy source key without
|
|
15
|
+
* the integration id (which is the provider): source types and workspaces
|
|
16
|
+
* scope it, because ids such as a GitLab iid or a Slack `ts` repeat across them.
|
|
17
|
+
*/
|
|
18
|
+
export declare function providerExternalId(source: ExternalWorkItemSource): string;
|
|
19
|
+
export declare function mergedState(_source: ExternalWorkItemSource, metadata: Record<string, unknown>): string | null;
|
|
20
|
+
/** An adapter for a provider whose cards carry an {@link ExternalWorkItemSource}. */
|
|
21
|
+
export declare function externalAdapter(provider: WorkItemProvider, spec: ExternalAdapterSpec): WorkItemProviderAdapter;
|
|
22
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/work-items/providers/base.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sDAAsD,CAAC;AAE7F,OAAO,KAAK,EAA0B,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAElF,MAAM,WAAW,mBAAmB;IAClC,+FAA+F;IAC/F,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,4EAA4E;IAC5E,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,GAAG,CAAC,MAAM,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACtF,KAAK,CAAC,CAAC,MAAM,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACzF,MAAM,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC;CAC3D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAGzE;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI,CAE7G;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,CAwB9G"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { externalSourceKey } from "../../storage/domains/work-items/base.js";
|
|
2
|
+
import { SHARED_PROVIDER_METADATA_KEYS, splitCardMetadata, stringList, stringValue } from "./metadata-keys.js";
|
|
3
|
+
// src/work-items/providers/base.ts
|
|
4
|
+
/**
|
|
5
|
+
* The id unique per project and provider. It is the legacy source key without
|
|
6
|
+
* the integration id (which is the provider): source types and workspaces
|
|
7
|
+
* scope it, because ids such as a GitLab iid or a Slack `ts` repeat across them.
|
|
8
|
+
*/
|
|
9
|
+
function providerExternalId(source) {
|
|
10
|
+
const workspace = source.workspaceId ? `${source.workspaceId}:` : "";
|
|
11
|
+
return `${source.type}:${workspace}${source.externalId}`;
|
|
12
|
+
}
|
|
13
|
+
function mergedState(_source, metadata) {
|
|
14
|
+
return metadata.merged === true ? "merged" : stringValue(metadata.state);
|
|
15
|
+
}
|
|
16
|
+
/** An adapter for a provider whose cards carry an {@link ExternalWorkItemSource}. */
|
|
17
|
+
function externalAdapter(provider, spec) {
|
|
18
|
+
const providerMetadataKeys = [...SHARED_PROVIDER_METADATA_KEYS, ...spec.providerMetadataKeys];
|
|
19
|
+
return {
|
|
20
|
+
provider,
|
|
21
|
+
providerMetadataKeys,
|
|
22
|
+
toSource(source, metadata) {
|
|
23
|
+
if (!source) throw new Error(`A ${provider} work item needs an external source.`);
|
|
24
|
+
const facts = metadata ?? {};
|
|
25
|
+
return {
|
|
26
|
+
provider: spec.providerFromSource ? source.integrationId : provider,
|
|
27
|
+
integrationId: source.integrationId,
|
|
28
|
+
sourceType: source.type,
|
|
29
|
+
workspaceId: source.workspaceId ?? null,
|
|
30
|
+
externalId: providerExternalId(source),
|
|
31
|
+
sourceKey: externalSourceKey(source),
|
|
32
|
+
url: source.url ?? null,
|
|
33
|
+
key: spec.key(source, facts),
|
|
34
|
+
state: spec.state ? spec.state(source, facts) : stringValue(facts.state),
|
|
35
|
+
labels: stringList(facts.labels),
|
|
36
|
+
author: spec.author ? spec.author(facts) : stringValue(facts.author),
|
|
37
|
+
metadata: splitCardMetadata(metadata, providerMetadataKeys).provider
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export { externalAdapter, mergedState, providerExternalId };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../../../src/work-items/providers/base.ts"],"sourcesContent":["import { externalSourceKey } from '../../storage/domains/work-items/base.js';\nimport type { ExternalWorkItemSource } from '../../storage/domains/work-items/base.js';\nimport type { WorkItemProvider } from '../../storage/domains/work-items/work-item-schema.js';\nimport { SHARED_PROVIDER_METADATA_KEYS, splitCardMetadata, stringList, stringValue } from './metadata-keys.js';\nimport type { ProviderWorkItemSource, WorkItemProviderAdapter } from './types.js';\n\nexport interface ExternalAdapterSpec {\n /** Take the provider from the source's integration id (chat adapters, custom integrations). */\n providerFromSource?: boolean;\n /** Keys this provider owns beyond {@link SHARED_PROVIDER_METADATA_KEYS}. */\n providerMetadataKeys: readonly string[];\n key(source: ExternalWorkItemSource, metadata: Record<string, unknown>): string | null;\n state?(source: ExternalWorkItemSource, metadata: Record<string, unknown>): string | null;\n author?(metadata: Record<string, unknown>): string | null;\n}\n\n/**\n * The id unique per project and provider. It is the legacy source key without\n * the integration id (which is the provider): source types and workspaces\n * scope it, because ids such as a GitLab iid or a Slack `ts` repeat across them.\n */\nexport function providerExternalId(source: ExternalWorkItemSource): string {\n const workspace = source.workspaceId ? `${source.workspaceId}:` : '';\n return `${source.type}:${workspace}${source.externalId}`;\n}\n\nexport function mergedState(_source: ExternalWorkItemSource, metadata: Record<string, unknown>): string | null {\n return metadata.merged === true ? 'merged' : stringValue(metadata.state);\n}\n\n/** An adapter for a provider whose cards carry an {@link ExternalWorkItemSource}. */\nexport function externalAdapter(provider: WorkItemProvider, spec: ExternalAdapterSpec): WorkItemProviderAdapter {\n const providerMetadataKeys = [...SHARED_PROVIDER_METADATA_KEYS, ...spec.providerMetadataKeys];\n return {\n provider,\n providerMetadataKeys,\n toSource(source: ExternalWorkItemSource | null, metadata: Record<string, unknown> | null): ProviderWorkItemSource {\n if (!source) throw new Error(`A ${provider} work item needs an external source.`);\n const facts = metadata ?? {};\n return {\n provider: spec.providerFromSource ? source.integrationId : provider,\n integrationId: source.integrationId,\n sourceType: source.type,\n workspaceId: source.workspaceId ?? null,\n externalId: providerExternalId(source),\n sourceKey: externalSourceKey(source),\n url: source.url ?? null,\n key: spec.key(source, facts),\n state: spec.state ? spec.state(source, facts) : stringValue(facts.state),\n labels: stringList(facts.labels),\n author: spec.author ? spec.author(facts) : stringValue(facts.author),\n metadata: splitCardMetadata(metadata, providerMetadataKeys).provider,\n };\n },\n };\n}\n"],"mappings":";;;;;;;;AAqBA,SAAgB,mBAAmB,QAAwC;CACzE,MAAM,YAAY,OAAO,cAAc,GAAG,OAAO,YAAY,KAAK;CAClE,OAAO,GAAG,OAAO,KAAK,GAAG,YAAY,OAAO;AAC9C;AAEA,SAAgB,YAAY,SAAiC,UAAkD;CAC7G,OAAO,SAAS,WAAW,OAAO,WAAW,YAAY,SAAS,KAAK;AACzE;;AAGA,SAAgB,gBAAgB,UAA4B,MAAoD;CAC9G,MAAM,uBAAuB,CAAC,GAAG,+BAA+B,GAAG,KAAK,oBAAoB;CAC5F,OAAO;EACL;EACA;EACA,SAAS,QAAuC,UAAkE;GAChH,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,KAAK,SAAS,qCAAqC;GAChF,MAAM,QAAQ,YAAY,CAAC;GAC3B,OAAO;IACL,UAAU,KAAK,qBAAqB,OAAO,gBAAgB;IAC3D,eAAe,OAAO;IACtB,YAAY,OAAO;IACnB,aAAa,OAAO,eAAe;IACnC,YAAY,mBAAmB,MAAM;IACrC,WAAW,kBAAkB,MAAM;IACnC,KAAK,OAAO,OAAO;IACnB,KAAK,KAAK,IAAI,QAAQ,KAAK;IAC3B,OAAO,KAAK,QAAQ,KAAK,MAAM,QAAQ,KAAK,IAAI,YAAY,MAAM,KAAK;IACvE,QAAQ,WAAW,MAAM,MAAM;IAC/B,QAAQ,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI,YAAY,MAAM,MAAM;IACnE,UAAU,kBAAkB,UAAU,oBAAoB,CAAC,CAAC;GAC9D;EACF;CACF;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/work-items/providers/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,uBAOpC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/work-items/providers/factory.ts
|
|
2
|
+
/** Native work has no external source; its metadata stays with its board placement. */
|
|
3
|
+
const factoryWorkItemAdapter = {
|
|
4
|
+
provider: "factory",
|
|
5
|
+
providerMetadataKeys: [],
|
|
6
|
+
toSource(source) {
|
|
7
|
+
if (source) throw new Error("A Factory work item has no external source.");
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export { factoryWorkItemAdapter };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","names":[],"sources":["../../../src/work-items/providers/factory.ts"],"sourcesContent":["import type { WorkItemProviderAdapter } from './types.js';\n\n/** Native work has no external source; its metadata stays with its board placement. */\nexport const factoryWorkItemAdapter: WorkItemProviderAdapter = {\n provider: 'factory',\n providerMetadataKeys: [],\n toSource(source) {\n if (source) throw new Error('A Factory work item has no external source.');\n return null;\n },\n};\n"],"mappings":";;AAGA,MAAa,yBAAkD;CAC7D,UAAU;CACV,sBAAsB,CAAC;CACvB,SAAS,QAAQ;EACf,IAAI,QAAQ,MAAM,IAAI,MAAM,6CAA6C;EACzE,OAAO;CACT;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.ts","sourceRoot":"","sources":["../../../src/work-items/providers/github.ts"],"names":[],"mappings":"AAQA,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,8CAmBhC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { externalAdapter, mergedState } from "./base.js";
|
|
2
|
+
// src/work-items/providers/github.ts
|
|
3
|
+
const GITHUB_URL = /^https?:\/\/[^/]+\/([^/]+\/[^/]+)\/(?:issues|pull)\/(\d+)/;
|
|
4
|
+
function githubNumber(metadata, pullRequest) {
|
|
5
|
+
return (pullRequest ? metadata.githubPullRequestNumber : metadata.githubIssueNumber) ?? metadata.number;
|
|
6
|
+
}
|
|
7
|
+
/** GitHub issues and pull requests: `acme/app#12`. */
|
|
8
|
+
const githubWorkItemAdapter = externalAdapter("github", {
|
|
9
|
+
providerMetadataKeys: [
|
|
10
|
+
"githubRepositoryId",
|
|
11
|
+
"githubIssueNumber",
|
|
12
|
+
"githubPullRequestNumber",
|
|
13
|
+
"githubAssigneesUpdatedAt",
|
|
14
|
+
"draft",
|
|
15
|
+
"merged",
|
|
16
|
+
"headBranch",
|
|
17
|
+
"baseBranch",
|
|
18
|
+
"requestedReviewers"
|
|
19
|
+
],
|
|
20
|
+
key: (source, metadata) => {
|
|
21
|
+
const match = source.url ? GITHUB_URL.exec(source.url) : null;
|
|
22
|
+
if (match) return `${match[1]}#${match[2]}`;
|
|
23
|
+
const number = githubNumber(metadata, source.type === "pull-request");
|
|
24
|
+
return typeof number === "number" ? `#${number}` : null;
|
|
25
|
+
},
|
|
26
|
+
state: mergedState
|
|
27
|
+
});
|
|
28
|
+
export { githubWorkItemAdapter };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=github.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.js","names":[],"sources":["../../../src/work-items/providers/github.ts"],"sourcesContent":["import { externalAdapter, mergedState } from './base.js';\n\nconst GITHUB_URL = /^https?:\\/\\/[^/]+\\/([^/]+\\/[^/]+)\\/(?:issues|pull)\\/(\\d+)/;\n\nfunction githubNumber(metadata: Record<string, unknown>, pullRequest: boolean): unknown {\n return (pullRequest ? metadata.githubPullRequestNumber : metadata.githubIssueNumber) ?? metadata.number;\n}\n\n/** GitHub issues and pull requests: `acme/app#12`. */\nexport const githubWorkItemAdapter = externalAdapter('github', {\n providerMetadataKeys: [\n 'githubRepositoryId',\n 'githubIssueNumber',\n 'githubPullRequestNumber',\n 'githubAssigneesUpdatedAt',\n 'draft',\n 'merged',\n 'headBranch',\n 'baseBranch',\n 'requestedReviewers',\n ],\n key: (source, metadata) => {\n const match = source.url ? GITHUB_URL.exec(source.url) : null;\n if (match) return `${match[1]}#${match[2]}`;\n const number = githubNumber(metadata, source.type === 'pull-request');\n return typeof number === 'number' ? `#${number}` : null;\n },\n state: mergedState,\n});\n"],"mappings":";;AAEA,MAAM,aAAa;AAEnB,SAAS,aAAa,UAAmC,aAA+B;CACtF,QAAQ,cAAc,SAAS,0BAA0B,SAAS,sBAAsB,SAAS;AACnG;;AAGA,MAAa,wBAAwB,gBAAgB,UAAU;CAC7D,sBAAsB;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM,QAAQ,aAAa;EACzB,MAAM,QAAQ,OAAO,MAAM,WAAW,KAAK,OAAO,GAAG,IAAI;EACzD,IAAI,OAAO,OAAO,GAAG,MAAM,GAAG,GAAG,MAAM;EACvC,MAAM,SAAS,aAAa,UAAU,OAAO,SAAS,cAAc;EACpE,OAAO,OAAO,WAAW,WAAW,IAAI,WAAW;CACrD;CACA,OAAO;AACT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitlab.d.ts","sourceRoot":"","sources":["../../../src/work-items/providers/gitlab.ts"],"names":[],"mappings":"AAMA,gFAAgF;AAChF,eAAO,MAAM,qBAAqB,8CAyBhC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { stringValue } from "./metadata-keys.js";
|
|
2
|
+
import { externalAdapter, mergedState } from "./base.js";
|
|
3
|
+
// src/work-items/providers/gitlab.ts
|
|
4
|
+
const MERGE_REQUEST_URL = /^https?:\/\/[^/]+\/(.+?)\/-\/merge_requests\/(\d+)/;
|
|
5
|
+
const ISSUE_URL = /^https?:\/\/[^/]+\/(.+?)\/-\/(?:issues|work_items)\/(\d+)/;
|
|
6
|
+
/** GitLab issues (`group/project#3`) and merge requests (`group/project!7`). */
|
|
7
|
+
const gitlabWorkItemAdapter = externalAdapter("gitlab", {
|
|
8
|
+
providerMetadataKeys: [
|
|
9
|
+
"gitlabHost",
|
|
10
|
+
"gitlabProjectId",
|
|
11
|
+
"gitlabIssueIid",
|
|
12
|
+
"gitlabMergeRequestIid",
|
|
13
|
+
"draft",
|
|
14
|
+
"merged",
|
|
15
|
+
"headBranch",
|
|
16
|
+
"baseBranch",
|
|
17
|
+
"requestedReviewers"
|
|
18
|
+
],
|
|
19
|
+
key: (source, metadata) => {
|
|
20
|
+
if (source.type === "pull-request") {
|
|
21
|
+
const match = source.url ? MERGE_REQUEST_URL.exec(source.url) : null;
|
|
22
|
+
if (match) return `${match[1]}!${match[2]}`;
|
|
23
|
+
return typeof metadata.gitlabMergeRequestIid === "number" ? `!${metadata.gitlabMergeRequestIid}` : null;
|
|
24
|
+
}
|
|
25
|
+
const identifier = stringValue(metadata.identifier);
|
|
26
|
+
if (identifier) return identifier;
|
|
27
|
+
const match = source.url ? ISSUE_URL.exec(source.url) : null;
|
|
28
|
+
if (match) return `${match[1]}#${match[2]}`;
|
|
29
|
+
return typeof metadata.gitlabIssueIid === "number" ? `#${metadata.gitlabIssueIid}` : null;
|
|
30
|
+
},
|
|
31
|
+
state: mergedState
|
|
32
|
+
});
|
|
33
|
+
export { gitlabWorkItemAdapter };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=gitlab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gitlab.js","names":[],"sources":["../../../src/work-items/providers/gitlab.ts"],"sourcesContent":["import { externalAdapter, mergedState } from './base.js';\nimport { stringValue } from './metadata-keys.js';\n\nconst MERGE_REQUEST_URL = /^https?:\\/\\/[^/]+\\/(.+?)\\/-\\/merge_requests\\/(\\d+)/;\nconst ISSUE_URL = /^https?:\\/\\/[^/]+\\/(.+?)\\/-\\/(?:issues|work_items)\\/(\\d+)/;\n\n/** GitLab issues (`group/project#3`) and merge requests (`group/project!7`). */\nexport const gitlabWorkItemAdapter = externalAdapter('gitlab', {\n providerMetadataKeys: [\n 'gitlabHost',\n 'gitlabProjectId',\n 'gitlabIssueIid',\n 'gitlabMergeRequestIid',\n 'draft',\n 'merged',\n 'headBranch',\n 'baseBranch',\n 'requestedReviewers',\n ],\n key: (source, metadata) => {\n if (source.type === 'pull-request') {\n const match = source.url ? MERGE_REQUEST_URL.exec(source.url) : null;\n if (match) return `${match[1]}!${match[2]}`;\n return typeof metadata.gitlabMergeRequestIid === 'number' ? `!${metadata.gitlabMergeRequestIid}` : null;\n }\n const identifier = stringValue(metadata.identifier);\n if (identifier) return identifier;\n const match = source.url ? ISSUE_URL.exec(source.url) : null;\n if (match) return `${match[1]}#${match[2]}`;\n return typeof metadata.gitlabIssueIid === 'number' ? `#${metadata.gitlabIssueIid}` : null;\n },\n state: mergedState,\n});\n"],"mappings":";;;AAGA,MAAM,oBAAoB;AAC1B,MAAM,YAAY;;AAGlB,MAAa,wBAAwB,gBAAgB,UAAU;CAC7D,sBAAsB;EACpB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,MAAM,QAAQ,aAAa;EACzB,IAAI,OAAO,SAAS,gBAAgB;GAClC,MAAM,QAAQ,OAAO,MAAM,kBAAkB,KAAK,OAAO,GAAG,IAAI;GAChE,IAAI,OAAO,OAAO,GAAG,MAAM,GAAG,GAAG,MAAM;GACvC,OAAO,OAAO,SAAS,0BAA0B,WAAW,IAAI,SAAS,0BAA0B;EACrG;EACA,MAAM,aAAa,YAAY,SAAS,UAAU;EAClD,IAAI,YAAY,OAAO;EACvB,MAAM,QAAQ,OAAO,MAAM,UAAU,KAAK,OAAO,GAAG,IAAI;EACxD,IAAI,OAAO,OAAO,GAAG,MAAM,GAAG,GAAG,MAAM;EACvC,OAAO,OAAO,SAAS,mBAAmB,WAAW,IAAI,SAAS,mBAAmB;CACvF;CACA,OAAO;AACT,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incidentio.d.ts","sourceRoot":"","sources":["../../../src/work-items/providers/incidentio.ts"],"names":[],"mappings":"AAGA,4DAA4D;AAC5D,eAAO,MAAM,yBAAyB,8CAgBpC,CAAC"}
|