@aexol/spectral 0.9.169 → 0.9.171
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/agent/agents.d.ts.map +1 -1
- package/dist/agent/agents.js +30 -42
- package/dist/generated/graphql-client.d.ts +39 -0
- package/dist/generated/graphql-client.d.ts.map +1 -0
- package/dist/generated/graphql-client.js +74 -0
- package/dist/generated/scalars.d.ts +24 -0
- package/dist/generated/scalars.d.ts.map +1 -0
- package/dist/generated/scalars.js +30 -0
- package/dist/generated/zeus/const.d.ts +8 -0
- package/dist/generated/zeus/const.d.ts.map +1 -0
- package/dist/generated/zeus/const.js +1626 -0
- package/dist/generated/zeus/index.d.ts +8565 -0
- package/dist/generated/zeus/index.d.ts.map +1 -0
- package/dist/generated/zeus/index.js +791 -0
- package/dist/mcp/ui-stream-types.d.ts +2 -2
- package/dist/relay/models-fetch.d.ts +4 -5
- package/dist/relay/models-fetch.d.ts.map +1 -1
- package/dist/relay/models-fetch.js +50 -79
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/agent/agents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/agent/agents.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;AACrD,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAC/C,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;CAClB;AACD,MAAM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,IAAI,CAChB,WAAW,EACX,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,CAC7D,GAAG,IAAI,GACP,MAAM,GAAG,SAAS,CAQpB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,IAAI,CACT,WAAW,EACX,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,CAC7D,GAAG,IAAI,GACP,MAAM,CAcR"}
|
package/dist/agent/agents.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as fs from "node:fs";
|
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { getAgentDir, parseFrontmatter } from "../sdk/coding-agent/index.js";
|
|
5
|
+
import { classifyGraphqlError, createBackendClient, graphqlErrorMessage, scalars, } from "../generated/graphql-client.js";
|
|
5
6
|
function loadAgentsFromDir(dir, source) {
|
|
6
7
|
const agents = [];
|
|
7
8
|
if (!fs.existsSync(dir))
|
|
@@ -70,48 +71,25 @@ export async function refreshCloudAgents(opts) {
|
|
|
70
71
|
let refresh;
|
|
71
72
|
refresh = (async () => {
|
|
72
73
|
try {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
authorization: `Bearer ${opts.machineJwt}`,
|
|
78
|
-
"x-team-id": teamId,
|
|
79
|
-
},
|
|
80
|
-
body: JSON.stringify({
|
|
81
|
-
query: `query CloudAgents($teamId: ID!) { agents(teamId: $teamId) { name description systemPrompt model mode scope } }`,
|
|
82
|
-
variables: { teamId },
|
|
83
|
-
}),
|
|
74
|
+
const client = createBackendClient({
|
|
75
|
+
backendUrl: opts.backendUrl,
|
|
76
|
+
machineJwt: opts.machineJwt,
|
|
77
|
+
teamId,
|
|
84
78
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
const
|
|
99
|
-
// GraphQL commonly returns 200 with an `errors` array when auth fails
|
|
100
|
-
// (e.g. "Authentication required", "Not authorized for this team").
|
|
101
|
-
// Treat any auth-flavored error as auth-rejected so the caller can
|
|
102
|
-
// recover; other GraphQL errors are non-fatal (no agents loaded).
|
|
103
|
-
if (payload.errors && payload.errors.length > 0) {
|
|
104
|
-
const msg = payload.errors.map((e) => e.message ?? "").join("; ");
|
|
105
|
-
const looksLikeAuth = /authentication required|not authorized|unauthor/i.test(msg);
|
|
106
|
-
const reason = `Cloud agents: backend rejected machine JWT (${msg})`;
|
|
107
|
-
if (looksLikeAuth) {
|
|
108
|
-
console.warn(reason);
|
|
109
|
-
return { authRejected: true, reason };
|
|
110
|
-
}
|
|
111
|
-
console.warn(reason);
|
|
112
|
-
return { authRejected: false, count: 0 };
|
|
113
|
-
}
|
|
114
|
-
const fetched = payload.data?.agents ?? [];
|
|
79
|
+
const result = await client("query", { scalars })({
|
|
80
|
+
agents: [
|
|
81
|
+
{ teamId },
|
|
82
|
+
{
|
|
83
|
+
name: true,
|
|
84
|
+
description: true,
|
|
85
|
+
systemPrompt: true,
|
|
86
|
+
model: true,
|
|
87
|
+
mode: true,
|
|
88
|
+
scope: true,
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
});
|
|
92
|
+
const fetched = result.agents ?? [];
|
|
115
93
|
const agents = fetched
|
|
116
94
|
.filter((a) => typeof a.name === "string" &&
|
|
117
95
|
typeof a.description === "string" &&
|
|
@@ -133,8 +111,18 @@ export async function refreshCloudAgents(opts) {
|
|
|
133
111
|
return { authRejected: false, count: agents.length };
|
|
134
112
|
}
|
|
135
113
|
catch (err) {
|
|
114
|
+
// Zeus surfaces a GraphQL `errors` array as `GraphQLError` (HTTP 200)
|
|
115
|
+
// and non-2xx responses as an error too. Treat auth-flavored failures
|
|
116
|
+
// as auth-rejected so the caller can trigger a forced re-registration
|
|
117
|
+
// instead of looping on the same dead token.
|
|
118
|
+
const classified = classifyGraphqlError(err);
|
|
119
|
+
if (classified.authRejected) {
|
|
120
|
+
const reason = `Cloud agents: backend rejected machine JWT (${classified.message})`;
|
|
121
|
+
console.warn(reason);
|
|
122
|
+
return { authRejected: true, reason };
|
|
123
|
+
}
|
|
136
124
|
// Network errors are non-fatal — local agents remain available offline.
|
|
137
|
-
const msg =
|
|
125
|
+
const msg = graphqlErrorMessage(err);
|
|
138
126
|
console.warn(`Cloud agents: refresh failed (${msg})`);
|
|
139
127
|
return { authRejected: false, count: 0 };
|
|
140
128
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrapper over the generated Zeus client for the CLI's backend
|
|
3
|
+
* GraphQL calls.
|
|
4
|
+
*
|
|
5
|
+
* Zeus is generated from `backend/schema.graphql` into
|
|
6
|
+
* `./zeus/index.ts` (see `backend/axolotl.json`). The generated files are
|
|
7
|
+
* codegen artifacts — never hand-edit them. This module centralizes auth
|
|
8
|
+
* headers (machine JWT + optional team id) so call sites never rebuild the
|
|
9
|
+
* `Authorization` / `X-Team-Id` contract by hand.
|
|
10
|
+
*/
|
|
11
|
+
import { Chain, type GraphQLResponse } from "./zeus/index.js";
|
|
12
|
+
import { scalars } from "./scalars.js";
|
|
13
|
+
export type { GraphQLResponse };
|
|
14
|
+
/** Create an authenticated backend GraphQL client (Zeus `Chain`). */
|
|
15
|
+
export declare function createBackendClient(opts: {
|
|
16
|
+
backendUrl: string;
|
|
17
|
+
machineJwt: string;
|
|
18
|
+
teamId?: string;
|
|
19
|
+
}): ReturnType<typeof Chain>;
|
|
20
|
+
/** Shared scalar codecs (ID / DateTime / Long). */
|
|
21
|
+
export { scalars };
|
|
22
|
+
/** True when an error message looks like an auth rejection. */
|
|
23
|
+
export declare function isAuthErrorMessage(message: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* The error message from a caught Zeus `GraphQLError`, or the raw error
|
|
26
|
+
* string when the thrown value is not a GraphQL response error.
|
|
27
|
+
*/
|
|
28
|
+
export declare function graphqlErrorMessage(err: unknown): string;
|
|
29
|
+
/**
|
|
30
|
+
* Classify a caught Zeus error as an auth rejection. Zeus throws
|
|
31
|
+
* `GraphQLError` for HTTP 200 responses with a GraphQL `errors` array, but
|
|
32
|
+
* non-2xx HTTP responses (e.g. 401/403) are rejected with the parsed JSON
|
|
33
|
+
* body object. Handle both without losing the original message.
|
|
34
|
+
*/
|
|
35
|
+
export declare function classifyGraphqlError(err: unknown): {
|
|
36
|
+
authRejected: boolean;
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=graphql-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql-client.d.ts","sourceRoot":"","sources":["../../src/generated/graphql-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,EAEL,KAAK,eAAe,EAErB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,qEAAqE;AACrE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAY3B;AAED,mDAAmD;AACnD,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAI3D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAQxD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG;IAClD,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB,CA4BA"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin wrapper over the generated Zeus client for the CLI's backend
|
|
3
|
+
* GraphQL calls.
|
|
4
|
+
*
|
|
5
|
+
* Zeus is generated from `backend/schema.graphql` into
|
|
6
|
+
* `./zeus/index.ts` (see `backend/axolotl.json`). The generated files are
|
|
7
|
+
* codegen artifacts — never hand-edit them. This module centralizes auth
|
|
8
|
+
* headers (machine JWT + optional team id) so call sites never rebuild the
|
|
9
|
+
* `Authorization` / `X-Team-Id` contract by hand.
|
|
10
|
+
*/
|
|
11
|
+
import { Chain, GraphQLError, } from "./zeus/index.js";
|
|
12
|
+
import { scalars } from "./scalars.js";
|
|
13
|
+
/** Create an authenticated backend GraphQL client (Zeus `Chain`). */
|
|
14
|
+
export function createBackendClient(opts) {
|
|
15
|
+
const headers = {
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
Authorization: `Bearer ${opts.machineJwt}`,
|
|
18
|
+
};
|
|
19
|
+
if (opts.teamId)
|
|
20
|
+
headers["X-Team-Id"] = opts.teamId;
|
|
21
|
+
const endpoint = [
|
|
22
|
+
`${opts.backendUrl.replace(/\/$/, "")}/graphql`,
|
|
23
|
+
{ headers },
|
|
24
|
+
];
|
|
25
|
+
return Chain(...endpoint);
|
|
26
|
+
}
|
|
27
|
+
/** Shared scalar codecs (ID / DateTime / Long). */
|
|
28
|
+
export { scalars };
|
|
29
|
+
/** True when an error message looks like an auth rejection. */
|
|
30
|
+
export function isAuthErrorMessage(message) {
|
|
31
|
+
return /authentication required|not authorized|unauthor|forbidden|invalid token|token expired/i.test(message);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The error message from a caught Zeus `GraphQLError`, or the raw error
|
|
35
|
+
* string when the thrown value is not a GraphQL response error.
|
|
36
|
+
*/
|
|
37
|
+
export function graphqlErrorMessage(err) {
|
|
38
|
+
if (err instanceof GraphQLError) {
|
|
39
|
+
return (err.response.errors?.map((e) => e.message).join("; ") ?? "GraphQL error");
|
|
40
|
+
}
|
|
41
|
+
if (err instanceof Error)
|
|
42
|
+
return err.message;
|
|
43
|
+
return String(err);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Classify a caught Zeus error as an auth rejection. Zeus throws
|
|
47
|
+
* `GraphQLError` for HTTP 200 responses with a GraphQL `errors` array, but
|
|
48
|
+
* non-2xx HTTP responses (e.g. 401/403) are rejected with the parsed JSON
|
|
49
|
+
* body object. Handle both without losing the original message.
|
|
50
|
+
*/
|
|
51
|
+
export function classifyGraphqlError(err) {
|
|
52
|
+
if (err instanceof GraphQLError) {
|
|
53
|
+
const message = graphqlErrorMessage(err);
|
|
54
|
+
return { authRejected: isAuthErrorMessage(message), message };
|
|
55
|
+
}
|
|
56
|
+
let message = "Unknown error";
|
|
57
|
+
if (err instanceof Error) {
|
|
58
|
+
message = err.message;
|
|
59
|
+
}
|
|
60
|
+
else if (typeof err === "string") {
|
|
61
|
+
message = err;
|
|
62
|
+
}
|
|
63
|
+
else if (err && typeof err === "object") {
|
|
64
|
+
const body = err;
|
|
65
|
+
if (Array.isArray(body.errors) && body.errors.length > 0) {
|
|
66
|
+
message = body.errors.map((e) => e.message ?? "unknown").join("; ");
|
|
67
|
+
}
|
|
68
|
+
if (typeof body.status === "number" &&
|
|
69
|
+
(body.status === 401 || body.status === 403)) {
|
|
70
|
+
return { authRejected: true, message };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { authRejected: isAuthErrorMessage(message), message };
|
|
74
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scalar codecs for the generated Zeus GraphQL client.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `landing/lib/scalars.ts`. The CLI only issues `query`/`mutation`
|
|
5
|
+
* operations against the backend's `availableAgentModels` and `agents`
|
|
6
|
+
* fields, neither of which carries a custom scalar today. The codecs are
|
|
7
|
+
* still defined here so any future CLI-side query that does touch `ID`,
|
|
8
|
+
* `DateTime`, `Long`, or `JSON` decodes consistently with the landing app.
|
|
9
|
+
*/
|
|
10
|
+
export declare const scalars: {
|
|
11
|
+
ID: {
|
|
12
|
+
decode: (e: unknown) => string;
|
|
13
|
+
encode: (e: unknown) => string;
|
|
14
|
+
};
|
|
15
|
+
DateTime: {
|
|
16
|
+
decode: (e: unknown) => Date;
|
|
17
|
+
encode: (e: unknown) => string;
|
|
18
|
+
};
|
|
19
|
+
Long: {
|
|
20
|
+
decode: (e: unknown) => number;
|
|
21
|
+
encode: (e: unknown) => string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=scalars.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalars.d.ts","sourceRoot":"","sources":["../../src/generated/scalars.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,eAAO,MAAM,OAAO;;oBAEJ,OAAO,KAAU,MAAM;oBACvB,OAAO;;;oBAGP,OAAO;oBACP,OAAO;;;oBAYP,OAAO,KAAU,MAAM;oBACvB,OAAO;;CAErB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scalar codecs for the generated Zeus GraphQL client.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `landing/lib/scalars.ts`. The CLI only issues `query`/`mutation`
|
|
5
|
+
* operations against the backend's `availableAgentModels` and `agents`
|
|
6
|
+
* fields, neither of which carries a custom scalar today. The codecs are
|
|
7
|
+
* still defined here so any future CLI-side query that does touch `ID`,
|
|
8
|
+
* `DateTime`, `Long`, or `JSON` decodes consistently with the landing app.
|
|
9
|
+
*/
|
|
10
|
+
import { ZeusScalars } from "./zeus/index.js";
|
|
11
|
+
export const scalars = ZeusScalars({
|
|
12
|
+
ID: {
|
|
13
|
+
decode: (e) => e,
|
|
14
|
+
encode: (e) => JSON.stringify(e),
|
|
15
|
+
},
|
|
16
|
+
DateTime: {
|
|
17
|
+
decode: (e) => new Date(e),
|
|
18
|
+
encode: (e) => {
|
|
19
|
+
const date = e instanceof Date ? e : typeof e === "string" ? new Date(e) : null;
|
|
20
|
+
if (!date || Number.isNaN(date.getTime())) {
|
|
21
|
+
throw new TypeError(`DateTime scalar cannot encode an invalid date value: ${String(e)}`);
|
|
22
|
+
}
|
|
23
|
+
return JSON.stringify(date.toISOString());
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
Long: {
|
|
27
|
+
decode: (e) => e,
|
|
28
|
+
encode: (e) => JSON.stringify(e),
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.d.ts","sourceRoot":"","sources":["../../../src/generated/zeus/const.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAC,GAAG,CA8xB5C,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAC,GAAG,CA8lC1C,CAAA;AAED,eAAO,MAAM,GAAG;;;;CAIf,CAAA"}
|