haansi 0.1.30 → 0.1.31
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/haansi.js +50 -13
- package/package.json +1 -1
package/dist/haansi.js
CHANGED
|
@@ -95,7 +95,7 @@ var require_package = __commonJS({
|
|
|
95
95
|
"package.json"(exports2, module2) {
|
|
96
96
|
module2.exports = {
|
|
97
97
|
name: "haansi",
|
|
98
|
-
version: "0.1.
|
|
98
|
+
version: "0.1.31",
|
|
99
99
|
description: "Haansi CLI - Session collector and MCP server for Claude Code & OpenAI Codex",
|
|
100
100
|
bin: {
|
|
101
101
|
haansi: "./dist/haansi.js"
|
|
@@ -1666,6 +1666,15 @@ var init_health = __esm({
|
|
|
1666
1666
|
}
|
|
1667
1667
|
});
|
|
1668
1668
|
|
|
1669
|
+
// ../../packages/@company/observability/src/degradation.ts
|
|
1670
|
+
var init_degradation = __esm({
|
|
1671
|
+
"../../packages/@company/observability/src/degradation.ts"() {
|
|
1672
|
+
"use strict";
|
|
1673
|
+
init_types();
|
|
1674
|
+
init_observability_service();
|
|
1675
|
+
}
|
|
1676
|
+
});
|
|
1677
|
+
|
|
1669
1678
|
// ../../packages/@company/observability/src/index.ts
|
|
1670
1679
|
var defaultObservability, getDefaultObservability, observability;
|
|
1671
1680
|
var init_src2 = __esm({
|
|
@@ -1676,6 +1685,8 @@ var init_src2 = __esm({
|
|
|
1676
1685
|
init_metrics();
|
|
1677
1686
|
init_middleware();
|
|
1678
1687
|
init_health();
|
|
1688
|
+
init_degradation();
|
|
1689
|
+
init_types();
|
|
1679
1690
|
defaultObservability = null;
|
|
1680
1691
|
getDefaultObservability = () => {
|
|
1681
1692
|
if (!defaultObservability) {
|
|
@@ -1959,7 +1970,8 @@ var init_agents = __esm({
|
|
|
1959
1970
|
// ../service-capture/claude-sessions/collector.ts
|
|
1960
1971
|
var collector_exports = {};
|
|
1961
1972
|
__export(collector_exports, {
|
|
1962
|
-
collect: () => collect
|
|
1973
|
+
collect: () => collect,
|
|
1974
|
+
uploadSession: () => uploadSession
|
|
1963
1975
|
});
|
|
1964
1976
|
function edgeScrub(content) {
|
|
1965
1977
|
let result = content;
|
|
@@ -2139,16 +2151,27 @@ async function uploadSession(sessionId, content, apiUrl2, token, agentSource, gi
|
|
|
2139
2151
|
if (gitInfo?.gitRemoteUrl) headers["x-git-remote-url"] = gitInfo.gitRemoteUrl;
|
|
2140
2152
|
if (gitInfo?.gitCommit) headers["x-git-commit"] = gitInfo.gitCommit;
|
|
2141
2153
|
if (gitInfo?.gitBranch) headers["x-git-branch"] = gitInfo.gitBranch;
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2154
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
2155
|
+
const response = await fetch(`${apiUrl2}/api/v1/capture/sessions/raw`, {
|
|
2156
|
+
method: "POST",
|
|
2157
|
+
headers,
|
|
2158
|
+
body: new Uint8Array(body)
|
|
2159
|
+
});
|
|
2160
|
+
if (response.ok) return;
|
|
2161
|
+
if (response.status === 429 && attempt < UPLOAD_RATE_LIMIT_RETRIES) {
|
|
2162
|
+
const retryAfter = Number(response.headers.get("Retry-After"));
|
|
2163
|
+
const waitMs = Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1e3 : DEFAULT_RATE_LIMIT_WAIT_MS;
|
|
2164
|
+
await new Promise((resolve4) => setTimeout(resolve4, waitMs));
|
|
2165
|
+
continue;
|
|
2166
|
+
}
|
|
2148
2167
|
const text = await response.text().catch(() => "");
|
|
2149
|
-
|
|
2168
|
+
const err = new Error(
|
|
2150
2169
|
`Upload failed (${response.status}): ${text.slice(0, 200)}`
|
|
2151
2170
|
);
|
|
2171
|
+
if (response.status === 429) {
|
|
2172
|
+
err.rateLimited = true;
|
|
2173
|
+
}
|
|
2174
|
+
throw err;
|
|
2152
2175
|
}
|
|
2153
2176
|
}
|
|
2154
2177
|
async function collect(options) {
|
|
@@ -2170,6 +2193,7 @@ async function collect(options) {
|
|
|
2170
2193
|
let uploaded = 0;
|
|
2171
2194
|
let skipped = 0;
|
|
2172
2195
|
let errors = 0;
|
|
2196
|
+
let deferred = 0;
|
|
2173
2197
|
const remoteMap = options.forceAll ? /* @__PURE__ */ new Map() : await getUploadedSessions(apiUrl2, token);
|
|
2174
2198
|
const toUpload = [];
|
|
2175
2199
|
for (const session of localSessions) {
|
|
@@ -2246,11 +2270,22 @@ async function collect(options) {
|
|
|
2246
2270
|
}
|
|
2247
2271
|
);
|
|
2248
2272
|
} catch (err) {
|
|
2249
|
-
|
|
2250
|
-
|
|
2273
|
+
if (err?.rateLimited) {
|
|
2274
|
+
deferred++;
|
|
2275
|
+
void logger.info(`Rate limited, will retry next run: ${shortId}`);
|
|
2276
|
+
} else {
|
|
2277
|
+
errors++;
|
|
2278
|
+
logger.error(`Failed to upload ${shortId}`, { err: err.message });
|
|
2279
|
+
}
|
|
2251
2280
|
}
|
|
2252
2281
|
}
|
|
2253
|
-
|
|
2282
|
+
if (deferred > 0) {
|
|
2283
|
+
void logger.info(
|
|
2284
|
+
`${deferred} session(s) deferred by the upload rate limit \u2014 they remain queued`,
|
|
2285
|
+
{ deferred, uploaded }
|
|
2286
|
+
);
|
|
2287
|
+
}
|
|
2288
|
+
return { uploaded, skipped, errors, deferred };
|
|
2254
2289
|
}
|
|
2255
2290
|
async function main() {
|
|
2256
2291
|
const forceAll = process.argv.includes("--force-all");
|
|
@@ -2269,7 +2304,7 @@ async function main() {
|
|
|
2269
2304
|
});
|
|
2270
2305
|
if (errors > 0) process.exit(1);
|
|
2271
2306
|
}
|
|
2272
|
-
var import_dotenv, import_path3, import_fs3, import_os3, import_zlib, import_child_process, logger, DEFAULT_API_URL2, CREDENTIALS_FILE4, MIN_LINES, EDGE_SCRUB_PATTERNS, GIT_BIN_CANDIDATES, resolvedGitBin;
|
|
2307
|
+
var import_dotenv, import_path3, import_fs3, import_os3, import_zlib, import_child_process, logger, DEFAULT_API_URL2, CREDENTIALS_FILE4, MIN_LINES, EDGE_SCRUB_PATTERNS, GIT_BIN_CANDIDATES, resolvedGitBin, UPLOAD_RATE_LIMIT_RETRIES, DEFAULT_RATE_LIMIT_WAIT_MS;
|
|
2273
2308
|
var init_collector = __esm({
|
|
2274
2309
|
"../service-capture/claude-sessions/collector.ts"() {
|
|
2275
2310
|
"use strict";
|
|
@@ -2332,6 +2367,8 @@ var init_collector = __esm({
|
|
|
2332
2367
|
"/usr/local/bin/git",
|
|
2333
2368
|
"/usr/bin/git"
|
|
2334
2369
|
];
|
|
2370
|
+
UPLOAD_RATE_LIMIT_RETRIES = 2;
|
|
2371
|
+
DEFAULT_RATE_LIMIT_WAIT_MS = 6e4;
|
|
2335
2372
|
if (require.main === module) {
|
|
2336
2373
|
main().catch((err) => {
|
|
2337
2374
|
logger.error("Collector failed", err);
|