@lingjingai/lj-awb-cli 0.3.12 → 0.3.14

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.
@@ -134,6 +134,7 @@ function normalizeDryRunResult(row = {}) {
134
134
 
135
135
  function normalizeDryRun(data = {}) {
136
136
  const localFiles = Array.isArray(data.localFiles) ? data.localFiles : (data.localFile ? [data.localFile] : undefined);
137
+ const resourceConversions = Array.isArray(data.resourceConversions) ? data.resourceConversions : undefined;
137
138
  return compactRecord({
138
139
  dryRun: true,
139
140
  action: data.action,
@@ -141,6 +142,10 @@ function normalizeDryRun(data = {}) {
141
142
  ...scalarRequestSummary(data.request),
142
143
  ...requestSummary(data.request),
143
144
  localFileCount: Array.isArray(localFiles) ? localFiles.length : undefined,
145
+ resourceConversionCount: Array.isArray(resourceConversions) ? resourceConversions.length : undefined,
146
+ resourceConversion: Array.isArray(resourceConversions) && resourceConversions.length === 1
147
+ ? `${resourceConversions[0].resource || 'resource'} ${resourceConversions[0].fromFormat}->${resourceConversions[0].toFormat}`
148
+ : undefined,
144
149
  fileCount: Array.isArray(data.files) ? data.files.length : undefined,
145
150
  assetCount: Array.isArray(data.assets) ? data.assets.length : undefined,
146
151
  files: data.files,
@@ -159,6 +164,12 @@ function normalizeTaskSubmission(data = {}) {
159
164
  projectGroupNo: data.projectGroupNo,
160
165
  pointNo: data.pointNo,
161
166
  points: data.points ?? data.point ?? data.costPoint ?? data.estimatePoint,
167
+ pointCost: data.pointCost,
168
+ billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
169
+ billingPointRemainingAfter: data.billingPointRemainingAfter ?? data.teamPointRemainingAfter,
170
+ projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
171
+ projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
172
+ projectBudgetRemainingAfter: data.projectBudgetRemainingAfter ?? data.projectPointRemainingAfter,
162
173
  uploadCount: Array.isArray(data.uploads) ? data.uploads.length : undefined,
163
174
  nextCommand: rewriteCommandPrefix(data.nextCommand),
164
175
  waited: data.waited ? normalizeTaskStatus(data.waited) : undefined,
@@ -178,11 +189,11 @@ function normalizeFee(data = {}) {
178
189
  modelGroupCode: data.modelGroupCode,
179
190
  projectGroupNo: data.projectGroupNo,
180
191
  pointCost: data.pointCost,
181
- teamPointBalance: data.teamPointBalance,
182
- projectPointBalance: data.projectPointBalance,
183
- projectPointMax: data.projectPointMax,
184
- teamPointRemainingAfter: data.teamPointRemainingAfter,
185
- projectPointRemainingAfter: data.projectPointRemainingAfter,
192
+ billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
193
+ billingPointRemainingAfter: data.billingPointRemainingAfter ?? data.teamPointRemainingAfter,
194
+ projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
195
+ projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
196
+ projectBudgetRemainingAfter: data.projectBudgetRemainingAfter ?? data.projectPointRemainingAfter,
186
197
  });
187
198
  }
188
199
 
@@ -194,19 +205,34 @@ function normalizeAccountInfo(data = {}) {
194
205
  groupName: data.groupName,
195
206
  currentProjectGroupNo: data.currentProjectGroupNo,
196
207
  currentProjectGroupName: data.currentProjectGroupName,
197
- teamPointBalance: data.teamPointBalance,
198
- projectPointBalance: data.projectPointBalance,
199
- projectPointMax: data.projectPointMax,
208
+ billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
209
+ projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
210
+ projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
200
211
  });
201
212
  }
202
213
 
203
214
  function normalizeCredits(data = {}) {
204
215
  return compactRecord({
205
- teamPointBalance: data.teamPointBalance,
216
+ billingPointBalance: data.billingPointBalance ?? data.teamPointBalance,
206
217
  currentProjectGroupNo: data.currentProjectGroupNo,
207
218
  currentProjectGroupName: data.currentProjectGroupName,
208
- projectPointBalance: data.projectPointBalance,
209
- projectPointMax: data.projectPointMax,
219
+ projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
220
+ projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
221
+ });
222
+ }
223
+
224
+ function normalizeProjectSummary(data = {}) {
225
+ return compactRecord({
226
+ selected: data.selected,
227
+ created: data.created,
228
+ updated: data.updated,
229
+ reused: data.reused,
230
+ projectGroupNo: data.projectGroupNo,
231
+ projectGroupName: data.projectGroupName,
232
+ isSelected: data.isSelected,
233
+ projectBudgetBalance: data.projectBudgetBalance ?? data.projectPointBalance,
234
+ projectBudgetMax: data.projectBudgetMax ?? data.projectPointMax,
235
+ memberCount: data.memberCount,
210
236
  });
211
237
  }
212
238
 
@@ -315,6 +341,12 @@ export function normalizeOutputData(commandName, data) {
315
341
  return normalizeAccountInfo(data);
316
342
  case 'credits balance':
317
343
  return normalizeCredits(data);
344
+ case 'project current':
345
+ case 'project use':
346
+ case 'project create':
347
+ case 'project update':
348
+ case 'project ensure':
349
+ return normalizeProjectSummary(data);
318
350
  case 'credits usage':
319
351
  return normalizeCreditsUsage(data);
320
352
  case 'image status':
@@ -355,14 +387,8 @@ export function normalizeOutputData(commandName, data) {
355
387
 
356
388
  export function normalizeJsonData(commandName, data) {
357
389
  if (!isPlainObject(data)) return rewriteNested(data);
358
- switch (commandName) {
359
- case 'auth status':
360
- return normalizeAuthStatus(data);
361
- case 'auth login-key':
362
- return normalizeAuthLogin(data);
363
- default:
364
- return rewriteNested(data);
365
- }
390
+ if (data.dryRun) return rewriteNested(data);
391
+ return normalizeOutputData(commandName, data);
366
392
  }
367
393
 
368
394
  function shortValue(value) {
@@ -451,6 +477,11 @@ function rowSummary(row) {
451
477
  'taskCount',
452
478
  'successTaskCount',
453
479
  'pointTotal',
480
+ 'billingPointBalance',
481
+ 'billingPointRemainingAfter',
482
+ 'projectBudgetBalance',
483
+ 'projectBudgetMax',
484
+ 'projectBudgetRemainingAfter',
454
485
  'projectPointBalance',
455
486
  'projectPointMax',
456
487
  'teamPointBalance',
@@ -544,9 +575,58 @@ function textItemCount(item = {}) {
544
575
  return undefined;
545
576
  }
546
577
 
578
+ function textAllowValues(values = []) {
579
+ return Array.isArray(values) && values.length ? valueList(values) : '<none>';
580
+ }
581
+
582
+ function textConditionValue(value) {
583
+ if (value === '__NOT_EMPTY__') return 'present';
584
+ if (value === '__EMPTY__') return 'empty';
585
+ return value;
586
+ }
587
+
588
+ function textConstraintConditions(conditions = []) {
589
+ if (!Array.isArray(conditions) || !conditions.length) return undefined;
590
+ return conditions
591
+ .map((item) => {
592
+ const key = item.key || item.configCode;
593
+ return key ? `${key}=${textConditionValue(item.value)}` : null;
594
+ })
595
+ .filter(Boolean)
596
+ .join('&');
597
+ }
598
+
599
+ const NORMAL_IMAGE_FORMATS = ['jpg', 'jpeg', 'png', 'jfif'];
600
+
601
+ function textImageFormats(item = {}) {
602
+ const policy = String(item.formatPolicy || '');
603
+ if (policy === 'normal_plus_webp') return valueList([...NORMAL_IMAGE_FORMATS, 'webp']);
604
+ if (policy === 'normal_without_webp') return valueList(NORMAL_IMAGE_FORMATS);
605
+ return valueList(item.fileTypes);
606
+ }
607
+
608
+ function textResourceFormats(item = {}) {
609
+ if (item.mediaType === 'IMAGE') return textImageFormats(item);
610
+ return valueList(item.fileTypes);
611
+ }
612
+
613
+ function textWebpInput(item = {}) {
614
+ if (item.mediaType !== 'IMAGE') return undefined;
615
+ const policy = String(item.formatPolicy || '');
616
+ if (policy === 'normal_plus_webp') return 'accepted';
617
+ if (policy === 'normal_without_webp') return item.autoConvertTo ? `autoConvertTo${String(item.autoConvertTo).toUpperCase()}` : 'unsupported';
618
+ return undefined;
619
+ }
620
+
621
+ function textResourceAutoConvert(item = {}) {
622
+ if (item.mediaType === 'IMAGE' && ['normal_plus_webp', 'normal_without_webp'].includes(String(item.formatPolicy || ''))) return undefined;
623
+ return item.autoConvertTo;
624
+ }
625
+
547
626
  function formatModelOptionsOutput(data = {}) {
548
627
  const params = Array.isArray(data.params) ? data.params : [];
549
628
  const resources = Array.isArray(data.resources) ? data.resources : [];
629
+ const constraints = Array.isArray(data.constraints) ? data.constraints : [];
550
630
  const lines = ['ok model options'];
551
631
  lines.push(renderRecord(compactRecord({
552
632
  modelGroupCode: data.modelGroupCode,
@@ -571,30 +651,48 @@ function formatModelOptionsOutput(data = {}) {
571
651
  media: item.mediaType,
572
652
  usage: item.usage,
573
653
  sources: textSources(item.sources),
574
- formats: valueList(item.fileTypes),
654
+ formats: textResourceFormats(item),
655
+ webpInput: textWebpInput(item),
656
+ autoConvert: textResourceAutoConvert(item),
575
657
  files: textFileCount(item),
576
658
  maxSizeKB: item.maxSizeKB,
577
659
  durationMs: textDurationRange(item),
578
660
  totalDurationMs: item.maxTotalDurationMs != null ? `<=${item.maxTotalDurationMs}` : undefined,
579
661
  items: textItemCount(item),
580
662
  maxPromptLength: item.maxPromptLength,
581
- supportLastFrame: item.supportLastFrame,
663
+ lastFrameOnly: item.supportLastFrameOnly,
582
664
  }), [
583
665
  'mode',
584
666
  'media',
585
667
  'usage',
586
668
  'sources',
587
669
  'formats',
670
+ 'webpInput',
671
+ 'autoConvert',
588
672
  'files',
589
673
  'maxSizeKB',
590
674
  'durationMs',
591
675
  'totalDurationMs',
592
676
  'items',
593
677
  'maxPromptLength',
594
- 'supportLastFrame',
678
+ 'lastFrameOnly',
595
679
  ])}`);
596
680
  }
597
681
  }
682
+ if (constraints.length) {
683
+ lines.push(`constraints.count=${constraints.length}`);
684
+ for (const [index, item] of constraints.entries()) {
685
+ lines.push(`constraint[${index}]: ${renderRecord(compactRecord({
686
+ target: item.target,
687
+ targetConfig: item.targetConfigCode && item.targetConfigCode !== item.target ? item.targetConfigCode : undefined,
688
+ allowedValues: textAllowValues(item.allowValues),
689
+ when: textConstraintConditions(item.conditions),
690
+ effect: item.effect,
691
+ priority: item.priority,
692
+ name: item.name,
693
+ }), ['target', 'targetConfig', 'allowedValues', 'when', 'effect', 'priority', 'name'])}`);
694
+ }
695
+ }
598
696
  return `${lines.join('\n')}\n`;
599
697
  }
600
698
 
@@ -626,9 +724,10 @@ function formatModelCreateSpecOutput(data = {}) {
626
724
  mode: intent.mode,
627
725
  intent: intent.intent,
628
726
  args: valueList(intent.requiredArgs),
727
+ usage: valueList(intent.resourceUsages),
629
728
  resources: valueList(intent.resourceSyntax),
630
729
  key: textKeyBinding(intent.promptBinding),
631
- }), ['mode', 'intent', 'args', 'resources', 'key'])}`);
730
+ }), ['mode', 'intent', 'args', 'usage', 'resources', 'key'])}`);
632
731
  }
633
732
  if (examples.length) {
634
733
  lines.push(`examples.count=${examples.length}`);
@@ -638,6 +737,36 @@ function formatModelCreateSpecOutput(data = {}) {
638
737
  return `${lines.join('\n')}\n`;
639
738
  }
640
739
 
740
+ function formatGuideTableRows(rows = []) {
741
+ return (Array.isArray(rows) ? rows : []).map((item, index) => {
742
+ const values = valueList(item.values);
743
+ return `field[${index}]: ${renderRecord(compactRecord({
744
+ name: item.field,
745
+ values,
746
+ desc: item.description,
747
+ }), ['name', 'values', 'desc'])}`;
748
+ });
749
+ }
750
+
751
+ function formatModelInputGuideOutput(data = {}) {
752
+ const lines = ['ok model input-guide'];
753
+ lines.push('commonFields.count=' + (Array.isArray(data.commonFields) ? data.commonFields.length : 0));
754
+ lines.push(...formatGuideTableRows(data.commonFields));
755
+ lines.push('resourceFields.count=' + (Array.isArray(data.resourceFields) ? data.resourceFields.length : 0));
756
+ lines.push(...formatGuideTableRows(data.resourceFields));
757
+ const rules = Array.isArray(data.resourceRules) ? data.resourceRules : [];
758
+ if (rules.length) {
759
+ lines.push(`resourceRules.count=${rules.length}`);
760
+ for (const [index, rule] of rules.entries()) lines.push(`rule[${index}]=${rule}`);
761
+ }
762
+ const referenceKeyGuide = Array.isArray(data.referenceKeyGuide) ? data.referenceKeyGuide : [];
763
+ if (referenceKeyGuide.length) {
764
+ lines.push(`referenceKey.count=${referenceKeyGuide.length}`);
765
+ for (const [index, item] of referenceKeyGuide.entries()) lines.push(`referenceKey[${index}]=${item}`);
766
+ }
767
+ return `${lines.join('\n')}\n`;
768
+ }
769
+
641
770
  function defaultJsonCommand(commandName) {
642
771
  return `${commandPrefix()} ${commandName} -f json`;
643
772
  }
@@ -664,6 +793,7 @@ function subtitleRemoveNextCommand(commandName, normalized) {
664
793
  export function formatTextOutput(commandName, data, context = {}) {
665
794
  if (commandName === 'model options') return formatModelOptionsOutput(data);
666
795
  if (commandName === 'model create-spec') return formatModelCreateSpecOutput(data);
796
+ if (commandName === 'model input-guide') return formatModelInputGuideOutput(data);
667
797
  const normalized = normalizeOutputData(commandName, data);
668
798
  if (!isPlainObject(normalized)) return `ok ${commandName}\nvalue=${shortValue(normalized)}\n`;
669
799
  const lines = [`ok ${commandName}`];
@@ -689,7 +819,14 @@ export function formatTextOutput(commandName, data, context = {}) {
689
819
  'status',
690
820
  'count',
691
821
  'resultCount',
822
+ 'resourceConversionCount',
823
+ 'resourceConversion',
692
824
  'pointCost',
825
+ 'billingPointBalance',
826
+ 'billingPointRemainingAfter',
827
+ 'projectBudgetBalance',
828
+ 'projectBudgetMax',
829
+ 'projectBudgetRemainingAfter',
693
830
  'pointTotal',
694
831
  'dryRun',
695
832
  'action',