feat(core): ContentPart + parts() helper for multi-format result envelopes#115
Merged
Conversation
… envelopes
Formalizes the convention surfaced during the admin-agents UX walk: the
final result event can carry multiple MIME-typed views of the same
output. Order in the array signals render preference. Backward
compatible — `result(success, output?: unknown)` still accepts any value.
API additions (no signature changes):
- `ContentPart` type — `{ type: string; content: unknown }`
- `ResultOutput` type — alias for `unknown` with docs
- `parts({ markdown, text, json, extra })` factory — builds a
ContentPart[] in canonical preference order
Canonical types: `text/markdown` → `text/plain` → `application/json`.
Anything else passes through `extra`.
Cross-repo follow-ups:
- web/dashboard ResultEvent: detect array-of-parts, render preferred
view + JSON toggle (in flight: agentage/web#235)
- agents: emit `result(true, parts({ markdown, json }))` on the 5 TS
agents (in flight: agentage/agents#5)
Bumps @agentage/core to 0.10.0 (minor — additive).
…ent-parts # Conflicts: # package-lock.json
Contributor
|
🎉 PR Validation ✅ PASSED Commit: Checks:
Ready to merge! ✨ 🔗 View workflow run |
vreshch
added a commit
that referenced
this pull request
Apr 26, 2026
Re-publish: 0.10.0 on npm pre-dates ContentPart + parts() from #115. 0.10.1 picks up the new exports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Formalizes the convention surfaced during the admin-agents UX walk: the final `result` event can carry multiple MIME-typed views of the same output. Order = render preference.
```ts
import { result, parts } from '@agentage/core';
yield result(true, parts({
markdown: '# Done\n\n42 commits',
json: { commits: 42 },
}));
```
Backward compatible — `result(success, output?: unknown)` still accepts any value.
API additions
Canonical MIME types: `text/markdown` → `text/plain` → `application/json`. Non-canonical parts pass through `extra`.
Bumps `@agentage/core` to 0.10.0 (minor — additive only).
Cross-repo follow-ups
Test plan