@sage-protocol/cli 0.3.7 → 0.3.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/cli/commands/bounty.js +123 -85
- package/dist/cli/commands/doctor.js +18 -7
- package/dist/cli/commands/personal.js +64 -78
- package/dist/cli/commands/premium-pre.js +23 -875
- package/dist/cli/commands/premium.js +237 -667
- package/dist/cli/commands/sxxx.js +103 -0
- package/dist/cli/commands/timelock.js +17 -186
- package/dist/cli/index.js +1 -5
- package/dist/cli/utils/aliases.js +3 -1
- package/dist/cli/utils/error-handler.js +9 -9
- package/dist/cli/utils/lit.js +103 -0
- package/package.json +1 -1
|
@@ -100,9 +100,6 @@ function resolveSubgraphUrl(override) {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
async function createAction(opts) {
|
|
103
|
-
if (process.env.SAGE_ENABLE_PERSONAL !== '1') {
|
|
104
|
-
throw new Error('Personal libraries are disabled. Set SAGE_ENABLE_PERSONAL=1 to enable experimental commands.');
|
|
105
|
-
}
|
|
106
103
|
const provider = await getProvider();
|
|
107
104
|
const wallet = await getWallet(provider);
|
|
108
105
|
const diamond = getConfigAddress('SUBDAO_FACTORY_ADDRESS');
|
|
@@ -129,9 +126,6 @@ async function createAction(opts) {
|
|
|
129
126
|
}
|
|
130
127
|
|
|
131
128
|
async function setPriceAction(key, price, opts) {
|
|
132
|
-
if (process.env.SAGE_ENABLE_PERSONAL !== '1') {
|
|
133
|
-
throw new Error('Personal libraries are disabled. Set SAGE_ENABLE_PERSONAL=1 to enable experimental commands.');
|
|
134
|
-
}
|
|
135
129
|
const provider = await getProvider();
|
|
136
130
|
const wallet = await getWallet(provider);
|
|
137
131
|
const mkt = getConfigAddress('PERSONAL_MARKETPLACE_ADDRESS');
|
|
@@ -157,9 +151,6 @@ async function setPriceAction(key, price, opts) {
|
|
|
157
151
|
}
|
|
158
152
|
|
|
159
153
|
async function sellAction(key, price, opts = {}) {
|
|
160
|
-
if (process.env.SAGE_ENABLE_PERSONAL !== '1') {
|
|
161
|
-
throw new Error('Personal libraries are disabled. Set SAGE_ENABLE_PERSONAL=1 to enable experimental commands.');
|
|
162
|
-
}
|
|
163
154
|
|
|
164
155
|
if (!price || Number.isNaN(Number(price))) {
|
|
165
156
|
throw new Error('Price must be a numeric value (in SXXX).');
|
|
@@ -357,9 +348,6 @@ async function unsellAction(key, opts = {}) {
|
|
|
357
348
|
}
|
|
358
349
|
|
|
359
350
|
async function priceAction(creator, key, opts = {}) {
|
|
360
|
-
if (process.env.SAGE_ENABLE_PERSONAL !== '1') {
|
|
361
|
-
throw new Error('Personal libraries are disabled. Set SAGE_ENABLE_PERSONAL=1 to enable experimental commands.');
|
|
362
|
-
}
|
|
363
351
|
|
|
364
352
|
const provider = await getProvider();
|
|
365
353
|
const marketplaceAddress = getConfigAddress('PERSONAL_MARKETPLACE_ADDRESS');
|
|
@@ -406,9 +394,6 @@ async function priceAction(creator, key, opts = {}) {
|
|
|
406
394
|
}
|
|
407
395
|
|
|
408
396
|
async function listAction(opts = {}) {
|
|
409
|
-
if (process.env.SAGE_ENABLE_PERSONAL !== '1') {
|
|
410
|
-
throw new Error('Personal libraries are disabled. Set SAGE_ENABLE_PERSONAL=1 to enable experimental commands.');
|
|
411
|
-
}
|
|
412
397
|
|
|
413
398
|
const provider = await getProvider();
|
|
414
399
|
const wallet = await getWallet(provider);
|
|
@@ -592,9 +577,6 @@ async function listAction(opts = {}) {
|
|
|
592
577
|
}
|
|
593
578
|
|
|
594
579
|
async function myLicensesAction(opts = {}) {
|
|
595
|
-
if (process.env.SAGE_ENABLE_PERSONAL !== '1') {
|
|
596
|
-
throw new Error('Personal libraries are disabled. Set SAGE_ENABLE_PERSONAL=1 to enable experimental commands.');
|
|
597
|
-
}
|
|
598
580
|
|
|
599
581
|
const provider = await getProvider();
|
|
600
582
|
const wallet = await getWallet(provider);
|
|
@@ -712,9 +694,6 @@ async function myLicensesAction(opts = {}) {
|
|
|
712
694
|
}
|
|
713
695
|
|
|
714
696
|
async function buyAction(creator, key, expectedPriceArg, opts = {}) {
|
|
715
|
-
if (process.env.SAGE_ENABLE_PERSONAL !== '1') {
|
|
716
|
-
throw new Error('Personal libraries are disabled. Set SAGE_ENABLE_PERSONAL=1 to enable experimental commands.');
|
|
717
|
-
}
|
|
718
697
|
|
|
719
698
|
const provider = await getProvider();
|
|
720
699
|
const wallet = await getWallet(provider);
|
|
@@ -827,9 +806,6 @@ async function buyAction(creator, key, expectedPriceArg, opts = {}) {
|
|
|
827
806
|
}
|
|
828
807
|
|
|
829
808
|
async function accessAction(creator, key, opts) {
|
|
830
|
-
if (process.env.SAGE_ENABLE_PERSONAL !== '1') {
|
|
831
|
-
throw new Error('Personal libraries are disabled. Set SAGE_ENABLE_PERSONAL=1 to enable experimental commands.');
|
|
832
|
-
}
|
|
833
809
|
|
|
834
810
|
const provider = await getProvider();
|
|
835
811
|
const wallet = await getWallet(provider);
|
|
@@ -993,59 +969,21 @@ async function accessAction(creator, key, opts) {
|
|
|
993
969
|
}
|
|
994
970
|
|
|
995
971
|
function register(program) {
|
|
996
|
-
const
|
|
972
|
+
const { Command } = require('commander');
|
|
973
|
+
const cmd = program.command('personal').description('Manage personal prompts and premium content');
|
|
974
|
+
|
|
975
|
+
// --- Registry management ---
|
|
997
976
|
cmd
|
|
998
977
|
.command('create')
|
|
999
978
|
.description('Create a personal registry (owned by your EOA)')
|
|
1000
979
|
.option('--policy <n>', 'Fork policy (0=open,1=gov_only,2=disabled)', '0')
|
|
1001
980
|
.action((opts) => createAction(opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1002
|
-
cmd
|
|
1003
|
-
.command('set-price <key> <price>')
|
|
1004
|
-
.description('Set price in SXXX (18 decimals) for a content key')
|
|
1005
|
-
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1006
|
-
.action((key, price, opts) => setPriceAction(key, price, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1007
|
-
cmd
|
|
1008
|
-
.command('sell <key> <price>')
|
|
1009
|
-
.description('List a personal prompt key for sale and optionally encrypt the payload')
|
|
1010
|
-
.option('--encrypt', 'Encrypt content and upload manifest to IPFS', false)
|
|
1011
|
-
.option('--file <path>', 'Path to plaintext prompt/content (required with --encrypt)')
|
|
1012
|
-
.option('--name <name>', 'Friendly name for the encrypted payload')
|
|
1013
|
-
.option('--description <text>', 'Description stored alongside the encrypted payload')
|
|
1014
|
-
.option('--metadata <file>', 'Path to JSON metadata to embed in the manifest')
|
|
1015
|
-
.option('--manifest <file>', 'Write manifest JSON to this path')
|
|
1016
|
-
.option('--policy <n>', 'Optional: create personal registry with policy (0=open,1=gov_only,2=disabled) before selling')
|
|
1017
|
-
.option('--session <file>', 'Lit session signatures JSON (preferred)')
|
|
1018
|
-
.option('--auth-sig <file>', 'Lit AuthSig JSON (fallback if no session signatures)')
|
|
1019
|
-
.option('--chain <litChain>', 'Override Lit chain key (default: infer)')
|
|
1020
|
-
.option('--lit-network <name>', 'Lit network (serrano | datil-test | datil-dev)', process.env.LIT_NETWORK || 'serrano')
|
|
1021
|
-
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1022
|
-
.action((key, price, opts) => sellAction(key, price, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1023
|
-
cmd
|
|
1024
|
-
.command('unsell <key>')
|
|
1025
|
-
.description('Remove a price listing (sets price to 0)')
|
|
1026
|
-
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1027
|
-
.action((key, opts) => unsellAction(key, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1028
|
-
cmd
|
|
1029
|
-
.command('buy <creator> <key> [expectedPrice]')
|
|
1030
|
-
.description('Buy a license for a content key')
|
|
1031
|
-
.option('--max-price <sxxx>', 'Maximum price you are willing to pay (SXXX)')
|
|
1032
|
-
.option('--deadline <seconds>', 'Relative deadline window in seconds (default: 600)', '600')
|
|
1033
|
-
.option('--auto-approve', 'Automatically approve SXXX allowance if needed', false)
|
|
1034
|
-
.option('--unlimited', 'When auto-approving, approve unlimited allowance', false)
|
|
1035
|
-
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1036
|
-
.action((creator, key, expectedPrice, opts) => buyAction(creator, key, expectedPrice, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1037
|
-
|
|
1038
|
-
cmd
|
|
1039
|
-
.command('price <creator> <key>')
|
|
1040
|
-
.description('Show current listing price and fee breakdown for a key')
|
|
1041
|
-
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1042
|
-
.action((creator, key, opts) => priceAction(creator, key, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1043
981
|
|
|
1044
982
|
cmd
|
|
1045
983
|
.command('list')
|
|
1046
|
-
.description('List
|
|
984
|
+
.description('List personal prompts for a creator')
|
|
1047
985
|
.option('--creator <address>', 'Creator address to inspect')
|
|
1048
|
-
.option('--mine', 'List
|
|
986
|
+
.option('--mine', 'List prompts for the active wallet')
|
|
1049
987
|
.option('--keys <keys...>', 'Explicit plaintext keys to list (skips subgraph)')
|
|
1050
988
|
.option('--key <key>', 'Single plaintext key to list')
|
|
1051
989
|
.option('--limit <n>', 'Maximum records to pull from subgraph (default 25)')
|
|
@@ -1055,28 +993,76 @@ function register(program) {
|
|
|
1055
993
|
|
|
1056
994
|
cmd
|
|
1057
995
|
.command('my-licenses')
|
|
1058
|
-
.description('Show
|
|
996
|
+
.description('Show premium licenses owned by the active wallet')
|
|
1059
997
|
.option('--holder <address>', 'Override holder address')
|
|
1060
998
|
.option('--limit <n>', 'Maximum records to pull (default 25)')
|
|
1061
999
|
.option('--subgraph <url>', 'Override subgraph endpoint')
|
|
1062
1000
|
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1063
1001
|
.action((opts) => myLicensesAction(opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1064
1002
|
|
|
1065
|
-
|
|
1003
|
+
// --- Premium subcommand group ---
|
|
1004
|
+
const premium = new Command('premium').description('Premium (paid) personal prompts');
|
|
1005
|
+
|
|
1006
|
+
premium
|
|
1007
|
+
.command('publish <key>')
|
|
1008
|
+
.description('Publish premium content for sale (encrypted, requires purchase)')
|
|
1009
|
+
.requiredOption('--price <sxxx>', 'Price in SXXX (18 decimals)')
|
|
1010
|
+
.requiredOption('--file <path>', 'Path to content file to encrypt')
|
|
1011
|
+
.option('--name <name>', 'Friendly name for the content')
|
|
1012
|
+
.option('--description <text>', 'Description of the content')
|
|
1013
|
+
.option('--metadata <file>', 'Path to JSON metadata to embed in the manifest')
|
|
1014
|
+
.option('--manifest <file>', 'Write manifest JSON to this path')
|
|
1015
|
+
.option('--policy <n>', 'Create personal registry with policy before publishing')
|
|
1016
|
+
.option('--session <file>', 'Lit session signatures JSON (preferred)')
|
|
1017
|
+
.option('--auth-sig <file>', 'Lit AuthSig JSON (fallback)')
|
|
1018
|
+
.option('--chain <litChain>', 'Override Lit chain key (default: infer)')
|
|
1019
|
+
.option('--lit-network <name>', 'Lit network (datil-test | datil-dev)', process.env.LIT_NETWORK || 'datil-test')
|
|
1020
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1021
|
+
.action((key, opts) => {
|
|
1022
|
+
// Call sellAction with encrypt always true for premium
|
|
1023
|
+
const sellOpts = { ...opts, encrypt: true };
|
|
1024
|
+
sellAction(key, opts.price, sellOpts).catch((err) => { console.error(err.message); process.exit(1); });
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
premium
|
|
1028
|
+
.command('buy <creator> <key> [expectedPrice]')
|
|
1029
|
+
.description('Purchase a license for premium content')
|
|
1030
|
+
.option('--max-price <sxxx>', 'Maximum price you are willing to pay (SXXX)')
|
|
1031
|
+
.option('--deadline <seconds>', 'Relative deadline window in seconds (default: 600)', '600')
|
|
1032
|
+
.option('--auto-approve', 'Automatically approve SXXX allowance if needed', false)
|
|
1033
|
+
.option('--unlimited', 'When auto-approving, approve unlimited allowance', false)
|
|
1034
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1035
|
+
.action((creator, key, expectedPrice, opts) => buyAction(creator, key, expectedPrice, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1036
|
+
|
|
1037
|
+
premium
|
|
1066
1038
|
.command('access <creator> <key>')
|
|
1067
|
-
.description('
|
|
1039
|
+
.description('Decrypt and view purchased premium content')
|
|
1068
1040
|
.option('--holder <address>', 'Override holder address (defaults to active wallet)')
|
|
1069
|
-
.option('--subgraph <url>', 'Override subgraph endpoint
|
|
1070
|
-
.option('--gateway <url>', 'IPFS gateway for
|
|
1041
|
+
.option('--subgraph <url>', 'Override subgraph endpoint')
|
|
1042
|
+
.option('--gateway <url>', 'IPFS gateway for payload fetch')
|
|
1071
1043
|
.option('--session <file>', 'Path to Lit session signatures JSON')
|
|
1072
|
-
.option('--auth-sig <file>', 'Path to Lit AuthSig JSON (fallback
|
|
1073
|
-
.option('--chain <litChain>', 'Lit chain identifier
|
|
1074
|
-
.option('--lit-network <name>', 'Lit network (
|
|
1044
|
+
.option('--auth-sig <file>', 'Path to Lit AuthSig JSON (fallback)')
|
|
1045
|
+
.option('--chain <litChain>', 'Lit chain identifier')
|
|
1046
|
+
.option('--lit-network <name>', 'Lit network (datil-test | datil-dev)', process.env.LIT_NETWORK || 'datil-test')
|
|
1075
1047
|
.option('--out <file>', 'Write decrypted output to file')
|
|
1076
|
-
.option('--skip-decrypt', 'Skip
|
|
1077
|
-
.option('--encrypted-cid <cid>', 'Override encrypted CID
|
|
1048
|
+
.option('--skip-decrypt', 'Skip decryption and only report license status')
|
|
1049
|
+
.option('--encrypted-cid <cid>', 'Override encrypted CID')
|
|
1078
1050
|
.option('--json', 'Emit machine-readable JSON report', false)
|
|
1079
1051
|
.action((creator, key, opts) => accessAction(creator, key, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1052
|
+
|
|
1053
|
+
premium
|
|
1054
|
+
.command('price <creator> <key>')
|
|
1055
|
+
.description('Show price and fee breakdown for premium content')
|
|
1056
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1057
|
+
.action((creator, key, opts) => priceAction(creator, key, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1058
|
+
|
|
1059
|
+
premium
|
|
1060
|
+
.command('unlist <key>')
|
|
1061
|
+
.description('Remove a premium listing (sets price to 0)')
|
|
1062
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
1063
|
+
.action((key, opts) => unsellAction(key, opts).catch((err) => { console.error(err.message); process.exit(1); }));
|
|
1064
|
+
|
|
1065
|
+
cmd.addCommand(premium);
|
|
1080
1066
|
}
|
|
1081
1067
|
|
|
1082
1068
|
module.exports = { register };
|