licos-platform-cli 0.4.6__tar.gz → 0.4.8__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: licos-platform-cli
3
- Version: 0.4.6
3
+ Version: 0.4.8
4
4
  Summary: LICOS platform CLI
5
5
  Requires-Python: >=3.10
6
- Requires-Dist: licos-platform-sdk>=0.5.4
6
+ Requires-Dist: licos-platform-sdk>=0.5.5
@@ -4,11 +4,11 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "licos-platform-cli"
7
- version = "0.4.6"
7
+ version = "0.4.8"
8
8
  description = "LICOS platform CLI"
9
9
  requires-python = ">=3.10"
10
10
  dependencies = [
11
- "licos-platform-sdk>=0.5.4",
11
+ "licos-platform-sdk>=0.5.5",
12
12
  ]
13
13
 
14
14
  [project.scripts]
@@ -817,10 +817,23 @@ ONTOLOGY_HELP = {
817
817
  "Resolve elements by stable IDs before querying context, model checks, or mapped data.",
818
818
  "READ tools query state, PREPARE tools validate a change draft, and PERSIST tools apply an explicitly confirmed draft.",
819
819
  "PERSIST commands require --confirm. Never reuse a catalog result after its catalogVersion changes.",
820
+ "实时订阅由项目后端 SDK 完成,CLI 不提供常驻 WebSocket 命令;不得读取 Token 或自行拼上游连接。",
820
821
  ],
822
+ "realtimeSdk": {
823
+ "node": "const subscription = await ontology.subscribeRealtime({ elementIds, attributeIds });\ntry { for await (const event of subscription) { sendBusinessEvent(event); } }\nfinally { await subscription.close(); }",
824
+ "python": "with ontology.subscribe_realtime(element_ids, attribute_ids=attribute_ids) as subscription:\n for event in subscription:\n send_business_event(event)",
825
+ "minimum_versions": {"node": "0.10.5", "python": "0.5.5"},
826
+ "parameters": {
827
+ "elementIds / element_ids": "必填,非空字符串 ID 数组;已解析且授权的元素,不递归子元素。",
828
+ "attributeIds / attribute_ids": "可选,字符串 ID 数组;省略或空数组表示所选元素的全部授权属性。",
829
+ },
830
+ "returns": "收到订阅确认后返回订阅对象;单消费者迭代 property.changed 原始业务事件,close 取消订阅。Node 使用异步迭代,Python 使用同步 with/for,异步服务放入工作线程。",
831
+ "errors": "创建错误直接抛出,后续错误从迭代器抛出;401 仅刷新一次,403/协议错误不重试,网络重连累计默认 3 次。不得把获取连接计划当成订阅成功。",
832
+ "reference": "industrial-ontology/references/realtime-sdk.md",
833
+ },
821
834
  "sdk": {
822
- "python": "from licos_platform_sdk import ontology\ncatalog = ontology.search_tools('查询设备实时数据')\nselected = catalog['items'][0]\n# 按 selected['definition']['function']['parameters'] 构造 arguments 后调用 selected 中的精确函数名。",
823
- "node": "import { ontology } from '@kmlckj/licos-platform-sdk';\nconst catalog = await ontology.searchTools('查询设备实时数据');\nconst selected = catalog.items[0];\n// 按 selected.definition.function.parameters 构造 arguments 后调用 selected 中的精确函数名。",
835
+ "python": "from licos_platform_sdk import ontology\ncatalog = ontology.search_tools('查询设备实时数据')\nselected = next((item for item in catalog['items'] if item['selection'] == 'MATCH' and item['mode'] == 'READ' and item['definition']['function']['name'] == requested_tool_name), None)\nif selected is None:\n raise RuntimeError('当前目录中没有匹配的只读本体工具')\n# 按 selected['definition']['function']['parameters'] 校验参数后调用精确函数名。",
836
+ "node": "import { ontology } from '@kmlckj/licos-platform-sdk';\nconst catalog = await ontology.searchTools('查询设备实时数据');\nconst selected = catalog.items.find((item) => item.selection === 'MATCH' && item.mode === 'READ' && item.definition.function.name === requestedToolName);\nif (!selected) throw new Error('当前目录中没有匹配的只读本体工具');\n// 按 selected.definition.function.parameters 校验参数后调用精确函数名。",
824
837
  },
825
838
  "commands": {
826
839
  "search": {
@@ -851,7 +864,7 @@ HELP_TOPICS = {
851
864
  "database": DATABASE_HELP,
852
865
  "knowledge": KNOWLEDGE_HELP,
853
866
  "oauth": OAUTH_HELP,
854
- "project-config": PROJECT_CONFIG_HELP,
867
+ "project-config": PROJECT_CONFIG_HELP,
855
868
  "ontology": ONTOLOGY_HELP,
856
869
  }
857
870
 
@@ -109,6 +109,14 @@ class PlatformCliTests(unittest.TestCase):
109
109
  self.assertEqual(payload["topic"], "ontology")
110
110
  self.assertEqual(set(payload["commands"]), {"search", "invoke"})
111
111
  self.assertTrue(any("catalogVersion" in rule for rule in payload["rules"]))
112
+ sdk_help = "\n".join(payload["sdk"].values())
113
+ self.assertNotIn("items[0]", sdk_help)
114
+ self.assertNotIn("items'][0]", sdk_help)
115
+ self.assertIn("selection", sdk_help)
116
+ self.assertIn("mode", sdk_help)
117
+ self.assertIn("subscribeRealtime", payload["realtimeSdk"]["node"])
118
+ self.assertIn("subscribe_realtime", payload["realtimeSdk"]["python"])
119
+ self.assertEqual(payload["realtimeSdk"]["minimum_versions"], {"node": "0.10.5", "python": "0.5.5"})
112
120
 
113
121
  def test_ontology_search_forwards_catalog_pagination(self) -> None:
114
122
  result = {"catalogVersion": "v1", "items": []}