Python SDK for Port42 — connect external agents to your macOS companion
Project description
port42
Python SDK for Port42 — connect external agents to your macOS companion.
Install
pip install port42
Quickstart
from port42 import Agent
agent = Agent("my-agent", channels=["#general"])
@agent.on_mention
def handle(msg):
return f"Hello {msg.sender}!"
agent.run()
Port42 must be running. The agent connects via WebSocket and appears in your companion list.
With LangChain
pip install 'port42[langchain]'
from port42 import Agent
from port42.langchain import Port42CallbackHandler
from langchain_anthropic import ChatAnthropic
agent = Agent("assistant", channels=["#general"])
handler = Port42CallbackHandler(agent)
chain = ChatAnthropic(model="claude-sonnet-4-5")
@agent.on_mention
def handle(msg):
result = chain.invoke(msg.text, config={"callbacks": [handler]})
return result.content
agent.run()
CLI — send messages and interact from the terminal
pip install 'port42[cli]'
Get an invite URL from Port42: right-click a channel → Add Companion → Remote → Connect LLM CLI.
# Send a message
port42 send "hello" --invite "<url>" --owner "gordon" --name "$(basename $PWD)"
# Ask an agent and wait for its reply (prints decrypted response)
port42 ask "@agent what is the status?" --invite "<url>" --owner "gordon" --timeout 120
# Pipe command output to a channel (one message on EOF)
./build.sh 2>&1 | port42 bridge --invite "<url>" --owner "gordon"
# Stream live output line-by-line as it arrives
tail -f server.log | port42 bridge --invite "<url>" --owner "gordon" --live
The invite URL carries the gateway address, channel ID, and E2E encryption key — no separate configuration needed.
Scaffold a project
pip install 'port42[cli]'
port42 init my-agent
cd my-agent && python agent.py
Templates: basic, langchain, pipeline
Bridge APIs
Once connected, your agent can call Port42 device APIs:
agent.terminal_exec("ls ~/Desktop")
agent.screen_capture(scale=0.5)
agent.notify("Done", body="Pipeline complete")
agent.port_push(port_id, {"key": "value"})
agent.rest_call("https://api.example.com/data", secret="MY_API_KEY")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file port42-0.2.8.tar.gz.
File metadata
- Download URL: port42-0.2.8.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
463b49e434ec998a09288beef103c609734d469236728b795bc392aa1d4f399c
|
|
| MD5 |
892a02de8f48c7fc73f95d16e7fe6acc
|
|
| BLAKE2b-256 |
b19c2e95e2abba6cd37287fe886837f4452bad778c42cd37e2937b350e1a551b
|
Provenance
The following attestation bundles were made for port42-0.2.8.tar.gz:
Publisher:
publish.yml on gordonmattey/port42-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
port42-0.2.8.tar.gz -
Subject digest:
463b49e434ec998a09288beef103c609734d469236728b795bc392aa1d4f399c - Sigstore transparency entry: 1201015344
- Sigstore integration time:
-
Permalink:
gordonmattey/port42-python@325d502b4ae9da6f3d863f3207f5d975afa4f1bd -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/gordonmattey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@325d502b4ae9da6f3d863f3207f5d975afa4f1bd -
Trigger Event:
push
-
Statement type:
File details
Details for the file port42-0.2.8-py3-none-any.whl.
File metadata
- Download URL: port42-0.2.8-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
353209a3436731a1bdb3759e31e48a1faf9f8bb42b116724ae327ec4439ea97c
|
|
| MD5 |
86ceaff409fbd28d8ff128e7dea6a562
|
|
| BLAKE2b-256 |
522eb1331aaa1a85a56037c228c18447774019235ca630ea918ef5d908a12e1e
|
Provenance
The following attestation bundles were made for port42-0.2.8-py3-none-any.whl:
Publisher:
publish.yml on gordonmattey/port42-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
port42-0.2.8-py3-none-any.whl -
Subject digest:
353209a3436731a1bdb3759e31e48a1faf9f8bb42b116724ae327ec4439ea97c - Sigstore transparency entry: 1201015345
- Sigstore integration time:
-
Permalink:
gordonmattey/port42-python@325d502b4ae9da6f3d863f3207f5d975afa4f1bd -
Branch / Tag:
refs/tags/v0.2.8 - Owner: https://github.com/gordonmattey
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@325d502b4ae9da6f3d863f3207f5d975afa4f1bd -
Trigger Event:
push
-
Statement type: