mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
b394f06fdc
Renames the Bots SDK to the Channels SDK. Names only — no behavior change. - 8 packages @copilotkit/bot* -> @copilotkit/channels* (git mv dirs, names, workspace: cross-deps). Now includes @copilotkit/bot-intelligence -> @copilotkit/channels-intelligence (landed on main via #5761; unpublished, so renamed fresh with the family). - release.config.json scope keys + versionSource; ReleaseScope union; canary/stable-release/publish-release scope dropdowns; verify script - examples/slack (Kite) + examples/teams: deps, jsxImportSource, imports - showcase/shell-docs: content dirs docs/bots->docs/channels and reference/bot->reference/channels, nav registry, redirects createBot and other API names unchanged. Old @copilotkit/bot* to be deprecated after the new packages publish (bot-intelligence was never published). Re-derived onto latest main (was conflicting after #5761 landed). Refs OSS-438
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
/**
|
|
* Adaptive Card `Action.Submit` decoding for the Teams adapter.
|
|
*
|
|
* A button rendered by {@link ../render/adaptive-card.renderButton} carries its
|
|
* opaque minted action id (`ck:...`) and tiny `value` in the action's `data`.
|
|
* When clicked, Teams delivers a **Message activity** whose `value` is that
|
|
* `data` object (merged with any card inputs) and whose `text` is empty. These
|
|
* helpers recognize and decode that activity so the engine's `awaitChoice`
|
|
* waiter resolves.
|
|
*/
|
|
|
|
/** Minimal shape of the inbound Teams activity we read for interaction decoding. */
|
|
export interface TeamsActivityLike {
|
|
value?: unknown;
|
|
conversation?: { id?: string };
|
|
}
|
|
|
|
/** The `data` our buttons round-trip (see `render/adaptive-card.ts` `renderButton`). */
|
|
interface CardActionData {
|
|
ckActionId?: string;
|
|
value?: unknown;
|
|
}
|
|
|
|
/**
|
|
* Stable conversation key shared by ingress (`onTurn`) and interaction decoding
|
|
* so the engine's `awaitChoice` waiters resolve. Teams gives one stable id per
|
|
* conversation; **both paths MUST derive the key here**. A mismatch silently
|
|
* strands the waiter. (The issue mandates a single shared helper.)
|
|
*/
|
|
export function conversationKeyOf(activity: TeamsActivityLike): string {
|
|
return activity.conversation?.id ?? "";
|
|
}
|
|
|
|
/**
|
|
* Recognize and parse an Adaptive Card `Action.Submit`. Returns the opaque
|
|
* action id + button value when the activity carries our `ckActionId`, else
|
|
* `undefined` (i.e. it's an ordinary chat message). Carries ONLY the opaque id
|
|
* and the tiny button value: no resume-data smuggling; durability rides on the
|
|
* engine's ActionStore keyed by that id.
|
|
*/
|
|
export function parseCardAction(
|
|
activity: TeamsActivityLike,
|
|
): { id: string; value: unknown } | undefined {
|
|
const data = activity.value as CardActionData | undefined;
|
|
if (
|
|
!data ||
|
|
typeof data !== "object" ||
|
|
typeof data.ckActionId !== "string"
|
|
) {
|
|
return undefined;
|
|
}
|
|
return { id: data.ckActionId, value: data.value };
|
|
}
|