@sage-protocol/sdk 0.1.24 → 0.2.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/dist/index.cjs CHANGED
@@ -14,7 +14,7 @@ var require_package = __commonJS({
14
14
  "package.json"(exports2, module2) {
15
15
  module2.exports = {
16
16
  name: "@sage-protocol/sdk",
17
- version: "0.1.24",
17
+ version: "0.2.0",
18
18
  description: "Backend-agnostic SDK for interacting with the Sage Protocol (governance, SubDAOs, tokens).",
19
19
  main: "dist/index.cjs",
20
20
  module: "dist/index.mjs",
@@ -67,6 +67,7 @@ var require_package = __commonJS({
67
67
  build: "tsup --config tsup.config.ts",
68
68
  clean: "rm -rf dist",
69
69
  test: 'yarn build && node --test "tests/**/*.test.js"',
70
+ prepublishOnly: "npm run build",
70
71
  release: "yarn build && npm publish --workspace @sage-protocol/sdk"
71
72
  },
72
73
  dependencies: {
@@ -3111,8 +3112,9 @@ var require_ipfs = __commonJS({
3111
3112
  async function uploadJson(payload, name = "metadata", options2 = {}) {
3112
3113
  const data = {
3113
3114
  name,
3114
- timestamp: Date.now(),
3115
- ...payload
3115
+ description: options2.description || `JSON: ${name}`,
3116
+ content: typeof payload === "string" ? payload : JSON.stringify(payload, null, 2),
3117
+ timestamp: Date.now()
3116
3118
  };
3117
3119
  const metadata = {
3118
3120
  name,
@@ -3123,6 +3125,7 @@ var require_ipfs = __commonJS({
3123
3125
  provider: options2.provider,
3124
3126
  warm: options2.warm,
3125
3127
  gateways: options2.gateways,
3128
+ pin: options2.pin,
3126
3129
  filename: `${name}.json`,
3127
3130
  metadata
3128
3131
  });
@@ -3649,7 +3652,13 @@ var require_validation = __commonJS({
3649
3652
  return { schema: null, schemaPath: null };
3650
3653
  }
3651
3654
  function detectVersion(manifest) {
3652
- return "3.0.0";
3655
+ const version = manifest?.version;
3656
+ if (typeof version === "string") {
3657
+ const trimmed = version.trim();
3658
+ if (trimmed === "3.0.0") return "3.0.0";
3659
+ return "2.0.0";
3660
+ }
3661
+ return "2.0.0";
3653
3662
  }
3654
3663
  function lintManifest(manifest, { enforceVersion = true, manifestPath = null } = {}) {
3655
3664
  if (!manifest || typeof manifest !== "object") {
@@ -5977,13 +5986,16 @@ var require_operations = __commonJS({
5977
5986
  proposalId,
5978
5987
  refresh = false,
5979
5988
  cache = null,
5980
- fromBlock = 0,
5989
+ fromBlock = null,
5990
+ // null means auto-detect from current block
5981
5991
  helperAddress = null,
5982
5992
  subgraphUrl = null,
5983
5993
  hints = {},
5984
5994
  chunkSizeBlocks = 1e4,
5985
5995
  lookBackBlocks = 2e3,
5986
- lookAheadBlocks = 2e3
5996
+ lookAheadBlocks = 2e3,
5997
+ maxBlockRange = 5e4
5998
+ // Default to 50k blocks to avoid RPC limits
5987
5999
  }) {
5988
6000
  if (!provider) throw new SageSDKError(CODES.INVALID_ARGS, "provider required");
5989
6001
  const govAddr = normaliseGovernor(governor);
@@ -6045,7 +6057,8 @@ var require_operations = __commonJS({
6045
6057
  metadata = null;
6046
6058
  }
6047
6059
  if (!metadata) {
6048
- let lower = fromBlock || 0;
6060
+ const currentBlock = await provider.getBlockNumber();
6061
+ let lower = fromBlock !== null ? fromBlock : Math.max(0, currentBlock - maxBlockRange);
6049
6062
  try {
6050
6063
  const govAbi = new Interface(ABI.Governor);
6051
6064
  const govC = new Contract(govAddr, govAbi, provider);
@@ -9789,6 +9802,335 @@ var require_contributions = __commonJS({
9789
9802
  }
9790
9803
  });
9791
9804
 
9805
+ // src/browser/reputation.js
9806
+ var require_reputation = __commonJS({
9807
+ "src/browser/reputation.js"(exports2, module2) {
9808
+ var { getAddress } = require_utils();
9809
+ var subgraph2 = require_subgraph2();
9810
+ function safeGetAddress(value) {
9811
+ try {
9812
+ return getAddress(value);
9813
+ } catch {
9814
+ return null;
9815
+ }
9816
+ }
9817
+ function clampInt(value, { min = 1, max = 100, fallback = 100 } = {}) {
9818
+ const n = Number(value);
9819
+ if (!Number.isFinite(n)) return fallback;
9820
+ return Math.min(max, Math.max(min, Math.trunc(n)));
9821
+ }
9822
+ function toBigIntString(value, fallback = "0") {
9823
+ try {
9824
+ if (typeof value === "bigint") return value.toString();
9825
+ if (typeof value === "number") return String(Math.trunc(value));
9826
+ const str = String(value).trim();
9827
+ if (!str) return fallback;
9828
+ if (!/^-?\d+$/.test(str)) return fallback;
9829
+ return str;
9830
+ } catch {
9831
+ return fallback;
9832
+ }
9833
+ }
9834
+ function mapSafe(list, mapper) {
9835
+ const out = [];
9836
+ for (const item of list || []) {
9837
+ try {
9838
+ const v = mapper(item);
9839
+ if (v != null) out.push(v);
9840
+ } catch {
9841
+ }
9842
+ }
9843
+ return out;
9844
+ }
9845
+ async function getBadgesByRecipient({ url, recipient, first = 50 }) {
9846
+ if (!url) throw new Error("subgraph url required");
9847
+ if (!recipient) throw new Error("recipient required");
9848
+ const addr = safeGetAddress(recipient);
9849
+ if (!addr) throw new Error("invalid recipient address");
9850
+ const doc = `
9851
+ query($recipient: Bytes!, $first: Int!) {
9852
+ soulboundBadges(
9853
+ where: { recipient: $recipient }
9854
+ first: $first
9855
+ orderBy: blockTimestamp
9856
+ orderDirection: desc
9857
+ ) {
9858
+ id
9859
+ contract
9860
+ badgeId
9861
+ recipient
9862
+ evidenceURI
9863
+ blockNumber
9864
+ blockTimestamp
9865
+ transactionHash
9866
+ }
9867
+ }
9868
+ `;
9869
+ const data = await subgraph2.query(url, doc, {
9870
+ recipient: addr.toLowerCase(),
9871
+ first: clampInt(first, { min: 1, max: 100, fallback: 50 })
9872
+ });
9873
+ return mapSafe(data?.soulboundBadges, (row) => {
9874
+ const contract = safeGetAddress(row.contract);
9875
+ const recipientAddr = safeGetAddress(row.recipient);
9876
+ if (!contract || !recipientAddr) return null;
9877
+ return {
9878
+ id: String(row.id),
9879
+ contract,
9880
+ badgeId: toBigIntString(row.badgeId, "0"),
9881
+ recipient: recipientAddr,
9882
+ evidenceURI: row.evidenceURI || null,
9883
+ blockNumber: Number(row.blockNumber || 0),
9884
+ blockTimestamp: Number(row.blockTimestamp || 0),
9885
+ transactionHash: row.transactionHash || null
9886
+ };
9887
+ });
9888
+ }
9889
+ async function listContributions({ url, contributor, subdao: subdao2, first = 50, orderBy = "updatedAt", orderDirection = "desc" }) {
9890
+ if (!url) throw new Error("subgraph url required");
9891
+ const filters = [];
9892
+ if (contributor) {
9893
+ const addr = safeGetAddress(contributor);
9894
+ if (!addr) throw new Error("invalid contributor address");
9895
+ filters.push(`contributor: "${addr.toLowerCase()}"`);
9896
+ }
9897
+ if (subdao2) {
9898
+ const addr = safeGetAddress(subdao2);
9899
+ if (!addr) throw new Error("invalid subdao address");
9900
+ filters.push(`dao: "${addr.toLowerCase()}"`);
9901
+ }
9902
+ const where = filters.length ? `where: { ${filters.join(", ")} }` : "";
9903
+ const safeOrderBy = ["updatedAt", "createdAt"].includes(orderBy) ? orderBy : "updatedAt";
9904
+ const safeOrderDirection = orderDirection === "asc" ? "asc" : "desc";
9905
+ const doc = `
9906
+ query($first: Int!) {
9907
+ promptContributions(
9908
+ ${where}
9909
+ first: $first
9910
+ orderBy: ${safeOrderBy}
9911
+ orderDirection: ${safeOrderDirection}
9912
+ ) {
9913
+ id
9914
+ dao
9915
+ promptKey
9916
+ contributor
9917
+ cid
9918
+ proposalId
9919
+ forVotes
9920
+ againstVotes
9921
+ abstainVotes
9922
+ uniqueVoters
9923
+ quorum
9924
+ fromBounty
9925
+ bountyId
9926
+ badgeId
9927
+ badgeEvidenceURI
9928
+ createdAt
9929
+ updatedAt
9930
+ transactionHash
9931
+ }
9932
+ }
9933
+ `;
9934
+ const data = await subgraph2.query(url, doc, {
9935
+ first: clampInt(first, { min: 1, max: 100, fallback: 50 })
9936
+ });
9937
+ return mapSafe(data?.promptContributions, (row) => {
9938
+ const dao = safeGetAddress(row.dao);
9939
+ const contributorAddr = safeGetAddress(row.contributor);
9940
+ if (!dao) return null;
9941
+ return {
9942
+ id: String(row.id),
9943
+ dao,
9944
+ promptKey: String(row.promptKey),
9945
+ contributor: contributorAddr || "0x0000000000000000000000000000000000000000",
9946
+ cid: String(row.cid),
9947
+ timestamp: Number(row.updatedAt || 0),
9948
+ createdAt: Number(row.createdAt || 0),
9949
+ updatedAt: Number(row.updatedAt || 0),
9950
+ transactionHash: row.transactionHash || null,
9951
+ proposalId: row.proposalId != null ? toBigIntString(row.proposalId) : null,
9952
+ forVotes: row.forVotes != null ? toBigIntString(row.forVotes) : null,
9953
+ againstVotes: row.againstVotes != null ? toBigIntString(row.againstVotes) : null,
9954
+ abstainVotes: row.abstainVotes != null ? toBigIntString(row.abstainVotes) : null,
9955
+ uniqueVoters: row.uniqueVoters != null ? Number(row.uniqueVoters) : null,
9956
+ quorum: row.quorum != null ? toBigIntString(row.quorum) : null,
9957
+ fromBounty: Boolean(row.fromBounty),
9958
+ bountyId: row.bountyId != null ? toBigIntString(row.bountyId) : null,
9959
+ badgeId: row.badgeId != null ? toBigIntString(row.badgeId) : null,
9960
+ badgeEvidenceURI: row.badgeEvidenceURI || null
9961
+ };
9962
+ });
9963
+ }
9964
+ function computeAggregates(contributions2) {
9965
+ if (!contributions2 || contributions2.length === 0) {
9966
+ return {
9967
+ totalContributions: 0,
9968
+ uniqueContributors: 0,
9969
+ bountyOriginated: 0,
9970
+ governanceOriginated: 0,
9971
+ totalForVotes: "0",
9972
+ totalAgainstVotes: "0",
9973
+ averageVoterCount: 0,
9974
+ badgeCount: 0
9975
+ };
9976
+ }
9977
+ const contributorSet = /* @__PURE__ */ new Set();
9978
+ let bountyOriginated = 0;
9979
+ let governanceOriginated = 0;
9980
+ let totalForVotes = 0n;
9981
+ let totalAgainstVotes = 0n;
9982
+ let voterCountSum = 0;
9983
+ let voterCountN = 0;
9984
+ let badgeCount = 0;
9985
+ for (const c of contributions2) {
9986
+ if (c.contributor) contributorSet.add(c.contributor.toLowerCase());
9987
+ if (c.fromBounty) {
9988
+ bountyOriginated++;
9989
+ } else {
9990
+ governanceOriginated++;
9991
+ }
9992
+ if (c.forVotes != null) {
9993
+ try {
9994
+ totalForVotes += BigInt(c.forVotes);
9995
+ } catch {
9996
+ }
9997
+ }
9998
+ if (c.againstVotes != null) {
9999
+ try {
10000
+ totalAgainstVotes += BigInt(c.againstVotes);
10001
+ } catch {
10002
+ }
10003
+ }
10004
+ if (c.uniqueVoters != null) {
10005
+ voterCountSum += c.uniqueVoters;
10006
+ voterCountN++;
10007
+ }
10008
+ if (c.badgeId != null) badgeCount++;
10009
+ }
10010
+ return {
10011
+ totalContributions: contributions2.length,
10012
+ uniqueContributors: contributorSet.size,
10013
+ bountyOriginated,
10014
+ governanceOriginated,
10015
+ totalForVotes: totalForVotes.toString(),
10016
+ totalAgainstVotes: totalAgainstVotes.toString(),
10017
+ averageVoterCount: voterCountN > 0 ? Math.round(voterCountSum / voterCountN) : 0,
10018
+ badgeCount
10019
+ };
10020
+ }
10021
+ async function getByAddress({
10022
+ url,
10023
+ address,
10024
+ subdao: subdao2,
10025
+ includeBadges = true,
10026
+ includeContributions = true,
10027
+ first = 100
10028
+ } = {}) {
10029
+ if (!url) throw new Error("subgraph url required");
10030
+ if (!address) throw new Error("address required");
10031
+ const addr = safeGetAddress(address);
10032
+ if (!addr) throw new Error("invalid address");
10033
+ const subdaoAddr = subdao2 ? safeGetAddress(subdao2) : null;
10034
+ if (subdao2 && !subdaoAddr) throw new Error("invalid subdao address");
10035
+ const limit = clampInt(first, { min: 1, max: 200, fallback: 100 });
10036
+ let badges = void 0;
10037
+ if (includeBadges) {
10038
+ badges = await getBadgesByRecipient({ url, recipient: addr, first: limit });
10039
+ }
10040
+ let contributionAggregates = void 0;
10041
+ let lastContributionAt = null;
10042
+ if (includeContributions) {
10043
+ const rows = await listContributions({
10044
+ url,
10045
+ contributor: addr,
10046
+ subdao: subdaoAddr || void 0,
10047
+ first: limit,
10048
+ orderBy: "updatedAt",
10049
+ orderDirection: "desc"
10050
+ });
10051
+ if (rows && rows.length) {
10052
+ const updatedAt = rows[0]?.updatedAt ?? rows[0]?.timestamp ?? null;
10053
+ lastContributionAt = updatedAt != null ? Number(updatedAt) : null;
10054
+ if (!Number.isFinite(lastContributionAt)) lastContributionAt = null;
10055
+ }
10056
+ contributionAggregates = computeAggregates(rows || []);
10057
+ }
10058
+ const signals = {
10059
+ badgeCount: includeBadges ? badges ? badges.length : 0 : null,
10060
+ totalContributions: includeContributions ? contributionAggregates ? contributionAggregates.totalContributions : 0 : null,
10061
+ governanceOriginated: includeContributions ? contributionAggregates ? contributionAggregates.governanceOriginated : 0 : null,
10062
+ bountyOriginated: includeContributions ? contributionAggregates ? contributionAggregates.bountyOriginated : 0 : null,
10063
+ lastContributionAt: includeContributions ? lastContributionAt : null
10064
+ };
10065
+ const out = {
10066
+ address: addr,
10067
+ subdao: subdaoAddr || null,
10068
+ signals
10069
+ };
10070
+ if (includeBadges) out.badges = badges;
10071
+ if (includeContributions) {
10072
+ out.contributionAggregates = contributionAggregates;
10073
+ out.lastContributionAt = lastContributionAt;
10074
+ }
10075
+ return out;
10076
+ }
10077
+ function normalizeGateInt(value, name) {
10078
+ if (value === void 0 || value === null) return null;
10079
+ const n = Number(value);
10080
+ if (!Number.isFinite(n) || n < 0) {
10081
+ throw new Error(`invalid gate: ${name}`);
10082
+ }
10083
+ return Math.trunc(n);
10084
+ }
10085
+ function normalizeRequiredBadgeIds(value) {
10086
+ const list = Array.isArray(value) ? value : value != null ? [value] : [];
10087
+ const out = [];
10088
+ for (const item of list) {
10089
+ const id2 = toBigIntString(item, "");
10090
+ if (id2) out.push(id2);
10091
+ }
10092
+ return out;
10093
+ }
10094
+ function evaluate(result, gates = {}) {
10095
+ const reasons = [];
10096
+ const minBadges = normalizeGateInt(gates.minBadges, "minBadges");
10097
+ const minContributions = normalizeGateInt(gates.minContributions, "minContributions");
10098
+ const requiredBadges = normalizeRequiredBadgeIds(gates.requireBadges ?? gates.requireBadge);
10099
+ const badgeCount = Number(result?.signals?.badgeCount ?? (result?.badges?.length ?? 0));
10100
+ const totalContributions = Number(result?.signals?.totalContributions ?? (result?.contributionAggregates?.totalContributions ?? 0));
10101
+ if (minBadges != null) {
10102
+ if (!Number.isFinite(badgeCount)) {
10103
+ reasons.push("badges_unavailable");
10104
+ } else if (badgeCount < minBadges) {
10105
+ reasons.push(`minBadges:${badgeCount}<${minBadges}`);
10106
+ }
10107
+ }
10108
+ if (minContributions != null) {
10109
+ if (!Number.isFinite(totalContributions)) {
10110
+ reasons.push("contributions_unavailable");
10111
+ } else if (totalContributions < minContributions) {
10112
+ reasons.push(`minContributions:${totalContributions}<${minContributions}`);
10113
+ }
10114
+ }
10115
+ if (requiredBadges.length) {
10116
+ const have = new Set((result?.badges || []).map((b) => toBigIntString(b?.badgeId, "")).filter(Boolean));
10117
+ for (const req2 of requiredBadges) {
10118
+ if (!have.has(req2)) reasons.push(`missingBadge:${req2}`);
10119
+ }
10120
+ }
10121
+ return { ok: reasons.length === 0, reasons };
10122
+ }
10123
+ module2.exports = {
10124
+ getByAddress,
10125
+ evaluate,
10126
+ // Expose lower-level functions for advanced usage
10127
+ getBadgesByRecipient,
10128
+ listContributions,
10129
+ computeAggregates
10130
+ };
10131
+ }
10132
+ });
10133
+
9792
10134
  // src/votingMultiplier/index.js
9793
10135
  var require_votingMultiplier = __commonJS({
9794
10136
  "src/votingMultiplier/index.js"(exports2, module2) {
@@ -13219,32 +13561,156 @@ var require_git_storage_client = __commonJS({
13219
13561
  this._authCacheExpiry = 0;
13220
13562
  }
13221
13563
  // =========================================================================
13222
- // Library Management
13564
+ // Path Building Helpers
13565
+ // =========================================================================
13566
+ /**
13567
+ * Build a library path based on tier
13568
+ * @private
13569
+ * @param {'dao'|'personal'|'cache'} tier - Library tier
13570
+ * @param {string} [subdao] - SubDAO address (required for DAO tier)
13571
+ * @param {string} libraryId - Library identifier
13572
+ * @param {string} [subpath] - Additional path segment
13573
+ * @returns {string}
13574
+ */
13575
+ _buildLibraryPath(tier, subdao2, libraryId, subpath = "") {
13576
+ const encodedLibraryId = encodeURIComponent(libraryId);
13577
+ const suffix = subpath ? `/${subpath}` : "";
13578
+ switch (tier) {
13579
+ case "dao":
13580
+ if (!subdao2) throw new Error("subdao required for DAO tier");
13581
+ return `/git/dao/${encodeURIComponent(subdao2)}/${encodedLibraryId}${suffix}`;
13582
+ case "personal":
13583
+ return `/git/personal/${encodedLibraryId}${suffix}`;
13584
+ case "cache":
13585
+ return `/git/cache${suffix}`;
13586
+ default:
13587
+ throw new Error(`Unknown tier: ${tier}`);
13588
+ }
13589
+ }
13590
+ /**
13591
+ * Build path from context object
13592
+ * @private
13593
+ * @param {LibraryContext} ctx - Library context
13594
+ * @param {string} [subpath] - Additional path segment
13595
+ * @returns {string}
13596
+ */
13597
+ _buildPath(ctx, subpath = "") {
13598
+ return this._buildLibraryPath(ctx.tier, ctx.subdao, ctx.libraryId, subpath);
13599
+ }
13600
+ // =========================================================================
13601
+ // Library Management - DAO Libraries
13223
13602
  // =========================================================================
13224
13603
  /**
13225
- * Create a new library
13604
+ * Create a new DAO library (requires governance authority)
13226
13605
  * @param {string} subdao - SubDAO address
13227
13606
  * @param {string} name - Library name
13228
13607
  * @param {Object} [options] - Creation options
13608
+ * @param {string} [options.libraryId] - Custom library ID (auto-generated from name if not provided)
13229
13609
  * @param {string} [options.description] - Library description
13230
13610
  * @param {'public'|'private'} [options.visibility='public'] - Library visibility
13231
13611
  * @returns {Promise<LibraryMetadata>}
13232
13612
  */
13233
- async createLibrary(subdao2, name, options = {}) {
13234
- return this._post("/git/libraries", {
13235
- subdao: subdao2,
13613
+ async createDAOLibrary(subdao2, name, options = {}) {
13614
+ return this._post(`/git/dao/${encodeURIComponent(subdao2)}/libraries`, {
13236
13615
  name,
13616
+ libraryId: options.libraryId,
13237
13617
  description: options.description,
13238
13618
  visibility: options.visibility || "public"
13239
13619
  }, { auth: true });
13240
13620
  }
13241
13621
  /**
13242
- * Get library metadata
13622
+ * List libraries for a SubDAO
13623
+ * @param {string} subdao - SubDAO address
13624
+ * @returns {Promise<{libraries: LibraryMetadata[], subdao: string}>}
13625
+ */
13626
+ async listDAOLibraries(subdao2) {
13627
+ return this._get(`/git/dao/${encodeURIComponent(subdao2)}/libraries`);
13628
+ }
13629
+ /**
13630
+ * Get DAO library metadata
13631
+ * @param {string} subdao - SubDAO address
13632
+ * @param {string} libraryId - Library identifier
13633
+ * @returns {Promise<LibraryMetadata>}
13634
+ */
13635
+ async getDAOLibrary(subdao2, libraryId) {
13636
+ return this._get(this._buildLibraryPath("dao", subdao2, libraryId));
13637
+ }
13638
+ /**
13639
+ * Delete a DAO library (requires admin or governance authority)
13640
+ * @param {string} subdao - SubDAO address
13641
+ * @param {string} libraryId - Library identifier
13642
+ * @returns {Promise<{deleted: boolean, libraryId: string}>}
13643
+ */
13644
+ async deleteDAOLibrary(subdao2, libraryId) {
13645
+ return this._delete(this._buildLibraryPath("dao", subdao2, libraryId), { auth: true });
13646
+ }
13647
+ // =========================================================================
13648
+ // Library Management - Personal Libraries
13649
+ // =========================================================================
13650
+ /**
13651
+ * Create a new personal library
13652
+ * @param {string} name - Library name
13653
+ * @param {Object} [options] - Creation options
13654
+ * @param {string} [options.libraryId] - Custom library ID (auto-generated from name if not provided)
13655
+ * @param {string} [options.description] - Library description
13656
+ * @param {'public'|'private'} [options.visibility='private'] - Library visibility
13657
+ * @returns {Promise<LibraryMetadata>}
13658
+ */
13659
+ async createPersonalLibrary(name, options = {}) {
13660
+ return this._post("/git/personal/libraries", {
13661
+ name,
13662
+ libraryId: options.libraryId,
13663
+ description: options.description,
13664
+ visibility: options.visibility || "private"
13665
+ }, { auth: true });
13666
+ }
13667
+ /**
13668
+ * List personal libraries for authenticated user
13669
+ * @returns {Promise<{libraries: LibraryMetadata[], owner: string}>}
13670
+ */
13671
+ async listPersonalLibraries() {
13672
+ return this._get("/git/personal/libraries", { auth: true });
13673
+ }
13674
+ /**
13675
+ * Get personal library metadata
13676
+ * @param {string} libraryId - Library identifier
13677
+ * @returns {Promise<LibraryMetadata>}
13678
+ */
13679
+ async getPersonalLibrary(libraryId) {
13680
+ return this._get(this._buildLibraryPath("personal", null, libraryId), { auth: true });
13681
+ }
13682
+ /**
13683
+ * Delete a personal library
13684
+ * @param {string} libraryId - Library identifier
13685
+ * @returns {Promise<{deleted: boolean, libraryId: string}>}
13686
+ */
13687
+ async deletePersonalLibrary(libraryId) {
13688
+ return this._delete(this._buildLibraryPath("personal", null, libraryId), { auth: true });
13689
+ }
13690
+ // =========================================================================
13691
+ // Library Management - Legacy/Generic (Backwards Compatibility)
13692
+ // =========================================================================
13693
+ /**
13694
+ * Create a new library (legacy - use createDAOLibrary or createPersonalLibrary)
13695
+ * @deprecated Use createDAOLibrary() or createPersonalLibrary() instead
13696
+ * @param {string} subdao - SubDAO address
13697
+ * @param {string} name - Library name
13698
+ * @param {Object} [options] - Creation options
13699
+ * @param {string} [options.description] - Library description
13700
+ * @param {'public'|'private'} [options.visibility='public'] - Library visibility
13701
+ * @returns {Promise<LibraryMetadata>}
13702
+ */
13703
+ async createLibrary(subdao2, name, options = {}) {
13704
+ return this.createDAOLibrary(subdao2, name, { ...options, libraryId: "default" });
13705
+ }
13706
+ /**
13707
+ * Get library metadata (legacy - use getDAOLibrary or getPersonalLibrary)
13708
+ * @deprecated Use getDAOLibrary() or getPersonalLibrary() instead
13243
13709
  * @param {string} subdao - SubDAO address
13244
13710
  * @returns {Promise<LibraryMetadata>}
13245
13711
  */
13246
13712
  async getLibrary(subdao2) {
13247
- return this._get(`/git/libraries/${encodeURIComponent(subdao2)}`);
13713
+ return this.getDAOLibrary(subdao2, "default");
13248
13714
  }
13249
13715
  /**
13250
13716
  * List all libraries
@@ -13261,207 +13727,251 @@ var require_git_storage_client = __commonJS({
13261
13727
  return this._get(`/git/libraries${queryString ? "?" + queryString : ""}`);
13262
13728
  }
13263
13729
  /**
13264
- * Delete a library (admin only)
13730
+ * Delete a library (legacy - use deleteDAOLibrary or deletePersonalLibrary)
13731
+ * @deprecated Use deleteDAOLibrary() or deletePersonalLibrary() instead
13265
13732
  * @param {string} subdao - SubDAO address
13266
13733
  * @returns {Promise<{ok: boolean}>}
13267
13734
  */
13268
13735
  async deleteLibrary(subdao2) {
13269
- return this._delete(`/git/libraries/${encodeURIComponent(subdao2)}`, { auth: true });
13736
+ return this.deleteDAOLibrary(subdao2, "default");
13270
13737
  }
13271
13738
  // =========================================================================
13272
13739
  // Git Object Operations
13273
13740
  // =========================================================================
13274
13741
  /**
13275
13742
  * Store git objects (batch)
13276
- * @param {string} subdao - SubDAO address
13743
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13277
13744
  * @param {GitObject[]} objects - Objects to store
13745
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13278
13746
  * @returns {Promise<{stored: number}>}
13279
13747
  */
13280
- async putObjects(subdao2, objects) {
13281
- return this._post(`/git/${encodeURIComponent(subdao2)}/objects`, { objects }, { auth: true });
13748
+ async putObjects(target, objects, libraryId = "default") {
13749
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, "objects") : this._buildPath(target, "objects");
13750
+ return this._post(path2, { objects }, { auth: true });
13282
13751
  }
13283
13752
  /**
13284
13753
  * Get a single git object
13285
- * @param {string} subdao - SubDAO address
13754
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13286
13755
  * @param {string} oid - Object ID
13756
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13287
13757
  * @returns {Promise<GitObject>}
13288
13758
  */
13289
- async getObject(subdao2, oid) {
13290
- return this._get(`/git/${encodeURIComponent(subdao2)}/objects/${oid}`);
13759
+ async getObject(target, oid, libraryId = "default") {
13760
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, `objects/${oid}`) : this._buildPath(target, `objects/${oid}`);
13761
+ return this._get(path2);
13291
13762
  }
13292
13763
  /**
13293
13764
  * Get multiple git objects
13294
- * @param {string} subdao - SubDAO address
13765
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13295
13766
  * @param {string[]} oids - Object IDs
13767
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13296
13768
  * @returns {Promise<{objects: GitObject[]}>}
13297
13769
  */
13298
- async getObjects(subdao2, oids) {
13299
- return this._get(`/git/${encodeURIComponent(subdao2)}/objects?oids=${oids.join(",")}`);
13770
+ async getObjects(target, oids, libraryId = "default") {
13771
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, `objects?oids=${oids.join(",")}`) : this._buildPath(target, `objects?oids=${oids.join(",")}`);
13772
+ return this._get(path2);
13300
13773
  }
13301
13774
  // =========================================================================
13302
13775
  // Reference Operations
13303
13776
  // =========================================================================
13304
13777
  /**
13305
13778
  * List all refs
13306
- * @param {string} subdao - SubDAO address
13779
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13780
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13307
13781
  * @returns {Promise<{refs: GitRef[]}>}
13308
13782
  */
13309
- async listRefs(subdao2) {
13310
- return this._get(`/git/${encodeURIComponent(subdao2)}/refs`);
13783
+ async listRefs(target, libraryId = "default") {
13784
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, "refs") : this._buildPath(target, "refs");
13785
+ return this._get(path2);
13311
13786
  }
13312
13787
  /**
13313
13788
  * Get a specific ref
13314
- * @param {string} subdao - SubDAO address
13789
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13315
13790
  * @param {string} refName - Reference name (e.g., 'refs/heads/main')
13791
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13316
13792
  * @returns {Promise<GitRef>}
13317
13793
  */
13318
- async getRef(subdao2, refName) {
13319
- return this._get(`/git/${encodeURIComponent(subdao2)}/refs/${encodeURIComponent(refName)}`);
13794
+ async getRef(target, refName, libraryId = "default") {
13795
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, `refs/${encodeURIComponent(refName)}`) : this._buildPath(target, `refs/${encodeURIComponent(refName)}`);
13796
+ return this._get(path2);
13320
13797
  }
13321
13798
  /**
13322
13799
  * Update a ref
13323
- * @param {string} subdao - SubDAO address
13800
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13324
13801
  * @param {string} refName - Reference name
13325
13802
  * @param {string} oid - New object ID
13326
13803
  * @param {Object} [options] - Update options
13327
13804
  * @param {string} [options.oldOid] - Expected current OID (for optimistic concurrency)
13805
+ * @param {string} [options.libraryId='default'] - Library ID (only used if target is string)
13328
13806
  * @returns {Promise<{ok: boolean}>}
13329
13807
  */
13330
- async updateRef(subdao2, refName, oid, options = {}) {
13331
- return this._post(
13332
- `/git/${encodeURIComponent(subdao2)}/refs/${encodeURIComponent(refName)}`,
13333
- { oid, oldOid: options.oldOid },
13334
- { auth: true }
13335
- );
13808
+ async updateRef(target, refName, oid, options = {}) {
13809
+ const libraryId = options.libraryId || "default";
13810
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, `refs/${encodeURIComponent(refName)}`) : this._buildPath(target, `refs/${encodeURIComponent(refName)}`);
13811
+ return this._post(path2, { oid, oldOid: options.oldOid }, { auth: true });
13336
13812
  }
13337
13813
  // =========================================================================
13338
13814
  // Sync Operations
13339
13815
  // =========================================================================
13340
13816
  /**
13341
13817
  * Push changes to library
13342
- * @param {string} subdao - SubDAO address
13818
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13343
13819
  * @param {Object} payload - Push payload
13344
13820
  * @param {GitObject[]} payload.objects - Objects to push
13345
13821
  * @param {Record<string, string>} payload.refs - Ref updates (name -> oid)
13346
13822
  * @param {string} payload.message - Commit message
13823
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13347
13824
  * @returns {Promise<PushResult>}
13348
13825
  */
13349
- async push(subdao2, payload) {
13350
- return this._post(`/git/${encodeURIComponent(subdao2)}/push`, payload, { auth: true });
13826
+ async push(target, payload, libraryId = "default") {
13827
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, "push") : this._buildPath(target, "push");
13828
+ return this._post(path2, payload, { auth: true });
13351
13829
  }
13352
13830
  /**
13353
13831
  * Clone a library (get all objects and refs)
13354
- * @param {string} subdao - SubDAO address
13832
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13833
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13355
13834
  * @returns {Promise<{objects: GitObject[], refs: Record<string, string>, metadata: LibraryMetadata}>}
13356
13835
  */
13357
- async clone(subdao2) {
13358
- return this._get(`/git/${encodeURIComponent(subdao2)}/clone`);
13836
+ async clone(target, libraryId = "default") {
13837
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, "clone") : this._buildPath(target, "clone");
13838
+ return this._get(path2);
13359
13839
  }
13360
13840
  /**
13361
13841
  * Fetch changes since a commit
13362
- * @param {string} subdao - SubDAO address
13842
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13363
13843
  * @param {string} [since] - Commit OID to fetch since
13844
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13364
13845
  * @returns {Promise<{objects: GitObject[], refs: Record<string, string>}>}
13365
13846
  */
13366
- async fetch(subdao2, since) {
13847
+ async fetch(target, since, libraryId = "default") {
13367
13848
  const params = since ? `?since=${since}` : "";
13368
- return this._get(`/git/${encodeURIComponent(subdao2)}/fetch${params}`);
13849
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, `fetch${params}`) : this._buildPath(target, `fetch${params}`);
13850
+ return this._get(path2);
13369
13851
  }
13370
13852
  // =========================================================================
13371
13853
  // File Access
13372
13854
  // =========================================================================
13373
13855
  /**
13374
13856
  * Get commit history
13375
- * @param {string} subdao - SubDAO address
13857
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13376
13858
  * @param {Object} [options] - History options
13377
13859
  * @param {string} [options.ref='refs/heads/main'] - Reference to get history from
13378
13860
  * @param {number} [options.limit=50] - Max commits to return
13861
+ * @param {string} [options.libraryId='default'] - Library ID (only used if target is string)
13379
13862
  * @returns {Promise<{commits: GitCommit[]}>}
13380
13863
  */
13381
- async getHistory(subdao2, options = {}) {
13864
+ async getHistory(target, options = {}) {
13382
13865
  const params = new URLSearchParams();
13383
13866
  if (options.ref) params.set("ref", options.ref);
13384
13867
  if (options.limit !== void 0) params.set("limit", String(options.limit));
13385
- return this._get(`/git/${encodeURIComponent(subdao2)}/log?${params}`);
13868
+ const libraryId = options.libraryId || "default";
13869
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, `log?${params}`) : this._buildPath(target, `log?${params}`);
13870
+ return this._get(path2);
13386
13871
  }
13387
13872
  /**
13388
13873
  * Get directory listing
13389
- * @param {string} subdao - SubDAO address
13874
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13390
13875
  * @param {string} ref - Reference (e.g., 'main')
13391
- * @param {string} path - Directory path
13876
+ * @param {string} filePath - Directory path
13877
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13392
13878
  * @returns {Promise<{entries: Array}>}
13393
13879
  */
13394
- async getTree(subdao2, ref, path2) {
13395
- return this._get(
13396
- `/git/${encodeURIComponent(subdao2)}/tree/${encodeURIComponent(ref)}/${encodeURIComponent(path2)}`
13397
- );
13880
+ async getTree(target, ref, filePath, libraryId = "default") {
13881
+ const subpath = `tree/${encodeURIComponent(ref)}/${encodeURIComponent(filePath)}`;
13882
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, subpath) : this._buildPath(target, subpath);
13883
+ return this._get(path2);
13398
13884
  }
13399
13885
  /**
13400
13886
  * Get file contents
13401
- * @param {string} subdao - SubDAO address
13887
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13402
13888
  * @param {string} ref - Reference (e.g., 'main')
13403
- * @param {string} path - File path
13889
+ * @param {string} filePath - File path
13890
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13404
13891
  * @returns {Promise<{content: string}>}
13405
13892
  */
13406
- async getBlob(subdao2, ref, path2) {
13407
- return this._get(
13408
- `/git/${encodeURIComponent(subdao2)}/blob/${encodeURIComponent(ref)}/${encodeURIComponent(path2)}`
13409
- );
13893
+ async getBlob(target, ref, filePath, libraryId = "default") {
13894
+ const subpath = `blob/${encodeURIComponent(ref)}/${encodeURIComponent(filePath)}`;
13895
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, subpath) : this._buildPath(target, subpath);
13896
+ return this._get(path2);
13410
13897
  }
13411
13898
  /**
13412
13899
  * Get file contents as string (convenience method)
13413
- * @param {string} subdao - SubDAO address
13900
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13414
13901
  * @param {string} ref - Reference (e.g., 'main')
13415
- * @param {string} path - File path
13902
+ * @param {string} filePath - File path
13903
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13416
13904
  * @returns {Promise<string>}
13417
13905
  */
13418
- async getFile(subdao2, ref, path2) {
13419
- const result = await this.getBlob(subdao2, ref, path2);
13906
+ async getFile(target, ref, filePath, libraryId = "default") {
13907
+ const result = await this.getBlob(target, ref, filePath, libraryId);
13420
13908
  return result.content;
13421
13909
  }
13422
13910
  // =========================================================================
13423
13911
  // Fork Operations
13424
13912
  // =========================================================================
13425
13913
  /**
13426
- * Fork a library to a new SubDAO
13914
+ * Fork a DAO library to a new SubDAO
13427
13915
  * @param {string} sourceSubdao - Source SubDAO address to fork from
13916
+ * @param {string} sourceLibraryId - Source library ID
13428
13917
  * @param {string} targetSubdao - Target SubDAO address for the fork
13429
13918
  * @param {Object} [options] - Fork options
13919
+ * @param {string} [options.targetLibraryId] - Library ID for the fork
13430
13920
  * @param {string} [options.targetName] - Name for the forked library
13431
13921
  * @param {string} [options.targetDescription] - Description for the forked library
13432
13922
  * @returns {Promise<{ok: boolean, forkedLibrary: string, sourceLibrary: string, commitsCopied: number}>}
13433
13923
  */
13434
- async fork(sourceSubdao, targetSubdao, options = {}) {
13435
- return this._post(`/git/libraries/${encodeURIComponent(sourceSubdao)}/fork`, {
13924
+ async forkDAOLibrary(sourceSubdao, sourceLibraryId, targetSubdao, options = {}) {
13925
+ const path2 = this._buildLibraryPath("dao", sourceSubdao, sourceLibraryId, "fork");
13926
+ return this._post(path2, {
13436
13927
  targetSubdao,
13928
+ targetLibraryId: options.targetLibraryId,
13437
13929
  targetName: options.targetName,
13438
13930
  targetDescription: options.targetDescription
13439
13931
  }, { auth: true });
13440
13932
  }
13933
+ /**
13934
+ * Fork a library (legacy - uses 'default' libraryId)
13935
+ * @deprecated Use forkDAOLibrary() instead
13936
+ * @param {string} sourceSubdao - Source SubDAO address to fork from
13937
+ * @param {string} targetSubdao - Target SubDAO address for the fork
13938
+ * @param {Object} [options] - Fork options
13939
+ * @param {string} [options.targetName] - Name for the forked library
13940
+ * @param {string} [options.targetDescription] - Description for the forked library
13941
+ * @returns {Promise<{ok: boolean, forkedLibrary: string, sourceLibrary: string, commitsCopied: number}>}
13942
+ */
13943
+ async fork(sourceSubdao, targetSubdao, options = {}) {
13944
+ return this.forkDAOLibrary(sourceSubdao, "default", targetSubdao, options);
13945
+ }
13441
13946
  /**
13442
13947
  * List forks of a library
13443
- * @param {string} subdao - SubDAO address
13948
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13949
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13444
13950
  * @returns {Promise<{forks: Array, count: number}>}
13445
13951
  */
13446
- async getForks(subdao2) {
13447
- return this._get(`/git/libraries/${encodeURIComponent(subdao2)}/forks`);
13952
+ async getForks(target, libraryId = "default") {
13953
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, "forks") : this._buildPath(target, "forks");
13954
+ return this._get(path2);
13448
13955
  }
13449
13956
  /**
13450
13957
  * Get upstream fork info (for forked libraries)
13451
- * @param {string} subdao - SubDAO address
13958
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13959
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13452
13960
  * @returns {Promise<{upstreamSubdao: string, upstreamCommit: string, forkedAt: number}>}
13453
13961
  */
13454
- async getUpstream(subdao2) {
13455
- return this._get(`/git/${encodeURIComponent(subdao2)}/upstream`);
13962
+ async getUpstream(target, libraryId = "default") {
13963
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, "upstream") : this._buildPath(target, "upstream");
13964
+ return this._get(path2);
13456
13965
  }
13457
13966
  /**
13458
13967
  * Check if a library is a fork
13459
- * @param {string} subdao - SubDAO address
13968
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13969
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13460
13970
  * @returns {Promise<boolean>}
13461
13971
  */
13462
- async isFork(subdao2) {
13972
+ async isFork(target, libraryId = "default") {
13463
13973
  try {
13464
- await this.getUpstream(subdao2);
13974
+ await this.getUpstream(target, libraryId);
13465
13975
  return true;
13466
13976
  } catch (e) {
13467
13977
  if (e.message && e.message.includes("404")) {
@@ -13475,59 +13985,62 @@ var require_git_storage_client = __commonJS({
13475
13985
  // =========================================================================
13476
13986
  /**
13477
13987
  * List collaborators
13478
- * @param {string} subdao - SubDAO address
13988
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13989
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13479
13990
  * @returns {Promise<{collaborators: Collaborator[]}>}
13480
13991
  */
13481
- async listCollaborators(subdao2) {
13482
- return this._get(`/git/${encodeURIComponent(subdao2)}/collaborators`);
13992
+ async listCollaborators(target, libraryId = "default") {
13993
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, "collaborators") : this._buildPath(target, "collaborators");
13994
+ return this._get(path2);
13483
13995
  }
13484
13996
  /**
13485
13997
  * Add a collaborator
13486
- * @param {string} subdao - SubDAO address
13998
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13487
13999
  * @param {string} address - Collaborator wallet address
13488
14000
  * @param {'read'|'write'|'admin'} permission - Permission level
14001
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13489
14002
  * @returns {Promise<{ok: boolean}>}
13490
14003
  */
13491
- async addCollaborator(subdao2, address, permission) {
13492
- return this._post(`/git/${encodeURIComponent(subdao2)}/collaborators`, {
13493
- address,
13494
- permission
13495
- }, { auth: true });
14004
+ async addCollaborator(target, address, permission, libraryId = "default") {
14005
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, "collaborators") : this._buildPath(target, "collaborators");
14006
+ return this._post(path2, { address, permission }, { auth: true });
13496
14007
  }
13497
14008
  /**
13498
14009
  * Remove a collaborator
13499
- * @param {string} subdao - SubDAO address
14010
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13500
14011
  * @param {string} address - Collaborator wallet address
14012
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13501
14013
  * @returns {Promise<{ok: boolean}>}
13502
14014
  */
13503
- async removeCollaborator(subdao2, address) {
13504
- return this._delete(
13505
- `/git/${encodeURIComponent(subdao2)}/collaborators/${encodeURIComponent(address)}`,
13506
- { auth: true }
13507
- );
14015
+ async removeCollaborator(target, address, libraryId = "default") {
14016
+ const subpath = `collaborators/${encodeURIComponent(address)}`;
14017
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, subpath) : this._buildPath(target, subpath);
14018
+ return this._delete(path2, { auth: true });
13508
14019
  }
13509
14020
  /**
13510
14021
  * Check permissions for an address
13511
- * @param {string} subdao - SubDAO address
14022
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13512
14023
  * @param {string} address - Wallet address to check
14024
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13513
14025
  * @returns {Promise<{canRead: boolean, canWrite: boolean, isAdmin: boolean, permission?: string}>}
13514
14026
  */
13515
- async getPermissions(subdao2, address) {
13516
- return this._get(
13517
- `/git/${encodeURIComponent(subdao2)}/collaborators/${encodeURIComponent(address)}/permissions`
13518
- );
14027
+ async getPermissions(target, address, libraryId = "default") {
14028
+ const subpath = `collaborators/${encodeURIComponent(address)}/permissions`;
14029
+ const path2 = typeof target === "string" ? this._buildLibraryPath("dao", target, libraryId, subpath) : this._buildPath(target, subpath);
14030
+ return this._get(path2);
13519
14031
  }
13520
14032
  // =========================================================================
13521
14033
  // High-Level Convenience Methods
13522
14034
  // =========================================================================
13523
14035
  /**
13524
14036
  * Push a manifest file (convenience method)
13525
- * @param {string} subdao - SubDAO address
14037
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13526
14038
  * @param {Object} manifest - Manifest object to push
13527
14039
  * @param {string} message - Commit message
14040
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13528
14041
  * @returns {Promise<PushResult>}
13529
14042
  */
13530
- async pushManifest(subdao2, manifest, message) {
14043
+ async pushManifest(target, manifest, message, libraryId = "default") {
13531
14044
  const content = JSON.stringify(manifest, null, 2);
13532
14045
  const oid = await this._computeOid(content);
13533
14046
  const objects = [{
@@ -13546,7 +14059,7 @@ var require_git_storage_client = __commonJS({
13546
14059
  });
13547
14060
  let parentOid = null;
13548
14061
  try {
13549
- const currentRef = await this.getRef(subdao2, "refs/heads/main");
14062
+ const currentRef = await this.getRef(target, "refs/heads/main", libraryId);
13550
14063
  parentOid = currentRef.oid;
13551
14064
  } catch (e) {
13552
14065
  }
@@ -13565,20 +14078,21 @@ var require_git_storage_client = __commonJS({
13565
14078
  size: commitContent.length,
13566
14079
  data: this._toBase64(commitContent)
13567
14080
  });
13568
- return this.push(subdao2, {
14081
+ return this.push(target, {
13569
14082
  objects,
13570
14083
  refs: { "refs/heads/main": commitOid },
13571
14084
  message
13572
- });
14085
+ }, libraryId);
13573
14086
  }
13574
14087
  /**
13575
14088
  * Get manifest from library (convenience method)
13576
- * @param {string} subdao - SubDAO address
14089
+ * @param {string|LibraryContext} target - SubDAO address (legacy) or LibraryContext
13577
14090
  * @param {string} [ref='main'] - Reference to get manifest from
14091
+ * @param {string} [libraryId='default'] - Library ID (only used if target is string)
13578
14092
  * @returns {Promise<Object>}
13579
14093
  */
13580
- async getManifest(subdao2, ref = "main") {
13581
- const content = await this.getFile(subdao2, ref, "manifest.json");
14094
+ async getManifest(target, ref = "main", libraryId = "default") {
14095
+ const content = await this.getFile(target, ref, "manifest.json", libraryId);
13582
14096
  return JSON.parse(content);
13583
14097
  }
13584
14098
  // =========================================================================
@@ -14041,6 +14555,7 @@ var treasury = require_treasury();
14041
14555
  var boost = require_boost();
14042
14556
  var bounty = require_bounty();
14043
14557
  var contributions = require_contributions();
14558
+ var reputation = require_reputation();
14044
14559
  var votingMultiplier = require_votingMultiplier();
14045
14560
  var auction = require_auction();
14046
14561
  var wallet = require_wallet();
@@ -14094,6 +14609,7 @@ module.exports = {
14094
14609
  utils: { ...utils, privateTx, safe, time },
14095
14610
  bounty,
14096
14611
  contributions,
14612
+ reputation,
14097
14613
  votingMultiplier,
14098
14614
  auction,
14099
14615
  wallet: Object.assign(wallet, {