@mcoda/agents 0.1.38 → 0.1.40
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentService.d.ts","sourceRoot":"","sources":["../../src/AgentService/AgentService.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EAKpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAY7C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"AgentService.d.ts","sourceRoot":"","sources":["../../src/AgentService/AgentService.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,EACL,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EAKpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAY7C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAyMhG,UAAU,mBAAmB;IAC3B,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,qBAAa,YAAY;IAErB,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,OAAO;gBADP,IAAI,EAAE,gBAAgB,EACtB,OAAO,GAAE,mBAAwB;WAG9B,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAKtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,YAAY,CAAC,UAAU,EAAE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MswarmCloudAgent = (agent) => {
|
|
60
|
+
const config = agent.config;
|
|
61
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const managed = config.mswarmCloud;
|
|
65
|
+
return Boolean(managed &&
|
|
66
|
+
typeof managed === "object" &&
|
|
67
|
+
!Array.isArray(managed) &&
|
|
68
|
+
managed.managed === true);
|
|
69
|
+
};
|
|
59
70
|
const isIoEnabled = () => {
|
|
60
71
|
const raw = process.env[IO_ENV];
|
|
61
72
|
if (!raw)
|
|
@@ -266,6 +277,10 @@ export class AgentService {
|
|
|
266
277
|
if (adapterType.endsWith("-api")) {
|
|
267
278
|
if (hasSecret)
|
|
268
279
|
return adapterType;
|
|
280
|
+
if (adapterType === "openai-api" && isManagedMswarmCloudAgent(agent)) {
|
|
281
|
+
const label = agent.slug ?? agent.id;
|
|
282
|
+
throw new Error(`AUTH_REQUIRED: Managed mswarm cloud agent ${label} is missing the synced API key; run \`mcoda config set mswarm-api-key <KEY>\` and \`mcoda cloud agent sync\`.`);
|
|
283
|
+
}
|
|
269
284
|
if (adapterType === "codex-api" || adapterType === "openai-api") {
|
|
270
285
|
// Default to the codex CLI when API creds are missing.
|
|
271
286
|
adapterType = "codex-cli";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenAiAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/openai/OpenAiAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAwHtG,KAAK,YAAY,GAAG,aAAa,GAAG;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CA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UlC,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIpC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC;IAgFnC,MAAM,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwC5D,YAAY,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,CAAC,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC;IAwFhG,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,SAAS;IAoBjB,OAAO,CAAC,oBAAoB;CAU7B"}
|
|
@@ -128,16 +128,79 @@ export class OpenAiAdapter {
|
|
|
128
128
|
agentId: this.config.agent.id,
|
|
129
129
|
status: "unreachable",
|
|
130
130
|
lastCheckedAt: new Date().toISOString(),
|
|
131
|
-
details: {
|
|
131
|
+
details: {
|
|
132
|
+
adapter: "openai-api",
|
|
133
|
+
source: "openai_probe",
|
|
134
|
+
model: this.config.model,
|
|
135
|
+
baseUrl: this.baseUrl,
|
|
136
|
+
reason: "missing_api_key",
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const startedAt = Date.now();
|
|
141
|
+
try {
|
|
142
|
+
const model = this.ensureModel();
|
|
143
|
+
const apiKey = this.ensureApiKey();
|
|
144
|
+
const url = this.ensureBaseUrl();
|
|
145
|
+
const response = await fetch(`${url}/chat/completions`, {
|
|
146
|
+
method: "POST",
|
|
147
|
+
headers: this.buildHeaders(apiKey, false),
|
|
148
|
+
body: JSON.stringify(this.buildHealthCheckBody(model)),
|
|
149
|
+
});
|
|
150
|
+
const responseText = await response.text().catch(() => "");
|
|
151
|
+
const latencyMs = Date.now() - startedAt;
|
|
152
|
+
if (!response.ok) {
|
|
153
|
+
return {
|
|
154
|
+
agentId: this.config.agent.id,
|
|
155
|
+
status: response.status === 429 ? "degraded" : "unreachable",
|
|
156
|
+
lastCheckedAt: new Date().toISOString(),
|
|
157
|
+
latencyMs,
|
|
158
|
+
details: {
|
|
159
|
+
adapter: "openai-api",
|
|
160
|
+
source: "openai_probe",
|
|
161
|
+
model,
|
|
162
|
+
baseUrl: url,
|
|
163
|
+
reason: "http_error",
|
|
164
|
+
httpStatus: response.status,
|
|
165
|
+
response: responseText.slice(0, 500),
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
agentId: this.config.agent.id,
|
|
171
|
+
status: "healthy",
|
|
172
|
+
lastCheckedAt: new Date().toISOString(),
|
|
173
|
+
latencyMs,
|
|
174
|
+
details: {
|
|
175
|
+
adapter: "openai-api",
|
|
176
|
+
source: "openai_probe",
|
|
177
|
+
model,
|
|
178
|
+
baseUrl: url,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
184
|
+
const reason = /model is not configured/i.test(message)
|
|
185
|
+
? "missing_model"
|
|
186
|
+
: /missing api key/i.test(message)
|
|
187
|
+
? "missing_api_key"
|
|
188
|
+
: "probe_failed";
|
|
189
|
+
return {
|
|
190
|
+
agentId: this.config.agent.id,
|
|
191
|
+
status: "unreachable",
|
|
192
|
+
lastCheckedAt: new Date().toISOString(),
|
|
193
|
+
latencyMs: Date.now() - startedAt,
|
|
194
|
+
details: {
|
|
195
|
+
adapter: "openai-api",
|
|
196
|
+
source: "openai_probe",
|
|
197
|
+
model: this.config.model,
|
|
198
|
+
baseUrl: this.baseUrl,
|
|
199
|
+
reason,
|
|
200
|
+
error: message,
|
|
201
|
+
},
|
|
132
202
|
};
|
|
133
203
|
}
|
|
134
|
-
return {
|
|
135
|
-
agentId: this.config.agent.id,
|
|
136
|
-
status: "healthy",
|
|
137
|
-
lastCheckedAt: new Date().toISOString(),
|
|
138
|
-
latencyMs: 0,
|
|
139
|
-
details: { adapter: "openai-api", model: this.config.model, baseUrl: this.baseUrl },
|
|
140
|
-
};
|
|
141
204
|
}
|
|
142
205
|
async invoke(request) {
|
|
143
206
|
const url = this.ensureBaseUrl();
|
|
@@ -321,4 +384,14 @@ export class OpenAiAdapter {
|
|
|
321
384
|
}
|
|
322
385
|
return body;
|
|
323
386
|
}
|
|
387
|
+
buildHealthCheckBody(model) {
|
|
388
|
+
const body = this.buildBody("healthcheck", model, false);
|
|
389
|
+
if (body.max_tokens === undefined && body.max_completion_tokens === undefined) {
|
|
390
|
+
body.max_tokens = 1;
|
|
391
|
+
}
|
|
392
|
+
if (body.temperature === undefined) {
|
|
393
|
+
body.temperature = 0;
|
|
394
|
+
}
|
|
395
|
+
return body;
|
|
396
|
+
}
|
|
324
397
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcoda/agents",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.40",
|
|
4
4
|
"description": "Agent registry and capabilities for mcoda.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@mcoda/shared": "0.1.
|
|
34
|
-
"@mcoda/db": "0.1.
|
|
33
|
+
"@mcoda/shared": "0.1.40",
|
|
34
|
+
"@mcoda/db": "0.1.40"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc -p tsconfig.json",
|