Skip to content

Commit 18a2250

Browse files
committed
Add automate/settings/sitemap guides
1 parent 534c0a0 commit 18a2250

4 files changed

Lines changed: 805 additions & 0 deletions

File tree

.vitepress/sidebars/guides.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ export const guidesSidebar: DefaultTheme.SidebarItem[] = [
7676
text: "Customize the Command Palette",
7777
link: "/guides/command_palette_advanced",
7878
},
79+
{
80+
text: "Custom Settings Pages",
81+
link: "/guides/settings",
82+
},
7983
],
8084
},
8185
{
@@ -106,6 +110,14 @@ export const guidesSidebar: DefaultTheme.SidebarItem[] = [
106110
text: "Manage Replay Sessions",
107111
link: "/guides/replay",
108112
},
113+
{
114+
text: "Manage Automate Sessions",
115+
link: "/guides/automate",
116+
},
117+
{
118+
text: "Manage Sitemap",
119+
link: "/guides/sitemap",
120+
},
109121
{
110122
text: "Manage Match and Replace",
111123
link: "/guides/match_replace",

src/guides/automate.md

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# Manage Automate Sessions and Entries
2+
3+
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.
4+
5+
## Session Management
6+
7+
### Getting Sessions
8+
9+
To retrieve all automate sessions:
10+
11+
```ts
12+
const sessions = sdk.automate.getSessions();
13+
```
14+
15+
Each session contains:
16+
- `id` - The unique identifier
17+
- `name` - The session name
18+
- `createdAt` - The creation date
19+
- `entryIds` - Array of entry IDs in the session
20+
21+
### Getting Entries
22+
23+
To get all entries for a specific session:
24+
25+
```ts
26+
const entries = sdk.automate.getEntries(sessionId);
27+
```
28+
29+
Each entry contains:
30+
- `id` - The unique identifier
31+
- `name` - The entry name
32+
- `createdAt` - The creation date
33+
34+
## Adding Indicators
35+
36+
Indicators are visual badges displayed next to entry names in the collections tree. They're useful for highlighting important entries or showing status information.
37+
38+
### Adding an Entry Indicator
39+
40+
```ts
41+
const indicator = sdk.automate.addEntryIndicator(entryId, {
42+
icon: "fas fa-exclamation-triangle",
43+
description: "Security warning",
44+
});
45+
```
46+
47+
The `addEntryIndicator` method returns a handle object with a `remove` method to remove the indicator later:
48+
49+
```ts
50+
// Later, remove the indicator
51+
indicator.remove();
52+
```
53+
54+
### Indicator Options
55+
56+
- `icon` - Font Awesome icon class (e.g., `"fas fa-check"`, `"fas fa-warning"`)
57+
- `description` - Tooltip text shown on hover
58+
59+
## Extending Editors
60+
61+
You can add CodeMirror extensions to the request editor on the Automate page:
62+
63+
```ts
64+
import { Extension } from "@codemirror/state";
65+
66+
const myExtension: Extension = [
67+
// Your CodeMirror extension configuration
68+
];
69+
70+
sdk.automate.addRequestEditorExtension(myExtension);
71+
```
72+
73+
For more information on creating editor extensions, see the [Extend Editors](/guides/editor_extensions.md) guide.
74+
75+
## Adding View Modes
76+
77+
You can add custom request and response view modes to the Automate page:
78+
79+
### Request View Modes
80+
81+
```ts
82+
sdk.automate.addRequestViewMode({
83+
label: "My Custom View",
84+
view: {
85+
component: MyComponent,
86+
},
87+
});
88+
```
89+
90+
### Response View Modes
91+
92+
```ts
93+
sdk.automate.addResponseViewMode({
94+
label: "My Custom Response View",
95+
view: {
96+
component: MyResponseComponent,
97+
},
98+
});
99+
```
100+
101+
For more information on creating view modes, see the [Add View Modes](/guides/view_modes.md) guide.
102+
103+
## Page Context
104+
105+
You can access the Automate page context to get information about the current state:
106+
107+
```ts
108+
const context = sdk.window.getPageContext();
109+
if (context?.kind === "Automate") {
110+
// Access Automate-specific context
111+
const { selection, requestSelection } = context;
112+
}
113+
```
114+
115+
The Automate page context includes:
116+
- `kind` - Always `"Automate"`
117+
- `selection` - Current selection of sessions or entries
118+
- `requestSelection` - Current request selection
119+
120+
## Examples
121+
122+
### Session Monitor Plugin
123+
124+
This example creates a plugin that monitors automate sessions and adds indicators to entries based on custom criteria:
125+
126+
```ts
127+
import type { Caido } from "@caido/sdk-frontend";
128+
129+
export type CaidoSDK = Caido;
130+
131+
export const init = (sdk: CaidoSDK) => {
132+
const checkEntries = () => {
133+
const sessions = sdk.automate.getSessions();
134+
135+
sessions.forEach((session) => {
136+
const entries = sdk.automate.getEntries(session.id);
137+
138+
entries.forEach((entry) => {
139+
// Add indicator for entries created in the last hour
140+
const oneHourAgo = Date.now() - 60 * 60 * 1000;
141+
if (entry.createdAt.getTime() > oneHourAgo) {
142+
sdk.automate.addEntryIndicator(entry.id, {
143+
icon: "fas fa-clock",
144+
description: "Recently created",
145+
});
146+
}
147+
});
148+
});
149+
};
150+
151+
// Check entries periodically
152+
setInterval(checkEntries, 60000); // Every minute
153+
154+
// Initial check
155+
checkEntries();
156+
};
157+
```
158+
159+
### Custom Request Analyzer
160+
161+
This example adds a custom view mode to analyze automate requests:
162+
163+
```vue
164+
<script setup lang="ts">
165+
import { computed } from "vue";
166+
import type { Caido, RequestFull } from "@caido/sdk-frontend";
167+
168+
const props = defineProps<{
169+
sdk: Caido;
170+
request: RequestFull;
171+
}>();
172+
173+
const analysis = computed(() => {
174+
const body = props.request.body || "";
175+
const headers = props.request.headers || {};
176+
177+
return {
178+
bodySize: body.length,
179+
hasAuth: !!headers.authorization,
180+
method: props.request.method,
181+
};
182+
});
183+
</script>
184+
185+
<template>
186+
<div class="p-4">
187+
<h3 class="font-bold mb-2">Request Analysis</h3>
188+
<div class="space-y-1">
189+
<div>Body Size: {{ analysis.bodySize }} bytes</div>
190+
<div>Has Auth: {{ analysis.hasAuth ? "Yes" : "No" }}</div>
191+
<div>Method: {{ analysis.method }}</div>
192+
</div>
193+
</div>
194+
</template>
195+
```
196+
197+
```ts
198+
import type { Caido } from "@caido/sdk-frontend";
199+
import RequestAnalyzer from "./RequestAnalyzer.vue";
200+
201+
export type CaidoSDK = Caido;
202+
203+
export const init = (sdk: CaidoSDK) => {
204+
sdk.automate.addRequestViewMode({
205+
label: "Request Analyzer",
206+
view: {
207+
component: RequestAnalyzer,
208+
},
209+
});
210+
};
211+
```
212+

0 commit comments

Comments
 (0)