@thinkingai/ae-cli 6.1.20 → 6.1.21
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 +2 -1
- package/README.zh.md +2 -1
- package/dist/{auth-FUM37MHF.js → auth-XZNXFRJS.js} +5 -5
- package/dist/{capability-AXFQW5WM.js → capability-FYTU3X6L.js} +42 -12
- package/dist/{chunk-LNZBEQXW.js → chunk-4NRCTUZJ.js} +27041 -474
- package/dist/{chunk-VXNMYUXU.js → chunk-57RRFUEZ.js} +23 -7
- package/dist/{chunk-WZ6YVQSF.js → chunk-7FTTULED.js} +1 -1
- package/dist/{chunk-ATSM5XAW.js → chunk-7XGFSUOM.js} +2 -2
- package/dist/chunk-CCS66K4K.js +155 -0
- package/dist/{chunk-I4WQAEYB.js → chunk-DVMLWQD4.js} +8 -186
- package/dist/{chunk-CZU3V3DQ.js → chunk-DX5CDO34.js} +27 -6
- package/dist/chunk-EQ255HKO.js +38248 -0
- package/dist/{chunk-BBEFP4SB.js → chunk-HBGADCKA.js} +3 -3
- package/dist/{chunk-QJQZH5GQ.js → chunk-HFGZGYCG.js} +10 -6
- package/dist/{chunk-ECBLHAZO.js → chunk-JOCDD4ON.js} +1 -1
- package/dist/{chunk-TKHSULJT.js → chunk-KPQY44JQ.js} +6 -0
- package/dist/{chunk-4P355ZWB.js → chunk-MAPZ7VB6.js} +21 -1
- package/dist/chunk-V2NUHPXF.js +196 -0
- package/dist/{chunk-RSG4ONOI.js → chunk-VYXXOKYS.js} +5 -5
- package/dist/{community-report-client-XXWGSBSD.js → community-report-client-CU22W53K.js} +1 -1
- package/dist/{config-EXUGQN5T.js → config-XO3LI3SA.js} +4 -4
- package/dist/context-IFJI3LIT.js +46 -0
- package/dist/{data-integration-4NZ53OMT.js → data-integration-HNGUKFIC.js} +44 -35
- package/dist/index.js +101 -64
- package/dist/{local-data-upload-client-KYOKVYZV.js → local-data-upload-client-GTRIT64F.js} +3 -2
- package/dist/{memory-ATNKZNW5.js → memory-QGPSNCQS.js} +4 -4
- package/dist/{metadata-VZVC7YMH.js → metadata-DI5BMYFU.js} +8 -8
- package/dist/{model-E4JMQ4V2.js → model-RNPQXIBI.js} +4 -4
- package/dist/{personal-semantic-preference-7S2SQ3UV.js → personal-semantic-preference-5C3WUXFI.js} +11 -8
- package/dist/{project-semantic-2SZP2OPO.js → project-semantic-3LF6Q6JZ.js} +27 -21
- package/dist/{sync-YV3E66IF.js → sync-O45NXEQY.js} +7 -6
- package/dist/{te-agent-JB5T3PO7.js → te-agent-K5MSPNHJ.js} +5 -5
- package/dist/{te-analysis-3YJAAT2D.js → te-analysis-AISWCOOZ.js} +1086 -354
- package/dist/{te-community-UDBI672N.js → te-community-4OYU3BDA.js} +4 -4
- package/dist/{te-dataops-ZLYOCXZ4.js → te-dataops-NFIPB6FX.js} +5 -5
- package/dist/{te-engage-4XG6OJML.js → te-engage-BAM3GBFX.js} +7 -7
- package/dist/{te-experiment-VXUWPINJ.js → te-experiment-GUTZXZ5Z.js} +132 -14
- package/dist/{te-kb-WYQWHFSC.js → te-kb-3TS73NO6.js} +454 -194
- package/dist/{te-system-7G6F2LJA.js → te-system-STMHLS5J.js} +12 -7
- package/dist/{te-team-E7FBBXMQ.js → te-team-3I5AOX3N.js} +6 -6
- package/dist/{update-D47BUG25.js → update-RZXLPCRH.js} +4 -4
- package/package.json +21 -14
- package/skills/ae-analysis/SKILL.md +91 -78
- package/skills/ae-analysis/references/adhoc_export.md +11 -18
- package/skills/ae-analysis/references/adhoc_run.md +15 -7
- package/skills/ae-analysis/references/agent_review_detail.md +11 -0
- package/skills/ae-analysis/references/agent_review_evidence.md +46 -0
- package/skills/ae-analysis/references/agent_review_list.md +9 -0
- package/skills/ae-analysis/references/agent_review_preflight.md +96 -0
- package/skills/ae-analysis/references/agent_review_priorities_comparisons.md +76 -0
- package/skills/ae-analysis/references/agent_review_records.md +9 -0
- package/skills/ae-analysis/references/agent_review_retry.md +12 -0
- package/skills/ae-analysis/references/agent_review_review.md +16 -0
- package/skills/ae-analysis/references/agent_review_submit_to_page.md +184 -0
- package/skills/ae-analysis/references/ai_models/attribution.md +29 -0
- package/skills/ae-analysis/references/ai_models/distribution.md +40 -0
- package/skills/ae-analysis/references/ai_models/event.md +108 -0
- package/skills/ae-analysis/references/ai_models/funnel.md +46 -0
- package/skills/ae-analysis/references/ai_models/heat_map.md +26 -0
- package/skills/ae-analysis/references/ai_models/interval.md +20 -0
- package/skills/ae-analysis/references/ai_models/path.md +38 -0
- package/skills/ae-analysis/references/ai_models/prop_analysis.md +39 -0
- package/skills/ae-analysis/references/ai_models/rank_list.md +25 -0
- package/skills/ae-analysis/references/ai_models/retention.md +70 -0
- package/skills/ae-analysis/references/ai_models/revenue.md +28 -0
- package/skills/ae-analysis/references/ai_models/sql.md +74 -0
- package/skills/ae-analysis/references/ai_models/tag.md +19 -0
- package/skills/ae-analysis/references/ai_models.md +32 -473
- package/skills/ae-analysis/references/alert_create.md +7 -7
- package/skills/ae-analysis/references/alert_delete.md +4 -6
- package/skills/ae-analysis/references/alert_detail_list.md +7 -9
- package/skills/ae-analysis/references/alert_get.md +5 -7
- package/skills/ae-analysis/references/alert_job_list.md +4 -6
- package/skills/ae-analysis/references/alert_list.md +6 -8
- package/skills/ae-analysis/references/alert_notice_config_list.md +4 -6
- package/skills/ae-analysis/references/alert_start.md +5 -7
- package/skills/ae-analysis/references/alert_stop.md +5 -7
- package/skills/ae-analysis/references/alert_update.md +8 -8
- package/skills/ae-analysis/references/analysis_data_export.md +72 -0
- package/skills/ae-analysis/references/analysis_data_retrieval.md +32 -196
- package/skills/ae-analysis/references/analysis_gateway_assets.md +23 -180
- package/skills/ae-analysis/references/analysis_interpretation.md +37 -17
- package/skills/ae-analysis/references/asset_abnormal_get.md +0 -1
- package/skills/ae-analysis/references/asset_abnormal_list.md +0 -1
- package/skills/ae-analysis/references/asset_authentication_export.md +4 -0
- package/skills/ae-analysis/references/asset_authentication_list.md +7 -1
- package/skills/ae-analysis/references/asset_authentication_update.md +5 -1
- package/skills/ae-analysis/references/asset_batch_dashboard_schedule_freeze.md +8 -6
- package/skills/ae-analysis/references/asset_batch_delete.md +6 -6
- package/skills/ae-analysis/references/asset_batch_disable_auto_backup.md +4 -5
- package/skills/ae-analysis/references/asset_batch_disable_auto_update.md +5 -6
- package/skills/ae-analysis/references/asset_batch_handover.md +4 -5
- package/skills/ae-analysis/references/asset_batch_info_export.md +4 -5
- package/skills/ae-analysis/references/asset_batch_sql_export.md +5 -6
- package/skills/ae-analysis/references/asset_dependency_list.md +4 -5
- package/skills/ae-analysis/references/asset_export.md +4 -5
- package/skills/ae-analysis/references/asset_impact_list.md +5 -9
- package/skills/ae-analysis/references/asset_lineage_get.md +5 -6
- package/skills/ae-analysis/references/asset_list.md +4 -5
- package/skills/ae-analysis/references/asset_query_history_list.md +4 -8
- package/skills/ae-analysis/references/asset_recent_list.md +0 -1
- package/skills/ae-analysis/references/asset_search.md +12 -9
- package/skills/ae-analysis/references/asset_url_get.md +3 -4
- package/skills/ae-analysis/references/bi_panel_copy.md +2 -2
- package/skills/ae-analysis/references/bi_panel_page_data_export.md +4 -12
- package/skills/ae-analysis/references/bi_panel_page_data_run.md +2 -0
- package/skills/ae-analysis/references/catalog_export.md +4 -17
- package/skills/ae-analysis/references/catalog_list.md +4 -4
- package/skills/ae-analysis/references/check_delete.md +5 -7
- package/skills/ae-analysis/references/check_export.md +11 -11
- package/skills/ae-analysis/references/check_get.md +8 -10
- package/skills/ae-analysis/references/check_list.md +4 -6
- package/skills/ae-analysis/references/check_retry.md +8 -10
- package/skills/ae-analysis/references/check_run.md +2 -4
- package/skills/ae-analysis/references/command_index.md +44 -26
- package/skills/ae-analysis/references/dashboard_report_data_export.md +5 -13
- package/skills/ae-analysis/references/dashboard_report_data_run.md +1 -1
- package/skills/ae-analysis/references/dashboard_update.md +14 -3
- package/skills/ae-analysis/references/datatable_columns_get.md +0 -1
- package/skills/ae-analysis/references/datatable_influence_list.md +0 -1
- package/skills/ae-analysis/references/datatable_version_get.md +0 -1
- package/skills/ae-analysis/references/datatable_version_list.md +0 -1
- package/skills/ae-analysis/references/debug_device_add.md +1 -2
- package/skills/ae-analysis/references/drilldown_entities_export.md +3 -3
- package/skills/ae-analysis/references/drilldown_events_export.md +3 -2
- package/skills/ae-analysis/references/drilldown_user_events_export.md +2 -2
- package/skills/ae-analysis/references/entity_detail_export.md +3 -2
- package/skills/ae-analysis/references/entity_detail_run.md +1 -0
- package/skills/ae-analysis/references/event_blacklist_add.md +5 -7
- package/skills/ae-analysis/references/event_blacklist_list.md +4 -6
- package/skills/ae-analysis/references/event_blacklist_update.md +6 -8
- package/skills/ae-analysis/references/event_changelog_list.md +0 -1
- package/skills/ae-analysis/references/event_create.md +0 -1
- package/skills/ae-analysis/references/event_detail_export.md +3 -2
- package/skills/ae-analysis/references/event_detail_run.md +1 -0
- package/skills/ae-analysis/references/event_export.md +0 -1
- package/skills/ae-analysis/references/event_get.md +0 -1
- package/skills/ae-analysis/references/event_hide_update.md +0 -1
- package/skills/ae-analysis/references/event_influence_list.md +0 -1
- package/skills/ae-analysis/references/event_list.md +0 -1
- package/skills/ae-analysis/references/event_property_bundle_export.md +5 -14
- package/skills/ae-analysis/references/event_property_bundle_import.md +2 -6
- package/skills/ae-analysis/references/event_relation_update.md +0 -1
- package/skills/ae-analysis/references/event_update.md +0 -1
- package/skills/ae-analysis/references/exchange_config_update.md +0 -1
- package/skills/ae-analysis/references/exchange_rate_refresh.md +0 -1
- package/skills/ae-analysis/references/exchange_rule_list.md +0 -1
- package/skills/ae-analysis/references/exchange_rule_update.md +0 -1
- package/skills/ae-analysis/references/exchange_rule_validate.md +0 -1
- package/skills/ae-analysis/references/governance_recommendation_decisions.md +23 -0
- package/skills/ae-analysis/references/governance_recommendation_export.md +108 -0
- package/skills/ae-analysis/references/governance_recommendation_submit.md +41 -0
- package/skills/ae-analysis/references/history_tag_data_drilldown_export.md +4 -4
- package/skills/ae-analysis/references/history_tag_data_export.md +3 -3
- package/skills/ae-analysis/references/ingest_error_list.md +7 -9
- package/skills/ae-analysis/references/ingest_summary.md +6 -8
- package/skills/ae-analysis/references/live_data_export.md +10 -10
- package/skills/ae-analysis/references/live_data_list.md +7 -9
- package/skills/ae-analysis/references/metadata_resolution.md +78 -0
- package/skills/ae-analysis/references/metric_export.md +0 -1
- package/skills/ae-analysis/references/metric_get.md +0 -1
- package/skills/ae-analysis/references/metric_list.md +4 -5
- package/skills/ae-analysis/references/metric_update.md +0 -1
- package/skills/ae-analysis/references/operation_record_export.md +4 -5
- package/skills/ae-analysis/references/operation_record_list.md +4 -5
- package/skills/ae-analysis/references/personal_semantic_preference_list.md +18 -1
- package/skills/ae-analysis/references/plan_change_log_export.md +10 -10
- package/skills/ae-analysis/references/plan_change_log_list.md +4 -6
- package/skills/ae-analysis/references/plan_delete_items.md +2 -4
- package/skills/ae-analysis/references/plan_export.md +9 -9
- package/skills/ae-analysis/references/plan_generate.md +2 -4
- package/skills/ae-analysis/references/plan_get.md +4 -6
- package/skills/ae-analysis/references/plan_import_excel.md +6 -8
- package/skills/ae-analysis/references/plan_save_items.md +2 -4
- package/skills/ae-analysis/references/plan_sync_from_meta.md +4 -6
- package/skills/ae-analysis/references/project_access_detail_get.md +0 -1
- package/skills/ae-analysis/references/project_data_power_get.md +0 -1
- package/skills/ae-analysis/references/project_data_power_list.md +0 -1
- package/skills/ae-analysis/references/project_data_power_upsert.md +0 -1
- package/skills/ae-analysis/references/project_entity_create.md +0 -1
- package/skills/ae-analysis/references/project_entity_event_list.md +0 -1
- package/skills/ae-analysis/references/project_entity_get.md +0 -1
- package/skills/ae-analysis/references/project_entity_list.md +0 -1
- package/skills/ae-analysis/references/project_entity_update.md +0 -1
- package/skills/ae-analysis/references/project_function_list.md +0 -1
- package/skills/ae-analysis/references/project_info_get.md +0 -1
- package/skills/ae-analysis/references/project_info_list.md +0 -1
- package/skills/ae-analysis/references/project_info_update.md +0 -1
- package/skills/ae-analysis/references/project_mark_time_create.md +0 -1
- package/skills/ae-analysis/references/project_mark_time_list.md +0 -1
- package/skills/ae-analysis/references/project_mark_time_update.md +0 -1
- package/skills/ae-analysis/references/project_member_add.md +6 -5
- package/skills/ae-analysis/references/project_member_batch_update.md +0 -1
- package/skills/ae-analysis/references/project_member_candidate_list.md +4 -3
- package/skills/ae-analysis/references/project_member_handover_run.md +2 -3
- package/skills/ae-analysis/references/project_member_list.md +0 -1
- package/skills/ae-analysis/references/project_member_receiver_list.md +0 -1
- package/skills/ae-analysis/references/project_member_update.md +0 -1
- package/skills/ae-analysis/references/project_owner_update.md +0 -1
- package/skills/ae-analysis/references/project_permission_binding_list.md +0 -1
- package/skills/ae-analysis/references/project_role_function_list.md +0 -1
- package/skills/ae-analysis/references/project_role_get.md +0 -1
- package/skills/ae-analysis/references/project_role_list.md +0 -1
- package/skills/ae-analysis/references/project_role_upsert.md +32 -2
- package/skills/ae-analysis/references/project_role_user_list.md +0 -1
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +214 -0
- package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +93 -0
- package/skills/ae-analysis/references/project_timezone_get.md +0 -1
- package/skills/ae-analysis/references/project_timezone_overview.md +0 -1
- package/skills/ae-analysis/references/project_timezone_update.md +0 -1
- package/skills/ae-analysis/references/project_user_id_items_update.md +0 -1
- package/skills/ae-analysis/references/property_changelog_list.md +0 -1
- package/skills/ae-analysis/references/property_create.md +0 -1
- package/skills/ae-analysis/references/property_export.md +0 -1
- package/skills/ae-analysis/references/property_get.md +0 -1
- package/skills/ae-analysis/references/property_hide_update.md +0 -1
- package/skills/ae-analysis/references/property_influence_list.md +0 -1
- package/skills/ae-analysis/references/property_list.md +3 -4
- package/skills/ae-analysis/references/property_related_events.md +0 -1
- package/skills/ae-analysis/references/property_relation_update.md +0 -1
- package/skills/ae-analysis/references/property_update.md +0 -1
- package/skills/ae-analysis/references/report_create.md +4 -2
- package/skills/ae-analysis/references/report_data_export.md +11 -9
- package/skills/ae-analysis/references/report_data_run.md +14 -7
- package/skills/ae-analysis/references/report_get.md +5 -3
- package/skills/ae-analysis/references/report_list.md +2 -0
- package/skills/ae-analysis/references/report_update.md +5 -3
- package/skills/ae-analysis/references/rule_create.md +5 -6
- package/skills/ae-analysis/references/rule_delete.md +5 -5
- package/skills/ae-analysis/references/rule_list.md +3 -4
- package/skills/ae-analysis/references/rule_schema.md +3 -4
- package/skills/ae-analysis/references/rule_update.md +5 -6
- package/skills/ae-analysis/references/sdk_sample_generate.md +2 -4
- package/skills/ae-analysis/references/sql_table_columns.md +1 -1
- package/skills/ae-analysis/references/super_metadata_batch_create.md +1 -1
- package/skills/ae-analysis/references/super_metadata_batch_edit.md +1 -1
- package/skills/ae-analysis/references/system_member_add.md +1 -2
- package/skills/ae-analysis/references/system_member_status_update.md +1 -1
- package/skills/ae-analysis/references/system_ops_alert_contact_list.md +1 -1
- package/skills/ae-analysis/references/system_ops_alert_contact_test.md +0 -1
- package/skills/ae-analysis/references/system_query_monitor_overview.md +3 -3
- package/skills/ae-analysis/references/system_query_task_export.md +4 -14
- package/skills/ae-analysis/references/system_query_task_get.md +1 -1
- package/skills/ae-analysis/references/system_query_task_list.md +5 -6
- package/skills/ae-analysis/references/system_receiver_address_upsert.md +3 -3
- package/skills/ae-analysis/references/system_receiver_detection_get.md +1 -1
- package/skills/ae-analysis/references/system_third_party_login_disable.md +1 -1
- package/skills/ae-analysis/references/system_usage_trend_export.md +3 -12
- package/skills/ae-analysis/references/user_cluster_list.md +1 -1
- package/skills/ae-analysis/references/user_cluster_member_export.md +4 -4
- package/skills/ae-analysis/references/user_tag_list.md +1 -1
- package/skills/ae-analysis/references/user_tag_member_export.md +4 -4
- package/skills/ae-analysis/references/virtual_event_create.md +10 -5
- package/skills/ae-analysis/references/virtual_event_get.md +0 -1
- package/skills/ae-analysis/references/virtual_property_create.md +0 -1
- package/skills/ae-analysis/references/virtual_property_sql_rule_update.md +0 -1
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +1054 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +112 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +30 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +2735 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/package-wiki-source-zip.mjs +376 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/plan-kb-source-sync.mjs +264 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/precompiled-source.mjs +49 -0
- package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/upload-kb-sources-concurrently.mjs +200 -0
- package/skills/ae-analysis/scripts/read_results.py +197 -0
- package/skills/ae-analysis-global/SKILL.md +1 -1
- package/skills/ae-capability/SKILL.md +1 -1
- package/skills/ae-community/SKILL.md +1 -1
- package/skills/ae-current-context/SKILL.md +53 -0
- package/skills/ae-data-integration/SKILL.md +5 -4
- package/skills/ae-data-integration/references/lark-bitable-source.md +288 -0
- package/skills/ae-data-integration/references/lark-sheet-source.md +130 -0
- package/skills/ae-data-integration/references/manual-export-source.md +83 -0
- package/skills/ae-data-integration/references/reuse.md +2 -0
- package/skills/ae-data-integration/references/sink-upload.md +32 -0
- package/skills/ae-data-integration/references/tracking-plan.md +4 -1
- package/skills/ae-data-integration/references/ue-mapping.md +2 -2
- package/skills/ae-data-integration-helper/SKILL.md +5 -5
- package/skills/ae-data-integration-helper/references/android_sdk_faq.md +3 -3
- package/skills/ae-data-integration-helper/references/c_sdk_faq.md +3 -3
- package/skills/ae-data-integration-helper/references/cocoscreator_sdk_faq.md +1 -1
- package/skills/ae-data-integration-helper/references/cpp_server_sdk_faq.md +3 -3
- package/skills/ae-data-integration-helper/references/ios_sdk_faq.md +1 -1
- package/skills/ae-data-integration-helper/references/java_sdk_faq.md +3 -3
- package/skills/ae-data-integration-helper/references/javascript_sdk_faq.md +1 -1
- package/skills/ae-data-integration-helper/references/logbus2_guide.md +1 -1
- package/skills/ae-data-integration-helper/references/logbus2_parser_plugin.md +2 -2
- package/skills/ae-data-integration-helper/references/minigame_sdk_faq.md +2 -2
- package/skills/ae-data-integration-helper/references/miniprogram_sdk_faq.md +1 -1
- package/skills/ae-data-integration-helper/references/python_sdk_faq.md +2 -2
- package/skills/ae-data-integration-helper/references/restful_api_notes.md +2 -2
- package/skills/ae-data-integration-helper/references/sdk_log_guide.md +3 -3
- package/skills/ae-data-integration-helper/references/sdk_usage_notes.md +11 -11
- package/skills/ae-data-integration-helper/references/unity_sdk_faq.md +1 -1
- package/skills/ae-dataops/SKILL.md +1 -1
- package/skills/ae-engage/SKILL.md +4 -3
- package/skills/ae-engage/references/build-task-save-guide.md +3 -0
- package/skills/ae-engage/references/flow-metric-update.md +115 -1
- package/skills/ae-engage/references/save-flow.md +3 -0
- package/skills/ae-engage/references/save-task.md +21 -0
- package/skills/ae-engage/references/task-metric-update.md +151 -0
- package/skills/ae-experiment/SKILL.md +14 -7
- package/skills/ae-experiment/references/save_submit_external_experiment.md +52 -0
- package/skills/ae-experiment-design/SKILL.md +3 -3
- package/skills/ae-experiment-design/references/platform-operations.md +1 -1
- package/skills/ae-experiment-insight/SKILL.md +2 -2
- package/skills/ae-experiment-insight/references/platform-operations.md +1 -1
- package/skills/ae-generate-tracking-code/SKILL.md +2 -1
- package/skills/ae-generate-tracking-code/references/client-sdk-insert.md +1 -1
- package/skills/ae-generate-tracking-code/references/datax-config.md +1 -1
- package/skills/ae-generate-tracking-code/references/logbus-config.md +1 -1
- package/skills/ae-generate-tracking-code/references/modes.md +1 -1
- package/skills/ae-generate-tracking-code/references/server-sdk-insert.md +5 -5
- package/skills/ae-generate-tracking-code/references/snippet-delivery.md +3 -3
- package/skills/ae-generate-tracking-plan/SKILL.md +2 -2
- package/skills/ae-generate-tracking-plan/references/te-api.md +1 -0
- package/skills/ae-generate-tracking-plan/references/xlsx-schema.md +3 -2
- package/skills/ae-kb/SKILL.md +41 -2
- package/skills/ae-kb/references/analysis-workflow.md +292 -0
- package/skills/ae-kb/references/source-mutations.md +95 -0
- package/skills/ae-kb-discovery/SKILL.md +5 -1
- package/skills/ae-metadata/SKILL.md +1 -1
- package/skills/ae-migrate-tracking-code/SKILL.md +195 -0
- package/skills/ae-migrate-tracking-code/references/ae-preset-properties.md +76 -0
- package/skills/ae-migrate-tracking-code/references/ir.md +167 -0
- package/skills/ae-migrate-tracking-code/references/mapping-framework.md +112 -0
- package/skills/ae-migrate-tracking-code/references/providers/README.md +58 -0
- package/skills/ae-migrate-tracking-code/references/providers/amplitude.md +208 -0
- package/skills/ae-migrate-tracking-code/references/providers/firebase.md +160 -0
- package/skills/ae-migrate-tracking-code/references/providers/ga4.md +92 -0
- package/skills/ae-migrate-tracking-code/references/providers/mixpanel.md +150 -0
- package/skills/ae-migrate-tracking-code/references/providers/sensors-data.md +146 -0
- package/skills/ae-project-semantic/SKILL.md +1 -1
- package/skills/ae-system/SKILL.md +4 -4
- package/skills/ae-team/SKILL.md +2 -2
- package/skills/ae-use-agent/references/local-agent.md +1 -1
- package/dist/chunk-TAL6CZH6.js +0 -72
- package/skills/ae-analysis/metadata_resolution.md +0 -184
|
@@ -2,28 +2,23 @@ import { createRequire as __createRequire } from 'node:module'; const require =
|
|
|
2
2
|
import {
|
|
3
3
|
kbApi,
|
|
4
4
|
kbUpload
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-57RRFUEZ.js";
|
|
6
6
|
import {
|
|
7
7
|
TeAgentApiError
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-HBGADCKA.js";
|
|
9
9
|
import {
|
|
10
10
|
CapabilityGatewayError
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-HFGZGYCG.js";
|
|
12
12
|
import {
|
|
13
13
|
printError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-DX5CDO34.js";
|
|
15
15
|
import "./chunk-Y74WTIKJ.js";
|
|
16
|
-
import "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-7XGFSUOM.js";
|
|
17
|
+
import "./chunk-7FTTULED.js";
|
|
18
18
|
import {
|
|
19
19
|
CliValidationError,
|
|
20
20
|
PermissionError
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
|
|
23
|
-
// src/commands/te-kb/add.ts
|
|
24
|
-
import { promises as fs } from "fs";
|
|
25
|
-
import * as path from "path";
|
|
26
|
-
import TurndownService from "turndown";
|
|
21
|
+
} from "./chunk-MAPZ7VB6.js";
|
|
27
22
|
|
|
28
23
|
// src/commands/te-kb/target-scope.ts
|
|
29
24
|
function getExternalKnowledgeBaseTargetScope(ctx) {
|
|
@@ -35,8 +30,235 @@ function getExternalKnowledgeBaseTargetScope(ctx) {
|
|
|
35
30
|
);
|
|
36
31
|
}
|
|
37
32
|
|
|
33
|
+
// src/commands/te-kb/source-check-updates.ts
|
|
34
|
+
var API_PATH = "/agent/api/external/knowledge-bases/sources/check-updates";
|
|
35
|
+
function body(ctx) {
|
|
36
|
+
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
37
|
+
return { name: ctx.str("name").trim(), sourceId: ctx.str("id").trim(), ...scope ? { scope } : {} };
|
|
38
|
+
}
|
|
39
|
+
var sourceCheckUpdates = {
|
|
40
|
+
service: "kb",
|
|
41
|
+
resource: "source",
|
|
42
|
+
command: "check-updates",
|
|
43
|
+
risk: "write",
|
|
44
|
+
description: "Check one compiled Feishu URL source for updates using the scheduled detector. Marks changes without compiling. Existing pending changes are preserved; updated=0 does not prove identical content.",
|
|
45
|
+
flags: [
|
|
46
|
+
{ name: "name", type: "string", required: true, minLength: 1, maxLength: 200, desc: "Knowledge base name" },
|
|
47
|
+
{ name: "id", type: "string", required: true, minLength: 1, maxLength: 191, desc: "Stable Feishu source ID from kb +list-sources" },
|
|
48
|
+
{ name: "scope", type: "string", desc: "Exact scope: personal | company (omit for personal then company lookup)" }
|
|
49
|
+
],
|
|
50
|
+
validate: (ctx) => {
|
|
51
|
+
for (const [flag, max] of [["name", 200], ["id", 191]]) {
|
|
52
|
+
const value = ctx.str(flag).trim();
|
|
53
|
+
if (!value || value.length > max) throw new CliValidationError(`Invalid --${flag}: expected 1-${max} characters.`);
|
|
54
|
+
}
|
|
55
|
+
getExternalKnowledgeBaseTargetScope(ctx);
|
|
56
|
+
},
|
|
57
|
+
dryRun: (ctx) => ({ method: "POST", url: `${ctx.host().replace(/\/$/, "")}${API_PATH}`, body: body(ctx) }),
|
|
58
|
+
execute: async (ctx) => {
|
|
59
|
+
try {
|
|
60
|
+
return await kbApi(ctx, "POST", API_PATH, {}, body(ctx), { preserveErrorMetadata: true });
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const hint = "Read kb +list-sources to confirm the current source state before retrying.";
|
|
63
|
+
if (error instanceof PermissionError) {
|
|
64
|
+
throw new PermissionError("Source write permission is required for this knowledge base.", error.code, "Request source write access; signing in again does not grant permission.");
|
|
65
|
+
}
|
|
66
|
+
if (error instanceof CapabilityGatewayError) {
|
|
67
|
+
const messages = {
|
|
68
|
+
INVALID_REQUEST: "Invalid source update-check parameters.",
|
|
69
|
+
KB_NOT_FOUND: "The knowledge base was not found or is not accessible.",
|
|
70
|
+
SOURCE_NOT_FOUND: "The source was not found in the selected knowledge base.",
|
|
71
|
+
SOURCE_NOT_FEISHU: "Only Feishu URL sources support update checks.",
|
|
72
|
+
SOURCE_NOT_COMPILED: "The source must finish compilation before checking for updates.",
|
|
73
|
+
SOURCE_CHECK_FAILED: "The Feishu source update check failed. Check server detection logs.",
|
|
74
|
+
SOURCE_CHECK_UNAVAILABLE: "The source changed or could not be selected for detection.",
|
|
75
|
+
SOURCE_CHECK_INTERNAL_ERROR: "The Feishu source update check could not complete."
|
|
76
|
+
};
|
|
77
|
+
throw new CapabilityGatewayError(messages[error.code ?? ""] ?? "The source update-check request failed.", error.code, error.httpStatus, hint, error.meta);
|
|
78
|
+
}
|
|
79
|
+
if (error instanceof Error && /[^\x00-\x7f]/.test(error.message)) {
|
|
80
|
+
error.message = "The source update-check request failed. Check credentials, rate limits and server logs.";
|
|
81
|
+
}
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// src/commands/te-kb/source-mutation.ts
|
|
88
|
+
import { promises as fs } from "fs";
|
|
89
|
+
import path from "path";
|
|
90
|
+
var API = "/agent/api/external/knowledge-bases";
|
|
91
|
+
var apiOptions = { preserveErrorMetadata: true };
|
|
92
|
+
var maxBytes = 50 * 1024 * 1024;
|
|
93
|
+
var fileExtensions = /* @__PURE__ */ new Set([".md", ".markdown", ".txt", ".csv", ".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp", ".svg"]);
|
|
94
|
+
var identityFlags = [
|
|
95
|
+
{ name: "name", type: "string", required: true, desc: "Exact knowledge base name from kb +list" },
|
|
96
|
+
{ name: "scope", type: "string", required: true, desc: "Exact knowledge base scope: personal or company" },
|
|
97
|
+
{ name: "id", type: "string", required: true, desc: "Current stable source ID from kb +list-sources" }
|
|
98
|
+
];
|
|
99
|
+
var typeFlag = { name: "source-type", type: "string", required: true, desc: "Current source type from kb +list-sources: file or zip" };
|
|
100
|
+
var revisionFlag = { name: "expected-revision", type: "number", required: true, min: 1, max: 2147483647, desc: "Current contentRevision from kb +list-sources; never automatically retry a conflict" };
|
|
101
|
+
var previewFlag = { name: "preview-id", type: "string", required: true, desc: "Exact previewId returned by ZIP replace or restore" };
|
|
102
|
+
function validateIdentity(ctx) {
|
|
103
|
+
for (const [flag, max] of [["name", 200], ["id", 191], ["preview-id", 191]]) {
|
|
104
|
+
const value = ctx.str(flag);
|
|
105
|
+
if ((flag !== "preview-id" || value) && (!value.trim() || value.length > max || /[\x00-\x1f\x7f]/.test(value))) {
|
|
106
|
+
throw new CliValidationError(`--${flag} must contain 1 to ${max} characters without control characters.`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!["personal", "company"].includes(ctx.str("scope"))) throw new CliValidationError("--scope must be personal or company.");
|
|
110
|
+
}
|
|
111
|
+
function positiveInteger(ctx, flag) {
|
|
112
|
+
const value = ctx.num(flag);
|
|
113
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > 2147483647) throw new CliValidationError(`--${flag} must be an integer from 1 to 2147483647.`);
|
|
114
|
+
}
|
|
115
|
+
function validateMutation(ctx) {
|
|
116
|
+
validateIdentity(ctx);
|
|
117
|
+
positiveInteger(ctx, "expected-revision");
|
|
118
|
+
if (!["file", "zip"].includes(ctx.str("source-type"))) throw new CliValidationError("--source-type must be file or zip; URL sources cannot be replaced or restored.");
|
|
119
|
+
}
|
|
120
|
+
function query(ctx) {
|
|
121
|
+
return { name: ctx.str("name").trim(), scope: ctx.str("scope") };
|
|
122
|
+
}
|
|
123
|
+
function sourceEndpoint(ctx, suffix) {
|
|
124
|
+
return `${API}/sources/${encodeURIComponent(ctx.str("id").trim())}/${suffix}`;
|
|
125
|
+
}
|
|
126
|
+
function previewEndpoint(ctx) {
|
|
127
|
+
return sourceEndpoint(ctx, `directory/previews/${encodeURIComponent(ctx.str("preview-id").trim())}`);
|
|
128
|
+
}
|
|
129
|
+
function dryRequest(ctx, method, endpoint2, body2) {
|
|
130
|
+
return { method, url: `${ctx.host().replace(/\/$/, "")}${endpoint2}`, params: query(ctx), ...body2 === void 0 ? {} : { body: body2 } };
|
|
131
|
+
}
|
|
132
|
+
async function replacementFile(ctx, read) {
|
|
133
|
+
const file = path.resolve(ctx.str("file"));
|
|
134
|
+
const extension = path.extname(file).toLowerCase();
|
|
135
|
+
if (ctx.str("source-type") === "zip" ? extension !== ".zip" : !fileExtensions.has(extension)) {
|
|
136
|
+
throw new CliValidationError("--file must be a ZIP for a ZIP source, or a supported non-ZIP file for a file source. File sources must keep their original format.");
|
|
137
|
+
}
|
|
138
|
+
const handle = await fs.open(file, "r");
|
|
139
|
+
try {
|
|
140
|
+
const stat = await handle.stat();
|
|
141
|
+
if (!stat.isFile() || stat.size > maxBytes) throw new CliValidationError("--file must be a regular file of at most 50 MB.");
|
|
142
|
+
const content = read ? await handle.readFile() : void 0;
|
|
143
|
+
if (content && content.length > maxBytes) throw new CliValidationError("--file exceeds 50 MB.");
|
|
144
|
+
return { file, filename: path.basename(file), sizeBytes: content?.length ?? stat.size, content };
|
|
145
|
+
} finally {
|
|
146
|
+
await handle.close();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function replaceEndpoint(ctx) {
|
|
150
|
+
return sourceEndpoint(ctx, ctx.str("source-type") === "zip" ? "directory/previews" : "raw");
|
|
151
|
+
}
|
|
152
|
+
function replaceFields(ctx) {
|
|
153
|
+
return { expectedRevision: ctx.num("expected-revision"), ...ctx.str("source-type") === "zip" ? { mode: "archive" } : {} };
|
|
154
|
+
}
|
|
155
|
+
var sourceReplace = {
|
|
156
|
+
service: "kb",
|
|
157
|
+
resource: "source",
|
|
158
|
+
command: "replace",
|
|
159
|
+
risk: "write",
|
|
160
|
+
description: "Replace a file source draft, or prepare a ZIP archive replacement preview. ZIP changes require source commit. Does not compile or publish.",
|
|
161
|
+
flags: [...identityFlags, typeFlag, revisionFlag, { name: "file", type: "string", required: true, desc: "Local replacement file, at most 50 MB; same format, different filename allowed" }],
|
|
162
|
+
validate: (ctx) => {
|
|
163
|
+
validateMutation(ctx);
|
|
164
|
+
if (!ctx.str("file").trim()) throw new CliValidationError("--file is required.");
|
|
165
|
+
},
|
|
166
|
+
dryRun: async (ctx) => {
|
|
167
|
+
const { file, filename, sizeBytes } = await replacementFile(ctx, false);
|
|
168
|
+
return { ...dryRequest(ctx, ctx.str("source-type") === "zip" ? "POST" : "PUT", replaceEndpoint(ctx), replaceFields(ctx)), multipart: { file, filename, sizeBytes, content: "<redacted>" } };
|
|
169
|
+
},
|
|
170
|
+
execute: async (ctx) => {
|
|
171
|
+
const file = await replacementFile(ctx, true);
|
|
172
|
+
const form = new FormData();
|
|
173
|
+
form.append("file", new Blob([new Uint8Array(file.content)]), file.filename);
|
|
174
|
+
for (const [key, value] of Object.entries(replaceFields(ctx))) form.append(key, String(value));
|
|
175
|
+
return kbUpload(ctx, replaceEndpoint(ctx), form, query(ctx), { ...apiOptions, method: ctx.str("source-type") === "zip" ? "POST" : "PUT" });
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
function restoreEndpoint(ctx) {
|
|
179
|
+
return `${API}/versions/${ctx.num("version")}/sources/${encodeURIComponent(ctx.str("id").trim())}/restore`;
|
|
180
|
+
}
|
|
181
|
+
function restoreBody(ctx) {
|
|
182
|
+
return { expectedRevision: ctx.num("expected-revision"), ...ctx.str("source-type") === "zip" ? ctx.str("path") ? { target: "file", path: ctx.str("path") } : { target: "source" } : {} };
|
|
183
|
+
}
|
|
184
|
+
var sourceRestore = {
|
|
185
|
+
service: "kb",
|
|
186
|
+
resource: "source",
|
|
187
|
+
command: "restore",
|
|
188
|
+
risk: "write",
|
|
189
|
+
description: "Restore one current source draft from a published version. File sources restore immediately; ZIP source or child restores return a preview. Does not roll back the whole knowledge base or publish.",
|
|
190
|
+
flags: [
|
|
191
|
+
...identityFlags,
|
|
192
|
+
typeFlag,
|
|
193
|
+
revisionFlag,
|
|
194
|
+
{ name: "version", type: "number", required: true, min: 1, max: 2147483647, desc: "Published version number from kb +versions; use the latest number to discard unpublished changes" },
|
|
195
|
+
{ name: "path", type: "string", desc: "Optional exact historical ZIP child file path from kb +version-tree; omit to restore the entire ZIP source" }
|
|
196
|
+
],
|
|
197
|
+
validate: (ctx) => {
|
|
198
|
+
validateMutation(ctx);
|
|
199
|
+
positiveInteger(ctx, "version");
|
|
200
|
+
const value = ctx.str("path");
|
|
201
|
+
if (value && (ctx.str("source-type") !== "zip" || value.length > 1024 || /[\\\x00-\x1f\x7f]/.test(value) || /^[A-Za-z]:/.test(value) || value.split("/").some((p) => !p || p === "." || p === ".."))) {
|
|
202
|
+
throw new CliValidationError("--path is only valid for a ZIP child and must be a normalized relative file path.");
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
dryRun: (ctx) => dryRequest(ctx, "POST", restoreEndpoint(ctx), restoreBody(ctx)),
|
|
206
|
+
execute: (ctx) => kbApi(ctx, "POST", restoreEndpoint(ctx), query(ctx), restoreBody(ctx), apiOptions)
|
|
207
|
+
};
|
|
208
|
+
var sourcePreview = {
|
|
209
|
+
service: "kb",
|
|
210
|
+
resource: "source",
|
|
211
|
+
command: "preview",
|
|
212
|
+
risk: "read",
|
|
213
|
+
description: "Read one page of a ZIP replacement or restore preview, including additions, modifications and deletions.",
|
|
214
|
+
flags: [
|
|
215
|
+
...identityFlags,
|
|
216
|
+
previewFlag,
|
|
217
|
+
{ name: "cursor", type: "string", desc: "Opaque nextCursor returned by the previous preview page" },
|
|
218
|
+
{ name: "limit", type: "number", default: 100, min: 1, max: 200, desc: "Preview page size from 1 to 200" }
|
|
219
|
+
],
|
|
220
|
+
validate: (ctx) => {
|
|
221
|
+
validateIdentity(ctx);
|
|
222
|
+
if (!Number.isInteger(ctx.num("limit")) || ctx.num("limit") < 1 || ctx.num("limit") > 200) throw new CliValidationError("--limit must be an integer from 1 to 200.");
|
|
223
|
+
if (ctx.str("cursor").length > 4096) throw new CliValidationError("--cursor must be at most 4096 characters.");
|
|
224
|
+
},
|
|
225
|
+
dryRun: (ctx) => ({ ...dryRequest(ctx, "GET", previewEndpoint(ctx)), params: { ...query(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} } }),
|
|
226
|
+
execute: (ctx) => kbApi(ctx, "GET", previewEndpoint(ctx), { ...query(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} }, void 0, apiOptions)
|
|
227
|
+
};
|
|
228
|
+
var sourceCommit = {
|
|
229
|
+
service: "kb",
|
|
230
|
+
resource: "source",
|
|
231
|
+
command: "commit",
|
|
232
|
+
risk: "high-risk-write",
|
|
233
|
+
description: "Confirm a reviewed ZIP replacement or restore preview. May delete missing files; changes only the draft. On uncertain outcome, inspect state before any retry.",
|
|
234
|
+
flags: [...identityFlags, previewFlag, revisionFlag],
|
|
235
|
+
validate: (ctx) => {
|
|
236
|
+
validateIdentity(ctx);
|
|
237
|
+
positiveInteger(ctx, "expected-revision");
|
|
238
|
+
},
|
|
239
|
+
dryRun: (ctx) => dryRequest(ctx, "POST", `${previewEndpoint(ctx)}/commit`, { expectedRevision: ctx.num("expected-revision"), confirmed: true }),
|
|
240
|
+
execute: (ctx) => kbApi(ctx, "POST", `${previewEndpoint(ctx)}/commit`, query(ctx), { expectedRevision: ctx.num("expected-revision"), confirmed: true }, apiOptions)
|
|
241
|
+
};
|
|
242
|
+
var sourceCancel = {
|
|
243
|
+
service: "kb",
|
|
244
|
+
resource: "source",
|
|
245
|
+
command: "cancel",
|
|
246
|
+
risk: "high-risk-write",
|
|
247
|
+
description: "Discard an uncommitted ZIP replacement or restore preview; leaves the source draft unchanged.",
|
|
248
|
+
flags: [...identityFlags, previewFlag],
|
|
249
|
+
validate: validateIdentity,
|
|
250
|
+
dryRun: (ctx) => dryRequest(ctx, "DELETE", previewEndpoint(ctx)),
|
|
251
|
+
execute: async (ctx) => {
|
|
252
|
+
await kbApi(ctx, "DELETE", previewEndpoint(ctx), query(ctx), void 0, { ...apiOptions, responseType: "empty" });
|
|
253
|
+
return { previewId: ctx.str("preview-id"), cancelled: true };
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
|
|
38
257
|
// src/commands/te-kb/add.ts
|
|
39
|
-
|
|
258
|
+
import { promises as fs2 } from "fs";
|
|
259
|
+
import * as path2 from "path";
|
|
260
|
+
import TurndownService from "turndown";
|
|
261
|
+
var API_PATH2 = "/agent/api/external/knowledge-bases/sources/upload";
|
|
40
262
|
var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
41
263
|
".zip",
|
|
42
264
|
".md",
|
|
@@ -83,7 +305,7 @@ function sanitizeFilename(name) {
|
|
|
83
305
|
return cleaned || "document";
|
|
84
306
|
}
|
|
85
307
|
function getMimeType(filename) {
|
|
86
|
-
const ext =
|
|
308
|
+
const ext = path2.extname(filename).toLowerCase();
|
|
87
309
|
switch (ext) {
|
|
88
310
|
case ".zip":
|
|
89
311
|
return "application/zip";
|
|
@@ -126,23 +348,23 @@ function getMimeType(filename) {
|
|
|
126
348
|
}
|
|
127
349
|
}
|
|
128
350
|
async function readLocalFile(filePath) {
|
|
129
|
-
const ext =
|
|
351
|
+
const ext = path2.extname(filePath).toLowerCase();
|
|
130
352
|
if (!SUPPORTED_EXTENSIONS.has(ext)) {
|
|
131
353
|
throw new Error(`Unsupported file extension (${ext || "none"}): ${filePath}`);
|
|
132
354
|
}
|
|
133
|
-
const content = await
|
|
134
|
-
const filename =
|
|
355
|
+
const content = await fs2.readFile(filePath);
|
|
356
|
+
const filename = path2.basename(filePath);
|
|
135
357
|
return { filename, content, mimeType: getMimeType(filename), origin: "file", source: filePath };
|
|
136
358
|
}
|
|
137
359
|
async function readDirectory(dir) {
|
|
138
|
-
const entries = await
|
|
360
|
+
const entries = await fs2.readdir(dir, { withFileTypes: true });
|
|
139
361
|
const files = [];
|
|
140
362
|
for (const entry of entries) {
|
|
141
363
|
if (!entry.isFile()) continue;
|
|
142
|
-
const ext =
|
|
364
|
+
const ext = path2.extname(entry.name).toLowerCase();
|
|
143
365
|
if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
|
|
144
|
-
const full =
|
|
145
|
-
const content = await
|
|
366
|
+
const full = path2.join(dir, entry.name);
|
|
367
|
+
const content = await fs2.readFile(full);
|
|
146
368
|
files.push({ filename: entry.name, content, mimeType: getMimeType(entry.name), origin: "dir", source: full });
|
|
147
369
|
}
|
|
148
370
|
if (files.length === 0) {
|
|
@@ -177,10 +399,10 @@ async function fetchAsMarkdown(rawUrl) {
|
|
|
177
399
|
};
|
|
178
400
|
}
|
|
179
401
|
async function resolveLocalPath(p) {
|
|
180
|
-
const abs =
|
|
402
|
+
const abs = path2.resolve(p);
|
|
181
403
|
let stat;
|
|
182
404
|
try {
|
|
183
|
-
stat = await
|
|
405
|
+
stat = await fs2.stat(abs);
|
|
184
406
|
} catch {
|
|
185
407
|
throw new Error(`Path not found: ${p}`);
|
|
186
408
|
}
|
|
@@ -216,7 +438,7 @@ function dedupeByFilename(files) {
|
|
|
216
438
|
const count = used.get(f.filename) ?? 0;
|
|
217
439
|
used.set(f.filename, count + 1);
|
|
218
440
|
if (count === 0) return f;
|
|
219
|
-
const ext =
|
|
441
|
+
const ext = path2.extname(f.filename);
|
|
220
442
|
const stem = f.filename.slice(0, f.filename.length - ext.length);
|
|
221
443
|
return { ...f, filename: `${stem}-${count}${ext}` };
|
|
222
444
|
});
|
|
@@ -251,17 +473,17 @@ var add = {
|
|
|
251
473
|
},
|
|
252
474
|
dryRun: (ctx) => {
|
|
253
475
|
const items = normalizeFilesInput(ctx.json("files"));
|
|
254
|
-
const
|
|
476
|
+
const body2 = {
|
|
255
477
|
name: ctx.str("name")
|
|
256
478
|
};
|
|
257
479
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
258
|
-
if (scope)
|
|
259
|
-
|
|
260
|
-
|
|
480
|
+
if (scope) body2.scope = scope;
|
|
481
|
+
body2.files = items.map((item) => ({ value: item, type: classifyInput(item) }));
|
|
482
|
+
body2.contentType = "multipart/form-data";
|
|
261
483
|
return {
|
|
262
484
|
method: "POST",
|
|
263
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
264
|
-
body
|
|
485
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH2}`,
|
|
486
|
+
body: body2
|
|
265
487
|
};
|
|
266
488
|
},
|
|
267
489
|
execute: async (ctx) => {
|
|
@@ -269,7 +491,7 @@ var add = {
|
|
|
269
491
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
270
492
|
const files = await collectFiles(ctx);
|
|
271
493
|
const form = buildForm(name, scope, files);
|
|
272
|
-
const result = await kbUpload(ctx,
|
|
494
|
+
const result = await kbUpload(ctx, API_PATH2, form);
|
|
273
495
|
return {
|
|
274
496
|
uploaded: files.map((f) => ({ filename: f.filename, origin: f.origin, source: f.source })),
|
|
275
497
|
result
|
|
@@ -278,7 +500,7 @@ var add = {
|
|
|
278
500
|
};
|
|
279
501
|
|
|
280
502
|
// src/commands/te-kb/compile.ts
|
|
281
|
-
var
|
|
503
|
+
var API_PATH3 = "/agent/api/external/knowledge-bases/compile";
|
|
282
504
|
var VALID_MODES = /* @__PURE__ */ new Set(["incremental", "full"]);
|
|
283
505
|
function getMode(ctx) {
|
|
284
506
|
const mode = ctx.str("mode") || "incremental";
|
|
@@ -288,15 +510,15 @@ function getMode(ctx) {
|
|
|
288
510
|
return mode;
|
|
289
511
|
}
|
|
290
512
|
function buildBody(ctx) {
|
|
291
|
-
const
|
|
513
|
+
const body2 = {
|
|
292
514
|
name: ctx.str("name"),
|
|
293
515
|
mode: getMode(ctx)
|
|
294
516
|
};
|
|
295
517
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
296
|
-
if (scope)
|
|
518
|
+
if (scope) body2.scope = scope;
|
|
297
519
|
const model = ctx.str("model");
|
|
298
|
-
if (model)
|
|
299
|
-
return
|
|
520
|
+
if (model) body2.model = model;
|
|
521
|
+
return body2;
|
|
300
522
|
}
|
|
301
523
|
var compile = {
|
|
302
524
|
service: "kb",
|
|
@@ -315,19 +537,19 @@ var compile = {
|
|
|
315
537
|
},
|
|
316
538
|
dryRun: (ctx) => ({
|
|
317
539
|
method: "POST",
|
|
318
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
540
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH3}`,
|
|
319
541
|
body: buildBody(ctx)
|
|
320
542
|
}),
|
|
321
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
543
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH3, {}, buildBody(ctx))
|
|
322
544
|
};
|
|
323
545
|
|
|
324
546
|
// src/commands/te-kb/remove.ts
|
|
325
|
-
var
|
|
547
|
+
var API_PATH4 = "/agent/api/external/knowledge-bases";
|
|
326
548
|
function buildBody2(ctx) {
|
|
327
|
-
const
|
|
549
|
+
const body2 = { name: ctx.str("name") };
|
|
328
550
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
329
|
-
if (scope)
|
|
330
|
-
return
|
|
551
|
+
if (scope) body2.scope = scope;
|
|
552
|
+
return body2;
|
|
331
553
|
}
|
|
332
554
|
var remove = {
|
|
333
555
|
service: "kb",
|
|
@@ -343,14 +565,14 @@ var remove = {
|
|
|
343
565
|
},
|
|
344
566
|
dryRun: (ctx) => ({
|
|
345
567
|
method: "DELETE",
|
|
346
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
568
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH4}`,
|
|
347
569
|
body: buildBody2(ctx)
|
|
348
570
|
}),
|
|
349
|
-
execute: async (ctx) => kbApi(ctx, "DELETE",
|
|
571
|
+
execute: async (ctx) => kbApi(ctx, "DELETE", API_PATH4, {}, buildBody2(ctx))
|
|
350
572
|
};
|
|
351
573
|
|
|
352
574
|
// src/commands/te-kb/create.ts
|
|
353
|
-
var
|
|
575
|
+
var API_PATH5 = "/agent/api/external/knowledge-bases/create";
|
|
354
576
|
var VALID_SCOPES = /* @__PURE__ */ new Set(["personal", "company"]);
|
|
355
577
|
function getScope(ctx) {
|
|
356
578
|
const scope = ctx.str("scope") || "company";
|
|
@@ -378,19 +600,19 @@ function normalizeTags(raw) {
|
|
|
378
600
|
return tags;
|
|
379
601
|
}
|
|
380
602
|
function buildBody3(ctx) {
|
|
381
|
-
const
|
|
603
|
+
const body2 = {
|
|
382
604
|
scope: getScope(ctx),
|
|
383
605
|
name: ctx.str("name")
|
|
384
606
|
};
|
|
385
607
|
const description = ctx.str("description");
|
|
386
|
-
if (description)
|
|
608
|
+
if (description) body2.description = description;
|
|
387
609
|
const tags = normalizeTags(ctx.json("tags"));
|
|
388
|
-
if (tags && tags.length > 0)
|
|
610
|
+
if (tags && tags.length > 0) body2.tags = tags;
|
|
389
611
|
const projectId = ctx.str("project-id");
|
|
390
|
-
if (projectId)
|
|
612
|
+
if (projectId) body2.projectId = projectId;
|
|
391
613
|
const projectName = ctx.str("project-name");
|
|
392
|
-
if (projectName)
|
|
393
|
-
return
|
|
614
|
+
if (projectName) body2.projectName = projectName;
|
|
615
|
+
return body2;
|
|
394
616
|
}
|
|
395
617
|
var create = {
|
|
396
618
|
service: "kb",
|
|
@@ -411,14 +633,14 @@ var create = {
|
|
|
411
633
|
},
|
|
412
634
|
dryRun: (ctx) => ({
|
|
413
635
|
method: "POST",
|
|
414
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
636
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH5}`,
|
|
415
637
|
body: buildBody3(ctx)
|
|
416
638
|
}),
|
|
417
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
639
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH5, {}, buildBody3(ctx))
|
|
418
640
|
};
|
|
419
641
|
|
|
420
642
|
// src/commands/te-kb/rm-source.ts
|
|
421
|
-
var
|
|
643
|
+
var API_PATH6 = "/agent/api/external/knowledge-bases/sources";
|
|
422
644
|
function sourceSelector(ctx) {
|
|
423
645
|
const id = ctx.str("id").trim();
|
|
424
646
|
if (id) return { id };
|
|
@@ -427,12 +649,12 @@ function sourceSelector(ctx) {
|
|
|
427
649
|
throw new CliValidationError("One of --id or --display-name is required.");
|
|
428
650
|
}
|
|
429
651
|
function buildBody4(ctx) {
|
|
430
|
-
const
|
|
652
|
+
const body2 = {
|
|
431
653
|
name: ctx.str("name")
|
|
432
654
|
};
|
|
433
655
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
434
|
-
if (scope)
|
|
435
|
-
return { ...
|
|
656
|
+
if (scope) body2.scope = scope;
|
|
657
|
+
return { ...body2, ...sourceSelector(ctx) };
|
|
436
658
|
}
|
|
437
659
|
var rmSource = {
|
|
438
660
|
service: "kb",
|
|
@@ -451,31 +673,49 @@ var rmSource = {
|
|
|
451
673
|
},
|
|
452
674
|
dryRun: (ctx) => ({
|
|
453
675
|
method: "DELETE",
|
|
454
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
676
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH6}`,
|
|
455
677
|
body: buildBody4(ctx)
|
|
456
678
|
}),
|
|
457
|
-
execute: async (ctx) => kbApi(ctx, "DELETE",
|
|
679
|
+
execute: async (ctx) => kbApi(ctx, "DELETE", API_PATH6, {}, buildBody4(ctx), {
|
|
458
680
|
preserveErrorMetadata: true
|
|
459
681
|
})
|
|
460
682
|
};
|
|
461
683
|
|
|
462
684
|
// src/commands/te-kb/schema.ts
|
|
463
|
-
|
|
685
|
+
import fs3 from "fs";
|
|
686
|
+
import path3 from "path";
|
|
687
|
+
var API_PATH7 = "/agent/api/external/knowledge-bases/schema";
|
|
688
|
+
var MAX_CUSTOM_INSTRUCTIONS_CHARS = 1e4;
|
|
689
|
+
function getCustomInstructions(ctx) {
|
|
690
|
+
const inline = ctx.str("custom-instructions");
|
|
691
|
+
const file = ctx.str("custom-instructions-file");
|
|
692
|
+
if (inline && file) {
|
|
693
|
+
throw new Error("Use either --custom-instructions or --custom-instructions-file, not both.");
|
|
694
|
+
}
|
|
695
|
+
const content = file ? fs3.readFileSync(path3.resolve(file), "utf8") : inline;
|
|
696
|
+
if (file && !content.trim()) {
|
|
697
|
+
throw new Error("--custom-instructions-file is empty.");
|
|
698
|
+
}
|
|
699
|
+
if ([...content].length > MAX_CUSTOM_INSTRUCTIONS_CHARS) {
|
|
700
|
+
throw new Error("Custom instructions exceed 10000 characters.");
|
|
701
|
+
}
|
|
702
|
+
return content;
|
|
703
|
+
}
|
|
464
704
|
function buildBody5(ctx) {
|
|
465
|
-
const
|
|
705
|
+
const body2 = {
|
|
466
706
|
name: ctx.str("name")
|
|
467
707
|
};
|
|
468
708
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
469
|
-
if (scope)
|
|
470
|
-
if (ctx.bool("force"))
|
|
709
|
+
if (scope) body2.scope = scope;
|
|
710
|
+
if (ctx.bool("force")) body2.force = true;
|
|
471
711
|
const model = ctx.str("model");
|
|
472
|
-
if (model)
|
|
473
|
-
const customInstructions = ctx
|
|
474
|
-
if (customInstructions)
|
|
475
|
-
return
|
|
712
|
+
if (model) body2.model = model;
|
|
713
|
+
const customInstructions = getCustomInstructions(ctx);
|
|
714
|
+
if (customInstructions) body2.customInstructions = customInstructions;
|
|
715
|
+
return body2;
|
|
476
716
|
}
|
|
477
717
|
async function executeSchema(ctx, api = kbApi) {
|
|
478
|
-
return api(ctx, "POST",
|
|
718
|
+
return api(ctx, "POST", API_PATH7, {}, buildBody5(ctx), {
|
|
479
719
|
preserveBusinessErrorCode: true
|
|
480
720
|
});
|
|
481
721
|
}
|
|
@@ -494,29 +734,37 @@ var schema = {
|
|
|
494
734
|
required: false,
|
|
495
735
|
sensitive: true,
|
|
496
736
|
desc: "Optional per-run instructions for generating this knowledge base schema"
|
|
737
|
+
},
|
|
738
|
+
{
|
|
739
|
+
name: "custom-instructions-file",
|
|
740
|
+
type: "string",
|
|
741
|
+
required: false,
|
|
742
|
+
sensitive: true,
|
|
743
|
+
desc: "Read optional per-run schema generation instructions from a UTF-8 text file"
|
|
497
744
|
}
|
|
498
745
|
],
|
|
499
746
|
risk: "write",
|
|
500
747
|
validate: (ctx) => {
|
|
501
748
|
getExternalKnowledgeBaseTargetScope(ctx);
|
|
749
|
+
getCustomInstructions(ctx);
|
|
502
750
|
},
|
|
503
751
|
dryRun: (ctx) => ({
|
|
504
752
|
method: "POST",
|
|
505
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
753
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH7}`,
|
|
506
754
|
body: buildBody5(ctx)
|
|
507
755
|
}),
|
|
508
756
|
execute: executeSchema
|
|
509
757
|
};
|
|
510
758
|
|
|
511
759
|
// src/commands/te-kb/status.ts
|
|
512
|
-
var
|
|
760
|
+
var API_PATH8 = "/agent/api/external/knowledge-bases/status";
|
|
513
761
|
function buildBody6(ctx) {
|
|
514
|
-
const
|
|
762
|
+
const body2 = {
|
|
515
763
|
name: ctx.str("name")
|
|
516
764
|
};
|
|
517
765
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
518
|
-
if (scope)
|
|
519
|
-
return
|
|
766
|
+
if (scope) body2.scope = scope;
|
|
767
|
+
return body2;
|
|
520
768
|
}
|
|
521
769
|
var status = {
|
|
522
770
|
service: "kb",
|
|
@@ -532,21 +780,21 @@ var status = {
|
|
|
532
780
|
},
|
|
533
781
|
dryRun: (ctx) => ({
|
|
534
782
|
method: "POST",
|
|
535
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
783
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH8}`,
|
|
536
784
|
body: buildBody6(ctx)
|
|
537
785
|
}),
|
|
538
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
786
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH8, {}, buildBody6(ctx))
|
|
539
787
|
};
|
|
540
788
|
|
|
541
789
|
// src/commands/te-kb/kb-index.ts
|
|
542
|
-
var
|
|
790
|
+
var API_PATH9 = "/agent/api/external/knowledge-bases/index";
|
|
543
791
|
function buildBody7(ctx) {
|
|
544
|
-
const
|
|
792
|
+
const body2 = {};
|
|
545
793
|
const sources = ctx.json("sources");
|
|
546
|
-
if (sources)
|
|
794
|
+
if (sources) body2.sources = sources;
|
|
547
795
|
const locale = ctx.str("locale");
|
|
548
|
-
if (locale)
|
|
549
|
-
return
|
|
796
|
+
if (locale) body2.locale = locale;
|
|
797
|
+
return body2;
|
|
550
798
|
}
|
|
551
799
|
var kbIndex = {
|
|
552
800
|
service: "kb",
|
|
@@ -564,14 +812,14 @@ var kbIndex = {
|
|
|
564
812
|
risk: "read",
|
|
565
813
|
dryRun: (ctx) => ({
|
|
566
814
|
method: "POST",
|
|
567
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
815
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH9}`,
|
|
568
816
|
body: buildBody7(ctx)
|
|
569
817
|
}),
|
|
570
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
818
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH9, {}, buildBody7(ctx))
|
|
571
819
|
};
|
|
572
820
|
|
|
573
821
|
// src/commands/te-kb/kb-list.ts
|
|
574
|
-
var
|
|
822
|
+
var API_PATH10 = "/agent/api/external/knowledge-bases/list";
|
|
575
823
|
var DEFAULT_BUILD_STATUS = "compiled";
|
|
576
824
|
var VALID_BUILD_STATUSES = ["idle", "pending", "compiling", "compiled", "failed"];
|
|
577
825
|
function getBuildStatus(ctx) {
|
|
@@ -588,12 +836,12 @@ function validateBuildStatus(ctx) {
|
|
|
588
836
|
}
|
|
589
837
|
}
|
|
590
838
|
function buildBody8(ctx) {
|
|
591
|
-
const
|
|
839
|
+
const body2 = {
|
|
592
840
|
buildStatus: getBuildStatus(ctx)
|
|
593
841
|
};
|
|
594
842
|
const locale = ctx.str("locale");
|
|
595
|
-
if (locale)
|
|
596
|
-
return
|
|
843
|
+
if (locale) body2.locale = locale;
|
|
844
|
+
return body2;
|
|
597
845
|
}
|
|
598
846
|
var kbList = {
|
|
599
847
|
service: "kb",
|
|
@@ -615,20 +863,20 @@ var kbList = {
|
|
|
615
863
|
},
|
|
616
864
|
dryRun: (ctx) => ({
|
|
617
865
|
method: "POST",
|
|
618
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
866
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH10}`,
|
|
619
867
|
body: buildBody8(ctx)
|
|
620
868
|
}),
|
|
621
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
869
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH10, {}, buildBody8(ctx))
|
|
622
870
|
};
|
|
623
871
|
|
|
624
872
|
// src/commands/te-kb/list-sources.ts
|
|
625
|
-
var
|
|
873
|
+
var API_PATH11 = "/agent/api/external/knowledge-bases/sources";
|
|
626
874
|
var MAX_KNOWLEDGE_BASE_NAME_LENGTH = 200;
|
|
627
875
|
function knowledgeBaseName(ctx) {
|
|
628
876
|
return ctx.str("name").trim();
|
|
629
877
|
}
|
|
630
878
|
function buildUrl(ctx) {
|
|
631
|
-
const url2 = new URL(`${ctx.host().replace(/\/$/, "")}${
|
|
879
|
+
const url2 = new URL(`${ctx.host().replace(/\/$/, "")}${API_PATH11}`);
|
|
632
880
|
url2.searchParams.set("name", knowledgeBaseName(ctx));
|
|
633
881
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
634
882
|
if (scope) url2.searchParams.set("scope", scope);
|
|
@@ -675,26 +923,26 @@ var listSources = {
|
|
|
675
923
|
const params = { name: knowledgeBaseName(ctx) };
|
|
676
924
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
677
925
|
if (scope) params.scope = scope;
|
|
678
|
-
return kbApi(ctx, "GET",
|
|
926
|
+
return kbApi(ctx, "GET", API_PATH11, params, void 0, {
|
|
679
927
|
preserveErrorMetadata: true,
|
|
680
|
-
retryUnauthorized:
|
|
928
|
+
retryUnauthorized: false
|
|
681
929
|
});
|
|
682
930
|
}
|
|
683
931
|
};
|
|
684
932
|
|
|
685
933
|
// src/commands/te-kb/kb-grep.ts
|
|
686
|
-
var
|
|
934
|
+
var API_PATH12 = "/agent/api/external/knowledge-bases/grep";
|
|
687
935
|
function buildBody9(ctx) {
|
|
688
|
-
const
|
|
936
|
+
const body2 = {
|
|
689
937
|
query: ctx.str("query"),
|
|
690
938
|
sources: ctx.json("sources"),
|
|
691
939
|
paths: ctx.json("paths")
|
|
692
940
|
};
|
|
693
941
|
const topK = ctx.optionalNum("top-k");
|
|
694
|
-
if (topK !== void 0)
|
|
942
|
+
if (topK !== void 0) body2.topK = topK;
|
|
695
943
|
const locale = ctx.str("locale");
|
|
696
|
-
if (locale)
|
|
697
|
-
return
|
|
944
|
+
if (locale) body2.locale = locale;
|
|
945
|
+
return body2;
|
|
698
946
|
}
|
|
699
947
|
var kbGrep = {
|
|
700
948
|
service: "kb",
|
|
@@ -726,14 +974,14 @@ var kbGrep = {
|
|
|
726
974
|
risk: "read",
|
|
727
975
|
dryRun: (ctx) => ({
|
|
728
976
|
method: "POST",
|
|
729
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
977
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH12}`,
|
|
730
978
|
body: buildBody9(ctx)
|
|
731
979
|
}),
|
|
732
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
980
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH12, {}, buildBody9(ctx))
|
|
733
981
|
};
|
|
734
982
|
|
|
735
983
|
// src/commands/te-kb/kb-read.ts
|
|
736
|
-
var
|
|
984
|
+
var API_PATH13 = "/agent/api/external/knowledge-bases/read";
|
|
737
985
|
var VALID_EXPAND_MODES = /* @__PURE__ */ new Set(["block", "none"]);
|
|
738
986
|
var MAX_READ_LIMIT = 2e3;
|
|
739
987
|
function readExpand(ctx) {
|
|
@@ -757,20 +1005,20 @@ function readLimit(ctx) {
|
|
|
757
1005
|
return limit;
|
|
758
1006
|
}
|
|
759
1007
|
function buildBody10(ctx) {
|
|
760
|
-
const
|
|
1008
|
+
const body2 = {
|
|
761
1009
|
source: ctx.json("source"),
|
|
762
1010
|
path: ctx.str("path")
|
|
763
1011
|
};
|
|
764
1012
|
const offset = ctx.optionalNum("offset");
|
|
765
|
-
if (offset !== void 0)
|
|
1013
|
+
if (offset !== void 0) body2.offset = offset;
|
|
766
1014
|
const limit = ctx.optionalNum("limit");
|
|
767
|
-
if (limit !== void 0)
|
|
1015
|
+
if (limit !== void 0) body2.limit = limit;
|
|
768
1016
|
const expand = readExpand(ctx);
|
|
769
|
-
if (expand)
|
|
770
|
-
if (ctx.bool("outline"))
|
|
1017
|
+
if (expand) body2.expand = expand;
|
|
1018
|
+
if (ctx.bool("outline")) body2.outline = true;
|
|
771
1019
|
const locale = ctx.str("locale");
|
|
772
|
-
if (locale)
|
|
773
|
-
return
|
|
1020
|
+
if (locale) body2.locale = locale;
|
|
1021
|
+
return body2;
|
|
774
1022
|
}
|
|
775
1023
|
var kbRead = {
|
|
776
1024
|
service: "kb",
|
|
@@ -811,10 +1059,10 @@ var kbRead = {
|
|
|
811
1059
|
},
|
|
812
1060
|
dryRun: (ctx) => ({
|
|
813
1061
|
method: "POST",
|
|
814
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
1062
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH13}`,
|
|
815
1063
|
body: buildBody10(ctx)
|
|
816
1064
|
}),
|
|
817
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
1065
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH13, {}, buildBody10(ctx))
|
|
818
1066
|
};
|
|
819
1067
|
|
|
820
1068
|
// src/commands/te-kb/ask-shared.ts
|
|
@@ -895,16 +1143,16 @@ function validateLocale(locale) {
|
|
|
895
1143
|
}
|
|
896
1144
|
}
|
|
897
1145
|
function buildBody11(ctx) {
|
|
898
|
-
const
|
|
1146
|
+
const body2 = {
|
|
899
1147
|
question: ctx.str("question")
|
|
900
1148
|
};
|
|
901
1149
|
const sources = ctx.json("sources");
|
|
902
|
-
if (sources)
|
|
1150
|
+
if (sources) body2.sources = sources;
|
|
903
1151
|
const modelId = ctx.str("model-id");
|
|
904
|
-
if (modelId)
|
|
1152
|
+
if (modelId) body2.modelId = modelId;
|
|
905
1153
|
const locale = ctx.str("locale");
|
|
906
|
-
if (locale)
|
|
907
|
-
return
|
|
1154
|
+
if (locale) body2.locale = locale;
|
|
1155
|
+
return body2;
|
|
908
1156
|
}
|
|
909
1157
|
var ask = {
|
|
910
1158
|
service: "kb",
|
|
@@ -1024,24 +1272,24 @@ var askStatus = {
|
|
|
1024
1272
|
};
|
|
1025
1273
|
|
|
1026
1274
|
// src/commands/te-kb/url.ts
|
|
1027
|
-
var
|
|
1275
|
+
var API_PATH14 = "/agent/api/external/knowledge-bases/sources/url";
|
|
1028
1276
|
function validateUrl(url2) {
|
|
1029
1277
|
if (!/^https?:\/\//i.test(url2)) {
|
|
1030
1278
|
throw new Error(`Invalid --url: ${url2}. Must be an http(s) URL`);
|
|
1031
1279
|
}
|
|
1032
1280
|
}
|
|
1033
1281
|
function buildBody12(ctx) {
|
|
1034
|
-
const
|
|
1282
|
+
const body2 = {
|
|
1035
1283
|
name: ctx.str("name"),
|
|
1036
1284
|
url: ctx.str("url")
|
|
1037
1285
|
};
|
|
1038
1286
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
1039
|
-
if (scope)
|
|
1287
|
+
if (scope) body2.scope = scope;
|
|
1040
1288
|
const displayName = ctx.str("display-name");
|
|
1041
|
-
if (displayName)
|
|
1289
|
+
if (displayName) body2.displayName = displayName;
|
|
1042
1290
|
const parseInstruction = ctx.str("parse-instruction");
|
|
1043
|
-
if (parseInstruction)
|
|
1044
|
-
return
|
|
1291
|
+
if (parseInstruction) body2.parseInstruction = parseInstruction;
|
|
1292
|
+
return body2;
|
|
1045
1293
|
}
|
|
1046
1294
|
var url = {
|
|
1047
1295
|
service: "kb",
|
|
@@ -1061,16 +1309,16 @@ var url = {
|
|
|
1061
1309
|
},
|
|
1062
1310
|
dryRun: (ctx) => ({
|
|
1063
1311
|
method: "POST",
|
|
1064
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
1312
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH14}`,
|
|
1065
1313
|
body: buildBody12(ctx)
|
|
1066
1314
|
}),
|
|
1067
|
-
execute: async (ctx) => kbApi(ctx, "POST",
|
|
1315
|
+
execute: async (ctx) => kbApi(ctx, "POST", API_PATH14, {}, buildBody12(ctx))
|
|
1068
1316
|
};
|
|
1069
1317
|
|
|
1070
1318
|
// src/commands/te-kb/import.ts
|
|
1071
|
-
import { promises as
|
|
1072
|
-
import
|
|
1073
|
-
var
|
|
1319
|
+
import { promises as fs4 } from "fs";
|
|
1320
|
+
import path4 from "path";
|
|
1321
|
+
var API_PATH15 = "/agent/api/external/knowledge-bases/import";
|
|
1074
1322
|
var MAX_SNAPSHOT_ARCHIVE_BYTES = 50 * 1024 * 1024;
|
|
1075
1323
|
var VALID_SCOPES2 = /* @__PURE__ */ new Set(["personal", "company"]);
|
|
1076
1324
|
function getScope2(ctx) {
|
|
@@ -1106,16 +1354,16 @@ function normalizeTags2(raw) {
|
|
|
1106
1354
|
return tags;
|
|
1107
1355
|
}
|
|
1108
1356
|
function validateArchivePath(filePath) {
|
|
1109
|
-
if (
|
|
1357
|
+
if (path4.extname(filePath).toLocaleLowerCase("en-US") !== ".zip") {
|
|
1110
1358
|
throw new Error("--file must point to a .zip archive");
|
|
1111
1359
|
}
|
|
1112
1360
|
}
|
|
1113
1361
|
async function readArchive(filePath) {
|
|
1114
1362
|
validateArchivePath(filePath);
|
|
1115
|
-
const absolutePath =
|
|
1363
|
+
const absolutePath = path4.resolve(filePath);
|
|
1116
1364
|
let stat;
|
|
1117
1365
|
try {
|
|
1118
|
-
stat = await
|
|
1366
|
+
stat = await fs4.stat(absolutePath);
|
|
1119
1367
|
} catch {
|
|
1120
1368
|
throw new Error(`File not found: ${filePath}`);
|
|
1121
1369
|
}
|
|
@@ -1125,7 +1373,7 @@ async function readArchive(filePath) {
|
|
|
1125
1373
|
if (stat.size > MAX_SNAPSHOT_ARCHIVE_BYTES) {
|
|
1126
1374
|
throw new Error("--file must not exceed 50 MB");
|
|
1127
1375
|
}
|
|
1128
|
-
return { absolutePath, bytes: await
|
|
1376
|
+
return { absolutePath, bytes: await fs4.readFile(absolutePath) };
|
|
1129
1377
|
}
|
|
1130
1378
|
function appendOptionalFields(ctx, form) {
|
|
1131
1379
|
const description = ctx.str("description").trim();
|
|
@@ -1192,7 +1440,7 @@ var importSnapshot = {
|
|
|
1192
1440
|
form.append(
|
|
1193
1441
|
"file",
|
|
1194
1442
|
new Blob([Uint8Array.from(archive.bytes)], { type: "application/zip" }),
|
|
1195
|
-
|
|
1443
|
+
path4.basename(archive.absolutePath)
|
|
1196
1444
|
);
|
|
1197
1445
|
form.append("name", ctx.str("name").trim());
|
|
1198
1446
|
form.append("scope", getScope2(ctx));
|
|
@@ -1200,7 +1448,7 @@ var importSnapshot = {
|
|
|
1200
1448
|
try {
|
|
1201
1449
|
return await kbUpload(
|
|
1202
1450
|
ctx,
|
|
1203
|
-
|
|
1451
|
+
API_PATH15,
|
|
1204
1452
|
form,
|
|
1205
1453
|
{ scope: getScope2(ctx) },
|
|
1206
1454
|
{ preserveErrorMetadata: true, retryUnauthorized: true }
|
|
@@ -1229,7 +1477,7 @@ var importSnapshot = {
|
|
|
1229
1477
|
};
|
|
1230
1478
|
|
|
1231
1479
|
// src/commands/te-kb/import-status.ts
|
|
1232
|
-
var
|
|
1480
|
+
var API_PATH16 = "/agent/api/external/knowledge-bases/import";
|
|
1233
1481
|
var MAX_REQUEST_ID_LENGTH = 191;
|
|
1234
1482
|
function requestIdFrom(ctx) {
|
|
1235
1483
|
return ctx.str("request-id").trim();
|
|
@@ -1260,7 +1508,7 @@ var importStatus = {
|
|
|
1260
1508
|
},
|
|
1261
1509
|
dryRun: (ctx) => ({
|
|
1262
1510
|
method: "GET",
|
|
1263
|
-
url: `${ctx.host().replace(/\/$/, "")}${
|
|
1511
|
+
url: `${ctx.host().replace(/\/$/, "")}${API_PATH16}?requestId=${encodeURIComponent(requestIdFrom(ctx))}`
|
|
1264
1512
|
}),
|
|
1265
1513
|
execute: async (ctx) => {
|
|
1266
1514
|
const hint = "Verify the request ID and that the server supports kb +import-status. Do not retry the import until its status is known.";
|
|
@@ -1268,10 +1516,10 @@ var importStatus = {
|
|
|
1268
1516
|
return await kbApi(
|
|
1269
1517
|
ctx,
|
|
1270
1518
|
"GET",
|
|
1271
|
-
|
|
1519
|
+
API_PATH16,
|
|
1272
1520
|
{ requestId: requestIdFrom(ctx) },
|
|
1273
1521
|
void 0,
|
|
1274
|
-
{ preserveErrorMetadata: true }
|
|
1522
|
+
{ preserveErrorMetadata: true, retryUnauthorized: true }
|
|
1275
1523
|
);
|
|
1276
1524
|
} catch (error) {
|
|
1277
1525
|
if (error instanceof PermissionError) {
|
|
@@ -1299,23 +1547,23 @@ var importStatus = {
|
|
|
1299
1547
|
};
|
|
1300
1548
|
|
|
1301
1549
|
// src/commands/te-kb/source-directory.ts
|
|
1302
|
-
import { promises as
|
|
1303
|
-
import
|
|
1550
|
+
import { promises as fs5 } from "fs";
|
|
1551
|
+
import path5 from "path";
|
|
1304
1552
|
var sourceFlags = [
|
|
1305
1553
|
{ name: "name", type: "string", required: true, desc: "Knowledge base name (personal then company)" },
|
|
1306
1554
|
{ name: "id", type: "string", required: true, desc: "ZIP source ID copied from +list-sources" }
|
|
1307
1555
|
];
|
|
1308
1556
|
var pathFlag = { name: "path", type: "string", required: true, desc: "Exact path relative to the ZIP source root" };
|
|
1309
|
-
var
|
|
1557
|
+
var revisionFlag2 = {
|
|
1310
1558
|
name: "expected-revision",
|
|
1311
1559
|
type: "number",
|
|
1312
1560
|
required: true,
|
|
1313
1561
|
min: 1,
|
|
1314
1562
|
desc: "Revision returned by +source-ls; a conflict requires a fresh read and explicit retry"
|
|
1315
1563
|
};
|
|
1316
|
-
var
|
|
1564
|
+
var apiOptions2 = { preserveErrorMetadata: true, retryUnauthorized: false };
|
|
1317
1565
|
var maxFileBytes = 50 * 1024 * 1024;
|
|
1318
|
-
function
|
|
1566
|
+
function validateIdentity2(ctx) {
|
|
1319
1567
|
for (const [flag, max] of [["name", 200], ["id", 191]]) {
|
|
1320
1568
|
const value = ctx.str(flag).trim();
|
|
1321
1569
|
if (!value || value.length > max) throw new CliValidationError(`Invalid --${flag}.`);
|
|
@@ -1329,8 +1577,8 @@ function relativePath(ctx, allowRoot = false) {
|
|
|
1329
1577
|
}
|
|
1330
1578
|
return value;
|
|
1331
1579
|
}
|
|
1332
|
-
function
|
|
1333
|
-
|
|
1580
|
+
function validateMutation2(ctx) {
|
|
1581
|
+
validateIdentity2(ctx);
|
|
1334
1582
|
relativePath(ctx);
|
|
1335
1583
|
if (!Number.isSafeInteger(ctx.num("expected-revision")) || ctx.num("expected-revision") < 1) {
|
|
1336
1584
|
throw new CliValidationError("--expected-revision must be a positive safe integer.");
|
|
@@ -1339,11 +1587,11 @@ function validateMutation(ctx) {
|
|
|
1339
1587
|
function endpoint(ctx, suffix = "directory") {
|
|
1340
1588
|
return `/agent/api/external/knowledge-bases/sources/${encodeURIComponent(ctx.str("id").trim())}/${suffix}`;
|
|
1341
1589
|
}
|
|
1342
|
-
function
|
|
1590
|
+
function query2(ctx) {
|
|
1343
1591
|
return { name: ctx.str("name").trim(), path: ctx.str("path") };
|
|
1344
1592
|
}
|
|
1345
|
-
function preview(ctx, method, suffix = "directory",
|
|
1346
|
-
return { method, url: `${ctx.host().replace(/\/$/, "")}${endpoint(ctx, suffix)}`, ...
|
|
1593
|
+
function preview(ctx, method, suffix = "directory", body2) {
|
|
1594
|
+
return { method, url: `${ctx.host().replace(/\/$/, "")}${endpoint(ctx, suffix)}`, ...body2 ? { body: body2 } : { params: query2(ctx) } };
|
|
1347
1595
|
}
|
|
1348
1596
|
function mutationBody(ctx, operation) {
|
|
1349
1597
|
return { name: ctx.str("name").trim(), expectedRevision: ctx.num("expected-revision"), operations: [operation] };
|
|
@@ -1360,18 +1608,18 @@ var sourceLs = {
|
|
|
1360
1608
|
{ name: "limit", type: "number", default: 100, min: 1, max: 200, desc: "Page size (1-200)" }
|
|
1361
1609
|
],
|
|
1362
1610
|
validate: (ctx) => {
|
|
1363
|
-
|
|
1611
|
+
validateIdentity2(ctx);
|
|
1364
1612
|
relativePath(ctx, true);
|
|
1365
1613
|
if (!Number.isInteger(ctx.num("limit")) || ctx.num("limit") < 1 || ctx.num("limit") > 200) {
|
|
1366
1614
|
throw new CliValidationError("--limit must be an integer from 1 to 200.");
|
|
1367
1615
|
}
|
|
1368
1616
|
},
|
|
1369
|
-
dryRun: (ctx) => ({ ...preview(ctx, "GET"), params: { ...
|
|
1617
|
+
dryRun: (ctx) => ({ ...preview(ctx, "GET"), params: { ...query2(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} } }),
|
|
1370
1618
|
execute: (ctx) => kbApi(ctx, "GET", endpoint(ctx), {
|
|
1371
|
-
...
|
|
1619
|
+
...query2(ctx),
|
|
1372
1620
|
limit: ctx.num("limit"),
|
|
1373
1621
|
...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {}
|
|
1374
|
-
}, void 0,
|
|
1622
|
+
}, void 0, apiOptions2)
|
|
1375
1623
|
};
|
|
1376
1624
|
var sourceRead = {
|
|
1377
1625
|
service: "kb",
|
|
@@ -1385,18 +1633,18 @@ var sourceRead = {
|
|
|
1385
1633
|
{ name: "output", type: "string", desc: "Save original bytes to this local path; existing files are never overwritten" }
|
|
1386
1634
|
],
|
|
1387
1635
|
validate: (ctx) => {
|
|
1388
|
-
|
|
1636
|
+
validateIdentity2(ctx);
|
|
1389
1637
|
relativePath(ctx);
|
|
1390
1638
|
if (!["utf8", "base64"].includes(ctx.str("encoding"))) throw new CliValidationError("--encoding must be utf8 or base64.");
|
|
1391
1639
|
},
|
|
1392
1640
|
dryRun: (ctx) => preview(ctx, "GET", "raw"),
|
|
1393
1641
|
execute: async (ctx) => {
|
|
1394
|
-
const result = await kbApi(ctx, "GET", endpoint(ctx, "raw"),
|
|
1642
|
+
const result = await kbApi(ctx, "GET", endpoint(ctx, "raw"), query2(ctx), void 0, { ...apiOptions2, responseType: "bytes" });
|
|
1395
1643
|
const bytes = Buffer.from(result.bytes);
|
|
1396
1644
|
const metadata = { path: ctx.str("path"), sizeBytes: bytes.length, contentType: result.contentType };
|
|
1397
1645
|
if (ctx.str("output")) {
|
|
1398
|
-
const output =
|
|
1399
|
-
await
|
|
1646
|
+
const output = path5.resolve(ctx.str("output"));
|
|
1647
|
+
await fs5.writeFile(output, bytes, { flag: "wx" });
|
|
1400
1648
|
return { ...metadata, output };
|
|
1401
1649
|
}
|
|
1402
1650
|
if (ctx.str("encoding") === "base64") return { ...metadata, encoding: "base64", content: bytes.toString("base64") };
|
|
@@ -1408,8 +1656,8 @@ var sourceRead = {
|
|
|
1408
1656
|
}
|
|
1409
1657
|
};
|
|
1410
1658
|
async function fileOperation(ctx, dryRun) {
|
|
1411
|
-
const file =
|
|
1412
|
-
const handle = await
|
|
1659
|
+
const file = path5.resolve(ctx.str("file"));
|
|
1660
|
+
const handle = await fs5.open(file, "r");
|
|
1413
1661
|
try {
|
|
1414
1662
|
const stat = await handle.stat();
|
|
1415
1663
|
if (!stat.isFile() || stat.size > maxFileBytes) throw new CliValidationError("--file must be a regular file of at most 50 MB.");
|
|
@@ -1434,17 +1682,17 @@ var sourcePut = {
|
|
|
1434
1682
|
flags: [
|
|
1435
1683
|
...sourceFlags,
|
|
1436
1684
|
pathFlag,
|
|
1437
|
-
|
|
1685
|
+
revisionFlag2,
|
|
1438
1686
|
{ name: "file", type: "string", required: true, desc: "Local file to upload (at most 50 MB)" },
|
|
1439
1687
|
{ name: "action", type: "string", default: "add", desc: "add rejects an existing path; replace explicitly overwrites an existing file" }
|
|
1440
1688
|
],
|
|
1441
1689
|
validate: (ctx) => {
|
|
1442
|
-
|
|
1690
|
+
validateMutation2(ctx);
|
|
1443
1691
|
if (!ctx.str("file").trim()) throw new CliValidationError("--file must be non-empty.");
|
|
1444
1692
|
if (!["add", "replace"].includes(ctx.str("action"))) throw new CliValidationError("--action must be add or replace.");
|
|
1445
1693
|
},
|
|
1446
1694
|
dryRun: async (ctx) => preview(ctx, "POST", "directory", mutationBody(ctx, await fileOperation(ctx, true))),
|
|
1447
|
-
execute: async (ctx) => kbApi(ctx, "POST", endpoint(ctx), {}, mutationBody(ctx, await fileOperation(ctx, false)),
|
|
1695
|
+
execute: async (ctx) => kbApi(ctx, "POST", endpoint(ctx), {}, mutationBody(ctx, await fileOperation(ctx, false)), apiOptions2)
|
|
1448
1696
|
};
|
|
1449
1697
|
function deleteOperation(ctx) {
|
|
1450
1698
|
return { action: "delete", path: ctx.str("path"), confirmed: true, ...ctx.bool("recursive") ? { recursive: true } : {} };
|
|
@@ -1457,19 +1705,19 @@ var sourceRm = {
|
|
|
1457
1705
|
flags: [
|
|
1458
1706
|
...sourceFlags,
|
|
1459
1707
|
pathFlag,
|
|
1460
|
-
|
|
1708
|
+
revisionFlag2,
|
|
1461
1709
|
{ name: "recursive", type: "boolean", desc: "Explicitly allow recursive directory deletion" }
|
|
1462
1710
|
],
|
|
1463
|
-
validate:
|
|
1711
|
+
validate: validateMutation2,
|
|
1464
1712
|
dryRun: (ctx) => preview(ctx, "POST", "directory", mutationBody(ctx, deleteOperation(ctx))),
|
|
1465
|
-
execute: (ctx) => kbApi(ctx, "POST", endpoint(ctx), {}, mutationBody(ctx, deleteOperation(ctx)),
|
|
1713
|
+
execute: (ctx) => kbApi(ctx, "POST", endpoint(ctx), {}, mutationBody(ctx, deleteOperation(ctx)), apiOptions2)
|
|
1466
1714
|
};
|
|
1467
1715
|
|
|
1468
1716
|
// src/commands/te-kb/version-management.ts
|
|
1469
|
-
import { promises as
|
|
1470
|
-
import
|
|
1471
|
-
var
|
|
1472
|
-
var
|
|
1717
|
+
import { promises as fs6 } from "fs";
|
|
1718
|
+
import path6 from "path";
|
|
1719
|
+
var API2 = "/agent/api/external/knowledge-bases/versions";
|
|
1720
|
+
var apiOptions3 = { preserveErrorMetadata: true, retryUnauthorized: false };
|
|
1473
1721
|
var targetFlags = [
|
|
1474
1722
|
{ name: "name", type: "string", required: true, minLength: 1, maxLength: 200, desc: "Exact knowledge base name copied from +list" },
|
|
1475
1723
|
{ name: "scope", type: "string", desc: "Exact personal or company scope; omit for personal then company lookup" }
|
|
@@ -1481,7 +1729,7 @@ var pagingFlags = [
|
|
|
1481
1729
|
{ name: "limit", type: "number", default: 100, min: 1, max: 200, desc: "Page size from 1 to 200" }
|
|
1482
1730
|
];
|
|
1483
1731
|
var pathFlag2 = { name: "path", type: "string", desc: "Exact path relative to the historical source directory" };
|
|
1484
|
-
function
|
|
1732
|
+
function positiveInteger2(ctx, flag) {
|
|
1485
1733
|
const value = ctx.num(flag);
|
|
1486
1734
|
if (!Number.isSafeInteger(value) || value < 1 || value > 2147483647) throw new CliValidationError(`--${flag} must be a positive integer no greater than 2147483647.`);
|
|
1487
1735
|
return value;
|
|
@@ -1493,7 +1741,7 @@ function validateTarget(ctx) {
|
|
|
1493
1741
|
}
|
|
1494
1742
|
function validateVersion(ctx) {
|
|
1495
1743
|
validateTarget(ctx);
|
|
1496
|
-
|
|
1744
|
+
positiveInteger2(ctx, "version");
|
|
1497
1745
|
}
|
|
1498
1746
|
function validateSource(ctx) {
|
|
1499
1747
|
validateVersion(ctx);
|
|
@@ -1512,21 +1760,21 @@ function validatePath(ctx, required = false) {
|
|
|
1512
1760
|
throw new CliValidationError("--path must be a normalized relative path inside the historical source.");
|
|
1513
1761
|
}
|
|
1514
1762
|
}
|
|
1515
|
-
function
|
|
1763
|
+
function query3(ctx) {
|
|
1516
1764
|
const scope = getExternalKnowledgeBaseTargetScope(ctx);
|
|
1517
1765
|
return { name: ctx.str("name").trim(), ...scope ? { scope } : {} };
|
|
1518
1766
|
}
|
|
1519
1767
|
function pageQuery(ctx) {
|
|
1520
|
-
return { ...
|
|
1768
|
+
return { ...query3(ctx), limit: ctx.num("limit"), ...ctx.str("cursor") ? { cursor: ctx.str("cursor") } : {} };
|
|
1521
1769
|
}
|
|
1522
1770
|
function versionEndpoint(ctx, suffix = "") {
|
|
1523
|
-
return `${
|
|
1771
|
+
return `${API2}/${positiveInteger2(ctx, "version")}${suffix}`;
|
|
1524
1772
|
}
|
|
1525
|
-
function
|
|
1773
|
+
function sourceEndpoint2(ctx, action) {
|
|
1526
1774
|
return versionEndpoint(ctx, `/sources/${encodeURIComponent(ctx.str("id").trim())}/${action}`);
|
|
1527
1775
|
}
|
|
1528
|
-
function preview2(ctx, endpoint2, params,
|
|
1529
|
-
return { method:
|
|
1776
|
+
function preview2(ctx, endpoint2, params, body2) {
|
|
1777
|
+
return { method: body2 ? "POST" : "GET", url: `${ctx.host().replace(/\/$/, "")}${endpoint2}`, params, ...body2 ? { body: body2 } : {} };
|
|
1530
1778
|
}
|
|
1531
1779
|
var versions = {
|
|
1532
1780
|
service: "kb",
|
|
@@ -1539,8 +1787,8 @@ var versions = {
|
|
|
1539
1787
|
validatePage(ctx);
|
|
1540
1788
|
if (ctx.str("cursor") && (!/^[1-9][0-9]*$/.test(ctx.str("cursor")) || Number(ctx.str("cursor")) > 2147483647)) throw new CliValidationError("--cursor must be a version number returned as nextCursor.");
|
|
1541
1789
|
},
|
|
1542
|
-
dryRun: (ctx) => preview2(ctx,
|
|
1543
|
-
execute: (ctx) => kbApi(ctx, "GET",
|
|
1790
|
+
dryRun: (ctx) => preview2(ctx, API2, pageQuery(ctx)),
|
|
1791
|
+
execute: (ctx) => kbApi(ctx, "GET", API2, pageQuery(ctx), void 0, apiOptions3)
|
|
1544
1792
|
};
|
|
1545
1793
|
var versionShow = {
|
|
1546
1794
|
service: "kb",
|
|
@@ -1549,8 +1797,8 @@ var versionShow = {
|
|
|
1549
1797
|
description: "Read one published version summary without reading current sources.",
|
|
1550
1798
|
flags: [...targetFlags, versionFlag],
|
|
1551
1799
|
validate: validateVersion,
|
|
1552
|
-
dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx),
|
|
1553
|
-
execute: (ctx) => kbApi(ctx, "GET", versionEndpoint(ctx),
|
|
1800
|
+
dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx), query3(ctx)),
|
|
1801
|
+
execute: (ctx) => kbApi(ctx, "GET", versionEndpoint(ctx), query3(ctx), void 0, apiOptions3)
|
|
1554
1802
|
};
|
|
1555
1803
|
var versionSources = {
|
|
1556
1804
|
service: "kb",
|
|
@@ -1564,7 +1812,7 @@ var versionSources = {
|
|
|
1564
1812
|
if (ctx.str("source-type") && !["file", "url", "zip"].includes(ctx.str("source-type"))) throw new CliValidationError("--source-type must be file, url, or zip.");
|
|
1565
1813
|
},
|
|
1566
1814
|
dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx, "/sources"), { ...pageQuery(ctx), ...ctx.str("source-type") ? { sourceType: ctx.str("source-type") } : {} }),
|
|
1567
|
-
execute: (ctx) => kbApi(ctx, "GET", versionEndpoint(ctx, "/sources"), { ...pageQuery(ctx), ...ctx.str("source-type") ? { sourceType: ctx.str("source-type") } : {} }, void 0,
|
|
1815
|
+
execute: (ctx) => kbApi(ctx, "GET", versionEndpoint(ctx, "/sources"), { ...pageQuery(ctx), ...ctx.str("source-type") ? { sourceType: ctx.str("source-type") } : {} }, void 0, apiOptions3)
|
|
1568
1816
|
};
|
|
1569
1817
|
var versionDiff = {
|
|
1570
1818
|
service: "kb",
|
|
@@ -1574,11 +1822,11 @@ var versionDiff = {
|
|
|
1574
1822
|
flags: [...targetFlags, { ...versionFlag, name: "from", desc: "Before version number" }, { ...versionFlag, name: "to", desc: "After version number" }],
|
|
1575
1823
|
validate: (ctx) => {
|
|
1576
1824
|
validateTarget(ctx);
|
|
1577
|
-
|
|
1578
|
-
|
|
1825
|
+
positiveInteger2(ctx, "from");
|
|
1826
|
+
positiveInteger2(ctx, "to");
|
|
1579
1827
|
},
|
|
1580
|
-
dryRun: (ctx) => preview2(ctx, `${
|
|
1581
|
-
execute: (ctx) => kbApi(ctx, "GET", `${
|
|
1828
|
+
dryRun: (ctx) => preview2(ctx, `${API2}/compare`, { ...query3(ctx), from: ctx.num("from"), to: ctx.num("to") }),
|
|
1829
|
+
execute: (ctx) => kbApi(ctx, "GET", `${API2}/compare`, { ...query3(ctx), from: ctx.num("from"), to: ctx.num("to") }, void 0, apiOptions3)
|
|
1582
1830
|
};
|
|
1583
1831
|
var versionTree = {
|
|
1584
1832
|
service: "kb",
|
|
@@ -1591,8 +1839,8 @@ var versionTree = {
|
|
|
1591
1839
|
validatePath(ctx);
|
|
1592
1840
|
validatePage(ctx);
|
|
1593
1841
|
},
|
|
1594
|
-
dryRun: (ctx) => preview2(ctx,
|
|
1595
|
-
execute: (ctx) => kbApi(ctx, "GET",
|
|
1842
|
+
dryRun: (ctx) => preview2(ctx, sourceEndpoint2(ctx, "tree"), { ...pageQuery(ctx), path: ctx.str("path") }),
|
|
1843
|
+
execute: (ctx) => kbApi(ctx, "GET", sourceEndpoint2(ctx, "tree"), { ...pageQuery(ctx), path: ctx.str("path") }, void 0, apiOptions3)
|
|
1596
1844
|
};
|
|
1597
1845
|
var versionRead = {
|
|
1598
1846
|
service: "kb",
|
|
@@ -1604,8 +1852,8 @@ var versionRead = {
|
|
|
1604
1852
|
validateSource(ctx);
|
|
1605
1853
|
validatePath(ctx, true);
|
|
1606
1854
|
},
|
|
1607
|
-
dryRun: (ctx) => preview2(ctx,
|
|
1608
|
-
execute: (ctx) => kbApi(ctx, "GET",
|
|
1855
|
+
dryRun: (ctx) => preview2(ctx, sourceEndpoint2(ctx, "file"), { ...query3(ctx), path: ctx.str("path") }),
|
|
1856
|
+
execute: (ctx) => kbApi(ctx, "GET", sourceEndpoint2(ctx, "file"), { ...query3(ctx), path: ctx.str("path") }, void 0, apiOptions3)
|
|
1609
1857
|
};
|
|
1610
1858
|
var versionDownload = {
|
|
1611
1859
|
service: "kb",
|
|
@@ -1617,12 +1865,12 @@ var versionDownload = {
|
|
|
1617
1865
|
validateSource(ctx);
|
|
1618
1866
|
if (!ctx.str("output").trim()) throw new CliValidationError("--output is required.");
|
|
1619
1867
|
},
|
|
1620
|
-
dryRun: (ctx) => ({ ...preview2(ctx,
|
|
1868
|
+
dryRun: (ctx) => ({ ...preview2(ctx, sourceEndpoint2(ctx, "raw"), query3(ctx)), output: path6.resolve(ctx.str("output")) }),
|
|
1621
1869
|
execute: async (ctx) => {
|
|
1622
|
-
const result = await kbApi(ctx, "GET",
|
|
1623
|
-
const output =
|
|
1870
|
+
const result = await kbApi(ctx, "GET", sourceEndpoint2(ctx, "raw"), query3(ctx), void 0, { ...apiOptions3, responseType: "bytes" });
|
|
1871
|
+
const output = path6.resolve(ctx.str("output"));
|
|
1624
1872
|
const bytes = Buffer.from(result.bytes);
|
|
1625
|
-
await
|
|
1873
|
+
await fs6.writeFile(output, bytes, { flag: "wx" });
|
|
1626
1874
|
return { versionNumber: ctx.num("version"), sourceId: ctx.str("id").trim(), sizeBytes: String(bytes.length), output };
|
|
1627
1875
|
}
|
|
1628
1876
|
};
|
|
@@ -1646,8 +1894,8 @@ var rollback = {
|
|
|
1646
1894
|
const latest = ctx.str("expected-latest-version-id");
|
|
1647
1895
|
if (!latest || latest.length > 191) throw new CliValidationError("--expected-latest-version-id must contain 1 to 191 characters.");
|
|
1648
1896
|
},
|
|
1649
|
-
dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx, "/rollback"),
|
|
1650
|
-
execute: (ctx) => kbApi(ctx, "POST", versionEndpoint(ctx, "/rollback"),
|
|
1897
|
+
dryRun: (ctx) => preview2(ctx, versionEndpoint(ctx, "/rollback"), query3(ctx), rollbackBody(ctx)),
|
|
1898
|
+
execute: (ctx) => kbApi(ctx, "POST", versionEndpoint(ctx, "/rollback"), query3(ctx), rollbackBody(ctx), apiOptions3)
|
|
1651
1899
|
};
|
|
1652
1900
|
var rollbackStatus = {
|
|
1653
1901
|
service: "kb",
|
|
@@ -1659,12 +1907,18 @@ var rollbackStatus = {
|
|
|
1659
1907
|
validateTarget(ctx);
|
|
1660
1908
|
if (!ctx.str("operation-id").trim() || ctx.str("operation-id").length > 191) throw new CliValidationError("--operation-id must contain 1 to 191 characters.");
|
|
1661
1909
|
},
|
|
1662
|
-
dryRun: (ctx) => preview2(ctx, `${
|
|
1663
|
-
execute: (ctx) => kbApi(ctx, "GET", `${
|
|
1910
|
+
dryRun: (ctx) => preview2(ctx, `${API2}/operations/${encodeURIComponent(ctx.str("operation-id").trim())}`, query3(ctx)),
|
|
1911
|
+
execute: (ctx) => kbApi(ctx, "GET", `${API2}/operations/${encodeURIComponent(ctx.str("operation-id").trim())}`, query3(ctx), void 0, apiOptions3)
|
|
1664
1912
|
};
|
|
1665
1913
|
|
|
1666
1914
|
// src/commands/te-kb/index.ts
|
|
1667
1915
|
var commands = [
|
|
1916
|
+
sourceCheckUpdates,
|
|
1917
|
+
sourceReplace,
|
|
1918
|
+
sourceRestore,
|
|
1919
|
+
sourcePreview,
|
|
1920
|
+
sourceCommit,
|
|
1921
|
+
sourceCancel,
|
|
1668
1922
|
versions,
|
|
1669
1923
|
versionShow,
|
|
1670
1924
|
versionSources,
|
|
@@ -1716,9 +1970,15 @@ export {
|
|
|
1716
1970
|
rollback,
|
|
1717
1971
|
rollbackStatus,
|
|
1718
1972
|
schema,
|
|
1973
|
+
sourceCancel,
|
|
1974
|
+
sourceCheckUpdates,
|
|
1975
|
+
sourceCommit,
|
|
1719
1976
|
sourceLs,
|
|
1977
|
+
sourcePreview,
|
|
1720
1978
|
sourcePut,
|
|
1721
1979
|
sourceRead,
|
|
1980
|
+
sourceReplace,
|
|
1981
|
+
sourceRestore,
|
|
1722
1982
|
sourceRm,
|
|
1723
1983
|
status,
|
|
1724
1984
|
url,
|