@heossihq/bee 0.1.5
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/LICENSE +190 -0
- package/README.md +179 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +196 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +123 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +331 -0
- package/dist/client.js.map +1 -0
- package/dist/code.d.ts +162 -0
- package/dist/code.d.ts.map +1 -0
- package/dist/code.js +111 -0
- package/dist/code.js.map +1 -0
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +35 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/quantum-local.d.ts +49 -0
- package/dist/quantum-local.d.ts.map +1 -0
- package/dist/quantum-local.js +114 -0
- package/dist/quantum-local.js.map +1 -0
- package/dist/types.d.ts +234 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/dist/code.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/** Public contracts for Bee's managed Code sessions and actions. */
|
|
2
|
+
export const BEE_CODE_AUTHORITY_MODES = ["read_only", "approve_edits", "auto_edit"];
|
|
3
|
+
export const BEE_CODE_ACTIONS = [
|
|
4
|
+
"list_files",
|
|
5
|
+
"discover_repository_controls",
|
|
6
|
+
"read_file",
|
|
7
|
+
"search_files",
|
|
8
|
+
"write_file",
|
|
9
|
+
"stage_file_chunk",
|
|
10
|
+
"apply_file_batch",
|
|
11
|
+
"rollback_file_batch",
|
|
12
|
+
"git_status",
|
|
13
|
+
"git_diff",
|
|
14
|
+
"create_checkpoint",
|
|
15
|
+
"checkpoint_diff",
|
|
16
|
+
"create_branch",
|
|
17
|
+
"commit_changes",
|
|
18
|
+
"open_pull_request",
|
|
19
|
+
"diagnostics",
|
|
20
|
+
"test",
|
|
21
|
+
"lint",
|
|
22
|
+
"typecheck",
|
|
23
|
+
"build",
|
|
24
|
+
"run_hooks",
|
|
25
|
+
];
|
|
26
|
+
const ACTION_FIELDS = {
|
|
27
|
+
list_files: { required: [], optional: [] },
|
|
28
|
+
discover_repository_controls: { required: [], optional: [] },
|
|
29
|
+
read_file: { required: ["path"], optional: [] },
|
|
30
|
+
search_files: { required: ["query"], optional: [] },
|
|
31
|
+
write_file: { required: ["path", "content", "checkpoint_sha"], optional: ["approved"] },
|
|
32
|
+
stage_file_chunk: {
|
|
33
|
+
required: ["batch_id", "path", "chunk_index", "total_chunks", "content", "content_sha256"],
|
|
34
|
+
optional: ["approved"],
|
|
35
|
+
},
|
|
36
|
+
apply_file_batch: { required: ["batch_id", "checkpoint_sha"], optional: ["approved"] },
|
|
37
|
+
rollback_file_batch: { required: ["batch_id"], optional: ["approved"] },
|
|
38
|
+
git_status: { required: [], optional: [] },
|
|
39
|
+
git_diff: { required: [], optional: ["path"] },
|
|
40
|
+
create_checkpoint: { required: [], optional: [] },
|
|
41
|
+
checkpoint_diff: { required: ["checkpoint_sha"], optional: ["path"] },
|
|
42
|
+
create_branch: { required: ["branch"], optional: ["approved"] },
|
|
43
|
+
commit_changes: { required: ["message"], optional: ["approved"] },
|
|
44
|
+
open_pull_request: { required: ["title", "description"], optional: ["base", "approved"] },
|
|
45
|
+
diagnostics: { required: [], optional: [] },
|
|
46
|
+
test: { required: [], optional: ["approved"] },
|
|
47
|
+
lint: { required: [], optional: ["approved"] },
|
|
48
|
+
typecheck: { required: [], optional: ["approved"] },
|
|
49
|
+
build: { required: [], optional: ["approved"] },
|
|
50
|
+
run_hooks: { required: [], optional: ["approved"] },
|
|
51
|
+
};
|
|
52
|
+
function isRecord(value) {
|
|
53
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
54
|
+
}
|
|
55
|
+
function requireNonEmptyString(value, field) {
|
|
56
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
57
|
+
throw new TypeError(`Bee Code ${field} must be a non-empty string`);
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
/** Validate untyped JavaScript/CLI input before any managed Code action is sent. */
|
|
62
|
+
export function validateBeeCodeActionRequest(value) {
|
|
63
|
+
if (!isRecord(value) || typeof value.action !== "string" || !(value.action in ACTION_FIELDS)) {
|
|
64
|
+
throw new TypeError("Bee Code action request has an unsupported action");
|
|
65
|
+
}
|
|
66
|
+
const action = value.action;
|
|
67
|
+
const fields = ACTION_FIELDS[action];
|
|
68
|
+
const supplied = Object.keys(value).filter((field) => field !== "action");
|
|
69
|
+
const missing = fields.required.filter((field) => !(field in value));
|
|
70
|
+
const unknown = supplied.filter((field) => !fields.required.includes(field) && !fields.optional.includes(field));
|
|
71
|
+
if (missing.length)
|
|
72
|
+
throw new TypeError(`Bee Code ${action} is missing: ${missing.join(", ")}`);
|
|
73
|
+
if (unknown.length)
|
|
74
|
+
throw new TypeError(`Bee Code ${action} has unsupported fields: ${unknown.join(", ")}`);
|
|
75
|
+
for (const field of [
|
|
76
|
+
"path",
|
|
77
|
+
"query",
|
|
78
|
+
"batch_id",
|
|
79
|
+
"checkpoint_sha",
|
|
80
|
+
"branch",
|
|
81
|
+
"message",
|
|
82
|
+
"title",
|
|
83
|
+
"base",
|
|
84
|
+
]) {
|
|
85
|
+
if (field in value)
|
|
86
|
+
requireNonEmptyString(value[field], field);
|
|
87
|
+
}
|
|
88
|
+
if ("checkpoint_sha" in value && !/^[0-9a-f]{40}$/i.test(String(value.checkpoint_sha))) {
|
|
89
|
+
throw new TypeError("Bee Code checkpoint_sha must be a full SHA-1 hex object ID");
|
|
90
|
+
}
|
|
91
|
+
if ("content" in value && typeof value.content !== "string") {
|
|
92
|
+
throw new TypeError("Bee Code content must be a string");
|
|
93
|
+
}
|
|
94
|
+
if ("approved" in value && typeof value.approved !== "boolean") {
|
|
95
|
+
throw new TypeError("Bee Code approved must be a boolean");
|
|
96
|
+
}
|
|
97
|
+
if (action === "stage_file_chunk") {
|
|
98
|
+
if (!Number.isSafeInteger(value.chunk_index) ||
|
|
99
|
+
!Number.isSafeInteger(value.total_chunks) ||
|
|
100
|
+
Number(value.chunk_index) < 0 ||
|
|
101
|
+
Number(value.total_chunks) < 1 ||
|
|
102
|
+
Number(value.chunk_index) >= Number(value.total_chunks)) {
|
|
103
|
+
throw new TypeError("Bee Code chunk indexes must identify one bounded chunk");
|
|
104
|
+
}
|
|
105
|
+
if (typeof value.content_sha256 !== "string" || !/^[0-9a-f]{64}$/i.test(value.content_sha256)) {
|
|
106
|
+
throw new TypeError("Bee Code content_sha256 must be a SHA-256 hex digest");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return { ...value };
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=code.js.map
|
package/dist/code.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../src/code.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAEpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,WAAW,EAAE,eAAe,EAAE,WAAW,CAAU,CAAC;AAG7F,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,YAAY;IACZ,8BAA8B;IAC9B,WAAW;IACX,cAAc;IACd,YAAY;IACZ,kBAAkB;IAClB,kBAAkB;IAClB,qBAAqB;IACrB,YAAY;IACZ,UAAU;IACV,mBAAmB;IACnB,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,mBAAmB;IACnB,aAAa;IACb,MAAM;IACN,MAAM;IACN,WAAW;IACX,OAAO;IACP,WAAW;CACH,CAAC;AA2IX,MAAM,aAAa,GAEf;IACF,UAAU,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC1C,4BAA4B,EAAE,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 +1,20 @@
|
|
|
1
|
+
/** Base error type — every BeeError carries the HTTP status and (when present) the upstream JSON body. */
|
|
2
|
+
export declare class BeeError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly body: unknown;
|
|
5
|
+
constructor(message: string, status: number, body: unknown);
|
|
6
|
+
}
|
|
7
|
+
/** 401 / 403 — bad or missing API key, or the key's plan does not grant the requested tier. */
|
|
8
|
+
export declare class BeeAuthError extends BeeError {
|
|
9
|
+
constructor(message: string, status: number, body: unknown);
|
|
10
|
+
}
|
|
11
|
+
/** 429 — rate-limited. The `retryAfterSeconds` field reflects the Retry-After header when the server set it. */
|
|
12
|
+
export declare class BeeRateLimitError extends BeeError {
|
|
13
|
+
readonly retryAfterSeconds: number | null;
|
|
14
|
+
constructor(message: string, body: unknown, retryAfterSeconds: number | null);
|
|
15
|
+
}
|
|
16
|
+
/** AbortController fired before the response landed. */
|
|
17
|
+
export declare class BeeTimeoutError extends BeeError {
|
|
18
|
+
constructor(message: string, timeoutMs: number);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAED,+FAA+F;AAC/F,qBAAa,YAAa,SAAQ,QAAQ;gBAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAI3D;AAED,gHAAgH;AAChH,qBAAa,iBAAkB,SAAQ,QAAQ;IAC7C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;gBAC9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,IAAI;CAK7E;AAED,wDAAwD;AACxD,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAI/C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/** Base error type — every BeeError carries the HTTP status and (when present) the upstream JSON body. */
|
|
2
|
+
export class BeeError extends Error {
|
|
3
|
+
status;
|
|
4
|
+
body;
|
|
5
|
+
constructor(message, status, body) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "BeeError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.body = body;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** 401 / 403 — bad or missing API key, or the key's plan does not grant the requested tier. */
|
|
13
|
+
export class BeeAuthError extends BeeError {
|
|
14
|
+
constructor(message, status, body) {
|
|
15
|
+
super(message, status, body);
|
|
16
|
+
this.name = "BeeAuthError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** 429 — rate-limited. The `retryAfterSeconds` field reflects the Retry-After header when the server set it. */
|
|
20
|
+
export class BeeRateLimitError extends BeeError {
|
|
21
|
+
retryAfterSeconds;
|
|
22
|
+
constructor(message, body, retryAfterSeconds) {
|
|
23
|
+
super(message, 429, body);
|
|
24
|
+
this.name = "BeeRateLimitError";
|
|
25
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** AbortController fired before the response landed. */
|
|
29
|
+
export class BeeTimeoutError extends BeeError {
|
|
30
|
+
constructor(message, timeoutMs) {
|
|
31
|
+
super(message, 0, { timeoutMs });
|
|
32
|
+
this.name = "BeeTimeoutError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAS;IACf,IAAI,CAAU;IAEvB,YAAY,OAAe,EAAE,MAAc,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,+FAA+F;AAC/F,MAAM,OAAO,YAAa,SAAQ,QAAQ;IACxC,YAAY,OAAe,EAAE,MAAc,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AAED,gHAAgH;AAChH,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IACpC,iBAAiB,CAAgB;IAC1C,YAAY,OAAe,EAAE,IAAa,EAAE,iBAAgC;QAC1E,KAAK,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC7C,CAAC;CACF;AAED,wDAAwD;AACxD,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAe,EAAE,SAAiB;QAC5C,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @heossihq/bee — Official TypeScript / JavaScript SDK for
|
|
3
|
+
* Bee by HEOSSI — The Progressive Quantum-Native Intelligence Engine.
|
|
4
|
+
*
|
|
5
|
+
* Bee exposes an OpenAI-compatible /chat/completions surface backed by a
|
|
6
|
+
* domain-specialised LoRA-routed model ladder (Cell, Brood, Comb, Buzz,
|
|
7
|
+
* Hive, Swarm, Enclave). This SDK is the typed entry point — pure
|
|
8
|
+
* ESM, zero runtime dependencies, native fetch.
|
|
9
|
+
*
|
|
10
|
+
* See https://bee.heossi.com/docs for the full API reference.
|
|
11
|
+
*/
|
|
12
|
+
export { BeeClient } from "./client.js";
|
|
13
|
+
export type { BeeClientOptions } from "./client.js";
|
|
14
|
+
export { BeeError, BeeAuthError, BeeRateLimitError, BeeTimeoutError } from "./errors.js";
|
|
15
|
+
export { executeByopaDirect, quantumLocalSelect } from "./quantum-local.js";
|
|
16
|
+
export type { ByopaDirectAdapter, ByopaDirectRequest, ByopaDirectResult, QuantumLocalAccelerator, QuantumLocalResult, } from "./quantum-local.js";
|
|
17
|
+
export type { ChatMessage, Role, ContentPart, TextPart, ImageUrlPart, ChatCompletionCreateParams, ChatCompletion, ChatCompletionChoice, ChatCompletionChunk, ChatCompletionChunkChoice, ChatCompletionUsage, ModelInfo, ModelsListResponse, QuantumReasoningModel, QuantumProductId, QuantumReasoningJobStatus, QuantumReasoningRealRequestStatus, QuantumReasoningCandidate, QuantumReasoningJob, QuantumReasoningCapabilities, QuantumReasoningJobCreateParams, ProvenanceLink, ProvenanceResult, UsageAllowance, UsageBreakdownTier, UsageResponse, } from "./types.js";
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,WAAW,EACX,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,yBAAyB,EACzB,iCAAiC,EACjC,yBAAyB,EACzB,mBAAmB,EACnB,4BAA4B,EAC5B,+BAA+B,EAC/B,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,aAAa,GACd,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @heossihq/bee — Official TypeScript / JavaScript SDK for
|
|
3
|
+
* Bee by HEOSSI — The Progressive Quantum-Native Intelligence Engine.
|
|
4
|
+
*
|
|
5
|
+
* Bee exposes an OpenAI-compatible /chat/completions surface backed by a
|
|
6
|
+
* domain-specialised LoRA-routed model ladder (Cell, Brood, Comb, Buzz,
|
|
7
|
+
* Hive, Swarm, Enclave). This SDK is the typed entry point — pure
|
|
8
|
+
* ESM, zero runtime dependencies, native fetch.
|
|
9
|
+
*
|
|
10
|
+
* See https://bee.heossi.com/docs for the full API reference.
|
|
11
|
+
*/
|
|
12
|
+
export { BeeClient } from "./client.js";
|
|
13
|
+
export { BeeError, BeeAuthError, BeeRateLimitError, BeeTimeoutError } from "./errors.js";
|
|
14
|
+
export { executeByopaDirect, quantumLocalSelect } from "./quantum-local.js";
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export interface QuantumLocalAccelerator {
|
|
2
|
+
backend: "customer_gpu" | string;
|
|
3
|
+
run(probabilities: readonly number[], shots: number, seed: number): Promise<Record<string, number>>;
|
|
4
|
+
}
|
|
5
|
+
export interface QuantumLocalResult {
|
|
6
|
+
selected_index: number;
|
|
7
|
+
selected: string;
|
|
8
|
+
probabilities: number[];
|
|
9
|
+
/** Real amplitudes for the prepared, normalized state; padded to 2^qubits. */
|
|
10
|
+
amplitudes: number[];
|
|
11
|
+
qubits: number;
|
|
12
|
+
counts: Record<string, number>;
|
|
13
|
+
shots: number;
|
|
14
|
+
backend: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function quantumLocalSelect(input: {
|
|
17
|
+
candidates: readonly string[];
|
|
18
|
+
scores: readonly number[];
|
|
19
|
+
shots?: number;
|
|
20
|
+
seed?: number;
|
|
21
|
+
accelerator?: QuantumLocalAccelerator;
|
|
22
|
+
}): Promise<QuantumLocalResult>;
|
|
23
|
+
export interface ByopaDirectRequest {
|
|
24
|
+
circuit: string;
|
|
25
|
+
shots: number;
|
|
26
|
+
backend: string;
|
|
27
|
+
max_cost_minor: number;
|
|
28
|
+
currency: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ByopaDirectResult {
|
|
31
|
+
provider_job_id: string;
|
|
32
|
+
backend: string;
|
|
33
|
+
counts: Record<string, number>;
|
|
34
|
+
billed_cost_minor?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ByopaDirectAdapter {
|
|
37
|
+
quote(request: ByopaDirectRequest): Promise<{
|
|
38
|
+
cost_minor: number;
|
|
39
|
+
currency: string;
|
|
40
|
+
expires_at: string;
|
|
41
|
+
}>;
|
|
42
|
+
run(request: ByopaDirectRequest, quote: {
|
|
43
|
+
cost_minor: number;
|
|
44
|
+
currency: string;
|
|
45
|
+
expires_at: string;
|
|
46
|
+
}): Promise<ByopaDirectResult>;
|
|
47
|
+
}
|
|
48
|
+
export declare function executeByopaDirect(request: ByopaDirectRequest, adapter: ByopaDirectAdapter): Promise<ByopaDirectResult>;
|
|
49
|
+
//# sourceMappingURL=quantum-local.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantum-local.d.ts","sourceRoot":"","sources":["../src/quantum-local.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,cAAc,GAAG,MAAM,CAAC;IACjC,GAAG,CACD,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,8EAA8E;IAC9E,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAkCD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,uBAAuB,CAAC;CACvC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA0D9B;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AACD,MAAM,WAAW,kBAAkB;IACjC,KAAK,CACH,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzE,GAAG,CACD,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAClE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/B;AAED,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,iBAAiB,CAAC,CAsC5B"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
function validateProviderCounts(counts, shots) {
|
|
2
|
+
const entries = Object.entries(counts);
|
|
3
|
+
if (entries.length === 0 ||
|
|
4
|
+
entries.some(([key, value]) => !/^[01]{1,64}$/.test(key) || !Number.isInteger(value) || value < 0) ||
|
|
5
|
+
entries.reduce((sum, [, value]) => sum + value, 0) !== shots) {
|
|
6
|
+
throw new Error("provider returned invalid counts");
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function finite(value, name) {
|
|
10
|
+
if (!Number.isFinite(value))
|
|
11
|
+
throw new TypeError(`${name} must be finite`);
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
function validateCounts(counts, size, shots) {
|
|
15
|
+
const entries = Object.entries(counts);
|
|
16
|
+
if (entries.length === 0 ||
|
|
17
|
+
entries.some(([key, value]) => !/^\d+$/.test(key) || Number(key) >= size || !Number.isInteger(value) || value < 0) ||
|
|
18
|
+
entries.reduce((sum, [, value]) => sum + value, 0) !== shots) {
|
|
19
|
+
throw new Error("accelerator returned invalid counts");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export async function quantumLocalSelect(input) {
|
|
23
|
+
const { candidates, scores } = input;
|
|
24
|
+
if (candidates.length < 1 || candidates.length > 256 || candidates.length !== scores.length) {
|
|
25
|
+
throw new RangeError("candidates and scores must have the same length from 1 to 256");
|
|
26
|
+
}
|
|
27
|
+
if (candidates.some((value) => !value || value.length > 256_000))
|
|
28
|
+
throw new RangeError("invalid candidate");
|
|
29
|
+
for (const value of scores)
|
|
30
|
+
finite(value, "score");
|
|
31
|
+
const shots = input.shots ?? 2_000;
|
|
32
|
+
const seed = input.seed ?? 0xbee;
|
|
33
|
+
if (!Number.isInteger(shots) || shots < 1 || shots > 100_000)
|
|
34
|
+
throw new RangeError("shots out of range");
|
|
35
|
+
if (!Number.isSafeInteger(seed))
|
|
36
|
+
throw new RangeError("seed must be a safe integer");
|
|
37
|
+
const high = Math.max(...scores);
|
|
38
|
+
const weights = scores.map((score) => Math.exp(score - high));
|
|
39
|
+
const total = weights.reduce((sum, value) => sum + value, 0);
|
|
40
|
+
const probabilities = weights.map((value) => value / total);
|
|
41
|
+
const qubits = Math.max(1, Math.ceil(Math.log2(candidates.length)));
|
|
42
|
+
const amplitudes = Array.from({ length: 2 ** qubits }, (_, index) => index < probabilities.length ? Math.sqrt(probabilities[index]) : 0);
|
|
43
|
+
let counts;
|
|
44
|
+
let backend = "customer_cpu";
|
|
45
|
+
if (input.accelerator) {
|
|
46
|
+
counts = await input.accelerator.run(probabilities, shots, seed);
|
|
47
|
+
backend = input.accelerator.backend;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
counts = {};
|
|
51
|
+
let state = seed >>> 0;
|
|
52
|
+
for (let shot = 0; shot < shots; shot += 1) {
|
|
53
|
+
state = (Math.imul(1664525, state) + 1013904223) >>> 0;
|
|
54
|
+
const sample = state / 2 ** 32;
|
|
55
|
+
let cumulative = 0;
|
|
56
|
+
let index = probabilities.length - 1;
|
|
57
|
+
for (let candidate = 0; candidate < probabilities.length; candidate += 1) {
|
|
58
|
+
cumulative += probabilities[candidate];
|
|
59
|
+
if (sample < cumulative) {
|
|
60
|
+
index = candidate;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
counts[String(index)] = (counts[String(index)] ?? 0) + 1;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
validateCounts(counts, candidates.length, shots);
|
|
68
|
+
const selectedIndex = Number(Object.keys(counts).reduce((best, key) => (counts[key] > counts[best] ? key : best)));
|
|
69
|
+
return {
|
|
70
|
+
selected_index: selectedIndex,
|
|
71
|
+
selected: candidates[selectedIndex],
|
|
72
|
+
probabilities,
|
|
73
|
+
amplitudes,
|
|
74
|
+
qubits,
|
|
75
|
+
counts,
|
|
76
|
+
shots,
|
|
77
|
+
backend,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export async function executeByopaDirect(request, adapter) {
|
|
81
|
+
if (!request.circuit || request.circuit.length > 1_000_000)
|
|
82
|
+
throw new RangeError("invalid circuit");
|
|
83
|
+
if (!Number.isInteger(request.shots) || request.shots < 1 || request.shots > 100_000)
|
|
84
|
+
throw new RangeError("invalid shots");
|
|
85
|
+
if (!request.backend || request.backend.length > 200)
|
|
86
|
+
throw new RangeError("invalid backend");
|
|
87
|
+
if (!Number.isSafeInteger(request.max_cost_minor) || request.max_cost_minor < 0)
|
|
88
|
+
throw new RangeError("invalid cost cap");
|
|
89
|
+
if (!/^[A-Z]{3}$/.test(request.currency))
|
|
90
|
+
throw new RangeError("currency must be uppercase ISO-4217");
|
|
91
|
+
const quote = await adapter.quote(request);
|
|
92
|
+
if (!Number.isSafeInteger(quote.cost_minor) ||
|
|
93
|
+
quote.cost_minor < 0 ||
|
|
94
|
+
quote.cost_minor > request.max_cost_minor ||
|
|
95
|
+
quote.currency !== request.currency ||
|
|
96
|
+
!/(?:Z|[+-]\d{2}:\d{2})$/.test(quote.expires_at) ||
|
|
97
|
+
!Number.isFinite(Date.parse(quote.expires_at)) ||
|
|
98
|
+
Date.parse(quote.expires_at) <= Date.now())
|
|
99
|
+
throw new Error("provider returned invalid quote");
|
|
100
|
+
const result = await adapter.run(request, quote);
|
|
101
|
+
if (!result.provider_job_id ||
|
|
102
|
+
result.provider_job_id.length > 300 ||
|
|
103
|
+
result.backend !== request.backend)
|
|
104
|
+
throw new Error("provider returned invalid identity");
|
|
105
|
+
validateProviderCounts(result.counts, request.shots);
|
|
106
|
+
if (result.billed_cost_minor !== undefined &&
|
|
107
|
+
(!Number.isSafeInteger(result.billed_cost_minor) ||
|
|
108
|
+
result.billed_cost_minor < 0 ||
|
|
109
|
+
result.billed_cost_minor > quote.cost_minor ||
|
|
110
|
+
result.billed_cost_minor > request.max_cost_minor))
|
|
111
|
+
throw new Error("provider returned invalid bill");
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=quantum-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quantum-local.js","sourceRoot":"","sources":["../src/quantum-local.ts"],"names":[],"mappings":"AAqBA,SAAS,sBAAsB,CAAC,MAA8B,EAAE,KAAa;IAC3E,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,C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MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACjD,IACE,CAAC,MAAM,CAAC,eAAe;QACvB,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,GAAG;QACnC,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO;QAElC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IACxD,sBAAsB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACrD,IACE,MAAM,CAAC,iBAAiB,KAAK,SAAS;QACtC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,iBAAiB,CAAC;YAC9C,MAAM,CAAC,iBAAiB,GAAG,CAAC;YAC5B,MAAM,CAAC,iBAAiB,GAAG,KAAK,CAAC,UAAU;YAC3C,MAAM,CAAC,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;QAEpD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAI-compatible request / response types for Bee.
|
|
3
|
+
*
|
|
4
|
+
* Bee exposes a strict subset of the OpenAI Chat Completions surface
|
|
5
|
+
* at https://api.bee.heossi.com/bee/chat/completions — same JSON shapes,
|
|
6
|
+
* same streaming format. Anything unsupported (function calling,
|
|
7
|
+
* logprobs, n>1, etc.) silently 400s upstream rather than surfacing
|
|
8
|
+
* a misleading "ok" response. This SDK exposes only what's verified
|
|
9
|
+
* to work end-to-end so callers don't ship dead options.
|
|
10
|
+
*/
|
|
11
|
+
export type Role = "system" | "user" | "assistant";
|
|
12
|
+
export type TextPart = {
|
|
13
|
+
type: "text";
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
export type ImageUrlPart = {
|
|
17
|
+
type: "image_url";
|
|
18
|
+
image_url: {
|
|
19
|
+
url: string;
|
|
20
|
+
detail?: "auto" | "low" | "high";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type ContentPart = TextPart | ImageUrlPart;
|
|
24
|
+
export interface ChatMessage {
|
|
25
|
+
role: Role;
|
|
26
|
+
/** A plain string OR an OpenAI-style multimodal content array. */
|
|
27
|
+
content: string | ContentPart[];
|
|
28
|
+
}
|
|
29
|
+
export interface ChatCompletionCreateParams {
|
|
30
|
+
/** Bee tier id — `bee-cell`, `bee-brood`, `bee-comb`, `bee-buzz`, `bee-hive`, `bee-swarm`, `bee-enclave`. Default `bee-cell`. */
|
|
31
|
+
model?: string;
|
|
32
|
+
messages: ChatMessage[];
|
|
33
|
+
temperature?: number;
|
|
34
|
+
max_tokens?: number;
|
|
35
|
+
/** Optional deterministic seed (forwarded to the backend; honoured by some tiers). */
|
|
36
|
+
seed?: number;
|
|
37
|
+
/** When true, returns an async iterator of OpenAI SSE chunks. */
|
|
38
|
+
stream?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export interface ChatCompletionChoice {
|
|
41
|
+
index: number;
|
|
42
|
+
message: {
|
|
43
|
+
role: "assistant";
|
|
44
|
+
content: string;
|
|
45
|
+
};
|
|
46
|
+
finish_reason: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ChatCompletionUsage {
|
|
49
|
+
prompt_tokens: number;
|
|
50
|
+
completion_tokens: number;
|
|
51
|
+
total_tokens: number;
|
|
52
|
+
}
|
|
53
|
+
export interface ChatCompletion {
|
|
54
|
+
id: string;
|
|
55
|
+
object: "chat.completion";
|
|
56
|
+
created: number;
|
|
57
|
+
model: string;
|
|
58
|
+
choices: ChatCompletionChoice[];
|
|
59
|
+
usage: ChatCompletionUsage;
|
|
60
|
+
}
|
|
61
|
+
export interface ChatCompletionChunkChoice {
|
|
62
|
+
index: number;
|
|
63
|
+
delta: {
|
|
64
|
+
role?: "assistant";
|
|
65
|
+
content?: string;
|
|
66
|
+
};
|
|
67
|
+
finish_reason: string | null;
|
|
68
|
+
}
|
|
69
|
+
export interface ChatCompletionChunk {
|
|
70
|
+
id: string;
|
|
71
|
+
object: "chat.completion.chunk";
|
|
72
|
+
created: number;
|
|
73
|
+
model: string;
|
|
74
|
+
choices: ChatCompletionChunkChoice[];
|
|
75
|
+
}
|
|
76
|
+
export interface ModelInfo {
|
|
77
|
+
id: string;
|
|
78
|
+
object: "model";
|
|
79
|
+
created?: number;
|
|
80
|
+
owned_by?: string;
|
|
81
|
+
}
|
|
82
|
+
export interface ModelsListResponse {
|
|
83
|
+
object: "list";
|
|
84
|
+
data: ModelInfo[];
|
|
85
|
+
}
|
|
86
|
+
export type QuantumReasoningModel = "bee-hive" | "bee-swarm";
|
|
87
|
+
export type QuantumProductId = "local_simulator" | "simulation_cloud" | "managed_qpu" | "byopa_direct" | "byopa_managed";
|
|
88
|
+
export type QuantumReasoningJobStatus = "queued" | "generating_candidates" | "scoring" | "selecting" | "awaiting_qpu" | "completed" | "classical_fallback" | "failed" | "cancelled";
|
|
89
|
+
export type QuantumReasoningRealRequestStatus = "not_requested" | "reserved" | "executed" | "provider_used_simulator" | "quantum_not_enabled" | "quantum_allowance_exhausted" | "released_after_failure";
|
|
90
|
+
export interface QuantumReasoningCandidate {
|
|
91
|
+
index: number;
|
|
92
|
+
content: string;
|
|
93
|
+
score: number;
|
|
94
|
+
}
|
|
95
|
+
export interface QuantumReasoningJob {
|
|
96
|
+
id: string;
|
|
97
|
+
product: Exclude<QuantumProductId, "local_simulator" | "byopa_direct">;
|
|
98
|
+
status: QuantumReasoningJobStatus;
|
|
99
|
+
model: QuantumReasoningModel;
|
|
100
|
+
scoring_method: "hive_logprob" | "swarm_judge";
|
|
101
|
+
requested_real: boolean;
|
|
102
|
+
prompt?: string;
|
|
103
|
+
candidates?: QuantumReasoningCandidate[];
|
|
104
|
+
selected_index?: number;
|
|
105
|
+
result?: string;
|
|
106
|
+
selector_backend?: string;
|
|
107
|
+
selector_confidence?: number;
|
|
108
|
+
used_real_qubits: boolean;
|
|
109
|
+
quoted_credits: number | null;
|
|
110
|
+
fallback_reason: "selector_unreachable" | "invalid_selection" | null;
|
|
111
|
+
real_request_status: QuantumReasoningRealRequestStatus;
|
|
112
|
+
usage: Record<string, number>;
|
|
113
|
+
inference_receipt_id: string | null;
|
|
114
|
+
attempt_count: number;
|
|
115
|
+
max_attempts: number;
|
|
116
|
+
next_attempt_at: string | null;
|
|
117
|
+
outcome_state: "not_started" | "in_progress" | "committed" | "outcome_unknown" | "reconciled";
|
|
118
|
+
error: {
|
|
119
|
+
code: string;
|
|
120
|
+
message: string;
|
|
121
|
+
} | null;
|
|
122
|
+
workspace_id?: string | null;
|
|
123
|
+
created_at: string;
|
|
124
|
+
updated_at: string;
|
|
125
|
+
completed_at: string | null;
|
|
126
|
+
}
|
|
127
|
+
export interface QuantumReasoningCapabilities {
|
|
128
|
+
allowed_models: QuantumReasoningModel[];
|
|
129
|
+
real_enabled: boolean;
|
|
130
|
+
allowance_credits: number;
|
|
131
|
+
used_credits: number;
|
|
132
|
+
remaining_credits: number;
|
|
133
|
+
workspace_role: "owner" | "admin" | "member";
|
|
134
|
+
can_run_real: boolean;
|
|
135
|
+
can_manage_jobs: boolean;
|
|
136
|
+
products: Array<{
|
|
137
|
+
product: QuantumProductId;
|
|
138
|
+
purchased: boolean;
|
|
139
|
+
server_dispatch: boolean;
|
|
140
|
+
available: boolean;
|
|
141
|
+
}>;
|
|
142
|
+
}
|
|
143
|
+
export interface QuantumReasoningJobCreateParams {
|
|
144
|
+
prompt: string;
|
|
145
|
+
model: QuantumReasoningModel;
|
|
146
|
+
product: QuantumProductId;
|
|
147
|
+
provider_connection_id?: string | null;
|
|
148
|
+
workspace_id?: string | null;
|
|
149
|
+
/** At-least 16 characters. Reuse it to retry the same logical create safely. */
|
|
150
|
+
idempotency_key?: string;
|
|
151
|
+
}
|
|
152
|
+
/** One sealed, ML-DSA-65-signed link in a session's provenance chain. */
|
|
153
|
+
export interface ProvenanceLink {
|
|
154
|
+
seq: number;
|
|
155
|
+
sessionId: string;
|
|
156
|
+
prevHash: string;
|
|
157
|
+
/** Digests of the turn — never the raw code/args. */
|
|
158
|
+
action: {
|
|
159
|
+
tool: string;
|
|
160
|
+
argsDigest: string;
|
|
161
|
+
resultDigest: string;
|
|
162
|
+
tier: string;
|
|
163
|
+
};
|
|
164
|
+
issuedAt: string;
|
|
165
|
+
linkHash: string;
|
|
166
|
+
signatureAlgorithm: "ML-DSA-65";
|
|
167
|
+
signatureKeyId: string;
|
|
168
|
+
signature: string;
|
|
169
|
+
}
|
|
170
|
+
/** Result of {@link BeeClient.provenance}.verify — server verdict + re-verifiable chain. */
|
|
171
|
+
export interface ProvenanceResult {
|
|
172
|
+
session_id: string;
|
|
173
|
+
/** Bee's verdict for the whole chain. */
|
|
174
|
+
verified: boolean;
|
|
175
|
+
/** Number of sealed turns. */
|
|
176
|
+
turns: number;
|
|
177
|
+
verification: {
|
|
178
|
+
ok: boolean;
|
|
179
|
+
count: number;
|
|
180
|
+
failedAt?: number;
|
|
181
|
+
reason?: string;
|
|
182
|
+
};
|
|
183
|
+
signature_algorithm: "ML-DSA-65";
|
|
184
|
+
/** SPKI PEM — re-verify every link offline with any FIPS-204 verifier. */
|
|
185
|
+
public_key_pem: string | null;
|
|
186
|
+
chain: ProvenanceLink[];
|
|
187
|
+
}
|
|
188
|
+
/** One metered tier's allowance for the current billing period. */
|
|
189
|
+
export interface UsageAllowance {
|
|
190
|
+
tier: string;
|
|
191
|
+
label: string;
|
|
192
|
+
unit: "requests" | "seconds" | "tokens";
|
|
193
|
+
used: number;
|
|
194
|
+
limit: number;
|
|
195
|
+
remaining: number;
|
|
196
|
+
percent: number;
|
|
197
|
+
overage_behavior: "hard_fail" | "payg" | "contract";
|
|
198
|
+
addons_enabled: boolean;
|
|
199
|
+
}
|
|
200
|
+
/** One Bee tier's share of recent token usage ("what's contributing"). */
|
|
201
|
+
export interface UsageBreakdownTier {
|
|
202
|
+
label: string;
|
|
203
|
+
tokens: number;
|
|
204
|
+
messages: number;
|
|
205
|
+
percent: number;
|
|
206
|
+
}
|
|
207
|
+
/** Result of {@link BeeClient.usage}.retrieve — real account, usage, and breakdown. */
|
|
208
|
+
export interface UsageResponse {
|
|
209
|
+
account: {
|
|
210
|
+
email: string | null;
|
|
211
|
+
plan_id: string;
|
|
212
|
+
plan_name: string;
|
|
213
|
+
organization: string;
|
|
214
|
+
};
|
|
215
|
+
usage: {
|
|
216
|
+
period: "month";
|
|
217
|
+
resets_at: string;
|
|
218
|
+
tokens_used: number;
|
|
219
|
+
tokens_included: number | null;
|
|
220
|
+
messages: number;
|
|
221
|
+
active_days: number;
|
|
222
|
+
credits_usd: number;
|
|
223
|
+
allowances: UsageAllowance[];
|
|
224
|
+
};
|
|
225
|
+
breakdown: {
|
|
226
|
+
window: "day" | "week";
|
|
227
|
+
hours: number;
|
|
228
|
+
total_tokens: number;
|
|
229
|
+
total_messages: number;
|
|
230
|
+
input_percent: number;
|
|
231
|
+
tiers: UsageBreakdownTier[];
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=types.d.ts.map
|