@lovrabet/lovrabet-cli 2.3.13-beta.1 → 2.4.0-beta.1
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/README.md +22 -14
- package/lib/cli.js +4 -1
- package/lib/commands/api-doc/index.js +11 -1
- package/lib/commands/app/cache.js +2 -1
- package/lib/commands/app/definitions.js +7 -1
- package/lib/commands/app/eligibility.js +2 -1
- package/lib/commands/app/mock-loader.js +1 -1
- package/lib/commands/app/remote-source.js +2 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/approval/index.js +7 -1
- package/lib/commands/artifact/index.js +11 -1
- package/lib/commands/auth/device.js +8 -1
- package/lib/commands/auth/index.js +9 -1
- package/lib/commands/auth/prompt.js +2 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/exec.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/cli-skill/index.js +2 -1
- package/lib/commands/common/config-policy.js +2 -1
- package/lib/commands/common/constraints.js +2 -1
- package/lib/commands/common/flags.js +2 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/config/definitions.js +8 -1
- package/lib/commands/config/init.js +4 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/import-excel.js +10 -1
- package/lib/commands/data/index.js +10 -1
- package/lib/commands/dataset/detail.js +6 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +2 -1
- package/lib/commands/dataset/sdk-doc.js +1 -1
- package/lib/commands/doctor.js +9 -1
- package/lib/commands/file/index.js +3 -1
- package/lib/commands/init.js +4 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/report.js +5 -1
- package/lib/commands/kb/index.js +7 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/metric/contract.js +5 -1
- package/lib/commands/metric/definition.js +4 -1
- package/lib/commands/metric/detail.js +1 -1
- package/lib/commands/metric/exec.js +3 -1
- package/lib/commands/metric/index.js +1 -1
- package/lib/commands/metric/list.js +2 -1
- package/lib/commands/metric/shared.js +2 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +2 -1
- package/lib/commands/ocr/index.js +4 -1
- package/lib/commands/permit/dataset-get.js +1 -1
- package/lib/commands/permit/dataset-set.js +5 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +3 -1
- package/lib/commands/permit/role-menus-set.js +4 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +7 -1
- package/lib/commands/personal-bff/index.js +7 -1
- package/lib/commands/registry.js +6 -1
- package/lib/commands/role/create.js +2 -1
- package/lib/commands/role/delete.js +2 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +2 -1
- package/lib/commands/role/shared.js +8 -1
- package/lib/commands/role/update.js +3 -1
- package/lib/commands/role/user-add.js +2 -1
- package/lib/commands/role/user-remove.js +2 -1
- package/lib/commands/schedule/index.js +7 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/service/dynamic.js +10 -1
- package/lib/commands/service/function-name-adapter.js +3 -1
- package/lib/commands/service/index.js +8 -1
- package/lib/commands/service/registry.js +12 -1
- package/lib/commands/skill/commands/create.js +3 -1
- package/lib/commands/skill/commands/diagram.js +4 -1
- package/lib/commands/skill/commands/install.js +6 -1
- package/lib/commands/skill/commands/list.js +3 -1
- package/lib/commands/skill/commands/push.js +1 -1
- package/lib/commands/skill/commands/validate.js +1 -1
- package/lib/commands/skill/diagram.js +3 -1
- package/lib/commands/skill/flags.js +4 -1
- package/lib/commands/skill/index.js +1 -1
- package/lib/commands/skill/manifest-helpers.js +1 -1
- package/lib/commands/skill/push-execute.js +11 -1
- package/lib/commands/skill/push-flow-helpers.js +4 -1
- package/lib/commands/skill/push-retarget.js +1 -1
- package/lib/commands/skill/scopes.js +1 -1
- package/lib/commands/skill/summary.js +1 -1
- package/lib/commands/skill/templates.js +8 -1
- package/lib/commands/skill/validate.js +8 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +2 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/update.d.ts +2 -1
- package/lib/commands/update.js +8 -1
- package/lib/commands/user-account/bind.js +3 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/index.js +7 -1
- package/lib/config/domain-config.js +6 -1
- package/lib/config/schema.js +5 -1
- package/lib/constant/app.js +1 -1
- package/lib/constant/auth-mode.js +1 -1
- package/lib/constant/cli.js +3 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/distribution.js +1 -1
- package/lib/constant/domain.js +2 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/product.js +2 -1
- package/lib/constant/region.js +2 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/url.js +1 -1
- package/lib/context.js +11 -1
- package/lib/core/api-client.js +38 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/kb-management-client.js +6 -1
- package/lib/core/kb-sdk-errors.js +2 -1
- package/lib/core/kb-search-client.js +2 -1
- package/lib/core/sdk-client.js +5 -1
- package/lib/errors.js +2 -1
- package/lib/framework/access-error.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/dryrun.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +2 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/preparse.js +3 -1
- package/lib/framework/rate-limit.js +2 -1
- package/lib/framework/raw-flags.js +2 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-confirmation.js +2 -1
- package/lib/framework/runner-error.js +2 -1
- package/lib/framework/runner.js +9 -1
- package/lib/framework/schema-export.js +2 -1
- package/lib/framework/service-order.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +2 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +4 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +2 -1
- package/lib/runtime/types.js +1 -1
- package/lib/services/dataset-import/auto-id-runner.js +9 -1
- package/lib/services/dataset-import/excel-reader.js +25 -1
- package/lib/services/dataset-import/image-bytes.js +6 -1
- package/lib/services/dataset-import/image-ooxml.js +15 -1
- package/lib/services/dataset-import/image-runner.js +9 -1
- package/lib/services/dataset-import/metadata.js +1 -1
- package/lib/services/dataset-import/preview.js +1 -1
- package/lib/services/dataset-import/runner.js +13 -1
- package/lib/services/dataset-import/types.js +1 -1
- package/lib/skills/builtin-skill.js +8 -1
- package/lib/skills/install-updated-skill.d.ts +8 -0
- package/lib/skills/install-updated-skill.js +3 -0
- package/lib/skills/local-skills-installer.d.ts +2 -0
- package/lib/skills/local-skills-installer.js +1 -0
- package/lib/skills/npx-skills-add.d.ts +2 -2
- package/lib/skills/npx-skills-add.js +4 -1
- package/lib/skills/runtime-skill-sync/constants.js +1 -1
- package/lib/skills/runtime-skill-sync/fs-utils.js +3 -1
- package/lib/skills/runtime-skill-sync/hashing.js +1 -1
- package/lib/skills/runtime-skill-sync/install-target.js +1 -1
- package/lib/skills/runtime-skill-sync/links.js +9 -1
- package/lib/skills/runtime-skill-sync/list-local.js +4 -1
- package/lib/skills/runtime-skill-sync/local-files.js +5 -1
- package/lib/skills/runtime-skill-sync/materialize.js +9 -1
- package/lib/skills/runtime-skill-sync/metadata.js +3 -1
- package/lib/skills/runtime-skill-sync/paths.js +2 -1
- package/lib/skills/runtime-skill-sync/push.js +8 -1
- package/lib/skills/runtime-skill-sync/scopes.js +1 -1
- package/lib/skills/runtime-skill-sync/types.js +1 -1
- package/lib/skills/runtime-skill-sync/zip-codec.js +2 -1
- package/lib/skills/runtime-skill-sync/zip-package.js +6 -1
- package/lib/skills/runtime-skill-sync.js +1 -1
- package/lib/skills/skill-presence.d.ts +1 -34
- package/lib/skills/skill-presence.js +2 -1
- package/lib/utils/access-key-redaction.js +2 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cli-version-check.js +2 -1
- package/lib/utils/cli-version-policy.js +3 -1
- package/lib/utils/logger.js +3 -1
- package/lib/utils/lossless-json.js +3 -1
- package/lib/utils/params.js +3 -1
- package/lib/utils/positive-safe-integer.js +1 -1
- package/lib/utils/redaction.js +2 -1
- package/lib/utils/runtime-user-id.js +1 -1
- package/lib/utils/update-notice.js +3 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +5 -7
- package/skills/lovrabet/SKILL.md +3 -3
- package/skills/lovrabet/references/lovrabet-skill-install.md +1 -1
- package/skills/lovrabet/references/lovrabet-update.md +6 -4
- package/skills/lovrabet-report-generation/SKILL.md +1 -1
- package/skills/lovrabet.manifest.json +3 -3
- package/lib/postinstall.d.ts +0 -2
- package/lib/postinstall.js +0 -1
- package/scripts/postinstall.mjs +0 -24
package/lib/commands/doctor.js
CHANGED
|
@@ -1 +1,9 @@
|
|
|
1
|
-
const a32_0x29b9d1=a32_0x39a5;(function(_0x3784a2,_0xa3afce){const _0x450ff5=a32_0x39a5,_0x519abb=_0x3784a2();while(!![]){try{const _0x2fa887=-parseInt(_0x450ff5(0x1de))/0x1+parseInt(_0x450ff5(0x203))/0x2+parseInt(_0x450ff5(0x21f))/0x3+parseInt(_0x450ff5(0x1cd))/0x4*(parseInt(_0x450ff5(0x219))/0x5)+parseInt(_0x450ff5(0x1d9))/0x6*(-parseInt(_0x450ff5(0x231))/0x7)+-parseInt(_0x450ff5(0x1f7))/0x8+-parseInt(_0x450ff5(0x1f9))/0x9*(parseInt(_0x450ff5(0x1eb))/0xa);if(_0x2fa887===_0xa3afce)break;else _0x519abb['push'](_0x519abb['shift']());}catch(_0x571d0f){_0x519abb['push'](_0x519abb['shift']());}}}(a32_0x38ab,0xdd1fe));import a32_0x1af0eb from'chalk';import{CLI_BIN_NAME}from'../constant/cli.js';import{DEFAULT_CONFIG_VALUES}from'../constant/defaults.js';import{getCliVersion}from'../utils/version.js';import{getApiDomain,getKbServiceDomain,getRuntimeDomain,getSkillDomain,getUserDomain}from'../constant/domain.js';import{normalizeLovrabetRegion}from'../constant/region.js';import{buildConfigFromFlags,initGlobalEnvironment,getProjectConfigPath,getGlobalConfigPath,inspectCliConfigJsonFile,loadRawConfigLayers}from'../context.js';function a32_0x38ab(){const _0x51198b=['repairCommand','pageSize','region','raw','red','current','verbose','\x20\x20Mode:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','\x20\x20Package\x20Version:\x20','path','\x20\x20─','filter','(unnamed)','\x20\x20appCode:\x20\x20\x20\x20\x20\x20\x20\x20\x20','accessKeySource','\x20\x20Repair\x20global:\x20\x20\x20','\x20config\x20delete\x20inherit\x20--global','✗\x20Invalid','\x20\x20Platform:\x20\x20\x20\x20\x20\x20\x20\x20','\x20\x20Config\x20Files','✓\x20Valid\x20JSON','\x20\x20Installed\x20Path:\x20\x20','appcode','\x20\x20Services:\x20\x20\x20\x20\x20\x20\x20\x20','\x20\x20Config\x20JSON','✓\x20current','repeat','231432JavHwW','riskLevel','\x20\x20Repair\x20project:\x20\x20','\x20\x20currentApp:\x20\x20\x20\x20\x20\x20','bold','installedPath','Project','state','(set,\x20length=','(default:\x20','check','str','588pCJrln','log','\x20config\x20delete\x20inherit','\x20\x20userDomain:\x20\x20\x20\x20\x20\x20','not\x20configured','805214KeDtoJ','includes','registryPath','prototype','\x20(accessKey)','ClientAk','(default)','call','\x20\x20kbServiceDomain:\x20','(none)','app','status','(removed\x20—\x20cookie\x20auth\x20disabled)','3290XtjGkS','\x20doctor','platform','\x20\x20Node:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','\x20\x20Country/Region\x20Configuration','\x20config\x20delete\x20routing','project','locale','Unavailable\x20until\x20routing\x20configuration\x20is\x20repaired','\x20\x20Service\x20Tree','\x20\x20defaultApp:\x20\x20\x20\x20\x20\x20','⚠\x20Empty\x20(treated\x20as\x20{})','12944656KyaFfd','\x20\x20Merged\x20Config','13473wzWApp','Diagnose\x20CLI\x20configuration\x20and\x20environment','padEnd','\x20Imported\x20from:\x20','(invalid)','\x20\x20accessKey:\x20\x20\x20\x20\x20\x20\x20','format','appCode','gray','\x20\x20Repair\x20project:\x20\x20\x20','2158744hVAJak','arch','green','\x20commands)','\x20config','\x20\x20CLI\x20Version:\x20\x20\x20\x20\x20','globalConfig','(not\x20found)','read','inherit','\x20\x20Session\x20check:\x20\x20\x20','\x20\x20Commands:\x20\x20\x20\x20\x20\x20\x20\x20','\x20\x20Skill\x20Version:\x20\x20\x20','join','\x20\x20app\x20locale:\x20\x20\x20\x20\x20\x20','\x20\x20State:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','ignored\x20in\x20','reason','yellow','\x20config\x20delete\x20region','\x20+\x20','commandCount','110YnYgON','(no\x20file)','\x20\x20format:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','serviceCount','empty','accessKey','5000271QXxyJn','routing','services','\x20\x20Auth','\x20\x20App\x20selection\x20does\x20not\x20switch\x20credentials\x20or\x20identity.','\x20\x20Status:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','message','\x20\x20Registry:\x20\x20\x20\x20\x20\x20\x20\x20','projectConfig','\x20\x20Local\x20configuration\x20does\x20not\x20verify\x20identity\x20or\x20operation\x20permissions;\x20the\x20server\x20enforces\x20access.','\x20\x20Global:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','hasOwnProperty','\x20\x20Routing\x20Configuration','(missing)','\x20\x20Project:\x20\x20\x20\x20\x20\x20\x20\x20\x20','missing','global','\x20\x20Reason:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','14105pOWcQy','\x20\x20verbose:\x20\x20\x20\x20\x20\x20\x20\x20\x20','\x20\x20skillDomain:\x20\x20\x20\x20\x20','doctor','skillVersion'];a32_0x38ab=function(){return _0x51198b;};return a32_0x38ab();}function a32_0x39a5(_0x3b64c7,_0x49474f){_0x3b64c7=_0x3b64c7-0x1b3;const _0x38abdb=a32_0x38ab();let _0x39a52e=_0x38abdb[_0x3b64c7];return _0x39a52e;}import{AUTH_MODE}from'../constant/auth-mode.js';import{inspectServiceRegistry}from'../commands/service/registry.js';import{inspectBuiltinSkill}from'../skills/builtin-skill.js';async function execute(_0x529919){const _0x1d9e52=a32_0x39a5,_0x54cf2a=getCliVersion(),_0x382ac2=buildConfigFromFlags({'app':_0x529919[_0x1d9e52(0x1d8)]?.(_0x1d9e52(0x1e8)),'appcode':_0x529919[_0x1d9e52(0x1d8)]?.(_0x1d9e52(0x1c8)),'env':_0x529919['str']?.('env')});let _0x434795,_0x19d669;try{_0x434795=normalizeLovrabetRegion(_0x382ac2[_0x1d9e52(0x1b5)][_0x1d9e52(0x1b4)]);}catch(_0x58a276){_0x19d669=_0x58a276 instanceof Error?_0x58a276:new Error(String(_0x58a276));}let _0xb106ee;if(!_0x19d669)try{await initGlobalEnvironment(_0x382ac2);}catch(_0x3db6a8){_0xb106ee=_0x3db6a8 instanceof Error?_0x3db6a8:new Error(String(_0x3db6a8));}console[_0x1d9e52(0x1da)](),console['log'](a32_0x1af0eb['bold'](CLI_BIN_NAME+_0x1d9e52(0x1ec))),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x201)]('─'[_0x1d9e52(0x1cc)](0x32))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x208)+_0x54cf2a),console[_0x1d9e52(0x1da)](_0x1d9e52(0x1ee)+process['version']),console[_0x1d9e52(0x1da)](_0x1d9e52(0x1c4)+process[_0x1d9e52(0x1ed)]+'\x20'+process[_0x1d9e52(0x204)]);const _0x127fe7=inspectBuiltinSkill();console[_0x1d9e52(0x1da)](),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x1d1)]('\x20\x20Built-in\x20Skill')),console['log'](a32_0x1af0eb['gray'](_0x1d9e52(0x1bc)[_0x1d9e52(0x1cc)](0x1e))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x212)+(_0x127fe7[_0x1d9e52(0x1d4)]===_0x1d9e52(0x1b7)?a32_0x1af0eb[_0x1d9e52(0x205)](_0x1d9e52(0x1cb)):a32_0x1af0eb[_0x1d9e52(0x1b6)]('✗\x20'+_0x127fe7[_0x1d9e52(0x1d4)]))),console['log'](_0x1d9e52(0x1ba)+_0x127fe7['packageVersion']),console['log'](_0x1d9e52(0x20f)+(_0x127fe7[_0x1d9e52(0x235)]||a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x22c)))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x1c7)+(_0x127fe7[_0x1d9e52(0x1d2)]||a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x20a))));_0x127fe7['state']!==_0x1d9e52(0x1b7)&&console[_0x1d9e52(0x1da)]('\x20\x20Repair:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+_0x127fe7[_0x1d9e52(0x236)]);_0x127fe7[_0x1d9e52(0x214)]&&console[_0x1d9e52(0x1da)](_0x1d9e52(0x230)+_0x127fe7[_0x1d9e52(0x214)]);console[_0x1d9e52(0x1da)](),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x1d1)](_0x1d9e52(0x1c5))),console['log'](a32_0x1af0eb['gray'](_0x1d9e52(0x1bc)['repeat'](0x1e)));const _0x204ed4=getGlobalConfigPath(),_0x19a0e3=getProjectConfigPath();console[_0x1d9e52(0x1da)](_0x1d9e52(0x229)+(_0x204ed4||a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x20a)))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x22d)+(_0x19a0e3||a32_0x1af0eb['gray'](_0x1d9e52(0x20a)))),console[_0x1d9e52(0x1da)](),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x1d1)](_0x1d9e52(0x1ca))),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x201)]('\x20\x20─'[_0x1d9e52(0x1cc)](0x1e)));const _0xd7ec36=(_0x574db1,_0x34d124)=>{const _0x4c3cb5=_0x1d9e52;if(!_0x34d124){console[_0x4c3cb5(0x1da)]('\x20\x20'+_0x574db1[_0x4c3cb5(0x1fb)](0x11)+'\x20'+a32_0x1af0eb[_0x4c3cb5(0x201)](_0x4c3cb5(0x21a)));return;}const _0x17a154=inspectCliConfigJsonFile(_0x34d124);if(_0x17a154['status']==='ok')console['log']('\x20\x20'+_0x574db1['padEnd'](0x11)+'\x20'+a32_0x1af0eb[_0x4c3cb5(0x205)](_0x4c3cb5(0x1c6)));else{if(_0x17a154[_0x4c3cb5(0x1e9)]===_0x4c3cb5(0x21d))console[_0x4c3cb5(0x1da)]('\x20\x20'+_0x574db1[_0x4c3cb5(0x1fb)](0x11)+'\x20'+a32_0x1af0eb[_0x4c3cb5(0x215)](_0x4c3cb5(0x1f6)));else _0x17a154['status']===_0x4c3cb5(0x22e)?console[_0x4c3cb5(0x1da)]('\x20\x20'+_0x574db1[_0x4c3cb5(0x1fb)](0x11)+'\x20'+a32_0x1af0eb[_0x4c3cb5(0x201)](_0x4c3cb5(0x22c))):(console[_0x4c3cb5(0x1da)]('\x20\x20'+_0x574db1[_0x4c3cb5(0x1fb)](0x11)+'\x20'+a32_0x1af0eb[_0x4c3cb5(0x1b6)]('✗\x20Invalid\x20JSON')),console['log']('\x20\x20'+''[_0x4c3cb5(0x1fb)](0x11)+'\x20'+a32_0x1af0eb['red'](_0x17a154['message'])));}};_0xd7ec36('Global',_0x204ed4),_0xd7ec36(_0x1d9e52(0x1d3),_0x19a0e3);const _0x17aaf6=loadRawConfigLayers(),_0x133b3e=[Object['prototype']['hasOwnProperty'][_0x1d9e52(0x1e5)](_0x17aaf6['globalConfig'],_0x1d9e52(0x20c))?_0x1d9e52(0x22f):null,Object['prototype'][_0x1d9e52(0x22a)][_0x1d9e52(0x1e5)](_0x17aaf6[_0x1d9e52(0x227)],_0x1d9e52(0x20c))?_0x1d9e52(0x1f1):null][_0x1d9e52(0x1bd)](Boolean);_0x133b3e['length']>0x0&&(console['log']('\x20\x20Legacy\x20inherit:\x20\x20\x20'+a32_0x1af0eb['yellow'](_0x1d9e52(0x213)+_0x133b3e[_0x1d9e52(0x210)](_0x1d9e52(0x217))+_0x1d9e52(0x207))),_0x133b3e['includes'](_0x1d9e52(0x1f1))&&console[_0x1d9e52(0x1da)](_0x1d9e52(0x202)+CLI_BIN_NAME+_0x1d9e52(0x1db)),_0x133b3e[_0x1d9e52(0x1df)](_0x1d9e52(0x22f))&&console[_0x1d9e52(0x1da)]('\x20\x20Repair\x20global:\x20\x20\x20\x20'+CLI_BIN_NAME+_0x1d9e52(0x1c2)));_0xb106ee&&(console[_0x1d9e52(0x1da)](),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x1d1)](_0x1d9e52(0x22b))),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1bc)['repeat'](0x1e))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x224)+a32_0x1af0eb['red'](_0x1d9e52(0x1c3))),console[_0x1d9e52(0x1da)]('\x20\x20Reason:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+_0xb106ee[_0x1d9e52(0x225)]),Object['prototype'][_0x1d9e52(0x22a)][_0x1d9e52(0x1e5)](_0x17aaf6['projectConfig'],'routing')&&console[_0x1d9e52(0x1da)](_0x1d9e52(0x1cf)+CLI_BIN_NAME+_0x1d9e52(0x1f0)),Object[_0x1d9e52(0x1e1)][_0x1d9e52(0x22a)][_0x1d9e52(0x1e5)](_0x17aaf6[_0x1d9e52(0x209)],_0x1d9e52(0x220))&&console[_0x1d9e52(0x1da)](_0x1d9e52(0x1c1)+CLI_BIN_NAME+'\x20config\x20delete\x20routing\x20--global'));_0x19d669&&(console[_0x1d9e52(0x1da)](),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x1d1)](_0x1d9e52(0x1ef))),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1bc)['repeat'](0x1e))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x224)+a32_0x1af0eb['red'](_0x1d9e52(0x1c3))),console['log']('\x20\x20Reason:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+_0x19d669['message']),Object['prototype']['hasOwnProperty'][_0x1d9e52(0x1e5)](_0x17aaf6['projectConfig'],_0x1d9e52(0x1b4))&&console[_0x1d9e52(0x1da)]('\x20\x20Repair\x20project:\x20\x20'+CLI_BIN_NAME+_0x1d9e52(0x216)),Object[_0x1d9e52(0x1e1)]['hasOwnProperty'][_0x1d9e52(0x1e5)](_0x17aaf6[_0x1d9e52(0x209)],_0x1d9e52(0x1b4))&&console['log']('\x20\x20Repair\x20global:\x20\x20\x20'+CLI_BIN_NAME+'\x20config\x20init'));console[_0x1d9e52(0x1da)](),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x1d1)](_0x1d9e52(0x1f8))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x223)),console[_0x1d9e52(0x1da)](_0x1d9e52(0x228)),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x201)]('\x20\x20─'[_0x1d9e52(0x1cc)](0x1e))),console['log'](_0x1d9e52(0x1bf)+(_0x382ac2[_0x1d9e52(0x200)]||a32_0x1af0eb[_0x1d9e52(0x1b6)]('(not\x20set)'))),console[_0x1d9e52(0x1da)]('\x20\x20region:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+(_0x434795??a32_0x1af0eb['red'](_0x1d9e52(0x1fd)))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x211)+_0x382ac2[_0x1d9e52(0x1f2)]),console['log'](_0x1d9e52(0x1f5)+(_0x382ac2['defaultApp']||a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1e7)))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x1d0)+(_0x382ac2['currentApp']||a32_0x1af0eb['gray'](_0x1d9e52(0x1e7)))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x21b)+(_0x382ac2[_0x1d9e52(0x1ff)]||a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1d6)+DEFAULT_CONFIG_VALUES[_0x1d9e52(0x1ff)]+')'))),console[_0x1d9e52(0x1da)]('\x20\x20pageSize:\x20\x20\x20\x20\x20\x20\x20\x20'+(_0x382ac2[_0x1d9e52(0x1b3)]??a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1e4)))),console[_0x1d9e52(0x1da)]('\x20\x20riskLevel:\x20\x20\x20\x20\x20\x20\x20'+_0x382ac2[_0x1d9e52(0x1ce)]),console[_0x1d9e52(0x1da)](_0x1d9e52(0x232)+_0x382ac2[_0x1d9e52(0x1b8)]),console[_0x1d9e52(0x1da)]('\x20\x20auth\x20(effective):\x20'+AUTH_MODE[_0x1d9e52(0x1e3)]);if(_0x382ac2[_0x1d9e52(0x1c0)])console[_0x1d9e52(0x1da)]('\x20\x20AK\x20source:\x20\x20\x20\x20\x20\x20\x20'+_0x382ac2[_0x1d9e52(0x1c0)]);console[_0x1d9e52(0x1da)](_0x1d9e52(0x1fe)+(_0x382ac2[_0x1d9e52(0x21e)]?a32_0x1af0eb['green'](_0x1d9e52(0x1d5)+_0x382ac2[_0x1d9e52(0x21e)]['length']+')'):a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1e7)))),console[_0x1d9e52(0x1da)](),console['log'](a32_0x1af0eb[_0x1d9e52(0x1d1)]('\x20\x20API\x20Endpoints')),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1bc)['repeat'](0x1e)));_0xb106ee||_0x19d669?console[_0x1d9e52(0x1da)](_0x1d9e52(0x224)+a32_0x1af0eb[_0x1d9e52(0x1b6)](_0x1d9e52(0x1f3))):(console[_0x1d9e52(0x1da)]('\x20\x20apiDomain:\x20\x20\x20\x20\x20\x20\x20'+getApiDomain()),console['log'](_0x1d9e52(0x1dc)+getUserDomain()),console[_0x1d9e52(0x1da)]('\x20\x20runtimeDomain:\x20\x20\x20'+getRuntimeDomain()),console[_0x1d9e52(0x1da)](_0x1d9e52(0x233)+getSkillDomain()),console['log'](_0x1d9e52(0x1e6)+(getKbServiceDomain()??_0x1d9e52(0x1dd))));console[_0x1d9e52(0x1da)](),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x1d1)](_0x1d9e52(0x1f4))),console['log'](a32_0x1af0eb['gray'](_0x1d9e52(0x1bc)[_0x1d9e52(0x1cc)](0x1e)));const _0xc9372e=inspectServiceRegistry();console[_0x1d9e52(0x1da)](_0x1d9e52(0x226)+_0xc9372e[_0x1d9e52(0x1e0)]),console[_0x1d9e52(0x1da)]('\x20\x20Status:\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+formatServiceRegistryStatus(_0xc9372e)),console[_0x1d9e52(0x1da)](_0x1d9e52(0x1c9)+_0xc9372e[_0x1d9e52(0x21c)]),console[_0x1d9e52(0x1da)](_0x1d9e52(0x20e)+_0xc9372e['commandCount']);for(const _0x6bd7f6 of _0xc9372e[_0x1d9e52(0x221)]){console[_0x1d9e52(0x1da)]('\x20\x20'+(_0x6bd7f6['serviceCode']+':')[_0x1d9e52(0x1fb)](0x11)+'\x20'+(_0x6bd7f6['name']||a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1be)))+'\x20('+_0x6bd7f6[_0x1d9e52(0x218)]+_0x1d9e52(0x206)),console[_0x1d9e52(0x1da)]('\x20\x20'+''[_0x1d9e52(0x1fb)](0x11)+_0x1d9e52(0x1fc)+_0x6bd7f6['source'][_0x1d9e52(0x1bb)]);}return console[_0x1d9e52(0x1da)](),console['log'](a32_0x1af0eb['bold'](_0x1d9e52(0x222))),console[_0x1d9e52(0x1da)](a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1bc)[_0x1d9e52(0x1cc)](0x1e))),console[_0x1d9e52(0x1da)](_0x1d9e52(0x1b9)+a32_0x1af0eb[_0x1d9e52(0x205)](AUTH_MODE['ClientAk']+_0x1d9e52(0x1e2))),console['log'](_0x1d9e52(0x20d)+a32_0x1af0eb[_0x1d9e52(0x201)](_0x1d9e52(0x1ea))),console[_0x1d9e52(0x1da)](),{'ok':!![]};}function formatServiceRegistryStatus(_0x446be2){const _0x5a6075=a32_0x39a5;if(_0x446be2[_0x5a6075(0x1e9)]==='ok')return a32_0x1af0eb[_0x5a6075(0x205)]('✓\x20Loaded');if(_0x446be2['status']==='missing')return a32_0x1af0eb[_0x5a6075(0x201)](_0x5a6075(0x20a));if(_0x446be2[_0x5a6075(0x1e9)]===_0x5a6075(0x21d))return a32_0x1af0eb[_0x5a6075(0x215)]('⚠\x20Empty');return a32_0x1af0eb[_0x5a6075(0x1b6)]('✗\x20Invalid'+(_0x446be2[_0x5a6075(0x225)]?':\x20'+_0x446be2[_0x5a6075(0x225)]:''));}export const doctorDefinition={'service':a32_0x29b9d1(0x234),'command':a32_0x29b9d1(0x1d7),'description':a32_0x29b9d1(0x1fa),'risk':a32_0x29b9d1(0x20b),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'flags':[],'execute':execute};
|
|
1
|
+
import chalk from"chalk";import{CLI_BIN_NAME}from"../constant/cli.js";import{DEFAULT_CONFIG_VALUES}from"../constant/defaults.js";import{getCliVersion}from"../utils/version.js";import{getApiDomain,getKbServiceDomain,getRuntimeDomain,getSkillDomain,getUserDomain}from"../constant/domain.js";import{normalizeLovrabetRegion}from"../constant/region.js";import{buildConfigFromFlags,initGlobalEnvironment,getProjectConfigPath,getGlobalConfigPath,inspectCliConfigJsonFile,loadRawConfigLayers}from"../context.js";import{AUTH_MODE}from"../constant/auth-mode.js";import{inspectServiceRegistry}from"../commands/service/registry.js";import{inspectBuiltinSkill}from"../skills/builtin-skill.js";async function execute(ctx){const cliVersion=getCliVersion();const resolved=buildConfigFromFlags({app:ctx.str?.("app"),appcode:ctx.str?.("appcode"),env:ctx.str?.("env")});let effectiveRegion;let regionError;try{effectiveRegion=normalizeLovrabetRegion(resolved.raw.region)}catch(err){
|
|
2
|
+
regionError=err instanceof Error?err:new Error(String(err))}let routingError;if(!regionError){try{await initGlobalEnvironment(resolved)}catch(err){routingError=err instanceof Error?err:new Error(String(err))}}console.log();console.log(chalk.bold(`${CLI_BIN_NAME} doctor`));console.log(chalk.gray("─".repeat(50)));console.log(` CLI Version: ${cliVersion}`);console.log(` Node: ${process.version}`);console.log(` Platform: ${process.platform} ${process.arch}`);const builtinSkill=inspectBuiltinSkill();console.log();console.log(chalk.bold(" Built-in Skill"));console.log(chalk.gray(" ─".repeat(30)));console.log(` State: ${builtinSkill.state==="current"?chalk.green("✓ current"):chalk.red(`✗ ${builtinSkill.state}`)}`);console.log(` Package Version: ${builtinSkill.packageVersion}`);console.log(` Skill Version: ${builtinSkill.skillVersion||chalk.gray("(missing)")}`);console.log(` Installed Path: ${builtinSkill.installedPath||chalk.gray("(not found)")}`)
|
|
3
|
+
;if(builtinSkill.state!=="current"){console.log(` Repair: ${builtinSkill.repairCommand}`)}if(builtinSkill.reason){console.log(` Reason: ${builtinSkill.reason}`)}console.log();console.log(chalk.bold(" Config Files"));console.log(chalk.gray(" ─".repeat(30)));const globalPath=getGlobalConfigPath();const projectPath=getProjectConfigPath();console.log(` Global: ${globalPath||chalk.gray("(not found)")}`);console.log(` Project: ${projectPath||chalk.gray("(not found)")}`);console.log();console.log(chalk.bold(" Config JSON"));console.log(chalk.gray(" ─".repeat(30)));const printJsonDiag=(label,path)=>{if(!path){console.log(` ${label.padEnd(17)} ${chalk.gray("(no file)")}`);return}const r=inspectCliConfigJsonFile(path);if(r.status==="ok"){console.log(` ${label.padEnd(17)} ${chalk.green("✓ Valid JSON")}`)}else if(r.status==="empty"){console.log(` ${label.padEnd(17)} ${chalk.yellow("⚠ Empty (treated as {})")}`)}else if(r.status==="missing"){
|
|
4
|
+
console.log(` ${label.padEnd(17)} ${chalk.gray("(missing)")}`)}else{console.log(` ${label.padEnd(17)} ${chalk.red("✗ Invalid JSON")}`);console.log(` ${"".padEnd(17)} ${chalk.red(r.message)}`)}};printJsonDiag("Global",globalPath);printJsonDiag("Project",projectPath);const configLayers=loadRawConfigLayers();const legacyInheritScopes=[Object.prototype.hasOwnProperty.call(configLayers.globalConfig,"inherit")?"global":null,Object.prototype.hasOwnProperty.call(configLayers.projectConfig,"inherit")?"project":null].filter(Boolean);if(legacyInheritScopes.length>0){console.log(` Legacy inherit: ${chalk.yellow(`ignored in ${legacyInheritScopes.join(" + ")} config`)}`);if(legacyInheritScopes.includes("project")){console.log(` Repair project: ${CLI_BIN_NAME} config delete inherit`)}if(legacyInheritScopes.includes("global")){console.log(` Repair global: ${CLI_BIN_NAME} config delete inherit --global`)}}if(routingError){console.log();console.log(chalk.bold(" Routing Configuration"))
|
|
5
|
+
;console.log(chalk.gray(" ─".repeat(30)));console.log(` Status: ${chalk.red("✗ Invalid")}`);console.log(` Reason: ${routingError.message}`);if(Object.prototype.hasOwnProperty.call(configLayers.projectConfig,"routing")){console.log(` Repair project: ${CLI_BIN_NAME} config delete routing`)}if(Object.prototype.hasOwnProperty.call(configLayers.globalConfig,"routing")){console.log(` Repair global: ${CLI_BIN_NAME} config delete routing --global`)}}if(regionError){console.log();console.log(chalk.bold(" Country/Region Configuration"));console.log(chalk.gray(" ─".repeat(30)));console.log(` Status: ${chalk.red("✗ Invalid")}`);console.log(` Reason: ${regionError.message}`);if(Object.prototype.hasOwnProperty.call(configLayers.projectConfig,"region")){console.log(` Repair project: ${CLI_BIN_NAME} config delete region`)}if(Object.prototype.hasOwnProperty.call(configLayers.globalConfig,"region")){
|
|
6
|
+
console.log(` Repair global: ${CLI_BIN_NAME} config init`)}}console.log();console.log(chalk.bold(" Merged Config"));console.log(" App selection does not switch credentials or identity.");console.log(" Local configuration does not verify identity or operation permissions; the server enforces access.");console.log(chalk.gray(" ─".repeat(30)));console.log(` appCode: ${resolved.appCode||chalk.red("(not set)")}`);console.log(` region: ${effectiveRegion??chalk.red("(invalid)")}`);console.log(` app locale: ${resolved.locale}`);console.log(` defaultApp: ${resolved.defaultApp||chalk.gray("(none)")}`);console.log(` currentApp: ${resolved.currentApp||chalk.gray("(none)")}`);console.log(` format: ${resolved.format||chalk.gray(`(default: ${DEFAULT_CONFIG_VALUES.format})`)}`);console.log(` pageSize: ${resolved.pageSize??chalk.gray("(default)")}`);console.log(` riskLevel: ${resolved.riskLevel}`)
|
|
7
|
+
;console.log(` verbose: ${resolved.verbose}`);console.log(` auth (effective): ${AUTH_MODE.ClientAk}`);if(resolved.accessKeySource)console.log(` AK source: ${resolved.accessKeySource}`);console.log(` accessKey: ${resolved.accessKey?chalk.green("(set, length="+resolved.accessKey.length+")"):chalk.gray("(none)")}`);console.log();console.log(chalk.bold(" API Endpoints"));console.log(chalk.gray(" ─".repeat(30)));if(routingError||regionError){console.log(` Status: ${chalk.red("Unavailable until routing configuration is repaired")}`)}else{console.log(` apiDomain: ${getApiDomain()}`);console.log(` userDomain: ${getUserDomain()}`);console.log(` runtimeDomain: ${getRuntimeDomain()}`);console.log(` skillDomain: ${getSkillDomain()}`);console.log(` kbServiceDomain: ${getKbServiceDomain()??"not configured"}`)}console.log();console.log(chalk.bold(" Service Tree"));console.log(chalk.gray(" ─".repeat(30)))
|
|
8
|
+
;const serviceRegistry=inspectServiceRegistry();console.log(` Registry: ${serviceRegistry.registryPath}`);console.log(` Status: ${formatServiceRegistryStatus(serviceRegistry)}`);console.log(` Services: ${serviceRegistry.serviceCount}`);console.log(` Commands: ${serviceRegistry.commandCount}`);for(const service of serviceRegistry.services){console.log(` ${`${service.serviceCode}:`.padEnd(17)} ${service.name||chalk.gray("(unnamed)")} (${service.commandCount} commands)`);console.log(` ${"".padEnd(17)} Imported from: ${service.source.path}`)}console.log();console.log(chalk.bold(" Auth"));console.log(chalk.gray(" ─".repeat(30)));console.log(` Mode: ${chalk.green(`${AUTH_MODE.ClientAk} (accessKey)`)}`);console.log(` Session check: ${chalk.gray("(removed — cookie auth disabled)")}`);console.log();return{ok:true}}function formatServiceRegistryStatus(inspection){if(inspection.status==="ok")return chalk.green("✓ Loaded")
|
|
9
|
+
;if(inspection.status==="missing")return chalk.gray("(not found)");if(inspection.status==="empty")return chalk.yellow("⚠ Empty");return chalk.red(`✗ Invalid${inspection.message?`: ${inspection.message}`:""}`)}export const doctorDefinition={service:"doctor",command:"check",description:"Diagnose CLI configuration and environment",risk:"read",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:[],execute:execute};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{requireRuntimeUploadFile}from"../../commands/common/local-file.js";import{queryRuntimeFileUrl,uploadRuntimeFile}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{dryRun}from"../../framework/dryrun.js";const FILE_FLAG={name:"file",type:"string",required:true,description:"Path to the local file to upload"};const FILEPATH_FLAG={name:"filepath",type:"string",required:true,description:"Runtime filePath returned by file upload; store it in file fields and durable data"};const DOWNLOAD_FLAG={name:"download",type:"boolean",description:"Return a short-lived download URL instead of a short-lived preview URL"};const LONG_TERM_FLAG={name:"long-term",type:"boolean",description:"Return a 3-year URL for URL-only content embedding such as rich text, Markdown, or HTML"};function requireFilePath(filePath){const normalized=filePath.trim();if(!normalized){throw CliErrors.validation("filePath is required.")}return normalized}const fileUpload={service:"file",
|
|
2
|
+
command:"upload",description:"Upload a local file and return filePath for durable references",risk:"read",flags:[FILE_FLAG],async dryRun(ctx){const file=requireRuntimeUploadFile(ctx.str("file"),"File");return dryRun("POST","/client/uploadFile").body({appCode:ctx.appCode,multipart:{file:file}}).description(`Preview: upload ${file.path} to runtime app ${ctx.appCode}`).build()},async execute(ctx){const file=requireRuntimeUploadFile(ctx.str("file"),"File");const data=await uploadRuntimeFile(ctx.appCode,file.path);return{ok:true,data:data,message:data.filePath?`Uploaded file: ${data.filePath}. Store filePath for durable references; use file query-url for short-lived access.`:"Uploaded file. Store filePath for durable references; use file query-url for short-lived access."}}};const fileQueryUrl={service:"file",command:"query-url",description:"Query a short-lived URL for preview, download, OCR, or immediate access",risk:"read",flags:[FILEPATH_FLAG,DOWNLOAD_FLAG,LONG_TERM_FLAG],
|
|
3
|
+
async execute(ctx){const filePath=requireFilePath(ctx.str("filepath"));const data=await queryRuntimeFileUrl(filePath,{download:ctx.bool("download"),longTerm:ctx.bool("long-term")});return{ok:true,data:data}}};export const fileDefinitions=[fileUpload,fileQueryUrl];
|
package/lib/commands/init.js
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{resolve,isAbsolute}from"node:path";import{CliErrors}from"../errors.js";import{DEFAULT_CONFIG_VALUES}from"../constant/defaults.js";import{RUNTIME_ENV_VALUES}from"../constant/env.js";import{IMPORTABLE_RUNTIME_CONFIG_KEYS}from"../config/schema.js";import{resolveWriteConfigPath,readConfigFile,writeConfigFile}from"../context.js";import{PRODUCT_CONFIG}from"../constant/product.js";export const appImportFlagDefs=[{name:"file",type:"string",description:"Import from a .rabetbase.json file path",required:true},{name:"appcode",type:"string",description:"Override imported default appcode"},{name:"env",type:"string",description:"Override imported default env",enum:[...RUNTIME_ENV_VALUES]},{name:"global",type:"boolean",description:`Write to global (~/${PRODUCT_CONFIG.newConfigFileName}) instead of project`,default:false},{name:"yes",type:"boolean",description:"Skip confirmation when overwriting",default:false}]
|
|
2
|
+
;export async function runAppImport(flags){const scope=flags.global?"global":"project";const configPath=resolveWriteConfigPath(scope);await runFromImport(flags,configPath)}async function runFromImport(flags,configPath){const fromPath=resolveFilePath(flags.file);if(!existsSync(fromPath)){throw CliErrors.validation(`Source file not found: ${fromPath}`)}const source=readSourceFile(fromPath);const imported=convertToRuntimeConfig(source);if(flags.appcode){imported.appcode=String(flags.appcode)}if(flags.env){imported.env=resolveImportEnv(flags)}if(!imported.appcode){throw CliErrors.validation("Source file does not contain an importable appcode.",`Provide --appcode <code> or use an upgraded .rabetbase.json with top-level appcode. Legacy files must be upgraded first with \`rabetbase project upgrade\`.`)}await writeImportConfig(configPath,imported,flags);console.log(`Imported from ${fromPath}`);console.log(` config: ${configPath}`);console.log(` appcode: ${imported.appcode}`)
|
|
3
|
+
;if(imported.defaultApp)console.log(` default: ${imported.defaultApp}`)}function convertToRuntimeConfig(source){if(source.apps&&typeof source.apps==="object"){throw CliErrors.validation("Legacy / multi-app .rabetbase.json is no longer supported for import.","Run `rabetbase project upgrade` first, then retry `lovrabet app import`.")}const result={};for(const key of IMPORTABLE_RUNTIME_CONFIG_KEYS){if(source[key]!==undefined){result[key]=source[key]}}if(!result.riskLevel){result.riskLevel=DEFAULT_CONFIG_VALUES.riskLevel}return result}async function writeImportConfig(configPath,imported,flags){let config={};if(existsSync(configPath)&&!flags.yes){config=readConfigFile(configPath)}for(const[key,value]of Object.entries(imported)){if(value!==undefined){config[key]=value}}if(config.app)delete config.app;writeConfigFile(configPath,config)}function resolveFilePath(input){return isAbsolute(input)?input:resolve(process.cwd(),input)}function readSourceFile(filePath){try{
|
|
4
|
+
const raw=readFileSync(filePath,{encoding:"utf8"});return JSON.parse(raw)}catch(e){throw CliErrors.validation(`Failed to parse source file: ${e.message}`)}}function resolveImportEnv(flags){const env=flags.env;if(env===undefined||env===""){return DEFAULT_CONFIG_VALUES.env}if(!RUNTIME_ENV_VALUES.includes(env)){throw CliErrors.validation(`Invalid env "${env}". Allowed: ${RUNTIME_ENV_VALUES.join(", ")}`)}return env}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{platform,release,arch}from"node:os";import{getLoginUserInfo}from"../../core/api-client.js";import{getCliVersion}from"../../utils/version.js";export async function getIssueReportContext(ctx,dryRun){const user=dryRun?undefined:await getLoginUserInfo();return{serviceName:"@lovrabet/lovrabet-cli",serviceVersion:getCliVersion(),environment:ctx.envName??"production",appCode:ctx.appCode||ctx.mergedCli?.appCode,os:`${platform()} ${release()} ${arch()}`,terminal:process.env.TERM,user:user?{id:String(user.id??user.userId??""),username:user.username??user.userName??user.loginName,nickname:user.nickname??user.nickName??user.name??undefined,email:user.email??undefined,tenantCode:user.tenantCode}:undefined}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{issueReport}from"./report.js";export const issueDefinitions=[issueReport];
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{existsSync}from"node:fs";import{readFile}from"node:fs/promises";import{resolve}from"node:path";import{CliErrors}from"../../errors.js";import{reportIssue}from"@lovrabet/cli-framework";import{getIssueReportContext}from"./context.js";const DESCRIPTION_FILE_FLAG="description-file";export const issueReport={service:"issue",command:"report",description:"Report a problem log with title and markdown context",risk:"read",confirmationDescription:"Submit the issue description and diagnostic context as a problem log.",requiresAuth:true,requiresAppCode:false,defaultOutputFormat:"compress",flags:[{name:"title",type:"string",required:true,description:"One-line issue summary"},{name:"description",type:"string",description:"Inline markdown issue description (alternative to --description-file)"},{name:DESCRIPTION_FILE_FLAG,type:"string",description:"Path to a markdown file whose contents become issue.description"}],async validate(ctx){const title=ctx.str("title").trim()
|
|
2
|
+
;const inlineDescription=ctx.str("description").trim();const descriptionFile=ctx.str(DESCRIPTION_FILE_FLAG).trim();if(!title){throw CliErrors.flagMissing("title","Provide --title with a one-line issue summary.")}const hasInlineDescription=inlineDescription.length>0;const hasDescriptionFile=descriptionFile.length>0;if(hasInlineDescription===hasDescriptionFile){throw CliErrors.validation("Provide exactly one of --description or --description-file.","Use --description for short markdown text, or --description-file for full issue context.")}if(hasDescriptionFile){const absPath=resolve(process.cwd(),descriptionFile);if(!existsSync(absPath)){throw CliErrors.validation(`File not found: ${absPath}`)}}},async dryRun(ctx){const report=await prepareIssueReport(ctx,true);return{method:"POST",url:`otel://${report.traceName}/${report.spanName}`,body:{traceName:report.traceName,spanName:report.spanName,logData:report.logData},
|
|
3
|
+
description:["Submit a problem log",`descriptionSource: ${report.descriptionSource}`,report.descriptionFilePath?`descriptionFile: ${report.descriptionFilePath}`:null,report.sanitize.truncated?`truncated: original ${report.sanitize.originalBytes} bytes`:null,report.sanitize.redactionCount>0?`redactions: ${report.sanitize.redactionCount} (${report.sanitize.redactionKinds.join(", ")})`:null].filter(Boolean).join("\n")}},async execute(ctx){const report=await prepareIssueReport(ctx,false);return{ok:true,message:report.sanitize.redactionCount||report.sanitize.truncated?"Issue log submitted (content redacted or truncated)":"Issue log submitted",data:{traceName:report.traceName,spanName:report.spanName,logDataKeys:Object.keys(report.logData),issue:{title:report.title,descriptionLength:report.description.length,descriptionSource:report.descriptionSource,...report.descriptionFilePath?{descriptionFile:report.descriptionFilePath}:{},sanitize:{originalBytes:report.sanitize.originalBytes,
|
|
4
|
+
truncated:report.sanitize.truncated,redactions:report.sanitize.redactionCount,redactionKinds:report.sanitize.redactionKinds}}}}}};async function prepareIssueReport(ctx,dryRun){await issueReport.validate(ctx);const descriptionFile=ctx.str(DESCRIPTION_FILE_FLAG).trim();const descriptionFilePath=descriptionFile?resolve(process.cwd(),descriptionFile):undefined;let description=ctx.str("description");if(descriptionFilePath){try{description=await readFile(descriptionFilePath,"utf8")}catch{throw CliErrors.validation(`Cannot read issue description file: ${descriptionFilePath}`)}}if(!description.trim())throw CliErrors.validation("Issue description cannot be empty.");const context=await getIssueReportContext(ctx,dryRun);try{const report=await reportIssue({title:ctx.str("title"),description:description,context:context,dryRun:dryRun});return{...report,descriptionSource:descriptionFilePath?"file":"inline",descriptionFilePath:descriptionFilePath}}catch(error){
|
|
5
|
+
throw CliErrors.apiError(`Failed to submit issue log: ${error instanceof Error?error.message:String(error)}`,"Check your login and network connectivity.")}}
|
package/lib/commands/kb/index.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
const a38_0x48d3ee=a38_0x3884;(function(_0x2e0667,_0x5841dd){const _0x32466c=a38_0x3884,_0x2d43b8=_0x2e0667();while(!![]){try{const _0x4546cd=-parseInt(_0x32466c(0x137))/0x1*(parseInt(_0x32466c(0x130))/0x2)+-parseInt(_0x32466c(0xfd))/0x3*(parseInt(_0x32466c(0x13f))/0x4)+parseInt(_0x32466c(0x11f))/0x5*(parseInt(_0x32466c(0x115))/0x6)+parseInt(_0x32466c(0x10d))/0x7*(parseInt(_0x32466c(0x12c))/0x8)+-parseInt(_0x32466c(0x121))/0x9+parseInt(_0x32466c(0x113))/0xa*(parseInt(_0x32466c(0x12b))/0xb)+parseInt(_0x32466c(0x108))/0xc*(-parseInt(_0x32466c(0x100))/0xd);if(_0x4546cd===_0x5841dd)break;else _0x2d43b8['push'](_0x2d43b8['shift']());}catch(_0x3e6abf){_0x2d43b8['push'](_0x2d43b8['shift']());}}}(a38_0x3042,0x34e67));import{existsSync,readFileSync,statSync}from'node:fs';import{createPersonalKnowledgeBaseItem,getPersonalKnowledgeBaseItem,listPersonalKnowledgeBaseItems,updatePersonalKnowledgeBaseItem}from'../../core/api-client.js';import{searchDirectKnowledge,normalizeKbServiceOrigin}from'../../core/kb-search-client.js';function a38_0x3042(){const _0x2a9155=['scope','Updated\x20KB\x20entry\x20','execute','Create\x20a\x20personal\x20knowledge-base\x20entry\x20from\x20a\x20local\x20file','10LUPzio','Created\x20KB\x20entry\x20','378639JPHbGJ','build','method','File\x20not\x20found:\x20','Personal\x20knowledge-base\x20entry\x20title','--topk\x20must\x20be\x20an\x20integer\x20from\x201\x20through\x2050.','List\x20personal\x20knowledge-base\x20entries\x20for\x20the\x20current\x20app','num','Saves\x20local\x20file\x20content\x20as\x20a\x20personal\x20knowledge-base\x20entry\x20and\x20starts\x20retrieval\x20sync.','Configure\x20kbServiceDomain\x20in\x20the\x20connection\x20settings,\x20or\x20pass\x20`--kb-service-url\x20<https-origin>`\x20for\x20this\x20request.','2155307OAvFQm','2440SIkIJv','userId','str','isSafeInteger','2284VeWlOt','body','Personal\x20knowledge-base\x20entry\x20ID','Search\x20query\x20for\x20visible\x20public,\x20company,\x20and\x20personal\x20knowledge','read','flag','verbose','94pjtSIb','kb-service-url','Override\x20the\x20existing\x20entry\x20title','length','dryRun','write','Show\x20one\x20personal\x20knowledge-base\x20entry\x20by\x20id','createTime','673036ykAaMw','number','Search\x20visible\x20public,\x20company,\x20and\x20personal\x20knowledge','content','updateTime','Preview:\x20create\x20personal\x20knowledge-base\x20entry\x20\x22','3rSmSsU','title','appCode','13JoyHiL','string','version','detail','search','ragStatus','description','accessKey','4771956rIQkNr','Update\x20a\x20personal\x20knowledge-base\x20entry\x20from\x20a\x20local\x20file','signal','utf8','query','9219syjFBJ','topk','validation','file','path','trim','10VXxpMr','jsonBody','1003194XQILHn','Optional\x20trusted\x20KB\x20Service\x20HTTPS\x20origin\x20for\x20this\x20request\x20only','parse','Maximum\x20number\x20of\x20search\x20hits\x20to\x20return','create','bool'];a38_0x3042=function(){return _0x2a9155;};return a38_0x3042();}import{planPersonalKnowledgeWrite,withKbManagementOrigin}from'../../core/kb-management-client.js';import{ID_FLAG,VERBOSE_FLAG}from'../../commands/common/flags.js';import{CliErrors}from'../../errors.js';import{getKbServiceDomain}from'../../constant/domain.js';import{dryRun}from'../../framework/dryrun.js';const TITLE_FLAG={'name':a38_0x48d3ee(0xfe),'type':'string','required':!![],'description':a38_0x48d3ee(0x125)},FILE_FLAG={'name':a38_0x48d3ee(0x110),'type':'string','required':!![],'description':'Path\x20to\x20a\x20local\x20UTF-8\x20text\x20or\x20Markdown\x20file'},QUERY_FLAG={'name':a38_0x48d3ee(0x10c),'type':a38_0x48d3ee(0x101),'required':!![],'description':a38_0x48d3ee(0x133)},TOPK_FLAG={'name':'topk','type':a38_0x48d3ee(0xf8),'description':a38_0x48d3ee(0x118)};function readKnowledgeFile(_0x77a0a4){const _0x1fcb2e=a38_0x48d3ee;if(!_0x77a0a4)throw CliErrors['validation']('File\x20path\x20is\x20required.');if(!existsSync(_0x77a0a4))throw CliErrors[_0x1fcb2e(0x10f)](_0x1fcb2e(0x124)+_0x77a0a4);if(!statSync(_0x77a0a4)['isFile']())throw CliErrors['validation']('File\x20is\x20not\x20a\x20regular\x20file:\x20'+_0x77a0a4);return readFileSync(_0x77a0a4,_0x1fcb2e(0x10b));}function a38_0x3884(_0x5ace70,_0x494b5b){_0x5ace70=_0x5ace70-0xf8;const _0x304208=a38_0x3042();let _0x388486=_0x304208[_0x5ace70];return _0x388486;}function summarizePersonalItem(_0x1b2550){const _0x5f5a6d=a38_0x48d3ee;return{'id':_0x1b2550['id'],'title':_0x1b2550[_0x5f5a6d(0xfe)],'version':_0x1b2550['version'],'ragStatus':_0x1b2550[_0x5f5a6d(0x105)],'ragErrorMessage':_0x1b2550['ragErrorMessage'],'updateTime':_0x1b2550['updateTime']};}function detailPersonalItem(_0x316d33){const _0x1a2bdc=a38_0x48d3ee;return{'id':_0x316d33['id'],'appCode':_0x316d33[_0x1a2bdc(0xff)],'scope':_0x316d33[_0x1a2bdc(0x11b)],'userId':_0x316d33[_0x1a2bdc(0x12d)],'title':_0x316d33[_0x1a2bdc(0xfe)],'content':_0x316d33[_0x1a2bdc(0xfa)],'version':_0x316d33[_0x1a2bdc(0x102)],'ragStatus':_0x316d33[_0x1a2bdc(0x105)],'ragErrorMessage':_0x316d33['ragErrorMessage'],'createTime':_0x316d33[_0x1a2bdc(0x13e)],'updateTime':_0x316d33[_0x1a2bdc(0xfb)]};}function readTopK(_0x53f90a){const _0xa8ba2f=a38_0x48d3ee,_0x25e4aa=_0x53f90a[_0xa8ba2f(0x135)](_0xa8ba2f(0x10e));if(_0x25e4aa===undefined||_0x25e4aa===null||_0x25e4aa==='')return undefined;const _0x1ca564=_0x53f90a[_0xa8ba2f(0x128)](_0xa8ba2f(0x10e));if(!Number[_0xa8ba2f(0x12f)](_0x1ca564)||_0x1ca564<0x1||_0x1ca564>0x32)throw CliErrors[_0xa8ba2f(0x10f)](_0xa8ba2f(0x126));return _0x1ca564;}const kbList={'service':'kb','command':'list','description':a38_0x48d3ee(0x127),'risk':a38_0x48d3ee(0x134),'flags':[VERBOSE_FLAG],async 'execute'(_0x4e0e88){const _0x130228=a38_0x48d3ee,_0xbc025d=await listPersonalKnowledgeBaseItems(_0x4e0e88[_0x130228(0xff)],_0x4e0e88[_0x130228(0x10a)]);if(_0x4e0e88[_0x130228(0x11a)](_0x130228(0x136)))return{'ok':!![],'data':{'total':_0xbc025d[_0x130228(0x13a)],'items':_0xbc025d}};return{'ok':!![],'data':{'total':_0xbc025d['length'],'items':_0xbc025d['map'](summarizePersonalItem)}};}},kbDetail={'service':'kb','command':a38_0x48d3ee(0x103),'description':a38_0x48d3ee(0x13d),'risk':'read','flags':[{...ID_FLAG,'type':a38_0x48d3ee(0x101),'description':a38_0x48d3ee(0x132)}],async 'execute'(_0x7513a7){const _0x1d7fa0=a38_0x48d3ee,_0x4e19da=await getPersonalKnowledgeBaseItem(_0x7513a7['str']('id'),_0x7513a7[_0x1d7fa0(0xff)],_0x7513a7[_0x1d7fa0(0x10a)]);return{'ok':!![],'data':detailPersonalItem(_0x4e19da)};}},kbCreate={'service':'kb','command':a38_0x48d3ee(0x119),'description':a38_0x48d3ee(0x11e),'risk':a38_0x48d3ee(0x13c),'confirmationDescription':a38_0x48d3ee(0x129),'flags':[TITLE_FLAG,FILE_FLAG],async 'execute'(_0x232477){const _0x1ecbfe=a38_0x48d3ee,_0x5ecfdf=_0x232477[_0x1ecbfe(0x12e)](_0x1ecbfe(0xfe)),_0x3d7242=readKnowledgeFile(_0x232477['str'](_0x1ecbfe(0x110))),_0x17f726=await createPersonalKnowledgeBaseItem(_0x232477['appCode'],{'title':_0x5ecfdf,'content':_0x3d7242},_0x232477['signal']);return{'ok':!![],'data':summarizePersonalItem(_0x17f726),'message':_0x1ecbfe(0x120)+_0x17f726['id']+'\x20('+_0x17f726[_0x1ecbfe(0xfe)]+')'};},async 'dryRun'(_0x345a5a){const _0x3981ac=a38_0x48d3ee,_0x15e2f3=_0x345a5a['str']('title'),_0x51303b=readKnowledgeFile(_0x345a5a[_0x3981ac(0x12e)](_0x3981ac(0x110))),_0x797191=planPersonalKnowledgeWrite(_0x345a5a[_0x3981ac(0xff)],{'title':_0x15e2f3,'content':_0x51303b});return dryRun(_0x797191['method'],_0x797191[_0x3981ac(0x111)])[_0x3981ac(0x131)](JSON[_0x3981ac(0x117)](_0x797191[_0x3981ac(0x114)]))[_0x3981ac(0x106)](_0x3981ac(0xfc)+_0x15e2f3+'\x22')[_0x3981ac(0x122)]();}},kbUpdate={'service':'kb','command':'update','description':a38_0x48d3ee(0x109),'risk':a38_0x48d3ee(0x13c),'confirmationDescription':'Replaces\x20the\x20personal\x20knowledge-base\x20entry\x20body\x20with\x20local\x20file\x20content\x20and\x20triggers\x20retrieval\x20sync.','flags':[{...ID_FLAG,'type':'string','description':a38_0x48d3ee(0x132)},{...TITLE_FLAG,'required':![],'description':a38_0x48d3ee(0x139)},FILE_FLAG],async 'execute'(_0xe930fd){const _0x3faee7=a38_0x48d3ee,_0xde226a=_0xe930fd[_0x3faee7(0x12e)]('id'),_0x41ab3b=readKnowledgeFile(_0xe930fd['str'](_0x3faee7(0x110))),_0x30dc97=_0xe930fd[_0x3faee7(0x12e)]('title')||undefined,_0x2dbf56=await updatePersonalKnowledgeBaseItem(_0xde226a,_0xe930fd[_0x3faee7(0xff)],{'title':_0x30dc97,'content':_0x41ab3b},_0xe930fd[_0x3faee7(0x10a)]);return{'ok':!![],'data':summarizePersonalItem(_0x2dbf56),'message':_0x3faee7(0x11c)+_0x2dbf56['id']+'\x20('+_0x2dbf56[_0x3faee7(0xfe)]+')'};},async 'dryRun'(_0x338394){const _0x2c9539=a38_0x48d3ee,_0x1c2393=_0x338394[_0x2c9539(0x12e)]('id'),_0x31b531=readKnowledgeFile(_0x338394[_0x2c9539(0x12e)]('file')),_0x36d3f6=await getPersonalKnowledgeBaseItem(_0x1c2393,_0x338394[_0x2c9539(0xff)],_0x338394[_0x2c9539(0x10a)]),_0x2b3ab8=_0x338394[_0x2c9539(0x12e)](_0x2c9539(0xfe))||_0x36d3f6[_0x2c9539(0xfe)],_0x46b270=planPersonalKnowledgeWrite(_0x338394[_0x2c9539(0xff)],{'title':_0x2b3ab8,'content':_0x31b531},_0x1c2393,_0x36d3f6['version']);return dryRun(_0x46b270[_0x2c9539(0x123)],_0x46b270[_0x2c9539(0x111)])[_0x2c9539(0x131)](JSON[_0x2c9539(0x117)](_0x46b270[_0x2c9539(0x114)]))[_0x2c9539(0x106)]('Preview:\x20update\x20personal\x20knowledge-base\x20entry\x20'+_0x1c2393)[_0x2c9539(0x122)]();}};function readSearchServiceUrl(_0x34a8dd){const _0x2a44f9=a38_0x48d3ee;if(_0x34a8dd['flag'](_0x2a44f9(0x138))!==undefined)return normalizeKbServiceOrigin(_0x34a8dd[_0x2a44f9(0x12e)]('kb-service-url'));const _0x489520=getKbServiceDomain();if(!_0x489520)throw CliErrors[_0x2a44f9(0x10f)]('KB\x20Service\x20is\x20not\x20configured\x20for\x20knowledge\x20search.',_0x2a44f9(0x12a));return normalizeKbServiceOrigin(_0x489520);}const kbSearch={'service':'kb','command':a38_0x48d3ee(0x104),'description':a38_0x48d3ee(0xf9),'risk':a38_0x48d3ee(0x134),'flags':[QUERY_FLAG,TOPK_FLAG,{'name':a38_0x48d3ee(0x138),'type':a38_0x48d3ee(0x101),'required':![],'description':a38_0x48d3ee(0x116)}],async 'validate'(_0x5a2aa1){const _0x19922d=a38_0x48d3ee;if(!_0x5a2aa1['str'](_0x19922d(0x10c))[_0x19922d(0x112)]())throw CliErrors['validation']('Search\x20query\x20is\x20required.');readTopK(_0x5a2aa1),readSearchServiceUrl(_0x5a2aa1);},async 'execute'(_0x2ca1f7){const _0x1b05b5=a38_0x48d3ee,_0x498732=_0x2ca1f7[_0x1b05b5(0x12e)]('query')[_0x1b05b5(0x112)](),_0x4186f6=readTopK(_0x2ca1f7),_0x456e26=readSearchServiceUrl(_0x2ca1f7),_0x375f50={'appCode':_0x2ca1f7['appCode'],'accessKey':_0x2ca1f7[_0x1b05b5(0x107)]??'','query':_0x498732,..._0x4186f6!==undefined?{'topK':_0x4186f6}:{},'signal':_0x2ca1f7[_0x1b05b5(0x10a)]},_0x4e8766=await searchDirectKnowledge({..._0x375f50,'serviceUrl':_0x456e26});return{'ok':!![],'data':_0x4e8766};}};function managementCommand(_0x436d82){const _0xee4042=a38_0x48d3ee;return{..._0x436d82,'execute':_0x5c5a94=>withKbManagementOrigin(()=>_0x436d82[_0xee4042(0x11d)](_0x5c5a94)),..._0x436d82[_0xee4042(0x13b)]?{'dryRun':_0x4fe5fd=>withKbManagementOrigin(()=>_0x436d82['dryRun'](_0x4fe5fd))}:{}};}export const kbDefinitions=[...[kbList,kbDetail,kbCreate,kbUpdate]['map'](managementCommand),kbSearch];
|
|
1
|
+
import{existsSync,readFileSync,statSync}from"node:fs";import{createPersonalKnowledgeBaseItem,getPersonalKnowledgeBaseItem,listPersonalKnowledgeBaseItems,updatePersonalKnowledgeBaseItem}from"../../core/api-client.js";import{searchDirectKnowledge,normalizeKbServiceOrigin}from"../../core/kb-search-client.js";import{planPersonalKnowledgeWrite,withKbManagementOrigin}from"../../core/kb-management-client.js";import{ID_FLAG,VERBOSE_FLAG}from"../../commands/common/flags.js";import{CliErrors}from"../../errors.js";import{getKbServiceDomain}from"../../constant/domain.js";import{dryRun}from"../../framework/dryrun.js";const TITLE_FLAG={name:"title",type:"string",required:true,description:"Personal knowledge-base entry title"};const FILE_FLAG={name:"file",type:"string",required:true,description:"Path to a local UTF-8 text or Markdown file"};const QUERY_FLAG={name:"query",type:"string",required:true,description:"Search query for visible public, company, and personal knowledge"};const TOPK_FLAG={
|
|
2
|
+
name:"topk",type:"number",description:"Maximum number of search hits to return"};function readKnowledgeFile(path){if(!path){throw CliErrors.validation("File path is required.")}if(!existsSync(path)){throw CliErrors.validation(`File not found: ${path}`)}if(!statSync(path).isFile()){throw CliErrors.validation(`File is not a regular file: ${path}`)}return readFileSync(path,"utf8")}function summarizePersonalItem(item){return{id:item.id,title:item.title,version:item.version,ragStatus:item.ragStatus,ragErrorMessage:item.ragErrorMessage,updateTime:item.updateTime}}function detailPersonalItem(item){return{id:item.id,appCode:item.appCode,scope:item.scope,userId:item.userId,title:item.title,content:item.content,version:item.version,ragStatus:item.ragStatus,ragErrorMessage:item.ragErrorMessage,createTime:item.createTime,updateTime:item.updateTime}}function readTopK(ctx){const value=ctx.flag("topk");if(value===undefined||value===null||value===""){return undefined}const topK=ctx.num("topk")
|
|
3
|
+
;if(!Number.isSafeInteger(topK)||topK<1||topK>50){throw CliErrors.validation("--topk must be an integer from 1 through 50.")}return topK}const kbList={service:"kb",command:"list",description:"List personal knowledge-base entries for the current app",risk:"read",flags:[VERBOSE_FLAG],async execute(ctx){const items=await listPersonalKnowledgeBaseItems(ctx.appCode,ctx.signal);if(ctx.bool("verbose")){return{ok:true,data:{total:items.length,items:items}}}return{ok:true,data:{total:items.length,items:items.map(summarizePersonalItem)}}}};const kbDetail={service:"kb",command:"detail",description:"Show one personal knowledge-base entry by id",risk:"read",flags:[{...ID_FLAG,type:"string",description:"Personal knowledge-base entry ID"}],async execute(ctx){const item=await getPersonalKnowledgeBaseItem(ctx.str("id"),ctx.appCode,ctx.signal);return{ok:true,data:detailPersonalItem(item)}}};const kbCreate={service:"kb",command:"create",
|
|
4
|
+
description:"Create a personal knowledge-base entry from a local file",risk:"write",confirmationDescription:"Saves local file content as a personal knowledge-base entry and starts retrieval sync.",flags:[TITLE_FLAG,FILE_FLAG],async execute(ctx){const title=ctx.str("title");const content=readKnowledgeFile(ctx.str("file"));const item=await createPersonalKnowledgeBaseItem(ctx.appCode,{title:title,content:content},ctx.signal);return{ok:true,data:summarizePersonalItem(item),message:`Created KB entry ${item.id} (${item.title})`}},async dryRun(ctx){const title=ctx.str("title");const content=readKnowledgeFile(ctx.str("file"));const target=planPersonalKnowledgeWrite(ctx.appCode,{title:title,content:content});return dryRun(target.method,target.path).body(JSON.parse(target.jsonBody)).description(`Preview: create personal knowledge-base entry "${title}"`).build()}};const kbUpdate={service:"kb",command:"update",description:"Update a personal knowledge-base entry from a local file",risk:"write",
|
|
5
|
+
confirmationDescription:"Replaces the personal knowledge-base entry body with local file content and triggers retrieval sync.",flags:[{...ID_FLAG,type:"string",description:"Personal knowledge-base entry ID"},{...TITLE_FLAG,required:false,description:"Override the existing entry title"},FILE_FLAG],async execute(ctx){const id=ctx.str("id");const content=readKnowledgeFile(ctx.str("file"));const title=ctx.str("title")||undefined;const item=await updatePersonalKnowledgeBaseItem(id,ctx.appCode,{title:title,content:content},ctx.signal);return{ok:true,data:summarizePersonalItem(item),message:`Updated KB entry ${item.id} (${item.title})`}},async dryRun(ctx){const id=ctx.str("id");const content=readKnowledgeFile(ctx.str("file"));const previous=await getPersonalKnowledgeBaseItem(id,ctx.appCode,ctx.signal);const title=ctx.str("title")||previous.title;const target=planPersonalKnowledgeWrite(ctx.appCode,{title:title,content:content},id,previous.version)
|
|
6
|
+
;return dryRun(target.method,target.path).body(JSON.parse(target.jsonBody)).description(`Preview: update personal knowledge-base entry ${id}`).build()}};function readSearchServiceUrl(ctx){if(ctx.flag("kb-service-url")!==undefined){return normalizeKbServiceOrigin(ctx.str("kb-service-url"))}const serviceUrl=getKbServiceDomain();if(!serviceUrl){throw CliErrors.validation("KB Service is not configured for knowledge search.","Configure kbServiceDomain in the connection settings, or pass `--kb-service-url <https-origin>` for this request.")}return normalizeKbServiceOrigin(serviceUrl)}const kbSearch={service:"kb",command:"search",description:"Search visible public, company, and personal knowledge",risk:"read",flags:[QUERY_FLAG,TOPK_FLAG,{name:"kb-service-url",type:"string",required:false,description:"Optional trusted KB Service HTTPS origin for this request only"}],async validate(ctx){if(!ctx.str("query").trim()){throw CliErrors.validation("Search query is required.")}readTopK(ctx)
|
|
7
|
+
;readSearchServiceUrl(ctx)},async execute(ctx){const query=ctx.str("query").trim();const topK=readTopK(ctx);const serviceUrl=readSearchServiceUrl(ctx);const input={appCode:ctx.appCode,accessKey:ctx.accessKey??"",query:query,...topK!==undefined?{topK:topK}:{},signal:ctx.signal};const data=await searchDirectKnowledge({...input,serviceUrl:serviceUrl});return{ok:true,data:data}}};function managementCommand(definition){return{...definition,execute:ctx=>withKbManagementOrigin(()=>definition.execute(ctx)),...definition.dryRun?{dryRun:ctx=>withKbManagementOrigin(()=>definition.dryRun(ctx))}:{}}}export const kbDefinitions=[...[kbList,kbDetail,kbCreate,kbUpdate].map(managementCommand),kbSearch];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{logger}from"../../utils/logger.js";import{CLI_DISPLAY_NAME}from"../../constant/cli.js";function printLogs(logs){if(logs.length===0){console.log("* No logs found");return}console.log(`* ${CLI_DISPLAY_NAME} logs:\n`);logs.forEach((log,index)=>{const time=new Date(log.timestamp).toLocaleString("en-US");const icon=log.level==="success"?"√":log.level==="error"?"×":log.level==="warn"?"!":"i";console.log(`${index+1}. ${icon} [${log.command}] ${log.message}`);console.log(` Time: ${time}`);if(log.duration){console.log(` Duration: ${log.duration}ms`)}if(log.details&&Object.keys(log.details).length>0){console.log(` Details: ${JSON.stringify(log.details,null,2)}`)}console.log("")})}export const logsDefinitions=[{service:"logs",command:"show",description:"View command history logs",risk:"read",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:[],async execute(_ctx){printLogs(logger.readLogs());return{ok:true}}}];
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{Ajv2020}from"ajv/dist/2020.js";import addFormats from"ajv-formats";import{CliError,CliErrors}from"../../errors.js";function object(value){return value!==null&&typeof value==="object"&&!Array.isArray(value)}function assertMetricNumbers(value,failure=CliErrors.validation){if(typeof value==="number"&&(!Number.isFinite(value)||Number.isInteger(value)&&!Number.isSafeInteger(value))){throw failure("Metric JSON numbers must be finite and integers must be within the safe integer range.","Represent larger integers as decimal strings in the schema, examples and endpoint payloads.")}if(value!==null&&typeof value==="object"){for(const child of Object.values(value))assertMetricNumbers(child,failure)}}export function parseMetricJson(text){try{const parsed=JSON.parse(text);assertMetricNumbers(parsed);const stack=[];for(const[token]of text.matchAll(/"(?:\\[\s\S]|[^"\\])*"|[{}\[\],]/g)){const frame=stack[stack.length-1];if(token==="{")stack.push({keys:new Set,keyExpected:true
|
|
2
|
+
});else if(token==="[")stack.push(null);else if(token==="}"||token==="]")stack.pop();else if(token===","){if(frame)frame.keyExpected=true}else if(frame?.keyExpected){const key=JSON.parse(token);if(frame.keys.has(key))throw CliErrors.validation("Metric JSON must not contain duplicate object keys.");frame.keys.add(key);frame.keyExpected=false}}return parsed}catch(error){if(error instanceof CliError)throw error;throw CliErrors.validation("Cannot parse a valid metric JSON document.")}}export function compileMetricContract(value){assertMetricNumbers(value);if(!object(value)||!Object.hasOwn(value,"inputSchema")||!Object.hasOwn(value,"outputSchema")||Object.keys(value).some(key=>!["inputSchema","outputSchema","examples"].includes(key))){throw CliErrors.validation("Metric contract requires inputSchema and outputSchema, with optional examples only.")}const compile=(schema,label)=>{if(!object(schema))throw CliErrors.validation(`${label} must be a JSON Schema object.`);try{const ajv=new Ajv2020({
|
|
3
|
+
strict:true,allErrors:false,coerceTypes:false,useDefaults:false,removeAdditional:false});addFormats.default(ajv);const validate=ajv.compile(schema);if("$async"in validate&&validate.$async)throw new Error("Asynchronous schemas are not supported.");return validate}catch(error){throw CliErrors.validation(`Invalid metric ${label}: ${error instanceof Error?error.message:"schema compilation failed"}`,"Use synchronous JSON Schema 2020-12 with local fragment references; remote schemas are not loaded.")}};if(!object(value.inputSchema)||value.inputSchema.type!=="object"){throw CliErrors.validation("Metric inputSchema must declare type: object.")}const input=compile(value.inputSchema,"inputSchema");const output=compile(value.outputSchema,"outputSchema");if(value.examples!==undefined){if(!Array.isArray(value.examples))throw CliErrors.validation("Metric contract examples must be an array.");for(const[index,example]of value.examples.entries()){
|
|
4
|
+
if(!object(example)||!Object.hasOwn(example,"input")||!Object.hasOwn(example,"output")||Object.keys(example).some(key=>!["input","output"].includes(key))){throw CliErrors.validation(`Metric example ${index} requires input and output only.`)}assertMetricInput(input,example.input);if(!output(example.output))throw CliErrors.validation(`Metric example ${index} output: ${validationMessage(output)}`)}}return{input:input,output:output}}function validationMessage(validate){const error=validate.errors?.[0];return error?`${error.instancePath||"/"} ${error.message}`:"does not match its schema"}export function assertMetricInput(validate,value){if(!object(value))throw CliErrors.validation("Metric input must be a JSON object.");assertMetricNumbers(value);if(!validate(value))throw CliErrors.validation(`Metric input: ${validationMessage(validate)}`)}export function assertMetricOutput(validate,value){if(value===undefined)throw CliErrors.apiError("Metric output is missing.")
|
|
5
|
+
;assertMetricNumbers(value,CliErrors.apiError);if(!validate(value))throw CliErrors.apiError(`Metric output: ${validationMessage(validate)}`)}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";import{SQLCODE_FLAG}from"../../commands/common/flags.js";import{compileMetricContract,parseMetricJson}from"./contract.js";function invalid(path,message){throw CliErrors.validation(`${path}: ${message}`,"Correct the metric definition before execution.")}function object(value,keys,path,optional=[]){if(!value||typeof value!=="object"||Array.isArray(value))invalid(path,"Expected an object.");const record=value;for(const key of keys){if(!Object.hasOwn(record,key))invalid(`${path}.${key}`,"Required field is missing.")}for(const key of Object.keys(record)){if(!keys.includes(key)&&!optional.includes(key))invalid(`${path}.${key}`,"Unknown field.")}return record}function text(value,path){if(typeof value!=="string"||!value.trim()||value!==value.trim()){invalid(path,"Expected a non-empty string without leading or trailing whitespace.")}return value}export function validateMetricEntry(entry,path="metric"){
|
|
2
|
+
const metric=object(entry,["name","description","unit","target","contract"],path,["displayName","categoryPath"]);if(Object.hasOwn(metric,"displayName"))text(metric.displayName,`${path}.displayName`);if(Object.hasOwn(metric,"categoryPath")){const categories=metric.categoryPath;if(!Array.isArray(categories)||categories.length<1||categories.length>2){invalid(`${path}.categoryPath`,"Expected a category path with one or two levels.")}for(const[index,category]of categories.entries())text(category,`${path}.categoryPath[${index}]`)}validateMetricName(text(metric.name,`${path}.name`));for(const field of["description","unit"])text(metric[field],`${path}.${field}`);const targetValue=metric.target;if(!targetValue||typeof targetValue!=="object"||Array.isArray(targetValue))invalid(`${path}.target`,"Expected an object.");const kind=targetValue.kind;if(kind!=="sql"&&kind!=="bff")invalid(`${path}.target.kind`,"Expected sql or bff.");const selector=kind==="sql"?"sqlCode":"functionName"
|
|
3
|
+
;const target=object(targetValue,["kind","appCode",selector],`${path}.target`);const appCode=text(target.appCode,`${path}.target.appCode`);const code=text(target[selector],`${path}.target.${selector}`);if(kind==="sql"&&!SQLCODE_FLAG.pattern.regex.test(code)){invalid(`${path}.target.sqlCode`,"Expected a SQL code in xxxxxxxx-xxxxxxxx hexadecimal format.")}return metric}export function validateMetricName(name){if(!/^metrics\.[a-z][a-z0-9_-]*$/.test(name)||name!==name.trim()||name.length>256){throw CliErrors.validation("Metric name must be a metrics.<identifier> key of at most 256 characters.")}return name}export function validateMetricDefinition(value,appCode,name){const metric=validateMetricEntry(value);if(appCode!==undefined&&metric.target.appCode!==appCode||name!==undefined&&metric.name!==name){throw CliErrors.validation("Metric identity does not match the selected app and name.")}const contract=compileMetricContract(metric.contract);return{metric:metric,contract:contract}}
|
|
4
|
+
export function readStoredMetric(record,appCode,name){if(!record||typeof record!=="object"||Array.isArray(record)||record.appCode!==appCode||record.tags!=="METRIC"||typeof record.value!=="string"||typeof record.key!=="string"){throw CliErrors.apiError("Invalid metric app-config record.")}const storedName=record.key;const value=parseMetricJson(record.value);if(!value||typeof value!=="object"||Array.isArray(value)||["name","description","tags"].some(field=>Object.hasOwn(value,field))){throw CliErrors.apiError("Metric value must contain only the metric payload, without app-config metadata.")}return validateMetricDefinition({...value,name:storedName,description:record.description},appCode,name).metric}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{loadApplicationMetric,METRIC_NAME_FLAG}from"./shared.js";export const metricDetail={service:"metric",command:"detail",risk:"read",description:"Read and validate one application metric definition without executing it",flags:[METRIC_NAME_FLAG],async execute(ctx){const{metric:metric}=await loadApplicationMetric(ctx.appCode,ctx.str("name"));return{ok:true,data:metric}}};
|
|
@@ -1 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import{executeSdkSql,executeSdkBff}from"../../core/sdk-client.js";import{CliErrors}from"../../errors.js";import{assertMetricInput,assertMetricOutput,parseMetricJson}from"./contract.js";import{loadApplicationMetric,metricFailure,METRIC_NAME_FLAG}from"./shared.js";async function prepare(ctx){const{metric:metric,contract:contract}=await loadApplicationMetric(ctx.appCode,ctx.str("name"));try{const params=parseMetricJson(ctx.str("params"));assertMetricInput(contract.input,params);if(metric.target.kind==="sql"){if(Object.values(params).some(value=>typeof value!=="string"&&(typeof value!=="number"||!Number.isFinite(value)))){throw CliErrors.validation("SQL metric parameters must be strings or finite numbers.")}}return{metric:metric,contract:contract,params:params}}catch(error){throw metricFailure(error,ctx.appCode,metric.name,"input-validation")}}export const metricExec={service:"metric",command:"exec",risk:"read",
|
|
2
|
+
description:"Execute an application metric with input and output JSON Schema validation",flags:[METRIC_NAME_FLAG,{name:"params",type:"string",required:true,description:"JSON input object matching the metric contract"}],async dryRun(ctx){const{metric:metric}=await prepare(ctx);return{method:"POST",url:metric.target.kind==="sql"?"/client/sql/execute":`/client/bff/excute/${encodeURIComponent(ctx.appCode)}/${encodeURIComponent(metric.target.functionName)}`,data:{name:metric.name,appCode:ctx.appCode,target:metric.target,inputValidated:true,executionVerified:false},description:"Inputs validated against the current definition. No SQL/BFF was executed; output and execution access remain unverified."}},async execute(ctx){const{metric:metric,contract:contract,params:params}=await prepare(ctx);let result;try{if(metric.target.kind==="sql"){const response=await executeSdkSql(metric.target.sqlCode,params)
|
|
3
|
+
;if(!response||typeof response!=="object"||Array.isArray(response)||response.execSuccess!==true){throw CliErrors.apiError("Metric SQL execution failed or returned an invalid execution status.")}if(!Array.isArray(response.execResult))throw CliErrors.apiError("Metric SQL execution did not return a result array.");result=response.execResult}else{result=await executeSdkBff(metric.target.functionName,params)}}catch(error){throw metricFailure(error,ctx.appCode,metric.name,"execution")}try{assertMetricOutput(contract.output,result)}catch(error){throw metricFailure(error,ctx.appCode,metric.name,"output-validation")}return{ok:true,data:{name:metric.name,appCode:ctx.appCode,result:result,validated:true}}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{metricExec}from"./exec.js";import{metricDetail}from"./detail.js";import{metricList}from"./list.js";export const metricDefinitions=[metricList,metricDetail,metricExec];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{listRuntimeMetricConfigs}from"../../core/api-client.js";import{CliError,CliErrors}from"../../errors.js";import{readStoredMetric}from"./definition.js";export const metricList={service:"metric",command:"list",risk:"read",description:"List application metric summaries, optionally filtering keys or descriptions by keyword",flags:[{name:"key",type:"string",description:"Case-insensitive literal substring of the config key or description"}],async execute(ctx){const key=ctx.str("key").trim();const records=await listRuntimeMetricConfigs(ctx.appCode,key||undefined);const names=new Set;const summaries=records.map(record=>{try{const metric=readStoredMetric(record,ctx.appCode);if(names.has(metric.name)){throw CliErrors.validation("Metric identity is mismatched or duplicated.")}names.add(metric.name);const{name:name,description:description,displayName:displayName,categoryPath:categoryPath,unit:unit}=metric;return{name:name,description:description,...displayName===undefined?{}:{
|
|
2
|
+
displayName:displayName},...categoryPath===undefined?{}:{categoryPath:categoryPath},unit:unit}}catch(error){if(error instanceof CliError){throw new CliError(error.code,error.exitCode,`Invalid metric definition: ${record?.key??"(unknown)"}`,error.message)}throw error}});const metrics=summaries.sort((a,b)=>a.name<b.name?-1:a.name>b.name?1:0);return{ok:true,data:{appCode:ctx.appCode,count:metrics.length,metrics:metrics}}}};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{getRuntimeMetricDetail}from"../../core/api-client.js";import{validateMetricName,validateMetricDefinition}from"./definition.js";import{CliError}from"../../errors.js";import{mapUserFacingExecuteError}from"../../framework/runner-error.js";export function metricFailure(error,appCode,name,stage){const mapped=mapUserFacingExecuteError(error);if(!(mapped instanceof CliError))return mapped;const context=`Metric stage: ${stage}; app: ${JSON.stringify(appCode)}; name: ${JSON.stringify(name)}.`;const descriptors=Object.getOwnPropertyDescriptors(mapped);return Object.defineProperties(new CliError(mapped.code,mapped.exitCode,mapped.message),{...descriptors,hint:{...descriptors.hint,value:[context,mapped.hint].filter(Boolean).join(" ")}})}export const METRIC_NAME_FLAG={name:"name",type:"string",required:true,description:"Exact full metric name (e.g. metrics.paid_order_count); use name, not displayName"};export async function loadApplicationMetric(appCode,name){validateMetricName(name)
|
|
2
|
+
;let record;try{record=await getRuntimeMetricDetail(appCode,name)}catch(error){throw metricFailure(error,appCode,name,"definition-read")}try{const definition=record&&typeof record==="object"&&"metricDefinition"in record?record.metricDefinition:undefined;return validateMetricDefinition(definition,appCode,name)}catch(error){throw metricFailure(error,appCode,name,"definition-validation")}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{listNotificationChannelConfigs}from"../../core/api-client.js";import{NOTIFICATION_CHANNEL_TYPES,projectNotificationListConfig,readNotificationChannelType}from"../../commands/notification/shared.js";export const notificationConfigList={service:"notification",command:"config-list",description:"List app-level notification configs and their configCode values",risk:"read",flags:[{name:"type",type:"string",description:"Notification channel type",enum:NOTIFICATION_CHANNEL_TYPES,default:"EMAIL"}],async validate(ctx){readNotificationChannelType(ctx)},async execute(ctx){const channelType=readNotificationChannelType(ctx);const items=await listNotificationChannelConfigs(ctx.appCode,channelType);const configs=items.map(projectNotificationListConfig);return{ok:true,data:{appCode:ctx.appCode,channelType:channelType,count:configs.length,configs:configs},message:`Found ${configs.length} ${channelType} notification config(s)`}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{notificationConfigList}from"../../commands/notification/config-list.js";export const notificationDefinitions=[notificationConfigList];
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{CliErrors}from"../../errors.js";export const NOTIFICATION_CHANNEL_TYPES=["EMAIL","FEISHU","DINGTALK","WECOM","WEBHOOK"];export function readNotificationChannelType(ctx){const value=ctx.str("type").trim()||"EMAIL";if(!NOTIFICATION_CHANNEL_TYPES.includes(value)){throw CliErrors.validation(`Invalid --type: ${value}`,`Allowed values: ${NOTIFICATION_CHANNEL_TYPES.join(", ")}.`)}return value}export function projectNotificationListConfig(item,index){const config=requireResponseObject(item,index);return{configCode:requireResponseString(config.configCode,"configCode",index),configName:requireResponseString(config.configName,"configName",index),channelType:requireResponseString(config.channelType,"channelType",index),description:normalizeNullableString(config.description)}}function requireResponseObject(value,index){if(typeof value!=="object"||value===null||Array.isArray(value)){throw CliErrors.apiError("Invalid notification config response.",`Item ${index+1} must be an object.`)}
|
|
2
|
+
return value}function requireResponseString(value,field,index){if(typeof value!=="string"||!value.trim()){throw CliErrors.apiError("Invalid notification config response.",`Item ${index+1} is missing required field "${field}".`)}return value.trim()}function normalizeNullableString(value){return typeof value==="string"&&value.trim()?value.trim():null}
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import{requireRuntimeUploadFile}from"../../commands/common/local-file.js";import{queryRuntimeFileUrl,recognizeRuntimeOcr,uploadRuntimeFile}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{dryRun}from"../../framework/dryrun.js";const SUPPORTED_SCENES=["invoice","general","form","idCard"];const SCENE_TO_LEGACY_TYPE={invoice:"Invoice",general:"General",form:"Table",idCard:"IdCard"};const SCENE_FLAG={name:"scene",type:"string",required:true,enum:[...SUPPORTED_SCENES],description:"OCR scene: invoice, general, form, or idCard"};const IMAGE_FILE_FLAG={name:"image-file",type:"string",description:"Local image or PDF file; current backend uses upload -> query-url -> OCR"};const IMAGE_URL_FLAG={name:"image-url",type:"string",description:"Publicly accessible image or file URL"};function normalizeScene(scene){const normalized=scene.trim().toLowerCase();if(normalized==="idcard"){return"idCard"}if(normalized==="invoice"||normalized==="general"||normalized==="form"){
|
|
2
|
+
return normalized}throw CliErrors.validation(`Unsupported OCR scene: ${scene}. Supported scenes: ${SUPPORTED_SCENES.join(", ")}`)}function selectedInputs(ctx){const imageFile=ctx.str("image-file").trim();const imageUrl=ctx.str("image-url").trim();return{imageFile:imageFile,imageUrl:imageUrl,count:[imageFile,imageUrl].filter(Boolean).length}}function validateInputSelection(ctx){const inputs=selectedInputs(ctx);if(inputs.count!==1){throw CliErrors.validation("Choose exactly one OCR input: --image-file or --image-url.")}return inputs}function withScene(result,scene,sourceFile){return{...result,scene:scene,...sourceFile?{sourceFile:{fileName:sourceFile.fileName,filePath:sourceFile.filePath}}:{}}}const ocrRecognize={service:"ocr",command:"recognize",description:"Extract text and structured fields from voucher-style business documents; not for general image understanding",risk:"read",flags:[SCENE_FLAG,IMAGE_FILE_FLAG,IMAGE_URL_FLAG],async dryRun(ctx){
|
|
3
|
+
const scene=normalizeScene(ctx.str("scene"));const legacyType=SCENE_TO_LEGACY_TYPE[scene];const inputs=validateInputSelection(ctx);if(inputs.imageUrl){return dryRun("POST","/client/ocr").body({appCode:ctx.appCode,url:inputs.imageUrl,type:legacyType}).description(`Preview: recognize ${scene} OCR from URL`).build()}const file=requireRuntimeUploadFile(inputs.imageFile,"image-file");return dryRun("POST","/client/uploadFile").body({steps:[{method:"POST",url:"/client/uploadFile",body:{appCode:ctx.appCode,multipart:{file:file}}},{method:"POST",url:"/client/queryFileUrl",body:{filePath:"<filePath returned by /client/uploadFile>",downloadFlag:false}},{method:"POST",url:"/client/ocr",body:{appCode:ctx.appCode,url:"<fileUrl returned by /client/queryFileUrl>",type:legacyType}}]}).description(`Preview: upload local file, query temporary URL, then recognize ${scene} OCR`).build()},async execute(ctx){const scene=normalizeScene(ctx.str("scene"));const legacyType=SCENE_TO_LEGACY_TYPE[scene]
|
|
4
|
+
;const inputs=validateInputSelection(ctx);if(inputs.imageUrl){const data=await recognizeRuntimeOcr(ctx.appCode,{url:inputs.imageUrl,type:legacyType});return{ok:true,data:withScene(data,scene)}}const file=requireRuntimeUploadFile(inputs.imageFile,"image-file");const uploaded=await uploadRuntimeFile(ctx.appCode,file.path);if(!uploaded.filePath){throw CliErrors.apiError("File upload response missing filePath.")}const urlResult=await queryRuntimeFileUrl(uploaded.filePath,{download:false});if(!urlResult.fileUrl){throw CliErrors.apiError("File URL response missing fileUrl.")}const data=await recognizeRuntimeOcr(ctx.appCode,{url:urlResult.fileUrl,type:legacyType});return{ok:true,data:withScene(data,scene,uploaded)}}};export const ocrDefinitions=[ocrRecognize];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{listRuntimeDatasetPermits,listRuntimeDatasetRolePermits}from"../../core/api-client.js";import{resolveRuntimeRoleRef}from"../../commands/role/shared.js";export const permitDatasetGet={service:"permit",command:"dataset-get",description:"Show runtime dataset permissions, optionally evaluated for one role",risk:"read",flags:[{name:"role",type:"string",description:"Runtime role ID or exact role name"}],async execute(ctx){const ref=ctx.str("role").trim();if(!ref){return{ok:true,data:{scope:"runtime",datasets:await listRuntimeDatasetRolePermits(ctx.appCode)}}}const role=await resolveRuntimeRoleRef(ctx.appCode,ref);return{ok:true,data:{scope:"runtime",role:{id:role.id,roleName:role.roleName,roleType:role.roleType},datasets:await listRuntimeDatasetPermits(ctx.appCode,role.id)}}}};
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import{listRuntimeDatasetRolePermits,listRuntimePermitRoles,saveRuntimeDatasetRolePermits}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";import{dryRun}from"../../framework/dryrun.js";import{resolveRuntimeRoleRef}from"../../commands/role/shared.js";import{applyRuntimeRolePermission,assertGrantOrRevoke,assertRuntimePermissionManager,assertRuntimePermitRoleConfigurable,GRANT_FLAG,REVOKE_FLAG,ROLE_REF_FLAG,runtimePermitWriteResult,splitRefs}from"../../commands/permit/shared.js";const DATA_ACTIONS=["DATA_CREATE","DATA_UPDATE","DATA_DELETE","DATA_DETAIL","DATA_EXPORT","DATA_ROW"];const DATASETS_FLAG={name:"datasets",type:"string",required:true,description:"Comma-separated runtime dataset codes"};const ACTIONS_FLAG={name:"actions",type:"string",required:true,description:`Comma-separated actions: ${DATA_ACTIONS.join(", ")}`};async function prepare(ctx){await assertRuntimePermissionManager(ctx.appCode)
|
|
2
|
+
;const operation=assertGrantOrRevoke(ctx.bool("grant"),ctx.bool("revoke"));const role=await resolveRuntimeRoleRef(ctx.appCode,ctx.str("role"));assertRuntimePermitRoleConfigurable(role);const datasetCodes=splitRefs(ctx.str("datasets"),"--datasets");const actions=[...new Set(splitRefs(ctx.str("actions"),"--actions").map(value=>value.toUpperCase()))];const invalid=actions.filter(value=>!DATA_ACTIONS.includes(value));if(invalid.length>0){throw CliErrors.validation(`Invalid dataset actions: ${invalid.join(", ")}.`)}const datasets=await listRuntimeDatasetRolePermits(ctx.appCode);const allRoles=await listRuntimePermitRoles(ctx.appCode);const permitList=[];const before=[];const after=[];const warnings=[];for(const datasetCode of datasetCodes){const dataset=datasets.find(item=>item.datasetCode===datasetCode);if(!dataset)throw CliErrors.validation(`Runtime dataset ${datasetCode} was not found.`);for(const resourceType of actions){
|
|
3
|
+
const current=dataset.dataPermitList?.find(item=>item.resourceType===resourceType);if(!current){throw CliErrors.validation(`Dataset ${datasetCode} does not expose ${resourceType}.`)}const changed=applyRuntimeRolePermission(current.rolePermit,role,allRoles,operation);before.push({datasetCode:datasetCode,resourceType:resourceType,rolePermit:current.rolePermit});after.push({datasetCode:datasetCode,resourceType:resourceType,rolePermit:changed.roles});if(changed.changed){permitList.push({...current.permitId!=null?{id:current.permitId}:{},appCode:ctx.appCode,resourceCode:datasetCode,resourceType:resourceType,resourceName:current.resourceName,rolePermit:changed.roles})}else{warnings.push(`${datasetCode}/${resourceType} already reflects ${operation} for role ${role.id}.`)}}}return{operation:operation,role:role,datasetCodes:datasetCodes,actions:actions,permitList:permitList,before:before,after:after,warnings:warnings}}export const permitDatasetSet={service:"permit",command:"dataset-set",
|
|
4
|
+
description:"Grant or revoke selected runtime dataset actions for one role",risk:"high-risk-write",confirmationDescription:"Grants or revokes the target role permission for the given dataset actions. Data operations for users in that role will change.",flags:[ROLE_REF_FLAG,GRANT_FLAG,REVOKE_FLAG,DATASETS_FLAG,ACTIONS_FLAG],async validate(ctx){assertGrantOrRevoke(ctx.bool("grant"),ctx.bool("revoke"))},async dryRun(ctx){const change=await prepare(ctx);return dryRun("POST","/client/permit/resource/batch-save-dataset").body({appCode:ctx.appCode,permitList:change.permitList}).description(`Preview: ${change.operation} selected runtime dataset actions`).build()},async execute(ctx){const change=await prepare(ctx);if(change.permitList.length>0){await saveRuntimeDatasetRolePermits(ctx.appCode,change.permitList)}return{ok:true,data:runtimePermitWriteResult(`dataset-${change.operation}`,{roleId:change.role.id,datasetCodes:change.datasetCodes,actions:change.actions},change.before,change.after,{
|
|
5
|
+
method:"POST",path:"/client/permit/resource/batch-save-dataset"},change.warnings)}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import{permitPageGet}from"../../commands/permit/page-get.js";import{permitPageSet}from"../../commands/permit/page-set.js";import{permitRoleMenus}from"../../commands/permit/role-menus.js";import{permitRoleMenusSet}from"../../commands/permit/role-menus-set.js";import{permitDatasetGet}from"../../commands/permit/dataset-get.js";import{permitDatasetSet}from"../../commands/permit/dataset-set.js";export const permitDefinitions=[permitPageGet,permitPageSet,permitRoleMenus,permitRoleMenusSet,permitDatasetGet,permitDatasetSet];
|