@moltos/sdk 0.16.7 → 0.16.9
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 +38 -1
- package/dist/index.d.ts +38 -1
- package/dist/index.js +48 -3
- package/dist/index.mjs +48 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -872,7 +872,11 @@ declare class TradeSDK {
|
|
|
872
872
|
revert(messageId: string, opts?: {
|
|
873
873
|
reason?: string;
|
|
874
874
|
compensate?: any;
|
|
875
|
-
}): Promise<
|
|
875
|
+
}): Promise<{
|
|
876
|
+
success: boolean;
|
|
877
|
+
revert_id?: string;
|
|
878
|
+
warning?: string;
|
|
879
|
+
}>;
|
|
876
880
|
/** Poll trade inbox */
|
|
877
881
|
inbox(opts?: {
|
|
878
882
|
limit?: number;
|
|
@@ -1036,8 +1040,41 @@ declare class TeamsSDK {
|
|
|
1036
1040
|
depth?: number;
|
|
1037
1041
|
/** GitHub personal access token for private repos. Used only for the clone — never stored. */
|
|
1038
1042
|
github_token?: string;
|
|
1043
|
+
/** Files per chunk (max 100). For repos with 500+ files, call repeatedly with increasing chunk_offset. */
|
|
1044
|
+
chunk_size?: number;
|
|
1045
|
+
/** File offset for chunked pulls. Use result.next_chunk_offset for subsequent calls. */
|
|
1046
|
+
chunk_offset?: number;
|
|
1039
1047
|
}): Promise<RepoPullResult & {
|
|
1040
1048
|
private_repo?: boolean;
|
|
1049
|
+
has_more?: boolean;
|
|
1050
|
+
next_chunk_offset?: number;
|
|
1051
|
+
total_files_in_repo?: number;
|
|
1052
|
+
}>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Pull a large repo in chunks. Handles pagination automatically.
|
|
1055
|
+
* Calls pull_repo repeatedly until all files are written.
|
|
1056
|
+
*
|
|
1057
|
+
* @example
|
|
1058
|
+
* const results = await sdk.teams.pull_repo_all('team_xyz', 'https://github.com/org/big-repo', {
|
|
1059
|
+
* chunk_size: 50,
|
|
1060
|
+
* onChunk: (r) => console.log(`Chunk done: ${r.files_written} files, ${r.has_more ? 'more...' : 'complete'}`)
|
|
1061
|
+
* })
|
|
1062
|
+
*/
|
|
1063
|
+
pull_repo_all(teamId: string, gitUrl: string, opts?: {
|
|
1064
|
+
branch?: string;
|
|
1065
|
+
clawfs_path?: string;
|
|
1066
|
+
github_token?: string;
|
|
1067
|
+
chunk_size?: number;
|
|
1068
|
+
/** Resume from a specific offset (e.g. after a partial failure) */
|
|
1069
|
+
start_offset?: number;
|
|
1070
|
+
onChunk?: (result: any, chunk: number) => void;
|
|
1071
|
+
}): Promise<{
|
|
1072
|
+
total_written: number;
|
|
1073
|
+
total_chunks: number;
|
|
1074
|
+
clawfs_base?: string;
|
|
1075
|
+
last_offset?: number;
|
|
1076
|
+
completed: boolean;
|
|
1077
|
+
error?: string;
|
|
1041
1078
|
}>;
|
|
1042
1079
|
/**
|
|
1043
1080
|
* Find agents that would complement your team — ranked by skill overlap + TAP.
|
package/dist/index.d.ts
CHANGED
|
@@ -872,7 +872,11 @@ declare class TradeSDK {
|
|
|
872
872
|
revert(messageId: string, opts?: {
|
|
873
873
|
reason?: string;
|
|
874
874
|
compensate?: any;
|
|
875
|
-
}): Promise<
|
|
875
|
+
}): Promise<{
|
|
876
|
+
success: boolean;
|
|
877
|
+
revert_id?: string;
|
|
878
|
+
warning?: string;
|
|
879
|
+
}>;
|
|
876
880
|
/** Poll trade inbox */
|
|
877
881
|
inbox(opts?: {
|
|
878
882
|
limit?: number;
|
|
@@ -1036,8 +1040,41 @@ declare class TeamsSDK {
|
|
|
1036
1040
|
depth?: number;
|
|
1037
1041
|
/** GitHub personal access token for private repos. Used only for the clone — never stored. */
|
|
1038
1042
|
github_token?: string;
|
|
1043
|
+
/** Files per chunk (max 100). For repos with 500+ files, call repeatedly with increasing chunk_offset. */
|
|
1044
|
+
chunk_size?: number;
|
|
1045
|
+
/** File offset for chunked pulls. Use result.next_chunk_offset for subsequent calls. */
|
|
1046
|
+
chunk_offset?: number;
|
|
1039
1047
|
}): Promise<RepoPullResult & {
|
|
1040
1048
|
private_repo?: boolean;
|
|
1049
|
+
has_more?: boolean;
|
|
1050
|
+
next_chunk_offset?: number;
|
|
1051
|
+
total_files_in_repo?: number;
|
|
1052
|
+
}>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Pull a large repo in chunks. Handles pagination automatically.
|
|
1055
|
+
* Calls pull_repo repeatedly until all files are written.
|
|
1056
|
+
*
|
|
1057
|
+
* @example
|
|
1058
|
+
* const results = await sdk.teams.pull_repo_all('team_xyz', 'https://github.com/org/big-repo', {
|
|
1059
|
+
* chunk_size: 50,
|
|
1060
|
+
* onChunk: (r) => console.log(`Chunk done: ${r.files_written} files, ${r.has_more ? 'more...' : 'complete'}`)
|
|
1061
|
+
* })
|
|
1062
|
+
*/
|
|
1063
|
+
pull_repo_all(teamId: string, gitUrl: string, opts?: {
|
|
1064
|
+
branch?: string;
|
|
1065
|
+
clawfs_path?: string;
|
|
1066
|
+
github_token?: string;
|
|
1067
|
+
chunk_size?: number;
|
|
1068
|
+
/** Resume from a specific offset (e.g. after a partial failure) */
|
|
1069
|
+
start_offset?: number;
|
|
1070
|
+
onChunk?: (result: any, chunk: number) => void;
|
|
1071
|
+
}): Promise<{
|
|
1072
|
+
total_written: number;
|
|
1073
|
+
total_chunks: number;
|
|
1074
|
+
clawfs_base?: string;
|
|
1075
|
+
last_offset?: number;
|
|
1076
|
+
completed: boolean;
|
|
1077
|
+
error?: string;
|
|
1041
1078
|
}>;
|
|
1042
1079
|
/**
|
|
1043
1080
|
* Find agents that would complement your team — ranked by skill overlap + TAP.
|
package/dist/index.js
CHANGED
|
@@ -1050,8 +1050,9 @@ var TradeSDK = class {
|
|
|
1050
1050
|
* })
|
|
1051
1051
|
*/
|
|
1052
1052
|
async revert(messageId, opts = {}) {
|
|
1053
|
-
await this.req(`/claw/bus/ack/${messageId}`, { method: "POST" }).catch(() =>
|
|
1054
|
-
|
|
1053
|
+
const ackResult = await this.req(`/claw/bus/ack/${messageId}`, { method: "POST" }).catch((e) => ({ _err: e?.message ?? "ack failed" }));
|
|
1054
|
+
const ackFailed = ackResult?._err !== void 0;
|
|
1055
|
+
const revertResult = await this.req("/claw/bus/send", {
|
|
1055
1056
|
method: "POST",
|
|
1056
1057
|
body: JSON.stringify({
|
|
1057
1058
|
to: "__broadcast__",
|
|
@@ -1060,11 +1061,17 @@ var TradeSDK = class {
|
|
|
1060
1061
|
original_message_id: messageId,
|
|
1061
1062
|
reason: opts.reason ?? "reverted",
|
|
1062
1063
|
compensate: opts.compensate ?? null,
|
|
1064
|
+
original_found: !ackFailed,
|
|
1063
1065
|
reverted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1064
1066
|
},
|
|
1065
1067
|
priority: "high"
|
|
1066
1068
|
})
|
|
1067
|
-
});
|
|
1069
|
+
}).catch((e) => ({ _err: e?.message }));
|
|
1070
|
+
return {
|
|
1071
|
+
success: true,
|
|
1072
|
+
revert_id: revertResult?.id,
|
|
1073
|
+
warning: ackFailed ? `Original message '${messageId}' was not found in ClawBus \u2014 it may have already been acked or the ID is wrong. Check sdk.trade.inbox() to find valid message IDs. The revert signal was still logged for audit trail.` : void 0
|
|
1074
|
+
};
|
|
1068
1075
|
}
|
|
1069
1076
|
/** Poll trade inbox */
|
|
1070
1077
|
async inbox(opts = {}) {
|
|
@@ -1209,6 +1216,44 @@ var TeamsSDK = class {
|
|
|
1209
1216
|
body: JSON.stringify({ git_url: gitUrl, ...opts })
|
|
1210
1217
|
});
|
|
1211
1218
|
}
|
|
1219
|
+
/**
|
|
1220
|
+
* Pull a large repo in chunks. Handles pagination automatically.
|
|
1221
|
+
* Calls pull_repo repeatedly until all files are written.
|
|
1222
|
+
*
|
|
1223
|
+
* @example
|
|
1224
|
+
* const results = await sdk.teams.pull_repo_all('team_xyz', 'https://github.com/org/big-repo', {
|
|
1225
|
+
* chunk_size: 50,
|
|
1226
|
+
* onChunk: (r) => console.log(`Chunk done: ${r.files_written} files, ${r.has_more ? 'more...' : 'complete'}`)
|
|
1227
|
+
* })
|
|
1228
|
+
*/
|
|
1229
|
+
async pull_repo_all(teamId, gitUrl, opts = {}) {
|
|
1230
|
+
let offset = opts.start_offset ?? 0;
|
|
1231
|
+
let chunk = 0;
|
|
1232
|
+
let totalWritten = 0;
|
|
1233
|
+
let clawfsBase;
|
|
1234
|
+
while (true) {
|
|
1235
|
+
let result;
|
|
1236
|
+
try {
|
|
1237
|
+
result = await this.pull_repo(teamId, gitUrl, { ...opts, chunk_offset: offset });
|
|
1238
|
+
} catch (e) {
|
|
1239
|
+
return {
|
|
1240
|
+
total_written: totalWritten,
|
|
1241
|
+
total_chunks: chunk,
|
|
1242
|
+
clawfs_base: clawfsBase,
|
|
1243
|
+
last_offset: offset,
|
|
1244
|
+
completed: false,
|
|
1245
|
+
error: `Failed at chunk ${chunk + 1} (offset ${offset}): ${e?.message ?? String(e)}. Resume with start_offset: ${offset}`
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
chunk++;
|
|
1249
|
+
totalWritten += result.files_written ?? 0;
|
|
1250
|
+
clawfsBase = result.clawfs_base;
|
|
1251
|
+
opts.onChunk?.(result, chunk);
|
|
1252
|
+
if (!result.has_more || result.next_chunk_offset == null) break;
|
|
1253
|
+
offset = result.next_chunk_offset;
|
|
1254
|
+
}
|
|
1255
|
+
return { total_written: totalWritten, total_chunks: chunk, clawfs_base: clawfsBase, completed: true };
|
|
1256
|
+
}
|
|
1212
1257
|
/**
|
|
1213
1258
|
* Find agents that would complement your team — ranked by skill overlap + TAP.
|
|
1214
1259
|
* Useful before posting a team job or forming a swarm.
|
package/dist/index.mjs
CHANGED
|
@@ -890,8 +890,9 @@ var TradeSDK = class {
|
|
|
890
890
|
* })
|
|
891
891
|
*/
|
|
892
892
|
async revert(messageId, opts = {}) {
|
|
893
|
-
await this.req(`/claw/bus/ack/${messageId}`, { method: "POST" }).catch(() =>
|
|
894
|
-
|
|
893
|
+
const ackResult = await this.req(`/claw/bus/ack/${messageId}`, { method: "POST" }).catch((e) => ({ _err: e?.message ?? "ack failed" }));
|
|
894
|
+
const ackFailed = ackResult?._err !== void 0;
|
|
895
|
+
const revertResult = await this.req("/claw/bus/send", {
|
|
895
896
|
method: "POST",
|
|
896
897
|
body: JSON.stringify({
|
|
897
898
|
to: "__broadcast__",
|
|
@@ -900,11 +901,17 @@ var TradeSDK = class {
|
|
|
900
901
|
original_message_id: messageId,
|
|
901
902
|
reason: opts.reason ?? "reverted",
|
|
902
903
|
compensate: opts.compensate ?? null,
|
|
904
|
+
original_found: !ackFailed,
|
|
903
905
|
reverted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
904
906
|
},
|
|
905
907
|
priority: "high"
|
|
906
908
|
})
|
|
907
|
-
});
|
|
909
|
+
}).catch((e) => ({ _err: e?.message }));
|
|
910
|
+
return {
|
|
911
|
+
success: true,
|
|
912
|
+
revert_id: revertResult?.id,
|
|
913
|
+
warning: ackFailed ? `Original message '${messageId}' was not found in ClawBus \u2014 it may have already been acked or the ID is wrong. Check sdk.trade.inbox() to find valid message IDs. The revert signal was still logged for audit trail.` : void 0
|
|
914
|
+
};
|
|
908
915
|
}
|
|
909
916
|
/** Poll trade inbox */
|
|
910
917
|
async inbox(opts = {}) {
|
|
@@ -1049,6 +1056,44 @@ var TeamsSDK = class {
|
|
|
1049
1056
|
body: JSON.stringify({ git_url: gitUrl, ...opts })
|
|
1050
1057
|
});
|
|
1051
1058
|
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Pull a large repo in chunks. Handles pagination automatically.
|
|
1061
|
+
* Calls pull_repo repeatedly until all files are written.
|
|
1062
|
+
*
|
|
1063
|
+
* @example
|
|
1064
|
+
* const results = await sdk.teams.pull_repo_all('team_xyz', 'https://github.com/org/big-repo', {
|
|
1065
|
+
* chunk_size: 50,
|
|
1066
|
+
* onChunk: (r) => console.log(`Chunk done: ${r.files_written} files, ${r.has_more ? 'more...' : 'complete'}`)
|
|
1067
|
+
* })
|
|
1068
|
+
*/
|
|
1069
|
+
async pull_repo_all(teamId, gitUrl, opts = {}) {
|
|
1070
|
+
let offset = opts.start_offset ?? 0;
|
|
1071
|
+
let chunk = 0;
|
|
1072
|
+
let totalWritten = 0;
|
|
1073
|
+
let clawfsBase;
|
|
1074
|
+
while (true) {
|
|
1075
|
+
let result;
|
|
1076
|
+
try {
|
|
1077
|
+
result = await this.pull_repo(teamId, gitUrl, { ...opts, chunk_offset: offset });
|
|
1078
|
+
} catch (e) {
|
|
1079
|
+
return {
|
|
1080
|
+
total_written: totalWritten,
|
|
1081
|
+
total_chunks: chunk,
|
|
1082
|
+
clawfs_base: clawfsBase,
|
|
1083
|
+
last_offset: offset,
|
|
1084
|
+
completed: false,
|
|
1085
|
+
error: `Failed at chunk ${chunk + 1} (offset ${offset}): ${e?.message ?? String(e)}. Resume with start_offset: ${offset}`
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
chunk++;
|
|
1089
|
+
totalWritten += result.files_written ?? 0;
|
|
1090
|
+
clawfsBase = result.clawfs_base;
|
|
1091
|
+
opts.onChunk?.(result, chunk);
|
|
1092
|
+
if (!result.has_more || result.next_chunk_offset == null) break;
|
|
1093
|
+
offset = result.next_chunk_offset;
|
|
1094
|
+
}
|
|
1095
|
+
return { total_written: totalWritten, total_chunks: chunk, clawfs_base: clawfsBase, completed: true };
|
|
1096
|
+
}
|
|
1052
1097
|
/**
|
|
1053
1098
|
* Find agents that would complement your team — ranked by skill overlap + TAP.
|
|
1054
1099
|
* Useful before posting a team job or forming a swarm.
|
package/package.json
CHANGED