@gaunt-sloth/core 2.0.0-beta.2 → 2.0.0-beta.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/dist/config/shell-policy.d.ts +2 -2
- package/dist/config/shell-policy.js +3 -3
- package/dist/config/tool-descriptions.d.ts +5 -5
- package/dist/config/tool-descriptions.js +3 -3
- package/dist/core/GthAbstractAgent.d.ts +1 -1
- package/dist/core/GthAbstractAgent.js +63 -3
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +9 -9
- package/dist/core/GthAgentRunner.js +62 -13
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.js +1 -1
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/reasoningBlocks.d.ts +4 -6
- package/dist/core/reasoningBlocks.js +4 -6
- package/dist/core/reasoningBlocks.js.map +1 -1
- package/dist/core/shell/ShellCommandFailedError.d.ts +4 -4
- package/dist/core/shell/ShellCommandFailedError.js +4 -4
- package/dist/core/shell/openWorld.d.ts +4 -3
- package/dist/core/shell/openWorld.js +4 -3
- package/dist/core/shell/openWorld.js.map +1 -1
- package/dist/core/toolDisplay.d.ts +49 -2
- package/dist/core/toolDisplay.js +137 -19
- package/dist/core/toolDisplay.js.map +1 -1
- package/dist/core/types.d.ts +6 -6
- package/dist/providers/geminiSchemaSanitizer.d.ts +2 -2
- package/dist/providers/geminiSchemaSanitizer.js +2 -2
- package/dist/providers/geminiThinking.d.ts +10 -5
- package/dist/providers/geminiThinking.js +10 -5
- package/dist/providers/geminiThinking.js.map +1 -1
- package/dist/runtime/askStructured.d.ts +22 -0
- package/dist/runtime/askStructured.js +53 -0
- package/dist/runtime/askStructured.js.map +1 -1
- package/dist/utils/aiignoreUtils.d.ts +6 -0
- package/dist/utils/aiignoreUtils.js +69 -1
- package/dist/utils/aiignoreUtils.js.map +1 -1
- package/dist/utils/displayWidth.d.ts +10 -5
- package/dist/utils/displayWidth.js +148 -54
- package/dist/utils/displayWidth.js.map +1 -1
- package/dist/utils/llmUtils.d.ts +1 -1
- package/dist/utils/llmUtils.js +1 -1
- package/dist/utils/systemPromptNotes.d.ts +3 -3
- package/dist/utils/systemPromptNotes.js +3 -3
- package/dist/utils/vertexaiUtils.js +100 -1
- package/dist/utils/vertexaiUtils.js.map +1 -1
- package/package.json +4 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { env } from '#src/utils/systemUtils.js';
|
|
1
2
|
export function isVertexGoogleLlm(llm) {
|
|
2
3
|
if (!llm || typeof llm !== 'object') {
|
|
3
4
|
return false;
|
|
@@ -70,12 +71,110 @@ const VERTEX_AUTH_GUIDANCE = {
|
|
|
70
71
|
'Check the one this session is configured for — a Google AI Studio key is not valid for ' +
|
|
71
72
|
'Vertex AI endpoints.',
|
|
72
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* The longest value still treated as a filesystem path. 260 is Windows' classic `MAX_PATH`, which is
|
|
76
|
+
* a defensible ceiling for a path and sits an order of magnitude below any credential: the deepest
|
|
77
|
+
* realistic ADC path — a CI runner's temp directory plus
|
|
78
|
+
* `application_default_credentials.json` — is around 120 characters, while a service-account key is
|
|
79
|
+
* ~1700 as JSON and ~2300 base64-encoded. Nothing has to land in the gap for the test to be useful.
|
|
80
|
+
*/
|
|
81
|
+
const MAX_CREDENTIAL_PATH_LENGTH = 260;
|
|
82
|
+
/**
|
|
83
|
+
* Whether a value is the credential ITSELF rather than a path to one.
|
|
84
|
+
*
|
|
85
|
+
* Deliberately tested by SIZE first rather than by shape. The shape test alone (`{`) catches a
|
|
86
|
+
* pasted JSON key and misses the base64 form that CI secret stores hand out, and widening it one
|
|
87
|
+
* encoding at a time only ever covers the last spelling somebody thought of — the value is
|
|
88
|
+
* attacker-irrelevant but user-supplied and its formats are open-ended. Length closes the class
|
|
89
|
+
* because every credential is enormous next to every path. The shape test is kept alongside it for
|
|
90
|
+
* the short, hand-trimmed JSON that a size test alone would let through.
|
|
91
|
+
*/
|
|
92
|
+
function isCredentialContent(value) {
|
|
93
|
+
return value.length > MAX_CREDENTIAL_PATH_LENGTH || value.trimStart().startsWith('{');
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Where an ADC session's credentials are being read from when an environment variable names a file,
|
|
97
|
+
* and the spelling of the variable that named it — `undefined` when no such variable is in play.
|
|
98
|
+
*
|
|
99
|
+
* THIS IS THE ONE ENVIRONMENT READ IN THIS FILE AND IT IS DELIBERATE, so read it against the
|
|
100
|
+
* comment on {@link vertexAuthMode} rather than as a contradiction of it. That function decides
|
|
101
|
+
* WHICH credential is in use and must keep doing so from the constructed client alone. This one
|
|
102
|
+
* decides nothing: the session has already been classified as ADC from the client, and the
|
|
103
|
+
* environment is consulted only to compose the DIAGNOSTIC SENTENCE for it. Read-only, through the
|
|
104
|
+
* `systemUtils` accessor like every other environment read in this package.
|
|
105
|
+
*
|
|
106
|
+
* It is not client-derived because there is nothing client-derived to be had. Measured on
|
|
107
|
+
* google-auth-library 10.9.1: `GoogleAuth.keyFilename` is populated only from constructor options,
|
|
108
|
+
* so on a Vertex client it is `undefined` both with and without the variable set, and stays
|
|
109
|
+
* `undefined` after a resolution attempt. The only artifact a successful resolution leaves behind is
|
|
110
|
+
* `jsonContent` — the parsed key file, which holds the private key and must never be printed.
|
|
111
|
+
*
|
|
112
|
+
* Mirrors `googleauth.js` rather than reinventing it: both spellings, upper case first, and an empty
|
|
113
|
+
* value falls through to the well-known file instead of counting as set.
|
|
114
|
+
*/
|
|
115
|
+
function adcCredentialFileFromEnvironment() {
|
|
116
|
+
for (const variable of ['GOOGLE_APPLICATION_CREDENTIALS', 'google_application_credentials']) {
|
|
117
|
+
const path = env[variable];
|
|
118
|
+
if (!path) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
// First non-empty wins, exactly as the library's `||` does — so a value that is credential
|
|
122
|
+
// CONTENT rather than a path ends the search rather than falling through to the other spelling.
|
|
123
|
+
//
|
|
124
|
+
// Pasting the service-account key into the variable instead of writing it to a file is a common
|
|
125
|
+
// CI misconfiguration, and such a session must NOT be described below. There is no file for the
|
|
126
|
+
// message to point at, so naming one would be exactly the kind of claim-that-does-not-hold this
|
|
127
|
+
// hint exists to avoid; and the value is a private key, while this message also reaches the log
|
|
128
|
+
// stream and debug dumps. It falls back to the pinned `adc` sentence, which asserts nothing
|
|
129
|
+
// about where the credentials came from.
|
|
130
|
+
return isCredentialContent(path) ? undefined : { variable, path };
|
|
131
|
+
}
|
|
132
|
+
return undefined;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The remedy for an ADC session whose credentials come from a file named in the environment.
|
|
136
|
+
*
|
|
137
|
+
* The diagnosis is the same as the plain `adc` one and is CORRECT — this really is ADC. What
|
|
138
|
+
* differs is that the plain remedy is inert here: `google-auth-library` resolves this variable
|
|
139
|
+
* before it reads the well-known file, so `gcloud auth application-default login` writes a file
|
|
140
|
+
* this session never opens, reports success, and leaves the failure exactly where it was. Naming
|
|
141
|
+
* the command anyway is the point — the reader has usually just run it.
|
|
142
|
+
*/
|
|
143
|
+
function adcFromEnvironmentGuidance(variable, path) {
|
|
144
|
+
return ('This session authenticates through Application Default Credentials, and those credentials ' +
|
|
145
|
+
'come from `' +
|
|
146
|
+
variable +
|
|
147
|
+
'` in your environment, which points at `' +
|
|
148
|
+
path +
|
|
149
|
+
'`. That variable is resolved BEFORE the well-known credentials file, so ' +
|
|
150
|
+
'`gcloud auth application-default login` writes a file this session never reads and the ' +
|
|
151
|
+
'failure survives it. Repair or replace the credentials in the file above, or unset ' +
|
|
152
|
+
'`' +
|
|
153
|
+
variable +
|
|
154
|
+
'` so the well-known Application Default Credentials file is used instead. ' +
|
|
155
|
+
'No API key is in use — a `type: vertexai` config ignores any `GOOGLE_API_KEY` in your ' +
|
|
156
|
+
'environment, so unsetting that will not help here.');
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The sentence for a classified session. Only the ADC branch is refined further, and only into the
|
|
160
|
+
* one sub-case whose remedy would otherwise be inert; every other mode returns its pinned string
|
|
161
|
+
* unchanged.
|
|
162
|
+
*/
|
|
163
|
+
function vertexAuthGuidance(mode) {
|
|
164
|
+
if (mode === 'adc') {
|
|
165
|
+
const fromEnvironment = adcCredentialFileFromEnvironment();
|
|
166
|
+
if (fromEnvironment) {
|
|
167
|
+
return adcFromEnvironmentGuidance(fromEnvironment.variable, fromEnvironment.path);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return VERTEX_AUTH_GUIDANCE[mode];
|
|
171
|
+
}
|
|
73
172
|
export function enhanceVertexUnauthorizedMessage(originalMessage, llm) {
|
|
74
173
|
if (!isVertexGoogleLlm(llm) || !VERTEX_AUTH_ERROR_PATTERN.test(originalMessage)) {
|
|
75
174
|
return originalMessage;
|
|
76
175
|
}
|
|
77
176
|
return (`${originalMessage}\n\n` +
|
|
78
177
|
'Vertex AI authentication failed. ' +
|
|
79
|
-
`${
|
|
178
|
+
`${vertexAuthGuidance(vertexAuthMode(llm))}\n`);
|
|
80
179
|
}
|
|
81
180
|
//# sourceMappingURL=vertexaiUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vertexaiUtils.js","sourceRoot":"","sources":["../../src/utils/vertexaiUtils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,iBAAiB,CAAC,GAAY;IAC5C,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,KAAK,GAAG,GAA6B,CAAC;IAC5C,OAAO,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC;AACnC,CAAC;AAED,4DAA4D;AAC5D,gEAAgE;AAChE,gFAAgF;AAChF,qFAAqF;AACrF,MAAM,yBAAyB,GAAG,4DAA4D,CAAC;AAY/F;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAC,GAAY;IAClC,IAAI,CAAC;Q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,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,IAAoB;IAC9C,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;QACnB,MAAM,eAAe,GAAG,gCAAgC,EAAE,CAAC;QAC3D,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,0BAA0B,CAAC,eAAe,CAAC,QAAQ,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;QACpF,CAAC;IACH,CAAC;IACD,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,eAAuB,EAAE,GAAY;IACpF,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;QAChF,OAAO,eAAe,CAAC;IACzB,CAAC;IAED,OAAO,CACL,GAAG,eAAe,MAAM;QACxB,mCAAmC;QACnC,GAAG,kBAAkB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,IAAI,CAC/C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaunt-sloth/core",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Core utilities and types for Gaunt Sloth",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Andrew Kondratev",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@langchain/core": "^1.2.9",
|
|
34
|
-
"@langchain/langgraph": "^1.4.
|
|
34
|
+
"@langchain/langgraph": "^1.4.13",
|
|
35
35
|
"jiti": "^2.7.0",
|
|
36
36
|
"jsonc-parser": "^3.3.1",
|
|
37
37
|
"langchain": "^1.5.10",
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
"scripts": {
|
|
90
90
|
"build": "tsc",
|
|
91
91
|
"schema:generate": "node scripts/generate-config-schema.mjs",
|
|
92
|
-
"surface:generate": "node scripts/generate-type-surface.mjs"
|
|
92
|
+
"surface:generate": "node scripts/generate-type-surface.mjs",
|
|
93
|
+
"value-surface:generate": "node scripts/generate-value-surface.mjs"
|
|
93
94
|
}
|
|
94
95
|
}
|