@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/cli/index.js
CHANGED
|
@@ -44240,17 +44240,32 @@ var OwnerDiagnosticReportSchema = exports_external.discriminatedUnion("status",
|
|
|
44240
44240
|
objectExpired: exports_external.literal(false)
|
|
44241
44241
|
}).strict()
|
|
44242
44242
|
]);
|
|
44243
|
+
// ../shared/src/community-profile-resource.ts
|
|
44244
|
+
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
44245
|
+
id: exports_external.string().min(1),
|
|
44246
|
+
name: exports_external.string(),
|
|
44247
|
+
discriminator: exports_external.string().min(1),
|
|
44248
|
+
avatar: exports_external.string().nullable(),
|
|
44249
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
44250
|
+
aboutMe: exports_external.string().optional(),
|
|
44251
|
+
bannerColor: exports_external.string().nullable().optional(),
|
|
44252
|
+
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
44253
|
+
ownerUserId: exports_external.string().min(1).nullable().optional(),
|
|
44254
|
+
ownerHandle: exports_external.string().nullable().optional(),
|
|
44255
|
+
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
44256
|
+
ownedByViewer: exports_external.boolean().optional(),
|
|
44257
|
+
statusEmoji: exports_external.string().nullable().optional(),
|
|
44258
|
+
statusText: exports_external.string().nullable().optional()
|
|
44259
|
+
});
|
|
44260
|
+
// ../shared/src/business-schema-version.ts
|
|
44261
|
+
var BUSINESS_SCHEMA_VERSION = 7;
|
|
44262
|
+
|
|
44243
44263
|
// ../shared/src/community-contract.ts
|
|
44244
|
-
var COMMUNITY_RESOURCE_CONTRACT_VERSION =
|
|
44264
|
+
var COMMUNITY_RESOURCE_CONTRACT_VERSION = BUSINESS_SCHEMA_VERSION;
|
|
44245
44265
|
|
|
44246
44266
|
// ../shared/src/community-friend-approval.ts
|
|
44247
|
-
var
|
|
44248
|
-
|
|
44249
|
-
name: exports_external.string(),
|
|
44250
|
-
discriminator: exports_external.string(),
|
|
44251
|
-
image: exports_external.string().nullable(),
|
|
44252
|
-
avatarVersion: exports_external.number().int().nonnegative()
|
|
44253
|
-
});
|
|
44267
|
+
var identity = CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatarVersion: true });
|
|
44268
|
+
var profile = identity.extend({ image: CommunityResourceProfileSchema.shape.avatar });
|
|
44254
44269
|
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
44255
44270
|
friendshipId: exports_external.string(),
|
|
44256
44271
|
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
@@ -44260,6 +44275,29 @@ var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
|
44260
44275
|
waitingOnProfile: profile.nullable().optional()
|
|
44261
44276
|
});
|
|
44262
44277
|
|
|
44278
|
+
// ../shared/src/constants/community.ts
|
|
44279
|
+
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
44280
|
+
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
44281
|
+
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
44282
|
+
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
44283
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
44284
|
+
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
44285
|
+
var MAX_ATTACHMENT_THUMBNAIL_EDGE_PX = 720;
|
|
44286
|
+
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
44287
|
+
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
44288
|
+
var ALLOWED_ICON_MIME_TYPES = [
|
|
44289
|
+
"image/png",
|
|
44290
|
+
"image/jpeg",
|
|
44291
|
+
"image/webp",
|
|
44292
|
+
"image/gif"
|
|
44293
|
+
];
|
|
44294
|
+
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
44295
|
+
var PARTICIPANT_SOURCE = {
|
|
44296
|
+
MENTION: "mention",
|
|
44297
|
+
SPOKE: "spoke",
|
|
44298
|
+
ADDED: "added"
|
|
44299
|
+
};
|
|
44300
|
+
|
|
44263
44301
|
// ../shared/src/runtime-models-contract.ts
|
|
44264
44302
|
var RUNTIME_MODEL_DISCOVERY_CAPABILITY = "runtime-model-discovery-v1";
|
|
44265
44303
|
var RuntimeModelDiscoveryRequestSchema = exports_external.strictObject({
|
|
@@ -44354,6 +44392,13 @@ var PiiLocalRequestSchema = exports_external.discriminatedUnion("action", [
|
|
|
44354
44392
|
})
|
|
44355
44393
|
]);
|
|
44356
44394
|
|
|
44395
|
+
// ../shared/src/utils/community-roles.ts
|
|
44396
|
+
var ROLES = {
|
|
44397
|
+
OWNER: "owner",
|
|
44398
|
+
ADMIN: "admin",
|
|
44399
|
+
MEMBER: "member"
|
|
44400
|
+
};
|
|
44401
|
+
|
|
44357
44402
|
// ../shared/src/lib/discriminator.ts
|
|
44358
44403
|
function parseNameAndTag(q) {
|
|
44359
44404
|
const m = /^(.+)#(\d{4,})$/.exec(q);
|
|
@@ -44611,11 +44656,11 @@ var AvailableQuotaObservationSchema = exports_external.object({
|
|
|
44611
44656
|
}).strict().superRefine((value, ctx) => {
|
|
44612
44657
|
const identities = new Set;
|
|
44613
44658
|
for (const [index2, limit] of value.limits.entries()) {
|
|
44614
|
-
const
|
|
44615
|
-
if (identities.has(
|
|
44659
|
+
const identity2 = quotaIdentity(limit);
|
|
44660
|
+
if (identities.has(identity2)) {
|
|
44616
44661
|
ctx.addIssue({ code: "custom", message: "duplicate quota bucket identity", path: ["limits", index2] });
|
|
44617
44662
|
}
|
|
44618
|
-
identities.add(
|
|
44663
|
+
identities.add(identity2);
|
|
44619
44664
|
}
|
|
44620
44665
|
});
|
|
44621
44666
|
var ProviderQuotaObservationSchema = exports_external.union([
|
|
@@ -44632,24 +44677,6 @@ var ProviderQuotaSnapshotSchema = exports_external.object({
|
|
|
44632
44677
|
observation: ProviderQuotaObservationSchema
|
|
44633
44678
|
}).strict();
|
|
44634
44679
|
|
|
44635
|
-
// ../shared/src/constants/community.ts
|
|
44636
|
-
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
44637
|
-
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
44638
|
-
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
44639
|
-
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
44640
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
44641
|
-
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
44642
|
-
var MAX_ATTACHMENT_THUMBNAIL_EDGE_PX = 720;
|
|
44643
|
-
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
44644
|
-
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
44645
|
-
var ALLOWED_ICON_MIME_TYPES = [
|
|
44646
|
-
"image/png",
|
|
44647
|
-
"image/jpeg",
|
|
44648
|
-
"image/webp",
|
|
44649
|
-
"image/gif"
|
|
44650
|
-
];
|
|
44651
|
-
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
44652
|
-
|
|
44653
44680
|
// ../shared/src/lib/community-name.ts
|
|
44654
44681
|
var FORBIDDEN_NAME_CHARS = /[#@\x00-\x1f\x7f-\x9f]/;
|
|
44655
44682
|
function validateCommunityName(name) {
|
|
@@ -45611,13 +45638,12 @@ var BotCreationSubmitSchema = exports_external.strictObject({
|
|
|
45611
45638
|
requestId: exports_external.string().min(1).max(128),
|
|
45612
45639
|
bots: exports_external.array(BotCreationProposalSchema).min(1).max(BOT_CREATION_MAX_ITEMS)
|
|
45613
45640
|
});
|
|
45614
|
-
var BotCreationIdentitySchema =
|
|
45615
|
-
id:
|
|
45616
|
-
name:
|
|
45617
|
-
discriminator:
|
|
45618
|
-
|
|
45619
|
-
|
|
45620
|
-
});
|
|
45641
|
+
var BotCreationIdentitySchema = CommunityResourceProfileSchema.pick({
|
|
45642
|
+
id: true,
|
|
45643
|
+
name: true,
|
|
45644
|
+
discriminator: true,
|
|
45645
|
+
avatarVersion: true
|
|
45646
|
+
}).extend({ image: CommunityResourceProfileSchema.shape.avatar });
|
|
45621
45647
|
var BotCreationItemSchema = BotCreationProposalSchema.extend({
|
|
45622
45648
|
itemId: exports_external.string(),
|
|
45623
45649
|
description: exports_external.string(),
|
|
@@ -45640,7 +45666,26 @@ var BotCreationDecisionSchema = exports_external.strictObject({ decision: export
|
|
|
45640
45666
|
// ../shared/src/community-resources.ts
|
|
45641
45667
|
var id = exports_external.string().min(1);
|
|
45642
45668
|
var nullableId = id.nullable();
|
|
45643
|
-
var
|
|
45669
|
+
var storedArchivedSchema = exports_external.union([exports_external.boolean(), exports_external.literal(0), exports_external.literal(1)]).transform((value) => value === true || value === 1);
|
|
45670
|
+
var CommunityServerResourceSchema = exports_external.strictObject({
|
|
45671
|
+
id: exports_external.string().min(1),
|
|
45672
|
+
position: exports_external.number().int().nonnegative(),
|
|
45673
|
+
name: exports_external.string(),
|
|
45674
|
+
discriminator: exports_external.string(),
|
|
45675
|
+
description: exports_external.string(),
|
|
45676
|
+
ownerId: exports_external.string(),
|
|
45677
|
+
icon: exports_external.string().nullable(),
|
|
45678
|
+
official: exports_external.boolean(),
|
|
45679
|
+
isOwner: exports_external.boolean()
|
|
45680
|
+
});
|
|
45681
|
+
var CommunityCategoryResourceSchema = exports_external.strictObject({
|
|
45682
|
+
id: exports_external.string().min(1),
|
|
45683
|
+
serverId: exports_external.string().min(1),
|
|
45684
|
+
name: exports_external.string(),
|
|
45685
|
+
position: exports_external.number(),
|
|
45686
|
+
private: exports_external.boolean(),
|
|
45687
|
+
creatorId: exports_external.string().nullable()
|
|
45688
|
+
});
|
|
45644
45689
|
var CommunityChannelResourceSchema = exports_external.strictObject({
|
|
45645
45690
|
id,
|
|
45646
45691
|
type: exports_external.enum(["text", "forum", "thread", "dm"]),
|
|
@@ -45668,31 +45713,13 @@ var CommunityChannelIdentitySchema = CommunityChannelResourceSchema.pick({
|
|
|
45668
45713
|
archived: true,
|
|
45669
45714
|
lastMessageAt: true,
|
|
45670
45715
|
createdAt: true
|
|
45671
|
-
}).
|
|
45672
|
-
var legacyChannelIdentitySchema = CommunityChannelIdentitySchema.extend({
|
|
45673
|
-
archived: legacyArchivedSchema,
|
|
45674
|
-
parentChannelId: nullableId.default(null),
|
|
45675
|
-
parentMessageId: nullableId.default(null),
|
|
45676
|
-
creatorId: nullableId.default(null),
|
|
45677
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null)
|
|
45678
|
-
});
|
|
45716
|
+
}).strip();
|
|
45679
45717
|
var CommunityAccessDecisionSchema = exports_external.strictObject({
|
|
45680
45718
|
channelId: id,
|
|
45681
45719
|
canRead: exports_external.boolean(),
|
|
45682
45720
|
canSend: exports_external.boolean(),
|
|
45683
45721
|
canCreateDiscussion: exports_external.boolean()
|
|
45684
45722
|
});
|
|
45685
|
-
var CommunityLegacyMessageAttachmentSchema = exports_external.strictObject({
|
|
45686
|
-
kind: exports_external.enum(["image", "file"]),
|
|
45687
|
-
name: exports_external.string(),
|
|
45688
|
-
url: exports_external.string(),
|
|
45689
|
-
thumbnailUrl: exports_external.string().optional(),
|
|
45690
|
-
contentType: exports_external.string().optional(),
|
|
45691
|
-
size: exports_external.string().optional(),
|
|
45692
|
-
sizeBytes: exports_external.number().nonnegative().optional(),
|
|
45693
|
-
width: exports_external.number().nonnegative().optional(),
|
|
45694
|
-
height: exports_external.number().nonnegative().optional()
|
|
45695
|
-
});
|
|
45696
45723
|
var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
45697
45724
|
id,
|
|
45698
45725
|
name: exports_external.string(),
|
|
@@ -45703,23 +45730,6 @@ var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
|
45703
45730
|
width: exports_external.number().int().nonnegative().nullable(),
|
|
45704
45731
|
height: exports_external.number().int().nonnegative().nullable()
|
|
45705
45732
|
});
|
|
45706
|
-
var CommunityMessagePreviewAttachmentSchema = CommunityMessageAttachmentSchema.partial().required({ name: true, url: true });
|
|
45707
|
-
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
45708
|
-
id,
|
|
45709
|
-
name: exports_external.string(),
|
|
45710
|
-
discriminator: exports_external.string().min(1).nullable(),
|
|
45711
|
-
avatar: exports_external.string().nullable(),
|
|
45712
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
45713
|
-
aboutMe: exports_external.string().optional(),
|
|
45714
|
-
bannerColor: exports_external.string().nullable().optional(),
|
|
45715
|
-
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
45716
|
-
ownerUserId: nullableId.optional(),
|
|
45717
|
-
ownerHandle: exports_external.string().nullable().optional(),
|
|
45718
|
-
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
45719
|
-
ownedByViewer: exports_external.boolean().optional(),
|
|
45720
|
-
statusEmoji: exports_external.string().nullable().optional(),
|
|
45721
|
-
statusText: exports_external.string().nullable().optional()
|
|
45722
|
-
});
|
|
45723
45733
|
var CommunityMessageThreadParticipantSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatar: true, avatarVersion: true });
|
|
45724
45734
|
var messageThreadSchema = exports_external.strictObject({
|
|
45725
45735
|
id,
|
|
@@ -45731,14 +45741,6 @@ var messageThreadSchema = exports_external.strictObject({
|
|
|
45731
45741
|
participants: exports_external.array(CommunityMessageThreadParticipantSchema).optional(),
|
|
45732
45742
|
participantCount: exports_external.number().int().nonnegative().optional()
|
|
45733
45743
|
});
|
|
45734
|
-
var legacyMessageThreadSchema = messageThreadSchema.extend({
|
|
45735
|
-
name: exports_external.string(),
|
|
45736
|
-
lastReplyAt: exports_external.string().optional(),
|
|
45737
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.extend({ avatar: exports_external.string() })).optional()
|
|
45738
|
-
});
|
|
45739
|
-
var messageThreadPreviewSchema = messageThreadSchema.partial().required({ id: true }).extend({
|
|
45740
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.partial().required({ id: true })).optional()
|
|
45741
|
-
});
|
|
45742
45744
|
var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
45743
45745
|
id,
|
|
45744
45746
|
channelId: id,
|
|
@@ -45761,7 +45763,7 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
45761
45763
|
authorName: exports_external.string(),
|
|
45762
45764
|
text: exports_external.string(),
|
|
45763
45765
|
deleted: exports_external.boolean().optional()
|
|
45764
|
-
}).optional(),
|
|
45766
|
+
}).refine((reply) => reply.deleted === true || reply.authorId !== undefined, { message: "Live reply author identity missing" }).optional(),
|
|
45765
45767
|
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
45766
45768
|
reactions: exports_external.array(exports_external.strictObject({
|
|
45767
45769
|
emoji: exports_external.string(),
|
|
@@ -45773,21 +45775,37 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
45773
45775
|
approval: FriendApprovalPayloadSchema.optional(),
|
|
45774
45776
|
botCreation: BotCreationPayloadSchema.optional()
|
|
45775
45777
|
});
|
|
45776
|
-
|
|
45777
|
-
|
|
45778
|
-
|
|
45779
|
-
|
|
45778
|
+
function communityMessageProfileIds(messages) {
|
|
45779
|
+
return [...new Set(messages.flatMap((message2) => [message2.authorId, ...message2.replyTo?.authorId && message2.replyTo.deleted !== true ? [message2.replyTo.authorId] : []]))];
|
|
45780
|
+
}
|
|
45781
|
+
var CommunityMessageResourcesSchema = exports_external.strictObject({
|
|
45782
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
45783
|
+
profiles: exports_external.array(CommunityResourceProfileSchema)
|
|
45784
|
+
}).superRefine((resources, ctx) => {
|
|
45785
|
+
const ids = new Set(resources.profiles.map((profile2) => profile2.id));
|
|
45786
|
+
if (ids.size !== resources.profiles.length || communityMessageProfileIds(resources.messages).some((id2) => !ids.has(id2))) {
|
|
45787
|
+
ctx.addIssue({ code: "custom", path: ["profiles"], message: "Message profile missing or duplicated in resource graph" });
|
|
45788
|
+
}
|
|
45789
|
+
});
|
|
45780
45790
|
var CommunityReadStateResourceSchema = exports_external.strictObject({
|
|
45781
45791
|
channelId: id,
|
|
45782
45792
|
lastReadMessageId: nullableId,
|
|
45783
45793
|
lastReadAt: exports_external.string().nullable(),
|
|
45784
45794
|
lastReadSeq: exports_external.number().int().nonnegative()
|
|
45785
45795
|
});
|
|
45786
|
-
var
|
|
45796
|
+
var CommunityServerMembershipResourceSchema = exports_external.strictObject({
|
|
45797
|
+
serverId: id,
|
|
45798
|
+
userId: id,
|
|
45799
|
+
memberId: id,
|
|
45800
|
+
role: exports_external.string()
|
|
45801
|
+
});
|
|
45802
|
+
var CommunityChannelMembershipResourceSchema = exports_external.strictObject({
|
|
45787
45803
|
channelId: id,
|
|
45788
45804
|
userId: id,
|
|
45789
45805
|
relation: exports_external.enum(["access", "notify"]),
|
|
45790
|
-
source: exports_external.
|
|
45806
|
+
source: exports_external.enum([...Object.values(PARTICIPANT_SOURCE), "explicit", "inherited", "admin", "access-decision"])
|
|
45807
|
+
});
|
|
45808
|
+
var CommunityMemberRelationSchema = CommunityChannelMembershipResourceSchema.extend({
|
|
45791
45809
|
isCreator: exports_external.boolean(),
|
|
45792
45810
|
role: exports_external.string().nullable(),
|
|
45793
45811
|
memberId: nullableId
|
|
@@ -45800,14 +45818,25 @@ var CommunityPageSchema = exports_external.strictObject({
|
|
|
45800
45818
|
latestSeq: exports_external.number().int().nonnegative()
|
|
45801
45819
|
});
|
|
45802
45820
|
var envelope = { contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), channelId: id };
|
|
45821
|
+
var CommunityResourceBundleSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
45822
|
+
viewerId: id,
|
|
45823
|
+
servers: exports_external.array(CommunityServerResourceSchema),
|
|
45824
|
+
serverMemberships: exports_external.array(CommunityServerMembershipResourceSchema),
|
|
45825
|
+
channels: exports_external.array(CommunityChannelResourceSchema),
|
|
45826
|
+
memberships: exports_external.array(CommunityChannelMembershipResourceSchema)
|
|
45827
|
+
}).superRefine((bundle, ctx) => {
|
|
45828
|
+
const channels = new Set(bundle.channels.map((row) => row.id));
|
|
45829
|
+
const servers = new Set(bundle.servers.map((row) => row.id));
|
|
45830
|
+
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)))
|
|
45831
|
+
ctx.addIssue({ code: "custom", message: "Resource bundle scope mismatch" });
|
|
45832
|
+
});
|
|
45803
45833
|
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
45804
|
-
var CommunityMessagesReadSchema =
|
|
45834
|
+
var CommunityMessagesReadSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
45805
45835
|
...envelope,
|
|
45806
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
45807
45836
|
page: CommunityPageSchema,
|
|
45808
45837
|
surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
|
|
45809
45838
|
});
|
|
45810
|
-
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.
|
|
45839
|
+
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.safeExtend({
|
|
45811
45840
|
viewerId: id,
|
|
45812
45841
|
peer: CommunityResourceProfileSchema.nullable(),
|
|
45813
45842
|
channel: CommunityChannelResourceSchema,
|
|
@@ -45822,6 +45851,12 @@ var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
|
45822
45851
|
anchorMessageId: nullableId
|
|
45823
45852
|
})
|
|
45824
45853
|
}).superRefine((entry, ctx) => {
|
|
45854
|
+
if (entry.opener) {
|
|
45855
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [...entry.messages, entry.opener], profiles: entry.profiles });
|
|
45856
|
+
if (!graph.success)
|
|
45857
|
+
for (const issue3 of graph.error.issues)
|
|
45858
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
45859
|
+
}
|
|
45825
45860
|
for (const [path, channelId] of [
|
|
45826
45861
|
[["channel", "id"], entry.channel.id],
|
|
45827
45862
|
[["access", "channelId"], entry.access.channelId],
|
|
@@ -45859,72 +45894,37 @@ var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
|
45859
45894
|
if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
|
|
45860
45895
|
ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
|
|
45861
45896
|
});
|
|
45862
|
-
var
|
|
45897
|
+
var CommunityMessageReadSchema = exports_external.strictObject({
|
|
45898
|
+
...envelope,
|
|
45863
45899
|
message: CommunityMessageResourceSchema,
|
|
45864
|
-
|
|
45865
|
-
|
|
45900
|
+
profiles: CommunityMessageResourcesSchema.shape.profiles
|
|
45901
|
+
}).superRefine((read, ctx) => {
|
|
45902
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [read.message], profiles: read.profiles });
|
|
45903
|
+
if (!graph.success)
|
|
45904
|
+
for (const issue3 of graph.error.issues)
|
|
45905
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
45866
45906
|
});
|
|
45867
|
-
var
|
|
45907
|
+
var CommunityMessagePostedSchema = CommunityMessageReadSchema.safeExtend({ deduped: exports_external.boolean(), threadId: id.optional() });
|
|
45868
45908
|
var CommunityMembersReadSchema = exports_external.strictObject({ ...envelope, relation: exports_external.enum(["access", "notify"]), members: exports_external.array(CommunityMemberRelationSchema), profiles: exports_external.array(CommunityResourceProfileSchema) });
|
|
45869
45909
|
var CommunityThreadsReadSchema = exports_external.strictObject({
|
|
45870
45910
|
...envelope,
|
|
45871
45911
|
channel: CommunityChannelResourceSchema,
|
|
45872
45912
|
threads: exports_external.array(CommunityChannelResourceSchema),
|
|
45873
|
-
included:
|
|
45874
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
45913
|
+
included: CommunityMessageResourcesSchema.safeExtend({
|
|
45875
45914
|
members: exports_external.array(CommunityMemberRelationSchema),
|
|
45876
|
-
profiles: exports_external.array(CommunityResourceProfileSchema),
|
|
45877
45915
|
tags: exports_external.array(exports_external.strictObject({ messageId: id, tag: exports_external.string() })),
|
|
45878
45916
|
participantCounts: exports_external.array(exports_external.strictObject({ channelId: id, count: exports_external.number().int().nonnegative() }))
|
|
45879
45917
|
}),
|
|
45880
45918
|
page: exports_external.strictObject({ nextCursor: exports_external.string().nullable(), hasMore: exports_external.boolean() })
|
|
45881
45919
|
});
|
|
45882
45920
|
var CommunityReadAdvanceSchema = exports_external.strictObject({ ...envelope, changed: exports_external.boolean(), targetSeq: exports_external.number().int().nonnegative(), revision: exports_external.number().int().nonnegative() });
|
|
45921
|
+
var CommunityInviteJoinTargetSchema = exports_external.object({ serverId: CommunityServerResourceSchema.shape.id }).strip();
|
|
45883
45922
|
var CommunityReadErrorSchema = exports_external.strictObject({ contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), error: exports_external.strictObject({
|
|
45884
45923
|
code: exports_external.enum(["invalid_input", "invalid_reply_target", "unauthenticated", "not_found", "not_allowed", "blocked", "idempotency_conflict", "rate_limited", "temporarily_unavailable"]),
|
|
45885
45924
|
message: exports_external.string(),
|
|
45886
|
-
retryable: exports_external.boolean()
|
|
45925
|
+
retryable: exports_external.boolean(),
|
|
45926
|
+
details: exports_external.array(exports_external.string()).optional()
|
|
45887
45927
|
}) });
|
|
45888
|
-
var legacyProfileSchema = CommunityResourceProfileSchema.pick({
|
|
45889
|
-
id: true,
|
|
45890
|
-
name: true,
|
|
45891
|
-
avatar: true,
|
|
45892
|
-
avatarVersion: true
|
|
45893
|
-
}).extend({ discriminator: exports_external.string().nullable(), statusEmoji: exports_external.string().nullable(), statusText: exports_external.string() });
|
|
45894
|
-
var CommunityLegacyMessageResourceSchema = CommunityMessageResourceSchema.extend({ authorAvatar: exports_external.string().optional(), attachments: exports_external.array(CommunityLegacyMessageAttachmentSchema), thread: legacyMessageThreadSchema.optional() });
|
|
45895
|
-
var legacyEnvelope = { contractVersion: exports_external.literal(2), channelId: id };
|
|
45896
|
-
var legacyReadSchemas = {
|
|
45897
|
-
channel: CommunityChannelReadSchema.extend(legacyEnvelope),
|
|
45898
|
-
messages: CommunityMessagesReadSchema.extend({ ...legacyEnvelope, messages: exports_external.array(CommunityLegacyMessageResourceSchema) }),
|
|
45899
|
-
members: CommunityMembersReadSchema.extend({ ...legacyEnvelope, profiles: exports_external.array(legacyProfileSchema) }),
|
|
45900
|
-
threads: CommunityThreadsReadSchema.extend({ ...legacyEnvelope, included: CommunityThreadsReadSchema.shape.included.extend({
|
|
45901
|
-
messages: exports_external.array(CommunityLegacyMessageResourceSchema),
|
|
45902
|
-
profiles: exports_external.array(legacyProfileSchema)
|
|
45903
|
-
}) }),
|
|
45904
|
-
readAdvance: CommunityReadAdvanceSchema.extend(legacyEnvelope),
|
|
45905
|
-
error: CommunityReadErrorSchema.extend({ contractVersion: exports_external.literal(2) })
|
|
45906
|
-
};
|
|
45907
|
-
var legacyChannelResourcePreviewSchema = CommunityChannelResourceSchema.partial().strip().extend({
|
|
45908
|
-
archived: legacyArchivedSchema.optional()
|
|
45909
|
-
});
|
|
45910
|
-
var legacyChannelResourceSchema = CommunityChannelResourceSchema.strip().extend({
|
|
45911
|
-
topic: CommunityChannelResourceSchema.shape.topic.nullish().transform((value) => value ?? ""),
|
|
45912
|
-
position: CommunityChannelResourceSchema.shape.position.nullish().transform((value) => value ?? 0),
|
|
45913
|
-
messageCount: CommunityChannelResourceSchema.shape.messageCount.nullish().transform((value) => value ?? 0),
|
|
45914
|
-
categoryId: nullableId.default(null),
|
|
45915
|
-
parentChannelId: nullableId.default(null),
|
|
45916
|
-
parentMessageId: nullableId.default(null),
|
|
45917
|
-
creatorId: nullableId.default(null),
|
|
45918
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null),
|
|
45919
|
-
archived: legacyArchivedSchema
|
|
45920
|
-
});
|
|
45921
|
-
var legacyMessageResourceSchema = CommunityLegacyMessageResourceSchema.strip().extend({
|
|
45922
|
-
channelId: id.optional(),
|
|
45923
|
-
replyToId: nullableId.optional(),
|
|
45924
|
-
clientNonce: CommunityMessageResourceSchema.shape.clientNonce.default(null),
|
|
45925
|
-
attachments: CommunityLegacyMessageResourceSchema.shape.attachments.default([]),
|
|
45926
|
-
embeds: CommunityMessageResourceSchema.shape.embeds.nullable().transform((value) => value ?? undefined)
|
|
45927
|
-
});
|
|
45928
45928
|
|
|
45929
45929
|
// ../shared/src/community-attention.ts
|
|
45930
45930
|
var id2 = exports_external.string().min(1);
|
|
@@ -45979,11 +45979,7 @@ var AttentionItemSchema = exports_external.strictObject({
|
|
|
45979
45979
|
ctx.addIssue({ code: "custom", message: "mention or reply cannot carry forum presentation refs" });
|
|
45980
45980
|
}
|
|
45981
45981
|
});
|
|
45982
|
-
var AttentionIncludedServerSchema =
|
|
45983
|
-
id: id2,
|
|
45984
|
-
name: exports_external.string(),
|
|
45985
|
-
discriminator: exports_external.string()
|
|
45986
|
-
});
|
|
45982
|
+
var AttentionIncludedServerSchema = CommunityServerResourceSchema.pick({ id: true, name: true, discriminator: true });
|
|
45987
45983
|
var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
45988
45984
|
id: true,
|
|
45989
45985
|
serverId: true,
|
|
@@ -46004,20 +46000,17 @@ var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
|
46004
46000
|
var AttentionIncludedDmSchema = exports_external.strictObject({
|
|
46005
46001
|
id: id2,
|
|
46006
46002
|
userId: id2,
|
|
46007
|
-
name:
|
|
46008
|
-
discriminator: exports_external.string(),
|
|
46009
|
-
avatar: exports_external.string(),
|
|
46010
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
46003
|
+
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
46011
46004
|
lastMessageAt: exports_external.string(),
|
|
46012
46005
|
lastUnreadSeq: exports_external.number().int().nonnegative()
|
|
46013
46006
|
});
|
|
46014
46007
|
var AttentionIncludedProfileSchema = exports_external.strictObject({
|
|
46015
46008
|
userId: CommunityResourceProfileSchema.shape.id,
|
|
46016
46009
|
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
46017
|
-
discriminator:
|
|
46018
|
-
avatar:
|
|
46010
|
+
discriminator: CommunityResourceProfileSchema.shape.discriminator,
|
|
46011
|
+
avatar: CommunityResourceProfileSchema.shape.avatar
|
|
46019
46012
|
});
|
|
46020
|
-
var AttentionIncludedMessageSchema =
|
|
46013
|
+
var AttentionIncludedMessageSchema = CommunityMessageResourceSchema.pick({
|
|
46021
46014
|
id: true,
|
|
46022
46015
|
channelId: true,
|
|
46023
46016
|
type: true,
|
|
@@ -46026,7 +46019,7 @@ var AttentionIncludedMessageSchema = CommunityMessagePreviewSchema.pick({
|
|
|
46026
46019
|
seq: true,
|
|
46027
46020
|
createdAt: true,
|
|
46028
46021
|
content: true
|
|
46029
|
-
}).
|
|
46022
|
+
}).partial({ authorId: true });
|
|
46030
46023
|
var AttentionIncludedSchema = exports_external.strictObject({
|
|
46031
46024
|
servers: exports_external.array(AttentionIncludedServerSchema),
|
|
46032
46025
|
channels: exports_external.array(AttentionIncludedChannelSchema),
|
|
@@ -46034,13 +46027,19 @@ var AttentionIncludedSchema = exports_external.strictObject({
|
|
|
46034
46027
|
profiles: exports_external.array(AttentionIncludedProfileSchema),
|
|
46035
46028
|
messages: exports_external.array(AttentionIncludedMessageSchema)
|
|
46036
46029
|
});
|
|
46037
|
-
var
|
|
46030
|
+
var AccountAttentionProjectionSchema = exports_external.strictObject({
|
|
46038
46031
|
scopes: exports_external.array(AttentionScopeSchema),
|
|
46039
46032
|
items: exports_external.array(AttentionItemSchema),
|
|
46040
46033
|
limit: exports_external.number().int().positive(),
|
|
46041
46034
|
truncated: exports_external.boolean(),
|
|
46042
46035
|
included: AttentionIncludedSchema
|
|
46036
|
+
});
|
|
46037
|
+
var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
46038
|
+
resources: CommunityResourceBundleSchema
|
|
46043
46039
|
}).superRefine((snapshot, ctx) => {
|
|
46040
|
+
const resources = snapshot.resources;
|
|
46041
|
+
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)))
|
|
46042
|
+
ctx.addIssue({ code: "custom", message: "Attention resource closure mismatch" });
|
|
46044
46043
|
const scopeIds = new Set;
|
|
46045
46044
|
for (const scope of snapshot.scopes) {
|
|
46046
46045
|
if (scopeIds.has(scope.scopeId)) {
|
|
@@ -46835,52 +46834,85 @@ var AGENT_UNREAD_CHANNEL_CHUNK_SIZE = maxInParams(13);
|
|
|
46835
46834
|
|
|
46836
46835
|
// ../shared/src/db/queries/community/mention.ts
|
|
46837
46836
|
var MENTION_INSERT_MAX_ROWS = maxRowsPerInsert(5);
|
|
46837
|
+
// ../shared/src/community-cache.ts
|
|
46838
|
+
var nullableString = exports_external.string().nullable();
|
|
46839
|
+
var optionalNullableString = nullableString.optional();
|
|
46840
|
+
var serverSchema = CommunityServerResourceSchema;
|
|
46841
|
+
var categorySchema = CommunityCategoryResourceSchema.extend({ pending: exports_external.boolean() });
|
|
46842
|
+
var channelLocalSchema = exports_external.strictObject({
|
|
46843
|
+
muted: exports_external.boolean(),
|
|
46844
|
+
tags: exports_external.array(exports_external.string()),
|
|
46845
|
+
pending: exports_external.boolean(),
|
|
46846
|
+
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
46847
|
+
openerUnread: exports_external.boolean().optional(),
|
|
46848
|
+
preview: exports_external.string().optional(),
|
|
46849
|
+
firstMessageId: exports_external.string().min(1).nullable().optional(),
|
|
46850
|
+
participantCount: exports_external.number().int().nonnegative().optional()
|
|
46851
|
+
});
|
|
46852
|
+
var channelSchema = CommunityChannelResourceSchema.extend(channelLocalSchema.shape);
|
|
46853
|
+
var serverMembershipSchema = CommunityServerMembershipResourceSchema.extend({
|
|
46854
|
+
id: exports_external.string().min(1),
|
|
46855
|
+
nickname: optionalNullableString,
|
|
46856
|
+
joinedAt: exports_external.string().optional(),
|
|
46857
|
+
viewer: exports_external.boolean()
|
|
46858
|
+
});
|
|
46859
|
+
var channelMembershipSchema = CommunityChannelMembershipResourceSchema.extend({ id: exports_external.string().min(1) });
|
|
46860
|
+
var readStateSchema = CommunityReadStateResourceSchema.extend({ observedRevision: exports_external.number().int().nonnegative().optional() });
|
|
46861
|
+
var friendshipSchema = exports_external.strictObject({
|
|
46862
|
+
id: exports_external.string().min(1),
|
|
46863
|
+
userId: exports_external.string().min(1),
|
|
46864
|
+
kind: exports_external.enum(["accepted", "incoming", "outgoing", "blocked"]),
|
|
46865
|
+
sub: exports_external.string().optional(),
|
|
46866
|
+
needsOwnerApproval: optionalNullableString
|
|
46867
|
+
});
|
|
46868
|
+
var readStateClockSchema = exports_external.strictObject({
|
|
46869
|
+
id: exports_external.literal("account"),
|
|
46870
|
+
revision: exports_external.number().int().nonnegative()
|
|
46871
|
+
});
|
|
46872
|
+
var folderSchema = exports_external.strictObject({
|
|
46873
|
+
id: exports_external.string().min(1),
|
|
46874
|
+
name: exports_external.string()
|
|
46875
|
+
});
|
|
46876
|
+
var serverRailSchema = exports_external.strictObject({
|
|
46877
|
+
id: exports_external.literal("account"),
|
|
46878
|
+
entries: exports_external.array(serverRailEntrySchema)
|
|
46879
|
+
});
|
|
46880
|
+
var folderItemSchema = exports_external.strictObject({
|
|
46881
|
+
id: exports_external.string().min(1),
|
|
46882
|
+
folderId: exports_external.string().min(1),
|
|
46883
|
+
serverId: exports_external.string().min(1),
|
|
46884
|
+
position: exports_external.number()
|
|
46885
|
+
});
|
|
46886
|
+
var notificationSettingSchema = exports_external.strictObject({
|
|
46887
|
+
id: exports_external.string().min(1),
|
|
46888
|
+
serverId: optionalNullableString,
|
|
46889
|
+
channelId: optionalNullableString,
|
|
46890
|
+
level: exports_external.string()
|
|
46891
|
+
}).superRefine((row, ctx) => {
|
|
46892
|
+
if (Boolean(row.serverId) === Boolean(row.channelId)) {
|
|
46893
|
+
ctx.addIssue({
|
|
46894
|
+
code: "custom",
|
|
46895
|
+
message: "notification setting requires exactly one target"
|
|
46896
|
+
});
|
|
46897
|
+
}
|
|
46898
|
+
});
|
|
46899
|
+
|
|
46838
46900
|
// ../shared/src/community-ws-events.ts
|
|
46839
46901
|
var string4 = exports_external.string();
|
|
46840
|
-
var
|
|
46902
|
+
var nullableString2 = string4.nullable();
|
|
46841
46903
|
var channelTypeSchema = CommunityChannelResourceSchema.shape.type.extract(["text", "forum"]);
|
|
46842
|
-
var
|
|
46843
|
-
id: string4,
|
|
46844
|
-
filename: string4,
|
|
46845
|
-
url: string4,
|
|
46846
|
-
thumbnailUrl: string4.optional(),
|
|
46847
|
-
contentType: string4.optional(),
|
|
46848
|
-
size: exports_external.number().optional(),
|
|
46849
|
-
width: exports_external.number().nullable().optional(),
|
|
46850
|
-
height: exports_external.number().nullable().optional()
|
|
46851
|
-
});
|
|
46852
|
-
var messageSchema = CommunityMessageResourceSchema.pick({
|
|
46853
|
-
content: true,
|
|
46854
|
-
type: true,
|
|
46855
|
-
systemKind: true,
|
|
46856
|
-
authorAvatar: true,
|
|
46857
|
-
authorAvatarVersion: true,
|
|
46858
|
-
mentionType: true,
|
|
46859
|
-
embeds: true,
|
|
46860
|
-
createdAt: true,
|
|
46861
|
-
approval: true,
|
|
46862
|
-
botCreation: true
|
|
46863
|
-
}).extend({
|
|
46864
|
-
id: string4,
|
|
46865
|
-
seq: exports_external.number(),
|
|
46866
|
-
authorId: string4,
|
|
46867
|
-
authorName: string4,
|
|
46868
|
-
authorAvatar: string4.optional(),
|
|
46869
|
-
authorAvatarVersion: CommunityMessageResourceSchema.shape.authorAvatarVersion.unwrap(),
|
|
46870
|
-
replyToId: nullableString.optional(),
|
|
46871
|
-
replyTo: CommunityMessageResourceSchema.shape.replyTo.unwrap().extend({
|
|
46872
|
-
id: string4,
|
|
46873
|
-
authorId: string4.optional()
|
|
46874
|
-
}).optional(),
|
|
46875
|
-
attachments: exports_external.array(messageAttachmentSchema).optional(),
|
|
46876
|
-
clientNonce: string4.optional()
|
|
46877
|
-
});
|
|
46878
|
-
var CommunityLegacyMessageCreateSchema = exports_external.strictObject({
|
|
46904
|
+
var communityMessageCreateSchema = exports_external.strictObject({
|
|
46879
46905
|
type: exports_external.literal("community:message.create"),
|
|
46880
46906
|
channelId: string4,
|
|
46881
46907
|
serverId: string4.optional(),
|
|
46882
46908
|
parentChannelId: string4.optional(),
|
|
46883
|
-
message:
|
|
46909
|
+
message: CommunityMessageResourceSchema.required({ authorName: true, authorAvatarVersion: true }),
|
|
46910
|
+
profiles: CommunityMessageResourcesSchema.shape.profiles
|
|
46911
|
+
}).refine((event) => event.message.channelId === event.channelId).superRefine((event, ctx) => {
|
|
46912
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [event.message], profiles: event.profiles });
|
|
46913
|
+
if (!graph.success)
|
|
46914
|
+
for (const issue3 of graph.error.issues)
|
|
46915
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
46884
46916
|
});
|
|
46885
46917
|
var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
46886
46918
|
type: exports_external.literal("community:message.updated"),
|
|
@@ -46889,14 +46921,6 @@ var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
|
46889
46921
|
approval: FriendApprovalPayloadSchema.optional(),
|
|
46890
46922
|
botCreation: BotCreationPayloadSchema.optional()
|
|
46891
46923
|
}).refine((event) => event.approval !== undefined || event.botCreation !== undefined);
|
|
46892
|
-
var communityMessageEditedSchema = exports_external.strictObject({
|
|
46893
|
-
type: exports_external.literal("community:message.edited"),
|
|
46894
|
-
channelId: string4,
|
|
46895
|
-
messageId: string4,
|
|
46896
|
-
content: string4,
|
|
46897
|
-
parentChannelId: string4.optional(),
|
|
46898
|
-
serverId: string4.optional()
|
|
46899
|
-
}).refine((event) => event.parentChannelId === undefined || event.serverId !== undefined);
|
|
46900
46924
|
var communityReactionAddSchema = exports_external.strictObject({
|
|
46901
46925
|
type: exports_external.literal("community:reaction.add"),
|
|
46902
46926
|
channelId: string4,
|
|
@@ -46938,35 +46962,19 @@ var communityTypingStopSchema = exports_external.strictObject({
|
|
|
46938
46962
|
var communityChildChannelCreateSchema = exports_external.strictObject({
|
|
46939
46963
|
type: exports_external.literal("community:channel.child_create"),
|
|
46940
46964
|
parentChannelId: string4,
|
|
46941
|
-
channel: exports_external.
|
|
46942
|
-
id: string4,
|
|
46943
|
-
name: string4,
|
|
46944
|
-
type: exports_external.literal("thread"),
|
|
46945
|
-
creatorId: string4.optional(),
|
|
46946
|
-
createdAt: string4
|
|
46947
|
-
}),
|
|
46965
|
+
channel: CommunityChannelResourceSchema.extend({ type: exports_external.literal("thread") }),
|
|
46948
46966
|
parentMessageId: string4.optional()
|
|
46949
|
-
});
|
|
46967
|
+
}).refine((event) => event.channel.parentChannelId === event.parentChannelId && (event.parentMessageId === undefined || event.parentMessageId === event.channel.parentMessageId));
|
|
46950
46968
|
var communityChildChannelUpdateSchema = exports_external.strictObject({
|
|
46951
46969
|
type: exports_external.literal("community:channel.child_update"),
|
|
46952
46970
|
parentChannelId: string4,
|
|
46953
46971
|
channelId: string4,
|
|
46954
|
-
changes: exports_external.
|
|
46955
|
-
name: string4.optional(),
|
|
46956
|
-
archived: exports_external.boolean().optional(),
|
|
46957
|
-
tags: exports_external.array(string4).nullable().optional(),
|
|
46958
|
-
lastMessageAt: string4.optional(),
|
|
46959
|
-
messageCount: exports_external.number().optional()
|
|
46960
|
-
})
|
|
46972
|
+
changes: CommunityChannelResourceSchema.pick({ name: true, archived: true, lastMessageAt: true, messageCount: true }).partial().extend({ tags: exports_external.array(string4).nullable().optional() })
|
|
46961
46973
|
});
|
|
46962
46974
|
var communityServerUpdateSchema = exports_external.strictObject({
|
|
46963
46975
|
type: exports_external.literal("community:server.update"),
|
|
46964
46976
|
serverId: string4,
|
|
46965
|
-
changes:
|
|
46966
|
-
name: string4.optional(),
|
|
46967
|
-
description: string4.optional(),
|
|
46968
|
-
icon: nullableString.optional()
|
|
46969
|
-
})
|
|
46977
|
+
changes: serverSchema.pick({ name: true, description: true, icon: true }).partial()
|
|
46970
46978
|
});
|
|
46971
46979
|
var communityServerRailChangedSchema = exports_external.strictObject({
|
|
46972
46980
|
type: exports_external.literal("community:server_rail.changed")
|
|
@@ -46978,32 +46986,19 @@ var communityServerDeleteSchema = exports_external.strictObject({
|
|
|
46978
46986
|
var communityChannelCreateSchema = exports_external.strictObject({
|
|
46979
46987
|
type: exports_external.literal("community:channel.create"),
|
|
46980
46988
|
serverId: string4,
|
|
46981
|
-
channel:
|
|
46982
|
-
|
|
46983
|
-
name: string4,
|
|
46984
|
-
type: channelTypeSchema,
|
|
46985
|
-
categoryId: nullableString.optional(),
|
|
46986
|
-
topic: string4.optional(),
|
|
46987
|
-
position: exports_external.number(),
|
|
46988
|
-
createdAt: string4
|
|
46989
|
-
})
|
|
46990
|
-
});
|
|
46989
|
+
channel: CommunityChannelResourceSchema.extend({ type: channelTypeSchema })
|
|
46990
|
+
}).refine((event) => event.channel.serverId === event.serverId);
|
|
46991
46991
|
var communityChannelUpdateSchema = exports_external.strictObject({
|
|
46992
46992
|
type: exports_external.literal("community:channel.update"),
|
|
46993
46993
|
serverId: string4,
|
|
46994
46994
|
channelId: string4,
|
|
46995
|
-
changes:
|
|
46996
|
-
name: string4.optional(),
|
|
46997
|
-
topic: string4.optional(),
|
|
46998
|
-
categoryId: nullableString.optional(),
|
|
46999
|
-
type: channelTypeSchema.optional()
|
|
47000
|
-
})
|
|
46995
|
+
changes: CommunityChannelResourceSchema.pick({ name: true, topic: true, categoryId: true, type: true }).partial().extend({ type: channelTypeSchema.optional() })
|
|
47001
46996
|
});
|
|
47002
46997
|
var communityChannelDeleteSchema = exports_external.strictObject({
|
|
47003
46998
|
type: exports_external.literal("community:channel.delete"),
|
|
47004
46999
|
serverId: string4,
|
|
47005
47000
|
channelId: string4,
|
|
47006
|
-
parentChannelId:
|
|
47001
|
+
parentChannelId: nullableString2.optional(),
|
|
47007
47002
|
parentMessageId: string4.optional()
|
|
47008
47003
|
}).refine((event) => event.parentMessageId === undefined || typeof event.parentChannelId === "string" && event.parentChannelId.length > 0, { message: "parentMessageId requires parentChannelId" });
|
|
47009
47004
|
var positionedIdSchema = exports_external.strictObject({ id: string4, position: exports_external.number() });
|
|
@@ -47012,18 +47007,6 @@ var communityChannelReorderSchema = exports_external.strictObject({
|
|
|
47012
47007
|
serverId: string4,
|
|
47013
47008
|
channels: exports_external.array(positionedIdSchema)
|
|
47014
47009
|
});
|
|
47015
|
-
var communityChannelMemberAddSchema = exports_external.strictObject({
|
|
47016
|
-
type: exports_external.literal("community:channel.member_add"),
|
|
47017
|
-
serverId: string4,
|
|
47018
|
-
channelId: string4,
|
|
47019
|
-
userId: string4
|
|
47020
|
-
});
|
|
47021
|
-
var communityChannelMemberRemoveSchema = exports_external.strictObject({
|
|
47022
|
-
type: exports_external.literal("community:channel.member_remove"),
|
|
47023
|
-
serverId: string4,
|
|
47024
|
-
channelId: string4,
|
|
47025
|
-
userId: string4
|
|
47026
|
-
});
|
|
47027
47010
|
var communityChannelMembershipChangeSchema = exports_external.strictObject({
|
|
47028
47011
|
type: exports_external.literal("community:channel.membership.change"),
|
|
47029
47012
|
channelId: string4,
|
|
@@ -47035,12 +47018,7 @@ var communityChannelMembershipChangeSchema = exports_external.strictObject({
|
|
|
47035
47018
|
var communityCategoryCreateSchema = exports_external.strictObject({
|
|
47036
47019
|
type: exports_external.literal("community:category.create"),
|
|
47037
47020
|
serverId: string4,
|
|
47038
|
-
category:
|
|
47039
|
-
id: string4,
|
|
47040
|
-
name: string4,
|
|
47041
|
-
position: exports_external.number(),
|
|
47042
|
-
private: exports_external.boolean()
|
|
47043
|
-
})
|
|
47021
|
+
category: CommunityCategoryResourceSchema
|
|
47044
47022
|
});
|
|
47045
47023
|
var communityCategoryUpdateSchema = exports_external.strictObject({
|
|
47046
47024
|
type: exports_external.literal("community:category.update"),
|
|
@@ -47065,13 +47043,9 @@ var communityCategoryReorderSchema = exports_external.strictObject({
|
|
|
47065
47043
|
var communityMemberJoinSchema = exports_external.strictObject({
|
|
47066
47044
|
type: exports_external.literal("community:member.join"),
|
|
47067
47045
|
serverId: string4,
|
|
47068
|
-
member:
|
|
47046
|
+
member: CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).extend({
|
|
47069
47047
|
id: string4,
|
|
47070
47048
|
userId: string4,
|
|
47071
|
-
name: string4,
|
|
47072
|
-
discriminator: string4,
|
|
47073
|
-
avatar: string4.optional(),
|
|
47074
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
47075
47049
|
role: string4,
|
|
47076
47050
|
joinedAt: string4
|
|
47077
47051
|
})
|
|
@@ -47088,7 +47062,7 @@ var communityMemberUpdateSchema = exports_external.strictObject({
|
|
|
47088
47062
|
userId: string4.optional(),
|
|
47089
47063
|
changes: exports_external.strictObject({
|
|
47090
47064
|
role: string4.optional(),
|
|
47091
|
-
nickname:
|
|
47065
|
+
nickname: nullableString2.optional()
|
|
47092
47066
|
})
|
|
47093
47067
|
});
|
|
47094
47068
|
var communityFriendRequestSchema = exports_external.strictObject({
|
|
@@ -47119,7 +47093,7 @@ var communityFriendBlockSchema = exports_external.strictObject({
|
|
|
47119
47093
|
userId: string4,
|
|
47120
47094
|
blockedByViewer: exports_external.boolean().optional()
|
|
47121
47095
|
});
|
|
47122
|
-
var
|
|
47096
|
+
var CommunityInviteCreateSchema = exports_external.strictObject({
|
|
47123
47097
|
type: exports_external.literal("community:invite.create"),
|
|
47124
47098
|
serverId: string4,
|
|
47125
47099
|
invite: exports_external.strictObject({
|
|
@@ -47127,7 +47101,7 @@ var communityInviteCreateSchema = exports_external.strictObject({
|
|
|
47127
47101
|
token: string4,
|
|
47128
47102
|
maxUses: exports_external.number().nullable().optional(),
|
|
47129
47103
|
uses: exports_external.number().nullable().optional(),
|
|
47130
|
-
expiresAt:
|
|
47104
|
+
expiresAt: nullableString2.optional(),
|
|
47131
47105
|
createdAt: string4
|
|
47132
47106
|
})
|
|
47133
47107
|
});
|
|
@@ -47172,24 +47146,17 @@ var communityPresenceUpdateSchema = exports_external.strictObject({
|
|
|
47172
47146
|
var communityStatusUpdateSchema = exports_external.strictObject({
|
|
47173
47147
|
type: exports_external.literal("community:status.update"),
|
|
47174
47148
|
userId: string4,
|
|
47175
|
-
statusEmoji:
|
|
47176
|
-
statusText:
|
|
47149
|
+
statusEmoji: nullableString2,
|
|
47150
|
+
statusText: nullableString2
|
|
47177
47151
|
});
|
|
47178
|
-
var communityIdentityUpdateSchema =
|
|
47152
|
+
var communityIdentityUpdateSchema = CommunityResourceProfileSchema.pick({ avatar: true, avatarVersion: true }).extend({
|
|
47179
47153
|
type: exports_external.literal("community:identity.update"),
|
|
47180
47154
|
userId: string4,
|
|
47181
|
-
|
|
47182
|
-
avatarVersion: exports_external.number().int().positive()
|
|
47155
|
+
avatarVersion: CommunityResourceProfileSchema.shape.avatarVersion.refine((version3) => version3 > 0)
|
|
47183
47156
|
});
|
|
47184
|
-
var communityProfileUpdateSchema =
|
|
47157
|
+
var communityProfileUpdateSchema = CommunityResourceProfileSchema.pick({ name: true, discriminator: true, aboutMe: true, bannerColor: true, kind: true, ownerUserId: true }).required().extend({
|
|
47185
47158
|
type: exports_external.literal("community:profile.update"),
|
|
47186
|
-
userId: string4
|
|
47187
|
-
name: string4,
|
|
47188
|
-
discriminator: string4,
|
|
47189
|
-
aboutMe: string4,
|
|
47190
|
-
bannerColor: nullableString,
|
|
47191
|
-
kind: exports_external.enum(["human", "bot"]),
|
|
47192
|
-
ownerUserId: nullableString
|
|
47159
|
+
userId: string4
|
|
47193
47160
|
});
|
|
47194
47161
|
var communityMachineCreatedSchema = exports_external.strictObject({
|
|
47195
47162
|
type: exports_external.literal("community:machine.created"),
|
|
@@ -47216,8 +47183,8 @@ var communityBotAuditEventSchema = exports_external.strictObject({
|
|
|
47216
47183
|
id: string4,
|
|
47217
47184
|
kind: exports_external.enum(["cli_invocation", "tool_call", "thinking", "text", "turn_interrupt", "wake_trigger", "session_reset", "nap", "model_changed", "provider_changed", "error"]),
|
|
47218
47185
|
payload: exports_external.unknown(),
|
|
47219
|
-
sessionId:
|
|
47220
|
-
launchId:
|
|
47186
|
+
sessionId: nullableString2.optional(),
|
|
47187
|
+
launchId: nullableString2.optional(),
|
|
47221
47188
|
createdAt: string4
|
|
47222
47189
|
}).refine((event) => Object.prototype.hasOwnProperty.call(event, "payload"));
|
|
47223
47190
|
var communityRuntimeModelsSchema = exports_external.strictObject({
|
|
@@ -47237,7 +47204,6 @@ var communityBotPiiSchema = exports_external.strictObject({
|
|
|
47237
47204
|
var commonCommunityEventSchemas = [
|
|
47238
47205
|
communityBotPiiSchema,
|
|
47239
47206
|
communityMessageUpdatedSchema,
|
|
47240
|
-
communityMessageEditedSchema,
|
|
47241
47207
|
communityReactionAddSchema,
|
|
47242
47208
|
communityReactionRemoveSchema,
|
|
47243
47209
|
communityPinAddSchema,
|
|
@@ -47249,8 +47215,6 @@ var commonCommunityEventSchemas = [
|
|
|
47249
47215
|
communityServerDeleteSchema,
|
|
47250
47216
|
communityChannelDeleteSchema,
|
|
47251
47217
|
communityChannelReorderSchema,
|
|
47252
|
-
communityChannelMemberAddSchema,
|
|
47253
|
-
communityChannelMemberRemoveSchema,
|
|
47254
47218
|
communityChannelMembershipChangeSchema,
|
|
47255
47219
|
communityCategoryCreateSchema,
|
|
47256
47220
|
communityCategoryUpdateSchema,
|
|
@@ -47264,7 +47228,7 @@ var commonCommunityEventSchemas = [
|
|
|
47264
47228
|
communityFriendRejectSchema,
|
|
47265
47229
|
communityFriendRemoveSchema,
|
|
47266
47230
|
communityFriendBlockSchema,
|
|
47267
|
-
|
|
47231
|
+
CommunityInviteCreateSchema,
|
|
47268
47232
|
communityMentionCreateSchema,
|
|
47269
47233
|
communityUnreadBumpSchema,
|
|
47270
47234
|
communityReadStateAdvancedSchema,
|
|
@@ -47278,9 +47242,9 @@ var commonCommunityEventSchemas = [
|
|
|
47278
47242
|
communityMachineRemovedSchema,
|
|
47279
47243
|
communityBotAuditEventSchema
|
|
47280
47244
|
];
|
|
47281
|
-
var
|
|
47245
|
+
var CommunityWsEventSchema = exports_external.discriminatedUnion("type", [
|
|
47282
47246
|
...commonCommunityEventSchemas,
|
|
47283
|
-
|
|
47247
|
+
communityMessageCreateSchema,
|
|
47284
47248
|
communityChildChannelCreateSchema,
|
|
47285
47249
|
communityChannelCreateSchema,
|
|
47286
47250
|
communityChildChannelUpdateSchema,
|
|
@@ -47288,22 +47252,9 @@ var CommunityWsEventDiscriminatedSchema = exports_external.discriminatedUnion("t
|
|
|
47288
47252
|
communityIdentityUpdateSchema,
|
|
47289
47253
|
communityProfileUpdateSchema
|
|
47290
47254
|
]);
|
|
47291
|
-
var CommunityResourceWsEventDiscriminatedSchema = exports_external.discriminatedUnion("type", [
|
|
47292
|
-
...commonCommunityEventSchemas,
|
|
47293
|
-
CommunityLegacyMessageCreateSchema.extend({ message: CommunityMessageResourceSchema.required({ authorName: true, authorAvatarVersion: true }) }).refine((event) => event.message.channelId === event.channelId),
|
|
47294
|
-
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)),
|
|
47295
|
-
communityChannelCreateSchema.extend({ channel: CommunityChannelResourceSchema.extend({ type: channelTypeSchema }) }).refine((event) => event.channel.serverId === event.serverId),
|
|
47296
|
-
communityChildChannelUpdateSchema.extend({ changes: CommunityChannelResourceSchema.pick({ name: true, archived: true, lastMessageAt: true, messageCount: true }).partial().extend({ tags: exports_external.array(string4).nullable().optional() }) }),
|
|
47297
|
-
communityChannelUpdateSchema.extend({ changes: CommunityChannelResourceSchema.pick({ name: true, topic: true, categoryId: true, type: true }).partial().extend({ type: channelTypeSchema.optional() }) }),
|
|
47298
|
-
communityIdentityUpdateSchema.extend({ avatar: CommunityResourceProfileSchema.shape.avatar, avatarVersion: CommunityResourceProfileSchema.shape.avatarVersion.refine((version3) => version3 > 0) }),
|
|
47299
|
-
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 })
|
|
47300
|
-
]);
|
|
47301
|
-
var CommunityWsEventSchema = CommunityWsEventDiscriminatedSchema.transform((event) => event);
|
|
47302
|
-
var CommunityResourceWsEventSchema = CommunityResourceWsEventDiscriminatedSchema.transform((event) => event);
|
|
47303
47255
|
var WS_EVENTS = {
|
|
47304
47256
|
MESSAGE_CREATE: "community:message.create",
|
|
47305
47257
|
MESSAGE_UPDATED: "community:message.updated",
|
|
47306
|
-
MESSAGE_EDITED: "community:message.edited",
|
|
47307
47258
|
REACTION_ADD: "community:reaction.add",
|
|
47308
47259
|
REACTION_REMOVE: "community:reaction.remove",
|
|
47309
47260
|
PIN_ADD: "community:pin.add",
|
|
@@ -47319,8 +47270,6 @@ var WS_EVENTS = {
|
|
|
47319
47270
|
CHANNEL_UPDATE: "community:channel.update",
|
|
47320
47271
|
CHANNEL_DELETE: "community:channel.delete",
|
|
47321
47272
|
CHANNEL_REORDER: "community:channel.reorder",
|
|
47322
|
-
CHANNEL_MEMBER_ADD: "community:channel.member_add",
|
|
47323
|
-
CHANNEL_MEMBER_REMOVE: "community:channel.member_remove",
|
|
47324
47273
|
CHANNEL_MEMBERSHIP_CHANGE: "community:channel.membership.change",
|
|
47325
47274
|
CATEGORY_CREATE: "community:category.create",
|
|
47326
47275
|
CATEGORY_UPDATE: "community:category.update",
|
|
@@ -47380,20 +47329,14 @@ var MESSAGE_DELIVERY_MAX_USERS = 1000;
|
|
|
47380
47329
|
var MESSAGE_DELIVERY_MAX_EVENTS_PER_USER = 5;
|
|
47381
47330
|
var target = exports_external.string().refine(isValidCommunityUserTarget);
|
|
47382
47331
|
var targetList = exports_external.array(target).max(MESSAGE_DELIVERY_MAX_USERS);
|
|
47383
|
-
var memberAddedSchema = exports_external.strictObject({
|
|
47384
|
-
userId: target,
|
|
47385
|
-
serverId: exports_external.string().min(1),
|
|
47386
|
-
channelId: exports_external.string().min(1)
|
|
47387
|
-
});
|
|
47388
47332
|
var batchShape = exports_external.strictObject({
|
|
47389
|
-
communityContract: exports_external.literal(
|
|
47333
|
+
communityContract: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
47390
47334
|
messageId: exports_external.string().min(1),
|
|
47391
47335
|
messageEvent: exports_external.unknown(),
|
|
47392
47336
|
contentUserIds: targetList,
|
|
47393
47337
|
unreadPlainUserIds: targetList,
|
|
47394
47338
|
unreadMentionUserIds: targetList,
|
|
47395
47339
|
mentionUserIds: targetList,
|
|
47396
|
-
memberAdded: memberAddedSchema.optional(),
|
|
47397
47340
|
joinedParticipantUserIds: targetList.optional(),
|
|
47398
47341
|
rosterRefreshUserId: target.optional(),
|
|
47399
47342
|
parentProjection: exports_external.unknown().optional(),
|
|
@@ -47690,6 +47633,199 @@ var channelReorderRequestSchema = exports_external.strictObject({
|
|
|
47690
47633
|
channelIds: exports_external.array(exports_external.string().min(1)).min(1).refine((ids) => new Set(ids).size === ids.length, "channelIds must be unique"),
|
|
47691
47634
|
move: exports_external.strictObject({ channelId: exports_external.string().min(1), categoryId: exports_external.string().min(1).nullable() }).optional()
|
|
47692
47635
|
}).refine((request) => !request.move || request.channelIds.includes(request.move.channelId), "moved channel must be included in channelIds");
|
|
47636
|
+
// ../shared/src/task-payload-cache.ts
|
|
47637
|
+
var TaskEmailAddressCacheSchema = exports_external.array(exports_external.strictObject({
|
|
47638
|
+
workspaceId: exports_external.string().min(1),
|
|
47639
|
+
agentId: exports_external.string().min(1),
|
|
47640
|
+
emailAddress: exports_external.string()
|
|
47641
|
+
}));
|
|
47642
|
+
var TaskMemberInstructionCacheSchema = exports_external.strictObject({
|
|
47643
|
+
workspaceId: exports_external.string().min(1),
|
|
47644
|
+
userId: exports_external.string().min(1),
|
|
47645
|
+
globalInstruction: exports_external.string()
|
|
47646
|
+
}).nullable();
|
|
47647
|
+
var TaskUserIdentityCacheSchema = CommunityResourceProfileSchema.pick({ id: true, name: true }).extend({ email: exports_external.string() }).nullable();
|
|
47648
|
+
// ../shared/src/community-forum-sidebar.ts
|
|
47649
|
+
var timestamp = exports_external.string().refine((value) => Number.isFinite(Date.parse(value)));
|
|
47650
|
+
var CommunityForumSidebarChannelSummarySchema = CommunityChannelResourceSchema.pick({
|
|
47651
|
+
id: true,
|
|
47652
|
+
name: true,
|
|
47653
|
+
serverId: true,
|
|
47654
|
+
parentChannelId: true,
|
|
47655
|
+
parentMessageId: true
|
|
47656
|
+
}).extend({
|
|
47657
|
+
serverId: CommunityChannelResourceSchema.shape.serverId.unwrap(),
|
|
47658
|
+
parentChannelId: CommunityChannelResourceSchema.shape.parentChannelId.unwrap(),
|
|
47659
|
+
parentMessageId: CommunityChannelResourceSchema.shape.parentMessageId.unwrap(),
|
|
47660
|
+
activityAt: timestamp,
|
|
47661
|
+
expiresAt: timestamp,
|
|
47662
|
+
unread: exports_external.boolean()
|
|
47663
|
+
});
|
|
47664
|
+
var CommunityForumSidebarEnvelopeSchema = exports_external.strictObject({
|
|
47665
|
+
schemaVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
47666
|
+
serverId: exports_external.string().min(1),
|
|
47667
|
+
channels: exports_external.array(CommunityForumSidebarChannelSummarySchema),
|
|
47668
|
+
canonicalChannels: exports_external.array(CommunityForumSidebarChannelSummarySchema),
|
|
47669
|
+
retainedChannel: CommunityForumSidebarChannelSummarySchema.nullable(),
|
|
47670
|
+
retainedDisposition: exports_external.enum(["eligible", "opener-archived", "genuine-negative"]).nullable(),
|
|
47671
|
+
resources: CommunityResourceBundleSchema,
|
|
47672
|
+
serverNow: timestamp
|
|
47673
|
+
}).superRefine((data, ctx) => {
|
|
47674
|
+
const selected = [...data.canonicalChannels, ...data.retainedChannel ? [data.retainedChannel] : []];
|
|
47675
|
+
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"))) {
|
|
47676
|
+
ctx.addIssue({ code: "custom", message: "Forum sidebar resource closure mismatch" });
|
|
47677
|
+
}
|
|
47678
|
+
});
|
|
47679
|
+
// ../shared/src/community-machine-resources.ts
|
|
47680
|
+
var CommunityMachineIdentityCacheSchema = CommunityMachineSummarySchema.pick({
|
|
47681
|
+
id: true,
|
|
47682
|
+
hostname: true,
|
|
47683
|
+
displayName: true,
|
|
47684
|
+
platform: true,
|
|
47685
|
+
arch: true,
|
|
47686
|
+
osRelease: true,
|
|
47687
|
+
daemonVersion: true,
|
|
47688
|
+
createdAt: true,
|
|
47689
|
+
updatedAt: true
|
|
47690
|
+
});
|
|
47691
|
+
var CommunityMachineListReadSchema = exports_external.strictObject({ machines: exports_external.array(CommunityMachineSummarySchema), complete: exports_external.literal(true) });
|
|
47692
|
+
// ../shared/src/community-friends.ts
|
|
47693
|
+
var CommunityAcceptedFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true, sub: true });
|
|
47694
|
+
var CommunityBlockedFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true });
|
|
47695
|
+
var CommunityPendingFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true, needsOwnerApproval: true }).extend({
|
|
47696
|
+
kind: friendshipSchema.shape.kind.extract(["incoming", "outgoing"])
|
|
47697
|
+
});
|
|
47698
|
+
var envelope2 = { contractVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION) };
|
|
47699
|
+
var fresh = { ...envelope2, resources: CommunityResourceBundleSchema, stale: exports_external.literal(false).optional() };
|
|
47700
|
+
var stale = { ...envelope2, stale: exports_external.literal(true) };
|
|
47701
|
+
function checkProfiles(rows, resources, ctx) {
|
|
47702
|
+
if (rows.some((row) => !resources.profiles.some((profile2) => profile2.id === row.userId))) {
|
|
47703
|
+
ctx.addIssue({ code: "custom", message: "Friend profile resource missing" });
|
|
47704
|
+
}
|
|
47705
|
+
}
|
|
47706
|
+
var CommunityAcceptedFriendsReadSchema = exports_external.union([
|
|
47707
|
+
exports_external.strictObject({ ...fresh, friends: exports_external.array(CommunityAcceptedFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.friends, value.resources, ctx)),
|
|
47708
|
+
exports_external.strictObject({ ...stale, friends: exports_external.array(CommunityAcceptedFriendDescriptorSchema).length(0) })
|
|
47709
|
+
]);
|
|
47710
|
+
var CommunityBlockedFriendsReadSchema = exports_external.union([
|
|
47711
|
+
exports_external.strictObject({ ...fresh, blocked: exports_external.array(CommunityBlockedFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.blocked, value.resources, ctx)),
|
|
47712
|
+
exports_external.strictObject({ ...stale, blocked: exports_external.array(CommunityBlockedFriendDescriptorSchema).length(0) })
|
|
47713
|
+
]);
|
|
47714
|
+
var CommunityPendingFriendsReadSchema = exports_external.union([
|
|
47715
|
+
exports_external.strictObject({ ...fresh, pending: exports_external.array(CommunityPendingFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.pending, value.resources, ctx)),
|
|
47716
|
+
exports_external.strictObject({ ...stale, pending: exports_external.array(CommunityPendingFriendDescriptorSchema).length(0) })
|
|
47717
|
+
]);
|
|
47718
|
+
// ../shared/src/community-invites.ts
|
|
47719
|
+
var CommunityInviteListItemSchema = CommunityInviteCreateSchema.shape.invite.required({ maxUses: true, uses: true, expiresAt: true }).extend({
|
|
47720
|
+
uses: CommunityInviteCreateSchema.shape.invite.shape.uses.unwrap().unwrap().int().nonnegative(),
|
|
47721
|
+
creatorId: CommunityResourceProfileSchema.shape.id.nullable()
|
|
47722
|
+
});
|
|
47723
|
+
var CommunityInvitesReadSchema = exports_external.strictObject({
|
|
47724
|
+
contractVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
47725
|
+
serverId: CommunityServerResourceSchema.shape.id,
|
|
47726
|
+
invites: exports_external.array(CommunityInviteListItemSchema),
|
|
47727
|
+
resources: CommunityResourceBundleSchema
|
|
47728
|
+
}).superRefine((value, ctx) => {
|
|
47729
|
+
if (new Set(value.invites.map((row) => row.id)).size !== value.invites.length)
|
|
47730
|
+
ctx.addIssue({ code: "custom", message: "Duplicate invite descriptor" });
|
|
47731
|
+
if (!value.resources.servers.some((row) => row.id === value.serverId) || value.resources.servers.some((row) => row.id !== value.serverId))
|
|
47732
|
+
ctx.addIssue({ code: "custom", message: "Invite server resource mismatch" });
|
|
47733
|
+
if (value.invites.some((row) => row.creatorId !== null && !value.resources.profiles.some((profile2) => profile2.id === row.creatorId)))
|
|
47734
|
+
ctx.addIssue({ code: "custom", message: "Invite creator profile resource missing" });
|
|
47735
|
+
});
|
|
47736
|
+
// ../shared/src/community-dms.ts
|
|
47737
|
+
var CommunityDmReadItemSchema = exports_external.strictObject({
|
|
47738
|
+
id: CommunityChannelResourceSchema.shape.id,
|
|
47739
|
+
userId: CommunityResourceProfileSchema.shape.id,
|
|
47740
|
+
channel: CommunityChannelResourceSchema,
|
|
47741
|
+
profile: CommunityResourceProfileSchema,
|
|
47742
|
+
memberships: exports_external.array(CommunityMemberRelationSchema).length(2),
|
|
47743
|
+
preview: exports_external.string(),
|
|
47744
|
+
activityAt: CommunityChannelResourceSchema.shape.createdAt,
|
|
47745
|
+
unread: exports_external.boolean(),
|
|
47746
|
+
lastUnreadSeq: CommunityMessageResourceSchema.shape.seq.optional()
|
|
47747
|
+
}).superRefine((dm, ctx) => {
|
|
47748
|
+
const users = new Set(dm.memberships.map((row) => row.userId));
|
|
47749
|
+
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)) {
|
|
47750
|
+
ctx.addIssue({ code: "custom", message: "DM resource scope mismatch" });
|
|
47751
|
+
}
|
|
47752
|
+
});
|
|
47753
|
+
var CommunityDmsReadSchema = exports_external.strictObject({ conversations: exports_external.array(CommunityDmReadItemSchema) }).superRefine((value, ctx) => {
|
|
47754
|
+
if (new Set(value.conversations.map((row) => row.id)).size !== value.conversations.length) {
|
|
47755
|
+
ctx.addIssue({ code: "custom", message: "Duplicate DM resource identity" });
|
|
47756
|
+
}
|
|
47757
|
+
});
|
|
47758
|
+
// ../shared/src/community-profile-reads.ts
|
|
47759
|
+
var CommunitySelfProfileReadSchema = CommunityResourceProfileSchema.pick({
|
|
47760
|
+
id: true,
|
|
47761
|
+
name: true,
|
|
47762
|
+
discriminator: true,
|
|
47763
|
+
avatar: true,
|
|
47764
|
+
avatarVersion: true,
|
|
47765
|
+
aboutMe: true,
|
|
47766
|
+
bannerColor: true,
|
|
47767
|
+
statusEmoji: true,
|
|
47768
|
+
statusText: true
|
|
47769
|
+
}).required();
|
|
47770
|
+
var card = CommunitySelfProfileReadSchema.omit({ avatar: true }).extend({
|
|
47771
|
+
image: CommunityResourceProfileSchema.shape.avatar,
|
|
47772
|
+
mutualServers: CommunityResourceProfileSchema.shape.mutualServers.unwrap()
|
|
47773
|
+
});
|
|
47774
|
+
var CommunityUserCardReadSchema = exports_external.discriminatedUnion("kind", [
|
|
47775
|
+
card.extend({ kind: exports_external.literal("human") }),
|
|
47776
|
+
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() })
|
|
47777
|
+
]);
|
|
47778
|
+
var CommunityServerMemberReadSchema = CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true, statusEmoji: true, statusText: true }).required().extend({
|
|
47779
|
+
id: CommunityServerMembershipResourceSchema.shape.memberId,
|
|
47780
|
+
userId: CommunityResourceProfileSchema.shape.id,
|
|
47781
|
+
role: exports_external.enum(ROLES),
|
|
47782
|
+
status: exports_external.enum(["online", "offline"]),
|
|
47783
|
+
sub: exports_external.string(),
|
|
47784
|
+
isBot: exports_external.literal(true).optional(),
|
|
47785
|
+
ownerUserId: CommunityResourceProfileSchema.shape.id.optional()
|
|
47786
|
+
}).superRefine((row, ctx) => {
|
|
47787
|
+
if (row.isBot === true !== (row.ownerUserId !== undefined))
|
|
47788
|
+
ctx.addIssue({ code: "custom", message: "Member owner metadata mismatch" });
|
|
47789
|
+
});
|
|
47790
|
+
var page = exports_external.strictObject({
|
|
47791
|
+
viewerId: CommunityResourceProfileSchema.shape.id,
|
|
47792
|
+
serverId: CommunityServerMembershipResourceSchema.shape.serverId,
|
|
47793
|
+
members: exports_external.array(CommunityServerMemberReadSchema),
|
|
47794
|
+
hasMore: exports_external.boolean(),
|
|
47795
|
+
cursor: exports_external.string().min(1).optional(),
|
|
47796
|
+
limit: exports_external.number().int().positive()
|
|
47797
|
+
});
|
|
47798
|
+
var validatePage = (value, ctx) => {
|
|
47799
|
+
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))
|
|
47800
|
+
ctx.addIssue({ code: "custom", message: "Member page scope mismatch" });
|
|
47801
|
+
};
|
|
47802
|
+
var CommunityServerMembersReadSchema = page.extend({ total: exports_external.number().int().nonnegative() }).superRefine(validatePage);
|
|
47803
|
+
var CommunityServerMemberSearchReadSchema = page.superRefine(validatePage);
|
|
47804
|
+
var CommunityUserSearchReadSchema = exports_external.strictObject({ users: exports_external.array(CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatarVersion: true }).extend({ image: CommunityResourceProfileSchema.shape.avatar })) });
|
|
47805
|
+
var CommunityReactionActorProfileSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatar: true, avatarVersion: true });
|
|
47806
|
+
var CommunityReactionDetailsReadSchema = exports_external.strictObject({
|
|
47807
|
+
messageId: CommunityResourceProfileSchema.shape.id,
|
|
47808
|
+
scope: exports_external.discriminatedUnion("kind", [
|
|
47809
|
+
exports_external.strictObject({ kind: exports_external.literal("server"), serverId: CommunityServerMembershipResourceSchema.shape.serverId, channelId: CommunityResourceProfileSchema.shape.id }),
|
|
47810
|
+
exports_external.strictObject({ kind: exports_external.literal("dm"), channelId: CommunityResourceProfileSchema.shape.id })
|
|
47811
|
+
]),
|
|
47812
|
+
actors: exports_external.array(exports_external.strictObject({ userId: CommunityResourceProfileSchema.shape.id, profile: CommunityReactionActorProfileSchema.nullable() }))
|
|
47813
|
+
}).superRefine((value, ctx) => {
|
|
47814
|
+
if (new Set(value.actors.map((row) => row.userId)).size !== value.actors.length || value.actors.some((row) => row.profile && row.profile.id !== row.userId))
|
|
47815
|
+
ctx.addIssue({ code: "custom", message: "Reaction actor identity mismatch" });
|
|
47816
|
+
});
|
|
47817
|
+
var CommunityBotProfileSummarySchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatarVersion: true }).extend({
|
|
47818
|
+
image: CommunityResourceProfileSchema.shape.avatar,
|
|
47819
|
+
discriminator: CommunityResourceProfileSchema.shape.discriminator.optional(),
|
|
47820
|
+
description: CommunityResourceProfileSchema.shape.aboutMe,
|
|
47821
|
+
presence: exports_external.enum(["online", "offline"]).optional()
|
|
47822
|
+
}).strip();
|
|
47823
|
+
var CommunityBotsProfileReadSchema = exports_external.object({
|
|
47824
|
+
bots: exports_external.array(CommunityBotProfileSummarySchema.required({ discriminator: true, description: true, presence: true }).extend({ ownerUserId: CommunityResourceProfileSchema.shape.id }))
|
|
47825
|
+
}).strip().superRefine((value, ctx) => {
|
|
47826
|
+
if (new Set(value.bots.map((row) => row.id)).size !== value.bots.length)
|
|
47827
|
+
ctx.addIssue({ code: "custom", message: "Duplicate bot catalogue identity" });
|
|
47828
|
+
});
|
|
47693
47829
|
// src/cli/platform.ts
|
|
47694
47830
|
var failure2 = (message2, code, details) => Object.assign(new Error(message2), { code, platformDetails: details });
|
|
47695
47831
|
function registerPlatformCommands(program, getApi, output2) {
|
|
@@ -49927,10 +50063,10 @@ async function probeAgy(command, includeModels = false) {
|
|
|
49927
50063
|
function validIdentityPart(value) {
|
|
49928
50064
|
return value.trim().length > 0 && Buffer.byteLength(value, "utf8") <= 512;
|
|
49929
50065
|
}
|
|
49930
|
-
function identityKey(
|
|
49931
|
-
if (!validIdentityPart(
|
|
50066
|
+
function identityKey(identity2) {
|
|
50067
|
+
if (!validIdentityPart(identity2.runtime) || !validIdentityPart(identity2.backendSessionId) || !validIdentityPart(identity2.providerRecordId))
|
|
49932
50068
|
return null;
|
|
49933
|
-
return JSON.stringify([
|
|
50069
|
+
return JSON.stringify([identity2.runtime, identity2.backendSessionId, identity2.providerRecordId]);
|
|
49934
50070
|
}
|
|
49935
50071
|
function metric(value) {
|
|
49936
50072
|
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : null;
|
|
@@ -49970,8 +50106,8 @@ class SettledUsageProjector {
|
|
|
49970
50106
|
usage: { input: input2, output: output2, cache }
|
|
49971
50107
|
};
|
|
49972
50108
|
}
|
|
49973
|
-
release(
|
|
49974
|
-
const key = identityKey(
|
|
50109
|
+
release(identity2) {
|
|
50110
|
+
const key = identityKey(identity2);
|
|
49975
50111
|
if (key)
|
|
49976
50112
|
this.active.delete(key);
|
|
49977
50113
|
}
|
|
@@ -50277,9 +50413,9 @@ function count(data, number4) {
|
|
|
50277
50413
|
function parseNativeGeneration(data) {
|
|
50278
50414
|
const chat = nested(fields(data), 1);
|
|
50279
50415
|
const usage = nested(chat, 4);
|
|
50280
|
-
const
|
|
50281
|
-
const seconds = count(
|
|
50282
|
-
const nanos = count(
|
|
50416
|
+
const timestamp2 = nested(nested(chat, 9), 4);
|
|
50417
|
+
const seconds = count(timestamp2, 1);
|
|
50418
|
+
const nanos = count(timestamp2, 2) ?? 0;
|
|
50283
50419
|
const milliseconds = seconds === null ? NaN : seconds * 1000 + Math.floor(nanos / 1e6);
|
|
50284
50420
|
const occurredAt = nanos < 1e9 && Number.isFinite(milliseconds) && milliseconds <= 8640000000000000 ? new Date(milliseconds).toISOString() : null;
|
|
50285
50421
|
return { usage: { input: count(usage, 2), output: count(usage, 3), cache: count(usage, 5) }, occurredAt };
|
|
@@ -51170,8 +51306,8 @@ function antigravitySpawnSpec(command, platform = process.platform) {
|
|
|
51170
51306
|
async function probeAntigravity(command, options = {}) {
|
|
51171
51307
|
const spec = antigravitySpawnSpec(command);
|
|
51172
51308
|
const includeModels = options.includeModels !== false;
|
|
51173
|
-
const
|
|
51174
|
-
const directory = options.cacheDirectory ?? (includeModels ? join6(homedir5(), ".cache", "alook", "antigravity-probe",
|
|
51309
|
+
const identity2 = createHash3("sha256").update(JSON.stringify([spec.command, process.env.GEMINI_HOME ?? ""])).digest("hex").slice(0, 16);
|
|
51310
|
+
const directory = options.cacheDirectory ?? (includeModels ? join6(homedir5(), ".cache", "alook", "antigravity-probe", identity2) : homedir5());
|
|
51175
51311
|
const cacheFile = join6(directory, "session");
|
|
51176
51312
|
let cachedSessionId;
|
|
51177
51313
|
if (includeModels)
|
|
@@ -52651,22 +52787,22 @@ class CodexEventNormalizer {
|
|
|
52651
52787
|
handleItemStarted(params) {
|
|
52652
52788
|
const t = params?.item?.type ?? params?.type;
|
|
52653
52789
|
const callId = this.itemCallId(params);
|
|
52654
|
-
const
|
|
52790
|
+
const identity2 = callId ? { callId } : {};
|
|
52655
52791
|
switch (t) {
|
|
52656
52792
|
case "commandExecution":
|
|
52657
|
-
return [{ kind: "tool_call", ...
|
|
52793
|
+
return [{ kind: "tool_call", ...identity2, name: "shell", input: params?.item }];
|
|
52658
52794
|
case "contextCompaction":
|
|
52659
52795
|
return [{ kind: "compaction_started" }];
|
|
52660
52796
|
case "enteredReviewMode":
|
|
52661
52797
|
return [{ kind: "review_started" }];
|
|
52662
52798
|
case "fileChange":
|
|
52663
|
-
return [{ kind: "tool_call", ...
|
|
52799
|
+
return [{ kind: "tool_call", ...identity2, name: "file_change", input: normalizeFileChangeInput(params?.item) }];
|
|
52664
52800
|
case "mcpToolCall":
|
|
52665
|
-
return [{ kind: "tool_call", ...
|
|
52801
|
+
return [{ kind: "tool_call", ...identity2, name: `mcp_${params?.item?.tool ?? params?.item?.name ?? "tool"}`, input: params?.item }];
|
|
52666
52802
|
case "webSearch":
|
|
52667
|
-
return [{ kind: "tool_call", ...
|
|
52803
|
+
return [{ kind: "tool_call", ...identity2, name: "web_search", input: params?.item }];
|
|
52668
52804
|
case "collabAgentToolCall":
|
|
52669
|
-
return [{ kind: "tool_call", ...
|
|
52805
|
+
return [{ kind: "tool_call", ...identity2, name: "collab_tool_call", input: params?.item }];
|
|
52670
52806
|
default:
|
|
52671
52807
|
return [];
|
|
52672
52808
|
}
|
|
@@ -52674,22 +52810,22 @@ class CodexEventNormalizer {
|
|
|
52674
52810
|
handleItemCompleted(params) {
|
|
52675
52811
|
const t = params?.item?.type ?? params?.type;
|
|
52676
52812
|
const callId = this.itemCallId(params);
|
|
52677
|
-
const
|
|
52813
|
+
const identity2 = callId ? { callId } : {};
|
|
52678
52814
|
switch (t) {
|
|
52679
52815
|
case "commandExecution":
|
|
52680
|
-
return [{ kind: "tool_output", ...
|
|
52816
|
+
return [{ kind: "tool_output", ...identity2, name: "shell" }];
|
|
52681
52817
|
case "contextCompaction":
|
|
52682
52818
|
return [{ kind: "compaction_finished" }];
|
|
52683
52819
|
case "exitedReviewMode":
|
|
52684
52820
|
return [{ kind: "review_finished" }];
|
|
52685
52821
|
case "fileChange":
|
|
52686
|
-
return [{ kind: "tool_output", ...
|
|
52822
|
+
return [{ kind: "tool_output", ...identity2, name: "file_change" }];
|
|
52687
52823
|
case "mcpToolCall":
|
|
52688
|
-
return [{ kind: "tool_output", ...
|
|
52824
|
+
return [{ kind: "tool_output", ...identity2, name: `mcp_${params?.item?.tool ?? params?.item?.name ?? "tool"}` }];
|
|
52689
52825
|
case "webSearch":
|
|
52690
|
-
return [{ kind: "tool_output", ...
|
|
52826
|
+
return [{ kind: "tool_output", ...identity2, name: "web_search" }];
|
|
52691
52827
|
case "collabAgentToolCall":
|
|
52692
|
-
return [{ kind: "tool_output", ...
|
|
52828
|
+
return [{ kind: "tool_output", ...identity2, name: "collab_tool_call" }];
|
|
52693
52829
|
case "agentMessage":
|
|
52694
52830
|
return [{ kind: "assistant_message_completed", text: params?.item?.text ?? "" }];
|
|
52695
52831
|
case "reasoning": {
|
|
@@ -55892,9 +56028,9 @@ class OpenCodeServiceLane {
|
|
|
55892
56028
|
if (this.stopping)
|
|
55893
56029
|
throw new OpenCodeStoppedError("OpenCode service lane stopped during startup");
|
|
55894
56030
|
}
|
|
55895
|
-
assertStartupIdentity(
|
|
56031
|
+
assertStartupIdentity(identity2) {
|
|
55896
56032
|
this.assertRunning();
|
|
55897
|
-
if (!this.isIdentity(
|
|
56033
|
+
if (!this.isIdentity(identity2)) {
|
|
55898
56034
|
throw new Error("OpenCode service identity changed during startup");
|
|
55899
56035
|
}
|
|
55900
56036
|
}
|
|
@@ -56009,14 +56145,14 @@ class OpenCodeServiceLane {
|
|
|
56009
56145
|
await this.catchUpHistory(false);
|
|
56010
56146
|
}
|
|
56011
56147
|
startStreams() {
|
|
56012
|
-
const
|
|
56013
|
-
if (!
|
|
56148
|
+
const identity2 = this.identity;
|
|
56149
|
+
if (!identity2 || !this.sessionId)
|
|
56014
56150
|
throw new Error("OpenCode service streams started before session initialization");
|
|
56015
|
-
this.durableTask = this.runDurableStream(
|
|
56016
|
-
this.liveTask = this.runLiveStream(
|
|
56151
|
+
this.durableTask = this.runDurableStream(identity2).catch((error62) => this.streamFailure("durable", error62));
|
|
56152
|
+
this.liveTask = this.runLiveStream(identity2).catch((error62) => this.streamFailure("live", error62));
|
|
56017
56153
|
}
|
|
56018
|
-
async runDurableStream(
|
|
56019
|
-
while (!this.stopping && this.isIdentity(
|
|
56154
|
+
async runDurableStream(identity2) {
|
|
56155
|
+
while (!this.stopping && this.isIdentity(identity2)) {
|
|
56020
56156
|
this.durableGap = true;
|
|
56021
56157
|
const gate = this.durableGate;
|
|
56022
56158
|
const controller = new AbortController;
|
|
@@ -56025,7 +56161,7 @@ class OpenCodeServiceLane {
|
|
|
56025
56161
|
const path10 = `/api/session/${encodeURIComponent(this.sessionId)}/event?after=${this.lastDurableSeq}`;
|
|
56026
56162
|
const response = await this.openStream(path10, controller, "durable event stream");
|
|
56027
56163
|
await this.catchUpHistory(true);
|
|
56028
|
-
if (!this.isIdentity(
|
|
56164
|
+
if (!this.isIdentity(identity2))
|
|
56029
56165
|
return;
|
|
56030
56166
|
this.durableGap = false;
|
|
56031
56167
|
gate.resolve();
|
|
@@ -56036,7 +56172,7 @@ class OpenCodeServiceLane {
|
|
|
56036
56172
|
if (!this.stopping)
|
|
56037
56173
|
this.diagnostic("warning", "OpenCode durable event stream disconnected; replaying from its cursor");
|
|
56038
56174
|
} catch (error62) {
|
|
56039
|
-
if (this.stopping || !this.isIdentity(
|
|
56175
|
+
if (this.stopping || !this.isIdentity(identity2) || controller.signal.aborted)
|
|
56040
56176
|
return;
|
|
56041
56177
|
if (error62 instanceof OpenCodeProtocolError || error62 instanceof OpenCodeHttpError && error62.status < 500) {
|
|
56042
56178
|
this.protocolFailure("OpenCode durable event stream violated the v2 protocol", error62);
|
|
@@ -56057,22 +56193,22 @@ class OpenCodeServiceLane {
|
|
|
56057
56193
|
await delay(this.options.reconnectDelayMs ?? RECONNECT_DELAY_MS);
|
|
56058
56194
|
}
|
|
56059
56195
|
}
|
|
56060
|
-
async runLiveStream(
|
|
56061
|
-
while (!this.stopping && this.isIdentity(
|
|
56196
|
+
async runLiveStream(identity2) {
|
|
56197
|
+
while (!this.stopping && this.isIdentity(identity2)) {
|
|
56062
56198
|
const gate = this.liveGate;
|
|
56063
56199
|
const controller = new AbortController;
|
|
56064
56200
|
this.liveAbort = controller;
|
|
56065
56201
|
try {
|
|
56066
56202
|
const response = await this.openStream("/api/event", controller, "live event stream");
|
|
56067
56203
|
await this.recoverPendingPermissions();
|
|
56068
|
-
if (!this.isIdentity(
|
|
56204
|
+
if (!this.isIdentity(identity2))
|
|
56069
56205
|
return;
|
|
56070
56206
|
gate.resolve();
|
|
56071
56207
|
await this.consumeSse(response, (value) => this.handleLiveEvent(value));
|
|
56072
56208
|
if (!this.stopping)
|
|
56073
56209
|
this.diagnostic("warning", "OpenCode live event stream disconnected; reconnecting");
|
|
56074
56210
|
} catch (error62) {
|
|
56075
|
-
if (this.stopping || !this.isIdentity(
|
|
56211
|
+
if (this.stopping || !this.isIdentity(identity2) || controller.signal.aborted)
|
|
56076
56212
|
return;
|
|
56077
56213
|
if (error62 instanceof OpenCodeProtocolError || error62 instanceof OpenCodeHttpError && error62.status < 500) {
|
|
56078
56214
|
this.protocolFailure("OpenCode live event stream violated the v2 protocol", error62);
|
|
@@ -56273,13 +56409,13 @@ class OpenCodeServiceLane {
|
|
|
56273
56409
|
const tokens = record5(data.tokens);
|
|
56274
56410
|
if (tokens) {
|
|
56275
56411
|
const cache = record5(tokens.cache);
|
|
56276
|
-
const
|
|
56412
|
+
const identity2 = {
|
|
56277
56413
|
runtime: "opencode",
|
|
56278
56414
|
backendSessionId,
|
|
56279
56415
|
providerRecordId: event.id
|
|
56280
56416
|
};
|
|
56281
56417
|
const usage = this.usageProjector.project({
|
|
56282
|
-
...
|
|
56418
|
+
...identity2,
|
|
56283
56419
|
source: "opencode.v2",
|
|
56284
56420
|
input: tokens.input,
|
|
56285
56421
|
output: tokens.output,
|
|
@@ -56291,7 +56427,7 @@ class OpenCodeServiceLane {
|
|
|
56291
56427
|
});
|
|
56292
56428
|
if (usage)
|
|
56293
56429
|
this.events.emit("runtime_event", usage);
|
|
56294
|
-
this.usageProjector.release(
|
|
56430
|
+
this.usageProjector.release(identity2);
|
|
56295
56431
|
}
|
|
56296
56432
|
break;
|
|
56297
56433
|
}
|
|
@@ -56456,8 +56592,8 @@ class OpenCodeServiceLane {
|
|
|
56456
56592
|
}
|
|
56457
56593
|
async evaluateTerminal() {
|
|
56458
56594
|
const root = this.activeRoot;
|
|
56459
|
-
const
|
|
56460
|
-
if (!root || !
|
|
56595
|
+
const identity2 = this.identity;
|
|
56596
|
+
if (!root || !identity2 || this.stopping || this.evaluating)
|
|
56461
56597
|
return;
|
|
56462
56598
|
if (root.pendingAdmissions > 0 || root.interruptPending || this.durableGap || root.frontier.size === 0 || root.observedAdmissions.size !== root.frontier.size)
|
|
56463
56599
|
return;
|
|
@@ -56474,14 +56610,14 @@ class OpenCodeServiceLane {
|
|
|
56474
56610
|
const active = record5(body?.data);
|
|
56475
56611
|
if (!active)
|
|
56476
56612
|
throw new OpenCodeProtocolError("OpenCode active session query returned invalid data");
|
|
56477
|
-
if (!this.barrierStillCurrent(root,
|
|
56613
|
+
if (!this.barrierStillCurrent(root, identity2, generation))
|
|
56478
56614
|
return;
|
|
56479
56615
|
if (active[this.sessionId] !== undefined) {
|
|
56480
56616
|
this.scheduleEvaluation(this.options.activePollMs ?? ACTIVE_POLL_MS);
|
|
56481
56617
|
return;
|
|
56482
56618
|
}
|
|
56483
56619
|
await this.catchUpHistory(true);
|
|
56484
|
-
if (!this.barrierStillCurrent(root,
|
|
56620
|
+
if (!this.barrierStillCurrent(root, identity2, generation) || this.durableGap)
|
|
56485
56621
|
return;
|
|
56486
56622
|
if (root.observedAdmissions.size !== root.frontier.size || this.lastDurableSeq < maxAdmission)
|
|
56487
56623
|
return;
|
|
@@ -56500,7 +56636,7 @@ class OpenCodeServiceLane {
|
|
|
56500
56636
|
this.protocolFailure("OpenCode active barrier violated the v2 protocol", error62);
|
|
56501
56637
|
return;
|
|
56502
56638
|
}
|
|
56503
|
-
if (!this.stopping && this.activeRoot === root && this.isIdentity(
|
|
56639
|
+
if (!this.stopping && this.activeRoot === root && this.isIdentity(identity2)) {
|
|
56504
56640
|
this.diagnostic("warning", "OpenCode active barrier query failed; retrying without settling the turn");
|
|
56505
56641
|
this.scheduleEvaluation(this.options.activePollMs ?? ACTIVE_POLL_MS);
|
|
56506
56642
|
}
|
|
@@ -56514,8 +56650,8 @@ class OpenCodeServiceLane {
|
|
|
56514
56650
|
}
|
|
56515
56651
|
}
|
|
56516
56652
|
}
|
|
56517
|
-
barrierStillCurrent(root,
|
|
56518
|
-
return this.activeRoot === root && root.generation === generation && root.pendingAdmissions === 0 && !root.interruptPending && this.isIdentity(
|
|
56653
|
+
barrierStillCurrent(root, identity2, generation) {
|
|
56654
|
+
return this.activeRoot === root && root.generation === generation && root.pendingAdmissions === 0 && !root.interruptPending && this.isIdentity(identity2) && this.identityMatches();
|
|
56519
56655
|
}
|
|
56520
56656
|
settleRoot(root, success2, message2, code = "opencode.turn_failed") {
|
|
56521
56657
|
if (this.activeRoot !== root)
|
|
@@ -56625,15 +56761,15 @@ class OpenCodeServiceLane {
|
|
|
56625
56761
|
this.events.emit("error", new Error(message2));
|
|
56626
56762
|
}
|
|
56627
56763
|
identityMatches() {
|
|
56628
|
-
const
|
|
56629
|
-
const matches = !!
|
|
56630
|
-
if (!matches &&
|
|
56764
|
+
const identity2 = this.identity;
|
|
56765
|
+
const matches = !!identity2 && identity2.process === this.process && identity2.process.pid === identity2.pid && !this.isProcessClosed(identity2.process);
|
|
56766
|
+
if (!matches && identity2 && identity2.process === this.process && identity2.process.pid !== identity2.pid && this.ready && !this.stopping) {
|
|
56631
56767
|
this.failPidIdentity();
|
|
56632
56768
|
}
|
|
56633
56769
|
return matches;
|
|
56634
56770
|
}
|
|
56635
|
-
isIdentity(
|
|
56636
|
-
return this.identity ===
|
|
56771
|
+
isIdentity(identity2) {
|
|
56772
|
+
return this.identity === identity2 && this.identityMatches();
|
|
56637
56773
|
}
|
|
56638
56774
|
isProcessClosed(proc) {
|
|
56639
56775
|
return proc.exitCode !== null || proc.signalCode !== null;
|
|
@@ -56878,8 +57014,8 @@ class OpenCodeV2ServiceLane extends OpenCodeServiceLane {
|
|
|
56878
57014
|
}
|
|
56879
57015
|
async primeHistory() {}
|
|
56880
57016
|
startStreams() {
|
|
56881
|
-
const
|
|
56882
|
-
this.liveTask = this.runLiveStream(
|
|
57017
|
+
const identity2 = this.identity;
|
|
57018
|
+
this.liveTask = this.runLiveStream(identity2).catch((error62) => {
|
|
56883
57019
|
if (!this.stopping)
|
|
56884
57020
|
this.protocolFailure("OpenCode CLI v2 live stream failed", error62);
|
|
56885
57021
|
});
|
|
@@ -56947,13 +57083,13 @@ class OpenCodeV2ServiceLane extends OpenCodeServiceLane {
|
|
|
56947
57083
|
return this.admit(input2.text, "steer", this.newMessageId(), root);
|
|
56948
57084
|
}
|
|
56949
57085
|
async beginRoot(input2) {
|
|
56950
|
-
const
|
|
57086
|
+
const page2 = await this.messagePage(undefined, 1);
|
|
56951
57087
|
if (this.stopping || !this.identityMatches())
|
|
56952
57088
|
return { ok: false, reason: "closed" };
|
|
56953
57089
|
const receipt = input2.terminalOwner?.startsWith("msg_") ? input2.terminalOwner : this.newMessageId();
|
|
56954
57090
|
const root = {
|
|
56955
57091
|
receipt,
|
|
56956
|
-
baseline: typeof
|
|
57092
|
+
baseline: typeof page2.data[0]?.id === "string" ? page2.data[0].id : null,
|
|
56957
57093
|
inputs: new Set,
|
|
56958
57094
|
generation: 0,
|
|
56959
57095
|
pending: 0
|
|
@@ -56995,37 +57131,37 @@ class OpenCodeV2ServiceLane extends OpenCodeServiceLane {
|
|
|
56995
57131
|
const { response, body } = await this.fetchJsonWithTimeout(`/api/session/${encodeURIComponent(this.sessionId)}/message?${query}`, { method: "GET" }, "message recovery");
|
|
56996
57132
|
if (!response.ok)
|
|
56997
57133
|
throw new OpenCodeHttpError(response.status, "message recovery");
|
|
56998
|
-
const
|
|
56999
|
-
const cursors = record5(
|
|
57000
|
-
if (!Array.isArray(
|
|
57134
|
+
const page2 = record5(body);
|
|
57135
|
+
const cursors = record5(page2?.cursor);
|
|
57136
|
+
if (!Array.isArray(page2?.data) || !cursors || page2.data.some((item) => typeof record5(item)?.id !== "string")) {
|
|
57001
57137
|
throw new OpenCodeProtocolError("OpenCode CLI v2 returned an invalid message page");
|
|
57002
57138
|
}
|
|
57003
57139
|
if (cursors.next !== undefined && cursors.next !== null && typeof cursors.next !== "string")
|
|
57004
57140
|
throw new OpenCodeProtocolError("OpenCode CLI v2 returned an invalid message cursor");
|
|
57005
|
-
return { data:
|
|
57141
|
+
return { data: page2.data, next: typeof cursors.next === "string" ? cursors.next : undefined };
|
|
57006
57142
|
}
|
|
57007
57143
|
async messagesAfter(root) {
|
|
57008
57144
|
const messages = [];
|
|
57009
57145
|
const cursors = new Set;
|
|
57010
57146
|
let cursor;
|
|
57011
57147
|
for (;; ) {
|
|
57012
|
-
const
|
|
57148
|
+
const page2 = await this.messagePage(cursor);
|
|
57013
57149
|
if (this.root !== root || this.stopping)
|
|
57014
57150
|
return [];
|
|
57015
|
-
for (const message2 of
|
|
57151
|
+
for (const message2 of page2.data) {
|
|
57016
57152
|
if (message2.id === root.baseline)
|
|
57017
57153
|
return messages.reverse();
|
|
57018
57154
|
messages.push(message2);
|
|
57019
57155
|
}
|
|
57020
|
-
if (!
|
|
57156
|
+
if (!page2.next) {
|
|
57021
57157
|
if (root.baseline !== null)
|
|
57022
57158
|
throw new OpenCodeProtocolError("OpenCode CLI v2 message recovery lost its root boundary");
|
|
57023
57159
|
return messages.reverse();
|
|
57024
57160
|
}
|
|
57025
|
-
if (cursors.has(
|
|
57161
|
+
if (cursors.has(page2.next))
|
|
57026
57162
|
throw new OpenCodeProtocolError("OpenCode CLI v2 message cursor did not advance");
|
|
57027
|
-
cursors.add(
|
|
57028
|
-
cursor =
|
|
57163
|
+
cursors.add(page2.next);
|
|
57164
|
+
cursor = page2.next;
|
|
57029
57165
|
}
|
|
57030
57166
|
}
|
|
57031
57167
|
schedule() {
|
|
@@ -57048,12 +57184,12 @@ class OpenCodeV2ServiceLane extends OpenCodeServiceLane {
|
|
|
57048
57184
|
}
|
|
57049
57185
|
async evaluate() {
|
|
57050
57186
|
const root = this.root;
|
|
57051
|
-
const
|
|
57052
|
-
if (!root || !
|
|
57187
|
+
const identity2 = this.identity;
|
|
57188
|
+
if (!root || !identity2 || this.stopping || root.pending > 0 || root.inputs.size === 0 || this.v2Evaluating)
|
|
57053
57189
|
return;
|
|
57054
57190
|
this.v2Evaluating = true;
|
|
57055
57191
|
const generation = root.generation;
|
|
57056
|
-
const current = () => this.root === root && root.generation === generation && root.pending === 0 && this.isIdentity(
|
|
57192
|
+
const current = () => this.root === root && root.generation === generation && root.pending === 0 && this.isIdentity(identity2);
|
|
57057
57193
|
try {
|
|
57058
57194
|
if (await this.isActive())
|
|
57059
57195
|
return;
|
|
@@ -57191,9 +57327,9 @@ class OpenCodeV2ServiceLane extends OpenCodeServiceLane {
|
|
|
57191
57327
|
if (!tokens || !this.sessionId)
|
|
57192
57328
|
return;
|
|
57193
57329
|
const cache = record5(tokens.cache);
|
|
57194
|
-
const
|
|
57330
|
+
const identity2 = { runtime: "opencode", backendSessionId: this.sessionId, providerRecordId: message2.id };
|
|
57195
57331
|
const usage = this.usage.project({
|
|
57196
|
-
...
|
|
57332
|
+
...identity2,
|
|
57197
57333
|
source: "opencode.v2",
|
|
57198
57334
|
input: tokens.input,
|
|
57199
57335
|
output: tokens.output,
|
|
@@ -57205,7 +57341,7 @@ class OpenCodeV2ServiceLane extends OpenCodeServiceLane {
|
|
|
57205
57341
|
});
|
|
57206
57342
|
if (usage)
|
|
57207
57343
|
this.events.emit("runtime_event", usage);
|
|
57208
|
-
this.usage.release(
|
|
57344
|
+
this.usage.release(identity2);
|
|
57209
57345
|
}
|
|
57210
57346
|
async interrupt(_input) {
|
|
57211
57347
|
const root = this.root;
|
|
@@ -57693,9 +57829,9 @@ function mapPiSdkEvent(event, sessionId, state) {
|
|
|
57693
57829
|
state.usageRecordSequence = (state.usageRecordSequence ?? 0) + 1;
|
|
57694
57830
|
const providerRecordId = typeof message2.responseId === "string" && message2.responseId ? message2.responseId : `live:${message2.timestamp ?? "unknown"}:${state.usageRecordSequence}`;
|
|
57695
57831
|
const { projector, pending } = piUsageState(state);
|
|
57696
|
-
const
|
|
57832
|
+
const identity2 = { runtime: "pi", backendSessionId: sessionId, providerRecordId };
|
|
57697
57833
|
const usage = projector.project({
|
|
57698
|
-
...
|
|
57834
|
+
...identity2,
|
|
57699
57835
|
source: "pi_message_end",
|
|
57700
57836
|
input: message2.usage.input,
|
|
57701
57837
|
output: message2.usage.output,
|
|
@@ -59920,6 +60056,11 @@ function readDaemonVersion() {
|
|
|
59920
60056
|
return "";
|
|
59921
60057
|
}
|
|
59922
60058
|
|
|
60059
|
+
// src/npmEnvironment.ts
|
|
60060
|
+
function withoutNpmExecPackage(env) {
|
|
60061
|
+
return Object.fromEntries(Object.entries(env).filter(([key]) => key.toLowerCase() !== "npm_config_package"));
|
|
60062
|
+
}
|
|
60063
|
+
|
|
59923
60064
|
// src/cli/daemonRunner.ts
|
|
59924
60065
|
import * as fs11 from "node:fs";
|
|
59925
60066
|
import * as path17 from "node:path";
|
|
@@ -63201,14 +63342,14 @@ function reduceManager(state, event) {
|
|
|
63201
63342
|
if (!matchesSession(a, event.sessionInstanceId))
|
|
63202
63343
|
return;
|
|
63203
63344
|
const lease = a.execution.lease;
|
|
63204
|
-
const
|
|
63205
|
-
if ((lease.state === "active" || lease.state === "suspect_active") && !sameIdentity(lease.identity,
|
|
63345
|
+
const identity2 = identityOf(event);
|
|
63346
|
+
if ((lease.state === "active" || lease.state === "suspect_active") && !sameIdentity(lease.identity, identity2))
|
|
63206
63347
|
return;
|
|
63207
63348
|
const startedCommands = new Set(event.commandIds);
|
|
63208
63349
|
a.pendingAdmissions = a.pendingAdmissions.filter((entry) => !startedCommands.has(entry.commandId));
|
|
63209
63350
|
a.execution.lease = {
|
|
63210
63351
|
state: "active",
|
|
63211
|
-
identity,
|
|
63352
|
+
identity: identity2,
|
|
63212
63353
|
lastWorkAt: event.nowMs,
|
|
63213
63354
|
nativeDeadlineAt: event.nowMs + a.turnSilence.normalBudgetMs,
|
|
63214
63355
|
recoveryExtensionsUsed: 0
|
|
@@ -63236,8 +63377,8 @@ function reduceManager(state, event) {
|
|
|
63236
63377
|
if (!matchesSession(a, event.sessionInstanceId))
|
|
63237
63378
|
return;
|
|
63238
63379
|
const lease = a.execution.lease;
|
|
63239
|
-
const
|
|
63240
|
-
if ((lease.state === "active" || lease.state === "suspect_active") && sameIdentity(lease.identity,
|
|
63380
|
+
const identity2 = identityOf(event);
|
|
63381
|
+
if ((lease.state === "active" || lease.state === "suspect_active") && sameIdentity(lease.identity, identity2)) {
|
|
63241
63382
|
a.execution.lease = {
|
|
63242
63383
|
...lease,
|
|
63243
63384
|
lastWorkAt: event.nowMs,
|
|
@@ -63246,11 +63387,11 @@ function reduceManager(state, event) {
|
|
|
63246
63387
|
};
|
|
63247
63388
|
} else {
|
|
63248
63389
|
const terminal = lease.state === "none" ? lease.lastTerminal : null;
|
|
63249
|
-
if (!terminal || !sameIdentity(terminal.identity,
|
|
63390
|
+
if (!terminal || !sameIdentity(terminal.identity, identity2))
|
|
63250
63391
|
return;
|
|
63251
63392
|
a.execution.lease = {
|
|
63252
63393
|
state: "suspect_active",
|
|
63253
|
-
identity,
|
|
63394
|
+
identity: identity2,
|
|
63254
63395
|
lastWorkAt: event.nowMs,
|
|
63255
63396
|
nativeDeadlineAt: event.nowMs + a.turnSilence.normalBudgetMs,
|
|
63256
63397
|
recoveryExtensionsUsed: 0,
|
|
@@ -63289,13 +63430,13 @@ function reduceManager(state, event) {
|
|
|
63289
63430
|
if (!existing || existing.execution.sessionInstanceId !== event.sessionInstanceId)
|
|
63290
63431
|
return { state, effects: [] };
|
|
63291
63432
|
const lease = existing.execution.lease;
|
|
63292
|
-
const
|
|
63293
|
-
if (lease.state !== "active" && lease.state !== "suspect_active" || !sameIdentity(lease.identity,
|
|
63433
|
+
const identity2 = { sessionInstanceId: event.sessionInstanceId, turnId: event.turnId };
|
|
63434
|
+
if (lease.state !== "active" && lease.state !== "suspect_active" || !sameIdentity(lease.identity, identity2)) {
|
|
63294
63435
|
return { state, effects: [] };
|
|
63295
63436
|
}
|
|
63296
63437
|
return mutate(state, event.agentId, (a) => {
|
|
63297
63438
|
const active = a.execution.lease;
|
|
63298
|
-
if (active.state !== "active" && active.state !== "suspect_active" || !sameIdentity(active.identity,
|
|
63439
|
+
if (active.state !== "active" && active.state !== "suspect_active" || !sameIdentity(active.identity, identity2))
|
|
63299
63440
|
return;
|
|
63300
63441
|
if (event.kind === "recovery" && event.recoveryStage !== "recovered") {
|
|
63301
63442
|
if (active.recoveryExtensionsUsed < a.turnSilence.maxRecoveryExtensions) {
|
|
@@ -63382,10 +63523,10 @@ function onTurnCompleted(state, agentId, sessionInstanceId, nowMs, turnId, endRe
|
|
|
63382
63523
|
const lease = agent2.execution.lease;
|
|
63383
63524
|
if (lease.state !== "active" && lease.state !== "suspect_active")
|
|
63384
63525
|
return { state, effects: [] };
|
|
63385
|
-
const
|
|
63386
|
-
if (!sameIdentity(lease.identity,
|
|
63526
|
+
const identity2 = { sessionInstanceId, turnId };
|
|
63527
|
+
if (!sameIdentity(lease.identity, identity2))
|
|
63387
63528
|
return { state, effects: [] };
|
|
63388
|
-
const lastTerminal = { identity, at: nowMs };
|
|
63529
|
+
const lastTerminal = { identity: identity2, at: nowMs };
|
|
63389
63530
|
agent2.execution.lease = { state: "none", lastTerminal };
|
|
63390
63531
|
agent2.lastProgressAt = nowMs;
|
|
63391
63532
|
agent2.lastNativeActivityAt = nowMs;
|
|
@@ -63411,9 +63552,9 @@ function onTurnToolLifecycle(state, event, lifecycle) {
|
|
|
63411
63552
|
if (!existing || existing.resetting || existing.execution.sessionInstanceId !== event.sessionInstanceId)
|
|
63412
63553
|
return { state, effects: [] };
|
|
63413
63554
|
const current = existing.execution.lease;
|
|
63414
|
-
const
|
|
63415
|
-
const matchesActive = (current.state === "active" || current.state === "suspect_active") && sameIdentity(current.identity,
|
|
63416
|
-
const matchesTerminal = lifecycle === "started" && current.state === "none" && current.lastTerminal !== null && sameIdentity(current.lastTerminal.identity,
|
|
63555
|
+
const identity2 = identityOf(event);
|
|
63556
|
+
const matchesActive = (current.state === "active" || current.state === "suspect_active") && sameIdentity(current.identity, identity2);
|
|
63557
|
+
const matchesTerminal = lifecycle === "started" && current.state === "none" && current.lastTerminal !== null && sameIdentity(current.lastTerminal.identity, identity2);
|
|
63417
63558
|
if (!matchesActive && !matchesTerminal)
|
|
63418
63559
|
return { state, effects: [] };
|
|
63419
63560
|
return mutate(state, event.agentId, (agent2) => {
|
|
@@ -63421,7 +63562,7 @@ function onTurnToolLifecycle(state, event, lifecycle) {
|
|
|
63421
63562
|
return;
|
|
63422
63563
|
const lease = agent2.execution.lease;
|
|
63423
63564
|
const callId = normalizedToolCallId(event.callId);
|
|
63424
|
-
if ((lease.state === "active" || lease.state === "suspect_active") && sameIdentity(lease.identity,
|
|
63565
|
+
if ((lease.state === "active" || lease.state === "suspect_active") && sameIdentity(lease.identity, identity2)) {
|
|
63425
63566
|
const identified = new Set(lease.outstandingToolCallIds ?? []);
|
|
63426
63567
|
const currentCount = lease.outstandingToolUses ?? 0;
|
|
63427
63568
|
const anonymousCount = Math.max(0, currentCount - identified.size);
|
|
@@ -63459,11 +63600,11 @@ function onTurnToolLifecycle(state, event, lifecycle) {
|
|
|
63459
63600
|
}
|
|
63460
63601
|
} else {
|
|
63461
63602
|
const terminal = lease.state === "none" ? lease.lastTerminal : null;
|
|
63462
|
-
if (lifecycle !== "started" || !terminal || !sameIdentity(terminal.identity,
|
|
63603
|
+
if (lifecycle !== "started" || !terminal || !sameIdentity(terminal.identity, identity2))
|
|
63463
63604
|
return;
|
|
63464
63605
|
agent2.execution.lease = {
|
|
63465
63606
|
state: "suspect_active",
|
|
63466
|
-
identity,
|
|
63607
|
+
identity: identity2,
|
|
63467
63608
|
lastWorkAt: event.nowMs,
|
|
63468
63609
|
nativeDeadlineAt: event.nowMs + agent2.turnSilence.normalBudgetMs,
|
|
63469
63610
|
recoveryExtensionsUsed: 0,
|
|
@@ -63800,9 +63941,9 @@ async function readAntigravityQuota(options = {}) {
|
|
|
63800
63941
|
if (!(failure3 instanceof SyntaxError) && asRecord(failure3)?.code !== "ENOENT")
|
|
63801
63942
|
storageUnavailable = true;
|
|
63802
63943
|
}
|
|
63803
|
-
const
|
|
63804
|
-
if (activeSource.identity !==
|
|
63805
|
-
activeSource = { identity, epoch: randomBytes6(16).toString("base64url") };
|
|
63944
|
+
const identity2 = createHash5("sha256").update(JSON.stringify([root, authType, credentials?.client_id, credentials?.refresh_token, credentials?.project_id])).digest("hex");
|
|
63945
|
+
if (activeSource.identity !== identity2)
|
|
63946
|
+
activeSource = { identity: identity2, epoch: randomBytes6(16).toString("base64url") };
|
|
63806
63947
|
const source = activeSource;
|
|
63807
63948
|
const error62 = (code, retryable = false) => ({ status: "error", sourceEpoch: activeSource.epoch, code: source === activeSource ? code : "unavailable", retryable: source === activeSource ? retryable : true });
|
|
63808
63949
|
const clientId = text2(credentials?.client_id);
|
|
@@ -64040,7 +64181,7 @@ var MESSAGE_SEND_STDIN_POLICY = [
|
|
|
64040
64181
|
" - a short list or table for several exact items, mappings, or comparisons;",
|
|
64041
64182
|
" - pseudocode for logic, a shallow tree for hierarchy or ownership, Mermaid for sequence or " + "flow, and `diff` for what changed.",
|
|
64042
64183
|
"- 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.",
|
|
64043
|
-
"- 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."
|
|
64184
|
+
"- 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."
|
|
64044
64185
|
].join(`
|
|
64045
64186
|
`);
|
|
64046
64187
|
function identitySection(config2) {
|
|
@@ -64167,6 +64308,7 @@ function messagingSection() {
|
|
|
64167
64308
|
"",
|
|
64168
64309
|
`- Send body: use \`${CLI} message send --target <ref> --remind-after T --stdin\` with the ` + "quoted-heredoc form under *Message formatting*.",
|
|
64169
64310
|
`- Long detail: upload it with \`${CLI} message attachment upload --file <path>.md\`; ` + "add the returned id as `--attachment <id>` on the short stdin send.",
|
|
64311
|
+
`- 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.",
|
|
64170
64312
|
"- 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.",
|
|
64171
64313
|
`- Cite a specific message: add \`--reply "#37"\` — \`--reply\` takes the \`#N\` seq ` + "(within `--target`) of the message you're answering.",
|
|
64172
64314
|
"",
|
|
@@ -66483,23 +66625,23 @@ class AgentRouter {
|
|
|
66483
66625
|
const reply = this.opts.channel.reportRuntimeModels;
|
|
66484
66626
|
if (!reply)
|
|
66485
66627
|
return;
|
|
66486
|
-
const
|
|
66628
|
+
const identity2 = { type: "runtime_models", requestId: cmd.requestId, runtimeId: cmd.runtimeId };
|
|
66487
66629
|
try {
|
|
66488
66630
|
const current = this.runtimes.get(cmd.runtimeId);
|
|
66489
66631
|
if (!current)
|
|
66490
66632
|
throw new UnknownRuntimeError(cmd.runtimeId, [...this.runtimes.keys()]);
|
|
66491
66633
|
const probe = await this.discoverRuntimeModels(cmd.runtimeId);
|
|
66492
66634
|
if (!probe) {
|
|
66493
|
-
reply.call(this.opts.channel, { ...
|
|
66635
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: "model_discovery_timeout", message: "Model discovery timed out; retry the request" } });
|
|
66494
66636
|
return;
|
|
66495
66637
|
}
|
|
66496
66638
|
if (probe.status !== "healthy") {
|
|
66497
|
-
reply.call(this.opts.channel, { ...
|
|
66639
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: probe.error.code, message: probe.error.message } });
|
|
66498
66640
|
return;
|
|
66499
66641
|
}
|
|
66500
|
-
reply.call(this.opts.channel, { ...
|
|
66642
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "complete", runtimeReport: [...this.runtimes.values()] } });
|
|
66501
66643
|
} catch {
|
|
66502
|
-
reply.call(this.opts.channel, { ...
|
|
66644
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: "model_discovery_failed", message: "Could not discover models for this runtime" } });
|
|
66503
66645
|
}
|
|
66504
66646
|
return;
|
|
66505
66647
|
}
|
|
@@ -68226,7 +68368,7 @@ function createDaemonAgentDriverHost(ctx, onRawLine) {
|
|
|
68226
68368
|
const resource = {
|
|
68227
68369
|
executablePath: ctx.agentCliPath,
|
|
68228
68370
|
environmentLayers: {
|
|
68229
|
-
base:
|
|
68371
|
+
base: withoutNpmExecPackage(process.env),
|
|
68230
68372
|
hostStatic: {},
|
|
68231
68373
|
identityProtected: buildGitIdentityEnv({
|
|
68232
68374
|
agentName: ctx.config.agentName,
|
|
@@ -68409,13 +68551,13 @@ class DailyTokenUsageStore {
|
|
|
68409
68551
|
dayKeyInTimeZone(0, timeZone);
|
|
68410
68552
|
return timeZone;
|
|
68411
68553
|
}
|
|
68412
|
-
record(botId, delta,
|
|
68554
|
+
record(botId, delta, identity2) {
|
|
68413
68555
|
return this.enqueue(async () => {
|
|
68414
|
-
if (
|
|
68415
|
-
if (!
|
|
68556
|
+
if (identity2) {
|
|
68557
|
+
if (!identity2.source || identity2.source.length > 256 || !Number.isSafeInteger(identity2.index) || identity2.index < 0 || !Number.isFinite(Date.parse(identity2.occurredAt)))
|
|
68416
68558
|
throw new Error("Invalid token usage identity");
|
|
68417
|
-
if (!this.pending.some((sample) => sample.botId === botId && sample.identity.source ===
|
|
68418
|
-
this.pending.push({ botId, delta, identity });
|
|
68559
|
+
if (!this.pending.some((sample) => sample.botId === botId && sample.identity.source === identity2.source && sample.identity.index === identity2.index))
|
|
68560
|
+
this.pending.push({ botId, delta, identity: identity2 });
|
|
68419
68561
|
await this.load();
|
|
68420
68562
|
await this.flushPending();
|
|
68421
68563
|
} else {
|
|
@@ -68448,13 +68590,13 @@ class DailyTokenUsageStore {
|
|
|
68448
68590
|
throw error62;
|
|
68449
68591
|
}
|
|
68450
68592
|
}
|
|
68451
|
-
apply(botId, delta,
|
|
68593
|
+
apply(botId, delta, identity2) {
|
|
68452
68594
|
const at = this.now();
|
|
68453
68595
|
const timeZone = this.timeZone;
|
|
68454
|
-
const day = dayKeyInTimeZone(
|
|
68455
|
-
if (
|
|
68596
|
+
const day = dayKeyInTimeZone(identity2 ? new Date(identity2.occurredAt) : at, timeZone);
|
|
68597
|
+
if (identity2 && day < oldestRetainedDay(at, timeZone))
|
|
68456
68598
|
return;
|
|
68457
|
-
if (
|
|
68599
|
+
if (identity2 && this.data.sources?.[botId]?.[identity2.source]?.ranges.some(([start, end]) => identity2.index >= start && identity2.index <= end))
|
|
68458
68600
|
return;
|
|
68459
68601
|
this.prune(at, timeZone);
|
|
68460
68602
|
const snapshots = this.data.bots[botId] ?? [];
|
|
@@ -68469,11 +68611,11 @@ class DailyTokenUsageStore {
|
|
|
68469
68611
|
snapshots.push(next);
|
|
68470
68612
|
snapshots.sort((a, b) => a.day.localeCompare(b.day));
|
|
68471
68613
|
this.data.bots[botId] = snapshots;
|
|
68472
|
-
if (
|
|
68614
|
+
if (identity2) {
|
|
68473
68615
|
this.data.sources ??= {};
|
|
68474
68616
|
this.data.sources[botId] ??= {};
|
|
68475
|
-
const saved = this.data.sources[botId][
|
|
68476
|
-
const ranges = [...saved?.ranges ?? [], [
|
|
68617
|
+
const saved = this.data.sources[botId][identity2.source];
|
|
68618
|
+
const ranges = [...saved?.ranges ?? [], [identity2.index, identity2.index]].sort((a, b) => a[0] - b[0]);
|
|
68477
68619
|
const merged = [];
|
|
68478
68620
|
for (const range of ranges) {
|
|
68479
68621
|
const last = merged.at(-1);
|
|
@@ -68482,7 +68624,7 @@ class DailyTokenUsageStore {
|
|
|
68482
68624
|
else
|
|
68483
68625
|
merged.push([range[0], range[1]]);
|
|
68484
68626
|
}
|
|
68485
|
-
this.data.sources[botId][
|
|
68627
|
+
this.data.sources[botId][identity2.source] = { ranges: merged, day: saved && saved.day > day ? saved.day : day };
|
|
68486
68628
|
}
|
|
68487
68629
|
}
|
|
68488
68630
|
snapshots(botId) {
|
|
@@ -69277,10 +69419,10 @@ async function createDaemon(opts) {
|
|
|
69277
69419
|
tokenUsageAvailability.set(agentId, { backendId, status });
|
|
69278
69420
|
reportTelemetryForIdleAgent(agentId);
|
|
69279
69421
|
},
|
|
69280
|
-
onTokenUsage: ({ agentId, usage, identity }) => {
|
|
69422
|
+
onTokenUsage: ({ agentId, usage, identity: identity2 }) => {
|
|
69281
69423
|
if (usageSealed)
|
|
69282
69424
|
return;
|
|
69283
|
-
trackTelemetry(dailyTokenUsage2.record(agentId, usage,
|
|
69425
|
+
trackTelemetry(dailyTokenUsage2.record(agentId, usage, identity2).then(() => reportTelemetryForIdleAgent(agentId)).catch(() => {
|
|
69284
69426
|
log2.warn("daily token usage persistence failed", { agentId });
|
|
69285
69427
|
}));
|
|
69286
69428
|
},
|
|
@@ -70193,7 +70335,7 @@ async function buildDiagnosticBundle(args) {
|
|
|
70193
70335
|
let truncated = false;
|
|
70194
70336
|
const counts = { status: args.status ? 1 : 0, daemon_log: 0, fsm: 0 };
|
|
70195
70337
|
const statusTime = typeof args.status?.timeMs === "number" ? args.status.timeMs : null;
|
|
70196
|
-
const
|
|
70338
|
+
const envelope3 = () => {
|
|
70197
70339
|
const firstEvent = retained[head]?.row.timeMs ?? null;
|
|
70198
70340
|
const lastEvent = retained.at(-1)?.row.timeMs ?? null;
|
|
70199
70341
|
const earliestAt = statusTime === null ? firstEvent : firstEvent === null ? statusTime : Math.min(statusTime, firstEvent);
|
|
@@ -70224,7 +70366,7 @@ async function buildDiagnosticBundle(args) {
|
|
|
70224
70366
|
retained.push({ row, bytes: serialized });
|
|
70225
70367
|
retainedBytes += serialized.byteLength;
|
|
70226
70368
|
counts[row.recordType] += 1;
|
|
70227
|
-
while (
|
|
70369
|
+
while (envelope3().total > maxUncompressed && head < retained.length) {
|
|
70228
70370
|
const removed = retained[head];
|
|
70229
70371
|
delete retained[head];
|
|
70230
70372
|
head += 1;
|
|
@@ -70238,7 +70380,7 @@ async function buildDiagnosticBundle(args) {
|
|
|
70238
70380
|
head = 0;
|
|
70239
70381
|
}
|
|
70240
70382
|
}
|
|
70241
|
-
const { footer, total } =
|
|
70383
|
+
const { footer, total } = envelope3();
|
|
70242
70384
|
if (total > maxUncompressed)
|
|
70243
70385
|
throw new BundleTooLargeError;
|
|
70244
70386
|
const hash2 = createHash7("sha256");
|
|
@@ -72268,6 +72410,7 @@ function runnerArguments() {
|
|
|
72268
72410
|
}
|
|
72269
72411
|
function spawnBlockedRunner() {
|
|
72270
72412
|
return spawn3(process.execPath, runnerArguments(), {
|
|
72413
|
+
env: withoutNpmExecPackage(process.env),
|
|
72271
72414
|
detached: true,
|
|
72272
72415
|
stdio: ["ignore", "ignore", "ignore", "ipc"]
|
|
72273
72416
|
});
|