@kosuke-ai/kosuke 1.0.99 → 1.0.100
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 +4 -0
- package/dist/integrations/api.js +17 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.100
|
|
4
|
+
|
|
5
|
+
- When an integration tool call is rate limited, `kosuke integrations tools call` now says how many seconds to wait before trying again.
|
|
6
|
+
|
|
3
7
|
## 1.0.99
|
|
4
8
|
|
|
5
9
|
- `integrations request` and `integrations list --toolkit` take a toolkit slug in any case, such as `SLACK`.
|
package/dist/integrations/api.js
CHANGED
|
@@ -85,6 +85,22 @@ function sentenceOf(error, status) {
|
|
|
85
85
|
const said = isRow(error) ? oneLine(error.error, 300) : '';
|
|
86
86
|
return said || `HTTP ${status}`;
|
|
87
87
|
}
|
|
88
|
+
/** Seconds the platform asked to wait on a 429, bounded to the minute its budgets run on. */
|
|
89
|
+
function retryAfterOf(error) {
|
|
90
|
+
const value = isRow(error) ? error.retryAfterSeconds : undefined;
|
|
91
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < 1)
|
|
92
|
+
return null;
|
|
93
|
+
return Math.min(60, Math.ceil(value));
|
|
94
|
+
}
|
|
95
|
+
/** A 429's sentence: the platform's own, else ours, always ending in how long to wait. */
|
|
96
|
+
function tooManyMessage(error) {
|
|
97
|
+
const seconds = retryAfterOf(error);
|
|
98
|
+
if (seconds === null)
|
|
99
|
+
return 'Too many requests. Try again shortly.';
|
|
100
|
+
const said = isRow(error) ? oneLine(error.error, 300).replace(/\s*Try again\b.*$/, '') : '';
|
|
101
|
+
const wait = `Wait ${seconds} second${seconds === 1 ? '' : 's'} before trying again.`;
|
|
102
|
+
return said ? `${said} ${wait}` : `Too many requests. ${wait}`;
|
|
103
|
+
}
|
|
88
104
|
/**
|
|
89
105
|
* Why a request failed, in words the reader can act on. The 4xx sentences are
|
|
90
106
|
* the platform's own (a Connector Token, a workspace the key is not a member of,
|
|
@@ -103,7 +119,7 @@ export function failureOf(status, error, method) {
|
|
|
103
119
|
};
|
|
104
120
|
}
|
|
105
121
|
if (status === 429) {
|
|
106
|
-
return { ok: false, status, message:
|
|
122
|
+
return { ok: false, status, message: tooManyMessage(error) };
|
|
107
123
|
}
|
|
108
124
|
if (status >= 400 && status < 500) {
|
|
109
125
|
return { ok: false, status, message: sentenceOf(error, status) };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kosuke-ai/kosuke",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.100",
|
|
4
4
|
"description": "Sensei platform CLI. The client customers install to drive app.kosuke.ai from their own machine.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"minimatch": "^11.0.1"
|
|
44
44
|
},
|
|
45
45
|
"kosukeRelease": {
|
|
46
|
-
"sourceCommit": "
|
|
47
|
-
"sourceIdentity": "
|
|
46
|
+
"sourceCommit": "3c780f8681d98f9a28af2ba6d9ab02461fd53228",
|
|
47
|
+
"sourceIdentity": "bf0207239e671e75c5d6a2a0270a0f4dfbf78a7deb24348c850133c6a10d3d69",
|
|
48
48
|
"fragments": [
|
|
49
|
-
"integration-
|
|
49
|
+
"integration-rate-limit-wait-r7k2qd.json"
|
|
50
50
|
]
|
|
51
51
|
}
|
|
52
52
|
}
|