@ziggs-ai/api-client 0.40.4 → 0.40.6
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/CHANGELOG.md +8 -0
- package/dist/capabilities/agreementVerbs.d.ts +6 -0
- package/dist/capabilities/agreementVerbs.js +18 -0
- package/dist/capabilities/agreements.js +3 -1
- package/dist/capabilities/artifacts.d.ts +1 -12
- package/dist/capabilities/artifacts.js +2 -83
- package/dist/capabilities/buckets.d.ts +15 -0
- package/dist/capabilities/buckets.js +353 -0
- package/dist/capabilities/context.js +7 -4
- package/dist/capabilities/grants.js +1 -1
- package/dist/capabilities/index.d.ts +2 -1
- package/dist/capabilities/index.js +2 -1
- package/dist/capabilities/links.js +0 -1
- package/dist/capabilities/mcpBriefs.js +51 -4
- package/dist/capabilities/nextCall.js +0 -2
- package/dist/http/AgreementClient.d.ts +15 -0
- package/dist/http/AgreementClient.js +1 -1
- package/dist/http/BucketsClient.d.ts +219 -0
- package/dist/http/BucketsClient.js +109 -0
- package/dist/http/ContextGrantsClient.d.ts +0 -16
- package/dist/http/ContextGrantsClient.js +0 -27
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +1 -0
- package/dist/shared/operationError.d.ts +11 -1
- package/dist/shared/operationError.js +18 -20
- package/package.json +2 -2
|
@@ -64,34 +64,31 @@ function thrownFields(err) {
|
|
|
64
64
|
const message = typeof o.message === 'string' && o.message ? o.message : String(err);
|
|
65
65
|
return { message, status, code, choices: choicesIn(o.body) };
|
|
66
66
|
}
|
|
67
|
-
/**
|
|
68
|
-
function
|
|
67
|
+
/** A refusal body's fields, when the server sent a JSON object. */
|
|
68
|
+
function refusalBody(body) {
|
|
69
69
|
if (typeof body !== 'string' || !body)
|
|
70
70
|
return null;
|
|
71
71
|
try {
|
|
72
72
|
const parsed = JSON.parse(body);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return recovery;
|
|
73
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
74
|
+
? parsed
|
|
75
|
+
: null;
|
|
77
76
|
}
|
|
78
77
|
catch {
|
|
79
78
|
return null;
|
|
80
79
|
}
|
|
81
80
|
}
|
|
81
|
+
/** One object field of a refusal body (`recovery`, `impact`), when the server sent it. */
|
|
82
|
+
function objectIn(body, field) {
|
|
83
|
+
const value = refusalBody(body)?.[field];
|
|
84
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
85
|
+
? value
|
|
86
|
+
: null;
|
|
87
|
+
}
|
|
82
88
|
/** The `choices` list of a refusal body, when the server sent one. */
|
|
83
89
|
function choicesIn(body) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
const parsed = JSON.parse(body);
|
|
88
|
-
return Array.isArray(parsed?.choices)
|
|
89
|
-
? parsed.choices
|
|
90
|
-
: null;
|
|
91
|
-
}
|
|
92
|
-
catch {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
90
|
+
const choices = refusalBody(body)?.choices;
|
|
91
|
+
return Array.isArray(choices) ? choices : null;
|
|
95
92
|
}
|
|
96
93
|
/**
|
|
97
94
|
* Classify a thrown client error (or a plain string this layer raised) into a
|
|
@@ -101,9 +98,9 @@ export function describeOperationError(input, surface = 'sdk') {
|
|
|
101
98
|
input = unwrapApiError(input);
|
|
102
99
|
const shape = classify(input);
|
|
103
100
|
const { choices } = thrownFields(input);
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
const body = typeof input === 'object' && input !== null ? input.body : undefined;
|
|
102
|
+
const recovery = objectIn(body, 'recovery');
|
|
103
|
+
const impact = objectIn(body, 'impact');
|
|
107
104
|
let recoveryCursor;
|
|
108
105
|
if (shape.code === 'INBOX_OBSERVATION_LIMIT' && input && typeof input === 'object') {
|
|
109
106
|
try {
|
|
@@ -117,6 +114,7 @@ export function describeOperationError(input, surface = 'sdk') {
|
|
|
117
114
|
...shape,
|
|
118
115
|
...(recoveryCursor ? { recoveryCursor } : {}),
|
|
119
116
|
...(choices ? { choices } : {}),
|
|
117
|
+
...(impact ? { impact } : {}),
|
|
120
118
|
...(recovery ? { recovery: typeof recovery.tool === 'string'
|
|
121
119
|
? { ...presentResourceCall(recovery, surface) }
|
|
122
120
|
: recovery } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ziggs-ai/api-client",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.6",
|
|
4
4
|
"description": "HTTP and WebSocket client for the Ziggs backend API",
|
|
5
5
|
"homepage": "https://ziggsai.com/docs",
|
|
6
6
|
"bugs": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test:watch": "node --import tsx/esm --test --watch test/*.test.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@ziggs-ai/contracts": "0.
|
|
34
|
+
"@ziggs-ai/contracts": "0.48.0",
|
|
35
35
|
"socket.io-client": "^4.7.0"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|