@ocis/myagent-cli 0.2.4 → 0.2.5
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/index.js +13 -4
- package/dist/protocol/client.js +18 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { stdin as input, stdout as output } from "node:process";
|
|
|
10
10
|
import { homedir } from "node:os";
|
|
11
11
|
import { resolve } from "node:path";
|
|
12
12
|
import pkg from "../package.json" with { type: "json" };
|
|
13
|
-
import { IntegrationClient } from "./protocol/client.js";
|
|
13
|
+
import { IntegrationClient, IntegrationApiError } from "./protocol/client.js";
|
|
14
14
|
import { ToolRegistry } from "./tools/registry.js";
|
|
15
15
|
import { combinedIntegrationUrl, configDir, isConfigured, loadConfig, migrateLegacyConfigDir, resolveConfig, saveConfig, sessionsPath, splitIntegrationUrl, } from "./config.js";
|
|
16
16
|
import { SessionIndex } from "./agent/sessions.js";
|
|
@@ -335,15 +335,24 @@ async function main() {
|
|
|
335
335
|
integrationId: config.integrationId,
|
|
336
336
|
apiKey: config.apiKey,
|
|
337
337
|
});
|
|
338
|
-
let status;
|
|
338
|
+
let status = null;
|
|
339
339
|
try {
|
|
340
340
|
// Bounded connect: a hung server must fail (exit 2) instead of hanging CI.
|
|
341
341
|
status = await client.getStatus({ signal: AbortSignal.timeout(30_000) });
|
|
342
342
|
}
|
|
343
343
|
catch (err) {
|
|
344
|
-
|
|
344
|
+
// A paused platform sandbox answers the status check with 503 — the check
|
|
345
|
+
// deliberately does not wake it (see the platform's proxy-activator). That
|
|
346
|
+
// is not a connection failure: the first run wakes the sandbox, so proceed
|
|
347
|
+
// with a notice instead of failing.
|
|
348
|
+
if (err instanceof IntegrationApiError && err.status === 503) {
|
|
349
|
+
process.stderr.write("Sandbox is paused — it will start on your first message.\n");
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
return fail(args.flags.outputFormat, `Could not reach ${config.baseUrl}: ${err instanceof Error ? err.message : String(err)}`, "connection_failed");
|
|
353
|
+
}
|
|
345
354
|
}
|
|
346
|
-
if (!status.enabled) {
|
|
355
|
+
if (status && !status.enabled) {
|
|
347
356
|
return fail(args.flags.outputFormat, `Integration "${status.label}" is disabled on the server.`, "integration_disabled");
|
|
348
357
|
}
|
|
349
358
|
const sessionIndex = await SessionIndex.load(sessionsPath());
|
package/dist/protocol/client.js
CHANGED
|
@@ -231,14 +231,26 @@ export class IntegrationClient {
|
|
|
231
231
|
let message = `HTTP ${res.status}`;
|
|
232
232
|
let code;
|
|
233
233
|
let details;
|
|
234
|
+
// Read the body once as text: myagent's error bodies are JSON, but the
|
|
235
|
+
// platform proxy answers with plain text (e.g. its 503 for a paused
|
|
236
|
+
// sandbox) — keep that text instead of collapsing it to "HTTP 503".
|
|
237
|
+
let text = "";
|
|
234
238
|
try {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
239
|
+
text = await res.text();
|
|
240
|
+
}
|
|
241
|
+
catch { /* unreadable body */ }
|
|
242
|
+
if (text) {
|
|
243
|
+
try {
|
|
244
|
+
const body = JSON.parse(text);
|
|
245
|
+
if (body.error?.message)
|
|
246
|
+
message = body.error.message;
|
|
247
|
+
code = body.error?.code;
|
|
248
|
+
details = body.error?.details;
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
message = text.trim() || message;
|
|
252
|
+
}
|
|
240
253
|
}
|
|
241
|
-
catch { /* non-JSON error body */ }
|
|
242
254
|
if (res.status === 404) {
|
|
243
255
|
message += " (check the integration id and that the integration is enabled)";
|
|
244
256
|
}
|