🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@shadowob/shared

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shadowob/shared - npm Package Compare versions

Comparing version
1.1.47
to
1.1.48
+368
dist/chunk-OSMIYTN4.js
// src/types/inbox.types.ts
var BUDDY_INBOX_TOPIC_PREFIX = "shadow:buddy-inbox:";
var BUDDY_INBOX_DELIVERY_PERMISSION = "buddy_inbox:deliver";
var BUDDY_INBOX_PLATFORM_PERMISSIONS = [BUDDY_INBOX_DELIVERY_PERMISSION];
function isBuddyInboxPlatformPermission(value) {
return typeof value === "string" && BUDDY_INBOX_PLATFORM_PERMISSIONS.includes(value);
}
function buddyInboxTopic(agentId) {
return `${BUDDY_INBOX_TOPIC_PREFIX}${agentId}`;
}
function parseBuddyInboxAgentId(topic) {
if (!topic?.startsWith(BUDDY_INBOX_TOPIC_PREFIX)) return null;
const agentId = topic.slice(BUDDY_INBOX_TOPIC_PREFIX.length).trim();
return agentId || null;
}
function isBuddyInboxTopic(topic) {
return parseBuddyInboxAgentId(topic) !== null;
}
var TASK_MESSAGE_CARD_STATUSES = [
"queued",
"claimed",
"running",
"completed",
"failed",
"canceled",
"transferred"
];
var TERMINAL_TASK_MESSAGE_CARD_STATUSES = [
"completed",
"failed",
"canceled",
"transferred"
];
var TASK_MESSAGE_CARD_STATUS_TRANSITIONS = {
queued: ["queued", "claimed", "running", "completed", "failed", "canceled"],
claimed: ["claimed", "running", "completed", "failed", "canceled"],
running: ["running", "completed", "failed", "canceled"],
completed: ["completed"],
failed: ["failed", "transferred"],
canceled: ["canceled"],
transferred: ["transferred"]
};
function isTerminalTaskMessageCardStatus(status) {
return TERMINAL_TASK_MESSAGE_CARD_STATUSES.includes(
status
);
}
function isTaskMessageCardStatus(value) {
return typeof value === "string" && TASK_MESSAGE_CARD_STATUSES.includes(value);
}
function canTransitionTaskMessageCardStatus(from, to) {
const allowed = TASK_MESSAGE_CARD_STATUS_TRANSITIONS[from];
return allowed.includes(to);
}
function isRecord(value) {
return !!value && typeof value === "object" && !Array.isArray(value);
}
function isTaskReplyNotificationCard(card) {
return isRecord(card.data) && card.data.taskReplyNotification === true;
}
function isMessageReferenceCard(card) {
return card?.kind === "message_reference" && typeof card.title === "string" && isRecord(card.target) && typeof card.target.channelId === "string" && typeof card.target.messageId === "string";
}
function getBuddyInboxTaskCards(message) {
const cards = message.metadata?.cards;
if (!Array.isArray(cards)) return [];
return cards.filter(
(card) => card?.kind === "task" && typeof card.id === "string" && isTaskMessageCardStatus(card.status) && !isTaskReplyNotificationCard(card)
);
}
function hasBuddyInboxTaskCard(message) {
return getBuddyInboxTaskCards(message).length > 0;
}
function hasBuddyInboxTaskReplyNotificationCard(message) {
const cards = message.metadata?.cards;
return Array.isArray(cards) && cards.some(isTaskReplyNotificationCard);
}
function getBuddyInboxTaskStatuses(message) {
return getBuddyInboxTaskCards(message).map((card) => card.status);
}
function buddyInboxMessageMatchesTaskFilter(message, filter) {
const statuses = getBuddyInboxTaskStatuses(message);
if (statuses.length === 0) return false;
if (filter === "all") return true;
if (filter === "done") return statuses.every((status) => isTerminalTaskMessageCardStatus(status));
return statuses.some((status) => !isTerminalTaskMessageCardStatus(status));
}
function getBuddyInboxTaskMessageIds(messages) {
const ids = /* @__PURE__ */ new Set();
for (const message of messages) {
if (hasBuddyInboxTaskCard(message)) ids.add(message.id);
}
return ids;
}
function isBuddyInboxTaskReply(message, taskMessageIds) {
return Boolean(message.replyToId && taskMessageIds.has(message.replyToId));
}
function buildBuddyInboxViewMessages(messages, options) {
if (!options.isInboxChannel) return [...messages];
const taskMessageIds = getBuddyInboxTaskMessageIds(messages);
const taskFilter = options.taskFilter ?? "all";
return messages.filter((message) => {
if (isBuddyInboxTaskReply(message, taskMessageIds)) return false;
if (hasBuddyInboxTaskReplyNotificationCard(message)) return false;
if (!hasBuddyInboxTaskCard(message)) return taskFilter === "all";
return buddyInboxMessageMatchesTaskFilter(message, taskFilter);
});
}
var DEFAULT_BUDDY_INBOX_ADMISSION_POLICY = {
defaultMode: "allow",
rules: []
};
function parseAdmissionMode(value, fallback) {
if (value === "allow" || value === "deny" || value === "first_time" || value === "every_time") {
return value;
}
if (value === void 0 || value === null) return fallback;
throw new Error("Invalid Buddy Inbox admission mode");
}
function parseSubjectKind(value) {
if (value === "user" || value === "agent" || value === "server_app" || value === "system") {
return value;
}
throw new Error("Invalid Buddy Inbox admission subject kind");
}
function parseOptionalString(value, field, maxLength) {
if (value === void 0 || value === null || value === "") return void 0;
if (typeof value !== "string" || value.length > maxLength) {
throw new Error(`Invalid Buddy Inbox admission ${field}`);
}
return value;
}
function normalizeBuddyInboxAdmissionPolicy(value) {
if (value === void 0 || value === null) return { ...DEFAULT_BUDDY_INBOX_ADMISSION_POLICY };
if (!isRecord(value)) throw new Error("Invalid Buddy Inbox admission policy");
const defaultMode = parseAdmissionMode(value.defaultMode, "allow");
const rawRules = value.rules;
if (rawRules !== void 0 && !Array.isArray(rawRules)) {
throw new Error("Invalid Buddy Inbox admission rules");
}
const rules = (rawRules ?? []).slice(0, 100).map((entry) => {
if (!isRecord(entry)) throw new Error("Invalid Buddy Inbox admission rule");
return {
subjectKind: parseSubjectKind(entry.subjectKind),
subjectId: parseOptionalString(entry.subjectId, "subjectId", 160),
appKey: parseOptionalString(entry.appKey, "appKey", 120),
mode: parseAdmissionMode(entry.mode, defaultMode),
...entry.approved === true ? { approved: true } : {},
note: parseOptionalString(entry.note, "note", 500),
createdAt: parseOptionalString(entry.createdAt, "createdAt", 64),
updatedAt: parseOptionalString(entry.updatedAt, "updatedAt", 64)
};
});
return { defaultMode, rules };
}
function buddyInboxAdmissionRuleKey(rule) {
return [rule.subjectKind, rule.subjectId ?? "", rule.appKey ?? ""].join(":");
}
function parsePendingTask(value) {
if (!isRecord(value)) throw new Error("Invalid Buddy Inbox pending task");
const title = parseOptionalString(value.title, "task.title", 180);
if (!title) throw new Error("Invalid Buddy Inbox pending task title");
const body = parseOptionalString(value.body, "task.body", 8e3);
const priority = value.priority;
if (priority !== void 0 && priority !== "low" && priority !== "normal" && priority !== "medium" && priority !== "high") {
throw new Error("Invalid Buddy Inbox pending task priority");
}
const idempotencyKey = parseOptionalString(value.idempotencyKey, "task.idempotencyKey", 240);
const source = isRecord(value.source) ? value.source : void 0;
const requirements = isRecord(value.requirements) ? value.requirements : void 0;
const outputContract = isRecord(value.outputContract) ? value.outputContract : void 0;
const privacy = isRecord(value.privacy) ? value.privacy : void 0;
const data = isRecord(value.data) ? value.data : void 0;
return {
title,
...body ? { body } : {},
...priority ? { priority } : {},
...idempotencyKey ? { idempotencyKey } : {},
...source ? { source } : {},
...requirements ? { requirements } : {},
...outputContract ? { outputContract } : {},
...privacy ? { privacy } : {},
...data ? { data } : {}
};
}
function normalizeBuddyInboxAdmissionPendingDeliveries(value) {
if (value === void 0 || value === null) return [];
if (!Array.isArray(value)) throw new Error("Invalid Buddy Inbox pending deliveries");
return value.slice(0, 100).map((entry) => {
if (!isRecord(entry)) throw new Error("Invalid Buddy Inbox pending delivery");
const id = parseOptionalString(entry.id, "pending.id", 80);
const serverId = parseOptionalString(entry.serverId, "pending.serverId", 160);
const channelId = parseOptionalString(entry.channelId, "pending.channelId", 160);
const agentId = parseOptionalString(entry.agentId, "pending.agentId", 160);
const mode = parseAdmissionMode(entry.mode, "first_time");
if (mode !== "first_time" && mode !== "every_time") {
throw new Error("Invalid Buddy Inbox pending mode");
}
if (!isRecord(entry.subject)) throw new Error("Invalid Buddy Inbox pending subject");
if (!isRecord(entry.requestedBy)) throw new Error("Invalid Buddy Inbox pending requester");
if (!id || !serverId || !channelId || !agentId) {
throw new Error("Invalid Buddy Inbox pending delivery identifiers");
}
const requestedAt = parseOptionalString(entry.requestedAt, "pending.requestedAt", 64);
if (!requestedAt) throw new Error("Invalid Buddy Inbox pending requestedAt");
return {
id,
serverId,
channelId,
agentId,
mode,
subject: {
kind: parseSubjectKind(entry.subject.kind),
id: parseOptionalString(entry.subject.id, "subject.id", 160),
appKey: parseOptionalString(entry.subject.appKey, "subject.appKey", 120),
label: parseOptionalString(entry.subject.label, "subject.label", 160)
},
task: parsePendingTask(entry.task),
requestedBy: entry.requestedBy,
requestedAt,
updatedAt: parseOptionalString(entry.updatedAt, "pending.updatedAt", 64)
};
});
}
// src/types/message.types.ts
var MESSAGE_COPILOT_CONTEXT_METADATA_KEY = "copilotContext";
function isBoundedMetadataString(value, maxLength, required = false) {
if (typeof value !== "string") return !required && value == null;
const trimmed = value.trim();
return trimmed.length > 0 && trimmed.length <= maxLength;
}
function isMessageCopilotContext(value) {
if (!value || typeof value !== "object") return false;
const record = value;
return record.kind === "server_app_copilot" && isBoundedMetadataString(record.appKey, 120, true) && isBoundedMetadataString(record.serverAppId, 160) && isBoundedMetadataString(record.appId, 160) && isBoundedMetadataString(record.appName, 160) && isBoundedMetadataString(record.serverId, 160) && isBoundedMetadataString(record.serverSlug, 160) && isBoundedMetadataString(record.channelId, 160) && isBoundedMetadataString(record.channelKind, 40);
}
function buildMessageCopilotContextMetadata(context) {
return context && isMessageCopilotContext(context) ? { copilotContext: context } : void 0;
}
// src/types/runtime-session.types.ts
var RUNTIME_SESSION_PET_REACTION_BY_STATE = {
idle: "idle",
running: "working",
streaming: "thinking",
tool_call: "working",
waiting_for_approval: "waiting",
blocked: "waiting",
completed: "success",
failed: "error",
stopped: "idle",
unknown: "idle"
};
function runtimeSessionPetReactionForState(state) {
return RUNTIME_SESSION_PET_REACTION_BY_STATE[state] ?? "idle";
}
function runtimeSessionSignalToPetReaction(signal) {
switch (signal) {
case "running":
return "working";
case "streaming":
return "thinking";
case "tool_call":
return "working";
case "waiting_for_approval":
case "blocked":
return "waiting";
case "completed":
return "success";
case "failed":
return "error";
case "stopped":
case "unknown":
return "idle";
default:
return signal;
}
}
function runtimeSessionStateLooksActive(state) {
return state === "running" || state === "streaming" || state === "tool_call" || state === "waiting_for_approval" || state === "blocked";
}
// src/types/user.types.ts
var USER_STATUSES = ["online", "idle", "dnd", "offline"];
var BUDDY_PRESENCE_STATUSES = ["online", "busy", "idle", "dnd", "offline"];
var BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS = 9e4;
function normalizeUserStatus(status) {
if (status === "online" || status === "idle" || status === "dnd" || status === "offline") {
return status;
}
return "offline";
}
function normalizeBuddyPresenceStatus(status, options) {
if (options?.busy) {
return "busy";
}
if (status === "busy") {
return "busy";
}
return normalizeUserStatus(status);
}
function isBuddyHeartbeatActive(lastHeartbeat, options) {
if (!lastHeartbeat) return false;
const heartbeatMs = lastHeartbeat instanceof Date ? lastHeartbeat.getTime() : new Date(lastHeartbeat).getTime();
if (!Number.isFinite(heartbeatMs)) return false;
const nowMs = options?.nowMs ?? Date.now();
const thresholdMs = options?.thresholdMs ?? BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS;
return nowMs - heartbeatMs <= thresholdMs;
}
function normalizeBuddyRuntimePresenceStatus({
userStatus,
agentStatus,
lastHeartbeat,
busy = false,
nowMs
}) {
if (busy || agentStatus === "busy") return "busy";
if (agentStatus === "running") {
return isBuddyHeartbeatActive(lastHeartbeat, { nowMs }) ? "online" : "offline";
}
const normalizedAgentStatus = normalizeBuddyPresenceStatus(agentStatus);
if (normalizedAgentStatus !== "offline") return normalizedAgentStatus;
return normalizeUserStatus(userStatus);
}
export {
BUDDY_INBOX_TOPIC_PREFIX,
BUDDY_INBOX_DELIVERY_PERMISSION,
BUDDY_INBOX_PLATFORM_PERMISSIONS,
isBuddyInboxPlatformPermission,
buddyInboxTopic,
parseBuddyInboxAgentId,
isBuddyInboxTopic,
TASK_MESSAGE_CARD_STATUSES,
TERMINAL_TASK_MESSAGE_CARD_STATUSES,
TASK_MESSAGE_CARD_STATUS_TRANSITIONS,
isTerminalTaskMessageCardStatus,
isTaskMessageCardStatus,
canTransitionTaskMessageCardStatus,
isTaskReplyNotificationCard,
isMessageReferenceCard,
getBuddyInboxTaskCards,
hasBuddyInboxTaskCard,
getBuddyInboxTaskStatuses,
buddyInboxMessageMatchesTaskFilter,
getBuddyInboxTaskMessageIds,
isBuddyInboxTaskReply,
buildBuddyInboxViewMessages,
DEFAULT_BUDDY_INBOX_ADMISSION_POLICY,
normalizeBuddyInboxAdmissionPolicy,
buddyInboxAdmissionRuleKey,
normalizeBuddyInboxAdmissionPendingDeliveries,
MESSAGE_COPILOT_CONTEXT_METADATA_KEY,
isMessageCopilotContext,
buildMessageCopilotContextMetadata,
RUNTIME_SESSION_PET_REACTION_BY_STATE,
runtimeSessionPetReactionForState,
runtimeSessionSignalToPetReaction,
runtimeSessionStateLooksActive,
USER_STATUSES,
BUDDY_PRESENCE_STATUSES,
BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS,
normalizeUserStatus,
normalizeBuddyPresenceStatus,
isBuddyHeartbeatActive,
normalizeBuddyRuntimePresenceStatus
};
interface Message {
id: string;
content: string;
channelId: string;
authorId: string;
threadId: string | null;
replyToId: string | null;
isEdited: boolean;
isPinned: boolean;
createdAt: string;
updatedAt: string;
author?: {
id: string;
username: string;
displayName: string;
avatarUrl: string | null;
isBot: boolean;
};
attachments?: Attachment[];
reactions?: ReactionGroup[];
metadata?: MessageMetadata | null;
}
type MessageMentionKind = 'user' | 'buddy' | 'app' | 'channel' | 'server' | 'here' | 'everyone';
interface MessageMentionRange {
start: number;
end: number;
}
interface MessageMention {
kind: MessageMentionKind;
/** Canonical target id. For users this is userId, for channels channelId, for servers serverId. */
targetId: string;
/** Canonical text persisted in message content, e.g. <@userId>, <#channelId>. */
token: string;
/** Optional display text selected or typed by the sender before canonicalization. */
sourceToken?: string;
/** Human-readable label used by renderers. */
label: string;
/** Optional source range in content. Clients may omit it; servers may recompute later. */
range?: MessageMentionRange;
serverId?: string;
serverSlug?: string | null;
serverName?: string | null;
channelId?: string;
channelName?: string | null;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
userId?: string;
username?: string | null;
displayName?: string | null;
avatarUrl?: string | null;
isBot?: boolean;
isPrivate?: boolean;
}
declare const MESSAGE_COPILOT_CONTEXT_METADATA_KEY: "copilotContext";
interface MessageCopilotContext {
kind: 'server_app_copilot';
/** Server app install id when the current surface is an installed server app. */
serverAppId?: string | null;
/** Catalog app id when available. */
appId?: string | null;
/** Stable app key from the app route, e.g. kanban. */
appKey: string;
appName?: string | null;
serverId?: string | null;
serverSlug?: string | null;
/** Channel or Inbox currently opened in the Copilot panel. */
channelId?: string | null;
channelKind?: string | null;
}
declare function isMessageCopilotContext(value: unknown): value is MessageCopilotContext;
declare function buildMessageCopilotContextMetadata(context: MessageCopilotContext | null | undefined): {
copilotContext: MessageCopilotContext;
} | undefined;
interface MessageMetadata {
mentions?: MessageMention[];
copilotContext?: MessageCopilotContext;
collaboration?: {
id: string;
rootMessageId: string;
buddyId: string;
turn: number;
target?: 'main' | 'thread';
threadId?: string;
suggestedTextLimit?: number;
replyDensity?: 'reaction' | 'short' | 'normal' | 'long';
};
interactive?: Record<string, unknown>;
interactiveResponse?: Record<string, unknown>;
interactiveState?: Record<string, unknown>;
/** Unified card protocol. New card-like message surfaces must use this field. */
cards?: MessageCard[];
/**
* @deprecated Compatibility-only commerce card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
commerceCards?: CommerceMessageCard[];
/**
* @deprecated Compatibility-only paid-file delivery card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
paidFileCards?: PaidFileCard[];
/**
* @deprecated Compatibility-only OAuth link card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
oauthLinkCards?: OAuthLinkCard[];
[key: string]: unknown;
}
type MessageCardStatus = 'queued' | 'claimed' | 'running' | 'completed' | 'failed' | 'canceled' | 'transferred';
interface MessageCardSource {
kind: 'user' | 'pat' | 'oauth' | 'agent' | 'system' | 'server_app' | 'buddy';
id?: string;
label?: string;
userId?: string;
agentId?: string;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
serverId?: string;
channelId?: string;
command?: string;
resource?: {
kind: string;
id: string;
label?: string;
url?: string;
[key: string]: unknown;
};
[key: string]: unknown;
}
type TaskMessageCardTag = string | {
id?: string;
label: string;
color?: string;
[key: string]: unknown;
};
interface MessageCardApp {
id?: string;
appId?: string;
appKey?: string;
name?: string | null;
label?: string | null;
iconUrl?: string | null;
logoUrl?: string | null;
avatarUrl?: string | null;
imageUrl?: string | null;
url?: string | null;
[key: string]: unknown;
}
interface TaskMessageCardReply {
id?: string;
messageId?: string;
cardId?: string;
authorId?: string;
authorLabel?: string;
authorAvatarUrl?: string | null;
content: string;
createdAt: string;
source?: MessageCardSource;
[key: string]: unknown;
}
interface MessageCardClaim {
id: string;
actor: MessageCardSource;
claimedAt: string;
expiresAt: string;
}
interface MessageCardCapability {
kind: 'task';
scope: string[];
issuedAt: string;
expiresAt: string;
claimId?: string;
binding?: {
messageId?: string;
cardId: string;
workspaceId?: string;
};
}
interface TaskMessageRequirementSkill {
kind: 'runtime-skill';
package: string;
version?: string;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageRequirementTool {
kind: string;
name: string;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageRequirements {
capabilities?: string[];
skills?: TaskMessageRequirementSkill[];
tools?: TaskMessageRequirementTool[];
[key: string]: unknown;
}
interface TaskMessageExpectedArtifact {
kind: string;
mimeTypes?: string[];
maxBytes?: number;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageSubmitCommand {
appKey: string;
command: string;
[key: string]: unknown;
}
interface TaskMessageOutputContract {
expectedArtifacts?: TaskMessageExpectedArtifact[];
submitCommand?: TaskMessageSubmitCommand;
[key: string]: unknown;
}
type TaskMessagePrivacyDataClass = 'public' | 'server-private' | 'channel-private' | 'financial' | 'secret' | 'cloud-secret';
interface TaskMessagePrivacy {
dataClass: TaskMessagePrivacyDataClass;
redactionRequired?: boolean;
[key: string]: unknown;
}
interface TaskMessageCard {
id: string;
kind: 'task';
version: number;
title: string;
body?: string;
status: MessageCardStatus;
priority?: 'low' | 'normal' | 'medium' | 'high';
tags?: TaskMessageCardTag[];
app?: MessageCardApp;
assignee?: {
agentId?: string;
userId?: string;
label?: string;
[key: string]: unknown;
};
source?: MessageCardSource;
requirements?: TaskMessageRequirements;
outputContract?: TaskMessageOutputContract;
privacy?: TaskMessagePrivacy;
claim?: MessageCardClaim;
capability?: MessageCardCapability;
progress?: Array<{
at: string;
status: MessageCardStatus;
note?: string;
actor?: MessageCardSource;
[key: string]: unknown;
}>;
replies?: TaskMessageCardReply[];
createdAt: string;
updatedAt?: string;
data?: Record<string, unknown> & {
task?: {
workspaceId?: string;
[key: string]: unknown;
};
};
[key: string]: unknown;
}
type GenericMessageCard = {
id?: string;
kind: string;
version?: number;
title?: string;
data?: Record<string, unknown>;
[key: string]: unknown;
};
interface ServerAppMessageCard {
id?: string;
kind: 'server_app';
version?: number;
appKey: string;
title: string;
description?: string;
label?: string;
action?: {
mode: 'open_app';
path?: string;
};
data?: Record<string, unknown>;
[key: string]: unknown;
}
interface MessageReferenceCard {
id?: string;
kind: 'message_reference';
version?: number;
title: string;
description?: string;
label?: string;
target: {
serverId?: string | null;
serverSlug?: string | null;
channelId: string;
messageId: string;
taskCardId?: string | null;
inboxAgentId?: string | null;
kind?: 'channel_message' | 'inbox_message';
};
source?: MessageCardSource;
data?: Record<string, unknown>;
[key: string]: unknown;
}
type MessageCard = TaskMessageCard | ServerAppMessageCard | MessageReferenceCard | GenericMessageCard;
interface CommerceOfferCardInput {
id?: string;
kind: 'offer';
offerId: string;
}
type CommerceMessageCard = CommerceProductCard | CommerceOfferCardInput;
interface CommerceProductCard {
id: string;
kind: 'offer' | 'product';
offerId?: string;
shopId: string;
shopScope: {
kind: 'server' | 'user';
id: string;
};
productId: string;
skuId?: string;
snapshot: {
name: string;
summary?: string | null;
imageUrl?: string | null;
shopName?: string | null;
deliveryPromise?: string | null;
price: number;
currency: string;
productType: 'physical' | 'entitlement';
billingMode?: 'one_time' | 'fixed_duration' | 'subscription';
durationSeconds?: number | null;
resourceType?: string;
resourceId?: string;
capability?: string;
};
purchase: {
mode: 'direct' | 'select_sku' | 'open_detail';
};
}
interface PaidFileCard {
id: string;
kind: 'paid_file';
fileId: string;
entitlementId?: string | null;
deliverableId?: string;
snapshot: {
name: string;
summary?: string | null;
mime?: string | null;
sizeBytes?: number | null;
previewUrl?: string | null;
};
action: {
mode: 'open_paid_file';
};
}
interface OAuthLinkCard {
id: string;
kind: 'oauth_link';
appId: string;
clientId?: string | null;
title: string;
description?: string | null;
iconUrl?: string | null;
meta?: {
appName?: string | null;
avatarUrl?: string | null;
iconUrl?: string | null;
coverUrl?: string | null;
homepageUrl?: string | null;
origin?: string | null;
};
url: string;
embedUrl?: string | null;
fallbackUrl?: string | null;
scopes?: string[];
action: {
mode: 'open_iframe' | 'open_external';
};
}
type MentionSuggestionTrigger = '@' | '#';
interface MentionSuggestion {
id: string;
kind: MessageMentionKind;
targetId: string;
token: string;
label: string;
description?: string | null;
serverId?: string;
serverSlug?: string | null;
serverName?: string | null;
channelId?: string;
channelName?: string | null;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
userId?: string;
username?: string | null;
displayName?: string | null;
avatarUrl?: string | null;
isBot?: boolean;
isPrivate?: boolean;
}
interface Attachment {
id: string;
messageId: string;
filename: string;
url: string;
contentType: string;
size: number;
width: number | null;
height: number | null;
workspaceNodeId?: string | null;
kind?: 'file' | 'image' | 'voice';
durationMs?: number | null;
audioCodec?: string | null;
audioContainer?: string | null;
waveformPeaks?: number[] | null;
waveformVersion?: number | null;
transcript?: {
id: string;
status: 'pending' | 'processing' | 'ready' | 'failed';
text: string | null;
language: string | null;
source: 'client' | 'server' | 'runtime';
provider?: string | null;
confidence?: number | null;
errorCode?: string | null;
updatedAt?: string;
} | null;
playback?: {
played: boolean;
completed: boolean;
lastPositionMs: number;
playedCount?: number;
} | null;
createdAt: string;
}
interface ReactionGroup {
emoji: string;
count: number;
userIds: string[];
}
interface Thread {
id: string;
name: string;
channelId: string;
parentMessageId: string;
creatorId: string;
isArchived: boolean;
createdAt: string;
updatedAt: string;
}
interface SendMessageRequest {
content: string;
threadId?: string;
replyToId?: string;
mentions?: MessageMention[];
metadata?: MessageMetadata;
}
interface UpdateMessageRequest {
content: string;
}
type NotificationType = 'mention' | 'reply' | 'dm' | 'system';
interface Notification {
id: string;
userId: string;
type: NotificationType;
title: string;
body: string | null;
referenceId: string | null;
referenceType: string | null;
isRead: boolean;
createdAt: string;
}
export { type Attachment as A, type TaskMessageRequirementTool as B, type CommerceMessageCard as C, type TaskMessageRequirements as D, type TaskMessageSubmitCommand as E, type Thread as F, type GenericMessageCard as G, buildMessageCopilotContextMetadata as H, isMessageCopilotContext as I, MESSAGE_COPILOT_CONTEXT_METADATA_KEY as M, type Notification as N, type OAuthLinkCard as O, type PaidFileCard as P, type ReactionGroup as R, type SendMessageRequest as S, type TaskMessageCard as T, type UpdateMessageRequest as U, type CommerceOfferCardInput as a, type CommerceProductCard as b, type MentionSuggestion as c, type MentionSuggestionTrigger as d, type Message as e, type MessageCard as f, type MessageCardApp as g, type MessageCardCapability as h, type MessageCardClaim as i, type MessageCardSource as j, type MessageCardStatus as k, type MessageCopilotContext as l, type MessageMention as m, type MessageMentionKind as n, type MessageMentionRange as o, type MessageMetadata as p, type MessageReferenceCard as q, type NotificationType as r, type ServerAppMessageCard as s, type TaskMessageCardReply as t, type TaskMessageCardTag as u, type TaskMessageExpectedArtifact as v, type TaskMessageOutputContract as w, type TaskMessagePrivacy as x, type TaskMessagePrivacyDataClass as y, type TaskMessageRequirementSkill as z };
interface Message {
id: string;
content: string;
channelId: string;
authorId: string;
threadId: string | null;
replyToId: string | null;
isEdited: boolean;
isPinned: boolean;
createdAt: string;
updatedAt: string;
author?: {
id: string;
username: string;
displayName: string;
avatarUrl: string | null;
isBot: boolean;
};
attachments?: Attachment[];
reactions?: ReactionGroup[];
metadata?: MessageMetadata | null;
}
type MessageMentionKind = 'user' | 'buddy' | 'app' | 'channel' | 'server' | 'here' | 'everyone';
interface MessageMentionRange {
start: number;
end: number;
}
interface MessageMention {
kind: MessageMentionKind;
/** Canonical target id. For users this is userId, for channels channelId, for servers serverId. */
targetId: string;
/** Canonical text persisted in message content, e.g. <@userId>, <#channelId>. */
token: string;
/** Optional display text selected or typed by the sender before canonicalization. */
sourceToken?: string;
/** Human-readable label used by renderers. */
label: string;
/** Optional source range in content. Clients may omit it; servers may recompute later. */
range?: MessageMentionRange;
serverId?: string;
serverSlug?: string | null;
serverName?: string | null;
channelId?: string;
channelName?: string | null;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
userId?: string;
username?: string | null;
displayName?: string | null;
avatarUrl?: string | null;
isBot?: boolean;
isPrivate?: boolean;
}
declare const MESSAGE_COPILOT_CONTEXT_METADATA_KEY: "copilotContext";
interface MessageCopilotContext {
kind: 'server_app_copilot';
/** Server app install id when the current surface is an installed server app. */
serverAppId?: string | null;
/** Catalog app id when available. */
appId?: string | null;
/** Stable app key from the app route, e.g. kanban. */
appKey: string;
appName?: string | null;
serverId?: string | null;
serverSlug?: string | null;
/** Channel or Inbox currently opened in the Copilot panel. */
channelId?: string | null;
channelKind?: string | null;
}
declare function isMessageCopilotContext(value: unknown): value is MessageCopilotContext;
declare function buildMessageCopilotContextMetadata(context: MessageCopilotContext | null | undefined): {
copilotContext: MessageCopilotContext;
} | undefined;
interface MessageMetadata {
mentions?: MessageMention[];
copilotContext?: MessageCopilotContext;
collaboration?: {
id: string;
rootMessageId: string;
buddyId: string;
turn: number;
target?: 'main' | 'thread';
threadId?: string;
suggestedTextLimit?: number;
replyDensity?: 'reaction' | 'short' | 'normal' | 'long';
};
interactive?: Record<string, unknown>;
interactiveResponse?: Record<string, unknown>;
interactiveState?: Record<string, unknown>;
/** Unified card protocol. New card-like message surfaces must use this field. */
cards?: MessageCard[];
/**
* @deprecated Compatibility-only commerce card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
commerceCards?: CommerceMessageCard[];
/**
* @deprecated Compatibility-only paid-file delivery card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
paidFileCards?: PaidFileCard[];
/**
* @deprecated Compatibility-only OAuth link card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
oauthLinkCards?: OAuthLinkCard[];
[key: string]: unknown;
}
type MessageCardStatus = 'queued' | 'claimed' | 'running' | 'completed' | 'failed' | 'canceled' | 'transferred';
interface MessageCardSource {
kind: 'user' | 'pat' | 'oauth' | 'agent' | 'system' | 'server_app' | 'buddy';
id?: string;
label?: string;
userId?: string;
agentId?: string;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
serverId?: string;
channelId?: string;
command?: string;
resource?: {
kind: string;
id: string;
label?: string;
url?: string;
[key: string]: unknown;
};
[key: string]: unknown;
}
type TaskMessageCardTag = string | {
id?: string;
label: string;
color?: string;
[key: string]: unknown;
};
interface MessageCardApp {
id?: string;
appId?: string;
appKey?: string;
name?: string | null;
label?: string | null;
iconUrl?: string | null;
logoUrl?: string | null;
avatarUrl?: string | null;
imageUrl?: string | null;
url?: string | null;
[key: string]: unknown;
}
interface TaskMessageCardReply {
id?: string;
messageId?: string;
cardId?: string;
authorId?: string;
authorLabel?: string;
authorAvatarUrl?: string | null;
content: string;
createdAt: string;
source?: MessageCardSource;
[key: string]: unknown;
}
interface MessageCardClaim {
id: string;
actor: MessageCardSource;
claimedAt: string;
expiresAt: string;
}
interface MessageCardCapability {
kind: 'task';
scope: string[];
issuedAt: string;
expiresAt: string;
claimId?: string;
binding?: {
messageId?: string;
cardId: string;
workspaceId?: string;
};
}
interface TaskMessageRequirementSkill {
kind: 'runtime-skill';
package: string;
version?: string;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageRequirementTool {
kind: string;
name: string;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageRequirements {
capabilities?: string[];
skills?: TaskMessageRequirementSkill[];
tools?: TaskMessageRequirementTool[];
[key: string]: unknown;
}
interface TaskMessageExpectedArtifact {
kind: string;
mimeTypes?: string[];
maxBytes?: number;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageSubmitCommand {
appKey: string;
command: string;
[key: string]: unknown;
}
interface TaskMessageOutputContract {
expectedArtifacts?: TaskMessageExpectedArtifact[];
submitCommand?: TaskMessageSubmitCommand;
[key: string]: unknown;
}
type TaskMessagePrivacyDataClass = 'public' | 'server-private' | 'channel-private' | 'financial' | 'secret' | 'cloud-secret';
interface TaskMessagePrivacy {
dataClass: TaskMessagePrivacyDataClass;
redactionRequired?: boolean;
[key: string]: unknown;
}
interface TaskMessageCard {
id: string;
kind: 'task';
version: number;
title: string;
body?: string;
status: MessageCardStatus;
priority?: 'low' | 'normal' | 'medium' | 'high';
tags?: TaskMessageCardTag[];
app?: MessageCardApp;
assignee?: {
agentId?: string;
userId?: string;
label?: string;
[key: string]: unknown;
};
source?: MessageCardSource;
requirements?: TaskMessageRequirements;
outputContract?: TaskMessageOutputContract;
privacy?: TaskMessagePrivacy;
claim?: MessageCardClaim;
capability?: MessageCardCapability;
progress?: Array<{
at: string;
status: MessageCardStatus;
note?: string;
actor?: MessageCardSource;
[key: string]: unknown;
}>;
replies?: TaskMessageCardReply[];
createdAt: string;
updatedAt?: string;
data?: Record<string, unknown> & {
task?: {
workspaceId?: string;
[key: string]: unknown;
};
};
[key: string]: unknown;
}
type GenericMessageCard = {
id?: string;
kind: string;
version?: number;
title?: string;
data?: Record<string, unknown>;
[key: string]: unknown;
};
interface ServerAppMessageCard {
id?: string;
kind: 'server_app';
version?: number;
appKey: string;
title: string;
description?: string;
label?: string;
action?: {
mode: 'open_app';
path?: string;
};
data?: Record<string, unknown>;
[key: string]: unknown;
}
interface MessageReferenceCard {
id?: string;
kind: 'message_reference';
version?: number;
title: string;
description?: string;
label?: string;
target: {
serverId?: string | null;
serverSlug?: string | null;
channelId: string;
messageId: string;
taskCardId?: string | null;
inboxAgentId?: string | null;
kind?: 'channel_message' | 'inbox_message';
};
source?: MessageCardSource;
data?: Record<string, unknown>;
[key: string]: unknown;
}
type MessageCard = TaskMessageCard | ServerAppMessageCard | MessageReferenceCard | GenericMessageCard;
interface CommerceOfferCardInput {
id?: string;
kind: 'offer';
offerId: string;
}
type CommerceMessageCard = CommerceProductCard | CommerceOfferCardInput;
interface CommerceProductCard {
id: string;
kind: 'offer' | 'product';
offerId?: string;
shopId: string;
shopScope: {
kind: 'server' | 'user';
id: string;
};
productId: string;
skuId?: string;
snapshot: {
name: string;
summary?: string | null;
imageUrl?: string | null;
shopName?: string | null;
deliveryPromise?: string | null;
price: number;
currency: string;
productType: 'physical' | 'entitlement';
billingMode?: 'one_time' | 'fixed_duration' | 'subscription';
durationSeconds?: number | null;
resourceType?: string;
resourceId?: string;
capability?: string;
};
purchase: {
mode: 'direct' | 'select_sku' | 'open_detail';
};
}
interface PaidFileCard {
id: string;
kind: 'paid_file';
fileId: string;
entitlementId?: string | null;
deliverableId?: string;
snapshot: {
name: string;
summary?: string | null;
mime?: string | null;
sizeBytes?: number | null;
previewUrl?: string | null;
};
action: {
mode: 'open_paid_file';
};
}
interface OAuthLinkCard {
id: string;
kind: 'oauth_link';
appId: string;
clientId?: string | null;
title: string;
description?: string | null;
iconUrl?: string | null;
meta?: {
appName?: string | null;
avatarUrl?: string | null;
iconUrl?: string | null;
coverUrl?: string | null;
homepageUrl?: string | null;
origin?: string | null;
};
url: string;
embedUrl?: string | null;
fallbackUrl?: string | null;
scopes?: string[];
action: {
mode: 'open_iframe' | 'open_external';
};
}
type MentionSuggestionTrigger = '@' | '#';
interface MentionSuggestion {
id: string;
kind: MessageMentionKind;
targetId: string;
token: string;
label: string;
description?: string | null;
serverId?: string;
serverSlug?: string | null;
serverName?: string | null;
channelId?: string;
channelName?: string | null;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
userId?: string;
username?: string | null;
displayName?: string | null;
avatarUrl?: string | null;
isBot?: boolean;
isPrivate?: boolean;
}
interface Attachment {
id: string;
messageId: string;
filename: string;
url: string;
contentType: string;
size: number;
width: number | null;
height: number | null;
workspaceNodeId?: string | null;
kind?: 'file' | 'image' | 'voice';
durationMs?: number | null;
audioCodec?: string | null;
audioContainer?: string | null;
waveformPeaks?: number[] | null;
waveformVersion?: number | null;
transcript?: {
id: string;
status: 'pending' | 'processing' | 'ready' | 'failed';
text: string | null;
language: string | null;
source: 'client' | 'server' | 'runtime';
provider?: string | null;
confidence?: number | null;
errorCode?: string | null;
updatedAt?: string;
} | null;
playback?: {
played: boolean;
completed: boolean;
lastPositionMs: number;
playedCount?: number;
} | null;
createdAt: string;
}
interface ReactionGroup {
emoji: string;
count: number;
userIds: string[];
}
interface Thread {
id: string;
name: string;
channelId: string;
parentMessageId: string;
creatorId: string;
isArchived: boolean;
createdAt: string;
updatedAt: string;
}
interface SendMessageRequest {
content: string;
threadId?: string;
replyToId?: string;
mentions?: MessageMention[];
metadata?: MessageMetadata;
}
interface UpdateMessageRequest {
content: string;
}
type NotificationType = 'mention' | 'reply' | 'dm' | 'system';
interface Notification {
id: string;
userId: string;
type: NotificationType;
title: string;
body: string | null;
referenceId: string | null;
referenceType: string | null;
isRead: boolean;
createdAt: string;
}
export { type Attachment as A, type TaskMessageRequirementTool as B, type CommerceMessageCard as C, type TaskMessageRequirements as D, type TaskMessageSubmitCommand as E, type Thread as F, type GenericMessageCard as G, buildMessageCopilotContextMetadata as H, isMessageCopilotContext as I, MESSAGE_COPILOT_CONTEXT_METADATA_KEY as M, type Notification as N, type OAuthLinkCard as O, type PaidFileCard as P, type ReactionGroup as R, type SendMessageRequest as S, type TaskMessageCard as T, type UpdateMessageRequest as U, type CommerceOfferCardInput as a, type CommerceProductCard as b, type MentionSuggestion as c, type MentionSuggestionTrigger as d, type Message as e, type MessageCard as f, type MessageCardApp as g, type MessageCardCapability as h, type MessageCardClaim as i, type MessageCardSource as j, type MessageCardStatus as k, type MessageCopilotContext as l, type MessageMention as m, type MessageMentionKind as n, type MessageMentionRange as o, type MessageMetadata as p, type MessageReferenceCard as q, type NotificationType as r, type ServerAppMessageCard as s, type TaskMessageCardReply as t, type TaskMessageCardTag as u, type TaskMessageExpectedArtifact as v, type TaskMessageOutputContract as w, type TaskMessagePrivacy as x, type TaskMessagePrivacyDataClass as y, type TaskMessageRequirementSkill as z };
+1
-1

@@ -5,4 +5,4 @@ export { CLIENT_EVENTS, ClientEvent, LIMITS, SERVER_EVENTS, ServerEvent } from './constants/index.cjs';

export { Agent, AgentCapability, AgentInfo, AgentKernelType, AgentStatus, AuthResponse, BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS, BUDDY_INBOX_DELIVERY_PERMISSION, BUDDY_INBOX_PLATFORM_PERMISSIONS, BUDDY_INBOX_TOPIC_PREFIX, BUDDY_PRESENCE_STATUSES, BuddyInboxAdmissionMode, BuddyInboxAdmissionPendingDelivery, BuddyInboxAdmissionPendingTask, BuddyInboxAdmissionPolicy, BuddyInboxAdmissionRule, BuddyInboxAdmissionSubjectKind, BuddyInboxPlatformPermission, BuddyInboxTaskFilter, BuddyInboxViewMessage, BuddyInboxViewMode, BuddyPresenceStatus, Channel, ChannelSortBy, ChannelSortDirection, ChannelSortOptions, ChannelType, CreateAgentRequest, CreateChannelRequest, CreateServerRequest, DEFAULT_BUDDY_INBOX_ADMISSION_POLICY, FriendEntry, FriendSource, Friendship, FriendshipStatus, LoginRequest, Member, MemberRole, RUNTIME_SESSION_PET_REACTION_BY_STATE, RegisterRequest, RuntimeSessionAnimationSignal, RuntimeSessionPetActivity, RuntimeSessionPetActivityKind, RuntimeSessionPetReaction, RuntimeSessionState, Server, TASK_MESSAGE_CARD_STATUSES, TASK_MESSAGE_CARD_STATUS_TRANSITIONS, TERMINAL_TASK_MESSAGE_CARD_STATUSES, USER_STATUSES, UpdateChannelRequest, UpdateServerRequest, User, UserMembership, UserMembershipTier, UserProfile, UserStatus, VoiceChannelCredentials, VoiceChannelJoinResult, VoiceChannelLeaveResult, VoiceChannelPolicy, VoiceChannelState, VoiceParticipant, buddyInboxAdmissionRuleKey, buddyInboxMessageMatchesTaskFilter, buddyInboxTopic, buildBuddyInboxViewMessages, canTransitionTaskMessageCardStatus, getBuddyInboxTaskCards, getBuddyInboxTaskMessageIds, getBuddyInboxTaskStatuses, hasBuddyInboxTaskCard, isBuddyHeartbeatActive, isBuddyInboxPlatformPermission, isBuddyInboxTaskReply, isBuddyInboxTopic, isMessageReferenceCard, isTaskMessageCardStatus, isTaskReplyNotificationCard, isTerminalTaskMessageCardStatus, normalizeBuddyInboxAdmissionPendingDeliveries, normalizeBuddyInboxAdmissionPolicy, normalizeBuddyPresenceStatus, normalizeBuddyRuntimePresenceStatus, normalizeUserStatus, parseBuddyInboxAgentId, runtimeSessionPetReactionForState, runtimeSessionSignalToPetReaction, runtimeSessionStateLooksActive } from './types/index.cjs';
export { A as Attachment, C as CommerceMessageCard, a as CommerceOfferCardInput, b as CommerceProductCard, G as GenericMessageCard, M as MESSAGE_COPILOT_CONTEXT_METADATA_KEY, c as MentionSuggestion, d as MentionSuggestionTrigger, e as Message, f as MessageCard, g as MessageCardApp, h as MessageCardCapability, i as MessageCardClaim, j as MessageCardSource, k as MessageCardStatus, l as MessageCopilotContext, m as MessageMention, n as MessageMentionKind, o as MessageMentionRange, p as MessageMetadata, q as MessageReferenceCard, N as Notification, r as NotificationType, O as OAuthLinkCard, P as PaidFileCard, R as ReactionGroup, S as SendMessageRequest, s as ServerAppMessageCard, T as TaskMessageCard, t as TaskMessageCardReply, u as TaskMessageCardTag, v as TaskMessageExpectedArtifact, w as TaskMessageOutputContract, x as TaskMessagePrivacy, y as TaskMessagePrivacyDataClass, z as TaskMessageRequirementSkill, B as TaskMessageRequirementTool, D as TaskMessageRequirements, E as TaskMessageSubmitCommand, F as Thread, U as UpdateMessageRequest, H as buildMessageCopilotContextMetadata, I as isMessageCopilotContext } from './message.types-CEpYjGEy.cjs';
export { A as Attachment, C as CommerceMessageCard, a as CommerceOfferCardInput, b as CommerceProductCard, G as GenericMessageCard, M as MESSAGE_COPILOT_CONTEXT_METADATA_KEY, c as MentionSuggestion, d as MentionSuggestionTrigger, e as Message, f as MessageCard, g as MessageCardApp, h as MessageCardCapability, i as MessageCardClaim, j as MessageCardSource, k as MessageCardStatus, l as MessageCopilotContext, m as MessageMention, n as MessageMentionKind, o as MessageMentionRange, p as MessageMetadata, q as MessageReferenceCard, N as Notification, r as NotificationType, O as OAuthLinkCard, P as PaidFileCard, R as ReactionGroup, S as SendMessageRequest, s as ServerAppMessageCard, T as TaskMessageCard, t as TaskMessageCardReply, u as TaskMessageCardTag, v as TaskMessageExpectedArtifact, w as TaskMessageOutputContract, x as TaskMessagePrivacy, y as TaskMessagePrivacyDataClass, z as TaskMessageRequirementSkill, B as TaskMessageRequirementTool, D as TaskMessageRequirements, E as TaskMessageSubmitCommand, F as Thread, U as UpdateMessageRequest, H as buildMessageCopilotContextMetadata, I as isMessageCopilotContext } from './message.types-CQX9uQpa.cjs';
export { BgPattern, CAT_AVATAR_COUNT, CatConfig, CatDecoration, CatExpression, CatPattern, MessageMentionTextSegment, SlashCommandAction, assignMentionRanges, buildMentionMarkdownLinks, canonicalMentionToken, canonicalizeMentionContent, escapeMarkdownLinkLabel, extractSlashCommandActions, formatDate, generateInviteCode, generateRandomCatConfig, getAllCatAvatars, getCatAvatar, getCatAvatarByUserId, getCatSvgString, isCanonicalMentionToken, isValidEmail, mentionDisplayText, parseCanonicalMentionToken, renderCatSvg, segmentTextByMentions, slugify } from './utils/index.cjs';
import 'zod';

@@ -5,4 +5,4 @@ export { CLIENT_EVENTS, ClientEvent, LIMITS, SERVER_EVENTS, ServerEvent } from './constants/index.js';

export { Agent, AgentCapability, AgentInfo, AgentKernelType, AgentStatus, AuthResponse, BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS, BUDDY_INBOX_DELIVERY_PERMISSION, BUDDY_INBOX_PLATFORM_PERMISSIONS, BUDDY_INBOX_TOPIC_PREFIX, BUDDY_PRESENCE_STATUSES, BuddyInboxAdmissionMode, BuddyInboxAdmissionPendingDelivery, BuddyInboxAdmissionPendingTask, BuddyInboxAdmissionPolicy, BuddyInboxAdmissionRule, BuddyInboxAdmissionSubjectKind, BuddyInboxPlatformPermission, BuddyInboxTaskFilter, BuddyInboxViewMessage, BuddyInboxViewMode, BuddyPresenceStatus, Channel, ChannelSortBy, ChannelSortDirection, ChannelSortOptions, ChannelType, CreateAgentRequest, CreateChannelRequest, CreateServerRequest, DEFAULT_BUDDY_INBOX_ADMISSION_POLICY, FriendEntry, FriendSource, Friendship, FriendshipStatus, LoginRequest, Member, MemberRole, RUNTIME_SESSION_PET_REACTION_BY_STATE, RegisterRequest, RuntimeSessionAnimationSignal, RuntimeSessionPetActivity, RuntimeSessionPetActivityKind, RuntimeSessionPetReaction, RuntimeSessionState, Server, TASK_MESSAGE_CARD_STATUSES, TASK_MESSAGE_CARD_STATUS_TRANSITIONS, TERMINAL_TASK_MESSAGE_CARD_STATUSES, USER_STATUSES, UpdateChannelRequest, UpdateServerRequest, User, UserMembership, UserMembershipTier, UserProfile, UserStatus, VoiceChannelCredentials, VoiceChannelJoinResult, VoiceChannelLeaveResult, VoiceChannelPolicy, VoiceChannelState, VoiceParticipant, buddyInboxAdmissionRuleKey, buddyInboxMessageMatchesTaskFilter, buddyInboxTopic, buildBuddyInboxViewMessages, canTransitionTaskMessageCardStatus, getBuddyInboxTaskCards, getBuddyInboxTaskMessageIds, getBuddyInboxTaskStatuses, hasBuddyInboxTaskCard, isBuddyHeartbeatActive, isBuddyInboxPlatformPermission, isBuddyInboxTaskReply, isBuddyInboxTopic, isMessageReferenceCard, isTaskMessageCardStatus, isTaskReplyNotificationCard, isTerminalTaskMessageCardStatus, normalizeBuddyInboxAdmissionPendingDeliveries, normalizeBuddyInboxAdmissionPolicy, normalizeBuddyPresenceStatus, normalizeBuddyRuntimePresenceStatus, normalizeUserStatus, parseBuddyInboxAgentId, runtimeSessionPetReactionForState, runtimeSessionSignalToPetReaction, runtimeSessionStateLooksActive } from './types/index.js';
export { A as Attachment, C as CommerceMessageCard, a as CommerceOfferCardInput, b as CommerceProductCard, G as GenericMessageCard, M as MESSAGE_COPILOT_CONTEXT_METADATA_KEY, c as MentionSuggestion, d as MentionSuggestionTrigger, e as Message, f as MessageCard, g as MessageCardApp, h as MessageCardCapability, i as MessageCardClaim, j as MessageCardSource, k as MessageCardStatus, l as MessageCopilotContext, m as MessageMention, n as MessageMentionKind, o as MessageMentionRange, p as MessageMetadata, q as MessageReferenceCard, N as Notification, r as NotificationType, O as OAuthLinkCard, P as PaidFileCard, R as ReactionGroup, S as SendMessageRequest, s as ServerAppMessageCard, T as TaskMessageCard, t as TaskMessageCardReply, u as TaskMessageCardTag, v as TaskMessageExpectedArtifact, w as TaskMessageOutputContract, x as TaskMessagePrivacy, y as TaskMessagePrivacyDataClass, z as TaskMessageRequirementSkill, B as TaskMessageRequirementTool, D as TaskMessageRequirements, E as TaskMessageSubmitCommand, F as Thread, U as UpdateMessageRequest, H as buildMessageCopilotContextMetadata, I as isMessageCopilotContext } from './message.types-CEpYjGEy.js';
export { A as Attachment, C as CommerceMessageCard, a as CommerceOfferCardInput, b as CommerceProductCard, G as GenericMessageCard, M as MESSAGE_COPILOT_CONTEXT_METADATA_KEY, c as MentionSuggestion, d as MentionSuggestionTrigger, e as Message, f as MessageCard, g as MessageCardApp, h as MessageCardCapability, i as MessageCardClaim, j as MessageCardSource, k as MessageCardStatus, l as MessageCopilotContext, m as MessageMention, n as MessageMentionKind, o as MessageMentionRange, p as MessageMetadata, q as MessageReferenceCard, N as Notification, r as NotificationType, O as OAuthLinkCard, P as PaidFileCard, R as ReactionGroup, S as SendMessageRequest, s as ServerAppMessageCard, T as TaskMessageCard, t as TaskMessageCardReply, u as TaskMessageCardTag, v as TaskMessageExpectedArtifact, w as TaskMessageOutputContract, x as TaskMessagePrivacy, y as TaskMessagePrivacyDataClass, z as TaskMessageRequirementSkill, B as TaskMessageRequirementTool, D as TaskMessageRequirements, E as TaskMessageSubmitCommand, F as Thread, U as UpdateMessageRequest, H as buildMessageCopilotContextMetadata, I as isMessageCopilotContext } from './message.types-CQX9uQpa.js';
export { BgPattern, CAT_AVATAR_COUNT, CatConfig, CatDecoration, CatExpression, CatPattern, MessageMentionTextSegment, SlashCommandAction, assignMentionRanges, buildMentionMarkdownLinks, canonicalMentionToken, canonicalizeMentionContent, escapeMarkdownLinkLabel, extractSlashCommandActions, formatDate, generateInviteCode, generateRandomCatConfig, getAllCatAvatars, getCatAvatar, getCatAvatarByUserId, getCatSvgString, isCanonicalMentionToken, isValidEmail, mentionDisplayText, parseCanonicalMentionToken, renderCatSvg, segmentTextByMentions, slugify } from './utils/index.js';
import 'zod';

@@ -59,2 +59,8 @@ import {

import {
DEFAULT_HOMEPLAY_CATALOG,
getDefaultHomePlay,
getPlayBuddyEmail,
getPlayBuddyUsername
} from "./chunk-KKRZTKE6.js";
import {
BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS,

@@ -100,10 +106,4 @@ BUDDY_INBOX_DELIVERY_PERMISSION,

runtimeSessionStateLooksActive
} from "./chunk-2PV37RNB.js";
} from "./chunk-OSMIYTN4.js";
import {
DEFAULT_HOMEPLAY_CATALOG,
getDefaultHomePlay,
getPlayBuddyEmail,
getPlayBuddyUsername
} from "./chunk-KKRZTKE6.js";
import {
CAT_AVATAR_COUNT,

@@ -110,0 +110,0 @@ assignMentionRanges,

@@ -139,2 +139,6 @@ "use strict";

}
function hasBuddyInboxTaskReplyNotificationCard(message) {
const cards = message.metadata?.cards;
return Array.isArray(cards) && cards.some(isTaskReplyNotificationCard);
}
function getBuddyInboxTaskStatuses(message) {

@@ -161,7 +165,11 @@ return getBuddyInboxTaskCards(message).map((card) => card.status);

function buildBuddyInboxViewMessages(messages, options) {
if (!options.isInboxChannel || options.mode === "chat") return [...messages];
if (!options.isInboxChannel) return [...messages];
const taskMessageIds = getBuddyInboxTaskMessageIds(messages);
return messages.filter(
(message) => !isBuddyInboxTaskReply(message, taskMessageIds) && buddyInboxMessageMatchesTaskFilter(message, options.taskFilter ?? "all")
);
const taskFilter = options.taskFilter ?? "all";
return messages.filter((message) => {
if (isBuddyInboxTaskReply(message, taskMessageIds)) return false;
if (hasBuddyInboxTaskReplyNotificationCard(message)) return false;
if (!hasBuddyInboxTaskCard(message)) return taskFilter === "all";
return buddyInboxMessageMatchesTaskFilter(message, taskFilter);
});
}

@@ -224,3 +232,3 @@ var DEFAULT_BUDDY_INBOX_ADMISSION_POLICY = {

const priority = value.priority;
if (priority !== void 0 && priority !== "low" && priority !== "normal" && priority !== "high" && priority !== "urgent") {
if (priority !== void 0 && priority !== "low" && priority !== "normal" && priority !== "medium" && priority !== "high") {
throw new Error("Invalid Buddy Inbox pending task priority");

@@ -227,0 +235,0 @@ }

@@ -1,3 +0,3 @@

import { j as MessageCardSource, D as TaskMessageRequirements, w as TaskMessageOutputContract, x as TaskMessagePrivacy, p as MessageMetadata, k as MessageCardStatus, T as TaskMessageCard, f as MessageCard, q as MessageReferenceCard } from '../message.types-CEpYjGEy.cjs';
export { A as Attachment, C as CommerceMessageCard, a as CommerceOfferCardInput, b as CommerceProductCard, G as GenericMessageCard, M as MESSAGE_COPILOT_CONTEXT_METADATA_KEY, c as MentionSuggestion, d as MentionSuggestionTrigger, e as Message, g as MessageCardApp, h as MessageCardCapability, i as MessageCardClaim, l as MessageCopilotContext, m as MessageMention, n as MessageMentionKind, o as MessageMentionRange, N as Notification, r as NotificationType, O as OAuthLinkCard, P as PaidFileCard, R as ReactionGroup, S as SendMessageRequest, s as ServerAppMessageCard, t as TaskMessageCardReply, u as TaskMessageCardTag, v as TaskMessageExpectedArtifact, y as TaskMessagePrivacyDataClass, z as TaskMessageRequirementSkill, B as TaskMessageRequirementTool, E as TaskMessageSubmitCommand, F as Thread, U as UpdateMessageRequest, H as buildMessageCopilotContextMetadata, I as isMessageCopilotContext } from '../message.types-CEpYjGEy.cjs';
import { j as MessageCardSource, D as TaskMessageRequirements, w as TaskMessageOutputContract, x as TaskMessagePrivacy, p as MessageMetadata, k as MessageCardStatus, T as TaskMessageCard, f as MessageCard, q as MessageReferenceCard } from '../message.types-CQX9uQpa.cjs';
export { A as Attachment, C as CommerceMessageCard, a as CommerceOfferCardInput, b as CommerceProductCard, G as GenericMessageCard, M as MESSAGE_COPILOT_CONTEXT_METADATA_KEY, c as MentionSuggestion, d as MentionSuggestionTrigger, e as Message, g as MessageCardApp, h as MessageCardCapability, i as MessageCardClaim, l as MessageCopilotContext, m as MessageMention, n as MessageMentionKind, o as MessageMentionRange, N as Notification, r as NotificationType, O as OAuthLinkCard, P as PaidFileCard, R as ReactionGroup, S as SendMessageRequest, s as ServerAppMessageCard, t as TaskMessageCardReply, u as TaskMessageCardTag, v as TaskMessageExpectedArtifact, y as TaskMessagePrivacyDataClass, z as TaskMessageRequirementSkill, B as TaskMessageRequirementTool, E as TaskMessageSubmitCommand, F as Thread, U as UpdateMessageRequest, H as buildMessageCopilotContextMetadata, I as isMessageCopilotContext } from '../message.types-CQX9uQpa.cjs';

@@ -187,3 +187,3 @@ type AgentStatus = 'running' | 'stopped' | 'error';

isInboxChannel: boolean;
mode: BuddyInboxViewMode;
mode?: BuddyInboxViewMode;
taskFilter?: BuddyInboxTaskFilter;

@@ -210,3 +210,3 @@ }): TMessage[];

body?: string;
priority?: 'low' | 'normal' | 'high' | 'urgent';
priority?: 'low' | 'normal' | 'medium' | 'high';
idempotencyKey?: string;

@@ -213,0 +213,0 @@ source?: MessageCardSource;

@@ -1,3 +0,3 @@

import { j as MessageCardSource, D as TaskMessageRequirements, w as TaskMessageOutputContract, x as TaskMessagePrivacy, p as MessageMetadata, k as MessageCardStatus, T as TaskMessageCard, f as MessageCard, q as MessageReferenceCard } from '../message.types-CEpYjGEy.js';
export { A as Attachment, C as CommerceMessageCard, a as CommerceOfferCardInput, b as CommerceProductCard, G as GenericMessageCard, M as MESSAGE_COPILOT_CONTEXT_METADATA_KEY, c as MentionSuggestion, d as MentionSuggestionTrigger, e as Message, g as MessageCardApp, h as MessageCardCapability, i as MessageCardClaim, l as MessageCopilotContext, m as MessageMention, n as MessageMentionKind, o as MessageMentionRange, N as Notification, r as NotificationType, O as OAuthLinkCard, P as PaidFileCard, R as ReactionGroup, S as SendMessageRequest, s as ServerAppMessageCard, t as TaskMessageCardReply, u as TaskMessageCardTag, v as TaskMessageExpectedArtifact, y as TaskMessagePrivacyDataClass, z as TaskMessageRequirementSkill, B as TaskMessageRequirementTool, E as TaskMessageSubmitCommand, F as Thread, U as UpdateMessageRequest, H as buildMessageCopilotContextMetadata, I as isMessageCopilotContext } from '../message.types-CEpYjGEy.js';
import { j as MessageCardSource, D as TaskMessageRequirements, w as TaskMessageOutputContract, x as TaskMessagePrivacy, p as MessageMetadata, k as MessageCardStatus, T as TaskMessageCard, f as MessageCard, q as MessageReferenceCard } from '../message.types-CQX9uQpa.js';
export { A as Attachment, C as CommerceMessageCard, a as CommerceOfferCardInput, b as CommerceProductCard, G as GenericMessageCard, M as MESSAGE_COPILOT_CONTEXT_METADATA_KEY, c as MentionSuggestion, d as MentionSuggestionTrigger, e as Message, g as MessageCardApp, h as MessageCardCapability, i as MessageCardClaim, l as MessageCopilotContext, m as MessageMention, n as MessageMentionKind, o as MessageMentionRange, N as Notification, r as NotificationType, O as OAuthLinkCard, P as PaidFileCard, R as ReactionGroup, S as SendMessageRequest, s as ServerAppMessageCard, t as TaskMessageCardReply, u as TaskMessageCardTag, v as TaskMessageExpectedArtifact, y as TaskMessagePrivacyDataClass, z as TaskMessageRequirementSkill, B as TaskMessageRequirementTool, E as TaskMessageSubmitCommand, F as Thread, U as UpdateMessageRequest, H as buildMessageCopilotContextMetadata, I as isMessageCopilotContext } from '../message.types-CQX9uQpa.js';

@@ -187,3 +187,3 @@ type AgentStatus = 'running' | 'stopped' | 'error';

isInboxChannel: boolean;
mode: BuddyInboxViewMode;
mode?: BuddyInboxViewMode;
taskFilter?: BuddyInboxTaskFilter;

@@ -210,3 +210,3 @@ }): TMessage[];

body?: string;
priority?: 'low' | 'normal' | 'high' | 'urgent';
priority?: 'low' | 'normal' | 'medium' | 'high';
idempotencyKey?: string;

@@ -213,0 +213,0 @@ source?: MessageCardSource;

@@ -42,3 +42,3 @@ import {

runtimeSessionStateLooksActive
} from "../chunk-2PV37RNB.js";
} from "../chunk-OSMIYTN4.js";
export {

@@ -45,0 +45,0 @@ BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS,

@@ -1,2 +0,2 @@

import { o as MessageMentionRange, m as MessageMention } from '../message.types-CEpYjGEy.cjs';
import { o as MessageMentionRange, m as MessageMention } from '../message.types-CQX9uQpa.cjs';

@@ -3,0 +3,0 @@ type CatPattern = 'none' | 'tabby' | 'tuxedo' | 'siamese' | 'calico' | 'bicolor';

@@ -1,2 +0,2 @@

import { o as MessageMentionRange, m as MessageMention } from '../message.types-CEpYjGEy.js';
import { o as MessageMentionRange, m as MessageMention } from '../message.types-CQX9uQpa.js';

@@ -3,0 +3,0 @@ type CatPattern = 'none' | 'tabby' | 'tuxedo' | 'siamese' | 'calico' | 'bicolor';

{
"name": "@shadowob/shared",
"version": "1.1.47",
"version": "1.1.48",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

// src/types/inbox.types.ts
var BUDDY_INBOX_TOPIC_PREFIX = "shadow:buddy-inbox:";
var BUDDY_INBOX_DELIVERY_PERMISSION = "buddy_inbox:deliver";
var BUDDY_INBOX_PLATFORM_PERMISSIONS = [BUDDY_INBOX_DELIVERY_PERMISSION];
function isBuddyInboxPlatformPermission(value) {
return typeof value === "string" && BUDDY_INBOX_PLATFORM_PERMISSIONS.includes(value);
}
function buddyInboxTopic(agentId) {
return `${BUDDY_INBOX_TOPIC_PREFIX}${agentId}`;
}
function parseBuddyInboxAgentId(topic) {
if (!topic?.startsWith(BUDDY_INBOX_TOPIC_PREFIX)) return null;
const agentId = topic.slice(BUDDY_INBOX_TOPIC_PREFIX.length).trim();
return agentId || null;
}
function isBuddyInboxTopic(topic) {
return parseBuddyInboxAgentId(topic) !== null;
}
var TASK_MESSAGE_CARD_STATUSES = [
"queued",
"claimed",
"running",
"completed",
"failed",
"canceled",
"transferred"
];
var TERMINAL_TASK_MESSAGE_CARD_STATUSES = [
"completed",
"failed",
"canceled",
"transferred"
];
var TASK_MESSAGE_CARD_STATUS_TRANSITIONS = {
queued: ["queued", "claimed", "running", "completed", "failed", "canceled"],
claimed: ["claimed", "running", "completed", "failed", "canceled"],
running: ["running", "completed", "failed", "canceled"],
completed: ["completed"],
failed: ["failed", "transferred"],
canceled: ["canceled"],
transferred: ["transferred"]
};
function isTerminalTaskMessageCardStatus(status) {
return TERMINAL_TASK_MESSAGE_CARD_STATUSES.includes(
status
);
}
function isTaskMessageCardStatus(value) {
return typeof value === "string" && TASK_MESSAGE_CARD_STATUSES.includes(value);
}
function canTransitionTaskMessageCardStatus(from, to) {
const allowed = TASK_MESSAGE_CARD_STATUS_TRANSITIONS[from];
return allowed.includes(to);
}
function isRecord(value) {
return !!value && typeof value === "object" && !Array.isArray(value);
}
function isTaskReplyNotificationCard(card) {
return isRecord(card.data) && card.data.taskReplyNotification === true;
}
function isMessageReferenceCard(card) {
return card?.kind === "message_reference" && typeof card.title === "string" && isRecord(card.target) && typeof card.target.channelId === "string" && typeof card.target.messageId === "string";
}
function getBuddyInboxTaskCards(message) {
const cards = message.metadata?.cards;
if (!Array.isArray(cards)) return [];
return cards.filter(
(card) => card?.kind === "task" && typeof card.id === "string" && isTaskMessageCardStatus(card.status) && !isTaskReplyNotificationCard(card)
);
}
function hasBuddyInboxTaskCard(message) {
return getBuddyInboxTaskCards(message).length > 0;
}
function getBuddyInboxTaskStatuses(message) {
return getBuddyInboxTaskCards(message).map((card) => card.status);
}
function buddyInboxMessageMatchesTaskFilter(message, filter) {
const statuses = getBuddyInboxTaskStatuses(message);
if (statuses.length === 0) return false;
if (filter === "all") return true;
if (filter === "done") return statuses.every((status) => isTerminalTaskMessageCardStatus(status));
return statuses.some((status) => !isTerminalTaskMessageCardStatus(status));
}
function getBuddyInboxTaskMessageIds(messages) {
const ids = /* @__PURE__ */ new Set();
for (const message of messages) {
if (hasBuddyInboxTaskCard(message)) ids.add(message.id);
}
return ids;
}
function isBuddyInboxTaskReply(message, taskMessageIds) {
return Boolean(message.replyToId && taskMessageIds.has(message.replyToId));
}
function buildBuddyInboxViewMessages(messages, options) {
if (!options.isInboxChannel || options.mode === "chat") return [...messages];
const taskMessageIds = getBuddyInboxTaskMessageIds(messages);
return messages.filter(
(message) => !isBuddyInboxTaskReply(message, taskMessageIds) && buddyInboxMessageMatchesTaskFilter(message, options.taskFilter ?? "all")
);
}
var DEFAULT_BUDDY_INBOX_ADMISSION_POLICY = {
defaultMode: "allow",
rules: []
};
function parseAdmissionMode(value, fallback) {
if (value === "allow" || value === "deny" || value === "first_time" || value === "every_time") {
return value;
}
if (value === void 0 || value === null) return fallback;
throw new Error("Invalid Buddy Inbox admission mode");
}
function parseSubjectKind(value) {
if (value === "user" || value === "agent" || value === "server_app" || value === "system") {
return value;
}
throw new Error("Invalid Buddy Inbox admission subject kind");
}
function parseOptionalString(value, field, maxLength) {
if (value === void 0 || value === null || value === "") return void 0;
if (typeof value !== "string" || value.length > maxLength) {
throw new Error(`Invalid Buddy Inbox admission ${field}`);
}
return value;
}
function normalizeBuddyInboxAdmissionPolicy(value) {
if (value === void 0 || value === null) return { ...DEFAULT_BUDDY_INBOX_ADMISSION_POLICY };
if (!isRecord(value)) throw new Error("Invalid Buddy Inbox admission policy");
const defaultMode = parseAdmissionMode(value.defaultMode, "allow");
const rawRules = value.rules;
if (rawRules !== void 0 && !Array.isArray(rawRules)) {
throw new Error("Invalid Buddy Inbox admission rules");
}
const rules = (rawRules ?? []).slice(0, 100).map((entry) => {
if (!isRecord(entry)) throw new Error("Invalid Buddy Inbox admission rule");
return {
subjectKind: parseSubjectKind(entry.subjectKind),
subjectId: parseOptionalString(entry.subjectId, "subjectId", 160),
appKey: parseOptionalString(entry.appKey, "appKey", 120),
mode: parseAdmissionMode(entry.mode, defaultMode),
...entry.approved === true ? { approved: true } : {},
note: parseOptionalString(entry.note, "note", 500),
createdAt: parseOptionalString(entry.createdAt, "createdAt", 64),
updatedAt: parseOptionalString(entry.updatedAt, "updatedAt", 64)
};
});
return { defaultMode, rules };
}
function buddyInboxAdmissionRuleKey(rule) {
return [rule.subjectKind, rule.subjectId ?? "", rule.appKey ?? ""].join(":");
}
function parsePendingTask(value) {
if (!isRecord(value)) throw new Error("Invalid Buddy Inbox pending task");
const title = parseOptionalString(value.title, "task.title", 180);
if (!title) throw new Error("Invalid Buddy Inbox pending task title");
const body = parseOptionalString(value.body, "task.body", 8e3);
const priority = value.priority;
if (priority !== void 0 && priority !== "low" && priority !== "normal" && priority !== "high" && priority !== "urgent") {
throw new Error("Invalid Buddy Inbox pending task priority");
}
const idempotencyKey = parseOptionalString(value.idempotencyKey, "task.idempotencyKey", 240);
const source = isRecord(value.source) ? value.source : void 0;
const requirements = isRecord(value.requirements) ? value.requirements : void 0;
const outputContract = isRecord(value.outputContract) ? value.outputContract : void 0;
const privacy = isRecord(value.privacy) ? value.privacy : void 0;
const data = isRecord(value.data) ? value.data : void 0;
return {
title,
...body ? { body } : {},
...priority ? { priority } : {},
...idempotencyKey ? { idempotencyKey } : {},
...source ? { source } : {},
...requirements ? { requirements } : {},
...outputContract ? { outputContract } : {},
...privacy ? { privacy } : {},
...data ? { data } : {}
};
}
function normalizeBuddyInboxAdmissionPendingDeliveries(value) {
if (value === void 0 || value === null) return [];
if (!Array.isArray(value)) throw new Error("Invalid Buddy Inbox pending deliveries");
return value.slice(0, 100).map((entry) => {
if (!isRecord(entry)) throw new Error("Invalid Buddy Inbox pending delivery");
const id = parseOptionalString(entry.id, "pending.id", 80);
const serverId = parseOptionalString(entry.serverId, "pending.serverId", 160);
const channelId = parseOptionalString(entry.channelId, "pending.channelId", 160);
const agentId = parseOptionalString(entry.agentId, "pending.agentId", 160);
const mode = parseAdmissionMode(entry.mode, "first_time");
if (mode !== "first_time" && mode !== "every_time") {
throw new Error("Invalid Buddy Inbox pending mode");
}
if (!isRecord(entry.subject)) throw new Error("Invalid Buddy Inbox pending subject");
if (!isRecord(entry.requestedBy)) throw new Error("Invalid Buddy Inbox pending requester");
if (!id || !serverId || !channelId || !agentId) {
throw new Error("Invalid Buddy Inbox pending delivery identifiers");
}
const requestedAt = parseOptionalString(entry.requestedAt, "pending.requestedAt", 64);
if (!requestedAt) throw new Error("Invalid Buddy Inbox pending requestedAt");
return {
id,
serverId,
channelId,
agentId,
mode,
subject: {
kind: parseSubjectKind(entry.subject.kind),
id: parseOptionalString(entry.subject.id, "subject.id", 160),
appKey: parseOptionalString(entry.subject.appKey, "subject.appKey", 120),
label: parseOptionalString(entry.subject.label, "subject.label", 160)
},
task: parsePendingTask(entry.task),
requestedBy: entry.requestedBy,
requestedAt,
updatedAt: parseOptionalString(entry.updatedAt, "pending.updatedAt", 64)
};
});
}
// src/types/message.types.ts
var MESSAGE_COPILOT_CONTEXT_METADATA_KEY = "copilotContext";
function isBoundedMetadataString(value, maxLength, required = false) {
if (typeof value !== "string") return !required && value == null;
const trimmed = value.trim();
return trimmed.length > 0 && trimmed.length <= maxLength;
}
function isMessageCopilotContext(value) {
if (!value || typeof value !== "object") return false;
const record = value;
return record.kind === "server_app_copilot" && isBoundedMetadataString(record.appKey, 120, true) && isBoundedMetadataString(record.serverAppId, 160) && isBoundedMetadataString(record.appId, 160) && isBoundedMetadataString(record.appName, 160) && isBoundedMetadataString(record.serverId, 160) && isBoundedMetadataString(record.serverSlug, 160) && isBoundedMetadataString(record.channelId, 160) && isBoundedMetadataString(record.channelKind, 40);
}
function buildMessageCopilotContextMetadata(context) {
return context && isMessageCopilotContext(context) ? { copilotContext: context } : void 0;
}
// src/types/runtime-session.types.ts
var RUNTIME_SESSION_PET_REACTION_BY_STATE = {
idle: "idle",
running: "working",
streaming: "thinking",
tool_call: "working",
waiting_for_approval: "waiting",
blocked: "waiting",
completed: "success",
failed: "error",
stopped: "idle",
unknown: "idle"
};
function runtimeSessionPetReactionForState(state) {
return RUNTIME_SESSION_PET_REACTION_BY_STATE[state] ?? "idle";
}
function runtimeSessionSignalToPetReaction(signal) {
switch (signal) {
case "running":
return "working";
case "streaming":
return "thinking";
case "tool_call":
return "working";
case "waiting_for_approval":
case "blocked":
return "waiting";
case "completed":
return "success";
case "failed":
return "error";
case "stopped":
case "unknown":
return "idle";
default:
return signal;
}
}
function runtimeSessionStateLooksActive(state) {
return state === "running" || state === "streaming" || state === "tool_call" || state === "waiting_for_approval" || state === "blocked";
}
// src/types/user.types.ts
var USER_STATUSES = ["online", "idle", "dnd", "offline"];
var BUDDY_PRESENCE_STATUSES = ["online", "busy", "idle", "dnd", "offline"];
var BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS = 9e4;
function normalizeUserStatus(status) {
if (status === "online" || status === "idle" || status === "dnd" || status === "offline") {
return status;
}
return "offline";
}
function normalizeBuddyPresenceStatus(status, options) {
if (options?.busy) {
return "busy";
}
if (status === "busy") {
return "busy";
}
return normalizeUserStatus(status);
}
function isBuddyHeartbeatActive(lastHeartbeat, options) {
if (!lastHeartbeat) return false;
const heartbeatMs = lastHeartbeat instanceof Date ? lastHeartbeat.getTime() : new Date(lastHeartbeat).getTime();
if (!Number.isFinite(heartbeatMs)) return false;
const nowMs = options?.nowMs ?? Date.now();
const thresholdMs = options?.thresholdMs ?? BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS;
return nowMs - heartbeatMs <= thresholdMs;
}
function normalizeBuddyRuntimePresenceStatus({
userStatus,
agentStatus,
lastHeartbeat,
busy = false,
nowMs
}) {
if (busy || agentStatus === "busy") return "busy";
if (agentStatus === "running") {
return isBuddyHeartbeatActive(lastHeartbeat, { nowMs }) ? "online" : "offline";
}
const normalizedAgentStatus = normalizeBuddyPresenceStatus(agentStatus);
if (normalizedAgentStatus !== "offline") return normalizedAgentStatus;
return normalizeUserStatus(userStatus);
}
export {
BUDDY_INBOX_TOPIC_PREFIX,
BUDDY_INBOX_DELIVERY_PERMISSION,
BUDDY_INBOX_PLATFORM_PERMISSIONS,
isBuddyInboxPlatformPermission,
buddyInboxTopic,
parseBuddyInboxAgentId,
isBuddyInboxTopic,
TASK_MESSAGE_CARD_STATUSES,
TERMINAL_TASK_MESSAGE_CARD_STATUSES,
TASK_MESSAGE_CARD_STATUS_TRANSITIONS,
isTerminalTaskMessageCardStatus,
isTaskMessageCardStatus,
canTransitionTaskMessageCardStatus,
isTaskReplyNotificationCard,
isMessageReferenceCard,
getBuddyInboxTaskCards,
hasBuddyInboxTaskCard,
getBuddyInboxTaskStatuses,
buddyInboxMessageMatchesTaskFilter,
getBuddyInboxTaskMessageIds,
isBuddyInboxTaskReply,
buildBuddyInboxViewMessages,
DEFAULT_BUDDY_INBOX_ADMISSION_POLICY,
normalizeBuddyInboxAdmissionPolicy,
buddyInboxAdmissionRuleKey,
normalizeBuddyInboxAdmissionPendingDeliveries,
MESSAGE_COPILOT_CONTEXT_METADATA_KEY,
isMessageCopilotContext,
buildMessageCopilotContextMetadata,
RUNTIME_SESSION_PET_REACTION_BY_STATE,
runtimeSessionPetReactionForState,
runtimeSessionSignalToPetReaction,
runtimeSessionStateLooksActive,
USER_STATUSES,
BUDDY_PRESENCE_STATUSES,
BUDDY_HEARTBEAT_ONLINE_THRESHOLD_MS,
normalizeUserStatus,
normalizeBuddyPresenceStatus,
isBuddyHeartbeatActive,
normalizeBuddyRuntimePresenceStatus
};
interface Message {
id: string;
content: string;
channelId: string;
authorId: string;
threadId: string | null;
replyToId: string | null;
isEdited: boolean;
isPinned: boolean;
createdAt: string;
updatedAt: string;
author?: {
id: string;
username: string;
displayName: string;
avatarUrl: string | null;
isBot: boolean;
};
attachments?: Attachment[];
reactions?: ReactionGroup[];
metadata?: MessageMetadata | null;
}
type MessageMentionKind = 'user' | 'buddy' | 'app' | 'channel' | 'server' | 'here' | 'everyone';
interface MessageMentionRange {
start: number;
end: number;
}
interface MessageMention {
kind: MessageMentionKind;
/** Canonical target id. For users this is userId, for channels channelId, for servers serverId. */
targetId: string;
/** Canonical text persisted in message content, e.g. <@userId>, <#channelId>. */
token: string;
/** Optional display text selected or typed by the sender before canonicalization. */
sourceToken?: string;
/** Human-readable label used by renderers. */
label: string;
/** Optional source range in content. Clients may omit it; servers may recompute later. */
range?: MessageMentionRange;
serverId?: string;
serverSlug?: string | null;
serverName?: string | null;
channelId?: string;
channelName?: string | null;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
userId?: string;
username?: string | null;
displayName?: string | null;
avatarUrl?: string | null;
isBot?: boolean;
isPrivate?: boolean;
}
declare const MESSAGE_COPILOT_CONTEXT_METADATA_KEY: "copilotContext";
interface MessageCopilotContext {
kind: 'server_app_copilot';
/** Server app install id when the current surface is an installed server app. */
serverAppId?: string | null;
/** Catalog app id when available. */
appId?: string | null;
/** Stable app key from the app route, e.g. kanban. */
appKey: string;
appName?: string | null;
serverId?: string | null;
serverSlug?: string | null;
/** Channel or Inbox currently opened in the Copilot panel. */
channelId?: string | null;
channelKind?: string | null;
}
declare function isMessageCopilotContext(value: unknown): value is MessageCopilotContext;
declare function buildMessageCopilotContextMetadata(context: MessageCopilotContext | null | undefined): {
copilotContext: MessageCopilotContext;
} | undefined;
interface MessageMetadata {
mentions?: MessageMention[];
copilotContext?: MessageCopilotContext;
collaboration?: {
id: string;
rootMessageId: string;
buddyId: string;
turn: number;
target?: 'main' | 'thread';
threadId?: string;
suggestedTextLimit?: number;
replyDensity?: 'reaction' | 'short' | 'normal' | 'long';
};
interactive?: Record<string, unknown>;
interactiveResponse?: Record<string, unknown>;
interactiveState?: Record<string, unknown>;
/** Unified card protocol. New card-like message surfaces must use this field. */
cards?: MessageCard[];
/**
* @deprecated Compatibility-only commerce card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
commerceCards?: CommerceMessageCard[];
/**
* @deprecated Compatibility-only paid-file delivery card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
paidFileCards?: PaidFileCard[];
/**
* @deprecated Compatibility-only OAuth link card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
oauthLinkCards?: OAuthLinkCard[];
[key: string]: unknown;
}
type MessageCardStatus = 'queued' | 'claimed' | 'running' | 'completed' | 'failed' | 'canceled' | 'transferred';
interface MessageCardSource {
kind: 'user' | 'pat' | 'oauth' | 'agent' | 'system' | 'server_app' | 'buddy';
id?: string;
label?: string;
userId?: string;
agentId?: string;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
serverId?: string;
channelId?: string;
command?: string;
resource?: {
kind: string;
id: string;
label?: string;
url?: string;
[key: string]: unknown;
};
[key: string]: unknown;
}
type TaskMessageCardTag = string | {
id?: string;
label: string;
color?: string;
[key: string]: unknown;
};
interface MessageCardApp {
id?: string;
appId?: string;
appKey?: string;
name?: string | null;
label?: string | null;
iconUrl?: string | null;
logoUrl?: string | null;
avatarUrl?: string | null;
imageUrl?: string | null;
url?: string | null;
[key: string]: unknown;
}
interface TaskMessageCardReply {
id?: string;
messageId?: string;
cardId?: string;
authorId?: string;
authorLabel?: string;
authorAvatarUrl?: string | null;
content: string;
createdAt: string;
source?: MessageCardSource;
[key: string]: unknown;
}
interface MessageCardClaim {
id: string;
actor: MessageCardSource;
claimedAt: string;
expiresAt: string;
}
interface MessageCardCapability {
kind: 'task';
scope: string[];
issuedAt: string;
expiresAt: string;
claimId?: string;
binding?: {
messageId?: string;
cardId: string;
workspaceId?: string;
};
}
interface TaskMessageRequirementSkill {
kind: 'runtime-skill';
package: string;
version?: string;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageRequirementTool {
kind: string;
name: string;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageRequirements {
capabilities?: string[];
skills?: TaskMessageRequirementSkill[];
tools?: TaskMessageRequirementTool[];
[key: string]: unknown;
}
interface TaskMessageExpectedArtifact {
kind: string;
mimeTypes?: string[];
maxBytes?: number;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageSubmitCommand {
appKey: string;
command: string;
[key: string]: unknown;
}
interface TaskMessageOutputContract {
expectedArtifacts?: TaskMessageExpectedArtifact[];
submitCommand?: TaskMessageSubmitCommand;
[key: string]: unknown;
}
type TaskMessagePrivacyDataClass = 'public' | 'server-private' | 'channel-private' | 'financial' | 'secret' | 'cloud-secret';
interface TaskMessagePrivacy {
dataClass: TaskMessagePrivacyDataClass;
redactionRequired?: boolean;
[key: string]: unknown;
}
interface TaskMessageCard {
id: string;
kind: 'task';
version: number;
title: string;
body?: string;
status: MessageCardStatus;
priority?: 'low' | 'normal' | 'high' | 'urgent';
tags?: TaskMessageCardTag[];
app?: MessageCardApp;
assignee?: {
agentId?: string;
userId?: string;
label?: string;
[key: string]: unknown;
};
source?: MessageCardSource;
requirements?: TaskMessageRequirements;
outputContract?: TaskMessageOutputContract;
privacy?: TaskMessagePrivacy;
claim?: MessageCardClaim;
capability?: MessageCardCapability;
progress?: Array<{
at: string;
status: MessageCardStatus;
note?: string;
actor?: MessageCardSource;
[key: string]: unknown;
}>;
replies?: TaskMessageCardReply[];
createdAt: string;
updatedAt?: string;
data?: Record<string, unknown> & {
task?: {
workspaceId?: string;
[key: string]: unknown;
};
};
[key: string]: unknown;
}
type GenericMessageCard = {
id?: string;
kind: string;
version?: number;
title?: string;
data?: Record<string, unknown>;
[key: string]: unknown;
};
interface ServerAppMessageCard {
id?: string;
kind: 'server_app';
version?: number;
appKey: string;
title: string;
description?: string;
label?: string;
action?: {
mode: 'open_app';
path?: string;
};
data?: Record<string, unknown>;
[key: string]: unknown;
}
interface MessageReferenceCard {
id?: string;
kind: 'message_reference';
version?: number;
title: string;
description?: string;
label?: string;
target: {
serverId?: string | null;
serverSlug?: string | null;
channelId: string;
messageId: string;
taskCardId?: string | null;
inboxAgentId?: string | null;
kind?: 'channel_message' | 'inbox_message';
};
source?: MessageCardSource;
data?: Record<string, unknown>;
[key: string]: unknown;
}
type MessageCard = TaskMessageCard | ServerAppMessageCard | MessageReferenceCard | GenericMessageCard;
interface CommerceOfferCardInput {
id?: string;
kind: 'offer';
offerId: string;
}
type CommerceMessageCard = CommerceProductCard | CommerceOfferCardInput;
interface CommerceProductCard {
id: string;
kind: 'offer' | 'product';
offerId?: string;
shopId: string;
shopScope: {
kind: 'server' | 'user';
id: string;
};
productId: string;
skuId?: string;
snapshot: {
name: string;
summary?: string | null;
imageUrl?: string | null;
shopName?: string | null;
deliveryPromise?: string | null;
price: number;
currency: string;
productType: 'physical' | 'entitlement';
billingMode?: 'one_time' | 'fixed_duration' | 'subscription';
durationSeconds?: number | null;
resourceType?: string;
resourceId?: string;
capability?: string;
};
purchase: {
mode: 'direct' | 'select_sku' | 'open_detail';
};
}
interface PaidFileCard {
id: string;
kind: 'paid_file';
fileId: string;
entitlementId?: string | null;
deliverableId?: string;
snapshot: {
name: string;
summary?: string | null;
mime?: string | null;
sizeBytes?: number | null;
previewUrl?: string | null;
};
action: {
mode: 'open_paid_file';
};
}
interface OAuthLinkCard {
id: string;
kind: 'oauth_link';
appId: string;
clientId?: string | null;
title: string;
description?: string | null;
iconUrl?: string | null;
meta?: {
appName?: string | null;
avatarUrl?: string | null;
iconUrl?: string | null;
coverUrl?: string | null;
homepageUrl?: string | null;
origin?: string | null;
};
url: string;
embedUrl?: string | null;
fallbackUrl?: string | null;
scopes?: string[];
action: {
mode: 'open_iframe' | 'open_external';
};
}
type MentionSuggestionTrigger = '@' | '#';
interface MentionSuggestion {
id: string;
kind: MessageMentionKind;
targetId: string;
token: string;
label: string;
description?: string | null;
serverId?: string;
serverSlug?: string | null;
serverName?: string | null;
channelId?: string;
channelName?: string | null;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
userId?: string;
username?: string | null;
displayName?: string | null;
avatarUrl?: string | null;
isBot?: boolean;
isPrivate?: boolean;
}
interface Attachment {
id: string;
messageId: string;
filename: string;
url: string;
contentType: string;
size: number;
width: number | null;
height: number | null;
workspaceNodeId?: string | null;
kind?: 'file' | 'image' | 'voice';
durationMs?: number | null;
audioCodec?: string | null;
audioContainer?: string | null;
waveformPeaks?: number[] | null;
waveformVersion?: number | null;
transcript?: {
id: string;
status: 'pending' | 'processing' | 'ready' | 'failed';
text: string | null;
language: string | null;
source: 'client' | 'server' | 'runtime';
provider?: string | null;
confidence?: number | null;
errorCode?: string | null;
updatedAt?: string;
} | null;
playback?: {
played: boolean;
completed: boolean;
lastPositionMs: number;
playedCount?: number;
} | null;
createdAt: string;
}
interface ReactionGroup {
emoji: string;
count: number;
userIds: string[];
}
interface Thread {
id: string;
name: string;
channelId: string;
parentMessageId: string;
creatorId: string;
isArchived: boolean;
createdAt: string;
updatedAt: string;
}
interface SendMessageRequest {
content: string;
threadId?: string;
replyToId?: string;
mentions?: MessageMention[];
metadata?: MessageMetadata;
}
interface UpdateMessageRequest {
content: string;
}
type NotificationType = 'mention' | 'reply' | 'dm' | 'system';
interface Notification {
id: string;
userId: string;
type: NotificationType;
title: string;
body: string | null;
referenceId: string | null;
referenceType: string | null;
isRead: boolean;
createdAt: string;
}
export { type Attachment as A, type TaskMessageRequirementTool as B, type CommerceMessageCard as C, type TaskMessageRequirements as D, type TaskMessageSubmitCommand as E, type Thread as F, type GenericMessageCard as G, buildMessageCopilotContextMetadata as H, isMessageCopilotContext as I, MESSAGE_COPILOT_CONTEXT_METADATA_KEY as M, type Notification as N, type OAuthLinkCard as O, type PaidFileCard as P, type ReactionGroup as R, type SendMessageRequest as S, type TaskMessageCard as T, type UpdateMessageRequest as U, type CommerceOfferCardInput as a, type CommerceProductCard as b, type MentionSuggestion as c, type MentionSuggestionTrigger as d, type Message as e, type MessageCard as f, type MessageCardApp as g, type MessageCardCapability as h, type MessageCardClaim as i, type MessageCardSource as j, type MessageCardStatus as k, type MessageCopilotContext as l, type MessageMention as m, type MessageMentionKind as n, type MessageMentionRange as o, type MessageMetadata as p, type MessageReferenceCard as q, type NotificationType as r, type ServerAppMessageCard as s, type TaskMessageCardReply as t, type TaskMessageCardTag as u, type TaskMessageExpectedArtifact as v, type TaskMessageOutputContract as w, type TaskMessagePrivacy as x, type TaskMessagePrivacyDataClass as y, type TaskMessageRequirementSkill as z };
interface Message {
id: string;
content: string;
channelId: string;
authorId: string;
threadId: string | null;
replyToId: string | null;
isEdited: boolean;
isPinned: boolean;
createdAt: string;
updatedAt: string;
author?: {
id: string;
username: string;
displayName: string;
avatarUrl: string | null;
isBot: boolean;
};
attachments?: Attachment[];
reactions?: ReactionGroup[];
metadata?: MessageMetadata | null;
}
type MessageMentionKind = 'user' | 'buddy' | 'app' | 'channel' | 'server' | 'here' | 'everyone';
interface MessageMentionRange {
start: number;
end: number;
}
interface MessageMention {
kind: MessageMentionKind;
/** Canonical target id. For users this is userId, for channels channelId, for servers serverId. */
targetId: string;
/** Canonical text persisted in message content, e.g. <@userId>, <#channelId>. */
token: string;
/** Optional display text selected or typed by the sender before canonicalization. */
sourceToken?: string;
/** Human-readable label used by renderers. */
label: string;
/** Optional source range in content. Clients may omit it; servers may recompute later. */
range?: MessageMentionRange;
serverId?: string;
serverSlug?: string | null;
serverName?: string | null;
channelId?: string;
channelName?: string | null;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
userId?: string;
username?: string | null;
displayName?: string | null;
avatarUrl?: string | null;
isBot?: boolean;
isPrivate?: boolean;
}
declare const MESSAGE_COPILOT_CONTEXT_METADATA_KEY: "copilotContext";
interface MessageCopilotContext {
kind: 'server_app_copilot';
/** Server app install id when the current surface is an installed server app. */
serverAppId?: string | null;
/** Catalog app id when available. */
appId?: string | null;
/** Stable app key from the app route, e.g. kanban. */
appKey: string;
appName?: string | null;
serverId?: string | null;
serverSlug?: string | null;
/** Channel or Inbox currently opened in the Copilot panel. */
channelId?: string | null;
channelKind?: string | null;
}
declare function isMessageCopilotContext(value: unknown): value is MessageCopilotContext;
declare function buildMessageCopilotContextMetadata(context: MessageCopilotContext | null | undefined): {
copilotContext: MessageCopilotContext;
} | undefined;
interface MessageMetadata {
mentions?: MessageMention[];
copilotContext?: MessageCopilotContext;
collaboration?: {
id: string;
rootMessageId: string;
buddyId: string;
turn: number;
target?: 'main' | 'thread';
threadId?: string;
suggestedTextLimit?: number;
replyDensity?: 'reaction' | 'short' | 'normal' | 'long';
};
interactive?: Record<string, unknown>;
interactiveResponse?: Record<string, unknown>;
interactiveState?: Record<string, unknown>;
/** Unified card protocol. New card-like message surfaces must use this field. */
cards?: MessageCard[];
/**
* @deprecated Compatibility-only commerce card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
commerceCards?: CommerceMessageCard[];
/**
* @deprecated Compatibility-only paid-file delivery card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
paidFileCards?: PaidFileCard[];
/**
* @deprecated Compatibility-only OAuth link card array.
* New card-like protocols must use `cards`; do not use this field for new product decisions.
*/
oauthLinkCards?: OAuthLinkCard[];
[key: string]: unknown;
}
type MessageCardStatus = 'queued' | 'claimed' | 'running' | 'completed' | 'failed' | 'canceled' | 'transferred';
interface MessageCardSource {
kind: 'user' | 'pat' | 'oauth' | 'agent' | 'system' | 'server_app' | 'buddy';
id?: string;
label?: string;
userId?: string;
agentId?: string;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
serverId?: string;
channelId?: string;
command?: string;
resource?: {
kind: string;
id: string;
label?: string;
url?: string;
[key: string]: unknown;
};
[key: string]: unknown;
}
type TaskMessageCardTag = string | {
id?: string;
label: string;
color?: string;
[key: string]: unknown;
};
interface MessageCardApp {
id?: string;
appId?: string;
appKey?: string;
name?: string | null;
label?: string | null;
iconUrl?: string | null;
logoUrl?: string | null;
avatarUrl?: string | null;
imageUrl?: string | null;
url?: string | null;
[key: string]: unknown;
}
interface TaskMessageCardReply {
id?: string;
messageId?: string;
cardId?: string;
authorId?: string;
authorLabel?: string;
authorAvatarUrl?: string | null;
content: string;
createdAt: string;
source?: MessageCardSource;
[key: string]: unknown;
}
interface MessageCardClaim {
id: string;
actor: MessageCardSource;
claimedAt: string;
expiresAt: string;
}
interface MessageCardCapability {
kind: 'task';
scope: string[];
issuedAt: string;
expiresAt: string;
claimId?: string;
binding?: {
messageId?: string;
cardId: string;
workspaceId?: string;
};
}
interface TaskMessageRequirementSkill {
kind: 'runtime-skill';
package: string;
version?: string;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageRequirementTool {
kind: string;
name: string;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageRequirements {
capabilities?: string[];
skills?: TaskMessageRequirementSkill[];
tools?: TaskMessageRequirementTool[];
[key: string]: unknown;
}
interface TaskMessageExpectedArtifact {
kind: string;
mimeTypes?: string[];
maxBytes?: number;
required?: boolean;
[key: string]: unknown;
}
interface TaskMessageSubmitCommand {
appKey: string;
command: string;
[key: string]: unknown;
}
interface TaskMessageOutputContract {
expectedArtifacts?: TaskMessageExpectedArtifact[];
submitCommand?: TaskMessageSubmitCommand;
[key: string]: unknown;
}
type TaskMessagePrivacyDataClass = 'public' | 'server-private' | 'channel-private' | 'financial' | 'secret' | 'cloud-secret';
interface TaskMessagePrivacy {
dataClass: TaskMessagePrivacyDataClass;
redactionRequired?: boolean;
[key: string]: unknown;
}
interface TaskMessageCard {
id: string;
kind: 'task';
version: number;
title: string;
body?: string;
status: MessageCardStatus;
priority?: 'low' | 'normal' | 'high' | 'urgent';
tags?: TaskMessageCardTag[];
app?: MessageCardApp;
assignee?: {
agentId?: string;
userId?: string;
label?: string;
[key: string]: unknown;
};
source?: MessageCardSource;
requirements?: TaskMessageRequirements;
outputContract?: TaskMessageOutputContract;
privacy?: TaskMessagePrivacy;
claim?: MessageCardClaim;
capability?: MessageCardCapability;
progress?: Array<{
at: string;
status: MessageCardStatus;
note?: string;
actor?: MessageCardSource;
[key: string]: unknown;
}>;
replies?: TaskMessageCardReply[];
createdAt: string;
updatedAt?: string;
data?: Record<string, unknown> & {
task?: {
workspaceId?: string;
[key: string]: unknown;
};
};
[key: string]: unknown;
}
type GenericMessageCard = {
id?: string;
kind: string;
version?: number;
title?: string;
data?: Record<string, unknown>;
[key: string]: unknown;
};
interface ServerAppMessageCard {
id?: string;
kind: 'server_app';
version?: number;
appKey: string;
title: string;
description?: string;
label?: string;
action?: {
mode: 'open_app';
path?: string;
};
data?: Record<string, unknown>;
[key: string]: unknown;
}
interface MessageReferenceCard {
id?: string;
kind: 'message_reference';
version?: number;
title: string;
description?: string;
label?: string;
target: {
serverId?: string | null;
serverSlug?: string | null;
channelId: string;
messageId: string;
taskCardId?: string | null;
inboxAgentId?: string | null;
kind?: 'channel_message' | 'inbox_message';
};
source?: MessageCardSource;
data?: Record<string, unknown>;
[key: string]: unknown;
}
type MessageCard = TaskMessageCard | ServerAppMessageCard | MessageReferenceCard | GenericMessageCard;
interface CommerceOfferCardInput {
id?: string;
kind: 'offer';
offerId: string;
}
type CommerceMessageCard = CommerceProductCard | CommerceOfferCardInput;
interface CommerceProductCard {
id: string;
kind: 'offer' | 'product';
offerId?: string;
shopId: string;
shopScope: {
kind: 'server' | 'user';
id: string;
};
productId: string;
skuId?: string;
snapshot: {
name: string;
summary?: string | null;
imageUrl?: string | null;
shopName?: string | null;
deliveryPromise?: string | null;
price: number;
currency: string;
productType: 'physical' | 'entitlement';
billingMode?: 'one_time' | 'fixed_duration' | 'subscription';
durationSeconds?: number | null;
resourceType?: string;
resourceId?: string;
capability?: string;
};
purchase: {
mode: 'direct' | 'select_sku' | 'open_detail';
};
}
interface PaidFileCard {
id: string;
kind: 'paid_file';
fileId: string;
entitlementId?: string | null;
deliverableId?: string;
snapshot: {
name: string;
summary?: string | null;
mime?: string | null;
sizeBytes?: number | null;
previewUrl?: string | null;
};
action: {
mode: 'open_paid_file';
};
}
interface OAuthLinkCard {
id: string;
kind: 'oauth_link';
appId: string;
clientId?: string | null;
title: string;
description?: string | null;
iconUrl?: string | null;
meta?: {
appName?: string | null;
avatarUrl?: string | null;
iconUrl?: string | null;
coverUrl?: string | null;
homepageUrl?: string | null;
origin?: string | null;
};
url: string;
embedUrl?: string | null;
fallbackUrl?: string | null;
scopes?: string[];
action: {
mode: 'open_iframe' | 'open_external';
};
}
type MentionSuggestionTrigger = '@' | '#';
interface MentionSuggestion {
id: string;
kind: MessageMentionKind;
targetId: string;
token: string;
label: string;
description?: string | null;
serverId?: string;
serverSlug?: string | null;
serverName?: string | null;
channelId?: string;
channelName?: string | null;
appId?: string;
appKey?: string;
appName?: string | null;
iconUrl?: string | null;
userId?: string;
username?: string | null;
displayName?: string | null;
avatarUrl?: string | null;
isBot?: boolean;
isPrivate?: boolean;
}
interface Attachment {
id: string;
messageId: string;
filename: string;
url: string;
contentType: string;
size: number;
width: number | null;
height: number | null;
workspaceNodeId?: string | null;
kind?: 'file' | 'image' | 'voice';
durationMs?: number | null;
audioCodec?: string | null;
audioContainer?: string | null;
waveformPeaks?: number[] | null;
waveformVersion?: number | null;
transcript?: {
id: string;
status: 'pending' | 'processing' | 'ready' | 'failed';
text: string | null;
language: string | null;
source: 'client' | 'server' | 'runtime';
provider?: string | null;
confidence?: number | null;
errorCode?: string | null;
updatedAt?: string;
} | null;
playback?: {
played: boolean;
completed: boolean;
lastPositionMs: number;
playedCount?: number;
} | null;
createdAt: string;
}
interface ReactionGroup {
emoji: string;
count: number;
userIds: string[];
}
interface Thread {
id: string;
name: string;
channelId: string;
parentMessageId: string;
creatorId: string;
isArchived: boolean;
createdAt: string;
updatedAt: string;
}
interface SendMessageRequest {
content: string;
threadId?: string;
replyToId?: string;
mentions?: MessageMention[];
metadata?: MessageMetadata;
}
interface UpdateMessageRequest {
content: string;
}
type NotificationType = 'mention' | 'reply' | 'dm' | 'system';
interface Notification {
id: string;
userId: string;
type: NotificationType;
title: string;
body: string | null;
referenceId: string | null;
referenceType: string | null;
isRead: boolean;
createdAt: string;
}
export { type Attachment as A, type TaskMessageRequirementTool as B, type CommerceMessageCard as C, type TaskMessageRequirements as D, type TaskMessageSubmitCommand as E, type Thread as F, type GenericMessageCard as G, buildMessageCopilotContextMetadata as H, isMessageCopilotContext as I, MESSAGE_COPILOT_CONTEXT_METADATA_KEY as M, type Notification as N, type OAuthLinkCard as O, type PaidFileCard as P, type ReactionGroup as R, type SendMessageRequest as S, type TaskMessageCard as T, type UpdateMessageRequest as U, type CommerceOfferCardInput as a, type CommerceProductCard as b, type MentionSuggestion as c, type MentionSuggestionTrigger as d, type Message as e, type MessageCard as f, type MessageCardApp as g, type MessageCardCapability as h, type MessageCardClaim as i, type MessageCardSource as j, type MessageCardStatus as k, type MessageCopilotContext as l, type MessageMention as m, type MessageMentionKind as n, type MessageMentionRange as o, type MessageMetadata as p, type MessageReferenceCard as q, type NotificationType as r, type ServerAppMessageCard as s, type TaskMessageCardReply as t, type TaskMessageCardTag as u, type TaskMessageExpectedArtifact as v, type TaskMessageOutputContract as w, type TaskMessagePrivacy as x, type TaskMessagePrivacyDataClass as y, type TaskMessageRequirementSkill as z };

Sorry, the diff of this file is too big to display