macrocosmos 1.4.2 → 2.0.0
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 +0 -40
- package/dist/README.md +0 -40
- package/dist/__tests__/sn13/client.test.js +10 -4
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +1 -2
- package/dist/generated/billing/v1/billing.d.ts +97 -5
- package/dist/generated/billing/v1/billing.js +547 -3
- package/dist/generated/google/protobuf/empty.js +1 -1
- package/dist/generated/google/protobuf/struct.js +1 -1
- package/dist/generated/google/protobuf/timestamp.d.ts +7 -6
- package/dist/generated/google/protobuf/timestamp.js +1 -1
- package/dist/generated/gravity/v1/gravity.d.ts +408 -14
- package/dist/generated/gravity/v1/gravity.js +3867 -2102
- package/dist/generated/logger/v1/logger.js +1 -1
- package/dist/generated/sn13/v1/sn13_validator.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +9 -4
- package/dist/__tests__/apex/client-chat.test.d.ts +0 -1
- package/dist/__tests__/apex/client-chat.test.js +0 -324
- package/dist/__tests__/apex/client-web-search.test.d.ts +0 -1
- package/dist/__tests__/apex/client-web-search.test.js +0 -38
- package/dist/generated/apex/v1/apex.d.ts +0 -941
- package/dist/generated/apex/v1/apex.js +0 -5422
- package/dist/lib/apex/Client.d.ts +0 -104
- package/dist/lib/apex/Client.js +0 -444
- package/dist/lib/apex/Stream.d.ts +0 -31
- package/dist/lib/apex/Stream.js +0 -162
- package/dist/lib/apex/index.d.ts +0 -2
- package/dist/lib/apex/index.js +0 -19
package/README.md
CHANGED
|
@@ -10,46 +10,6 @@ npm install macrocosmos
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
### Apex Client
|
|
14
|
-
|
|
15
|
-
The Apex client provides an interface for accessing the Apex API for chat completions, web search and deep research.
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import { ApexClient } from 'macrocosmos';
|
|
19
|
-
|
|
20
|
-
// Initialize the client
|
|
21
|
-
const client = new ApexClient({ apiKey: 'your-api-key' });
|
|
22
|
-
|
|
23
|
-
// Chat completions
|
|
24
|
-
const response = await client.chat.completions.create({
|
|
25
|
-
messages: [
|
|
26
|
-
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
27
|
-
{ role: 'user', content: 'Hello, how are you?' }
|
|
28
|
-
],
|
|
29
|
-
stream: true
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Web retrieval
|
|
33
|
-
const webResults = await client.webRetrieval({
|
|
34
|
-
query: 'latest news about AI'
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Deep Researcher
|
|
38
|
-
|
|
39
|
-
// Submit a deep research job
|
|
40
|
-
const submittedJob = await client.submitDeepResearcherJob({
|
|
41
|
-
messages: [
|
|
42
|
-
{ role: "user",
|
|
43
|
-
content: `Can you propose a mechanism by which a decentralized network
|
|
44
|
-
of AI agents could achieve provable alignment on abstract ethical principles
|
|
45
|
-
without relying on human-defined ontologies or centralized arbitration?`},
|
|
46
|
-
],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Get the results of a deep research job
|
|
50
|
-
const polledJobResult = await client.getDeepResearcherJob({jobId: submittedJob.jobId});
|
|
51
|
-
```
|
|
52
|
-
|
|
53
13
|
### Gravity Client
|
|
54
14
|
|
|
55
15
|
The Gravity client provides an interface for data collection and dataset management.
|
package/dist/README.md
CHANGED
|
@@ -10,46 +10,6 @@ npm install macrocosmos
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
### Apex Client
|
|
14
|
-
|
|
15
|
-
The Apex client provides an interface for accessing the Apex API for chat completions, web search and deep research.
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import { ApexClient } from 'macrocosmos';
|
|
19
|
-
|
|
20
|
-
// Initialize the client
|
|
21
|
-
const client = new ApexClient({ apiKey: 'your-api-key' });
|
|
22
|
-
|
|
23
|
-
// Chat completions
|
|
24
|
-
const response = await client.chat.completions.create({
|
|
25
|
-
messages: [
|
|
26
|
-
{ role: 'system', content: 'You are a helpful assistant.' },
|
|
27
|
-
{ role: 'user', content: 'Hello, how are you?' }
|
|
28
|
-
],
|
|
29
|
-
stream: true
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Web retrieval
|
|
33
|
-
const webResults = await client.webRetrieval({
|
|
34
|
-
query: 'latest news about AI'
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// Deep Researcher
|
|
38
|
-
|
|
39
|
-
// Submit a deep research job
|
|
40
|
-
const submittedJob = await client.submitDeepResearcherJob({
|
|
41
|
-
messages: [
|
|
42
|
-
{ role: "user",
|
|
43
|
-
content: `Can you propose a mechanism by which a decentralized network
|
|
44
|
-
of AI agents could achieve provable alignment on abstract ethical principles
|
|
45
|
-
without relying on human-defined ontologies or centralized arbitration?`},
|
|
46
|
-
],
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// Get the results of a deep research job
|
|
50
|
-
const polledJobResult = await client.getDeepResearcherJob({jobId: submittedJob.jobId});
|
|
51
|
-
```
|
|
52
|
-
|
|
53
13
|
### Gravity Client
|
|
54
14
|
|
|
55
15
|
The Gravity client provides an interface for data collection and dataset management.
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const macrocosmos_1 = require("macrocosmos");
|
|
4
|
+
const endDate = new Date();
|
|
5
|
+
const startDate = new Date();
|
|
6
|
+
startDate.setDate(startDate.getDate() - 7);
|
|
7
|
+
// format as "YYYY-MM-DD"
|
|
8
|
+
const formattedStartDate = startDate.toISOString().split("T")[0];
|
|
9
|
+
const formattedEndDate = endDate.toISOString().split("T")[0];
|
|
4
10
|
describe("Sn13Client", () => {
|
|
5
11
|
const API_KEY = process.env.MACROCOSMOS_API_KEY;
|
|
6
12
|
if (!API_KEY) {
|
|
@@ -39,8 +45,8 @@ describe("Sn13Client", () => {
|
|
|
39
45
|
source: "x",
|
|
40
46
|
usernames: ["nasa", "spacex"],
|
|
41
47
|
keywords: ["photo", "space", "mars"],
|
|
42
|
-
startDate:
|
|
43
|
-
endDate:
|
|
48
|
+
startDate: formattedStartDate,
|
|
49
|
+
endDate: formattedEndDate,
|
|
44
50
|
limit: 3,
|
|
45
51
|
};
|
|
46
52
|
// Fetch on-demand data
|
|
@@ -65,8 +71,8 @@ describe("Sn13Client", () => {
|
|
|
65
71
|
source: "x",
|
|
66
72
|
usernames: ["nasa", "spacex"],
|
|
67
73
|
keywords: ["photo", "space", "mars"],
|
|
68
|
-
startDate:
|
|
69
|
-
endDate:
|
|
74
|
+
startDate: formattedStartDate,
|
|
75
|
+
endDate: formattedEndDate,
|
|
70
76
|
limit: 3,
|
|
71
77
|
keywordMode: "any",
|
|
72
78
|
};
|
package/dist/constants.d.ts
CHANGED
package/dist/constants.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GRAVITY_API_KEY = exports.
|
|
3
|
+
exports.GRAVITY_API_KEY = exports.BASE_URL = exports.CLIENT_NAME = exports.VERSION = void 0;
|
|
4
4
|
var version_1 = require("./version");
|
|
5
5
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
|
6
6
|
// Package name for the SDK
|
|
7
7
|
exports.CLIENT_NAME = "macrocosmos-ts-sdk";
|
|
8
8
|
exports.BASE_URL = process.env.MACROCOSMOS_BASE_URL || "constellation.api.cloud.macrocosmos.ai";
|
|
9
|
-
exports.APEX_API_KEY = process.env.APEX_API_KEY || process.env.MACROCOSMOS_API_KEY;
|
|
10
9
|
exports.GRAVITY_API_KEY = process.env.GRAVITY_API_KEY || process.env.MACROCOSMOS_API_KEY;
|
|
@@ -6,9 +6,9 @@ export interface GetUsageRequest {
|
|
|
6
6
|
/** product_type: the type of the product (i.e. "gravity") */
|
|
7
7
|
productType?: string | undefined;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
9
|
+
/** BillingRate is the billing rate for a product */
|
|
10
10
|
export interface BillingRate {
|
|
11
|
-
/**
|
|
11
|
+
/** rate_type: the type of the billing rate (i.e. "gravity") */
|
|
12
12
|
rateType: string;
|
|
13
13
|
/** unit_size: the size of the unit of the subscription (e.g. 1000, 10000, 100000) */
|
|
14
14
|
unitSize: number;
|
|
@@ -19,6 +19,21 @@ export interface BillingRate {
|
|
|
19
19
|
/** currency: the currency of the subscription */
|
|
20
20
|
currency: string;
|
|
21
21
|
}
|
|
22
|
+
/** SubscriptionInfo contains the active subscription details */
|
|
23
|
+
export interface SubscriptionInfo {
|
|
24
|
+
/** external_id: the external ID of the subscription */
|
|
25
|
+
externalId: string;
|
|
26
|
+
/** plan_code: the plan code of the subscription */
|
|
27
|
+
planCode: string;
|
|
28
|
+
/** plan_tier: the tier of the plan (0=Free, 1=Astronaut, 2=Cosmonaut) */
|
|
29
|
+
planTier: number;
|
|
30
|
+
/** free_allowance_usd: the total free allowance in USD per month for the active subscription */
|
|
31
|
+
freeAllowanceUsd: number;
|
|
32
|
+
/** free_allowance_remaining_usd: the remaining free allowance in USD for the current period */
|
|
33
|
+
freeAllowanceRemainingUsd: number;
|
|
34
|
+
/** usage_in_usd: the current usage amount in USD for the billing period */
|
|
35
|
+
usageInUsd: number;
|
|
36
|
+
}
|
|
22
37
|
/** GetUsageResponse is the response message for getting the usage of the user's credits */
|
|
23
38
|
export interface GetUsageResponse {
|
|
24
39
|
/** available_credits: the number of credits available to the user */
|
|
@@ -29,13 +44,58 @@ export interface GetUsageResponse {
|
|
|
29
44
|
remainingCredits: number;
|
|
30
45
|
/** subscription: the subscription that the user has */
|
|
31
46
|
billingRates: BillingRate[];
|
|
47
|
+
/** active_subscription: the currently active subscription */
|
|
48
|
+
activeSubscription?: SubscriptionInfo | undefined;
|
|
49
|
+
}
|
|
50
|
+
/** ChargeUserForUsageRequest is the request message for charging a user for usage */
|
|
51
|
+
export interface ChargeUserForUsageRequest {
|
|
52
|
+
/** transaction_id: unique identifier for this transaction */
|
|
53
|
+
transactionId: string;
|
|
54
|
+
/** channel: the gravity service channel ("dataset" or "on_demand") */
|
|
55
|
+
channel: string;
|
|
56
|
+
/** rows: the number of rows to charge for (can be negative for refunds) */
|
|
57
|
+
rows: number;
|
|
58
|
+
}
|
|
59
|
+
/** ChargeUserForUsageResponse is the response message for charging a user for usage */
|
|
60
|
+
export interface ChargeUserForUsageResponse {
|
|
61
|
+
/** charge_cents: the amount charged in cents */
|
|
62
|
+
chargeCents: number;
|
|
63
|
+
/** transaction_id: the transaction ID */
|
|
64
|
+
transactionId: string;
|
|
65
|
+
/** channel: the channel that was charged */
|
|
66
|
+
channel: string;
|
|
67
|
+
/** rows: the number of rows charged */
|
|
68
|
+
rows: number;
|
|
69
|
+
}
|
|
70
|
+
/** UserHasEnoughAllowanceAndCreditsRequest is the request message for checking if a user has enough allowance and credits */
|
|
71
|
+
export interface UserHasEnoughAllowanceAndCreditsRequest {
|
|
72
|
+
/** channel: the gravity service channel ("dataset" or "on_demand") */
|
|
73
|
+
channel: string;
|
|
74
|
+
/** rows: the number of rows to check for */
|
|
75
|
+
rows: number;
|
|
76
|
+
}
|
|
77
|
+
/** UserHasEnoughAllowanceAndCreditsResponse is the response message for checking if a user has enough allowance and credits */
|
|
78
|
+
export interface UserHasEnoughAllowanceAndCreditsResponse {
|
|
79
|
+
/** has_enough: whether the user has enough allowance and credits */
|
|
80
|
+
hasEnough: boolean;
|
|
81
|
+
/** charge_cents: the amount that would be charged in cents */
|
|
82
|
+
chargeCents: number;
|
|
83
|
+
/** channel: the channel that would be charged */
|
|
84
|
+
channel: string;
|
|
85
|
+
/** rows: the number of rows that would be charged */
|
|
86
|
+
rows: number;
|
|
32
87
|
}
|
|
33
88
|
export declare const GetUsageRequest: MessageFns<GetUsageRequest>;
|
|
34
89
|
export declare const BillingRate: MessageFns<BillingRate>;
|
|
90
|
+
export declare const SubscriptionInfo: MessageFns<SubscriptionInfo>;
|
|
35
91
|
export declare const GetUsageResponse: MessageFns<GetUsageResponse>;
|
|
92
|
+
export declare const ChargeUserForUsageRequest: MessageFns<ChargeUserForUsageRequest>;
|
|
93
|
+
export declare const ChargeUserForUsageResponse: MessageFns<ChargeUserForUsageResponse>;
|
|
94
|
+
export declare const UserHasEnoughAllowanceAndCreditsRequest: MessageFns<UserHasEnoughAllowanceAndCreditsRequest>;
|
|
95
|
+
export declare const UserHasEnoughAllowanceAndCreditsResponse: MessageFns<UserHasEnoughAllowanceAndCreditsResponse>;
|
|
36
96
|
export type BillingServiceService = typeof BillingServiceService;
|
|
37
97
|
export declare const BillingServiceService: {
|
|
38
|
-
/** Get the usage of the user's credits */
|
|
98
|
+
/** Get the usage of the user's credits with subscription-aware billing */
|
|
39
99
|
readonly getUsage: {
|
|
40
100
|
readonly path: "/billing.v1.BillingService/GetUsage";
|
|
41
101
|
readonly requestStream: false;
|
|
@@ -45,16 +105,48 @@ export declare const BillingServiceService: {
|
|
|
45
105
|
readonly responseSerialize: (value: GetUsageResponse) => Buffer<ArrayBuffer>;
|
|
46
106
|
readonly responseDeserialize: (value: Buffer) => GetUsageResponse;
|
|
47
107
|
};
|
|
108
|
+
/** ChargeUserForUsage charges a user for gravity data usage (testing endpoint) */
|
|
109
|
+
readonly chargeUserForUsage: {
|
|
110
|
+
readonly path: "/billing.v1.BillingService/ChargeUserForUsage";
|
|
111
|
+
readonly requestStream: false;
|
|
112
|
+
readonly responseStream: false;
|
|
113
|
+
readonly requestSerialize: (value: ChargeUserForUsageRequest) => Buffer<ArrayBuffer>;
|
|
114
|
+
readonly requestDeserialize: (value: Buffer) => ChargeUserForUsageRequest;
|
|
115
|
+
readonly responseSerialize: (value: ChargeUserForUsageResponse) => Buffer<ArrayBuffer>;
|
|
116
|
+
readonly responseDeserialize: (value: Buffer) => ChargeUserForUsageResponse;
|
|
117
|
+
};
|
|
118
|
+
/** Check if a user has enough allowance and credits to cover a charge (testing endpoint) */
|
|
119
|
+
readonly userHasEnoughAllowanceAndCredits: {
|
|
120
|
+
readonly path: "/billing.v1.BillingService/UserHasEnoughAllowanceAndCredits";
|
|
121
|
+
readonly requestStream: false;
|
|
122
|
+
readonly responseStream: false;
|
|
123
|
+
readonly requestSerialize: (value: UserHasEnoughAllowanceAndCreditsRequest) => Buffer<ArrayBuffer>;
|
|
124
|
+
readonly requestDeserialize: (value: Buffer) => UserHasEnoughAllowanceAndCreditsRequest;
|
|
125
|
+
readonly responseSerialize: (value: UserHasEnoughAllowanceAndCreditsResponse) => Buffer<ArrayBuffer>;
|
|
126
|
+
readonly responseDeserialize: (value: Buffer) => UserHasEnoughAllowanceAndCreditsResponse;
|
|
127
|
+
};
|
|
48
128
|
};
|
|
49
129
|
export interface BillingServiceServer extends UntypedServiceImplementation {
|
|
50
|
-
/** Get the usage of the user's credits */
|
|
130
|
+
/** Get the usage of the user's credits with subscription-aware billing */
|
|
51
131
|
getUsage: handleUnaryCall<GetUsageRequest, GetUsageResponse>;
|
|
132
|
+
/** ChargeUserForUsage charges a user for gravity data usage (testing endpoint) */
|
|
133
|
+
chargeUserForUsage: handleUnaryCall<ChargeUserForUsageRequest, ChargeUserForUsageResponse>;
|
|
134
|
+
/** Check if a user has enough allowance and credits to cover a charge (testing endpoint) */
|
|
135
|
+
userHasEnoughAllowanceAndCredits: handleUnaryCall<UserHasEnoughAllowanceAndCreditsRequest, UserHasEnoughAllowanceAndCreditsResponse>;
|
|
52
136
|
}
|
|
53
137
|
export interface BillingServiceClient extends Client {
|
|
54
|
-
/** Get the usage of the user's credits */
|
|
138
|
+
/** Get the usage of the user's credits with subscription-aware billing */
|
|
55
139
|
getUsage(request: GetUsageRequest, callback: (error: ServiceError | null, response: GetUsageResponse) => void): ClientUnaryCall;
|
|
56
140
|
getUsage(request: GetUsageRequest, metadata: Metadata, callback: (error: ServiceError | null, response: GetUsageResponse) => void): ClientUnaryCall;
|
|
57
141
|
getUsage(request: GetUsageRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: GetUsageResponse) => void): ClientUnaryCall;
|
|
142
|
+
/** ChargeUserForUsage charges a user for gravity data usage (testing endpoint) */
|
|
143
|
+
chargeUserForUsage(request: ChargeUserForUsageRequest, callback: (error: ServiceError | null, response: ChargeUserForUsageResponse) => void): ClientUnaryCall;
|
|
144
|
+
chargeUserForUsage(request: ChargeUserForUsageRequest, metadata: Metadata, callback: (error: ServiceError | null, response: ChargeUserForUsageResponse) => void): ClientUnaryCall;
|
|
145
|
+
chargeUserForUsage(request: ChargeUserForUsageRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: ChargeUserForUsageResponse) => void): ClientUnaryCall;
|
|
146
|
+
/** Check if a user has enough allowance and credits to cover a charge (testing endpoint) */
|
|
147
|
+
userHasEnoughAllowanceAndCredits(request: UserHasEnoughAllowanceAndCreditsRequest, callback: (error: ServiceError | null, response: UserHasEnoughAllowanceAndCreditsResponse) => void): ClientUnaryCall;
|
|
148
|
+
userHasEnoughAllowanceAndCredits(request: UserHasEnoughAllowanceAndCreditsRequest, metadata: Metadata, callback: (error: ServiceError | null, response: UserHasEnoughAllowanceAndCreditsResponse) => void): ClientUnaryCall;
|
|
149
|
+
userHasEnoughAllowanceAndCredits(request: UserHasEnoughAllowanceAndCreditsRequest, metadata: Metadata, options: Partial<CallOptions>, callback: (error: ServiceError | null, response: UserHasEnoughAllowanceAndCreditsResponse) => void): ClientUnaryCall;
|
|
58
150
|
}
|
|
59
151
|
export declare const BillingServiceClient: {
|
|
60
152
|
new (address: string, credentials: ChannelCredentials, options?: Partial<ClientOptions>): BillingServiceClient;
|