@mastra/factory 0.24.0-alpha.0 → 0.24.0-alpha.1

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.
@@ -364,6 +364,15 @@ export declare class IncidentioApiError extends Error {
364
364
  export interface IncidentioApiClientConfig {
365
365
  baseUrl: string;
366
366
  accessToken: string;
367
+ /**
368
+ * Mastra project id sent as `x-mastra-project-id` when the base URL is a
369
+ * Mastra Platform connection proxy, so the platform can attribute proxied
370
+ * incident.io activity to the project. When omitted, falls back to the
371
+ * `MASTRA_PROJECT_ID` environment variable; the platform strips the header
372
+ * before forwarding the request upstream. Pass `null` for direct
373
+ * api.incident.io access so the header never reaches incident.io.
374
+ */
375
+ projectId?: string | null;
367
376
  fetchImpl?: typeof fetch;
368
377
  }
369
378
  export declare class IncidentioApiClient {
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/integrations/incidentio/api.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,OAAO,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,QAAQ,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,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;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAQtG,gBAAgB,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAKpD,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQ1D,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,EAAE,CAAC;IAK5D,SAAS,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;IASvF,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAK5C,aAAa,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAU/F,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQpD,kBAAkB,CACtB,OAAO,GAAE,mCAAwC,GAChD,OAAO,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;IAU7C,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;CA8DrE"}
@@ -10,6 +10,7 @@ var IncidentioApiError = class extends Error {
10
10
  var IncidentioApiClient = class {
11
11
  #baseUrl;
12
12
  #accessToken;
13
+ #projectId;
13
14
  #fetch;
14
15
  constructor(config) {
15
16
  const baseUrl = config.baseUrl.trim();
@@ -17,6 +18,7 @@ var IncidentioApiClient = class {
17
18
  if (!baseUrl || !accessToken) throw new Error("IncidentioApiClient requires a base URL and access token.");
18
19
  this.#baseUrl = baseUrl.replace(/\/+$/, "");
19
20
  this.#accessToken = accessToken;
21
+ this.#projectId = config.projectId === null ? null : (config.projectId ?? process.env.MASTRA_PROJECT_ID)?.trim() || null;
20
22
  this.#fetch = config.fetchImpl ?? globalThis.fetch;
21
23
  }
22
24
  async listIncidents(cursor) {
@@ -163,6 +165,7 @@ var IncidentioApiClient = class {
163
165
  headers: {
164
166
  accept: "application/json",
165
167
  authorization: `Bearer ${this.#accessToken}`,
168
+ ...this.#projectId ? { "x-mastra-project-id": this.#projectId } : {},
166
169
  ...options.body === void 0 ? {} : { "content-type": "application/json" }
167
170
  },
168
171
  ...options.body === void 0 ? {} : { body: JSON.stringify(options.body) }
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","names":["#baseUrl","#accessToken","#fetch","#request","#page"],"sources":["../../../src/integrations/incidentio/api.ts"],"sourcesContent":["export interface IncidentioUser {\n id: string;\n name: string;\n email?: string;\n role?: string;\n slack_user_id?: string;\n}\n\nexport interface IncidentioActor {\n alert?: { id: string; title: string };\n api_key?: { id: string; name: string };\n user?: IncidentioUser;\n workflow?: { id: string; name: string };\n}\n\nexport interface IncidentioIncident {\n id: string;\n reference: string;\n name: string;\n summary?: string;\n permalink?: string;\n visibility: string;\n mode: string;\n creator: IncidentioActor;\n incident_status: { id: string; name: string; category: string };\n incident_type?: { id: string; name: string };\n severity?: { id: string; name: string; rank: number };\n slack_channel_url?: string;\n postmortem_document_url?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioFollowUp {\n id: string;\n incident_id: string;\n title: string;\n description?: string;\n status: 'outstanding' | 'completed' | 'deleted' | 'not_doing';\n creator: IncidentioActor;\n assignee?: IncidentioUser | null;\n assignee_team?: { id: string; name: string } | null;\n labels: string[];\n priority?: { id: string; name: string; rank: number } | null;\n category?: { id: string; name: string } | null;\n external_issue_reference?: { issue_name: string; issue_permalink: string; provider: string } | null;\n completed_at?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioAction {\n id: string;\n incident_id: string;\n description: string;\n status: 'outstanding' | 'completed' | 'deleted' | 'not_doing';\n creator: IncidentioActor;\n assignee?: IncidentioUser;\n completed_at?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioIncidentUpdate {\n id: string;\n incident_id: string;\n updater: IncidentioActor;\n new_incident_status: { id: string; name: string; category: string };\n message?: string;\n merged_into_incident_id?: string;\n new_severity?: { id: string; name: string; rank: number };\n created_at: string;\n}\n\nexport interface IncidentioAlertAttributeValue {\n catalog_entry?: { id: string; name: string; catalog_type_id?: string };\n label?: string;\n literal?: string;\n}\n\nexport interface IncidentioAlertAttributeEntry {\n attribute: {\n id: string;\n name: string;\n type: string;\n array: boolean;\n required: boolean;\n emoji?: string;\n };\n value?: IncidentioAlertAttributeValue;\n array_value?: IncidentioAlertAttributeValue[];\n}\n\nexport interface IncidentioAlert {\n id: string;\n alert_source_id: string;\n deduplication_key: string;\n status: 'firing' | 'resolved';\n title: string;\n attributes: IncidentioAlertAttributeEntry[];\n alert_group_ids?: string[];\n description?: string;\n resolved_at?: string;\n source_url?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioEscalation {\n id: string;\n status:\n 'pending' | 'triggered' | 'acked' | 'resolved' | 'expired' | 'cancelled' | 'snoozed' | 'delayed' | 'pending_repeat';\n title: string;\n description: string;\n priority: { name: string };\n creator: IncidentioActor;\n escalation_path_id?: string;\n events: Array<{\n id: string;\n event:\n | 'entered_grace_period'\n | 'triggered'\n | 'notified_users'\n | 'notified_channels'\n | 'acked'\n | 'cancelled'\n | 'resolved'\n | 'expired';\n occurred_at: string;\n urgency?: 'high' | 'low';\n users?: IncidentioUser[];\n channels?: Array<{\n microsoft_teams_channel_id?: string;\n microsoft_teams_team_id?: string;\n slack_channel_id?: string;\n slack_team_id?: string;\n }>;\n }>;\n related_incidents: Array<{\n id: string;\n external_id: number;\n name: string;\n reference: string;\n visibility: 'public' | 'private';\n status_category: string;\n summary?: string;\n }>;\n related_alerts: Array<{\n id: string;\n alert_source_id: string;\n deduplication_key: string;\n status: 'firing' | 'resolved';\n title: string;\n alert_group_ids?: string[];\n description?: string;\n resolved_at?: string;\n source_url?: string;\n created_at: string;\n updated_at: string;\n }>;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioCatalogEntry {\n id: string;\n catalog_type_id: string;\n name: string;\n aliases: string[];\n rank: number;\n attribute_values: Record<\n string,\n {\n value?: { label: string; literal?: string };\n array_value?: Array<{ label: string; literal?: string }>;\n }\n >;\n external_id?: string;\n archived_at?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioCatalogType {\n id: string;\n name: string;\n description: string;\n type_name: string;\n ranked: boolean;\n is_editable: boolean;\n use_name_as_identifier: boolean;\n categories: string[];\n annotations: Record<string, string>;\n color: string;\n icon: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioCatalogResource {\n type: string;\n engine_resource_type: string;\n label: string;\n description: string;\n value_docstring: string;\n category: string;\n}\n\nexport interface IncidentioTeam {\n id: string;\n name: string;\n catalog_entry: { id: string; name: string; external_id?: string };\n members: IncidentioUser[];\n}\n\nexport interface IncidentioSchedule {\n id: string;\n name: string;\n timezone: string;\n team_ids: string[];\n permalink: string;\n annotations: Record<string, string>;\n config?: {\n rotations: Array<{\n id: string;\n name: string;\n users: IncidentioUser[];\n handover_start_at: string;\n scheduling_mode?: 'fair' | 'sequential';\n }>;\n };\n current_shifts?: IncidentioScheduleEntry[];\n next_shifts?: IncidentioScheduleEntry[];\n holidays_public_config?: { country_codes: string[] };\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioScheduleEntry {\n start_at: string;\n end_at: string;\n entry_id?: string;\n fingerprint?: string;\n layer_id?: string;\n rotation_id?: string;\n user?: IncidentioUser;\n}\n\nexport interface IncidentioPolicyFinding {\n id: string;\n policy_id: string;\n policy_type: 'debrief' | 'follow_up' | 'on_call_readiness' | 'post_mortem' | 'schedule' | 'vacation_conflict';\n state: 'pending' | 'active' | 'resolved' | 'cancelled' | 'dismissed';\n responsible_users: IncidentioUser[];\n days?: number;\n due_at?: string;\n debrief?: { incident_id: string };\n dismissal?: { dismissed_at: string; dismissed_by: IncidentioActor; reason: string };\n follow_up?: { incident_id: string; follow_up_id: string };\n on_call_readiness?: {\n user_id: string;\n high_urgency: IncidentioReadinessRule[];\n low_urgency: IncidentioReadinessRule[];\n };\n post_mortem?: { incident_id: string };\n schedule?: {\n schedule_id: string;\n start_at: string;\n end_at: string;\n cause?: 'nobody_scheduled' | 'no_on_call_seat' | 'user_deactivated';\n has_unscheduled_time?: boolean;\n rotation_id?: string;\n };\n vacation_conflict?: {\n user_id: string;\n schedule_id: string;\n start_at: string;\n end_at: string;\n holiday_name?: string;\n rotation_id?: string;\n };\n last_checked_at: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioReadinessRule {\n method_types: string[];\n met: boolean;\n max_delay_seconds?: number;\n}\n\nexport interface IncidentioPage<T> {\n items: T[];\n nextCursor: string | null;\n total?: number;\n}\n\nexport interface IncidentioCatalogEntryPage extends IncidentioPage<IncidentioCatalogEntry> {\n catalogType: IncidentioCatalogType;\n}\n\nexport interface IncidentioCatalogEntryResult {\n entry: IncidentioCatalogEntry;\n catalogType: IncidentioCatalogType;\n}\n\nexport interface IncidentioListOptions {\n cursor?: string;\n pageSize?: number;\n}\n\nexport interface IncidentioListActionsOptions extends IncidentioListOptions {\n incidentId?: string;\n incidentMode?: string;\n}\n\nexport interface IncidentioListIncidentUpdatesOptions extends IncidentioListOptions {\n incidentId?: string;\n}\n\nexport interface IncidentioListPolicyFindingsOptions extends IncidentioListOptions {\n policyId?: string;\n}\n\nexport class IncidentioApiError extends Error {\n readonly status: number | null;\n\n constructor(message: string, status: number | null) {\n super(message);\n this.name = 'IncidentioApiError';\n this.status = status;\n }\n}\n\nexport interface IncidentioApiClientConfig {\n baseUrl: string;\n accessToken: string;\n fetchImpl?: typeof fetch;\n}\n\ninterface IncidentioPaginationMeta {\n after?: string | null;\n total_record_count?: number;\n}\n\nexport class IncidentioApiClient {\n readonly #baseUrl: string;\n readonly #accessToken: string;\n readonly #fetch: typeof fetch;\n\n constructor(config: IncidentioApiClientConfig) {\n const baseUrl = config.baseUrl.trim();\n const accessToken = config.accessToken.trim();\n if (!baseUrl || !accessToken) {\n throw new Error('IncidentioApiClient requires a base URL and access token.');\n }\n this.#baseUrl = baseUrl.replace(/\\/+$/, '');\n this.#accessToken = accessToken;\n this.#fetch = config.fetchImpl ?? globalThis.fetch;\n }\n\n async listIncidents(cursor?: string): Promise<IncidentioPage<IncidentioIncident>> {\n const result = await this.#request<{\n incidents: IncidentioIncident[];\n pagination_meta?: IncidentioPaginationMeta;\n }>('GET', '/v2/incidents', {\n query: { page_size: 100, after: cursor, sort_by: 'created_at_newest_first' },\n });\n return this.#page(result.incidents, result.pagination_meta);\n }\n\n async getIncident(id: string): Promise<IncidentioIncident> {\n const result = await this.#request<{ incident: IncidentioIncident }>(\n 'GET',\n `/v2/incidents/${encodeURIComponent(id)}`,\n );\n return result.incident;\n }\n\n async listFollowUps(cursor?: string): Promise<IncidentioPage<IncidentioFollowUp>> {\n const result = await this.#request<{\n follow_ups: IncidentioFollowUp[];\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v3/follow_ups', { query: { page_size: 100, after: cursor } });\n return this.#page(result.follow_ups, result.pagination_meta);\n }\n\n async getFollowUp(id: string): Promise<IncidentioFollowUp> {\n const result = await this.#request<{ follow_up: IncidentioFollowUp }>(\n 'GET',\n `/v3/follow_ups/${encodeURIComponent(id)}`,\n );\n return result.follow_up;\n }\n\n async updateFollowUp(\n followUp: IncidentioFollowUp,\n status: IncidentioFollowUp['status'],\n ): Promise<IncidentioFollowUp> {\n const result = await this.#request<{ follow_up: IncidentioFollowUp }>(\n 'PUT',\n `/v3/follow_ups/${encodeURIComponent(followUp.id)}`,\n { body: { title: followUp.title, status } },\n );\n return result.follow_up;\n }\n\n async listActions(options: IncidentioListActionsOptions = {}): Promise<IncidentioPage<IncidentioAction>> {\n const result = await this.#request<{\n actions: IncidentioAction[];\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v3/actions', {\n query: {\n page_size: options.pageSize ?? 100,\n after: options.cursor,\n incident_id: options.incidentId,\n incident_mode: options.incidentMode,\n },\n });\n return this.#page(result.actions, result.pagination_meta);\n }\n\n async getAction(id: string): Promise<IncidentioAction> {\n const result = await this.#request<{ action: IncidentioAction }>('GET', `/v3/actions/${encodeURIComponent(id)}`);\n return result.action;\n }\n\n async listIncidentUpdates(\n options: IncidentioListIncidentUpdatesOptions = {},\n ): Promise<IncidentioPage<IncidentioIncidentUpdate>> {\n const result = await this.#request<{\n incident_updates: IncidentioIncidentUpdate[];\n pagination_meta?: IncidentioPaginationMeta;\n }>('GET', '/v2/incident_updates', {\n query: { page_size: options.pageSize ?? 100, after: options.cursor, incident_id: options.incidentId },\n });\n return this.#page(result.incident_updates, result.pagination_meta);\n }\n\n async listAlerts(options: IncidentioListOptions = {}): Promise<IncidentioPage<IncidentioAlert>> {\n const result = await this.#request<{ alerts: IncidentioAlert[]; pagination_meta: IncidentioPaginationMeta }>(\n 'GET',\n '/v2/alerts',\n { query: { page_size: options.pageSize ?? 50, after: options.cursor } },\n );\n return this.#page(result.alerts, result.pagination_meta);\n }\n\n async getAlert(id: string): Promise<IncidentioAlert> {\n const result = await this.#request<{ alert: IncidentioAlert }>('GET', `/v2/alerts/${encodeURIComponent(id)}`);\n return result.alert;\n }\n\n async listEscalations(options: IncidentioListOptions = {}): Promise<IncidentioPage<IncidentioEscalation>> {\n const result = await this.#request<{\n escalations: IncidentioEscalation[];\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v2/escalations', {\n query: { page_size: options.pageSize ?? 50, after: options.cursor },\n });\n return this.#page(result.escalations, result.pagination_meta);\n }\n\n async getEscalation(id: string): Promise<IncidentioEscalation> {\n const result = await this.#request<{ escalation: IncidentioEscalation }>(\n 'GET',\n `/v2/escalations/${encodeURIComponent(id)}`,\n );\n return result.escalation;\n }\n\n async listCatalogEntries(\n catalogTypeId: string,\n options: IncidentioListOptions & { identifier?: string } = {},\n ): Promise<IncidentioCatalogEntryPage> {\n const result = await this.#request<{\n catalog_entries: IncidentioCatalogEntry[];\n catalog_type: IncidentioCatalogType;\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v3/catalog_entries', {\n query: {\n catalog_type_id: catalogTypeId,\n page_size: options.pageSize ?? 100,\n after: options.cursor,\n identifier: options.identifier,\n },\n });\n return { ...this.#page(result.catalog_entries, result.pagination_meta), catalogType: result.catalog_type };\n }\n\n async getCatalogEntry(id: string, options: { expand?: boolean } = {}): Promise<IncidentioCatalogEntryResult> {\n const result = await this.#request<{\n catalog_entry: IncidentioCatalogEntry;\n catalog_type: IncidentioCatalogType;\n }>('GET', `/v3/catalog_entries/${encodeURIComponent(id)}`, { query: { expand: options.expand } });\n return { entry: result.catalog_entry, catalogType: result.catalog_type };\n }\n\n async listCatalogTypes(): Promise<IncidentioCatalogType[]> {\n const result = await this.#request<{ catalog_types: IncidentioCatalogType[] }>('GET', '/v3/catalog_types');\n return result.catalog_types;\n }\n\n async getCatalogType(id: string): Promise<IncidentioCatalogType> {\n const result = await this.#request<{ catalog_type: IncidentioCatalogType }>(\n 'GET',\n `/v3/catalog_types/${encodeURIComponent(id)}`,\n );\n return result.catalog_type;\n }\n\n async listCatalogResources(): Promise<IncidentioCatalogResource[]> {\n const result = await this.#request<{ resources: IncidentioCatalogResource[] }>('GET', '/v3/catalog_resources');\n return result.resources;\n }\n\n async listTeams(options: IncidentioListOptions = {}): Promise<IncidentioPage<IncidentioTeam>> {\n const result = await this.#request<{ teams: IncidentioTeam[]; pagination_meta: IncidentioPaginationMeta }>(\n 'GET',\n '/v3/teams',\n { query: { page_size: options.pageSize ?? 100, after: options.cursor } },\n );\n return this.#page(result.teams, result.pagination_meta);\n }\n\n async getTeam(id: string): Promise<IncidentioTeam> {\n const result = await this.#request<{ team: IncidentioTeam }>('GET', `/v3/teams/${encodeURIComponent(id)}`);\n return result.team;\n }\n\n async listSchedules(options: IncidentioListOptions = {}): Promise<IncidentioPage<IncidentioSchedule>> {\n const result = await this.#request<{\n schedules: IncidentioSchedule[];\n pagination_meta?: IncidentioPaginationMeta;\n }>('GET', '/v2/schedules', {\n query: { page_size: options.pageSize ?? 25, after: options.cursor },\n });\n return this.#page(result.schedules, result.pagination_meta);\n }\n\n async getSchedule(id: string): Promise<IncidentioSchedule> {\n const result = await this.#request<{ schedule: IncidentioSchedule }>(\n 'GET',\n `/v2/schedules/${encodeURIComponent(id)}`,\n );\n return result.schedule;\n }\n\n async listPolicyFindings(\n options: IncidentioListPolicyFindingsOptions = {},\n ): Promise<IncidentioPage<IncidentioPolicyFinding>> {\n const result = await this.#request<{\n policy_findings: IncidentioPolicyFinding[];\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v2/policy_findings', {\n query: { page_size: options.pageSize ?? 100, after: options.cursor, policy_id: options.policyId },\n });\n return this.#page(result.policy_findings, result.pagination_meta);\n }\n\n async getPolicyFinding(id: string): Promise<IncidentioPolicyFinding> {\n const result = await this.#request<{ policy_finding: IncidentioPolicyFinding }>(\n 'GET',\n `/v2/policy_findings/${encodeURIComponent(id)}`,\n );\n return result.policy_finding;\n }\n\n #page<T>(items: T[], paginationMeta?: IncidentioPaginationMeta): IncidentioPage<T> {\n return {\n items,\n nextCursor: paginationMeta?.after ?? null,\n ...(paginationMeta?.total_record_count === undefined ? {} : { total: paginationMeta.total_record_count }),\n };\n }\n\n async #request<T>(\n method: 'GET' | 'PUT',\n path: string,\n options: { query?: Record<string, string | number | boolean | undefined>; body?: unknown } = {},\n ): Promise<T> {\n const query = new URLSearchParams();\n for (const [key, value] of Object.entries(options.query ?? {})) {\n if (value !== undefined) query.set(key, String(value));\n }\n\n let response: Response;\n try {\n response = await this.#fetch(`${this.#baseUrl}${path}${query.size > 0 ? `?${query.toString()}` : ''}`, {\n method,\n signal: AbortSignal.timeout(15_000),\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${this.#accessToken}`,\n ...(options.body === undefined ? {} : { 'content-type': 'application/json' }),\n },\n ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),\n });\n } catch (error) {\n if (error instanceof Error && error.message.includes(this.#accessToken)) {\n const redacted = new Error(error.message.replaceAll(this.#accessToken, '[REDACTED]'));\n redacted.name = error.name;\n throw redacted;\n }\n throw error;\n }\n\n if (!response.ok) {\n let detail = `incident.io API request failed (${response.status})`;\n try {\n const body = (await response.clone().json()) as { message?: string; error?: string; detail?: string };\n detail = body.message ?? body.error ?? body.detail ?? detail;\n } catch {\n // Use the status-based message.\n }\n throw new IncidentioApiError(detail.replaceAll(this.#accessToken, '[REDACTED]'), response.status);\n }\n return (await response.json()) as T;\n }\n}\n"],"mappings":";AAqUA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAiB,QAAuB;EAClD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAaA,IAAa,sBAAb,MAAiC;CAC/B;CACA;CACA;CAEA,YAAY,QAAmC;EAC7C,MAAM,UAAU,OAAO,QAAQ,KAAK;EACpC,MAAM,cAAc,OAAO,YAAY,KAAK;EAC5C,IAAI,CAAC,WAAW,CAAC,aACf,MAAM,IAAI,MAAM,2DAA2D;EAE7E,KAAKA,WAAW,QAAQ,QAAQ,QAAQ,EAAE;EAC1C,KAAKC,eAAe;EACpB,KAAKC,SAAS,OAAO,aAAa,WAAW;CAC/C;CAEA,MAAM,cAAc,QAA8D;EAChF,MAAM,SAAS,MAAM,KAAKC,SAGvB,OAAO,iBAAiB,EACzB,OAAO;GAAE,WAAW;GAAK,OAAO;GAAQ,SAAS;EAA0B,EAC7E,CAAC;EACD,OAAO,KAAKC,MAAM,OAAO,WAAW,OAAO,eAAe;CAC5D;CAEA,MAAM,YAAY,IAAyC;EAKzD,QAAO,MAJc,KAAKD,SACxB,OACA,iBAAiB,mBAAmB,EAAE,GACxC,EAAA,CACc;CAChB;CAEA,MAAM,cAAc,QAA8D;EAChF,MAAM,SAAS,MAAM,KAAKA,SAGvB,OAAO,kBAAkB,EAAE,OAAO;GAAE,WAAW;GAAK,OAAO;EAAO,EAAE,CAAC;EACxE,OAAO,KAAKC,MAAM,OAAO,YAAY,OAAO,eAAe;CAC7D;CAEA,MAAM,YAAY,IAAyC;E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AAI,KAAK,OAAO,KAAK,CAAC;EAGvD,IAAI;EACJ,IAAI;GACF,WAAW,MAAM,KAAKD,OAAO,GAAG,KAAKF,WAAW,OAAO,MAAM,OAAO,IAAI,IAAI,MAAM,SAAS,MAAM,MAAM;IACrG;IACA,QAAQ,YAAY,QAAQ,IAAM;IAClC,SAAS;KACP,QAAQ;KACR,eAAe,UAAU,KAAKC;KAC9B,GAAI,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,gBAAgB,mBAAmB;IAC7E;IACA,GAAI,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,QAAQ,IAAI,EAAE;GAC7E,CAAC;EACH,SAAS,OAAO;GACd,IAAI,iBAAiB,SAAS,MAAM,QAAQ,SAAS,KAAKA,YAAY,GAAG;IACvE,MAAM,WAAW,IAAI,MAAM,MAAM,QAAQ,WAAW,KAAKA,cAAc,YAAY,CAAC;IACpF,SAAS,OAAO,MAAM;IACtB,MAAM;GACR;GACA,MAAM;EACR;EAEA,IAAI,CAAC,SAAS,IAAI;GAChB,IAAI,SAAS,mCAAmC,SAAS,OAAO;GAChE,IAAI;IACF,MAAM,OAAQ,MAAM,SAAS,MAAM,CAAC,CAAC,KAAK;IAC1C,SAAS,KAAK,WAAW,KAAK,SAAS,KAAK,UAAU;GACxD,QAAQ,CAER;GACA,MAAM,IAAI,mBAAmB,OAAO,WAAW,KAAKA,cAAc,YAAY,GAAG,SAAS,MAAM;EAClG;EACA,OAAQ,MAAM,SAAS,KAAK;CAC9B;AACF"}
1
+ {"version":3,"file":"api.js","names":["#baseUrl","#accessToken","#projectId","#fetch","#request","#page"],"sources":["../../../src/integrations/incidentio/api.ts"],"sourcesContent":["export interface IncidentioUser {\n id: string;\n name: string;\n email?: string;\n role?: string;\n slack_user_id?: string;\n}\n\nexport interface IncidentioActor {\n alert?: { id: string; title: string };\n api_key?: { id: string; name: string };\n user?: IncidentioUser;\n workflow?: { id: string; name: string };\n}\n\nexport interface IncidentioIncident {\n id: string;\n reference: string;\n name: string;\n summary?: string;\n permalink?: string;\n visibility: string;\n mode: string;\n creator: IncidentioActor;\n incident_status: { id: string; name: string; category: string };\n incident_type?: { id: string; name: string };\n severity?: { id: string; name: string; rank: number };\n slack_channel_url?: string;\n postmortem_document_url?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioFollowUp {\n id: string;\n incident_id: string;\n title: string;\n description?: string;\n status: 'outstanding' | 'completed' | 'deleted' | 'not_doing';\n creator: IncidentioActor;\n assignee?: IncidentioUser | null;\n assignee_team?: { id: string; name: string } | null;\n labels: string[];\n priority?: { id: string; name: string; rank: number } | null;\n category?: { id: string; name: string } | null;\n external_issue_reference?: { issue_name: string; issue_permalink: string; provider: string } | null;\n completed_at?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioAction {\n id: string;\n incident_id: string;\n description: string;\n status: 'outstanding' | 'completed' | 'deleted' | 'not_doing';\n creator: IncidentioActor;\n assignee?: IncidentioUser;\n completed_at?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioIncidentUpdate {\n id: string;\n incident_id: string;\n updater: IncidentioActor;\n new_incident_status: { id: string; name: string; category: string };\n message?: string;\n merged_into_incident_id?: string;\n new_severity?: { id: string; name: string; rank: number };\n created_at: string;\n}\n\nexport interface IncidentioAlertAttributeValue {\n catalog_entry?: { id: string; name: string; catalog_type_id?: string };\n label?: string;\n literal?: string;\n}\n\nexport interface IncidentioAlertAttributeEntry {\n attribute: {\n id: string;\n name: string;\n type: string;\n array: boolean;\n required: boolean;\n emoji?: string;\n };\n value?: IncidentioAlertAttributeValue;\n array_value?: IncidentioAlertAttributeValue[];\n}\n\nexport interface IncidentioAlert {\n id: string;\n alert_source_id: string;\n deduplication_key: string;\n status: 'firing' | 'resolved';\n title: string;\n attributes: IncidentioAlertAttributeEntry[];\n alert_group_ids?: string[];\n description?: string;\n resolved_at?: string;\n source_url?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioEscalation {\n id: string;\n status:\n 'pending' | 'triggered' | 'acked' | 'resolved' | 'expired' | 'cancelled' | 'snoozed' | 'delayed' | 'pending_repeat';\n title: string;\n description: string;\n priority: { name: string };\n creator: IncidentioActor;\n escalation_path_id?: string;\n events: Array<{\n id: string;\n event:\n | 'entered_grace_period'\n | 'triggered'\n | 'notified_users'\n | 'notified_channels'\n | 'acked'\n | 'cancelled'\n | 'resolved'\n | 'expired';\n occurred_at: string;\n urgency?: 'high' | 'low';\n users?: IncidentioUser[];\n channels?: Array<{\n microsoft_teams_channel_id?: string;\n microsoft_teams_team_id?: string;\n slack_channel_id?: string;\n slack_team_id?: string;\n }>;\n }>;\n related_incidents: Array<{\n id: string;\n external_id: number;\n name: string;\n reference: string;\n visibility: 'public' | 'private';\n status_category: string;\n summary?: string;\n }>;\n related_alerts: Array<{\n id: string;\n alert_source_id: string;\n deduplication_key: string;\n status: 'firing' | 'resolved';\n title: string;\n alert_group_ids?: string[];\n description?: string;\n resolved_at?: string;\n source_url?: string;\n created_at: string;\n updated_at: string;\n }>;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioCatalogEntry {\n id: string;\n catalog_type_id: string;\n name: string;\n aliases: string[];\n rank: number;\n attribute_values: Record<\n string,\n {\n value?: { label: string; literal?: string };\n array_value?: Array<{ label: string; literal?: string }>;\n }\n >;\n external_id?: string;\n archived_at?: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioCatalogType {\n id: string;\n name: string;\n description: string;\n type_name: string;\n ranked: boolean;\n is_editable: boolean;\n use_name_as_identifier: boolean;\n categories: string[];\n annotations: Record<string, string>;\n color: string;\n icon: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioCatalogResource {\n type: string;\n engine_resource_type: string;\n label: string;\n description: string;\n value_docstring: string;\n category: string;\n}\n\nexport interface IncidentioTeam {\n id: string;\n name: string;\n catalog_entry: { id: string; name: string; external_id?: string };\n members: IncidentioUser[];\n}\n\nexport interface IncidentioSchedule {\n id: string;\n name: string;\n timezone: string;\n team_ids: string[];\n permalink: string;\n annotations: Record<string, string>;\n config?: {\n rotations: Array<{\n id: string;\n name: string;\n users: IncidentioUser[];\n handover_start_at: string;\n scheduling_mode?: 'fair' | 'sequential';\n }>;\n };\n current_shifts?: IncidentioScheduleEntry[];\n next_shifts?: IncidentioScheduleEntry[];\n holidays_public_config?: { country_codes: string[] };\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioScheduleEntry {\n start_at: string;\n end_at: string;\n entry_id?: string;\n fingerprint?: string;\n layer_id?: string;\n rotation_id?: string;\n user?: IncidentioUser;\n}\n\nexport interface IncidentioPolicyFinding {\n id: string;\n policy_id: string;\n policy_type: 'debrief' | 'follow_up' | 'on_call_readiness' | 'post_mortem' | 'schedule' | 'vacation_conflict';\n state: 'pending' | 'active' | 'resolved' | 'cancelled' | 'dismissed';\n responsible_users: IncidentioUser[];\n days?: number;\n due_at?: string;\n debrief?: { incident_id: string };\n dismissal?: { dismissed_at: string; dismissed_by: IncidentioActor; reason: string };\n follow_up?: { incident_id: string; follow_up_id: string };\n on_call_readiness?: {\n user_id: string;\n high_urgency: IncidentioReadinessRule[];\n low_urgency: IncidentioReadinessRule[];\n };\n post_mortem?: { incident_id: string };\n schedule?: {\n schedule_id: string;\n start_at: string;\n end_at: string;\n cause?: 'nobody_scheduled' | 'no_on_call_seat' | 'user_deactivated';\n has_unscheduled_time?: boolean;\n rotation_id?: string;\n };\n vacation_conflict?: {\n user_id: string;\n schedule_id: string;\n start_at: string;\n end_at: string;\n holiday_name?: string;\n rotation_id?: string;\n };\n last_checked_at: string;\n created_at: string;\n updated_at: string;\n}\n\nexport interface IncidentioReadinessRule {\n method_types: string[];\n met: boolean;\n max_delay_seconds?: number;\n}\n\nexport interface IncidentioPage<T> {\n items: T[];\n nextCursor: string | null;\n total?: number;\n}\n\nexport interface IncidentioCatalogEntryPage extends IncidentioPage<IncidentioCatalogEntry> {\n catalogType: IncidentioCatalogType;\n}\n\nexport interface IncidentioCatalogEntryResult {\n entry: IncidentioCatalogEntry;\n catalogType: IncidentioCatalogType;\n}\n\nexport interface IncidentioListOptions {\n cursor?: string;\n pageSize?: number;\n}\n\nexport interface IncidentioListActionsOptions extends IncidentioListOptions {\n incidentId?: string;\n incidentMode?: string;\n}\n\nexport interface IncidentioListIncidentUpdatesOptions extends IncidentioListOptions {\n incidentId?: string;\n}\n\nexport interface IncidentioListPolicyFindingsOptions extends IncidentioListOptions {\n policyId?: string;\n}\n\nexport class IncidentioApiError extends Error {\n readonly status: number | null;\n\n constructor(message: string, status: number | null) {\n super(message);\n this.name = 'IncidentioApiError';\n this.status = status;\n }\n}\n\nexport interface IncidentioApiClientConfig {\n baseUrl: string;\n accessToken: string;\n /**\n * Mastra project id sent as `x-mastra-project-id` when the base URL is a\n * Mastra Platform connection proxy, so the platform can attribute proxied\n * incident.io activity to the project. When omitted, falls back to the\n * `MASTRA_PROJECT_ID` environment variable; the platform strips the header\n * before forwarding the request upstream. Pass `null` for direct\n * api.incident.io access so the header never reaches incident.io.\n */\n projectId?: string | null;\n fetchImpl?: typeof fetch;\n}\n\ninterface IncidentioPaginationMeta {\n after?: string | null;\n total_record_count?: number;\n}\n\nexport class IncidentioApiClient {\n readonly #baseUrl: string;\n readonly #accessToken: string;\n readonly #projectId: string | null;\n readonly #fetch: typeof fetch;\n\n constructor(config: IncidentioApiClientConfig) {\n const baseUrl = config.baseUrl.trim();\n const accessToken = config.accessToken.trim();\n if (!baseUrl || !accessToken) {\n throw new Error('IncidentioApiClient requires a base URL and access token.');\n }\n this.#baseUrl = baseUrl.replace(/\\/+$/, '');\n this.#accessToken = accessToken;\n this.#projectId =\n config.projectId === null ? null : (config.projectId ?? process.env.MASTRA_PROJECT_ID)?.trim() || null;\n this.#fetch = config.fetchImpl ?? globalThis.fetch;\n }\n\n async listIncidents(cursor?: string): Promise<IncidentioPage<IncidentioIncident>> {\n const result = await this.#request<{\n incidents: IncidentioIncident[];\n pagination_meta?: IncidentioPaginationMeta;\n }>('GET', '/v2/incidents', {\n query: { page_size: 100, after: cursor, sort_by: 'created_at_newest_first' },\n });\n return this.#page(result.incidents, result.pagination_meta);\n }\n\n async getIncident(id: string): Promise<IncidentioIncident> {\n const result = await this.#request<{ incident: IncidentioIncident }>(\n 'GET',\n `/v2/incidents/${encodeURIComponent(id)}`,\n );\n return result.incident;\n }\n\n async listFollowUps(cursor?: string): Promise<IncidentioPage<IncidentioFollowUp>> {\n const result = await this.#request<{\n follow_ups: IncidentioFollowUp[];\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v3/follow_ups', { query: { page_size: 100, after: cursor } });\n return this.#page(result.follow_ups, result.pagination_meta);\n }\n\n async getFollowUp(id: string): Promise<IncidentioFollowUp> {\n const result = await this.#request<{ follow_up: IncidentioFollowUp }>(\n 'GET',\n `/v3/follow_ups/${encodeURIComponent(id)}`,\n );\n return result.follow_up;\n }\n\n async updateFollowUp(\n followUp: IncidentioFollowUp,\n status: IncidentioFollowUp['status'],\n ): Promise<IncidentioFollowUp> {\n const result = await this.#request<{ follow_up: IncidentioFollowUp }>(\n 'PUT',\n `/v3/follow_ups/${encodeURIComponent(followUp.id)}`,\n { body: { title: followUp.title, status } },\n );\n return result.follow_up;\n }\n\n async listActions(options: IncidentioListActionsOptions = {}): Promise<IncidentioPage<IncidentioAction>> {\n const result = await this.#request<{\n actions: IncidentioAction[];\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v3/actions', {\n query: {\n page_size: options.pageSize ?? 100,\n after: options.cursor,\n incident_id: options.incidentId,\n incident_mode: options.incidentMode,\n },\n });\n return this.#page(result.actions, result.pagination_meta);\n }\n\n async getAction(id: string): Promise<IncidentioAction> {\n const result = await this.#request<{ action: IncidentioAction }>('GET', `/v3/actions/${encodeURIComponent(id)}`);\n return result.action;\n }\n\n async listIncidentUpdates(\n options: IncidentioListIncidentUpdatesOptions = {},\n ): Promise<IncidentioPage<IncidentioIncidentUpdate>> {\n const result = await this.#request<{\n incident_updates: IncidentioIncidentUpdate[];\n pagination_meta?: IncidentioPaginationMeta;\n }>('GET', '/v2/incident_updates', {\n query: { page_size: options.pageSize ?? 100, after: options.cursor, incident_id: options.incidentId },\n });\n return this.#page(result.incident_updates, result.pagination_meta);\n }\n\n async listAlerts(options: IncidentioListOptions = {}): Promise<IncidentioPage<IncidentioAlert>> {\n const result = await this.#request<{ alerts: IncidentioAlert[]; pagination_meta: IncidentioPaginationMeta }>(\n 'GET',\n '/v2/alerts',\n { query: { page_size: options.pageSize ?? 50, after: options.cursor } },\n );\n return this.#page(result.alerts, result.pagination_meta);\n }\n\n async getAlert(id: string): Promise<IncidentioAlert> {\n const result = await this.#request<{ alert: IncidentioAlert }>('GET', `/v2/alerts/${encodeURIComponent(id)}`);\n return result.alert;\n }\n\n async listEscalations(options: IncidentioListOptions = {}): Promise<IncidentioPage<IncidentioEscalation>> {\n const result = await this.#request<{\n escalations: IncidentioEscalation[];\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v2/escalations', {\n query: { page_size: options.pageSize ?? 50, after: options.cursor },\n });\n return this.#page(result.escalations, result.pagination_meta);\n }\n\n async getEscalation(id: string): Promise<IncidentioEscalation> {\n const result = await this.#request<{ escalation: IncidentioEscalation }>(\n 'GET',\n `/v2/escalations/${encodeURIComponent(id)}`,\n );\n return result.escalation;\n }\n\n async listCatalogEntries(\n catalogTypeId: string,\n options: IncidentioListOptions & { identifier?: string } = {},\n ): Promise<IncidentioCatalogEntryPage> {\n const result = await this.#request<{\n catalog_entries: IncidentioCatalogEntry[];\n catalog_type: IncidentioCatalogType;\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v3/catalog_entries', {\n query: {\n catalog_type_id: catalogTypeId,\n page_size: options.pageSize ?? 100,\n after: options.cursor,\n identifier: options.identifier,\n },\n });\n return { ...this.#page(result.catalog_entries, result.pagination_meta), catalogType: result.catalog_type };\n }\n\n async getCatalogEntry(id: string, options: { expand?: boolean } = {}): Promise<IncidentioCatalogEntryResult> {\n const result = await this.#request<{\n catalog_entry: IncidentioCatalogEntry;\n catalog_type: IncidentioCatalogType;\n }>('GET', `/v3/catalog_entries/${encodeURIComponent(id)}`, { query: { expand: options.expand } });\n return { entry: result.catalog_entry, catalogType: result.catalog_type };\n }\n\n async listCatalogTypes(): Promise<IncidentioCatalogType[]> {\n const result = await this.#request<{ catalog_types: IncidentioCatalogType[] }>('GET', '/v3/catalog_types');\n return result.catalog_types;\n }\n\n async getCatalogType(id: string): Promise<IncidentioCatalogType> {\n const result = await this.#request<{ catalog_type: IncidentioCatalogType }>(\n 'GET',\n `/v3/catalog_types/${encodeURIComponent(id)}`,\n );\n return result.catalog_type;\n }\n\n async listCatalogResources(): Promise<IncidentioCatalogResource[]> {\n const result = await this.#request<{ resources: IncidentioCatalogResource[] }>('GET', '/v3/catalog_resources');\n return result.resources;\n }\n\n async listTeams(options: IncidentioListOptions = {}): Promise<IncidentioPage<IncidentioTeam>> {\n const result = await this.#request<{ teams: IncidentioTeam[]; pagination_meta: IncidentioPaginationMeta }>(\n 'GET',\n '/v3/teams',\n { query: { page_size: options.pageSize ?? 100, after: options.cursor } },\n );\n return this.#page(result.teams, result.pagination_meta);\n }\n\n async getTeam(id: string): Promise<IncidentioTeam> {\n const result = await this.#request<{ team: IncidentioTeam }>('GET', `/v3/teams/${encodeURIComponent(id)}`);\n return result.team;\n }\n\n async listSchedules(options: IncidentioListOptions = {}): Promise<IncidentioPage<IncidentioSchedule>> {\n const result = await this.#request<{\n schedules: IncidentioSchedule[];\n pagination_meta?: IncidentioPaginationMeta;\n }>('GET', '/v2/schedules', {\n query: { page_size: options.pageSize ?? 25, after: options.cursor },\n });\n return this.#page(result.schedules, result.pagination_meta);\n }\n\n async getSchedule(id: string): Promise<IncidentioSchedule> {\n const result = await this.#request<{ schedule: IncidentioSchedule }>(\n 'GET',\n `/v2/schedules/${encodeURIComponent(id)}`,\n );\n return result.schedule;\n }\n\n async listPolicyFindings(\n options: IncidentioListPolicyFindingsOptions = {},\n ): Promise<IncidentioPage<IncidentioPolicyFinding>> {\n const result = await this.#request<{\n policy_findings: IncidentioPolicyFinding[];\n pagination_meta: IncidentioPaginationMeta;\n }>('GET', '/v2/policy_findings', {\n query: { page_size: options.pageSize ?? 100, after: options.cursor, policy_id: options.policyId },\n });\n return this.#page(result.policy_findings, result.pagination_meta);\n }\n\n async getPolicyFinding(id: string): Promise<IncidentioPolicyFinding> {\n const result = await this.#request<{ policy_finding: IncidentioPolicyFinding }>(\n 'GET',\n `/v2/policy_findings/${encodeURIComponent(id)}`,\n );\n return result.policy_finding;\n }\n\n #page<T>(items: T[], paginationMeta?: IncidentioPaginationMeta): IncidentioPage<T> {\n return {\n items,\n nextCursor: paginationMeta?.after ?? null,\n ...(paginationMeta?.total_record_count === undefined ? {} : { total: paginationMeta.total_record_count }),\n };\n }\n\n async #request<T>(\n method: 'GET' | 'PUT',\n path: string,\n options: { query?: Record<string, string | number | boolean | undefined>; body?: unknown } = {},\n ): Promise<T> {\n const query = new URLSearchParams();\n for (const [key, value] of Object.entries(options.query ?? {})) {\n if (value !== undefined) query.set(key, String(value));\n }\n\n let response: Response;\n try {\n response = await this.#fetch(`${this.#baseUrl}${path}${query.size > 0 ? `?${query.toString()}` : ''}`, {\n method,\n signal: AbortSignal.timeout(15_000),\n headers: {\n accept: 'application/json',\n authorization: `Bearer ${this.#accessToken}`,\n // Project attribution for the Mastra platform proxy; stripped by\n // the platform before the request reaches incident.io.\n ...(this.#projectId ? { 'x-mastra-project-id': this.#projectId } : {}),\n ...(options.body === undefined ? {} : { 'content-type': 'application/json' }),\n },\n ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),\n });\n } catch (error) {\n if (error instanceof Error && error.message.includes(this.#accessToken)) {\n const redacted = new Error(error.message.replaceAll(this.#accessToken, '[REDACTED]'));\n redacted.name = error.name;\n throw redacted;\n }\n throw error;\n }\n\n if (!response.ok) {\n let detail = `incident.io API request failed (${response.status})`;\n try {\n const body = (await response.clone().json()) as { message?: string; error?: string; detail?: string };\n detail = body.message ?? body.error ?? body.detail ?? detail;\n } catch {\n // Use the status-based message.\n }\n throw new IncidentioApiError(detail.replaceAll(this.#accessToken, '[REDACTED]'), response.status);\n }\n return (await response.json()) as T;\n }\n}\n"],"mappings":";AAqUA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAiB,QAAuB;EAClD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;CAChB;AACF;AAsBA,IAAa,sBAAb,MAAiC;CAC/B;CACA;CACA;CACA;CAEA,YAAY,QAAmC;EAC7C,MAAM,UAAU,OAAO,QAAQ,KAAK;EACpC,MAAM,cAAc,OAAO,YAAY,KAAK;EAC5C,IAAI,CAAC,WAAW,CAAC,aACf,MAAM,IAAI,MAAM,2DAA2D;EAE7E,KAAKA,WAAW,QAAQ,QAAQ,QAAQ,EAAE;EAC1C,KAAKC,eAAe;EACpB,KAAKC,aACH,OAAO,cAAc,OAAO,QAAQ,OAAO,aAAa,QAAQ,IAAI,kBAAA,EAAoB,KAAK,KAAK;EACpG,KAAKC,SAAS,OAAO,aAAa,WAAW;CAC/C;CAEA,MAAM,cAAc,QAA8D;EAChF,MAAM,SAAS,MAAM,KAAKC,SAGvB,OAAO,iBAAiB,EACzB,OAAO;GAAE,WAAW;GAAK,OAAO;GAAQ,SAAS;EAA0B,EAC7E,CAAC;EACD,OAAO,KAAKC,MAAM,OAAO,WAAW,OAAO,eAAe;CAC5D;CAEA,MAAM,YAAY,IAAyC;EAKzD,QAAO,MAJc,KAAKD,SACxB,OACA,iBAAiB,mBAAmB,EAAE,GACxC,EAAA,CACc;CAChB;CAEA,MAAM,cAAc,QAA8D;EAChF,MAAM,SAAS,MAAM,KAAKA,SAGvB,OAAO,kBAAkB,EAAE,OAAO;GAAE,WAAW;GAAK,OAAO;EAAO,EAAE,CAAC;EACxE,OAAO,KAAKC,MAAM,OAAO,YAAY,OAAO,eAAe;CAC7D;CAEA,MAAM,Y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AAC,MAAM,gDAAC;gBAUJ,MAAM,GAAE,2BAAgC;IAsBpD,kFAAkF;IAClF,IAAI,KAAK,IAAI,oBAAoB,CAEhC;IAED;;;;OAIG;IACH,UAAU,CAAC,EACT,QAAQ,EACR,IAAI,EACJ,MAAM,GACP,EAAE;QACD,QAAQ,EAAE,sBAAsB,CAAC;QACjC,IAAI,EAAE,SAAS,CAAC;QAChB,MAAM,EAAE,aAAa,CAAC;KACvB,GAAG,IAAI;IAMR,oFAAoF;IACpF,IAAI,aAAa,IAAI,aAAa,CAKjC;IAED,+EAA+E;IAC/E,IAAI,QAAQ,IAAI,sBAAsB,CAKrC;IAED,sFAAsF;IACtF,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;;;OAIG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAqB9D,oDAAoD;IACpD,WAAW,IAAI,IAAI;IAInB;;;OAGG;IACG,UAAU,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIrF,OAAO,CAAC,GAAG,EAAE,kBAAkB,GAAG,YAAY,EAAE;IAchD;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,kBAAkB,GAAG,QAAQ,EAAE;IAU3C,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGvC"}
@@ -29,6 +29,7 @@ var IncidentioIntegration = class {
29
29
  const api = new IncidentioApiClient({
30
30
  baseUrl,
31
31
  accessToken: apiKey,
32
+ projectId: null,
32
33
  ...config.fetchImpl ? { fetchImpl: config.fetchImpl } : {}
33
34
  });
34
35
  this.intake = createIncidentioIntake({
@@ -1 +1 @@
1
- {"version":3,"file":"integration.js","names":["#endpointHost","#rules","#orgIdByResourceId","#projects","#auth","#intakeStorage"],"sources":["../../../src/integrations/incidentio/integration.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { MastraWorker } from '@mastra/core/worker';\n\nimport type { RouteAuth } from '../../routes/route.js';\nimport type { IntakeStorage } from '../../storage/domains/intake/base.js';\nimport type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js';\nimport type { FactoryIntegration, IntegrationContext, IntegrationTools } from '../base.js';\nimport { IssueReconcileWorker } from '../issue-reconcile-worker.js';\nimport { buildIncidentioAgentTools } from './agent-tools.js';\nimport { IncidentioApiClient } from './api.js';\nimport { resolveIncidentioRules } from './default-rules.js';\nimport type { IncidentioEventRules, IncidentioRuleOverrides } from './default-rules.js';\nimport { createIncidentioIntake } from './intake.js';\nimport { attachIncidentioIssueReconciler } from './issue-reconciler.js';\nimport { incidentioReconciliationEnabled, incidentioReconciliationInterval } from './reconciliation-config.js';\nimport { buildIncidentioRoutes } from './routes.js';\nimport { attachIncidentioRules } from './rules.js';\n\nexport interface IncidentioIntegrationConfig {\n apiKey?: string;\n fetchImpl?: typeof fetch;\n baseUrl?: string;\n /** Per-event replacements for the default Factory incident.io rules. */\n rules?: IncidentioRuleOverrides;\n}\n\nconst DIRECT_CONNECTION_TOKEN = 'incidentio-direct-api-key';\nconst UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nexport class IncidentioIntegration implements FactoryIntegration {\n readonly id = 'incidentio';\n readonly intake;\n readonly #endpointHost: string;\n readonly #rules: IncidentioEventRules;\n\n /** Bound once by the factory via `initialize()` before any surface is used. */\n #projects: FactoryProjectsStorage | undefined;\n #auth: RouteAuth | undefined;\n #intakeStorage: IntakeStorage | undefined;\n readonly #orgIdByResourceId = new Map<string, string | null>();\n\n constructor(config: IncidentioIntegrationConfig = {}) {\n this.#rules = resolveIncidentioRules(config.rules);\n const apiKey = config.apiKey?.trim() || process.env.INCIDENT_IO_API_KEY?.trim();\n if (!apiKey) {\n throw new Error('IncidentioIntegration: missing required INCIDENT_IO_API_KEY.');\n }\n const baseUrl = config.baseUrl ?? 'https://api.incident.io';\n this.#endpointHost = new URL(baseUrl).host;\n const api = new IncidentioApiClient({\n baseUrl,\n accessToken: apiKey,\n ...(config.fetchImpl ? { fetchImpl: config.fetchImpl } : {}),\n });\n this.intake = createIncidentioIntake({\n api,\n connection: { type: 'oauth', accessToken: DIRECT_CONNECTION_TOKEN },\n });\n }\n\n /** Event rules driving automatic follow-up materialization and close handling. */\n get rules(): IncidentioEventRules {\n return this.#rules;\n }\n\n /**\n * Bind the projects domain and the host auth seam. incident.io has no\n * per-org connection rows here — credentials are deployment-global\n * constructor config.\n */\n initialize({\n projects,\n auth,\n intake,\n }: {\n projects: FactoryProjectsStorage;\n auth: RouteAuth;\n intake: IntakeStorage;\n }): void {\n this.#projects = projects;\n this.#auth = auth;\n this.#intakeStorage = intake;\n }\n\n /** Cross-integration intake selection/binding domain — agent-tool authorization. */\n get intakeStorage(): IntakeStorage {\n if (!this.#intakeStorage) {\n throw new Error('IncidentioIntegration is not initialized — the factory binds storage during prepare().');\n }\n return this.#intakeStorage;\n }\n\n /** Factory projects domain — maps a session's resourceId to its owning org. */\n get projects(): FactoryProjectsStorage {\n if (!this.#projects) {\n throw new Error('IncidentioIntegration is not initialized — the factory binds storage during prepare().');\n }\n return this.#projects;\n }\n\n /** Whether the host runs with web auth enabled; every surface is inert without it. */\n get authEnabled(): boolean {\n return this.#auth?.enabled() ?? false;\n }\n\n /**\n * Map a session's resourceId (the factory project id) to its owning org.\n * Same caching semantics as the Jira integration: definitive misses are\n * cached, transient database failures are not.\n */\n async resolveOrgId(resourceId: string): Promise<string | null> {\n const cached = this.#orgIdByResourceId.get(resourceId);\n if (cached !== undefined) return cached;\n if (!UUID_PATTERN.test(resourceId)) {\n this.#orgIdByResourceId.set(resourceId, null);\n return null;\n }\n let orgId: string | null;\n try {\n await this.projects.ensureReady();\n const project = await this.projects.getById({ id: resourceId });\n orgId = project?.orgId ?? null;\n } catch {\n // Transient database failure: skip the tools for this request but don't\n // cache the miss, so the next request retries the lookup.\n return null;\n }\n this.#orgIdByResourceId.set(resourceId, orgId);\n return orgId;\n }\n\n /** Test hook: clear the org cache between specs. */\n clearCaches(): void {\n this.#orgIdByResourceId.clear();\n }\n\n /**\n * Org-scoped agent tools: the read-only follow-up detail tool for sessions\n * whose resource is a factory project, matching the Linear/Jira surface.\n */\n async agentTools(args: { requestContext: RequestContext }): Promise<IntegrationTools> {\n return buildIncidentioAgentTools({ requestContext: args.requestContext, incidentio: this });\n }\n\n workers(ctx: IntegrationContext): MastraWorker[] {\n if (!incidentioReconciliationEnabled()) return [];\n const reconcile = attachIncidentioIssueReconciler(this, ctx);\n if (!reconcile) return [];\n const intervalMs = incidentioReconciliationInterval();\n return [\n new IssueReconcileWorker({\n integrationId: this.id,\n reconcile,\n ...(intervalMs ? { intervalMs } : {}),\n }),\n ];\n }\n\n /**\n * The integration's HTTP surface: `/web/incidentio/*` Mastra `apiRoutes`\n * (status + follow-up listing/detail for Intake). Handlers operate on this\n * instance; a board-scoped listing also feeds the incident.io event rules.\n */\n routes(ctx: IntegrationContext): ApiRoute[] {\n return buildIncidentioRoutes({\n incidentio: this,\n mode: 'api-key',\n auth: ctx.auth,\n intake: ctx.storage.intake,\n ingestFactoryIssues: attachIncidentioRules(this, ctx),\n });\n }\n\n diagnostics(): Record<string, unknown> {\n return { mode: 'api-key', endpointHost: this.#endpointHost };\n }\n}\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,0BAA0B;AAChC,MAAM,eAAe;AAErB,IAAa,wBAAb,MAAiE;CAC/D,KAAc;CACd;CACA;CACA;;CAGA;CACA;CACA;CACA,qCAA8B,IAAI,IAA2B;CAE7D,YAAY,SAAsC,CAAC,GAAG;EACpD,KAAKC,SAAS,uBAAuB,OAAO,KAAK;EACjD,MAAM,SAAS,OAAO,QAAQ,KAAK,KAAK,QAAQ,IAAI,qBAAqB,KAAK;EAC9E,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,8DAA8D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pF,OAAO,0BAA0B;GAAE,gBAAgB,KAAK;GAAgB,YAAY;EAAK,CAAC;CAC5F;CAEA,QAAQ,KAAyC;EAC/C,IAAI,CAAC,gCAAgC,GAAG,OAAO,CAAC;EAChD,MAAM,YAAY,gCAAgC,MAAM,GAAG;EAC3D,IAAI,CAAC,WAAW,OAAO,CAAC;EACxB,MAAM,aAAa,iCAAiC;EACpD,OAAO,CACL,IAAI,qBAAqB;GACvB,eAAe,KAAK;GACpB;GACA,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;EACrC,CAAC,CACH;CACF;;;;;;CAOA,OAAO,KAAqC;EAC1C,OAAO,sBAAsB;GAC3B,YAAY;GACZ,MAAM;GACN,MAAM,IAAI;GACV,QAAQ,IAAI,QAAQ;GACpB,qBAAqB,sBAAsB,MAAM,GAAG;EACtD,CAAC;CACH;CAEA,cAAuC;EACrC,OAAO;GAAE,MAAM;GAAW,cAAc,KAAKF;EAAc;CAC7D;AACF"}
1
+ {"version":3,"file":"integration.js","names":["#endpointHost","#rules","#orgIdByResourceId","#projects","#auth","#intakeStorage"],"sources":["../../../src/integrations/incidentio/integration.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { MastraWorker } from '@mastra/core/worker';\n\nimport type { RouteAuth } from '../../routes/route.js';\nimport type { IntakeStorage } from '../../storage/domains/intake/base.js';\nimport type { FactoryProjectsStorage } from '../../storage/domains/projects/base.js';\nimport type { FactoryIntegration, IntegrationContext, IntegrationTools } from '../base.js';\nimport { IssueReconcileWorker } from '../issue-reconcile-worker.js';\nimport { buildIncidentioAgentTools } from './agent-tools.js';\nimport { IncidentioApiClient } from './api.js';\nimport { resolveIncidentioRules } from './default-rules.js';\nimport type { IncidentioEventRules, IncidentioRuleOverrides } from './default-rules.js';\nimport { createIncidentioIntake } from './intake.js';\nimport { attachIncidentioIssueReconciler } from './issue-reconciler.js';\nimport { incidentioReconciliationEnabled, incidentioReconciliationInterval } from './reconciliation-config.js';\nimport { buildIncidentioRoutes } from './routes.js';\nimport { attachIncidentioRules } from './rules.js';\n\nexport interface IncidentioIntegrationConfig {\n apiKey?: string;\n fetchImpl?: typeof fetch;\n baseUrl?: string;\n /** Per-event replacements for the default Factory incident.io rules. */\n rules?: IncidentioRuleOverrides;\n}\n\nconst DIRECT_CONNECTION_TOKEN = 'incidentio-direct-api-key';\nconst UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nexport class IncidentioIntegration implements FactoryIntegration {\n readonly id = 'incidentio';\n readonly intake;\n readonly #endpointHost: string;\n readonly #rules: IncidentioEventRules;\n\n /** Bound once by the factory via `initialize()` before any surface is used. */\n #projects: FactoryProjectsStorage | undefined;\n #auth: RouteAuth | undefined;\n #intakeStorage: IntakeStorage | undefined;\n readonly #orgIdByResourceId = new Map<string, string | null>();\n\n constructor(config: IncidentioIntegrationConfig = {}) {\n this.#rules = resolveIncidentioRules(config.rules);\n const apiKey = config.apiKey?.trim() || process.env.INCIDENT_IO_API_KEY?.trim();\n if (!apiKey) {\n throw new Error('IncidentioIntegration: missing required INCIDENT_IO_API_KEY.');\n }\n const baseUrl = config.baseUrl ?? 'https://api.incident.io';\n this.#endpointHost = new URL(baseUrl).host;\n const api = new IncidentioApiClient({\n baseUrl,\n accessToken: apiKey,\n // Direct incident.io access: never leak the Mastra project id header\n // to incident.io itself.\n projectId: null,\n ...(config.fetchImpl ? { fetchImpl: config.fetchImpl } : {}),\n });\n this.intake = createIncidentioIntake({\n api,\n connection: { type: 'oauth', accessToken: DIRECT_CONNECTION_TOKEN },\n });\n }\n\n /** Event rules driving automatic follow-up materialization and close handling. */\n get rules(): IncidentioEventRules {\n return this.#rules;\n }\n\n /**\n * Bind the projects domain and the host auth seam. incident.io has no\n * per-org connection rows here — credentials are deployment-global\n * constructor config.\n */\n initialize({\n projects,\n auth,\n intake,\n }: {\n projects: FactoryProjectsStorage;\n auth: RouteAuth;\n intake: IntakeStorage;\n }): void {\n this.#projects = projects;\n this.#auth = auth;\n this.#intakeStorage = intake;\n }\n\n /** Cross-integration intake selection/binding domain — agent-tool authorization. */\n get intakeStorage(): IntakeStorage {\n if (!this.#intakeStorage) {\n throw new Error('IncidentioIntegration is not initialized — the factory binds storage during prepare().');\n }\n return this.#intakeStorage;\n }\n\n /** Factory projects domain — maps a session's resourceId to its owning org. */\n get projects(): FactoryProjectsStorage {\n if (!this.#projects) {\n throw new Error('IncidentioIntegration is not initialized — the factory binds storage during prepare().');\n }\n return this.#projects;\n }\n\n /** Whether the host runs with web auth enabled; every surface is inert without it. */\n get authEnabled(): boolean {\n return this.#auth?.enabled() ?? false;\n }\n\n /**\n * Map a session's resourceId (the factory project id) to its owning org.\n * Same caching semantics as the Jira integration: definitive misses are\n * cached, transient database failures are not.\n */\n async resolveOrgId(resourceId: string): Promise<string | null> {\n const cached = this.#orgIdByResourceId.get(resourceId);\n if (cached !== undefined) return cached;\n if (!UUID_PATTERN.test(resourceId)) {\n this.#orgIdByResourceId.set(resourceId, null);\n return null;\n }\n let orgId: string | null;\n try {\n await this.projects.ensureReady();\n const project = await this.projects.getById({ id: resourceId });\n orgId = project?.orgId ?? null;\n } catch {\n // Transient database failure: skip the tools for this request but don't\n // cache the miss, so the next request retries the lookup.\n return null;\n }\n this.#orgIdByResourceId.set(resourceId, orgId);\n return orgId;\n }\n\n /** Test hook: clear the org cache between specs. */\n clearCaches(): void {\n this.#orgIdByResourceId.clear();\n }\n\n /**\n * Org-scoped agent tools: the read-only follow-up detail tool for sessions\n * whose resource is a factory project, matching the Linear/Jira surface.\n */\n async agentTools(args: { requestContext: RequestContext }): Promise<IntegrationTools> {\n return buildIncidentioAgentTools({ requestContext: args.requestContext, incidentio: this });\n }\n\n workers(ctx: IntegrationContext): MastraWorker[] {\n if (!incidentioReconciliationEnabled()) return [];\n const reconcile = attachIncidentioIssueReconciler(this, ctx);\n if (!reconcile) return [];\n const intervalMs = incidentioReconciliationInterval();\n return [\n new IssueReconcileWorker({\n integrationId: this.id,\n reconcile,\n ...(intervalMs ? { intervalMs } : {}),\n }),\n ];\n }\n\n /**\n * The integration's HTTP surface: `/web/incidentio/*` Mastra `apiRoutes`\n * (status + follow-up listing/detail for Intake). Handlers operate on this\n * instance; a board-scoped listing also feeds the incident.io event rules.\n */\n routes(ctx: IntegrationContext): ApiRoute[] {\n return buildIncidentioRoutes({\n incidentio: this,\n mode: 'api-key',\n auth: ctx.auth,\n intake: ctx.storage.intake,\n ingestFactoryIssues: attachIncidentioRules(this, ctx),\n });\n }\n\n diagnostics(): Record<string, unknown> {\n return { mode: 'api-key', endpointHost: this.#endpointHost };\n }\n}\n"],"mappings":";;;;;;;;;;AA2BA,MAAM,0BAA0B;AAChC,MAAM,eAAe;AAErB,IAAa,wBAAb,MAAiE;CAC/D,KAAc;CACd;CACA;CACA;;CAGA;CACA;CACA;CACA,qCAA8B,IAAI,IAA2B;CAE7D,YAAY,SAAsC,CAAC,GAAG;EACpD,KAAKC,SAAS,uBAAuB,OAAO,KAAK;EACjD,MAAM,SAAS,OAAO,QAAQ,KAAK,KAAK,QAAQ,IAAI,qBAAqB,KAAK;EAC9E,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,8DAA8D;EAEhF,MAAM,UAAU,OAAO,WAAW;EAClC,KAAKD,gBAAgB,IAAI,IAAI,OAAO,CAAC,CAAC;EACtC,MAAM,MAAM,IAAI,oBAAoB;GAClC;GACA,aAAa;GAGb,WAAW;GACX,GAAI,OAAO,YAAY,EAAE,WAAW,OAAO,UAAU,IAAI,CAAC;EAC5D,CAAC;EACD,KAAK,SAAS,uBAAuB;GACnC;GACA,YAAY;IAAE,MAAM;IAAS,aAAa;GAAwB;EACpE,CAAC;CACH;;CAGA,IAAI,QAA8B;EAChC,OAAO,KAAKC;CACd;;;;;;CAOA,WAAW,EACT,UACA,MACA,UAKO;EACP,KAAKE,YAAY;EACjB,KAAKC,QAAQ;EACb,KA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AAM;GACN,MAAM,IAAI;GACV,QAAQ,IAAI,QAAQ;GACpB,qBAAqB,sBAAsB,MAAM,GAAG;EACtD,CAAC;CACH;CAEA,cAAuC;EACrC,OAAO;GAAE,MAAM;GAAW,cAAc,KAAKF;EAAc;CAC7D;AACF"}
@@ -37,6 +37,13 @@ export type JiraApiClientConfig = JiraApiClientBaseConfig & ({
37
37
  } | {
38
38
  /** Bearer token used when the base URL is a Mastra Platform connection proxy. */
39
39
  accessToken: string;
40
+ /**
41
+ * Mastra project id sent as `x-mastra-project-id` so the platform can
42
+ * attribute proxied Jira activity to the project. Falls back to the
43
+ * `MASTRA_PROJECT_ID` environment variable. The platform strips the
44
+ * header before forwarding the request to Atlassian.
45
+ */
46
+ projectId?: string;
40
47
  email?: never;
41
48
  apiToken?: never;
42
49
  });
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/integrations/jira/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAMxC,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,uEAAuE;AACvE,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAE1C,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,2IAYpB,CAAC;AAEX,UAAU,uBAAuB;IAC/B,mFAAmF;IACnF,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,GACvD,CACI;IACE,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,GACD;IACE,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;IACpB,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ChE,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAQjE,+DAA+D;IACzD,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAK5E"}
@@ -41,6 +41,7 @@ var JiraApiError = class extends Error {
41
41
  var JiraApiClient = class {
42
42
  #baseUrl;
43
43
  #authHeader;
44
+ #projectId;
44
45
  #fetch;
45
46
  constructor(config) {
46
47
  if (!config.baseUrl) throw new Error("JiraApiClient is missing required config: baseUrl.");
@@ -54,11 +55,13 @@ var JiraApiClient = class {
54
55
  if (config.accessToken !== void 0) {
55
56
  if (!config.accessToken) throw new Error("JiraApiClient is missing required config: accessToken.");
56
57
  this.#authHeader = `Bearer ${config.accessToken}`;
58
+ this.#projectId = (config.projectId ?? process.env.MASTRA_PROJECT_ID)?.trim() || null;
57
59
  } else {
58
60
  const missing = ["email", "apiToken"].filter((key) => !config[key]);
59
61
  if (missing.length > 0) throw new Error(`JiraApiClient is missing required config: ${missing.join(", ")}.`);
60
62
  if (parsed.protocol === "http:" && !LOOPBACK_HOSTS.has(parsed.hostname)) throw new Error("JiraApiClient baseUrl must use https when Basic credentials are configured.");
61
63
  this.#authHeader = `Basic ${Buffer.from(`${config.email}:${config.apiToken}`).toString("base64")}`;
64
+ this.#projectId = null;
62
65
  }
63
66
  this.#baseUrl = config.baseUrl.replace(/\/+$/, "");
64
67
  this.#fetch = config.fetchImpl ?? globalThis.fetch;
@@ -77,6 +80,7 @@ var JiraApiClient = class {
77
80
  headers: {
78
81
  authorization: this.#authHeader,
79
82
  accept: "application/json",
83
+ ...this.#projectId ? { "x-mastra-project-id": this.#projectId } : {},
80
84
  ...hasBody ? { "content-type": "application/json" } : {}
81
85
  },
82
86
  ...hasBody ? { body: JSON.stringify(options.body) } : {}
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","names":["#baseUrl","#authHeader","#fetch","#request"],"sources":["../../../src/integrations/jira/api.ts"],"sourcesContent":["/**\n * Typed Jira Cloud REST client (API v3).\n *\n * Shared by the direct and Platform-managed Jira integrations. Direct Jira\n * uses Basic auth against an Atlassian site; Platform Jira points the same\n * client at a connection proxy with a bearer token. Both modes use the same\n * request shapes, timeout, and error normalization.\n *\n * Endpoint notes (Jira Cloud, 2026):\n * - Issue search is `POST /rest/api/3/search/jql` — the legacy\n * `GET /rest/api/3/search` endpoint has been removed. The new endpoint\n * returns only ids unless `fields` is requested explicitly, and pages with\n * an opaque `nextPageToken` cursor (no `startAt`/`total`).\n * - Project listing is `GET /rest/api/3/project/search` with classic\n * `startAt`/`isLast` paging.\n * - Descriptions and comment bodies are ADF documents (see `adf.ts`).\n */\n\nimport type { AdfNode } from './adf.js';\nimport { textToAdf } from './adf.js';\n\nconst JIRA_TIMEOUT_MS = 15_000;\n/** Hosts allowed to receive Basic credentials over plain http (local development mocks). */\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);\n/** Issue page size — Linear parity (`LINEAR_ISSUES_PAGE_SIZE`). */\nexport const JIRA_ISSUES_PAGE_SIZE = 30;\n/** Comment page size — Linear parity (`LINEAR_COMMENTS_PAGE_SIZE`). */\nexport const JIRA_COMMENTS_PAGE_SIZE = 50;\nexport const JIRA_PROJECTS_PAGE_SIZE = 50;\n\n/** Fields requested from issue reads — `search/jql` returns ids only without an explicit list. */\nexport const JIRA_ISSUE_FIELDS = [\n 'summary',\n 'description',\n 'status',\n 'assignee',\n 'reporter',\n 'labels',\n 'priority',\n 'issuetype',\n 'project',\n 'created',\n 'updated',\n] as const;\n\ninterface JiraApiClientBaseConfig {\n /** Jira API base URL, either the Atlassian site or a Platform connection proxy. */\n baseUrl: string;\n fetchImpl?: typeof fetch;\n}\n\nexport type JiraApiClientConfig = JiraApiClientBaseConfig &\n (\n | {\n /** Atlassian account email the API token belongs to. */\n email: string;\n /** API token from id.atlassian.com → Security → API tokens. */\n apiToken: string;\n accessToken?: never;\n }\n | {\n /** Bearer token used when the base URL is a Mastra Platform connection proxy. */\n accessToken: string;\n email?: never;\n apiToken?: never;\n }\n );\n\n/** Stable error code the routes/tools surface to the SPA and agents. */\nexport type JiraApiErrorCode = 'jira_auth_failed' | 'jira_request_failed';\n\n/** Normalized Jira API failure carrying the HTTP status and Jira's error detail. */\nexport class JiraApiError extends Error {\n readonly status: number | null;\n readonly code: JiraApiErrorCode;\n\n constructor(message: string, status: number | null) {\n super(message);\n this.name = 'JiraApiError';\n this.status = status;\n this.code = status === 401 || status === 403 ? 'jira_auth_failed' : 'jira_request_failed';\n }\n}\n\nexport interface JiraStatusCategory {\n /** `new` | `indeterminate` | `done` — Jira's fixed status families. */\n key: string;\n name?: string;\n}\n\nexport interface JiraStatus {\n name: string;\n statusCategory?: JiraStatusCategory;\n}\n\nexport interface JiraProject {\n id: string;\n key: string;\n name: string;\n}\n\nexport interface JiraProjectSearchPage {\n values: JiraProject[];\n startAt: number;\n isLast: boolean;\n}\n\nexport interface JiraServerInfo {\n baseUrl: string;\n serverTitle?: string;\n}\n\nexport interface JiraUser {\n displayName: string;\n}\n\nexport interface JiraComment {\n id: string;\n author?: JiraUser | null;\n body?: AdfNode | null;\n created: string;\n}\n\nexport interface JiraCommentPage {\n comments: JiraComment[];\n startAt: number;\n maxResults: number;\n total: number;\n}\n\nexport interface JiraIssueFields {\n summary?: string;\n description?: AdfNode | null;\n status?: JiraStatus;\n assignee?: JiraUser | null;\n reporter?: JiraUser | null;\n labels?: string[];\n priority?: { name: string } | null;\n issuetype?: { name: string };\n project?: { id: string; key: string; name?: string };\n created?: string;\n updated?: string;\n}\n\nexport interface JiraIssue {\n id: string;\n key: string;\n fields: JiraIssueFields;\n}\n\nexport interface JiraSearchPage {\n issues: JiraIssue[];\n /** Opaque cursor for the next page; absent on the last page. */\n nextPageToken?: string | null;\n}\n\nexport interface JiraTransition {\n id: string;\n name: string;\n /** Target status the transition moves the issue to. */\n to?: JiraStatus;\n}\n\nexport class JiraApiClient {\n readonly #baseUrl: string;\n readonly #authHeader: string;\n readonly #fetch: typeof fetch;\n\n constructor(config: JiraApiClientConfig) {\n if (!config.baseUrl) {\n throw new Error('JiraApiClient is missing required config: baseUrl.');\n }\n // Fail fast on a malformed base URL: a bare host like `acme.atlassian.net`\n // would otherwise surface later as an opaque `TypeError: Invalid URL`.\n let parsed: URL;\n try {\n parsed = new URL(config.baseUrl);\n } catch {\n throw new Error(`JiraApiClient baseUrl is not an absolute URL: \"${config.baseUrl}\".`);\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new Error(`JiraApiClient baseUrl must be an http(s) URL: \"${config.baseUrl}\".`);\n }\n if (config.accessToken !== undefined) {\n if (!config.accessToken) {\n throw new Error('JiraApiClient is missing required config: accessToken.');\n }\n this.#authHeader = `Bearer ${config.accessToken}`;\n } else {\n const missing = (['email', 'apiToken'] as const).filter(key => !config[key]);\n if (missing.length > 0) {\n throw new Error(`JiraApiClient is missing required config: ${missing.join(', ')}.`);\n }\n // Basic credentials ride on every request, so never send them over\n // plaintext to a remote host. Loopback stays allowed for local mocks.\n if (parsed.protocol === 'http:' && !LOOPBACK_HOSTS.has(parsed.hostname)) {\n throw new Error('JiraApiClient baseUrl must use https when Basic credentials are configured.');\n }\n this.#authHeader = `Basic ${Buffer.from(`${config.email}:${config.apiToken}`).toString('base64')}`;\n }\n this.#baseUrl = config.baseUrl.replace(/\\/+$/, '');\n this.#fetch = config.fetchImpl ?? globalThis.fetch;\n }\n\n /** Normalized site base URL (no trailing slash) — used for `/browse/<key>` links. */\n get baseUrl(): string {\n return this.#baseUrl;\n }\n\n async #request<T>(\n method: 'GET' | 'POST',\n path: string,\n options: { query?: Record<string, string | number | undefined>; body?: unknown } = {},\n ): Promise<T> {\n const url = new URL(`${this.#baseUrl}${path}`);\n for (const [key, value] of Object.entries(options.query ?? {})) {\n if (value !== undefined) url.searchParams.set(key, String(value));\n }\n const hasBody = options.body !== undefined;\n const res = await this.#fetch(url, {\n method,\n signal: AbortSignal.timeout(JIRA_TIMEOUT_MS),\n headers: {\n authorization: this.#authHeader,\n accept: 'application/json',\n ...(hasBody ? { 'content-type': 'application/json' } : {}),\n },\n ...(hasBody ? { body: JSON.stringify(options.body) } : {}),\n });\n if (!res.ok) {\n // Jira reports validation failures as `errorMessages` and `errors`;\n // the Platform proxy reports upstream failures through `detail`/`error`/`title`.\n let detail: string | null = null;\n try {\n const errBody = (await res.json()) as {\n errorMessages?: string[];\n errors?: Record<string, string>;\n detail?: string;\n error?: string;\n title?: string;\n };\n detail =\n errBody.errorMessages?.[0] ??\n Object.values(errBody.errors ?? {})[0] ??\n errBody.detail ??\n errBody.error ??\n errBody.title ??\n null;\n } catch {\n // Non-JSON error body; fall back to the status code alone.\n }\n throw new JiraApiError(`Jira API request failed (${res.status})${detail ? `: ${detail}` : ''}`, res.status);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n\n async getServerInfo(): Promise<JiraServerInfo> {\n return this.#request<JiraServerInfo>('GET', '/rest/api/3/serverInfo');\n }\n\n /** One page of the site's projects (Settings intake-source picker). */\n async listProjects(options: { startAt?: number } = {}): Promise<JiraProjectSearchPage> {\n return this.#request<JiraProjectSearchPage>('GET', '/rest/api/3/project/search', {\n query: { startAt: options.startAt ?? 0, maxResults: JIRA_PROJECTS_PAGE_SIZE },\n });\n }\n\n /** One page of a JQL search with explicitly requested fields. */\n async searchIssues(options: {\n jql: string;\n fields?: readonly string[];\n nextPageToken?: string;\n maxResults?: number;\n }): Promise<JiraSearchPage> {\n return this.#request<JiraSearchPage>('POST', '/rest/api/3/search/jql', {\n body: {\n jql: options.jql,\n fields: [...(options.fields ?? JIRA_ISSUE_FIELDS)],\n maxResults: options.maxResults ?? JIRA_ISSUES_PAGE_SIZE,\n ...(options.nextPageToken ? { nextPageToken: options.nextPageToken } : {}),\n },\n });\n }\n\n /** Full issue detail by key (`ENG-42`) or id. */\n async getIssue(keyOrId: string): Promise<JiraIssue> {\n return this.#request<JiraIssue>('GET', `/rest/api/3/issue/${encodeURIComponent(keyOrId)}`, {\n query: { fields: JIRA_ISSUE_FIELDS.join(',') },\n });\n }\n\n /** One page of an issue's comments (oldest first, Jira default order). */\n async listComments(keyOrId: string, options: { startAt?: number } = {}): Promise<JiraCommentPage> {\n return this.#request<JiraCommentPage>('GET', `/rest/api/3/issue/${encodeURIComponent(keyOrId)}/comment`, {\n query: { startAt: options.startAt ?? 0, maxResults: JIRA_COMMENTS_PAGE_SIZE },\n });\n }\n\n /** Post a plain-text comment (wrapped into a minimal ADF document). */\n async createComment(keyOrId: string, body: string): Promise<JiraComment> {\n return this.#request<JiraComment>('POST', `/rest/api/3/issue/${encodeURIComponent(keyOrId)}/comment`, {\n body: { body: textToAdf(body) },\n });\n }\n\n /** Transitions currently legal for the issue (workflow-dependent). */\n async listTransitions(keyOrId: string): Promise<JiraTransition[]> {\n const data = await this.#request<{ transitions?: JiraTransition[] }>(\n 'GET',\n `/rest/api/3/issue/${encodeURIComponent(keyOrId)}/transitions`,\n );\n return data.transitions ?? [];\n }\n\n /** Apply a transition by id (Jira responds 204 on success). */\n async applyTransition(keyOrId: string, transitionId: string): Promise<void> {\n await this.#request<void>('POST', `/rest/api/3/issue/${encodeURIComponent(keyOrId)}/transitions`, {\n body: { transition: { id: transitionId } },\n });\n }\n}\n"],"mappings":";;AAqBA,MAAM,kBAAkB;;AAExB,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAa;CAAa;CAAS;AAAK,CAAC;;AAEzE,MAAa,wBAAwB;;AAErC,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;;AAGvC,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AA6BA,IAAa,eAAb,cAAkC,MAAM;CACtC;CACA;CAEA,YAAY,SAAiB,QAAuB;EAClD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,OAAO,WAAW,OAAO,WAAW,MAAM,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AGA,MAAM,SAAS,SAAqC;EAClD,OAAO,KAAKA,SAAoB,OAAO,qBAAqB,mBAAmB,OAAO,KAAK,EACzF,OAAO,EAAE,QAAQ,kBAAkB,KAAK,GAAG,EAAE,EAC/C,CAAC;CACH;;CAGA,MAAM,aAAa,SAAiB,UAAgC,CAAC,GAA6B;EAChG,OAAO,KAAKA,SAA0B,OAAO,qBAAqB,mBAAmB,OAAO,EAAE,WAAW,EACvG,OAAO;GAAE,SAAS,QAAQ,WAAW;GAAG,YAAA;EAAoC,EAC9E,CAAC;CACH;;CAGA,MAAM,cAAc,SAAiB,MAAoC;EACvE,OAAO,KAAKA,SAAsB,QAAQ,qBAAqB,mBAAmB,OAAO,EAAE,WAAW,EACpG,MAAM,EAAE,MAAM,UAAU,IAAI,EAAE,EAChC,CAAC;CACH;;CAGA,MAAM,gBAAgB,SAA4C;EAKhE,QAAO,MAJY,KAAKA,SACtB,OACA,qBAAqB,mBAAmB,OAAO,EAAE,aACnD,EAAA,CACY,eAAe,CAAC;CAC9B;;CAGA,MAAM,gBAAgB,SAAiB,cAAqC;EAC1E,MAAM,KAAKA,SAAe,QAAQ,qBAAqB,mBAAmB,OAAO,EAAE,eAAe,EAChG,MAAM,EAAE,YAAY,EAAE,IAAI,aAAa,EAAE,EAC3C,CAAC;CACH;AACF"}
1
+ {"version":3,"file":"api.js","names":["#baseUrl","#authHeader","#projectId","#fetch","#request"],"sources":["../../../src/integrations/jira/api.ts"],"sourcesContent":["/**\n * Typed Jira Cloud REST client (API v3).\n *\n * Shared by the direct and Platform-managed Jira integrations. Direct Jira\n * uses Basic auth against an Atlassian site; Platform Jira points the same\n * client at a connection proxy with a bearer token. Both modes use the same\n * request shapes, timeout, and error normalization.\n *\n * Endpoint notes (Jira Cloud, 2026):\n * - Issue search is `POST /rest/api/3/search/jql` — the legacy\n * `GET /rest/api/3/search` endpoint has been removed. The new endpoint\n * returns only ids unless `fields` is requested explicitly, and pages with\n * an opaque `nextPageToken` cursor (no `startAt`/`total`).\n * - Project listing is `GET /rest/api/3/project/search` with classic\n * `startAt`/`isLast` paging.\n * - Descriptions and comment bodies are ADF documents (see `adf.ts`).\n */\n\nimport type { AdfNode } from './adf.js';\nimport { textToAdf } from './adf.js';\n\nconst JIRA_TIMEOUT_MS = 15_000;\n/** Hosts allowed to receive Basic credentials over plain http (local development mocks). */\nconst LOOPBACK_HOSTS = new Set(['localhost', '127.0.0.1', '[::1]', '::1']);\n/** Issue page size — Linear parity (`LINEAR_ISSUES_PAGE_SIZE`). */\nexport const JIRA_ISSUES_PAGE_SIZE = 30;\n/** Comment page size — Linear parity (`LINEAR_COMMENTS_PAGE_SIZE`). */\nexport const JIRA_COMMENTS_PAGE_SIZE = 50;\nexport const JIRA_PROJECTS_PAGE_SIZE = 50;\n\n/** Fields requested from issue reads — `search/jql` returns ids only without an explicit list. */\nexport const JIRA_ISSUE_FIELDS = [\n 'summary',\n 'description',\n 'status',\n 'assignee',\n 'reporter',\n 'labels',\n 'priority',\n 'issuetype',\n 'project',\n 'created',\n 'updated',\n] as const;\n\ninterface JiraApiClientBaseConfig {\n /** Jira API base URL, either the Atlassian site or a Platform connection proxy. */\n baseUrl: string;\n fetchImpl?: typeof fetch;\n}\n\nexport type JiraApiClientConfig = JiraApiClientBaseConfig &\n (\n | {\n /** Atlassian account email the API token belongs to. */\n email: string;\n /** API token from id.atlassian.com → Security → API tokens. */\n apiToken: string;\n accessToken?: never;\n }\n | {\n /** Bearer token used when the base URL is a Mastra Platform connection proxy. */\n accessToken: string;\n /**\n * Mastra project id sent as `x-mastra-project-id` so the platform can\n * attribute proxied Jira activity to the project. Falls back to the\n * `MASTRA_PROJECT_ID` environment variable. The platform strips the\n * header before forwarding the request to Atlassian.\n */\n projectId?: string;\n email?: never;\n apiToken?: never;\n }\n );\n\n/** Stable error code the routes/tools surface to the SPA and agents. */\nexport type JiraApiErrorCode = 'jira_auth_failed' | 'jira_request_failed';\n\n/** Normalized Jira API failure carrying the HTTP status and Jira's error detail. */\nexport class JiraApiError extends Error {\n readonly status: number | null;\n readonly code: JiraApiErrorCode;\n\n constructor(message: string, status: number | null) {\n super(message);\n this.name = 'JiraApiError';\n this.status = status;\n this.code = status === 401 || status === 403 ? 'jira_auth_failed' : 'jira_request_failed';\n }\n}\n\nexport interface JiraStatusCategory {\n /** `new` | `indeterminate` | `done` — Jira's fixed status families. */\n key: string;\n name?: string;\n}\n\nexport interface JiraStatus {\n name: string;\n statusCategory?: JiraStatusCategory;\n}\n\nexport interface JiraProject {\n id: string;\n key: string;\n name: string;\n}\n\nexport interface JiraProjectSearchPage {\n values: JiraProject[];\n startAt: number;\n isLast: boolean;\n}\n\nexport interface JiraServerInfo {\n baseUrl: string;\n serverTitle?: string;\n}\n\nexport interface JiraUser {\n displayName: string;\n}\n\nexport interface JiraComment {\n id: string;\n author?: JiraUser | null;\n body?: AdfNode | null;\n created: string;\n}\n\nexport interface JiraCommentPage {\n comments: JiraComment[];\n startAt: number;\n maxResults: number;\n total: number;\n}\n\nexport interface JiraIssueFields {\n summary?: string;\n description?: AdfNode | null;\n status?: JiraStatus;\n assignee?: JiraUser | null;\n reporter?: JiraUser | null;\n labels?: string[];\n priority?: { name: string } | null;\n issuetype?: { name: string };\n project?: { id: string; key: string; name?: string };\n created?: string;\n updated?: string;\n}\n\nexport interface JiraIssue {\n id: string;\n key: string;\n fields: JiraIssueFields;\n}\n\nexport interface JiraSearchPage {\n issues: JiraIssue[];\n /** Opaque cursor for the next page; absent on the last page. */\n nextPageToken?: string | null;\n}\n\nexport interface JiraTransition {\n id: string;\n name: string;\n /** Target status the transition moves the issue to. */\n to?: JiraStatus;\n}\n\nexport class JiraApiClient {\n readonly #baseUrl: string;\n readonly #authHeader: string;\n readonly #projectId: string | null;\n readonly #fetch: typeof fetch;\n\n constructor(config: JiraApiClientConfig) {\n if (!config.baseUrl) {\n throw new Error('JiraApiClient is missing required config: baseUrl.');\n }\n // Fail fast on a malformed base URL: a bare host like `acme.atlassian.net`\n // would otherwise surface later as an opaque `TypeError: Invalid URL`.\n let parsed: URL;\n try {\n parsed = new URL(config.baseUrl);\n } catch {\n throw new Error(`JiraApiClient baseUrl is not an absolute URL: \"${config.baseUrl}\".`);\n }\n if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n throw new Error(`JiraApiClient baseUrl must be an http(s) URL: \"${config.baseUrl}\".`);\n }\n if (config.accessToken !== undefined) {\n if (!config.accessToken) {\n throw new Error('JiraApiClient is missing required config: accessToken.');\n }\n this.#authHeader = `Bearer ${config.accessToken}`;\n this.#projectId = (config.projectId ?? process.env.MASTRA_PROJECT_ID)?.trim() || null;\n } else {\n const missing = (['email', 'apiToken'] as const).filter(key => !config[key]);\n if (missing.length > 0) {\n throw new Error(`JiraApiClient is missing required config: ${missing.join(', ')}.`);\n }\n // Basic credentials ride on every request, so never send them over\n // plaintext to a remote host. Loopback stays allowed for local mocks.\n if (parsed.protocol === 'http:' && !LOOPBACK_HOSTS.has(parsed.hostname)) {\n throw new Error('JiraApiClient baseUrl must use https when Basic credentials are configured.');\n }\n this.#authHeader = `Basic ${Buffer.from(`${config.email}:${config.apiToken}`).toString('base64')}`;\n // Direct Atlassian mode: never send Mastra platform headers to Jira itself.\n this.#projectId = null;\n }\n this.#baseUrl = config.baseUrl.replace(/\\/+$/, '');\n this.#fetch = config.fetchImpl ?? globalThis.fetch;\n }\n\n /** Normalized site base URL (no trailing slash) — used for `/browse/<key>` links. */\n get baseUrl(): string {\n return this.#baseUrl;\n }\n\n async #request<T>(\n method: 'GET' | 'POST',\n path: string,\n options: { query?: Record<string, string | number | undefined>; body?: unknown } = {},\n ): Promise<T> {\n const url = new URL(`${this.#baseUrl}${path}`);\n for (const [key, value] of Object.entries(options.query ?? {})) {\n if (value !== undefined) url.searchParams.set(key, String(value));\n }\n const hasBody = options.body !== undefined;\n const res = await this.#fetch(url, {\n method,\n signal: AbortSignal.timeout(JIRA_TIMEOUT_MS),\n headers: {\n authorization: this.#authHeader,\n accept: 'application/json',\n // Project attribution for the Mastra platform proxy; stripped by the\n // platform before the request reaches Atlassian.\n ...(this.#projectId ? { 'x-mastra-project-id': this.#projectId } : {}),\n ...(hasBody ? { 'content-type': 'application/json' } : {}),\n },\n ...(hasBody ? { body: JSON.stringify(options.body) } : {}),\n });\n if (!res.ok) {\n // Jira reports validation failures as `errorMessages` and `errors`;\n // the Platform proxy reports upstream failures through `detail`/`error`/`title`.\n let detail: string | null = null;\n try {\n const errBody = (await res.json()) as {\n errorMessages?: string[];\n errors?: Record<string, string>;\n detail?: string;\n error?: string;\n title?: string;\n };\n detail =\n errBody.errorMessages?.[0] ??\n Object.values(errBody.errors ?? {})[0] ??\n errBody.detail ??\n errBody.error ??\n errBody.title ??\n null;\n } catch {\n // Non-JSON error body; fall back to the status code alone.\n }\n throw new JiraApiError(`Jira API request failed (${res.status})${detail ? `: ${detail}` : ''}`, res.status);\n }\n if (res.status === 204) return undefined as T;\n return (await res.json()) as T;\n }\n\n async getServerInfo(): Promise<JiraServerInfo> {\n return this.#request<JiraServerInfo>('GET', '/rest/api/3/serverInfo');\n }\n\n /** One page of the site's projects (Settings intake-source picker). */\n async listProjects(options: { startAt?: number } = {}): Promise<JiraProjectSearchPage> {\n return this.#request<JiraProjectSearchPage>('GET', '/rest/api/3/project/search', {\n query: { startAt: options.startAt ?? 0, maxResults: JIRA_PROJECTS_PAGE_SIZE },\n });\n }\n\n /** One page of a JQL search with explicitly requested fields. */\n async searchIssues(options: {\n jql: string;\n fields?: readonly string[];\n nextPageToken?: string;\n maxResults?: number;\n }): Promise<JiraSearchPage> {\n return this.#request<JiraSearchPage>('POST', '/rest/api/3/search/jql', {\n body: {\n jql: options.jql,\n fields: [...(options.fields ?? JIRA_ISSUE_FIELDS)],\n maxResults: options.maxResults ?? JIRA_ISSUES_PAGE_SIZE,\n ...(options.nextPageToken ? { nextPageToken: options.nextPageToken } : {}),\n },\n });\n }\n\n /** Full issue detail by key (`ENG-42`) or id. */\n async getIssue(keyOrId: string): Promise<JiraIssue> {\n return this.#request<JiraIssue>('GET', `/rest/api/3/issue/${encodeURIComponent(keyOrId)}`, {\n query: { fields: JIRA_ISSUE_FIELDS.join(',') },\n });\n }\n\n /** One page of an issue's comments (oldest first, Jira default order). */\n async listComments(keyOrId: string, options: { startAt?: number } = {}): Promise<JiraCommentPage> {\n return this.#request<JiraCommentPage>('GET', `/rest/api/3/issue/${encodeURIComponent(keyOrId)}/comment`, {\n query: { startAt: options.startAt ?? 0, maxResults: JIRA_COMMENTS_PAGE_SIZE },\n });\n }\n\n /** Post a plain-text comment (wrapped into a minimal ADF document). */\n async createComment(keyOrId: string, body: string): Promise<JiraComment> {\n return this.#request<JiraComment>('POST', `/rest/api/3/issue/${encodeURIComponent(keyOrId)}/comment`, {\n body: { body: textToAdf(body) },\n });\n }\n\n /** Transitions currently legal for the issue (workflow-dependent). */\n async listTransitions(keyOrId: string): Promise<JiraTransition[]> {\n const data = await this.#request<{ transitions?: JiraTransition[] }>(\n 'GET',\n `/rest/api/3/issue/${encodeURIComponent(keyOrId)}/transitions`,\n );\n return data.transitions ?? [];\n }\n\n /** Apply a transition by id (Jira responds 204 on success). */\n async applyTransition(keyOrId: string, transitionId: string): Promise<void> {\n await this.#request<void>('POST', `/rest/api/3/issue/${encodeURIComponent(keyOrId)}/transitions`, {\n body: { transition: { id: transitionId } },\n });\n }\n}\n"],"mappings":";;AAqBA,MAAM,kBAAkB;;AAExB,MAAM,iCAAiB,IAAI,IAAI;CAAC;CAAa;CAAa;CAAS;AAAK,CAAC;;AAEzE,MAAa,wBAAwB;;AAErC,MAAa,0BAA0B;AACvC,MAAa,0BAA0B;;AAGvC,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAoCA,IAAa,eAAb,cAAkC,MAAM;CACtC;CACA;CAEA,YAAY,SAAiB,QAAuB;EAClD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,OAAO,WAAW,OAAO,WAAW,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,QAAQ;GACb,QAAQ,CAAC,GAAI,QAAQ,UAAU,iBAAkB;GACjD,YAAY,QAAQ,cAAA;GACpB,GAAI,QAAQ,gBAAgB,EAAE,eAAe,QAAQ,cAAc,IAAI,CAAC;EAC1E,EACF,CAAC;CACH;;CAGA,MAAM,SAAS,SAAqC;EAClD,OAAO,KAAKA,SAAoB,OAAO,qBAAqB,mBAAmB,OAAO,KAAK,EACzF,OAAO,EAAE,QAAQ,kBAAkB,KAAK,GAAG,EAAE,EAC/C,CAAC;CACH;;CAGA,MAAM,aAAa,SAAiB,UAAgC,CAAC,GAA6B;EAChG,OAAO,KAAKA,SAA0B,OAAO,qBAAqB,mBAAmB,OAAO,EAAE,WAAW,EACvG,OAAO;GAAE,SAAS,QAAQ,WAAW;GAAG,YAAA;EAAoC,EAC9E,CAAC;CACH;;CAGA,MAAM,cAAc,SAAiB,MAAoC;EACvE,OAAO,KAAKA,SAAsB,QAAQ,qBAAqB,mBAAmB,OAAO,EAAE,WAAW,EACpG,MAAM,EAAE,MAAM,UAAU,IAAI,EAAE,EAChC,CAAC;CACH;;CAGA,MAAM,gBAAgB,SAA4C;EAKhE,QAAO,MAJY,KAAKA,SACtB,OACA,qBAAqB,mBAAmB,OAAO,EAAE,aACnD,EAAA,CACY,eAAe,CAAC;CAC9B;;CAGA,MAAM,gBAAgB,SAAiB,cAAqC;EAC1E,MAAM,KAAKA,SAAe,QAAQ,qBAAqB,mBAAmB,OAAO,EAAE,eAAe,EAChG,MAAM,EAAE,YAAY,EAAE,IAAI,aAAa,EAAE,EAC3C,CAAC;CACH;AACF"}
@@ -1,6 +1,12 @@
1
1
  export interface PlatformApiClientConfig {
2
2
  baseUrl: string;
3
3
  accessToken: string;
4
+ /**
5
+ * Mastra project this deployment belongs to. Sent as `x-mastra-project-id`
6
+ * so the platform can attribute proxied provider activity to the project;
7
+ * the platform strips the header before forwarding anything upstream.
8
+ */
9
+ projectId?: string;
4
10
  fetchImpl?: typeof fetch;
5
11
  }
6
12
  export declare function platformApiClientConfigFromEnv(): PlatformApiClientConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../../../src/integrations/platform/api-client.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAQD,wBAAgB,8BAA8B,IAAI,uBAAuB,CAiBxE;AAuBD,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;gBAE9B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAE,MAAM,GAAG,IAAW;CAMrF;AAED,qBAAa,iBAAiB;;gBAKhB,MAAM,EAAE,uBAAuB;IAUrC,OAAO,CAAC,CAAC,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GACxD,OAAO,CAAC,CAAC,CAAC;IAkBP,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CA0EzG;AAkBD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAEvF;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,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O,CAAC,GAAG,IAAI,CAEvF;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAEvF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAExF"}
@@ -8,9 +8,11 @@ function platformApiClientConfigFromEnv() {
8
8
  const integrationsApiUrl = process.env.MASTRA_INTEGRATIONS_API_URL?.trim() || resolveIntegrationsUrl();
9
9
  const accessToken = process.env.MASTRA_PLATFORM_ACCESS_TOKEN?.trim() || process.env.MASTRA_PLATFORM_SECRET_KEY?.trim();
10
10
  if (!accessToken) throw new Error("Platform integration: missing required environment variable MASTRA_PLATFORM_ACCESS_TOKEN (or MASTRA_PLATFORM_SECRET_KEY).");
11
+ const projectId = process.env.MASTRA_PROJECT_ID?.trim();
11
12
  return {
12
13
  baseUrl: normalizeIntegrationsApiUrl(integrationsApiUrl),
13
- accessToken
14
+ accessToken,
15
+ ...projectId ? { projectId } : {}
14
16
  };
15
17
  }
16
18
  /**
@@ -45,12 +47,14 @@ var PlatformApiError = class extends Error {
45
47
  var PlatformApiClient = class {
46
48
  #baseUrl;
47
49
  #accessToken;
50
+ #projectId;
48
51
  #fetch;
49
52
  constructor(config) {
50
53
  const missing = ["baseUrl", "accessToken"].filter((field) => !config[field]);
51
54
  if (missing.length > 0) throw new Error(`Platform integration: missing required config field(s): ${missing.join(", ")}.`);
52
55
  this.#baseUrl = config.baseUrl.replace(/\/+$/, "");
53
56
  this.#accessToken = config.accessToken;
57
+ this.#projectId = config.projectId?.trim() || null;
54
58
  this.#fetch = config.fetchImpl ?? globalThis.fetch;
55
59
  }
56
60
  async request(method, path, body, options) {
@@ -100,6 +104,7 @@ var PlatformApiClient = class {
100
104
  accept: "application/json",
101
105
  authorization: `Bearer ${this.#accessToken}`
102
106
  };
107
+ if (this.#projectId) headers["x-mastra-project-id"] = this.#projectId;
103
108
  if (options?.actingUserId) headers["x-acting-user-id"] = options.actingUserId;
104
109
  const timeoutSignal = AbortSignal.timeout(15e3);
105
110
  const init = {
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.js","names":["#baseUrl","#accessToken","#fetch","#send"],"sources":["../../../src/integrations/platform/api-client.ts"],"sourcesContent":["export interface PlatformApiClientConfig {\n baseUrl: string;\n accessToken: string;\n fetchImpl?: typeof fetch;\n}\n\nconst DEFAULT_INTEGRATIONS_URL = 'https://integrations.mastra.ai';\nconst REGIONAL_INTEGRATIONS_URLS: Record<'us' | 'eu', string> = {\n us: 'https://integrations.us.mastra.ai',\n eu: 'https://integrations.eu.mastra.ai',\n};\n\nexport function platformApiClientConfigFromEnv(): PlatformApiClientConfig {\n // MASTRA_INTEGRATIONS_API_URL is the dedicated override for the\n // integrations service and takes precedence over MASTRA_PLATFORM_REGION.\n // MASTRA_SHARED_API_URL is deliberately not consulted: it configures the\n // shared platform API, and integrations routing is independent of it.\n const integrationsApiUrl = process.env.MASTRA_INTEGRATIONS_API_URL?.trim() || resolveIntegrationsUrl();\n // MASTRA_PLATFORM_ACCESS_TOKEN is the credential Mastra Platform injects\n // into deployed projects; MASTRA_PLATFORM_SECRET_KEY is the org secret key\n // written by project scaffolding. The platform API accepts both forms.\n const accessToken =\n process.env.MASTRA_PLATFORM_ACCESS_TOKEN?.trim() || process.env.MASTRA_PLATFORM_SECRET_KEY?.trim();\n if (!accessToken) {\n throw new Error(\n 'Platform integration: missing required environment variable MASTRA_PLATFORM_ACCESS_TOKEN (or MASTRA_PLATFORM_SECRET_KEY).',\n );\n }\n return { baseUrl: normalizeIntegrationsApiUrl(integrationsApiUrl), accessToken };\n}\n\n/**\n * Resolves the integrations API base URL from `MASTRA_PLATFORM_REGION`\n * (case-insensitive `us` or `eu`), falling back to the global default.\n * Unknown region values fall through to the global default.\n */\nfunction resolveIntegrationsUrl(): string {\n const region = process.env.MASTRA_PLATFORM_REGION?.trim().toLowerCase();\n if (region === 'us' || region === 'eu') return REGIONAL_INTEGRATIONS_URLS[region];\n return DEFAULT_INTEGRATIONS_URL;\n}\n\n/**\n * Normalizes an integrations API URL to a bare origin. Callers pass fully\n * versioned paths (`/v1/server/...`, `/v2/...`), so a trailing `/v1` — as in\n * legacy platform API URLs like `https://platform.mastra.ai/v1` — is stripped\n * to avoid duplicated version segments.\n */\nfunction normalizeIntegrationsApiUrl(integrationsApiUrl: string): string {\n return integrationsApiUrl.replace(/\\/+$/, '').replace(/\\/v1$/, '');\n}\n\nexport class PlatformApiError extends Error {\n readonly status: number;\n readonly retryAfterSeconds: number | null;\n\n constructor(message: string, status: number, retryAfterSeconds: number | null = null) {\n super(message);\n this.name = 'PlatformApiError';\n this.status = status;\n this.retryAfterSeconds = retryAfterSeconds;\n }\n}\n\nexport class PlatformApiClient {\n readonly #baseUrl: string;\n readonly #accessToken: string;\n readonly #fetch: typeof fetch;\n\n constructor(config: PlatformApiClientConfig) {\n const missing = ['baseUrl', 'accessToken'].filter(field => !config[field as keyof PlatformApiClientConfig]);\n if (missing.length > 0) {\n throw new Error(`Platform integration: missing required config field(s): ${missing.join(', ')}.`);\n }\n this.#baseUrl = config.baseUrl.replace(/\\/+$/, '');\n this.#accessToken = config.accessToken;\n this.#fetch = config.fetchImpl ?? globalThis.fetch;\n }\n\n async request<T>(\n method: string,\n path: string,\n body?: unknown,\n options?: { signal?: AbortSignal; actingUserId?: string },\n ): Promise<T> {\n const response = await this.#send(method, path, body, options);\n if (!response.ok) {\n const message = redact(await extractError(response), this.#accessToken);\n const retryAfterSeconds = parseRetryAfter(response.headers.get('retry-after'));\n logPlatformError('Platform API request failed', {\n method,\n path,\n status: response.status,\n retryAfterSeconds,\n message,\n });\n throw new PlatformApiError(message, response.status, retryAfterSeconds);\n }\n if (response.status === 204) return undefined as T;\n return (await response.json()) as T;\n }\n\n async requestRedirect(method: string, path: string, options?: { signal?: AbortSignal }): Promise<string> {\n const response = await this.#send(method, path, undefined, options, 'manual');\n if (response.status >= 300 && response.status < 400) {\n const location = response.headers.get('location');\n if (location) return location;\n }\n if (!response.ok) {\n const message = redact(await extractError(response), this.#accessToken);\n const retryAfterSeconds = parseRetryAfter(response.headers.get('retry-after'));\n logPlatformError('Platform API redirect request failed', {\n method,\n path,\n status: response.status,\n retryAfterSeconds,\n message,\n });\n throw new PlatformApiError(message, response.status, retryAfterSeconds);\n }\n logPlatformError('Platform API request did not return a redirect', { method, path, status: response.status });\n throw new PlatformApiError('Platform API request did not return a redirect.', response.status);\n }\n\n async #send(\n method: string,\n path: string,\n body?: unknown,\n options?: { signal?: AbortSignal; actingUserId?: string },\n redirect?: RequestInit['redirect'],\n ): Promise<Response> {\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${this.#accessToken}`,\n };\n // Acting end-user for platform GitHub writes: the platform resolves this\n // user's GitHub OAuth connection (org-scoped) so issues/PRs are authored\n // by the human instead of the App bot. Ignored by older platforms.\n if (options?.actingUserId) {\n headers['x-acting-user-id'] = options.actingUserId;\n }\n const timeoutSignal = AbortSignal.timeout(15_000);\n const init: RequestInit = {\n method,\n headers,\n redirect,\n signal: options?.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal,\n };\n if (body !== undefined) {\n headers['content-type'] = 'application/json';\n init.body = JSON.stringify(body);\n }\n\n try {\n return await this.#fetch(`${this.#baseUrl}${path}`, init);\n } catch (error) {\n if (error instanceof Error && error.message.includes(this.#accessToken)) {\n const redacted = new Error(redact(error.message, this.#accessToken));\n redacted.name = error.name;\n logPlatformError('Platform API transport error', {\n method,\n path,\n name: redacted.name,\n message: redacted.message,\n });\n throw redacted;\n }\n logPlatformError('Platform API transport error', {\n method,\n path,\n name: error instanceof Error ? error.name : undefined,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n }\n}\n\nasync function extractError(response: Response): Promise<string> {\n try {\n const data = (await response.clone().json()) as Record<string, unknown>;\n for (const field of ['detail', 'error', 'title']) {\n if (typeof data[field] === 'string' && data[field]) return data[field];\n }\n } catch {\n // Fall through to the status-based message.\n }\n return `Platform API request failed (${response.status})`;\n}\n\nfunction redact(message: string, accessToken: string): string {\n return message.split(accessToken).join('[REDACTED]');\n}\n\nexport function logPlatformInfo(message: string, fields?: Record<string, unknown>): void {\n writePlatformLog('info', message, fields);\n}\n\nexport function logPlatformWarn(message: string, fields?: Record<string, unknown>): void {\n writePlatformLog('warn', message, fields);\n}\n\nexport function logPlatformError(message: string, fields?: Record<string, unknown>): void {\n writePlatformLog('error', message, fields);\n}\n\nfunction writePlatformLog(level: 'info' | 'warn' | 'error', message: string, fields?: Record<string, unknown>): void {\n const metadata = fields ? ` ${JSON.stringify(stripUndefined(fields))}` : '';\n process.stderr.write(`[Mastra Factory] ${level.toUpperCase()} ${message}${metadata}\\n`);\n}\n\nfunction stripUndefined(fields: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));\n}\n\nfunction parseRetryAfter(value: string | null): number | null {\n if (!value) return null;\n const seconds = Number.parseInt(value, 10);\n return Number.isSafeInteger(seconds) && seconds >= 0 ? seconds : null;\n}\n"],"mappings":";AAMA,MAAM,2BAA2B;AACjC,MAAM,6BAA0D;CAC9D,IAAI;CACJ,IAAI;AACN;AAEA,SAAgB,iCAA0D;CAKxE,MAAM,qBAAqB,QAAQ,IAAI,6BAA6B,KAAK,KAAK,uBAAuB;CAIrG,MAAM,cACJ,QAAQ,IAAI,8BAA8B,KAAK,KAAK,QAAQ,IAAI,4BAA4B,KAAK;CACnG,IAAI,CAAC,aACH,MAAM,IAAI,MACR,2HACF;CAEF,OAAO;EAAE,SAAS,4BAA4B,kBAAkB;EAAG;CAAY;AACjF;;;;;;AAOA,SAAS,yBAAiC;CACxC,MAAM,SAAS,QAAQ,IAAI,wBAAwB,KAAK,CAAC,CAAC,YAAY;CACtE,IAAI,WAAW,QAAQ,WAAW,MAAM,OAAO,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AO,EAAE;CACzC,OAAO,OAAO,cAAc,OAAO,KAAK,WAAW,IAAI,UAAU;AACnE"}
1
+ {"version":3,"file":"api-client.js","names":["#baseUrl","#accessToken","#projectId","#fetch","#send"],"sources":["../../../src/integrations/platform/api-client.ts"],"sourcesContent":["export interface PlatformApiClientConfig {\n baseUrl: string;\n accessToken: string;\n /**\n * Mastra project this deployment belongs to. Sent as `x-mastra-project-id`\n * so the platform can attribute proxied provider activity to the project;\n * the platform strips the header before forwarding anything upstream.\n */\n projectId?: string;\n fetchImpl?: typeof fetch;\n}\n\nconst DEFAULT_INTEGRATIONS_URL = 'https://integrations.mastra.ai';\nconst REGIONAL_INTEGRATIONS_URLS: Record<'us' | 'eu', string> = {\n us: 'https://integrations.us.mastra.ai',\n eu: 'https://integrations.eu.mastra.ai',\n};\n\nexport function platformApiClientConfigFromEnv(): PlatformApiClientConfig {\n // MASTRA_INTEGRATIONS_API_URL is the dedicated override for the\n // integrations service and takes precedence over MASTRA_PLATFORM_REGION.\n // MASTRA_SHARED_API_URL is deliberately not consulted: it configures the\n // shared platform API, and integrations routing is independent of it.\n const integrationsApiUrl = process.env.MASTRA_INTEGRATIONS_API_URL?.trim() || resolveIntegrationsUrl();\n // MASTRA_PLATFORM_ACCESS_TOKEN is the credential Mastra Platform injects\n // into deployed projects; MASTRA_PLATFORM_SECRET_KEY is the org secret key\n // written by project scaffolding. The platform API accepts both forms.\n const accessToken =\n process.env.MASTRA_PLATFORM_ACCESS_TOKEN?.trim() || process.env.MASTRA_PLATFORM_SECRET_KEY?.trim();\n if (!accessToken) {\n throw new Error(\n 'Platform integration: missing required environment variable MASTRA_PLATFORM_ACCESS_TOKEN (or MASTRA_PLATFORM_SECRET_KEY).',\n );\n }\n const projectId = process.env.MASTRA_PROJECT_ID?.trim();\n return {\n baseUrl: normalizeIntegrationsApiUrl(integrationsApiUrl),\n accessToken,\n ...(projectId ? { projectId } : {}),\n };\n}\n\n/**\n * Resolves the integrations API base URL from `MASTRA_PLATFORM_REGION`\n * (case-insensitive `us` or `eu`), falling back to the global default.\n * Unknown region values fall through to the global default.\n */\nfunction resolveIntegrationsUrl(): string {\n const region = process.env.MASTRA_PLATFORM_REGION?.trim().toLowerCase();\n if (region === 'us' || region === 'eu') return REGIONAL_INTEGRATIONS_URLS[region];\n return DEFAULT_INTEGRATIONS_URL;\n}\n\n/**\n * Normalizes an integrations API URL to a bare origin. Callers pass fully\n * versioned paths (`/v1/server/...`, `/v2/...`), so a trailing `/v1` — as in\n * legacy platform API URLs like `https://platform.mastra.ai/v1` — is stripped\n * to avoid duplicated version segments.\n */\nfunction normalizeIntegrationsApiUrl(integrationsApiUrl: string): string {\n return integrationsApiUrl.replace(/\\/+$/, '').replace(/\\/v1$/, '');\n}\n\nexport class PlatformApiError extends Error {\n readonly status: number;\n readonly retryAfterSeconds: number | null;\n\n constructor(message: string, status: number, retryAfterSeconds: number | null = null) {\n super(message);\n this.name = 'PlatformApiError';\n this.status = status;\n this.retryAfterSeconds = retryAfterSeconds;\n }\n}\n\nexport class PlatformApiClient {\n readonly #baseUrl: string;\n readonly #accessToken: string;\n readonly #projectId: string | null;\n readonly #fetch: typeof fetch;\n\n constructor(config: PlatformApiClientConfig) {\n const missing = ['baseUrl', 'accessToken'].filter(field => !config[field as keyof PlatformApiClientConfig]);\n if (missing.length > 0) {\n throw new Error(`Platform integration: missing required config field(s): ${missing.join(', ')}.`);\n }\n this.#baseUrl = config.baseUrl.replace(/\\/+$/, '');\n this.#accessToken = config.accessToken;\n this.#projectId = config.projectId?.trim() || null;\n this.#fetch = config.fetchImpl ?? globalThis.fetch;\n }\n\n async request<T>(\n method: string,\n path: string,\n body?: unknown,\n options?: { signal?: AbortSignal; actingUserId?: string },\n ): Promise<T> {\n const response = await this.#send(method, path, body, options);\n if (!response.ok) {\n const message = redact(await extractError(response), this.#accessToken);\n const retryAfterSeconds = parseRetryAfter(response.headers.get('retry-after'));\n logPlatformError('Platform API request failed', {\n method,\n path,\n status: response.status,\n retryAfterSeconds,\n message,\n });\n throw new PlatformApiError(message, response.status, retryAfterSeconds);\n }\n if (response.status === 204) return undefined as T;\n return (await response.json()) as T;\n }\n\n async requestRedirect(method: string, path: string, options?: { signal?: AbortSignal }): Promise<string> {\n const response = await this.#send(method, path, undefined, options, 'manual');\n if (response.status >= 300 && response.status < 400) {\n const location = response.headers.get('location');\n if (location) return location;\n }\n if (!response.ok) {\n const message = redact(await extractError(response), this.#accessToken);\n const retryAfterSeconds = parseRetryAfter(response.headers.get('retry-after'));\n logPlatformError('Platform API redirect request failed', {\n method,\n path,\n status: response.status,\n retryAfterSeconds,\n message,\n });\n throw new PlatformApiError(message, response.status, retryAfterSeconds);\n }\n logPlatformError('Platform API request did not return a redirect', { method, path, status: response.status });\n throw new PlatformApiError('Platform API request did not return a redirect.', response.status);\n }\n\n async #send(\n method: string,\n path: string,\n body?: unknown,\n options?: { signal?: AbortSignal; actingUserId?: string },\n redirect?: RequestInit['redirect'],\n ): Promise<Response> {\n const headers: Record<string, string> = {\n accept: 'application/json',\n authorization: `Bearer ${this.#accessToken}`,\n };\n // Project attribution for proxied provider calls. Org-scoped machine\n // tokens carry no project claim, so without this header the platform\n // records proxy activity with no project.\n if (this.#projectId) {\n headers['x-mastra-project-id'] = this.#projectId;\n }\n // Acting end-user for platform GitHub writes: the platform resolves this\n // user's GitHub OAuth connection (org-scoped) so issues/PRs are authored\n // by the human instead of the App bot. Ignored by older platforms.\n if (options?.actingUserId) {\n headers['x-acting-user-id'] = options.actingUserId;\n }\n const timeoutSignal = AbortSignal.timeout(15_000);\n const init: RequestInit = {\n method,\n headers,\n redirect,\n signal: options?.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal,\n };\n if (body !== undefined) {\n headers['content-type'] = 'application/json';\n init.body = JSON.stringify(body);\n }\n\n try {\n return await this.#fetch(`${this.#baseUrl}${path}`, init);\n } catch (error) {\n if (error instanceof Error && error.message.includes(this.#accessToken)) {\n const redacted = new Error(redact(error.message, this.#accessToken));\n redacted.name = error.name;\n logPlatformError('Platform API transport error', {\n method,\n path,\n name: redacted.name,\n message: redacted.message,\n });\n throw redacted;\n }\n logPlatformError('Platform API transport error', {\n method,\n path,\n name: error instanceof Error ? error.name : undefined,\n message: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }\n }\n}\n\nasync function extractError(response: Response): Promise<string> {\n try {\n const data = (await response.clone().json()) as Record<string, unknown>;\n for (const field of ['detail', 'error', 'title']) {\n if (typeof data[field] === 'string' && data[field]) return data[field];\n }\n } catch {\n // Fall through to the status-based message.\n }\n return `Platform API request failed (${response.status})`;\n}\n\nfunction redact(message: string, accessToken: string): string {\n return message.split(accessToken).join('[REDACTED]');\n}\n\nexport function logPlatformInfo(message: string, fields?: Record<string, unknown>): void {\n writePlatformLog('info', message, fields);\n}\n\nexport function logPlatformWarn(message: string, fields?: Record<string, unknown>): void {\n writePlatformLog('warn', message, fields);\n}\n\nexport function logPlatformError(message: string, fields?: Record<string, unknown>): void {\n writePlatformLog('error', message, fields);\n}\n\nfunction writePlatformLog(level: 'info' | 'warn' | 'error', message: string, fields?: Record<string, unknown>): void {\n const metadata = fields ? ` ${JSON.stringify(stripUndefined(fields))}` : '';\n process.stderr.write(`[Mastra Factory] ${level.toUpperCase()} ${message}${metadata}\\n`);\n}\n\nfunction stripUndefined(fields: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));\n}\n\nfunction parseRetryAfter(value: string | null): number | null {\n if (!value) return null;\n const seconds = Number.parseInt(value, 10);\n return Number.isSafeInteger(seconds) && seconds >= 0 ? seconds : null;\n}\n"],"mappings":";AAYA,MAAM,2BAA2B;AACjC,MAAM,6BAA0D;CAC9D,IAAI;CACJ,IAAI;AACN;AAEA,SAAgB,iCAA0D;CAKxE,MAAM,qBAAqB,QAAQ,IAAI,6BAA6B,KAAK,KAAK,uBAAuB;CAIrG,MAAM,cACJ,QAAQ,IAAI,8BAA8B,KAAK,KAAK,QAAQ,IAAI,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,CAAC,MAAM,EAAE,MAAM,CAQrB;IA4JF,OAAO,CAAC,GAAG,EAAE,kBAAkB,GAAG,YAAY,EAAE;IAchD;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,kBAAkB,GAAG,QAAQ,EAAE;IAU3C,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGvC"}
@@ -176,6 +176,7 @@ var PlatformIncidentioIntegration = class {
176
176
  api: new IncidentioApiClient({
177
177
  baseUrl: `${this.#clientConfig.baseUrl.replace(/\/+$/, "")}/v2/connections/${encodeURIComponent(connectionId)}/proxy`,
178
178
  accessToken: this.#clientConfig.accessToken,
179
+ ...this.#clientConfig.projectId ? { projectId: this.#clientConfig.projectId } : {},
179
180
  ...this.#clientConfig.fetchImpl ? { fetchImpl: this.#clientConfig.fetchImpl } : {}
180
181
  }),
181
182
  connection: incidentioConnection(connectionId)
@@ -1 +1 @@
1
- {"version":3,"file":"integration.js","names":["#clientConfig","#platformClient","#endpointHost","#intakeByConnectionId","#rules","#orgIdByResourceId","#projects","#auth","#intakeStorage","#activeConnections","#connectionContexts","#connectionIntake","#intakeForConnection","#resolveIntakeDispatch","#listSources","#listItems","#listIssues","#getIssue","#createComment","#updateIssue","#scopeResolvedDispatch","#withBaseSource"],"sources":["../../../../src/integrations/platform/incidentio/integration.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { MastraWorker } from '@mastra/core/worker';\n\nimport type { IntegrationConnection } from '../../../capabilities/connection.js';\nimport type {\n CreateIntakeCommentInput,\n CreatedIntakeComment,\n GetIntakeIssueInput,\n Intake,\n IntakeIssue,\n IntakeIssueDetail,\n IntakeItemPage,\n IntakeSource,\n ListIntakeIssuesInput,\n ListIntakeItemsInput,\n ResolveIntakeDispatchInput,\n ResolvedIntakeDispatch,\n UpdateIntakeIssueInput,\n} from '../../../capabilities/intake.js';\nimport type { RouteAuth } from '../../../routes/route.js';\nimport type { IntakeStorage } from '../../../storage/domains/intake/base.js';\nimport type { FactoryProjectsStorage } from '../../../storage/domains/projects/base.js';\nimport type { FactoryIntegration, IntegrationContext, IntegrationTools } from '../../base.js';\nimport { buildIncidentioAgentTools } from '../../incidentio/agent-tools.js';\nimport { IncidentioApiClient, IncidentioApiError } from '../../incidentio/api.js';\nimport { resolveIncidentioRules } from '../../incidentio/default-rules.js';\nimport type { IncidentioEventRules, IncidentioRuleOverrides } from '../../incidentio/default-rules.js';\nimport {\n createIncidentioIntake,\n INCIDENTIO_FOLLOW_UPS_SOURCE_ID,\n INCIDENTIO_INCIDENTS_SOURCE_ID,\n} from '../../incidentio/intake.js';\nimport { attachIncidentioIssueReconciler } from '../../incidentio/issue-reconciler.js';\nimport {\n incidentioReconciliationEnabled,\n incidentioReconciliationInterval,\n} from '../../incidentio/reconciliation-config.js';\nimport { buildIncidentioRoutes } from '../../incidentio/routes.js';\nimport { attachIncidentioRules } from '../../incidentio/rules.js';\nimport { IssueReconcileWorker } from '../../issue-reconcile-worker.js';\nimport { PlatformApiClient, platformApiClientConfigFromEnv, type PlatformApiClientConfig } from '../api-client.js';\n\nexport interface PlatformIncidentioIntegrationConfig {\n clientConfig?: PlatformApiClientConfig;\n /** Per-event replacements for the default Factory incident.io rules. */\n rules?: IncidentioRuleOverrides;\n}\n\n/**\n * Provider config key registered for incident.io in Mastra Platform's\n * integrations catalog. Connections are discovered at runtime — no\n * deploy-time connection ID wiring.\n */\nconst PLATFORM_INCIDENTIO_PROVIDER_CONFIG_KEY = 'incident-io';\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst CONNECTION_TOKEN_PREFIX = 'incidentio-connection:';\nconst SCOPED_SOURCE_PREFIX = 'incidentio-source:';\nconst BASE_SOURCE_IDS = [INCIDENTIO_INCIDENTS_SOURCE_ID, INCIDENTIO_FOLLOW_UPS_SOURCE_ID] as const;\n\ninterface PlatformIntegrationConnection {\n id: string;\n integrationId: string;\n status: 'active' | 'needs_reauth';\n accountLabel: string | null;\n}\n\ninterface ScopedSourceId {\n connectionId: string;\n sourceId: string;\n}\n\n/** An intake plus the exact inner connection it was resolved for, so operations discover active connections once. */\ninterface ResolvedIncidentioIntake {\n intake: Intake;\n connection: IntegrationConnection;\n}\n\ninterface AggregatePageCursor {\n /** Connection ID the cursor points at; keyed by ID so the active list can change between pages. */\n connectionId: string;\n inner?: string;\n}\n\nexport function encodeScopedSourceId(connectionId: string, sourceId: string): string {\n return `${SCOPED_SOURCE_PREFIX}${Buffer.from(JSON.stringify({ connectionId, sourceId })).toString('base64url')}`;\n}\n\nexport function decodeScopedSourceId(value: string): ScopedSourceId | null {\n if (!value.startsWith(SCOPED_SOURCE_PREFIX)) return null;\n try {\n const parsed = JSON.parse(\n Buffer.from(value.slice(SCOPED_SOURCE_PREFIX.length), 'base64url').toString('utf8'),\n ) as Record<string, unknown>;\n return typeof parsed.connectionId === 'string' && typeof parsed.sourceId === 'string'\n ? { connectionId: parsed.connectionId, sourceId: parsed.sourceId }\n : null;\n } catch {\n return null;\n }\n}\n\nfunction incidentioConnection(connectionId: string): IntegrationConnection {\n return { type: 'oauth', accessToken: `${CONNECTION_TOKEN_PREFIX}${connectionId}` };\n}\n\nfunction connectionIdFromConnection(connection: IntegrationConnection): string | null {\n if (connection.type !== 'oauth' || !connection.accessToken.startsWith(CONNECTION_TOKEN_PREFIX)) return null;\n return connection.accessToken.slice(CONNECTION_TOKEN_PREFIX.length) || null;\n}\n\n/**\n * Base (per-connection) source ids selected for a connection. Scoped ids\n * select their own connection; legacy unscoped ids (`incidentio:incidents`)\n * from pre-discovery deploys apply to every connection.\n */\nfunction baseSourceIdsFor(connectionId: string, sourceIds: string[]): string[] {\n const selected = new Set<string>();\n for (const sourceId of sourceIds) {\n const scoped = decodeScopedSourceId(sourceId);\n if (scoped) {\n if (scoped.connectionId === connectionId) selected.add(scoped.sourceId);\n continue;\n }\n if ((BASE_SOURCE_IDS as readonly string[]).includes(sourceId)) selected.add(sourceId);\n }\n return [...selected];\n}\n\nfunction encodePageCursor(cursor: AggregatePageCursor): string {\n return Buffer.from(JSON.stringify(cursor)).toString('base64url');\n}\n\nfunction decodePageCursor(cursor: string | undefined): AggregatePageCursor | null {\n if (!cursor) return null;\n try {\n const parsed = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8')) as Partial<AggregatePageCursor>;\n if (typeof parsed.connectionId !== 'string' || !parsed.connectionId) return null;\n return {\n connectionId: parsed.connectionId,\n ...(typeof parsed.inner === 'string' && parsed.inner ? { inner: parsed.inner } : {}),\n };\n } catch {\n return null;\n }\n}\n\ninterface IncidentioConnectionContext {\n connection: PlatformIntegrationConnection;\n intake: Intake;\n}\n\nexport class PlatformIncidentioIntegration implements FactoryIntegration {\n readonly id = 'incidentio';\n readonly #clientConfig: PlatformApiClientConfig;\n readonly #platformClient: PlatformApiClient;\n readonly #endpointHost: string;\n readonly #intakeByConnectionId = new Map<string, Intake>();\n readonly #rules: IncidentioEventRules;\n\n /** Bound once by the factory via `initialize()` before any surface is used. */\n #projects: FactoryProjectsStorage | undefined;\n #auth: RouteAuth | undefined;\n #intakeStorage: IntakeStorage | undefined;\n readonly #orgIdByResourceId = new Map<string, string | null>();\n\n constructor(config: PlatformIncidentioIntegrationConfig = {}) {\n this.#clientConfig = config.clientConfig ?? platformApiClientConfigFromEnv();\n this.#platformClient = new PlatformApiClient(this.#clientConfig);\n this.#endpointHost = new URL(this.#clientConfig.baseUrl).host;\n this.#rules = resolveIncidentioRules(config.rules);\n }\n\n /** Event rules driving automatic follow-up materialization and close handling. */\n get rules(): IncidentioEventRules {\n return this.#rules;\n }\n\n initialize({\n projects,\n auth,\n intake,\n }: {\n projects: FactoryProjectsStorage;\n auth: RouteAuth;\n intake: IntakeStorage;\n }): void {\n this.#projects = projects;\n this.#auth = auth;\n this.#intakeStorage = intake;\n }\n\n /** Cross-integration intake selection/binding domain — agent-tool authorization. */\n get intakeStorage(): IntakeStorage {\n if (!this.#intakeStorage) {\n throw new Error('PlatformIncidentioIntegration is not initialized — the factory binds storage during prepare().');\n }\n return this.#intakeStorage;\n }\n\n /** Factory projects domain — maps a session's resourceId to its owning org. */\n get projects(): FactoryProjectsStorage {\n if (!this.#projects) {\n throw new Error('PlatformIncidentioIntegration is not initialized — the factory binds storage during prepare().');\n }\n return this.#projects;\n }\n\n /** Whether the host runs with web auth enabled; every surface is inert without it. */\n get authEnabled(): boolean {\n return this.#auth?.enabled() ?? false;\n }\n\n /**\n * Map a session's resourceId (the factory project id) to its owning org.\n * Same caching semantics as the Jira integration: definitive misses are\n * cached, transient database failures are not.\n */\n async resolveOrgId(resourceId: string): Promise<string | null> {\n const cached = this.#orgIdByResourceId.get(resourceId);\n if (cached !== undefined) return cached;\n if (!UUID_RE.test(resourceId)) {\n this.#orgIdByResourceId.set(resourceId, null);\n return null;\n }\n let orgId: string | null;\n try {\n await this.projects.ensureReady();\n const project = await this.projects.getById({ id: resourceId });\n orgId = project?.orgId ?? null;\n } catch {\n // Transient database failure: skip the tools for this request but don't\n // cache the miss, so the next request retries the lookup.\n return null;\n }\n this.#orgIdByResourceId.set(resourceId, orgId);\n return orgId;\n }\n\n /**\n * Org-scoped agent tools: the read-only follow-up detail tool for sessions\n * whose resource is a factory project with an active Platform-managed\n * incident.io connection.\n */\n async agentTools(args: { requestContext: RequestContext }): Promise<IntegrationTools> {\n if (!(await this.hasActiveConnections())) return {};\n return buildIncidentioAgentTools({ requestContext: args.requestContext, incidentio: this });\n }\n\n async listConnections(): Promise<PlatformIntegrationConnection[]> {\n const providerKey = encodeURIComponent(PLATFORM_INCIDENTIO_PROVIDER_CONFIG_KEY);\n const result = await this.#platformClient.request<{ connections: PlatformIntegrationConnection[] }>(\n 'GET',\n `/v2/connections?providerKey=${providerKey}`,\n );\n return result.connections;\n }\n\n async hasActiveConnections(): Promise<boolean> {\n return (await this.#activeConnections()).length > 0;\n }\n\n clearCaches(): void {\n this.#intakeByConnectionId.clear();\n this.#orgIdByResourceId.clear();\n }\n\n async #activeConnections(): Promise<PlatformIntegrationConnection[]> {\n const connections = (await this.listConnections()).filter(connection => connection.status === 'active');\n // Stable ordering keeps aggregate page cursors valid across requests.\n return connections.slice().sort((left, right) => left.id.localeCompare(right.id));\n }\n\n #connectionIntake(connectionId: string): Intake {\n const cached = this.#intakeByConnectionId.get(connectionId);\n if (cached) return cached;\n const proxyBaseUrl = `${this.#clientConfig.baseUrl.replace(/\\/+$/, '')}/v2/connections/${encodeURIComponent(\n connectionId,\n )}/proxy`;\n const intake = createIncidentioIntake({\n api: new IncidentioApiClient({\n baseUrl: proxyBaseUrl,\n accessToken: this.#clientConfig.accessToken,\n ...(this.#clientConfig.fetchImpl ? { fetchImpl: this.#clientConfig.fetchImpl } : {}),\n }),\n connection: incidentioConnection(connectionId),\n });\n this.#intakeByConnectionId.set(connectionId, intake);\n return intake;\n }\n\n async #connectionContexts(): Promise<IncidentioConnectionContext[]> {\n return (await this.#activeConnections()).map(connection => ({\n connection,\n intake: this.#connectionIntake(connection.id),\n }));\n }\n\n /**\n * Resolve the intake for an explicit connection token, or fall back to the\n * sole active connection so legacy single-connection callers keep working.\n *\n * A caller-supplied connection token is only a claim: the id it carries\n * must match a connection the deployment actually discovered as active\n * before any proxy request is minted with the Platform credential.\n */\n async #intakeForConnection(connection: IntegrationConnection): Promise<ResolvedIncidentioIntake> {\n const connectionId = connectionIdFromConnection(connection);\n const active = await this.#activeConnections();\n if (connectionId) {\n if (!active.some(candidate => candidate.id === connectionId)) {\n throw new IncidentioApiError('incident.io connection is unavailable or requires reauthentication.', 401);\n }\n return { intake: this.#connectionIntake(connectionId), connection: incidentioConnection(connectionId) };\n }\n if (active.length === 1) {\n const soleId = active[0]!.id;\n return { intake: this.#connectionIntake(soleId), connection: incidentioConnection(soleId) };\n }\n throw new IncidentioApiError(\n active.length === 0\n ? 'incident.io connection is unavailable or requires reauthentication.'\n : 'incident.io request must identify a connection when multiple accounts are connected.',\n active.length === 0 ? 401 : 400,\n );\n }\n\n readonly intake: Intake = {\n resolveIntakeDispatch: input => this.#resolveIntakeDispatch(input),\n listSources: () => this.#listSources(),\n listItems: input => this.#listItems(input),\n listIssues: input => this.#listIssues(input),\n getIssue: input => this.#getIssue(input),\n createComment: input => this.#createComment(input),\n updateIssue: input => this.#updateIssue(input),\n };\n\n async #resolveIntakeDispatch(input: ResolveIntakeDispatchInput): Promise<ResolvedIntakeDispatch | null> {\n if (input.externalSource.type !== 'issue') return null;\n const externalId = input.externalSource.externalId;\n const contexts = await this.#connectionContexts();\n if (contexts.length === 0) return null;\n if (contexts.length === 1) {\n const resolved = await contexts[0]!.intake.resolveIntakeDispatch?.(input);\n return resolved ? this.#scopeResolvedDispatch(contexts[0]!.connection.id, resolved) : null;\n }\n // Multiple accounts: item references carry no connection id, so probe\n // each connection for the item — first account that knows it wins\n // (incident.io ids are globally unique ULIDs, collisions are not a\n // practical concern and this capability is read-mostly).\n let firstError: unknown;\n for (const context of contexts) {\n try {\n const issue = await context.intake.getIssue({\n connection: incidentioConnection(context.connection.id),\n issueId: externalId,\n });\n if (!issue) continue;\n const resolved = await context.intake.resolveIntakeDispatch?.(input);\n return resolved ? this.#scopeResolvedDispatch(context.connection.id, resolved) : null;\n } catch (error) {\n if (error instanceof IncidentioApiError && error.status === 404) continue;\n firstError ??= error;\n }\n }\n if (firstError !== undefined) throw firstError;\n return null;\n }\n\n #scopeResolvedDispatch(connectionId: string, resolved: ResolvedIntakeDispatch): ResolvedIntakeDispatch {\n return {\n ...resolved,\n connection: incidentioConnection(connectionId),\n ...(resolved.sourceId ? { sourceId: encodeScopedSourceId(connectionId, resolved.sourceId) } : {}),\n };\n }\n\n async #listSources(): Promise<IntakeSource[]> {\n const contexts = await this.#connectionContexts();\n const sources: IntakeSource[] = [];\n for (const context of contexts) {\n const account = context.connection.accountLabel;\n const inner = await context.intake.listSources({ orgId: '', userId: '' });\n for (const source of inner) {\n sources.push({\n ...source,\n id: encodeScopedSourceId(context.connection.id, source.id),\n name: contexts.length > 1 && account ? `${source.name} (${account})` : source.name,\n metadata: {\n ...(source.metadata ?? {}),\n connectionId: context.connection.id,\n ...(account ? { account } : {}),\n },\n });\n }\n }\n return sources;\n }\n\n async #listItems(input: ListIntakeItemsInput): Promise<IntakeItemPage> {\n if (input.sourceIds.length === 0) return { items: [], nextCursor: null };\n const contexts = await this.#connectionContexts();\n const cursor = decodePageCursor(input.cursor);\n\n // Resume by connection ID: the active list can change between pages, so an\n // index would replay or skip connections. When the cursor's connection is\n // gone, resume at its sorted successor and drop the inner cursor.\n let startIndex = 0;\n let exactMatch = false;\n if (cursor) {\n const index = contexts.findIndex(context => context.connection.id === cursor.connectionId);\n exactMatch = index !== -1;\n startIndex = exactMatch\n ? index\n : contexts.findIndex(context => context.connection.id.localeCompare(cursor.connectionId) > 0);\n if (startIndex === -1) return { items: [], nextCursor: null };\n }\n\n for (let index = startIndex; index < contexts.length; index++) {\n const context = contexts[index]!;\n const baseSourceIds = baseSourceIdsFor(context.connection.id, input.sourceIds);\n if (baseSourceIds.length === 0) continue;\n const page = await context.intake.listItems({\n orgId: input.orgId,\n userId: input.userId,\n sourceIds: baseSourceIds,\n ...(index === startIndex && exactMatch && cursor?.inner ? { cursor: cursor.inner } : {}),\n });\n const nextCursor = page.nextCursor\n ? encodePageCursor({ connectionId: context.connection.id, inner: page.nextCursor })\n : index + 1 < contexts.length\n ? encodePageCursor({ connectionId: contexts[index + 1]!.connection.id })\n : null;\n return {\n items: page.items.map(item => ({\n ...item,\n sourceId: encodeScopedSourceId(context.connection.id, item.sourceId),\n metadata: { ...(item.metadata ?? {}), connectionId: context.connection.id },\n })),\n nextCursor,\n };\n }\n return { items: [], nextCursor: null };\n }\n\n async #listIssues(input: ListIntakeIssuesInput): Promise<{ issues: IntakeIssue[]; nextCursor: string | null }> {\n const resolved = await this.#intakeForConnection(input.connection);\n // Scope to the connection that was actually resolved (which may be the\n // sole-connection fallback), so a source id scoped to a different\n // connection is dropped instead of being read against this one.\n const connectionId = connectionIdFromConnection(resolved.connection);\n const baseSourceIds = connectionId\n ? baseSourceIdsFor(connectionId, input.sourceIds)\n : input.sourceIds.map(sourceId => decodeScopedSourceId(sourceId)?.sourceId ?? sourceId);\n return resolved.intake.listIssues({\n ...input,\n connection: resolved.connection,\n sourceIds: baseSourceIds,\n });\n }\n\n async #getIssue(input: GetIntakeIssueInput): Promise<IntakeIssueDetail | null> {\n const resolved = await this.#intakeForConnection(input.connection);\n return resolved.intake.getIssue({\n ...this.#withBaseSource(input),\n connection: resolved.connection,\n });\n }\n\n async #createComment(input: CreateIntakeCommentInput): Promise<CreatedIntakeComment | null> {\n const resolved = await this.#intakeForConnection(input.connection);\n return resolved.intake.createComment({\n ...this.#withBaseSource(input),\n connection: resolved.connection,\n });\n }\n\n async #updateIssue(input: UpdateIntakeIssueInput): Promise<IntakeIssue | null> {\n const resolved = await this.#intakeForConnection(input.connection);\n return resolved.intake.updateIssue({\n ...this.#withBaseSource(input),\n connection: resolved.connection,\n });\n }\n\n #withBaseSource<T extends { sourceId?: string }>(input: T): T {\n if (!input.sourceId) return input;\n const scoped = decodeScopedSourceId(input.sourceId);\n return scoped ? { ...input, sourceId: scoped.sourceId } : input;\n }\n\n workers(ctx: IntegrationContext): MastraWorker[] {\n if (!incidentioReconciliationEnabled()) return [];\n const reconcile = attachIncidentioIssueReconciler(this, ctx);\n if (!reconcile) return [];\n const intervalMs = incidentioReconciliationInterval();\n return [\n new IssueReconcileWorker({\n integrationId: this.id,\n reconcile,\n ...(intervalMs ? { intervalMs } : {}),\n }),\n ];\n }\n\n /**\n * The integration's HTTP surface: `/web/incidentio/*` Mastra `apiRoutes`\n * (status + follow-up listing/detail for Intake), aggregated across every\n * discovered Platform connection. A board-scoped listing also feeds the\n * incident.io event rules.\n */\n routes(ctx: IntegrationContext): ApiRoute[] {\n return buildIncidentioRoutes({\n incidentio: this,\n mode: 'platform',\n auth: ctx.auth,\n intake: ctx.storage.intake,\n ingestFactoryIssues: attachIncidentioRules(this, ctx),\n });\n }\n\n diagnostics(): Record<string, unknown> {\n return { configured: true, mode: 'platform', endpointHost: this.#endpointHost };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsDA,MAAM,0CAA0C;AAChD,MAAM,UAAU;AAChB,MAAM,0BAA0B;AAChC,MAAM,uBAAuB;AAC7B,MAAM,kBAAkB,CAAC,gCAAgC,+BAA+B;AA0BxF,SAAgB,qBAAqB,cAAsB,UAA0B;CACnF,OAAO,GAAG,uBAAuB,OAAO,KAAK,KAAK,UAAU;EAAE;EAAc;CAAS,CAAC,CAAC,CAAC,CAAC,SAAS,WAAW;AAC/G;AAEA,SAAgB,qBAAqB,OAAsC;CACzE,IAAI,CAAC,MAAM,WAAW,oBAAoB,GAAG,OAAO;CACpD,IAAI;EACF,MAAM,SAAS,KAAK,MAClB,OAAO,KAAK,MAAM,MAAM,EAA2B,GAAG,WAAW,CAAC,CAAC,SAAS,MAAM,CACpF;EACA,OAAO,OAAO,OAAO,iBAAiB,YAAY,OAAO,OAAO,aAAa,WACzE;GAAE,cAAc,OAAO;GAAc,UAAU,OAAO;EAAS,IAC/D;CACN,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,qBAAqB,cAA6C;CACzE,OAAO;EAAE,MAAM;EAAS,aAAa,GAAG,0BAA0B;CAAe;AACnF;AAEA,SAAS,2BAA2B,YAAkD;CACpF,IAAI,WAAW,SAAS,WAAW,CAAC,WAAW,YAAY,WAAW,uBAAuB,GAAG,OAAO;CACvG,OAAO,WAAW,YAAY,MAAM,EAA8B,KAAK;AACzE;;;;;;AAOA,SAAS,iBAAiB,cAAsB,WAA+B;CAC7E,MAAM,2BAAW,IAAI,IAAY;CACjC,KAAK,MAAM,YAAY,WAAW;EAChC,MAAM,SAAS,qBAAqB,QAAQ;EAC5C,IAAI,QAAQ;GACV,IAAI,OAAO,iBAAiB,cAAc,SAAS,IAAI,OAAO,QAAQ;GACtE;EACF;EACA,IAAK,gBAAsC,SAA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AAM,KAAKP,qBAAqB,MAAM,UAAU;EACjE,OAAO,SAAS,OAAO,YAAY;GACjC,GAAG,KAAKS,gBAAgB,KAAK;GAC7B,YAAY,SAAS;EACvB,CAAC;CACH;CAEA,gBAAiD,OAAa;EAC5D,IAAI,CAAC,MAAM,UAAU,OAAO;EAC5B,MAAM,SAAS,qBAAqB,MAAM,QAAQ;EAClD,OAAO,SAAS;GAAE,GAAG;GAAO,UAAU,OAAO;EAAS,IAAI;CAC5D;CAEA,QAAQ,KAAyC;EAC/C,IAAI,CAAC,gCAAgC,GAAG,OAAO,CAAC;EAChD,MAAM,YAAY,gCAAgC,MAAM,GAAG;EAC3D,IAAI,CAAC,WAAW,OAAO,CAAC;EACxB,MAAM,aAAa,iCAAiC;EACpD,OAAO,CACL,IAAI,qBAAqB;GACvB,eAAe,KAAK;GACpB;GACA,GAAI,aAAa,EAAE,WAAW,IAAI,CAAC;EACrC,CAAC,CACH;CACF;;;;;;;CAQA,OAAO,KAAqC;EAC1C,OAAO,sBAAsB;GAC3B,YAAY;GACZ,MAAM;GACN,MAAM,IAAI;GACV,QAAQ,IAAI,QAAQ;GACpB,qBAAqB,sBAAsB,MAAM,GAAG;EACtD,CAAC;CACH;CAEA,cAAuC;EACrC,OAAO;GAAE,YAAY;GAAM,MAAM;GAAY,cAAc,KAAKnB;EAAc;CAChF;AACF"}
1
+ {"version":3,"file":"integration.js","names":["#clientConfig","#platformClient","#endpointHost","#intakeByConnectionId","#rules","#orgIdByResourceId","#projects","#auth","#intakeStorage","#activeConnections","#connectionContexts","#connectionIntake","#intakeForConnection","#resolveIntakeDispatch","#listSources","#listItems","#listIssues","#getIssue","#createComment","#updateIssue","#scopeResolvedDispatch","#withBaseSource"],"sources":["../../../../src/integrations/platform/incidentio/integration.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { MastraWorker } from '@mastra/core/worker';\n\nimport type { IntegrationConnection } from '../../../capabilities/connection.js';\nimport type {\n CreateIntakeCommentInput,\n CreatedIntakeComment,\n GetIntakeIssueInput,\n Intake,\n IntakeIssue,\n IntakeIssueDetail,\n IntakeItemPage,\n IntakeSource,\n ListIntakeIssuesInput,\n ListIntakeItemsInput,\n ResolveIntakeDispatchInput,\n ResolvedIntakeDispatch,\n UpdateIntakeIssueInput,\n} from '../../../capabilities/intake.js';\nimport type { RouteAuth } from '../../../routes/route.js';\nimport type { IntakeStorage } from '../../../storage/domains/intake/base.js';\nimport type { FactoryProjectsStorage } from '../../../storage/domains/projects/base.js';\nimport type { FactoryIntegration, IntegrationContext, IntegrationTools } from '../../base.js';\nimport { buildIncidentioAgentTools } from '../../incidentio/agent-tools.js';\nimport { IncidentioApiClient, IncidentioApiError } from '../../incidentio/api.js';\nimport { resolveIncidentioRules } from '../../incidentio/default-rules.js';\nimport type { IncidentioEventRules, IncidentioRuleOverrides } from '../../incidentio/default-rules.js';\nimport {\n createIncidentioIntake,\n INCIDENTIO_FOLLOW_UPS_SOURCE_ID,\n INCIDENTIO_INCIDENTS_SOURCE_ID,\n} from '../../incidentio/intake.js';\nimport { attachIncidentioIssueReconciler } from '../../incidentio/issue-reconciler.js';\nimport {\n incidentioReconciliationEnabled,\n incidentioReconciliationInterval,\n} from '../../incidentio/reconciliation-config.js';\nimport { buildIncidentioRoutes } from '../../incidentio/routes.js';\nimport { attachIncidentioRules } from '../../incidentio/rules.js';\nimport { IssueReconcileWorker } from '../../issue-reconcile-worker.js';\nimport { PlatformApiClient, platformApiClientConfigFromEnv, type PlatformApiClientConfig } from '../api-client.js';\n\nexport interface PlatformIncidentioIntegrationConfig {\n clientConfig?: PlatformApiClientConfig;\n /** Per-event replacements for the default Factory incident.io rules. */\n rules?: IncidentioRuleOverrides;\n}\n\n/**\n * Provider config key registered for incident.io in Mastra Platform's\n * integrations catalog. Connections are discovered at runtime — no\n * deploy-time connection ID wiring.\n */\nconst PLATFORM_INCIDENTIO_PROVIDER_CONFIG_KEY = 'incident-io';\nconst UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst CONNECTION_TOKEN_PREFIX = 'incidentio-connection:';\nconst SCOPED_SOURCE_PREFIX = 'incidentio-source:';\nconst BASE_SOURCE_IDS = [INCIDENTIO_INCIDENTS_SOURCE_ID, INCIDENTIO_FOLLOW_UPS_SOURCE_ID] as const;\n\ninterface PlatformIntegrationConnection {\n id: string;\n integrationId: string;\n status: 'active' | 'needs_reauth';\n accountLabel: string | null;\n}\n\ninterface ScopedSourceId {\n connectionId: string;\n sourceId: string;\n}\n\n/** An intake plus the exact inner connection it was resolved for, so operations discover active connections once. */\ninterface ResolvedIncidentioIntake {\n intake: Intake;\n connection: IntegrationConnection;\n}\n\ninterface AggregatePageCursor {\n /** Connection ID the cursor points at; keyed by ID so the active list can change between pages. */\n connectionId: string;\n inner?: string;\n}\n\nexport function encodeScopedSourceId(connectionId: string, sourceId: string): string {\n return `${SCOPED_SOURCE_PREFIX}${Buffer.from(JSON.stringify({ connectionId, sourceId })).toString('base64url')}`;\n}\n\nexport function decodeScopedSourceId(value: string): ScopedSourceId | null {\n if (!value.startsWith(SCOPED_SOURCE_PREFIX)) return null;\n try {\n const parsed = JSON.parse(\n Buffer.from(value.slice(SCOPED_SOURCE_PREFIX.length), 'base64url').toString('utf8'),\n ) as Record<string, unknown>;\n return typeof parsed.connectionId === 'string' && typeof parsed.sourceId === 'string'\n ? { connectionId: parsed.connectionId, sourceId: parsed.sourceId }\n : null;\n } catch {\n return null;\n }\n}\n\nfunction incidentioConnection(connectionId: string): IntegrationConnection {\n return { type: 'oauth', accessToken: `${CONNECTION_TOKEN_PREFIX}${connectionId}` };\n}\n\nfunction connectionIdFromConnection(connection: IntegrationConnection): string | null {\n if (connection.type !== 'oauth' || !connection.accessToken.startsWith(CONNECTION_TOKEN_PREFIX)) return null;\n return connection.accessToken.slice(CONNECTION_TOKEN_PREFIX.length) || null;\n}\n\n/**\n * Base (per-connection) source ids selected for a connection. Scoped ids\n * select their own connection; legacy unscoped ids (`incidentio:incidents`)\n * from pre-discovery deploys apply to every connection.\n */\nfunction baseSourceIdsFor(connectionId: string, sourceIds: string[]): string[] {\n const selected = new Set<string>();\n for (const sourceId of sourceIds) {\n const scoped = decodeScopedSourceId(sourceId);\n if (scoped) {\n if (scoped.connectionId === connectionId) selected.add(scoped.sourceId);\n continue;\n }\n if ((BASE_SOURCE_IDS as readonly string[]).includes(sourceId)) selected.add(sourceId);\n }\n return [...selected];\n}\n\nfunction encodePageCursor(cursor: AggregatePageCursor): string {\n return Buffer.from(JSON.stringify(cursor)).toString('base64url');\n}\n\nfunction decodePageCursor(cursor: string | undefined): AggregatePageCursor | null {\n if (!cursor) return null;\n try {\n const parsed = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8')) as Partial<AggregatePageCursor>;\n if (typeof parsed.connectionId !== 'string' || !parsed.connectionId) return null;\n return {\n connectionId: parsed.connectionId,\n ...(typeof parsed.inner === 'string' && parsed.inner ? { inner: parsed.inner } : {}),\n };\n } catch {\n return null;\n }\n}\n\ninterface IncidentioConnectionContext {\n connection: PlatformIntegrationConnection;\n intake: Intake;\n}\n\nexport class PlatformIncidentioIntegration implements FactoryIntegration {\n readonly id = 'incidentio';\n readonly #clientConfig: PlatformApiClientConfig;\n readonly #platformClient: PlatformApiClient;\n readonly #endpointHost: string;\n readonly #intakeByConnectionId = new Map<string, Intake>();\n readonly #rules: IncidentioEventRules;\n\n /** Bound once by the factory via `initialize()` before any surface is used. */\n #projects: FactoryProjectsStorage | undefined;\n #auth: RouteAuth | undefined;\n #intakeStorage: IntakeStorage | undefined;\n readonly #orgIdByResourceId = new Map<string, string | null>();\n\n constructor(config: PlatformIncidentioIntegrationConfig = {}) {\n this.#clientConfig = config.clientConfig ?? platformApiClientConfigFromEnv();\n this.#platformClient = new PlatformApiClient(this.#clientConfig);\n this.#endpointHost = new URL(this.#clientConfig.baseUrl).host;\n this.#rules = resolveIncidentioRules(config.rules);\n }\n\n /** Event rules driving automatic follow-up materialization and close handling. */\n get rules(): IncidentioEventRules {\n return this.#rules;\n }\n\n initialize({\n projects,\n auth,\n intake,\n }: {\n projects: FactoryProjectsStorage;\n auth: RouteAuth;\n intake: IntakeStorage;\n }): void {\n this.#projects = projects;\n this.#auth = auth;\n this.#intakeStorage = intake;\n }\n\n /** Cross-integration intake selection/binding domain — agent-tool authorization. */\n get intakeStorage(): IntakeStorage {\n if (!this.#intakeStorage) {\n throw new Error('PlatformIncidentioIntegration is not initialized — the factory binds storage during prepare().');\n }\n return this.#intakeStorage;\n }\n\n /** Factory projects domain — maps a session's resourceId to its owning org. */\n get projects(): FactoryProjectsStorage {\n if (!this.#projects) {\n throw new Error('PlatformIncidentioIntegration is not initialized — the factory binds storage during prepare().');\n }\n return this.#projects;\n }\n\n /** Whether the host runs with web auth enabled; every surface is inert without it. */\n get authEnabled(): boolean {\n return this.#auth?.enabled() ?? false;\n }\n\n /**\n * Map a session's resourceId (the factory project id) to its owning org.\n * Same caching semantics as the Jira integration: definitive misses are\n * cached, transient database failures are not.\n */\n async resolveOrgId(resourceId: string): Promise<string | null> {\n const cached = this.#orgIdByResourceId.get(resourceId);\n if (cached !== undefined) return cached;\n if (!UUID_RE.test(resourceId)) {\n this.#orgIdByResourceId.set(resourceId, null);\n return null;\n }\n let orgId: string | null;\n try {\n await this.projects.ensureReady();\n const project = await this.projects.getById({ id: resourceId });\n orgId = project?.orgId ?? null;\n } catch {\n // Transient database failure: skip the tools for this request but don't\n // cache the miss, so the next request retries the lookup.\n return null;\n }\n this.#orgIdByResourceId.set(resourceId, orgId);\n return orgId;\n }\n\n /**\n * Org-scoped agent tools: the read-only follow-up detail tool for sessions\n * whose resource is a factory project with an active Platform-managed\n * incident.io connection.\n */\n async agentTools(args: { requestContext: RequestContext }): Promise<IntegrationTools> {\n if (!(await this.hasActiveConnections())) return {};\n return buildIncidentioAgentTools({ requestContext: args.requestContext, incidentio: this });\n }\n\n async listConnections(): Promise<PlatformIntegrationConnection[]> {\n const providerKey = encodeURIComponent(PLATFORM_INCIDENTIO_PROVIDER_CONFIG_KEY);\n const result = await this.#platformClient.request<{ connections: PlatformIntegrationConnection[] }>(\n 'GET',\n `/v2/connections?providerKey=${providerKey}`,\n );\n return result.connections;\n }\n\n async hasActiveConnections(): Promise<boolean> {\n return (await this.#activeConnections()).length > 0;\n }\n\n clearCaches(): void {\n this.#intakeByConnectionId.clear();\n this.#orgIdByResourceId.clear();\n }\n\n async #activeConnections(): Promise<PlatformIntegrationConnection[]> {\n const connections = (await this.listConnections()).filter(connection => connection.status === 'active');\n // Stable ordering keeps aggregate page cursors valid across requests.\n return connections.slice().sort((left, right) => left.id.localeCompare(right.id));\n }\n\n #connectionIntake(connectionId: string): Intake {\n const cached = this.#intakeByConnectionId.get(connectionId);\n if (cached) return cached;\n const proxyBaseUrl = `${this.#clientConfig.baseUrl.replace(/\\/+$/, '')}/v2/connections/${encodeURIComponent(\n connectionId,\n )}/proxy`;\n const intake = createIncidentioIntake({\n api: new IncidentioApiClient({\n baseUrl: proxyBaseUrl,\n accessToken: this.#clientConfig.accessToken,\n ...(this.#clientConfig.projectId ? { projectId: this.#clientConfig.projectId } : {}),\n ...(this.#clientConfig.fetchImpl ? { fetchImpl: this.#clientConfig.fetchImpl } : {}),\n }),\n connection: incidentioConnection(connectionId),\n });\n this.#intakeByConnectionId.set(connectionId, intake);\n return intake;\n }\n\n async #connectionContexts(): Promise<IncidentioConnectionContext[]> {\n return (await this.#activeConnections()).map(connection => ({\n connection,\n intake: this.#connectionIntake(connection.id),\n }));\n }\n\n /**\n * Resolve the intake for an explicit connection token, or fall back to the\n * sole active connection so legacy single-connection callers keep working.\n *\n * A caller-supplied connection token is only a claim: the id it carries\n * must match a connection the deployment actually discovered as active\n * before any proxy request is minted with the Platform credential.\n */\n async #intakeForConnection(connection: IntegrationConnection): Promise<ResolvedIncidentioIntake> {\n const connectionId = connectionIdFromConnection(connection);\n const active = await this.#activeConnections();\n if (connectionId) {\n if (!active.some(candidate => candidate.id === connectionId)) {\n throw new IncidentioApiError('incident.io connection is unavailable or requires reauthentication.', 401);\n }\n return { intake: this.#connectionIntake(connectionId), connection: incidentioConnection(connectionId) };\n }\n if (active.length === 1) {\n const soleId = active[0]!.id;\n return { intake: this.#connectionIntake(soleId), connection: incidentioConnection(soleId) };\n }\n throw new IncidentioApiError(\n active.length === 0\n ? 'incident.io connection is unavailable or requires reauthentication.'\n : 'incident.io request must identify a connection when multiple accounts are connected.',\n active.length === 0 ? 401 : 400,\n );\n }\n\n readonly intake: Intake = {\n resolveIntakeDispatch: input => this.#resolveIntakeDispatch(input),\n listSources: () => this.#listSources(),\n listItems: input => this.#listItems(input),\n listIssues: input => this.#listIssues(input),\n getIssue: input => this.#getIssue(input),\n createComment: input => this.#createComment(input),\n updateIssue: input => this.#updateIssue(input),\n };\n\n async #resolveIntakeDispatch(input: ResolveIntakeDispatchInput): Promise<ResolvedIntakeDispatch | null> {\n if (input.externalSource.type !== 'issue') return null;\n const externalId = input.externalSource.externalId;\n const contexts = await this.#connectionContexts();\n if (contexts.length === 0) return null;\n if (contexts.length === 1) {\n const resolved = await contexts[0]!.intake.resolveIntakeDispatch?.(input);\n return resolved ? this.#scopeResolvedDispatch(contexts[0]!.connection.id, resolved) : null;\n }\n // Multiple accounts: item references carry no connection id, so probe\n // each connection for the item — first account that knows it wins\n // (incident.io ids are globally unique ULIDs, collisions are not a\n // practical concern and this capability is read-mostly).\n let firstError: unknown;\n for (const context of contexts) {\n try {\n const issue = await context.intake.getIssue({\n connection: incidentioConnection(context.connection.id),\n issueId: externalId,\n });\n if (!issue) continue;\n const resolved = await context.intake.resolveIntakeDispatch?.(input);\n return resolved ? this.#scopeResolvedDispatch(context.connection.id, resolved) : null;\n } catch (error) {\n if (error instanceof IncidentioApiError && error.status === 404) continue;\n firstError ??= error;\n }\n }\n if (firstError !== undefined) throw firstError;\n return null;\n }\n\n #scopeResolvedDispatch(connectionId: string, resolved: ResolvedIntakeDispatch): ResolvedIntakeDispatch {\n return {\n ...resolved,\n connection: incidentioConnection(connectionId),\n ...(resolved.sourceId ? { sourceId: encodeScopedSourceId(connectionId, resolved.sourceId) } : {}),\n };\n }\n\n async #listSources(): Promise<IntakeSource[]> {\n const contexts = await this.#connectionContexts();\n const sources: IntakeSource[] = [];\n for (const context of contexts) {\n const account = context.connection.accountLabel;\n const inner = await context.intake.listSources({ orgId: '', userId: '' });\n for (const source of inner) {\n sources.push({\n ...source,\n id: encodeScopedSourceId(context.connection.id, source.id),\n name: contexts.length > 1 && account ? `${source.name} (${account})` : source.name,\n metadata: {\n ...(source.metadata ?? {}),\n connectionId: context.connection.id,\n ...(account ? { account } : {}),\n },\n });\n }\n }\n return sources;\n }\n\n async #listItems(input: ListIntakeItemsInput): Promise<IntakeItemPage> {\n if (input.sourceIds.length === 0) return { items: [], nextCursor: null };\n const contexts = await this.#connectionContexts();\n const cursor = decodePageCursor(input.cursor);\n\n // Resume by connection ID: the active list can change between pages, so an\n // index would replay or skip connections. When the cursor's connection is\n // gone, resume at its sorted successor and drop the inner cursor.\n let startIndex = 0;\n let exactMatch = false;\n if (cursor) {\n const index = contexts.findIndex(context => context.connection.id === cursor.connectionId);\n exactMatch = index !== -1;\n startIndex = exactMatch\n ? index\n : contexts.findIndex(context => context.connection.id.localeCompare(cursor.connectionId) > 0);\n if (startIndex === -1) return { items: [], nextCursor: null };\n }\n\n for (let index = startIndex; index < contexts.length; index++) {\n const context = contexts[index]!;\n const baseSourceIds = baseSourceIdsFor(context.connection.id, input.sourceIds);\n if (baseSourceIds.length === 0) continue;\n const page = await context.intake.listItems({\n orgId: input.orgId,\n userId: input.userId,\n sourceIds: baseSourceIds,\n ...(index === startIndex && exactMatch && cursor?.inner ? { cursor: cursor.inner } : {}),\n });\n const nextCursor = page.nextCursor\n ? encodePageCursor({ connectionId: context.connection.id, inner: page.nextCursor })\n : index + 1 < contexts.length\n ? encodePageCursor({ connectionId: contexts[index + 1]!.connection.id })\n : null;\n return {\n items: page.items.map(item => ({\n ...item,\n sourceId: encodeScopedSourceId(context.connection.id, item.sourceId),\n metadata: { ...(item.metadata ?? {}), connectionId: context.connection.id },\n })),\n nextCursor,\n };\n }\n return { items: [], nextCursor: null };\n }\n\n async #listIssues(input: ListIntakeIssuesInput): Promise<{ issues: IntakeIssue[]; nextCursor: string | null }> {\n const resolved = await this.#intakeForConnection(input.connection);\n // Scope to the connection that was actually resolved (which may be the\n // sole-connection fallback), so a source id scoped to a different\n // connection is dropped instead of being read against this one.\n const connectionId = connectionIdFromConnection(resolved.connection);\n const baseSourceIds = connectionId\n ? baseSourceIdsFor(connectionId, input.sourceIds)\n : input.sourceIds.map(sourceId => decodeScopedSourceId(sourceId)?.sourceId ?? sourceId);\n return resolved.intake.listIssues({\n ...input,\n connection: resolved.connection,\n sourceIds: baseSourceIds,\n });\n }\n\n async #getIssue(input: GetIntakeIssueInput): Promise<IntakeIssueDetail | null> {\n const resolved = await this.#intakeForConnection(input.connection);\n return resolved.intake.getIssue({\n ...this.#withBaseSource(input),\n connection: resolved.connection,\n });\n }\n\n async #createComment(input: CreateIntakeCommentInput): Promise<CreatedIntakeComment | null> {\n const resolved = await this.#intakeForConnection(input.connection);\n return resolved.intake.createComment({\n ...this.#withBaseSource(input),\n connection: resolved.connection,\n });\n }\n\n async #updateIssue(input: UpdateIntakeIssueInput): Promise<IntakeIssue | null> {\n const resolved = await this.#intakeForConnection(input.connection);\n return resolved.intake.updateIssue({\n ...this.#withBaseSource(input),\n connection: resolved.connection,\n });\n }\n\n #withBaseSource<T extends { sourceId?: string }>(input: T): T {\n if (!input.sourceId) return input;\n const scoped = decodeScopedSourceId(input.sourceId);\n return scoped ? { ...input, sourceId: scoped.sourceId } : input;\n }\n\n workers(ctx: IntegrationContext): MastraWorker[] {\n if (!incidentioReconciliationEnabled()) return [];\n const reconcile = attachIncidentioIssueReconciler(this, ctx);\n if (!reconcile) return [];\n const intervalMs = incidentioReconciliationInterval();\n return [\n new IssueReconcileWorker({\n integrationId: this.id,\n reconcile,\n ...(intervalMs ? { intervalMs } : {}),\n }),\n ];\n }\n\n /**\n * The integration's HTTP surface: `/web/incidentio/*` Mastra `apiRoutes`\n * (status + follow-up listing/detail for Intake), aggregated across every\n * discovered Platform connection. A board-scoped listing also feeds the\n * incident.io event rules.\n */\n routes(ctx: IntegrationContext): ApiRoute[] {\n return buildIncidentioRoutes({\n incidentio: this,\n mode: 'platform',\n auth: ctx.auth,\n intake: ctx.storage.intake,\n ingestFactoryIssues: attachIncidentioRules(this, ctx),\n });\n }\n\n diagnostics(): Record<string, unknown> {\n return { configured: true, mode: 'platform', endpointHost: this.#endpointHost };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsDA,MAAM,0CAA0C;AAChD,MAAM,UAAU;AAChB,MAAM,0BAA0B;AAChC,MAAM,uBAAuB;AAC7B,MAAM,kBAAkB,CAAC,gCAAgC,+BAA+B;AA0BxF,SAAgB,qBAAqB,cAAsB,UAA0B;CACnF,OAAO,GAAG,uBAAuB,OAAO,KAAK,KAAK,UAAU;EAAE;EAAc;CAAS,CAAC,CAAC,CAAC,CAAC,SAAS,WAAW;AAC/G;AAEA,SAAgB,qBAAqB,OAAsC;CACzE,IAAI,CAAC,MAAM,WAAW,oBAAoB,GAAG,OAAO;CACpD,IAAI;EACF,MAAM,SAAS,KAAK,MAClB,OAAO,KAAK,MAAM,MAAM,EAA2B,GAAG,WAAW,CAAC,CAAC,SAAS,MAAM,CACpF;EACA,OAAO,OAAO,OAAO,iBAAiB,YAAY,OAAO,OAAO,aAAa,WACzE;GAAE,cAAc,OAAO;GAAc,UAAU,OAAO;EAAS,IAC/D;CACN,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,qBAAqB,cAA6C;CACzE,OAAO;EAAE,MAAM;EAAS,aAAa,GAAG,0BAA0B;CAAe;AACnF;AAEA,SAAS,2BAA2B,YAAkD;CACpF,IAAI,WAAW,SAAS,WAAW,CAAC,WAAW,YAAY,WAAW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AI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAGvC;AAWD,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAYnG;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,kBAAkB,GAAG,MAAM,CAE1E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,CAe7E"}
@@ -381,6 +381,7 @@ var PlatformJiraIntegration = class {
381
381
  const api = new JiraApiClient({
382
382
  baseUrl: `${proxyBaseUrl}/ex/jira/${encodeURIComponent(cloudId)}`,
383
383
  accessToken: this.#clientConfig.accessToken,
384
+ ...this.#clientConfig.projectId ? { projectId: this.#clientConfig.projectId } : {},
384
385
  ...this.#clientConfig.fetchImpl ? { fetchImpl: this.#clientConfig.fetchImpl } : {}
385
386
  });
386
387
  let siteUrl = this.#siteUrlByConnectionId.get(connection.id);
@@ -1 +1 @@
1
- {"version":3,"file":"integration.js","names":["#clientConfig","#platformClient","#endpointHost","#cloudIdByConnectionId","#siteUrlByConnectionId","#orgIdByResourceId","#rules","#projects","#auth","#activeConnections","#resolveIntakeDispatch","#listSources","#listItems","#listIssues","#getIssue","#createComment","#updateIssue","#connectionContext","#connectionContextById","#toIntakeIssue","#findIssue","#listAllComments","#resolveRequest","#cloudId"],"sources":["../../../../src/integrations/platform/jira/integration.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { MastraWorker } from '@mastra/core/worker';\n\nimport type { IntegrationConnection } from '../../../capabilities/connection.js';\nimport type {\n CreateIntakeCommentInput,\n CreatedIntakeComment,\n GetIntakeIssueInput,\n Intake,\n IntakeIssue,\n IntakeIssueDetail,\n IntakeItemPage,\n IntakeSource,\n ListIntakeIssuesInput,\n ListIntakeItemsInput,\n ResolveIntakeDispatchInput,\n ResolvedIntakeDispatch,\n UpdateIntakeIssueInput,\n} from '../../../capabilities/intake.js';\nimport type { RouteAuth } from '../../../routes/route.js';\nimport type { FactoryProjectsStorage } from '../../../storage/domains/projects/base.js';\nimport type { FactoryIntegration, IntegrationContext, IntegrationTools } from '../../base.js';\nimport { IssueReconcileWorker } from '../../issue-reconcile-worker.js';\nimport { adfToText } from '../../jira/adf.js';\nimport type { JiraComment, JiraIssue, JiraTransition } from '../../jira/api.js';\nimport { JiraApiClient, JiraApiError } from '../../jira/api.js';\nimport type { JiraEventRules, JiraRuleOverrides } from '../../jira/default-rules.js';\nimport { resolveJiraRules } from '../../jira/default-rules.js';\nimport { attachJiraIssueReconciler } from '../../jira/issue-reconciler.js';\nimport { jiraReconciliationEnabled, jiraReconciliationInterval } from '../../jira/reconciliation-config.js';\nimport { attachJiraRules } from '../../jira/rules.js';\nimport {\n logPlatformInfo,\n PlatformApiClient,\n platformApiClientConfigFromEnv,\n type PlatformApiClientConfig,\n} from '../api-client.js';\nimport { buildPlatformJiraAgentTools } from './agent-tools.js';\nimport { buildPlatformJiraRoutes } from './routes.js';\n\ninterface PlatformIntegrationConnection {\n id: string;\n integrationId: string;\n status: 'active' | 'needs_reauth';\n accountLabel: string | null;\n}\n\ninterface JiraConnectionContext {\n connection: PlatformIntegrationConnection;\n api: JiraApiClient;\n siteUrl: string;\n}\n\ninterface PlatformConnectionContextResponse {\n connection_config: Record<string, unknown> | null;\n metadata: Record<string, unknown> | null;\n}\n\ninterface JiraIssueReference {\n connectionId: string;\n issueId: string;\n projectId?: string;\n}\n\ninterface JiraPageCursor {\n group: number;\n jira?: string;\n}\n\nconst ISSUE_COMMENTS_MAX_PAGES = 20;\n\n/** Hard stop for project pagination so a misbehaving `isLast` can't loop forever. */\nconst PROJECT_SEARCH_MAX_PAGES = 50;\nconst ISSUE_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_]*-\\d+$/;\nconst PLATFORM_JIRA_PROVIDER_CONFIG_KEY = 'jira';\nconst UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst JIRA_CONNECTION_TOKEN_PREFIX = 'jira-connection:';\nconst JIRA_ISSUE_REF_PREFIX = 'jira-issue:';\nconst JIRA_SOURCE_PREFIX = 'jira-project:';\n\nconst STATE_TYPE_TO_CATEGORY: Record<'unstarted' | 'started' | 'completed', string> = {\n unstarted: 'new',\n started: 'indeterminate',\n completed: 'done',\n};\n\nfunction stateTypeFromCategory(key: string | undefined): string | null {\n switch (key) {\n case 'new':\n return 'unstarted';\n case 'indeterminate':\n return 'started';\n case 'done':\n return 'completed';\n default:\n return null;\n }\n}\n\nexport interface PlatformJiraIntegrationConfig {\n clientConfig?: PlatformApiClientConfig;\n /** Per-event replacements; omitted events retain defaults, null disables. */\n rules?: JiraRuleOverrides;\n}\n\nexport class PlatformJiraIntegration implements FactoryIntegration {\n readonly id = 'jira';\n readonly #clientConfig: PlatformApiClientConfig;\n readonly #platformClient: PlatformApiClient;\n readonly #endpointHost: string;\n readonly #cloudIdByConnectionId = new Map<string, string>();\n readonly #siteUrlByConnectionId = new Map<string, string>();\n #projects: FactoryProjectsStorage | undefined;\n #auth: RouteAuth | undefined;\n readonly #orgIdByResourceId = new Map<string, string | null>();\n\n readonly #rules: JiraEventRules;\n\n get rules(): JiraEventRules {\n return this.#rules;\n }\n\n constructor(config: PlatformJiraIntegrationConfig = {}) {\n this.#rules = resolveJiraRules(config.rules);\n this.#clientConfig = config.clientConfig ?? platformApiClientConfigFromEnv();\n this.#platformClient = new PlatformApiClient(this.#clientConfig);\n this.#endpointHost = new URL(this.#clientConfig.baseUrl).host;\n }\n\n initialize({ projects, auth }: { projects: FactoryProjectsStorage; auth: RouteAuth }): void {\n this.#projects = projects;\n this.#auth = auth;\n logPlatformInfo('Platform Jira integration initialized', { endpointHost: this.#endpointHost });\n }\n\n get projects(): FactoryProjectsStorage {\n if (!this.#projects)\n throw new Error('PlatformJiraIntegration is not initialized — the factory binds storage during prepare().');\n return this.#projects;\n }\n\n get authEnabled(): boolean {\n return this.#auth?.enabled() ?? false;\n }\n\n async resolveOrgId(resourceId: string): Promise<string | null> {\n const cached = this.#orgIdByResourceId.get(resourceId);\n if (cached !== undefined) return cached;\n if (!UUID_PATTERN.test(resourceId)) {\n this.#orgIdByResourceId.set(resourceId, null);\n return null;\n }\n try {\n await this.projects.ensureReady();\n const project = await this.projects.getById({ id: resourceId });\n const orgId = project?.orgId ?? null;\n this.#orgIdByResourceId.set(resourceId, orgId);\n return orgId;\n } catch {\n return null;\n }\n }\n\n clearCaches(): void {\n this.#orgIdByResourceId.clear();\n this.#cloudIdByConnectionId.clear();\n this.#siteUrlByConnectionId.clear();\n }\n\n async listConnections(): Promise<PlatformIntegrationConnection[]> {\n const providerKey = encodeURIComponent(PLATFORM_JIRA_PROVIDER_CONFIG_KEY);\n const result = await this.#platformClient.request<{ connections: PlatformIntegrationConnection[] }>(\n 'GET',\n `/v2/connections?providerKey=${providerKey}`,\n );\n return result.connections;\n }\n\n async hasActiveConnections(): Promise<boolean> {\n return (await this.#activeConnections()).length > 0;\n }\n\n readonly intake: Intake = {\n resolveIntakeDispatch: input => this.#resolveIntakeDispatch(input),\n listSources: () => this.#listSources(),\n listItems: input => this.#listItems(input),\n listIssues: input => this.#listIssues(input),\n getIssue: input => this.#getIssue(input),\n createComment: input => this.#createComment(input),\n updateIssue: input => this.#updateIssue(input),\n };\n\n async #resolveIntakeDispatch({ externalSource }: ResolveIntakeDispatchInput): Promise<ResolvedIntakeDispatch | null> {\n if (externalSource.type !== 'issue') return null;\n const reference = decodeIssueReference(externalSource.externalId);\n if (!reference) return null;\n return {\n connection: jiraConnection(reference.connectionId),\n ...(reference.projectId ? { sourceId: encodeSourceId(reference.connectionId, reference.projectId) } : {}),\n issueId: reference.issueId,\n };\n }\n\n async #listSources(): Promise<IntakeSource[]> {\n const sources: IntakeSource[] = [];\n for (const connection of await this.#activeConnections()) {\n const context = await this.#connectionContext(connection);\n let startAt = 0;\n for (let pageCount = 0; pageCount < PROJECT_SEARCH_MAX_PAGES; pageCount++) {\n const page = await context.api.listProjects({ startAt });\n for (const project of page.values) {\n sources.push({\n id: encodeSourceId(connection.id, project.id),\n name: project.name,\n type: 'project',\n metadata: {\n key: project.key,\n connectionId: connection.id,\n site: new URL(context.siteUrl).host,\n },\n });\n }\n if (page.isLast || page.values.length === 0) break;\n startAt += page.values.length;\n }\n }\n return sources;\n }\n\n async #listItems({ sourceIds, cursor }: ListIntakeItemsInput): Promise<IntakeItemPage> {\n if (sourceIds.length === 0) return { items: [], nextCursor: null };\n const page = await this.listActiveIssues(cursor, sourceIds);\n return {\n items: page.issues.map(issue => ({\n source: { type: 'issue', externalId: issue.externalId, url: issue.url },\n sourceId: issue.sourceId,\n title: `${issue.identifier}: ${issue.title}`,\n status: issue.state ?? undefined,\n labels: issue.labels,\n assignee: issue.assignee,\n createdAt: issue.createdAt,\n updatedAt: issue.updatedAt,\n metadata: {\n identifier: issue.identifier,\n issueRef: issue.externalId,\n state: issue.state,\n stateType: issue.stateType,\n priority: issue.priority,\n project: issue.source,\n site: issue.site,\n assignee: issue.assignee,\n assignees: issue.assignees ?? [],\n creator: issue.author,\n author: issue.author,\n labels: issue.labels,\n createdAt: issue.createdAt,\n updatedAt: issue.updatedAt,\n },\n })),\n nextCursor: page.nextCursor,\n };\n }\n\n async #listIssues(input: ListIntakeIssuesInput): Promise<{ issues: IntakeIssue[]; nextCursor: string | null }> {\n const page = await this.listActiveIssues(input.cursor, input.sourceIds, input.labels);\n return { issues: page.issues, nextCursor: page.nextCursor };\n }\n\n async listActiveIssues(\n cursor?: string,\n sourceIds: string[] = [],\n labels?: string[],\n ): Promise<{\n issues: Array<IntakeIssue & { sourceId: string; externalId: string; site: string }>;\n nextCursor: string | null;\n }> {\n const grouped = groupSources(sourceIds);\n if (grouped.length === 0) return { issues: [], nextCursor: null };\n const decodedCursor = decodePageCursor(cursor);\n if (decodedCursor.group >= grouped.length) return { issues: [], nextCursor: null };\n\n for (let groupIndex = decodedCursor.group; groupIndex < grouped.length; groupIndex++) {\n const group = grouped[groupIndex]!;\n const context = await this.#connectionContextById(group.connectionId);\n const jql = buildIntakeJql(group.projectIds, labels);\n if (jql === null) continue;\n const page = await context.api.searchIssues({\n jql,\n ...(groupIndex === decodedCursor.group && decodedCursor.jira ? { nextPageToken: decodedCursor.jira } : {}),\n });\n const nextCursor = page.nextPageToken\n ? encodePageCursor({ group: groupIndex, jira: page.nextPageToken })\n : groupIndex + 1 < grouped.length\n ? encodePageCursor({ group: groupIndex + 1 })\n : null;\n return {\n issues: page.issues.map(issue => {\n const projectId = issue.fields.project?.id ?? group.projectIds[0] ?? '';\n return {\n ...this.#toIntakeIssue(issue, context.siteUrl),\n sourceId: encodeSourceId(group.connectionId, projectId),\n externalId: encodeIssueReference({ connectionId: group.connectionId, issueId: issue.key, projectId }),\n site: new URL(context.siteUrl).host,\n };\n }),\n nextCursor,\n };\n }\n return { issues: [], nextCursor: null };\n }\n\n async #getIssue(input: GetIntakeIssueInput): Promise<IntakeIssueDetail | null> {\n const { context, issue } = (await this.#findIssue(input)) ?? {};\n if (!context || !issue) return null;\n const { comments, total } = await this.#listAllComments(context.api, issue.key);\n return {\n ...this.#toIntakeIssue(issue, context.siteUrl),\n commentCount: total,\n description: issue.fields.description ? adfToText(issue.fields.description) || null : null,\n comments: comments.map(comment => ({\n author: comment.author?.displayName ?? null,\n body: adfToText(comment.body),\n createdAt: comment.created,\n })),\n };\n }\n\n async #listAllComments(api: JiraApiClient, keyOrId: string): Promise<{ comments: JiraComment[]; total: number }> {\n const comments: JiraComment[] = [];\n let total = 0;\n for (let page = 0; page < ISSUE_COMMENTS_MAX_PAGES; page++) {\n const result = await api.listComments(keyOrId, { startAt: comments.length });\n comments.push(...result.comments);\n total = result.total;\n if (result.comments.length === 0 || comments.length >= total) break;\n }\n return { comments, total };\n }\n\n async #createComment(input: CreateIntakeCommentInput): Promise<CreatedIntakeComment | null> {\n const resolved = await this.#resolveRequest(input);\n let key = resolved.issueId;\n if (!ISSUE_KEY_PATTERN.test(key)) {\n try {\n key = (await resolved.context.api.getIssue(key)).key;\n } catch (error) {\n if (error instanceof JiraApiError && error.status === 404) return null;\n throw error;\n }\n }\n let comment;\n try {\n comment = await resolved.context.api.createComment(key, input.body);\n } catch (error) {\n if (error instanceof JiraApiError && error.status === 404) return null;\n throw error;\n }\n return {\n id: comment.id,\n url: `${resolved.context.siteUrl}/browse/${key}?focusedCommentId=${comment.id}`,\n };\n }\n\n async #updateIssue(input: UpdateIntakeIssueInput): Promise<IntakeIssue | null> {\n const resolved = await this.#resolveRequest(input);\n let issue: JiraIssue;\n try {\n issue = await resolved.context.api.getIssue(resolved.issueId);\n } catch (error) {\n if (error instanceof JiraApiError && error.status === 404) return null;\n throw error;\n }\n if (currentStatusMatches(issue, input.state)) return this.#toIntakeIssue(issue, resolved.context.siteUrl);\n const transitions = await resolved.context.api.listTransitions(issue.key);\n const transition = resolveTransition(transitions, input.state);\n if (!transition) return null;\n await resolved.context.api.applyTransition(issue.key, transition.id);\n return this.#toIntakeIssue(await resolved.context.api.getIssue(issue.key), resolved.context.siteUrl);\n }\n\n async #resolveRequest(input: GetIntakeIssueInput): Promise<{ context: JiraConnectionContext; issueId: string }> {\n const issueReference = decodeIssueReference(input.issueId);\n const source = input.sourceId ? decodeSourceId(input.sourceId) : null;\n const connectionId =\n issueReference?.connectionId ?? source?.connectionId ?? connectionIdFromConnection(input.connection);\n const issueId = issueReference?.issueId ?? input.issueId;\n if (connectionId) return { context: await this.#connectionContextById(connectionId), issueId };\n const active = await this.#activeConnections();\n if (active.length !== 1) {\n throw new JiraApiError('Jira issue reference must identify a connection when multiple sites are connected.', 400);\n }\n return { context: await this.#connectionContext(active[0]!), issueId };\n }\n\n /**\n * Locate an issue for a read. A connection-scoped reference resolves\n * directly; a plain issue key (the agent tool's normal input) is looked up\n * across every active connection so multi-site organizations can still\n * fetch by key — the first site that knows the key wins, which is safe\n * because Jira project-key prefixes make cross-site collisions unlikely and\n * the tool is read-only.\n */\n async #findIssue(input: GetIntakeIssueInput): Promise<{ context: JiraConnectionContext; issue: JiraIssue } | null> {\n const issueReference = decodeIssueReference(input.issueId);\n const source = input.sourceId ? decodeSourceId(input.sourceId) : null;\n const connectionId =\n issueReference?.connectionId ?? source?.connectionId ?? connectionIdFromConnection(input.connection);\n const issueId = issueReference?.issueId ?? input.issueId;\n\n const candidates: JiraConnectionContext[] = [];\n if (connectionId) {\n candidates.push(await this.#connectionContextById(connectionId));\n } else {\n const active = await this.#activeConnections();\n if (active.length === 0) {\n throw new JiraApiError('Jira connection is unavailable or requires reauthentication.', 401);\n }\n for (const connection of active) candidates.push(await this.#connectionContext(connection));\n }\n\n let firstError: unknown;\n for (const context of candidates) {\n try {\n return { context, issue: await context.api.getIssue(issueId) };\n } catch (error) {\n if (error instanceof JiraApiError && error.status === 404) continue;\n firstError ??= error;\n }\n }\n // Not found anywhere. If a site failed for a non-404 reason, surface that\n // failure instead of a silent \"not found\".\n if (firstError !== undefined) throw firstError;\n return null;\n }\n\n #toIntakeIssue(issue: JiraIssue, siteUrl: string): IntakeIssue {\n const { fields } = issue;\n return {\n id: issue.id,\n identifier: issue.key,\n title: fields.summary ?? issue.key,\n url: `${siteUrl}/browse/${issue.key}`,\n author: fields.reporter?.displayName ?? null,\n state: fields.status?.name ?? null,\n stateType: stateTypeFromCategory(fields.status?.statusCategory?.key),\n priority: fields.priority?.name ?? null,\n assignee: fields.assignee?.displayName ?? null,\n source: fields.project?.key ?? null,\n labels: fields.labels ?? [],\n commentCount: null,\n createdAt: fields.created ?? '',\n updatedAt: fields.updated ?? '',\n };\n }\n\n async #activeConnections(): Promise<PlatformIntegrationConnection[]> {\n return (await this.listConnections()).filter(connection => connection.status === 'active');\n }\n\n async #connectionContextById(connectionId: string): Promise<JiraConnectionContext> {\n const connection = (await this.#activeConnections()).find(candidate => candidate.id === connectionId);\n if (!connection) {\n throw new JiraApiError('Jira connection is unavailable or requires reauthentication.', 401);\n }\n return this.#connectionContext(connection);\n }\n\n async #cloudId(connectionId: string): Promise<string> {\n const cached = this.#cloudIdByConnectionId.get(connectionId);\n if (cached) return cached;\n\n const context = await this.#platformClient.request<PlatformConnectionContextResponse>(\n 'GET',\n `/v2/connections/${encodeURIComponent(connectionId)}/context`,\n );\n const cloudId = context.connection_config?.cloudId;\n if (typeof cloudId !== 'string' || !UUID_PATTERN.test(cloudId)) {\n throw new JiraApiError('Platform Jira connection context is missing a valid cloudId.', 502);\n }\n this.#cloudIdByConnectionId.set(connectionId, cloudId);\n return cloudId;\n }\n\n async #connectionContext(connection: PlatformIntegrationConnection): Promise<JiraConnectionContext> {\n const proxyBaseUrl = `${this.#clientConfig.baseUrl.replace(/\\/+$/, '')}/v2/connections/${encodeURIComponent(\n connection.id,\n )}/proxy`;\n const cloudId = await this.#cloudId(connection.id);\n const api = new JiraApiClient({\n baseUrl: `${proxyBaseUrl}/ex/jira/${encodeURIComponent(cloudId)}`,\n accessToken: this.#clientConfig.accessToken,\n ...(this.#clientConfig.fetchImpl ? { fetchImpl: this.#clientConfig.fetchImpl } : {}),\n });\n let siteUrl = this.#siteUrlByConnectionId.get(connection.id);\n if (!siteUrl) {\n siteUrl = connection.accountLabel\n ? normalizeSiteUrl(connection.accountLabel)\n : normalizeSiteUrl((await api.getServerInfo()).baseUrl);\n this.#siteUrlByConnectionId.set(connection.id, siteUrl);\n }\n return { connection, api, siteUrl };\n }\n\n workers(ctx: IntegrationContext): MastraWorker[] {\n if (!jiraReconciliationEnabled()) return [];\n const reconcile = attachJiraIssueReconciler(this, ctx);\n if (!reconcile) return [];\n const intervalMs = jiraReconciliationInterval();\n return [\n new IssueReconcileWorker({\n integrationId: this.id,\n reconcile,\n ...(intervalMs ? { intervalMs } : {}),\n }),\n ];\n }\n\n routes(ctx: IntegrationContext): ApiRoute[] {\n return buildPlatformJiraRoutes({\n jira: this,\n auth: ctx.auth,\n intake: ctx.storage.intake,\n appDbConfigured: Boolean(ctx.factoryStorage),\n ingestFactoryIssues: attachJiraRules(this, ctx),\n });\n }\n\n async agentTools(args: { requestContext: RequestContext }): Promise<IntegrationTools> {\n return buildPlatformJiraAgentTools({ requestContext: args.requestContext, jira: this });\n }\n\n diagnostics(): Record<string, unknown> {\n return { configured: true, mode: 'platform', endpointHost: this.#endpointHost };\n }\n}\n\nfunction jiraConnection(connectionId: string): IntegrationConnection {\n return { type: 'oauth', accessToken: `${JIRA_CONNECTION_TOKEN_PREFIX}${connectionId}` };\n}\n\nfunction connectionIdFromConnection(connection: IntegrationConnection): string | null {\n if (connection.type !== 'oauth' || !connection.accessToken.startsWith(JIRA_CONNECTION_TOKEN_PREFIX)) return null;\n return connection.accessToken.slice(JIRA_CONNECTION_TOKEN_PREFIX.length) || null;\n}\n\nexport function encodeSourceId(connectionId: string, projectId: string): string {\n return `${JIRA_SOURCE_PREFIX}${Buffer.from(JSON.stringify({ connectionId, projectId })).toString('base64url')}`;\n}\n\nexport function decodeSourceId(sourceId: string): { connectionId: string; projectId: string } | null {\n if (!sourceId.startsWith(JIRA_SOURCE_PREFIX)) return null;\n try {\n const parsed = JSON.parse(\n Buffer.from(sourceId.slice(JIRA_SOURCE_PREFIX.length), 'base64url').toString('utf8'),\n ) as Record<string, unknown>;\n return typeof parsed.connectionId === 'string' && typeof parsed.projectId === 'string'\n ? { connectionId: parsed.connectionId, projectId: parsed.projectId }\n : null;\n } catch {\n return null;\n }\n}\n\nexport function encodeIssueReference(reference: JiraIssueReference): string {\n return `${JIRA_ISSUE_REF_PREFIX}${Buffer.from(JSON.stringify(reference)).toString('base64url')}`;\n}\n\nexport function decodeIssueReference(value: string): JiraIssueReference | null {\n if (!value.startsWith(JIRA_ISSUE_REF_PREFIX)) return null;\n try {\n const parsed = JSON.parse(\n Buffer.from(value.slice(JIRA_ISSUE_REF_PREFIX.length), 'base64url').toString('utf8'),\n ) as Record<string, unknown>;\n if (typeof parsed.connectionId !== 'string' || typeof parsed.issueId !== 'string') return null;\n return {\n connectionId: parsed.connectionId,\n issueId: parsed.issueId,\n ...(typeof parsed.projectId === 'string' ? { projectId: parsed.projectId } : {}),\n };\n } catch {\n return null;\n }\n}\n\nfunction groupSources(sourceIds: string[]): Array<{ connectionId: string; projectIds: string[] }> {\n const groups = new Map<string, Set<string>>();\n for (const sourceId of sourceIds) {\n const source = decodeSourceId(sourceId);\n if (!source) continue;\n const projectIds = groups.get(source.connectionId) ?? new Set<string>();\n projectIds.add(source.projectId);\n groups.set(source.connectionId, projectIds);\n }\n return [...groups.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([connectionId, projectIds]) => ({ connectionId, projectIds: [...projectIds].sort() }));\n}\n\nfunction encodePageCursor(cursor: JiraPageCursor): string {\n return Buffer.from(JSON.stringify(cursor)).toString('base64url');\n}\n\nfunction decodePageCursor(cursor: string | undefined): JiraPageCursor {\n if (!cursor) return { group: 0 };\n try {\n const parsed = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8')) as Record<string, unknown>;\n if (!Number.isInteger(parsed.group) || (parsed.group as number) < 0) throw new Error();\n return {\n group: parsed.group as number,\n ...(typeof parsed.jira === 'string' ? { jira: parsed.jira } : {}),\n };\n } catch {\n throw new JiraApiError('Jira pagination cursor is invalid.', 400);\n }\n}\n\nfunction normalizeSiteUrl(value: string): string {\n const candidate = /^https?:\\/\\//i.test(value) ? value : `https://${value}`;\n // `accountLabel` is free-form Platform data — an unparsable value must\n // surface as the classified 502 the routes already handle, not a raw\n // TypeError escaping the connection context.\n let url: URL;\n try {\n url = new URL(candidate);\n } catch {\n throw new JiraApiError('Jira site URL is invalid.', 502);\n }\n if (url.protocol !== 'http:' && url.protocol !== 'https:') throw new JiraApiError('Jira site URL is invalid.', 502);\n return url.origin;\n}\n\nfunction buildIntakeJql(projectIds?: string[], labels?: string[]): string | null {\n const clauses: string[] = [];\n const safeProjects = (projectIds ?? [])\n .map(id => id.trim())\n .filter(id => /^[A-Za-z0-9_]+$/.test(id))\n .map(id => (/^\\d+$/.test(id) ? id : `\"${id}\"`));\n if (projectIds && safeProjects.length === 0) return null;\n if (safeProjects.length > 0) clauses.push(`project IN (${safeProjects.join(', ')})`);\n clauses.push('statusCategory != Done');\n const safeLabels = [...new Set((labels ?? []).map(label => label.trim().replace(/[\"\\\\]/g, '')).filter(Boolean))];\n if (safeLabels.length > 0) clauses.push(`labels IN (${safeLabels.map(label => `\"${label}\"`).join(', ')})`);\n return `${clauses.join(' AND ')} ORDER BY updated DESC`;\n}\n\nfunction currentStatusMatches(issue: JiraIssue, target: UpdateIntakeIssueInput['state']): boolean {\n const status = issue.fields.status;\n if (!status) return false;\n if (target.kind === 'byName') return status.name.toLowerCase() === target.name.toLowerCase();\n if (target.stateType === 'canceled') return status.statusCategory?.key === 'done' && /cancel/i.test(status.name);\n return status.statusCategory?.key === STATE_TYPE_TO_CATEGORY[target.stateType];\n}\n\nfunction resolveTransition(\n transitions: JiraTransition[],\n target: UpdateIntakeIssueInput['state'],\n): JiraTransition | null {\n if (target.kind === 'byName') {\n const wanted = target.name.toLowerCase();\n return transitions.find(transition => transition.to?.name.toLowerCase() === wanted) ?? null;\n }\n if (target.stateType === 'canceled') {\n return (\n transitions.find(\n transition => transition.to?.statusCategory?.key === 'done' && /cancel/i.test(transition.to.name),\n ) ?? null\n );\n }\n const category = STATE_TYPE_TO_CATEGORY[target.stateType];\n return transitions.find(transition => transition.to?.statusCategory?.key === category) ?? null;\n}\n"],"mappings":";;;;;;;;;;;AAsEA,MAAM,2BAA2B;;AAGjC,MAAM,2BAA2B;AACjC,MAAM,oBAAoB;AAC1B,MAAM,oCAAoC;AAC1C,MAAM,eAAe;AACrB,MAAM,+BAA+B;AACrC,MAAM,wBAAwB;AAC9B,MAAM,qBAAqB;AAE3B,MAAM,yBAAgF;CACpF,WAAW;CACX,SAAS;CACT,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#clientConfig","#platformClient","#endpointHost","#cloudIdByConnectionId","#siteUrlByConnectionId","#orgIdByResourceId","#rules","#projects","#auth","#activeConnections","#resolveIntakeDispatch","#listSources","#listItems","#listIssues","#getIssue","#createComment","#updateIssue","#connectionContext","#connectionContextById","#toIntakeIssue","#findIssue","#listAllComments","#resolveRequest","#cloudId"],"sources":["../../../../src/integrations/platform/jira/integration.ts"],"sourcesContent":["import type { RequestContext } from '@mastra/core/request-context';\nimport type { ApiRoute } from '@mastra/core/server';\nimport type { MastraWorker } from '@mastra/core/worker';\n\nimport type { IntegrationConnection } from '../../../capabilities/connection.js';\nimport type {\n CreateIntakeCommentInput,\n CreatedIntakeComment,\n GetIntakeIssueInput,\n Intake,\n IntakeIssue,\n IntakeIssueDetail,\n IntakeItemPage,\n IntakeSource,\n ListIntakeIssuesInput,\n ListIntakeItemsInput,\n ResolveIntakeDispatchInput,\n ResolvedIntakeDispatch,\n UpdateIntakeIssueInput,\n} from '../../../capabilities/intake.js';\nimport type { RouteAuth } from '../../../routes/route.js';\nimport type { FactoryProjectsStorage } from '../../../storage/domains/projects/base.js';\nimport type { FactoryIntegration, IntegrationContext, IntegrationTools } from '../../base.js';\nimport { IssueReconcileWorker } from '../../issue-reconcile-worker.js';\nimport { adfToText } from '../../jira/adf.js';\nimport type { JiraComment, JiraIssue, JiraTransition } from '../../jira/api.js';\nimport { JiraApiClient, JiraApiError } from '../../jira/api.js';\nimport type { JiraEventRules, JiraRuleOverrides } from '../../jira/default-rules.js';\nimport { resolveJiraRules } from '../../jira/default-rules.js';\nimport { attachJiraIssueReconciler } from '../../jira/issue-reconciler.js';\nimport { jiraReconciliationEnabled, jiraReconciliationInterval } from '../../jira/reconciliation-config.js';\nimport { attachJiraRules } from '../../jira/rules.js';\nimport {\n logPlatformInfo,\n PlatformApiClient,\n platformApiClientConfigFromEnv,\n type PlatformApiClientConfig,\n} from '../api-client.js';\nimport { buildPlatformJiraAgentTools } from './agent-tools.js';\nimport { buildPlatformJiraRoutes } from './routes.js';\n\ninterface PlatformIntegrationConnection {\n id: string;\n integrationId: string;\n status: 'active' | 'needs_reauth';\n accountLabel: string | null;\n}\n\ninterface JiraConnectionContext {\n connection: PlatformIntegrationConnection;\n api: JiraApiClient;\n siteUrl: string;\n}\n\ninterface PlatformConnectionContextResponse {\n connection_config: Record<string, unknown> | null;\n metadata: Record<string, unknown> | null;\n}\n\ninterface JiraIssueReference {\n connectionId: string;\n issueId: string;\n projectId?: string;\n}\n\ninterface JiraPageCursor {\n group: number;\n jira?: string;\n}\n\nconst ISSUE_COMMENTS_MAX_PAGES = 20;\n\n/** Hard stop for project pagination so a misbehaving `isLast` can't loop forever. */\nconst PROJECT_SEARCH_MAX_PAGES = 50;\nconst ISSUE_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_]*-\\d+$/;\nconst PLATFORM_JIRA_PROVIDER_CONFIG_KEY = 'jira';\nconst UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst JIRA_CONNECTION_TOKEN_PREFIX = 'jira-connection:';\nconst JIRA_ISSUE_REF_PREFIX = 'jira-issue:';\nconst JIRA_SOURCE_PREFIX = 'jira-project:';\n\nconst STATE_TYPE_TO_CATEGORY: Record<'unstarted' | 'started' | 'completed', string> = {\n unstarted: 'new',\n started: 'indeterminate',\n completed: 'done',\n};\n\nfunction stateTypeFromCategory(key: string | undefined): string | null {\n switch (key) {\n case 'new':\n return 'unstarted';\n case 'indeterminate':\n return 'started';\n case 'done':\n return 'completed';\n default:\n return null;\n }\n}\n\nexport interface PlatformJiraIntegrationConfig {\n clientConfig?: PlatformApiClientConfig;\n /** Per-event replacements; omitted events retain defaults, null disables. */\n rules?: JiraRuleOverrides;\n}\n\nexport class PlatformJiraIntegration implements FactoryIntegration {\n readonly id = 'jira';\n readonly #clientConfig: PlatformApiClientConfig;\n readonly #platformClient: PlatformApiClient;\n readonly #endpointHost: string;\n readonly #cloudIdByConnectionId = new Map<string, string>();\n readonly #siteUrlByConnectionId = new Map<string, string>();\n #projects: FactoryProjectsStorage | undefined;\n #auth: RouteAuth | undefined;\n readonly #orgIdByResourceId = new Map<string, string | null>();\n\n readonly #rules: JiraEventRules;\n\n get rules(): JiraEventRules {\n return this.#rules;\n }\n\n constructor(config: PlatformJiraIntegrationConfig = {}) {\n this.#rules = resolveJiraRules(config.rules);\n this.#clientConfig = config.clientConfig ?? platformApiClientConfigFromEnv();\n this.#platformClient = new PlatformApiClient(this.#clientConfig);\n this.#endpointHost = new URL(this.#clientConfig.baseUrl).host;\n }\n\n initialize({ projects, auth }: { projects: FactoryProjectsStorage; auth: RouteAuth }): void {\n this.#projects = projects;\n this.#auth = auth;\n logPlatformInfo('Platform Jira integration initialized', { endpointHost: this.#endpointHost });\n }\n\n get projects(): FactoryProjectsStorage {\n if (!this.#projects)\n throw new Error('PlatformJiraIntegration is not initialized — the factory binds storage during prepare().');\n return this.#projects;\n }\n\n get authEnabled(): boolean {\n return this.#auth?.enabled() ?? false;\n }\n\n async resolveOrgId(resourceId: string): Promise<string | null> {\n const cached = this.#orgIdByResourceId.get(resourceId);\n if (cached !== undefined) return cached;\n if (!UUID_PATTERN.test(resourceId)) {\n this.#orgIdByResourceId.set(resourceId, null);\n return null;\n }\n try {\n await this.projects.ensureReady();\n const project = await this.projects.getById({ id: resourceId });\n const orgId = project?.orgId ?? null;\n this.#orgIdByResourceId.set(resourceId, orgId);\n return orgId;\n } catch {\n return null;\n }\n }\n\n clearCaches(): void {\n this.#orgIdByResourceId.clear();\n this.#cloudIdByConnectionId.clear();\n this.#siteUrlByConnectionId.clear();\n }\n\n async listConnections(): Promise<PlatformIntegrationConnection[]> {\n const providerKey = encodeURIComponent(PLATFORM_JIRA_PROVIDER_CONFIG_KEY);\n const result = await this.#platformClient.request<{ connections: PlatformIntegrationConnection[] }>(\n 'GET',\n `/v2/connections?providerKey=${providerKey}`,\n );\n return result.connections;\n }\n\n async hasActiveConnections(): Promise<boolean> {\n return (await this.#activeConnections()).length > 0;\n }\n\n readonly intake: Intake = {\n resolveIntakeDispatch: input => this.#resolveIntakeDispatch(input),\n listSources: () => this.#listSources(),\n listItems: input => this.#listItems(input),\n listIssues: input => this.#listIssues(input),\n getIssue: input => this.#getIssue(input),\n createComment: input => this.#createComment(input),\n updateIssue: input => this.#updateIssue(input),\n };\n\n async #resolveIntakeDispatch({ externalSource }: ResolveIntakeDispatchInput): Promise<ResolvedIntakeDispatch | null> {\n if (externalSource.type !== 'issue') return null;\n const reference = decodeIssueReference(externalSource.externalId);\n if (!reference) return null;\n return {\n connection: jiraConnection(reference.connectionId),\n ...(reference.projectId ? { sourceId: encodeSourceId(reference.connectionId, reference.projectId) } : {}),\n issueId: reference.issueId,\n };\n }\n\n async #listSources(): Promise<IntakeSource[]> {\n const sources: IntakeSource[] = [];\n for (const connection of await this.#activeConnections()) {\n const context = await this.#connectionContext(connection);\n let startAt = 0;\n for (let pageCount = 0; pageCount < PROJECT_SEARCH_MAX_PAGES; pageCount++) {\n const page = await context.api.listProjects({ startAt });\n for (const project of page.values) {\n sources.push({\n id: encodeSourceId(connection.id, project.id),\n name: project.name,\n type: 'project',\n metadata: {\n key: project.key,\n connectionId: connection.id,\n site: new URL(context.siteUrl).host,\n },\n });\n }\n if (page.isLast || page.values.length === 0) break;\n startAt += page.values.length;\n }\n }\n return sources;\n }\n\n async #listItems({ sourceIds, cursor }: ListIntakeItemsInput): Promise<IntakeItemPage> {\n if (sourceIds.length === 0) return { items: [], nextCursor: null };\n const page = await this.listActiveIssues(cursor, sourceIds);\n return {\n items: page.issues.map(issue => ({\n source: { type: 'issue', externalId: issue.externalId, url: issue.url },\n sourceId: issue.sourceId,\n title: `${issue.identifier}: ${issue.title}`,\n status: issue.state ?? undefined,\n labels: issue.labels,\n assignee: issue.assignee,\n createdAt: issue.createdAt,\n updatedAt: issue.updatedAt,\n metadata: {\n identifier: issue.identifier,\n issueRef: issue.externalId,\n state: issue.state,\n stateType: issue.stateType,\n priority: issue.priority,\n project: issue.source,\n site: issue.site,\n assignee: issue.assignee,\n assignees: issue.assignees ?? [],\n creator: issue.author,\n author: issue.author,\n labels: issue.labels,\n createdAt: issue.createdAt,\n updatedAt: issue.updatedAt,\n },\n })),\n nextCursor: page.nextCursor,\n };\n }\n\n async #listIssues(input: ListIntakeIssuesInput): Promise<{ issues: IntakeIssue[]; nextCursor: string | null }> {\n const page = await this.listActiveIssues(input.cursor, input.sourceIds, input.labels);\n return { issues: page.issues, nextCursor: page.nextCursor };\n }\n\n async listActiveIssues(\n cursor?: string,\n sourceIds: string[] = [],\n labels?: string[],\n ): Promise<{\n issues: Array<IntakeIssue & { sourceId: string; externalId: string; site: string }>;\n nextCursor: string | null;\n }> {\n const grouped = groupSources(sourceIds);\n if (grouped.length === 0) return { issues: [], nextCursor: null };\n const decodedCursor = decodePageCursor(cursor);\n if (decodedCursor.group >= grouped.length) return { issues: [], nextCursor: null };\n\n for (let groupIndex = decodedCursor.group; groupIndex < grouped.length; groupIndex++) {\n const group = grouped[groupIndex]!;\n const context = await this.#connectionContextById(group.connectionId);\n const jql = buildIntakeJql(group.projectIds, labels);\n if (jql === null) continue;\n const page = await context.api.searchIssues({\n jql,\n ...(groupIndex === decodedCursor.group && decodedCursor.jira ? { nextPageToken: decodedCursor.jira } : {}),\n });\n const nextCursor = page.nextPageToken\n ? encodePageCursor({ group: groupIndex, jira: page.nextPageToken })\n : groupIndex + 1 < grouped.length\n ? encodePageCursor({ group: groupIndex + 1 })\n : null;\n return {\n issues: page.issues.map(issue => {\n const projectId = issue.fields.project?.id ?? group.projectIds[0] ?? '';\n return {\n ...this.#toIntakeIssue(issue, context.siteUrl),\n sourceId: encodeSourceId(group.connectionId, projectId),\n externalId: encodeIssueReference({ connectionId: group.connectionId, issueId: issue.key, projectId }),\n site: new URL(context.siteUrl).host,\n };\n }),\n nextCursor,\n };\n }\n return { issues: [], nextCursor: null };\n }\n\n async #getIssue(input: GetIntakeIssueInput): Promise<IntakeIssueDetail | null> {\n const { context, issue } = (await this.#findIssue(input)) ?? {};\n if (!context || !issue) return null;\n const { comments, total } = await this.#listAllComments(context.api, issue.key);\n return {\n ...this.#toIntakeIssue(issue, context.siteUrl),\n commentCount: total,\n description: issue.fields.description ? adfToText(issue.fields.description) || null : null,\n comments: comments.map(comment => ({\n author: comment.author?.displayName ?? null,\n body: adfToText(comment.body),\n createdAt: comment.created,\n })),\n };\n }\n\n async #listAllComments(api: JiraApiClient, keyOrId: string): Promise<{ comments: JiraComment[]; total: number }> {\n const comments: JiraComment[] = [];\n let total = 0;\n for (let page = 0; page < ISSUE_COMMENTS_MAX_PAGES; page++) {\n const result = await api.listComments(keyOrId, { startAt: comments.length });\n comments.push(...result.comments);\n total = result.total;\n if (result.comments.length === 0 || comments.length >= total) break;\n }\n return { comments, total };\n }\n\n async #createComment(input: CreateIntakeCommentInput): Promise<CreatedIntakeComment | null> {\n const resolved = await this.#resolveRequest(input);\n let key = resolved.issueId;\n if (!ISSUE_KEY_PATTERN.test(key)) {\n try {\n key = (await resolved.context.api.getIssue(key)).key;\n } catch (error) {\n if (error instanceof JiraApiError && error.status === 404) return null;\n throw error;\n }\n }\n let comment;\n try {\n comment = await resolved.context.api.createComment(key, input.body);\n } catch (error) {\n if (error instanceof JiraApiError && error.status === 404) return null;\n throw error;\n }\n return {\n id: comment.id,\n url: `${resolved.context.siteUrl}/browse/${key}?focusedCommentId=${comment.id}`,\n };\n }\n\n async #updateIssue(input: UpdateIntakeIssueInput): Promise<IntakeIssue | null> {\n const resolved = await this.#resolveRequest(input);\n let issue: JiraIssue;\n try {\n issue = await resolved.context.api.getIssue(resolved.issueId);\n } catch (error) {\n if (error instanceof JiraApiError && error.status === 404) return null;\n throw error;\n }\n if (currentStatusMatches(issue, input.state)) return this.#toIntakeIssue(issue, resolved.context.siteUrl);\n const transitions = await resolved.context.api.listTransitions(issue.key);\n const transition = resolveTransition(transitions, input.state);\n if (!transition) return null;\n await resolved.context.api.applyTransition(issue.key, transition.id);\n return this.#toIntakeIssue(await resolved.context.api.getIssue(issue.key), resolved.context.siteUrl);\n }\n\n async #resolveRequest(input: GetIntakeIssueInput): Promise<{ context: JiraConnectionContext; issueId: string }> {\n const issueReference = decodeIssueReference(input.issueId);\n const source = input.sourceId ? decodeSourceId(input.sourceId) : null;\n const connectionId =\n issueReference?.connectionId ?? source?.connectionId ?? connectionIdFromConnection(input.connection);\n const issueId = issueReference?.issueId ?? input.issueId;\n if (connectionId) return { context: await this.#connectionContextById(connectionId), issueId };\n const active = await this.#activeConnections();\n if (active.length !== 1) {\n throw new JiraApiError('Jira issue reference must identify a connection when multiple sites are connected.', 400);\n }\n return { context: await this.#connectionContext(active[0]!), issueId };\n }\n\n /**\n * Locate an issue for a read. A connection-scoped reference resolves\n * directly; a plain issue key (the agent tool's normal input) is looked up\n * across every active connection so multi-site organizations can still\n * fetch by key — the first site that knows the key wins, which is safe\n * because Jira project-key prefixes make cross-site collisions unlikely and\n * the tool is read-only.\n */\n async #findIssue(input: GetIntakeIssueInput): Promise<{ context: JiraConnectionContext; issue: JiraIssue } | null> {\n const issueReference = decodeIssueReference(input.issueId);\n const source = input.sourceId ? decodeSourceId(input.sourceId) : null;\n const connectionId =\n issueReference?.connectionId ?? source?.connectionId ?? connectionIdFromConnection(input.connection);\n const issueId = issueReference?.issueId ?? input.issueId;\n\n const candidates: JiraConnectionContext[] = [];\n if (connectionId) {\n candidates.push(await this.#connectionContextById(connectionId));\n } else {\n const active = await this.#activeConnections();\n if (active.length === 0) {\n throw new JiraApiError('Jira connection is unavailable or requires reauthentication.', 401);\n }\n for (const connection of active) candidates.push(await this.#connectionContext(connection));\n }\n\n let firstError: unknown;\n for (const context of candidates) {\n try {\n return { context, issue: await context.api.getIssue(issueId) };\n } catch (error) {\n if (error instanceof JiraApiError && error.status === 404) continue;\n firstError ??= error;\n }\n }\n // Not found anywhere. If a site failed for a non-404 reason, surface that\n // failure instead of a silent \"not found\".\n if (firstError !== undefined) throw firstError;\n return null;\n }\n\n #toIntakeIssue(issue: JiraIssue, siteUrl: string): IntakeIssue {\n const { fields } = issue;\n return {\n id: issue.id,\n identifier: issue.key,\n title: fields.summary ?? issue.key,\n url: `${siteUrl}/browse/${issue.key}`,\n author: fields.reporter?.displayName ?? null,\n state: fields.status?.name ?? null,\n stateType: stateTypeFromCategory(fields.status?.statusCategory?.key),\n priority: fields.priority?.name ?? null,\n assignee: fields.assignee?.displayName ?? null,\n source: fields.project?.key ?? null,\n labels: fields.labels ?? [],\n commentCount: null,\n createdAt: fields.created ?? '',\n updatedAt: fields.updated ?? '',\n };\n }\n\n async #activeConnections(): Promise<PlatformIntegrationConnection[]> {\n return (await this.listConnections()).filter(connection => connection.status === 'active');\n }\n\n async #connectionContextById(connectionId: string): Promise<JiraConnectionContext> {\n const connection = (await this.#activeConnections()).find(candidate => candidate.id === connectionId);\n if (!connection) {\n throw new JiraApiError('Jira connection is unavailable or requires reauthentication.', 401);\n }\n return this.#connectionContext(connection);\n }\n\n async #cloudId(connectionId: string): Promise<string> {\n const cached = this.#cloudIdByConnectionId.get(connectionId);\n if (cached) return cached;\n\n const context = await this.#platformClient.request<PlatformConnectionContextResponse>(\n 'GET',\n `/v2/connections/${encodeURIComponent(connectionId)}/context`,\n );\n const cloudId = context.connection_config?.cloudId;\n if (typeof cloudId !== 'string' || !UUID_PATTERN.test(cloudId)) {\n throw new JiraApiError('Platform Jira connection context is missing a valid cloudId.', 502);\n }\n this.#cloudIdByConnectionId.set(connectionId, cloudId);\n return cloudId;\n }\n\n async #connectionContext(connection: PlatformIntegrationConnection): Promise<JiraConnectionContext> {\n const proxyBaseUrl = `${this.#clientConfig.baseUrl.replace(/\\/+$/, '')}/v2/connections/${encodeURIComponent(\n connection.id,\n )}/proxy`;\n const cloudId = await this.#cloudId(connection.id);\n const api = new JiraApiClient({\n baseUrl: `${proxyBaseUrl}/ex/jira/${encodeURIComponent(cloudId)}`,\n accessToken: this.#clientConfig.accessToken,\n ...(this.#clientConfig.projectId ? { projectId: this.#clientConfig.projectId } : {}),\n ...(this.#clientConfig.fetchImpl ? { fetchImpl: this.#clientConfig.fetchImpl } : {}),\n });\n let siteUrl = this.#siteUrlByConnectionId.get(connection.id);\n if (!siteUrl) {\n siteUrl = connection.accountLabel\n ? normalizeSiteUrl(connection.accountLabel)\n : normalizeSiteUrl((await api.getServerInfo()).baseUrl);\n this.#siteUrlByConnectionId.set(connection.id, siteUrl);\n }\n return { connection, api, siteUrl };\n }\n\n workers(ctx: IntegrationContext): MastraWorker[] {\n if (!jiraReconciliationEnabled()) return [];\n const reconcile = attachJiraIssueReconciler(this, ctx);\n if (!reconcile) return [];\n const intervalMs = jiraReconciliationInterval();\n return [\n new IssueReconcileWorker({\n integrationId: this.id,\n reconcile,\n ...(intervalMs ? { intervalMs } : {}),\n }),\n ];\n }\n\n routes(ctx: IntegrationContext): ApiRoute[] {\n return buildPlatformJiraRoutes({\n jira: this,\n auth: ctx.auth,\n intake: ctx.storage.intake,\n appDbConfigured: Boolean(ctx.factoryStorage),\n ingestFactoryIssues: attachJiraRules(this, ctx),\n });\n }\n\n async agentTools(args: { requestContext: RequestContext }): Promise<IntegrationTools> {\n return buildPlatformJiraAgentTools({ requestContext: args.requestContext, jira: this });\n }\n\n diagnostics(): Record<string, unknown> {\n return { configured: true, mode: 'platform', endpointHost: this.#endpointHost };\n }\n}\n\nfunction jiraConnection(connectionId: string): IntegrationConnection {\n return { type: 'oauth', accessToken: `${JIRA_CONNECTION_TOKEN_PREFIX}${connectionId}` };\n}\n\nfunction connectionIdFromConnection(connection: IntegrationConnection): string | null {\n if (connection.type !== 'oauth' || !connection.accessToken.startsWith(JIRA_CONNECTION_TOKEN_PREFIX)) return null;\n return connection.accessToken.slice(JIRA_CONNECTION_TOKEN_PREFIX.length) || null;\n}\n\nexport function encodeSourceId(connectionId: string, projectId: string): string {\n return `${JIRA_SOURCE_PREFIX}${Buffer.from(JSON.stringify({ connectionId, projectId })).toString('base64url')}`;\n}\n\nexport function decodeSourceId(sourceId: string): { connectionId: string; projectId: string } | null {\n if (!sourceId.startsWith(JIRA_SOURCE_PREFIX)) return null;\n try {\n const parsed = JSON.parse(\n Buffer.from(sourceId.slice(JIRA_SOURCE_PREFIX.length), 'base64url').toString('utf8'),\n ) as Record<string, unknown>;\n return typeof parsed.connectionId === 'string' && typeof parsed.projectId === 'string'\n ? { connectionId: parsed.connectionId, projectId: parsed.projectId }\n : null;\n } catch {\n return null;\n }\n}\n\nexport function encodeIssueReference(reference: JiraIssueReference): string {\n return `${JIRA_ISSUE_REF_PREFIX}${Buffer.from(JSON.stringify(reference)).toString('base64url')}`;\n}\n\nexport function decodeIssueReference(value: string): JiraIssueReference | null {\n if (!value.startsWith(JIRA_ISSUE_REF_PREFIX)) return null;\n try {\n const parsed = JSON.parse(\n Buffer.from(value.slice(JIRA_ISSUE_REF_PREFIX.length), 'base64url').toString('utf8'),\n ) as Record<string, unknown>;\n if (typeof parsed.connectionId !== 'string' || typeof parsed.issueId !== 'string') return null;\n return {\n connectionId: parsed.connectionId,\n issueId: parsed.issueId,\n ...(typeof parsed.projectId === 'string' ? { projectId: parsed.projectId } : {}),\n };\n } catch {\n return null;\n }\n}\n\nfunction groupSources(sourceIds: string[]): Array<{ connectionId: string; projectIds: string[] }> {\n const groups = new Map<string, Set<string>>();\n for (const sourceId of sourceIds) {\n const source = decodeSourceId(sourceId);\n if (!source) continue;\n const projectIds = groups.get(source.connectionId) ?? new Set<string>();\n projectIds.add(source.projectId);\n groups.set(source.connectionId, projectIds);\n }\n return [...groups.entries()]\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([connectionId, projectIds]) => ({ connectionId, projectIds: [...projectIds].sort() }));\n}\n\nfunction encodePageCursor(cursor: JiraPageCursor): string {\n return Buffer.from(JSON.stringify(cursor)).toString('base64url');\n}\n\nfunction decodePageCursor(cursor: string | undefined): JiraPageCursor {\n if (!cursor) return { group: 0 };\n try {\n const parsed = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8')) as Record<string, unknown>;\n if (!Number.isInteger(parsed.group) || (parsed.group as number) < 0) throw new Error();\n return {\n group: parsed.group as number,\n ...(typeof parsed.jira === 'string' ? { jira: parsed.jira } : {}),\n };\n } catch {\n throw new JiraApiError('Jira pagination cursor is invalid.', 400);\n }\n}\n\nfunction normalizeSiteUrl(value: string): string {\n const candidate = /^https?:\\/\\//i.test(value) ? value : `https://${value}`;\n // `accountLabel` is free-form Platform data — an unparsable value must\n // surface as the classified 502 the routes already handle, not a raw\n // TypeError escaping the connection context.\n let url: URL;\n try {\n url = new URL(candidate);\n } catch {\n throw new JiraApiError('Jira site URL is invalid.', 502);\n }\n if (url.protocol !== 'http:' && url.protocol !== 'https:') throw new JiraApiError('Jira site URL is invalid.', 502);\n return url.origin;\n}\n\nfunction buildIntakeJql(projectIds?: string[], labels?: string[]): string | null {\n const clauses: string[] = [];\n const safeProjects = (projectIds ?? [])\n .map(id => id.trim())\n .filter(id => /^[A-Za-z0-9_]+$/.test(id))\n .map(id => (/^\\d+$/.test(id) ? id : `\"${id}\"`));\n if (projectIds && safeProjects.length === 0) return null;\n if (safeProjects.length > 0) clauses.push(`project IN (${safeProjects.join(', ')})`);\n clauses.push('statusCategory != Done');\n const safeLabels = [...new Set((labels ?? []).map(label => label.trim().replace(/[\"\\\\]/g, '')).filter(Boolean))];\n if (safeLabels.length > 0) clauses.push(`labels IN (${safeLabels.map(label => `\"${label}\"`).join(', ')})`);\n return `${clauses.join(' AND ')} ORDER BY updated DESC`;\n}\n\nfunction currentStatusMatches(issue: JiraIssue, target: UpdateIntakeIssueInput['state']): boolean {\n const status = issue.fields.status;\n if (!status) return false;\n if (target.kind === 'byName') return status.name.toLowerCase() === target.name.toLowerCase();\n if (target.stateType === 'canceled') return status.statusCategory?.key === 'done' && /cancel/i.test(status.name);\n return status.statusCategory?.key === STATE_TYPE_TO_CATEGORY[target.stateType];\n}\n\nfunction resolveTransition(\n transitions: JiraTransition[],\n target: UpdateIntakeIssueInput['state'],\n): JiraTransition | null {\n if (target.kind === 'byName') {\n const wanted = target.name.toLowerCase();\n return transitions.find(transition => transition.to?.name.toLowerCase() === wanted) ?? null;\n }\n if (target.stateType === 'canceled') {\n return (\n transitions.find(\n transition => transition.to?.statusCategory?.key === 'done' && /cancel/i.test(transition.to.name),\n ) ?? null\n );\n }\n const category = STATE_TYPE_TO_CATEGORY[target.stateType];\n return transitions.find(transition => transition.to?.statusCategory?.key === category) ?? null;\n}\n"],"mappings":";;;;;;;;;;;AAsEA,MAAM,2BAA2B;;AAGjC,MAAM,2BAA2B;AACjC,MAAM,oBAAoB;AAC1B,MAAM,oCAAoC;AAC1C,MAAM,eAAe;AACrB,MAAM,+BAA+B;AACrC,MAAM,wBAAwB;AAC9B,MAAM,qBAAqB;AAE3B,MAAM,yBAAgF;CACpF,WAAW;CACX,SAAS;CACT,WAAW;AACb;AAEA,SAAS,sBAAsB,KAAwC;CACrE,QAAQ,KAAR;EACE,KAAK,OACH,OAAO;EACT,KAAK,iBACH,OAAO;EACT,KAAK,QACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAQA,IAAa,0BAAb,MAAmE;CACjE,KAAc;CACd;CACA;CACA;CACA,yCAAkC,IAAI,IAAoB;CAC1D,yCAAkC,IAAI,IAAoB;CAC1D;CACA;CACA,qCAA8B,IAAI,IAA2B;CAE7D;CAEA,IAAI,QAAwB;EAC1B,OAAO,KAAKM;CACd;CAEA,YAAY,SAAwC,CAAC,GAAG;EACtD,KAAKA,SAAS,iBAAiB,OAAO,KAAK;EAC3C,KAAKN,gBAAgB,OAAO,gBAAgB,+BAA+B;EAC3E,KAAKC,kBAAkB,IAAI,kBAAkB,KAAKD,aAAa;EAC/D,KAAKE,gBAAgB,IAAI,IAAI,KAAKF,cAAc,OAAO,CAAC,CAAC;CAC3D;CAEA,WAAW,EAAE,UAAU,QAAqE;EAC1F,KAAKO,YAAY;EACjB,KAAKC,QAAQ;EACb,gBAAgB,yCAAyC,EAAE,cAAc,KAAKN,cAAc,CAAC;CAC/F;CA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C3F,IAAI,OAAO,cAAc,YAAY,OAAO,OAAO,gBAAgB,QAAQ,UAAU,UAAU,KAAK,OAAO,IAAI;CAC/G,OAAO,OAAO,gBAAgB,QAAQ,uBAAuB,OAAO;AACtE;AAEA,SAAS,kBACP,aACA,QACuB;CACvB,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,SAAS,OAAO,KAAK,YAAY;EACvC,OAAO,YAAY,MAAK,eAAc,WAAW,IAAI,KAAK,YAAY,MAAM,MAAM,KAAK;CACzF;CACA,IAAI,OAAO,cAAc,YACvB,OACE,YAAY,MACV,eAAc,WAAW,IAAI,gBAAgB,QAAQ,UAAU,UAAU,KAAK,WAAW,GAAG,IAAI,CAClG,KAAK;CAGT,MAAM,WAAW,uBAAuB,OAAO;CAC/C,OAAO,YAAY,MAAK,eAAc,WAAW,IAAI,gBAAgB,QAAQ,QAAQ,KAAK;AAC5F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/factory",
3
- "version": "0.24.0-alpha.0",
3
+ "version": "0.24.0-alpha.1",
4
4
  "description": "Mastra Software Factory module: the server core behind the Mastra Software Factory — storage domains, integrations, and surfaces for agent-powered software delivery",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -57,11 +57,11 @@
57
57
  "hono": "^4.13.7",
58
58
  "posthog-node": "^5.46.1",
59
59
  "zod": "^4.6.4",
60
- "@mastra/auth-studio": "1.3.10-alpha.0",
61
- "@mastra/auth-workos": "1.6.7-alpha.0",
62
- "@mastra/code-sdk": "1.15.0-alpha.0",
60
+ "@mastra/code-sdk": "1.15.0-alpha.1",
61
+ "@mastra/core": "1.79.0-alpha.1",
63
62
  "@mastra/slack": "1.7.3-alpha.0",
64
- "@mastra/core": "1.78.1-alpha.0"
63
+ "@mastra/auth-workos": "1.6.7-alpha.0",
64
+ "@mastra/auth-studio": "1.3.10-alpha.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/node": "22.20.1",
@@ -71,11 +71,11 @@
71
71
  "typescript-eslint": "^8.57.0",
72
72
  "vitest": "4.1.11",
73
73
  "@internal/lint": "0.0.144",
74
- "@mastra/libsql": "1.26.3-alpha.0",
75
- "@mastra/pg": "1.31.3-alpha.0",
76
- "@mastra/server": "1.78.1-alpha.0",
77
- "@internal/workspace": "0.0.16",
78
- "@internal/types-builder": "0.0.119"
74
+ "@mastra/libsql": "1.27.0-alpha.1",
75
+ "@mastra/pg": "1.32.0-alpha.1",
76
+ "@internal/types-builder": "0.0.119",
77
+ "@mastra/server": "1.79.0-alpha.1",
78
+ "@internal/workspace": "0.0.16"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=22.19.0"