@ziggs-ai/api-client 0.1.21 → 0.1.22
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/http/AgreementClient.js +16 -10
- package/package.json +1 -1
|
@@ -289,25 +289,31 @@ export async function getAgreement(agreementId, creds) {
|
|
|
289
289
|
if (!agreementId)
|
|
290
290
|
return null;
|
|
291
291
|
assertCreds(creds, 'get agreement');
|
|
292
|
+
// ZIG-698 — a genuine 404 (and 200-with-no-agreement) is a real "not found"
|
|
293
|
+
// and returns null. Every other failure (403/5xx/network) must throw so the
|
|
294
|
+
// caller can tell "does not exist" from "could not fetch" instead of a 403
|
|
295
|
+
// masquerading as not-found. The MCP tool classifies the thrown status via
|
|
296
|
+
// toolError; the message keeps the status whitespace-delimited for that.
|
|
297
|
+
let res;
|
|
292
298
|
try {
|
|
293
|
-
|
|
299
|
+
res = await fetch(`${getAgreementBaseUrl()}/${agreementId}`, {
|
|
294
300
|
method: 'GET',
|
|
295
301
|
headers: buildHeaders(creds),
|
|
296
302
|
});
|
|
297
|
-
if (res.status === 404)
|
|
298
|
-
return null;
|
|
299
|
-
if (!res.ok) {
|
|
300
|
-
const body = await res.text().catch(() => '');
|
|
301
|
-
runtimeLog.warn('AgreementClient', `⚠️ Get agreement failed: ${res.status} ${res.statusText} ${body?.slice(0, 200)}`);
|
|
302
|
-
return null;
|
|
303
|
-
}
|
|
304
|
-
const data = await res.json().catch(() => null);
|
|
305
|
-
return data?.['agreement'] ?? null;
|
|
306
303
|
}
|
|
307
304
|
catch (e) {
|
|
308
305
|
runtimeLog.warn('AgreementClient', `⚠️ Get agreement failed: ${e.message}`);
|
|
306
|
+
throw new Error(`GET /agreements/${agreementId} network error: ${e.message}`);
|
|
307
|
+
}
|
|
308
|
+
if (res.status === 404)
|
|
309
309
|
return null;
|
|
310
|
+
if (!res.ok) {
|
|
311
|
+
const body = await res.text().catch(() => '');
|
|
312
|
+
runtimeLog.warn('AgreementClient', `⚠️ Get agreement failed: ${res.status} ${res.statusText} ${body?.slice(0, 200)}`);
|
|
313
|
+
throw new Error(`GET /agreements/${agreementId} ${res.status} ${body?.slice(0, 200)}`);
|
|
310
314
|
}
|
|
315
|
+
const data = await res.json().catch(() => null);
|
|
316
|
+
return data?.['agreement'] ?? null;
|
|
311
317
|
}
|
|
312
318
|
export async function createAgreement(body, creds) {
|
|
313
319
|
if (!body)
|