continuum-engine-client 1.0.0 → 1.0.1
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/client-kernel.js +68 -32
- package/package.json +2 -2
package/client-kernel.js
CHANGED
|
@@ -26,15 +26,23 @@ class ContinuumClient {
|
|
|
26
26
|
*/
|
|
27
27
|
async ask(message) {
|
|
28
28
|
if (!this.continuumToken || !this.authHeaderName) {
|
|
29
|
-
console.error(
|
|
29
|
+
console.error(
|
|
30
|
+
"🚨 Error: Access credentials or header name are not configured.\n" +
|
|
31
|
+
"👉 Please read the official documentation to learn how to obtain your credentials:\n" +
|
|
32
|
+
" https://www.npmjs.com/package/continuum-engine-client\n"
|
|
33
|
+
);
|
|
30
34
|
return;
|
|
31
35
|
}
|
|
32
|
-
|
|
33
|
-
process.stdout.write(
|
|
34
|
-
|
|
36
|
+
|
|
37
|
+
process.stdout.write(
|
|
38
|
+
"\n⏳ ASI-OPEX Engine: Executing inference & cost purge..."
|
|
39
|
+
);
|
|
40
|
+
const spinner = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
35
41
|
let i = 0;
|
|
36
42
|
const interval = setInterval(() => {
|
|
37
|
-
process.stdout.write(
|
|
43
|
+
process.stdout.write(
|
|
44
|
+
`\r⏳ ASI-OPEX Engine: Executing inference & cost purge... ${spinner[i]} `
|
|
45
|
+
);
|
|
38
46
|
i = (i + 1) % spinner.length;
|
|
39
47
|
}, 100);
|
|
40
48
|
|
|
@@ -43,24 +51,28 @@ class ContinuumClient {
|
|
|
43
51
|
method: "POST",
|
|
44
52
|
headers: {
|
|
45
53
|
"Content-Type": "application/json",
|
|
46
|
-
[this.authHeaderName]: this.continuumToken
|
|
54
|
+
[this.authHeaderName]: this.continuumToken,
|
|
47
55
|
},
|
|
48
56
|
body: JSON.stringify({
|
|
49
57
|
message: message,
|
|
50
58
|
docId: this.docId,
|
|
51
|
-
sessionId: this.sessionId
|
|
52
|
-
})
|
|
59
|
+
sessionId: this.sessionId,
|
|
60
|
+
}),
|
|
53
61
|
});
|
|
54
|
-
|
|
62
|
+
|
|
55
63
|
clearInterval(interval);
|
|
56
|
-
process.stdout.write(
|
|
57
|
-
|
|
64
|
+
process.stdout.write(
|
|
65
|
+
"\r✅ Inference & Security Audit Completed! \n"
|
|
66
|
+
);
|
|
67
|
+
|
|
58
68
|
const data = await response.json();
|
|
59
69
|
if (!response.ok) {
|
|
60
|
-
console.error(
|
|
70
|
+
console.error(
|
|
71
|
+
`\n❌ API Error (${response.status}): ${data.error || "Unknown Error"}`
|
|
72
|
+
);
|
|
61
73
|
return;
|
|
62
74
|
}
|
|
63
|
-
|
|
75
|
+
|
|
64
76
|
this._renderResponse(data);
|
|
65
77
|
} catch (error) {
|
|
66
78
|
clearInterval(interval);
|
|
@@ -73,26 +85,32 @@ class ContinuumClient {
|
|
|
73
85
|
*/
|
|
74
86
|
async query(message) {
|
|
75
87
|
if (!this.continuumToken || !this.authHeaderName) {
|
|
76
|
-
throw new Error(
|
|
88
|
+
throw new Error(
|
|
89
|
+
"🚨 Error: Access credentials or header name are not configured.\n" +
|
|
90
|
+
"👉 Please read the official documentation to learn how to obtain your credentials:\n" +
|
|
91
|
+
" https://www.npmjs.com/package/continuum-engine-client"
|
|
92
|
+
);
|
|
77
93
|
}
|
|
78
94
|
const response = await fetch(this.endpointUrl, {
|
|
79
95
|
method: "POST",
|
|
80
96
|
headers: {
|
|
81
97
|
"Content-Type": "application/json",
|
|
82
|
-
[this.authHeaderName]: this.continuumToken
|
|
98
|
+
[this.authHeaderName]: this.continuumToken,
|
|
83
99
|
},
|
|
84
100
|
body: JSON.stringify({
|
|
85
101
|
message: message,
|
|
86
102
|
docId: this.docId,
|
|
87
|
-
sessionId: this.sessionId
|
|
88
|
-
})
|
|
103
|
+
sessionId: this.sessionId,
|
|
104
|
+
}),
|
|
89
105
|
});
|
|
90
|
-
|
|
106
|
+
|
|
91
107
|
const data = await response.json();
|
|
92
108
|
if (!response.ok) {
|
|
93
|
-
throw new Error(
|
|
109
|
+
throw new Error(
|
|
110
|
+
`API Error (${response.status}): ${data.error || "Unknown Error"}`
|
|
111
|
+
);
|
|
94
112
|
}
|
|
95
|
-
|
|
113
|
+
|
|
96
114
|
return data;
|
|
97
115
|
}
|
|
98
116
|
|
|
@@ -100,14 +118,20 @@ class ContinuumClient {
|
|
|
100
118
|
* Internal Method: Terminal visualization logic for response data
|
|
101
119
|
*/
|
|
102
120
|
_renderResponse(data) {
|
|
103
|
-
const {
|
|
104
|
-
|
|
121
|
+
const {
|
|
122
|
+
ai_response,
|
|
123
|
+
source_urls,
|
|
124
|
+
remaining_requests,
|
|
125
|
+
finops_report,
|
|
126
|
+
doc_id,
|
|
127
|
+
} = data;
|
|
128
|
+
|
|
105
129
|
console.log("\n==================================================");
|
|
106
130
|
console.log("🤖 [AI RESPONSE]");
|
|
107
131
|
console.log("==================================================");
|
|
108
132
|
console.log(ai_response);
|
|
109
133
|
console.log("--------------------------------------------------");
|
|
110
|
-
|
|
134
|
+
|
|
111
135
|
if (source_urls && source_urls.length > 0) {
|
|
112
136
|
console.log("🔗 [VERIFIED PRIMARY SOURCES]");
|
|
113
137
|
source_urls.forEach((src, idx) => {
|
|
@@ -115,26 +139,38 @@ class ContinuumClient {
|
|
|
115
139
|
});
|
|
116
140
|
console.log("--------------------------------------------------");
|
|
117
141
|
}
|
|
118
|
-
|
|
142
|
+
|
|
119
143
|
if (doc_id) {
|
|
120
|
-
console.log(
|
|
144
|
+
console.log(
|
|
145
|
+
`📝 [STATE STORAGE] History successfully synced to your private document.`
|
|
146
|
+
);
|
|
121
147
|
console.log("--------------------------------------------------");
|
|
122
148
|
}
|
|
123
149
|
|
|
124
150
|
if (finops_report && finops_report.breakdown) {
|
|
125
151
|
const br = finops_report.breakdown;
|
|
126
152
|
console.log("🔍 [FINOPS TELEMETRY BREAKDOWN]");
|
|
127
|
-
console.log(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
153
|
+
console.log(
|
|
154
|
+
` ├─ T_input (Optimized Prompt) : ${br.t_input_optimized} tokens`
|
|
155
|
+
);
|
|
156
|
+
console.log(
|
|
157
|
+
` ├─ T_grounding (Dynamic Search) : ${br.t_grounding_dynamic} tokens`
|
|
158
|
+
);
|
|
159
|
+
console.log(
|
|
160
|
+
` └─ T_output (Generated Result) : ${br.t_output_generated} tokens`
|
|
161
|
+
);
|
|
162
|
+
|
|
131
163
|
if (finops_report.tokens_saved > 0) {
|
|
132
|
-
console.log(
|
|
164
|
+
console.log(
|
|
165
|
+
` 🛡️ Edge Purge (Tokens Prevented) : ${finops_report.tokens_saved} tokens`
|
|
166
|
+
);
|
|
133
167
|
}
|
|
134
|
-
console.log(
|
|
168
|
+
console.log(
|
|
169
|
+
` 📉 Net Billed Consumption : ${finops_report.billed_tokens} tokens`
|
|
170
|
+
);
|
|
135
171
|
console.log("==================================================");
|
|
136
172
|
}
|
|
137
|
-
|
|
173
|
+
|
|
138
174
|
console.log(`💳 Quota Balance: ${remaining_requests} requests remaining`);
|
|
139
175
|
console.log("==================================================\n");
|
|
140
176
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "continuum-engine-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Enterprise middleware kernel that visualizes SI labor and constantizes inference OPEX.",
|
|
5
5
|
"main": "client-kernel.js",
|
|
6
6
|
"author": "MC MP",
|
|
7
7
|
"license": "MIT"
|
|
8
|
-
}
|
|
8
|
+
}
|