explorbot 0.4.2 → 0.4.3
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/bin/explorbot-cli.ts +6 -1
- package/dist/bin/explorbot-cli.js +5 -1
- package/dist/package.json +1 -1
- package/dist/src/ai/fisherman/request-haul.d.ts +1 -0
- package/dist/src/ai/fisherman/request-haul.js +3 -0
- package/dist/src/ai/fisherman/tools.d.ts +50 -0
- package/dist/src/ai/{fisherman-tools.js → fisherman/tools.js} +78 -13
- package/dist/src/ai/fisherman.d.ts +12 -3
- package/dist/src/ai/fisherman.js +89 -13
- package/dist/src/ai/pilot.d.ts +13 -1
- package/dist/src/ai/pilot.js +20 -7
- package/dist/src/ai/rules.js +2 -0
- package/dist/src/api/request-result.js +3 -1
- package/dist/src/api/request-store.d.ts +6 -1
- package/dist/src/api/request-store.js +55 -17
- package/dist/src/api/xhr-capture.d.ts +2 -0
- package/dist/src/api/xhr-capture.js +35 -10
- package/dist/src/commands/help-json-command.d.ts +31 -0
- package/dist/src/commands/help-json-command.js +58 -0
- package/docs/reference/commands.md +1 -0
- package/docs/reference/configuration.md +4 -0
- package/docs/superpowers/plans/2026-09-03-fisherman-query-api.md +1361 -0
- package/docs/workflow/agentic-usage.md +12 -0
- package/package.json +1 -1
- package/src/ai/fisherman/request-haul.ts +4 -0
- package/src/ai/{fisherman-tools.ts → fisherman/tools.ts} +93 -20
- package/src/ai/fisherman.ts +104 -15
- package/src/ai/pilot.ts +20 -7
- package/src/ai/rules.ts +2 -0
- package/src/api/request-result.ts +2 -1
- package/src/api/request-store.ts +58 -18
- package/src/api/xhr-capture.ts +39 -11
- package/src/commands/help-json-command.ts +74 -0
- package/dist/src/ai/fisherman-tools.d.ts +0 -147
package/src/api/xhr-capture.ts
CHANGED
|
@@ -60,26 +60,25 @@ export class XhrCapture {
|
|
|
60
60
|
this.store.addFailedRequest(failure);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
if (!WRITE_METHODS.has(method)) return;
|
|
64
|
-
|
|
65
63
|
const contentType = response.headers()['content-type'] || '';
|
|
66
64
|
if (!JSON_CONTENT_TYPES.test(contentType)) return;
|
|
67
65
|
|
|
66
|
+
if (method === 'GET') {
|
|
67
|
+
if (status !== 200) return;
|
|
68
|
+
this.captureReadEndpoint(request, response);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!WRITE_METHODS.has(method)) return;
|
|
73
|
+
|
|
68
74
|
if (status === 304) return;
|
|
69
75
|
|
|
70
76
|
const parsedUrl = new URL(url);
|
|
71
77
|
const origin = parsedUrl.pathname + parsedUrl.search;
|
|
72
78
|
const id = generateRequestId(method, parsedUrl.pathname, 'xhr_');
|
|
73
79
|
|
|
74
|
-
const requestHeaders
|
|
75
|
-
|
|
76
|
-
requestHeaders[k] = String(v);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const responseHeaders: Record<string, string> = {};
|
|
80
|
-
for (const [k, v] of Object.entries(response.headers())) {
|
|
81
|
-
responseHeaders[k] = String(v);
|
|
82
|
-
}
|
|
80
|
+
const requestHeaders = this.toHeaderMap(request.headers());
|
|
81
|
+
const responseHeaders = this.toHeaderMap(response.headers());
|
|
83
82
|
|
|
84
83
|
let rawBody = '';
|
|
85
84
|
try {
|
|
@@ -115,4 +114,33 @@ export class XhrCapture {
|
|
|
115
114
|
|
|
116
115
|
this.store.addCapturedRequest(result);
|
|
117
116
|
}
|
|
117
|
+
|
|
118
|
+
private captureReadEndpoint(request: any, response: any): void {
|
|
119
|
+
const parsedUrl = new URL(request.url());
|
|
120
|
+
const requestHeaders = this.toHeaderMap(request.headers());
|
|
121
|
+
|
|
122
|
+
const result = new RequestResult({
|
|
123
|
+
id: generateRequestId('GET', parsedUrl.pathname, 'xhr_'),
|
|
124
|
+
method: 'GET',
|
|
125
|
+
path: parsedUrl.pathname,
|
|
126
|
+
fullUrl: parsedUrl.pathname + parsedUrl.search,
|
|
127
|
+
requestHeaders,
|
|
128
|
+
status: response.status(),
|
|
129
|
+
statusText: response.statusText(),
|
|
130
|
+
responseHeaders: {},
|
|
131
|
+
timing: 0,
|
|
132
|
+
timestamp: new Date(),
|
|
133
|
+
});
|
|
134
|
+
result.rawResponseBodyValue = '';
|
|
135
|
+
|
|
136
|
+
this.store.addReadRequest(result);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private toHeaderMap(headers: Record<string, unknown>): Record<string, string> {
|
|
140
|
+
const map: Record<string, string> = {};
|
|
141
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
142
|
+
map[k] = String(v);
|
|
143
|
+
}
|
|
144
|
+
return map;
|
|
145
|
+
}
|
|
118
146
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
import { EXPLORBOT_ENV_VARS } from '../config.js';
|
|
3
|
+
|
|
4
|
+
const DESCRIPTION = 'Print command definitions as JSON for agents and tools';
|
|
5
|
+
|
|
6
|
+
export class HelpJsonCommand {
|
|
7
|
+
static register(program: Command): void {
|
|
8
|
+
program
|
|
9
|
+
.command('help-json [command...]')
|
|
10
|
+
.description(DESCRIPTION)
|
|
11
|
+
.action(async (names: string[]) => {
|
|
12
|
+
const target = HelpJsonCommand.find(program, names);
|
|
13
|
+
if (!target) {
|
|
14
|
+
console.error(`Unknown command: ${names.join(' ')}`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
const json = JSON.stringify(HelpJsonCommand.data(target, target === program), null, 2);
|
|
18
|
+
await new Promise<void>((resolve) => process.stdout.write(`${json}\n`, () => resolve()));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static data(cmd: Command, root = false): CommandDefinition {
|
|
23
|
+
const helper = cmd.createHelp();
|
|
24
|
+
const definition: CommandDefinition = {
|
|
25
|
+
name: cmd.name(),
|
|
26
|
+
description: cmd.description(),
|
|
27
|
+
aliases: cmd.aliases(),
|
|
28
|
+
arguments: cmd.registeredArguments.map((argument) => ({
|
|
29
|
+
name: argument.name(),
|
|
30
|
+
description: argument.description,
|
|
31
|
+
required: argument.required,
|
|
32
|
+
variadic: argument.variadic,
|
|
33
|
+
})),
|
|
34
|
+
options: helper.visibleOptions(cmd).map((option) => ({
|
|
35
|
+
flags: option.flags,
|
|
36
|
+
description: option.description,
|
|
37
|
+
default: option.defaultValue,
|
|
38
|
+
choices: option.argChoices,
|
|
39
|
+
})),
|
|
40
|
+
commands: helper.visibleCommands(cmd).map((sub) => HelpJsonCommand.data(sub)),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
if (!root) return definition;
|
|
44
|
+
|
|
45
|
+
definition.version = cmd.version();
|
|
46
|
+
definition.env = EXPLORBOT_ENV_VARS.map((variable) => ({
|
|
47
|
+
name: variable.name,
|
|
48
|
+
description: variable.description,
|
|
49
|
+
required: !!variable.required,
|
|
50
|
+
}));
|
|
51
|
+
return definition;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private static find(cmd: Command, names: string[]): Command | undefined {
|
|
55
|
+
let target = cmd;
|
|
56
|
+
for (const name of names) {
|
|
57
|
+
const sub = target.commands.find((candidate) => candidate.name() === name || candidate.aliases().includes(name));
|
|
58
|
+
if (!sub) return undefined;
|
|
59
|
+
target = sub;
|
|
60
|
+
}
|
|
61
|
+
return target;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
interface CommandDefinition {
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
aliases: string[];
|
|
69
|
+
version?: string;
|
|
70
|
+
arguments: { name: string; description: string; required: boolean; variadic: boolean }[];
|
|
71
|
+
options: { flags: string; description: string; default?: unknown; choices?: string[] }[];
|
|
72
|
+
commands: CommandDefinition[];
|
|
73
|
+
env?: { name: string; description: string; required: boolean }[];
|
|
74
|
+
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import type { ApiClient } from '../api/api-client.js';
|
|
2
|
-
import type { RequestStore } from '../api/request-store.js';
|
|
3
|
-
import type { RequestHaul } from './fisherman/request-haul.js';
|
|
4
|
-
export declare function createFishermanTools(apiClient: ApiClient, requestStore: RequestStore, haul: RequestHaul, opts: {
|
|
5
|
-
spec?: any;
|
|
6
|
-
baseEndpoint?: string;
|
|
7
|
-
}): {
|
|
8
|
-
tools: {
|
|
9
|
-
getEndpointSpec: import("@ai-sdk/provider-utils").ExecutableTool<import("ai").Tool<{
|
|
10
|
-
method: any;
|
|
11
|
-
path: any;
|
|
12
|
-
}, {
|
|
13
|
-
source: string;
|
|
14
|
-
method: any;
|
|
15
|
-
path: any;
|
|
16
|
-
definition: string;
|
|
17
|
-
rejectedCapture: {
|
|
18
|
-
status: number;
|
|
19
|
-
requestBody: any;
|
|
20
|
-
};
|
|
21
|
-
usable?: undefined;
|
|
22
|
-
rejectedRequestBody?: undefined;
|
|
23
|
-
status?: undefined;
|
|
24
|
-
requestBody?: undefined;
|
|
25
|
-
error?: undefined;
|
|
26
|
-
} | {
|
|
27
|
-
source: string;
|
|
28
|
-
method: any;
|
|
29
|
-
path: any;
|
|
30
|
-
usable: boolean;
|
|
31
|
-
rejectedRequestBody: any;
|
|
32
|
-
status: number;
|
|
33
|
-
definition?: undefined;
|
|
34
|
-
rejectedCapture?: undefined;
|
|
35
|
-
requestBody?: undefined;
|
|
36
|
-
error?: undefined;
|
|
37
|
-
} | {
|
|
38
|
-
source: string;
|
|
39
|
-
method: string;
|
|
40
|
-
path: string;
|
|
41
|
-
status: number;
|
|
42
|
-
requestBody: any;
|
|
43
|
-
definition?: undefined;
|
|
44
|
-
rejectedCapture?: undefined;
|
|
45
|
-
usable?: undefined;
|
|
46
|
-
rejectedRequestBody?: undefined;
|
|
47
|
-
error?: undefined;
|
|
48
|
-
} | {
|
|
49
|
-
source: string;
|
|
50
|
-
definition: string;
|
|
51
|
-
method?: undefined;
|
|
52
|
-
path?: undefined;
|
|
53
|
-
rejectedCapture?: undefined;
|
|
54
|
-
usable?: undefined;
|
|
55
|
-
rejectedRequestBody?: undefined;
|
|
56
|
-
status?: undefined;
|
|
57
|
-
requestBody?: undefined;
|
|
58
|
-
error?: undefined;
|
|
59
|
-
} | {
|
|
60
|
-
source: string;
|
|
61
|
-
error: any;
|
|
62
|
-
method?: undefined;
|
|
63
|
-
path?: undefined;
|
|
64
|
-
definition?: undefined;
|
|
65
|
-
rejectedCapture?: undefined;
|
|
66
|
-
usable?: undefined;
|
|
67
|
-
rejectedRequestBody?: undefined;
|
|
68
|
-
status?: undefined;
|
|
69
|
-
requestBody?: undefined;
|
|
70
|
-
}, import("@ai-sdk/provider-utils").Context>>;
|
|
71
|
-
request: import("@ai-sdk/provider-utils").ExecutableTool<import("ai").Tool<any, {
|
|
72
|
-
success: boolean;
|
|
73
|
-
error: string;
|
|
74
|
-
status?: undefined;
|
|
75
|
-
statusText?: undefined;
|
|
76
|
-
category?: undefined;
|
|
77
|
-
errorPreview?: undefined;
|
|
78
|
-
extracted?: undefined;
|
|
79
|
-
} | {
|
|
80
|
-
success: boolean;
|
|
81
|
-
status: number;
|
|
82
|
-
statusText: string;
|
|
83
|
-
category: ResponseCategory;
|
|
84
|
-
errorPreview: string;
|
|
85
|
-
error?: undefined;
|
|
86
|
-
extracted?: undefined;
|
|
87
|
-
} | {
|
|
88
|
-
success: boolean;
|
|
89
|
-
status: number;
|
|
90
|
-
extracted: Record<string, any>;
|
|
91
|
-
error?: undefined;
|
|
92
|
-
statusText?: undefined;
|
|
93
|
-
category?: undefined;
|
|
94
|
-
errorPreview?: undefined;
|
|
95
|
-
}, import("@ai-sdk/provider-utils").Context>>;
|
|
96
|
-
finish: import("@ai-sdk/provider-utils").ExecutableTool<import("ai").Tool<{
|
|
97
|
-
summary: string;
|
|
98
|
-
created: {
|
|
99
|
-
type: string;
|
|
100
|
-
id?: string | number;
|
|
101
|
-
title?: string;
|
|
102
|
-
}[];
|
|
103
|
-
failed?: {
|
|
104
|
-
type: string;
|
|
105
|
-
reason: string;
|
|
106
|
-
}[];
|
|
107
|
-
}, {
|
|
108
|
-
finished: boolean;
|
|
109
|
-
error: string;
|
|
110
|
-
} | {
|
|
111
|
-
finished: boolean;
|
|
112
|
-
error?: undefined;
|
|
113
|
-
}, import("@ai-sdk/provider-utils").Context>>;
|
|
114
|
-
stop: import("@ai-sdk/provider-utils").ExecutableTool<import("ai").Tool<{
|
|
115
|
-
reason: any;
|
|
116
|
-
}, {
|
|
117
|
-
stopped: boolean;
|
|
118
|
-
}, import("@ai-sdk/provider-utils").Context>>;
|
|
119
|
-
};
|
|
120
|
-
getResult: () => FishermanResult;
|
|
121
|
-
isFinished: () => boolean;
|
|
122
|
-
finishFromText: (text?: string) => void;
|
|
123
|
-
};
|
|
124
|
-
export declare function verifyFinish(haul: RequestHaul, input: {
|
|
125
|
-
summary: string;
|
|
126
|
-
created: FishermanResult['created'];
|
|
127
|
-
failed?: FishermanResult['failed'];
|
|
128
|
-
}): {
|
|
129
|
-
result: FishermanResult | null;
|
|
130
|
-
error?: string;
|
|
131
|
-
};
|
|
132
|
-
export interface FishermanResult {
|
|
133
|
-
success: boolean;
|
|
134
|
-
summary: string;
|
|
135
|
-
created: Array<{
|
|
136
|
-
type: string;
|
|
137
|
-
id?: string | number;
|
|
138
|
-
title?: string;
|
|
139
|
-
request?: string;
|
|
140
|
-
}>;
|
|
141
|
-
failed: Array<{
|
|
142
|
-
type: string;
|
|
143
|
-
reason: string;
|
|
144
|
-
}>;
|
|
145
|
-
}
|
|
146
|
-
type ResponseCategory = 'validation' | 'authorization' | 'not_found' | 'conflict' | 'temporary' | 'server' | 'client';
|
|
147
|
-
export {};
|