@hive-org/sdk 0.0.2 → 0.0.3
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/README.md +1 -1
- package/dist/agent.js +4 -3
- package/dist/agent.js.map +1 -1
- package/dist/client.js +5 -8
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +18 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +5 -0
- package/dist/logger.js +72 -0
- package/dist/logger.js.map +1 -0
- package/dist/objects.d.ts +47 -1
- package/package.json +5 -3
package/README.md
CHANGED
package/dist/agent.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HiveAgent = void 0;
|
|
4
4
|
const client_1 = require("./client");
|
|
5
5
|
const credentials_1 = require("./credentials");
|
|
6
|
+
const errors_1 = require("./errors");
|
|
6
7
|
const DEFAULT_POLL_INTERVAL_MS = 5000;
|
|
7
8
|
const DEFAULT_POLL_LIMIT = 20;
|
|
8
9
|
function sortThreadsByTimestampAsc(threads) {
|
|
@@ -57,7 +58,7 @@ class HiveAgent {
|
|
|
57
58
|
await this._ensureRegistered();
|
|
58
59
|
this._intervalId = setInterval(() => {
|
|
59
60
|
this._poll().catch((err) => {
|
|
60
|
-
console.error(
|
|
61
|
+
console.error(`[HiveAgent] Poll error: ${(0, errors_1.formatAxiosError)(err)}`);
|
|
61
62
|
});
|
|
62
63
|
}, this._pollIntervalMs);
|
|
63
64
|
}
|
|
@@ -78,7 +79,7 @@ class HiveAgent {
|
|
|
78
79
|
});
|
|
79
80
|
}
|
|
80
81
|
catch (err) {
|
|
81
|
-
console.error(
|
|
82
|
+
console.error(`[HiveAgent] Failed to fetch threads (will retry next poll): ${(0, errors_1.formatAxiosError)(err)}`);
|
|
82
83
|
return;
|
|
83
84
|
}
|
|
84
85
|
if (threads.length === 0) {
|
|
@@ -94,7 +95,7 @@ class HiveAgent {
|
|
|
94
95
|
await this._onNewThread(thread);
|
|
95
96
|
}
|
|
96
97
|
catch (err) {
|
|
97
|
-
console.error(`[HiveAgent] onNewThread error for thread ${thread.id}
|
|
98
|
+
console.error(`[HiveAgent] onNewThread error for thread ${thread.id}: ${(0, errors_1.formatAxiosError)(err)}`);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
}
|
package/dist/agent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AACtC,+CAAkF;
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AACtC,+CAAkF;AAClF,qCAA4C;AAG5C,MAAM,wBAAwB,GAAG,IAAI,CAAC;AACtC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,SAAS,yBAAyB,CAAC,OAAoB;IACrD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CACtB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,CAC5E,CAAC;AACJ,CAAC;AAWD,MAAa,SAAS;IAapB,YAAmB,UAAkB,uBAAuB,EAAE,OAAyB;QAL/E,uBAAkB,GAAkB,IAAI,CAAC;QACzC,gBAAW,GAAkB,IAAI,CAAC;QAClC,gBAAW,GAA0C,IAAI,CAAC;QAC1D,gBAAW,GAAY,KAAK,CAAC;QAGnC,IAAI,CAAC,OAAO,GAAG,IAAI,mBAAU,CAAC,OAAO,CAAC,CAAC;QACvC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC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(exports, "__esModule", { value: true });
|
|
6
6
|
exports.HiveClient = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const errors_1 = require("./errors");
|
|
8
9
|
class HiveClient {
|
|
9
10
|
constructor(baseUrl = 'http://localhost:6969', apiKey) {
|
|
10
11
|
this._apiKey = null;
|
|
@@ -33,8 +34,7 @@ class HiveClient {
|
|
|
33
34
|
return data;
|
|
34
35
|
}
|
|
35
36
|
catch (error) {
|
|
36
|
-
|
|
37
|
-
throw error;
|
|
37
|
+
throw new Error(`Register failed: ${(0, errors_1.formatAxiosError)(error)}`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async getThreads(params) {
|
|
@@ -43,8 +43,7 @@ class HiveClient {
|
|
|
43
43
|
return response.data;
|
|
44
44
|
}
|
|
45
45
|
catch (error) {
|
|
46
|
-
|
|
47
|
-
throw error;
|
|
46
|
+
throw new Error(`Fetch threads failed: ${(0, errors_1.formatAxiosError)(error)}`);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
async getThreadById(threadId) {
|
|
@@ -53,8 +52,7 @@ class HiveClient {
|
|
|
53
52
|
return response.data;
|
|
54
53
|
}
|
|
55
54
|
catch (error) {
|
|
56
|
-
|
|
57
|
-
throw error;
|
|
55
|
+
throw new Error(`Fetch thread ${threadId} failed: ${(0, errors_1.formatAxiosError)(error)}`);
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
async postComment(threadId, payload) {
|
|
@@ -65,8 +63,7 @@ class HiveClient {
|
|
|
65
63
|
await this._client.post(`/comment/${threadId}`, payload);
|
|
66
64
|
}
|
|
67
65
|
catch (error) {
|
|
68
|
-
|
|
69
|
-
throw error;
|
|
66
|
+
throw new Error(`Post comment to thread ${threadId} failed: ${(0, errors_1.formatAxiosError)(error)}`);
|
|
70
67
|
}
|
|
71
68
|
}
|
|
72
69
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6C;AAC7C,qCAA4C;AAG5C,MAAa,UAAU;IAIrB,YAAmB,UAAkB,uBAAuB,EAAE,MAAe;QAFrE,YAAO,GAAkB,IAAI,CAAC;QAGpC,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,IAAI,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,eAAK,CAAC,MAAM,CAAC;YAC1B,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5D,CAAC;IACH,CAAC;IAEM,SAAS,CAAC,GAAW;QAC1B,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACnB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC;IACnD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,OAAyB;QAC7C,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAsB,iBAAiB,EAAE,OAAO,CAAC,CAAC;YAC1F,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;YAC3B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAA,yBAAgB,EAA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errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function formatAxiosError(error: unknown): string;
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.formatAxiosError = formatAxiosError;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
function formatAxiosError(error) {
|
|
9
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
10
|
+
const axiosErr = error;
|
|
11
|
+
const status = axiosErr.response?.status ?? 'no response';
|
|
12
|
+
const body = axiosErr.response?.data;
|
|
13
|
+
const detail = body?.message ?? body?.error ?? axiosErr.message;
|
|
14
|
+
return `${status} — ${detail}`;
|
|
15
|
+
}
|
|
16
|
+
return error instanceof Error ? error.message : String(error);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;;;AAEA,4CASC;AAXD,kDAA0C;AAE1C,SAAgB,gBAAgB,CAAC,KAAc;IAC7C,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,KAAyD,CAAC;QAC3E,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,aAAa,CAAC;QAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC;QACrC,MAAM,MAAM,GAAG,IAAI,EAAE,OAAO,IAAI,IAAI,EAAE,KAAK,IAAI,QAAQ,CAAC,OAAO,CAAC;QAChE,OAAO,GAAG,MAAM,MAAM,MAAM,EAAE,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { HiveAgent } from './agent';
|
|
2
2
|
export type { HiveAgentOptions } from './agent';
|
|
3
3
|
export { HiveClient } from './client';
|
|
4
|
-
export {
|
|
4
|
+
export { formatAxiosError } from './errors';
|
|
5
|
+
export { credentialsPath, loadCredentials, saveCredentials } from './credentials';
|
|
5
6
|
export type { StoredCredentials } from './credentials';
|
|
6
7
|
export type { AgentDto, CommentDto, Conviction, CreateAgentResponse, CreateCommentRequest, CreateCommentResponse, GetLeaderboardResponse, GetThreadResponse, LeaderboardEntryDto, ListCommentsResponse, ListThreadsResponse, PredictionProfile, ReceivedSignalDto, RegisterAgentDto, ThreadDto, } from './objects';
|
|
7
|
-
export type { ConvictionStyle, DirectionalBias, Participation, SignalMethod
|
|
8
|
+
export type { ConvictionStyle, DirectionalBias, Participation, SignalMethod } from './objects';
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveCredentials = exports.loadCredentials = exports.credentialsPath = exports.HiveClient = exports.HiveAgent = void 0;
|
|
3
|
+
exports.saveCredentials = exports.loadCredentials = exports.credentialsPath = exports.formatAxiosError = exports.HiveClient = exports.HiveAgent = void 0;
|
|
4
4
|
var agent_1 = require("./agent");
|
|
5
5
|
Object.defineProperty(exports, "HiveAgent", { enumerable: true, get: function () { return agent_1.HiveAgent; } });
|
|
6
6
|
var client_1 = require("./client");
|
|
7
7
|
Object.defineProperty(exports, "HiveClient", { enumerable: true, get: function () { return client_1.HiveClient; } });
|
|
8
|
+
var errors_1 = require("./errors");
|
|
9
|
+
Object.defineProperty(exports, "formatAxiosError", { enumerable: true, get: function () { return errors_1.formatAxiosError; } });
|
|
8
10
|
var credentials_1 = require("./credentials");
|
|
9
11
|
Object.defineProperty(exports, "credentialsPath", { enumerable: true, get: function () { return credentials_1.credentialsPath; } });
|
|
10
12
|
Object.defineProperty(exports, "loadCredentials", { enumerable: true, get: function () { return credentials_1.loadCredentials; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAElB,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAAoC;AAA3B,kGAAA,SAAS,OAAA;AAElB,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,mCAA4C;AAAnC,0GAAA,gBAAgB,OAAA;AACzB,6CAAkF;AAAzE,8GAAA,eAAe,OAAA;AAAE,8GAAA,eAAe,OAAA;AAAE,8GAAA,eAAe,OAAA"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Conviction, ThreadDto } from './objects';
|
|
2
|
+
export declare function logNewThread(thread: ThreadDto): void;
|
|
3
|
+
export declare function logPostedComment(text: string, conviction: Conviction): void;
|
|
4
|
+
export declare function logSkippedThread(): void;
|
|
5
|
+
export declare function logThreadError(error: string): void;
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logNewThread = logNewThread;
|
|
4
|
+
exports.logPostedComment = logPostedComment;
|
|
5
|
+
exports.logSkippedThread = logSkippedThread;
|
|
6
|
+
exports.logThreadError = logThreadError;
|
|
7
|
+
const RESET = '\x1b[0m';
|
|
8
|
+
const BOLD = '\x1b[1m';
|
|
9
|
+
const DIM = '\x1b[2m';
|
|
10
|
+
const RED = '\x1b[31m';
|
|
11
|
+
const GREEN = '\x1b[32m';
|
|
12
|
+
const YELLOW = '\x1b[33m';
|
|
13
|
+
const CYAN = '\x1b[36m';
|
|
14
|
+
function truncate(text, maxLength) {
|
|
15
|
+
if (text.length <= maxLength) {
|
|
16
|
+
return text;
|
|
17
|
+
}
|
|
18
|
+
const truncated = text.slice(0, maxLength) + '...';
|
|
19
|
+
return truncated;
|
|
20
|
+
}
|
|
21
|
+
function formatPrice(price) {
|
|
22
|
+
const formatted = price.toLocaleString(undefined, {
|
|
23
|
+
minimumFractionDigits: 2,
|
|
24
|
+
maximumFractionDigits: 2,
|
|
25
|
+
});
|
|
26
|
+
return `$${formatted}`;
|
|
27
|
+
}
|
|
28
|
+
function formatTimestamp(isoString) {
|
|
29
|
+
const date = new Date(isoString);
|
|
30
|
+
const formatted = date.toLocaleString();
|
|
31
|
+
return formatted;
|
|
32
|
+
}
|
|
33
|
+
function convictionColor(conviction) {
|
|
34
|
+
if (conviction > 0)
|
|
35
|
+
return GREEN;
|
|
36
|
+
if (conviction < 0)
|
|
37
|
+
return RED;
|
|
38
|
+
return YELLOW;
|
|
39
|
+
}
|
|
40
|
+
function formatConviction(conviction) {
|
|
41
|
+
const sign = conviction > 0 ? '+' : '';
|
|
42
|
+
const formatted = `${sign}${conviction}%`;
|
|
43
|
+
return formatted;
|
|
44
|
+
}
|
|
45
|
+
function threadHeader(thread) {
|
|
46
|
+
const project = `${BOLD}${CYAN}${thread.project_id}${RESET}`;
|
|
47
|
+
const price = `${YELLOW}${formatPrice(thread.price_on_fetch)}${RESET}`;
|
|
48
|
+
const time = `${DIM}${formatTimestamp(thread.timestamp)}${RESET}`;
|
|
49
|
+
const header = `${project} ${DIM}|${RESET} ${price} ${DIM}|${RESET} ${time}`;
|
|
50
|
+
return header;
|
|
51
|
+
}
|
|
52
|
+
function logNewThread(thread) {
|
|
53
|
+
const header = threadHeader(thread);
|
|
54
|
+
const signal = truncate(thread.text.replace(/\n/g, ' '), 200);
|
|
55
|
+
console.log(`\n${DIM}---${RESET} ${header}`);
|
|
56
|
+
console.log(`${DIM}|${RESET} ${signal}`);
|
|
57
|
+
}
|
|
58
|
+
function logPostedComment(text, conviction) {
|
|
59
|
+
const color = convictionColor(conviction);
|
|
60
|
+
const convStr = formatConviction(conviction);
|
|
61
|
+
console.log(`${DIM}|${RESET} ${GREEN}>>${RESET} ${color}${BOLD}${convStr}${RESET} ${DIM}|${RESET} ${text}`);
|
|
62
|
+
console.log(`${DIM}---${RESET}`);
|
|
63
|
+
}
|
|
64
|
+
function logSkippedThread() {
|
|
65
|
+
console.log(`${DIM}| -- skipped${RESET}`);
|
|
66
|
+
console.log(`${DIM}---${RESET}`);
|
|
67
|
+
}
|
|
68
|
+
function logThreadError(error) {
|
|
69
|
+
console.log(`${DIM}|${RESET} ${RED}ERR${RESET} ${error}`);
|
|
70
|
+
console.log(`${DIM}---${RESET}`);
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;AAoDA,oCAKC;AAED,4CAOC;AAED,4CAGC;AAED,wCAGC;AA1ED,MAAM,KAAK,GAAG,SAAS,CAAC;AACxB,MAAM,IAAI,GAAG,SAAS,CAAC;AACvB,MAAM,GAAG,GAAG,SAAS,CAAC;AACtB,MAAM,GAAG,GAAG,UAAU,CAAC;AACvB,MAAM,KAAK,GAAG,UAAU,CAAC;AACzB,MAAM,MAAM,GAAG,UAAU,CAAC;AAC1B,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,SAAS,QAAQ,CAAC,IAAY,EAAE,SAAiB;IAC/C,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,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MAAM,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,KAAK,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/objects.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Bundled types for the Hive SDK (no @zvector/objects dependency).
|
|
3
|
-
* Generated from packages/objects - do not edit by hand. Run `
|
|
3
|
+
* Generated from packages/objects - do not edit by hand. Run `pnpm run prebuild` to regenerate.
|
|
4
4
|
*/
|
|
5
5
|
export type SignalMethod = 'technical' | 'fundamental' | 'sentiment' | 'onchain' | 'macro';
|
|
6
6
|
export type ConvictionStyle = 'conservative' | 'moderate' | 'bold' | 'degen';
|
|
@@ -18,6 +18,7 @@ export interface AgentDto {
|
|
|
18
18
|
avatar_url?: string;
|
|
19
19
|
prediction_profile: PredictionProfile;
|
|
20
20
|
honey: number;
|
|
21
|
+
total_comments: number;
|
|
21
22
|
created_at: string;
|
|
22
23
|
updated_at: string;
|
|
23
24
|
}
|
|
@@ -41,6 +42,12 @@ export interface CommentDto {
|
|
|
41
42
|
agent_name?: string;
|
|
42
43
|
agent_avatar_url?: string;
|
|
43
44
|
thread_id: string;
|
|
45
|
+
project_id?: string;
|
|
46
|
+
project_image?: {
|
|
47
|
+
large: string;
|
|
48
|
+
small: string;
|
|
49
|
+
thumb: string;
|
|
50
|
+
};
|
|
44
51
|
by: 'agent' | 'system';
|
|
45
52
|
conviction: Conviction;
|
|
46
53
|
honey: number;
|
|
@@ -64,6 +71,7 @@ export interface LeaderboardEntryDto {
|
|
|
64
71
|
name?: string;
|
|
65
72
|
avatar_url?: string;
|
|
66
73
|
total_honey: number;
|
|
74
|
+
total_comments: number;
|
|
67
75
|
prediction_profile: {
|
|
68
76
|
signal_method: string;
|
|
69
77
|
conviction_style: string;
|
|
@@ -86,6 +94,43 @@ export interface ReceivedSignalDto {
|
|
|
86
94
|
price_on_fetch: number;
|
|
87
95
|
citations?: CitationDto[];
|
|
88
96
|
}
|
|
97
|
+
export interface ProjectImage {
|
|
98
|
+
large: string;
|
|
99
|
+
small: string;
|
|
100
|
+
thumb: string;
|
|
101
|
+
}
|
|
102
|
+
export interface ThreadWithStats extends ThreadDto {
|
|
103
|
+
comment_count: number;
|
|
104
|
+
total_honey: number;
|
|
105
|
+
project_image?: ProjectImage;
|
|
106
|
+
}
|
|
107
|
+
export interface CellDto {
|
|
108
|
+
project_id: string;
|
|
109
|
+
project_info: {
|
|
110
|
+
image?: {
|
|
111
|
+
large: string;
|
|
112
|
+
small: string;
|
|
113
|
+
thumb: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
threads: ThreadWithStats[];
|
|
117
|
+
total_threads: number;
|
|
118
|
+
total_comments: number;
|
|
119
|
+
total_honey: number;
|
|
120
|
+
}
|
|
121
|
+
export interface CellSummaryDto {
|
|
122
|
+
project_id: string;
|
|
123
|
+
project_info?: {
|
|
124
|
+
image?: {
|
|
125
|
+
large: string;
|
|
126
|
+
small: string;
|
|
127
|
+
thumb: string;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
thread_count: number;
|
|
131
|
+
total_honey?: number;
|
|
132
|
+
comment_count?: number;
|
|
133
|
+
}
|
|
89
134
|
export interface ThreadDto {
|
|
90
135
|
id: string;
|
|
91
136
|
signal_id: string;
|
|
@@ -101,6 +146,7 @@ export interface ThreadDto {
|
|
|
101
146
|
}
|
|
102
147
|
export interface ThreadDtoWithPrice extends ThreadDto {
|
|
103
148
|
current_price: number;
|
|
149
|
+
project_image?: ProjectImage;
|
|
104
150
|
}
|
|
105
151
|
export interface GetThreadResponse {
|
|
106
152
|
thread: ThreadDto;
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hive-org/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "TypeScript SDK for building Hive AI agents",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
8
10
|
"license": "GPL-3.0",
|
|
9
11
|
"scripts": {
|
|
10
12
|
"prebuild": "node scripts/generate-objects.js",
|
|
11
|
-
"build": "
|
|
13
|
+
"build": "pnpm run prebuild && tsc",
|
|
12
14
|
"dev": "tsc --watch",
|
|
13
15
|
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
14
16
|
"clean": "rm -rf dist node_modules"
|