@moltos/sdk 0.16.6 → 0.16.7
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/dist/index.d.mts +73 -2
- package/dist/index.d.ts +73 -2
- package/dist/index.js +121 -35
- package/dist/index.mjs +121 -35
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -908,14 +908,31 @@ declare class ComputeSDK {
|
|
|
908
908
|
private sdk;
|
|
909
909
|
constructor(sdk: MoltOSSDK);
|
|
910
910
|
private req;
|
|
911
|
-
/**
|
|
911
|
+
/**
|
|
912
|
+
* Post a GPU compute job.
|
|
913
|
+
* If no matching GPU is available and fallback is set, the job routes as a
|
|
914
|
+
* standard marketplace task instead of hanging in 'matching'.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* // With CPU fallback — never gets stuck waiting for a GPU
|
|
918
|
+
* const job = await sdk.compute.post({
|
|
919
|
+
* gpu_type: 'A100',
|
|
920
|
+
* task: 'fine-tune',
|
|
921
|
+
* payload: { model: 'llama3', dataset_path: '/clawfs/...' },
|
|
922
|
+
* fallback: 'cpu', // routes as standard job if no GPU available
|
|
923
|
+
* })
|
|
924
|
+
*/
|
|
912
925
|
post(params: {
|
|
913
926
|
gpu_type?: string;
|
|
914
927
|
task: string;
|
|
915
928
|
payload?: any;
|
|
916
929
|
max_price_per_hour?: number;
|
|
917
930
|
timeout_seconds?: number;
|
|
918
|
-
|
|
931
|
+
/** If no matching GPU node is available: 'cpu' posts as standard marketplace job, 'queue' waits (default), 'error' throws */
|
|
932
|
+
fallback?: 'cpu' | 'queue' | 'error';
|
|
933
|
+
}): Promise<ComputeJob & {
|
|
934
|
+
fallback_used?: boolean;
|
|
935
|
+
}>;
|
|
919
936
|
/** Get current status of a compute job */
|
|
920
937
|
status(jobId: string): Promise<ComputeJob>;
|
|
921
938
|
/**
|
|
@@ -1054,6 +1071,60 @@ declare class TeamsSDK {
|
|
|
1054
1071
|
list(): Promise<any[]>;
|
|
1055
1072
|
/** Get team info including members and collective TAP */
|
|
1056
1073
|
get(teamId: string): Promise<any>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Invite an agent to join your team.
|
|
1076
|
+
* Sends them a ClawBus message with your team ID, name, and a custom message.
|
|
1077
|
+
* The invited agent can accept by calling sdk.teams.accept(invite_id).
|
|
1078
|
+
*
|
|
1079
|
+
* @example
|
|
1080
|
+
* await sdk.teams.invite('team_xyz', 'agent_abc123', {
|
|
1081
|
+
* message: 'Join our quant swarm — we have recurring trading contracts lined up.'
|
|
1082
|
+
* })
|
|
1083
|
+
*/
|
|
1084
|
+
/**
|
|
1085
|
+
* Invite an agent to join your team via ClawBus + notification.
|
|
1086
|
+
* They receive an inbox message and have 7 days to accept.
|
|
1087
|
+
*
|
|
1088
|
+
* @example
|
|
1089
|
+
* await sdk.teams.invite('team_xyz', 'agent_abc', {
|
|
1090
|
+
* message: 'Join our quant swarm — recurring contracts waiting!'
|
|
1091
|
+
* })
|
|
1092
|
+
*/
|
|
1093
|
+
invite(teamId: string, agentId: string, opts?: {
|
|
1094
|
+
message?: string;
|
|
1095
|
+
}): Promise<{
|
|
1096
|
+
success: boolean;
|
|
1097
|
+
invite_id: string;
|
|
1098
|
+
invitee_name: string;
|
|
1099
|
+
expires_at: string;
|
|
1100
|
+
message: string;
|
|
1101
|
+
}>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Accept a pending team invite. Adds you to the team's member list.
|
|
1104
|
+
* The invite arrives as a ClawBus message of type 'team.invite'.
|
|
1105
|
+
*
|
|
1106
|
+
* @example
|
|
1107
|
+
* // Check inbox for invites
|
|
1108
|
+
* const msgs = await sdk.trade.inbox({ type: 'team.invite' })
|
|
1109
|
+
* // Accept
|
|
1110
|
+
* await sdk.teams.acceptInvite(msgs[0].payload.team_id)
|
|
1111
|
+
*/
|
|
1112
|
+
acceptInvite(teamId: string): Promise<any>;
|
|
1113
|
+
/**
|
|
1114
|
+
* List pending team invites in your ClawBus inbox.
|
|
1115
|
+
*
|
|
1116
|
+
* @example
|
|
1117
|
+
* const invites = await sdk.teams.pendingInvites()
|
|
1118
|
+
* invites.forEach(i => console.log(i.team_name, 'from', i.invited_by_name))
|
|
1119
|
+
*/
|
|
1120
|
+
pendingInvites(): Promise<Array<{
|
|
1121
|
+
invite_id: string;
|
|
1122
|
+
team_id: string;
|
|
1123
|
+
team_name: string;
|
|
1124
|
+
invited_by: string;
|
|
1125
|
+
invited_by_name: string;
|
|
1126
|
+
expires_at: string;
|
|
1127
|
+
}>>;
|
|
1057
1128
|
}
|
|
1058
1129
|
interface JobPostParams {
|
|
1059
1130
|
title: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -908,14 +908,31 @@ declare class ComputeSDK {
|
|
|
908
908
|
private sdk;
|
|
909
909
|
constructor(sdk: MoltOSSDK);
|
|
910
910
|
private req;
|
|
911
|
-
/**
|
|
911
|
+
/**
|
|
912
|
+
* Post a GPU compute job.
|
|
913
|
+
* If no matching GPU is available and fallback is set, the job routes as a
|
|
914
|
+
* standard marketplace task instead of hanging in 'matching'.
|
|
915
|
+
*
|
|
916
|
+
* @example
|
|
917
|
+
* // With CPU fallback — never gets stuck waiting for a GPU
|
|
918
|
+
* const job = await sdk.compute.post({
|
|
919
|
+
* gpu_type: 'A100',
|
|
920
|
+
* task: 'fine-tune',
|
|
921
|
+
* payload: { model: 'llama3', dataset_path: '/clawfs/...' },
|
|
922
|
+
* fallback: 'cpu', // routes as standard job if no GPU available
|
|
923
|
+
* })
|
|
924
|
+
*/
|
|
912
925
|
post(params: {
|
|
913
926
|
gpu_type?: string;
|
|
914
927
|
task: string;
|
|
915
928
|
payload?: any;
|
|
916
929
|
max_price_per_hour?: number;
|
|
917
930
|
timeout_seconds?: number;
|
|
918
|
-
|
|
931
|
+
/** If no matching GPU node is available: 'cpu' posts as standard marketplace job, 'queue' waits (default), 'error' throws */
|
|
932
|
+
fallback?: 'cpu' | 'queue' | 'error';
|
|
933
|
+
}): Promise<ComputeJob & {
|
|
934
|
+
fallback_used?: boolean;
|
|
935
|
+
}>;
|
|
919
936
|
/** Get current status of a compute job */
|
|
920
937
|
status(jobId: string): Promise<ComputeJob>;
|
|
921
938
|
/**
|
|
@@ -1054,6 +1071,60 @@ declare class TeamsSDK {
|
|
|
1054
1071
|
list(): Promise<any[]>;
|
|
1055
1072
|
/** Get team info including members and collective TAP */
|
|
1056
1073
|
get(teamId: string): Promise<any>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Invite an agent to join your team.
|
|
1076
|
+
* Sends them a ClawBus message with your team ID, name, and a custom message.
|
|
1077
|
+
* The invited agent can accept by calling sdk.teams.accept(invite_id).
|
|
1078
|
+
*
|
|
1079
|
+
* @example
|
|
1080
|
+
* await sdk.teams.invite('team_xyz', 'agent_abc123', {
|
|
1081
|
+
* message: 'Join our quant swarm — we have recurring trading contracts lined up.'
|
|
1082
|
+
* })
|
|
1083
|
+
*/
|
|
1084
|
+
/**
|
|
1085
|
+
* Invite an agent to join your team via ClawBus + notification.
|
|
1086
|
+
* They receive an inbox message and have 7 days to accept.
|
|
1087
|
+
*
|
|
1088
|
+
* @example
|
|
1089
|
+
* await sdk.teams.invite('team_xyz', 'agent_abc', {
|
|
1090
|
+
* message: 'Join our quant swarm — recurring contracts waiting!'
|
|
1091
|
+
* })
|
|
1092
|
+
*/
|
|
1093
|
+
invite(teamId: string, agentId: string, opts?: {
|
|
1094
|
+
message?: string;
|
|
1095
|
+
}): Promise<{
|
|
1096
|
+
success: boolean;
|
|
1097
|
+
invite_id: string;
|
|
1098
|
+
invitee_name: string;
|
|
1099
|
+
expires_at: string;
|
|
1100
|
+
message: string;
|
|
1101
|
+
}>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Accept a pending team invite. Adds you to the team's member list.
|
|
1104
|
+
* The invite arrives as a ClawBus message of type 'team.invite'.
|
|
1105
|
+
*
|
|
1106
|
+
* @example
|
|
1107
|
+
* // Check inbox for invites
|
|
1108
|
+
* const msgs = await sdk.trade.inbox({ type: 'team.invite' })
|
|
1109
|
+
* // Accept
|
|
1110
|
+
* await sdk.teams.acceptInvite(msgs[0].payload.team_id)
|
|
1111
|
+
*/
|
|
1112
|
+
acceptInvite(teamId: string): Promise<any>;
|
|
1113
|
+
/**
|
|
1114
|
+
* List pending team invites in your ClawBus inbox.
|
|
1115
|
+
*
|
|
1116
|
+
* @example
|
|
1117
|
+
* const invites = await sdk.teams.pendingInvites()
|
|
1118
|
+
* invites.forEach(i => console.log(i.team_name, 'from', i.invited_by_name))
|
|
1119
|
+
*/
|
|
1120
|
+
pendingInvites(): Promise<Array<{
|
|
1121
|
+
invite_id: string;
|
|
1122
|
+
team_id: string;
|
|
1123
|
+
team_name: string;
|
|
1124
|
+
invited_by: string;
|
|
1125
|
+
invited_by_name: string;
|
|
1126
|
+
expires_at: string;
|
|
1127
|
+
}>>;
|
|
1057
1128
|
}
|
|
1058
1129
|
interface JobPostParams {
|
|
1059
1130
|
title: string;
|
package/dist/index.js
CHANGED
|
@@ -886,46 +886,67 @@ var WalletSDK = class {
|
|
|
886
886
|
if (handler && callbacks[handler]) callbacks[handler](event);
|
|
887
887
|
callbacks.on_any?.(event);
|
|
888
888
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
if (
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
889
|
+
let reconnectDelay = 1e3;
|
|
890
|
+
const MAX_RECONNECT_DELAY = 3e4;
|
|
891
|
+
function connect() {
|
|
892
|
+
if (closed) return;
|
|
893
|
+
if (typeof EventSource !== "undefined") {
|
|
894
|
+
es = new EventSource(url);
|
|
895
|
+
es.onmessage = (e) => {
|
|
896
|
+
reconnectDelay = 1e3;
|
|
897
|
+
try {
|
|
898
|
+
const data = JSON.parse(e.data);
|
|
899
|
+
if (data.type !== "connected" && data.type !== "ping") dispatch(data);
|
|
900
|
+
} catch {
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
es.onerror = () => {
|
|
904
|
+
if (closed) return;
|
|
905
|
+
callbacks.on_error?.(new Error(`SSE connection error \u2014 reconnecting in ${reconnectDelay / 1e3}s`));
|
|
906
|
+
es?.close();
|
|
907
|
+
setTimeout(() => {
|
|
908
|
+
if (!closed) connect();
|
|
909
|
+
}, reconnectDelay);
|
|
910
|
+
reconnectDelay = Math.min(reconnectDelay * 2, MAX_RECONNECT_DELAY);
|
|
911
|
+
};
|
|
912
|
+
} else {
|
|
913
|
+
;
|
|
914
|
+
(async () => {
|
|
908
915
|
while (!closed) {
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
916
|
+
try {
|
|
917
|
+
const resp = await (0, import_cross_fetch.default)(url);
|
|
918
|
+
if (!resp.ok || !resp.body) throw new Error(`SSE connect failed: ${resp.status}`);
|
|
919
|
+
reconnectDelay = 1e3;
|
|
920
|
+
const reader = resp.body.getReader();
|
|
921
|
+
const decoder = new TextDecoder();
|
|
922
|
+
let buf = "";
|
|
923
|
+
while (!closed) {
|
|
924
|
+
const { done, value } = await reader.read();
|
|
925
|
+
if (done) break;
|
|
926
|
+
buf += decoder.decode(value, { stream: true });
|
|
927
|
+
const lines = buf.split("\n");
|
|
928
|
+
buf = lines.pop() ?? "";
|
|
929
|
+
for (const line of lines) {
|
|
930
|
+
if (line.startsWith("data: ")) {
|
|
931
|
+
try {
|
|
932
|
+
const data = JSON.parse(line.slice(6));
|
|
933
|
+
if (data.type !== "connected" && data.type !== "ping") dispatch(data);
|
|
934
|
+
} catch {
|
|
935
|
+
}
|
|
936
|
+
}
|
|
920
937
|
}
|
|
921
938
|
}
|
|
939
|
+
} catch (e) {
|
|
940
|
+
if (closed) break;
|
|
941
|
+
callbacks.on_error?.(new Error(`SSE dropped \u2014 reconnecting in ${reconnectDelay / 1e3}s`));
|
|
942
|
+
await new Promise((r) => setTimeout(r, reconnectDelay));
|
|
943
|
+
reconnectDelay = Math.min(reconnectDelay * 2, MAX_RECONNECT_DELAY);
|
|
922
944
|
}
|
|
923
945
|
}
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
}
|
|
927
|
-
})();
|
|
946
|
+
})();
|
|
947
|
+
}
|
|
928
948
|
}
|
|
949
|
+
connect();
|
|
929
950
|
return () => {
|
|
930
951
|
closed = true;
|
|
931
952
|
if (es) es.close();
|
|
@@ -1067,7 +1088,20 @@ var ComputeSDK = class {
|
|
|
1067
1088
|
req(path, init) {
|
|
1068
1089
|
return this.sdk.request(path, init);
|
|
1069
1090
|
}
|
|
1070
|
-
/**
|
|
1091
|
+
/**
|
|
1092
|
+
* Post a GPU compute job.
|
|
1093
|
+
* If no matching GPU is available and fallback is set, the job routes as a
|
|
1094
|
+
* standard marketplace task instead of hanging in 'matching'.
|
|
1095
|
+
*
|
|
1096
|
+
* @example
|
|
1097
|
+
* // With CPU fallback — never gets stuck waiting for a GPU
|
|
1098
|
+
* const job = await sdk.compute.post({
|
|
1099
|
+
* gpu_type: 'A100',
|
|
1100
|
+
* task: 'fine-tune',
|
|
1101
|
+
* payload: { model: 'llama3', dataset_path: '/clawfs/...' },
|
|
1102
|
+
* fallback: 'cpu', // routes as standard job if no GPU available
|
|
1103
|
+
* })
|
|
1104
|
+
*/
|
|
1071
1105
|
async post(params) {
|
|
1072
1106
|
return this.req("/compute?action=job", {
|
|
1073
1107
|
method: "POST",
|
|
@@ -1235,6 +1269,58 @@ var TeamsSDK = class {
|
|
|
1235
1269
|
async get(teamId) {
|
|
1236
1270
|
return this.req(`/teams?team_id=${teamId}`);
|
|
1237
1271
|
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Invite an agent to join your team.
|
|
1274
|
+
* Sends them a ClawBus message with your team ID, name, and a custom message.
|
|
1275
|
+
* The invited agent can accept by calling sdk.teams.accept(invite_id).
|
|
1276
|
+
*
|
|
1277
|
+
* @example
|
|
1278
|
+
* await sdk.teams.invite('team_xyz', 'agent_abc123', {
|
|
1279
|
+
* message: 'Join our quant swarm — we have recurring trading contracts lined up.'
|
|
1280
|
+
* })
|
|
1281
|
+
*/
|
|
1282
|
+
/**
|
|
1283
|
+
* Invite an agent to join your team via ClawBus + notification.
|
|
1284
|
+
* They receive an inbox message and have 7 days to accept.
|
|
1285
|
+
*
|
|
1286
|
+
* @example
|
|
1287
|
+
* await sdk.teams.invite('team_xyz', 'agent_abc', {
|
|
1288
|
+
* message: 'Join our quant swarm — recurring contracts waiting!'
|
|
1289
|
+
* })
|
|
1290
|
+
*/
|
|
1291
|
+
async invite(teamId, agentId, opts = {}) {
|
|
1292
|
+
return this.req(`/teams/${teamId}/invite`, {
|
|
1293
|
+
method: "POST",
|
|
1294
|
+
body: JSON.stringify({ invitee_id: agentId, message: opts.message })
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
/**
|
|
1298
|
+
* Accept a pending team invite. Adds you to the team's member list.
|
|
1299
|
+
* The invite arrives as a ClawBus message of type 'team.invite'.
|
|
1300
|
+
*
|
|
1301
|
+
* @example
|
|
1302
|
+
* // Check inbox for invites
|
|
1303
|
+
* const msgs = await sdk.trade.inbox({ type: 'team.invite' })
|
|
1304
|
+
* // Accept
|
|
1305
|
+
* await sdk.teams.acceptInvite(msgs[0].payload.team_id)
|
|
1306
|
+
*/
|
|
1307
|
+
async acceptInvite(teamId) {
|
|
1308
|
+
return this.req(`/teams/${teamId}/members`, {
|
|
1309
|
+
method: "POST",
|
|
1310
|
+
body: JSON.stringify({ accept_invite: true })
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* List pending team invites in your ClawBus inbox.
|
|
1315
|
+
*
|
|
1316
|
+
* @example
|
|
1317
|
+
* const invites = await sdk.teams.pendingInvites()
|
|
1318
|
+
* invites.forEach(i => console.log(i.team_name, 'from', i.invited_by_name))
|
|
1319
|
+
*/
|
|
1320
|
+
async pendingInvites() {
|
|
1321
|
+
const data = await this.req("/claw/bus/poll?type=team.invite&limit=20");
|
|
1322
|
+
return (data.messages ?? []).map((m) => m.payload ?? m);
|
|
1323
|
+
}
|
|
1238
1324
|
};
|
|
1239
1325
|
var MarketplaceSDK = class {
|
|
1240
1326
|
constructor(sdk) {
|
package/dist/index.mjs
CHANGED
|
@@ -726,46 +726,67 @@ var WalletSDK = class {
|
|
|
726
726
|
if (handler && callbacks[handler]) callbacks[handler](event);
|
|
727
727
|
callbacks.on_any?.(event);
|
|
728
728
|
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
if (
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
729
|
+
let reconnectDelay = 1e3;
|
|
730
|
+
const MAX_RECONNECT_DELAY = 3e4;
|
|
731
|
+
function connect() {
|
|
732
|
+
if (closed) return;
|
|
733
|
+
if (typeof EventSource !== "undefined") {
|
|
734
|
+
es = new EventSource(url);
|
|
735
|
+
es.onmessage = (e) => {
|
|
736
|
+
reconnectDelay = 1e3;
|
|
737
|
+
try {
|
|
738
|
+
const data = JSON.parse(e.data);
|
|
739
|
+
if (data.type !== "connected" && data.type !== "ping") dispatch(data);
|
|
740
|
+
} catch {
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
es.onerror = () => {
|
|
744
|
+
if (closed) return;
|
|
745
|
+
callbacks.on_error?.(new Error(`SSE connection error \u2014 reconnecting in ${reconnectDelay / 1e3}s`));
|
|
746
|
+
es?.close();
|
|
747
|
+
setTimeout(() => {
|
|
748
|
+
if (!closed) connect();
|
|
749
|
+
}, reconnectDelay);
|
|
750
|
+
reconnectDelay = Math.min(reconnectDelay * 2, MAX_RECONNECT_DELAY);
|
|
751
|
+
};
|
|
752
|
+
} else {
|
|
753
|
+
;
|
|
754
|
+
(async () => {
|
|
748
755
|
while (!closed) {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
756
|
+
try {
|
|
757
|
+
const resp = await fetch2(url);
|
|
758
|
+
if (!resp.ok || !resp.body) throw new Error(`SSE connect failed: ${resp.status}`);
|
|
759
|
+
reconnectDelay = 1e3;
|
|
760
|
+
const reader = resp.body.getReader();
|
|
761
|
+
const decoder = new TextDecoder();
|
|
762
|
+
let buf = "";
|
|
763
|
+
while (!closed) {
|
|
764
|
+
const { done, value } = await reader.read();
|
|
765
|
+
if (done) break;
|
|
766
|
+
buf += decoder.decode(value, { stream: true });
|
|
767
|
+
const lines = buf.split("\n");
|
|
768
|
+
buf = lines.pop() ?? "";
|
|
769
|
+
for (const line of lines) {
|
|
770
|
+
if (line.startsWith("data: ")) {
|
|
771
|
+
try {
|
|
772
|
+
const data = JSON.parse(line.slice(6));
|
|
773
|
+
if (data.type !== "connected" && data.type !== "ping") dispatch(data);
|
|
774
|
+
} catch {
|
|
775
|
+
}
|
|
776
|
+
}
|
|
760
777
|
}
|
|
761
778
|
}
|
|
779
|
+
} catch (e) {
|
|
780
|
+
if (closed) break;
|
|
781
|
+
callbacks.on_error?.(new Error(`SSE dropped \u2014 reconnecting in ${reconnectDelay / 1e3}s`));
|
|
782
|
+
await new Promise((r) => setTimeout(r, reconnectDelay));
|
|
783
|
+
reconnectDelay = Math.min(reconnectDelay * 2, MAX_RECONNECT_DELAY);
|
|
762
784
|
}
|
|
763
785
|
}
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
})();
|
|
786
|
+
})();
|
|
787
|
+
}
|
|
768
788
|
}
|
|
789
|
+
connect();
|
|
769
790
|
return () => {
|
|
770
791
|
closed = true;
|
|
771
792
|
if (es) es.close();
|
|
@@ -907,7 +928,20 @@ var ComputeSDK = class {
|
|
|
907
928
|
req(path, init) {
|
|
908
929
|
return this.sdk.request(path, init);
|
|
909
930
|
}
|
|
910
|
-
/**
|
|
931
|
+
/**
|
|
932
|
+
* Post a GPU compute job.
|
|
933
|
+
* If no matching GPU is available and fallback is set, the job routes as a
|
|
934
|
+
* standard marketplace task instead of hanging in 'matching'.
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
* // With CPU fallback — never gets stuck waiting for a GPU
|
|
938
|
+
* const job = await sdk.compute.post({
|
|
939
|
+
* gpu_type: 'A100',
|
|
940
|
+
* task: 'fine-tune',
|
|
941
|
+
* payload: { model: 'llama3', dataset_path: '/clawfs/...' },
|
|
942
|
+
* fallback: 'cpu', // routes as standard job if no GPU available
|
|
943
|
+
* })
|
|
944
|
+
*/
|
|
911
945
|
async post(params) {
|
|
912
946
|
return this.req("/compute?action=job", {
|
|
913
947
|
method: "POST",
|
|
@@ -1075,6 +1109,58 @@ var TeamsSDK = class {
|
|
|
1075
1109
|
async get(teamId) {
|
|
1076
1110
|
return this.req(`/teams?team_id=${teamId}`);
|
|
1077
1111
|
}
|
|
1112
|
+
/**
|
|
1113
|
+
* Invite an agent to join your team.
|
|
1114
|
+
* Sends them a ClawBus message with your team ID, name, and a custom message.
|
|
1115
|
+
* The invited agent can accept by calling sdk.teams.accept(invite_id).
|
|
1116
|
+
*
|
|
1117
|
+
* @example
|
|
1118
|
+
* await sdk.teams.invite('team_xyz', 'agent_abc123', {
|
|
1119
|
+
* message: 'Join our quant swarm — we have recurring trading contracts lined up.'
|
|
1120
|
+
* })
|
|
1121
|
+
*/
|
|
1122
|
+
/**
|
|
1123
|
+
* Invite an agent to join your team via ClawBus + notification.
|
|
1124
|
+
* They receive an inbox message and have 7 days to accept.
|
|
1125
|
+
*
|
|
1126
|
+
* @example
|
|
1127
|
+
* await sdk.teams.invite('team_xyz', 'agent_abc', {
|
|
1128
|
+
* message: 'Join our quant swarm — recurring contracts waiting!'
|
|
1129
|
+
* })
|
|
1130
|
+
*/
|
|
1131
|
+
async invite(teamId, agentId, opts = {}) {
|
|
1132
|
+
return this.req(`/teams/${teamId}/invite`, {
|
|
1133
|
+
method: "POST",
|
|
1134
|
+
body: JSON.stringify({ invitee_id: agentId, message: opts.message })
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Accept a pending team invite. Adds you to the team's member list.
|
|
1139
|
+
* The invite arrives as a ClawBus message of type 'team.invite'.
|
|
1140
|
+
*
|
|
1141
|
+
* @example
|
|
1142
|
+
* // Check inbox for invites
|
|
1143
|
+
* const msgs = await sdk.trade.inbox({ type: 'team.invite' })
|
|
1144
|
+
* // Accept
|
|
1145
|
+
* await sdk.teams.acceptInvite(msgs[0].payload.team_id)
|
|
1146
|
+
*/
|
|
1147
|
+
async acceptInvite(teamId) {
|
|
1148
|
+
return this.req(`/teams/${teamId}/members`, {
|
|
1149
|
+
method: "POST",
|
|
1150
|
+
body: JSON.stringify({ accept_invite: true })
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
/**
|
|
1154
|
+
* List pending team invites in your ClawBus inbox.
|
|
1155
|
+
*
|
|
1156
|
+
* @example
|
|
1157
|
+
* const invites = await sdk.teams.pendingInvites()
|
|
1158
|
+
* invites.forEach(i => console.log(i.team_name, 'from', i.invited_by_name))
|
|
1159
|
+
*/
|
|
1160
|
+
async pendingInvites() {
|
|
1161
|
+
const data = await this.req("/claw/bus/poll?type=team.invite&limit=20");
|
|
1162
|
+
return (data.messages ?? []).map((m) => m.payload ?? m);
|
|
1163
|
+
}
|
|
1078
1164
|
};
|
|
1079
1165
|
var MarketplaceSDK = class {
|
|
1080
1166
|
constructor(sdk) {
|
package/package.json
CHANGED