@optifye/dashboard-core 6.2.0 → 6.3.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.
package/dist/index.js CHANGED
@@ -22,9 +22,9 @@ var jsPDF = require('jspdf');
22
22
  var SelectPrimitive = require('@radix-ui/react-select');
23
23
  var videojs = require('video.js');
24
24
  require('video.js/dist/video-js.css');
25
- var stream = require('stream');
26
25
  var sonner = require('sonner');
27
26
  var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
27
+ var stream = require('stream');
28
28
 
29
29
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
30
30
 
@@ -7293,7 +7293,7 @@ var S3ClipsService = class {
7293
7293
  "best_cycle_time",
7294
7294
  "worst_cycle_time",
7295
7295
  "long_cycle_time",
7296
- "cycle_completions",
7296
+ "cycle_completion",
7297
7297
  "bottleneck"
7298
7298
  ];
7299
7299
  console.log(`[S3ClipsService] ${buildIndex ? "Building video index and counting" : "Fast counting"} clips for ${workspaceId} on ${date}, shift ${shiftId}`);
@@ -29493,386 +29493,6 @@ var FactoryView = ({
29493
29493
  };
29494
29494
  var AuthenticatedFactoryView = withAuth(FactoryView);
29495
29495
  var FactoryView_default = FactoryView;
29496
-
29497
- // src/lib/api/optifye-agent.ts
29498
- var OPTIFYE_API_URL = "https://optifye-agent-production.up.railway.app";
29499
- var OptifyeAgentClient = class {
29500
- constructor(apiUrl = OPTIFYE_API_URL) {
29501
- this.apiUrl = apiUrl;
29502
- }
29503
- /**
29504
- * Call Optifye Agent for manufacturing analysis
29505
- */
29506
- async getManufacturingInsights(userQuestion, lineId, shiftId, companyId, context) {
29507
- try {
29508
- const requestData = {
29509
- prompt: userQuestion,
29510
- line_id: lineId,
29511
- shift_id: shiftId,
29512
- company_id: companyId
29513
- };
29514
- if (context) {
29515
- requestData.context = context;
29516
- }
29517
- console.log("[OptifyeAgent] Sending request:", requestData);
29518
- const response = await fetch(`${this.apiUrl}/api/custom-analysis`, {
29519
- method: "POST",
29520
- headers: {
29521
- "Content-Type": "application/json"
29522
- },
29523
- body: JSON.stringify(requestData),
29524
- signal: AbortSignal.timeout(6e4)
29525
- // 60 second timeout
29526
- });
29527
- const responseText = await response.text();
29528
- console.log("[OptifyeAgent] Response status:", response.status);
29529
- console.log("[OptifyeAgent] Response text:", responseText);
29530
- let result;
29531
- try {
29532
- result = JSON.parse(responseText);
29533
- } catch (parseError) {
29534
- console.error("[OptifyeAgent] Failed to parse response as JSON:", parseError);
29535
- if (responseText.includes("'Agent' object has no attribute")) {
29536
- return {
29537
- success: false,
29538
- error: "Server error: The AI agent service is experiencing issues. Please try again later or contact support."
29539
- };
29540
- }
29541
- return {
29542
- success: false,
29543
- error: `Invalid response format from server: ${responseText.substring(0, 200)}`
29544
- };
29545
- }
29546
- if (response.ok) {
29547
- return {
29548
- success: result.success ?? true,
29549
- analysis: result.analysis || result.response || result.message || result.data,
29550
- timestamp: result.timestamp,
29551
- error: result.error
29552
- };
29553
- } else {
29554
- const errorMsg = result.error || result.message || `API request failed: ${response.status}`;
29555
- console.error("[OptifyeAgent] API error:", errorMsg);
29556
- if (errorMsg.includes("'Agent' object has no attribute")) {
29557
- return {
29558
- success: false,
29559
- error: "The AI service is currently being updated. Please try again in a few moments."
29560
- };
29561
- }
29562
- return {
29563
- success: false,
29564
- error: errorMsg
29565
- };
29566
- }
29567
- } catch (error) {
29568
- const errorMsg = error instanceof Error ? `Failed to connect to Optifye Agent: ${error.message}` : "Failed to connect to Optifye Agent";
29569
- console.error("[OptifyeAgent] Request failed:", error);
29570
- if (error instanceof Error && error.name === "AbortError") {
29571
- return {
29572
- success: false,
29573
- error: "Request timed out. The AI agent is taking too long to respond. Please try again."
29574
- };
29575
- }
29576
- return {
29577
- success: false,
29578
- error: errorMsg
29579
- };
29580
- }
29581
- }
29582
- /**
29583
- * Check if Optifye Agent API is healthy
29584
- */
29585
- async checkHealth() {
29586
- try {
29587
- const response = await fetch(`${this.apiUrl}/health`, {
29588
- signal: AbortSignal.timeout(1e4)
29589
- // 10 second timeout
29590
- });
29591
- if (response.ok) {
29592
- const healthData = await response.json();
29593
- return healthData.status === "healthy";
29594
- }
29595
- return false;
29596
- } catch (error) {
29597
- console.error("[OptifyeAgent] Health check failed:", error);
29598
- return false;
29599
- }
29600
- }
29601
- };
29602
- var optifyeAgentClient = new OptifyeAgentClient();
29603
- async function getManufacturingInsights(userQuestion, lineId, shiftId, companyId, context) {
29604
- if (!userQuestion || !userQuestion.trim()) {
29605
- return {
29606
- success: false,
29607
- error: "Please provide a question"
29608
- };
29609
- }
29610
- if (!lineId || !companyId) {
29611
- console.warn("[OptifyeAgent] Missing required IDs:", { lineId, companyId });
29612
- }
29613
- return optifyeAgentClient.getManufacturingInsights(
29614
- userQuestion,
29615
- lineId,
29616
- shiftId,
29617
- companyId,
29618
- context
29619
- );
29620
- }
29621
- function createStreamProxyHandler(config) {
29622
- const cloudFrontDomain = config?.cloudFrontDomain || "https://d1eiob0chi5jw.cloudfront.net";
29623
- return async function handler(req, res) {
29624
- if (req.method !== "GET") {
29625
- return res.status(405).json({ error: "Method not allowed" });
29626
- }
29627
- const { path } = req.query;
29628
- if (!path || !Array.isArray(path)) {
29629
- return res.status(400).json({ error: "Missing path parameter" });
29630
- }
29631
- const fullPath = path.join("/");
29632
- const targetUrl = `${cloudFrontDomain}/${fullPath}`;
29633
- try {
29634
- console.log(`[HLS Stream Proxy] Streaming: ${targetUrl}`);
29635
- const response = await fetch(targetUrl, {
29636
- method: "GET",
29637
- headers: {
29638
- "User-Agent": "NextJS-HLS-Stream-Proxy",
29639
- // Pass through range headers for partial content requests
29640
- ...req.headers.range && { "Range": req.headers.range }
29641
- }
29642
- });
29643
- if (!response.ok) {
29644
- console.error(`[HLS Stream Proxy] CloudFront error: ${response.status} ${response.statusText}`);
29645
- return res.status(response.status).json({
29646
- error: `CloudFront request failed: ${response.statusText}`
29647
- });
29648
- }
29649
- const contentType = response.headers.get("content-type") || "application/octet-stream";
29650
- const contentLength = response.headers.get("content-length");
29651
- res.setHeader("Access-Control-Allow-Origin", "*");
29652
- res.setHeader("Access-Control-Allow-Methods", "GET, HEAD");
29653
- res.setHeader("Access-Control-Allow-Headers", "Content-Type, Range");
29654
- res.setHeader("Access-Control-Expose-Headers", "Content-Length, Content-Range");
29655
- res.setHeader("Content-Type", contentType);
29656
- if (contentLength) {
29657
- res.setHeader("Content-Length", contentLength);
29658
- }
29659
- if (fullPath.endsWith(".m3u8")) {
29660
- res.setHeader("Content-Type", "application/vnd.apple.mpegurl");
29661
- } else if (fullPath.endsWith(".ts")) {
29662
- res.setHeader("Content-Type", "video/mp2t");
29663
- }
29664
- if (response.status === 206) {
29665
- res.status(206);
29666
- const contentRange = response.headers.get("content-range");
29667
- if (contentRange) {
29668
- res.setHeader("Content-Range", contentRange);
29669
- }
29670
- res.setHeader("Accept-Ranges", "bytes");
29671
- }
29672
- if (response.body) {
29673
- const reader = response.body.getReader();
29674
- const nodeStream = new stream.Readable({
29675
- async read() {
29676
- try {
29677
- const { done, value } = await reader.read();
29678
- if (done) {
29679
- this.push(null);
29680
- } else {
29681
- this.push(Buffer.from(value));
29682
- }
29683
- } catch (error) {
29684
- console.error("[HLS Stream Proxy] Stream read error:", error);
29685
- this.destroy(error);
29686
- }
29687
- }
29688
- });
29689
- nodeStream.pipe(res);
29690
- req.on("close", () => {
29691
- reader.cancel();
29692
- nodeStream.destroy();
29693
- });
29694
- } else {
29695
- const buffer = await response.arrayBuffer();
29696
- res.send(Buffer.from(buffer));
29697
- }
29698
- } catch (error) {
29699
- console.error("[HLS Stream Proxy] Error:", error);
29700
- res.status(500).json({
29701
- error: "Failed to stream from CloudFront",
29702
- details: error instanceof Error ? error.message : String(error)
29703
- });
29704
- }
29705
- };
29706
- }
29707
- var streamProxyConfig = {
29708
- api: {
29709
- bodyParser: false,
29710
- responseLimit: false
29711
- }
29712
- };
29713
-
29714
- // src/lib/api/slackApi.ts
29715
- var SlackAPI = class {
29716
- /**
29717
- * Sends a support ticket notification to Slack.
29718
- * 1. If slackWebhookUrl is configured, send directly (preferred)
29719
- * 2. Otherwise, if slackProxyEndpoint is configured, send to the proxy
29720
- * If neither is configured, logs a warning.
29721
- */
29722
- static async sendSupportTicketNotification(ticket) {
29723
- try {
29724
- const config = _getDashboardConfigInstance();
29725
- const endpointsConfig = config.endpoints ?? DEFAULT_ENDPOINTS_CONFIG;
29726
- const { slackWebhookUrl, slackProxyEndpoint } = endpointsConfig;
29727
- console.log("SlackAPI Debug - Configuration check:", {
29728
- hasConfig: !!config,
29729
- hasEndpoints: !!config.endpoints,
29730
- slackWebhookUrl: slackWebhookUrl ? "configured" : "not configured",
29731
- slackProxyEndpoint: slackProxyEndpoint ? "configured" : "not configured",
29732
- envVariable: process.env.SLACK_WEBHOOK_URL ? "set" : "not set",
29733
- publicEnvVariable: process.env.NEXT_PUBLIC_SLACK_WEBHOOK_URL ? "set" : "not set"
29734
- });
29735
- if (slackProxyEndpoint) {
29736
- const slackMessage = this.formatSlackMessage(ticket);
29737
- const response = await fetch(slackProxyEndpoint, {
29738
- method: "POST",
29739
- headers: {
29740
- "Content-Type": "application/json"
29741
- },
29742
- body: JSON.stringify(slackMessage)
29743
- });
29744
- if (!response.ok) {
29745
- const errorData = await response.json().catch(() => ({ message: "Unknown error" }));
29746
- throw new Error(errorData.message || `Proxy failed with status: ${response.status}`);
29747
- }
29748
- console.log("Support ticket notification sent to Slack successfully via proxy");
29749
- return;
29750
- }
29751
- if (slackWebhookUrl) {
29752
- const slackMessage = this.formatSlackMessage(ticket);
29753
- const response = await fetch(slackWebhookUrl, {
29754
- method: "POST",
29755
- headers: {
29756
- "Content-Type": "application/json"
29757
- },
29758
- body: JSON.stringify(slackMessage)
29759
- });
29760
- if (!response.ok) {
29761
- const errorText = await response.text();
29762
- console.error("Slack webhook error:", errorText);
29763
- throw new Error(`Slack webhook failed with status: ${response.status}`);
29764
- }
29765
- console.log("Support ticket notification sent to Slack successfully via webhook");
29766
- return;
29767
- }
29768
- console.warn("Slack notification skipped: No webhook or proxy endpoint configured");
29769
- console.info("To fix this, either:");
29770
- console.info("1. Set up a server-side proxy endpoint and configure slackProxyEndpoint in your dashboard config");
29771
- console.info("2. For development only: use NEXT_PUBLIC_SLACK_WEBHOOK_URL (not recommended for production)");
29772
- console.info("3. Configure the webhook URL directly in your dashboard config at runtime");
29773
- } catch (error) {
29774
- console.error("Failed to send Slack notification:", error);
29775
- throw error;
29776
- }
29777
- }
29778
- /**
29779
- * Formats a support ticket into a Slack message format
29780
- * This can be used by server-side implementations
29781
- */
29782
- static formatSlackMessage(ticket) {
29783
- const timestamp = new Date(ticket.timestamp).toLocaleString("en-US", {
29784
- dateStyle: "medium",
29785
- timeStyle: "short",
29786
- timeZone: "UTC"
29787
- });
29788
- const maxDescriptionLength = 300;
29789
- const description = ticket.description.length > maxDescriptionLength ? `${ticket.description.substring(0, maxDescriptionLength)}...` : ticket.description;
29790
- const categoryConfig = {
29791
- general: { emoji: "\u{1F4AC}", color: "#36a64f" },
29792
- technical: { emoji: "\u{1F527}", color: "#ff6b6b" },
29793
- feature: { emoji: "\u2728", color: "#4ecdc4" },
29794
- billing: { emoji: "\u{1F4B3}", color: "#f7b731" }
29795
- };
29796
- const priorityConfig = {
29797
- low: { emoji: "\u{1F7E2}", color: "#36a64f" },
29798
- normal: { emoji: "\u{1F7E1}", color: "#ffc107" },
29799
- high: { emoji: "\u{1F7E0}", color: "#ff8c00" },
29800
- urgent: { emoji: "\u{1F534}", color: "#dc3545" }
29801
- };
29802
- const categoryInfo = categoryConfig[ticket.category] || categoryConfig.general;
29803
- const priorityInfo = priorityConfig[ticket.priority] || priorityConfig.normal;
29804
- const messageColor = ticket.priority === "high" || ticket.priority === "urgent" ? priorityInfo.color : categoryInfo.color;
29805
- return {
29806
- text: `New support ticket from ${ticket.email}`,
29807
- blocks: [
29808
- {
29809
- type: "header",
29810
- text: {
29811
- type: "plain_text",
29812
- text: "\u{1F3AB} New Support Ticket Submitted",
29813
- emoji: true
29814
- }
29815
- },
29816
- {
29817
- type: "section",
29818
- fields: [
29819
- {
29820
- type: "mrkdwn",
29821
- text: `*From:*
29822
- ${ticket.email}`
29823
- },
29824
- {
29825
- type: "mrkdwn",
29826
- text: `*Category:*
29827
- ${categoryInfo.emoji} ${ticket.category.charAt(0).toUpperCase() + ticket.category.slice(1)}`
29828
- },
29829
- {
29830
- type: "mrkdwn",
29831
- text: `*Priority:*
29832
- ${priorityInfo.emoji} ${ticket.priority.charAt(0).toUpperCase() + ticket.priority.slice(1)}`
29833
- },
29834
- {
29835
- type: "mrkdwn",
29836
- text: `*Subject:*
29837
- ${ticket.subject}`
29838
- },
29839
- {
29840
- type: "mrkdwn",
29841
- text: `*Submitted:*
29842
- ${timestamp} UTC`
29843
- }
29844
- ]
29845
- },
29846
- {
29847
- type: "section",
29848
- text: {
29849
- type: "mrkdwn",
29850
- text: `*Description:*
29851
- ${description}`
29852
- }
29853
- },
29854
- {
29855
- type: "divider"
29856
- },
29857
- {
29858
- type: "context",
29859
- elements: [
29860
- {
29861
- type: "mrkdwn",
29862
- text: `Category: \`${ticket.category}\` | Priority: ${priorityInfo.emoji} \`${ticket.priority.toUpperCase()}\` | ${ticket.priority === "urgent" ? "\u26A0\uFE0F Requires immediate attention" : "Standard processing"}`
29863
- }
29864
- ]
29865
- }
29866
- ],
29867
- attachments: [
29868
- {
29869
- color: messageColor,
29870
- fields: []
29871
- }
29872
- ]
29873
- };
29874
- }
29875
- };
29876
29496
  var HelpView = ({
29877
29497
  onTicketSubmit,
29878
29498
  supportEmail = "support@optifye.com"
@@ -29937,11 +29557,6 @@ var HelpView = ({
29937
29557
  category: ticket.category,
29938
29558
  priority: ticket.priority
29939
29559
  });
29940
- try {
29941
- await SlackAPI.sendSupportTicketNotification(ticket);
29942
- } catch (slackError) {
29943
- console.error("Failed to send Slack notification:", slackError);
29944
- }
29945
29560
  if (onTicketSubmit) {
29946
29561
  await onTicketSubmit(ticket);
29947
29562
  } else {
@@ -35907,6 +35522,223 @@ var S3Service = class {
35907
35522
  }
35908
35523
  };
35909
35524
 
35525
+ // src/lib/api/optifye-agent.ts
35526
+ var OPTIFYE_API_URL = "https://optifye-agent-production.up.railway.app";
35527
+ var OptifyeAgentClient = class {
35528
+ constructor(apiUrl = OPTIFYE_API_URL) {
35529
+ this.apiUrl = apiUrl;
35530
+ }
35531
+ /**
35532
+ * Call Optifye Agent for manufacturing analysis
35533
+ */
35534
+ async getManufacturingInsights(userQuestion, lineId, shiftId, companyId, context) {
35535
+ try {
35536
+ const requestData = {
35537
+ prompt: userQuestion,
35538
+ line_id: lineId,
35539
+ shift_id: shiftId,
35540
+ company_id: companyId
35541
+ };
35542
+ if (context) {
35543
+ requestData.context = context;
35544
+ }
35545
+ console.log("[OptifyeAgent] Sending request:", requestData);
35546
+ const response = await fetch(`${this.apiUrl}/api/custom-analysis`, {
35547
+ method: "POST",
35548
+ headers: {
35549
+ "Content-Type": "application/json"
35550
+ },
35551
+ body: JSON.stringify(requestData),
35552
+ signal: AbortSignal.timeout(6e4)
35553
+ // 60 second timeout
35554
+ });
35555
+ const responseText = await response.text();
35556
+ console.log("[OptifyeAgent] Response status:", response.status);
35557
+ console.log("[OptifyeAgent] Response text:", responseText);
35558
+ let result;
35559
+ try {
35560
+ result = JSON.parse(responseText);
35561
+ } catch (parseError) {
35562
+ console.error("[OptifyeAgent] Failed to parse response as JSON:", parseError);
35563
+ if (responseText.includes("'Agent' object has no attribute")) {
35564
+ return {
35565
+ success: false,
35566
+ error: "Server error: The AI agent service is experiencing issues. Please try again later or contact support."
35567
+ };
35568
+ }
35569
+ return {
35570
+ success: false,
35571
+ error: `Invalid response format from server: ${responseText.substring(0, 200)}`
35572
+ };
35573
+ }
35574
+ if (response.ok) {
35575
+ return {
35576
+ success: result.success ?? true,
35577
+ analysis: result.analysis || result.response || result.message || result.data,
35578
+ timestamp: result.timestamp,
35579
+ error: result.error
35580
+ };
35581
+ } else {
35582
+ const errorMsg = result.error || result.message || `API request failed: ${response.status}`;
35583
+ console.error("[OptifyeAgent] API error:", errorMsg);
35584
+ if (errorMsg.includes("'Agent' object has no attribute")) {
35585
+ return {
35586
+ success: false,
35587
+ error: "The AI service is currently being updated. Please try again in a few moments."
35588
+ };
35589
+ }
35590
+ return {
35591
+ success: false,
35592
+ error: errorMsg
35593
+ };
35594
+ }
35595
+ } catch (error) {
35596
+ const errorMsg = error instanceof Error ? `Failed to connect to Optifye Agent: ${error.message}` : "Failed to connect to Optifye Agent";
35597
+ console.error("[OptifyeAgent] Request failed:", error);
35598
+ if (error instanceof Error && error.name === "AbortError") {
35599
+ return {
35600
+ success: false,
35601
+ error: "Request timed out. The AI agent is taking too long to respond. Please try again."
35602
+ };
35603
+ }
35604
+ return {
35605
+ success: false,
35606
+ error: errorMsg
35607
+ };
35608
+ }
35609
+ }
35610
+ /**
35611
+ * Check if Optifye Agent API is healthy
35612
+ */
35613
+ async checkHealth() {
35614
+ try {
35615
+ const response = await fetch(`${this.apiUrl}/health`, {
35616
+ signal: AbortSignal.timeout(1e4)
35617
+ // 10 second timeout
35618
+ });
35619
+ if (response.ok) {
35620
+ const healthData = await response.json();
35621
+ return healthData.status === "healthy";
35622
+ }
35623
+ return false;
35624
+ } catch (error) {
35625
+ console.error("[OptifyeAgent] Health check failed:", error);
35626
+ return false;
35627
+ }
35628
+ }
35629
+ };
35630
+ var optifyeAgentClient = new OptifyeAgentClient();
35631
+ async function getManufacturingInsights(userQuestion, lineId, shiftId, companyId, context) {
35632
+ if (!userQuestion || !userQuestion.trim()) {
35633
+ return {
35634
+ success: false,
35635
+ error: "Please provide a question"
35636
+ };
35637
+ }
35638
+ if (!lineId || !companyId) {
35639
+ console.warn("[OptifyeAgent] Missing required IDs:", { lineId, companyId });
35640
+ }
35641
+ return optifyeAgentClient.getManufacturingInsights(
35642
+ userQuestion,
35643
+ lineId,
35644
+ shiftId,
35645
+ companyId,
35646
+ context
35647
+ );
35648
+ }
35649
+ function createStreamProxyHandler(config) {
35650
+ const cloudFrontDomain = config?.cloudFrontDomain || "https://d1eiob0chi5jw.cloudfront.net";
35651
+ return async function handler(req, res) {
35652
+ if (req.method !== "GET") {
35653
+ return res.status(405).json({ error: "Method not allowed" });
35654
+ }
35655
+ const { path } = req.query;
35656
+ if (!path || !Array.isArray(path)) {
35657
+ return res.status(400).json({ error: "Missing path parameter" });
35658
+ }
35659
+ const fullPath = path.join("/");
35660
+ const targetUrl = `${cloudFrontDomain}/${fullPath}`;
35661
+ try {
35662
+ console.log(`[HLS Stream Proxy] Streaming: ${targetUrl}`);
35663
+ const response = await fetch(targetUrl, {
35664
+ method: "GET",
35665
+ headers: {
35666
+ "User-Agent": "NextJS-HLS-Stream-Proxy",
35667
+ // Pass through range headers for partial content requests
35668
+ ...req.headers.range && { "Range": req.headers.range }
35669
+ }
35670
+ });
35671
+ if (!response.ok) {
35672
+ console.error(`[HLS Stream Proxy] CloudFront error: ${response.status} ${response.statusText}`);
35673
+ return res.status(response.status).json({
35674
+ error: `CloudFront request failed: ${response.statusText}`
35675
+ });
35676
+ }
35677
+ const contentType = response.headers.get("content-type") || "application/octet-stream";
35678
+ const contentLength = response.headers.get("content-length");
35679
+ res.setHeader("Access-Control-Allow-Origin", "*");
35680
+ res.setHeader("Access-Control-Allow-Methods", "GET, HEAD");
35681
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type, Range");
35682
+ res.setHeader("Access-Control-Expose-Headers", "Content-Length, Content-Range");
35683
+ res.setHeader("Content-Type", contentType);
35684
+ if (contentLength) {
35685
+ res.setHeader("Content-Length", contentLength);
35686
+ }
35687
+ if (fullPath.endsWith(".m3u8")) {
35688
+ res.setHeader("Content-Type", "application/vnd.apple.mpegurl");
35689
+ } else if (fullPath.endsWith(".ts")) {
35690
+ res.setHeader("Content-Type", "video/mp2t");
35691
+ }
35692
+ if (response.status === 206) {
35693
+ res.status(206);
35694
+ const contentRange = response.headers.get("content-range");
35695
+ if (contentRange) {
35696
+ res.setHeader("Content-Range", contentRange);
35697
+ }
35698
+ res.setHeader("Accept-Ranges", "bytes");
35699
+ }
35700
+ if (response.body) {
35701
+ const reader = response.body.getReader();
35702
+ const nodeStream = new stream.Readable({
35703
+ async read() {
35704
+ try {
35705
+ const { done, value } = await reader.read();
35706
+ if (done) {
35707
+ this.push(null);
35708
+ } else {
35709
+ this.push(Buffer.from(value));
35710
+ }
35711
+ } catch (error) {
35712
+ console.error("[HLS Stream Proxy] Stream read error:", error);
35713
+ this.destroy(error);
35714
+ }
35715
+ }
35716
+ });
35717
+ nodeStream.pipe(res);
35718
+ req.on("close", () => {
35719
+ reader.cancel();
35720
+ nodeStream.destroy();
35721
+ });
35722
+ } else {
35723
+ const buffer = await response.arrayBuffer();
35724
+ res.send(Buffer.from(buffer));
35725
+ }
35726
+ } catch (error) {
35727
+ console.error("[HLS Stream Proxy] Error:", error);
35728
+ res.status(500).json({
35729
+ error: "Failed to stream from CloudFront",
35730
+ details: error instanceof Error ? error.message : String(error)
35731
+ });
35732
+ }
35733
+ };
35734
+ }
35735
+ var streamProxyConfig = {
35736
+ api: {
35737
+ bodyParser: false,
35738
+ responseLimit: false
35739
+ }
35740
+ };
35741
+
35910
35742
  exports.ACTION_NAMES = ACTION_NAMES;
35911
35743
  exports.AIAgentView = AIAgentView_default;
35912
35744
  exports.AuthCallback = AuthCallback;
@@ -36013,7 +35845,6 @@ exports.ShiftsView = ShiftsView_default;
36013
35845
  exports.SideNavBar = SideNavBar;
36014
35846
  exports.SingleVideoStream = SingleVideoStream_default;
36015
35847
  exports.Skeleton = Skeleton;
36016
- exports.SlackAPI = SlackAPI;
36017
35848
  exports.SubscriptionManager = SubscriptionManager;
36018
35849
  exports.SubscriptionManagerProvider = SubscriptionManagerProvider;
36019
35850
  exports.SupabaseProvider = SupabaseProvider;