@alook/daemon 0.1.57 → 0.1.59
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 +1048 -823
- package/dist/index.js +948 -827
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1490,6 +1490,7 @@ function nativeId(value) {
|
|
|
1490
1490
|
class AgyDriver {
|
|
1491
1491
|
launchSpec;
|
|
1492
1492
|
id = "agy";
|
|
1493
|
+
modelCatalogOrigin = "native_report";
|
|
1493
1494
|
instructionDelivery = { kind: "native" };
|
|
1494
1495
|
execution = {
|
|
1495
1496
|
lifetime: "session",
|
|
@@ -2827,6 +2828,7 @@ async function probeAntigravity(command, options = {}) {
|
|
|
2827
2828
|
// agent-driver/dist/adapters/antigravity/index.js
|
|
2828
2829
|
class AntigravityDriver {
|
|
2829
2830
|
id = "antigravity";
|
|
2831
|
+
modelCatalogOrigin = "native_report";
|
|
2830
2832
|
instructionDelivery = { kind: "native" };
|
|
2831
2833
|
execution = {
|
|
2832
2834
|
lifetime: "session",
|
|
@@ -3542,6 +3544,7 @@ var CLAUDE_MODEL_CATALOG = {
|
|
|
3542
3544
|
|
|
3543
3545
|
class ClaudeDriver {
|
|
3544
3546
|
id = "claude";
|
|
3547
|
+
modelCatalogOrigin = "adapter_suggestions";
|
|
3545
3548
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
3546
3549
|
execution = {
|
|
3547
3550
|
lifetime: "session",
|
|
@@ -4315,6 +4318,7 @@ function isCodexMissingRolloutError(message) {
|
|
|
4315
4318
|
|
|
4316
4319
|
class CodexDriver {
|
|
4317
4320
|
id = "codex";
|
|
4321
|
+
modelCatalogOrigin = "native_report";
|
|
4318
4322
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
4319
4323
|
execution = {
|
|
4320
4324
|
lifetime: "session",
|
|
@@ -5719,6 +5723,7 @@ async function discoverCursorRecentContext(request, dependencies = {}) {
|
|
|
5719
5723
|
class CursorDriver {
|
|
5720
5724
|
catalogProbe;
|
|
5721
5725
|
id = "cursor";
|
|
5726
|
+
modelCatalogOrigin = "native_report";
|
|
5722
5727
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
5723
5728
|
execution = {
|
|
5724
5729
|
lifetime: "session",
|
|
@@ -6935,6 +6940,7 @@ class GrokDriver {
|
|
|
6935
6940
|
catalogProbe;
|
|
6936
6941
|
spawnProcess;
|
|
6937
6942
|
id = "grok";
|
|
6943
|
+
modelCatalogOrigin = "native_report";
|
|
6938
6944
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
6939
6945
|
execution = {
|
|
6940
6946
|
lifetime: "session",
|
|
@@ -8734,6 +8740,7 @@ class OpenCodeDriver {
|
|
|
8734
8740
|
outputProbe;
|
|
8735
8741
|
versionProbe;
|
|
8736
8742
|
id = "opencode";
|
|
8743
|
+
modelCatalogOrigin = "native_report";
|
|
8737
8744
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
8738
8745
|
execution = {
|
|
8739
8746
|
lifetime: "session",
|
|
@@ -9228,6 +9235,7 @@ class PiDriver {
|
|
|
9228
9235
|
loadSdk;
|
|
9229
9236
|
readVersion;
|
|
9230
9237
|
id = "pi";
|
|
9238
|
+
modelCatalogOrigin = "native_report";
|
|
9231
9239
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
9232
9240
|
execution = {
|
|
9233
9241
|
lifetime: "session",
|
|
@@ -11124,7 +11132,7 @@ function createAgentDriverSdkWithRegistry(options) {
|
|
|
11124
11132
|
status: "healthy",
|
|
11125
11133
|
version: result.version,
|
|
11126
11134
|
capabilities: capabilities2,
|
|
11127
|
-
reasoning: result.reasoning
|
|
11135
|
+
reasoning: result.reasoning && adapter.modelCatalogOrigin ? { ...result.reasoning, catalogOrigin: adapter.modelCatalogOrigin } : result.reasoning
|
|
11128
11136
|
};
|
|
11129
11137
|
}
|
|
11130
11138
|
return {
|
|
@@ -11136,7 +11144,7 @@ function createAgentDriverSdkWithRegistry(options) {
|
|
|
11136
11144
|
retryable: true
|
|
11137
11145
|
},
|
|
11138
11146
|
capabilities: capabilities2,
|
|
11139
|
-
reasoning: result.reasoning
|
|
11147
|
+
reasoning: result.reasoning && adapter.modelCatalogOrigin ? { ...result.reasoning, catalogOrigin: adapter.modelCatalogOrigin } : result.reasoning
|
|
11140
11148
|
};
|
|
11141
11149
|
} catch (error) {
|
|
11142
11150
|
const contractInvalid = error instanceof Error && (error.message.startsWith("Adapter ") || error.message.startsWith("Agent backend registration "));
|
|
@@ -34965,655 +34973,6 @@ var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
|
34965
34973
|
waitingOnProfile: profile.nullable().optional()
|
|
34966
34974
|
});
|
|
34967
34975
|
|
|
34968
|
-
// ../shared/src/community-resources.ts
|
|
34969
|
-
var id = exports_external.string().min(1);
|
|
34970
|
-
var nullableId = id.nullable();
|
|
34971
|
-
var legacyArchivedSchema = exports_external.union([exports_external.boolean(), exports_external.literal(0), exports_external.literal(1)]).transform((value) => value === true || value === 1);
|
|
34972
|
-
var CommunityChannelResourceSchema = exports_external.strictObject({
|
|
34973
|
-
id,
|
|
34974
|
-
type: exports_external.enum(["text", "forum", "thread", "dm"]),
|
|
34975
|
-
serverId: nullableId,
|
|
34976
|
-
categoryId: nullableId,
|
|
34977
|
-
name: exports_external.string().nullable(),
|
|
34978
|
-
topic: exports_external.string(),
|
|
34979
|
-
parentChannelId: nullableId,
|
|
34980
|
-
parentMessageId: nullableId,
|
|
34981
|
-
creatorId: nullableId,
|
|
34982
|
-
position: exports_external.number(),
|
|
34983
|
-
archived: exports_external.boolean(),
|
|
34984
|
-
createdAt: exports_external.string(),
|
|
34985
|
-
lastMessageAt: exports_external.string().nullable(),
|
|
34986
|
-
messageCount: exports_external.number().int().nonnegative()
|
|
34987
|
-
});
|
|
34988
|
-
var CommunityChannelIdentitySchema = CommunityChannelResourceSchema.pick({
|
|
34989
|
-
id: true,
|
|
34990
|
-
type: true,
|
|
34991
|
-
serverId: true,
|
|
34992
|
-
name: true,
|
|
34993
|
-
parentChannelId: true,
|
|
34994
|
-
parentMessageId: true,
|
|
34995
|
-
creatorId: true,
|
|
34996
|
-
archived: true,
|
|
34997
|
-
lastMessageAt: true,
|
|
34998
|
-
createdAt: true
|
|
34999
|
-
}).partial({ createdAt: true }).strip();
|
|
35000
|
-
var legacyChannelIdentitySchema = CommunityChannelIdentitySchema.extend({
|
|
35001
|
-
archived: legacyArchivedSchema,
|
|
35002
|
-
parentChannelId: nullableId.default(null),
|
|
35003
|
-
parentMessageId: nullableId.default(null),
|
|
35004
|
-
creatorId: nullableId.default(null),
|
|
35005
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null)
|
|
35006
|
-
});
|
|
35007
|
-
var CommunityAccessDecisionSchema = exports_external.strictObject({
|
|
35008
|
-
channelId: id,
|
|
35009
|
-
canRead: exports_external.boolean(),
|
|
35010
|
-
canSend: exports_external.boolean(),
|
|
35011
|
-
canCreateDiscussion: exports_external.boolean()
|
|
35012
|
-
});
|
|
35013
|
-
var CommunityLegacyMessageAttachmentSchema = exports_external.strictObject({
|
|
35014
|
-
kind: exports_external.enum(["image", "file"]),
|
|
35015
|
-
name: exports_external.string(),
|
|
35016
|
-
url: exports_external.string(),
|
|
35017
|
-
thumbnailUrl: exports_external.string().optional(),
|
|
35018
|
-
contentType: exports_external.string().optional(),
|
|
35019
|
-
size: exports_external.string().optional(),
|
|
35020
|
-
sizeBytes: exports_external.number().nonnegative().optional(),
|
|
35021
|
-
width: exports_external.number().nonnegative().optional(),
|
|
35022
|
-
height: exports_external.number().nonnegative().optional()
|
|
35023
|
-
});
|
|
35024
|
-
var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
35025
|
-
id,
|
|
35026
|
-
name: exports_external.string(),
|
|
35027
|
-
url: exports_external.string(),
|
|
35028
|
-
thumbnailUrl: exports_external.string().nullable(),
|
|
35029
|
-
contentType: exports_external.string().nullable(),
|
|
35030
|
-
sizeBytes: exports_external.number().int().nonnegative().nullable(),
|
|
35031
|
-
width: exports_external.number().int().nonnegative().nullable(),
|
|
35032
|
-
height: exports_external.number().int().nonnegative().nullable()
|
|
35033
|
-
});
|
|
35034
|
-
var CommunityMessagePreviewAttachmentSchema = CommunityMessageAttachmentSchema.partial().required({ name: true, url: true });
|
|
35035
|
-
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
35036
|
-
id,
|
|
35037
|
-
name: exports_external.string(),
|
|
35038
|
-
discriminator: exports_external.string().min(1).nullable(),
|
|
35039
|
-
avatar: exports_external.string().nullable(),
|
|
35040
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
35041
|
-
aboutMe: exports_external.string().optional(),
|
|
35042
|
-
bannerColor: exports_external.string().nullable().optional(),
|
|
35043
|
-
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
35044
|
-
ownerUserId: nullableId.optional(),
|
|
35045
|
-
ownerHandle: exports_external.string().nullable().optional(),
|
|
35046
|
-
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
35047
|
-
ownedByViewer: exports_external.boolean().optional(),
|
|
35048
|
-
statusEmoji: exports_external.string().nullable().optional(),
|
|
35049
|
-
statusText: exports_external.string().nullable().optional()
|
|
35050
|
-
});
|
|
35051
|
-
var CommunityMessageThreadParticipantSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatar: true, avatarVersion: true });
|
|
35052
|
-
var messageThreadSchema = exports_external.strictObject({
|
|
35053
|
-
id,
|
|
35054
|
-
name: CommunityChannelResourceSchema.shape.name,
|
|
35055
|
-
messageCount: CommunityChannelResourceSchema.shape.messageCount,
|
|
35056
|
-
lastReplyAt: CommunityChannelResourceSchema.shape.lastMessageAt.optional(),
|
|
35057
|
-
tags: exports_external.array(exports_external.string()).optional(),
|
|
35058
|
-
preview: exports_external.string().optional(),
|
|
35059
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema).optional(),
|
|
35060
|
-
participantCount: exports_external.number().int().nonnegative().optional()
|
|
35061
|
-
});
|
|
35062
|
-
var legacyMessageThreadSchema = messageThreadSchema.extend({
|
|
35063
|
-
name: exports_external.string(),
|
|
35064
|
-
lastReplyAt: exports_external.string().optional(),
|
|
35065
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.extend({ avatar: exports_external.string() })).optional()
|
|
35066
|
-
});
|
|
35067
|
-
var messageThreadPreviewSchema = messageThreadSchema.partial().required({ id: true }).extend({
|
|
35068
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.partial().required({ id: true })).optional()
|
|
35069
|
-
});
|
|
35070
|
-
var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
35071
|
-
id,
|
|
35072
|
-
channelId: id,
|
|
35073
|
-
seq: exports_external.number().int().nonnegative(),
|
|
35074
|
-
authorId: id,
|
|
35075
|
-
createdAt: exports_external.string(),
|
|
35076
|
-
type: exports_external.enum(["chat", "system"]),
|
|
35077
|
-
content: exports_external.string(),
|
|
35078
|
-
replyToId: nullableId,
|
|
35079
|
-
clientNonce: exports_external.string().nullable(),
|
|
35080
|
-
attachments: exports_external.array(CommunityMessageAttachmentSchema),
|
|
35081
|
-
systemKind: exports_external.literal("thread").optional(),
|
|
35082
|
-
authorName: exports_external.string().optional(),
|
|
35083
|
-
authorAvatar: exports_external.string().nullable().optional(),
|
|
35084
|
-
authorAvatarVersion: exports_external.number().int().nonnegative().optional(),
|
|
35085
|
-
mentionType: exports_external.literal("everyone").nullable().optional(),
|
|
35086
|
-
replyTo: exports_external.strictObject({
|
|
35087
|
-
id,
|
|
35088
|
-
authorId: id.optional(),
|
|
35089
|
-
authorName: exports_external.string(),
|
|
35090
|
-
text: exports_external.string(),
|
|
35091
|
-
deleted: exports_external.boolean().optional()
|
|
35092
|
-
}).optional(),
|
|
35093
|
-
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
35094
|
-
reactions: exports_external.array(exports_external.strictObject({
|
|
35095
|
-
emoji: exports_external.string(),
|
|
35096
|
-
count: exports_external.number().int().nonnegative(),
|
|
35097
|
-
me: exports_external.boolean(),
|
|
35098
|
-
userIds: exports_external.array(id)
|
|
35099
|
-
})).optional(),
|
|
35100
|
-
thread: messageThreadSchema.optional(),
|
|
35101
|
-
approval: FriendApprovalPayloadSchema.optional()
|
|
35102
|
-
});
|
|
35103
|
-
var CommunityMessagePreviewSchema = CommunityMessageResourceSchema.partial().required({
|
|
35104
|
-
id: true,
|
|
35105
|
-
type: true
|
|
35106
|
-
}).extend({ attachments: exports_external.array(CommunityMessagePreviewAttachmentSchema).optional(), thread: messageThreadPreviewSchema.optional() });
|
|
35107
|
-
var CommunityReadStateResourceSchema = exports_external.strictObject({
|
|
35108
|
-
channelId: id,
|
|
35109
|
-
lastReadMessageId: nullableId,
|
|
35110
|
-
lastReadAt: exports_external.string().nullable(),
|
|
35111
|
-
lastReadSeq: exports_external.number().int().nonnegative()
|
|
35112
|
-
});
|
|
35113
|
-
var CommunityMemberRelationSchema = exports_external.strictObject({
|
|
35114
|
-
channelId: id,
|
|
35115
|
-
userId: id,
|
|
35116
|
-
relation: exports_external.enum(["access", "notify"]),
|
|
35117
|
-
source: exports_external.string(),
|
|
35118
|
-
isCreator: exports_external.boolean(),
|
|
35119
|
-
role: exports_external.string().nullable(),
|
|
35120
|
-
memberId: nullableId
|
|
35121
|
-
});
|
|
35122
|
-
var CommunityPageSchema = exports_external.strictObject({
|
|
35123
|
-
olderCursor: exports_external.string().nullable(),
|
|
35124
|
-
newerCursor: exports_external.string().nullable(),
|
|
35125
|
-
hasMoreOlder: exports_external.boolean(),
|
|
35126
|
-
hasMoreNewer: exports_external.boolean(),
|
|
35127
|
-
latestSeq: exports_external.number().int().nonnegative()
|
|
35128
|
-
});
|
|
35129
|
-
var envelope = { contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), channelId: id };
|
|
35130
|
-
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
35131
|
-
var CommunityMessagesReadSchema = exports_external.strictObject({
|
|
35132
|
-
...envelope,
|
|
35133
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
35134
|
-
page: CommunityPageSchema,
|
|
35135
|
-
surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
|
|
35136
|
-
});
|
|
35137
|
-
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
35138
|
-
viewerId: id,
|
|
35139
|
-
peer: CommunityResourceProfileSchema.nullable(),
|
|
35140
|
-
channel: CommunityChannelResourceSchema,
|
|
35141
|
-
access: CommunityAccessDecisionSchema.extend({ canRead: exports_external.literal(true) }),
|
|
35142
|
-
readState: CommunityReadStateResourceSchema,
|
|
35143
|
-
readStateRevision: exports_external.number().int().nonnegative(),
|
|
35144
|
-
forumFeed: exports_external.lazy(() => CommunityThreadsReadSchema).optional(),
|
|
35145
|
-
opener: CommunityMessageResourceSchema.optional(),
|
|
35146
|
-
parent: CommunityChannelResourceSchema.optional(),
|
|
35147
|
-
selection: exports_external.strictObject({
|
|
35148
|
-
reason: exports_external.enum(["explicit_anchor", "read_pointer", "tail", "read_pointer_missing"]),
|
|
35149
|
-
anchorMessageId: nullableId
|
|
35150
|
-
})
|
|
35151
|
-
}).superRefine((entry, ctx) => {
|
|
35152
|
-
for (const [path13, channelId] of [
|
|
35153
|
-
[["channel", "id"], entry.channel.id],
|
|
35154
|
-
[["access", "channelId"], entry.access.channelId],
|
|
35155
|
-
[["readState", "channelId"], entry.readState.channelId],
|
|
35156
|
-
[["surfaceReceipt", "channelId"], entry.surfaceReceipt.channelId],
|
|
35157
|
-
...entry.messages.map((message2, index2) => [["messages", index2, "channelId"], message2.channelId])
|
|
35158
|
-
]) {
|
|
35159
|
-
if (channelId !== entry.channelId)
|
|
35160
|
-
ctx.addIssue({ code: "custom", path: [...path13], message: "Conversation entry scope mismatch" });
|
|
35161
|
-
}
|
|
35162
|
-
if (entry.channel.type === "dm" !== (entry.peer !== null) || entry.peer?.id === entry.viewerId)
|
|
35163
|
-
ctx.addIssue({ code: "custom", path: ["peer"], message: "Conversation entry peer mismatch" });
|
|
35164
|
-
if (entry.opener && (entry.channel.type !== "thread" || entry.opener.id !== entry.channel.parentMessageId || entry.opener.channelId !== entry.channel.parentChannelId))
|
|
35165
|
-
ctx.addIssue({ code: "custom", path: ["opener"], message: "Conversation entry opener scope mismatch" });
|
|
35166
|
-
if (entry.parent && (entry.channel.type !== "thread" || entry.parent.id !== entry.channel.parentChannelId || entry.parent.serverId !== entry.channel.serverId || entry.parent.type !== "text" && entry.parent.type !== "forum"))
|
|
35167
|
-
ctx.addIssue({ code: "custom", path: ["parent"], message: "Conversation entry parent scope mismatch" });
|
|
35168
|
-
if (entry.forumFeed && (entry.channel.type !== "forum" || entry.forumFeed.channelId !== entry.channelId || entry.forumFeed.channel.id !== entry.channelId || entry.forumFeed.channel.serverId !== entry.channel.serverId || entry.forumFeed.threads.some((thread) => thread.parentChannelId !== entry.channelId || thread.serverId !== entry.channel.serverId)))
|
|
35169
|
-
ctx.addIssue({ code: "custom", path: ["forumFeed"], message: "Conversation entry forum scope mismatch" });
|
|
35170
|
-
if (entry.forumFeed) {
|
|
35171
|
-
const feed = entry.forumFeed, children = new Set(feed.threads.map((thread) => thread.id)), profiles = new Set(feed.included.profiles.map((profile2) => profile2.id));
|
|
35172
|
-
const openers = new Set(feed.threads.flatMap((thread) => thread.parentMessageId ? [thread.parentMessageId] : []));
|
|
35173
|
-
if (feed.included.messages.some((message2) => message2.channelId !== entry.channelId && !children.has(message2.channelId)) || feed.included.tags.some((row) => !openers.has(row.messageId)) || feed.included.participantCounts.some((row) => !children.has(row.channelId)) || feed.included.members.some((member2) => !children.has(member2.channelId) || member2.relation !== "notify" || !profiles.has(member2.userId)))
|
|
35174
|
-
ctx.addIssue({ code: "custom", path: ["forumFeed", "included"], message: "Conversation entry forum included scope mismatch" });
|
|
35175
|
-
}
|
|
35176
|
-
const surfaceKind = entry.channel.type === "text" ? "channel" : entry.channel.type;
|
|
35177
|
-
if (entry.surfaceReceipt.surfaceKind !== surfaceKind)
|
|
35178
|
-
ctx.addIssue({ code: "custom", path: ["surfaceReceipt", "surfaceKind"], message: "Conversation entry surface mismatch" });
|
|
35179
|
-
if (entry.channel.archived)
|
|
35180
|
-
ctx.addIssue({ code: "custom", path: ["channel", "archived"], message: "Conversation entry is archived" });
|
|
35181
|
-
const anchored = entry.selection.reason === "explicit_anchor" || entry.selection.reason === "read_pointer";
|
|
35182
|
-
if (anchored !== (entry.selection.anchorMessageId !== null))
|
|
35183
|
-
ctx.addIssue({ code: "custom", path: ["selection"], message: "Conversation entry selection mismatch" });
|
|
35184
|
-
if (entry.selection.reason === "read_pointer" && entry.selection.anchorMessageId !== entry.readState.lastReadMessageId)
|
|
35185
|
-
ctx.addIssue({ code: "custom", path: ["selection", "anchorMessageId"], message: "Conversation entry read pointer mismatch" });
|
|
35186
|
-
if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
|
|
35187
|
-
ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
|
|
35188
|
-
});
|
|
35189
|
-
var CommunityMessagePostedSchema = CommunityMessagesReadSchema.pick({ contractVersion: true, channelId: true }).extend({
|
|
35190
|
-
message: CommunityMessageResourceSchema,
|
|
35191
|
-
deduped: exports_external.boolean(),
|
|
35192
|
-
threadId: id.optional()
|
|
35193
|
-
});
|
|
35194
|
-
var CommunityMessageReadSchema = CommunityMessagePostedSchema.omit({ deduped: true, threadId: true });
|
|
35195
|
-
var CommunityMembersReadSchema = exports_external.strictObject({ ...envelope, relation: exports_external.enum(["access", "notify"]), members: exports_external.array(CommunityMemberRelationSchema), profiles: exports_external.array(CommunityResourceProfileSchema) });
|
|
35196
|
-
var CommunityThreadsReadSchema = exports_external.strictObject({
|
|
35197
|
-
...envelope,
|
|
35198
|
-
channel: CommunityChannelResourceSchema,
|
|
35199
|
-
threads: exports_external.array(CommunityChannelResourceSchema),
|
|
35200
|
-
included: exports_external.strictObject({
|
|
35201
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
35202
|
-
members: exports_external.array(CommunityMemberRelationSchema),
|
|
35203
|
-
profiles: exports_external.array(CommunityResourceProfileSchema),
|
|
35204
|
-
tags: exports_external.array(exports_external.strictObject({ messageId: id, tag: exports_external.string() })),
|
|
35205
|
-
participantCounts: exports_external.array(exports_external.strictObject({ channelId: id, count: exports_external.number().int().nonnegative() }))
|
|
35206
|
-
}),
|
|
35207
|
-
page: exports_external.strictObject({ nextCursor: exports_external.string().nullable(), hasMore: exports_external.boolean() })
|
|
35208
|
-
});
|
|
35209
|
-
var CommunityReadAdvanceSchema = exports_external.strictObject({ ...envelope, changed: exports_external.boolean(), targetSeq: exports_external.number().int().nonnegative(), revision: exports_external.number().int().nonnegative() });
|
|
35210
|
-
var CommunityReadErrorSchema = exports_external.strictObject({ contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), error: exports_external.strictObject({
|
|
35211
|
-
code: exports_external.enum(["invalid_input", "invalid_reply_target", "unauthenticated", "not_found", "not_allowed", "blocked", "idempotency_conflict", "rate_limited", "temporarily_unavailable"]),
|
|
35212
|
-
message: exports_external.string(),
|
|
35213
|
-
retryable: exports_external.boolean()
|
|
35214
|
-
}) });
|
|
35215
|
-
var legacyProfileSchema = CommunityResourceProfileSchema.pick({
|
|
35216
|
-
id: true,
|
|
35217
|
-
name: true,
|
|
35218
|
-
avatar: true,
|
|
35219
|
-
avatarVersion: true
|
|
35220
|
-
}).extend({ discriminator: exports_external.string().nullable(), statusEmoji: exports_external.string().nullable(), statusText: exports_external.string() });
|
|
35221
|
-
var CommunityLegacyMessageResourceSchema = CommunityMessageResourceSchema.extend({ authorAvatar: exports_external.string().optional(), attachments: exports_external.array(CommunityLegacyMessageAttachmentSchema), thread: legacyMessageThreadSchema.optional() });
|
|
35222
|
-
var legacyEnvelope = { contractVersion: exports_external.literal(2), channelId: id };
|
|
35223
|
-
var legacyReadSchemas = {
|
|
35224
|
-
channel: CommunityChannelReadSchema.extend(legacyEnvelope),
|
|
35225
|
-
messages: CommunityMessagesReadSchema.extend({ ...legacyEnvelope, messages: exports_external.array(CommunityLegacyMessageResourceSchema) }),
|
|
35226
|
-
members: CommunityMembersReadSchema.extend({ ...legacyEnvelope, profiles: exports_external.array(legacyProfileSchema) }),
|
|
35227
|
-
threads: CommunityThreadsReadSchema.extend({ ...legacyEnvelope, included: CommunityThreadsReadSchema.shape.included.extend({
|
|
35228
|
-
messages: exports_external.array(CommunityLegacyMessageResourceSchema),
|
|
35229
|
-
profiles: exports_external.array(legacyProfileSchema)
|
|
35230
|
-
}) }),
|
|
35231
|
-
readAdvance: CommunityReadAdvanceSchema.extend(legacyEnvelope),
|
|
35232
|
-
error: CommunityReadErrorSchema.extend({ contractVersion: exports_external.literal(2) })
|
|
35233
|
-
};
|
|
35234
|
-
var legacyChannelResourcePreviewSchema = CommunityChannelResourceSchema.partial().strip().extend({
|
|
35235
|
-
archived: legacyArchivedSchema.optional()
|
|
35236
|
-
});
|
|
35237
|
-
var legacyChannelResourceSchema = CommunityChannelResourceSchema.strip().extend({
|
|
35238
|
-
topic: CommunityChannelResourceSchema.shape.topic.nullish().transform((value) => value ?? ""),
|
|
35239
|
-
position: CommunityChannelResourceSchema.shape.position.nullish().transform((value) => value ?? 0),
|
|
35240
|
-
messageCount: CommunityChannelResourceSchema.shape.messageCount.nullish().transform((value) => value ?? 0),
|
|
35241
|
-
categoryId: nullableId.default(null),
|
|
35242
|
-
parentChannelId: nullableId.default(null),
|
|
35243
|
-
parentMessageId: nullableId.default(null),
|
|
35244
|
-
creatorId: nullableId.default(null),
|
|
35245
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null),
|
|
35246
|
-
archived: legacyArchivedSchema
|
|
35247
|
-
});
|
|
35248
|
-
var legacyMessageResourceSchema = CommunityLegacyMessageResourceSchema.strip().extend({
|
|
35249
|
-
channelId: id.optional(),
|
|
35250
|
-
replyToId: nullableId.optional(),
|
|
35251
|
-
clientNonce: CommunityMessageResourceSchema.shape.clientNonce.default(null),
|
|
35252
|
-
attachments: CommunityLegacyMessageResourceSchema.shape.attachments.default([]),
|
|
35253
|
-
embeds: CommunityMessageResourceSchema.shape.embeds.nullable().transform((value) => value ?? undefined)
|
|
35254
|
-
});
|
|
35255
|
-
|
|
35256
|
-
// ../shared/src/community-attention.ts
|
|
35257
|
-
var id2 = exports_external.string().min(1);
|
|
35258
|
-
var AttentionScopeSchema = exports_external.strictObject({
|
|
35259
|
-
scopeId: id2,
|
|
35260
|
-
channelId: id2,
|
|
35261
|
-
serverId: id2.nullable().optional(),
|
|
35262
|
-
parentChannelId: id2.nullable().optional(),
|
|
35263
|
-
ordinaryUnread: exports_external.boolean(),
|
|
35264
|
-
lastUnreadSeq: exports_external.number().int().nonnegative(),
|
|
35265
|
-
lastAttentionSeq: exports_external.number().int().nonnegative().nullable().optional(),
|
|
35266
|
-
attentionCount: exports_external.number().int().nonnegative()
|
|
35267
|
-
});
|
|
35268
|
-
var AttentionItemSchema = exports_external.strictObject({
|
|
35269
|
-
id: id2,
|
|
35270
|
-
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post"]),
|
|
35271
|
-
sourceId: id2,
|
|
35272
|
-
scopeId: id2.nullable().optional(),
|
|
35273
|
-
messageId: id2.nullable().optional(),
|
|
35274
|
-
actorUserId: id2.nullable().optional(),
|
|
35275
|
-
createdAt: exports_external.string(),
|
|
35276
|
-
childChannelId: id2.optional(),
|
|
35277
|
-
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
35278
|
-
readTarget: exports_external.strictObject({
|
|
35279
|
-
channelId: id2,
|
|
35280
|
-
seq: exports_external.number().int().nonnegative()
|
|
35281
|
-
}).optional()
|
|
35282
|
-
}).superRefine((item, ctx) => {
|
|
35283
|
-
if (item.kind === "friend_request") {
|
|
35284
|
-
if (!item.actorUserId || item.scopeId != null || item.messageId != null) {
|
|
35285
|
-
ctx.addIssue({ code: "custom", message: "friend request cannot reference a scope or message" });
|
|
35286
|
-
}
|
|
35287
|
-
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
35288
|
-
ctx.addIssue({ code: "custom", message: "friend request cannot carry forum presentation refs" });
|
|
35289
|
-
}
|
|
35290
|
-
return;
|
|
35291
|
-
}
|
|
35292
|
-
if (!item.scopeId || !item.messageId) {
|
|
35293
|
-
ctx.addIssue({ code: "custom", message: "message attention requires scope and message refs" });
|
|
35294
|
-
}
|
|
35295
|
-
if (item.kind === "forum_post") {
|
|
35296
|
-
if (item.actorUserId != null || !item.childChannelId || item.openerSeq === undefined || !item.readTarget || item.sourceId !== item.childChannelId || item.readTarget.seq !== item.openerSeq) {
|
|
35297
|
-
ctx.addIssue({ code: "custom", message: "forum post requires exact child, opener, and read-target refs" });
|
|
35298
|
-
}
|
|
35299
|
-
return;
|
|
35300
|
-
}
|
|
35301
|
-
if (!item.actorUserId) {
|
|
35302
|
-
ctx.addIssue({ code: "custom", message: "message attention requires an actor" });
|
|
35303
|
-
}
|
|
35304
|
-
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
35305
|
-
ctx.addIssue({ code: "custom", message: "mention or reply cannot carry forum presentation refs" });
|
|
35306
|
-
}
|
|
35307
|
-
});
|
|
35308
|
-
var AttentionIncludedServerSchema = exports_external.strictObject({
|
|
35309
|
-
id: id2,
|
|
35310
|
-
name: exports_external.string(),
|
|
35311
|
-
discriminator: exports_external.string()
|
|
35312
|
-
});
|
|
35313
|
-
var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
35314
|
-
id: true,
|
|
35315
|
-
serverId: true,
|
|
35316
|
-
name: true,
|
|
35317
|
-
type: true,
|
|
35318
|
-
parentChannelId: true,
|
|
35319
|
-
parentMessageId: true,
|
|
35320
|
-
creatorId: true,
|
|
35321
|
-
archived: true,
|
|
35322
|
-
lastMessageAt: true
|
|
35323
|
-
}).extend({
|
|
35324
|
-
serverId: CommunityChannelResourceSchema.shape.serverId.unwrap(),
|
|
35325
|
-
name: CommunityChannelResourceSchema.shape.name.unwrap(),
|
|
35326
|
-
type: CommunityChannelResourceSchema.shape.type.extract(["text", "forum", "thread"]),
|
|
35327
|
-
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
35328
|
-
openerUnread: exports_external.boolean().optional()
|
|
35329
|
-
});
|
|
35330
|
-
var AttentionIncludedDmSchema = exports_external.strictObject({
|
|
35331
|
-
id: id2,
|
|
35332
|
-
userId: id2,
|
|
35333
|
-
name: exports_external.string(),
|
|
35334
|
-
discriminator: exports_external.string(),
|
|
35335
|
-
avatar: exports_external.string(),
|
|
35336
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
35337
|
-
lastMessageAt: exports_external.string(),
|
|
35338
|
-
lastUnreadSeq: exports_external.number().int().nonnegative()
|
|
35339
|
-
});
|
|
35340
|
-
var AttentionIncludedProfileSchema = exports_external.strictObject({
|
|
35341
|
-
userId: CommunityResourceProfileSchema.shape.id,
|
|
35342
|
-
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
35343
|
-
discriminator: exports_external.string(),
|
|
35344
|
-
avatar: exports_external.string()
|
|
35345
|
-
});
|
|
35346
|
-
var AttentionIncludedMessageSchema = CommunityMessagePreviewSchema.pick({
|
|
35347
|
-
id: true,
|
|
35348
|
-
channelId: true,
|
|
35349
|
-
type: true,
|
|
35350
|
-
authorId: true,
|
|
35351
|
-
authorName: true,
|
|
35352
|
-
seq: true,
|
|
35353
|
-
createdAt: true,
|
|
35354
|
-
content: true
|
|
35355
|
-
}).required({ channelId: true, seq: true, createdAt: true, content: true });
|
|
35356
|
-
var AttentionIncludedSchema = exports_external.strictObject({
|
|
35357
|
-
servers: exports_external.array(AttentionIncludedServerSchema),
|
|
35358
|
-
channels: exports_external.array(AttentionIncludedChannelSchema),
|
|
35359
|
-
dms: exports_external.array(AttentionIncludedDmSchema),
|
|
35360
|
-
profiles: exports_external.array(AttentionIncludedProfileSchema),
|
|
35361
|
-
messages: exports_external.array(AttentionIncludedMessageSchema)
|
|
35362
|
-
});
|
|
35363
|
-
var AccountAttentionSnapshotSchema = exports_external.strictObject({
|
|
35364
|
-
scopes: exports_external.array(AttentionScopeSchema),
|
|
35365
|
-
items: exports_external.array(AttentionItemSchema),
|
|
35366
|
-
limit: exports_external.number().int().positive(),
|
|
35367
|
-
truncated: exports_external.boolean(),
|
|
35368
|
-
included: AttentionIncludedSchema
|
|
35369
|
-
}).superRefine((snapshot, ctx) => {
|
|
35370
|
-
const scopeIds = new Set;
|
|
35371
|
-
for (const scope of snapshot.scopes) {
|
|
35372
|
-
if (scopeIds.has(scope.scopeId)) {
|
|
35373
|
-
ctx.addIssue({ code: "custom", message: `duplicate attention scope: ${scope.scopeId}` });
|
|
35374
|
-
}
|
|
35375
|
-
scopeIds.add(scope.scopeId);
|
|
35376
|
-
}
|
|
35377
|
-
const itemIds = new Set;
|
|
35378
|
-
const serverById = new Map(snapshot.included.servers.map((server) => [server.id, server]));
|
|
35379
|
-
const channelById = new Map(snapshot.included.channels.map((channel2) => [channel2.id, channel2]));
|
|
35380
|
-
const dmById = new Map(snapshot.included.dms.map((dm) => [dm.id, dm]));
|
|
35381
|
-
const profileById = new Map(snapshot.included.profiles.map((profile2) => [profile2.userId, profile2]));
|
|
35382
|
-
const messageById = new Map(snapshot.included.messages.map((message2) => [message2.id, message2]));
|
|
35383
|
-
const rejectDuplicates = (values, kind) => {
|
|
35384
|
-
const seen = new Set;
|
|
35385
|
-
for (const value of values) {
|
|
35386
|
-
if (seen.has(value))
|
|
35387
|
-
ctx.addIssue({ code: "custom", message: `duplicate included ${kind}: ${value}` });
|
|
35388
|
-
seen.add(value);
|
|
35389
|
-
}
|
|
35390
|
-
};
|
|
35391
|
-
rejectDuplicates(snapshot.included.servers.map((server) => server.id), "server");
|
|
35392
|
-
rejectDuplicates(snapshot.included.channels.map((channel2) => channel2.id), "channel");
|
|
35393
|
-
rejectDuplicates(snapshot.included.dms.map((dm) => dm.id), "dm");
|
|
35394
|
-
rejectDuplicates(snapshot.included.profiles.map((profile2) => profile2.userId), "profile");
|
|
35395
|
-
rejectDuplicates(snapshot.included.messages.map((message2) => message2.id), "message");
|
|
35396
|
-
for (const scope of snapshot.scopes) {
|
|
35397
|
-
if (scope.serverId) {
|
|
35398
|
-
const channel2 = channelById.get(scope.channelId);
|
|
35399
|
-
if (!serverById.has(scope.serverId) || !channel2 || channel2.serverId !== scope.serverId) {
|
|
35400
|
-
ctx.addIssue({ code: "custom", message: `attention scope references missing owner: ${scope.scopeId}` });
|
|
35401
|
-
continue;
|
|
35402
|
-
}
|
|
35403
|
-
if (scope.parentChannelId) {
|
|
35404
|
-
const parent = channelById.get(scope.parentChannelId);
|
|
35405
|
-
const opener = channel2.parentMessageId ? messageById.get(channel2.parentMessageId) : undefined;
|
|
35406
|
-
if (channel2.parentChannelId !== scope.parentChannelId || !parent || parent.serverId !== scope.serverId || !opener || opener.channelId !== parent.id || channel2.openerSeq !== opener.seq || channel2.openerUnread === undefined) {
|
|
35407
|
-
ctx.addIssue({ code: "custom", message: `attention scope references missing parent: ${scope.scopeId}` });
|
|
35408
|
-
}
|
|
35409
|
-
} else if (channel2.parentChannelId !== null) {
|
|
35410
|
-
ctx.addIssue({ code: "custom", message: `attention scope parent mismatch: ${scope.scopeId}` });
|
|
35411
|
-
}
|
|
35412
|
-
} else {
|
|
35413
|
-
const dm = dmById.get(scope.channelId);
|
|
35414
|
-
if (!dm || !profileById.has(dm.userId)) {
|
|
35415
|
-
ctx.addIssue({ code: "custom", message: `attention scope references missing DM owner: ${scope.scopeId}` });
|
|
35416
|
-
}
|
|
35417
|
-
}
|
|
35418
|
-
}
|
|
35419
|
-
for (const item of snapshot.items) {
|
|
35420
|
-
if (itemIds.has(item.id)) {
|
|
35421
|
-
ctx.addIssue({ code: "custom", message: `duplicate attention item: ${item.id}` });
|
|
35422
|
-
}
|
|
35423
|
-
itemIds.add(item.id);
|
|
35424
|
-
if (item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
35425
|
-
ctx.addIssue({ code: "custom", message: `attention item references missing scope: ${item.scopeId}` });
|
|
35426
|
-
}
|
|
35427
|
-
if (item.kind === "friend_request") {
|
|
35428
|
-
if (!item.actorUserId || !profileById.has(item.actorUserId)) {
|
|
35429
|
-
ctx.addIssue({ code: "custom", message: `friend request references missing profile: ${item.id}` });
|
|
35430
|
-
}
|
|
35431
|
-
continue;
|
|
35432
|
-
}
|
|
35433
|
-
const scope = item.scopeId ? snapshot.scopes.find((candidate) => candidate.scopeId === item.scopeId) : undefined;
|
|
35434
|
-
const message2 = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
35435
|
-
if (!scope || !message2) {
|
|
35436
|
-
ctx.addIssue({ code: "custom", message: `attention item references missing message: ${item.id}` });
|
|
35437
|
-
continue;
|
|
35438
|
-
}
|
|
35439
|
-
if (item.kind === "forum_post") {
|
|
35440
|
-
const parent = channelById.get(scope.channelId);
|
|
35441
|
-
const child = item.childChannelId ? channelById.get(item.childChannelId) : undefined;
|
|
35442
|
-
if (!scope.serverId || parent?.type !== "forum" || child?.type !== "thread" || child.parentChannelId !== parent.id || child.parentMessageId !== message2.id || message2.channelId !== parent.id || message2.seq !== item.openerSeq || item.readTarget?.channelId !== parent.id) {
|
|
35443
|
-
ctx.addIssue({ code: "custom", message: `forum post references incomplete presentation owners: ${item.id}` });
|
|
35444
|
-
}
|
|
35445
|
-
continue;
|
|
35446
|
-
}
|
|
35447
|
-
if (message2.channelId !== scope.channelId || !item.actorUserId || !profileById.has(item.actorUserId)) {
|
|
35448
|
-
ctx.addIssue({ code: "custom", message: `message attention references incomplete owners: ${item.id}` });
|
|
35449
|
-
}
|
|
35450
|
-
}
|
|
35451
|
-
});
|
|
35452
|
-
// ../shared/src/constants/community.ts
|
|
35453
|
-
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
35454
|
-
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
35455
|
-
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
35456
|
-
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
35457
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
35458
|
-
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
35459
|
-
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
35460
|
-
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
35461
|
-
var ALLOWED_ICON_MIME_TYPES = [
|
|
35462
|
-
"image/png",
|
|
35463
|
-
"image/jpeg",
|
|
35464
|
-
"image/webp",
|
|
35465
|
-
"image/gif"
|
|
35466
|
-
];
|
|
35467
|
-
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
35468
|
-
// ../shared/src/provider-telemetry.ts
|
|
35469
|
-
var DAILY_TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
35470
|
-
var safeToken = exports_external.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
35471
|
-
var boundedText2 = exports_external.string().min(1).refine((value) => new TextEncoder().encode(value).length <= 64, { message: "must be at most 64 UTF-8 bytes" });
|
|
35472
|
-
var DailyUsageMetricSchema = safeToken.nullable();
|
|
35473
|
-
var DailyUsageSnapshotSchema = exports_external.object({
|
|
35474
|
-
botId: exports_external.string().min(1),
|
|
35475
|
-
day: exports_external.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
35476
|
-
metrics: exports_external.object({
|
|
35477
|
-
input: DailyUsageMetricSchema,
|
|
35478
|
-
output: DailyUsageMetricSchema,
|
|
35479
|
-
cache: DailyUsageMetricSchema
|
|
35480
|
-
}).strict()
|
|
35481
|
-
}).strict();
|
|
35482
|
-
var QuotaProductIdentitySchema = exports_external.discriminatedUnion("kind", [
|
|
35483
|
-
exports_external.object({ kind: exports_external.literal("reported"), id: boundedText2, displayName: boundedText2 }).strict(),
|
|
35484
|
-
exports_external.object({ kind: exports_external.literal("unknown"), displayName: boundedText2 }).strict()
|
|
35485
|
-
]);
|
|
35486
|
-
var QuotaModelIdentitySchema = exports_external.discriminatedUnion("kind", [
|
|
35487
|
-
exports_external.object({ kind: exports_external.literal("reported"), id: boundedText2 }).strict(),
|
|
35488
|
-
exports_external.object({ kind: exports_external.literal("not_applicable") }).strict(),
|
|
35489
|
-
exports_external.object({ kind: exports_external.literal("unknown") }).strict()
|
|
35490
|
-
]);
|
|
35491
|
-
var QuotaWindowIdentitySchema = exports_external.discriminatedUnion("kind", [
|
|
35492
|
-
exports_external.object({
|
|
35493
|
-
kind: exports_external.literal("rolling"),
|
|
35494
|
-
durationSeconds: exports_external.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
35495
|
-
displayName: boundedText2
|
|
35496
|
-
}).strict(),
|
|
35497
|
-
exports_external.object({
|
|
35498
|
-
kind: exports_external.literal("calendar"),
|
|
35499
|
-
period: exports_external.enum(["day", "week", "month"]),
|
|
35500
|
-
displayName: boundedText2
|
|
35501
|
-
}).strict(),
|
|
35502
|
-
exports_external.object({
|
|
35503
|
-
kind: exports_external.literal("provider_defined"),
|
|
35504
|
-
id: boundedText2,
|
|
35505
|
-
durationSeconds: exports_external.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
35506
|
-
displayName: boundedText2
|
|
35507
|
-
}).strict()
|
|
35508
|
-
]);
|
|
35509
|
-
var QuotaLimitSchema = exports_external.object({
|
|
35510
|
-
bucket: exports_external.object({
|
|
35511
|
-
limitId: boundedText2,
|
|
35512
|
-
product: QuotaProductIdentitySchema,
|
|
35513
|
-
model: QuotaModelIdentitySchema,
|
|
35514
|
-
window: QuotaWindowIdentitySchema
|
|
35515
|
-
}).strict(),
|
|
35516
|
-
usedPercent: exports_external.number().finite().min(0).max(100),
|
|
35517
|
-
resetsAt: exports_external.string().datetime({ offset: true }).optional()
|
|
35518
|
-
}).strict();
|
|
35519
|
-
function quotaIdentity(limit) {
|
|
35520
|
-
const { product, model, window: window2, limitId } = limit.bucket;
|
|
35521
|
-
const productKey = product.kind === "reported" ? `reported:${product.id}` : "unknown";
|
|
35522
|
-
const modelKey = model.kind === "reported" ? `reported:${model.id}` : model.kind;
|
|
35523
|
-
const windowKey = window2.kind === "rolling" ? `rolling:${window2.durationSeconds}` : window2.kind === "calendar" ? `calendar:${window2.period}` : `provider_defined:${window2.id}:${window2.durationSeconds === undefined ? "absent" : window2.durationSeconds}`;
|
|
35524
|
-
return `${productKey}\x00${modelKey}\x00${windowKey}\x00${limitId}`;
|
|
35525
|
-
}
|
|
35526
|
-
var AvailableQuotaObservationSchema = exports_external.object({
|
|
35527
|
-
status: exports_external.literal("available"),
|
|
35528
|
-
sourceEpoch: exports_external.string().regex(/^[A-Za-z0-9_-]{22}$/),
|
|
35529
|
-
planName: boundedText2.optional(),
|
|
35530
|
-
freshForSeconds: exports_external.number().int().positive().max(86400),
|
|
35531
|
-
limits: exports_external.array(QuotaLimitSchema).min(1).max(8)
|
|
35532
|
-
}).strict().superRefine((value, ctx) => {
|
|
35533
|
-
const identities = new Set;
|
|
35534
|
-
for (const [index2, limit] of value.limits.entries()) {
|
|
35535
|
-
const identity = quotaIdentity(limit);
|
|
35536
|
-
if (identities.has(identity)) {
|
|
35537
|
-
ctx.addIssue({ code: "custom", message: "duplicate quota bucket identity", path: ["limits", index2] });
|
|
35538
|
-
}
|
|
35539
|
-
identities.add(identity);
|
|
35540
|
-
}
|
|
35541
|
-
});
|
|
35542
|
-
var ProviderQuotaObservationSchema = exports_external.union([
|
|
35543
|
-
AvailableQuotaObservationSchema,
|
|
35544
|
-
exports_external.object({
|
|
35545
|
-
status: exports_external.literal("error"),
|
|
35546
|
-
sourceEpoch: exports_external.string().regex(/^[A-Za-z0-9_-]{22}$/),
|
|
35547
|
-
code: exports_external.enum(["unavailable", "unauthorized", "network", "provider_error", "invalid_response"]),
|
|
35548
|
-
retryable: exports_external.boolean()
|
|
35549
|
-
}).strict()
|
|
35550
|
-
]);
|
|
35551
|
-
var ProviderQuotaSnapshotSchema = exports_external.object({
|
|
35552
|
-
agentBackendId: exports_external.enum(["claude", "codex", "grok", "antigravity"]),
|
|
35553
|
-
observation: ProviderQuotaObservationSchema
|
|
35554
|
-
}).strict();
|
|
35555
|
-
// ../shared/src/product-entitlements.ts
|
|
35556
|
-
var EntitlementValueSchema = exports_external.lazy(() => exports_external.union([
|
|
35557
|
-
exports_external.null(),
|
|
35558
|
-
exports_external.boolean(),
|
|
35559
|
-
exports_external.number().finite(),
|
|
35560
|
-
exports_external.string(),
|
|
35561
|
-
exports_external.array(EntitlementValueSchema),
|
|
35562
|
-
exports_external.record(exports_external.string(), EntitlementValueSchema)
|
|
35563
|
-
]));
|
|
35564
|
-
var NonNegativeIntegerEntitlementSchema = exports_external.number().int().nonnegative();
|
|
35565
|
-
var CommunityBotActivationRequestSchema = exports_external.strictObject({
|
|
35566
|
-
active: exports_external.boolean()
|
|
35567
|
-
});
|
|
35568
|
-
// ../shared/src/billing.ts
|
|
35569
|
-
var BillingPlanSchema = exports_external.object({
|
|
35570
|
-
id: exports_external.string().min(1),
|
|
35571
|
-
displayName: exports_external.string().min(1)
|
|
35572
|
-
});
|
|
35573
|
-
var BillingOfferSchema = exports_external.object({
|
|
35574
|
-
priceId: exports_external.string().min(1),
|
|
35575
|
-
botLimit: exports_external.number().int().nonnegative(),
|
|
35576
|
-
machineLimit: exports_external.number().int().nonnegative(),
|
|
35577
|
-
plan: BillingPlanSchema,
|
|
35578
|
-
unitAmount: exports_external.number().int().nonnegative(),
|
|
35579
|
-
currency: exports_external.string().min(1),
|
|
35580
|
-
interval: exports_external.enum(["month", "year", "week", "day"]),
|
|
35581
|
-
intervalCount: exports_external.number().int().positive()
|
|
35582
|
-
});
|
|
35583
|
-
var BillingSubscriptionSchema = exports_external.object({
|
|
35584
|
-
plan: BillingPlanSchema,
|
|
35585
|
-
status: exports_external.string().min(1),
|
|
35586
|
-
currentPeriodEnd: exports_external.string().datetime().nullable(),
|
|
35587
|
-
cancelAt: exports_external.string().datetime().nullable(),
|
|
35588
|
-
scheduledChange: exports_external.object({
|
|
35589
|
-
plan: BillingPlanSchema,
|
|
35590
|
-
effectiveAt: exports_external.string().datetime()
|
|
35591
|
-
}).nullable()
|
|
35592
|
-
});
|
|
35593
|
-
var PublicPricingSchema = exports_external.object({
|
|
35594
|
-
free: exports_external.object({
|
|
35595
|
-
plan: BillingPlanSchema,
|
|
35596
|
-
botLimit: exports_external.number().int().nonnegative(),
|
|
35597
|
-
machineLimit: exports_external.number().int().nonnegative()
|
|
35598
|
-
}),
|
|
35599
|
-
offers: exports_external.array(BillingOfferSchema)
|
|
35600
|
-
});
|
|
35601
|
-
var BillingSummarySchema = exports_external.object({
|
|
35602
|
-
plan: BillingPlanSchema,
|
|
35603
|
-
isFounder: exports_external.boolean(),
|
|
35604
|
-
offers: exports_external.array(BillingOfferSchema),
|
|
35605
|
-
subscription: BillingSubscriptionSchema.nullable()
|
|
35606
|
-
});
|
|
35607
|
-
var BillingCheckoutRequestSchema = exports_external.strictObject({
|
|
35608
|
-
priceId: exports_external.string().min(1).max(255),
|
|
35609
|
-
founderAcknowledged: exports_external.boolean().optional()
|
|
35610
|
-
});
|
|
35611
|
-
var BillingPortalRequestSchema = exports_external.strictObject({
|
|
35612
|
-
priceId: exports_external.string().min(1).max(255).optional()
|
|
35613
|
-
});
|
|
35614
|
-
var BillingRedirectResponseSchema = exports_external.object({
|
|
35615
|
-
url: exports_external.string().url()
|
|
35616
|
-
});
|
|
35617
34976
|
// ../shared/src/runtime-models-contract.ts
|
|
35618
34977
|
var RUNTIME_MODEL_DISCOVERY_CAPABILITY = "runtime-model-discovery-v1";
|
|
35619
34978
|
var RuntimeModelDiscoveryRequestSchema = exports_external.strictObject({
|
|
@@ -35655,6 +35014,7 @@ function formatHandle(name, discriminator) {
|
|
|
35655
35014
|
var AGENT_EVENT_PROMPT_MAX_LENGTH = 32768;
|
|
35656
35015
|
var DM_SERVER = ".dm";
|
|
35657
35016
|
var CONTROL_HEARTBEAT_CAPABILITY = "control-heartbeat-v1";
|
|
35017
|
+
var MACHINE_STOP_CAPABILITY = "machine-stop-v1";
|
|
35658
35018
|
var AgentInterruptRequestSchema = exports_external.strictObject({
|
|
35659
35019
|
type: exports_external.literal("agent:interrupt"),
|
|
35660
35020
|
agentId: exports_external.string().min(1).max(128)
|
|
@@ -35796,6 +35156,9 @@ var HostCommandSchema = exports_external.discriminatedUnion("type", [
|
|
|
35796
35156
|
exports_external.strictObject({
|
|
35797
35157
|
type: exports_external.literal("machine:update")
|
|
35798
35158
|
}),
|
|
35159
|
+
exports_external.strictObject({
|
|
35160
|
+
type: exports_external.literal("machine:stop")
|
|
35161
|
+
}),
|
|
35799
35162
|
exports_external.object({
|
|
35800
35163
|
type: exports_external.literal("bot:added"),
|
|
35801
35164
|
botId: exports_external.string().min(1),
|
|
@@ -35821,6 +35184,111 @@ var HostCommandSchema = exports_external.discriminatedUnion("type", [
|
|
|
35821
35184
|
DiagnosticCollectCommandSchema
|
|
35822
35185
|
]);
|
|
35823
35186
|
|
|
35187
|
+
// ../shared/src/provider-telemetry.ts
|
|
35188
|
+
var DAILY_TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
35189
|
+
var safeToken = exports_external.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
35190
|
+
var boundedText2 = exports_external.string().min(1).refine((value) => new TextEncoder().encode(value).length <= 64, { message: "must be at most 64 UTF-8 bytes" });
|
|
35191
|
+
var DailyUsageMetricSchema = safeToken.nullable();
|
|
35192
|
+
var DailyUsageSnapshotSchema = exports_external.object({
|
|
35193
|
+
botId: exports_external.string().min(1),
|
|
35194
|
+
day: exports_external.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
35195
|
+
metrics: exports_external.object({
|
|
35196
|
+
input: DailyUsageMetricSchema,
|
|
35197
|
+
output: DailyUsageMetricSchema,
|
|
35198
|
+
cache: DailyUsageMetricSchema
|
|
35199
|
+
}).strict()
|
|
35200
|
+
}).strict();
|
|
35201
|
+
var QuotaProductIdentitySchema = exports_external.discriminatedUnion("kind", [
|
|
35202
|
+
exports_external.object({ kind: exports_external.literal("reported"), id: boundedText2, displayName: boundedText2 }).strict(),
|
|
35203
|
+
exports_external.object({ kind: exports_external.literal("unknown"), displayName: boundedText2 }).strict()
|
|
35204
|
+
]);
|
|
35205
|
+
var QuotaModelIdentitySchema = exports_external.discriminatedUnion("kind", [
|
|
35206
|
+
exports_external.object({ kind: exports_external.literal("reported"), id: boundedText2 }).strict(),
|
|
35207
|
+
exports_external.object({ kind: exports_external.literal("not_applicable") }).strict(),
|
|
35208
|
+
exports_external.object({ kind: exports_external.literal("unknown") }).strict()
|
|
35209
|
+
]);
|
|
35210
|
+
var QuotaWindowIdentitySchema = exports_external.discriminatedUnion("kind", [
|
|
35211
|
+
exports_external.object({
|
|
35212
|
+
kind: exports_external.literal("rolling"),
|
|
35213
|
+
durationSeconds: exports_external.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
35214
|
+
displayName: boundedText2
|
|
35215
|
+
}).strict(),
|
|
35216
|
+
exports_external.object({
|
|
35217
|
+
kind: exports_external.literal("calendar"),
|
|
35218
|
+
period: exports_external.enum(["day", "week", "month"]),
|
|
35219
|
+
displayName: boundedText2
|
|
35220
|
+
}).strict(),
|
|
35221
|
+
exports_external.object({
|
|
35222
|
+
kind: exports_external.literal("provider_defined"),
|
|
35223
|
+
id: boundedText2,
|
|
35224
|
+
durationSeconds: exports_external.number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
35225
|
+
displayName: boundedText2
|
|
35226
|
+
}).strict()
|
|
35227
|
+
]);
|
|
35228
|
+
var QuotaLimitSchema = exports_external.object({
|
|
35229
|
+
bucket: exports_external.object({
|
|
35230
|
+
limitId: boundedText2,
|
|
35231
|
+
product: QuotaProductIdentitySchema,
|
|
35232
|
+
model: QuotaModelIdentitySchema,
|
|
35233
|
+
window: QuotaWindowIdentitySchema
|
|
35234
|
+
}).strict(),
|
|
35235
|
+
usedPercent: exports_external.number().finite().min(0).max(100),
|
|
35236
|
+
resetsAt: exports_external.string().datetime({ offset: true }).optional()
|
|
35237
|
+
}).strict();
|
|
35238
|
+
function quotaIdentity(limit) {
|
|
35239
|
+
const { product, model, window: window2, limitId } = limit.bucket;
|
|
35240
|
+
const productKey = product.kind === "reported" ? `reported:${product.id}` : "unknown";
|
|
35241
|
+
const modelKey = model.kind === "reported" ? `reported:${model.id}` : model.kind;
|
|
35242
|
+
const windowKey = window2.kind === "rolling" ? `rolling:${window2.durationSeconds}` : window2.kind === "calendar" ? `calendar:${window2.period}` : `provider_defined:${window2.id}:${window2.durationSeconds === undefined ? "absent" : window2.durationSeconds}`;
|
|
35243
|
+
return `${productKey}\x00${modelKey}\x00${windowKey}\x00${limitId}`;
|
|
35244
|
+
}
|
|
35245
|
+
var AvailableQuotaObservationSchema = exports_external.object({
|
|
35246
|
+
status: exports_external.literal("available"),
|
|
35247
|
+
sourceEpoch: exports_external.string().regex(/^[A-Za-z0-9_-]{22}$/),
|
|
35248
|
+
planName: boundedText2.optional(),
|
|
35249
|
+
freshForSeconds: exports_external.number().int().positive().max(86400),
|
|
35250
|
+
limits: exports_external.array(QuotaLimitSchema).min(1).max(8)
|
|
35251
|
+
}).strict().superRefine((value, ctx) => {
|
|
35252
|
+
const identities = new Set;
|
|
35253
|
+
for (const [index2, limit] of value.limits.entries()) {
|
|
35254
|
+
const identity = quotaIdentity(limit);
|
|
35255
|
+
if (identities.has(identity)) {
|
|
35256
|
+
ctx.addIssue({ code: "custom", message: "duplicate quota bucket identity", path: ["limits", index2] });
|
|
35257
|
+
}
|
|
35258
|
+
identities.add(identity);
|
|
35259
|
+
}
|
|
35260
|
+
});
|
|
35261
|
+
var ProviderQuotaObservationSchema = exports_external.union([
|
|
35262
|
+
AvailableQuotaObservationSchema,
|
|
35263
|
+
exports_external.object({
|
|
35264
|
+
status: exports_external.literal("error"),
|
|
35265
|
+
sourceEpoch: exports_external.string().regex(/^[A-Za-z0-9_-]{22}$/),
|
|
35266
|
+
code: exports_external.enum(["unavailable", "unauthorized", "network", "provider_error", "invalid_response"]),
|
|
35267
|
+
retryable: exports_external.boolean()
|
|
35268
|
+
}).strict()
|
|
35269
|
+
]);
|
|
35270
|
+
var ProviderQuotaSnapshotSchema = exports_external.object({
|
|
35271
|
+
agentBackendId: exports_external.enum(["claude", "codex", "grok", "antigravity"]),
|
|
35272
|
+
observation: ProviderQuotaObservationSchema
|
|
35273
|
+
}).strict();
|
|
35274
|
+
|
|
35275
|
+
// ../shared/src/constants/community.ts
|
|
35276
|
+
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
35277
|
+
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
35278
|
+
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
35279
|
+
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
35280
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
35281
|
+
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
35282
|
+
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
35283
|
+
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
35284
|
+
var ALLOWED_ICON_MIME_TYPES = [
|
|
35285
|
+
"image/png",
|
|
35286
|
+
"image/jpeg",
|
|
35287
|
+
"image/webp",
|
|
35288
|
+
"image/gif"
|
|
35289
|
+
];
|
|
35290
|
+
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
35291
|
+
|
|
35824
35292
|
// ../shared/src/lib/community-name.ts
|
|
35825
35293
|
var FORBIDDEN_NAME_CHARS = /[#@\x00-\x1f\x7f-\x9f]/;
|
|
35826
35294
|
function validateCommunityName(name) {
|
|
@@ -36360,6 +35828,7 @@ var RuntimeReasoningModelSchema = exports_external.object({
|
|
|
36360
35828
|
return defaultReasoningEffort !== undefined && model.supportedReasoningEfforts.some((option) => option.value === defaultReasoningEffort) ? { ...rest, defaultReasoningEffort } : rest;
|
|
36361
35829
|
});
|
|
36362
35830
|
var RuntimeReasoningCatalogSchema = exports_external.object({
|
|
35831
|
+
catalogOrigin: exports_external.enum(["native_report", "adapter_suggestions"]).optional().catch(undefined),
|
|
36363
35832
|
updateMode: exports_external.enum(["live_next_turn", "context_preserving_restart", "unsupported"]),
|
|
36364
35833
|
defaultModelId: exports_external.string().min(1).max(100).optional().catch(undefined),
|
|
36365
35834
|
models: exports_external.array(exports_external.unknown()).transform((models) => {
|
|
@@ -36413,11 +35882,11 @@ var HostRuntimeModelsFrameSchema = RuntimeModelDiscoveryRequestSchema.extend({
|
|
|
36413
35882
|
var CommunityRunningAgentListSchema = exports_external.array(exports_external.string()).transform((list) => {
|
|
36414
35883
|
const seen = new Set;
|
|
36415
35884
|
const out = [];
|
|
36416
|
-
for (const
|
|
36417
|
-
if (seen.has(
|
|
35885
|
+
for (const id of list) {
|
|
35886
|
+
if (seen.has(id))
|
|
36418
35887
|
continue;
|
|
36419
|
-
seen.add(
|
|
36420
|
-
out.push(
|
|
35888
|
+
seen.add(id);
|
|
35889
|
+
out.push(id);
|
|
36421
35890
|
}
|
|
36422
35891
|
return out;
|
|
36423
35892
|
});
|
|
@@ -36620,153 +36089,739 @@ var CommunityAgentUpdateProfileRequestSchema = exports_external.object({
|
|
|
36620
36089
|
var CommunityAgentInboxPullRequestSchema = exports_external.object({
|
|
36621
36090
|
max: exports_external.number().int().min(1).max(200).optional()
|
|
36622
36091
|
});
|
|
36623
|
-
var CommunityAgentAckRequestSchema = exports_external.object({
|
|
36624
|
-
cursors: exports_external.array(CommunityAgentCursorSchema).min(1)
|
|
36092
|
+
var CommunityAgentAckRequestSchema = exports_external.object({
|
|
36093
|
+
cursors: exports_external.array(CommunityAgentCursorSchema).min(1)
|
|
36094
|
+
});
|
|
36095
|
+
var CommunityAgentReadRequestSchema = exports_external.object({
|
|
36096
|
+
channel: exports_external.string().min(1),
|
|
36097
|
+
before: CommunityAgentSeqSchema.optional(),
|
|
36098
|
+
after: CommunityAgentSeqSchema.optional(),
|
|
36099
|
+
around: CommunityAgentSeqSchema.optional(),
|
|
36100
|
+
limit: exports_external.number().int().min(1).max(200).optional()
|
|
36101
|
+
}).refine((v) => [v.before, v.after, v.around].filter((x) => x !== undefined).length <= 1, { message: "at most one of before/after/around may be supplied" });
|
|
36102
|
+
var CommunityAgentResolveRequestSchema = exports_external.object({
|
|
36103
|
+
channel: exports_external.string().min(1),
|
|
36104
|
+
seq: CommunityAgentSeqSchema
|
|
36105
|
+
});
|
|
36106
|
+
var CommunityAgentListChannelsRequestSchema = exports_external.object({
|
|
36107
|
+
server: exports_external.string().min(1).optional()
|
|
36108
|
+
});
|
|
36109
|
+
var CommunityAgentListMembersRequestSchema = exports_external.object({
|
|
36110
|
+
server: exports_external.string().min(1),
|
|
36111
|
+
limit: exports_external.number().int().positive().optional(),
|
|
36112
|
+
cursor: exports_external.string().min(1).optional()
|
|
36113
|
+
});
|
|
36114
|
+
var CommunityAgentChannelMemberRequestSchema = exports_external.object({
|
|
36115
|
+
channel: exports_external.string().min(1),
|
|
36116
|
+
agentId: exports_external.string().optional()
|
|
36117
|
+
});
|
|
36118
|
+
var CommunityAgentJoinServerRequestSchema = exports_external.object({
|
|
36119
|
+
invite: exports_external.string().min(1)
|
|
36120
|
+
});
|
|
36121
|
+
var CommunityAgentNapRequestSchema = exports_external.object({
|
|
36122
|
+
handoff: exports_external.string().refine((value) => value.trim().length > 0, {
|
|
36123
|
+
message: "handoff must not be blank"
|
|
36124
|
+
}).optional()
|
|
36125
|
+
});
|
|
36126
|
+
var CommunityAgentMessagePropertyRequestSchema = exports_external.object({
|
|
36127
|
+
channel: exports_external.string().min(1),
|
|
36128
|
+
seq: CommunityAgentPositiveSeqSchema,
|
|
36129
|
+
property: exports_external.unknown()
|
|
36130
|
+
});
|
|
36131
|
+
var CommunityAgentFriendRequestSchema = exports_external.object({
|
|
36132
|
+
username: exports_external.string().min(1)
|
|
36133
|
+
});
|
|
36134
|
+
var CommunityAgentListFriendsSchema = exports_external.object({});
|
|
36135
|
+
var AuditLogCliInvocationPayloadSchema = exports_external.object({
|
|
36136
|
+
subcommand: exports_external.string().min(1),
|
|
36137
|
+
propertyType: exports_external.enum(["emoji", "tag", "mark"]).optional()
|
|
36138
|
+
});
|
|
36139
|
+
var AuditLogToolCallPayloadSchema = exports_external.object({
|
|
36140
|
+
name: exports_external.string().min(1),
|
|
36141
|
+
target: exports_external.string().max(240).optional()
|
|
36142
|
+
});
|
|
36143
|
+
var AuditLogThinkingPayloadSchema = exports_external.object({
|
|
36144
|
+
text: exports_external.string(),
|
|
36145
|
+
truncated: exports_external.boolean(),
|
|
36146
|
+
chars: exports_external.number().int().nonnegative()
|
|
36147
|
+
});
|
|
36148
|
+
var AuditLogTextPayloadSchema = exports_external.object({
|
|
36149
|
+
text: exports_external.string().min(1).max(BOT_AUDIT_TEXT_MAX_BYTES).refine((text3) => new TextEncoder().encode(text3).byteLength <= BOT_AUDIT_TEXT_MAX_BYTES, { message: "Text exceeds 1024 UTF-8 bytes" }),
|
|
36150
|
+
truncated: exports_external.boolean(),
|
|
36151
|
+
chars: exports_external.number().int().nonnegative()
|
|
36152
|
+
});
|
|
36153
|
+
var AuditLogTurnInterruptPayloadSchema = exports_external.object({
|
|
36154
|
+
status: exports_external.literal("accepted")
|
|
36155
|
+
});
|
|
36156
|
+
var AuditLogWakeTriggerPayloadSchema = exports_external.object({
|
|
36157
|
+
messageId: exports_external.string().min(1),
|
|
36158
|
+
channel: exports_external.string().min(1),
|
|
36159
|
+
seq: CommunityAgentPositiveSeqSchema,
|
|
36160
|
+
senderId: exports_external.string().min(1),
|
|
36161
|
+
senderHandle: exports_external.string().min(1),
|
|
36162
|
+
reason: exports_external.enum(["unread", "mention"])
|
|
36163
|
+
});
|
|
36164
|
+
var AuditLogSessionResetPayloadSchema = exports_external.object({
|
|
36165
|
+
trigger: exports_external.enum(["single", "reset_all", "idle_timeout"])
|
|
36166
|
+
});
|
|
36167
|
+
var AuditLogNapPayloadSchema = exports_external.object({
|
|
36168
|
+
trigger: exports_external.literal("nap")
|
|
36169
|
+
});
|
|
36170
|
+
var AuditLogModelChangedPayloadSchema = exports_external.object({
|
|
36171
|
+
from: exports_external.string().nullable(),
|
|
36172
|
+
to: exports_external.string().nullable()
|
|
36173
|
+
});
|
|
36174
|
+
var AuditLogProviderChangedPayloadSchema = exports_external.object({
|
|
36175
|
+
from: exports_external.string().min(1),
|
|
36176
|
+
to: exports_external.string().min(1)
|
|
36177
|
+
});
|
|
36178
|
+
var AuditLogErrorPayloadSchema = exports_external.object({
|
|
36179
|
+
scope: exports_external.enum(["spawn", "runtime", "exit", "handshake_timeout", "model_switch", "reset"]),
|
|
36180
|
+
code: exports_external.string().min(1).max(120),
|
|
36181
|
+
message: exports_external.string().max(2048),
|
|
36182
|
+
model: exports_external.string().nullable()
|
|
36183
|
+
});
|
|
36184
|
+
var BotAuditEventSchema = exports_external.discriminatedUnion("kind", [
|
|
36185
|
+
exports_external.object({ kind: exports_external.literal("cli_invocation"), payload: AuditLogCliInvocationPayloadSchema }),
|
|
36186
|
+
exports_external.object({ kind: exports_external.literal("tool_call"), payload: AuditLogToolCallPayloadSchema }),
|
|
36187
|
+
exports_external.object({ kind: exports_external.literal("thinking"), payload: AuditLogThinkingPayloadSchema }),
|
|
36188
|
+
exports_external.object({ kind: exports_external.literal("text"), payload: AuditLogTextPayloadSchema }),
|
|
36189
|
+
exports_external.object({ kind: exports_external.literal("turn_interrupt"), payload: AuditLogTurnInterruptPayloadSchema }),
|
|
36190
|
+
exports_external.object({ kind: exports_external.literal("wake_trigger"), payload: AuditLogWakeTriggerPayloadSchema }),
|
|
36191
|
+
exports_external.object({ kind: exports_external.literal("session_reset"), payload: AuditLogSessionResetPayloadSchema }),
|
|
36192
|
+
exports_external.object({ kind: exports_external.literal("nap"), payload: AuditLogNapPayloadSchema }),
|
|
36193
|
+
exports_external.object({ kind: exports_external.literal("model_changed"), payload: AuditLogModelChangedPayloadSchema }),
|
|
36194
|
+
exports_external.object({ kind: exports_external.literal("provider_changed"), payload: AuditLogProviderChangedPayloadSchema }),
|
|
36195
|
+
exports_external.object({ kind: exports_external.literal("error"), payload: AuditLogErrorPayloadSchema })
|
|
36196
|
+
]);
|
|
36197
|
+
var BotAuditEventKindSchema = exports_external.enum([
|
|
36198
|
+
"cli_invocation",
|
|
36199
|
+
"tool_call",
|
|
36200
|
+
"thinking",
|
|
36201
|
+
"text",
|
|
36202
|
+
"turn_interrupt",
|
|
36203
|
+
"wake_trigger",
|
|
36204
|
+
"session_reset",
|
|
36205
|
+
"nap",
|
|
36206
|
+
"model_changed",
|
|
36207
|
+
"provider_changed",
|
|
36208
|
+
"error"
|
|
36209
|
+
]);
|
|
36210
|
+
var HostBotAuditEventFrameSchema = exports_external.object({
|
|
36211
|
+
type: exports_external.literal("bot_audit_event"),
|
|
36212
|
+
eventId: exports_external.string().min(1).max(128).optional(),
|
|
36213
|
+
occurredAt: exports_external.string().datetime({ offset: true }).optional(),
|
|
36214
|
+
agentId: exports_external.string().min(1),
|
|
36215
|
+
sessionId: exports_external.string().nullable().optional(),
|
|
36216
|
+
launchId: exports_external.string().nullable().optional(),
|
|
36217
|
+
event: BotAuditEventSchema
|
|
36218
|
+
}).superRefine((frame, ctx) => {
|
|
36219
|
+
if (frame.event.kind === "session_reset" && frame.event.payload.trigger === "idle_timeout" && (!frame.eventId || !frame.occurredAt)) {
|
|
36220
|
+
if (!frame.eventId) {
|
|
36221
|
+
ctx.addIssue({
|
|
36222
|
+
code: "custom",
|
|
36223
|
+
path: ["eventId"],
|
|
36224
|
+
message: "eventId is required for idle_timeout session_reset"
|
|
36225
|
+
});
|
|
36226
|
+
}
|
|
36227
|
+
if (!frame.occurredAt) {
|
|
36228
|
+
ctx.addIssue({
|
|
36229
|
+
code: "custom",
|
|
36230
|
+
path: ["occurredAt"],
|
|
36231
|
+
message: "occurredAt is required for idle_timeout session_reset"
|
|
36232
|
+
});
|
|
36233
|
+
}
|
|
36234
|
+
}
|
|
36235
|
+
});
|
|
36236
|
+
var BotAuditEventAckFrameSchema = exports_external.strictObject({
|
|
36237
|
+
type: exports_external.literal("bot_audit_event_ack"),
|
|
36238
|
+
eventId: exports_external.string().min(1).max(128)
|
|
36239
|
+
});
|
|
36240
|
+
|
|
36241
|
+
// ../shared/src/community-bot-creation.ts
|
|
36242
|
+
var BOT_CREATION_MAX_ITEMS = 20;
|
|
36243
|
+
var BotCreationProposalSchema = exports_external.strictObject({
|
|
36244
|
+
...CommunityBotCreateRequestSchema.omit({ runtime: true, image: true }).shape,
|
|
36245
|
+
backendId: exports_external.string().min(1).max(64),
|
|
36246
|
+
reason: exports_external.string().trim().min(1).max(1000)
|
|
36247
|
+
});
|
|
36248
|
+
var BotCreationSubmitSchema = exports_external.strictObject({
|
|
36249
|
+
requestId: exports_external.string().min(1).max(128),
|
|
36250
|
+
bots: exports_external.array(BotCreationProposalSchema).min(1).max(BOT_CREATION_MAX_ITEMS)
|
|
36251
|
+
});
|
|
36252
|
+
var BotCreationIdentitySchema = exports_external.strictObject({
|
|
36253
|
+
id: exports_external.string(),
|
|
36254
|
+
name: exports_external.string(),
|
|
36255
|
+
discriminator: exports_external.string(),
|
|
36256
|
+
image: exports_external.string().nullable(),
|
|
36257
|
+
avatarVersion: exports_external.number().int().nonnegative()
|
|
36258
|
+
});
|
|
36259
|
+
var BotCreationItemSchema = BotCreationProposalSchema.extend({
|
|
36260
|
+
itemId: exports_external.string(),
|
|
36261
|
+
description: exports_external.string(),
|
|
36262
|
+
model: exports_external.string().nullable(),
|
|
36263
|
+
reasoningEffort: exports_external.string().nullable(),
|
|
36264
|
+
machineName: exports_external.string(),
|
|
36265
|
+
createdBot: BotCreationIdentitySchema.nullable()
|
|
36266
|
+
});
|
|
36267
|
+
var BotCreationPayloadSchema = exports_external.strictObject({
|
|
36268
|
+
requestId: exports_external.string(),
|
|
36269
|
+
status: exports_external.enum(["pending", "approved", "declined"]),
|
|
36270
|
+
requesterId: exports_external.string(),
|
|
36271
|
+
ownerUserId: exports_external.string(),
|
|
36272
|
+
createdAt: exports_external.string(),
|
|
36273
|
+
resolvedAt: exports_external.string().nullable(),
|
|
36274
|
+
bots: exports_external.array(BotCreationItemSchema).min(1).max(BOT_CREATION_MAX_ITEMS)
|
|
36275
|
+
});
|
|
36276
|
+
var BotCreationDecisionSchema = exports_external.strictObject({ decision: exports_external.enum(["approve", "decline"]) });
|
|
36277
|
+
|
|
36278
|
+
// ../shared/src/community-resources.ts
|
|
36279
|
+
var id = exports_external.string().min(1);
|
|
36280
|
+
var nullableId = id.nullable();
|
|
36281
|
+
var legacyArchivedSchema = exports_external.union([exports_external.boolean(), exports_external.literal(0), exports_external.literal(1)]).transform((value) => value === true || value === 1);
|
|
36282
|
+
var CommunityChannelResourceSchema = exports_external.strictObject({
|
|
36283
|
+
id,
|
|
36284
|
+
type: exports_external.enum(["text", "forum", "thread", "dm"]),
|
|
36285
|
+
serverId: nullableId,
|
|
36286
|
+
categoryId: nullableId,
|
|
36287
|
+
name: exports_external.string().nullable(),
|
|
36288
|
+
topic: exports_external.string(),
|
|
36289
|
+
parentChannelId: nullableId,
|
|
36290
|
+
parentMessageId: nullableId,
|
|
36291
|
+
creatorId: nullableId,
|
|
36292
|
+
position: exports_external.number(),
|
|
36293
|
+
archived: exports_external.boolean(),
|
|
36294
|
+
createdAt: exports_external.string(),
|
|
36295
|
+
lastMessageAt: exports_external.string().nullable(),
|
|
36296
|
+
messageCount: exports_external.number().int().nonnegative()
|
|
36297
|
+
});
|
|
36298
|
+
var CommunityChannelIdentitySchema = CommunityChannelResourceSchema.pick({
|
|
36299
|
+
id: true,
|
|
36300
|
+
type: true,
|
|
36301
|
+
serverId: true,
|
|
36302
|
+
name: true,
|
|
36303
|
+
parentChannelId: true,
|
|
36304
|
+
parentMessageId: true,
|
|
36305
|
+
creatorId: true,
|
|
36306
|
+
archived: true,
|
|
36307
|
+
lastMessageAt: true,
|
|
36308
|
+
createdAt: true
|
|
36309
|
+
}).partial({ createdAt: true }).strip();
|
|
36310
|
+
var legacyChannelIdentitySchema = CommunityChannelIdentitySchema.extend({
|
|
36311
|
+
archived: legacyArchivedSchema,
|
|
36312
|
+
parentChannelId: nullableId.default(null),
|
|
36313
|
+
parentMessageId: nullableId.default(null),
|
|
36314
|
+
creatorId: nullableId.default(null),
|
|
36315
|
+
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null)
|
|
36316
|
+
});
|
|
36317
|
+
var CommunityAccessDecisionSchema = exports_external.strictObject({
|
|
36318
|
+
channelId: id,
|
|
36319
|
+
canRead: exports_external.boolean(),
|
|
36320
|
+
canSend: exports_external.boolean(),
|
|
36321
|
+
canCreateDiscussion: exports_external.boolean()
|
|
36322
|
+
});
|
|
36323
|
+
var CommunityLegacyMessageAttachmentSchema = exports_external.strictObject({
|
|
36324
|
+
kind: exports_external.enum(["image", "file"]),
|
|
36325
|
+
name: exports_external.string(),
|
|
36326
|
+
url: exports_external.string(),
|
|
36327
|
+
thumbnailUrl: exports_external.string().optional(),
|
|
36328
|
+
contentType: exports_external.string().optional(),
|
|
36329
|
+
size: exports_external.string().optional(),
|
|
36330
|
+
sizeBytes: exports_external.number().nonnegative().optional(),
|
|
36331
|
+
width: exports_external.number().nonnegative().optional(),
|
|
36332
|
+
height: exports_external.number().nonnegative().optional()
|
|
36333
|
+
});
|
|
36334
|
+
var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
36335
|
+
id,
|
|
36336
|
+
name: exports_external.string(),
|
|
36337
|
+
url: exports_external.string(),
|
|
36338
|
+
thumbnailUrl: exports_external.string().nullable(),
|
|
36339
|
+
contentType: exports_external.string().nullable(),
|
|
36340
|
+
sizeBytes: exports_external.number().int().nonnegative().nullable(),
|
|
36341
|
+
width: exports_external.number().int().nonnegative().nullable(),
|
|
36342
|
+
height: exports_external.number().int().nonnegative().nullable()
|
|
36343
|
+
});
|
|
36344
|
+
var CommunityMessagePreviewAttachmentSchema = CommunityMessageAttachmentSchema.partial().required({ name: true, url: true });
|
|
36345
|
+
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
36346
|
+
id,
|
|
36347
|
+
name: exports_external.string(),
|
|
36348
|
+
discriminator: exports_external.string().min(1).nullable(),
|
|
36349
|
+
avatar: exports_external.string().nullable(),
|
|
36350
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
36351
|
+
aboutMe: exports_external.string().optional(),
|
|
36352
|
+
bannerColor: exports_external.string().nullable().optional(),
|
|
36353
|
+
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
36354
|
+
ownerUserId: nullableId.optional(),
|
|
36355
|
+
ownerHandle: exports_external.string().nullable().optional(),
|
|
36356
|
+
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
36357
|
+
ownedByViewer: exports_external.boolean().optional(),
|
|
36358
|
+
statusEmoji: exports_external.string().nullable().optional(),
|
|
36359
|
+
statusText: exports_external.string().nullable().optional()
|
|
36360
|
+
});
|
|
36361
|
+
var CommunityMessageThreadParticipantSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatar: true, avatarVersion: true });
|
|
36362
|
+
var messageThreadSchema = exports_external.strictObject({
|
|
36363
|
+
id,
|
|
36364
|
+
name: CommunityChannelResourceSchema.shape.name,
|
|
36365
|
+
messageCount: CommunityChannelResourceSchema.shape.messageCount,
|
|
36366
|
+
lastReplyAt: CommunityChannelResourceSchema.shape.lastMessageAt.optional(),
|
|
36367
|
+
tags: exports_external.array(exports_external.string()).optional(),
|
|
36368
|
+
preview: exports_external.string().optional(),
|
|
36369
|
+
participants: exports_external.array(CommunityMessageThreadParticipantSchema).optional(),
|
|
36370
|
+
participantCount: exports_external.number().int().nonnegative().optional()
|
|
36371
|
+
});
|
|
36372
|
+
var legacyMessageThreadSchema = messageThreadSchema.extend({
|
|
36373
|
+
name: exports_external.string(),
|
|
36374
|
+
lastReplyAt: exports_external.string().optional(),
|
|
36375
|
+
participants: exports_external.array(CommunityMessageThreadParticipantSchema.extend({ avatar: exports_external.string() })).optional()
|
|
36376
|
+
});
|
|
36377
|
+
var messageThreadPreviewSchema = messageThreadSchema.partial().required({ id: true }).extend({
|
|
36378
|
+
participants: exports_external.array(CommunityMessageThreadParticipantSchema.partial().required({ id: true })).optional()
|
|
36379
|
+
});
|
|
36380
|
+
var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
36381
|
+
id,
|
|
36382
|
+
channelId: id,
|
|
36383
|
+
seq: exports_external.number().int().nonnegative(),
|
|
36384
|
+
authorId: id,
|
|
36385
|
+
createdAt: exports_external.string(),
|
|
36386
|
+
type: exports_external.enum(["chat", "system"]),
|
|
36387
|
+
content: exports_external.string(),
|
|
36388
|
+
replyToId: nullableId,
|
|
36389
|
+
clientNonce: exports_external.string().nullable(),
|
|
36390
|
+
attachments: exports_external.array(CommunityMessageAttachmentSchema),
|
|
36391
|
+
systemKind: exports_external.literal("thread").optional(),
|
|
36392
|
+
authorName: exports_external.string().optional(),
|
|
36393
|
+
authorAvatar: exports_external.string().nullable().optional(),
|
|
36394
|
+
authorAvatarVersion: exports_external.number().int().nonnegative().optional(),
|
|
36395
|
+
mentionType: exports_external.literal("everyone").nullable().optional(),
|
|
36396
|
+
replyTo: exports_external.strictObject({
|
|
36397
|
+
id,
|
|
36398
|
+
authorId: id.optional(),
|
|
36399
|
+
authorName: exports_external.string(),
|
|
36400
|
+
text: exports_external.string(),
|
|
36401
|
+
deleted: exports_external.boolean().optional()
|
|
36402
|
+
}).optional(),
|
|
36403
|
+
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
36404
|
+
reactions: exports_external.array(exports_external.strictObject({
|
|
36405
|
+
emoji: exports_external.string(),
|
|
36406
|
+
count: exports_external.number().int().nonnegative(),
|
|
36407
|
+
me: exports_external.boolean(),
|
|
36408
|
+
userIds: exports_external.array(id)
|
|
36409
|
+
})).optional(),
|
|
36410
|
+
thread: messageThreadSchema.optional(),
|
|
36411
|
+
approval: FriendApprovalPayloadSchema.optional(),
|
|
36412
|
+
botCreation: BotCreationPayloadSchema.optional()
|
|
36413
|
+
});
|
|
36414
|
+
var CommunityMessagePreviewSchema = CommunityMessageResourceSchema.partial().required({
|
|
36415
|
+
id: true,
|
|
36416
|
+
type: true
|
|
36417
|
+
}).extend({ attachments: exports_external.array(CommunityMessagePreviewAttachmentSchema).optional(), thread: messageThreadPreviewSchema.optional() });
|
|
36418
|
+
var CommunityReadStateResourceSchema = exports_external.strictObject({
|
|
36419
|
+
channelId: id,
|
|
36420
|
+
lastReadMessageId: nullableId,
|
|
36421
|
+
lastReadAt: exports_external.string().nullable(),
|
|
36422
|
+
lastReadSeq: exports_external.number().int().nonnegative()
|
|
36423
|
+
});
|
|
36424
|
+
var CommunityMemberRelationSchema = exports_external.strictObject({
|
|
36425
|
+
channelId: id,
|
|
36426
|
+
userId: id,
|
|
36427
|
+
relation: exports_external.enum(["access", "notify"]),
|
|
36428
|
+
source: exports_external.string(),
|
|
36429
|
+
isCreator: exports_external.boolean(),
|
|
36430
|
+
role: exports_external.string().nullable(),
|
|
36431
|
+
memberId: nullableId
|
|
36432
|
+
});
|
|
36433
|
+
var CommunityPageSchema = exports_external.strictObject({
|
|
36434
|
+
olderCursor: exports_external.string().nullable(),
|
|
36435
|
+
newerCursor: exports_external.string().nullable(),
|
|
36436
|
+
hasMoreOlder: exports_external.boolean(),
|
|
36437
|
+
hasMoreNewer: exports_external.boolean(),
|
|
36438
|
+
latestSeq: exports_external.number().int().nonnegative()
|
|
36439
|
+
});
|
|
36440
|
+
var envelope = { contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), channelId: id };
|
|
36441
|
+
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
36442
|
+
var CommunityMessagesReadSchema = exports_external.strictObject({
|
|
36443
|
+
...envelope,
|
|
36444
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
36445
|
+
page: CommunityPageSchema,
|
|
36446
|
+
surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
|
|
36447
|
+
});
|
|
36448
|
+
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
36449
|
+
viewerId: id,
|
|
36450
|
+
peer: CommunityResourceProfileSchema.nullable(),
|
|
36451
|
+
channel: CommunityChannelResourceSchema,
|
|
36452
|
+
access: CommunityAccessDecisionSchema.extend({ canRead: exports_external.literal(true) }),
|
|
36453
|
+
readState: CommunityReadStateResourceSchema,
|
|
36454
|
+
readStateRevision: exports_external.number().int().nonnegative(),
|
|
36455
|
+
forumFeed: exports_external.lazy(() => CommunityThreadsReadSchema).optional(),
|
|
36456
|
+
opener: CommunityMessageResourceSchema.optional(),
|
|
36457
|
+
parent: CommunityChannelResourceSchema.optional(),
|
|
36458
|
+
selection: exports_external.strictObject({
|
|
36459
|
+
reason: exports_external.enum(["explicit_anchor", "read_pointer", "tail", "read_pointer_missing"]),
|
|
36460
|
+
anchorMessageId: nullableId
|
|
36461
|
+
})
|
|
36462
|
+
}).superRefine((entry, ctx) => {
|
|
36463
|
+
for (const [path13, channelId] of [
|
|
36464
|
+
[["channel", "id"], entry.channel.id],
|
|
36465
|
+
[["access", "channelId"], entry.access.channelId],
|
|
36466
|
+
[["readState", "channelId"], entry.readState.channelId],
|
|
36467
|
+
[["surfaceReceipt", "channelId"], entry.surfaceReceipt.channelId],
|
|
36468
|
+
...entry.messages.map((message2, index2) => [["messages", index2, "channelId"], message2.channelId])
|
|
36469
|
+
]) {
|
|
36470
|
+
if (channelId !== entry.channelId)
|
|
36471
|
+
ctx.addIssue({ code: "custom", path: [...path13], message: "Conversation entry scope mismatch" });
|
|
36472
|
+
}
|
|
36473
|
+
if (entry.channel.type === "dm" !== (entry.peer !== null) || entry.peer?.id === entry.viewerId)
|
|
36474
|
+
ctx.addIssue({ code: "custom", path: ["peer"], message: "Conversation entry peer mismatch" });
|
|
36475
|
+
if (entry.opener && (entry.channel.type !== "thread" || entry.opener.id !== entry.channel.parentMessageId || entry.opener.channelId !== entry.channel.parentChannelId))
|
|
36476
|
+
ctx.addIssue({ code: "custom", path: ["opener"], message: "Conversation entry opener scope mismatch" });
|
|
36477
|
+
if (entry.parent && (entry.channel.type !== "thread" || entry.parent.id !== entry.channel.parentChannelId || entry.parent.serverId !== entry.channel.serverId || entry.parent.type !== "text" && entry.parent.type !== "forum"))
|
|
36478
|
+
ctx.addIssue({ code: "custom", path: ["parent"], message: "Conversation entry parent scope mismatch" });
|
|
36479
|
+
if (entry.forumFeed && (entry.channel.type !== "forum" || entry.forumFeed.channelId !== entry.channelId || entry.forumFeed.channel.id !== entry.channelId || entry.forumFeed.channel.serverId !== entry.channel.serverId || entry.forumFeed.threads.some((thread) => thread.parentChannelId !== entry.channelId || thread.serverId !== entry.channel.serverId)))
|
|
36480
|
+
ctx.addIssue({ code: "custom", path: ["forumFeed"], message: "Conversation entry forum scope mismatch" });
|
|
36481
|
+
if (entry.forumFeed) {
|
|
36482
|
+
const feed = entry.forumFeed, children = new Set(feed.threads.map((thread) => thread.id)), profiles = new Set(feed.included.profiles.map((profile2) => profile2.id));
|
|
36483
|
+
const openers = new Set(feed.threads.flatMap((thread) => thread.parentMessageId ? [thread.parentMessageId] : []));
|
|
36484
|
+
if (feed.included.messages.some((message2) => message2.channelId !== entry.channelId && !children.has(message2.channelId)) || feed.included.tags.some((row) => !openers.has(row.messageId)) || feed.included.participantCounts.some((row) => !children.has(row.channelId)) || feed.included.members.some((member2) => !children.has(member2.channelId) || member2.relation !== "notify" || !profiles.has(member2.userId)))
|
|
36485
|
+
ctx.addIssue({ code: "custom", path: ["forumFeed", "included"], message: "Conversation entry forum included scope mismatch" });
|
|
36486
|
+
}
|
|
36487
|
+
const surfaceKind = entry.channel.type === "text" ? "channel" : entry.channel.type;
|
|
36488
|
+
if (entry.surfaceReceipt.surfaceKind !== surfaceKind)
|
|
36489
|
+
ctx.addIssue({ code: "custom", path: ["surfaceReceipt", "surfaceKind"], message: "Conversation entry surface mismatch" });
|
|
36490
|
+
if (entry.channel.archived)
|
|
36491
|
+
ctx.addIssue({ code: "custom", path: ["channel", "archived"], message: "Conversation entry is archived" });
|
|
36492
|
+
const anchored = entry.selection.reason === "explicit_anchor" || entry.selection.reason === "read_pointer";
|
|
36493
|
+
if (anchored !== (entry.selection.anchorMessageId !== null))
|
|
36494
|
+
ctx.addIssue({ code: "custom", path: ["selection"], message: "Conversation entry selection mismatch" });
|
|
36495
|
+
if (entry.selection.reason === "read_pointer" && entry.selection.anchorMessageId !== entry.readState.lastReadMessageId)
|
|
36496
|
+
ctx.addIssue({ code: "custom", path: ["selection", "anchorMessageId"], message: "Conversation entry read pointer mismatch" });
|
|
36497
|
+
if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
|
|
36498
|
+
ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
|
|
36499
|
+
});
|
|
36500
|
+
var CommunityMessagePostedSchema = CommunityMessagesReadSchema.pick({ contractVersion: true, channelId: true }).extend({
|
|
36501
|
+
message: CommunityMessageResourceSchema,
|
|
36502
|
+
deduped: exports_external.boolean(),
|
|
36503
|
+
threadId: id.optional()
|
|
36625
36504
|
});
|
|
36626
|
-
var
|
|
36627
|
-
|
|
36628
|
-
|
|
36629
|
-
|
|
36630
|
-
|
|
36631
|
-
|
|
36632
|
-
|
|
36633
|
-
|
|
36634
|
-
|
|
36635
|
-
|
|
36505
|
+
var CommunityMessageReadSchema = CommunityMessagePostedSchema.omit({ deduped: true, threadId: true });
|
|
36506
|
+
var CommunityMembersReadSchema = exports_external.strictObject({ ...envelope, relation: exports_external.enum(["access", "notify"]), members: exports_external.array(CommunityMemberRelationSchema), profiles: exports_external.array(CommunityResourceProfileSchema) });
|
|
36507
|
+
var CommunityThreadsReadSchema = exports_external.strictObject({
|
|
36508
|
+
...envelope,
|
|
36509
|
+
channel: CommunityChannelResourceSchema,
|
|
36510
|
+
threads: exports_external.array(CommunityChannelResourceSchema),
|
|
36511
|
+
included: exports_external.strictObject({
|
|
36512
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
36513
|
+
members: exports_external.array(CommunityMemberRelationSchema),
|
|
36514
|
+
profiles: exports_external.array(CommunityResourceProfileSchema),
|
|
36515
|
+
tags: exports_external.array(exports_external.strictObject({ messageId: id, tag: exports_external.string() })),
|
|
36516
|
+
participantCounts: exports_external.array(exports_external.strictObject({ channelId: id, count: exports_external.number().int().nonnegative() }))
|
|
36517
|
+
}),
|
|
36518
|
+
page: exports_external.strictObject({ nextCursor: exports_external.string().nullable(), hasMore: exports_external.boolean() })
|
|
36636
36519
|
});
|
|
36637
|
-
var
|
|
36638
|
-
|
|
36520
|
+
var CommunityReadAdvanceSchema = exports_external.strictObject({ ...envelope, changed: exports_external.boolean(), targetSeq: exports_external.number().int().nonnegative(), revision: exports_external.number().int().nonnegative() });
|
|
36521
|
+
var CommunityReadErrorSchema = exports_external.strictObject({ contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), error: exports_external.strictObject({
|
|
36522
|
+
code: exports_external.enum(["invalid_input", "invalid_reply_target", "unauthenticated", "not_found", "not_allowed", "blocked", "idempotency_conflict", "rate_limited", "temporarily_unavailable"]),
|
|
36523
|
+
message: exports_external.string(),
|
|
36524
|
+
retryable: exports_external.boolean()
|
|
36525
|
+
}) });
|
|
36526
|
+
var legacyProfileSchema = CommunityResourceProfileSchema.pick({
|
|
36527
|
+
id: true,
|
|
36528
|
+
name: true,
|
|
36529
|
+
avatar: true,
|
|
36530
|
+
avatarVersion: true
|
|
36531
|
+
}).extend({ discriminator: exports_external.string().nullable(), statusEmoji: exports_external.string().nullable(), statusText: exports_external.string() });
|
|
36532
|
+
var CommunityLegacyMessageResourceSchema = CommunityMessageResourceSchema.extend({ authorAvatar: exports_external.string().optional(), attachments: exports_external.array(CommunityLegacyMessageAttachmentSchema), thread: legacyMessageThreadSchema.optional() });
|
|
36533
|
+
var legacyEnvelope = { contractVersion: exports_external.literal(2), channelId: id };
|
|
36534
|
+
var legacyReadSchemas = {
|
|
36535
|
+
channel: CommunityChannelReadSchema.extend(legacyEnvelope),
|
|
36536
|
+
messages: CommunityMessagesReadSchema.extend({ ...legacyEnvelope, messages: exports_external.array(CommunityLegacyMessageResourceSchema) }),
|
|
36537
|
+
members: CommunityMembersReadSchema.extend({ ...legacyEnvelope, profiles: exports_external.array(legacyProfileSchema) }),
|
|
36538
|
+
threads: CommunityThreadsReadSchema.extend({ ...legacyEnvelope, included: CommunityThreadsReadSchema.shape.included.extend({
|
|
36539
|
+
messages: exports_external.array(CommunityLegacyMessageResourceSchema),
|
|
36540
|
+
profiles: exports_external.array(legacyProfileSchema)
|
|
36541
|
+
}) }),
|
|
36542
|
+
readAdvance: CommunityReadAdvanceSchema.extend(legacyEnvelope),
|
|
36543
|
+
error: CommunityReadErrorSchema.extend({ contractVersion: exports_external.literal(2) })
|
|
36544
|
+
};
|
|
36545
|
+
var legacyChannelResourcePreviewSchema = CommunityChannelResourceSchema.partial().strip().extend({
|
|
36546
|
+
archived: legacyArchivedSchema.optional()
|
|
36639
36547
|
});
|
|
36640
|
-
var
|
|
36641
|
-
|
|
36642
|
-
|
|
36643
|
-
|
|
36548
|
+
var legacyChannelResourceSchema = CommunityChannelResourceSchema.strip().extend({
|
|
36549
|
+
topic: CommunityChannelResourceSchema.shape.topic.nullish().transform((value) => value ?? ""),
|
|
36550
|
+
position: CommunityChannelResourceSchema.shape.position.nullish().transform((value) => value ?? 0),
|
|
36551
|
+
messageCount: CommunityChannelResourceSchema.shape.messageCount.nullish().transform((value) => value ?? 0),
|
|
36552
|
+
categoryId: nullableId.default(null),
|
|
36553
|
+
parentChannelId: nullableId.default(null),
|
|
36554
|
+
parentMessageId: nullableId.default(null),
|
|
36555
|
+
creatorId: nullableId.default(null),
|
|
36556
|
+
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null),
|
|
36557
|
+
archived: legacyArchivedSchema
|
|
36644
36558
|
});
|
|
36645
|
-
var
|
|
36646
|
-
|
|
36647
|
-
|
|
36559
|
+
var legacyMessageResourceSchema = CommunityLegacyMessageResourceSchema.strip().extend({
|
|
36560
|
+
channelId: id.optional(),
|
|
36561
|
+
replyToId: nullableId.optional(),
|
|
36562
|
+
clientNonce: CommunityMessageResourceSchema.shape.clientNonce.default(null),
|
|
36563
|
+
attachments: CommunityLegacyMessageResourceSchema.shape.attachments.default([]),
|
|
36564
|
+
embeds: CommunityMessageResourceSchema.shape.embeds.nullable().transform((value) => value ?? undefined)
|
|
36648
36565
|
});
|
|
36649
|
-
|
|
36650
|
-
|
|
36566
|
+
|
|
36567
|
+
// ../shared/src/community-attention.ts
|
|
36568
|
+
var id2 = exports_external.string().min(1);
|
|
36569
|
+
var AttentionScopeSchema = exports_external.strictObject({
|
|
36570
|
+
scopeId: id2,
|
|
36571
|
+
channelId: id2,
|
|
36572
|
+
serverId: id2.nullable().optional(),
|
|
36573
|
+
parentChannelId: id2.nullable().optional(),
|
|
36574
|
+
ordinaryUnread: exports_external.boolean(),
|
|
36575
|
+
lastUnreadSeq: exports_external.number().int().nonnegative(),
|
|
36576
|
+
unreadCount: exports_external.number().int().nonnegative().optional(),
|
|
36577
|
+
lastAttentionSeq: exports_external.number().int().nonnegative().nullable().optional(),
|
|
36578
|
+
attentionCount: exports_external.number().int().nonnegative()
|
|
36651
36579
|
});
|
|
36652
|
-
var
|
|
36653
|
-
|
|
36654
|
-
|
|
36580
|
+
var AttentionItemSchema = exports_external.strictObject({
|
|
36581
|
+
id: id2,
|
|
36582
|
+
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post"]),
|
|
36583
|
+
sourceId: id2,
|
|
36584
|
+
scopeId: id2.nullable().optional(),
|
|
36585
|
+
messageId: id2.nullable().optional(),
|
|
36586
|
+
actorUserId: id2.nullable().optional(),
|
|
36587
|
+
createdAt: exports_external.string(),
|
|
36588
|
+
childChannelId: id2.optional(),
|
|
36589
|
+
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
36590
|
+
readTarget: exports_external.strictObject({
|
|
36591
|
+
channelId: id2,
|
|
36592
|
+
seq: exports_external.number().int().nonnegative()
|
|
36655
36593
|
}).optional()
|
|
36594
|
+
}).superRefine((item, ctx) => {
|
|
36595
|
+
if (item.kind === "friend_request") {
|
|
36596
|
+
if (!item.actorUserId || item.scopeId != null || item.messageId != null) {
|
|
36597
|
+
ctx.addIssue({ code: "custom", message: "friend request cannot reference a scope or message" });
|
|
36598
|
+
}
|
|
36599
|
+
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
36600
|
+
ctx.addIssue({ code: "custom", message: "friend request cannot carry forum presentation refs" });
|
|
36601
|
+
}
|
|
36602
|
+
return;
|
|
36603
|
+
}
|
|
36604
|
+
if (!item.scopeId || !item.messageId) {
|
|
36605
|
+
ctx.addIssue({ code: "custom", message: "message attention requires scope and message refs" });
|
|
36606
|
+
}
|
|
36607
|
+
if (item.kind === "forum_post") {
|
|
36608
|
+
if (item.actorUserId != null || !item.childChannelId || item.openerSeq === undefined || !item.readTarget || item.sourceId !== item.childChannelId || item.readTarget.seq !== item.openerSeq) {
|
|
36609
|
+
ctx.addIssue({ code: "custom", message: "forum post requires exact child, opener, and read-target refs" });
|
|
36610
|
+
}
|
|
36611
|
+
return;
|
|
36612
|
+
}
|
|
36613
|
+
if (!item.actorUserId) {
|
|
36614
|
+
ctx.addIssue({ code: "custom", message: "message attention requires an actor" });
|
|
36615
|
+
}
|
|
36616
|
+
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
36617
|
+
ctx.addIssue({ code: "custom", message: "mention or reply cannot carry forum presentation refs" });
|
|
36618
|
+
}
|
|
36656
36619
|
});
|
|
36657
|
-
var
|
|
36658
|
-
|
|
36659
|
-
|
|
36660
|
-
|
|
36620
|
+
var AttentionIncludedServerSchema = exports_external.strictObject({
|
|
36621
|
+
id: id2,
|
|
36622
|
+
name: exports_external.string(),
|
|
36623
|
+
discriminator: exports_external.string()
|
|
36661
36624
|
});
|
|
36662
|
-
var
|
|
36663
|
-
|
|
36625
|
+
var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
36626
|
+
id: true,
|
|
36627
|
+
serverId: true,
|
|
36628
|
+
name: true,
|
|
36629
|
+
type: true,
|
|
36630
|
+
parentChannelId: true,
|
|
36631
|
+
parentMessageId: true,
|
|
36632
|
+
creatorId: true,
|
|
36633
|
+
archived: true,
|
|
36634
|
+
lastMessageAt: true
|
|
36635
|
+
}).extend({
|
|
36636
|
+
serverId: CommunityChannelResourceSchema.shape.serverId.unwrap(),
|
|
36637
|
+
name: CommunityChannelResourceSchema.shape.name.unwrap(),
|
|
36638
|
+
type: CommunityChannelResourceSchema.shape.type.extract(["text", "forum", "thread"]),
|
|
36639
|
+
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
36640
|
+
openerUnread: exports_external.boolean().optional()
|
|
36664
36641
|
});
|
|
36665
|
-
var
|
|
36666
|
-
|
|
36667
|
-
|
|
36668
|
-
|
|
36642
|
+
var AttentionIncludedDmSchema = exports_external.strictObject({
|
|
36643
|
+
id: id2,
|
|
36644
|
+
userId: id2,
|
|
36645
|
+
name: exports_external.string(),
|
|
36646
|
+
discriminator: exports_external.string(),
|
|
36647
|
+
avatar: exports_external.string(),
|
|
36648
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
36649
|
+
lastMessageAt: exports_external.string(),
|
|
36650
|
+
lastUnreadSeq: exports_external.number().int().nonnegative()
|
|
36669
36651
|
});
|
|
36670
|
-
var
|
|
36671
|
-
|
|
36672
|
-
|
|
36652
|
+
var AttentionIncludedProfileSchema = exports_external.strictObject({
|
|
36653
|
+
userId: CommunityResourceProfileSchema.shape.id,
|
|
36654
|
+
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
36655
|
+
discriminator: exports_external.string(),
|
|
36656
|
+
avatar: exports_external.string()
|
|
36673
36657
|
});
|
|
36674
|
-
var
|
|
36675
|
-
|
|
36676
|
-
|
|
36677
|
-
|
|
36658
|
+
var AttentionIncludedMessageSchema = CommunityMessagePreviewSchema.pick({
|
|
36659
|
+
id: true,
|
|
36660
|
+
channelId: true,
|
|
36661
|
+
type: true,
|
|
36662
|
+
authorId: true,
|
|
36663
|
+
authorName: true,
|
|
36664
|
+
seq: true,
|
|
36665
|
+
createdAt: true,
|
|
36666
|
+
content: true
|
|
36667
|
+
}).required({ channelId: true, seq: true, createdAt: true, content: true });
|
|
36668
|
+
var AttentionIncludedSchema = exports_external.strictObject({
|
|
36669
|
+
servers: exports_external.array(AttentionIncludedServerSchema),
|
|
36670
|
+
channels: exports_external.array(AttentionIncludedChannelSchema),
|
|
36671
|
+
dms: exports_external.array(AttentionIncludedDmSchema),
|
|
36672
|
+
profiles: exports_external.array(AttentionIncludedProfileSchema),
|
|
36673
|
+
messages: exports_external.array(AttentionIncludedMessageSchema)
|
|
36678
36674
|
});
|
|
36679
|
-
var
|
|
36680
|
-
|
|
36675
|
+
var AccountAttentionSnapshotSchema = exports_external.strictObject({
|
|
36676
|
+
scopes: exports_external.array(AttentionScopeSchema),
|
|
36677
|
+
items: exports_external.array(AttentionItemSchema),
|
|
36678
|
+
limit: exports_external.number().int().positive(),
|
|
36681
36679
|
truncated: exports_external.boolean(),
|
|
36682
|
-
|
|
36680
|
+
included: AttentionIncludedSchema
|
|
36681
|
+
}).superRefine((snapshot, ctx) => {
|
|
36682
|
+
const scopeIds = new Set;
|
|
36683
|
+
for (const scope of snapshot.scopes) {
|
|
36684
|
+
if (scopeIds.has(scope.scopeId)) {
|
|
36685
|
+
ctx.addIssue({ code: "custom", message: `duplicate attention scope: ${scope.scopeId}` });
|
|
36686
|
+
}
|
|
36687
|
+
scopeIds.add(scope.scopeId);
|
|
36688
|
+
}
|
|
36689
|
+
const itemIds = new Set;
|
|
36690
|
+
const serverById = new Map(snapshot.included.servers.map((server) => [server.id, server]));
|
|
36691
|
+
const channelById = new Map(snapshot.included.channels.map((channel2) => [channel2.id, channel2]));
|
|
36692
|
+
const dmById = new Map(snapshot.included.dms.map((dm) => [dm.id, dm]));
|
|
36693
|
+
const profileById = new Map(snapshot.included.profiles.map((profile2) => [profile2.userId, profile2]));
|
|
36694
|
+
const messageById = new Map(snapshot.included.messages.map((message2) => [message2.id, message2]));
|
|
36695
|
+
const rejectDuplicates = (values, kind) => {
|
|
36696
|
+
const seen = new Set;
|
|
36697
|
+
for (const value of values) {
|
|
36698
|
+
if (seen.has(value))
|
|
36699
|
+
ctx.addIssue({ code: "custom", message: `duplicate included ${kind}: ${value}` });
|
|
36700
|
+
seen.add(value);
|
|
36701
|
+
}
|
|
36702
|
+
};
|
|
36703
|
+
rejectDuplicates(snapshot.included.servers.map((server) => server.id), "server");
|
|
36704
|
+
rejectDuplicates(snapshot.included.channels.map((channel2) => channel2.id), "channel");
|
|
36705
|
+
rejectDuplicates(snapshot.included.dms.map((dm) => dm.id), "dm");
|
|
36706
|
+
rejectDuplicates(snapshot.included.profiles.map((profile2) => profile2.userId), "profile");
|
|
36707
|
+
rejectDuplicates(snapshot.included.messages.map((message2) => message2.id), "message");
|
|
36708
|
+
for (const scope of snapshot.scopes) {
|
|
36709
|
+
if (scope.serverId) {
|
|
36710
|
+
const channel2 = channelById.get(scope.channelId);
|
|
36711
|
+
if (!serverById.has(scope.serverId) || !channel2 || channel2.serverId !== scope.serverId) {
|
|
36712
|
+
ctx.addIssue({ code: "custom", message: `attention scope references missing owner: ${scope.scopeId}` });
|
|
36713
|
+
continue;
|
|
36714
|
+
}
|
|
36715
|
+
if (scope.parentChannelId) {
|
|
36716
|
+
const parent = channelById.get(scope.parentChannelId);
|
|
36717
|
+
const opener = channel2.parentMessageId ? messageById.get(channel2.parentMessageId) : undefined;
|
|
36718
|
+
if (channel2.parentChannelId !== scope.parentChannelId || !parent || parent.serverId !== scope.serverId || !opener || opener.channelId !== parent.id || channel2.openerSeq !== opener.seq || channel2.openerUnread === undefined) {
|
|
36719
|
+
ctx.addIssue({ code: "custom", message: `attention scope references missing parent: ${scope.scopeId}` });
|
|
36720
|
+
}
|
|
36721
|
+
} else if (channel2.parentChannelId !== null) {
|
|
36722
|
+
ctx.addIssue({ code: "custom", message: `attention scope parent mismatch: ${scope.scopeId}` });
|
|
36723
|
+
}
|
|
36724
|
+
} else {
|
|
36725
|
+
const dm = dmById.get(scope.channelId);
|
|
36726
|
+
if (!dm || !profileById.has(dm.userId)) {
|
|
36727
|
+
ctx.addIssue({ code: "custom", message: `attention scope references missing DM owner: ${scope.scopeId}` });
|
|
36728
|
+
}
|
|
36729
|
+
}
|
|
36730
|
+
}
|
|
36731
|
+
for (const item of snapshot.items) {
|
|
36732
|
+
if (itemIds.has(item.id)) {
|
|
36733
|
+
ctx.addIssue({ code: "custom", message: `duplicate attention item: ${item.id}` });
|
|
36734
|
+
}
|
|
36735
|
+
itemIds.add(item.id);
|
|
36736
|
+
if (item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
36737
|
+
ctx.addIssue({ code: "custom", message: `attention item references missing scope: ${item.scopeId}` });
|
|
36738
|
+
}
|
|
36739
|
+
if (item.kind === "friend_request") {
|
|
36740
|
+
if (!item.actorUserId || !profileById.has(item.actorUserId)) {
|
|
36741
|
+
ctx.addIssue({ code: "custom", message: `friend request references missing profile: ${item.id}` });
|
|
36742
|
+
}
|
|
36743
|
+
continue;
|
|
36744
|
+
}
|
|
36745
|
+
const scope = item.scopeId ? snapshot.scopes.find((candidate) => candidate.scopeId === item.scopeId) : undefined;
|
|
36746
|
+
const message2 = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
36747
|
+
if (!scope || !message2) {
|
|
36748
|
+
ctx.addIssue({ code: "custom", message: `attention item references missing message: ${item.id}` });
|
|
36749
|
+
continue;
|
|
36750
|
+
}
|
|
36751
|
+
if (item.kind === "forum_post") {
|
|
36752
|
+
const parent = channelById.get(scope.channelId);
|
|
36753
|
+
const child = item.childChannelId ? channelById.get(item.childChannelId) : undefined;
|
|
36754
|
+
if (!scope.serverId || parent?.type !== "forum" || child?.type !== "thread" || child.parentChannelId !== parent.id || child.parentMessageId !== message2.id || message2.channelId !== parent.id || message2.seq !== item.openerSeq || item.readTarget?.channelId !== parent.id) {
|
|
36755
|
+
ctx.addIssue({ code: "custom", message: `forum post references incomplete presentation owners: ${item.id}` });
|
|
36756
|
+
}
|
|
36757
|
+
continue;
|
|
36758
|
+
}
|
|
36759
|
+
if (message2.channelId !== scope.channelId || !item.actorUserId || !profileById.has(item.actorUserId)) {
|
|
36760
|
+
ctx.addIssue({ code: "custom", message: `message attention references incomplete owners: ${item.id}` });
|
|
36761
|
+
}
|
|
36762
|
+
}
|
|
36683
36763
|
});
|
|
36684
|
-
|
|
36685
|
-
|
|
36764
|
+
// ../shared/src/product-entitlements.ts
|
|
36765
|
+
var EntitlementValueSchema = exports_external.lazy(() => exports_external.union([
|
|
36766
|
+
exports_external.null(),
|
|
36767
|
+
exports_external.boolean(),
|
|
36768
|
+
exports_external.number().finite(),
|
|
36769
|
+
exports_external.string(),
|
|
36770
|
+
exports_external.array(EntitlementValueSchema),
|
|
36771
|
+
exports_external.record(exports_external.string(), EntitlementValueSchema)
|
|
36772
|
+
]));
|
|
36773
|
+
var NonNegativeIntegerEntitlementSchema = exports_external.number().int().nonnegative();
|
|
36774
|
+
var CommunityBotActivationRequestSchema = exports_external.strictObject({
|
|
36775
|
+
active: exports_external.boolean()
|
|
36686
36776
|
});
|
|
36687
|
-
|
|
36688
|
-
|
|
36689
|
-
|
|
36690
|
-
|
|
36691
|
-
senderId: exports_external.string().min(1),
|
|
36692
|
-
senderHandle: exports_external.string().min(1),
|
|
36693
|
-
reason: exports_external.enum(["unread", "mention"])
|
|
36777
|
+
// ../shared/src/billing.ts
|
|
36778
|
+
var BillingPlanSchema = exports_external.object({
|
|
36779
|
+
id: exports_external.string().min(1),
|
|
36780
|
+
displayName: exports_external.string().min(1)
|
|
36694
36781
|
});
|
|
36695
|
-
var
|
|
36696
|
-
|
|
36782
|
+
var BillingOfferSchema = exports_external.object({
|
|
36783
|
+
priceId: exports_external.string().min(1),
|
|
36784
|
+
botLimit: exports_external.number().int().nonnegative(),
|
|
36785
|
+
machineLimit: exports_external.number().int().nonnegative(),
|
|
36786
|
+
plan: BillingPlanSchema,
|
|
36787
|
+
unitAmount: exports_external.number().int().nonnegative(),
|
|
36788
|
+
currency: exports_external.string().min(1),
|
|
36789
|
+
interval: exports_external.enum(["month", "year", "week", "day"]),
|
|
36790
|
+
intervalCount: exports_external.number().int().positive()
|
|
36697
36791
|
});
|
|
36698
|
-
var
|
|
36699
|
-
|
|
36792
|
+
var BillingSubscriptionSchema = exports_external.object({
|
|
36793
|
+
plan: BillingPlanSchema,
|
|
36794
|
+
status: exports_external.string().min(1),
|
|
36795
|
+
currentPeriodEnd: exports_external.string().datetime().nullable(),
|
|
36796
|
+
cancelAt: exports_external.string().datetime().nullable(),
|
|
36797
|
+
scheduledChange: exports_external.object({
|
|
36798
|
+
plan: BillingPlanSchema,
|
|
36799
|
+
effectiveAt: exports_external.string().datetime()
|
|
36800
|
+
}).nullable()
|
|
36700
36801
|
});
|
|
36701
|
-
var
|
|
36702
|
-
|
|
36703
|
-
|
|
36802
|
+
var PublicPricingSchema = exports_external.object({
|
|
36803
|
+
free: exports_external.object({
|
|
36804
|
+
plan: BillingPlanSchema,
|
|
36805
|
+
botLimit: exports_external.number().int().nonnegative(),
|
|
36806
|
+
machineLimit: exports_external.number().int().nonnegative()
|
|
36807
|
+
}),
|
|
36808
|
+
offers: exports_external.array(BillingOfferSchema)
|
|
36704
36809
|
});
|
|
36705
|
-
var
|
|
36706
|
-
|
|
36707
|
-
|
|
36810
|
+
var BillingSummarySchema = exports_external.object({
|
|
36811
|
+
plan: BillingPlanSchema,
|
|
36812
|
+
isFounder: exports_external.boolean(),
|
|
36813
|
+
offers: exports_external.array(BillingOfferSchema),
|
|
36814
|
+
subscription: BillingSubscriptionSchema.nullable()
|
|
36708
36815
|
});
|
|
36709
|
-
var
|
|
36710
|
-
|
|
36711
|
-
|
|
36712
|
-
message: exports_external.string().max(2048),
|
|
36713
|
-
model: exports_external.string().nullable()
|
|
36816
|
+
var BillingCheckoutRequestSchema = exports_external.strictObject({
|
|
36817
|
+
priceId: exports_external.string().min(1).max(255),
|
|
36818
|
+
founderAcknowledged: exports_external.boolean().optional()
|
|
36714
36819
|
});
|
|
36715
|
-
var
|
|
36716
|
-
|
|
36717
|
-
exports_external.object({ kind: exports_external.literal("tool_call"), payload: AuditLogToolCallPayloadSchema }),
|
|
36718
|
-
exports_external.object({ kind: exports_external.literal("thinking"), payload: AuditLogThinkingPayloadSchema }),
|
|
36719
|
-
exports_external.object({ kind: exports_external.literal("text"), payload: AuditLogTextPayloadSchema }),
|
|
36720
|
-
exports_external.object({ kind: exports_external.literal("turn_interrupt"), payload: AuditLogTurnInterruptPayloadSchema }),
|
|
36721
|
-
exports_external.object({ kind: exports_external.literal("wake_trigger"), payload: AuditLogWakeTriggerPayloadSchema }),
|
|
36722
|
-
exports_external.object({ kind: exports_external.literal("session_reset"), payload: AuditLogSessionResetPayloadSchema }),
|
|
36723
|
-
exports_external.object({ kind: exports_external.literal("nap"), payload: AuditLogNapPayloadSchema }),
|
|
36724
|
-
exports_external.object({ kind: exports_external.literal("model_changed"), payload: AuditLogModelChangedPayloadSchema }),
|
|
36725
|
-
exports_external.object({ kind: exports_external.literal("provider_changed"), payload: AuditLogProviderChangedPayloadSchema }),
|
|
36726
|
-
exports_external.object({ kind: exports_external.literal("error"), payload: AuditLogErrorPayloadSchema })
|
|
36727
|
-
]);
|
|
36728
|
-
var BotAuditEventKindSchema = exports_external.enum([
|
|
36729
|
-
"cli_invocation",
|
|
36730
|
-
"tool_call",
|
|
36731
|
-
"thinking",
|
|
36732
|
-
"text",
|
|
36733
|
-
"turn_interrupt",
|
|
36734
|
-
"wake_trigger",
|
|
36735
|
-
"session_reset",
|
|
36736
|
-
"nap",
|
|
36737
|
-
"model_changed",
|
|
36738
|
-
"provider_changed",
|
|
36739
|
-
"error"
|
|
36740
|
-
]);
|
|
36741
|
-
var HostBotAuditEventFrameSchema = exports_external.object({
|
|
36742
|
-
type: exports_external.literal("bot_audit_event"),
|
|
36743
|
-
eventId: exports_external.string().min(1).max(128).optional(),
|
|
36744
|
-
occurredAt: exports_external.string().datetime({ offset: true }).optional(),
|
|
36745
|
-
agentId: exports_external.string().min(1),
|
|
36746
|
-
sessionId: exports_external.string().nullable().optional(),
|
|
36747
|
-
launchId: exports_external.string().nullable().optional(),
|
|
36748
|
-
event: BotAuditEventSchema
|
|
36749
|
-
}).superRefine((frame, ctx) => {
|
|
36750
|
-
if (frame.event.kind === "session_reset" && frame.event.payload.trigger === "idle_timeout" && (!frame.eventId || !frame.occurredAt)) {
|
|
36751
|
-
if (!frame.eventId) {
|
|
36752
|
-
ctx.addIssue({
|
|
36753
|
-
code: "custom",
|
|
36754
|
-
path: ["eventId"],
|
|
36755
|
-
message: "eventId is required for idle_timeout session_reset"
|
|
36756
|
-
});
|
|
36757
|
-
}
|
|
36758
|
-
if (!frame.occurredAt) {
|
|
36759
|
-
ctx.addIssue({
|
|
36760
|
-
code: "custom",
|
|
36761
|
-
path: ["occurredAt"],
|
|
36762
|
-
message: "occurredAt is required for idle_timeout session_reset"
|
|
36763
|
-
});
|
|
36764
|
-
}
|
|
36765
|
-
}
|
|
36820
|
+
var BillingPortalRequestSchema = exports_external.strictObject({
|
|
36821
|
+
priceId: exports_external.string().min(1).max(255).optional()
|
|
36766
36822
|
});
|
|
36767
|
-
var
|
|
36768
|
-
|
|
36769
|
-
eventId: exports_external.string().min(1).max(128)
|
|
36823
|
+
var BillingRedirectResponseSchema = exports_external.object({
|
|
36824
|
+
url: exports_external.string().url()
|
|
36770
36825
|
});
|
|
36771
36826
|
// ../shared/src/utils/day-key.ts
|
|
36772
36827
|
function utcDayKey(now) {
|
|
@@ -36808,6 +36863,7 @@ function dayKeyInTimeZone(now, timeZone) {
|
|
|
36808
36863
|
var exports_community_schema = {};
|
|
36809
36864
|
__export(exports_community_schema, {
|
|
36810
36865
|
communityUserProfile: () => communityUserProfile,
|
|
36866
|
+
communityServerRail: () => communityServerRail,
|
|
36811
36867
|
communityServerMember: () => communityServerMember,
|
|
36812
36868
|
communityServerInvite: () => communityServerInvite,
|
|
36813
36869
|
communityServerFolderItem: () => communityServerFolderItem,
|
|
@@ -36926,20 +36982,21 @@ var communityServerMember = sqliteTable("community_server_member", {
|
|
|
36926
36982
|
serverId: text2("server_id").notNull().references(() => communityServer.id, { onDelete: "cascade" }),
|
|
36927
36983
|
userId: text2("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
36928
36984
|
role: text2("role").default("member"),
|
|
36929
|
-
railOrder: integer2("rail_order").default(0),
|
|
36930
36985
|
joinedAt: text2("joined_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
36931
36986
|
}, (t) => [
|
|
36932
36987
|
unique("uq_server_member_server_user").on(t.serverId, t.userId),
|
|
36933
36988
|
index("idx_server_member_user").on(t.userId),
|
|
36934
|
-
index("idx_server_member_user_rail_order").on(t.userId, t.railOrder),
|
|
36935
36989
|
index("idx_server_member_server_joined").on(t.serverId, t.joinedAt)
|
|
36936
36990
|
]);
|
|
36991
|
+
var communityServerRail = sqliteTable("community_server_rail", {
|
|
36992
|
+
userId: text2("user_id").primaryKey().references(() => user.id, { onDelete: "cascade" }),
|
|
36993
|
+
entries: text2("entries", { mode: "json" }).$type().notNull()
|
|
36994
|
+
});
|
|
36937
36995
|
var communityServerFolder = sqliteTable("community_server_folder", {
|
|
36938
36996
|
id: text2("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
36939
36997
|
userId: text2("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
36940
|
-
name: text2("name").notNull()
|
|
36941
|
-
|
|
36942
|
-
}, (t) => [index("idx_server_folder_user_position").on(t.userId, t.position)]);
|
|
36998
|
+
name: text2("name").notNull()
|
|
36999
|
+
}, (t) => [index("idx_server_folder_user").on(t.userId)]);
|
|
36943
37000
|
var communityServerFolderItem = sqliteTable("community_server_folder_item", {
|
|
36944
37001
|
folderId: text2("folder_id").notNull().references(() => communityServerFolder.id, { onDelete: "cascade" }),
|
|
36945
37002
|
serverId: text2("server_id").notNull().references(() => communityServer.id, { onDelete: "cascade" }),
|
|
@@ -37158,6 +37215,43 @@ function maxRowsPerInsert(paramsPerRow) {
|
|
|
37158
37215
|
return Math.floor(D1_MAX_BIND_PARAMS / paramsPerRow);
|
|
37159
37216
|
}
|
|
37160
37217
|
|
|
37218
|
+
// ../shared/src/community-server-rail.ts
|
|
37219
|
+
var MAX_SERVER_RAIL_COMMANDS = 3;
|
|
37220
|
+
var idSchema = exports_external.string().trim().min(1);
|
|
37221
|
+
var idsSchema = exports_external.array(idSchema);
|
|
37222
|
+
var serverRailEntrySchema = exports_external.discriminatedUnion("kind", [
|
|
37223
|
+
exports_external.strictObject({ kind: exports_external.literal("server"), id: idSchema }),
|
|
37224
|
+
exports_external.strictObject({ kind: exports_external.literal("folder"), id: idSchema })
|
|
37225
|
+
]);
|
|
37226
|
+
var reorderTopLevelSchema = exports_external.strictObject({
|
|
37227
|
+
kind: exports_external.literal("reorder-top-level"),
|
|
37228
|
+
entries: exports_external.array(serverRailEntrySchema)
|
|
37229
|
+
});
|
|
37230
|
+
var replaceFolderItemsSchema = exports_external.strictObject({
|
|
37231
|
+
kind: exports_external.literal("replace-folder-items"),
|
|
37232
|
+
folderId: idSchema,
|
|
37233
|
+
serverIds: idsSchema.min(1)
|
|
37234
|
+
});
|
|
37235
|
+
var deleteFolderSchema = exports_external.strictObject({
|
|
37236
|
+
kind: exports_external.literal("delete-folder"),
|
|
37237
|
+
folderId: idSchema
|
|
37238
|
+
});
|
|
37239
|
+
var createFolderSchema = exports_external.strictObject({
|
|
37240
|
+
kind: exports_external.literal("create-folder"),
|
|
37241
|
+
clientId: idSchema,
|
|
37242
|
+
name: exports_external.string().trim().min(1).max(MAX_FOLDER_NAME_LENGTH),
|
|
37243
|
+
serverIds: idsSchema.min(1)
|
|
37244
|
+
});
|
|
37245
|
+
var serverRailCommandSchema = exports_external.discriminatedUnion("kind", [
|
|
37246
|
+
reorderTopLevelSchema,
|
|
37247
|
+
replaceFolderItemsSchema,
|
|
37248
|
+
deleteFolderSchema,
|
|
37249
|
+
createFolderSchema
|
|
37250
|
+
]);
|
|
37251
|
+
var serverRailCommitRequestSchema = exports_external.strictObject({
|
|
37252
|
+
commands: exports_external.array(serverRailCommandSchema).min(1).max(MAX_SERVER_RAIL_COMMANDS)
|
|
37253
|
+
});
|
|
37254
|
+
|
|
37161
37255
|
// ../shared/src/db/queries/community/channel.ts
|
|
37162
37256
|
var CHANNEL_COLUMNS = {
|
|
37163
37257
|
id: communityChannel.id,
|
|
@@ -37402,7 +37496,8 @@ var messageSchema = CommunityMessageResourceSchema.pick({
|
|
|
37402
37496
|
mentionType: true,
|
|
37403
37497
|
embeds: true,
|
|
37404
37498
|
createdAt: true,
|
|
37405
|
-
approval: true
|
|
37499
|
+
approval: true,
|
|
37500
|
+
botCreation: true
|
|
37406
37501
|
}).extend({
|
|
37407
37502
|
id: string4,
|
|
37408
37503
|
seq: exports_external.number(),
|
|
@@ -37429,8 +37524,9 @@ var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
|
37429
37524
|
type: exports_external.literal("community:message.updated"),
|
|
37430
37525
|
channelId: string4,
|
|
37431
37526
|
messageId: string4,
|
|
37432
|
-
approval: FriendApprovalPayloadSchema
|
|
37433
|
-
|
|
37527
|
+
approval: FriendApprovalPayloadSchema.optional(),
|
|
37528
|
+
botCreation: BotCreationPayloadSchema.optional()
|
|
37529
|
+
}).refine((event) => event.approval !== undefined || event.botCreation !== undefined);
|
|
37434
37530
|
var communityMessageEditedSchema = exports_external.strictObject({
|
|
37435
37531
|
type: exports_external.literal("community:message.edited"),
|
|
37436
37532
|
channelId: string4,
|
|
@@ -37510,6 +37606,9 @@ var communityServerUpdateSchema = exports_external.strictObject({
|
|
|
37510
37606
|
icon: nullableString.optional()
|
|
37511
37607
|
})
|
|
37512
37608
|
});
|
|
37609
|
+
var communityServerRailChangedSchema = exports_external.strictObject({
|
|
37610
|
+
type: exports_external.literal("community:server_rail.changed")
|
|
37611
|
+
});
|
|
37513
37612
|
var communityServerDeleteSchema = exports_external.strictObject({
|
|
37514
37613
|
type: exports_external.literal("community:server.delete"),
|
|
37515
37614
|
serverId: string4
|
|
@@ -37776,6 +37875,7 @@ var commonCommunityEventSchemas = [
|
|
|
37776
37875
|
communityTypingStartSchema,
|
|
37777
37876
|
communityTypingStopSchema,
|
|
37778
37877
|
communityServerUpdateSchema,
|
|
37878
|
+
communityServerRailChangedSchema,
|
|
37779
37879
|
communityServerDeleteSchema,
|
|
37780
37880
|
communityChannelDeleteSchema,
|
|
37781
37881
|
communityChannelReorderSchema,
|
|
@@ -37843,6 +37943,7 @@ var WS_EVENTS = {
|
|
|
37843
37943
|
CHILD_CHANNEL_CREATE: "community:channel.child_create",
|
|
37844
37944
|
CHILD_CHANNEL_UPDATE: "community:channel.child_update",
|
|
37845
37945
|
SERVER_UPDATE: "community:server.update",
|
|
37946
|
+
SERVER_RAIL_CHANGED: "community:server_rail.changed",
|
|
37846
37947
|
SERVER_DELETE: "community:server.delete",
|
|
37847
37948
|
CHANNEL_CREATE: "community:channel.create",
|
|
37848
37949
|
CHANNEL_UPDATE: "community:channel.update",
|
|
@@ -38031,45 +38132,26 @@ var communityFunnelAnalyticsEvent = sqliteTable("community_funnel_analytics_even
|
|
|
38031
38132
|
index("idx_community_funnel_analytics_owner_claimed_created").on(t.ownerUserId, t.claimedAt, t.createdAt)
|
|
38032
38133
|
]);
|
|
38033
38134
|
|
|
38034
|
-
// ../shared/src/db/
|
|
38035
|
-
var
|
|
38036
|
-
|
|
38037
|
-
|
|
38038
|
-
var idSchema = exports_external.string().trim().min(1);
|
|
38039
|
-
var idsSchema = exports_external.array(idSchema);
|
|
38040
|
-
var reorderServersSchema = exports_external.strictObject({
|
|
38041
|
-
kind: exports_external.literal("reorder-servers"),
|
|
38042
|
-
serverIds: idsSchema
|
|
38043
|
-
});
|
|
38044
|
-
var reorderFoldersSchema = exports_external.strictObject({
|
|
38045
|
-
kind: exports_external.literal("reorder-folders"),
|
|
38046
|
-
folderIds: idsSchema
|
|
38047
|
-
});
|
|
38048
|
-
var replaceFolderItemsSchema = exports_external.strictObject({
|
|
38049
|
-
kind: exports_external.literal("replace-folder-items"),
|
|
38050
|
-
folderId: idSchema,
|
|
38051
|
-
serverIds: idsSchema.min(1)
|
|
38052
|
-
});
|
|
38053
|
-
var deleteFolderSchema = exports_external.strictObject({
|
|
38054
|
-
kind: exports_external.literal("delete-folder"),
|
|
38055
|
-
folderId: idSchema
|
|
38056
|
-
});
|
|
38057
|
-
var createFolderSchema = exports_external.strictObject({
|
|
38058
|
-
kind: exports_external.literal("create-folder"),
|
|
38059
|
-
clientId: idSchema,
|
|
38060
|
-
name: exports_external.string().trim().min(1).max(MAX_FOLDER_NAME_LENGTH),
|
|
38061
|
-
serverIds: idsSchema.min(1)
|
|
38062
|
-
});
|
|
38063
|
-
var serverRailCommandSchema = exports_external.discriminatedUnion("kind", [
|
|
38064
|
-
reorderServersSchema,
|
|
38065
|
-
reorderFoldersSchema,
|
|
38066
|
-
replaceFolderItemsSchema,
|
|
38067
|
-
deleteFolderSchema,
|
|
38068
|
-
createFolderSchema
|
|
38069
|
-
]);
|
|
38070
|
-
var serverRailCommitRequestSchema = exports_external.strictObject({
|
|
38071
|
-
commands: exports_external.array(serverRailCommandSchema).min(1).max(MAX_SERVER_RAIL_COMMANDS)
|
|
38135
|
+
// ../shared/src/db/bot-creation-schema.ts
|
|
38136
|
+
var exports_bot_creation_schema = {};
|
|
38137
|
+
__export(exports_bot_creation_schema, {
|
|
38138
|
+
communityBotCreationRequest: () => communityBotCreationRequest
|
|
38072
38139
|
});
|
|
38140
|
+
var communityBotCreationRequest = sqliteTable("community_bot_creation_request", {
|
|
38141
|
+
id: text2("id").primaryKey(),
|
|
38142
|
+
requesterId: text2("requester_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
38143
|
+
ownerId: text2("owner_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
38144
|
+
channelId: text2("channel_id").notNull().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
38145
|
+
messageId: text2("message_id").notNull().unique().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
38146
|
+
status: text2("status", { enum: ["pending", "approved", "declined"] }).notNull().default("pending"),
|
|
38147
|
+
bots: text2("bots", { mode: "json" }).$type().notNull(),
|
|
38148
|
+
decisionNonce: text2("decision_nonce"),
|
|
38149
|
+
createdAt: text2("created_at").notNull(),
|
|
38150
|
+
resolvedAt: text2("resolved_at")
|
|
38151
|
+
}, (t) => [index("idx_bot_creation_requester").on(t.requesterId, t.createdAt), index("idx_bot_creation_owner").on(t.ownerId, t.createdAt)]);
|
|
38152
|
+
|
|
38153
|
+
// ../shared/src/db/index.ts
|
|
38154
|
+
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema, ...exports_product_plan_schema, ...exports_billing_schema, ...exports_community_funnel_analytics_schema, ...exports_bot_creation_schema };
|
|
38073
38155
|
// ../shared/src/db/queries/native-oauth.ts
|
|
38074
38156
|
var ATTEMPT_TTL_MS = 10 * 60 * 1000;
|
|
38075
38157
|
var HANDOFF_TTL_MS = 2 * 60 * 1000;
|
|
@@ -38194,6 +38276,11 @@ var nativeOauthProofSchema = nativeOauthExchangeSchema.omit({ code: true }).stri
|
|
|
38194
38276
|
// ../shared/src/utils/community-mentions.ts
|
|
38195
38277
|
var MENTION_IDENTIFIER_CHARACTERS = /[\p{L}\p{N}_-]/u.source;
|
|
38196
38278
|
var ID_CHAR_RE = new RegExp(MENTION_IDENTIFIER_CHARACTERS, "u");
|
|
38279
|
+
// ../shared/src/community-channel-order.ts
|
|
38280
|
+
var channelReorderRequestSchema = exports_external.strictObject({
|
|
38281
|
+
channelIds: exports_external.array(exports_external.string().min(1)).min(1).refine((ids) => new Set(ids).size === ids.length, "channelIds must be unique"),
|
|
38282
|
+
move: exports_external.strictObject({ channelId: exports_external.string().min(1), categoryId: exports_external.string().min(1).nullable() }).optional()
|
|
38283
|
+
}).refine((request) => !request.move || request.channelIds.includes(request.move.channelId), "moved channel must be included in channelIds");
|
|
38197
38284
|
// src/manager/memoryMaintenancePrompt.ts
|
|
38198
38285
|
var MEMORY_MAINTENANCE_PROMPT = `The daemon is preparing to reset this idle session. First, clean up your memory so the next session does not inherit incorrect or outdated notes.
|
|
38199
38286
|
|
|
@@ -38296,6 +38383,18 @@ function cliCommandsSection() {
|
|
|
38296
38383
|
`1. \`${CLI} friend request --username "<name#0042>"\` — ask to friend a user by handle. ` + `Your owner must approve it in DM before it goes through, so expect a \`pending\` ` + `result with a hint (a same-owner sibling bot auto-accepts instead).`,
|
|
38297
38384
|
`2. \`${CLI} friend list\` — list your friends and pending requests ` + `(\`accepted\`, \`pendingOutgoing\`, \`pendingIncoming\`).`,
|
|
38298
38385
|
"",
|
|
38386
|
+
"### Platform",
|
|
38387
|
+
"",
|
|
38388
|
+
"A machine is one of your owner's computers connected to Alook through its daemon. A backend is an AI runtime on that machine, such as Codex or Claude Code. A bot is an Alook account that belongs to your owner and runs with a selected machine and backend.",
|
|
38389
|
+
"",
|
|
38390
|
+
"Only submit a bot creation request when your owner explicitly asks you to. Do not request new bots on your own initiative, even though the owner must approve them later.",
|
|
38391
|
+
"",
|
|
38392
|
+
`1. \`${CLI} platform machine --list\` — list your owner's machines.`,
|
|
38393
|
+
`2. \`${CLI} platform machine --backends --id <machine-id>\` — read the selected online machine's backends.`,
|
|
38394
|
+
`3. \`${CLI} platform machine --models --id <machine-id> --backend <backend-id> [--model <full-model-id>] [--refresh]\` — read reported models and model-specific effort options. \`--refresh\` only dispatches an asynchronous refresh; read once later without \`--refresh\` for the stored report. Do not poll.`,
|
|
38395
|
+
`4. \`${CLI} platform bot --list\` — list your owner's bots.`,
|
|
38396
|
+
`5. \`${CLI} platform bot --create '<bot-json>'\` — request new bots for your owner. Each JSON requires \`name\`, \`machineId\`, \`backendId\` and \`reason\`; optional fields are \`description\`, \`model\` and \`reasoningEffort\`. ` + `Use an online machine and its backend. The \`reason\` explains to your owner why the bot is needed and what work it will do; this text appears on the approval card. Repeat \`--create\` for up to 20 bots in one request. ` + `The command submits one approval card to the DM between you and your owner. It creates no bots until your human owner approves the request.`,
|
|
38397
|
+
"",
|
|
38299
38398
|
"### Settings",
|
|
38300
38399
|
"",
|
|
38301
38400
|
`1. \`${CLI} setting profile --set-bio <text> --set-avatar <path>\` — update your public bio ` + `and/or avatar. At least one flag is required; pass \`--set-bio ""\` to clear the bio.`,
|
|
@@ -40542,7 +40641,7 @@ class AgentRouter {
|
|
|
40542
40641
|
const timeZone = typeof this.opts.timeZone === "function" ? this.opts.timeZone() : this.opts.timeZone;
|
|
40543
40642
|
return {
|
|
40544
40643
|
runtimeReport: [...this.runtimes.values()],
|
|
40545
|
-
capabilities: [CONTROL_HEARTBEAT_CAPABILITY, ...this.opts.channel.reportRuntimeModels ? [RUNTIME_MODEL_DISCOVERY_CAPABILITY] : []],
|
|
40644
|
+
capabilities: [CONTROL_HEARTBEAT_CAPABILITY, ...this.opts.supportsMachineStop ? [MACHINE_STOP_CAPABILITY] : [], ...this.opts.channel.reportRuntimeModels ? [RUNTIME_MODEL_DISCOVERY_CAPABILITY] : []],
|
|
40546
40645
|
runningAgents: [...this.running],
|
|
40547
40646
|
hostname: this.opts.hostname,
|
|
40548
40647
|
platform: this.opts.platform,
|
|
@@ -41045,6 +41144,12 @@ function parseBearer(authHeader) {
|
|
|
41045
41144
|
return m ? m[1].trim() : null;
|
|
41046
41145
|
}
|
|
41047
41146
|
var DEFAULT_CAPABILITY_RESOLVER = (method, pathname) => {
|
|
41147
|
+
if (pathname.startsWith("/api/community/machines"))
|
|
41148
|
+
return "read";
|
|
41149
|
+
if (pathname === "/api/community/bots" && method === "GET")
|
|
41150
|
+
return "read";
|
|
41151
|
+
if (pathname === "/api/community/bots/creation-requests" && method === "POST")
|
|
41152
|
+
return "send";
|
|
41048
41153
|
if ((method === "GET" || method === "PATCH") && pathname === "/api/community/users/me/profile" || method === "POST" && pathname === "/api/community/users/me/avatar")
|
|
41049
41154
|
return "profile";
|
|
41050
41155
|
if (pathname.includes("/attachment"))
|
|
@@ -41227,7 +41332,11 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
41227
41332
|
req.resume();
|
|
41228
41333
|
return;
|
|
41229
41334
|
}
|
|
41230
|
-
|
|
41335
|
+
if (pathname.startsWith("/api/community/machines") && !(req.method === "GET" && /^\/api\/community\/machines(?:\/[^/]+(?:\/models)?)?$/.test(pathname) || req.method === "POST" && /^\/api\/community\/machines\/[^/]+\/discover-models$/.test(pathname))) {
|
|
41336
|
+
writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
|
|
41337
|
+
return;
|
|
41338
|
+
}
|
|
41339
|
+
const canonicalCommunityDoor = /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines)(\/|$)/.test(pathname);
|
|
41231
41340
|
if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
|
|
41232
41341
|
res.writeHead(404, { "content-type": "application/json" });
|
|
41233
41342
|
res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
|
|
@@ -43743,6 +43852,16 @@ function createSelfUpdateCommandListener(handleSelfUpdate) {
|
|
|
43743
43852
|
};
|
|
43744
43853
|
}
|
|
43745
43854
|
|
|
43855
|
+
// src/daemon/machineStopCommand.ts
|
|
43856
|
+
function createMachineStopCommandListener(onStopRequested) {
|
|
43857
|
+
return (command) => {
|
|
43858
|
+
if (command.type !== "machine:stop")
|
|
43859
|
+
return;
|
|
43860
|
+
onStopRequested?.();
|
|
43861
|
+
return WS_CONTROL_COMMAND_CONSUMED;
|
|
43862
|
+
};
|
|
43863
|
+
}
|
|
43864
|
+
|
|
43746
43865
|
// src/daemon/messageReminderScheduler.ts
|
|
43747
43866
|
function reminderKey(agentId, channel2) {
|
|
43748
43867
|
return `${agentId}\x00${channel2}`;
|
|
@@ -45056,6 +45175,7 @@ async function createDaemon(opts) {
|
|
|
45056
45175
|
manager,
|
|
45057
45176
|
channel: channel2,
|
|
45058
45177
|
runtimeReport: opts.runtimeReport,
|
|
45178
|
+
supportsMachineStop: typeof opts.onStopRequested === "function",
|
|
45059
45179
|
hostname: opts.hostname,
|
|
45060
45180
|
platform: opts.platform,
|
|
45061
45181
|
arch: opts.arch,
|
|
@@ -45098,6 +45218,7 @@ async function createDaemon(opts) {
|
|
|
45098
45218
|
channel2.sendReady?.(router.buildReady());
|
|
45099
45219
|
};
|
|
45100
45220
|
channel2.onCommand(createSelfUpdateCommandListener(opts.handleSelfUpdate));
|
|
45221
|
+
channel2.onCommand(createMachineStopCommandListener(opts.onStopRequested));
|
|
45101
45222
|
channel2.onCommand(createDiagnosticsCommandListener({
|
|
45102
45223
|
handleDiagnosticCommand: opts.handleDiagnosticCommand,
|
|
45103
45224
|
reportDiagnosticFailure: opts.reportDiagnosticFailure
|