Skip to content

feat: add status check route sdk for Maxun CLI#1012

Merged
amhsirak merged 3 commits intodevelopfrom
add-status
Mar 24, 2026
Merged

feat: add status check route sdk for Maxun CLI#1012
amhsirak merged 3 commits intodevelopfrom
add-status

Conversation

@RohitR311
Copy link
Collaborator

@RohitR311 RohitR311 commented Mar 24, 2026

What this PR does?

Adds a status check route in sdk for Maxun CLI support.

Summary by CodeRabbit

  • New Features

    • New SDK status endpoint returning authenticated user info (email, plan, credits).
    • Execution responses now include extracted text, markdown, and HTML outputs when available.
    • Crawl and search robot creations now record requested output formats.
  • Bug Fixes

    • Robot creation/execution better recognizes robot type from alternate metadata, improving handling of scrape vs. extract runs.
  • Behavior Change

    • When search robots specify output formats, search mode is now forced to scrape.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2026

Walkthrough

Added an authenticated GET /sdk/status endpoint; changed robot-type derivation to prefer meta.type or meta.robotType (default extract); expanded execution responses to include top-level text, markdown, and html; and added formats metadata and mode adjustments for crawl/search robot creation.

Changes

Cohort / File(s) Summary
SDK API & robot creation
server/src/api/sdk.ts
Added authenticated GET /sdk/status route returning { email, plan: 'OSS', credits: 999999 } with try/catch and logging. Updated robot creation to derive robotType from `workflowFile.meta.type
Execution branching based on robot type
server/src/api/record.ts
Changed execution branching to compute `robotType = recording.recording_meta.type

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I hopped through routes and robot trails tonight,

I added status shining bright,
I sniffed meta.type and robotType with care,
Pulled text, markdown, html from hidden lair,
Now formats dance and searches scrape the air.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title focuses on adding a status check route for Maxun CLI, which is only one aspect of the changes. The PR also modifies robot creation, execution responses, and search/crawl configurations. Update the title to reflect the broader scope of changes, such as 'feat: add status route and enhance robot metadata handling for SDK' or similar to better represent all modifications in the PR.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-status

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@server/src/api/sdk.ts`:
- Around line 39-44: The catch block in the status handler currently returns
internal error details to clients (catch (error: any) { logger.error(...);
return res.status(500).json({ error: "Failed to get status", message:
error.message }); }), which can leak internals; instead keep the full error in
server logs via logger.error (include error and error.stack) and return a
generic client-safe JSON (e.g., { error: "Failed to get status" } or a short
user-facing message) from res.status(500).json; update the catch block so
logger.error logs the full error and remove or replace usage of error.message in
the response.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dab1c36c-2de6-4977-8162-8e8d667e98d5

📥 Commits

Reviewing files that changed from the base of the PR and between c7bf0e9 and f88cc70.

📒 Files selected for processing (1)
  • server/src/api/sdk.ts

Comment on lines +39 to +44
} catch (error: any) {
logger.error("Error getting status:", error);
return res.status(500).json({
error: "Failed to get status",
message: error.message
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Do not return raw internal error messages to clients.

On Line 43, message: error.message can expose internals in 500 responses. Keep detailed context in logs and return a generic client-safe message.

🔧 Suggested fix
 } catch (error: any) {
     logger.error("Error getting status:", error);
     return res.status(500).json({
         error: "Failed to get status",
-        message: error.message
+        message: "Internal server error"
     });
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (error: any) {
logger.error("Error getting status:", error);
return res.status(500).json({
error: "Failed to get status",
message: error.message
});
} catch (error: any) {
logger.error("Error getting status:", error);
return res.status(500).json({
error: "Failed to get status",
message: "Internal server error"
});
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/src/api/sdk.ts` around lines 39 - 44, The catch block in the status
handler currently returns internal error details to clients (catch (error: any)
{ logger.error(...); return res.status(500).json({ error: "Failed to get
status", message: error.message }); }), which can leak internals; instead keep
the full error in server logs via logger.error (include error and error.stack)
and return a generic client-safe JSON (e.g., { error: "Failed to get status" }
or a short user-facing message) from res.status(500).json; update the catch
block so logger.error logs the full error and remove or replace usage of
error.message in the response.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
server/src/api/record.ts (1)

698-700: Reuse the resolved robotType for analytics too.

This branch now honors legacy recording_meta.robotType, but Line 1037 and Line 1182 still read recording_meta.type directly for capture(...). Records that only have robotType will execute correctly while analytics still report extract.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/src/api/record.ts` around lines 698 - 700, The analytics still read
recording.recording_meta.type directly even though you resolved robotType
earlier; update the capture(...) calls (the ones that currently access
recording.recording_meta.type) to use the already-resolved robotType variable
instead so analytics honor legacy recording_meta.robotType as well—search for
uses of recording.recording_meta.type near the capture(...) invocations and
replace them with the robotType identifier so both behavior and analytics are
consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@server/src/api/sdk.ts`:
- Around line 69-75: Validate and normalize workflowFile.meta.type/robotType
before persisting: instead of trusting the truthy value used by robotType =
(workflowFile.meta as any).type || (workflowFile.meta as any).robotType ||
'extract', explicitly check that the extracted value is a non-empty string and
one of the supported enum values (e.g., 'extract', 'scrape', ...), otherwise
either set a safe default ('extract') or reject/throw so invalid values like
"scrapper" or "" are not stored; update the logic around robotType and any other
similar usage (also at the later block around lines 102-109) to perform this
whitelist validation before saving recording_meta.type.

---

Nitpick comments:
In `@server/src/api/record.ts`:
- Around line 698-700: The analytics still read recording.recording_meta.type
directly even though you resolved robotType earlier; update the capture(...)
calls (the ones that currently access recording.recording_meta.type) to use the
already-resolved robotType variable instead so analytics honor legacy
recording_meta.robotType as well—search for uses of
recording.recording_meta.type near the capture(...) invocations and replace them
with the robotType identifier so both behavior and analytics are consistent.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7f75573-fdd9-4c6b-b8ff-ac1066c76914

📥 Commits

Reviewing files that changed from the base of the PR and between f88cc70 and dfaf56f.

📒 Files selected for processing (2)
  • server/src/api/record.ts
  • server/src/api/sdk.ts

Comment on lines +69 to 75
const robotType = (workflowFile.meta as any).type || (workflowFile.meta as any).robotType || 'extract';

let enrichedWorkflow: any[] = [];
let extractedUrl: string | undefined;

if (type === 'scrape') {
if (robotType === 'scrape') {
enrichedWorkflow = [];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Reject unsupported robot types before persisting them.

recording_meta.type is treated as an enum elsewhere, but this path currently trusts any truthy meta.type / meta.robotType value and stores it. A typo like "scrapper" — or an empty string silently coerced by || — will be persisted as valid-looking metadata even though downstream execution only understands the supported set.

🔧 Proposed fix
-        const robotType = (workflowFile.meta as any).type || (workflowFile.meta as any).robotType || 'extract';
+        const rawRobotType = (workflowFile.meta as any).type ?? (workflowFile.meta as any).robotType ?? 'extract';
+        const allowedRobotTypes = new Set(['extract', 'scrape', 'crawl', 'search']);
+
+        if (!allowedRobotTypes.has(rawRobotType)) {
+            return res.status(400).json({
+                error: "Invalid robot type. Must be one of: extract, scrape, crawl, search"
+            });
+        }
+
+        const robotType = rawRobotType as 'extract' | 'scrape' | 'crawl' | 'search';

Also applies to: 102-109

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/src/api/sdk.ts` around lines 69 - 75, Validate and normalize
workflowFile.meta.type/robotType before persisting: instead of trusting the
truthy value used by robotType = (workflowFile.meta as any).type ||
(workflowFile.meta as any).robotType || 'extract', explicitly check that the
extracted value is a non-empty string and one of the supported enum values
(e.g., 'extract', 'scrape', ...), otherwise either set a safe default
('extract') or reject/throw so invalid values like "scrapper" or "" are not
stored; update the logic around robotType and any other similar usage (also at
the later block around lines 102-109) to perform this whitelist validation
before saving recording_meta.type.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
server/src/api/sdk.ts (1)

858-860: Silent mode override may cause confusion.

When outputFormats is provided, the user's explicit mode: 'discover' setting is silently overwritten to 'scrape'. This could be unexpected. Consider either rejecting conflicting configurations or informing the user.

💡 Option: reject conflicting configuration
+        if (searchConfig.mode === 'discover' && searchConfig.outputFormats && Array.isArray(searchConfig.outputFormats) && searchConfig.outputFormats.length > 0) {
+            return res.status(400).json({
+                error: "outputFormats requires mode 'scrape'. Remove outputFormats or change mode to 'scrape'."
+            });
+        }
+
         if (searchConfig.outputFormats && Array.isArray(searchConfig.outputFormats) && searchConfig.outputFormats.length > 0) {
             searchConfig.mode = 'scrape';
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@server/src/api/sdk.ts` around lines 858 - 860, The code silently overwrites
searchConfig.mode to 'scrape' whenever searchConfig.outputFormats is present,
which can surprise callers who set mode: 'discover'; update the validation
around searchConfig (checking searchConfig.outputFormats and searchConfig.mode)
to either 1) throw a clear error rejecting the conflicting configuration
(preferred) or 2) emit a visible warning/log and preserve the user's explicit
mode rather than mutating it. Make the change where the current assignment
exists (the block that sets searchConfig.mode = 'scrape') so it performs the
conflict check and either throws/returns a descriptive error referencing
outputFormats and mode, or calls the logger to warn and skips the silent
override; also add/adjust unit tests to cover the conflicting-config behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@server/src/api/sdk.ts`:
- Around line 858-860: The code silently overwrites searchConfig.mode to
'scrape' whenever searchConfig.outputFormats is present, which can surprise
callers who set mode: 'discover'; update the validation around searchConfig
(checking searchConfig.outputFormats and searchConfig.mode) to either 1) throw a
clear error rejecting the conflicting configuration (preferred) or 2) emit a
visible warning/log and preserve the user's explicit mode rather than mutating
it. Make the change where the current assignment exists (the block that sets
searchConfig.mode = 'scrape') so it performs the conflict check and either
throws/returns a descriptive error referencing outputFormats and mode, or calls
the logger to warn and skips the silent override; also add/adjust unit tests to
cover the conflicting-config behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a09e1e1-30ec-40b7-950c-773552057214

📥 Commits

Reviewing files that changed from the base of the PR and between dfaf56f and 36e51b5.

📒 Files selected for processing (1)
  • server/src/api/sdk.ts

@amhsirak amhsirak changed the title feat: add status check route sdk feat: add status check route sdk for Maxun CLI Mar 24, 2026
@amhsirak amhsirak merged commit 7d74d4a into develop Mar 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants