sema-core 2.0.9__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 semacode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: sema-core
3
+ Version: 2.0.9
4
+ Summary: Python SDK for sema-core: thin client over the sema-grpc bridge
5
+ Author: SemaCode
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/midea-ai/sema-code-core
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: grpcio>=1.60
12
+ Requires-Dist: protobuf>=4.25
13
+ Provides-Extra: dev
14
+ Requires-Dist: grpcio-tools>=1.60; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # Sema Python SDK
18
+
19
+ [Sema Code Core](https://github.com/midea-ai/sema-code-core) 的官方 Python SDK:一个事件驱动的 AI 编程助手核心引擎,支持多代理协作、Skill 扩展、Plan 模式任务规划等能力。SDK 内嵌 core 运行时(sidecar),`pip install` 后开箱即用,asyncio-first。
20
+
21
+ ## 安装
22
+
23
+ ```bash
24
+ pip install sema-core
25
+ ```
26
+
27
+ 要求:Python 3.10+,本机 Node.js ≥ 18(core 运行时依赖)。
28
+
29
+ ## 快速开始
30
+
31
+ ```python
32
+ import asyncio
33
+ from sema_sdk import SemaCore
34
+
35
+ async def main():
36
+ core = await SemaCore.start({"workingDir": "/path/to/your/project"})
37
+ session = await core.create_session()
38
+ session.on("message:text:chunk", lambda d: print(d["delta"], end="", flush=True))
39
+ await session.process_user_input("你好")
40
+ await core.close()
41
+
42
+ asyncio.run(main())
43
+ ```
44
+
45
+ 模型配置与更多用法见 [文档](https://midea-ai.github.io/sema-code-core),完整示例见 [example/python-demo](https://github.com/midea-ai/sema-code-core/tree/main/example/python-demo)(交互式 CLI 与一次性执行)。
46
+
47
+ ## License
48
+
49
+ [MIT](https://github.com/midea-ai/sema-code-core/blob/main/LICENSE)
@@ -0,0 +1,33 @@
1
+ # Sema Python SDK
2
+
3
+ [Sema Code Core](https://github.com/midea-ai/sema-code-core) 的官方 Python SDK:一个事件驱动的 AI 编程助手核心引擎,支持多代理协作、Skill 扩展、Plan 模式任务规划等能力。SDK 内嵌 core 运行时(sidecar),`pip install` 后开箱即用,asyncio-first。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ pip install sema-core
9
+ ```
10
+
11
+ 要求:Python 3.10+,本机 Node.js ≥ 18(core 运行时依赖)。
12
+
13
+ ## 快速开始
14
+
15
+ ```python
16
+ import asyncio
17
+ from sema_sdk import SemaCore
18
+
19
+ async def main():
20
+ core = await SemaCore.start({"workingDir": "/path/to/your/project"})
21
+ session = await core.create_session()
22
+ session.on("message:text:chunk", lambda d: print(d["delta"], end="", flush=True))
23
+ await session.process_user_input("你好")
24
+ await core.close()
25
+
26
+ asyncio.run(main())
27
+ ```
28
+
29
+ 模型配置与更多用法见 [文档](https://midea-ai.github.io/sema-code-core),完整示例见 [example/python-demo](https://github.com/midea-ai/sema-code-core/tree/main/example/python-demo)(交互式 CLI 与一次性执行)。
30
+
31
+ ## License
32
+
33
+ [MIT](https://github.com/midea-ai/sema-code-core/blob/main/LICENSE)
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sema-core"
7
+ version = "2.0.9"
8
+ description = "Python SDK for sema-core: thin client over the sema-grpc bridge"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "SemaCode" }]
13
+ dependencies = [
14
+ "grpcio>=1.60",
15
+ "protobuf>=4.25",
16
+ ]
17
+
18
+ [project.urls]
19
+ Repository = "https://github.com/midea-ai/sema-code-core"
20
+
21
+ [project.optional-dependencies]
22
+ dev = ["grpcio-tools>=1.60"]
23
+
24
+ [tool.setuptools.packages.find]
25
+ where = ["src"]
26
+
27
+ [tool.setuptools.package-data]
28
+ # _generated 提交入仓(pip 安装不依赖 protoc);_sidecar 由 scripts/embed_sidecar.py
29
+ # 从 ../bridge/dist 复制(构建产物不入 git,发布前执行,与 Java jar 内嵌同构)
30
+ sema_sdk = ["_sidecar/server.js", "_sidecar/proto/sema.proto"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: sema-core
3
+ Version: 2.0.9
4
+ Summary: Python SDK for sema-core: thin client over the sema-grpc bridge
5
+ Author: SemaCode
6
+ License-Expression: MIT
7
+ Project-URL: Repository, https://github.com/midea-ai/sema-code-core
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: grpcio>=1.60
12
+ Requires-Dist: protobuf>=4.25
13
+ Provides-Extra: dev
14
+ Requires-Dist: grpcio-tools>=1.60; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # Sema Python SDK
18
+
19
+ [Sema Code Core](https://github.com/midea-ai/sema-code-core) 的官方 Python SDK:一个事件驱动的 AI 编程助手核心引擎,支持多代理协作、Skill 扩展、Plan 模式任务规划等能力。SDK 内嵌 core 运行时(sidecar),`pip install` 后开箱即用,asyncio-first。
20
+
21
+ ## 安装
22
+
23
+ ```bash
24
+ pip install sema-core
25
+ ```
26
+
27
+ 要求:Python 3.10+,本机 Node.js ≥ 18(core 运行时依赖)。
28
+
29
+ ## 快速开始
30
+
31
+ ```python
32
+ import asyncio
33
+ from sema_sdk import SemaCore
34
+
35
+ async def main():
36
+ core = await SemaCore.start({"workingDir": "/path/to/your/project"})
37
+ session = await core.create_session()
38
+ session.on("message:text:chunk", lambda d: print(d["delta"], end="", flush=True))
39
+ await session.process_user_input("你好")
40
+ await core.close()
41
+
42
+ asyncio.run(main())
43
+ ```
44
+
45
+ 模型配置与更多用法见 [文档](https://midea-ai.github.io/sema-code-core),完整示例见 [example/python-demo](https://github.com/midea-ai/sema-code-core/tree/main/example/python-demo)(交互式 CLI 与一次性执行)。
46
+
47
+ ## License
48
+
49
+ [MIT](https://github.com/midea-ai/sema-code-core/blob/main/LICENSE)
@@ -0,0 +1,20 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/sema_core.egg-info/PKG-INFO
5
+ src/sema_core.egg-info/SOURCES.txt
6
+ src/sema_core.egg-info/dependency_links.txt
7
+ src/sema_core.egg-info/requires.txt
8
+ src/sema_core.egg-info/top_level.txt
9
+ src/sema_sdk/__init__.py
10
+ src/sema_sdk/api.py
11
+ src/sema_sdk/constants.py
12
+ src/sema_sdk/events.py
13
+ src/sema_sdk/protocol.py
14
+ src/sema_sdk/runtime.py
15
+ src/sema_sdk/transport.py
16
+ src/sema_sdk/_generated/__init__.py
17
+ src/sema_sdk/_generated/sema_pb2.py
18
+ src/sema_sdk/_generated/sema_pb2_grpc.py
19
+ src/sema_sdk/_sidecar/server.js
20
+ src/sema_sdk/_sidecar/proto/sema.proto
@@ -0,0 +1,5 @@
1
+ grpcio>=1.60
2
+ protobuf>=4.25
3
+
4
+ [dev]
5
+ grpcio-tools>=1.60
@@ -0,0 +1 @@
1
+ sema_sdk
@@ -0,0 +1,24 @@
1
+ """sema-sdk:sema-core 的 Python SDK(gRPC 桥薄客户端,asyncio-first)。
2
+
3
+ from sema_sdk import SemaCore
4
+
5
+ core = await SemaCore.start({"workingDir": project_dir})
6
+ session = await core.create_session()
7
+ session.on("message:text:chunk", lambda d: print(d["delta"], end=""))
8
+ await session.process_user_input("你好")
9
+ await core.close()
10
+ """
11
+ from . import events as SemaEvents
12
+ from .api import SemaCore, SemaSession
13
+ from .constants import MAIN_AGENT_ID, PROTOCOL_VERSION
14
+ from .protocol import Registration, SemaBridgeClient, SemaBridgeException
15
+ from .runtime import NodeProvider, SidecarManager, system_node_provider
16
+ from .transport import BridgeConnection, ConnectionState, SemaEvent
17
+
18
+ __all__ = [
19
+ "SemaCore", "SemaSession", "SemaEvents",
20
+ "MAIN_AGENT_ID", "PROTOCOL_VERSION",
21
+ "SemaBridgeClient", "SemaBridgeException", "Registration",
22
+ "BridgeConnection", "ConnectionState", "SemaEvent",
23
+ "SidecarManager", "NodeProvider", "system_node_provider",
24
+ ]
File without changes
@@ -0,0 +1,41 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: sema.proto
5
+ # Protobuf Python Version: 7.35.0
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 7,
15
+ 35,
16
+ 0,
17
+ '',
18
+ 'sema.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+
26
+
27
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\nsema.proto\x12\x04sema\"P\n\rBridgeCommand\x12\n\n\x02id\x18\x01 \x01(\t\x12\x0e\n\x06\x61\x63tion\x18\x02 \x01(\t\x12\x0f\n\x07payload\x18\x03 \x01(\t\x12\x12\n\nsession_id\x18\x04 \x01(\t\"N\n\x0b\x42ridgeEvent\x12\r\n\x05\x65vent\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\t\x12\x0e\n\x06\x63md_id\x18\x03 \x01(\t\x12\x12\n\nsession_id\x18\x04 \x01(\t2C\n\nSemaBridge\x12\x35\n\x07\x43onnect\x12\x13.sema.BridgeCommand\x1a\x11.sema.BridgeEvent(\x01\x30\x01\x42\x42\n\x1a\x63om.sema.sdk.internal.grpcB\tSemaProtoP\x01\xaa\x02\x16Sema.Sdk.Internal.Grpcb\x06proto3')
28
+
29
+ _globals = globals()
30
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
31
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'sema_pb2', _globals)
32
+ if not _descriptor._USE_C_DESCRIPTORS:
33
+ _globals['DESCRIPTOR']._loaded_options = None
34
+ _globals['DESCRIPTOR']._serialized_options = b'\n\032com.sema.sdk.internal.grpcB\tSemaProtoP\001\252\002\026Sema.Sdk.Internal.Grpc'
35
+ _globals['_BRIDGECOMMAND']._serialized_start=20
36
+ _globals['_BRIDGECOMMAND']._serialized_end=100
37
+ _globals['_BRIDGEEVENT']._serialized_start=102
38
+ _globals['_BRIDGEEVENT']._serialized_end=180
39
+ _globals['_SEMABRIDGE']._serialized_start=182
40
+ _globals['_SEMABRIDGE']._serialized_end=249
41
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,98 @@
1
+ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
+ """Client and server classes corresponding to protobuf-defined services."""
3
+ import grpc
4
+ import warnings
5
+
6
+ from . import sema_pb2 as sema__pb2
7
+
8
+ GRPC_GENERATED_VERSION = '1.82.1'
9
+ GRPC_VERSION = grpc.__version__
10
+ _version_not_supported = False
11
+
12
+ try:
13
+ from grpc._utilities import first_version_is_lower
14
+ _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
15
+ except ImportError:
16
+ _version_not_supported = True
17
+
18
+ if _version_not_supported:
19
+ raise RuntimeError(
20
+ f'The grpc package installed is at version {GRPC_VERSION},'
21
+ + ' but the generated code in sema_pb2_grpc.py depends on'
22
+ + f' grpcio>={GRPC_GENERATED_VERSION}.'
23
+ + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
24
+ + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
25
+ )
26
+
27
+
28
+ class SemaBridgeStub:
29
+ """Missing associated documentation comment in .proto file."""
30
+
31
+ def __init__(self, channel):
32
+ """Constructor.
33
+
34
+ Args:
35
+ channel: A grpc.Channel.
36
+ """
37
+ self.Connect = channel.stream_stream(
38
+ '/sema.SemaBridge/Connect',
39
+ request_serializer=sema__pb2.BridgeCommand.SerializeToString,
40
+ response_deserializer=sema__pb2.BridgeEvent.FromString,
41
+ _registered_method=True)
42
+
43
+
44
+ class SemaBridgeServicer:
45
+ """Missing associated documentation comment in .proto file."""
46
+
47
+ def Connect(self, request_iterator, context):
48
+ """双向流:客户端发送指令,服务端推送事件
49
+ """
50
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
51
+ context.set_details('Method not implemented!')
52
+ raise NotImplementedError('Method not implemented!')
53
+
54
+
55
+ def add_SemaBridgeServicer_to_server(servicer, server):
56
+ rpc_method_handlers = {
57
+ 'Connect': grpc.stream_stream_rpc_method_handler(
58
+ servicer.Connect,
59
+ request_deserializer=sema__pb2.BridgeCommand.FromString,
60
+ response_serializer=sema__pb2.BridgeEvent.SerializeToString,
61
+ ),
62
+ }
63
+ generic_handler = grpc.method_handlers_generic_handler(
64
+ 'sema.SemaBridge', rpc_method_handlers)
65
+ server.add_generic_rpc_handlers((generic_handler,))
66
+ server.add_registered_method_handlers('sema.SemaBridge', rpc_method_handlers)
67
+
68
+
69
+ # This class is part of an EXPERIMENTAL API.
70
+ class SemaBridge:
71
+ """Missing associated documentation comment in .proto file."""
72
+
73
+ @staticmethod
74
+ def Connect(request_iterator,
75
+ target,
76
+ options=(),
77
+ channel_credentials=None,
78
+ call_credentials=None,
79
+ insecure=False,
80
+ compression=None,
81
+ wait_for_ready=None,
82
+ timeout=None,
83
+ metadata=None):
84
+ return grpc.experimental.stream_stream(
85
+ request_iterator,
86
+ target,
87
+ '/sema.SemaBridge/Connect',
88
+ sema__pb2.BridgeCommand.SerializeToString,
89
+ sema__pb2.BridgeEvent.FromString,
90
+ options,
91
+ channel_credentials,
92
+ insecure,
93
+ call_credentials,
94
+ compression,
95
+ wait_for_ready,
96
+ timeout,
97
+ metadata,
98
+ _registered_method=True)
@@ -0,0 +1,32 @@
1
+ syntax = "proto3";
2
+
3
+ package sema;
4
+
5
+ // ⚠️ 本文件是协议唯一源(sdks/proto/sema.proto):bridge 运行时加载、各语言 SDK 构建期生成,
6
+ // 不要在任何语言目录另行维护副本。
7
+ // 以下 option 只影响各语言代码生成,不影响 wire 格式(JS 的 proto-loader 会忽略)。
8
+ option java_multiple_files = true;
9
+ option java_package = "com.sema.sdk.internal.grpc";
10
+ option java_outer_classname = "SemaProto";
11
+ option csharp_namespace = "Sema.Sdk.Internal.Grpc";
12
+
13
+ service SemaBridge {
14
+ // 双向流:客户端发送指令,服务端推送事件
15
+ rpc Connect(stream BridgeCommand) returns (stream BridgeEvent);
16
+ }
17
+
18
+ // 宿主 → Node.js(指令帧)
19
+ message BridgeCommand {
20
+ string id = 1; // 请求 ID,用于匹配响应
21
+ string action = 2; // 操作名
22
+ string payload = 3; // JSON 序列化的 payload(可为空字符串)
23
+ string session_id = 4; // 目标会话 ID;会话级 action 必填,进程级 action 留空
24
+ }
25
+
26
+ // Node.js → 宿主(事件帧)
27
+ message BridgeEvent {
28
+ string event = 1; // 事件名
29
+ string data = 2; // JSON 序列化的 data(可为空字符串)
30
+ string cmd_id = 3; // 对应指令的 ID(仅响应类消息携带)
31
+ string session_id = 4; // 事件所属会话 ID;会话级事件携带,进程级事件留空
32
+ }