@alook/daemon 0.1.60 → 0.1.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +569 -426
- package/dist/index.js +469 -327
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57190,17 +57190,32 @@ var OwnerDiagnosticReportSchema = exports_external.discriminatedUnion("status",
|
|
|
57190
57190
|
objectExpired: exports_external.literal(false)
|
|
57191
57191
|
}).strict()
|
|
57192
57192
|
]);
|
|
57193
|
+
// ../shared/src/community-profile-resource.ts
|
|
57194
|
+
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
57195
|
+
id: exports_external.string().min(1),
|
|
57196
|
+
name: exports_external.string(),
|
|
57197
|
+
discriminator: exports_external.string().min(1),
|
|
57198
|
+
avatar: exports_external.string().nullable(),
|
|
57199
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
57200
|
+
aboutMe: exports_external.string().optional(),
|
|
57201
|
+
bannerColor: exports_external.string().nullable().optional(),
|
|
57202
|
+
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
57203
|
+
ownerUserId: exports_external.string().min(1).nullable().optional(),
|
|
57204
|
+
ownerHandle: exports_external.string().nullable().optional(),
|
|
57205
|
+
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
57206
|
+
ownedByViewer: exports_external.boolean().optional(),
|
|
57207
|
+
statusEmoji: exports_external.string().nullable().optional(),
|
|
57208
|
+
statusText: exports_external.string().nullable().optional()
|
|
57209
|
+
});
|
|
57210
|
+
// ../shared/src/business-schema-version.ts
|
|
57211
|
+
var BUSINESS_SCHEMA_VERSION = 7;
|
|
57212
|
+
|
|
57193
57213
|
// ../shared/src/community-contract.ts
|
|
57194
|
-
var COMMUNITY_RESOURCE_CONTRACT_VERSION =
|
|
57214
|
+
var COMMUNITY_RESOURCE_CONTRACT_VERSION = BUSINESS_SCHEMA_VERSION;
|
|
57195
57215
|
|
|
57196
57216
|
// ../shared/src/community-friend-approval.ts
|
|
57197
|
-
var
|
|
57198
|
-
|
|
57199
|
-
name: exports_external.string(),
|
|
57200
|
-
discriminator: exports_external.string(),
|
|
57201
|
-
image: exports_external.string().nullable(),
|
|
57202
|
-
avatarVersion: exports_external.number().int().nonnegative()
|
|
57203
|
-
});
|
|
57217
|
+
var identity = CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatarVersion: true });
|
|
57218
|
+
var profile = identity.extend({ image: CommunityResourceProfileSchema.shape.avatar });
|
|
57204
57219
|
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
57205
57220
|
friendshipId: exports_external.string(),
|
|
57206
57221
|
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
@@ -57210,6 +57225,28 @@ var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
|
57210
57225
|
waitingOnProfile: profile.nullable().optional()
|
|
57211
57226
|
});
|
|
57212
57227
|
|
|
57228
|
+
// ../shared/src/constants/community.ts
|
|
57229
|
+
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
57230
|
+
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
57231
|
+
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
57232
|
+
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
57233
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
57234
|
+
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
57235
|
+
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
57236
|
+
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
57237
|
+
var ALLOWED_ICON_MIME_TYPES = [
|
|
57238
|
+
"image/png",
|
|
57239
|
+
"image/jpeg",
|
|
57240
|
+
"image/webp",
|
|
57241
|
+
"image/gif"
|
|
57242
|
+
];
|
|
57243
|
+
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
57244
|
+
var PARTICIPANT_SOURCE = {
|
|
57245
|
+
MENTION: "mention",
|
|
57246
|
+
SPOKE: "spoke",
|
|
57247
|
+
ADDED: "added"
|
|
57248
|
+
};
|
|
57249
|
+
|
|
57213
57250
|
// ../shared/src/runtime-models-contract.ts
|
|
57214
57251
|
var RUNTIME_MODEL_DISCOVERY_CAPABILITY = "runtime-model-discovery-v1";
|
|
57215
57252
|
var RuntimeModelDiscoveryRequestSchema = exports_external.strictObject({
|
|
@@ -57304,6 +57341,13 @@ var PiiLocalRequestSchema = exports_external.discriminatedUnion("action", [
|
|
|
57304
57341
|
})
|
|
57305
57342
|
]);
|
|
57306
57343
|
|
|
57344
|
+
// ../shared/src/utils/community-roles.ts
|
|
57345
|
+
var ROLES = {
|
|
57346
|
+
OWNER: "owner",
|
|
57347
|
+
ADMIN: "admin",
|
|
57348
|
+
MEMBER: "member"
|
|
57349
|
+
};
|
|
57350
|
+
|
|
57307
57351
|
// ../shared/src/lib/discriminator.ts
|
|
57308
57352
|
function parseNameAndTag(q) {
|
|
57309
57353
|
const m = /^(.+)#(\d{4,})$/.exec(q);
|
|
@@ -57561,11 +57605,11 @@ var AvailableQuotaObservationSchema = exports_external.object({
|
|
|
57561
57605
|
}).strict().superRefine((value, ctx) => {
|
|
57562
57606
|
const identities = new Set;
|
|
57563
57607
|
for (const [index2, limit] of value.limits.entries()) {
|
|
57564
|
-
const
|
|
57565
|
-
if (identities.has(
|
|
57608
|
+
const identity2 = quotaIdentity(limit);
|
|
57609
|
+
if (identities.has(identity2)) {
|
|
57566
57610
|
ctx.addIssue({ code: "custom", message: "duplicate quota bucket identity", path: ["limits", index2] });
|
|
57567
57611
|
}
|
|
57568
|
-
identities.add(
|
|
57612
|
+
identities.add(identity2);
|
|
57569
57613
|
}
|
|
57570
57614
|
});
|
|
57571
57615
|
var ProviderQuotaObservationSchema = exports_external.union([
|
|
@@ -57582,23 +57626,6 @@ var ProviderQuotaSnapshotSchema = exports_external.object({
|
|
|
57582
57626
|
observation: ProviderQuotaObservationSchema
|
|
57583
57627
|
}).strict();
|
|
57584
57628
|
|
|
57585
|
-
// ../shared/src/constants/community.ts
|
|
57586
|
-
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
57587
|
-
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
57588
|
-
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
57589
|
-
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
57590
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
57591
|
-
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
57592
|
-
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
57593
|
-
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
57594
|
-
var ALLOWED_ICON_MIME_TYPES = [
|
|
57595
|
-
"image/png",
|
|
57596
|
-
"image/jpeg",
|
|
57597
|
-
"image/webp",
|
|
57598
|
-
"image/gif"
|
|
57599
|
-
];
|
|
57600
|
-
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
57601
|
-
|
|
57602
57629
|
// ../shared/src/lib/community-name.ts
|
|
57603
57630
|
var FORBIDDEN_NAME_CHARS = /[#@\x00-\x1f\x7f-\x9f]/;
|
|
57604
57631
|
function validateCommunityName(name) {
|
|
@@ -58559,13 +58586,12 @@ var BotCreationSubmitSchema = exports_external.strictObject({
|
|
|
58559
58586
|
requestId: exports_external.string().min(1).max(128),
|
|
58560
58587
|
bots: exports_external.array(BotCreationProposalSchema).min(1).max(BOT_CREATION_MAX_ITEMS)
|
|
58561
58588
|
});
|
|
58562
|
-
var BotCreationIdentitySchema =
|
|
58563
|
-
id:
|
|
58564
|
-
name:
|
|
58565
|
-
discriminator:
|
|
58566
|
-
|
|
58567
|
-
|
|
58568
|
-
});
|
|
58589
|
+
var BotCreationIdentitySchema = CommunityResourceProfileSchema.pick({
|
|
58590
|
+
id: true,
|
|
58591
|
+
name: true,
|
|
58592
|
+
discriminator: true,
|
|
58593
|
+
avatarVersion: true
|
|
58594
|
+
}).extend({ image: CommunityResourceProfileSchema.shape.avatar });
|
|
58569
58595
|
var BotCreationItemSchema = BotCreationProposalSchema.extend({
|
|
58570
58596
|
itemId: exports_external.string(),
|
|
58571
58597
|
description: exports_external.string(),
|
|
@@ -58588,7 +58614,26 @@ var BotCreationDecisionSchema = exports_external.strictObject({ decision: export
|
|
|
58588
58614
|
// ../shared/src/community-resources.ts
|
|
58589
58615
|
var id = exports_external.string().min(1);
|
|
58590
58616
|
var nullableId = id.nullable();
|
|
58591
|
-
var
|
|
58617
|
+
var storedArchivedSchema = exports_external.union([exports_external.boolean(), exports_external.literal(0), exports_external.literal(1)]).transform((value) => value === true || value === 1);
|
|
58618
|
+
var CommunityServerResourceSchema = exports_external.strictObject({
|
|
58619
|
+
id: exports_external.string().min(1),
|
|
58620
|
+
position: exports_external.number().int().nonnegative(),
|
|
58621
|
+
name: exports_external.string(),
|
|
58622
|
+
discriminator: exports_external.string(),
|
|
58623
|
+
description: exports_external.string(),
|
|
58624
|
+
ownerId: exports_external.string(),
|
|
58625
|
+
icon: exports_external.string().nullable(),
|
|
58626
|
+
official: exports_external.boolean(),
|
|
58627
|
+
isOwner: exports_external.boolean()
|
|
58628
|
+
});
|
|
58629
|
+
var CommunityCategoryResourceSchema = exports_external.strictObject({
|
|
58630
|
+
id: exports_external.string().min(1),
|
|
58631
|
+
serverId: exports_external.string().min(1),
|
|
58632
|
+
name: exports_external.string(),
|
|
58633
|
+
position: exports_external.number(),
|
|
58634
|
+
private: exports_external.boolean(),
|
|
58635
|
+
creatorId: exports_external.string().nullable()
|
|
58636
|
+
});
|
|
58592
58637
|
var CommunityChannelResourceSchema = exports_external.strictObject({
|
|
58593
58638
|
id,
|
|
58594
58639
|
type: exports_external.enum(["text", "forum", "thread", "dm"]),
|
|
@@ -58616,31 +58661,13 @@ var CommunityChannelIdentitySchema = CommunityChannelResourceSchema.pick({
|
|
|
58616
58661
|
archived: true,
|
|
58617
58662
|
lastMessageAt: true,
|
|
58618
58663
|
createdAt: true
|
|
58619
|
-
}).
|
|
58620
|
-
var legacyChannelIdentitySchema = CommunityChannelIdentitySchema.extend({
|
|
58621
|
-
archived: legacyArchivedSchema,
|
|
58622
|
-
parentChannelId: nullableId.default(null),
|
|
58623
|
-
parentMessageId: nullableId.default(null),
|
|
58624
|
-
creatorId: nullableId.default(null),
|
|
58625
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null)
|
|
58626
|
-
});
|
|
58664
|
+
}).strip();
|
|
58627
58665
|
var CommunityAccessDecisionSchema = exports_external.strictObject({
|
|
58628
58666
|
channelId: id,
|
|
58629
58667
|
canRead: exports_external.boolean(),
|
|
58630
58668
|
canSend: exports_external.boolean(),
|
|
58631
58669
|
canCreateDiscussion: exports_external.boolean()
|
|
58632
58670
|
});
|
|
58633
|
-
var CommunityLegacyMessageAttachmentSchema = exports_external.strictObject({
|
|
58634
|
-
kind: exports_external.enum(["image", "file"]),
|
|
58635
|
-
name: exports_external.string(),
|
|
58636
|
-
url: exports_external.string(),
|
|
58637
|
-
thumbnailUrl: exports_external.string().optional(),
|
|
58638
|
-
contentType: exports_external.string().optional(),
|
|
58639
|
-
size: exports_external.string().optional(),
|
|
58640
|
-
sizeBytes: exports_external.number().nonnegative().optional(),
|
|
58641
|
-
width: exports_external.number().nonnegative().optional(),
|
|
58642
|
-
height: exports_external.number().nonnegative().optional()
|
|
58643
|
-
});
|
|
58644
58671
|
var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
58645
58672
|
id,
|
|
58646
58673
|
name: exports_external.string(),
|
|
@@ -58651,23 +58678,6 @@ var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
|
58651
58678
|
width: exports_external.number().int().nonnegative().nullable(),
|
|
58652
58679
|
height: exports_external.number().int().nonnegative().nullable()
|
|
58653
58680
|
});
|
|
58654
|
-
var CommunityMessagePreviewAttachmentSchema = CommunityMessageAttachmentSchema.partial().required({ name: true, url: true });
|
|
58655
|
-
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
58656
|
-
id,
|
|
58657
|
-
name: exports_external.string(),
|
|
58658
|
-
discriminator: exports_external.string().min(1).nullable(),
|
|
58659
|
-
avatar: exports_external.string().nullable(),
|
|
58660
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
58661
|
-
aboutMe: exports_external.string().optional(),
|
|
58662
|
-
bannerColor: exports_external.string().nullable().optional(),
|
|
58663
|
-
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
58664
|
-
ownerUserId: nullableId.optional(),
|
|
58665
|
-
ownerHandle: exports_external.string().nullable().optional(),
|
|
58666
|
-
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
58667
|
-
ownedByViewer: exports_external.boolean().optional(),
|
|
58668
|
-
statusEmoji: exports_external.string().nullable().optional(),
|
|
58669
|
-
statusText: exports_external.string().nullable().optional()
|
|
58670
|
-
});
|
|
58671
58681
|
var CommunityMessageThreadParticipantSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatar: true, avatarVersion: true });
|
|
58672
58682
|
var messageThreadSchema = exports_external.strictObject({
|
|
58673
58683
|
id,
|
|
@@ -58679,14 +58689,6 @@ var messageThreadSchema = exports_external.strictObject({
|
|
|
58679
58689
|
participants: exports_external.array(CommunityMessageThreadParticipantSchema).optional(),
|
|
58680
58690
|
participantCount: exports_external.number().int().nonnegative().optional()
|
|
58681
58691
|
});
|
|
58682
|
-
var legacyMessageThreadSchema = messageThreadSchema.extend({
|
|
58683
|
-
name: exports_external.string(),
|
|
58684
|
-
lastReplyAt: exports_external.string().optional(),
|
|
58685
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.extend({ avatar: exports_external.string() })).optional()
|
|
58686
|
-
});
|
|
58687
|
-
var messageThreadPreviewSchema = messageThreadSchema.partial().required({ id: true }).extend({
|
|
58688
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.partial().required({ id: true })).optional()
|
|
58689
|
-
});
|
|
58690
58692
|
var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
58691
58693
|
id,
|
|
58692
58694
|
channelId: id,
|
|
@@ -58709,7 +58711,7 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
58709
58711
|
authorName: exports_external.string(),
|
|
58710
58712
|
text: exports_external.string(),
|
|
58711
58713
|
deleted: exports_external.boolean().optional()
|
|
58712
|
-
}).optional(),
|
|
58714
|
+
}).refine((reply) => reply.deleted === true || reply.authorId !== undefined, { message: "Live reply author identity missing" }).optional(),
|
|
58713
58715
|
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
58714
58716
|
reactions: exports_external.array(exports_external.strictObject({
|
|
58715
58717
|
emoji: exports_external.string(),
|
|
@@ -58721,21 +58723,37 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
58721
58723
|
approval: FriendApprovalPayloadSchema.optional(),
|
|
58722
58724
|
botCreation: BotCreationPayloadSchema.optional()
|
|
58723
58725
|
});
|
|
58724
|
-
|
|
58725
|
-
|
|
58726
|
-
|
|
58727
|
-
|
|
58726
|
+
function communityMessageProfileIds(messages) {
|
|
58727
|
+
return [...new Set(messages.flatMap((message2) => [message2.authorId, ...message2.replyTo?.authorId && message2.replyTo.deleted !== true ? [message2.replyTo.authorId] : []]))];
|
|
58728
|
+
}
|
|
58729
|
+
var CommunityMessageResourcesSchema = exports_external.strictObject({
|
|
58730
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
58731
|
+
profiles: exports_external.array(CommunityResourceProfileSchema)
|
|
58732
|
+
}).superRefine((resources, ctx) => {
|
|
58733
|
+
const ids = new Set(resources.profiles.map((profile2) => profile2.id));
|
|
58734
|
+
if (ids.size !== resources.profiles.length || communityMessageProfileIds(resources.messages).some((id2) => !ids.has(id2))) {
|
|
58735
|
+
ctx.addIssue({ code: "custom", path: ["profiles"], message: "Message profile missing or duplicated in resource graph" });
|
|
58736
|
+
}
|
|
58737
|
+
});
|
|
58728
58738
|
var CommunityReadStateResourceSchema = exports_external.strictObject({
|
|
58729
58739
|
channelId: id,
|
|
58730
58740
|
lastReadMessageId: nullableId,
|
|
58731
58741
|
lastReadAt: exports_external.string().nullable(),
|
|
58732
58742
|
lastReadSeq: exports_external.number().int().nonnegative()
|
|
58733
58743
|
});
|
|
58734
|
-
var
|
|
58744
|
+
var CommunityServerMembershipResourceSchema = exports_external.strictObject({
|
|
58745
|
+
serverId: id,
|
|
58746
|
+
userId: id,
|
|
58747
|
+
memberId: id,
|
|
58748
|
+
role: exports_external.string()
|
|
58749
|
+
});
|
|
58750
|
+
var CommunityChannelMembershipResourceSchema = exports_external.strictObject({
|
|
58735
58751
|
channelId: id,
|
|
58736
58752
|
userId: id,
|
|
58737
58753
|
relation: exports_external.enum(["access", "notify"]),
|
|
58738
|
-
source: exports_external.
|
|
58754
|
+
source: exports_external.enum([...Object.values(PARTICIPANT_SOURCE), "explicit", "inherited", "admin", "access-decision"])
|
|
58755
|
+
});
|
|
58756
|
+
var CommunityMemberRelationSchema = CommunityChannelMembershipResourceSchema.extend({
|
|
58739
58757
|
isCreator: exports_external.boolean(),
|
|
58740
58758
|
role: exports_external.string().nullable(),
|
|
58741
58759
|
memberId: nullableId
|
|
@@ -58748,14 +58766,25 @@ var CommunityPageSchema = exports_external.strictObject({
|
|
|
58748
58766
|
latestSeq: exports_external.number().int().nonnegative()
|
|
58749
58767
|
});
|
|
58750
58768
|
var envelope = { contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), channelId: id };
|
|
58769
|
+
var CommunityResourceBundleSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
58770
|
+
viewerId: id,
|
|
58771
|
+
servers: exports_external.array(CommunityServerResourceSchema),
|
|
58772
|
+
serverMemberships: exports_external.array(CommunityServerMembershipResourceSchema),
|
|
58773
|
+
channels: exports_external.array(CommunityChannelResourceSchema),
|
|
58774
|
+
memberships: exports_external.array(CommunityChannelMembershipResourceSchema)
|
|
58775
|
+
}).superRefine((bundle, ctx) => {
|
|
58776
|
+
const channels = new Set(bundle.channels.map((row) => row.id));
|
|
58777
|
+
const servers = new Set(bundle.servers.map((row) => row.id));
|
|
58778
|
+
if (channels.size !== bundle.channels.length || servers.size !== bundle.servers.length || new Set(bundle.messages.map((row) => row.id)).size !== bundle.messages.length || new Set(bundle.profiles.map((row) => row.id)).size !== bundle.profiles.length || new Set(bundle.memberships.map((row) => `${row.channelId}:${row.userId}:${row.relation}`)).size !== bundle.memberships.length || new Set(bundle.serverMemberships.map((row) => `${row.serverId}:${row.userId}`)).size !== bundle.serverMemberships.length || bundle.messages.some((row) => !channels.has(row.channelId)) || bundle.servers.some((row) => !bundle.serverMemberships.some((member2) => member2.serverId === row.id && member2.userId === bundle.viewerId)) || bundle.channels.some((row) => !bundle.memberships.some((member2) => member2.channelId === row.id && member2.userId === bundle.viewerId && member2.relation === "access")) || bundle.channels.some((row) => row.serverId !== null && !servers.has(row.serverId) || row.parentChannelId !== null && !channels.has(row.parentChannelId)) || bundle.memberships.some((row) => row.userId !== bundle.viewerId || !channels.has(row.channelId)) || bundle.serverMemberships.some((row) => row.userId !== bundle.viewerId || !servers.has(row.serverId)))
|
|
58779
|
+
ctx.addIssue({ code: "custom", message: "Resource bundle scope mismatch" });
|
|
58780
|
+
});
|
|
58751
58781
|
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
58752
|
-
var CommunityMessagesReadSchema =
|
|
58782
|
+
var CommunityMessagesReadSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
58753
58783
|
...envelope,
|
|
58754
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
58755
58784
|
page: CommunityPageSchema,
|
|
58756
58785
|
surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
|
|
58757
58786
|
});
|
|
58758
|
-
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.
|
|
58787
|
+
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.safeExtend({
|
|
58759
58788
|
viewerId: id,
|
|
58760
58789
|
peer: CommunityResourceProfileSchema.nullable(),
|
|
58761
58790
|
channel: CommunityChannelResourceSchema,
|
|
@@ -58770,6 +58799,12 @@ var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
|
58770
58799
|
anchorMessageId: nullableId
|
|
58771
58800
|
})
|
|
58772
58801
|
}).superRefine((entry, ctx) => {
|
|
58802
|
+
if (entry.opener) {
|
|
58803
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [...entry.messages, entry.opener], profiles: entry.profiles });
|
|
58804
|
+
if (!graph.success)
|
|
58805
|
+
for (const issue3 of graph.error.issues)
|
|
58806
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
58807
|
+
}
|
|
58773
58808
|
for (const [path13, channelId] of [
|
|
58774
58809
|
[["channel", "id"], entry.channel.id],
|
|
58775
58810
|
[["access", "channelId"], entry.access.channelId],
|
|
@@ -58807,72 +58842,37 @@ var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
|
58807
58842
|
if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
|
|
58808
58843
|
ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
|
|
58809
58844
|
});
|
|
58810
|
-
var
|
|
58845
|
+
var CommunityMessageReadSchema = exports_external.strictObject({
|
|
58846
|
+
...envelope,
|
|
58811
58847
|
message: CommunityMessageResourceSchema,
|
|
58812
|
-
|
|
58813
|
-
|
|
58848
|
+
profiles: CommunityMessageResourcesSchema.shape.profiles
|
|
58849
|
+
}).superRefine((read, ctx) => {
|
|
58850
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [read.message], profiles: read.profiles });
|
|
58851
|
+
if (!graph.success)
|
|
58852
|
+
for (const issue3 of graph.error.issues)
|
|
58853
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
58814
58854
|
});
|
|
58815
|
-
var
|
|
58855
|
+
var CommunityMessagePostedSchema = CommunityMessageReadSchema.safeExtend({ deduped: exports_external.boolean(), threadId: id.optional() });
|
|
58816
58856
|
var CommunityMembersReadSchema = exports_external.strictObject({ ...envelope, relation: exports_external.enum(["access", "notify"]), members: exports_external.array(CommunityMemberRelationSchema), profiles: exports_external.array(CommunityResourceProfileSchema) });
|
|
58817
58857
|
var CommunityThreadsReadSchema = exports_external.strictObject({
|
|
58818
58858
|
...envelope,
|
|
58819
58859
|
channel: CommunityChannelResourceSchema,
|
|
58820
58860
|
threads: exports_external.array(CommunityChannelResourceSchema),
|
|
58821
|
-
included:
|
|
58822
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
58861
|
+
included: CommunityMessageResourcesSchema.safeExtend({
|
|
58823
58862
|
members: exports_external.array(CommunityMemberRelationSchema),
|
|
58824
|
-
profiles: exports_external.array(CommunityResourceProfileSchema),
|
|
58825
58863
|
tags: exports_external.array(exports_external.strictObject({ messageId: id, tag: exports_external.string() })),
|
|
58826
58864
|
participantCounts: exports_external.array(exports_external.strictObject({ channelId: id, count: exports_external.number().int().nonnegative() }))
|
|
58827
58865
|
}),
|
|
58828
58866
|
page: exports_external.strictObject({ nextCursor: exports_external.string().nullable(), hasMore: exports_external.boolean() })
|
|
58829
58867
|
});
|
|
58830
58868
|
var CommunityReadAdvanceSchema = exports_external.strictObject({ ...envelope, changed: exports_external.boolean(), targetSeq: exports_external.number().int().nonnegative(), revision: exports_external.number().int().nonnegative() });
|
|
58869
|
+
var CommunityInviteJoinTargetSchema = exports_external.object({ serverId: CommunityServerResourceSchema.shape.id }).strip();
|
|
58831
58870
|
var CommunityReadErrorSchema = exports_external.strictObject({ contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), error: exports_external.strictObject({
|
|
58832
58871
|
code: exports_external.enum(["invalid_input", "invalid_reply_target", "unauthenticated", "not_found", "not_allowed", "blocked", "idempotency_conflict", "rate_limited", "temporarily_unavailable"]),
|
|
58833
58872
|
message: exports_external.string(),
|
|
58834
|
-
retryable: exports_external.boolean()
|
|
58873
|
+
retryable: exports_external.boolean(),
|
|
58874
|
+
details: exports_external.array(exports_external.string()).optional()
|
|
58835
58875
|
}) });
|
|
58836
|
-
var legacyProfileSchema = CommunityResourceProfileSchema.pick({
|
|
58837
|
-
id: true,
|
|
58838
|
-
name: true,
|
|
58839
|
-
avatar: true,
|
|
58840
|
-
avatarVersion: true
|
|
58841
|
-
}).extend({ discriminator: exports_external.string().nullable(), statusEmoji: exports_external.string().nullable(), statusText: exports_external.string() });
|
|
58842
|
-
var CommunityLegacyMessageResourceSchema = CommunityMessageResourceSchema.extend({ authorAvatar: exports_external.string().optional(), attachments: exports_external.array(CommunityLegacyMessageAttachmentSchema), thread: legacyMessageThreadSchema.optional() });
|
|
58843
|
-
var legacyEnvelope = { contractVersion: exports_external.literal(2), channelId: id };
|
|
58844
|
-
var legacyReadSchemas = {
|
|
58845
|
-
channel: CommunityChannelReadSchema.extend(legacyEnvelope),
|
|
58846
|
-
messages: CommunityMessagesReadSchema.extend({ ...legacyEnvelope, messages: exports_external.array(CommunityLegacyMessageResourceSchema) }),
|
|
58847
|
-
members: CommunityMembersReadSchema.extend({ ...legacyEnvelope, profiles: exports_external.array(legacyProfileSchema) }),
|
|
58848
|
-
threads: CommunityThreadsReadSchema.extend({ ...legacyEnvelope, included: CommunityThreadsReadSchema.shape.included.extend({
|
|
58849
|
-
messages: exports_external.array(CommunityLegacyMessageResourceSchema),
|
|
58850
|
-
profiles: exports_external.array(legacyProfileSchema)
|
|
58851
|
-
}) }),
|
|
58852
|
-
readAdvance: CommunityReadAdvanceSchema.extend(legacyEnvelope),
|
|
58853
|
-
error: CommunityReadErrorSchema.extend({ contractVersion: exports_external.literal(2) })
|
|
58854
|
-
};
|
|
58855
|
-
var legacyChannelResourcePreviewSchema = CommunityChannelResourceSchema.partial().strip().extend({
|
|
58856
|
-
archived: legacyArchivedSchema.optional()
|
|
58857
|
-
});
|
|
58858
|
-
var legacyChannelResourceSchema = CommunityChannelResourceSchema.strip().extend({
|
|
58859
|
-
topic: CommunityChannelResourceSchema.shape.topic.nullish().transform((value) => value ?? ""),
|
|
58860
|
-
position: CommunityChannelResourceSchema.shape.position.nullish().transform((value) => value ?? 0),
|
|
58861
|
-
messageCount: CommunityChannelResourceSchema.shape.messageCount.nullish().transform((value) => value ?? 0),
|
|
58862
|
-
categoryId: nullableId.default(null),
|
|
58863
|
-
parentChannelId: nullableId.default(null),
|
|
58864
|
-
parentMessageId: nullableId.default(null),
|
|
58865
|
-
creatorId: nullableId.default(null),
|
|
58866
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null),
|
|
58867
|
-
archived: legacyArchivedSchema
|
|
58868
|
-
});
|
|
58869
|
-
var legacyMessageResourceSchema = CommunityLegacyMessageResourceSchema.strip().extend({
|
|
58870
|
-
channelId: id.optional(),
|
|
58871
|
-
replyToId: nullableId.optional(),
|
|
58872
|
-
clientNonce: CommunityMessageResourceSchema.shape.clientNonce.default(null),
|
|
58873
|
-
attachments: CommunityLegacyMessageResourceSchema.shape.attachments.default([]),
|
|
58874
|
-
embeds: CommunityMessageResourceSchema.shape.embeds.nullable().transform((value) => value ?? undefined)
|
|
58875
|
-
});
|
|
58876
58876
|
|
|
58877
58877
|
// ../shared/src/community-attention.ts
|
|
58878
58878
|
var id2 = exports_external.string().min(1);
|
|
@@ -58927,11 +58927,7 @@ var AttentionItemSchema = exports_external.strictObject({
|
|
|
58927
58927
|
ctx.addIssue({ code: "custom", message: "mention or reply cannot carry forum presentation refs" });
|
|
58928
58928
|
}
|
|
58929
58929
|
});
|
|
58930
|
-
var AttentionIncludedServerSchema =
|
|
58931
|
-
id: id2,
|
|
58932
|
-
name: exports_external.string(),
|
|
58933
|
-
discriminator: exports_external.string()
|
|
58934
|
-
});
|
|
58930
|
+
var AttentionIncludedServerSchema = CommunityServerResourceSchema.pick({ id: true, name: true, discriminator: true });
|
|
58935
58931
|
var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
58936
58932
|
id: true,
|
|
58937
58933
|
serverId: true,
|
|
@@ -58952,20 +58948,17 @@ var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
|
58952
58948
|
var AttentionIncludedDmSchema = exports_external.strictObject({
|
|
58953
58949
|
id: id2,
|
|
58954
58950
|
userId: id2,
|
|
58955
|
-
name:
|
|
58956
|
-
discriminator: exports_external.string(),
|
|
58957
|
-
avatar: exports_external.string(),
|
|
58958
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
58951
|
+
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
58959
58952
|
lastMessageAt: exports_external.string(),
|
|
58960
58953
|
lastUnreadSeq: exports_external.number().int().nonnegative()
|
|
58961
58954
|
});
|
|
58962
58955
|
var AttentionIncludedProfileSchema = exports_external.strictObject({
|
|
58963
58956
|
userId: CommunityResourceProfileSchema.shape.id,
|
|
58964
58957
|
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
58965
|
-
discriminator:
|
|
58966
|
-
avatar:
|
|
58958
|
+
discriminator: CommunityResourceProfileSchema.shape.discriminator,
|
|
58959
|
+
avatar: CommunityResourceProfileSchema.shape.avatar
|
|
58967
58960
|
});
|
|
58968
|
-
var AttentionIncludedMessageSchema =
|
|
58961
|
+
var AttentionIncludedMessageSchema = CommunityMessageResourceSchema.pick({
|
|
58969
58962
|
id: true,
|
|
58970
58963
|
channelId: true,
|
|
58971
58964
|
type: true,
|
|
@@ -58974,7 +58967,7 @@ var AttentionIncludedMessageSchema = CommunityMessagePreviewSchema.pick({
|
|
|
58974
58967
|
seq: true,
|
|
58975
58968
|
createdAt: true,
|
|
58976
58969
|
content: true
|
|
58977
|
-
}).
|
|
58970
|
+
}).partial({ authorId: true });
|
|
58978
58971
|
var AttentionIncludedSchema = exports_external.strictObject({
|
|
58979
58972
|
servers: exports_external.array(AttentionIncludedServerSchema),
|
|
58980
58973
|
channels: exports_external.array(AttentionIncludedChannelSchema),
|
|
@@ -58982,13 +58975,19 @@ var AttentionIncludedSchema = exports_external.strictObject({
|
|
|
58982
58975
|
profiles: exports_external.array(AttentionIncludedProfileSchema),
|
|
58983
58976
|
messages: exports_external.array(AttentionIncludedMessageSchema)
|
|
58984
58977
|
});
|
|
58985
|
-
var
|
|
58978
|
+
var AccountAttentionProjectionSchema = exports_external.strictObject({
|
|
58986
58979
|
scopes: exports_external.array(AttentionScopeSchema),
|
|
58987
58980
|
items: exports_external.array(AttentionItemSchema),
|
|
58988
58981
|
limit: exports_external.number().int().positive(),
|
|
58989
58982
|
truncated: exports_external.boolean(),
|
|
58990
58983
|
included: AttentionIncludedSchema
|
|
58984
|
+
});
|
|
58985
|
+
var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
58986
|
+
resources: CommunityResourceBundleSchema
|
|
58991
58987
|
}).superRefine((snapshot, ctx) => {
|
|
58988
|
+
const resources = snapshot.resources;
|
|
58989
|
+
if (snapshot.included.servers.some((summary) => !resources.servers.some((row) => row.id === summary.id)) || [...snapshot.included.channels, ...snapshot.included.dms].some((summary) => !resources.channels.some((row) => row.id === summary.id)) || snapshot.included.profiles.some((summary) => !resources.profiles.some((row) => row.id === summary.userId)) || snapshot.included.messages.some((summary) => !resources.messages.some((row) => row.id === summary.id && row.channelId === summary.channelId)) || resources.memberships.some((row) => row.userId !== resources.viewerId || row.relation !== "access" || !resources.channels.some((channel2) => channel2.id === row.channelId)) || resources.serverMemberships.some((row) => row.userId !== resources.viewerId || !resources.servers.some((server) => server.id === row.serverId)))
|
|
58990
|
+
ctx.addIssue({ code: "custom", message: "Attention resource closure mismatch" });
|
|
58992
58991
|
const scopeIds = new Set;
|
|
58993
58992
|
for (const scope of snapshot.scopes) {
|
|
58994
58993
|
if (scopeIds.has(scope.scopeId)) {
|
|
@@ -59783,52 +59782,85 @@ var AGENT_UNREAD_CHANNEL_CHUNK_SIZE = maxInParams(13);
|
|
|
59783
59782
|
|
|
59784
59783
|
// ../shared/src/db/queries/community/mention.ts
|
|
59785
59784
|
var MENTION_INSERT_MAX_ROWS = maxRowsPerInsert(5);
|
|
59785
|
+
// ../shared/src/community-cache.ts
|
|
59786
|
+
var nullableString = exports_external.string().nullable();
|
|
59787
|
+
var optionalNullableString = nullableString.optional();
|
|
59788
|
+
var serverSchema = CommunityServerResourceSchema;
|
|
59789
|
+
var categorySchema = CommunityCategoryResourceSchema.extend({ pending: exports_external.boolean() });
|
|
59790
|
+
var channelLocalSchema = exports_external.strictObject({
|
|
59791
|
+
muted: exports_external.boolean(),
|
|
59792
|
+
tags: exports_external.array(exports_external.string()),
|
|
59793
|
+
pending: exports_external.boolean(),
|
|
59794
|
+
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
59795
|
+
openerUnread: exports_external.boolean().optional(),
|
|
59796
|
+
preview: exports_external.string().optional(),
|
|
59797
|
+
firstMessageId: exports_external.string().min(1).nullable().optional(),
|
|
59798
|
+
participantCount: exports_external.number().int().nonnegative().optional()
|
|
59799
|
+
});
|
|
59800
|
+
var channelSchema = CommunityChannelResourceSchema.extend(channelLocalSchema.shape);
|
|
59801
|
+
var serverMembershipSchema = CommunityServerMembershipResourceSchema.extend({
|
|
59802
|
+
id: exports_external.string().min(1),
|
|
59803
|
+
nickname: optionalNullableString,
|
|
59804
|
+
joinedAt: exports_external.string().optional(),
|
|
59805
|
+
viewer: exports_external.boolean()
|
|
59806
|
+
});
|
|
59807
|
+
var channelMembershipSchema = CommunityChannelMembershipResourceSchema.extend({ id: exports_external.string().min(1) });
|
|
59808
|
+
var readStateSchema = CommunityReadStateResourceSchema.extend({ observedRevision: exports_external.number().int().nonnegative().optional() });
|
|
59809
|
+
var friendshipSchema = exports_external.strictObject({
|
|
59810
|
+
id: exports_external.string().min(1),
|
|
59811
|
+
userId: exports_external.string().min(1),
|
|
59812
|
+
kind: exports_external.enum(["accepted", "incoming", "outgoing", "blocked"]),
|
|
59813
|
+
sub: exports_external.string().optional(),
|
|
59814
|
+
needsOwnerApproval: optionalNullableString
|
|
59815
|
+
});
|
|
59816
|
+
var readStateClockSchema = exports_external.strictObject({
|
|
59817
|
+
id: exports_external.literal("account"),
|
|
59818
|
+
revision: exports_external.number().int().nonnegative()
|
|
59819
|
+
});
|
|
59820
|
+
var folderSchema = exports_external.strictObject({
|
|
59821
|
+
id: exports_external.string().min(1),
|
|
59822
|
+
name: exports_external.string()
|
|
59823
|
+
});
|
|
59824
|
+
var serverRailSchema = exports_external.strictObject({
|
|
59825
|
+
id: exports_external.literal("account"),
|
|
59826
|
+
entries: exports_external.array(serverRailEntrySchema)
|
|
59827
|
+
});
|
|
59828
|
+
var folderItemSchema = exports_external.strictObject({
|
|
59829
|
+
id: exports_external.string().min(1),
|
|
59830
|
+
folderId: exports_external.string().min(1),
|
|
59831
|
+
serverId: exports_external.string().min(1),
|
|
59832
|
+
position: exports_external.number()
|
|
59833
|
+
});
|
|
59834
|
+
var notificationSettingSchema = exports_external.strictObject({
|
|
59835
|
+
id: exports_external.string().min(1),
|
|
59836
|
+
serverId: optionalNullableString,
|
|
59837
|
+
channelId: optionalNullableString,
|
|
59838
|
+
level: exports_external.string()
|
|
59839
|
+
}).superRefine((row, ctx) => {
|
|
59840
|
+
if (Boolean(row.serverId) === Boolean(row.channelId)) {
|
|
59841
|
+
ctx.addIssue({
|
|
59842
|
+
code: "custom",
|
|
59843
|
+
message: "notification setting requires exactly one target"
|
|
59844
|
+
});
|
|
59845
|
+
}
|
|
59846
|
+
});
|
|
59847
|
+
|
|
59786
59848
|
// ../shared/src/community-ws-events.ts
|
|
59787
59849
|
var string4 = exports_external.string();
|
|
59788
|
-
var
|
|
59850
|
+
var nullableString2 = string4.nullable();
|
|
59789
59851
|
var channelTypeSchema = CommunityChannelResourceSchema.shape.type.extract(["text", "forum"]);
|
|
59790
|
-
var
|
|
59791
|
-
id: string4,
|
|
59792
|
-
filename: string4,
|
|
59793
|
-
url: string4,
|
|
59794
|
-
thumbnailUrl: string4.optional(),
|
|
59795
|
-
contentType: string4.optional(),
|
|
59796
|
-
size: exports_external.number().optional(),
|
|
59797
|
-
width: exports_external.number().nullable().optional(),
|
|
59798
|
-
height: exports_external.number().nullable().optional()
|
|
59799
|
-
});
|
|
59800
|
-
var messageSchema = CommunityMessageResourceSchema.pick({
|
|
59801
|
-
content: true,
|
|
59802
|
-
type: true,
|
|
59803
|
-
systemKind: true,
|
|
59804
|
-
authorAvatar: true,
|
|
59805
|
-
authorAvatarVersion: true,
|
|
59806
|
-
mentionType: true,
|
|
59807
|
-
embeds: true,
|
|
59808
|
-
createdAt: true,
|
|
59809
|
-
approval: true,
|
|
59810
|
-
botCreation: true
|
|
59811
|
-
}).extend({
|
|
59812
|
-
id: string4,
|
|
59813
|
-
seq: exports_external.number(),
|
|
59814
|
-
authorId: string4,
|
|
59815
|
-
authorName: string4,
|
|
59816
|
-
authorAvatar: string4.optional(),
|
|
59817
|
-
authorAvatarVersion: CommunityMessageResourceSchema.shape.authorAvatarVersion.unwrap(),
|
|
59818
|
-
replyToId: nullableString.optional(),
|
|
59819
|
-
replyTo: CommunityMessageResourceSchema.shape.replyTo.unwrap().extend({
|
|
59820
|
-
id: string4,
|
|
59821
|
-
authorId: string4.optional()
|
|
59822
|
-
}).optional(),
|
|
59823
|
-
attachments: exports_external.array(messageAttachmentSchema).optional(),
|
|
59824
|
-
clientNonce: string4.optional()
|
|
59825
|
-
});
|
|
59826
|
-
var CommunityLegacyMessageCreateSchema = exports_external.strictObject({
|
|
59852
|
+
var communityMessageCreateSchema = exports_external.strictObject({
|
|
59827
59853
|
type: exports_external.literal("community:message.create"),
|
|
59828
59854
|
channelId: string4,
|
|
59829
59855
|
serverId: string4.optional(),
|
|
59830
59856
|
parentChannelId: string4.optional(),
|
|
59831
|
-
message:
|
|
59857
|
+
message: CommunityMessageResourceSchema.required({ authorName: true, authorAvatarVersion: true }),
|
|
59858
|
+
profiles: CommunityMessageResourcesSchema.shape.profiles
|
|
59859
|
+
}).refine((event) => event.message.channelId === event.channelId).superRefine((event, ctx) => {
|
|
59860
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [event.message], profiles: event.profiles });
|
|
59861
|
+
if (!graph.success)
|
|
59862
|
+
for (const issue3 of graph.error.issues)
|
|
59863
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
59832
59864
|
});
|
|
59833
59865
|
var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
59834
59866
|
type: exports_external.literal("community:message.updated"),
|
|
@@ -59837,14 +59869,6 @@ var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
|
59837
59869
|
approval: FriendApprovalPayloadSchema.optional(),
|
|
59838
59870
|
botCreation: BotCreationPayloadSchema.optional()
|
|
59839
59871
|
}).refine((event) => event.approval !== undefined || event.botCreation !== undefined);
|
|
59840
|
-
var communityMessageEditedSchema = exports_external.strictObject({
|
|
59841
|
-
type: exports_external.literal("community:message.edited"),
|
|
59842
|
-
channelId: string4,
|
|
59843
|
-
messageId: string4,
|
|
59844
|
-
content: string4,
|
|
59845
|
-
parentChannelId: string4.optional(),
|
|
59846
|
-
serverId: string4.optional()
|
|
59847
|
-
}).refine((event) => event.parentChannelId === undefined || event.serverId !== undefined);
|
|
59848
59872
|
var communityReactionAddSchema = exports_external.strictObject({
|
|
59849
59873
|
type: exports_external.literal("community:reaction.add"),
|
|
59850
59874
|
channelId: string4,
|
|
@@ -59886,35 +59910,19 @@ var communityTypingStopSchema = exports_external.strictObject({
|
|
|
59886
59910
|
var communityChildChannelCreateSchema = exports_external.strictObject({
|
|
59887
59911
|
type: exports_external.literal("community:channel.child_create"),
|
|
59888
59912
|
parentChannelId: string4,
|
|
59889
|
-
channel: exports_external.
|
|
59890
|
-
id: string4,
|
|
59891
|
-
name: string4,
|
|
59892
|
-
type: exports_external.literal("thread"),
|
|
59893
|
-
creatorId: string4.optional(),
|
|
59894
|
-
createdAt: string4
|
|
59895
|
-
}),
|
|
59913
|
+
channel: CommunityChannelResourceSchema.extend({ type: exports_external.literal("thread") }),
|
|
59896
59914
|
parentMessageId: string4.optional()
|
|
59897
|
-
});
|
|
59915
|
+
}).refine((event) => event.channel.parentChannelId === event.parentChannelId && (event.parentMessageId === undefined || event.parentMessageId === event.channel.parentMessageId));
|
|
59898
59916
|
var communityChildChannelUpdateSchema = exports_external.strictObject({
|
|
59899
59917
|
type: exports_external.literal("community:channel.child_update"),
|
|
59900
59918
|
parentChannelId: string4,
|
|
59901
59919
|
channelId: string4,
|
|
59902
|
-
changes: exports_external.
|
|
59903
|
-
name: string4.optional(),
|
|
59904
|
-
archived: exports_external.boolean().optional(),
|
|
59905
|
-
tags: exports_external.array(string4).nullable().optional(),
|
|
59906
|
-
lastMessageAt: string4.optional(),
|
|
59907
|
-
messageCount: exports_external.number().optional()
|
|
59908
|
-
})
|
|
59920
|
+
changes: CommunityChannelResourceSchema.pick({ name: true, archived: true, lastMessageAt: true, messageCount: true }).partial().extend({ tags: exports_external.array(string4).nullable().optional() })
|
|
59909
59921
|
});
|
|
59910
59922
|
var communityServerUpdateSchema = exports_external.strictObject({
|
|
59911
59923
|
type: exports_external.literal("community:server.update"),
|
|
59912
59924
|
serverId: string4,
|
|
59913
|
-
changes:
|
|
59914
|
-
name: string4.optional(),
|
|
59915
|
-
description: string4.optional(),
|
|
59916
|
-
icon: nullableString.optional()
|
|
59917
|
-
})
|
|
59925
|
+
changes: serverSchema.pick({ name: true, description: true, icon: true }).partial()
|
|
59918
59926
|
});
|
|
59919
59927
|
var communityServerRailChangedSchema = exports_external.strictObject({
|
|
59920
59928
|
type: exports_external.literal("community:server_rail.changed")
|
|
@@ -59926,32 +59934,19 @@ var communityServerDeleteSchema = exports_external.strictObject({
|
|
|
59926
59934
|
var communityChannelCreateSchema = exports_external.strictObject({
|
|
59927
59935
|
type: exports_external.literal("community:channel.create"),
|
|
59928
59936
|
serverId: string4,
|
|
59929
|
-
channel:
|
|
59930
|
-
|
|
59931
|
-
name: string4,
|
|
59932
|
-
type: channelTypeSchema,
|
|
59933
|
-
categoryId: nullableString.optional(),
|
|
59934
|
-
topic: string4.optional(),
|
|
59935
|
-
position: exports_external.number(),
|
|
59936
|
-
createdAt: string4
|
|
59937
|
-
})
|
|
59938
|
-
});
|
|
59937
|
+
channel: CommunityChannelResourceSchema.extend({ type: channelTypeSchema })
|
|
59938
|
+
}).refine((event) => event.channel.serverId === event.serverId);
|
|
59939
59939
|
var communityChannelUpdateSchema = exports_external.strictObject({
|
|
59940
59940
|
type: exports_external.literal("community:channel.update"),
|
|
59941
59941
|
serverId: string4,
|
|
59942
59942
|
channelId: string4,
|
|
59943
|
-
changes:
|
|
59944
|
-
name: string4.optional(),
|
|
59945
|
-
topic: string4.optional(),
|
|
59946
|
-
categoryId: nullableString.optional(),
|
|
59947
|
-
type: channelTypeSchema.optional()
|
|
59948
|
-
})
|
|
59943
|
+
changes: CommunityChannelResourceSchema.pick({ name: true, topic: true, categoryId: true, type: true }).partial().extend({ type: channelTypeSchema.optional() })
|
|
59949
59944
|
});
|
|
59950
59945
|
var communityChannelDeleteSchema = exports_external.strictObject({
|
|
59951
59946
|
type: exports_external.literal("community:channel.delete"),
|
|
59952
59947
|
serverId: string4,
|
|
59953
59948
|
channelId: string4,
|
|
59954
|
-
parentChannelId:
|
|
59949
|
+
parentChannelId: nullableString2.optional(),
|
|
59955
59950
|
parentMessageId: string4.optional()
|
|
59956
59951
|
}).refine((event) => event.parentMessageId === undefined || typeof event.parentChannelId === "string" && event.parentChannelId.length > 0, { message: "parentMessageId requires parentChannelId" });
|
|
59957
59952
|
var positionedIdSchema = exports_external.strictObject({ id: string4, position: exports_external.number() });
|
|
@@ -59960,18 +59955,6 @@ var communityChannelReorderSchema = exports_external.strictObject({
|
|
|
59960
59955
|
serverId: string4,
|
|
59961
59956
|
channels: exports_external.array(positionedIdSchema)
|
|
59962
59957
|
});
|
|
59963
|
-
var communityChannelMemberAddSchema = exports_external.strictObject({
|
|
59964
|
-
type: exports_external.literal("community:channel.member_add"),
|
|
59965
|
-
serverId: string4,
|
|
59966
|
-
channelId: string4,
|
|
59967
|
-
userId: string4
|
|
59968
|
-
});
|
|
59969
|
-
var communityChannelMemberRemoveSchema = exports_external.strictObject({
|
|
59970
|
-
type: exports_external.literal("community:channel.member_remove"),
|
|
59971
|
-
serverId: string4,
|
|
59972
|
-
channelId: string4,
|
|
59973
|
-
userId: string4
|
|
59974
|
-
});
|
|
59975
59958
|
var communityChannelMembershipChangeSchema = exports_external.strictObject({
|
|
59976
59959
|
type: exports_external.literal("community:channel.membership.change"),
|
|
59977
59960
|
channelId: string4,
|
|
@@ -59983,12 +59966,7 @@ var communityChannelMembershipChangeSchema = exports_external.strictObject({
|
|
|
59983
59966
|
var communityCategoryCreateSchema = exports_external.strictObject({
|
|
59984
59967
|
type: exports_external.literal("community:category.create"),
|
|
59985
59968
|
serverId: string4,
|
|
59986
|
-
category:
|
|
59987
|
-
id: string4,
|
|
59988
|
-
name: string4,
|
|
59989
|
-
position: exports_external.number(),
|
|
59990
|
-
private: exports_external.boolean()
|
|
59991
|
-
})
|
|
59969
|
+
category: CommunityCategoryResourceSchema
|
|
59992
59970
|
});
|
|
59993
59971
|
var communityCategoryUpdateSchema = exports_external.strictObject({
|
|
59994
59972
|
type: exports_external.literal("community:category.update"),
|
|
@@ -60013,13 +59991,9 @@ var communityCategoryReorderSchema = exports_external.strictObject({
|
|
|
60013
59991
|
var communityMemberJoinSchema = exports_external.strictObject({
|
|
60014
59992
|
type: exports_external.literal("community:member.join"),
|
|
60015
59993
|
serverId: string4,
|
|
60016
|
-
member:
|
|
59994
|
+
member: CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).extend({
|
|
60017
59995
|
id: string4,
|
|
60018
59996
|
userId: string4,
|
|
60019
|
-
name: string4,
|
|
60020
|
-
discriminator: string4,
|
|
60021
|
-
avatar: string4.optional(),
|
|
60022
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
60023
59997
|
role: string4,
|
|
60024
59998
|
joinedAt: string4
|
|
60025
59999
|
})
|
|
@@ -60036,7 +60010,7 @@ var communityMemberUpdateSchema = exports_external.strictObject({
|
|
|
60036
60010
|
userId: string4.optional(),
|
|
60037
60011
|
changes: exports_external.strictObject({
|
|
60038
60012
|
role: string4.optional(),
|
|
60039
|
-
nickname:
|
|
60013
|
+
nickname: nullableString2.optional()
|
|
60040
60014
|
})
|
|
60041
60015
|
});
|
|
60042
60016
|
var communityFriendRequestSchema = exports_external.strictObject({
|
|
@@ -60067,7 +60041,7 @@ var communityFriendBlockSchema = exports_external.strictObject({
|
|
|
60067
60041
|
userId: string4,
|
|
60068
60042
|
blockedByViewer: exports_external.boolean().optional()
|
|
60069
60043
|
});
|
|
60070
|
-
var
|
|
60044
|
+
var CommunityInviteCreateSchema = exports_external.strictObject({
|
|
60071
60045
|
type: exports_external.literal("community:invite.create"),
|
|
60072
60046
|
serverId: string4,
|
|
60073
60047
|
invite: exports_external.strictObject({
|
|
@@ -60075,7 +60049,7 @@ var communityInviteCreateSchema = exports_external.strictObject({
|
|
|
60075
60049
|
token: string4,
|
|
60076
60050
|
maxUses: exports_external.number().nullable().optional(),
|
|
60077
60051
|
uses: exports_external.number().nullable().optional(),
|
|
60078
|
-
expiresAt:
|
|
60052
|
+
expiresAt: nullableString2.optional(),
|
|
60079
60053
|
createdAt: string4
|
|
60080
60054
|
})
|
|
60081
60055
|
});
|
|
@@ -60120,24 +60094,17 @@ var communityPresenceUpdateSchema = exports_external.strictObject({
|
|
|
60120
60094
|
var communityStatusUpdateSchema = exports_external.strictObject({
|
|
60121
60095
|
type: exports_external.literal("community:status.update"),
|
|
60122
60096
|
userId: string4,
|
|
60123
|
-
statusEmoji:
|
|
60124
|
-
statusText:
|
|
60097
|
+
statusEmoji: nullableString2,
|
|
60098
|
+
statusText: nullableString2
|
|
60125
60099
|
});
|
|
60126
|
-
var communityIdentityUpdateSchema =
|
|
60100
|
+
var communityIdentityUpdateSchema = CommunityResourceProfileSchema.pick({ avatar: true, avatarVersion: true }).extend({
|
|
60127
60101
|
type: exports_external.literal("community:identity.update"),
|
|
60128
60102
|
userId: string4,
|
|
60129
|
-
|
|
60130
|
-
avatarVersion: exports_external.number().int().positive()
|
|
60103
|
+
avatarVersion: CommunityResourceProfileSchema.shape.avatarVersion.refine((version3) => version3 > 0)
|
|
60131
60104
|
});
|
|
60132
|
-
var communityProfileUpdateSchema =
|
|
60105
|
+
var communityProfileUpdateSchema = CommunityResourceProfileSchema.pick({ name: true, discriminator: true, aboutMe: true, bannerColor: true, kind: true, ownerUserId: true }).required().extend({
|
|
60133
60106
|
type: exports_external.literal("community:profile.update"),
|
|
60134
|
-
userId: string4
|
|
60135
|
-
name: string4,
|
|
60136
|
-
discriminator: string4,
|
|
60137
|
-
aboutMe: string4,
|
|
60138
|
-
bannerColor: nullableString,
|
|
60139
|
-
kind: exports_external.enum(["human", "bot"]),
|
|
60140
|
-
ownerUserId: nullableString
|
|
60107
|
+
userId: string4
|
|
60141
60108
|
});
|
|
60142
60109
|
var communityMachineCreatedSchema = exports_external.strictObject({
|
|
60143
60110
|
type: exports_external.literal("community:machine.created"),
|
|
@@ -60164,8 +60131,8 @@ var communityBotAuditEventSchema = exports_external.strictObject({
|
|
|
60164
60131
|
id: string4,
|
|
60165
60132
|
kind: exports_external.enum(["cli_invocation", "tool_call", "thinking", "text", "turn_interrupt", "wake_trigger", "session_reset", "nap", "model_changed", "provider_changed", "error"]),
|
|
60166
60133
|
payload: exports_external.unknown(),
|
|
60167
|
-
sessionId:
|
|
60168
|
-
launchId:
|
|
60134
|
+
sessionId: nullableString2.optional(),
|
|
60135
|
+
launchId: nullableString2.optional(),
|
|
60169
60136
|
createdAt: string4
|
|
60170
60137
|
}).refine((event) => Object.prototype.hasOwnProperty.call(event, "payload"));
|
|
60171
60138
|
var communityRuntimeModelsSchema = exports_external.strictObject({
|
|
@@ -60185,7 +60152,6 @@ var communityBotPiiSchema = exports_external.strictObject({
|
|
|
60185
60152
|
var commonCommunityEventSchemas = [
|
|
60186
60153
|
communityBotPiiSchema,
|
|
60187
60154
|
communityMessageUpdatedSchema,
|
|
60188
|
-
communityMessageEditedSchema,
|
|
60189
60155
|
communityReactionAddSchema,
|
|
60190
60156
|
communityReactionRemoveSchema,
|
|
60191
60157
|
communityPinAddSchema,
|
|
@@ -60197,8 +60163,6 @@ var commonCommunityEventSchemas = [
|
|
|
60197
60163
|
communityServerDeleteSchema,
|
|
60198
60164
|
communityChannelDeleteSchema,
|
|
60199
60165
|
communityChannelReorderSchema,
|
|
60200
|
-
communityChannelMemberAddSchema,
|
|
60201
|
-
communityChannelMemberRemoveSchema,
|
|
60202
60166
|
communityChannelMembershipChangeSchema,
|
|
60203
60167
|
communityCategoryCreateSchema,
|
|
60204
60168
|
communityCategoryUpdateSchema,
|
|
@@ -60212,7 +60176,7 @@ var commonCommunityEventSchemas = [
|
|
|
60212
60176
|
communityFriendRejectSchema,
|
|
60213
60177
|
communityFriendRemoveSchema,
|
|
60214
60178
|
communityFriendBlockSchema,
|
|
60215
|
-
|
|
60179
|
+
CommunityInviteCreateSchema,
|
|
60216
60180
|
communityMentionCreateSchema,
|
|
60217
60181
|
communityUnreadBumpSchema,
|
|
60218
60182
|
communityReadStateAdvancedSchema,
|
|
@@ -60226,9 +60190,9 @@ var commonCommunityEventSchemas = [
|
|
|
60226
60190
|
communityMachineRemovedSchema,
|
|
60227
60191
|
communityBotAuditEventSchema
|
|
60228
60192
|
];
|
|
60229
|
-
var
|
|
60193
|
+
var CommunityWsEventSchema = exports_external.discriminatedUnion("type", [
|
|
60230
60194
|
...commonCommunityEventSchemas,
|
|
60231
|
-
|
|
60195
|
+
communityMessageCreateSchema,
|
|
60232
60196
|
communityChildChannelCreateSchema,
|
|
60233
60197
|
communityChannelCreateSchema,
|
|
60234
60198
|
communityChildChannelUpdateSchema,
|
|
@@ -60236,22 +60200,9 @@ var CommunityWsEventDiscriminatedSchema = exports_external.discriminatedUnion("t
|
|
|
60236
60200
|
communityIdentityUpdateSchema,
|
|
60237
60201
|
communityProfileUpdateSchema
|
|
60238
60202
|
]);
|
|
60239
|
-
var CommunityResourceWsEventDiscriminatedSchema = exports_external.discriminatedUnion("type", [
|
|
60240
|
-
...commonCommunityEventSchemas,
|
|
60241
|
-
CommunityLegacyMessageCreateSchema.extend({ message: CommunityMessageResourceSchema.required({ authorName: true, authorAvatarVersion: true }) }).refine((event) => event.message.channelId === event.channelId),
|
|
60242
|
-
communityChildChannelCreateSchema.extend({ channel: CommunityChannelResourceSchema.extend({ type: exports_external.literal("thread") }) }).refine((event) => event.channel.parentChannelId === event.parentChannelId && (event.parentMessageId === undefined || event.parentMessageId === event.channel.parentMessageId)),
|
|
60243
|
-
communityChannelCreateSchema.extend({ channel: CommunityChannelResourceSchema.extend({ type: channelTypeSchema }) }).refine((event) => event.channel.serverId === event.serverId),
|
|
60244
|
-
communityChildChannelUpdateSchema.extend({ changes: CommunityChannelResourceSchema.pick({ name: true, archived: true, lastMessageAt: true, messageCount: true }).partial().extend({ tags: exports_external.array(string4).nullable().optional() }) }),
|
|
60245
|
-
communityChannelUpdateSchema.extend({ changes: CommunityChannelResourceSchema.pick({ name: true, topic: true, categoryId: true, type: true }).partial().extend({ type: channelTypeSchema.optional() }) }),
|
|
60246
|
-
communityIdentityUpdateSchema.extend({ avatar: CommunityResourceProfileSchema.shape.avatar, avatarVersion: CommunityResourceProfileSchema.shape.avatarVersion.refine((version3) => version3 > 0) }),
|
|
60247
|
-
CommunityResourceProfileSchema.pick({ name: true, discriminator: true, aboutMe: true, bannerColor: true, kind: true, ownerUserId: true }).required().extend({ type: exports_external.literal("community:profile.update"), userId: string4 })
|
|
60248
|
-
]);
|
|
60249
|
-
var CommunityWsEventSchema = CommunityWsEventDiscriminatedSchema.transform((event) => event);
|
|
60250
|
-
var CommunityResourceWsEventSchema = CommunityResourceWsEventDiscriminatedSchema.transform((event) => event);
|
|
60251
60203
|
var WS_EVENTS = {
|
|
60252
60204
|
MESSAGE_CREATE: "community:message.create",
|
|
60253
60205
|
MESSAGE_UPDATED: "community:message.updated",
|
|
60254
|
-
MESSAGE_EDITED: "community:message.edited",
|
|
60255
60206
|
REACTION_ADD: "community:reaction.add",
|
|
60256
60207
|
REACTION_REMOVE: "community:reaction.remove",
|
|
60257
60208
|
PIN_ADD: "community:pin.add",
|
|
@@ -60267,8 +60218,6 @@ var WS_EVENTS = {
|
|
|
60267
60218
|
CHANNEL_UPDATE: "community:channel.update",
|
|
60268
60219
|
CHANNEL_DELETE: "community:channel.delete",
|
|
60269
60220
|
CHANNEL_REORDER: "community:channel.reorder",
|
|
60270
|
-
CHANNEL_MEMBER_ADD: "community:channel.member_add",
|
|
60271
|
-
CHANNEL_MEMBER_REMOVE: "community:channel.member_remove",
|
|
60272
60221
|
CHANNEL_MEMBERSHIP_CHANGE: "community:channel.membership.change",
|
|
60273
60222
|
CATEGORY_CREATE: "community:category.create",
|
|
60274
60223
|
CATEGORY_UPDATE: "community:category.update",
|
|
@@ -60328,20 +60277,14 @@ var MESSAGE_DELIVERY_MAX_USERS = 1000;
|
|
|
60328
60277
|
var MESSAGE_DELIVERY_MAX_EVENTS_PER_USER = 5;
|
|
60329
60278
|
var target = exports_external.string().refine(isValidCommunityUserTarget);
|
|
60330
60279
|
var targetList = exports_external.array(target).max(MESSAGE_DELIVERY_MAX_USERS);
|
|
60331
|
-
var memberAddedSchema = exports_external.strictObject({
|
|
60332
|
-
userId: target,
|
|
60333
|
-
serverId: exports_external.string().min(1),
|
|
60334
|
-
channelId: exports_external.string().min(1)
|
|
60335
|
-
});
|
|
60336
60280
|
var batchShape = exports_external.strictObject({
|
|
60337
|
-
communityContract: exports_external.literal(
|
|
60281
|
+
communityContract: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
60338
60282
|
messageId: exports_external.string().min(1),
|
|
60339
60283
|
messageEvent: exports_external.unknown(),
|
|
60340
60284
|
contentUserIds: targetList,
|
|
60341
60285
|
unreadPlainUserIds: targetList,
|
|
60342
60286
|
unreadMentionUserIds: targetList,
|
|
60343
60287
|
mentionUserIds: targetList,
|
|
60344
|
-
memberAdded: memberAddedSchema.optional(),
|
|
60345
60288
|
joinedParticipantUserIds: targetList.optional(),
|
|
60346
60289
|
rosterRefreshUserId: target.optional(),
|
|
60347
60290
|
parentProjection: exports_external.unknown().optional(),
|
|
@@ -60600,6 +60543,199 @@ var channelReorderRequestSchema = exports_external.strictObject({
|
|
|
60600
60543
|
channelIds: exports_external.array(exports_external.string().min(1)).min(1).refine((ids) => new Set(ids).size === ids.length, "channelIds must be unique"),
|
|
60601
60544
|
move: exports_external.strictObject({ channelId: exports_external.string().min(1), categoryId: exports_external.string().min(1).nullable() }).optional()
|
|
60602
60545
|
}).refine((request) => !request.move || request.channelIds.includes(request.move.channelId), "moved channel must be included in channelIds");
|
|
60546
|
+
// ../shared/src/task-payload-cache.ts
|
|
60547
|
+
var TaskEmailAddressCacheSchema = exports_external.array(exports_external.strictObject({
|
|
60548
|
+
workspaceId: exports_external.string().min(1),
|
|
60549
|
+
agentId: exports_external.string().min(1),
|
|
60550
|
+
emailAddress: exports_external.string()
|
|
60551
|
+
}));
|
|
60552
|
+
var TaskMemberInstructionCacheSchema = exports_external.strictObject({
|
|
60553
|
+
workspaceId: exports_external.string().min(1),
|
|
60554
|
+
userId: exports_external.string().min(1),
|
|
60555
|
+
globalInstruction: exports_external.string()
|
|
60556
|
+
}).nullable();
|
|
60557
|
+
var TaskUserIdentityCacheSchema = CommunityResourceProfileSchema.pick({ id: true, name: true }).extend({ email: exports_external.string() }).nullable();
|
|
60558
|
+
// ../shared/src/community-forum-sidebar.ts
|
|
60559
|
+
var timestamp = exports_external.string().refine((value) => Number.isFinite(Date.parse(value)));
|
|
60560
|
+
var CommunityForumSidebarChannelSummarySchema = CommunityChannelResourceSchema.pick({
|
|
60561
|
+
id: true,
|
|
60562
|
+
name: true,
|
|
60563
|
+
serverId: true,
|
|
60564
|
+
parentChannelId: true,
|
|
60565
|
+
parentMessageId: true
|
|
60566
|
+
}).extend({
|
|
60567
|
+
serverId: CommunityChannelResourceSchema.shape.serverId.unwrap(),
|
|
60568
|
+
parentChannelId: CommunityChannelResourceSchema.shape.parentChannelId.unwrap(),
|
|
60569
|
+
parentMessageId: CommunityChannelResourceSchema.shape.parentMessageId.unwrap(),
|
|
60570
|
+
activityAt: timestamp,
|
|
60571
|
+
expiresAt: timestamp,
|
|
60572
|
+
unread: exports_external.boolean()
|
|
60573
|
+
});
|
|
60574
|
+
var CommunityForumSidebarEnvelopeSchema = exports_external.strictObject({
|
|
60575
|
+
schemaVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
60576
|
+
serverId: exports_external.string().min(1),
|
|
60577
|
+
channels: exports_external.array(CommunityForumSidebarChannelSummarySchema),
|
|
60578
|
+
canonicalChannels: exports_external.array(CommunityForumSidebarChannelSummarySchema),
|
|
60579
|
+
retainedChannel: CommunityForumSidebarChannelSummarySchema.nullable(),
|
|
60580
|
+
retainedDisposition: exports_external.enum(["eligible", "opener-archived", "genuine-negative"]).nullable(),
|
|
60581
|
+
resources: CommunityResourceBundleSchema,
|
|
60582
|
+
serverNow: timestamp
|
|
60583
|
+
}).superRefine((data, ctx) => {
|
|
60584
|
+
const selected = [...data.canonicalChannels, ...data.retainedChannel ? [data.retainedChannel] : []];
|
|
60585
|
+
if (data.resources.servers.some((row) => row.id !== data.serverId) || data.resources.channels.some((row) => row.serverId !== data.serverId) || new Set(data.channels.map((row) => row.id)).size !== data.channels.length || new Set(data.canonicalChannels.map((row) => row.id)).size !== data.canonicalChannels.length || data.canonicalChannels.some((row) => data.canonicalChannels.filter((other) => other.parentChannelId === row.parentChannelId).length > 5) || data.channels.some((row) => !selected.some((other) => other.id === row.id)) || data.retainedDisposition === "eligible" !== (data.retainedChannel !== null) || selected.some((row) => !data.resources.channels.some((channel2) => channel2.id === row.id && channel2.type === "thread" && channel2.serverId === row.serverId && channel2.parentChannelId === row.parentChannelId && channel2.parentMessageId === row.parentMessageId) || !data.resources.messages.some((message2) => message2.id === row.parentMessageId && message2.channelId === row.parentChannelId) || !data.resources.memberships.some((member2) => member2.channelId === row.id && member2.userId === data.resources.viewerId && member2.relation === "notify"))) {
|
|
60586
|
+
ctx.addIssue({ code: "custom", message: "Forum sidebar resource closure mismatch" });
|
|
60587
|
+
}
|
|
60588
|
+
});
|
|
60589
|
+
// ../shared/src/community-machine-resources.ts
|
|
60590
|
+
var CommunityMachineIdentityCacheSchema = CommunityMachineSummarySchema.pick({
|
|
60591
|
+
id: true,
|
|
60592
|
+
hostname: true,
|
|
60593
|
+
displayName: true,
|
|
60594
|
+
platform: true,
|
|
60595
|
+
arch: true,
|
|
60596
|
+
osRelease: true,
|
|
60597
|
+
daemonVersion: true,
|
|
60598
|
+
createdAt: true,
|
|
60599
|
+
updatedAt: true
|
|
60600
|
+
});
|
|
60601
|
+
var CommunityMachineListReadSchema = exports_external.strictObject({ machines: exports_external.array(CommunityMachineSummarySchema), complete: exports_external.literal(true) });
|
|
60602
|
+
// ../shared/src/community-friends.ts
|
|
60603
|
+
var CommunityAcceptedFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true, sub: true });
|
|
60604
|
+
var CommunityBlockedFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true });
|
|
60605
|
+
var CommunityPendingFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true, needsOwnerApproval: true }).extend({
|
|
60606
|
+
kind: friendshipSchema.shape.kind.extract(["incoming", "outgoing"])
|
|
60607
|
+
});
|
|
60608
|
+
var envelope2 = { contractVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION) };
|
|
60609
|
+
var fresh = { ...envelope2, resources: CommunityResourceBundleSchema, stale: exports_external.literal(false).optional() };
|
|
60610
|
+
var stale = { ...envelope2, stale: exports_external.literal(true) };
|
|
60611
|
+
function checkProfiles(rows, resources, ctx) {
|
|
60612
|
+
if (rows.some((row) => !resources.profiles.some((profile2) => profile2.id === row.userId))) {
|
|
60613
|
+
ctx.addIssue({ code: "custom", message: "Friend profile resource missing" });
|
|
60614
|
+
}
|
|
60615
|
+
}
|
|
60616
|
+
var CommunityAcceptedFriendsReadSchema = exports_external.union([
|
|
60617
|
+
exports_external.strictObject({ ...fresh, friends: exports_external.array(CommunityAcceptedFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.friends, value.resources, ctx)),
|
|
60618
|
+
exports_external.strictObject({ ...stale, friends: exports_external.array(CommunityAcceptedFriendDescriptorSchema).length(0) })
|
|
60619
|
+
]);
|
|
60620
|
+
var CommunityBlockedFriendsReadSchema = exports_external.union([
|
|
60621
|
+
exports_external.strictObject({ ...fresh, blocked: exports_external.array(CommunityBlockedFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.blocked, value.resources, ctx)),
|
|
60622
|
+
exports_external.strictObject({ ...stale, blocked: exports_external.array(CommunityBlockedFriendDescriptorSchema).length(0) })
|
|
60623
|
+
]);
|
|
60624
|
+
var CommunityPendingFriendsReadSchema = exports_external.union([
|
|
60625
|
+
exports_external.strictObject({ ...fresh, pending: exports_external.array(CommunityPendingFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.pending, value.resources, ctx)),
|
|
60626
|
+
exports_external.strictObject({ ...stale, pending: exports_external.array(CommunityPendingFriendDescriptorSchema).length(0) })
|
|
60627
|
+
]);
|
|
60628
|
+
// ../shared/src/community-invites.ts
|
|
60629
|
+
var CommunityInviteListItemSchema = CommunityInviteCreateSchema.shape.invite.required({ maxUses: true, uses: true, expiresAt: true }).extend({
|
|
60630
|
+
uses: CommunityInviteCreateSchema.shape.invite.shape.uses.unwrap().unwrap().int().nonnegative(),
|
|
60631
|
+
creatorId: CommunityResourceProfileSchema.shape.id.nullable()
|
|
60632
|
+
});
|
|
60633
|
+
var CommunityInvitesReadSchema = exports_external.strictObject({
|
|
60634
|
+
contractVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
60635
|
+
serverId: CommunityServerResourceSchema.shape.id,
|
|
60636
|
+
invites: exports_external.array(CommunityInviteListItemSchema),
|
|
60637
|
+
resources: CommunityResourceBundleSchema
|
|
60638
|
+
}).superRefine((value, ctx) => {
|
|
60639
|
+
if (new Set(value.invites.map((row) => row.id)).size !== value.invites.length)
|
|
60640
|
+
ctx.addIssue({ code: "custom", message: "Duplicate invite descriptor" });
|
|
60641
|
+
if (!value.resources.servers.some((row) => row.id === value.serverId) || value.resources.servers.some((row) => row.id !== value.serverId))
|
|
60642
|
+
ctx.addIssue({ code: "custom", message: "Invite server resource mismatch" });
|
|
60643
|
+
if (value.invites.some((row) => row.creatorId !== null && !value.resources.profiles.some((profile2) => profile2.id === row.creatorId)))
|
|
60644
|
+
ctx.addIssue({ code: "custom", message: "Invite creator profile resource missing" });
|
|
60645
|
+
});
|
|
60646
|
+
// ../shared/src/community-dms.ts
|
|
60647
|
+
var CommunityDmReadItemSchema = exports_external.strictObject({
|
|
60648
|
+
id: CommunityChannelResourceSchema.shape.id,
|
|
60649
|
+
userId: CommunityResourceProfileSchema.shape.id,
|
|
60650
|
+
channel: CommunityChannelResourceSchema,
|
|
60651
|
+
profile: CommunityResourceProfileSchema,
|
|
60652
|
+
memberships: exports_external.array(CommunityMemberRelationSchema).length(2),
|
|
60653
|
+
preview: exports_external.string(),
|
|
60654
|
+
activityAt: CommunityChannelResourceSchema.shape.createdAt,
|
|
60655
|
+
unread: exports_external.boolean(),
|
|
60656
|
+
lastUnreadSeq: CommunityMessageResourceSchema.shape.seq.optional()
|
|
60657
|
+
}).superRefine((dm, ctx) => {
|
|
60658
|
+
const users = new Set(dm.memberships.map((row) => row.userId));
|
|
60659
|
+
if (dm.channel.id !== dm.id || dm.channel.type !== "dm" || dm.channel.serverId !== null || dm.channel.categoryId !== null || dm.channel.parentChannelId !== null || dm.channel.parentMessageId !== null || dm.profile.id !== dm.userId || users.size !== 2 || !users.has(dm.userId) || dm.memberships.some((row) => row.channelId !== dm.id || row.relation !== "access") || dm.unread !== (dm.lastUnreadSeq !== undefined)) {
|
|
60660
|
+
ctx.addIssue({ code: "custom", message: "DM resource scope mismatch" });
|
|
60661
|
+
}
|
|
60662
|
+
});
|
|
60663
|
+
var CommunityDmsReadSchema = exports_external.strictObject({ conversations: exports_external.array(CommunityDmReadItemSchema) }).superRefine((value, ctx) => {
|
|
60664
|
+
if (new Set(value.conversations.map((row) => row.id)).size !== value.conversations.length) {
|
|
60665
|
+
ctx.addIssue({ code: "custom", message: "Duplicate DM resource identity" });
|
|
60666
|
+
}
|
|
60667
|
+
});
|
|
60668
|
+
// ../shared/src/community-profile-reads.ts
|
|
60669
|
+
var CommunitySelfProfileReadSchema = CommunityResourceProfileSchema.pick({
|
|
60670
|
+
id: true,
|
|
60671
|
+
name: true,
|
|
60672
|
+
discriminator: true,
|
|
60673
|
+
avatar: true,
|
|
60674
|
+
avatarVersion: true,
|
|
60675
|
+
aboutMe: true,
|
|
60676
|
+
bannerColor: true,
|
|
60677
|
+
statusEmoji: true,
|
|
60678
|
+
statusText: true
|
|
60679
|
+
}).required();
|
|
60680
|
+
var card = CommunitySelfProfileReadSchema.omit({ avatar: true }).extend({
|
|
60681
|
+
image: CommunityResourceProfileSchema.shape.avatar,
|
|
60682
|
+
mutualServers: CommunityResourceProfileSchema.shape.mutualServers.unwrap()
|
|
60683
|
+
});
|
|
60684
|
+
var CommunityUserCardReadSchema = exports_external.discriminatedUnion("kind", [
|
|
60685
|
+
card.extend({ kind: exports_external.literal("human") }),
|
|
60686
|
+
card.extend({ kind: exports_external.literal("bot"), ownerProfile: exports_external.strictObject({ id: CommunityResourceProfileSchema.shape.id, handle: CommunityResourceProfileSchema.shape.ownerHandle.unwrap().unwrap() }), ownedByViewer: CommunityResourceProfileSchema.shape.ownedByViewer.unwrap() })
|
|
60687
|
+
]);
|
|
60688
|
+
var CommunityServerMemberReadSchema = CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true, statusEmoji: true, statusText: true }).required().extend({
|
|
60689
|
+
id: CommunityServerMembershipResourceSchema.shape.memberId,
|
|
60690
|
+
userId: CommunityResourceProfileSchema.shape.id,
|
|
60691
|
+
role: exports_external.enum(ROLES),
|
|
60692
|
+
status: exports_external.enum(["online", "offline"]),
|
|
60693
|
+
sub: exports_external.string(),
|
|
60694
|
+
isBot: exports_external.literal(true).optional(),
|
|
60695
|
+
ownerUserId: CommunityResourceProfileSchema.shape.id.optional()
|
|
60696
|
+
}).superRefine((row, ctx) => {
|
|
60697
|
+
if (row.isBot === true !== (row.ownerUserId !== undefined))
|
|
60698
|
+
ctx.addIssue({ code: "custom", message: "Member owner metadata mismatch" });
|
|
60699
|
+
});
|
|
60700
|
+
var page = exports_external.strictObject({
|
|
60701
|
+
viewerId: CommunityResourceProfileSchema.shape.id,
|
|
60702
|
+
serverId: CommunityServerMembershipResourceSchema.shape.serverId,
|
|
60703
|
+
members: exports_external.array(CommunityServerMemberReadSchema),
|
|
60704
|
+
hasMore: exports_external.boolean(),
|
|
60705
|
+
cursor: exports_external.string().min(1).optional(),
|
|
60706
|
+
limit: exports_external.number().int().positive()
|
|
60707
|
+
});
|
|
60708
|
+
var validatePage = (value, ctx) => {
|
|
60709
|
+
if (value.hasMore && !value.cursor || new Set(value.members.map((row) => row.id)).size !== value.members.length || new Set(value.members.map((row) => row.userId)).size !== value.members.length || value.members.length > value.limit || value.members.some((row) => row.ownerUserId !== undefined && row.ownerUserId !== value.viewerId))
|
|
60710
|
+
ctx.addIssue({ code: "custom", message: "Member page scope mismatch" });
|
|
60711
|
+
};
|
|
60712
|
+
var CommunityServerMembersReadSchema = page.extend({ total: exports_external.number().int().nonnegative() }).superRefine(validatePage);
|
|
60713
|
+
var CommunityServerMemberSearchReadSchema = page.superRefine(validatePage);
|
|
60714
|
+
var CommunityUserSearchReadSchema = exports_external.strictObject({ users: exports_external.array(CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatarVersion: true }).extend({ image: CommunityResourceProfileSchema.shape.avatar })) });
|
|
60715
|
+
var CommunityReactionActorProfileSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatar: true, avatarVersion: true });
|
|
60716
|
+
var CommunityReactionDetailsReadSchema = exports_external.strictObject({
|
|
60717
|
+
messageId: CommunityResourceProfileSchema.shape.id,
|
|
60718
|
+
scope: exports_external.discriminatedUnion("kind", [
|
|
60719
|
+
exports_external.strictObject({ kind: exports_external.literal("server"), serverId: CommunityServerMembershipResourceSchema.shape.serverId, channelId: CommunityResourceProfileSchema.shape.id }),
|
|
60720
|
+
exports_external.strictObject({ kind: exports_external.literal("dm"), channelId: CommunityResourceProfileSchema.shape.id })
|
|
60721
|
+
]),
|
|
60722
|
+
actors: exports_external.array(exports_external.strictObject({ userId: CommunityResourceProfileSchema.shape.id, profile: CommunityReactionActorProfileSchema.nullable() }))
|
|
60723
|
+
}).superRefine((value, ctx) => {
|
|
60724
|
+
if (new Set(value.actors.map((row) => row.userId)).size !== value.actors.length || value.actors.some((row) => row.profile && row.profile.id !== row.userId))
|
|
60725
|
+
ctx.addIssue({ code: "custom", message: "Reaction actor identity mismatch" });
|
|
60726
|
+
});
|
|
60727
|
+
var CommunityBotProfileSummarySchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatarVersion: true }).extend({
|
|
60728
|
+
image: CommunityResourceProfileSchema.shape.avatar,
|
|
60729
|
+
discriminator: CommunityResourceProfileSchema.shape.discriminator.optional(),
|
|
60730
|
+
description: CommunityResourceProfileSchema.shape.aboutMe,
|
|
60731
|
+
presence: exports_external.enum(["online", "offline"]).optional()
|
|
60732
|
+
}).strip();
|
|
60733
|
+
var CommunityBotsProfileReadSchema = exports_external.object({
|
|
60734
|
+
bots: exports_external.array(CommunityBotProfileSummarySchema.required({ discriminator: true, description: true, presence: true }).extend({ ownerUserId: CommunityResourceProfileSchema.shape.id }))
|
|
60735
|
+
}).strip().superRefine((value, ctx) => {
|
|
60736
|
+
if (new Set(value.bots.map((row) => row.id)).size !== value.bots.length)
|
|
60737
|
+
ctx.addIssue({ code: "custom", message: "Duplicate bot catalogue identity" });
|
|
60738
|
+
});
|
|
60603
60739
|
// src/manager/memoryMaintenancePrompt.ts
|
|
60604
60740
|
var MEMORY_MAINTENANCE_PROMPT = `The daemon is preparing to reset this idle session. First, clean up your memory so the next session does not inherit incorrect or outdated notes.
|
|
60605
60741
|
|
|
@@ -60635,7 +60771,7 @@ var MESSAGE_SEND_STDIN_POLICY = [
|
|
|
60635
60771
|
" - a short list or table for several exact items, mappings, or comparisons;",
|
|
60636
60772
|
" - pseudocode for logic, a shallow tree for hierarchy or ownership, Mermaid for sequence or " + "flow, and `diff` for what changed.",
|
|
60637
60773
|
"- Keep each visual next to the short text it supports. Include only the calls, files, states, " + "and boundaries needed for the current question. Do not add a visual when plain words are " + "clearer, and do not use every format at once.",
|
|
60638
|
-
"- The message body is limited to 1 KiB. Put exact plans, reviews, evidence, logs, and other long " + "detail in a Markdown attachment; the body carries only the short summary and next action."
|
|
60774
|
+
"- The message body is limited to 1 KiB. Put exact plans, reviews, evidence, logs, and other long " + "detail in a Markdown attachment; put HTML pages for inline display (charts, diagrams, or interface " + "mockups) in an HTML attachment and reference them in the body using the required inline HTML format; " + "the body carries only the short summary and next action."
|
|
60639
60775
|
].join(`
|
|
60640
60776
|
`);
|
|
60641
60777
|
function identitySection(config2) {
|
|
@@ -60762,6 +60898,7 @@ function messagingSection() {
|
|
|
60762
60898
|
"",
|
|
60763
60899
|
`- Send body: use \`${CLI} message send --target <ref> --remind-after T --stdin\` with the ` + "quoted-heredoc form under *Message formatting*.",
|
|
60764
60900
|
`- Long detail: upload it with \`${CLI} message attachment upload --file <path>.md\`; ` + "add the returned id as `--attachment <id>` on the short stdin send.",
|
|
60901
|
+
`- Inline HTML: upload a self-contained UTF-8 \`<path>.html\` file with \`${CLI} message attachment upload --file <path>.html\`. ` + "Inline CSS and JavaScript in the file; do not depend on local paths on the sender's computer. " + "Include the returned ID with `--attachment <id>` when sending. Put `[alook-html-preview](attachment-id)` " + "in its own paragraph at the intended position in the message, with a blank line before and after; " + "do not put the marker in a code block. " + "Use the Alook theme CSS variables injected by the host on `:root`: " + "`--background`, `--foreground`, `--card`, `--card-foreground`, `--popover`, `--popover-foreground`, " + "`--primary`, `--primary-foreground`, `--secondary`, `--secondary-foreground`, `--muted`, `--muted-foreground`, " + "`--accent`, `--accent-foreground`, `--border`, `--input`, `--ring`, `--destructive`, `--warning`, " + "`--radius`, `--font-sans`, and `--font-mono`. Use their values directly with `var(...)`; " + "do not hardcode page theme colors to one light or dark scheme. " + "Do not add background colors to `html`, `body`, or the outermost element. Do not add an outer card, " + "border, banner title, or side padding. This rule takes priority over other page-background authoring rules. " + "An internal box that needs a background uses a theme variable, 16px padding, and `var(--radius)` corners. " + "Adapt to the available width and different screen sizes; do not hardcode a desktop page width. " + "Give charts fixed pixel heights. Let content set the page height. Do not use `vh`, `dvh`, `svh`, or `lvh`, " + "and do not set `height:100%` on `html` or `body`. The current preview validator rejects those viewport units; " + "percentage heights on the document roots can cause a measurement loop. " + "Alook measures the frame height automatically in CSS pixels, currently 80–2000px inline. " + "Sending a message requires no height parameter. Keep the original HTML within the current 2 MiB preview limit.",
|
|
60765
60902
|
"- Reuse files: to forward an attachment or send the same file again, pass its existing ID with `--attachment <id>`. " + "Do not download and upload it again. Reuse works across channels, DMs, and threads while you can still read the file. " + "Upload only a new or changed file.",
|
|
60766
60903
|
`- Cite a specific message: add \`--reply "#37"\` — \`--reply\` takes the \`#N\` seq ` + "(within `--target`) of the message you're answering.",
|
|
60767
60904
|
"",
|
|
@@ -63142,23 +63279,23 @@ class AgentRouter {
|
|
|
63142
63279
|
const reply = this.opts.channel.reportRuntimeModels;
|
|
63143
63280
|
if (!reply)
|
|
63144
63281
|
return;
|
|
63145
|
-
const
|
|
63282
|
+
const identity2 = { type: "runtime_models", requestId: cmd.requestId, runtimeId: cmd.runtimeId };
|
|
63146
63283
|
try {
|
|
63147
63284
|
const current = this.runtimes.get(cmd.runtimeId);
|
|
63148
63285
|
if (!current)
|
|
63149
63286
|
throw new UnknownRuntimeError(cmd.runtimeId, [...this.runtimes.keys()]);
|
|
63150
63287
|
const probe = await this.discoverRuntimeModels(cmd.runtimeId);
|
|
63151
63288
|
if (!probe) {
|
|
63152
|
-
reply.call(this.opts.channel, { ...
|
|
63289
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: "model_discovery_timeout", message: "Model discovery timed out; retry the request" } });
|
|
63153
63290
|
return;
|
|
63154
63291
|
}
|
|
63155
63292
|
if (probe.status !== "healthy") {
|
|
63156
|
-
reply.call(this.opts.channel, { ...
|
|
63293
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: probe.error.code, message: probe.error.message } });
|
|
63157
63294
|
return;
|
|
63158
63295
|
}
|
|
63159
|
-
reply.call(this.opts.channel, { ...
|
|
63296
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "complete", runtimeReport: [...this.runtimes.values()] } });
|
|
63160
63297
|
} catch {
|
|
63161
|
-
reply.call(this.opts.channel, { ...
|
|
63298
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: "model_discovery_failed", message: "Could not discover models for this runtime" } });
|
|
63162
63299
|
}
|
|
63163
63300
|
return;
|
|
63164
63301
|
}
|
|
@@ -68314,6 +68451,11 @@ function readHostGitIdentity() {
|
|
|
68314
68451
|
return value;
|
|
68315
68452
|
}
|
|
68316
68453
|
|
|
68454
|
+
// src/npmEnvironment.ts
|
|
68455
|
+
function withoutNpmExecPackage(env) {
|
|
68456
|
+
return Object.fromEntries(Object.entries(env).filter(([key]) => key.toLowerCase() !== "npm_config_package"));
|
|
68457
|
+
}
|
|
68458
|
+
|
|
68317
68459
|
// src/manager/agentDriverHost.ts
|
|
68318
68460
|
function runtimeEnvironment(ctx) {
|
|
68319
68461
|
const runtime = ctx.config.runtimeContext;
|
|
@@ -68372,7 +68514,7 @@ function createDaemonAgentDriverHost(ctx, onRawLine) {
|
|
|
68372
68514
|
const resource = {
|
|
68373
68515
|
executablePath: ctx.agentCliPath,
|
|
68374
68516
|
environmentLayers: {
|
|
68375
|
-
base:
|
|
68517
|
+
base: withoutNpmExecPackage(process.env),
|
|
68376
68518
|
hostStatic: {},
|
|
68377
68519
|
identityProtected: buildGitIdentityEnv({
|
|
68378
68520
|
agentName: ctx.config.agentName,
|
|
@@ -68555,13 +68697,13 @@ class DailyTokenUsageStore {
|
|
|
68555
68697
|
dayKeyInTimeZone(0, timeZone);
|
|
68556
68698
|
return timeZone;
|
|
68557
68699
|
}
|
|
68558
|
-
record(botId, delta,
|
|
68700
|
+
record(botId, delta, identity2) {
|
|
68559
68701
|
return this.enqueue(async () => {
|
|
68560
|
-
if (
|
|
68561
|
-
if (!
|
|
68702
|
+
if (identity2) {
|
|
68703
|
+
if (!identity2.source || identity2.source.length > 256 || !Number.isSafeInteger(identity2.index) || identity2.index < 0 || !Number.isFinite(Date.parse(identity2.occurredAt)))
|
|
68562
68704
|
throw new Error("Invalid token usage identity");
|
|
68563
|
-
if (!this.pending.some((sample) => sample.botId === botId && sample.identity.source ===
|
|
68564
|
-
this.pending.push({ botId, delta, identity });
|
|
68705
|
+
if (!this.pending.some((sample) => sample.botId === botId && sample.identity.source === identity2.source && sample.identity.index === identity2.index))
|
|
68706
|
+
this.pending.push({ botId, delta, identity: identity2 });
|
|
68565
68707
|
await this.load();
|
|
68566
68708
|
await this.flushPending();
|
|
68567
68709
|
} else {
|
|
@@ -68594,13 +68736,13 @@ class DailyTokenUsageStore {
|
|
|
68594
68736
|
throw error62;
|
|
68595
68737
|
}
|
|
68596
68738
|
}
|
|
68597
|
-
apply(botId, delta,
|
|
68739
|
+
apply(botId, delta, identity2) {
|
|
68598
68740
|
const at = this.now();
|
|
68599
68741
|
const timeZone = this.timeZone;
|
|
68600
|
-
const day = dayKeyInTimeZone(
|
|
68601
|
-
if (
|
|
68742
|
+
const day = dayKeyInTimeZone(identity2 ? new Date(identity2.occurredAt) : at, timeZone);
|
|
68743
|
+
if (identity2 && day < oldestRetainedDay(at, timeZone))
|
|
68602
68744
|
return;
|
|
68603
|
-
if (
|
|
68745
|
+
if (identity2 && this.data.sources?.[botId]?.[identity2.source]?.ranges.some(([start, end]) => identity2.index >= start && identity2.index <= end))
|
|
68604
68746
|
return;
|
|
68605
68747
|
this.prune(at, timeZone);
|
|
68606
68748
|
const snapshots = this.data.bots[botId] ?? [];
|
|
@@ -68615,11 +68757,11 @@ class DailyTokenUsageStore {
|
|
|
68615
68757
|
snapshots.push(next);
|
|
68616
68758
|
snapshots.sort((a, b) => a.day.localeCompare(b.day));
|
|
68617
68759
|
this.data.bots[botId] = snapshots;
|
|
68618
|
-
if (
|
|
68760
|
+
if (identity2) {
|
|
68619
68761
|
this.data.sources ??= {};
|
|
68620
68762
|
this.data.sources[botId] ??= {};
|
|
68621
|
-
const saved = this.data.sources[botId][
|
|
68622
|
-
const ranges = [...saved?.ranges ?? [], [
|
|
68763
|
+
const saved = this.data.sources[botId][identity2.source];
|
|
68764
|
+
const ranges = [...saved?.ranges ?? [], [identity2.index, identity2.index]].sort((a, b) => a[0] - b[0]);
|
|
68623
68765
|
const merged = [];
|
|
68624
68766
|
for (const range of ranges) {
|
|
68625
68767
|
const last = merged.at(-1);
|
|
@@ -68628,7 +68770,7 @@ class DailyTokenUsageStore {
|
|
|
68628
68770
|
else
|
|
68629
68771
|
merged.push([range[0], range[1]]);
|
|
68630
68772
|
}
|
|
68631
|
-
this.data.sources[botId][
|
|
68773
|
+
this.data.sources[botId][identity2.source] = { ranges: merged, day: saved && saved.day > day ? saved.day : day };
|
|
68632
68774
|
}
|
|
68633
68775
|
}
|
|
68634
68776
|
snapshots(botId) {
|
|
@@ -69423,10 +69565,10 @@ async function createDaemon(opts) {
|
|
|
69423
69565
|
tokenUsageAvailability.set(agentId, { backendId, status });
|
|
69424
69566
|
reportTelemetryForIdleAgent(agentId);
|
|
69425
69567
|
},
|
|
69426
|
-
onTokenUsage: ({ agentId, usage, identity }) => {
|
|
69568
|
+
onTokenUsage: ({ agentId, usage, identity: identity2 }) => {
|
|
69427
69569
|
if (usageSealed)
|
|
69428
69570
|
return;
|
|
69429
|
-
trackTelemetry(dailyTokenUsage2.record(agentId, usage,
|
|
69571
|
+
trackTelemetry(dailyTokenUsage2.record(agentId, usage, identity2).then(() => reportTelemetryForIdleAgent(agentId)).catch(() => {
|
|
69430
69572
|
log2.warn("daily token usage persistence failed", { agentId });
|
|
69431
69573
|
}));
|
|
69432
69574
|
},
|