MOSS cryptographic signing integration for LangChain
Project description
moss-langchain
MOSS signing integration for LangChain. Unsigned output is broken output.
Installation
pip install moss-langchain
Quick Start: Explicit Signing (Recommended)
Sign specific outputs with full control:
from langchain_openai import ChatOpenAI
from moss_langchain import sign_tool_call, sign_chain_result, sign_message
# Sign a tool call
tool_call = {"name": "get_weather", "args": {"location": "NYC"}, "id": "call_123"}
result = sign_tool_call(tool_call, agent_id="weather-bot")
print(f"Signed: {result.signature[:20]}...")
# Sign a chain result
chain = ChatOpenAI() | StrOutputParser()
output = chain.invoke("What is 2+2?")
result = sign_chain_result(output, agent_id="math-bot", chain_name="calculator")
# Sign a message
message = AIMessage(content="The answer is 4")
result = sign_message(message, agent_id="math-bot")
Enterprise Mode
Set MOSS_API_KEY for automatic policy evaluation:
import os
os.environ["MOSS_API_KEY"] = "your-api-key"
from moss_langchain import sign_tool_call, enterprise_enabled
print(f"Enterprise: {enterprise_enabled()}") # True
# Tool calls are evaluated against policies
result = sign_tool_call(
{"name": "send_email", "args": {"to": "user@example.com"}, "id": "call_1"},
agent_id="email-bot",
context={"user_id": "u123"}
)
if result.blocked:
print(f"Blocked by policy: {result.policy.reason}")
Callback Handler for Auto-Signing
For automatic signing of all chain events:
from moss_langchain import MOSSCallbackHandler
# Create handler - signs tool calls and chain outputs
handler = MOSSCallbackHandler(
agent_id="my-agent",
sign_tools=True,
sign_chains=True
)
chain = ChatOpenAI() | StrOutputParser()
result = chain.invoke("Hello", config={"callbacks": [handler]})
# Access signed envelopes
for envelope in handler.envelopes:
print(f"Signed: {envelope.subject}")
Verification
from moss_langchain import verify_envelope
# Verify any signed envelope
verify_result = verify_envelope(result.envelope)
if verify_result.valid:
print(f"Signed by: {verify_result.subject}")
All Functions
| Function | Description |
|---|---|
sign_tool_call() |
Sign a LangChain tool call |
sign_chain_result() |
Sign chain output |
sign_message() |
Sign an AI message |
sign_tool_result() |
Sign tool execution result |
sign_output() |
Sign any output (generic) |
verify_envelope() |
Verify a signed envelope |
Legacy API
The old auto-signing API is still available for backwards compatibility:
from moss_langchain import enable_moss, SignedCallbackHandler
enable_moss("moss:myteam:agent") # Global auto-signing
cb = SignedCallbackHandler("moss:bot:summary") # Per-chain signing
Enterprise Features
| Feature | Free | Enterprise |
|---|---|---|
| Local signing | ✓ | ✓ |
| Offline verification | ✓ | ✓ |
| Policy evaluation | - | ✓ |
| Evidence retention | - | ✓ |
| Audit exports | - | ✓ |
Links
- moss-sdk - Core MOSS SDK
- mosscomputing.com - Project site
License
This package is licensed under the Business Source License 1.1.
- Free for evaluation, testing, and development
- Free for non-production use
- Production use requires a MOSS subscription
- Converts to Apache 2.0 on January 25, 2030
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 moss_langchain-1.0.0.tar.gz.
File metadata
- Download URL: moss_langchain-1.0.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efb1dc932965098664ae2988486f645f2b960d7ff06608a6b399864222fcc91b
|
|
| MD5 |
97250b7e87b5ebc5eee2b8f9398b24f6
|
|
| BLAKE2b-256 |
42eac671b1f51bf6fc1fc562e508e7314cbd7c79ff56ad063f6a48ee945de1bb
|
Provenance
The following attestation bundles were made for moss_langchain-1.0.0.tar.gz:
Publisher:
publish.yml on mosscomputing/moss-langchain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moss_langchain-1.0.0.tar.gz -
Subject digest:
efb1dc932965098664ae2988486f645f2b960d7ff06608a6b399864222fcc91b - Sigstore transparency entry: 854525201
- Sigstore integration time:
-
Permalink:
mosscomputing/moss-langchain@b622a2c929a5098640b80c471145d3683da859fb -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/mosscomputing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b622a2c929a5098640b80c471145d3683da859fb -
Trigger Event:
release
-
Statement type:
File details
Details for the file moss_langchain-1.0.0-py3-none-any.whl.
File metadata
- Download URL: moss_langchain-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.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 |
af17737a2a81580d034cd06085bdd877c3972605371542e1472284d5f657e1b8
|
|
| MD5 |
1896f493a91f9779d429a6e297631ea6
|
|
| BLAKE2b-256 |
52f7b0ca88be6592613ce6bdbd888da108520c4b256477c03e3aff0bbba2a978
|
Provenance
The following attestation bundles were made for moss_langchain-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on mosscomputing/moss-langchain
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
moss_langchain-1.0.0-py3-none-any.whl -
Subject digest:
af17737a2a81580d034cd06085bdd877c3972605371542e1472284d5f657e1b8 - Sigstore transparency entry: 854525203
- Sigstore integration time:
-
Permalink:
mosscomputing/moss-langchain@b622a2c929a5098640b80c471145d3683da859fb -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/mosscomputing
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b622a2c929a5098640b80c471145d3683da859fb -
Trigger Event:
release
-
Statement type: