coact.emit¶
Emitters: one AgentDefinition → many serializations.
COACT_SPEC §5.3. Emit targets are an open-closed skill-style
Registry (register, don’t hardcode). Two ship by
default:
claude-agents-md— the filesystem.claude/agents/<name>.md(host frontmatter using the host’s exact camelCase field names + the persona body). coact-specific fields (the return contract,consumes,source_skill) are carried in an additivecoact:frontmatter sub-block so the round-trip is lossless and the host still ignores them. Reusesskill.basefrontmatter helpers — coact writes no YAML by hand.sdk-agent-dict— kwargs forclaude_agent_sdk.AgentDefinitionplus the leftoverquery()options, built by introspecting the installed SDK dataclass so it degrades gracefully across SDK versions (DECISIONS D2). The SDK is imported lazily here only; core stays SDK-free.
Future emitters (CrewAI / OpenAI via the aw adapter) register without
touching this module. Topology is never emitted (DECISIONS D8).
Module Attributes
|
Functions
Build the host frontmatter dict for an agent (omitting empty fields). |
|
|
Emit an agent to a registered target; optionally write a file target to |
|
Parse |
|
Adapt an |
Serialize an agent to |
|
Build Agent-SDK kwargs + leftover query options for one agent. |
- coact.emit.agent_to_frontmatter(ad)[source]¶
Build the host frontmatter dict for an agent (omitting empty fields).
>>> ad = AgentDefinition(name='x', description='y', tools=['Read'], model='haiku') >>> fm = agent_to_frontmatter(ad) >>> fm['name'], fm['tools'], fm['model'] ('x', ['Read'], 'haiku')- Return type:
- coact.emit.emit_agent(ad, target='claude-agents-md', *, dest=None)[source]¶
Emit an agent to a registered target; optionally write a file target to
dest.For string targets (e.g.
claude-agents-md) withdestgiven, writes<dest>/<name>.mdand returns thePath. Otherwise returns the emitter’s value (str or dict).>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are...') >>> emit_agent(ad).splitlines()[0] '---'- Return type:
- coact.emit.emitters: Registry[Callable[[AgentDefinition], Any]] = Registry('emitters', keys=['claude-agents-md', 'sdk-agent-dict'])¶
AgentDefinition -> serialized form(str or dict).- Type:
Registry of emit targets
- coact.emit.from_claude_agent_md(text)[source]¶
Parse
.claude/agents/*.mdcontent back into anAgentDefinition.The inverse of
to_claude_agent_md(): lossless for every structured field; thepromptbody is whitespace-trimmed on both ends (personas are not whitespace-sensitive).>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are an analyst.', ... tools=['Read', 'Grep'], model='sonnet', ... returns=ReturnContract(json_schema={'type': 'object'}, description='out')) >>> back = from_claude_agent_md(to_claude_agent_md(ad)) >>> (back.name, back.tools, back.model, back.prompt) == (ad.name, ad.tools, ad.model, ad.prompt) True >>> back.returns.json_schema {'type': 'object'}- Return type:
- coact.emit.to_aw_agent_spec(ad)[source]¶
Adapt an
AgentDefinitionto anaw.translators.AgentSpec.Lets coact reuse
aw’s CrewAI / OpenAI / SKILL.md renderers (the*_from_speccores) instead of reimplementing them — the ecosystem coordination point. Requiresaw.
- coact.emit.to_claude_agent_md(ad)[source]¶
Serialize an agent to
.claude/agents/<name>.mdcontent.>>> ad = AgentDefinition(name='ux', description='Analyze.', prompt='You are...') >>> md = to_claude_agent_md(ad) >>> md.startswith('---') and 'name: ux' in md and 'You are...' in md True- Return type:
- coact.emit.to_sdk_agent_dict(ad)[source]¶
Build Agent-SDK kwargs + leftover query options for one agent.
Returns
{'name', 'agent_kwargs', 'options'}whereagent_kwargsare accepted by the installedclaude_agent_sdk.AgentDefinitionandoptionsholds fields that version cannot express (to be wired intoquery()by thesdkrealize backend). Requires the Agent SDK.- Return type: