text
stringlengths
0
1.47k
* Chain selector for dsh 0.1.5 and earlier, whose turn tail elects one entry.
* @param owner - the turn-tail owner currency.
* @returns the cards as the match, or null to decline this turn.
*/
function selectTurnCards(owner) {
const cards = cardsBefore(owner.turn, owner.seq);
return cards.length === 0 ? null : cards;
}
const listStyle = {
display: "grid",
gap: 12,
margin: "8px 0 4px"
};
/**
* Turn-tail entry. A list turn tail mounts it on every turn, so it declines
* turns without cards itself, and it stays empty whenever the host is not
* folding — the toolview card is then already in view.
* @param props - turn owner props plus the injected folding selector.
* @returns the turn's cards, or null.
*/
function TurnCards({ turn, seq, useVisualizeFolds }) {
const folds = useVisualizeFolds((value) => value);
const cards = cardsBefore(turn, seq);
if (!folds || cards.length === 0) return null;
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
style: listStyle,
children: cards.map((card) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Frame, {
meta: card.meta,
callId: `turn-tail:${card.callId}`
}, card.callId))
});
}
//#endregion
//#region src/client/index.tsx
const name = "dsh-visualize";
const inject = ["slots"];
/**
* Look up the Conversation event registry without declaring the service, so
* hosts that predate it still load the plugin.
* @param host - client context.
* @returns the registry, or undefined on dsh 0.1.1.
*/
function conversationEvents(host) {
const service = host.get("uiConversation");
return typeof service?.events?.register === "function" ? service.events : void 0;
}
/**
* Turn-tail registration valid on both slot shapes the host has shipped: dsh
* 0.1.5 and earlier declare a chain (register requires `select`, orders by
* `priority`), 0.1.6 onward a list (register requires `id`, orders by
* `order`). Each register validates only its own kind's field. The cards sit
* after the host's deliverables and before other plugins' low-rank entries.
* @param host - client context, for the folding preference.
* @returns the register options.
*/
function turnTailOptions(host) {
const folds = foldingSource(host);
return {
name: "conversation.chat.turnTail",
id: "dsh-visualize-cards",
order: 100,
priority: 100,
select: selectTurnCards,
inject: () => ({ hooks: { visualizeFolds: folds } })
};
}
/**
* Register the keyed toolview and the dock preview. Waiting on each hole's
* declaration mirrors the official registrants: entry application order is
* loader-driven, and a direct register racing the declaration fails boot.
* @param ctx - client root context.
*/
function apply(ctx) {
ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
name: "tool.call.toolview",
key: "visualize"
}, VisualizeCard));
ctx.slots.inject("conversation.input.dock", () => ctx.slots.register({
name: "conversation.input.dock",
id: "visualize-stream",
order: 30
}, StreamingPreview));
ctx.slots.inject("conversation.chat.turnTail", () => {
const events = conversationEvents(ctx);
if (events === void 0) return () => void 0;
const disposeDefinition = events.register(turnCardsDefinition);
const disposeTail = ctx.slots.register(turnTailOptions(ctx), TurnCards);
return () => {
disposeTail();
disposeDefinition();
};
});
}
//#endregion
exports.apply = apply;
exports.inject = inject;
exports.name = name;
return module.exports;
}
});