@emseepea/testing 0.9.7 → 0.9.11
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/package.json +2 -2
- package/semantic/provider.mjs +9 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emseepea/testing",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.11",
|
|
4
4
|
"description": "MCP integration and semantic testing helpers",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"test:built": "node --test test/*.test.mjs"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@emseepea/server": "0.
|
|
44
|
+
"@emseepea/server": "0.10.1",
|
|
45
45
|
"@modelcontextprotocol/client": "2.0.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
package/semantic/provider.mjs
CHANGED
|
@@ -10,6 +10,13 @@ const providerErrorMessages = new Map([
|
|
|
10
10
|
["error_max_budget_usd", "Model command exceeded its budget"],
|
|
11
11
|
["error_max_turns", "Model command exceeded its turn limit"],
|
|
12
12
|
]);
|
|
13
|
+
const authenticationFailure = /not logged in|failed to authenticate|oauth session expired/i;
|
|
14
|
+
const hasAuthenticationFailure = (events) => events.some((event) => (
|
|
15
|
+
(Array.isArray(event.message?.content)
|
|
16
|
+
&& event.message.content.some(({ type, text }) => type === "text" && /not logged in/i.test(text ?? "")))
|
|
17
|
+
|| (event.type === "result" && event.is_error === true
|
|
18
|
+
&& typeof event.result === "string" && authenticationFailure.test(event.result))
|
|
19
|
+
));
|
|
13
20
|
|
|
14
21
|
export async function modelVersion() {
|
|
15
22
|
const result = await runProcess("claude", ["--version"], { env: modelEnvironment({}) });
|
|
@@ -27,14 +34,10 @@ export function parseClaudeEvents(stdout, processExitCode = 0) {
|
|
|
27
34
|
}
|
|
28
35
|
const result = events.findLast(({ type }) => type === "result");
|
|
29
36
|
const answer = result?.result;
|
|
30
|
-
const notLoggedIn = events.some(({ message }) => (
|
|
31
|
-
Array.isArray(message?.content)
|
|
32
|
-
&& message.content.some(({ type, text }) => type === "text" && /not logged in/i.test(text ?? ""))
|
|
33
|
-
));
|
|
34
37
|
const toolUses = events.flatMap(({ message }) => (
|
|
35
38
|
Array.isArray(message?.content) ? message.content.filter(({ type }) => type === "tool_use") : []
|
|
36
39
|
));
|
|
37
|
-
if (
|
|
40
|
+
if (hasAuthenticationFailure(events)) throw new Error("Model command is not signed in");
|
|
38
41
|
if (processExitCode !== 0) throw new Error(`Model command exited ${processExitCode}`);
|
|
39
42
|
if (!result) throw new Error("Model command omitted its result event");
|
|
40
43
|
if (result.is_error) {
|
|
@@ -118,9 +121,7 @@ export function parseNativeClaudeEvents(stdout, advertisedTools, requireInit = f
|
|
|
118
121
|
responseSha256: hash(response.content),
|
|
119
122
|
};
|
|
120
123
|
});
|
|
121
|
-
|
|
122
|
-
&& message.content.some(({ type, text }) => type === "text" && /not logged in/i.test(text ?? "")));
|
|
123
|
-
if (notLoggedIn) throw new Error("Model command is not signed in");
|
|
124
|
+
if (hasAuthenticationFailure(events)) throw new Error("Model command is not signed in");
|
|
124
125
|
if (result?.is_error || typeof result?.result !== "string") {
|
|
125
126
|
throw new Error("Model command returned no answer");
|
|
126
127
|
}
|