diff --git a/claude-code/bundle/capture.js b/claude-code/bundle/capture.js index 7251cf96..8b550a9d 100755 --- a/claude-code/bundle/capture.js +++ b/claude-code/bundle/capture.js @@ -76,6 +76,15 @@ function sqlStr(value) { return value.replace(/\\/g, "\\\\").replace(/'/g, "''").replace(/\0/g, "").replace(/[\x01-\x08\x0b\x0c\x0e-\x1f\x7f]/g, ""); } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/deeplake-api.js var log2 = (msg) => log("sdk", msg); function summarizeSql(sql, maxLen = 220) { @@ -187,7 +196,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -339,7 +349,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/claude-code/bundle/commands/auth-login.js b/claude-code/bundle/commands/auth-login.js index aa19693f..8caea41f 100755 --- a/claude-code/bundle/commands/auth-login.js +++ b/claude-code/bundle/commands/auth-login.js @@ -5,6 +5,17 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from " import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process"; + +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + +// dist/src/commands/auth.js var CONFIG_DIR = join(homedir(), ".deeplake"); var CREDS_PATH = join(CONFIG_DIR, "credentials.json"); var DEFAULT_API_URL = "https://api.deeplake.ai"; @@ -32,7 +43,8 @@ function deleteCredentials() { async function apiGet(path, token, apiUrl, orgId) { const headers = { Authorization: `Bearer ${token}`, - "Content-Type": "application/json" + "Content-Type": "application/json", + ...deeplakeClientHeader() }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; @@ -44,7 +56,8 @@ async function apiGet(path, token, apiUrl, orgId) { async function apiPost(path, body, token, apiUrl, orgId) { const headers = { Authorization: `Bearer ${token}`, - "Content-Type": "application/json" + "Content-Type": "application/json", + ...deeplakeClientHeader() }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; @@ -56,7 +69,8 @@ async function apiPost(path, body, token, apiUrl, orgId) { async function apiDelete(path, token, apiUrl, orgId) { const headers = { Authorization: `Bearer ${token}`, - "Content-Type": "application/json" + "Content-Type": "application/json", + ...deeplakeClientHeader() }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; @@ -67,7 +81,7 @@ async function apiDelete(path, token, apiUrl, orgId) { async function requestDeviceCode(apiUrl = DEFAULT_API_URL) { const resp = await fetch(`${apiUrl}/auth/device/code`, { method: "POST", - headers: { "Content-Type": "application/json" } + headers: { "Content-Type": "application/json", ...deeplakeClientHeader() } }); if (!resp.ok) throw new Error(`Device flow unavailable: HTTP ${resp.status}`); @@ -76,7 +90,7 @@ async function requestDeviceCode(apiUrl = DEFAULT_API_URL) { async function pollForToken(deviceCode, apiUrl = DEFAULT_API_URL) { const resp = await fetch(`${apiUrl}/auth/device/token`, { method: "POST", - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json", ...deeplakeClientHeader() }, body: JSON.stringify({ device_code: deviceCode }) }); if (resp.ok) @@ -368,7 +382,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -520,7 +535,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/claude-code/bundle/pre-tool-use.js b/claude-code/bundle/pre-tool-use.js index 94a5d724..9c281166 100755 --- a/claude-code/bundle/pre-tool-use.js +++ b/claude-code/bundle/pre-tool-use.js @@ -82,6 +82,15 @@ function sqlLike(value) { return sqlStr(value).replace(/%/g, "\\%").replace(/_/g, "\\_"); } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/deeplake-api.js var log2 = (msg) => log("sdk", msg); function summarizeSql(sql, maxLen = 220) { @@ -193,7 +202,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -345,7 +355,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/claude-code/bundle/session-start-setup.js b/claude-code/bundle/session-start-setup.js index 5eff08e8..9f2430e8 100755 --- a/claude-code/bundle/session-start-setup.js +++ b/claude-code/bundle/session-start-setup.js @@ -11,6 +11,17 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from " import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process"; + +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + +// dist/src/commands/auth.js var CONFIG_DIR = join(homedir(), ".deeplake"); var CREDS_PATH = join(CONFIG_DIR, "credentials.json"); function loadCredentials() { @@ -198,7 +209,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -350,7 +362,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/claude-code/bundle/session-start.js b/claude-code/bundle/session-start.js index 909bf88e..199bbf30 100755 --- a/claude-code/bundle/session-start.js +++ b/claude-code/bundle/session-start.js @@ -11,6 +11,17 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from " import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process"; + +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + +// dist/src/commands/auth.js var CONFIG_DIR = join(homedir(), ".deeplake"); var CREDS_PATH = join(CONFIG_DIR, "credentials.json"); function loadCredentials() { @@ -198,7 +209,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -350,7 +362,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/claude-code/bundle/shell/deeplake-shell.js b/claude-code/bundle/shell/deeplake-shell.js index 7e140a93..df3dbefa 100755 --- a/claude-code/bundle/shell/deeplake-shell.js +++ b/claude-code/bundle/shell/deeplake-shell.js @@ -66779,6 +66779,15 @@ function sqlLike(value) { return sqlStr(value).replace(/%/g, "\\%").replace(/_/g, "\\_"); } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/deeplake-api.js var log2 = (msg) => log("sdk", msg); function summarizeSql(sql, maxLen = 220) { @@ -66890,7 +66899,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -67042,7 +67052,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/claude-code/bundle/wiki-worker.js b/claude-code/bundle/wiki-worker.js index b2f974fc..f28a15ec 100755 --- a/claude-code/bundle/wiki-worker.js +++ b/claude-code/bundle/wiki-worker.js @@ -21,6 +21,15 @@ function log(tag, msg) { `); } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/hooks/summary-state.js import { readFileSync, writeFileSync, writeSync, mkdirSync, renameSync, existsSync, unlinkSync, openSync, closeSync } from "node:fs"; import { homedir as homedir2 } from "node:os"; @@ -154,7 +163,8 @@ async function query(sql, retries = 4) { headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": cfg.orgId + "X-Activeloop-Org-Id": cfg.orgId, + ...deeplakeClientHeader() }, body: JSON.stringify({ query: sql }) }); diff --git a/codex/bundle/capture.js b/codex/bundle/capture.js index 78bb3c9e..a1844518 100755 --- a/codex/bundle/capture.js +++ b/codex/bundle/capture.js @@ -76,6 +76,15 @@ function sqlStr(value) { return value.replace(/\\/g, "\\\\").replace(/'/g, "''").replace(/\0/g, "").replace(/[\x01-\x08\x0b\x0c\x0e-\x1f\x7f]/g, ""); } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/deeplake-api.js var log2 = (msg) => log("sdk", msg); function summarizeSql(sql, maxLen = 220) { @@ -187,7 +196,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -339,7 +349,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/codex/bundle/commands/auth-login.js b/codex/bundle/commands/auth-login.js index aa19693f..8caea41f 100755 --- a/codex/bundle/commands/auth-login.js +++ b/codex/bundle/commands/auth-login.js @@ -5,6 +5,17 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from " import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process"; + +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + +// dist/src/commands/auth.js var CONFIG_DIR = join(homedir(), ".deeplake"); var CREDS_PATH = join(CONFIG_DIR, "credentials.json"); var DEFAULT_API_URL = "https://api.deeplake.ai"; @@ -32,7 +43,8 @@ function deleteCredentials() { async function apiGet(path, token, apiUrl, orgId) { const headers = { Authorization: `Bearer ${token}`, - "Content-Type": "application/json" + "Content-Type": "application/json", + ...deeplakeClientHeader() }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; @@ -44,7 +56,8 @@ async function apiGet(path, token, apiUrl, orgId) { async function apiPost(path, body, token, apiUrl, orgId) { const headers = { Authorization: `Bearer ${token}`, - "Content-Type": "application/json" + "Content-Type": "application/json", + ...deeplakeClientHeader() }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; @@ -56,7 +69,8 @@ async function apiPost(path, body, token, apiUrl, orgId) { async function apiDelete(path, token, apiUrl, orgId) { const headers = { Authorization: `Bearer ${token}`, - "Content-Type": "application/json" + "Content-Type": "application/json", + ...deeplakeClientHeader() }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; @@ -67,7 +81,7 @@ async function apiDelete(path, token, apiUrl, orgId) { async function requestDeviceCode(apiUrl = DEFAULT_API_URL) { const resp = await fetch(`${apiUrl}/auth/device/code`, { method: "POST", - headers: { "Content-Type": "application/json" } + headers: { "Content-Type": "application/json", ...deeplakeClientHeader() } }); if (!resp.ok) throw new Error(`Device flow unavailable: HTTP ${resp.status}`); @@ -76,7 +90,7 @@ async function requestDeviceCode(apiUrl = DEFAULT_API_URL) { async function pollForToken(deviceCode, apiUrl = DEFAULT_API_URL) { const resp = await fetch(`${apiUrl}/auth/device/token`, { method: "POST", - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json", ...deeplakeClientHeader() }, body: JSON.stringify({ device_code: deviceCode }) }); if (resp.ok) @@ -368,7 +382,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -520,7 +535,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/codex/bundle/pre-tool-use.js b/codex/bundle/pre-tool-use.js index c7aeda76..beb5eac1 100755 --- a/codex/bundle/pre-tool-use.js +++ b/codex/bundle/pre-tool-use.js @@ -82,6 +82,15 @@ function sqlLike(value) { return sqlStr(value).replace(/%/g, "\\%").replace(/_/g, "\\_"); } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/deeplake-api.js var log2 = (msg) => log("sdk", msg); function summarizeSql(sql, maxLen = 220) { @@ -193,7 +202,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -345,7 +355,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/codex/bundle/session-start-setup.js b/codex/bundle/session-start-setup.js index 166c22b7..6a40ec13 100755 --- a/codex/bundle/session-start-setup.js +++ b/codex/bundle/session-start-setup.js @@ -11,6 +11,17 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from " import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process"; + +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + +// dist/src/commands/auth.js var CONFIG_DIR = join(homedir(), ".deeplake"); var CREDS_PATH = join(CONFIG_DIR, "credentials.json"); function loadCredentials() { @@ -198,7 +209,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -350,7 +362,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/codex/bundle/shell/deeplake-shell.js b/codex/bundle/shell/deeplake-shell.js index 7e140a93..df3dbefa 100755 --- a/codex/bundle/shell/deeplake-shell.js +++ b/codex/bundle/shell/deeplake-shell.js @@ -66779,6 +66779,15 @@ function sqlLike(value) { return sqlStr(value).replace(/%/g, "\\%").replace(/_/g, "\\_"); } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/deeplake-api.js var log2 = (msg) => log("sdk", msg); function summarizeSql(sql, maxLen = 220) { @@ -66890,7 +66899,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -67042,7 +67052,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/codex/bundle/stop.js b/codex/bundle/stop.js index eff0b090..e6c9ef68 100755 --- a/codex/bundle/stop.js +++ b/codex/bundle/stop.js @@ -79,6 +79,15 @@ function sqlStr(value) { return value.replace(/\\/g, "\\\\").replace(/'/g, "''").replace(/\0/g, "").replace(/[\x01-\x08\x0b\x0c\x0e-\x1f\x7f]/g, ""); } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/deeplake-api.js var log2 = (msg) => log("sdk", msg); function summarizeSql(sql, maxLen = 220) { @@ -190,7 +199,8 @@ var DeeplakeApi = class { headers: { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() }, signal, body: JSON.stringify({ query: sql }) @@ -342,7 +352,8 @@ var DeeplakeApi = class { const resp = await fetch(`${this.apiUrl}/workspaces/${this.workspaceId}/tables`, { headers: { Authorization: `Bearer ${this.token}`, - "X-Activeloop-Org-Id": this.orgId + "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader() } }); if (resp.ok) { diff --git a/codex/bundle/wiki-worker.js b/codex/bundle/wiki-worker.js index bf134ede..3eca1881 100755 --- a/codex/bundle/wiki-worker.js +++ b/codex/bundle/wiki-worker.js @@ -129,6 +129,15 @@ async function uploadSummary(query2, params) { return { path: "insert", sql, descLength: desc.length, summaryLength: text.length }; } +// dist/src/utils/client-header.js +var DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; +function deeplakeClientValue() { + return `hivemind/${"0.6.48"}`; +} +function deeplakeClientHeader() { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} + // dist/src/hooks/codex/wiki-worker.js var dlog2 = (msg) => log("codex-wiki-worker", msg); var cfg = JSON.parse(readFileSync2(process.argv[2], "utf-8")); @@ -153,7 +162,8 @@ async function query(sql, retries = 4) { headers: { Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", - "X-Activeloop-Org-Id": cfg.orgId + "X-Activeloop-Org-Id": cfg.orgId, + ...deeplakeClientHeader() }, body: JSON.stringify({ query: sql }) }); diff --git a/esbuild.config.mjs b/esbuild.config.mjs index eb2e623e..ebd0ae92 100644 --- a/esbuild.config.mjs +++ b/esbuild.config.mjs @@ -2,6 +2,7 @@ import { build } from "esbuild"; import { chmodSync, writeFileSync, readFileSync } from "node:fs"; const esmPackageJson = '{"type":"module"}\n'; +const hivemindVersion = JSON.parse(readFileSync("package.json", "utf-8")).version; const openclawVersion = JSON.parse(readFileSync("openclaw/package.json", "utf-8")).version; const openclawSkillBody = readFileSync("openclaw/skills/SKILL.md", "utf-8"); @@ -33,6 +34,9 @@ await build({ format: "esm", outdir: "claude-code/bundle", external: ["node:*", "node-liblzma", "@mongodb-js/zstd"], + define: { + __HIVEMIND_VERSION__: JSON.stringify(hivemindVersion), + }, }); for (const h of ccAll) { @@ -67,6 +71,9 @@ await build({ format: "esm", outdir: "codex/bundle", external: ["node:*", "node-liblzma", "@mongodb-js/zstd"], + define: { + __HIVEMIND_VERSION__: JSON.stringify(hivemindVersion), + }, }); for (const h of codexAll) { diff --git a/openclaw/src/index.ts b/openclaw/src/index.ts index 0b8287f5..264478d7 100644 --- a/openclaw/src/index.ts +++ b/openclaw/src/index.ts @@ -14,6 +14,7 @@ import { loadConfig } from "../../src/config.js"; import { loadCredentials, saveCredentials, requestDeviceCode, pollForToken, listOrgs, switchOrg, listWorkspaces, switchWorkspace } from "../../src/commands/auth.js"; import { DeeplakeApi } from "../../src/deeplake-api.js"; import { sqlStr } from "../../src/utils/sql.js"; +import { deeplakeClientHeader } from "../../src/utils/client-header.js"; // Memory-access primitives reused directly from the CC/Codex hooks so the // openclaw agent gets the same search + read semantics (multi-word across // memory ∪ sessions, path filters, JSONB normalization, virtual /index.md). @@ -200,6 +201,7 @@ async function requestAuth(): Promise { Authorization: `Bearer ${token}`, "Content-Type": "application/json", "X-Activeloop-Org-Id": orgId, + ...deeplakeClientHeader(), }, body: JSON.stringify({ name: `hivemind-${new Date().toISOString().split("T")[0]}`, duration: 365 * 24 * 60 * 60, organization_id: orgId }), }); diff --git a/src/commands/auth.ts b/src/commands/auth.ts index 1519f582..67e859f9 100644 --- a/src/commands/auth.ts +++ b/src/commands/auth.ts @@ -7,6 +7,7 @@ import { readFileSync, writeFileSync, existsSync, mkdirSync, unlinkSync } from " import { join } from "node:path"; import { homedir } from "node:os"; import { execSync } from "node:child_process"; +import { deeplakeClientHeader } from "../utils/client-header.js"; const CONFIG_DIR = join(homedir(), ".deeplake"); const CREDS_PATH = join(CONFIG_DIR, "credentials.json"); @@ -88,6 +89,7 @@ async function apiGet(path: string, token: string, apiUrl: string, orgId?: strin const headers: Record = { Authorization: `Bearer ${token}`, "Content-Type": "application/json", + ...deeplakeClientHeader(), }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; const resp = await fetch(`${apiUrl}${path}`, { headers }); @@ -99,6 +101,7 @@ async function apiPost(path: string, body: unknown, token: string, apiUrl: strin const headers: Record = { Authorization: `Bearer ${token}`, "Content-Type": "application/json", + ...deeplakeClientHeader(), }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; const resp = await fetch(`${apiUrl}${path}`, { method: "POST", headers, body: JSON.stringify(body) }); @@ -110,6 +113,7 @@ async function apiDelete(path: string, token: string, apiUrl: string, orgId?: st const headers: Record = { Authorization: `Bearer ${token}`, "Content-Type": "application/json", + ...deeplakeClientHeader(), }; if (orgId) headers["X-Activeloop-Org-Id"] = orgId; const resp = await fetch(`${apiUrl}${path}`, { method: "DELETE", headers }); @@ -121,7 +125,7 @@ async function apiDelete(path: string, token: string, apiUrl: string, orgId?: st export async function requestDeviceCode(apiUrl = DEFAULT_API_URL): Promise { const resp = await fetch(`${apiUrl}/auth/device/code`, { method: "POST", - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json", ...deeplakeClientHeader() }, }); if (!resp.ok) throw new Error(`Device flow unavailable: HTTP ${resp.status}`); return resp.json() as Promise; @@ -130,7 +134,7 @@ export async function requestDeviceCode(apiUrl = DEFAULT_API_URL): Promise { const resp = await fetch(`${apiUrl}/auth/device/token`, { method: "POST", - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json", ...deeplakeClientHeader() }, body: JSON.stringify({ device_code: deviceCode }), }); if (resp.ok) return resp.json() as Promise; diff --git a/src/deeplake-api.ts b/src/deeplake-api.ts index 5e763b2a..0bf9895a 100644 --- a/src/deeplake-api.ts +++ b/src/deeplake-api.ts @@ -4,6 +4,7 @@ import { join } from "node:path"; import { tmpdir } from "node:os"; import { log as _log } from "./utils/debug.js"; import { sqlStr } from "./utils/sql.js"; +import { deeplakeClientHeader } from "./utils/client-header.js"; const log = (msg: string) => _log("sdk", msg); @@ -146,6 +147,7 @@ export class DeeplakeApi { Authorization: `Bearer ${this.token}`, "Content-Type": "application/json", "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader(), }, signal, body: JSON.stringify({ query: sql }), @@ -319,6 +321,7 @@ export class DeeplakeApi { headers: { Authorization: `Bearer ${this.token}`, "X-Activeloop-Org-Id": this.orgId, + ...deeplakeClientHeader(), }, }); if (resp.ok) { diff --git a/src/hooks/codex/wiki-worker.ts b/src/hooks/codex/wiki-worker.ts index 7d74f759..73cc86e0 100644 --- a/src/hooks/codex/wiki-worker.ts +++ b/src/hooks/codex/wiki-worker.ts @@ -13,6 +13,7 @@ import { join } from "node:path"; import { finalizeSummary, releaseLock } from "../summary-state.js"; import { uploadSummary } from "../upload-summary.js"; import { log as _log } from "../../utils/debug.js"; +import { deeplakeClientHeader } from "../../utils/client-header.js"; const dlog = (msg: string) => _log("codex-wiki-worker", msg); @@ -60,6 +61,7 @@ async function query(sql: string, retries = 4): Promise[ Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", "X-Activeloop-Org-Id": cfg.orgId, + ...deeplakeClientHeader(), }, body: JSON.stringify({ query: sql }), }); diff --git a/src/hooks/wiki-worker.ts b/src/hooks/wiki-worker.ts index 2359ea02..34025403 100644 --- a/src/hooks/wiki-worker.ts +++ b/src/hooks/wiki-worker.ts @@ -11,6 +11,7 @@ import { readFileSync, writeFileSync, existsSync, appendFileSync, mkdirSync, rmS import { execFileSync } from "node:child_process"; import { join } from "node:path"; import { utcTimestamp, log as _log } from "../utils/debug.js"; +import { deeplakeClientHeader } from "../utils/client-header.js"; const dlog = (msg: string) => _log("wiki-worker", msg); import { finalizeSummary, releaseLock } from "./summary-state.js"; @@ -61,6 +62,7 @@ async function query(sql: string, retries = 4): Promise[ Authorization: `Bearer ${cfg.token}`, "Content-Type": "application/json", "X-Activeloop-Org-Id": cfg.orgId, + ...deeplakeClientHeader(), }, body: JSON.stringify({ query: sql }), }); diff --git a/src/utils/client-header.ts b/src/utils/client-header.ts new file mode 100644 index 00000000..60d76f68 --- /dev/null +++ b/src/utils/client-header.ts @@ -0,0 +1,26 @@ +/** + * X-Deeplake-Client header helper. + * + * The deeplake-api backend reads X-Deeplake-Client to attribute traffic + * (analytics source + engagement metrics). Every outbound request to + * deeplake-api should carry this header; without it, hivemind traffic + * looks indistinguishable from the activeloop-cli / device-code flow. + * + * __HIVEMIND_VERSION__ is replaced at build/test time: + * - production bundles: esbuild.config.mjs sets it to the real package.json version + * - vitest: vitest.config.ts sets it to "dev" + * Source code therefore reads it directly, no runtime guard needed. + */ +declare const __HIVEMIND_VERSION__: string; + +export const DEEPLAKE_CLIENT_HEADER = "X-Deeplake-Client"; + +/** Returns "hivemind/" — the value for the X-Deeplake-Client header. */ +export function deeplakeClientValue(): string { + return `hivemind/${__HIVEMIND_VERSION__}`; +} + +/** Returns { "X-Deeplake-Client": "hivemind/" } for spreading into a headers object. */ +export function deeplakeClientHeader(): Record { + return { [DEEPLAKE_CLIENT_HEADER]: deeplakeClientValue() }; +} diff --git a/vitest.config.ts b/vitest.config.ts index 882e6e09..c11efce7 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -10,6 +10,13 @@ import { defineConfig } from "vitest/config"; // that hides regressions in new code. export default defineConfig({ + // Match esbuild's `define` for __HIVEMIND_VERSION__ so source files that + // read it directly (e.g. src/utils/client-header.ts) don't need a typeof + // guard for tests. Bundled builds substitute the real version; tests get + // the "dev" sentinel. + define: { + __HIVEMIND_VERSION__: JSON.stringify("dev"), + }, test: { include: [ "claude-code/tests/**/*.test.ts",