capsule-emit 0.1.0__py3-none-any.whl

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,43 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """capsule-emit — one-call emit() for Agent Action Capsules.
3
+
4
+ The adoption surface for the Agent Action Capsule standard:
5
+
6
+ from capsule_emit import emit
7
+
8
+ cap = emit(
9
+ action="write_po",
10
+ operator="acme-co",
11
+ developer="po-agent@v1",
12
+ agent_input={"vendor": "Frobozz Supply", "total": 1240.19},
13
+ agent_output=result,
14
+ model={"provider": "anthropic", "model_id": "claude-sonnet-4-6"},
15
+ verdict="executed",
16
+ effect={"type": "write_po", "status": "dispatched"},
17
+ )
18
+ print(cap.capsule_id, cap.anchored)
19
+
20
+ Anchor is on by default (async, digest-only). Ledger is written to
21
+ ``ledger.jsonl`` by default. Both are configurable.
22
+ """
23
+ from .core import EmitResult, emit
24
+ from .ledger import append_to_ledger, read_ledger
25
+ from .ledger import view as ledger_view
26
+ from .manifest import ManifestDeclaration, find_manifest, load_manifest
27
+
28
+ __version__ = "0.1.0"
29
+
30
+ __all__ = [
31
+ "__version__",
32
+ # Core
33
+ "emit",
34
+ "EmitResult",
35
+ # Ledger
36
+ "append_to_ledger",
37
+ "read_ledger",
38
+ "ledger_view",
39
+ # Manifest
40
+ "load_manifest",
41
+ "find_manifest",
42
+ "ManifestDeclaration",
43
+ ]
@@ -0,0 +1,6 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """capsule-emit framework adapters.
3
+
4
+ MCP-first: ``capsule_emit.adapters.mcp.MCPCapsuleEmitter``
5
+ Thin shells: ``langchain``, ``crewai``, ``hermes`` (all over _base.CapsuleEmitterBase).
6
+ """
@@ -0,0 +1,84 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Shared base for all capsule-emit framework adapters.
3
+
4
+ All framework adapters (LangChain, CrewAI, Hermes, MCP) extend this base.
5
+ It holds operator/developer/ledger config and exposes a single
6
+ ``emit_capsule()`` helper that calls the top-level ``capsule_emit.emit()``.
7
+ """
8
+ from __future__ import annotations
9
+
10
+ import os
11
+ from typing import Any
12
+
13
+ from capsule_emit.core import EmitResult, emit
14
+
15
+ __all__ = ["CapsuleEmitterBase"]
16
+
17
+
18
+ class CapsuleEmitterBase:
19
+ """Shared config carrier for capsule-emit framework adapters.
20
+
21
+ Args:
22
+ operator: Tenant/org identifier stamped on every capsule.
23
+ developer: Agent name + version.
24
+ ledger: Path to the JSONL ledger file (default: ``ledger.jsonl``).
25
+ anchor: Fire-and-forget anchor on every emit (default: True).
26
+ anchor_url: Override anchor endpoint (else ``AAC_ANCHOR_URL`` env var).
27
+ """
28
+
29
+ def __init__(
30
+ self,
31
+ *,
32
+ operator: str,
33
+ developer: str,
34
+ ledger: str | os.PathLike = "ledger.jsonl",
35
+ anchor: bool = True,
36
+ anchor_url: str | None = None,
37
+ ) -> None:
38
+ self._operator = operator
39
+ self._developer = developer
40
+ self._ledger = ledger
41
+ self._anchor = anchor
42
+ self._anchor_url = anchor_url
43
+ self._last: EmitResult | None = None
44
+ self._results: list[EmitResult] = []
45
+
46
+ @property
47
+ def last(self) -> EmitResult | None:
48
+ """The most recent EmitResult, or None."""
49
+ return self._last
50
+
51
+ @property
52
+ def results(self) -> list[EmitResult]:
53
+ """All EmitResults emitted this session."""
54
+ return list(self._results)
55
+
56
+ def emit_capsule(
57
+ self,
58
+ action: str,
59
+ tool_input: Any = None,
60
+ tool_output: Any = None,
61
+ *,
62
+ verdict: str = "executed",
63
+ effect: dict[str, Any] | None = None,
64
+ prior_capsule_id: str | None = None,
65
+ model: dict[str, str] | None = None,
66
+ ) -> EmitResult:
67
+ """Emit one capsule for a completed tool call."""
68
+ result = emit(
69
+ action=action,
70
+ operator=self._operator,
71
+ developer=self._developer,
72
+ agent_input=tool_input,
73
+ agent_output=tool_output,
74
+ verdict=verdict,
75
+ effect=effect,
76
+ confirms=prior_capsule_id,
77
+ anchor=self._anchor,
78
+ ledger=self._ledger,
79
+ anchor_url=self._anchor_url,
80
+ model=model,
81
+ )
82
+ self._last = result
83
+ self._results.append(result)
84
+ return result
@@ -0,0 +1,50 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Thin CrewAI shell over CapsuleEmitterBase (~15 lines of adapter logic).
3
+
4
+ from capsule_emit.adapters.crewai import CrewAICapsuleEmitter
5
+
6
+ emitter = CrewAICapsuleEmitter(operator="acme-co", developer="my-agent@v1")
7
+ wrapped_tool = emitter.wrap(my_crewai_tool)
8
+
9
+ Works without installing crewai — ``wrap()`` is framework-free.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ import functools
14
+ from typing import Any
15
+
16
+ from ._base import CapsuleEmitterBase
17
+
18
+ __all__ = ["CrewAICapsuleEmitter"]
19
+
20
+
21
+ class CrewAICapsuleEmitter(CapsuleEmitterBase):
22
+ """CrewAI adapter — wrap a tool callable; emit a capsule per call."""
23
+
24
+ def wrap(self, tool: Any, action: str | None = None) -> Any:
25
+ """Wrap a CrewAI tool or any callable; emit a capsule on each call."""
26
+ _action = action or getattr(tool, "name", None) or getattr(tool, "__name__", "tool")
27
+
28
+ if callable(tool):
29
+ @functools.wraps(tool)
30
+ def _wrapper(*args: Any, **kwargs: Any) -> Any:
31
+ output = tool(*args, **kwargs)
32
+ inp = kwargs if kwargs else (args[0] if len(args) == 1 else args)
33
+ self.emit_capsule(_action, tool_input=inp, tool_output=output)
34
+ return output
35
+ return _wrapper
36
+
37
+ # CrewAI BaseTool subclass: patch ._run
38
+ original_run = getattr(tool, "_run", None)
39
+ if original_run is None:
40
+ return tool
41
+
42
+ @functools.wraps(original_run)
43
+ def _patched_run(*args: Any, **kwargs: Any) -> Any:
44
+ output = original_run(*args, **kwargs)
45
+ inp = kwargs if kwargs else (args[0] if len(args) == 1 else args)
46
+ self.emit_capsule(_action, tool_input=inp, tool_output=output)
47
+ return output
48
+
49
+ tool._run = _patched_run
50
+ return tool
@@ -0,0 +1,42 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Thin Hermes shell over CapsuleEmitterBase (~15 lines of adapter logic).
3
+
4
+ from capsule_emit.adapters.hermes import HermesCapsuleEmitter
5
+
6
+ emitter = HermesCapsuleEmitter(operator="acme-co", developer="my-agent@v1")
7
+
8
+ # Call around a Hermes tool execution:
9
+ result = execute_tool(tool_name, inputs)
10
+ cap = emitter.after_tool(tool_name, inputs, result)
11
+ """
12
+ from __future__ import annotations
13
+
14
+ from typing import Any
15
+
16
+ from capsule_emit.core import EmitResult
17
+
18
+ from ._base import CapsuleEmitterBase
19
+
20
+ __all__ = ["HermesCapsuleEmitter"]
21
+
22
+
23
+ class HermesCapsuleEmitter(CapsuleEmitterBase):
24
+ """Hermes adapter — emit capsules around Hermes tool calls."""
25
+
26
+ def after_tool(
27
+ self,
28
+ tool_name: str,
29
+ tool_input: Any = None,
30
+ tool_output: Any = None,
31
+ *,
32
+ verdict: str = "executed",
33
+ effect_status: str = "dispatched",
34
+ ) -> EmitResult:
35
+ """Call after a Hermes tool execution to emit a capsule."""
36
+ return self.emit_capsule(
37
+ tool_name,
38
+ tool_input=tool_input,
39
+ tool_output=tool_output,
40
+ verdict=verdict,
41
+ effect={"type": tool_name, "status": effect_status},
42
+ )
@@ -0,0 +1,45 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Thin LangChain shell over CapsuleEmitterBase (~15 lines of adapter logic).
3
+
4
+ from capsule_emit.adapters.langchain import LangChainCapsuleEmitter
5
+
6
+ emitter = LangChainCapsuleEmitter(operator="acme-co", developer="my-agent@v1")
7
+ agent.invoke(..., config={"callbacks": [emitter]})
8
+
9
+ Requires ``pip install langchain-core``.
10
+ """
11
+ from __future__ import annotations
12
+
13
+ from typing import Any
14
+
15
+ from ._base import CapsuleEmitterBase
16
+
17
+ __all__ = ["LangChainCapsuleEmitter"]
18
+
19
+ try:
20
+ from langchain_core.callbacks import BaseCallbackHandler as _Base
21
+ except ImportError as exc:
22
+ raise ImportError(
23
+ "LangChainCapsuleEmitter needs langchain-core. "
24
+ "Install with: pip install langchain-core"
25
+ ) from exc
26
+
27
+
28
+ class LangChainCapsuleEmitter(CapsuleEmitterBase, _Base):
29
+ """LangChain callback handler — emits one capsule per completed tool call."""
30
+
31
+ def __init__(self, **kwargs: Any) -> None:
32
+ CapsuleEmitterBase.__init__(self, **kwargs)
33
+ _Base.__init__(self)
34
+ self._pending: dict[Any, tuple[str, Any]] = {}
35
+
36
+ def on_tool_start(self, serialized: dict | None, input_str: str, *, run_id: Any = None, inputs: dict | None = None, **kw: Any) -> None:
37
+ name = (serialized or {}).get("name") or kw.get("name") or "tool"
38
+ self._pending[run_id] = (name, inputs if inputs is not None else input_str)
39
+
40
+ def on_tool_end(self, output: Any, *, run_id: Any = None, **kw: Any) -> None:
41
+ name, inp = self._pending.pop(run_id, ("tool", None))
42
+ self.emit_capsule(name, tool_input=inp, tool_output=output)
43
+
44
+ def on_tool_error(self, error: BaseException, *, run_id: Any = None, **kw: Any) -> None:
45
+ self._pending.pop(run_id, None)
@@ -0,0 +1,70 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """MCP-first capsule adapter (capsule-emit primary adapter).
3
+
4
+ Wraps an MCP tool function so every call emits a sealed, anchored capsule.
5
+ No MCP SDK dependency required — the wrapper works with any callable.
6
+
7
+ from capsule_emit.adapters.mcp import MCPCapsuleEmitter
8
+
9
+ emitter = MCPCapsuleEmitter(operator="acme-co", developer="my-agent@v1")
10
+
11
+ # Decorate a tool function — capsule emitted on every call.
12
+ @emitter.tool("write_po")
13
+ def write_po(vendor: str, total: float) -> dict:
14
+ ...
15
+
16
+ # Or wrap ad-hoc after a call:
17
+ result = write_po(vendor="Frobozz", total=1240.19)
18
+ cap = emitter.emit_capsule("write_po", tool_input={...}, tool_output=result)
19
+ """
20
+ from __future__ import annotations
21
+
22
+ import functools
23
+ from typing import Any, Callable
24
+
25
+ from ._base import CapsuleEmitterBase
26
+
27
+ __all__ = ["MCPCapsuleEmitter"]
28
+
29
+
30
+ class MCPCapsuleEmitter(CapsuleEmitterBase):
31
+ """MCP-first adapter: wrap tool callables; emit a capsule per call.
32
+
33
+ Designed for MCP tool endpoints but works with any Python callable.
34
+ """
35
+
36
+ def tool(
37
+ self,
38
+ action: str | None = None,
39
+ *,
40
+ effect_type: str | None = None,
41
+ verdict: str = "executed",
42
+ ) -> Callable:
43
+ """Decorator: wraps a tool function and emits a capsule on each call.
44
+
45
+ Args:
46
+ action: Action name for the capsule (defaults to the function name).
47
+ effect_type: Effect type string (defaults to *action*).
48
+ verdict: Disposition verdict_class (default ``"executed"``).
49
+ """
50
+
51
+ def decorator(fn: Callable) -> Callable:
52
+ _action = action or fn.__name__
53
+ _effect_type = effect_type or _action
54
+
55
+ @functools.wraps(fn)
56
+ def wrapper(*args: Any, **kwargs: Any) -> Any:
57
+ output = fn(*args, **kwargs)
58
+ tool_input = kwargs if kwargs else (args[0] if len(args) == 1 else args)
59
+ self.emit_capsule(
60
+ _action,
61
+ tool_input=tool_input,
62
+ tool_output=output,
63
+ verdict=verdict,
64
+ effect={"type": _effect_type, "status": "dispatched"},
65
+ )
66
+ return output
67
+
68
+ return wrapper
69
+
70
+ return decorator
capsule_emit/cli.py ADDED
@@ -0,0 +1,57 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """capsule-emit CLI.
3
+
4
+ capsule-emit ledger view <path> — print the chain table
5
+ capsule-emit ledger view <path> --json — raw JSON array
6
+
7
+ Exit codes: 0 = ok, 1 = error.
8
+ """
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import json
13
+
14
+
15
+ def _cmd_ledger_view(args: argparse.Namespace) -> int:
16
+ from .ledger import read_ledger
17
+ from .ledger import view as _view
18
+
19
+ if args.as_json:
20
+ records = read_ledger(args.path)
21
+ print(json.dumps(records, indent=2, default=str))
22
+ else:
23
+ _view(args.path)
24
+ return 0
25
+
26
+
27
+ def _build_parser() -> argparse.ArgumentParser:
28
+ parser = argparse.ArgumentParser(
29
+ prog="capsule-emit",
30
+ description="capsule-emit — emit + ledger CLI for Agent Action Capsules.",
31
+ )
32
+ sub = parser.add_subparsers(dest="command", required=True)
33
+
34
+ ledger = sub.add_parser("ledger", help="ledger operations")
35
+ ledger_sub = ledger.add_subparsers(dest="ledger_cmd", required=True)
36
+
37
+ view = ledger_sub.add_parser("view", help="display the ledger as a chain table")
38
+ view.add_argument("path", help="path to a JSONL ledger file")
39
+ view.add_argument("--json", dest="as_json", action="store_true", help="raw JSON output")
40
+
41
+ return parser
42
+
43
+
44
+ def main(argv: list[str] | None = None) -> int:
45
+ parser = _build_parser()
46
+ args = parser.parse_args(argv)
47
+
48
+ if args.command == "ledger":
49
+ if args.ledger_cmd == "view":
50
+ return _cmd_ledger_view(args)
51
+
52
+ parser.error(f"unknown command {args.command!r}")
53
+ return 1
54
+
55
+
56
+ if __name__ == "__main__":
57
+ raise SystemExit(main())
capsule_emit/core.py ADDED
@@ -0,0 +1,168 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """capsule-emit core — the one-call emit() with anchor-on-by-default.
3
+
4
+ This is the adoption-surface API described in capsule-emit-quickstart.md.
5
+ It wraps ``agent_action_capsule.emit()`` with:
6
+ - A friendlier signature (action, operator, developer, agent_input, agent_output, model, verdict, effect)
7
+ - Digest-only commitment of agent_input / agent_output (content stays local)
8
+ - Async anchor on by default (digest-only; no business content crosses the wire)
9
+ - Automatic JSONL ledger append
10
+ - A typed EmitResult with .capsule_id and .anchored
11
+
12
+ The ``confirms`` parameter threads a "did → confirmed" chain without a scheduler.
13
+
14
+ The same emit() calls and ledger files are compatible with gateway layers that
15
+ enforce declared manifests — no code changes required to add enforcement on top.
16
+ """
17
+ from __future__ import annotations
18
+
19
+ import hashlib
20
+ import json
21
+ import os
22
+ from dataclasses import dataclass
23
+ from typing import Any
24
+
25
+ from agent_action_capsule import emit as _base_emit
26
+ from agent_action_capsule.anchor import anchor as _simple_anchor
27
+ from agent_action_capsule.contracts import Disposition, EffectRecord
28
+
29
+ from .ledger import append_to_ledger
30
+
31
+ __all__ = ["emit", "EmitResult"]
32
+
33
+ _DEFAULT_LEDGER = "ledger.jsonl"
34
+
35
+
36
+ def _digest(value: Any) -> str:
37
+ """SHA-256 of the canonical JSON serialization of value."""
38
+ raw = json.dumps(value, sort_keys=True, separators=(",", ":"), default=str)
39
+ return hashlib.sha256(raw.encode("utf-8")).hexdigest()
40
+
41
+
42
+ @dataclass
43
+ class EmitResult:
44
+ """The result of a capsule-emit emit() call."""
45
+
46
+ capsule_id: str
47
+ anchored: bool
48
+ capsule: dict
49
+
50
+ def __repr__(self) -> str:
51
+ return f"EmitResult(capsule_id={self.capsule_id!r}, anchored={self.anchored})"
52
+
53
+
54
+ def emit(
55
+ action: str,
56
+ operator: str = "",
57
+ developer: str = "",
58
+ *,
59
+ runtime: str | None = None,
60
+ agent_input: Any = None,
61
+ agent_output: Any = None,
62
+ model: dict[str, str] | None = None,
63
+ verdict: str = "executed",
64
+ effect: dict[str, Any] | None = None,
65
+ confirms: str | None = None,
66
+ anchor: bool = True,
67
+ ledger: str | os.PathLike = _DEFAULT_LEDGER,
68
+ anchor_url: str | None = None,
69
+ ) -> EmitResult:
70
+ """Emit a sealed, optionally anchored Agent Action Capsule.
71
+
72
+ Args:
73
+ action: A short, stable action name (e.g. ``"write_po"``).
74
+ operator: Tenant / org identifier.
75
+ developer: Agent name + version (e.g. ``"po-agent@v1"``).
76
+ runtime: Framework hint (e.g. ``"langchain"``); stored in compute_attestation.
77
+ agent_input: The agent's input (any JSON-serializable value). Digest-committed;
78
+ the raw value never leaves the process.
79
+ agent_output: The agent's output. Digest-committed.
80
+ model: Dict with ``"provider"`` and ``"model_id"`` keys.
81
+ verdict: Disposition verdict_class (e.g. ``"executed"``, ``"confirmed"``).
82
+ effect: Effect dict with ``"type"`` and ``"status"`` (and optional ``"autonomy"``).
83
+ confirms: capsule_id of the prior capsule this one confirms (chains with relation
84
+ ``"confirms"``).
85
+ anchor: When True (default), fire-and-forget async digest-only anchor submission.
86
+ ledger: Path to the JSONL ledger file (default: ``ledger.jsonl``).
87
+ anchor_url: Override the anchor endpoint (else reads ``AAC_ANCHOR_URL`` env var).
88
+
89
+ Returns:
90
+ :class:`EmitResult` with ``.capsule_id`` and ``.anchored``.
91
+ """
92
+ compute_att: dict[str, Any] = {}
93
+ if agent_input is not None:
94
+ compute_att["agent_input_digest"] = _digest(agent_input)
95
+ if agent_output is not None:
96
+ compute_att["agent_output_digest"] = _digest(agent_output)
97
+ if runtime is not None:
98
+ compute_att["runtime"] = runtime
99
+
100
+ model_id: str | None = None
101
+ provider: str | None = None
102
+ if model:
103
+ model_id = model.get("model_id")
104
+ provider = model.get("provider")
105
+ extra_chip = {k: v for k, v in model.items() if k not in ("model_id", "provider")}
106
+ if extra_chip:
107
+ compute_att.update(extra_chip)
108
+
109
+ effect_record: EffectRecord | None = None
110
+ if effect is not None:
111
+ eff_status = effect.get("status", "dispatched")
112
+ response_digest: str | None = None
113
+ if eff_status == "confirmed":
114
+ # §5.2 confirmed-effect invariant: must supply response_digest.
115
+ # Auto-derive from agent_output when available; else from the
116
+ # confirms capsule_id (the "observed response" in a confirm chain).
117
+ if agent_output is not None:
118
+ response_digest = _digest(agent_output)
119
+ elif confirms is not None:
120
+ response_digest = _digest({"confirmed_capsule_id": confirms})
121
+ effect_record = EffectRecord(
122
+ type=effect.get("type", action),
123
+ status=eff_status,
124
+ response_digest=response_digest,
125
+ )
126
+
127
+ disposition = Disposition(
128
+ decision="accept",
129
+ approver="policy",
130
+ human_disposed=False,
131
+ verdict_class=verdict,
132
+ )
133
+
134
+ chain_relation: str | None = None
135
+ if confirms is not None:
136
+ chain_relation = "confirms"
137
+
138
+ capsule = _base_emit(
139
+ action_id=None,
140
+ action_type="decide" if verdict in ("executed", "confirmed", "denied", "blocked") else "fyi",
141
+ operator=operator,
142
+ developer=developer,
143
+ model_id=model_id,
144
+ provider=provider,
145
+ compute_attestation=compute_att if compute_att else None,
146
+ effect=effect_record,
147
+ prior_capsule_id=confirms,
148
+ chain_relation=chain_relation,
149
+ disposition=disposition,
150
+ tool_name=action,
151
+ )
152
+
153
+ append_to_ledger(capsule, ledger)
154
+
155
+ anchored = False
156
+ if anchor:
157
+ endpoint = anchor_url or os.environ.get("AAC_ANCHOR_URL", None)
158
+ _simple_anchor(
159
+ capsule["capsule_id"],
160
+ **({"endpoint": endpoint} if endpoint else {}),
161
+ )
162
+ anchored = True
163
+
164
+ return EmitResult(
165
+ capsule_id=capsule["capsule_id"],
166
+ anchored=anchored,
167
+ capsule=capsule,
168
+ )
capsule_emit/ledger.py ADDED
@@ -0,0 +1,105 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Ledger read/write utilities and the ledger view renderer.
3
+
4
+ The ledger is a newline-delimited JSON (JSONL) file — one capsule dict per line.
5
+ ``view()`` renders it as a human-readable chain table.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import json
10
+ import os
11
+ from pathlib import Path
12
+ from typing import Any
13
+
14
+ __all__ = ["append_to_ledger", "read_ledger", "view"]
15
+
16
+
17
+ def append_to_ledger(capsule: dict, path: str | os.PathLike = "ledger.jsonl") -> None:
18
+ """Append a sealed capsule dict as a single JSON line."""
19
+ with open(path, "a", encoding="utf-8") as fh:
20
+ fh.write(json.dumps(capsule, separators=(",", ":")) + "\n")
21
+
22
+
23
+ def read_ledger(path: str | os.PathLike) -> list[dict]:
24
+ """Read all capsule records from a JSONL ledger file."""
25
+ p = Path(path)
26
+ if not p.exists():
27
+ return []
28
+ records = []
29
+ with open(p, encoding="utf-8") as fh:
30
+ for line in fh:
31
+ line = line.strip()
32
+ if line:
33
+ records.append(json.loads(line))
34
+ return records
35
+
36
+
37
+ def view(path: str | os.PathLike, *, out: Any = None) -> None:
38
+ """Print a human-readable chain table for the ledger at *path*.
39
+
40
+ Args:
41
+ path: Path to the JSONL ledger file.
42
+ out: File-like object for output (defaults to stdout).
43
+ """
44
+ import sys
45
+
46
+ if out is None:
47
+ out = sys.stdout
48
+
49
+ records = read_ledger(path)
50
+ if not records:
51
+ print(f"ledger: {path} — empty or not found", file=out)
52
+ return
53
+
54
+ col_id = 14
55
+ col_action = 22
56
+ col_op = 14
57
+ col_effect = 22
58
+ col_verdict = 12
59
+
60
+ header = (
61
+ f"{'capsule_id':<{col_id}} "
62
+ f"{'action':<{col_action}} "
63
+ f"{'operator':<{col_op}} "
64
+ f"{'effect/status':<{col_effect}} "
65
+ f"{'verdict':<{col_verdict}} "
66
+ f"{'chain'}"
67
+ )
68
+ print(f"\ncapsule-emit ledger: {path} ({len(records)} record(s))\n", file=out)
69
+ print(header, file=out)
70
+ print("-" * len(header), file=out)
71
+
72
+ for cap in records:
73
+ cid = cap.get("capsule_id", "?")[:col_id]
74
+ action_id = cap.get("action_id", "?")
75
+ # action_id is "tool-name/<uuid>" — show just the tool part
76
+ action = action_id.split("/")[0] if "/" in action_id else action_id
77
+ action = action[:col_action]
78
+ operator = cap.get("operator", "")[:col_op]
79
+
80
+ eff = cap.get("effect", {}) or {}
81
+ eff_str = ""
82
+ if eff:
83
+ eff_str = f"{eff.get('type', '')}:{eff.get('status', '')}"
84
+ eff_str = eff_str[:col_effect]
85
+
86
+ disp = cap.get("disposition", {}) or {}
87
+ verdict = disp.get("verdict_class", "")[:col_verdict]
88
+
89
+ chain = cap.get("chain", {}) or {}
90
+ chain_str = ""
91
+ if chain:
92
+ parent = chain.get("parent_capsule_id", "")
93
+ rel = chain.get("relation", "")
94
+ chain_str = f"{rel}→{parent[:8]}…" if parent else ""
95
+
96
+ print(
97
+ f"{cid:<{col_id}} "
98
+ f"{action:<{col_action}} "
99
+ f"{operator:<{col_op}} "
100
+ f"{eff_str:<{col_effect}} "
101
+ f"{verdict:<{col_verdict}} "
102
+ f"{chain_str}",
103
+ file=out,
104
+ )
105
+ print(file=out)
@@ -0,0 +1,167 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ """Manifest parser — declare-only, engine-free.
3
+
4
+ Reads a ``flows/<wicket>/manifest.md`` file and returns a :class:`ManifestDeclaration`
5
+ with the declared wicket_id, autonomy (default ``"narrate"``), effect type, and
6
+ constraint names.
7
+
8
+ ``capsule-emit`` reads manifests to *declare* — no enforcement, no engine, no gate.
9
+ A compatible gateway layer reads the same manifest file and *enforces* the declared
10
+ constraints. This is the same-file upgrade path: no changes to manifests or emit()
11
+ calls are required to add an enforcement layer on top.
12
+
13
+ Safe-autonomy default: if ``autonomy`` is not declared, it defaults to ``"narrate"``
14
+ (the safest; the agent describes what it would do but does not execute).
15
+ """
16
+ from __future__ import annotations
17
+
18
+ import re
19
+ from dataclasses import dataclass, field
20
+ from pathlib import Path
21
+ from typing import Any
22
+
23
+ __all__ = ["ManifestDeclaration", "load_manifest", "find_manifest"]
24
+
25
+ _AUTONOMY_RE = re.compile(
26
+ r"autonomy\s+[`'\"]?(\w+)[`'\"]?",
27
+ re.IGNORECASE,
28
+ )
29
+ _EFFECT_RE = re.compile(
30
+ r"^`(\w+)`\s*—\s*autonomy\s+[`'\"]?(\w+)[`'\"]?",
31
+ re.IGNORECASE | re.MULTILINE,
32
+ )
33
+ _CONSTRAINT_ID_RE = re.compile(r"`([\w_]+)`")
34
+
35
+
36
+ @dataclass
37
+ class ManifestDeclaration:
38
+ """The declared metadata from a manifest.md file (no enforcement)."""
39
+
40
+ wicket_id: str
41
+ title: str = ""
42
+ autonomy: str = "narrate"
43
+ effect_type: str = ""
44
+ constraint_names: list[str] = field(default_factory=list)
45
+ raw_frontmatter: dict[str, Any] = field(default_factory=dict)
46
+
47
+
48
+ def _parse_yaml_frontmatter(text: str) -> tuple[dict[str, Any], str]:
49
+ """Extract simple YAML front matter (--- ... ---). No PyYAML dependency."""
50
+ if not text.startswith("---"):
51
+ return {}, text
52
+ end = text.find("\n---", 3)
53
+ if end == -1:
54
+ return {}, text
55
+ fm_block = text[3:end].strip()
56
+ body = text[end + 4:].lstrip("\n")
57
+ fm: dict[str, Any] = {}
58
+ for line in fm_block.splitlines():
59
+ if ":" in line:
60
+ key, _, val = line.partition(":")
61
+ key = key.strip()
62
+ val = val.strip()
63
+ # Strip inline comments
64
+ if "#" in val:
65
+ val = val[: val.index("#")].strip()
66
+ # Unquote
67
+ if (val.startswith('"') and val.endswith('"')) or (
68
+ val.startswith("'") and val.endswith("'")
69
+ ):
70
+ val = val[1:-1]
71
+ # Coerce obvious types
72
+ if val.lower() == "true":
73
+ fm[key] = True
74
+ elif val.lower() == "false":
75
+ fm[key] = False
76
+ elif val.isdigit():
77
+ fm[key] = int(val)
78
+ else:
79
+ fm[key] = val
80
+ return fm, body
81
+
82
+
83
+ def _extract_effect(body: str) -> tuple[str, str]:
84
+ """Return (effect_type, autonomy) from the ## Effect section."""
85
+ effect_section = re.search(r"##\s+Effect\s*\n(.*?)(?:\n##|\Z)", body, re.DOTALL)
86
+ if not effect_section:
87
+ return "", "narrate"
88
+ section_text = effect_section.group(1)
89
+ m = _EFFECT_RE.search(section_text)
90
+ if m:
91
+ return m.group(1), m.group(2).lower()
92
+ # Fallback: look for backtick-quoted identifier on the first non-empty line
93
+ for line in section_text.splitlines():
94
+ line = line.strip()
95
+ if not line:
96
+ continue
97
+ ids = _CONSTRAINT_ID_RE.findall(line)
98
+ if ids:
99
+ autonomy_m = _AUTONOMY_RE.search(line)
100
+ return ids[0], autonomy_m.group(1).lower() if autonomy_m else "narrate"
101
+ break
102
+ return "", "narrate"
103
+
104
+
105
+ def _extract_constraints(body: str) -> list[str]:
106
+ """Extract constraint id strings from the ## Constraints table."""
107
+ constraints_section = re.search(
108
+ r"##\s+Constraints.*?\n(.*?)(?:\n##|\Z)", body, re.DOTALL | re.IGNORECASE
109
+ )
110
+ if not constraints_section:
111
+ return []
112
+ names: list[str] = []
113
+ for line in constraints_section.group(1).splitlines():
114
+ if "|" not in line:
115
+ continue
116
+ # Table rows: | `id` | description | ... |
117
+ cells = [c.strip() for c in line.split("|") if c.strip()]
118
+ if not cells:
119
+ continue
120
+ ids = _CONSTRAINT_ID_RE.findall(cells[0])
121
+ if ids and not ids[0].startswith("-"):
122
+ names.append(ids[0])
123
+ return names
124
+
125
+
126
+ def load_manifest(path: str | Path) -> ManifestDeclaration:
127
+ """Parse a manifest.md file and return a :class:`ManifestDeclaration`.
128
+
129
+ Never raises on missing or malformed files — returns a safe default with
130
+ ``autonomy="narrate"``.
131
+ """
132
+ p = Path(path)
133
+ if not p.exists():
134
+ wicket_id = p.parent.name if p.parent.name != "." else "unknown"
135
+ return ManifestDeclaration(wicket_id=wicket_id)
136
+
137
+ text = p.read_text(encoding="utf-8")
138
+ fm, body = _parse_yaml_frontmatter(text)
139
+
140
+ wicket_id = str(fm.get("wicket_id", p.parent.name))
141
+ title = str(fm.get("title", ""))
142
+
143
+ # Front matter can declare autonomy; Effect section takes precedence.
144
+ fm_autonomy = str(fm.get("autonomy", "narrate")).lower()
145
+ effect_type, body_autonomy = _extract_effect(body)
146
+ autonomy = body_autonomy if body_autonomy != "narrate" else fm_autonomy
147
+ constraint_names = _extract_constraints(body)
148
+
149
+ return ManifestDeclaration(
150
+ wicket_id=wicket_id,
151
+ title=title,
152
+ autonomy=autonomy,
153
+ effect_type=effect_type,
154
+ constraint_names=constraint_names,
155
+ raw_frontmatter=fm,
156
+ )
157
+
158
+
159
+ def find_manifest(flows_dir: str | Path, wicket_id: str) -> ManifestDeclaration | None:
160
+ """Locate and load ``flows/<wicket_id>/manifest.md`` under *flows_dir*.
161
+
162
+ Returns ``None`` if no such file exists (safe — caller can proceed without it).
163
+ """
164
+ p = Path(flows_dir) / wicket_id / "manifest.md"
165
+ if not p.exists():
166
+ return None
167
+ return load_manifest(p)
@@ -0,0 +1,249 @@
1
+ Metadata-Version: 2.4
2
+ Name: capsule-emit
3
+ Version: 0.1.0
4
+ Summary: One-call emit() for Agent Action Capsules — anchor on by default, ledger view CLI, thin framework adapters.
5
+ Author: Action State Group
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/action-state-group/capsule-emit
8
+ Project-URL: Source, https://github.com/action-state-group/capsule-emit
9
+ Project-URL: Tracker, https://github.com/action-state-group/capsule-emit/issues
10
+ Project-URL: Specification, https://github.com/action-state-group/agent-action-capsule
11
+ Project-URL: Organization, https://github.com/action-state-group
12
+ Keywords: scitt,agent,capsule,verification,transparency,audit
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Security :: Cryptography
16
+ Classifier: Development Status :: 3 - Alpha
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ License-File: NOTICE
21
+ Requires-Dist: agent-action-capsule>=0.0.2
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=7.0; extra == "dev"
24
+ Requires-Dist: ruff>=0.4; extra == "dev"
25
+ Provides-Extra: langchain
26
+ Requires-Dist: langchain-core>=0.1; extra == "langchain"
27
+ Provides-Extra: crewai
28
+ Requires-Dist: crewai>=0.40; extra == "crewai"
29
+ Provides-Extra: mcp
30
+ Provides-Extra: hermes
31
+ Dynamic: license-file
32
+
33
+ # capsule-emit
34
+
35
+ **One call to seal a tamper-evident, independently-verifiable record of what your AI agent actually did.**
36
+
37
+ ```python
38
+ from capsule_emit import emit
39
+
40
+ cap = emit(action="write_po", operator="acme-co", developer="po-agent@v1",
41
+ agent_input={"vendor": "Frobozz Supply", "total": 1240.19},
42
+ agent_output=result, verdict="executed",
43
+ effect={"type": "write_po", "status": "dispatched"})
44
+
45
+ print(cap.capsule_id) # sealed, anchored, verifiable by anyone
46
+ ```
47
+
48
+ `capsule-emit` is the producer layer for the **Agent Action Capsule** — a [SCITT](https://datatracker.ietf.org/doc/draft-mih-scitt-agent-action-capsule/) statement profile. You add one line at the moment your agent does something consequential; you get back a signed, digest-committed capsule that a third party who trusts neither you nor your agent can independently verify.
49
+
50
+ ---
51
+
52
+ ## Why you need this
53
+
54
+ Agents now move money, change records, and act across organizational boundaries. When something goes wrong — or someone asks "did your agent really do that, and was it authorized?" — what's your proof?
55
+
56
+ Your **logs** are your own word. They're mutable, they live in your database, and they mean nothing to an auditor, a counterparty, or a regulator who has no reason to trust your systems. There's no way for an outside party to confirm a log wasn't edited after the fact.
57
+
58
+ A **capsule** is different: it's signed at the moment of the action, its content is committed to a hash, and it's recorded in a public append-only log. Anyone can verify it offline, from the bytes alone — *without trusting you*.
59
+
60
+ ## Why your existing stack can't do this
61
+
62
+ These layers answer **different questions** — a capsule fills the gap none of them cover:
63
+
64
+ | Layer | Examples | Answers | Doesn't answer |
65
+ |---|---|---|---|
66
+ | **Identity** | DIDs, SPIFFE, Agent Cards | *Who* is the agent? | What it did |
67
+ | **Authorization** | OPA, policy, permits | What is it *allowed* to do? | What it actually did, or the outcome |
68
+ | **Observability** | Datadog, audit logs, your DB | What *you say* happened | Nothing to a party who doesn't trust you — mutable, self-attested |
69
+ | **Agent Action Capsule** | `capsule-emit` | **What it *did*, provably** | (composes with the above by reference) |
70
+
71
+ A capsule records the action **and its outcome**, with a *confirmed-effect binding* so a **dispatched attempt can't be passed off as a completed effect** (the may/did distinction: approved ≠ executed ≠ confirmed). It records on **every verdict, including refusals** — a `blocked` capsule is auditor-grade evidence that a gate worked.
72
+
73
+ ## Concepts
74
+
75
+ A small vocabulary — each concept maps to a field you can see or a command you can run:
76
+
77
+ - **Capsule** — the unit: one consequential action *and its outcome*, sealed, signed, and digest-committed. It's plain JSON — inspect it with `cap.capsule` (see *What's in a capsule* below).
78
+ - **may / did** — the honesty model: *approved ≠ executed ≠ confirmed*. A capsule carries the verdict (`disposition.verdict_class`) **and** a confirmed-effect binding (`effect.status` + request/response digests), so a *dispatched attempt* can never be presented as a *completed effect*.
79
+ - **Chain** — actions link by digest: a confirm / supersede / escalate capsule points at its parent (`chain.parent_capsule_id`), turning *approved → executed → confirmed* (or *deferred → escalated → resolved*) into one verifiable trail. → `emit(..., confirms=parent_id)`
80
+ - **Break** — tamper-evidence: change a single byte and the recomputed `capsule_id` stops matching, so `verify` returns **INVALID**. The break *is* the proof — it's what makes the record trustworthy to someone who didn't write it.
81
+ - **Anchor** — the public proof: the capsule's digest is written to an append-only transparency log; the receipt proves it existed at time T, checkable by anyone *without trusting you* (see *Anchoring* below).
82
+ - **Ledger** — your local append-only trail of capsules (the chain of chains). → `capsule-emit ledger view ./ledger.jsonl`
83
+ - **Verify** — anyone, offline, from the bytes alone — no keys, no network, no clock. Class-1 (structure + IDs), Class-2 (manifest-aware). Independent of the producer on purpose (see *Verify* below).
84
+ - **Declare → Enforce** — a `manifest.md` *declares* autonomy + constraints; a compatible gateway *enforces* the same file later, with **no change** to your `emit()` calls (see *Declare now, enforce later* below).
85
+
86
+ The sections below are the depth behind each concept.
87
+
88
+ ## How easy it is
89
+
90
+ ```bash
91
+ pip install capsule-emit # emit + anchor client + ledger CLI
92
+ ```
93
+
94
+ ```python
95
+ from capsule_emit import emit
96
+
97
+ cap = emit(
98
+ action="write_po",
99
+ operator="acme-co", # the accountable tenant
100
+ developer="po-agent@v1", # the agent identity + version
101
+ agent_input={"vendor": "Frobozz Supply", "total": 1240.19},
102
+ agent_output=result,
103
+ model={"provider": "anthropic", "model_id": "claude-sonnet-4-6"},
104
+ verdict="executed", # executed | blocked | denied | errored | timed_out
105
+ effect={"type": "write_po", "status": "dispatched"},
106
+ )
107
+ print(cap.capsule_id, cap.anchored)
108
+ ```
109
+
110
+ That's it. The capsule is sealed and anchored. One call per consequential action.
111
+
112
+ ## What's inside a capsule
113
+
114
+ `emit()` returns `cap.capsule` — a JSON object you can inspect, store, or hand to anyone:
115
+
116
+ ```jsonc
117
+ {
118
+ "spec_version": "draft-mih-scitt-agent-action-capsule-01",
119
+ "format_version": "2",
120
+ "capsule_id": "9fddfcec…32eb26", // SHA-256 of the canonical payload (its content address)
121
+ "action_id": "write_po/39530d9c…", // the action name + a unique id (chain linkage)
122
+ "action_type": "decide", // the capsule class (a decision that produced an effect)
123
+ "operator": "acme-co", // accountable tenant
124
+ "developer": "po-agent@v1", // agent identity + version
125
+ "timestamp": "2026-06-20T04:45:11Z",
126
+ "model_attestation": { // which model + the evidence it produced
127
+ "provider": "anthropic",
128
+ "model_id": "claude-sonnet-4-6",
129
+ "compute_attestation": {
130
+ "agent_input_digest": "3c2c9123…", // the prompt/input, sealed by hash
131
+ "agent_output_digest": "c574d16d…" // the inference/output, sealed by hash
132
+ }
133
+ },
134
+ "effect": { // what was committed
135
+ "type": "write_po",
136
+ "status": "dispatched", // dispatched (attempted) vs confirmed (observed)
137
+ "effect_attestation": "runtime_claimed"
138
+ },
139
+ "disposition": { // the may/did verdict
140
+ "decision": "accept",
141
+ "verdict_class": "executed", // executed | blocked | denied | errored | confirmed
142
+ "approver": "policy",
143
+ "human_disposed": false // honest in-the-loop flag
144
+ },
145
+ "assurance": { // how far to trust each part
146
+ "attestation_mode": "self_attested",
147
+ "effect_mode": "dispatched_unconfirmed",
148
+ "ledger_mode": "standalone" // standalone | chained
149
+ }
150
+ // When a capsule confirms/supersedes another, a "chain" block appears and
151
+ // the effect gains a "response_digest" (the confirmed-effect binding):
152
+ // "chain": { "parent_capsule_id": "1008e6fc…", "relation": "confirms" }
153
+ }
154
+ ```
155
+
156
+ Confirming or superseding an action is itself a capsule that **chains** to the first — that's how "approved → executed → confirmed" becomes a verifiable trail. Full field reference: the [spec](https://datatracker.ietf.org/doc/draft-mih-scitt-agent-action-capsule/) §5.
157
+
158
+ ## Anchoring — where the proof lives
159
+
160
+ **Anchor is on by default.** When you `emit()`, the capsule's **digest only** is submitted to a SCITT transparency log, and you get back an [RFC 9162](https://www.rfc-editor.org/rfc/rfc9162) inclusion-proof **receipt** — durable, tamper-evident evidence that this exact capsule existed at that time.
161
+
162
+ - **Where:** the free hosted log at `https://anchor.agentactioncapsule.org/v1/digest` (no signup, no key).
163
+ - **What's logged:** a **SHA-256 digest** (the `capsule_id`) — nothing else. Your vendors, amounts, operator, and payloads **never leave your machine**.
164
+ - **What you get:** the receipt (an inclusion proof) — keep it with the capsule; anyone can later check the capsule against the log offline.
165
+ - **Self-host or repoint:** the log service ([`capsule-anchor`](https://github.com/action-state-group/capsule-anchor)) is open-source. Point anywhere with `AAC_ANCHOR_URL=https://your-log/...` or `emit(..., anchor_url=...)`.
166
+ - **Offline:** `emit(..., anchor=False)` seals locally and skips the network.
167
+ - **Why bother:** a self-hosted log you control isn't proof to an outsider; a shared, append-only transparency log is. That's what makes the capsule checkable by someone who trusts neither party.
168
+
169
+ ## Verify
170
+
171
+ The verifier ships in the spec package — install it and check any capsule (or a whole ledger) from the bytes alone, no keys/network/clock:
172
+
173
+ ```bash
174
+ pip install agent-action-capsule
175
+ agent-action-capsule verify ./ledger.jsonl
176
+ ```
177
+
178
+ Tamper with one byte and verification fails. The verifier is independent of `capsule-emit` on purpose — *any* tool can produce a capsule; *any* party can verify one.
179
+
180
+ ## Ledger view
181
+
182
+ Every `emit()` appends to a local JSONL ledger:
183
+
184
+ ```bash
185
+ capsule-emit ledger view ./ledger.jsonl
186
+ ```
187
+
188
+ ## Framework adapters
189
+
190
+ One `emit()` per tool call, regardless of framework — thin adapters over one shared base:
191
+
192
+ ```python
193
+ from capsule_emit.adapters.mcp import MCPCapsuleEmitter # primary (MCP)
194
+ emitter = MCPCapsuleEmitter(operator="acme-co", developer="my-agent@v1")
195
+
196
+ @emitter.tool("write_po")
197
+ def write_po(vendor: str, total: float) -> dict: ...
198
+ ```
199
+
200
+ LangChain (`LangChainCapsuleEmitter`, a callback handler), CrewAI (`CrewAICapsuleEmitter`, `.wrap(tool)`), and Hermes (`HermesCapsuleEmitter`, `.after_tool(...)`) work the same way. **Per-adapter guides — where to put the call, the one-line add, and a ready-made prompt for your coding agent — are in [`docs/adapters/`](docs/adapters/).**
201
+
202
+ ## Declare now, enforce later — same file
203
+
204
+ Drop a `flows/<action>/manifest.md` next to your code to declare autonomy + constraints:
205
+
206
+ ```markdown
207
+ ---
208
+ wicket_id: write-po
209
+ autonomy: narrate
210
+ ---
211
+ ## Constraints
212
+ | id | what it checks | method | severity |
213
+ |----|----------------|--------|----------|
214
+ | po_arithmetic | Line items re-add to total. | arithmetic_balance | block |
215
+ ```
216
+
217
+ `capsule-emit` reads the manifest to **declare** (no enforcement). A compatible gateway reads the **same file** and **enforces** — adding enforcement requires **no changes** to your `emit()` calls or manifests.
218
+
219
+ ## How it fits
220
+
221
+ ```
222
+ capsule-emit → agent-action-capsule (spec + reference verifier)
223
+
224
+ scitt-cose (COSE_Sign1 + SCITT receipt verification)
225
+ ```
226
+
227
+ `capsule-emit` produces; [`agent-action-capsule`](https://github.com/action-state-group/agent-action-capsule) is the specification + verifier; [`scitt-cose`](https://github.com/action-state-group/scitt-cose) verifies the transparency-log substrate. Separate on purpose.
228
+
229
+ ## Documentation
230
+
231
+ New here? These are written to be read top-to-bottom, no standards background needed:
232
+
233
+ - **[Tutorials](docs/tutorials/)** — five-minute, copy-paste sessions: your first capsule → confirming & chaining → reading your ledger → declaring rules.
234
+ - **[Concepts in plain words](docs/concepts.md)** — the seven words (capsule, seal, may/did, chain, break, anchor, ledger), each tied to a field or command.
235
+ - **[Anatomy of a capsule](docs/anatomy.md)** — exactly what gets sealed, the two-tier structure, and how each layer is captured.
236
+ - **[Adapters](docs/adapters/)** — let MCP / LangChain / CrewAI / Hermes emit capsules for you (with a paste-to-your-coding-agent prompt on each page).
237
+ - **[Going deeper — and popping out](docs/going-deeper.md)** — *down* into the spec + `scitt-cose` substrate if you want to verify it yourself; *up* to a compatible enforcement gateway (e.g. `gopher-ai`, OSS) when you want capsules to **block**, not just record.
238
+
239
+ ## Status
240
+
241
+ Alpha — API stable, not yet 1.0. The underlying specification is an **individual IETF Internet-Draft**, not an RFC; no RFC number is claimed.
242
+
243
+ ## Provenance, neutrality & governance
244
+
245
+ Developed by **Action State Group, Inc.** and published as **open-source software (Apache-2.0)**, with a clean transfer path to a **neutral home** (foundation donation or community project) as the ecosystem matures. The content is product-free — the emission layer, adapters, ledger utilities, and a manifest parser; nothing tenant- or product-specific. No primacy is claimed; the value is an interoperable, independently-verifiable record format. Discussion venue: the IETF **SCITT** Working Group (`scitt@ietf.org`).
246
+
247
+ ## License
248
+
249
+ Apache-2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,18 @@
1
+ capsule_emit/__init__.py,sha256=MgDTrbnXndjUcJkb3vC3_x4WCOuLteAkKSAe1LHwUfI,1186
2
+ capsule_emit/cli.py,sha256=z4KeX5tITw8qSZkBW4aUBkG-GaQfzB8GWCFBVdg1pnk,1622
3
+ capsule_emit/core.py,sha256=kXXrQDmeUIuTBrgdUAKN-OO9vuTQQehKoWsblXW3nLA,6069
4
+ capsule_emit/ledger.py,sha256=Zzbz0leKyiPoCW4yNtOOO2YawIRvtyl4uWu6b1W69m0,3196
5
+ capsule_emit/manifest.py,sha256=Wtgwybq8yCL6bdaQ3wAPf5Se60EY6pWuq-hlsLKdjr4,5809
6
+ capsule_emit/adapters/__init__.py,sha256=i6-qgSSXpmX3xvELixnnniAinZU4_wWFGkn6JfsRaeE,226
7
+ capsule_emit/adapters/_base.py,sha256=2kMO-uujYsgjvojW6u1QzkotMb12dzYvrcY2iUZ_RJI,2578
8
+ capsule_emit/adapters/crewai.py,sha256=ZbEdzxeTbeng7mjJCZwZJlAPsYQiOHS5yZXBrOCC-A8,1825
9
+ capsule_emit/adapters/hermes.py,sha256=UzchiEOGgSigfD8I_IOyncshwcpW-HqQ5KPpReYL1jE,1240
10
+ capsule_emit/adapters/langchain.py,sha256=3qQnfc6CEdlsWoC4koUxszCeaUvWmWoHqIGQ9bQcB8E,1734
11
+ capsule_emit/adapters/mcp.py,sha256=HbmLMTqvgNPZ3MKQv-s9ZaAIGP64lWPSMjS5BXddeDo,2310
12
+ capsule_emit-0.1.0.dist-info/licenses/LICENSE,sha256=fm743ElXZMxoFnlTFYMJuMOE70vxHAyliT47VC-fUms,10635
13
+ capsule_emit-0.1.0.dist-info/licenses/NOTICE,sha256=nuINAerH2aboFWGwCIg4XB2AM4_gARfWJhqwnnAKqMc,540
14
+ capsule_emit-0.1.0.dist-info/METADATA,sha256=KNFf71_lSr6PmhpPnp_wlf3wc2x-FtmUawyLhUw28mg,14272
15
+ capsule_emit-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
16
+ capsule_emit-0.1.0.dist-info/entry_points.txt,sha256=bfgS0aT_E6df1HixtCVRvPGM5QX1Pvp_IMGt7_G9YsY,55
17
+ capsule_emit-0.1.0.dist-info/top_level.txt,sha256=z65yhwMjlAlb_nCa0Tu3jD59UsPUNLcv6o6d6q5ykDY,13
18
+ capsule_emit-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ capsule-emit = capsule_emit.cli:main
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other transformations
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and its Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or otherwise designated in writing by the copyright owner as
57
+ "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contributions with
78
+ the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a
80
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
81
+ or a Contribution incorporated within the Work constitutes direct
82
+ or contributory patent infringement, then any patent licenses
83
+ granted to You under this License for that Work shall terminate
84
+ as of the date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or in addition to the
115
+ NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Contribution, either as is or with modifications, and to grant
122
+ third parties a sublicense to use, copy, modify, merge, publish,
123
+ distribute, sublicense, and/or sell copies of the Contribution.
124
+
125
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
126
+ any Contribution intentionally submitted for inclusion in the Work
127
+ by You to the Licensor shall be under the terms and conditions of
128
+ this License, without any additional terms or conditions.
129
+ Notwithstanding the above, nothing herein shall supersede or modify
130
+ the terms of any separate license agreement you may have executed
131
+ with Licensor regarding such Contributions.
132
+
133
+ 6. Trademarks. This License does not grant permission to use the trade
134
+ names, trademarks, service marks, or product names of the Licensor,
135
+ except as required for reasonable and customary use in describing the
136
+ origin of the Work and reproducing the content of the NOTICE file.
137
+
138
+ 7. Disclaimer of Warranty. Unless required by applicable law or
139
+ agreed to in writing, Licensor provides the Work (and each
140
+ Contributor provides its Contributions) on an "AS IS" BASIS,
141
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
142
+ implied, including, without limitation, any warranties or conditions
143
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
144
+ PARTICULAR PURPOSE. You are solely responsible for determining the
145
+ appropriateness of using or reproducing the Work and assume any
146
+ risks associated with Your exercise of permissions under this License.
147
+
148
+ 8. Limitation of Liability. In no event and under no legal theory,
149
+ whether in tort (including negligence), contract, or otherwise,
150
+ unless required by applicable law (such as deliberate and grossly
151
+ negligent acts) or agreed to in writing, shall any Contributor be
152
+ liable to You for damages, including any direct, indirect, special,
153
+ incidental, or exemplary damages of any character arising as a
154
+ result of this License or out of the use or inability to use the
155
+ Work (even if such Contributor has been advised of the possibility
156
+ of such damages).
157
+
158
+ 9. Accepting Warranty or Liability. While redistributing the Work or
159
+ Derivative Works thereof, You may choose to offer, and charge a fee
160
+ for, acceptance of support, warranty, indemnity, or other liability
161
+ obligations and/or rights consistent with this License. However, in
162
+ accepting such obligations, You may offer such conditions only on
163
+ Your own behalf and on Your sole responsibility, not on behalf of
164
+ any other Contributor, and only if You agree to indemnify, defend,
165
+ and hold each Contributor harmless for any liability incurred by,
166
+ or claims asserted against, such Contributor by reason of your
167
+ accepting any such warranty or additional liability.
168
+
169
+ END OF TERMS AND CONDITIONS
170
+
171
+ APPENDIX: How to apply the Apache License to your work.
172
+
173
+ To apply the Apache License to your work, attach the following
174
+ boilerplate notice, with the fields enclosed by brackets "[]"
175
+ replaced with your own identifying information. (Don't include
176
+ the brackets!) The text should be enclosed in the appropriate
177
+ comment syntax for the file format in question.
178
+
179
+ Copyright 2024-2026 Action State Group, Inc.
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
190
+ implied. See the License for the specific language governing
191
+ permissions and limitations under the License.
@@ -0,0 +1,13 @@
1
+ capsule-emit
2
+ Copyright 2024-2026 Action State Group, Inc.
3
+
4
+ This product is developed by Action State Group, Inc. and is published
5
+ as open-source software under the Apache License, Version 2.0.
6
+
7
+ The Agent Action Capsule specification (draft-mih-scitt-agent-action-capsule)
8
+ is developed and maintained at:
9
+ https://github.com/action-state-group/agent-action-capsule
10
+
11
+ This library is a producer/emission layer for that specification.
12
+ It depends on the agent-action-capsule reference library for capsule
13
+ construction and Class-1 verification.
@@ -0,0 +1 @@
1
+ capsule_emit