Manage Automate Sessions and Entries
The Automate SDK allows you to interact with the Automate page, manage sessions and entries, add indicators, and extend the request/response editors with custom functionality.
Session Management
Getting Sessions
To retrieve all automate sessions:
const sessions = sdk.automate.getSessions();Each session contains:
id- The unique identifiername- The session namecreatedAt- The creation dateentryIds- Array of entry IDs in the session
Getting Entries
To get all entries for a specific session:
const entries = sdk.automate.getEntries(sessionId);Each entry contains:
id- The unique identifiername- The entry namecreatedAt- The creation date
Adding Indicators
Indicators are visual badges displayed next to entry names in the collections tree. They're useful for highlighting important entries or showing status information.
Adding an Entry Indicator
const indicator = sdk.automate.addEntryIndicator(entryId, {
icon: "fas fa-exclamation-triangle",
description: "Security warning",
});The addEntryIndicator method returns a handle object with a remove method to remove the indicator later:
// Later, remove the indicator
indicator.remove();Indicator Options
icon- Font Awesome icon class (e.g.,"fas fa-check","fas fa-warning")description- Tooltip text shown on hover
Extending Editors
You can add CodeMirror extensions to the request editor on the Automate page:
import { Extension } from "@codemirror/state";
const myExtension: Extension = [
// Your CodeMirror extension configuration
];
sdk.automate.addRequestEditorExtension(myExtension);For more information on creating editor extensions, see the Extend Editors guide.
Adding View Modes
You can add custom request and response view modes to the Automate page:
Request View Modes
sdk.automate.addRequestViewMode({
label: "My Custom View",
view: {
component: MyComponent,
},
});Response View Modes
sdk.automate.addResponseViewMode({
label: "My Custom Response View",
view: {
component: MyResponseComponent,
},
});For more information on creating view modes, see the Add View Modes guide.
Page Context
You can access the Automate page context to get information about the current state:
const context = sdk.window.getPageContext();
if (context?.kind === "Automate") {
// Access Automate-specific context
const { selection, requestSelection } = context;
}The Automate page context includes:
kind- Always"Automate"selection- Current selection of sessions or entriesrequestSelection- Current request selection
Examples
Session Monitor Plugin
This example creates a plugin that monitors automate sessions and adds indicators to entries based on custom criteria:
import type { Caido } from "@caido/sdk-frontend";
export type CaidoSDK = Caido;
export const init = (sdk: CaidoSDK) => {
const checkEntries = () => {
const sessions = sdk.automate.getSessions();
sessions.forEach((session) => {
const entries = sdk.automate.getEntries(session.id);
entries.forEach((entry) => {
// Add indicator for entries created in the last hour
const oneHourAgo = Date.now() - 60 * 60 * 1000;
if (entry.createdAt.getTime() > oneHourAgo) {
sdk.automate.addEntryIndicator(entry.id, {
icon: "fas fa-clock",
description: "Recently created",
});
}
});
});
};
// Check entries periodically
setInterval(checkEntries, 60000); // Every minute
// Initial check
checkEntries();
};Custom Request Analyzer
This example adds a custom view mode to analyze automate requests:
<script setup lang="ts">
import { computed } from "vue";
import type { Caido, RequestFull } from "@caido/sdk-frontend";
const props = defineProps<{
sdk: Caido;
request: RequestFull;
}>();
const analysis = computed(() => {
const body = props.request.body || "";
const headers = props.request.headers || {};
return {
bodySize: body.length,
hasAuth: !!headers.authorization,
method: props.request.method,
};
});
</script>
<template>
<div class="p-4">
<h3 class="font-bold mb-2">Request Analysis</h3>
<div class="space-y-1">
<div>Body Size: {{ analysis.bodySize }} bytes</div>
<div>Has Auth: {{ analysis.hasAuth ? "Yes" : "No" }}</div>
<div>Method: {{ analysis.method }}</div>
</div>
</div>
</template>import type { Caido } from "@caido/sdk-frontend";
import RequestAnalyzer from "./RequestAnalyzer.vue";
export type CaidoSDK = Caido;
export const init = (sdk: CaidoSDK) => {
sdk.automate.addRequestViewMode({
label: "Request Analyzer",
view: {
component: RequestAnalyzer,
},
});
};