@anonx3247/universal-agent-harness 0.1.0
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/LICENSE +21 -0
- package/README.md +265 -0
- package/dist/agent-harness.d.ts +3 -0
- package/dist/agent-harness.d.ts.map +1 -0
- package/dist/agent-harness.js +326 -0
- package/dist/agent-harness.js.map +1 -0
- package/dist/db/index.d.ts +6 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +11 -0
- package/dist/db/index.js.map +1 -0
- package/dist/db/schema.d.ts +335 -0
- package/dist/db/schema.d.ts.map +1 -0
- package/dist/db/schema.js +39 -0
- package/dist/db/schema.js.map +1 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +156 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/assert.d.ts +2 -0
- package/dist/lib/assert.d.ts.map +1 -0
- package/dist/lib/assert.js +4 -0
- package/dist/lib/assert.js.map +1 -0
- package/dist/lib/async.d.ts +18 -0
- package/dist/lib/async.d.ts.map +1 -0
- package/dist/lib/async.js +41 -0
- package/dist/lib/async.js.map +1 -0
- package/dist/lib/error.d.ts +47 -0
- package/dist/lib/error.d.ts.map +1 -0
- package/dist/lib/error.js +101 -0
- package/dist/lib/error.js.map +1 -0
- package/dist/lib/fs.d.ts +3 -0
- package/dist/lib/fs.d.ts.map +1 -0
- package/dist/lib/fs.js +17 -0
- package/dist/lib/fs.js.map +1 -0
- package/dist/lib/mcp-config.d.ts +62 -0
- package/dist/lib/mcp-config.d.ts.map +1 -0
- package/dist/lib/mcp-config.js +80 -0
- package/dist/lib/mcp-config.js.map +1 -0
- package/dist/lib/mcp.d.ts +19 -0
- package/dist/lib/mcp.d.ts.map +1 -0
- package/dist/lib/mcp.js +105 -0
- package/dist/lib/mcp.js.map +1 -0
- package/dist/lib/prompts.d.ts +5 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +63 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/lib/utils.d.ts +5 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +13 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/models/anthropic.d.ts +20 -0
- package/dist/models/anthropic.d.ts.map +1 -0
- package/dist/models/anthropic.js +312 -0
- package/dist/models/anthropic.js.map +1 -0
- package/dist/models/deepseek/index.d.ts +20 -0
- package/dist/models/deepseek/index.d.ts.map +1 -0
- package/dist/models/deepseek/index.js +210 -0
- package/dist/models/deepseek/index.js.map +1 -0
- package/dist/models/gemini.d.ts +20 -0
- package/dist/models/gemini.d.ts.map +1 -0
- package/dist/models/gemini.js +250 -0
- package/dist/models/gemini.js.map +1 -0
- package/dist/models/index.d.ts +70 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +30 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/mistral.d.ts +19 -0
- package/dist/models/mistral.d.ts.map +1 -0
- package/dist/models/mistral.js +259 -0
- package/dist/models/mistral.js.map +1 -0
- package/dist/models/moonshotai.d.ts +20 -0
- package/dist/models/moonshotai.d.ts.map +1 -0
- package/dist/models/moonshotai.js +220 -0
- package/dist/models/moonshotai.js.map +1 -0
- package/dist/models/openai.d.ts +21 -0
- package/dist/models/openai.d.ts.map +1 -0
- package/dist/models/openai.js +302 -0
- package/dist/models/openai.js.map +1 -0
- package/dist/models/provider.d.ts +19 -0
- package/dist/models/provider.d.ts.map +1 -0
- package/dist/models/provider.js +95 -0
- package/dist/models/provider.js.map +1 -0
- package/dist/resources/experiment.d.ts +18 -0
- package/dist/resources/experiment.d.ts.map +1 -0
- package/dist/resources/experiment.js +55 -0
- package/dist/resources/experiment.js.map +1 -0
- package/dist/resources/messages.d.ts +23 -0
- package/dist/resources/messages.d.ts.map +1 -0
- package/dist/resources/messages.js +81 -0
- package/dist/resources/messages.js.map +1 -0
- package/dist/runner/config.d.ts +4 -0
- package/dist/runner/config.d.ts.map +1 -0
- package/dist/runner/config.js +2 -0
- package/dist/runner/config.js.map +1 -0
- package/dist/runner/index.d.ts +41 -0
- package/dist/runner/index.d.ts.map +1 -0
- package/dist/runner/index.js +370 -0
- package/dist/runner/index.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +4 -0
- package/dist/tools/index.js.map +1 -0
- package/package.json +57 -0
- package/profiles/example/prompt.md +54 -0
- package/profiles/example/settings.json +11 -0
- package/profiles/example/settings.json.example +38 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes an array of tasks concurrently with controlled parallelism.
|
|
3
|
+
*
|
|
4
|
+
* This function processes a list of items concurrently while maintaining a maximum number of
|
|
5
|
+
* parallel executions. It uses a shared queue approach where multiple workers pull items to
|
|
6
|
+
* process, ensuring each item is processed exactly once and results are maintained in the original
|
|
7
|
+
* order.
|
|
8
|
+
*
|
|
9
|
+
* @param items - Array of items to be processed
|
|
10
|
+
* @param iterator - Async function that processes each item. Receives the item and its index
|
|
11
|
+
* @param options.concurrency - Maximum number of parallel executions (default: 8)
|
|
12
|
+
* @returns Promise resolving to array of results in the same order as input items.
|
|
13
|
+
*/
|
|
14
|
+
export declare function concurrentExecutor<T, V>(items: T[], iterator: (item: T, idx: number) => Promise<V>, { concurrency }: {
|
|
15
|
+
concurrency: number;
|
|
16
|
+
}): Promise<V[]>;
|
|
17
|
+
export declare const setTimeoutAsync: (ms: number) => Promise<"timeout">;
|
|
18
|
+
//# sourceMappingURL=async.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../src/lib/async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAC3C,KAAK,EAAE,CAAC,EAAE,EACV,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAC9C,EAAE,WAAe,EAAE,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,gBAiC7C;AAED,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,KAAG,OAAO,CAAC,SAAS,CACM,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Executes an array of tasks concurrently with controlled parallelism.
|
|
3
|
+
*
|
|
4
|
+
* This function processes a list of items concurrently while maintaining a maximum number of
|
|
5
|
+
* parallel executions. It uses a shared queue approach where multiple workers pull items to
|
|
6
|
+
* process, ensuring each item is processed exactly once and results are maintained in the original
|
|
7
|
+
* order.
|
|
8
|
+
*
|
|
9
|
+
* @param items - Array of items to be processed
|
|
10
|
+
* @param iterator - Async function that processes each item. Receives the item and its index
|
|
11
|
+
* @param options.concurrency - Maximum number of parallel executions (default: 8)
|
|
12
|
+
* @returns Promise resolving to array of results in the same order as input items.
|
|
13
|
+
*/
|
|
14
|
+
export async function concurrentExecutor(items, iterator, { concurrency = 8 }) {
|
|
15
|
+
const results = new Array(items.length);
|
|
16
|
+
// Initialize queue with work items, preserving original index.
|
|
17
|
+
// This queue is shared between all workers.
|
|
18
|
+
const queue = items.map((item, index) => ({ item, index }));
|
|
19
|
+
/**
|
|
20
|
+
* Worker function that continuously processes items from the shared queue. Multiple instances of
|
|
21
|
+
* this worker run concurrently, each competing for the next available item in the queue. When the
|
|
22
|
+
* queue is empty, the worker terminates.
|
|
23
|
+
*
|
|
24
|
+
* The queue.shift() operation is atomic in JavaScript, ensuring each item is processed exactly
|
|
25
|
+
* once across all workers.
|
|
26
|
+
*/
|
|
27
|
+
async function worker() {
|
|
28
|
+
let work;
|
|
29
|
+
// Continue processing while there are items in the queue.
|
|
30
|
+
while ((work = queue.shift())) {
|
|
31
|
+
const result = await iterator(work.item, work.index);
|
|
32
|
+
results[work.index] = result;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Create and start workers, limiting the number to either the concurrency limit or the number of
|
|
36
|
+
// items, whichever is smaller. All workers share the same queue and results array.
|
|
37
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, () => worker()));
|
|
38
|
+
return results;
|
|
39
|
+
}
|
|
40
|
+
export const setTimeoutAsync = (ms) => new Promise((resolve) => setTimeout(() => resolve("timeout"), ms));
|
|
41
|
+
//# sourceMappingURL=async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async.js","sourceRoot":"","sources":["../../src/lib/async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAU,EACV,QAA8C,EAC9C,EAAE,WAAW,GAAG,CAAC,EAA2B;IAE5C,MAAM,OAAO,GAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE7C,+DAA+D;IAC/D,4CAA4C;IAC5C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAE5D;;;;;;;OAOG;IACH,KAAK,UAAU,MAAM;QACnB,IAAI,IAAS,CAAC;QAEd,0DAA0D;QAC1D,OAAO,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YACrD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,iGAAiG;IACjG,mFAAmF;IACnF,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,MAAM,EAAE,CAAC,CAC5E,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAU,EAAsB,EAAE,CAChE,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Result is a type that can be either Ok or Err. The main motivation behind this utils is to
|
|
3
|
+
* overcome the fact that Javascript does not let you check the type of an object at runtime, so you
|
|
4
|
+
* cannot know if a function returned an error type or a success type.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* ```
|
|
8
|
+
* import {Result, Ok, Err} from "@app/lib/result"
|
|
9
|
+
* function divide(numerator: number, denominator: number) : Result<number, Error> {
|
|
10
|
+
* if (denominator === 0) {
|
|
11
|
+
* return new Err(new Error("Cannot divide by zero"));
|
|
12
|
+
* }
|
|
13
|
+
* return ok(numerator / denominator);
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class Ok<T> {
|
|
18
|
+
value: T;
|
|
19
|
+
constructor(value: T);
|
|
20
|
+
isOk(): this is Ok<T>;
|
|
21
|
+
isErr(): this is Err<never>;
|
|
22
|
+
}
|
|
23
|
+
export declare class Err<E> {
|
|
24
|
+
error: E;
|
|
25
|
+
constructor(error: E);
|
|
26
|
+
isOk(): this is Ok<never>;
|
|
27
|
+
isErr(): this is Err<E>;
|
|
28
|
+
}
|
|
29
|
+
export type Result<T> = Ok<T> | Err<SrchdError>;
|
|
30
|
+
export type ErrorCode = "invalid_parameters_error" | "reading_file_error" | "copy_file_error" | "not_found_error" | "reference_not_found_error" | "experiment_error" | "publication_error" | "model_error" | "tool_error" | "resource_creation_error" | "resource_update_error" | "agent_loop_overflow_error" | "tool_execution_error" | "tool_not_found_error" | "pod_run_error" | "computer_run_error" | "pod_timeout_error" | "image_error" | "web_fetch_error" | "web_search_error" | "pod_deletion_error" | "pod_initialization_error" | "namespace_deletion_error" | "port_forward_error" | "string_edit_error";
|
|
31
|
+
export declare class SrchdError extends Error {
|
|
32
|
+
readonly code: ErrorCode;
|
|
33
|
+
readonly cause?: (Error | null) | undefined;
|
|
34
|
+
constructor(code: ErrorCode, message: string, cause?: (Error | null) | undefined);
|
|
35
|
+
}
|
|
36
|
+
export declare function ok<T>(value: T): Ok<T>;
|
|
37
|
+
export declare function err(code: ErrorCode, message: string, cause?: any): Err<SrchdError>;
|
|
38
|
+
export declare function errorToString(error: unknown): string;
|
|
39
|
+
export declare function normalizeError(error: unknown): Error;
|
|
40
|
+
type RetryOptions = {
|
|
41
|
+
retries?: number;
|
|
42
|
+
delayBetweenRetriesMs?: number;
|
|
43
|
+
retriableCodes?: ErrorCode[];
|
|
44
|
+
};
|
|
45
|
+
export declare function withRetries<T, U>(fn: (arg: T) => Promise<Result<U>>, { retries, delayBetweenRetriesMs, retriableCodes, }?: RetryOptions): (arg: T) => Promise<Result<U>>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/lib/error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AAEH,qBAAa,EAAE,CAAC,CAAC;IACI,KAAK,EAAE,CAAC;gBAAR,KAAK,EAAE,CAAC;IAE3B,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;IAIrB,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC;CAG5B;AAED,qBAAa,GAAG,CAAC,CAAC;IACG,KAAK,EAAE,CAAC;gBAAR,KAAK,EAAE,CAAC;IAE3B,IAAI,IAAI,IAAI,IAAI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EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,SAAS,EAAE,CAAC;CAC9B,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAClC,EACE,OAAW,EACX,qBAA4B,EAC5B,cAA0B,GAC3B,GAAE,YAAiB,GACnB,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CA6BhC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import assert from "assert";
|
|
2
|
+
import { isString } from "./utils";
|
|
3
|
+
/**
|
|
4
|
+
* A Result is a type that can be either Ok or Err. The main motivation behind this utils is to
|
|
5
|
+
* overcome the fact that Javascript does not let you check the type of an object at runtime, so you
|
|
6
|
+
* cannot know if a function returned an error type or a success type.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* ```
|
|
10
|
+
* import {Result, Ok, Err} from "@app/lib/result"
|
|
11
|
+
* function divide(numerator: number, denominator: number) : Result<number, Error> {
|
|
12
|
+
* if (denominator === 0) {
|
|
13
|
+
* return new Err(new Error("Cannot divide by zero"));
|
|
14
|
+
* }
|
|
15
|
+
* return ok(numerator / denominator);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class Ok {
|
|
20
|
+
value;
|
|
21
|
+
constructor(value) {
|
|
22
|
+
this.value = value;
|
|
23
|
+
}
|
|
24
|
+
isOk() {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
isErr() {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class Err {
|
|
32
|
+
error;
|
|
33
|
+
constructor(error) {
|
|
34
|
+
this.error = error;
|
|
35
|
+
}
|
|
36
|
+
isOk() {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
isErr() {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class SrchdError extends Error {
|
|
44
|
+
code;
|
|
45
|
+
cause;
|
|
46
|
+
constructor(code, message, cause) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.code = code;
|
|
49
|
+
this.cause = cause;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function ok(value) {
|
|
53
|
+
return new Ok(value);
|
|
54
|
+
}
|
|
55
|
+
export function err(code, message, cause) {
|
|
56
|
+
const errorCause = cause instanceof Error ? cause : null;
|
|
57
|
+
if (errorCause) {
|
|
58
|
+
console.error(errorCause);
|
|
59
|
+
}
|
|
60
|
+
return new Err(new SrchdError(code, message, errorCause));
|
|
61
|
+
}
|
|
62
|
+
export function errorToString(error) {
|
|
63
|
+
if (error instanceof Error) {
|
|
64
|
+
return error.message;
|
|
65
|
+
}
|
|
66
|
+
else if (isString(error)) {
|
|
67
|
+
return error;
|
|
68
|
+
}
|
|
69
|
+
return JSON.stringify(error);
|
|
70
|
+
}
|
|
71
|
+
export function normalizeError(error) {
|
|
72
|
+
if (error instanceof Error) {
|
|
73
|
+
return error;
|
|
74
|
+
}
|
|
75
|
+
return new Error(errorToString(error));
|
|
76
|
+
}
|
|
77
|
+
export function withRetries(fn, { retries = 3, delayBetweenRetriesMs = 3000, retriableCodes = undefined, } = {}) {
|
|
78
|
+
assert(retries >= 1);
|
|
79
|
+
return async (arg) => {
|
|
80
|
+
const errors = [];
|
|
81
|
+
for (let i = 0; i < retries; i++) {
|
|
82
|
+
const res = await fn(arg);
|
|
83
|
+
if (res.isOk()) {
|
|
84
|
+
return res;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
if (Array.isArray(retriableCodes) &&
|
|
88
|
+
!retriableCodes.includes(res.error.code)) {
|
|
89
|
+
return new Err(res.error);
|
|
90
|
+
}
|
|
91
|
+
const sleepTime = delayBetweenRetriesMs * (i + 1) ** 2;
|
|
92
|
+
console.warn(`RETRY: error=${res.error.code} attempt=${i + 1}/${retries} sleepTime=${sleepTime}ms`);
|
|
93
|
+
await new Promise((resolve) => setTimeout(resolve, sleepTime));
|
|
94
|
+
errors.push(res.error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const [error] = errors;
|
|
98
|
+
return new Err(error);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/lib/error.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,OAAO,EAAE;IACM;IAAnB,YAAmB,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAG,CAAC;IAE/B,IAAI;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,MAAM,OAAO,GAAG;IACK;IAAnB,YAAmB,KAAQ;QAAR,UAAK,GAAL,KAAK,CAAG;IAAG,CAAC;IAE/B,IAAI;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA+BD,MAAM,OAAO,UAAW,SAAQ,KAAK;IAExB;IAEA;IAHX,YACW,IAAe,EACxB,OAAe,EACN,KAAoB;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJN,SAAI,GAAJ,IAAI,CAAW;QAEf,UAAK,GAAL,KAAK,CAAe;IAG/B,CAAC;CACF;AAED,MAAM,UAAU,EAAE,CAAI,KAAQ;IAC5B,OAAO,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,GAAG,CACjB,IAAe,EACf,OAAe,EACf,KAAW;I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,GAAG,CAAC;YACb,CAAC;iBAAM,CAAC;gBACN,IACE,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC;oBAC7B,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EACxC,CAAC;oBACD,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC5B,CAAC;gBACD,MAAM,SAAS,GAAG,qBAAqB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;gBACvD,OAAO,CAAC,IAAI,CACV,gBAAgB,GAAG,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,OAAO,cAAc,SAAS,IAAI,CACtF,CAAC;gBACF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC;gBAC/D,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC;QACvB,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/lib/fs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/lib/fs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAW,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,KACf,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAexB,CAAC"}
|
package/dist/lib/fs.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as fs from "fs/promises";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as os from "os";
|
|
4
|
+
import { err, ok } from "./error";
|
|
5
|
+
export const readFileContent = async (filePath) => {
|
|
6
|
+
try {
|
|
7
|
+
const resolvedPath = filePath.startsWith("~")
|
|
8
|
+
? path.join(os.homedir(), filePath.slice(1))
|
|
9
|
+
: path.resolve(filePath);
|
|
10
|
+
const content = await fs.readFile(resolvedPath, "utf-8");
|
|
11
|
+
return ok(content);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
return err("reading_file_error", `Failed to read file at ${filePath}`, error);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/lib/fs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAU,GAAG,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,QAAgB,EACS,EAAE;IAC3B,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;YAC3C,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5C,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE3B,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzD,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,GAAG,CACR,oBAAoB,EACpB,0BAA0B,QAAQ,EAAE,EACpC,KAAK,CACN,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Result } from "./error";
|
|
2
|
+
/**
|
|
3
|
+
* MCP Server Configuration
|
|
4
|
+
*
|
|
5
|
+
* Defines how to connect to an MCP server
|
|
6
|
+
*/
|
|
7
|
+
export type MCPServerConfig = {
|
|
8
|
+
/**
|
|
9
|
+
* Server name (used for tool prefixing)
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* Transport type
|
|
14
|
+
*/
|
|
15
|
+
transport: "stdio" | "sse";
|
|
16
|
+
/**
|
|
17
|
+
* For stdio: command to execute
|
|
18
|
+
* For sse: URL to connect to
|
|
19
|
+
*/
|
|
20
|
+
command?: string;
|
|
21
|
+
url?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Arguments to pass to the command (stdio only)
|
|
24
|
+
*/
|
|
25
|
+
args?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Environment variables to set
|
|
28
|
+
*/
|
|
29
|
+
env?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Authentication token (for SSE)
|
|
32
|
+
*/
|
|
33
|
+
token?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to enable this server
|
|
36
|
+
*/
|
|
37
|
+
enabled?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Profile configuration
|
|
41
|
+
*/
|
|
42
|
+
export type ProfileConfig = {
|
|
43
|
+
/**
|
|
44
|
+
* MCP servers to connect to
|
|
45
|
+
*/
|
|
46
|
+
mcpServers?: MCPServerConfig[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Load MCP server configuration from profile
|
|
50
|
+
*/
|
|
51
|
+
export declare function loadProfileMCPConfig(profile: string): Result<MCPServerConfig[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Resolve environment variable references in config
|
|
54
|
+
*
|
|
55
|
+
* Replaces ${ENV_VAR} with actual environment variable values
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolveEnvVars(value: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Process MCP server config to resolve environment variables
|
|
60
|
+
*/
|
|
61
|
+
export declare function processMCPConfig(config: MCPServerConfig): MCPServerConfig;
|
|
62
|
+
//# sourceMappingURL=mcp-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-config.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,MAAM,EAAE,MAAM,SAAS,CAAC;AAK1C;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,SAAS,EAAE,OAAO,GAAG,KAAK,CAAC;IAE3B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE7B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC,CAiD/E;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIpD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAiCzE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from "fs";
|
|
2
|
+
import { join, dirname } from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { err, ok } from "./error";
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = dirname(__filename);
|
|
7
|
+
/**
|
|
8
|
+
* Load MCP server configuration from profile
|
|
9
|
+
*/
|
|
10
|
+
export function loadProfileMCPConfig(profile) {
|
|
11
|
+
const configPath = join(__dirname, "../../profiles", profile, "settings.json");
|
|
12
|
+
// If no settings file, return empty array (just computer tool)
|
|
13
|
+
if (!existsSync(configPath)) {
|
|
14
|
+
return ok([]);
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const content = readFileSync(configPath, "utf-8");
|
|
18
|
+
const config = JSON.parse(content);
|
|
19
|
+
// Filter enabled servers
|
|
20
|
+
const servers = (config.mcpServers || []).filter((server) => server.enabled !== false);
|
|
21
|
+
// Validate each server config
|
|
22
|
+
for (const server of servers) {
|
|
23
|
+
if (!server.name) {
|
|
24
|
+
return err("invalid_config_error", "MCP server config missing 'name' field");
|
|
25
|
+
}
|
|
26
|
+
if (server.transport === "stdio" && !server.command) {
|
|
27
|
+
return err("invalid_config_error", `MCP server '${server.name}' with stdio transport missing 'command' field`);
|
|
28
|
+
}
|
|
29
|
+
if (server.transport === "sse" && !server.url) {
|
|
30
|
+
return err("invalid_config_error", `MCP server '${server.name}' with sse transport missing 'url' field`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return ok(servers);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return err("config_load_error", `Failed to load MCP config from ${configPath}`, error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolve environment variable references in config
|
|
41
|
+
*
|
|
42
|
+
* Replaces ${ENV_VAR} with actual environment variable values
|
|
43
|
+
*/
|
|
44
|
+
export function resolveEnvVars(value) {
|
|
45
|
+
return value.replace(/\$\{(\w+)\}/g, (_, varName) => {
|
|
46
|
+
return process.env[varName] || "";
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Process MCP server config to resolve environment variables
|
|
51
|
+
*/
|
|
52
|
+
export function processMCPConfig(config) {
|
|
53
|
+
const processed = { ...config };
|
|
54
|
+
// Resolve env vars in command
|
|
55
|
+
if (processed.command) {
|
|
56
|
+
processed.command = resolveEnvVars(processed.command);
|
|
57
|
+
}
|
|
58
|
+
// Resolve env vars in URL
|
|
59
|
+
if (processed.url) {
|
|
60
|
+
processed.url = resolveEnvVars(processed.url);
|
|
61
|
+
}
|
|
62
|
+
// Resolve env vars in args
|
|
63
|
+
if (processed.args) {
|
|
64
|
+
processed.args = processed.args.map(resolveEnvVars);
|
|
65
|
+
}
|
|
66
|
+
// Resolve env vars in environment variables
|
|
67
|
+
if (processed.env) {
|
|
68
|
+
const resolvedEnv = {};
|
|
69
|
+
for (const [key, value] of Object.entries(processed.env)) {
|
|
70
|
+
resolvedEnv[key] = resolveEnvVars(value);
|
|
71
|
+
}
|
|
72
|
+
processed.env = resolvedEnv;
|
|
73
|
+
}
|
|
74
|
+
// Resolve token
|
|
75
|
+
if (processed.token) {
|
|
76
|
+
processed.token = resolveEnvVars(processed.token);
|
|
77
|
+
}
|
|
78
|
+
return processed;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=mcp-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-config.js","sourceRoot":"","sources":["../../src/lib/mcp-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,EAAE,EAAU,MAAM,SAAS,CAAC;AAE1C,MAAM,UAAU,GAAG,aAAa,C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CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC;QACD,SAAS,CAAC,GAAG,GAAG,WAAW,CAAC;IAC9B,CAAC;IAED,gBAAgB;IAChB,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;QACpB,SAAS,CAAC,KAAK,GAAG,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
|
+
import { SrchdError, Err, Result } from "./error";
|
|
4
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import type { MCPServerConfig } from "./mcp-config";
|
|
6
|
+
export declare function createClientServerPair(server: McpServer): Promise<[Client, McpServer]>;
|
|
7
|
+
/**
|
|
8
|
+
* Create MCP client from configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function createClientFromConfig(config: MCPServerConfig): Promise<Result<Client>>;
|
|
11
|
+
export declare function errorToCallToolResult(error: Err<SrchdError>): CallToolResult;
|
|
12
|
+
export declare function stringEdit({ content, oldStr, newStr, expectedReplacements, }: {
|
|
13
|
+
content: string;
|
|
14
|
+
oldStr: string;
|
|
15
|
+
newStr: string;
|
|
16
|
+
expectedReplacements?: number;
|
|
17
|
+
}): Result<string>;
|
|
18
|
+
export declare const STRING_EDIT_INSTRUCTIONS = "**Requirements**:\n- `old_str` NEEDS TO contain the precise literal content for substituation (preserving all spacing, formatting, line breaks, etc).\n- `new_str` NEEDS TO contain the precise literal content that will substitute `old_str` (maintaining all spacing, formatting, line breaks, etc). Verify the output maintains proper syntax and follows best practices.\n- DO NOT apply escaping to `old_str` or `new_str`, as this violates the literal text requirement.\n- `old_str` NEEDS TO provide unique identification for the specific instance to replace. Include surrounding textual context BEFORE and AFTER the target content.\n\n**Batch replacements**:\nDefine `expected_replacements` (optional, defaults to 1) when the change is meant to impact more than one occurrence. If there is a mismatch the tool will error.";
|
|
19
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/lib/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAW,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,SAAS,GAChB,OAAO,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAc9B;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CA6DzB;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,cAAc,CAY5E;AAED,wBAAgB,UAAU,CAAC,EACzB,OAAO,EACP,MAAM,EACN,MAAM,EACN,oBAAwB,GACzB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,GAAG,MAAM,CAAC,MAAM,CAAC,CA6BjB;AAED,eAAO,MAAM,wBAAwB,szBAQ+H,CAAC"}
|
package/dist/lib/mcp.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
2
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
3
|
+
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
|
|
4
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
|
+
import { err, ok } from "./error";
|
|
6
|
+
import { processMCPConfig } from "./mcp-config";
|
|
7
|
+
export async function createClientServerPair(server) {
|
|
8
|
+
const client = new Client({
|
|
9
|
+
// @ts-ignore use private _serverInfo
|
|
10
|
+
name: server.server._serverInfo.name,
|
|
11
|
+
// @ts-ignore use private _serverInfo
|
|
12
|
+
version: server.server._serverInfo.version,
|
|
13
|
+
});
|
|
14
|
+
const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();
|
|
15
|
+
await server.connect(serverTransport);
|
|
16
|
+
await client.connect(clientTransport);
|
|
17
|
+
return [client, server];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create MCP client from configuration
|
|
21
|
+
*/
|
|
22
|
+
export async function createClientFromConfig(config) {
|
|
23
|
+
try {
|
|
24
|
+
const processed = processMCPConfig(config);
|
|
25
|
+
const client = new Client({
|
|
26
|
+
name: processed.name,
|
|
27
|
+
version: "1.0.0",
|
|
28
|
+
});
|
|
29
|
+
if (processed.transport === "stdio") {
|
|
30
|
+
if (!processed.command) {
|
|
31
|
+
return err("mcp_config_error", `MCP server '${processed.name}' missing command for stdio transport`);
|
|
32
|
+
}
|
|
33
|
+
const transport = new StdioClientTransport({
|
|
34
|
+
command: processed.command,
|
|
35
|
+
args: processed.args || [],
|
|
36
|
+
env: {
|
|
37
|
+
...process.env,
|
|
38
|
+
...processed.env,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
await client.connect(transport);
|
|
42
|
+
return ok(client);
|
|
43
|
+
}
|
|
44
|
+
else if (processed.transport === "sse") {
|
|
45
|
+
if (!processed.url) {
|
|
46
|
+
return err("mcp_config_error", `MCP server '${processed.name}' missing URL for SSE transport`);
|
|
47
|
+
}
|
|
48
|
+
const headers = {};
|
|
49
|
+
if (processed.token) {
|
|
50
|
+
headers["Authorization"] = `Bearer ${processed.token}`;
|
|
51
|
+
}
|
|
52
|
+
const transport = new SSEClientTransport(new URL(processed.url), headers);
|
|
53
|
+
await client.connect(transport);
|
|
54
|
+
return ok(client);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return err("mcp_config_error", `Unsupported transport type: ${processed.transport}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
return err("mcp_connection_error", `Failed to connect to MCP server '${config.name}'`, error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function errorToCallToolResult(error) {
|
|
65
|
+
return {
|
|
66
|
+
isError: true,
|
|
67
|
+
content: [
|
|
68
|
+
{
|
|
69
|
+
type: "text",
|
|
70
|
+
text: `Error [${error.error.code}]: ${error.error.message}` +
|
|
71
|
+
(error.error.cause ? ` (cause: ${error.error.cause?.message})` : ""),
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export function stringEdit({ content, oldStr, newStr, expectedReplacements = 1, }) {
|
|
77
|
+
// Count occurrences of old_string
|
|
78
|
+
const regex = new RegExp(oldStr.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g");
|
|
79
|
+
const matches = content.match(regex);
|
|
80
|
+
const occurrences = matches ? matches.length : 0;
|
|
81
|
+
// console.log("----------------------------");
|
|
82
|
+
// console.log(content);
|
|
83
|
+
// console.log("----------------------------");
|
|
84
|
+
// console.log(oldStr);
|
|
85
|
+
// console.log("----------------------------");
|
|
86
|
+
// console.log(newStr);
|
|
87
|
+
// console.log("----------------------------");
|
|
88
|
+
if (occurrences === 0) {
|
|
89
|
+
return err("string_edit_error", `String to replace not found in content to edit`);
|
|
90
|
+
}
|
|
91
|
+
if (occurrences !== expectedReplacements) {
|
|
92
|
+
return err("string_edit_error", `Expected ${expectedReplacements} replacements, but found ${occurrences} occurrences`);
|
|
93
|
+
}
|
|
94
|
+
return ok(content.replace(regex, newStr));
|
|
95
|
+
}
|
|
96
|
+
export const STRING_EDIT_INSTRUCTIONS = `\
|
|
97
|
+
**Requirements**:
|
|
98
|
+
- \`old_str\` NEEDS TO contain the precise literal content for substituation (preserving all spacing, formatting, line breaks, etc).
|
|
99
|
+
- \`new_str\` NEEDS TO contain the precise literal content that will substitute \`old_str\` (maintaining all spacing, formatting, line breaks, etc). Verify the output maintains proper syntax and follows best practices.
|
|
100
|
+
- DO NOT apply escaping to \`old_str\` or \`new_str\`, as this violates the literal text requirement.
|
|
101
|
+
- \`old_str\` NEEDS TO provide unique identification for the specific instance to replace. Include surrounding textual context BEFORE and AFTER the target content.
|
|
102
|
+
|
|
103
|
+
**Batch replacements**:
|
|
104
|
+
Define \`expected_replacements\` (optional, defaults to 1) when the change is meant to impact more than one occurrence. If there is a mismatch the tool will error.`;
|
|
105
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/lib/mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAA2B,GAAG,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAG3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAiB;IAEjB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;QACxB,qCAAqC;QACrC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI;QACpC,qCAAqC;QACrC,OAAO,EAAE,MAAM,CAAC,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AAK,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjD,+CAA+C;IAC/C,wBAAwB;IACxB,+CAA+C;IAC/C,uBAAuB;IACvB,+CAA+C;IAC/C,uBAAuB;IACvB,+CAA+C;IAE/C,IAAI,WAAW,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,GAAG,CACR,mBAAmB,EACnB,gDAAgD,CACjD,CAAC;IACJ,CAAC;IAED,IAAI,WAAW,KAAK,oBAAoB,EAAE,CAAC;QACzC,OAAO,GAAG,CACR,mBAAmB,EACnB,YAAY,oBAAoB,4BAA4B,WAAW,cAAc,CACtF,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG;;;;;;;;oKAQ4H,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function prompt(question: string): Promise<string>;
|
|
2
|
+
export declare function select<T extends string>(question: string, choices: readonly T[], defaultChoice?: T): Promise<T>;
|
|
3
|
+
export declare function confirm(question: string, defaultValue?: boolean): Promise<boolean>;
|
|
4
|
+
export declare function number(question: string, defaultValue?: number, min?: number, max?: number): Promise<number>;
|
|
5
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":[],"mappings":"AAEA,wBAAsB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAY9D;AAED,wBAAsB,MAAM,CAAC,CAAC,SAAS,MAAM,EAC3C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,aAAa,CAAC,EAAE,CAAC,GAChB,OAAO,CAAC,CAAC,CAAC,CAwBZ;AAED,wBAAsB,OAAO,CAC3B,QAAQ,EAAE,MAAM,EAChB,YAAY,UAAQ,GACnB,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED,wBAAsB,MAAM,CAC1B,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,EACrB,GAAG,CAAC,EAAE,MAAM,EACZ,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CA6BjB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as readline from "readline";
|
|
2
|
+
export async function prompt(question) {
|
|
3
|
+
const rl = readline.createInterface({
|
|
4
|
+
input: process.stdin,
|
|
5
|
+
output: process.stdout,
|
|
6
|
+
});
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
rl.question(question, (answer) => {
|
|
9
|
+
rl.close();
|
|
10
|
+
resolve(answer.trim());
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export async function select(question, choices, defaultChoice) {
|
|
15
|
+
console.log(`\n${question}`);
|
|
16
|
+
choices.forEach((choice, idx) => {
|
|
17
|
+
const isDefault = choice === defaultChoice;
|
|
18
|
+
console.log(` ${idx + 1}. ${choice}${isDefault ? " (default)" : ""}`);
|
|
19
|
+
});
|
|
20
|
+
const answer = await prompt(`\nEnter choice (1-${choices.length})${defaultChoice ? ` [${choices.indexOf(defaultChoice) + 1}]` : ""}: `);
|
|
21
|
+
if (!answer && defaultChoice) {
|
|
22
|
+
return defaultChoice;
|
|
23
|
+
}
|
|
24
|
+
const choiceIdx = parseInt(answer) - 1;
|
|
25
|
+
if (isNaN(choiceIdx) || choiceIdx < 0 || choiceIdx >= choices.length) {
|
|
26
|
+
console.log("Invalid choice, please try again.");
|
|
27
|
+
return select(question, choices, defaultChoice);
|
|
28
|
+
}
|
|
29
|
+
return choices[choiceIdx];
|
|
30
|
+
}
|
|
31
|
+
export async function confirm(question, defaultValue = false) {
|
|
32
|
+
const answer = await prompt(`${question} (${defaultValue ? "Y/n" : "y/N"}): `);
|
|
33
|
+
if (!answer) {
|
|
34
|
+
return defaultValue;
|
|
35
|
+
}
|
|
36
|
+
const normalized = answer.toLowerCase();
|
|
37
|
+
return normalized === "y" || normalized === "yes";
|
|
38
|
+
}
|
|
39
|
+
export async function number(question, defaultValue, min, max) {
|
|
40
|
+
const defaultText = defaultValue !== undefined ? ` [${defaultValue}]` : "";
|
|
41
|
+
const rangeText = min !== undefined || max !== undefined
|
|
42
|
+
? ` (${min !== undefined ? `min: ${min}` : ""}${min !== undefined && max !== undefined ? ", " : ""}${max !== undefined ? `max: ${max}` : ""})`
|
|
43
|
+
: "";
|
|
44
|
+
const answer = await prompt(`${question}${rangeText}${defaultText}: `);
|
|
45
|
+
if (!answer && defaultValue !== undefined) {
|
|
46
|
+
return defaultValue;
|
|
47
|
+
}
|
|
48
|
+
const num = parseFloat(answer);
|
|
49
|
+
if (isNaN(num)) {
|
|
50
|
+
console.log("Invalid number, please try again.");
|
|
51
|
+
return number(question, defaultValue, min, max);
|
|
52
|
+
}
|
|
53
|
+
if (min !== undefined && num < min) {
|
|
54
|
+
console.log(`Number must be at least ${min}, please try again.`);
|
|
55
|
+
return number(question, defaultValue, min, max);
|
|
56
|
+
}
|
|
57
|
+
if (max !== undefined && num > max) {
|
|
58
|
+
console.log(`Number must be at most ${max}, please try again.`);
|
|
59
|
+
return number(question, defaultValue, min, max);
|
|
60
|
+
}
|
|
61
|
+
return num;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":[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,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG;QAC9I,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,IAAI,CAAC,CAAC;IAEvE,IAAI,CAAC,MAAM,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,2BAA2B,GAAG,qBAAqB,CAAC,CAAC;QACjE,OAAO,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,qBAAqB,CAAC,CAAC;QAChE,OAAO,MAAM,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function removeNulls<T>(arr: (T | null | undefined)[]): T[];
|
|
2
|
+
export declare function newID6(): string;
|
|
3
|
+
export declare function isArrayOf<T>(arr: unknown, tg: (v: unknown) => v is T): arr is T[];
|
|
4
|
+
export declare function isString(str: unknown): str is string;
|
|
5
|
+
//# sourceMappingURL=utils.d.ts.map
|