@gaunt-sloth/core 2.0.0-alpha.19 → 2.0.0-alpha.20
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/README.md +5 -4
- package/dist/config/defaults.js +6 -4
- package/dist/config/defaults.js.map +1 -1
- package/dist/config/loader.d.ts +29 -0
- package/dist/config/loader.js +158 -8
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +45 -0
- package/dist/config/schema.js +45 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shell-policy.d.ts +17 -0
- package/dist/config/shell-policy.js.map +1 -1
- package/dist/config/types.d.ts +60 -0
- package/dist/config/types.js.map +1 -1
- package/dist/constants.d.ts +11 -1
- package/dist/constants.js +11 -1
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +28 -1
- package/dist/core/GthAbstractAgent.js +227 -33
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthLangChainAgent.js +31 -14
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/providers/geminiSchemaSanitizer.d.ts +52 -0
- package/dist/providers/geminiSchemaSanitizer.js +201 -0
- package/dist/providers/geminiSchemaSanitizer.js.map +1 -0
- package/dist/providers/google-genai.js +4 -1
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/ollama.d.ts +18 -4
- package/dist/providers/ollama.js +55 -37
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openrouter.js +5 -0
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/vertexai.js +4 -1
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/runtime/conversation.d.ts +59 -0
- package/dist/runtime/conversation.js +137 -0
- package/dist/runtime/conversation.js.map +1 -0
- package/dist/runtime/singleShot.d.ts +3 -2
- package/dist/runtime/singleShot.js +16 -4
- package/dist/runtime/singleShot.js.map +1 -1
- package/dist/utils/debugDump.d.ts +30 -8
- package/dist/utils/debugDump.js +133 -10
- package/dist/utils/debugDump.js.map +1 -1
- package/dist/utils/redactSecrets.d.ts +63 -0
- package/dist/utils/redactSecrets.js +238 -0
- package/dist/utils/redactSecrets.js.map +1 -0
- package/dist/utils/systemPromptNotes.d.ts +92 -0
- package/dist/utils/systemPromptNotes.js +114 -0
- package/dist/utils/systemPromptNotes.js.map +1 -1
- package/dist/utils/systemUtils.d.ts +1 -1
- package/dist/utils/systemUtils.js +7 -2
- package/dist/utils/systemUtils.js.map +1 -1
- package/dist/utils/toolMatching.d.ts +30 -0
- package/dist/utils/toolMatching.js +44 -0
- package/dist/utils/toolMatching.js.map +1 -0
- package/package.json +5 -1
- package/schema/gsloth-config.schema.json +91 -0
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* they are genuinely deep-only (a deepagents artifact — lean never runs virtualMode) and stay in
|
|
15
15
|
* `GthDeepAgent`.
|
|
16
16
|
*/
|
|
17
|
+
import { DEFAULT_COMMIT_CO_AUTHOR_EMAIL, DEFAULT_COMMIT_CO_AUTHOR_NAME } from '#src/constants.js';
|
|
17
18
|
/**
|
|
18
19
|
* EXT-26: the platform-agnostic tail shared by both {@link appendOsShellNote} branches.
|
|
19
20
|
*
|
|
@@ -82,6 +83,119 @@ export function appendCwdNote(systemPrompt, cwd) {
|
|
|
82
83
|
'directory); do not assume the current directory is "/".';
|
|
83
84
|
return systemPrompt ? `${systemPrompt}\n\n${cwdNote}` : cwdNote;
|
|
84
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* GS2-35: append the commit co-authoring rule to the composed code-mode system prompt.
|
|
88
|
+
*
|
|
89
|
+
* Gaunt Sloth has **no dedicated git-commit tool** — the agent commits by calling
|
|
90
|
+
* `run_shell_command` with `git commit`, composing the message (including any trailer) itself. Left
|
|
91
|
+
* unguided, models emit `Co-Authored-By: <their own model name>` (e.g. `Claude`, `GPT`, `Gemini`)
|
|
92
|
+
* from trained habit, which is **factually wrong**: the commit was produced by *Gaunt Sloth*, not by
|
|
93
|
+
* the model. This note is the fix at the correct layer — first-party prompt guidance that (a) states
|
|
94
|
+
* the exact trailer to emit and (b) forbids a model-name co-author.
|
|
95
|
+
*
|
|
96
|
+
* The identity is config-driven (`commit.coAuthor` in {@link import('#src/config/types.js').GthConfig}).
|
|
97
|
+
* Each field falls back INDEPENDENTLY to the Gaunt Sloth account
|
|
98
|
+
* ({@link DEFAULT_COMMIT_CO_AUTHOR_NAME} / {@link DEFAULT_COMMIT_CO_AUTHOR_EMAIL}) — so a partial
|
|
99
|
+
* override (name only, or a config that bypassed the loader) still yields a complete trailer, and a
|
|
100
|
+
* fully-absent config yields the default account. Blank/whitespace values are treated as unset.
|
|
101
|
+
*
|
|
102
|
+
* Backend-agnostic: composed through the shared code path so BOTH the lean `GthLangChainAgent` and
|
|
103
|
+
* the deep `GthDeepAgent` inject it (the git-commit capability rides on `run_shell_command`, which
|
|
104
|
+
* both backends expose in code mode). Returns the note alone when there is no base prompt.
|
|
105
|
+
*/
|
|
106
|
+
export function appendCommitCoAuthorNote(systemPrompt, coAuthor) {
|
|
107
|
+
const name = coAuthor?.name?.trim() || DEFAULT_COMMIT_CO_AUTHOR_NAME;
|
|
108
|
+
const email = coAuthor?.email?.trim() || DEFAULT_COMMIT_CO_AUTHOR_EMAIL;
|
|
109
|
+
const note = 'When you create a git commit, add EXACTLY this co-author trailer line (on its own line, at ' +
|
|
110
|
+
`the end of the commit message):\nCo-Authored-By: ${name} <${email}>\n` +
|
|
111
|
+
'NEVER attribute the co-author to the underlying model or provider name (do not write ' +
|
|
112
|
+
'`Co-Authored-By: Claude`, `GPT`, `Gemini`, `Opus`, `Sonnet`, or any model/vendor name): the ' +
|
|
113
|
+
'commit is authored by Gaunt Sloth, the assistant, not the model. Emit at most this one ' +
|
|
114
|
+
'Co-Authored-By trailer.';
|
|
115
|
+
return systemPrompt ? `${systemPrompt}\n\n${note}` : note;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* GS2-34: resolve the active model identity from the effective config, for injection into the
|
|
119
|
+
* system prompt by {@link appendModelContextNote}.
|
|
120
|
+
*
|
|
121
|
+
* Both halves are read the SAME way the rest of gsloth already surfaces the active model:
|
|
122
|
+
* - MODEL: `config.modelDisplayName` (the string the status line renders — set by the loader from
|
|
123
|
+
* `llm.model`), falling back to the live model's own `model` field.
|
|
124
|
+
* - PROVIDER: the configured `config.modelProviderType` (the raw `llm.type` the loader stashed —
|
|
125
|
+
* `openrouter`/`deepseek`/`xai`/`anthropic`/…) when present, otherwise the live LangChain
|
|
126
|
+
* model's `_llmType()` (the source the AG-UI `/info` endpoint reports). GS2-53 — preferring the
|
|
127
|
+
* configured `type` fixes the OpenAI-compatible shims (openrouter/deepseek/xai all extend
|
|
128
|
+
* ChatOpenAI, so their `_llmType()` reports `openai`): a `type: openrouter` config now injects
|
|
129
|
+
* `openrouter:<model>`, not `openai:<model>`. The `type` is absent for module configs (which
|
|
130
|
+
* hand us an already-built LLM), where we fall back to `_llmType()` unchanged. The MODEL half is
|
|
131
|
+
* always exact.
|
|
132
|
+
*
|
|
133
|
+
* Returns `{ identity: 'provider:model', hasProvider: true }` when both resolve, `{ identity:
|
|
134
|
+
* 'model', hasProvider: false }` when only the model resolves, and `undefined` when the model is
|
|
135
|
+
* unknown (a provider with no model is not a usable identity) — in which case {@link
|
|
136
|
+
* appendModelContextNote} injects nothing, leaving the prompt exactly as before. `hasProvider` is
|
|
137
|
+
* the authoritative provider-present flag (GS2-53), so a bare model whose NAME contains a colon
|
|
138
|
+
* (e.g. `gemma3:27b`) is correctly reported as `hasProvider: false`. `_llmType()` is called
|
|
139
|
+
* defensively (guarded) so a provider whose accessor throws can never break prompt assembly (and is
|
|
140
|
+
* skipped entirely when a configured `type` is present).
|
|
141
|
+
*/
|
|
142
|
+
export function resolveModelIdentity(config) {
|
|
143
|
+
const llm = config?.llm;
|
|
144
|
+
// Prefer the configured provider `type` over the live model's `_llmType()`: OpenAI-compatible
|
|
145
|
+
// shims (openrouter/deepseek/xai) extend ChatOpenAI and report `_llmType() === 'openai'`, which
|
|
146
|
+
// would mislabel the provider half. Only fall through to the guarded `_llmType()` when no
|
|
147
|
+
// (non-blank) `type` was threaded (e.g. module configs that build the LLM themselves).
|
|
148
|
+
let provider = config?.modelProviderType?.trim() || undefined;
|
|
149
|
+
if (!provider) {
|
|
150
|
+
try {
|
|
151
|
+
provider = typeof llm?._llmType === 'function' ? llm._llmType() : undefined;
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
provider = undefined;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const model = config?.modelDisplayName ?? llm?.model;
|
|
158
|
+
if (!model)
|
|
159
|
+
return undefined;
|
|
160
|
+
// `provider` may be undefined OR an empty string (an empty `_llmType()`); both mean "no provider
|
|
161
|
+
// half", so `hasProvider` is false and the identity is the bare model — even if that model name
|
|
162
|
+
// happens to contain a colon.
|
|
163
|
+
return provider
|
|
164
|
+
? { identity: `${provider}:${model}`, hasProvider: true }
|
|
165
|
+
: { identity: model, hasProvider: false };
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* GS2-34: append the active model-identity note to the composed system prompt.
|
|
169
|
+
*
|
|
170
|
+
* The agent otherwise has no reliable knowledge of which `provider:model` is serving it, so it
|
|
171
|
+
* cannot answer "what model are you?" accurately or reason about its own capabilities/limits. This
|
|
172
|
+
* injects a single first-party line naming the resolved identity (see {@link resolveModelIdentity}).
|
|
173
|
+
*
|
|
174
|
+
* Injected in EVERY mode (chat/ask/code/exec), NOT gated to `code` like the cwd/os-shell/commit
|
|
175
|
+
* notes: "which model are you?" can be asked in any session, so the identity must be visible
|
|
176
|
+
* everywhere. Config-gated by `injectModelContext` (default ON): a caller passes an `undefined`
|
|
177
|
+
* `modelIdentity` — because the config opted out (`injectModelContext: false`) or because no model
|
|
178
|
+
* could be resolved — and the base prompt is returned UNCHANGED (no line), preserving the current
|
|
179
|
+
* prompt byte-for-byte.
|
|
180
|
+
*
|
|
181
|
+
* A short capability note from the GS2-6 model catalog is a DEFERRED follow-up (GS2-6 has not
|
|
182
|
+
* landed): this injects the bare `provider:model` identity only.
|
|
183
|
+
*/
|
|
184
|
+
export function appendModelContextNote(systemPrompt, modelIdentity) {
|
|
185
|
+
const identity = modelIdentity?.identity?.trim();
|
|
186
|
+
if (!identity)
|
|
187
|
+
return systemPrompt;
|
|
188
|
+
// GS2-53 — the `(provider:model)` label documents the identity FORMAT, so only emit it when a
|
|
189
|
+
// provider half is ACTUALLY present. Read that from the structured `hasProvider` flag, NOT from
|
|
190
|
+
// `identity.includes(':')`: a bare model name can itself contain a colon (e.g. `gemma3:27b`), and
|
|
191
|
+
// inferring from the colon would re-append the dangling/misleading label the bare-model branch is
|
|
192
|
+
// meant to avoid. The provider-present line is unchanged.
|
|
193
|
+
const formatLabel = modelIdentity?.hasProvider ? ' (provider:model)' : '';
|
|
194
|
+
const note = `The model currently serving this session is \`${identity}\`${formatLabel}. This is your ` +
|
|
195
|
+
'actual underlying model — use it when asked which model you are, and when reasoning about ' +
|
|
196
|
+
'your own capabilities or limits.';
|
|
197
|
+
return systemPrompt ? `${systemPrompt}\n\n${note}` : note;
|
|
198
|
+
}
|
|
85
199
|
/**
|
|
86
200
|
* EXT-32: hard per-server cap on injected MCP instruction length.
|
|
87
201
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemPromptNotes.js","sourceRoot":"","sources":["../../src/utils/systemPromptNotes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;
|
|
1
|
+
{"version":3,"file":"systemPromptNotes.js","sourceRoot":"","sources":["../../src/utils/systemPromptNotes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAElG;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,4FAA4F;IAC5F,wFAAwF;IACxF,2DAA2D,CAAC;AAE9D;;;;;;;;;;;;;;;;GAgB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IAC/E,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,kCAAkC,EAAE,CAAC;AAClF,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,+BAA+B,CAC7C,YAAgC,EAChC,YAAgD;IAEhD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,MAAM,KAAK,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,GAAG,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,IAAI;YAAE,SAAS,CAAC,qDAAqD;QAC1E,8FAA8F;QAC9F,gGAAgG;QAChG,wEAAwE;QACxE,MAAM,IAAI,GAAG,UAAU,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;QACnD,MAAM,CAAC,IAAI,CAAC,gBAAgB,KAAK,CAAC,MAAM,UAAU,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,8FAA8F;QAC9F,8FAA8F;QAC9F,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,MAAM,IAAI,GACR,2FAA2F;QAC3F,4FAA4F;QAC5F,iCAAiC;QACjC,GAAG,eAAe,IAAI;QACtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;QACnB,KAAK,aAAa,IAAI;QACtB,6FAA6F;QAC7F,4EAA4E,CAAC;IAE/E,OAAO,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5D,CAAC"}
|
|
@@ -7,7 +7,7 @@ export interface ProgramLike {
|
|
|
7
7
|
getOptionValue(key: string): unknown;
|
|
8
8
|
parseAsync(args?: string[]): Promise<unknown>;
|
|
9
9
|
}
|
|
10
|
-
export declare const waitForEscape: (callback: () => void, enabled: boolean) => void;
|
|
10
|
+
export declare const waitForEscape: (callback: () => void, enabled: boolean, showHint?: boolean) => void;
|
|
11
11
|
export declare const stopWaitingForEscape: () => void;
|
|
12
12
|
export declare const setRawMode: (rawMode: boolean) => void;
|
|
13
13
|
/**
|
|
@@ -35,7 +35,7 @@ const keypressHandler = (callback) => (chunk, key) => {
|
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
export const waitForEscape = (callback, enabled) => {
|
|
38
|
+
export const waitForEscape = (callback, enabled, showHint = true) => {
|
|
39
39
|
if (!enabled) {
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -50,11 +50,16 @@ export const waitForEscape = (callback, enabled) => {
|
|
|
50
50
|
process.stdin.ref?.();
|
|
51
51
|
innerState.waitForEscapeCallback = keypressHandler(callback);
|
|
52
52
|
process.stdin.on('keypress', innerState.waitForEscapeCallback);
|
|
53
|
-
|
|
53
|
+
// GS2-63: the hint box is part of the run-header preamble. When it is opted out (`showHint`
|
|
54
|
+
// false) the Esc/Q handler is still armed above — only the printed box (and its blank-line
|
|
55
|
+
// padding) is suppressed.
|
|
56
|
+
if (showHint) {
|
|
57
|
+
displayInfo(`
|
|
54
58
|
┌--------------------------------------┐
|
|
55
59
|
│ Press Escape or Q to interrupt Agent │
|
|
56
60
|
└--------------------------------------┘
|
|
57
61
|
`);
|
|
62
|
+
}
|
|
58
63
|
};
|
|
59
64
|
export const stopWaitingForEscape = () => {
|
|
60
65
|
if (innerState.waitForEscapeCallback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"systemUtils.js","sourceRoot":"","sources":["../../src/utils/systemUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,E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,YAAY,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACjE,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-name pattern matching for allow/deny lists.
|
|
3
|
+
*
|
|
4
|
+
* Generic over any list of tool-name patterns — used by the `allowedTools` allow-list
|
|
5
|
+
* today, and reusable for other name-list gates (e.g. BATCH-10's `must_call` /
|
|
6
|
+
* `must_not_call`). Depends on nothing but the standard library.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Match a single tool `name` against a single `pattern`.
|
|
10
|
+
*
|
|
11
|
+
* - A pattern with **no** `*` is an **exact** match (`name === pattern`), preserving the
|
|
12
|
+
* original exact-name allow-list behavior.
|
|
13
|
+
* - A pattern containing `*` is treated **glob-style**: each `*` matches any run of
|
|
14
|
+
* characters (including none) and every other character is matched literally. The whole
|
|
15
|
+
* name must match — the pattern is anchored at both ends.
|
|
16
|
+
*
|
|
17
|
+
* Regex metacharacters in the literal segments are escaped, so a `.` or `+` in a pattern
|
|
18
|
+
* matches that character literally, never as a regex class.
|
|
19
|
+
*
|
|
20
|
+
* @example toolNameMatchesPattern('mcp__unimarket__buy', 'mcp__unimarket__*') // true
|
|
21
|
+
* @example toolNameMatchesPattern('read_file', '*_file') // true
|
|
22
|
+
* @example toolNameMatchesPattern('abcde', 'a*c*e') // true
|
|
23
|
+
* @example toolNameMatchesPattern('read_file', 'gh_pr') // false
|
|
24
|
+
*/
|
|
25
|
+
export declare function toolNameMatchesPattern(name: string, pattern: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* True iff `name` matches **any** of `patterns` (see {@link toolNameMatchesPattern}).
|
|
28
|
+
* An empty pattern list matches nothing.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isToolAllowed(name: string, patterns: readonly string[]): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-name pattern matching for allow/deny lists.
|
|
3
|
+
*
|
|
4
|
+
* Generic over any list of tool-name patterns — used by the `allowedTools` allow-list
|
|
5
|
+
* today, and reusable for other name-list gates (e.g. BATCH-10's `must_call` /
|
|
6
|
+
* `must_not_call`). Depends on nothing but the standard library.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Match a single tool `name` against a single `pattern`.
|
|
10
|
+
*
|
|
11
|
+
* - A pattern with **no** `*` is an **exact** match (`name === pattern`), preserving the
|
|
12
|
+
* original exact-name allow-list behavior.
|
|
13
|
+
* - A pattern containing `*` is treated **glob-style**: each `*` matches any run of
|
|
14
|
+
* characters (including none) and every other character is matched literally. The whole
|
|
15
|
+
* name must match — the pattern is anchored at both ends.
|
|
16
|
+
*
|
|
17
|
+
* Regex metacharacters in the literal segments are escaped, so a `.` or `+` in a pattern
|
|
18
|
+
* matches that character literally, never as a regex class.
|
|
19
|
+
*
|
|
20
|
+
* @example toolNameMatchesPattern('mcp__unimarket__buy', 'mcp__unimarket__*') // true
|
|
21
|
+
* @example toolNameMatchesPattern('read_file', '*_file') // true
|
|
22
|
+
* @example toolNameMatchesPattern('abcde', 'a*c*e') // true
|
|
23
|
+
* @example toolNameMatchesPattern('read_file', 'gh_pr') // false
|
|
24
|
+
*/
|
|
25
|
+
export function toolNameMatchesPattern(name, pattern) {
|
|
26
|
+
if (!pattern.includes('*')) {
|
|
27
|
+
return name === pattern;
|
|
28
|
+
}
|
|
29
|
+
// Split on '*' so each literal segment can be fully regex-escaped, then rejoin the
|
|
30
|
+
// segments with '.*' (any run of characters) and anchor the whole thing.
|
|
31
|
+
const regexBody = pattern
|
|
32
|
+
.split('*')
|
|
33
|
+
.map((segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
|
34
|
+
.join('.*');
|
|
35
|
+
return new RegExp(`^${regexBody}$`).test(name);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* True iff `name` matches **any** of `patterns` (see {@link toolNameMatchesPattern}).
|
|
39
|
+
* An empty pattern list matches nothing.
|
|
40
|
+
*/
|
|
41
|
+
export function isToolAllowed(name, patterns) {
|
|
42
|
+
return patterns.some((pattern) => toolNameMatchesPattern(name, pattern));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=toolMatching.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolMatching.js","sourceRoot":"","sources":["../../src/utils/toolMatching.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,OAAe;IAClE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,KAAK,OAAO,CAAC;IAC1B,CAAC;IACD,mFAAmF;IACnF,yEAAyE;IACzE,MAAM,SAAS,GAAG,OAAO;SACtB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;SAChE,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,IAAI,MAAM,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAA2B;IACrE,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaunt-sloth/core",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.20",
|
|
4
4
|
"description": "Core utilities and types for Gaunt Sloth",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andrew Kondratev",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"@langchain/deepseek": "^1.1.1",
|
|
43
43
|
"@langchain/google": "^0.2.0",
|
|
44
44
|
"@langchain/groq": "^1.3.0",
|
|
45
|
+
"@langchain/ollama": "^1.3.0",
|
|
45
46
|
"@langchain/openai": "^1.5.1",
|
|
46
47
|
"@langchain/xai": "^1.4.1"
|
|
47
48
|
},
|
|
@@ -58,6 +59,9 @@
|
|
|
58
59
|
"@langchain/groq": {
|
|
59
60
|
"optional": true
|
|
60
61
|
},
|
|
62
|
+
"@langchain/ollama": {
|
|
63
|
+
"optional": true
|
|
64
|
+
},
|
|
61
65
|
"@langchain/openai": {
|
|
62
66
|
"optional": true
|
|
63
67
|
},
|
|
@@ -257,6 +257,13 @@
|
|
|
257
257
|
},
|
|
258
258
|
"yolo": {
|
|
259
259
|
"type": "boolean"
|
|
260
|
+
},
|
|
261
|
+
"fileSet": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"enum": [
|
|
264
|
+
"gitignore",
|
|
265
|
+
"all"
|
|
266
|
+
]
|
|
260
267
|
}
|
|
261
268
|
}
|
|
262
269
|
}
|
|
@@ -536,6 +543,13 @@
|
|
|
536
543
|
},
|
|
537
544
|
"yolo": {
|
|
538
545
|
"type": "boolean"
|
|
546
|
+
},
|
|
547
|
+
"fileSet": {
|
|
548
|
+
"type": "string",
|
|
549
|
+
"enum": [
|
|
550
|
+
"gitignore",
|
|
551
|
+
"all"
|
|
552
|
+
]
|
|
539
553
|
}
|
|
540
554
|
}
|
|
541
555
|
}
|
|
@@ -795,6 +809,13 @@
|
|
|
795
809
|
},
|
|
796
810
|
"yolo": {
|
|
797
811
|
"type": "boolean"
|
|
812
|
+
},
|
|
813
|
+
"fileSet": {
|
|
814
|
+
"type": "string",
|
|
815
|
+
"enum": [
|
|
816
|
+
"gitignore",
|
|
817
|
+
"all"
|
|
818
|
+
]
|
|
798
819
|
}
|
|
799
820
|
}
|
|
800
821
|
}
|
|
@@ -1045,6 +1066,13 @@
|
|
|
1045
1066
|
},
|
|
1046
1067
|
"yolo": {
|
|
1047
1068
|
"type": "boolean"
|
|
1069
|
+
},
|
|
1070
|
+
"fileSet": {
|
|
1071
|
+
"type": "string",
|
|
1072
|
+
"enum": [
|
|
1073
|
+
"gitignore",
|
|
1074
|
+
"all"
|
|
1075
|
+
]
|
|
1048
1076
|
}
|
|
1049
1077
|
}
|
|
1050
1078
|
}
|
|
@@ -1275,6 +1303,13 @@
|
|
|
1275
1303
|
},
|
|
1276
1304
|
"yolo": {
|
|
1277
1305
|
"type": "boolean"
|
|
1306
|
+
},
|
|
1307
|
+
"fileSet": {
|
|
1308
|
+
"type": "string",
|
|
1309
|
+
"enum": [
|
|
1310
|
+
"gitignore",
|
|
1311
|
+
"all"
|
|
1312
|
+
]
|
|
1278
1313
|
}
|
|
1279
1314
|
}
|
|
1280
1315
|
}
|
|
@@ -1505,6 +1540,13 @@
|
|
|
1505
1540
|
},
|
|
1506
1541
|
"yolo": {
|
|
1507
1542
|
"type": "boolean"
|
|
1543
|
+
},
|
|
1544
|
+
"fileSet": {
|
|
1545
|
+
"type": "string",
|
|
1546
|
+
"enum": [
|
|
1547
|
+
"gitignore",
|
|
1548
|
+
"all"
|
|
1549
|
+
]
|
|
1508
1550
|
}
|
|
1509
1551
|
}
|
|
1510
1552
|
}
|
|
@@ -1735,6 +1777,13 @@
|
|
|
1735
1777
|
},
|
|
1736
1778
|
"yolo": {
|
|
1737
1779
|
"type": "boolean"
|
|
1780
|
+
},
|
|
1781
|
+
"fileSet": {
|
|
1782
|
+
"type": "string",
|
|
1783
|
+
"enum": [
|
|
1784
|
+
"gitignore",
|
|
1785
|
+
"all"
|
|
1786
|
+
]
|
|
1738
1787
|
}
|
|
1739
1788
|
}
|
|
1740
1789
|
}
|
|
@@ -1965,6 +2014,13 @@
|
|
|
1965
2014
|
},
|
|
1966
2015
|
"yolo": {
|
|
1967
2016
|
"type": "boolean"
|
|
2017
|
+
},
|
|
2018
|
+
"fileSet": {
|
|
2019
|
+
"type": "string",
|
|
2020
|
+
"enum": [
|
|
2021
|
+
"gitignore",
|
|
2022
|
+
"all"
|
|
2023
|
+
]
|
|
1968
2024
|
}
|
|
1969
2025
|
}
|
|
1970
2026
|
}
|
|
@@ -1994,9 +2050,36 @@
|
|
|
1994
2050
|
}
|
|
1995
2051
|
}
|
|
1996
2052
|
},
|
|
2053
|
+
"commit": {
|
|
2054
|
+
"type": "object",
|
|
2055
|
+
"properties": {
|
|
2056
|
+
"coAuthor": {
|
|
2057
|
+
"type": "object",
|
|
2058
|
+
"properties": {
|
|
2059
|
+
"name": {
|
|
2060
|
+
"type": "string"
|
|
2061
|
+
},
|
|
2062
|
+
"email": {
|
|
2063
|
+
"type": "string"
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
},
|
|
1997
2069
|
"modelDisplayName": {
|
|
1998
2070
|
"type": "string"
|
|
1999
2071
|
},
|
|
2072
|
+
"injectModelContext": {
|
|
2073
|
+
"type": "boolean"
|
|
2074
|
+
},
|
|
2075
|
+
"debugDump": {
|
|
2076
|
+
"type": "object",
|
|
2077
|
+
"properties": {
|
|
2078
|
+
"redact": {
|
|
2079
|
+
"type": "boolean"
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
},
|
|
2000
2083
|
"allowDirs": {
|
|
2001
2084
|
"type": "array",
|
|
2002
2085
|
"items": {
|
|
@@ -2005,6 +2088,14 @@
|
|
|
2005
2088
|
},
|
|
2006
2089
|
"askWriteMode": {
|
|
2007
2090
|
"type": "boolean"
|
|
2091
|
+
},
|
|
2092
|
+
"output": {
|
|
2093
|
+
"type": "object",
|
|
2094
|
+
"properties": {
|
|
2095
|
+
"header": {
|
|
2096
|
+
"type": "boolean"
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2008
2099
|
}
|
|
2009
2100
|
},
|
|
2010
2101
|
"additionalProperties": {}
|