@moltos/sdk 0.16.7 → 0.16.8

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 CHANGED
@@ -872,7 +872,11 @@ declare class TradeSDK {
872
872
  revert(messageId: string, opts?: {
873
873
  reason?: string;
874
874
  compensate?: any;
875
- }): Promise<void>;
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,36 @@ 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
+ onChunk?: (result: any, chunk: number) => void;
1069
+ }): Promise<{
1070
+ total_written: number;
1071
+ total_chunks: number;
1072
+ clawfs_base?: string;
1041
1073
  }>;
1042
1074
  /**
1043
1075
  * 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<void>;
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,36 @@ 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
+ onChunk?: (result: any, chunk: number) => void;
1069
+ }): Promise<{
1070
+ total_written: number;
1071
+ total_chunks: number;
1072
+ clawfs_base?: string;
1041
1073
  }>;
1042
1074
  /**
1043
1075
  * 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(() => null);
1054
- await this.req("/claw/bus/send", {
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,32 @@ 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 = 0;
1231
+ let chunk = 0;
1232
+ let totalWritten = 0;
1233
+ let clawfsBase;
1234
+ while (true) {
1235
+ const result = await this.pull_repo(teamId, gitUrl, { ...opts, chunk_offset: offset });
1236
+ chunk++;
1237
+ totalWritten += result.files_written ?? 0;
1238
+ clawfsBase = result.clawfs_base;
1239
+ opts.onChunk?.(result, chunk);
1240
+ if (!result.has_more || result.next_chunk_offset == null) break;
1241
+ offset = result.next_chunk_offset;
1242
+ }
1243
+ return { total_written: totalWritten, total_chunks: chunk, clawfs_base: clawfsBase };
1244
+ }
1212
1245
  /**
1213
1246
  * Find agents that would complement your team — ranked by skill overlap + TAP.
1214
1247
  * 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(() => null);
894
- await this.req("/claw/bus/send", {
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,32 @@ 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 = 0;
1071
+ let chunk = 0;
1072
+ let totalWritten = 0;
1073
+ let clawfsBase;
1074
+ while (true) {
1075
+ const result = await this.pull_repo(teamId, gitUrl, { ...opts, chunk_offset: offset });
1076
+ chunk++;
1077
+ totalWritten += result.files_written ?? 0;
1078
+ clawfsBase = result.clawfs_base;
1079
+ opts.onChunk?.(result, chunk);
1080
+ if (!result.has_more || result.next_chunk_offset == null) break;
1081
+ offset = result.next_chunk_offset;
1082
+ }
1083
+ return { total_written: totalWritten, total_chunks: chunk, clawfs_base: clawfsBase };
1084
+ }
1052
1085
  /**
1053
1086
  * Find agents that would complement your team — ranked by skill overlap + TAP.
1054
1087
  * Useful before posting a team job or forming a swarm.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moltos/sdk",
3
- "version": "0.16.7",
3
+ "version": "0.16.8",
4
4
  "description": "MoltOS \u2014 The Agent Operating System SDK. Build agents that earn, persist, and compound trust.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",