@alook/daemon 0.1.57 → 0.1.58
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/cli/index.js
CHANGED
|
@@ -95,11 +95,8 @@ function nanoid3(size = 21) {
|
|
|
95
95
|
var POOL_SIZE_MULTIPLIER = 128, pool, poolOffset;
|
|
96
96
|
var init_nanoid = () => {};
|
|
97
97
|
|
|
98
|
-
// src/cli/
|
|
99
|
-
import {
|
|
100
|
-
import { realpathSync as realpathSync2 } from "node:fs";
|
|
101
|
-
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
102
|
-
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
98
|
+
// src/cli/platform.ts
|
|
99
|
+
import { randomUUID } from "node:crypto";
|
|
103
100
|
|
|
104
101
|
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/external.js
|
|
105
102
|
var exports_external = {};
|
|
@@ -19520,21 +19517,6 @@ function bigint3(params) {
|
|
|
19520
19517
|
function date4(params) {
|
|
19521
19518
|
return _coercedDate(ZodDate, params);
|
|
19522
19519
|
}
|
|
19523
|
-
// ../shared/src/lib/discriminator.ts
|
|
19524
|
-
function parseNameAndTag(q) {
|
|
19525
|
-
const m = /^(.+)#(\d{4,})$/.exec(q);
|
|
19526
|
-
if (!m)
|
|
19527
|
-
return null;
|
|
19528
|
-
const name = m[1].trim();
|
|
19529
|
-
const discriminator = m[2];
|
|
19530
|
-
if (!name)
|
|
19531
|
-
return null;
|
|
19532
|
-
return { name, discriminator };
|
|
19533
|
-
}
|
|
19534
|
-
function formatHandle(name, discriminator) {
|
|
19535
|
-
return `${name}#${discriminator}`;
|
|
19536
|
-
}
|
|
19537
|
-
|
|
19538
19520
|
// ../shared/src/db/community-machine-schema.ts
|
|
19539
19521
|
var exports_community_machine_schema = {};
|
|
19540
19522
|
__export(exports_community_machine_schema, {
|
|
@@ -22021,6 +22003,25 @@ var OwnerDiagnosticReportSchema = exports_external.discriminatedUnion("status",
|
|
|
22021
22003
|
objectExpired: exports_external.literal(false)
|
|
22022
22004
|
}).strict()
|
|
22023
22005
|
]);
|
|
22006
|
+
// ../shared/src/community-contract.ts
|
|
22007
|
+
var COMMUNITY_RESOURCE_CONTRACT_VERSION = 3;
|
|
22008
|
+
|
|
22009
|
+
// ../shared/src/community-friend-approval.ts
|
|
22010
|
+
var profile = exports_external.strictObject({
|
|
22011
|
+
id: exports_external.string(),
|
|
22012
|
+
name: exports_external.string(),
|
|
22013
|
+
discriminator: exports_external.string(),
|
|
22014
|
+
image: exports_external.string().nullable(),
|
|
22015
|
+
avatarVersion: exports_external.number().int().nonnegative()
|
|
22016
|
+
});
|
|
22017
|
+
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
22018
|
+
friendshipId: exports_external.string(),
|
|
22019
|
+
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
22020
|
+
waitingOn: exports_external.enum(["you", "other-owner", "addressee"]).nullable(),
|
|
22021
|
+
otherProfile: profile,
|
|
22022
|
+
botProfile: profile,
|
|
22023
|
+
waitingOnProfile: profile.nullable().optional()
|
|
22024
|
+
});
|
|
22024
22025
|
|
|
22025
22026
|
// ../shared/src/runtime-models-contract.ts
|
|
22026
22027
|
var RUNTIME_MODEL_DISCOVERY_CAPABILITY = "runtime-model-discovery-v1";
|
|
@@ -22037,10 +22038,33 @@ var RuntimeModelDiscoveryErrorSchema = exports_external.strictObject({
|
|
|
22037
22038
|
message: exports_external.string().min(1).max(256)
|
|
22038
22039
|
});
|
|
22039
22040
|
|
|
22041
|
+
// ../shared/src/utils/slug.ts
|
|
22042
|
+
init_nanoid();
|
|
22043
|
+
var slugId = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz");
|
|
22044
|
+
function sanitizeSlug(input2) {
|
|
22045
|
+
return input2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
|
|
22046
|
+
}
|
|
22047
|
+
|
|
22048
|
+
// ../shared/src/lib/discriminator.ts
|
|
22049
|
+
function parseNameAndTag(q) {
|
|
22050
|
+
const m = /^(.+)#(\d{4,})$/.exec(q);
|
|
22051
|
+
if (!m)
|
|
22052
|
+
return null;
|
|
22053
|
+
const name = m[1].trim();
|
|
22054
|
+
const discriminator = m[2];
|
|
22055
|
+
if (!name)
|
|
22056
|
+
return null;
|
|
22057
|
+
return { name, discriminator };
|
|
22058
|
+
}
|
|
22059
|
+
function formatHandle(name, discriminator) {
|
|
22060
|
+
return `${name}#${discriminator}`;
|
|
22061
|
+
}
|
|
22062
|
+
|
|
22040
22063
|
// ../shared/src/community-cli-contract.ts
|
|
22041
22064
|
var AGENT_EVENT_PROMPT_MAX_LENGTH = 32768;
|
|
22042
22065
|
var DM_SERVER = ".dm";
|
|
22043
22066
|
var CONTROL_HEARTBEAT_CAPABILITY = "control-heartbeat-v1";
|
|
22067
|
+
var MACHINE_STOP_CAPABILITY = "machine-stop-v1";
|
|
22044
22068
|
var AgentInterruptRequestSchema = exports_external.strictObject({
|
|
22045
22069
|
type: exports_external.literal("agent:interrupt"),
|
|
22046
22070
|
agentId: exports_external.string().min(1).max(128)
|
|
@@ -22182,6 +22206,9 @@ var HostCommandSchema = exports_external.discriminatedUnion("type", [
|
|
|
22182
22206
|
exports_external.strictObject({
|
|
22183
22207
|
type: exports_external.literal("machine:update")
|
|
22184
22208
|
}),
|
|
22209
|
+
exports_external.strictObject({
|
|
22210
|
+
type: exports_external.literal("machine:stop")
|
|
22211
|
+
}),
|
|
22185
22212
|
exports_external.object({
|
|
22186
22213
|
type: exports_external.literal("bot:added"),
|
|
22187
22214
|
botId: exports_external.string().min(1),
|
|
@@ -22206,530 +22233,7 @@ var HostCommandSchema = exports_external.discriminatedUnion("type", [
|
|
|
22206
22233
|
}),
|
|
22207
22234
|
DiagnosticCollectCommandSchema
|
|
22208
22235
|
]);
|
|
22209
|
-
// src/cli/proxyServerApi.ts
|
|
22210
|
-
import * as fs from "fs";
|
|
22211
|
-
import * as path from "path";
|
|
22212
|
-
// ../shared/src/community-contract.ts
|
|
22213
|
-
var COMMUNITY_RESOURCE_CONTRACT_VERSION = 3;
|
|
22214
|
-
|
|
22215
|
-
// ../shared/src/community-friend-approval.ts
|
|
22216
|
-
var profile = exports_external.strictObject({
|
|
22217
|
-
id: exports_external.string(),
|
|
22218
|
-
name: exports_external.string(),
|
|
22219
|
-
discriminator: exports_external.string(),
|
|
22220
|
-
image: exports_external.string().nullable(),
|
|
22221
|
-
avatarVersion: exports_external.number().int().nonnegative()
|
|
22222
|
-
});
|
|
22223
|
-
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
22224
|
-
friendshipId: exports_external.string(),
|
|
22225
|
-
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
22226
|
-
waitingOn: exports_external.enum(["you", "other-owner", "addressee"]).nullable(),
|
|
22227
|
-
otherProfile: profile,
|
|
22228
|
-
botProfile: profile,
|
|
22229
|
-
waitingOnProfile: profile.nullable().optional()
|
|
22230
|
-
});
|
|
22231
22236
|
|
|
22232
|
-
// ../shared/src/community-resources.ts
|
|
22233
|
-
var id = exports_external.string().min(1);
|
|
22234
|
-
var nullableId = id.nullable();
|
|
22235
|
-
var legacyArchivedSchema = exports_external.union([exports_external.boolean(), exports_external.literal(0), exports_external.literal(1)]).transform((value) => value === true || value === 1);
|
|
22236
|
-
var CommunityChannelResourceSchema = exports_external.strictObject({
|
|
22237
|
-
id,
|
|
22238
|
-
type: exports_external.enum(["text", "forum", "thread", "dm"]),
|
|
22239
|
-
serverId: nullableId,
|
|
22240
|
-
categoryId: nullableId,
|
|
22241
|
-
name: exports_external.string().nullable(),
|
|
22242
|
-
topic: exports_external.string(),
|
|
22243
|
-
parentChannelId: nullableId,
|
|
22244
|
-
parentMessageId: nullableId,
|
|
22245
|
-
creatorId: nullableId,
|
|
22246
|
-
position: exports_external.number(),
|
|
22247
|
-
archived: exports_external.boolean(),
|
|
22248
|
-
createdAt: exports_external.string(),
|
|
22249
|
-
lastMessageAt: exports_external.string().nullable(),
|
|
22250
|
-
messageCount: exports_external.number().int().nonnegative()
|
|
22251
|
-
});
|
|
22252
|
-
var CommunityChannelIdentitySchema = CommunityChannelResourceSchema.pick({
|
|
22253
|
-
id: true,
|
|
22254
|
-
type: true,
|
|
22255
|
-
serverId: true,
|
|
22256
|
-
name: true,
|
|
22257
|
-
parentChannelId: true,
|
|
22258
|
-
parentMessageId: true,
|
|
22259
|
-
creatorId: true,
|
|
22260
|
-
archived: true,
|
|
22261
|
-
lastMessageAt: true,
|
|
22262
|
-
createdAt: true
|
|
22263
|
-
}).partial({ createdAt: true }).strip();
|
|
22264
|
-
var legacyChannelIdentitySchema = CommunityChannelIdentitySchema.extend({
|
|
22265
|
-
archived: legacyArchivedSchema,
|
|
22266
|
-
parentChannelId: nullableId.default(null),
|
|
22267
|
-
parentMessageId: nullableId.default(null),
|
|
22268
|
-
creatorId: nullableId.default(null),
|
|
22269
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null)
|
|
22270
|
-
});
|
|
22271
|
-
var CommunityAccessDecisionSchema = exports_external.strictObject({
|
|
22272
|
-
channelId: id,
|
|
22273
|
-
canRead: exports_external.boolean(),
|
|
22274
|
-
canSend: exports_external.boolean(),
|
|
22275
|
-
canCreateDiscussion: exports_external.boolean()
|
|
22276
|
-
});
|
|
22277
|
-
var CommunityLegacyMessageAttachmentSchema = exports_external.strictObject({
|
|
22278
|
-
kind: exports_external.enum(["image", "file"]),
|
|
22279
|
-
name: exports_external.string(),
|
|
22280
|
-
url: exports_external.string(),
|
|
22281
|
-
thumbnailUrl: exports_external.string().optional(),
|
|
22282
|
-
contentType: exports_external.string().optional(),
|
|
22283
|
-
size: exports_external.string().optional(),
|
|
22284
|
-
sizeBytes: exports_external.number().nonnegative().optional(),
|
|
22285
|
-
width: exports_external.number().nonnegative().optional(),
|
|
22286
|
-
height: exports_external.number().nonnegative().optional()
|
|
22287
|
-
});
|
|
22288
|
-
var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
22289
|
-
id,
|
|
22290
|
-
name: exports_external.string(),
|
|
22291
|
-
url: exports_external.string(),
|
|
22292
|
-
thumbnailUrl: exports_external.string().nullable(),
|
|
22293
|
-
contentType: exports_external.string().nullable(),
|
|
22294
|
-
sizeBytes: exports_external.number().int().nonnegative().nullable(),
|
|
22295
|
-
width: exports_external.number().int().nonnegative().nullable(),
|
|
22296
|
-
height: exports_external.number().int().nonnegative().nullable()
|
|
22297
|
-
});
|
|
22298
|
-
var CommunityMessagePreviewAttachmentSchema = CommunityMessageAttachmentSchema.partial().required({ name: true, url: true });
|
|
22299
|
-
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
22300
|
-
id,
|
|
22301
|
-
name: exports_external.string(),
|
|
22302
|
-
discriminator: exports_external.string().min(1).nullable(),
|
|
22303
|
-
avatar: exports_external.string().nullable(),
|
|
22304
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
22305
|
-
aboutMe: exports_external.string().optional(),
|
|
22306
|
-
bannerColor: exports_external.string().nullable().optional(),
|
|
22307
|
-
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
22308
|
-
ownerUserId: nullableId.optional(),
|
|
22309
|
-
ownerHandle: exports_external.string().nullable().optional(),
|
|
22310
|
-
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
22311
|
-
ownedByViewer: exports_external.boolean().optional(),
|
|
22312
|
-
statusEmoji: exports_external.string().nullable().optional(),
|
|
22313
|
-
statusText: exports_external.string().nullable().optional()
|
|
22314
|
-
});
|
|
22315
|
-
var CommunityMessageThreadParticipantSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatar: true, avatarVersion: true });
|
|
22316
|
-
var messageThreadSchema = exports_external.strictObject({
|
|
22317
|
-
id,
|
|
22318
|
-
name: CommunityChannelResourceSchema.shape.name,
|
|
22319
|
-
messageCount: CommunityChannelResourceSchema.shape.messageCount,
|
|
22320
|
-
lastReplyAt: CommunityChannelResourceSchema.shape.lastMessageAt.optional(),
|
|
22321
|
-
tags: exports_external.array(exports_external.string()).optional(),
|
|
22322
|
-
preview: exports_external.string().optional(),
|
|
22323
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema).optional(),
|
|
22324
|
-
participantCount: exports_external.number().int().nonnegative().optional()
|
|
22325
|
-
});
|
|
22326
|
-
var legacyMessageThreadSchema = messageThreadSchema.extend({
|
|
22327
|
-
name: exports_external.string(),
|
|
22328
|
-
lastReplyAt: exports_external.string().optional(),
|
|
22329
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.extend({ avatar: exports_external.string() })).optional()
|
|
22330
|
-
});
|
|
22331
|
-
var messageThreadPreviewSchema = messageThreadSchema.partial().required({ id: true }).extend({
|
|
22332
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.partial().required({ id: true })).optional()
|
|
22333
|
-
});
|
|
22334
|
-
var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
22335
|
-
id,
|
|
22336
|
-
channelId: id,
|
|
22337
|
-
seq: exports_external.number().int().nonnegative(),
|
|
22338
|
-
authorId: id,
|
|
22339
|
-
createdAt: exports_external.string(),
|
|
22340
|
-
type: exports_external.enum(["chat", "system"]),
|
|
22341
|
-
content: exports_external.string(),
|
|
22342
|
-
replyToId: nullableId,
|
|
22343
|
-
clientNonce: exports_external.string().nullable(),
|
|
22344
|
-
attachments: exports_external.array(CommunityMessageAttachmentSchema),
|
|
22345
|
-
systemKind: exports_external.literal("thread").optional(),
|
|
22346
|
-
authorName: exports_external.string().optional(),
|
|
22347
|
-
authorAvatar: exports_external.string().nullable().optional(),
|
|
22348
|
-
authorAvatarVersion: exports_external.number().int().nonnegative().optional(),
|
|
22349
|
-
mentionType: exports_external.literal("everyone").nullable().optional(),
|
|
22350
|
-
replyTo: exports_external.strictObject({
|
|
22351
|
-
id,
|
|
22352
|
-
authorId: id.optional(),
|
|
22353
|
-
authorName: exports_external.string(),
|
|
22354
|
-
text: exports_external.string(),
|
|
22355
|
-
deleted: exports_external.boolean().optional()
|
|
22356
|
-
}).optional(),
|
|
22357
|
-
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
22358
|
-
reactions: exports_external.array(exports_external.strictObject({
|
|
22359
|
-
emoji: exports_external.string(),
|
|
22360
|
-
count: exports_external.number().int().nonnegative(),
|
|
22361
|
-
me: exports_external.boolean(),
|
|
22362
|
-
userIds: exports_external.array(id)
|
|
22363
|
-
})).optional(),
|
|
22364
|
-
thread: messageThreadSchema.optional(),
|
|
22365
|
-
approval: FriendApprovalPayloadSchema.optional()
|
|
22366
|
-
});
|
|
22367
|
-
var CommunityMessagePreviewSchema = CommunityMessageResourceSchema.partial().required({
|
|
22368
|
-
id: true,
|
|
22369
|
-
type: true
|
|
22370
|
-
}).extend({ attachments: exports_external.array(CommunityMessagePreviewAttachmentSchema).optional(), thread: messageThreadPreviewSchema.optional() });
|
|
22371
|
-
var CommunityReadStateResourceSchema = exports_external.strictObject({
|
|
22372
|
-
channelId: id,
|
|
22373
|
-
lastReadMessageId: nullableId,
|
|
22374
|
-
lastReadAt: exports_external.string().nullable(),
|
|
22375
|
-
lastReadSeq: exports_external.number().int().nonnegative()
|
|
22376
|
-
});
|
|
22377
|
-
var CommunityMemberRelationSchema = exports_external.strictObject({
|
|
22378
|
-
channelId: id,
|
|
22379
|
-
userId: id,
|
|
22380
|
-
relation: exports_external.enum(["access", "notify"]),
|
|
22381
|
-
source: exports_external.string(),
|
|
22382
|
-
isCreator: exports_external.boolean(),
|
|
22383
|
-
role: exports_external.string().nullable(),
|
|
22384
|
-
memberId: nullableId
|
|
22385
|
-
});
|
|
22386
|
-
var CommunityPageSchema = exports_external.strictObject({
|
|
22387
|
-
olderCursor: exports_external.string().nullable(),
|
|
22388
|
-
newerCursor: exports_external.string().nullable(),
|
|
22389
|
-
hasMoreOlder: exports_external.boolean(),
|
|
22390
|
-
hasMoreNewer: exports_external.boolean(),
|
|
22391
|
-
latestSeq: exports_external.number().int().nonnegative()
|
|
22392
|
-
});
|
|
22393
|
-
var envelope = { contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), channelId: id };
|
|
22394
|
-
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
22395
|
-
var CommunityMessagesReadSchema = exports_external.strictObject({
|
|
22396
|
-
...envelope,
|
|
22397
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
22398
|
-
page: CommunityPageSchema,
|
|
22399
|
-
surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
|
|
22400
|
-
});
|
|
22401
|
-
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
22402
|
-
viewerId: id,
|
|
22403
|
-
peer: CommunityResourceProfileSchema.nullable(),
|
|
22404
|
-
channel: CommunityChannelResourceSchema,
|
|
22405
|
-
access: CommunityAccessDecisionSchema.extend({ canRead: exports_external.literal(true) }),
|
|
22406
|
-
readState: CommunityReadStateResourceSchema,
|
|
22407
|
-
readStateRevision: exports_external.number().int().nonnegative(),
|
|
22408
|
-
forumFeed: exports_external.lazy(() => CommunityThreadsReadSchema).optional(),
|
|
22409
|
-
opener: CommunityMessageResourceSchema.optional(),
|
|
22410
|
-
parent: CommunityChannelResourceSchema.optional(),
|
|
22411
|
-
selection: exports_external.strictObject({
|
|
22412
|
-
reason: exports_external.enum(["explicit_anchor", "read_pointer", "tail", "read_pointer_missing"]),
|
|
22413
|
-
anchorMessageId: nullableId
|
|
22414
|
-
})
|
|
22415
|
-
}).superRefine((entry, ctx) => {
|
|
22416
|
-
for (const [path, channelId] of [
|
|
22417
|
-
[["channel", "id"], entry.channel.id],
|
|
22418
|
-
[["access", "channelId"], entry.access.channelId],
|
|
22419
|
-
[["readState", "channelId"], entry.readState.channelId],
|
|
22420
|
-
[["surfaceReceipt", "channelId"], entry.surfaceReceipt.channelId],
|
|
22421
|
-
...entry.messages.map((message2, index2) => [["messages", index2, "channelId"], message2.channelId])
|
|
22422
|
-
]) {
|
|
22423
|
-
if (channelId !== entry.channelId)
|
|
22424
|
-
ctx.addIssue({ code: "custom", path: [...path], message: "Conversation entry scope mismatch" });
|
|
22425
|
-
}
|
|
22426
|
-
if (entry.channel.type === "dm" !== (entry.peer !== null) || entry.peer?.id === entry.viewerId)
|
|
22427
|
-
ctx.addIssue({ code: "custom", path: ["peer"], message: "Conversation entry peer mismatch" });
|
|
22428
|
-
if (entry.opener && (entry.channel.type !== "thread" || entry.opener.id !== entry.channel.parentMessageId || entry.opener.channelId !== entry.channel.parentChannelId))
|
|
22429
|
-
ctx.addIssue({ code: "custom", path: ["opener"], message: "Conversation entry opener scope mismatch" });
|
|
22430
|
-
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"))
|
|
22431
|
-
ctx.addIssue({ code: "custom", path: ["parent"], message: "Conversation entry parent scope mismatch" });
|
|
22432
|
-
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)))
|
|
22433
|
-
ctx.addIssue({ code: "custom", path: ["forumFeed"], message: "Conversation entry forum scope mismatch" });
|
|
22434
|
-
if (entry.forumFeed) {
|
|
22435
|
-
const feed = entry.forumFeed, children = new Set(feed.threads.map((thread) => thread.id)), profiles = new Set(feed.included.profiles.map((profile2) => profile2.id));
|
|
22436
|
-
const openers = new Set(feed.threads.flatMap((thread) => thread.parentMessageId ? [thread.parentMessageId] : []));
|
|
22437
|
-
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)))
|
|
22438
|
-
ctx.addIssue({ code: "custom", path: ["forumFeed", "included"], message: "Conversation entry forum included scope mismatch" });
|
|
22439
|
-
}
|
|
22440
|
-
const surfaceKind = entry.channel.type === "text" ? "channel" : entry.channel.type;
|
|
22441
|
-
if (entry.surfaceReceipt.surfaceKind !== surfaceKind)
|
|
22442
|
-
ctx.addIssue({ code: "custom", path: ["surfaceReceipt", "surfaceKind"], message: "Conversation entry surface mismatch" });
|
|
22443
|
-
if (entry.channel.archived)
|
|
22444
|
-
ctx.addIssue({ code: "custom", path: ["channel", "archived"], message: "Conversation entry is archived" });
|
|
22445
|
-
const anchored = entry.selection.reason === "explicit_anchor" || entry.selection.reason === "read_pointer";
|
|
22446
|
-
if (anchored !== (entry.selection.anchorMessageId !== null))
|
|
22447
|
-
ctx.addIssue({ code: "custom", path: ["selection"], message: "Conversation entry selection mismatch" });
|
|
22448
|
-
if (entry.selection.reason === "read_pointer" && entry.selection.anchorMessageId !== entry.readState.lastReadMessageId)
|
|
22449
|
-
ctx.addIssue({ code: "custom", path: ["selection", "anchorMessageId"], message: "Conversation entry read pointer mismatch" });
|
|
22450
|
-
if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
|
|
22451
|
-
ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
|
|
22452
|
-
});
|
|
22453
|
-
var CommunityMessagePostedSchema = CommunityMessagesReadSchema.pick({ contractVersion: true, channelId: true }).extend({
|
|
22454
|
-
message: CommunityMessageResourceSchema,
|
|
22455
|
-
deduped: exports_external.boolean(),
|
|
22456
|
-
threadId: id.optional()
|
|
22457
|
-
});
|
|
22458
|
-
var CommunityMessageReadSchema = CommunityMessagePostedSchema.omit({ deduped: true, threadId: true });
|
|
22459
|
-
var CommunityMembersReadSchema = exports_external.strictObject({ ...envelope, relation: exports_external.enum(["access", "notify"]), members: exports_external.array(CommunityMemberRelationSchema), profiles: exports_external.array(CommunityResourceProfileSchema) });
|
|
22460
|
-
var CommunityThreadsReadSchema = exports_external.strictObject({
|
|
22461
|
-
...envelope,
|
|
22462
|
-
channel: CommunityChannelResourceSchema,
|
|
22463
|
-
threads: exports_external.array(CommunityChannelResourceSchema),
|
|
22464
|
-
included: exports_external.strictObject({
|
|
22465
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
22466
|
-
members: exports_external.array(CommunityMemberRelationSchema),
|
|
22467
|
-
profiles: exports_external.array(CommunityResourceProfileSchema),
|
|
22468
|
-
tags: exports_external.array(exports_external.strictObject({ messageId: id, tag: exports_external.string() })),
|
|
22469
|
-
participantCounts: exports_external.array(exports_external.strictObject({ channelId: id, count: exports_external.number().int().nonnegative() }))
|
|
22470
|
-
}),
|
|
22471
|
-
page: exports_external.strictObject({ nextCursor: exports_external.string().nullable(), hasMore: exports_external.boolean() })
|
|
22472
|
-
});
|
|
22473
|
-
var CommunityReadAdvanceSchema = exports_external.strictObject({ ...envelope, changed: exports_external.boolean(), targetSeq: exports_external.number().int().nonnegative(), revision: exports_external.number().int().nonnegative() });
|
|
22474
|
-
var CommunityReadErrorSchema = exports_external.strictObject({ contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), error: exports_external.strictObject({
|
|
22475
|
-
code: exports_external.enum(["invalid_input", "invalid_reply_target", "unauthenticated", "not_found", "not_allowed", "blocked", "idempotency_conflict", "rate_limited", "temporarily_unavailable"]),
|
|
22476
|
-
message: exports_external.string(),
|
|
22477
|
-
retryable: exports_external.boolean()
|
|
22478
|
-
}) });
|
|
22479
|
-
var legacyProfileSchema = CommunityResourceProfileSchema.pick({
|
|
22480
|
-
id: true,
|
|
22481
|
-
name: true,
|
|
22482
|
-
avatar: true,
|
|
22483
|
-
avatarVersion: true
|
|
22484
|
-
}).extend({ discriminator: exports_external.string().nullable(), statusEmoji: exports_external.string().nullable(), statusText: exports_external.string() });
|
|
22485
|
-
var CommunityLegacyMessageResourceSchema = CommunityMessageResourceSchema.extend({ authorAvatar: exports_external.string().optional(), attachments: exports_external.array(CommunityLegacyMessageAttachmentSchema), thread: legacyMessageThreadSchema.optional() });
|
|
22486
|
-
var legacyEnvelope = { contractVersion: exports_external.literal(2), channelId: id };
|
|
22487
|
-
var legacyReadSchemas = {
|
|
22488
|
-
channel: CommunityChannelReadSchema.extend(legacyEnvelope),
|
|
22489
|
-
messages: CommunityMessagesReadSchema.extend({ ...legacyEnvelope, messages: exports_external.array(CommunityLegacyMessageResourceSchema) }),
|
|
22490
|
-
members: CommunityMembersReadSchema.extend({ ...legacyEnvelope, profiles: exports_external.array(legacyProfileSchema) }),
|
|
22491
|
-
threads: CommunityThreadsReadSchema.extend({ ...legacyEnvelope, included: CommunityThreadsReadSchema.shape.included.extend({
|
|
22492
|
-
messages: exports_external.array(CommunityLegacyMessageResourceSchema),
|
|
22493
|
-
profiles: exports_external.array(legacyProfileSchema)
|
|
22494
|
-
}) }),
|
|
22495
|
-
readAdvance: CommunityReadAdvanceSchema.extend(legacyEnvelope),
|
|
22496
|
-
error: CommunityReadErrorSchema.extend({ contractVersion: exports_external.literal(2) })
|
|
22497
|
-
};
|
|
22498
|
-
var legacyChannelResourcePreviewSchema = CommunityChannelResourceSchema.partial().strip().extend({
|
|
22499
|
-
archived: legacyArchivedSchema.optional()
|
|
22500
|
-
});
|
|
22501
|
-
var legacyChannelResourceSchema = CommunityChannelResourceSchema.strip().extend({
|
|
22502
|
-
topic: CommunityChannelResourceSchema.shape.topic.nullish().transform((value) => value ?? ""),
|
|
22503
|
-
position: CommunityChannelResourceSchema.shape.position.nullish().transform((value) => value ?? 0),
|
|
22504
|
-
messageCount: CommunityChannelResourceSchema.shape.messageCount.nullish().transform((value) => value ?? 0),
|
|
22505
|
-
categoryId: nullableId.default(null),
|
|
22506
|
-
parentChannelId: nullableId.default(null),
|
|
22507
|
-
parentMessageId: nullableId.default(null),
|
|
22508
|
-
creatorId: nullableId.default(null),
|
|
22509
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null),
|
|
22510
|
-
archived: legacyArchivedSchema
|
|
22511
|
-
});
|
|
22512
|
-
var legacyMessageResourceSchema = CommunityLegacyMessageResourceSchema.strip().extend({
|
|
22513
|
-
channelId: id.optional(),
|
|
22514
|
-
replyToId: nullableId.optional(),
|
|
22515
|
-
clientNonce: CommunityMessageResourceSchema.shape.clientNonce.default(null),
|
|
22516
|
-
attachments: CommunityLegacyMessageResourceSchema.shape.attachments.default([]),
|
|
22517
|
-
embeds: CommunityMessageResourceSchema.shape.embeds.nullable().transform((value) => value ?? undefined)
|
|
22518
|
-
});
|
|
22519
|
-
|
|
22520
|
-
// ../shared/src/community-attention.ts
|
|
22521
|
-
var id2 = exports_external.string().min(1);
|
|
22522
|
-
var AttentionScopeSchema = exports_external.strictObject({
|
|
22523
|
-
scopeId: id2,
|
|
22524
|
-
channelId: id2,
|
|
22525
|
-
serverId: id2.nullable().optional(),
|
|
22526
|
-
parentChannelId: id2.nullable().optional(),
|
|
22527
|
-
ordinaryUnread: exports_external.boolean(),
|
|
22528
|
-
lastUnreadSeq: exports_external.number().int().nonnegative(),
|
|
22529
|
-
lastAttentionSeq: exports_external.number().int().nonnegative().nullable().optional(),
|
|
22530
|
-
attentionCount: exports_external.number().int().nonnegative()
|
|
22531
|
-
});
|
|
22532
|
-
var AttentionItemSchema = exports_external.strictObject({
|
|
22533
|
-
id: id2,
|
|
22534
|
-
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post"]),
|
|
22535
|
-
sourceId: id2,
|
|
22536
|
-
scopeId: id2.nullable().optional(),
|
|
22537
|
-
messageId: id2.nullable().optional(),
|
|
22538
|
-
actorUserId: id2.nullable().optional(),
|
|
22539
|
-
createdAt: exports_external.string(),
|
|
22540
|
-
childChannelId: id2.optional(),
|
|
22541
|
-
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
22542
|
-
readTarget: exports_external.strictObject({
|
|
22543
|
-
channelId: id2,
|
|
22544
|
-
seq: exports_external.number().int().nonnegative()
|
|
22545
|
-
}).optional()
|
|
22546
|
-
}).superRefine((item, ctx) => {
|
|
22547
|
-
if (item.kind === "friend_request") {
|
|
22548
|
-
if (!item.actorUserId || item.scopeId != null || item.messageId != null) {
|
|
22549
|
-
ctx.addIssue({ code: "custom", message: "friend request cannot reference a scope or message" });
|
|
22550
|
-
}
|
|
22551
|
-
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
22552
|
-
ctx.addIssue({ code: "custom", message: "friend request cannot carry forum presentation refs" });
|
|
22553
|
-
}
|
|
22554
|
-
return;
|
|
22555
|
-
}
|
|
22556
|
-
if (!item.scopeId || !item.messageId) {
|
|
22557
|
-
ctx.addIssue({ code: "custom", message: "message attention requires scope and message refs" });
|
|
22558
|
-
}
|
|
22559
|
-
if (item.kind === "forum_post") {
|
|
22560
|
-
if (item.actorUserId != null || !item.childChannelId || item.openerSeq === undefined || !item.readTarget || item.sourceId !== item.childChannelId || item.readTarget.seq !== item.openerSeq) {
|
|
22561
|
-
ctx.addIssue({ code: "custom", message: "forum post requires exact child, opener, and read-target refs" });
|
|
22562
|
-
}
|
|
22563
|
-
return;
|
|
22564
|
-
}
|
|
22565
|
-
if (!item.actorUserId) {
|
|
22566
|
-
ctx.addIssue({ code: "custom", message: "message attention requires an actor" });
|
|
22567
|
-
}
|
|
22568
|
-
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
22569
|
-
ctx.addIssue({ code: "custom", message: "mention or reply cannot carry forum presentation refs" });
|
|
22570
|
-
}
|
|
22571
|
-
});
|
|
22572
|
-
var AttentionIncludedServerSchema = exports_external.strictObject({
|
|
22573
|
-
id: id2,
|
|
22574
|
-
name: exports_external.string(),
|
|
22575
|
-
discriminator: exports_external.string()
|
|
22576
|
-
});
|
|
22577
|
-
var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
22578
|
-
id: true,
|
|
22579
|
-
serverId: true,
|
|
22580
|
-
name: true,
|
|
22581
|
-
type: true,
|
|
22582
|
-
parentChannelId: true,
|
|
22583
|
-
parentMessageId: true,
|
|
22584
|
-
creatorId: true,
|
|
22585
|
-
archived: true,
|
|
22586
|
-
lastMessageAt: true
|
|
22587
|
-
}).extend({
|
|
22588
|
-
serverId: CommunityChannelResourceSchema.shape.serverId.unwrap(),
|
|
22589
|
-
name: CommunityChannelResourceSchema.shape.name.unwrap(),
|
|
22590
|
-
type: CommunityChannelResourceSchema.shape.type.extract(["text", "forum", "thread"]),
|
|
22591
|
-
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
22592
|
-
openerUnread: exports_external.boolean().optional()
|
|
22593
|
-
});
|
|
22594
|
-
var AttentionIncludedDmSchema = exports_external.strictObject({
|
|
22595
|
-
id: id2,
|
|
22596
|
-
userId: id2,
|
|
22597
|
-
name: exports_external.string(),
|
|
22598
|
-
discriminator: exports_external.string(),
|
|
22599
|
-
avatar: exports_external.string(),
|
|
22600
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
22601
|
-
lastMessageAt: exports_external.string(),
|
|
22602
|
-
lastUnreadSeq: exports_external.number().int().nonnegative()
|
|
22603
|
-
});
|
|
22604
|
-
var AttentionIncludedProfileSchema = exports_external.strictObject({
|
|
22605
|
-
userId: CommunityResourceProfileSchema.shape.id,
|
|
22606
|
-
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
22607
|
-
discriminator: exports_external.string(),
|
|
22608
|
-
avatar: exports_external.string()
|
|
22609
|
-
});
|
|
22610
|
-
var AttentionIncludedMessageSchema = CommunityMessagePreviewSchema.pick({
|
|
22611
|
-
id: true,
|
|
22612
|
-
channelId: true,
|
|
22613
|
-
type: true,
|
|
22614
|
-
authorId: true,
|
|
22615
|
-
authorName: true,
|
|
22616
|
-
seq: true,
|
|
22617
|
-
createdAt: true,
|
|
22618
|
-
content: true
|
|
22619
|
-
}).required({ channelId: true, seq: true, createdAt: true, content: true });
|
|
22620
|
-
var AttentionIncludedSchema = exports_external.strictObject({
|
|
22621
|
-
servers: exports_external.array(AttentionIncludedServerSchema),
|
|
22622
|
-
channels: exports_external.array(AttentionIncludedChannelSchema),
|
|
22623
|
-
dms: exports_external.array(AttentionIncludedDmSchema),
|
|
22624
|
-
profiles: exports_external.array(AttentionIncludedProfileSchema),
|
|
22625
|
-
messages: exports_external.array(AttentionIncludedMessageSchema)
|
|
22626
|
-
});
|
|
22627
|
-
var AccountAttentionSnapshotSchema = exports_external.strictObject({
|
|
22628
|
-
scopes: exports_external.array(AttentionScopeSchema),
|
|
22629
|
-
items: exports_external.array(AttentionItemSchema),
|
|
22630
|
-
limit: exports_external.number().int().positive(),
|
|
22631
|
-
truncated: exports_external.boolean(),
|
|
22632
|
-
included: AttentionIncludedSchema
|
|
22633
|
-
}).superRefine((snapshot, ctx) => {
|
|
22634
|
-
const scopeIds = new Set;
|
|
22635
|
-
for (const scope of snapshot.scopes) {
|
|
22636
|
-
if (scopeIds.has(scope.scopeId)) {
|
|
22637
|
-
ctx.addIssue({ code: "custom", message: `duplicate attention scope: ${scope.scopeId}` });
|
|
22638
|
-
}
|
|
22639
|
-
scopeIds.add(scope.scopeId);
|
|
22640
|
-
}
|
|
22641
|
-
const itemIds = new Set;
|
|
22642
|
-
const serverById = new Map(snapshot.included.servers.map((server) => [server.id, server]));
|
|
22643
|
-
const channelById = new Map(snapshot.included.channels.map((channel2) => [channel2.id, channel2]));
|
|
22644
|
-
const dmById = new Map(snapshot.included.dms.map((dm) => [dm.id, dm]));
|
|
22645
|
-
const profileById = new Map(snapshot.included.profiles.map((profile2) => [profile2.userId, profile2]));
|
|
22646
|
-
const messageById = new Map(snapshot.included.messages.map((message2) => [message2.id, message2]));
|
|
22647
|
-
const rejectDuplicates = (values, kind) => {
|
|
22648
|
-
const seen = new Set;
|
|
22649
|
-
for (const value of values) {
|
|
22650
|
-
if (seen.has(value))
|
|
22651
|
-
ctx.addIssue({ code: "custom", message: `duplicate included ${kind}: ${value}` });
|
|
22652
|
-
seen.add(value);
|
|
22653
|
-
}
|
|
22654
|
-
};
|
|
22655
|
-
rejectDuplicates(snapshot.included.servers.map((server) => server.id), "server");
|
|
22656
|
-
rejectDuplicates(snapshot.included.channels.map((channel2) => channel2.id), "channel");
|
|
22657
|
-
rejectDuplicates(snapshot.included.dms.map((dm) => dm.id), "dm");
|
|
22658
|
-
rejectDuplicates(snapshot.included.profiles.map((profile2) => profile2.userId), "profile");
|
|
22659
|
-
rejectDuplicates(snapshot.included.messages.map((message2) => message2.id), "message");
|
|
22660
|
-
for (const scope of snapshot.scopes) {
|
|
22661
|
-
if (scope.serverId) {
|
|
22662
|
-
const channel2 = channelById.get(scope.channelId);
|
|
22663
|
-
if (!serverById.has(scope.serverId) || !channel2 || channel2.serverId !== scope.serverId) {
|
|
22664
|
-
ctx.addIssue({ code: "custom", message: `attention scope references missing owner: ${scope.scopeId}` });
|
|
22665
|
-
continue;
|
|
22666
|
-
}
|
|
22667
|
-
if (scope.parentChannelId) {
|
|
22668
|
-
const parent = channelById.get(scope.parentChannelId);
|
|
22669
|
-
const opener = channel2.parentMessageId ? messageById.get(channel2.parentMessageId) : undefined;
|
|
22670
|
-
if (channel2.parentChannelId !== scope.parentChannelId || !parent || parent.serverId !== scope.serverId || !opener || opener.channelId !== parent.id || channel2.openerSeq !== opener.seq || channel2.openerUnread === undefined) {
|
|
22671
|
-
ctx.addIssue({ code: "custom", message: `attention scope references missing parent: ${scope.scopeId}` });
|
|
22672
|
-
}
|
|
22673
|
-
} else if (channel2.parentChannelId !== null) {
|
|
22674
|
-
ctx.addIssue({ code: "custom", message: `attention scope parent mismatch: ${scope.scopeId}` });
|
|
22675
|
-
}
|
|
22676
|
-
} else {
|
|
22677
|
-
const dm = dmById.get(scope.channelId);
|
|
22678
|
-
if (!dm || !profileById.has(dm.userId)) {
|
|
22679
|
-
ctx.addIssue({ code: "custom", message: `attention scope references missing DM owner: ${scope.scopeId}` });
|
|
22680
|
-
}
|
|
22681
|
-
}
|
|
22682
|
-
}
|
|
22683
|
-
for (const item of snapshot.items) {
|
|
22684
|
-
if (itemIds.has(item.id)) {
|
|
22685
|
-
ctx.addIssue({ code: "custom", message: `duplicate attention item: ${item.id}` });
|
|
22686
|
-
}
|
|
22687
|
-
itemIds.add(item.id);
|
|
22688
|
-
if (item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
22689
|
-
ctx.addIssue({ code: "custom", message: `attention item references missing scope: ${item.scopeId}` });
|
|
22690
|
-
}
|
|
22691
|
-
if (item.kind === "friend_request") {
|
|
22692
|
-
if (!item.actorUserId || !profileById.has(item.actorUserId)) {
|
|
22693
|
-
ctx.addIssue({ code: "custom", message: `friend request references missing profile: ${item.id}` });
|
|
22694
|
-
}
|
|
22695
|
-
continue;
|
|
22696
|
-
}
|
|
22697
|
-
const scope = item.scopeId ? snapshot.scopes.find((candidate) => candidate.scopeId === item.scopeId) : undefined;
|
|
22698
|
-
const message2 = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
22699
|
-
if (!scope || !message2) {
|
|
22700
|
-
ctx.addIssue({ code: "custom", message: `attention item references missing message: ${item.id}` });
|
|
22701
|
-
continue;
|
|
22702
|
-
}
|
|
22703
|
-
if (item.kind === "forum_post") {
|
|
22704
|
-
const parent = channelById.get(scope.channelId);
|
|
22705
|
-
const child = item.childChannelId ? channelById.get(item.childChannelId) : undefined;
|
|
22706
|
-
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) {
|
|
22707
|
-
ctx.addIssue({ code: "custom", message: `forum post references incomplete presentation owners: ${item.id}` });
|
|
22708
|
-
}
|
|
22709
|
-
continue;
|
|
22710
|
-
}
|
|
22711
|
-
if (message2.channelId !== scope.channelId || !item.actorUserId || !profileById.has(item.actorUserId)) {
|
|
22712
|
-
ctx.addIssue({ code: "custom", message: `message attention references incomplete owners: ${item.id}` });
|
|
22713
|
-
}
|
|
22714
|
-
}
|
|
22715
|
-
});
|
|
22716
|
-
// ../shared/src/constants/community.ts
|
|
22717
|
-
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
22718
|
-
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
22719
|
-
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
22720
|
-
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
22721
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
22722
|
-
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
22723
|
-
var MAX_ATTACHMENT_THUMBNAIL_EDGE_PX = 720;
|
|
22724
|
-
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
22725
|
-
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
22726
|
-
var ALLOWED_ICON_MIME_TYPES = [
|
|
22727
|
-
"image/png",
|
|
22728
|
-
"image/jpeg",
|
|
22729
|
-
"image/webp",
|
|
22730
|
-
"image/gif"
|
|
22731
|
-
];
|
|
22732
|
-
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
22733
22237
|
// ../shared/src/provider-telemetry.ts
|
|
22734
22238
|
var DAILY_TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
22735
22239
|
var safeToken = exports_external.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
@@ -22817,74 +22321,24 @@ var ProviderQuotaSnapshotSchema = exports_external.object({
|
|
|
22817
22321
|
agentBackendId: exports_external.enum(["claude", "codex", "grok", "antigravity"]),
|
|
22818
22322
|
observation: ProviderQuotaObservationSchema
|
|
22819
22323
|
}).strict();
|
|
22820
|
-
|
|
22821
|
-
|
|
22822
|
-
|
|
22823
|
-
|
|
22824
|
-
|
|
22825
|
-
|
|
22826
|
-
|
|
22827
|
-
|
|
22828
|
-
|
|
22829
|
-
var
|
|
22830
|
-
var
|
|
22831
|
-
|
|
22832
|
-
|
|
22833
|
-
|
|
22834
|
-
|
|
22835
|
-
|
|
22836
|
-
|
|
22837
|
-
|
|
22838
|
-
var BillingOfferSchema = exports_external.object({
|
|
22839
|
-
priceId: exports_external.string().min(1),
|
|
22840
|
-
botLimit: exports_external.number().int().nonnegative(),
|
|
22841
|
-
machineLimit: exports_external.number().int().nonnegative(),
|
|
22842
|
-
plan: BillingPlanSchema,
|
|
22843
|
-
unitAmount: exports_external.number().int().nonnegative(),
|
|
22844
|
-
currency: exports_external.string().min(1),
|
|
22845
|
-
interval: exports_external.enum(["month", "year", "week", "day"]),
|
|
22846
|
-
intervalCount: exports_external.number().int().positive()
|
|
22847
|
-
});
|
|
22848
|
-
var BillingSubscriptionSchema = exports_external.object({
|
|
22849
|
-
plan: BillingPlanSchema,
|
|
22850
|
-
status: exports_external.string().min(1),
|
|
22851
|
-
currentPeriodEnd: exports_external.string().datetime().nullable(),
|
|
22852
|
-
cancelAt: exports_external.string().datetime().nullable(),
|
|
22853
|
-
scheduledChange: exports_external.object({
|
|
22854
|
-
plan: BillingPlanSchema,
|
|
22855
|
-
effectiveAt: exports_external.string().datetime()
|
|
22856
|
-
}).nullable()
|
|
22857
|
-
});
|
|
22858
|
-
var PublicPricingSchema = exports_external.object({
|
|
22859
|
-
free: exports_external.object({
|
|
22860
|
-
plan: BillingPlanSchema,
|
|
22861
|
-
botLimit: exports_external.number().int().nonnegative(),
|
|
22862
|
-
machineLimit: exports_external.number().int().nonnegative()
|
|
22863
|
-
}),
|
|
22864
|
-
offers: exports_external.array(BillingOfferSchema)
|
|
22865
|
-
});
|
|
22866
|
-
var BillingSummarySchema = exports_external.object({
|
|
22867
|
-
plan: BillingPlanSchema,
|
|
22868
|
-
isFounder: exports_external.boolean(),
|
|
22869
|
-
offers: exports_external.array(BillingOfferSchema),
|
|
22870
|
-
subscription: BillingSubscriptionSchema.nullable()
|
|
22871
|
-
});
|
|
22872
|
-
var BillingCheckoutRequestSchema = exports_external.strictObject({
|
|
22873
|
-
priceId: exports_external.string().min(1).max(255),
|
|
22874
|
-
founderAcknowledged: exports_external.boolean().optional()
|
|
22875
|
-
});
|
|
22876
|
-
var BillingPortalRequestSchema = exports_external.strictObject({
|
|
22877
|
-
priceId: exports_external.string().min(1).max(255).optional()
|
|
22878
|
-
});
|
|
22879
|
-
var BillingRedirectResponseSchema = exports_external.object({
|
|
22880
|
-
url: exports_external.string().url()
|
|
22881
|
-
});
|
|
22882
|
-
// ../shared/src/utils/slug.ts
|
|
22883
|
-
init_nanoid();
|
|
22884
|
-
var slugId = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz");
|
|
22885
|
-
function sanitizeSlug(input2) {
|
|
22886
|
-
return input2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
|
|
22887
|
-
}
|
|
22324
|
+
|
|
22325
|
+
// ../shared/src/constants/community.ts
|
|
22326
|
+
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
22327
|
+
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
22328
|
+
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
22329
|
+
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
22330
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
22331
|
+
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
22332
|
+
var MAX_ATTACHMENT_THUMBNAIL_EDGE_PX = 720;
|
|
22333
|
+
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
22334
|
+
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
22335
|
+
var ALLOWED_ICON_MIME_TYPES = [
|
|
22336
|
+
"image/png",
|
|
22337
|
+
"image/jpeg",
|
|
22338
|
+
"image/webp",
|
|
22339
|
+
"image/gif"
|
|
22340
|
+
];
|
|
22341
|
+
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
22888
22342
|
|
|
22889
22343
|
// ../shared/src/lib/community-name.ts
|
|
22890
22344
|
var FORBIDDEN_NAME_CHARS = /[#@\x00-\x1f\x7f-\x9f]/;
|
|
@@ -23425,6 +22879,7 @@ var RuntimeReasoningModelSchema = exports_external.object({
|
|
|
23425
22879
|
return defaultReasoningEffort !== undefined && model.supportedReasoningEfforts.some((option) => option.value === defaultReasoningEffort) ? { ...rest, defaultReasoningEffort } : rest;
|
|
23426
22880
|
});
|
|
23427
22881
|
var RuntimeReasoningCatalogSchema = exports_external.object({
|
|
22882
|
+
catalogOrigin: exports_external.enum(["native_report", "adapter_suggestions"]).optional().catch(undefined),
|
|
23428
22883
|
updateMode: exports_external.enum(["live_next_turn", "context_preserving_restart", "unsupported"]),
|
|
23429
22884
|
defaultModelId: exports_external.string().min(1).max(100).optional().catch(undefined),
|
|
23430
22885
|
models: exports_external.array(exports_external.unknown()).transform((models) => {
|
|
@@ -23478,11 +22933,11 @@ var HostRuntimeModelsFrameSchema = RuntimeModelDiscoveryRequestSchema.extend({
|
|
|
23478
22933
|
var CommunityRunningAgentListSchema = exports_external.array(exports_external.string()).transform((list) => {
|
|
23479
22934
|
const seen = new Set;
|
|
23480
22935
|
const out = [];
|
|
23481
|
-
for (const
|
|
23482
|
-
if (seen.has(
|
|
22936
|
+
for (const id of list) {
|
|
22937
|
+
if (seen.has(id))
|
|
23483
22938
|
continue;
|
|
23484
|
-
seen.add(
|
|
23485
|
-
out.push(
|
|
22939
|
+
seen.add(id);
|
|
22940
|
+
out.push(id);
|
|
23486
22941
|
}
|
|
23487
22942
|
return out;
|
|
23488
22943
|
});
|
|
@@ -23699,139 +23154,726 @@ var CommunityAgentResolveRequestSchema = exports_external.object({
|
|
|
23699
23154
|
channel: exports_external.string().min(1),
|
|
23700
23155
|
seq: CommunityAgentSeqSchema
|
|
23701
23156
|
});
|
|
23702
|
-
var CommunityAgentListChannelsRequestSchema = exports_external.object({
|
|
23703
|
-
server: exports_external.string().min(1).optional()
|
|
23157
|
+
var CommunityAgentListChannelsRequestSchema = exports_external.object({
|
|
23158
|
+
server: exports_external.string().min(1).optional()
|
|
23159
|
+
});
|
|
23160
|
+
var CommunityAgentListMembersRequestSchema = exports_external.object({
|
|
23161
|
+
server: exports_external.string().min(1),
|
|
23162
|
+
limit: exports_external.number().int().positive().optional(),
|
|
23163
|
+
cursor: exports_external.string().min(1).optional()
|
|
23164
|
+
});
|
|
23165
|
+
var CommunityAgentChannelMemberRequestSchema = exports_external.object({
|
|
23166
|
+
channel: exports_external.string().min(1),
|
|
23167
|
+
agentId: exports_external.string().optional()
|
|
23168
|
+
});
|
|
23169
|
+
var CommunityAgentJoinServerRequestSchema = exports_external.object({
|
|
23170
|
+
invite: exports_external.string().min(1)
|
|
23171
|
+
});
|
|
23172
|
+
var CommunityAgentNapRequestSchema = exports_external.object({
|
|
23173
|
+
handoff: exports_external.string().refine((value) => value.trim().length > 0, {
|
|
23174
|
+
message: "handoff must not be blank"
|
|
23175
|
+
}).optional()
|
|
23176
|
+
});
|
|
23177
|
+
var CommunityAgentMessagePropertyRequestSchema = exports_external.object({
|
|
23178
|
+
channel: exports_external.string().min(1),
|
|
23179
|
+
seq: CommunityAgentPositiveSeqSchema,
|
|
23180
|
+
property: exports_external.unknown()
|
|
23181
|
+
});
|
|
23182
|
+
var CommunityAgentFriendRequestSchema = exports_external.object({
|
|
23183
|
+
username: exports_external.string().min(1)
|
|
23184
|
+
});
|
|
23185
|
+
var CommunityAgentListFriendsSchema = exports_external.object({});
|
|
23186
|
+
var AuditLogCliInvocationPayloadSchema = exports_external.object({
|
|
23187
|
+
subcommand: exports_external.string().min(1),
|
|
23188
|
+
propertyType: exports_external.enum(["emoji", "tag", "mark"]).optional()
|
|
23189
|
+
});
|
|
23190
|
+
var AuditLogToolCallPayloadSchema = exports_external.object({
|
|
23191
|
+
name: exports_external.string().min(1),
|
|
23192
|
+
target: exports_external.string().max(240).optional()
|
|
23193
|
+
});
|
|
23194
|
+
var AuditLogThinkingPayloadSchema = exports_external.object({
|
|
23195
|
+
text: exports_external.string(),
|
|
23196
|
+
truncated: exports_external.boolean(),
|
|
23197
|
+
chars: exports_external.number().int().nonnegative()
|
|
23198
|
+
});
|
|
23199
|
+
var AuditLogTextPayloadSchema = exports_external.object({
|
|
23200
|
+
text: exports_external.string().min(1).max(BOT_AUDIT_TEXT_MAX_BYTES).refine((text2) => new TextEncoder().encode(text2).byteLength <= BOT_AUDIT_TEXT_MAX_BYTES, { message: "Text exceeds 1024 UTF-8 bytes" }),
|
|
23201
|
+
truncated: exports_external.boolean(),
|
|
23202
|
+
chars: exports_external.number().int().nonnegative()
|
|
23203
|
+
});
|
|
23204
|
+
var AuditLogTurnInterruptPayloadSchema = exports_external.object({
|
|
23205
|
+
status: exports_external.literal("accepted")
|
|
23206
|
+
});
|
|
23207
|
+
var AuditLogWakeTriggerPayloadSchema = exports_external.object({
|
|
23208
|
+
messageId: exports_external.string().min(1),
|
|
23209
|
+
channel: exports_external.string().min(1),
|
|
23210
|
+
seq: CommunityAgentPositiveSeqSchema,
|
|
23211
|
+
senderId: exports_external.string().min(1),
|
|
23212
|
+
senderHandle: exports_external.string().min(1),
|
|
23213
|
+
reason: exports_external.enum(["unread", "mention"])
|
|
23214
|
+
});
|
|
23215
|
+
var AuditLogSessionResetPayloadSchema = exports_external.object({
|
|
23216
|
+
trigger: exports_external.enum(["single", "reset_all", "idle_timeout"])
|
|
23217
|
+
});
|
|
23218
|
+
var AuditLogNapPayloadSchema = exports_external.object({
|
|
23219
|
+
trigger: exports_external.literal("nap")
|
|
23220
|
+
});
|
|
23221
|
+
var AuditLogModelChangedPayloadSchema = exports_external.object({
|
|
23222
|
+
from: exports_external.string().nullable(),
|
|
23223
|
+
to: exports_external.string().nullable()
|
|
23224
|
+
});
|
|
23225
|
+
var AuditLogProviderChangedPayloadSchema = exports_external.object({
|
|
23226
|
+
from: exports_external.string().min(1),
|
|
23227
|
+
to: exports_external.string().min(1)
|
|
23228
|
+
});
|
|
23229
|
+
var AuditLogErrorPayloadSchema = exports_external.object({
|
|
23230
|
+
scope: exports_external.enum(["spawn", "runtime", "exit", "handshake_timeout", "model_switch", "reset"]),
|
|
23231
|
+
code: exports_external.string().min(1).max(120),
|
|
23232
|
+
message: exports_external.string().max(2048),
|
|
23233
|
+
model: exports_external.string().nullable()
|
|
23234
|
+
});
|
|
23235
|
+
var BotAuditEventSchema = exports_external.discriminatedUnion("kind", [
|
|
23236
|
+
exports_external.object({ kind: exports_external.literal("cli_invocation"), payload: AuditLogCliInvocationPayloadSchema }),
|
|
23237
|
+
exports_external.object({ kind: exports_external.literal("tool_call"), payload: AuditLogToolCallPayloadSchema }),
|
|
23238
|
+
exports_external.object({ kind: exports_external.literal("thinking"), payload: AuditLogThinkingPayloadSchema }),
|
|
23239
|
+
exports_external.object({ kind: exports_external.literal("text"), payload: AuditLogTextPayloadSchema }),
|
|
23240
|
+
exports_external.object({ kind: exports_external.literal("turn_interrupt"), payload: AuditLogTurnInterruptPayloadSchema }),
|
|
23241
|
+
exports_external.object({ kind: exports_external.literal("wake_trigger"), payload: AuditLogWakeTriggerPayloadSchema }),
|
|
23242
|
+
exports_external.object({ kind: exports_external.literal("session_reset"), payload: AuditLogSessionResetPayloadSchema }),
|
|
23243
|
+
exports_external.object({ kind: exports_external.literal("nap"), payload: AuditLogNapPayloadSchema }),
|
|
23244
|
+
exports_external.object({ kind: exports_external.literal("model_changed"), payload: AuditLogModelChangedPayloadSchema }),
|
|
23245
|
+
exports_external.object({ kind: exports_external.literal("provider_changed"), payload: AuditLogProviderChangedPayloadSchema }),
|
|
23246
|
+
exports_external.object({ kind: exports_external.literal("error"), payload: AuditLogErrorPayloadSchema })
|
|
23247
|
+
]);
|
|
23248
|
+
var BotAuditEventKindSchema = exports_external.enum([
|
|
23249
|
+
"cli_invocation",
|
|
23250
|
+
"tool_call",
|
|
23251
|
+
"thinking",
|
|
23252
|
+
"text",
|
|
23253
|
+
"turn_interrupt",
|
|
23254
|
+
"wake_trigger",
|
|
23255
|
+
"session_reset",
|
|
23256
|
+
"nap",
|
|
23257
|
+
"model_changed",
|
|
23258
|
+
"provider_changed",
|
|
23259
|
+
"error"
|
|
23260
|
+
]);
|
|
23261
|
+
var HostBotAuditEventFrameSchema = exports_external.object({
|
|
23262
|
+
type: exports_external.literal("bot_audit_event"),
|
|
23263
|
+
eventId: exports_external.string().min(1).max(128).optional(),
|
|
23264
|
+
occurredAt: exports_external.string().datetime({ offset: true }).optional(),
|
|
23265
|
+
agentId: exports_external.string().min(1),
|
|
23266
|
+
sessionId: exports_external.string().nullable().optional(),
|
|
23267
|
+
launchId: exports_external.string().nullable().optional(),
|
|
23268
|
+
event: BotAuditEventSchema
|
|
23269
|
+
}).superRefine((frame, ctx) => {
|
|
23270
|
+
if (frame.event.kind === "session_reset" && frame.event.payload.trigger === "idle_timeout" && (!frame.eventId || !frame.occurredAt)) {
|
|
23271
|
+
if (!frame.eventId) {
|
|
23272
|
+
ctx.addIssue({
|
|
23273
|
+
code: "custom",
|
|
23274
|
+
path: ["eventId"],
|
|
23275
|
+
message: "eventId is required for idle_timeout session_reset"
|
|
23276
|
+
});
|
|
23277
|
+
}
|
|
23278
|
+
if (!frame.occurredAt) {
|
|
23279
|
+
ctx.addIssue({
|
|
23280
|
+
code: "custom",
|
|
23281
|
+
path: ["occurredAt"],
|
|
23282
|
+
message: "occurredAt is required for idle_timeout session_reset"
|
|
23283
|
+
});
|
|
23284
|
+
}
|
|
23285
|
+
}
|
|
23286
|
+
});
|
|
23287
|
+
var BotAuditEventAckFrameSchema = exports_external.strictObject({
|
|
23288
|
+
type: exports_external.literal("bot_audit_event_ack"),
|
|
23289
|
+
eventId: exports_external.string().min(1).max(128)
|
|
23290
|
+
});
|
|
23291
|
+
|
|
23292
|
+
// ../shared/src/community-bot-creation.ts
|
|
23293
|
+
var BOT_CREATION_MAX_ITEMS = 20;
|
|
23294
|
+
var BOT_CREATION_BODY_MAX_BYTES = 131072;
|
|
23295
|
+
var BotCreationProposalSchema = exports_external.strictObject({
|
|
23296
|
+
...CommunityBotCreateRequestSchema.omit({ runtime: true, image: true }).shape,
|
|
23297
|
+
backendId: exports_external.string().min(1).max(64),
|
|
23298
|
+
reason: exports_external.string().trim().min(1).max(1000)
|
|
23299
|
+
});
|
|
23300
|
+
var BotCreationSubmitSchema = exports_external.strictObject({
|
|
23301
|
+
requestId: exports_external.string().min(1).max(128),
|
|
23302
|
+
bots: exports_external.array(BotCreationProposalSchema).min(1).max(BOT_CREATION_MAX_ITEMS)
|
|
23303
|
+
});
|
|
23304
|
+
var BotCreationIdentitySchema = exports_external.strictObject({
|
|
23305
|
+
id: exports_external.string(),
|
|
23306
|
+
name: exports_external.string(),
|
|
23307
|
+
discriminator: exports_external.string(),
|
|
23308
|
+
image: exports_external.string().nullable(),
|
|
23309
|
+
avatarVersion: exports_external.number().int().nonnegative()
|
|
23310
|
+
});
|
|
23311
|
+
var BotCreationItemSchema = BotCreationProposalSchema.extend({
|
|
23312
|
+
itemId: exports_external.string(),
|
|
23313
|
+
description: exports_external.string(),
|
|
23314
|
+
model: exports_external.string().nullable(),
|
|
23315
|
+
reasoningEffort: exports_external.string().nullable(),
|
|
23316
|
+
machineName: exports_external.string(),
|
|
23317
|
+
createdBot: BotCreationIdentitySchema.nullable()
|
|
23318
|
+
});
|
|
23319
|
+
var BotCreationPayloadSchema = exports_external.strictObject({
|
|
23320
|
+
requestId: exports_external.string(),
|
|
23321
|
+
status: exports_external.enum(["pending", "approved", "declined"]),
|
|
23322
|
+
requesterId: exports_external.string(),
|
|
23323
|
+
ownerUserId: exports_external.string(),
|
|
23324
|
+
createdAt: exports_external.string(),
|
|
23325
|
+
resolvedAt: exports_external.string().nullable(),
|
|
23326
|
+
bots: exports_external.array(BotCreationItemSchema).min(1).max(BOT_CREATION_MAX_ITEMS)
|
|
23327
|
+
});
|
|
23328
|
+
var BotCreationDecisionSchema = exports_external.strictObject({ decision: exports_external.enum(["approve", "decline"]) });
|
|
23329
|
+
|
|
23330
|
+
// ../shared/src/community-resources.ts
|
|
23331
|
+
var id = exports_external.string().min(1);
|
|
23332
|
+
var nullableId = id.nullable();
|
|
23333
|
+
var legacyArchivedSchema = exports_external.union([exports_external.boolean(), exports_external.literal(0), exports_external.literal(1)]).transform((value) => value === true || value === 1);
|
|
23334
|
+
var CommunityChannelResourceSchema = exports_external.strictObject({
|
|
23335
|
+
id,
|
|
23336
|
+
type: exports_external.enum(["text", "forum", "thread", "dm"]),
|
|
23337
|
+
serverId: nullableId,
|
|
23338
|
+
categoryId: nullableId,
|
|
23339
|
+
name: exports_external.string().nullable(),
|
|
23340
|
+
topic: exports_external.string(),
|
|
23341
|
+
parentChannelId: nullableId,
|
|
23342
|
+
parentMessageId: nullableId,
|
|
23343
|
+
creatorId: nullableId,
|
|
23344
|
+
position: exports_external.number(),
|
|
23345
|
+
archived: exports_external.boolean(),
|
|
23346
|
+
createdAt: exports_external.string(),
|
|
23347
|
+
lastMessageAt: exports_external.string().nullable(),
|
|
23348
|
+
messageCount: exports_external.number().int().nonnegative()
|
|
23349
|
+
});
|
|
23350
|
+
var CommunityChannelIdentitySchema = CommunityChannelResourceSchema.pick({
|
|
23351
|
+
id: true,
|
|
23352
|
+
type: true,
|
|
23353
|
+
serverId: true,
|
|
23354
|
+
name: true,
|
|
23355
|
+
parentChannelId: true,
|
|
23356
|
+
parentMessageId: true,
|
|
23357
|
+
creatorId: true,
|
|
23358
|
+
archived: true,
|
|
23359
|
+
lastMessageAt: true,
|
|
23360
|
+
createdAt: true
|
|
23361
|
+
}).partial({ createdAt: true }).strip();
|
|
23362
|
+
var legacyChannelIdentitySchema = CommunityChannelIdentitySchema.extend({
|
|
23363
|
+
archived: legacyArchivedSchema,
|
|
23364
|
+
parentChannelId: nullableId.default(null),
|
|
23365
|
+
parentMessageId: nullableId.default(null),
|
|
23366
|
+
creatorId: nullableId.default(null),
|
|
23367
|
+
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null)
|
|
23368
|
+
});
|
|
23369
|
+
var CommunityAccessDecisionSchema = exports_external.strictObject({
|
|
23370
|
+
channelId: id,
|
|
23371
|
+
canRead: exports_external.boolean(),
|
|
23372
|
+
canSend: exports_external.boolean(),
|
|
23373
|
+
canCreateDiscussion: exports_external.boolean()
|
|
23374
|
+
});
|
|
23375
|
+
var CommunityLegacyMessageAttachmentSchema = exports_external.strictObject({
|
|
23376
|
+
kind: exports_external.enum(["image", "file"]),
|
|
23377
|
+
name: exports_external.string(),
|
|
23378
|
+
url: exports_external.string(),
|
|
23379
|
+
thumbnailUrl: exports_external.string().optional(),
|
|
23380
|
+
contentType: exports_external.string().optional(),
|
|
23381
|
+
size: exports_external.string().optional(),
|
|
23382
|
+
sizeBytes: exports_external.number().nonnegative().optional(),
|
|
23383
|
+
width: exports_external.number().nonnegative().optional(),
|
|
23384
|
+
height: exports_external.number().nonnegative().optional()
|
|
23385
|
+
});
|
|
23386
|
+
var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
23387
|
+
id,
|
|
23388
|
+
name: exports_external.string(),
|
|
23389
|
+
url: exports_external.string(),
|
|
23390
|
+
thumbnailUrl: exports_external.string().nullable(),
|
|
23391
|
+
contentType: exports_external.string().nullable(),
|
|
23392
|
+
sizeBytes: exports_external.number().int().nonnegative().nullable(),
|
|
23393
|
+
width: exports_external.number().int().nonnegative().nullable(),
|
|
23394
|
+
height: exports_external.number().int().nonnegative().nullable()
|
|
23395
|
+
});
|
|
23396
|
+
var CommunityMessagePreviewAttachmentSchema = CommunityMessageAttachmentSchema.partial().required({ name: true, url: true });
|
|
23397
|
+
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
23398
|
+
id,
|
|
23399
|
+
name: exports_external.string(),
|
|
23400
|
+
discriminator: exports_external.string().min(1).nullable(),
|
|
23401
|
+
avatar: exports_external.string().nullable(),
|
|
23402
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
23403
|
+
aboutMe: exports_external.string().optional(),
|
|
23404
|
+
bannerColor: exports_external.string().nullable().optional(),
|
|
23405
|
+
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
23406
|
+
ownerUserId: nullableId.optional(),
|
|
23407
|
+
ownerHandle: exports_external.string().nullable().optional(),
|
|
23408
|
+
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
23409
|
+
ownedByViewer: exports_external.boolean().optional(),
|
|
23410
|
+
statusEmoji: exports_external.string().nullable().optional(),
|
|
23411
|
+
statusText: exports_external.string().nullable().optional()
|
|
23412
|
+
});
|
|
23413
|
+
var CommunityMessageThreadParticipantSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatar: true, avatarVersion: true });
|
|
23414
|
+
var messageThreadSchema = exports_external.strictObject({
|
|
23415
|
+
id,
|
|
23416
|
+
name: CommunityChannelResourceSchema.shape.name,
|
|
23417
|
+
messageCount: CommunityChannelResourceSchema.shape.messageCount,
|
|
23418
|
+
lastReplyAt: CommunityChannelResourceSchema.shape.lastMessageAt.optional(),
|
|
23419
|
+
tags: exports_external.array(exports_external.string()).optional(),
|
|
23420
|
+
preview: exports_external.string().optional(),
|
|
23421
|
+
participants: exports_external.array(CommunityMessageThreadParticipantSchema).optional(),
|
|
23422
|
+
participantCount: exports_external.number().int().nonnegative().optional()
|
|
23423
|
+
});
|
|
23424
|
+
var legacyMessageThreadSchema = messageThreadSchema.extend({
|
|
23425
|
+
name: exports_external.string(),
|
|
23426
|
+
lastReplyAt: exports_external.string().optional(),
|
|
23427
|
+
participants: exports_external.array(CommunityMessageThreadParticipantSchema.extend({ avatar: exports_external.string() })).optional()
|
|
23428
|
+
});
|
|
23429
|
+
var messageThreadPreviewSchema = messageThreadSchema.partial().required({ id: true }).extend({
|
|
23430
|
+
participants: exports_external.array(CommunityMessageThreadParticipantSchema.partial().required({ id: true })).optional()
|
|
23431
|
+
});
|
|
23432
|
+
var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
23433
|
+
id,
|
|
23434
|
+
channelId: id,
|
|
23435
|
+
seq: exports_external.number().int().nonnegative(),
|
|
23436
|
+
authorId: id,
|
|
23437
|
+
createdAt: exports_external.string(),
|
|
23438
|
+
type: exports_external.enum(["chat", "system"]),
|
|
23439
|
+
content: exports_external.string(),
|
|
23440
|
+
replyToId: nullableId,
|
|
23441
|
+
clientNonce: exports_external.string().nullable(),
|
|
23442
|
+
attachments: exports_external.array(CommunityMessageAttachmentSchema),
|
|
23443
|
+
systemKind: exports_external.literal("thread").optional(),
|
|
23444
|
+
authorName: exports_external.string().optional(),
|
|
23445
|
+
authorAvatar: exports_external.string().nullable().optional(),
|
|
23446
|
+
authorAvatarVersion: exports_external.number().int().nonnegative().optional(),
|
|
23447
|
+
mentionType: exports_external.literal("everyone").nullable().optional(),
|
|
23448
|
+
replyTo: exports_external.strictObject({
|
|
23449
|
+
id,
|
|
23450
|
+
authorId: id.optional(),
|
|
23451
|
+
authorName: exports_external.string(),
|
|
23452
|
+
text: exports_external.string(),
|
|
23453
|
+
deleted: exports_external.boolean().optional()
|
|
23454
|
+
}).optional(),
|
|
23455
|
+
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
23456
|
+
reactions: exports_external.array(exports_external.strictObject({
|
|
23457
|
+
emoji: exports_external.string(),
|
|
23458
|
+
count: exports_external.number().int().nonnegative(),
|
|
23459
|
+
me: exports_external.boolean(),
|
|
23460
|
+
userIds: exports_external.array(id)
|
|
23461
|
+
})).optional(),
|
|
23462
|
+
thread: messageThreadSchema.optional(),
|
|
23463
|
+
approval: FriendApprovalPayloadSchema.optional(),
|
|
23464
|
+
botCreation: BotCreationPayloadSchema.optional()
|
|
23465
|
+
});
|
|
23466
|
+
var CommunityMessagePreviewSchema = CommunityMessageResourceSchema.partial().required({
|
|
23467
|
+
id: true,
|
|
23468
|
+
type: true
|
|
23469
|
+
}).extend({ attachments: exports_external.array(CommunityMessagePreviewAttachmentSchema).optional(), thread: messageThreadPreviewSchema.optional() });
|
|
23470
|
+
var CommunityReadStateResourceSchema = exports_external.strictObject({
|
|
23471
|
+
channelId: id,
|
|
23472
|
+
lastReadMessageId: nullableId,
|
|
23473
|
+
lastReadAt: exports_external.string().nullable(),
|
|
23474
|
+
lastReadSeq: exports_external.number().int().nonnegative()
|
|
23475
|
+
});
|
|
23476
|
+
var CommunityMemberRelationSchema = exports_external.strictObject({
|
|
23477
|
+
channelId: id,
|
|
23478
|
+
userId: id,
|
|
23479
|
+
relation: exports_external.enum(["access", "notify"]),
|
|
23480
|
+
source: exports_external.string(),
|
|
23481
|
+
isCreator: exports_external.boolean(),
|
|
23482
|
+
role: exports_external.string().nullable(),
|
|
23483
|
+
memberId: nullableId
|
|
23484
|
+
});
|
|
23485
|
+
var CommunityPageSchema = exports_external.strictObject({
|
|
23486
|
+
olderCursor: exports_external.string().nullable(),
|
|
23487
|
+
newerCursor: exports_external.string().nullable(),
|
|
23488
|
+
hasMoreOlder: exports_external.boolean(),
|
|
23489
|
+
hasMoreNewer: exports_external.boolean(),
|
|
23490
|
+
latestSeq: exports_external.number().int().nonnegative()
|
|
23491
|
+
});
|
|
23492
|
+
var envelope = { contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), channelId: id };
|
|
23493
|
+
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
23494
|
+
var CommunityMessagesReadSchema = exports_external.strictObject({
|
|
23495
|
+
...envelope,
|
|
23496
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
23497
|
+
page: CommunityPageSchema,
|
|
23498
|
+
surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
|
|
23499
|
+
});
|
|
23500
|
+
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
23501
|
+
viewerId: id,
|
|
23502
|
+
peer: CommunityResourceProfileSchema.nullable(),
|
|
23503
|
+
channel: CommunityChannelResourceSchema,
|
|
23504
|
+
access: CommunityAccessDecisionSchema.extend({ canRead: exports_external.literal(true) }),
|
|
23505
|
+
readState: CommunityReadStateResourceSchema,
|
|
23506
|
+
readStateRevision: exports_external.number().int().nonnegative(),
|
|
23507
|
+
forumFeed: exports_external.lazy(() => CommunityThreadsReadSchema).optional(),
|
|
23508
|
+
opener: CommunityMessageResourceSchema.optional(),
|
|
23509
|
+
parent: CommunityChannelResourceSchema.optional(),
|
|
23510
|
+
selection: exports_external.strictObject({
|
|
23511
|
+
reason: exports_external.enum(["explicit_anchor", "read_pointer", "tail", "read_pointer_missing"]),
|
|
23512
|
+
anchorMessageId: nullableId
|
|
23513
|
+
})
|
|
23514
|
+
}).superRefine((entry, ctx) => {
|
|
23515
|
+
for (const [path, channelId] of [
|
|
23516
|
+
[["channel", "id"], entry.channel.id],
|
|
23517
|
+
[["access", "channelId"], entry.access.channelId],
|
|
23518
|
+
[["readState", "channelId"], entry.readState.channelId],
|
|
23519
|
+
[["surfaceReceipt", "channelId"], entry.surfaceReceipt.channelId],
|
|
23520
|
+
...entry.messages.map((message2, index2) => [["messages", index2, "channelId"], message2.channelId])
|
|
23521
|
+
]) {
|
|
23522
|
+
if (channelId !== entry.channelId)
|
|
23523
|
+
ctx.addIssue({ code: "custom", path: [...path], message: "Conversation entry scope mismatch" });
|
|
23524
|
+
}
|
|
23525
|
+
if (entry.channel.type === "dm" !== (entry.peer !== null) || entry.peer?.id === entry.viewerId)
|
|
23526
|
+
ctx.addIssue({ code: "custom", path: ["peer"], message: "Conversation entry peer mismatch" });
|
|
23527
|
+
if (entry.opener && (entry.channel.type !== "thread" || entry.opener.id !== entry.channel.parentMessageId || entry.opener.channelId !== entry.channel.parentChannelId))
|
|
23528
|
+
ctx.addIssue({ code: "custom", path: ["opener"], message: "Conversation entry opener scope mismatch" });
|
|
23529
|
+
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"))
|
|
23530
|
+
ctx.addIssue({ code: "custom", path: ["parent"], message: "Conversation entry parent scope mismatch" });
|
|
23531
|
+
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)))
|
|
23532
|
+
ctx.addIssue({ code: "custom", path: ["forumFeed"], message: "Conversation entry forum scope mismatch" });
|
|
23533
|
+
if (entry.forumFeed) {
|
|
23534
|
+
const feed = entry.forumFeed, children = new Set(feed.threads.map((thread) => thread.id)), profiles = new Set(feed.included.profiles.map((profile2) => profile2.id));
|
|
23535
|
+
const openers = new Set(feed.threads.flatMap((thread) => thread.parentMessageId ? [thread.parentMessageId] : []));
|
|
23536
|
+
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)))
|
|
23537
|
+
ctx.addIssue({ code: "custom", path: ["forumFeed", "included"], message: "Conversation entry forum included scope mismatch" });
|
|
23538
|
+
}
|
|
23539
|
+
const surfaceKind = entry.channel.type === "text" ? "channel" : entry.channel.type;
|
|
23540
|
+
if (entry.surfaceReceipt.surfaceKind !== surfaceKind)
|
|
23541
|
+
ctx.addIssue({ code: "custom", path: ["surfaceReceipt", "surfaceKind"], message: "Conversation entry surface mismatch" });
|
|
23542
|
+
if (entry.channel.archived)
|
|
23543
|
+
ctx.addIssue({ code: "custom", path: ["channel", "archived"], message: "Conversation entry is archived" });
|
|
23544
|
+
const anchored = entry.selection.reason === "explicit_anchor" || entry.selection.reason === "read_pointer";
|
|
23545
|
+
if (anchored !== (entry.selection.anchorMessageId !== null))
|
|
23546
|
+
ctx.addIssue({ code: "custom", path: ["selection"], message: "Conversation entry selection mismatch" });
|
|
23547
|
+
if (entry.selection.reason === "read_pointer" && entry.selection.anchorMessageId !== entry.readState.lastReadMessageId)
|
|
23548
|
+
ctx.addIssue({ code: "custom", path: ["selection", "anchorMessageId"], message: "Conversation entry read pointer mismatch" });
|
|
23549
|
+
if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
|
|
23550
|
+
ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
|
|
23551
|
+
});
|
|
23552
|
+
var CommunityMessagePostedSchema = CommunityMessagesReadSchema.pick({ contractVersion: true, channelId: true }).extend({
|
|
23553
|
+
message: CommunityMessageResourceSchema,
|
|
23554
|
+
deduped: exports_external.boolean(),
|
|
23555
|
+
threadId: id.optional()
|
|
23556
|
+
});
|
|
23557
|
+
var CommunityMessageReadSchema = CommunityMessagePostedSchema.omit({ deduped: true, threadId: true });
|
|
23558
|
+
var CommunityMembersReadSchema = exports_external.strictObject({ ...envelope, relation: exports_external.enum(["access", "notify"]), members: exports_external.array(CommunityMemberRelationSchema), profiles: exports_external.array(CommunityResourceProfileSchema) });
|
|
23559
|
+
var CommunityThreadsReadSchema = exports_external.strictObject({
|
|
23560
|
+
...envelope,
|
|
23561
|
+
channel: CommunityChannelResourceSchema,
|
|
23562
|
+
threads: exports_external.array(CommunityChannelResourceSchema),
|
|
23563
|
+
included: exports_external.strictObject({
|
|
23564
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
23565
|
+
members: exports_external.array(CommunityMemberRelationSchema),
|
|
23566
|
+
profiles: exports_external.array(CommunityResourceProfileSchema),
|
|
23567
|
+
tags: exports_external.array(exports_external.strictObject({ messageId: id, tag: exports_external.string() })),
|
|
23568
|
+
participantCounts: exports_external.array(exports_external.strictObject({ channelId: id, count: exports_external.number().int().nonnegative() }))
|
|
23569
|
+
}),
|
|
23570
|
+
page: exports_external.strictObject({ nextCursor: exports_external.string().nullable(), hasMore: exports_external.boolean() })
|
|
23571
|
+
});
|
|
23572
|
+
var CommunityReadAdvanceSchema = exports_external.strictObject({ ...envelope, changed: exports_external.boolean(), targetSeq: exports_external.number().int().nonnegative(), revision: exports_external.number().int().nonnegative() });
|
|
23573
|
+
var CommunityReadErrorSchema = exports_external.strictObject({ contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), error: exports_external.strictObject({
|
|
23574
|
+
code: exports_external.enum(["invalid_input", "invalid_reply_target", "unauthenticated", "not_found", "not_allowed", "blocked", "idempotency_conflict", "rate_limited", "temporarily_unavailable"]),
|
|
23575
|
+
message: exports_external.string(),
|
|
23576
|
+
retryable: exports_external.boolean()
|
|
23577
|
+
}) });
|
|
23578
|
+
var legacyProfileSchema = CommunityResourceProfileSchema.pick({
|
|
23579
|
+
id: true,
|
|
23580
|
+
name: true,
|
|
23581
|
+
avatar: true,
|
|
23582
|
+
avatarVersion: true
|
|
23583
|
+
}).extend({ discriminator: exports_external.string().nullable(), statusEmoji: exports_external.string().nullable(), statusText: exports_external.string() });
|
|
23584
|
+
var CommunityLegacyMessageResourceSchema = CommunityMessageResourceSchema.extend({ authorAvatar: exports_external.string().optional(), attachments: exports_external.array(CommunityLegacyMessageAttachmentSchema), thread: legacyMessageThreadSchema.optional() });
|
|
23585
|
+
var legacyEnvelope = { contractVersion: exports_external.literal(2), channelId: id };
|
|
23586
|
+
var legacyReadSchemas = {
|
|
23587
|
+
channel: CommunityChannelReadSchema.extend(legacyEnvelope),
|
|
23588
|
+
messages: CommunityMessagesReadSchema.extend({ ...legacyEnvelope, messages: exports_external.array(CommunityLegacyMessageResourceSchema) }),
|
|
23589
|
+
members: CommunityMembersReadSchema.extend({ ...legacyEnvelope, profiles: exports_external.array(legacyProfileSchema) }),
|
|
23590
|
+
threads: CommunityThreadsReadSchema.extend({ ...legacyEnvelope, included: CommunityThreadsReadSchema.shape.included.extend({
|
|
23591
|
+
messages: exports_external.array(CommunityLegacyMessageResourceSchema),
|
|
23592
|
+
profiles: exports_external.array(legacyProfileSchema)
|
|
23593
|
+
}) }),
|
|
23594
|
+
readAdvance: CommunityReadAdvanceSchema.extend(legacyEnvelope),
|
|
23595
|
+
error: CommunityReadErrorSchema.extend({ contractVersion: exports_external.literal(2) })
|
|
23596
|
+
};
|
|
23597
|
+
var legacyChannelResourcePreviewSchema = CommunityChannelResourceSchema.partial().strip().extend({
|
|
23598
|
+
archived: legacyArchivedSchema.optional()
|
|
23704
23599
|
});
|
|
23705
|
-
var
|
|
23706
|
-
|
|
23707
|
-
|
|
23708
|
-
|
|
23600
|
+
var legacyChannelResourceSchema = CommunityChannelResourceSchema.strip().extend({
|
|
23601
|
+
topic: CommunityChannelResourceSchema.shape.topic.nullish().transform((value) => value ?? ""),
|
|
23602
|
+
position: CommunityChannelResourceSchema.shape.position.nullish().transform((value) => value ?? 0),
|
|
23603
|
+
messageCount: CommunityChannelResourceSchema.shape.messageCount.nullish().transform((value) => value ?? 0),
|
|
23604
|
+
categoryId: nullableId.default(null),
|
|
23605
|
+
parentChannelId: nullableId.default(null),
|
|
23606
|
+
parentMessageId: nullableId.default(null),
|
|
23607
|
+
creatorId: nullableId.default(null),
|
|
23608
|
+
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null),
|
|
23609
|
+
archived: legacyArchivedSchema
|
|
23709
23610
|
});
|
|
23710
|
-
var
|
|
23711
|
-
|
|
23712
|
-
|
|
23611
|
+
var legacyMessageResourceSchema = CommunityLegacyMessageResourceSchema.strip().extend({
|
|
23612
|
+
channelId: id.optional(),
|
|
23613
|
+
replyToId: nullableId.optional(),
|
|
23614
|
+
clientNonce: CommunityMessageResourceSchema.shape.clientNonce.default(null),
|
|
23615
|
+
attachments: CommunityLegacyMessageResourceSchema.shape.attachments.default([]),
|
|
23616
|
+
embeds: CommunityMessageResourceSchema.shape.embeds.nullable().transform((value) => value ?? undefined)
|
|
23713
23617
|
});
|
|
23714
|
-
|
|
23715
|
-
|
|
23618
|
+
|
|
23619
|
+
// ../shared/src/community-attention.ts
|
|
23620
|
+
var id2 = exports_external.string().min(1);
|
|
23621
|
+
var AttentionScopeSchema = exports_external.strictObject({
|
|
23622
|
+
scopeId: id2,
|
|
23623
|
+
channelId: id2,
|
|
23624
|
+
serverId: id2.nullable().optional(),
|
|
23625
|
+
parentChannelId: id2.nullable().optional(),
|
|
23626
|
+
ordinaryUnread: exports_external.boolean(),
|
|
23627
|
+
lastUnreadSeq: exports_external.number().int().nonnegative(),
|
|
23628
|
+
unreadCount: exports_external.number().int().nonnegative().optional(),
|
|
23629
|
+
lastAttentionSeq: exports_external.number().int().nonnegative().nullable().optional(),
|
|
23630
|
+
attentionCount: exports_external.number().int().nonnegative()
|
|
23716
23631
|
});
|
|
23717
|
-
var
|
|
23718
|
-
|
|
23719
|
-
|
|
23632
|
+
var AttentionItemSchema = exports_external.strictObject({
|
|
23633
|
+
id: id2,
|
|
23634
|
+
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post"]),
|
|
23635
|
+
sourceId: id2,
|
|
23636
|
+
scopeId: id2.nullable().optional(),
|
|
23637
|
+
messageId: id2.nullable().optional(),
|
|
23638
|
+
actorUserId: id2.nullable().optional(),
|
|
23639
|
+
createdAt: exports_external.string(),
|
|
23640
|
+
childChannelId: id2.optional(),
|
|
23641
|
+
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
23642
|
+
readTarget: exports_external.strictObject({
|
|
23643
|
+
channelId: id2,
|
|
23644
|
+
seq: exports_external.number().int().nonnegative()
|
|
23720
23645
|
}).optional()
|
|
23646
|
+
}).superRefine((item, ctx) => {
|
|
23647
|
+
if (item.kind === "friend_request") {
|
|
23648
|
+
if (!item.actorUserId || item.scopeId != null || item.messageId != null) {
|
|
23649
|
+
ctx.addIssue({ code: "custom", message: "friend request cannot reference a scope or message" });
|
|
23650
|
+
}
|
|
23651
|
+
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
23652
|
+
ctx.addIssue({ code: "custom", message: "friend request cannot carry forum presentation refs" });
|
|
23653
|
+
}
|
|
23654
|
+
return;
|
|
23655
|
+
}
|
|
23656
|
+
if (!item.scopeId || !item.messageId) {
|
|
23657
|
+
ctx.addIssue({ code: "custom", message: "message attention requires scope and message refs" });
|
|
23658
|
+
}
|
|
23659
|
+
if (item.kind === "forum_post") {
|
|
23660
|
+
if (item.actorUserId != null || !item.childChannelId || item.openerSeq === undefined || !item.readTarget || item.sourceId !== item.childChannelId || item.readTarget.seq !== item.openerSeq) {
|
|
23661
|
+
ctx.addIssue({ code: "custom", message: "forum post requires exact child, opener, and read-target refs" });
|
|
23662
|
+
}
|
|
23663
|
+
return;
|
|
23664
|
+
}
|
|
23665
|
+
if (!item.actorUserId) {
|
|
23666
|
+
ctx.addIssue({ code: "custom", message: "message attention requires an actor" });
|
|
23667
|
+
}
|
|
23668
|
+
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
23669
|
+
ctx.addIssue({ code: "custom", message: "mention or reply cannot carry forum presentation refs" });
|
|
23670
|
+
}
|
|
23721
23671
|
});
|
|
23722
|
-
var
|
|
23723
|
-
|
|
23724
|
-
|
|
23725
|
-
|
|
23672
|
+
var AttentionIncludedServerSchema = exports_external.strictObject({
|
|
23673
|
+
id: id2,
|
|
23674
|
+
name: exports_external.string(),
|
|
23675
|
+
discriminator: exports_external.string()
|
|
23726
23676
|
});
|
|
23727
|
-
var
|
|
23728
|
-
|
|
23677
|
+
var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
23678
|
+
id: true,
|
|
23679
|
+
serverId: true,
|
|
23680
|
+
name: true,
|
|
23681
|
+
type: true,
|
|
23682
|
+
parentChannelId: true,
|
|
23683
|
+
parentMessageId: true,
|
|
23684
|
+
creatorId: true,
|
|
23685
|
+
archived: true,
|
|
23686
|
+
lastMessageAt: true
|
|
23687
|
+
}).extend({
|
|
23688
|
+
serverId: CommunityChannelResourceSchema.shape.serverId.unwrap(),
|
|
23689
|
+
name: CommunityChannelResourceSchema.shape.name.unwrap(),
|
|
23690
|
+
type: CommunityChannelResourceSchema.shape.type.extract(["text", "forum", "thread"]),
|
|
23691
|
+
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
23692
|
+
openerUnread: exports_external.boolean().optional()
|
|
23729
23693
|
});
|
|
23730
|
-
var
|
|
23731
|
-
|
|
23732
|
-
|
|
23733
|
-
|
|
23694
|
+
var AttentionIncludedDmSchema = exports_external.strictObject({
|
|
23695
|
+
id: id2,
|
|
23696
|
+
userId: id2,
|
|
23697
|
+
name: exports_external.string(),
|
|
23698
|
+
discriminator: exports_external.string(),
|
|
23699
|
+
avatar: exports_external.string(),
|
|
23700
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
23701
|
+
lastMessageAt: exports_external.string(),
|
|
23702
|
+
lastUnreadSeq: exports_external.number().int().nonnegative()
|
|
23734
23703
|
});
|
|
23735
|
-
var
|
|
23736
|
-
|
|
23737
|
-
|
|
23704
|
+
var AttentionIncludedProfileSchema = exports_external.strictObject({
|
|
23705
|
+
userId: CommunityResourceProfileSchema.shape.id,
|
|
23706
|
+
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
23707
|
+
discriminator: exports_external.string(),
|
|
23708
|
+
avatar: exports_external.string()
|
|
23738
23709
|
});
|
|
23739
|
-
var
|
|
23740
|
-
|
|
23741
|
-
|
|
23742
|
-
|
|
23710
|
+
var AttentionIncludedMessageSchema = CommunityMessagePreviewSchema.pick({
|
|
23711
|
+
id: true,
|
|
23712
|
+
channelId: true,
|
|
23713
|
+
type: true,
|
|
23714
|
+
authorId: true,
|
|
23715
|
+
authorName: true,
|
|
23716
|
+
seq: true,
|
|
23717
|
+
createdAt: true,
|
|
23718
|
+
content: true
|
|
23719
|
+
}).required({ channelId: true, seq: true, createdAt: true, content: true });
|
|
23720
|
+
var AttentionIncludedSchema = exports_external.strictObject({
|
|
23721
|
+
servers: exports_external.array(AttentionIncludedServerSchema),
|
|
23722
|
+
channels: exports_external.array(AttentionIncludedChannelSchema),
|
|
23723
|
+
dms: exports_external.array(AttentionIncludedDmSchema),
|
|
23724
|
+
profiles: exports_external.array(AttentionIncludedProfileSchema),
|
|
23725
|
+
messages: exports_external.array(AttentionIncludedMessageSchema)
|
|
23743
23726
|
});
|
|
23744
|
-
var
|
|
23745
|
-
|
|
23727
|
+
var AccountAttentionSnapshotSchema = exports_external.strictObject({
|
|
23728
|
+
scopes: exports_external.array(AttentionScopeSchema),
|
|
23729
|
+
items: exports_external.array(AttentionItemSchema),
|
|
23730
|
+
limit: exports_external.number().int().positive(),
|
|
23746
23731
|
truncated: exports_external.boolean(),
|
|
23747
|
-
|
|
23732
|
+
included: AttentionIncludedSchema
|
|
23733
|
+
}).superRefine((snapshot, ctx) => {
|
|
23734
|
+
const scopeIds = new Set;
|
|
23735
|
+
for (const scope of snapshot.scopes) {
|
|
23736
|
+
if (scopeIds.has(scope.scopeId)) {
|
|
23737
|
+
ctx.addIssue({ code: "custom", message: `duplicate attention scope: ${scope.scopeId}` });
|
|
23738
|
+
}
|
|
23739
|
+
scopeIds.add(scope.scopeId);
|
|
23740
|
+
}
|
|
23741
|
+
const itemIds = new Set;
|
|
23742
|
+
const serverById = new Map(snapshot.included.servers.map((server) => [server.id, server]));
|
|
23743
|
+
const channelById = new Map(snapshot.included.channels.map((channel2) => [channel2.id, channel2]));
|
|
23744
|
+
const dmById = new Map(snapshot.included.dms.map((dm) => [dm.id, dm]));
|
|
23745
|
+
const profileById = new Map(snapshot.included.profiles.map((profile2) => [profile2.userId, profile2]));
|
|
23746
|
+
const messageById = new Map(snapshot.included.messages.map((message2) => [message2.id, message2]));
|
|
23747
|
+
const rejectDuplicates = (values, kind) => {
|
|
23748
|
+
const seen = new Set;
|
|
23749
|
+
for (const value of values) {
|
|
23750
|
+
if (seen.has(value))
|
|
23751
|
+
ctx.addIssue({ code: "custom", message: `duplicate included ${kind}: ${value}` });
|
|
23752
|
+
seen.add(value);
|
|
23753
|
+
}
|
|
23754
|
+
};
|
|
23755
|
+
rejectDuplicates(snapshot.included.servers.map((server) => server.id), "server");
|
|
23756
|
+
rejectDuplicates(snapshot.included.channels.map((channel2) => channel2.id), "channel");
|
|
23757
|
+
rejectDuplicates(snapshot.included.dms.map((dm) => dm.id), "dm");
|
|
23758
|
+
rejectDuplicates(snapshot.included.profiles.map((profile2) => profile2.userId), "profile");
|
|
23759
|
+
rejectDuplicates(snapshot.included.messages.map((message2) => message2.id), "message");
|
|
23760
|
+
for (const scope of snapshot.scopes) {
|
|
23761
|
+
if (scope.serverId) {
|
|
23762
|
+
const channel2 = channelById.get(scope.channelId);
|
|
23763
|
+
if (!serverById.has(scope.serverId) || !channel2 || channel2.serverId !== scope.serverId) {
|
|
23764
|
+
ctx.addIssue({ code: "custom", message: `attention scope references missing owner: ${scope.scopeId}` });
|
|
23765
|
+
continue;
|
|
23766
|
+
}
|
|
23767
|
+
if (scope.parentChannelId) {
|
|
23768
|
+
const parent = channelById.get(scope.parentChannelId);
|
|
23769
|
+
const opener = channel2.parentMessageId ? messageById.get(channel2.parentMessageId) : undefined;
|
|
23770
|
+
if (channel2.parentChannelId !== scope.parentChannelId || !parent || parent.serverId !== scope.serverId || !opener || opener.channelId !== parent.id || channel2.openerSeq !== opener.seq || channel2.openerUnread === undefined) {
|
|
23771
|
+
ctx.addIssue({ code: "custom", message: `attention scope references missing parent: ${scope.scopeId}` });
|
|
23772
|
+
}
|
|
23773
|
+
} else if (channel2.parentChannelId !== null) {
|
|
23774
|
+
ctx.addIssue({ code: "custom", message: `attention scope parent mismatch: ${scope.scopeId}` });
|
|
23775
|
+
}
|
|
23776
|
+
} else {
|
|
23777
|
+
const dm = dmById.get(scope.channelId);
|
|
23778
|
+
if (!dm || !profileById.has(dm.userId)) {
|
|
23779
|
+
ctx.addIssue({ code: "custom", message: `attention scope references missing DM owner: ${scope.scopeId}` });
|
|
23780
|
+
}
|
|
23781
|
+
}
|
|
23782
|
+
}
|
|
23783
|
+
for (const item of snapshot.items) {
|
|
23784
|
+
if (itemIds.has(item.id)) {
|
|
23785
|
+
ctx.addIssue({ code: "custom", message: `duplicate attention item: ${item.id}` });
|
|
23786
|
+
}
|
|
23787
|
+
itemIds.add(item.id);
|
|
23788
|
+
if (item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
23789
|
+
ctx.addIssue({ code: "custom", message: `attention item references missing scope: ${item.scopeId}` });
|
|
23790
|
+
}
|
|
23791
|
+
if (item.kind === "friend_request") {
|
|
23792
|
+
if (!item.actorUserId || !profileById.has(item.actorUserId)) {
|
|
23793
|
+
ctx.addIssue({ code: "custom", message: `friend request references missing profile: ${item.id}` });
|
|
23794
|
+
}
|
|
23795
|
+
continue;
|
|
23796
|
+
}
|
|
23797
|
+
const scope = item.scopeId ? snapshot.scopes.find((candidate) => candidate.scopeId === item.scopeId) : undefined;
|
|
23798
|
+
const message2 = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
23799
|
+
if (!scope || !message2) {
|
|
23800
|
+
ctx.addIssue({ code: "custom", message: `attention item references missing message: ${item.id}` });
|
|
23801
|
+
continue;
|
|
23802
|
+
}
|
|
23803
|
+
if (item.kind === "forum_post") {
|
|
23804
|
+
const parent = channelById.get(scope.channelId);
|
|
23805
|
+
const child = item.childChannelId ? channelById.get(item.childChannelId) : undefined;
|
|
23806
|
+
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) {
|
|
23807
|
+
ctx.addIssue({ code: "custom", message: `forum post references incomplete presentation owners: ${item.id}` });
|
|
23808
|
+
}
|
|
23809
|
+
continue;
|
|
23810
|
+
}
|
|
23811
|
+
if (message2.channelId !== scope.channelId || !item.actorUserId || !profileById.has(item.actorUserId)) {
|
|
23812
|
+
ctx.addIssue({ code: "custom", message: `message attention references incomplete owners: ${item.id}` });
|
|
23813
|
+
}
|
|
23814
|
+
}
|
|
23748
23815
|
});
|
|
23749
|
-
|
|
23750
|
-
|
|
23816
|
+
// ../shared/src/product-entitlements.ts
|
|
23817
|
+
var EntitlementValueSchema = exports_external.lazy(() => exports_external.union([
|
|
23818
|
+
exports_external.null(),
|
|
23819
|
+
exports_external.boolean(),
|
|
23820
|
+
exports_external.number().finite(),
|
|
23821
|
+
exports_external.string(),
|
|
23822
|
+
exports_external.array(EntitlementValueSchema),
|
|
23823
|
+
exports_external.record(exports_external.string(), EntitlementValueSchema)
|
|
23824
|
+
]));
|
|
23825
|
+
var NonNegativeIntegerEntitlementSchema = exports_external.number().int().nonnegative();
|
|
23826
|
+
var CommunityBotActivationRequestSchema = exports_external.strictObject({
|
|
23827
|
+
active: exports_external.boolean()
|
|
23751
23828
|
});
|
|
23752
|
-
|
|
23753
|
-
|
|
23754
|
-
|
|
23755
|
-
|
|
23756
|
-
senderId: exports_external.string().min(1),
|
|
23757
|
-
senderHandle: exports_external.string().min(1),
|
|
23758
|
-
reason: exports_external.enum(["unread", "mention"])
|
|
23829
|
+
// ../shared/src/billing.ts
|
|
23830
|
+
var BillingPlanSchema = exports_external.object({
|
|
23831
|
+
id: exports_external.string().min(1),
|
|
23832
|
+
displayName: exports_external.string().min(1)
|
|
23759
23833
|
});
|
|
23760
|
-
var
|
|
23761
|
-
|
|
23834
|
+
var BillingOfferSchema = exports_external.object({
|
|
23835
|
+
priceId: exports_external.string().min(1),
|
|
23836
|
+
botLimit: exports_external.number().int().nonnegative(),
|
|
23837
|
+
machineLimit: exports_external.number().int().nonnegative(),
|
|
23838
|
+
plan: BillingPlanSchema,
|
|
23839
|
+
unitAmount: exports_external.number().int().nonnegative(),
|
|
23840
|
+
currency: exports_external.string().min(1),
|
|
23841
|
+
interval: exports_external.enum(["month", "year", "week", "day"]),
|
|
23842
|
+
intervalCount: exports_external.number().int().positive()
|
|
23762
23843
|
});
|
|
23763
|
-
var
|
|
23764
|
-
|
|
23844
|
+
var BillingSubscriptionSchema = exports_external.object({
|
|
23845
|
+
plan: BillingPlanSchema,
|
|
23846
|
+
status: exports_external.string().min(1),
|
|
23847
|
+
currentPeriodEnd: exports_external.string().datetime().nullable(),
|
|
23848
|
+
cancelAt: exports_external.string().datetime().nullable(),
|
|
23849
|
+
scheduledChange: exports_external.object({
|
|
23850
|
+
plan: BillingPlanSchema,
|
|
23851
|
+
effectiveAt: exports_external.string().datetime()
|
|
23852
|
+
}).nullable()
|
|
23765
23853
|
});
|
|
23766
|
-
var
|
|
23767
|
-
|
|
23768
|
-
|
|
23854
|
+
var PublicPricingSchema = exports_external.object({
|
|
23855
|
+
free: exports_external.object({
|
|
23856
|
+
plan: BillingPlanSchema,
|
|
23857
|
+
botLimit: exports_external.number().int().nonnegative(),
|
|
23858
|
+
machineLimit: exports_external.number().int().nonnegative()
|
|
23859
|
+
}),
|
|
23860
|
+
offers: exports_external.array(BillingOfferSchema)
|
|
23769
23861
|
});
|
|
23770
|
-
var
|
|
23771
|
-
|
|
23772
|
-
|
|
23862
|
+
var BillingSummarySchema = exports_external.object({
|
|
23863
|
+
plan: BillingPlanSchema,
|
|
23864
|
+
isFounder: exports_external.boolean(),
|
|
23865
|
+
offers: exports_external.array(BillingOfferSchema),
|
|
23866
|
+
subscription: BillingSubscriptionSchema.nullable()
|
|
23773
23867
|
});
|
|
23774
|
-
var
|
|
23775
|
-
|
|
23776
|
-
|
|
23777
|
-
message: exports_external.string().max(2048),
|
|
23778
|
-
model: exports_external.string().nullable()
|
|
23868
|
+
var BillingCheckoutRequestSchema = exports_external.strictObject({
|
|
23869
|
+
priceId: exports_external.string().min(1).max(255),
|
|
23870
|
+
founderAcknowledged: exports_external.boolean().optional()
|
|
23779
23871
|
});
|
|
23780
|
-
var
|
|
23781
|
-
|
|
23782
|
-
exports_external.object({ kind: exports_external.literal("tool_call"), payload: AuditLogToolCallPayloadSchema }),
|
|
23783
|
-
exports_external.object({ kind: exports_external.literal("thinking"), payload: AuditLogThinkingPayloadSchema }),
|
|
23784
|
-
exports_external.object({ kind: exports_external.literal("text"), payload: AuditLogTextPayloadSchema }),
|
|
23785
|
-
exports_external.object({ kind: exports_external.literal("turn_interrupt"), payload: AuditLogTurnInterruptPayloadSchema }),
|
|
23786
|
-
exports_external.object({ kind: exports_external.literal("wake_trigger"), payload: AuditLogWakeTriggerPayloadSchema }),
|
|
23787
|
-
exports_external.object({ kind: exports_external.literal("session_reset"), payload: AuditLogSessionResetPayloadSchema }),
|
|
23788
|
-
exports_external.object({ kind: exports_external.literal("nap"), payload: AuditLogNapPayloadSchema }),
|
|
23789
|
-
exports_external.object({ kind: exports_external.literal("model_changed"), payload: AuditLogModelChangedPayloadSchema }),
|
|
23790
|
-
exports_external.object({ kind: exports_external.literal("provider_changed"), payload: AuditLogProviderChangedPayloadSchema }),
|
|
23791
|
-
exports_external.object({ kind: exports_external.literal("error"), payload: AuditLogErrorPayloadSchema })
|
|
23792
|
-
]);
|
|
23793
|
-
var BotAuditEventKindSchema = exports_external.enum([
|
|
23794
|
-
"cli_invocation",
|
|
23795
|
-
"tool_call",
|
|
23796
|
-
"thinking",
|
|
23797
|
-
"text",
|
|
23798
|
-
"turn_interrupt",
|
|
23799
|
-
"wake_trigger",
|
|
23800
|
-
"session_reset",
|
|
23801
|
-
"nap",
|
|
23802
|
-
"model_changed",
|
|
23803
|
-
"provider_changed",
|
|
23804
|
-
"error"
|
|
23805
|
-
]);
|
|
23806
|
-
var HostBotAuditEventFrameSchema = exports_external.object({
|
|
23807
|
-
type: exports_external.literal("bot_audit_event"),
|
|
23808
|
-
eventId: exports_external.string().min(1).max(128).optional(),
|
|
23809
|
-
occurredAt: exports_external.string().datetime({ offset: true }).optional(),
|
|
23810
|
-
agentId: exports_external.string().min(1),
|
|
23811
|
-
sessionId: exports_external.string().nullable().optional(),
|
|
23812
|
-
launchId: exports_external.string().nullable().optional(),
|
|
23813
|
-
event: BotAuditEventSchema
|
|
23814
|
-
}).superRefine((frame, ctx) => {
|
|
23815
|
-
if (frame.event.kind === "session_reset" && frame.event.payload.trigger === "idle_timeout" && (!frame.eventId || !frame.occurredAt)) {
|
|
23816
|
-
if (!frame.eventId) {
|
|
23817
|
-
ctx.addIssue({
|
|
23818
|
-
code: "custom",
|
|
23819
|
-
path: ["eventId"],
|
|
23820
|
-
message: "eventId is required for idle_timeout session_reset"
|
|
23821
|
-
});
|
|
23822
|
-
}
|
|
23823
|
-
if (!frame.occurredAt) {
|
|
23824
|
-
ctx.addIssue({
|
|
23825
|
-
code: "custom",
|
|
23826
|
-
path: ["occurredAt"],
|
|
23827
|
-
message: "occurredAt is required for idle_timeout session_reset"
|
|
23828
|
-
});
|
|
23829
|
-
}
|
|
23830
|
-
}
|
|
23872
|
+
var BillingPortalRequestSchema = exports_external.strictObject({
|
|
23873
|
+
priceId: exports_external.string().min(1).max(255).optional()
|
|
23831
23874
|
});
|
|
23832
|
-
var
|
|
23833
|
-
|
|
23834
|
-
eventId: exports_external.string().min(1).max(128)
|
|
23875
|
+
var BillingRedirectResponseSchema = exports_external.object({
|
|
23876
|
+
url: exports_external.string().url()
|
|
23835
23877
|
});
|
|
23836
23878
|
// ../shared/src/utils/day-key.ts
|
|
23837
23879
|
function utcDayKey(now) {
|
|
@@ -23873,6 +23915,7 @@ function dayKeyInTimeZone(now, timeZone) {
|
|
|
23873
23915
|
var exports_community_schema = {};
|
|
23874
23916
|
__export(exports_community_schema, {
|
|
23875
23917
|
communityUserProfile: () => communityUserProfile,
|
|
23918
|
+
communityServerRail: () => communityServerRail,
|
|
23876
23919
|
communityServerMember: () => communityServerMember,
|
|
23877
23920
|
communityServerInvite: () => communityServerInvite,
|
|
23878
23921
|
communityServerFolderItem: () => communityServerFolderItem,
|
|
@@ -23991,20 +24034,21 @@ var communityServerMember = sqliteTable("community_server_member", {
|
|
|
23991
24034
|
serverId: text("server_id").notNull().references(() => communityServer.id, { onDelete: "cascade" }),
|
|
23992
24035
|
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
23993
24036
|
role: text("role").default("member"),
|
|
23994
|
-
railOrder: integer2("rail_order").default(0),
|
|
23995
24037
|
joinedAt: text("joined_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
23996
24038
|
}, (t) => [
|
|
23997
24039
|
unique("uq_server_member_server_user").on(t.serverId, t.userId),
|
|
23998
24040
|
index("idx_server_member_user").on(t.userId),
|
|
23999
|
-
index("idx_server_member_user_rail_order").on(t.userId, t.railOrder),
|
|
24000
24041
|
index("idx_server_member_server_joined").on(t.serverId, t.joinedAt)
|
|
24001
24042
|
]);
|
|
24043
|
+
var communityServerRail = sqliteTable("community_server_rail", {
|
|
24044
|
+
userId: text("user_id").primaryKey().references(() => user.id, { onDelete: "cascade" }),
|
|
24045
|
+
entries: text("entries", { mode: "json" }).$type().notNull()
|
|
24046
|
+
});
|
|
24002
24047
|
var communityServerFolder = sqliteTable("community_server_folder", {
|
|
24003
24048
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
24004
24049
|
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
24005
|
-
name: text("name").notNull()
|
|
24006
|
-
|
|
24007
|
-
}, (t) => [index("idx_server_folder_user_position").on(t.userId, t.position)]);
|
|
24050
|
+
name: text("name").notNull()
|
|
24051
|
+
}, (t) => [index("idx_server_folder_user").on(t.userId)]);
|
|
24008
24052
|
var communityServerFolderItem = sqliteTable("community_server_folder_item", {
|
|
24009
24053
|
folderId: text("folder_id").notNull().references(() => communityServerFolder.id, { onDelete: "cascade" }),
|
|
24010
24054
|
serverId: text("server_id").notNull().references(() => communityServer.id, { onDelete: "cascade" }),
|
|
@@ -24223,6 +24267,43 @@ function maxRowsPerInsert(paramsPerRow) {
|
|
|
24223
24267
|
return Math.floor(D1_MAX_BIND_PARAMS / paramsPerRow);
|
|
24224
24268
|
}
|
|
24225
24269
|
|
|
24270
|
+
// ../shared/src/community-server-rail.ts
|
|
24271
|
+
var MAX_SERVER_RAIL_COMMANDS = 3;
|
|
24272
|
+
var idSchema = exports_external.string().trim().min(1);
|
|
24273
|
+
var idsSchema = exports_external.array(idSchema);
|
|
24274
|
+
var serverRailEntrySchema = exports_external.discriminatedUnion("kind", [
|
|
24275
|
+
exports_external.strictObject({ kind: exports_external.literal("server"), id: idSchema }),
|
|
24276
|
+
exports_external.strictObject({ kind: exports_external.literal("folder"), id: idSchema })
|
|
24277
|
+
]);
|
|
24278
|
+
var reorderTopLevelSchema = exports_external.strictObject({
|
|
24279
|
+
kind: exports_external.literal("reorder-top-level"),
|
|
24280
|
+
entries: exports_external.array(serverRailEntrySchema)
|
|
24281
|
+
});
|
|
24282
|
+
var replaceFolderItemsSchema = exports_external.strictObject({
|
|
24283
|
+
kind: exports_external.literal("replace-folder-items"),
|
|
24284
|
+
folderId: idSchema,
|
|
24285
|
+
serverIds: idsSchema.min(1)
|
|
24286
|
+
});
|
|
24287
|
+
var deleteFolderSchema = exports_external.strictObject({
|
|
24288
|
+
kind: exports_external.literal("delete-folder"),
|
|
24289
|
+
folderId: idSchema
|
|
24290
|
+
});
|
|
24291
|
+
var createFolderSchema = exports_external.strictObject({
|
|
24292
|
+
kind: exports_external.literal("create-folder"),
|
|
24293
|
+
clientId: idSchema,
|
|
24294
|
+
name: exports_external.string().trim().min(1).max(MAX_FOLDER_NAME_LENGTH),
|
|
24295
|
+
serverIds: idsSchema.min(1)
|
|
24296
|
+
});
|
|
24297
|
+
var serverRailCommandSchema = exports_external.discriminatedUnion("kind", [
|
|
24298
|
+
reorderTopLevelSchema,
|
|
24299
|
+
replaceFolderItemsSchema,
|
|
24300
|
+
deleteFolderSchema,
|
|
24301
|
+
createFolderSchema
|
|
24302
|
+
]);
|
|
24303
|
+
var serverRailCommitRequestSchema = exports_external.strictObject({
|
|
24304
|
+
commands: exports_external.array(serverRailCommandSchema).min(1).max(MAX_SERVER_RAIL_COMMANDS)
|
|
24305
|
+
});
|
|
24306
|
+
|
|
24226
24307
|
// ../shared/src/db/queries/community/channel.ts
|
|
24227
24308
|
var CHANNEL_COLUMNS = {
|
|
24228
24309
|
id: communityChannel.id,
|
|
@@ -24467,7 +24548,8 @@ var messageSchema = CommunityMessageResourceSchema.pick({
|
|
|
24467
24548
|
mentionType: true,
|
|
24468
24549
|
embeds: true,
|
|
24469
24550
|
createdAt: true,
|
|
24470
|
-
approval: true
|
|
24551
|
+
approval: true,
|
|
24552
|
+
botCreation: true
|
|
24471
24553
|
}).extend({
|
|
24472
24554
|
id: string4,
|
|
24473
24555
|
seq: exports_external.number(),
|
|
@@ -24494,8 +24576,9 @@ var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
|
24494
24576
|
type: exports_external.literal("community:message.updated"),
|
|
24495
24577
|
channelId: string4,
|
|
24496
24578
|
messageId: string4,
|
|
24497
|
-
approval: FriendApprovalPayloadSchema
|
|
24498
|
-
|
|
24579
|
+
approval: FriendApprovalPayloadSchema.optional(),
|
|
24580
|
+
botCreation: BotCreationPayloadSchema.optional()
|
|
24581
|
+
}).refine((event) => event.approval !== undefined || event.botCreation !== undefined);
|
|
24499
24582
|
var communityMessageEditedSchema = exports_external.strictObject({
|
|
24500
24583
|
type: exports_external.literal("community:message.edited"),
|
|
24501
24584
|
channelId: string4,
|
|
@@ -24575,6 +24658,9 @@ var communityServerUpdateSchema = exports_external.strictObject({
|
|
|
24575
24658
|
icon: nullableString.optional()
|
|
24576
24659
|
})
|
|
24577
24660
|
});
|
|
24661
|
+
var communityServerRailChangedSchema = exports_external.strictObject({
|
|
24662
|
+
type: exports_external.literal("community:server_rail.changed")
|
|
24663
|
+
});
|
|
24578
24664
|
var communityServerDeleteSchema = exports_external.strictObject({
|
|
24579
24665
|
type: exports_external.literal("community:server.delete"),
|
|
24580
24666
|
serverId: string4
|
|
@@ -24841,6 +24927,7 @@ var commonCommunityEventSchemas = [
|
|
|
24841
24927
|
communityTypingStartSchema,
|
|
24842
24928
|
communityTypingStopSchema,
|
|
24843
24929
|
communityServerUpdateSchema,
|
|
24930
|
+
communityServerRailChangedSchema,
|
|
24844
24931
|
communityServerDeleteSchema,
|
|
24845
24932
|
communityChannelDeleteSchema,
|
|
24846
24933
|
communityChannelReorderSchema,
|
|
@@ -24908,6 +24995,7 @@ var WS_EVENTS = {
|
|
|
24908
24995
|
CHILD_CHANNEL_CREATE: "community:channel.child_create",
|
|
24909
24996
|
CHILD_CHANNEL_UPDATE: "community:channel.child_update",
|
|
24910
24997
|
SERVER_UPDATE: "community:server.update",
|
|
24998
|
+
SERVER_RAIL_CHANGED: "community:server_rail.changed",
|
|
24911
24999
|
SERVER_DELETE: "community:server.delete",
|
|
24912
25000
|
CHANNEL_CREATE: "community:channel.create",
|
|
24913
25001
|
CHANNEL_UPDATE: "community:channel.update",
|
|
@@ -25096,45 +25184,26 @@ var communityFunnelAnalyticsEvent = sqliteTable("community_funnel_analytics_even
|
|
|
25096
25184
|
index("idx_community_funnel_analytics_owner_claimed_created").on(t.ownerUserId, t.claimedAt, t.createdAt)
|
|
25097
25185
|
]);
|
|
25098
25186
|
|
|
25099
|
-
// ../shared/src/db/
|
|
25100
|
-
var
|
|
25101
|
-
|
|
25102
|
-
|
|
25103
|
-
var idSchema = exports_external.string().trim().min(1);
|
|
25104
|
-
var idsSchema = exports_external.array(idSchema);
|
|
25105
|
-
var reorderServersSchema = exports_external.strictObject({
|
|
25106
|
-
kind: exports_external.literal("reorder-servers"),
|
|
25107
|
-
serverIds: idsSchema
|
|
25108
|
-
});
|
|
25109
|
-
var reorderFoldersSchema = exports_external.strictObject({
|
|
25110
|
-
kind: exports_external.literal("reorder-folders"),
|
|
25111
|
-
folderIds: idsSchema
|
|
25112
|
-
});
|
|
25113
|
-
var replaceFolderItemsSchema = exports_external.strictObject({
|
|
25114
|
-
kind: exports_external.literal("replace-folder-items"),
|
|
25115
|
-
folderId: idSchema,
|
|
25116
|
-
serverIds: idsSchema.min(1)
|
|
25117
|
-
});
|
|
25118
|
-
var deleteFolderSchema = exports_external.strictObject({
|
|
25119
|
-
kind: exports_external.literal("delete-folder"),
|
|
25120
|
-
folderId: idSchema
|
|
25121
|
-
});
|
|
25122
|
-
var createFolderSchema = exports_external.strictObject({
|
|
25123
|
-
kind: exports_external.literal("create-folder"),
|
|
25124
|
-
clientId: idSchema,
|
|
25125
|
-
name: exports_external.string().trim().min(1).max(MAX_FOLDER_NAME_LENGTH),
|
|
25126
|
-
serverIds: idsSchema.min(1)
|
|
25127
|
-
});
|
|
25128
|
-
var serverRailCommandSchema = exports_external.discriminatedUnion("kind", [
|
|
25129
|
-
reorderServersSchema,
|
|
25130
|
-
reorderFoldersSchema,
|
|
25131
|
-
replaceFolderItemsSchema,
|
|
25132
|
-
deleteFolderSchema,
|
|
25133
|
-
createFolderSchema
|
|
25134
|
-
]);
|
|
25135
|
-
var serverRailCommitRequestSchema = exports_external.strictObject({
|
|
25136
|
-
commands: exports_external.array(serverRailCommandSchema).min(1).max(MAX_SERVER_RAIL_COMMANDS)
|
|
25187
|
+
// ../shared/src/db/bot-creation-schema.ts
|
|
25188
|
+
var exports_bot_creation_schema = {};
|
|
25189
|
+
__export(exports_bot_creation_schema, {
|
|
25190
|
+
communityBotCreationRequest: () => communityBotCreationRequest
|
|
25137
25191
|
});
|
|
25192
|
+
var communityBotCreationRequest = sqliteTable("community_bot_creation_request", {
|
|
25193
|
+
id: text("id").primaryKey(),
|
|
25194
|
+
requesterId: text("requester_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
25195
|
+
ownerId: text("owner_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
25196
|
+
channelId: text("channel_id").notNull().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
25197
|
+
messageId: text("message_id").notNull().unique().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
25198
|
+
status: text("status", { enum: ["pending", "approved", "declined"] }).notNull().default("pending"),
|
|
25199
|
+
bots: text("bots", { mode: "json" }).$type().notNull(),
|
|
25200
|
+
decisionNonce: text("decision_nonce"),
|
|
25201
|
+
createdAt: text("created_at").notNull(),
|
|
25202
|
+
resolvedAt: text("resolved_at")
|
|
25203
|
+
}, (t) => [index("idx_bot_creation_requester").on(t.requesterId, t.createdAt), index("idx_bot_creation_owner").on(t.ownerId, t.createdAt)]);
|
|
25204
|
+
|
|
25205
|
+
// ../shared/src/db/index.ts
|
|
25206
|
+
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 };
|
|
25138
25207
|
// ../shared/src/db/queries/native-oauth.ts
|
|
25139
25208
|
var ATTEMPT_TTL_MS = 10 * 60 * 1000;
|
|
25140
25209
|
var HANDOFF_TTL_MS = 2 * 60 * 1000;
|
|
@@ -25297,7 +25366,87 @@ function releaseVersionGte(a, b) {
|
|
|
25297
25366
|
}
|
|
25298
25367
|
return true;
|
|
25299
25368
|
}
|
|
25369
|
+
// ../shared/src/community-channel-order.ts
|
|
25370
|
+
var channelReorderRequestSchema = exports_external.strictObject({
|
|
25371
|
+
channelIds: exports_external.array(exports_external.string().min(1)).min(1).refine((ids) => new Set(ids).size === ids.length, "channelIds must be unique"),
|
|
25372
|
+
move: exports_external.strictObject({ channelId: exports_external.string().min(1), categoryId: exports_external.string().min(1).nullable() }).optional()
|
|
25373
|
+
}).refine((request) => !request.move || request.channelIds.includes(request.move.channelId), "moved channel must be included in channelIds");
|
|
25374
|
+
// src/cli/platform.ts
|
|
25375
|
+
var failure2 = (message2, code, details) => Object.assign(new Error(message2), { code, platformDetails: details });
|
|
25376
|
+
function registerPlatformCommands(program, getApi, output2) {
|
|
25377
|
+
const platform = program.command("platform").description("owner-scoped platform capabilities").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
25378
|
+
const machine2 = platform.command("machine").description("read machines, backends, models and model-specific effort").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).option("--list", "list your owner's machines").option("--backends", "show backends on --id").option("--models", "show models and effort for --id and --backend").option("--id <id>", "owner machine ID").option("--backend <id>", "backend ID from the selected machine").option("--model <id>", "show effort for this full model ID").option("--refresh", "ask the target to refresh its reported models");
|
|
25379
|
+
machine2.action(async () => {
|
|
25380
|
+
const opts = machine2.opts();
|
|
25381
|
+
const actions = [opts.list, opts.backends, opts.models].filter(Boolean).length;
|
|
25382
|
+
if (!actions && Object.keys(opts).length === 0) {
|
|
25383
|
+
output2({ success: { usage: machine2.helpInformation() } });
|
|
25384
|
+
return;
|
|
25385
|
+
}
|
|
25386
|
+
if (actions !== 1)
|
|
25387
|
+
throw failure2("Choose one action: --list, --backends, or --models", "INVALID_ACTION");
|
|
25388
|
+
if (opts.list && (opts.id || opts.backend || opts.model || opts.refresh))
|
|
25389
|
+
throw failure2("--list does not accept target or model flags", "INVALID_ACTION");
|
|
25390
|
+
if (!opts.list && !opts.id)
|
|
25391
|
+
throw failure2("--id is required", "MACHINE_REQUIRED");
|
|
25392
|
+
if (opts.backends && (opts.backend || opts.model || opts.refresh))
|
|
25393
|
+
throw failure2("--backends only accepts --id", "INVALID_ACTION");
|
|
25394
|
+
if (opts.models && !opts.backend)
|
|
25395
|
+
throw failure2("--models requires --backend", "BACKEND_REQUIRED");
|
|
25396
|
+
const api2 = getApi();
|
|
25397
|
+
if (!api2.platformMachine)
|
|
25398
|
+
throw failure2("Platform machine commands are unavailable", "UPGRADE_REQUIRED");
|
|
25399
|
+
const result = await api2.platformMachine(opts.list ? { action: "list" } : opts.backends ? { action: "backends", machineId: opts.id } : { action: "models", machineId: opts.id, backendId: opts.backend, ...opts.model ? { model: opts.model } : {}, refresh: opts.refresh === true, ...opts.refresh ? { requestId: randomUUID() } : {} });
|
|
25400
|
+
output2({ success: result });
|
|
25401
|
+
});
|
|
25402
|
+
const bot = platform.command("bot").description("read bots or request owner-approved creation").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).option("--list", "list your owner's bot summaries").option("--create <bot-json>", "request one bot; repeat for one gallery request", (value, previous) => [...previous, value], []);
|
|
25403
|
+
bot.action(async () => {
|
|
25404
|
+
const opts = bot.opts();
|
|
25405
|
+
const values = opts.create;
|
|
25406
|
+
const actions = [opts.list, values.length > 0].filter(Boolean).length;
|
|
25407
|
+
if (!actions) {
|
|
25408
|
+
output2({ success: { usage: bot.helpInformation() } });
|
|
25409
|
+
return;
|
|
25410
|
+
}
|
|
25411
|
+
if (actions !== 1)
|
|
25412
|
+
throw failure2("Choose one action: --list or one or more --create values", "INVALID_ACTION");
|
|
25413
|
+
const api2 = getApi();
|
|
25414
|
+
if (!api2.platformBot)
|
|
25415
|
+
throw failure2("Platform bot commands are unavailable", "UPGRADE_REQUIRED");
|
|
25416
|
+
if (opts.list) {
|
|
25417
|
+
output2({ success: await api2.platformBot({ action: "list" }) });
|
|
25418
|
+
return;
|
|
25419
|
+
}
|
|
25420
|
+
if (Buffer.byteLength(values.join(""), "utf8") > BOT_CREATION_BODY_MAX_BYTES)
|
|
25421
|
+
throw failure2("Creation request is too large", "REQUEST_TOO_LARGE");
|
|
25422
|
+
const bots = values.map((value, index2) => {
|
|
25423
|
+
try {
|
|
25424
|
+
return JSON.parse(value);
|
|
25425
|
+
} catch {
|
|
25426
|
+
throw failure2("Invalid bot JSON", "INVALID_PROPOSAL", { itemIndex: index2 + 1 });
|
|
25427
|
+
}
|
|
25428
|
+
});
|
|
25429
|
+
const parsed = BotCreationSubmitSchema.safeParse({ requestId: randomUUID(), bots });
|
|
25430
|
+
if (!parsed.success) {
|
|
25431
|
+
const issue3 = parsed.error.issues[0];
|
|
25432
|
+
const field = issue3.path.at(-1);
|
|
25433
|
+
const itemIndex = typeof issue3.path[1] === "number" ? issue3.path[1] + 1 : undefined;
|
|
25434
|
+
throw failure2(issue3.message, field === "reason" && issue3.code === "too_small" ? "REASON_REQUIRED" : "INVALID_PROPOSAL", { ...itemIndex ? { itemIndex } : {}, field });
|
|
25435
|
+
}
|
|
25436
|
+
if (Buffer.byteLength(JSON.stringify(parsed.data), "utf8") > BOT_CREATION_BODY_MAX_BYTES)
|
|
25437
|
+
throw failure2("Creation request is too large", "REQUEST_TOO_LARGE");
|
|
25438
|
+
output2({ success: await api2.platformBot({ action: "create", ...parsed.data }) });
|
|
25439
|
+
});
|
|
25440
|
+
}
|
|
25441
|
+
|
|
25442
|
+
// src/cli/index.ts
|
|
25443
|
+
import { Command, CommanderError } from "commander";
|
|
25444
|
+
import { realpathSync as realpathSync2 } from "node:fs";
|
|
25445
|
+
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
25446
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
25300
25447
|
// src/cli/proxyServerApi.ts
|
|
25448
|
+
import * as fs from "fs";
|
|
25449
|
+
import * as path from "path";
|
|
25301
25450
|
function proxyServerApiFromEnv(prefix = "ALOOK", env = process.env) {
|
|
25302
25451
|
const proxyUrl = env[`${prefix}_PROXY_URL`];
|
|
25303
25452
|
const tokenFile = env[`${prefix}_PROXY_TOKEN_FILE`];
|
|
@@ -25343,6 +25492,8 @@ function createProxyServerApi(config2) {
|
|
|
25343
25492
|
e.code = json2.code;
|
|
25344
25493
|
if (json2?.hint !== undefined)
|
|
25345
25494
|
e.hint = json2.hint;
|
|
25495
|
+
const safeFields = ["requestId", "machineId", "backendId", "itemIndex", "field", "required", "available", "status", "allowedValues"];
|
|
25496
|
+
e.platformDetails = Object.fromEntries(Object.entries(json2 ?? {}).filter(([key]) => safeFields.includes(key)));
|
|
25346
25497
|
throw e;
|
|
25347
25498
|
}
|
|
25348
25499
|
return json2;
|
|
@@ -25692,7 +25843,32 @@ function createProxyServerApi(config2) {
|
|
|
25692
25843
|
await parseJsonResponse(res, "leaveServer");
|
|
25693
25844
|
return { left: req.server, scope: "server" };
|
|
25694
25845
|
}
|
|
25846
|
+
async function platformCall(path2, method = "GET", body) {
|
|
25847
|
+
const response = await fetchImpl(`${base}/api/community${path2}`, {
|
|
25848
|
+
method,
|
|
25849
|
+
headers: { authorization: `Bearer ${config2.voucher}`, ...body === undefined ? {} : { "content-type": "application/json" } },
|
|
25850
|
+
...body === undefined ? {} : { body: JSON.stringify(body) }
|
|
25851
|
+
});
|
|
25852
|
+
return parseJsonResponse(response, "platform");
|
|
25853
|
+
}
|
|
25854
|
+
async function callPlatformMachine(req) {
|
|
25855
|
+
if (req.action === "list")
|
|
25856
|
+
return platformCall("/machines?view=list");
|
|
25857
|
+
const machine2 = `/machines/${encodeURIComponent(req.machineId)}`;
|
|
25858
|
+
if (req.action === "backends")
|
|
25859
|
+
return platformCall(machine2);
|
|
25860
|
+
if (req.refresh)
|
|
25861
|
+
return platformCall(`${machine2}/discover-models`, "POST", { requestId: req.requestId ?? crypto.randomUUID(), runtimeId: req.backendId });
|
|
25862
|
+
return platformCall(`${machine2}/models?backend=${encodeURIComponent(req.backendId)}${req.model ? `&model=${encodeURIComponent(req.model)}` : ""}`);
|
|
25863
|
+
}
|
|
25864
|
+
async function callPlatformBot(req) {
|
|
25865
|
+
if (req.action === "list")
|
|
25866
|
+
return platformCall("/bots");
|
|
25867
|
+
return platformCall("/bots/creation-requests", "POST", { requestId: req.requestId, bots: req.bots });
|
|
25868
|
+
}
|
|
25695
25869
|
return {
|
|
25870
|
+
platformMachine: callPlatformMachine,
|
|
25871
|
+
platformBot: callPlatformBot,
|
|
25696
25872
|
listServers: (_r) => callListServers(),
|
|
25697
25873
|
joinServer: callJoinServer,
|
|
25698
25874
|
leaveServer: callLeaveServer,
|
|
@@ -25731,7 +25907,7 @@ import * as path14 from "path";
|
|
|
25731
25907
|
import * as fs6 from "fs";
|
|
25732
25908
|
import { fileURLToPath } from "url";
|
|
25733
25909
|
// agent-driver/dist/host/default-host.js
|
|
25734
|
-
import { randomUUID } from "node:crypto";
|
|
25910
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
25735
25911
|
function createDefaultAgentDriverHost(options = {}) {
|
|
25736
25912
|
const environment = { ...options.environment ?? process.env };
|
|
25737
25913
|
return {
|
|
@@ -25754,7 +25930,7 @@ function createDefaultAgentDriverHost(options = {}) {
|
|
|
25754
25930
|
options.onRawOutput?.(event);
|
|
25755
25931
|
},
|
|
25756
25932
|
now: () => Date.now(),
|
|
25757
|
-
createId: () =>
|
|
25933
|
+
createId: () => randomUUID2()
|
|
25758
25934
|
};
|
|
25759
25935
|
}
|
|
25760
25936
|
|
|
@@ -25767,7 +25943,7 @@ import { EventEmitter } from "events";
|
|
|
25767
25943
|
|
|
25768
25944
|
// agent-driver/dist/internal/killTree.js
|
|
25769
25945
|
import { execFileSync as execFileSync2, spawn } from "child_process";
|
|
25770
|
-
import { randomUUID as
|
|
25946
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
25771
25947
|
import { createServer } from "node:net";
|
|
25772
25948
|
import { PassThrough } from "node:stream";
|
|
25773
25949
|
|
|
@@ -26222,7 +26398,7 @@ function spawnAgentProcess(command, args, opts) {
|
|
|
26222
26398
|
if (!isPosix) {
|
|
26223
26399
|
const stdin = opts.stdin ?? "pipe";
|
|
26224
26400
|
const stdinProxy = stdin === "pipe" ? new PassThrough : undefined;
|
|
26225
|
-
const stdinPipe = stdinProxy ? `\\\\.\\pipe\\alook-agent-${process.pid}-${
|
|
26401
|
+
const stdinPipe = stdinProxy ? `\\\\.\\pipe\\alook-agent-${process.pid}-${randomUUID3()}` : undefined;
|
|
26226
26402
|
let stdinSocket;
|
|
26227
26403
|
const stdinServer = stdinProxy ? createServer((socket) => {
|
|
26228
26404
|
stdinSocket = socket;
|
|
@@ -26902,9 +27078,9 @@ async function prepareCliTransport(ctx, extraEnv = {}, cli = DEFAULT_CLI_CONFIG,
|
|
|
26902
27078
|
}
|
|
26903
27079
|
|
|
26904
27080
|
// agent-driver/dist/internal/utils.js
|
|
26905
|
-
import { randomUUID as
|
|
27081
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
26906
27082
|
function jsonRpcRequest(method, params, id3) {
|
|
26907
|
-
return JSON.stringify({ jsonrpc: "2.0", id: id3 ??
|
|
27083
|
+
return JSON.stringify({ jsonrpc: "2.0", id: id3 ?? randomUUID4(), method, params });
|
|
26908
27084
|
}
|
|
26909
27085
|
function tryParseJsonLine(line) {
|
|
26910
27086
|
try {
|
|
@@ -27123,6 +27299,7 @@ function nativeId(value) {
|
|
|
27123
27299
|
class AgyDriver {
|
|
27124
27300
|
launchSpec;
|
|
27125
27301
|
id = "agy";
|
|
27302
|
+
modelCatalogOrigin = "native_report";
|
|
27126
27303
|
instructionDelivery = { kind: "native" };
|
|
27127
27304
|
execution = {
|
|
27128
27305
|
lifetime: "session",
|
|
@@ -28290,7 +28467,7 @@ class AntigravityAcpLane {
|
|
|
28290
28467
|
}
|
|
28291
28468
|
|
|
28292
28469
|
// agent-driver/dist/adapters/antigravity/probe.js
|
|
28293
|
-
import { createHash as createHash3, randomUUID as
|
|
28470
|
+
import { createHash as createHash3, randomUUID as randomUUID5 } from "node:crypto";
|
|
28294
28471
|
import { mkdirSync as mkdirSync3, readFileSync as readFileSync2, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
28295
28472
|
import { homedir as homedir5 } from "node:os";
|
|
28296
28473
|
import { join as join6 } from "node:path";
|
|
@@ -28420,7 +28597,7 @@ async function probeAntigravity(command, options = {}) {
|
|
|
28420
28597
|
return fail("antigravity_acp_invalid_session");
|
|
28421
28598
|
if (!loading) {
|
|
28422
28599
|
try {
|
|
28423
|
-
const temporary = `${cacheFile}.${
|
|
28600
|
+
const temporary = `${cacheFile}.${randomUUID5()}.tmp`;
|
|
28424
28601
|
writeFileSync3(temporary, sessionId, { mode: 384 });
|
|
28425
28602
|
renameSync2(temporary, cacheFile);
|
|
28426
28603
|
} catch {
|
|
@@ -28460,6 +28637,7 @@ async function probeAntigravity(command, options = {}) {
|
|
|
28460
28637
|
// agent-driver/dist/adapters/antigravity/index.js
|
|
28461
28638
|
class AntigravityDriver {
|
|
28462
28639
|
id = "antigravity";
|
|
28640
|
+
modelCatalogOrigin = "native_report";
|
|
28463
28641
|
instructionDelivery = { kind: "native" };
|
|
28464
28642
|
execution = {
|
|
28465
28643
|
lifetime: "session",
|
|
@@ -28485,7 +28663,7 @@ class AntigravityDriver {
|
|
|
28485
28663
|
}
|
|
28486
28664
|
|
|
28487
28665
|
// agent-driver/dist/adapters/claude/index.js
|
|
28488
|
-
import { randomUUID as
|
|
28666
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
28489
28667
|
|
|
28490
28668
|
// agent-driver/dist/adapters/claude/providerIsolation.js
|
|
28491
28669
|
import * as fs5 from "fs";
|
|
@@ -28845,7 +29023,7 @@ class ClaudeEventNormalizer {
|
|
|
28845
29023
|
}
|
|
28846
29024
|
|
|
28847
29025
|
// agent-driver/dist/adapters/claude/turnProtocol.js
|
|
28848
|
-
import { randomUUID as
|
|
29026
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
28849
29027
|
|
|
28850
29028
|
class ClaudeTurnProtocol {
|
|
28851
29029
|
rootUuid = null;
|
|
@@ -28855,7 +29033,7 @@ class ClaudeTurnProtocol {
|
|
|
28855
29033
|
interruptRequested = false;
|
|
28856
29034
|
finalized = false;
|
|
28857
29035
|
beginTurn() {
|
|
28858
|
-
const uuid3 =
|
|
29036
|
+
const uuid3 = randomUUID6();
|
|
28859
29037
|
this.rootUuid = uuid3;
|
|
28860
29038
|
this.segmentOwnerUuid = uuid3;
|
|
28861
29039
|
this.delivered.clear();
|
|
@@ -28871,7 +29049,7 @@ class ClaudeTurnProtocol {
|
|
|
28871
29049
|
return this.rootUuid;
|
|
28872
29050
|
}
|
|
28873
29051
|
steeringInputUuid() {
|
|
28874
|
-
const uuid3 =
|
|
29052
|
+
const uuid3 = randomUUID6();
|
|
28875
29053
|
this.delivered.set(uuid3, { acknowledged: false, followOn: this.awaitingFollowOn });
|
|
28876
29054
|
return uuid3;
|
|
28877
29055
|
}
|
|
@@ -29175,6 +29353,7 @@ var CLAUDE_MODEL_CATALOG = {
|
|
|
29175
29353
|
|
|
29176
29354
|
class ClaudeDriver {
|
|
29177
29355
|
id = "claude";
|
|
29356
|
+
modelCatalogOrigin = "adapter_suggestions";
|
|
29178
29357
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
29179
29358
|
execution = {
|
|
29180
29359
|
lifetime: "session",
|
|
@@ -29250,7 +29429,7 @@ class ClaudeDriver {
|
|
|
29250
29429
|
writeInterrupt(input2, process2) {
|
|
29251
29430
|
process2.stdin.write(JSON.stringify({
|
|
29252
29431
|
type: "control_request",
|
|
29253
|
-
request_id: input2.requestId ??
|
|
29432
|
+
request_id: input2.requestId ?? randomUUID7(),
|
|
29254
29433
|
request: { subtype: "interrupt" }
|
|
29255
29434
|
}) + `
|
|
29256
29435
|
`);
|
|
@@ -29948,6 +30127,7 @@ function isCodexMissingRolloutError(message2) {
|
|
|
29948
30127
|
|
|
29949
30128
|
class CodexDriver {
|
|
29950
30129
|
id = "codex";
|
|
30130
|
+
modelCatalogOrigin = "native_report";
|
|
29951
30131
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
29952
30132
|
execution = {
|
|
29953
30133
|
lifetime: "session",
|
|
@@ -31352,6 +31532,7 @@ async function discoverCursorRecentContext(request, dependencies = {}) {
|
|
|
31352
31532
|
class CursorDriver {
|
|
31353
31533
|
catalogProbe;
|
|
31354
31534
|
id = "cursor";
|
|
31535
|
+
modelCatalogOrigin = "native_report";
|
|
31355
31536
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
31356
31537
|
execution = {
|
|
31357
31538
|
lifetime: "session",
|
|
@@ -32568,6 +32749,7 @@ class GrokDriver {
|
|
|
32568
32749
|
catalogProbe;
|
|
32569
32750
|
spawnProcess;
|
|
32570
32751
|
id = "grok";
|
|
32752
|
+
modelCatalogOrigin = "native_report";
|
|
32571
32753
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
32572
32754
|
execution = {
|
|
32573
32755
|
lifetime: "session",
|
|
@@ -34367,6 +34549,7 @@ class OpenCodeDriver {
|
|
|
34367
34549
|
outputProbe;
|
|
34368
34550
|
versionProbe;
|
|
34369
34551
|
id = "opencode";
|
|
34552
|
+
modelCatalogOrigin = "native_report";
|
|
34370
34553
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
34371
34554
|
execution = {
|
|
34372
34555
|
lifetime: "session",
|
|
@@ -34861,6 +35044,7 @@ class PiDriver {
|
|
|
34861
35044
|
loadSdk;
|
|
34862
35045
|
readVersion;
|
|
34863
35046
|
id = "pi";
|
|
35047
|
+
modelCatalogOrigin = "native_report";
|
|
34864
35048
|
instructionDelivery = { kind: "workspace_file", canonical: "AGENTS.md", aliases: ["CLAUDE.md"] };
|
|
34865
35049
|
execution = {
|
|
34866
35050
|
lifetime: "session",
|
|
@@ -35774,20 +35958,20 @@ class LogicalAgentSession {
|
|
|
35774
35958
|
if (!this.isStartCurrent(generation, turnId) || admission.finalized) {
|
|
35775
35959
|
return admission.accepted ? acceptedReceipt : { status: "rejected", reason: "closed" };
|
|
35776
35960
|
}
|
|
35777
|
-
const
|
|
35961
|
+
const failure3 = error62 instanceof StructuredLaneAdmissionError ? driverError(error62.code === "authentication_required" ? "authentication" : "configuration", error62.code, error62.message, false) : driverError("process", "failed_to_start", String(error62), true);
|
|
35778
35962
|
if (this.launch.resumeSessionId && this.resumeOutcome === "pending") {
|
|
35779
35963
|
this.resumeOutcome = error62 instanceof StructuredLaneAdmissionError && error62.code === "reset_required" ? "reset_required" : "failed";
|
|
35780
35964
|
}
|
|
35781
|
-
this.failTurnAdmissionWithError(
|
|
35965
|
+
this.failTurnAdmissionWithError(failure3);
|
|
35782
35966
|
this.activeTurn = undefined;
|
|
35783
35967
|
const failedLane = this.lane;
|
|
35784
35968
|
if (failedLane) {
|
|
35785
35969
|
this.lane = null;
|
|
35786
35970
|
await this.stopLaneInstanceBounded(failedLane, "failed_start", this.hostReleaseTimeoutMs);
|
|
35787
35971
|
}
|
|
35788
|
-
this.emit({ type: "session_failed", error:
|
|
35789
|
-
await this.finish((cleanup) => ({ outcome: "failed_to_start", requested: false, error:
|
|
35790
|
-
return { status: "rejected", reason: "runtime_unavailable", error:
|
|
35972
|
+
this.emit({ type: "session_failed", error: failure3 });
|
|
35973
|
+
await this.finish((cleanup) => ({ outcome: "failed_to_start", requested: false, error: failure3, cleanup }), "failed_start");
|
|
35974
|
+
return { status: "rejected", reason: "runtime_unavailable", error: failure3 };
|
|
35791
35975
|
}
|
|
35792
35976
|
};
|
|
35793
35977
|
const reuseExistingLane = this.adapter.execution.lifetime === "session" && this.lane !== null;
|
|
@@ -36460,23 +36644,23 @@ class LogicalAgentSession {
|
|
|
36460
36644
|
this.emit({ type: "command_accepted", commandId: message2.id, turnId: activeTurn.turnId, delivery: "steer" });
|
|
36461
36645
|
return { status: "accepted", delivery: "steer", commandId: message2.id, turnId: activeTurn.turnId };
|
|
36462
36646
|
} catch (error62) {
|
|
36463
|
-
const
|
|
36647
|
+
const failure3 = delivery.failure ?? (typeof error62 === "object" && error62 !== null && "category" in error62 ? error62 : driverError("process", "delivery_failed", String(error62), true));
|
|
36464
36648
|
if (!delivery.finalized) {
|
|
36465
36649
|
delivery.finalized = true;
|
|
36466
|
-
this.emit({ type: "command_failed", commandId: message2.id, turnId: activeTurn.turnId, error:
|
|
36650
|
+
this.emit({ type: "command_failed", commandId: message2.id, turnId: activeTurn.turnId, error: failure3 });
|
|
36467
36651
|
}
|
|
36468
|
-
return { status: "rejected", reason: "runtime_unavailable", error:
|
|
36652
|
+
return { status: "rejected", reason: "runtime_unavailable", error: failure3 };
|
|
36469
36653
|
}
|
|
36470
36654
|
});
|
|
36471
36655
|
try {
|
|
36472
36656
|
return await Promise.race([physical, cancellation]);
|
|
36473
36657
|
} catch (error62) {
|
|
36474
|
-
const
|
|
36658
|
+
const failure3 = delivery.failure ?? (typeof error62 === "object" && error62 !== null && "category" in error62 ? error62 : driverError("process", "delivery_failed", String(error62), true));
|
|
36475
36659
|
if (!delivery.finalized) {
|
|
36476
36660
|
delivery.finalized = true;
|
|
36477
|
-
this.emit({ type: "command_failed", commandId: message2.id, turnId: activeTurn.turnId, error:
|
|
36661
|
+
this.emit({ type: "command_failed", commandId: message2.id, turnId: activeTurn.turnId, error: failure3 });
|
|
36478
36662
|
}
|
|
36479
|
-
return { status: "rejected", reason: "runtime_unavailable", error:
|
|
36663
|
+
return { status: "rejected", reason: "runtime_unavailable", error: failure3 };
|
|
36480
36664
|
} finally {
|
|
36481
36665
|
this.steeringDeliveries.delete(delivery);
|
|
36482
36666
|
}
|
|
@@ -36757,7 +36941,7 @@ function createAgentDriverSdkWithRegistry(options) {
|
|
|
36757
36941
|
status: "healthy",
|
|
36758
36942
|
version: result.version,
|
|
36759
36943
|
capabilities: capabilities2,
|
|
36760
|
-
reasoning: result.reasoning
|
|
36944
|
+
reasoning: result.reasoning && adapter.modelCatalogOrigin ? { ...result.reasoning, catalogOrigin: adapter.modelCatalogOrigin } : result.reasoning
|
|
36761
36945
|
};
|
|
36762
36946
|
}
|
|
36763
36947
|
return {
|
|
@@ -36769,7 +36953,7 @@ function createAgentDriverSdkWithRegistry(options) {
|
|
|
36769
36953
|
retryable: true
|
|
36770
36954
|
},
|
|
36771
36955
|
capabilities: capabilities2,
|
|
36772
|
-
reasoning: result.reasoning
|
|
36956
|
+
reasoning: result.reasoning && adapter.modelCatalogOrigin ? { ...result.reasoning, catalogOrigin: adapter.modelCatalogOrigin } : result.reasoning
|
|
36773
36957
|
};
|
|
36774
36958
|
} catch (error62) {
|
|
36775
36959
|
const contractInvalid = error62 instanceof Error && (error62.message.startsWith("Adapter ") || error62.message.startsWith("Agent backend registration "));
|
|
@@ -38098,6 +38282,12 @@ function parseBearer(authHeader) {
|
|
|
38098
38282
|
return m ? m[1].trim() : null;
|
|
38099
38283
|
}
|
|
38100
38284
|
var DEFAULT_CAPABILITY_RESOLVER = (method, pathname) => {
|
|
38285
|
+
if (pathname.startsWith("/api/community/machines"))
|
|
38286
|
+
return "read";
|
|
38287
|
+
if (pathname === "/api/community/bots" && method === "GET")
|
|
38288
|
+
return "read";
|
|
38289
|
+
if (pathname === "/api/community/bots/creation-requests" && method === "POST")
|
|
38290
|
+
return "send";
|
|
38101
38291
|
if ((method === "GET" || method === "PATCH") && pathname === "/api/community/users/me/profile" || method === "POST" && pathname === "/api/community/users/me/avatar")
|
|
38102
38292
|
return "profile";
|
|
38103
38293
|
if (pathname.includes("/attachment"))
|
|
@@ -38238,14 +38428,14 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
38238
38428
|
const onPull = options.onInboxPullResponse;
|
|
38239
38429
|
const onAck = options.onInboxAckResponse;
|
|
38240
38430
|
const onProxyRequest = options.onProxyRequest;
|
|
38241
|
-
const reportInboxPullObservationError = (
|
|
38431
|
+
const reportInboxPullObservationError = (failure3) => {
|
|
38242
38432
|
try {
|
|
38243
|
-
options.onInboxPullObservationError?.(
|
|
38433
|
+
options.onInboxPullObservationError?.(failure3);
|
|
38244
38434
|
} catch {}
|
|
38245
38435
|
};
|
|
38246
|
-
const reportInboxAckObservationError = (
|
|
38436
|
+
const reportInboxAckObservationError = (failure3) => {
|
|
38247
38437
|
try {
|
|
38248
|
-
options.onInboxAckObservationError?.(
|
|
38438
|
+
options.onInboxAckObservationError?.(failure3);
|
|
38249
38439
|
} catch {
|
|
38250
38440
|
return;
|
|
38251
38441
|
}
|
|
@@ -38280,7 +38470,11 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
38280
38470
|
req.resume();
|
|
38281
38471
|
return;
|
|
38282
38472
|
}
|
|
38283
|
-
|
|
38473
|
+
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))) {
|
|
38474
|
+
writeJson(res, 403, { error: "Machine management is not available to bots", code: "forbidden" });
|
|
38475
|
+
return;
|
|
38476
|
+
}
|
|
38477
|
+
const canonicalCommunityDoor = /^\/api\/community\/(channels|messages|servers|invites|friends|users|bots|machines)(\/|$)/.test(pathname);
|
|
38284
38478
|
if (pathname === "/api" || pathname.startsWith("/api/") && !canonicalCommunityDoor) {
|
|
38285
38479
|
res.writeHead(404, { "content-type": "application/json" });
|
|
38286
38480
|
res.end(JSON.stringify({ error: "unknown API route", code: "not_found" }));
|
|
@@ -39260,8 +39454,8 @@ async function readAntigravityQuota(options = {}) {
|
|
|
39260
39454
|
let value;
|
|
39261
39455
|
try {
|
|
39262
39456
|
value = await load();
|
|
39263
|
-
} catch (
|
|
39264
|
-
if (asRecord(
|
|
39457
|
+
} catch (failure3) {
|
|
39458
|
+
if (asRecord(failure3)?.code !== "ENOENT")
|
|
39265
39459
|
storageUnavailable = true;
|
|
39266
39460
|
return null;
|
|
39267
39461
|
}
|
|
@@ -39281,8 +39475,8 @@ async function readAntigravityQuota(options = {}) {
|
|
|
39281
39475
|
credentials = await loadCredentials(() => read(join14(root, "antigravity-acp", "acp_token.json")));
|
|
39282
39476
|
}
|
|
39283
39477
|
}
|
|
39284
|
-
} catch (
|
|
39285
|
-
if (!(
|
|
39478
|
+
} catch (failure3) {
|
|
39479
|
+
if (!(failure3 instanceof SyntaxError) && asRecord(failure3)?.code !== "ENOENT")
|
|
39286
39480
|
storageUnavailable = true;
|
|
39287
39481
|
}
|
|
39288
39482
|
const identity = createHash5("sha256").update(JSON.stringify([root, authType, credentials?.client_id, credentials?.refresh_token, credentials?.project_id])).digest("hex");
|
|
@@ -39357,8 +39551,8 @@ async function readAntigravityQuota(options = {}) {
|
|
|
39357
39551
|
if (source !== activeSource)
|
|
39358
39552
|
return { status: "error", sourceEpoch: activeSource.epoch, code: "unavailable", retryable: true };
|
|
39359
39553
|
return { status: "available", sourceEpoch: source.epoch, freshForSeconds: 300, ...planName ? { planName } : {}, limits };
|
|
39360
|
-
} catch (
|
|
39361
|
-
const known = asRecord(
|
|
39554
|
+
} catch (failure3) {
|
|
39555
|
+
const known = asRecord(failure3);
|
|
39362
39556
|
if (known?.quotaCode === "unauthorized" || known?.quotaCode === "provider_error" || known?.quotaCode === "invalid_response") {
|
|
39363
39557
|
if (known.quotaCode === "unauthorized")
|
|
39364
39558
|
source.accessToken = undefined;
|
|
@@ -39592,6 +39786,18 @@ function cliCommandsSection() {
|
|
|
39592
39786
|
`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).`,
|
|
39593
39787
|
`2. \`${CLI} friend list\` — list your friends and pending requests ` + `(\`accepted\`, \`pendingOutgoing\`, \`pendingIncoming\`).`,
|
|
39594
39788
|
"",
|
|
39789
|
+
"### Platform",
|
|
39790
|
+
"",
|
|
39791
|
+
"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.",
|
|
39792
|
+
"",
|
|
39793
|
+
"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.",
|
|
39794
|
+
"",
|
|
39795
|
+
`1. \`${CLI} platform machine --list\` — list your owner's machines.`,
|
|
39796
|
+
`2. \`${CLI} platform machine --backends --id <machine-id>\` — read the selected online machine's backends.`,
|
|
39797
|
+
`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.`,
|
|
39798
|
+
`4. \`${CLI} platform bot --list\` — list your owner's bots.`,
|
|
39799
|
+
`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.`,
|
|
39800
|
+
"",
|
|
39595
39801
|
"### Settings",
|
|
39596
39802
|
"",
|
|
39597
39803
|
`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.`,
|
|
@@ -39910,7 +40116,7 @@ function toLocalISO(iso) {
|
|
|
39910
40116
|
}
|
|
39911
40117
|
|
|
39912
40118
|
// src/manager/managerRuntime.ts
|
|
39913
|
-
import { randomUUID as
|
|
40119
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
39914
40120
|
var SESSION_STOP_GRACE_MS2 = 2000;
|
|
39915
40121
|
function normalizeTerminationCause(value) {
|
|
39916
40122
|
return value === "runtime_error" || value === "killed_stalled" ? value : "other";
|
|
@@ -40150,7 +40356,7 @@ class AgentProcessManager {
|
|
|
40150
40356
|
shuttingDown = false;
|
|
40151
40357
|
shutdownPromise;
|
|
40152
40358
|
publishedAgentActivity = new Map;
|
|
40153
|
-
traceProcessNonce =
|
|
40359
|
+
traceProcessNonce = randomUUID8();
|
|
40154
40360
|
nextSpawnOrdinal = 1;
|
|
40155
40361
|
nextDaemonTurnOrdinal = 1;
|
|
40156
40362
|
nextDeliveryOrdinal = 1;
|
|
@@ -40459,7 +40665,7 @@ class AgentProcessManager {
|
|
|
40459
40665
|
const session2 = this.sessions.get(agentId);
|
|
40460
40666
|
if (!session2)
|
|
40461
40667
|
return;
|
|
40462
|
-
const result = await session2.interrupt({ requestId:
|
|
40668
|
+
const result = await session2.interrupt({ requestId: randomUUID8(), reason: "owner_request" });
|
|
40463
40669
|
if (result.status !== "accepted")
|
|
40464
40670
|
return;
|
|
40465
40671
|
this.log.info("agent turn interrupt accepted", {
|
|
@@ -41045,7 +41251,7 @@ ${this.opts.wakePromptFooter}` : text3;
|
|
|
41045
41251
|
if (!agent2 || agent2.sessionId !== effect.sessionId || agent2.resetting || agent2.idleSince === null)
|
|
41046
41252
|
break;
|
|
41047
41253
|
this.deliver(effect.agentId, {
|
|
41048
|
-
id: `${effect.agentId}:memory-maintenance:${
|
|
41254
|
+
id: `${effect.agentId}:memory-maintenance:${randomUUID8()}`,
|
|
41049
41255
|
text: MEMORY_MAINTENANCE_PROMPT
|
|
41050
41256
|
});
|
|
41051
41257
|
break;
|
|
@@ -41774,7 +41980,7 @@ class AgentRouter {
|
|
|
41774
41980
|
const timeZone = typeof this.opts.timeZone === "function" ? this.opts.timeZone() : this.opts.timeZone;
|
|
41775
41981
|
return {
|
|
41776
41982
|
runtimeReport: [...this.runtimes.values()],
|
|
41777
|
-
capabilities: [CONTROL_HEARTBEAT_CAPABILITY, ...this.opts.channel.reportRuntimeModels ? [RUNTIME_MODEL_DISCOVERY_CAPABILITY] : []],
|
|
41983
|
+
capabilities: [CONTROL_HEARTBEAT_CAPABILITY, ...this.opts.supportsMachineStop ? [MACHINE_STOP_CAPABILITY] : [], ...this.opts.channel.reportRuntimeModels ? [RUNTIME_MODEL_DISCOVERY_CAPABILITY] : []],
|
|
41778
41984
|
runningAgents: [...this.running],
|
|
41779
41985
|
hostname: this.opts.hostname,
|
|
41780
41986
|
platform: this.opts.platform,
|
|
@@ -43465,6 +43671,16 @@ function createSelfUpdateCommandListener(handleSelfUpdate) {
|
|
|
43465
43671
|
};
|
|
43466
43672
|
}
|
|
43467
43673
|
|
|
43674
|
+
// src/daemon/machineStopCommand.ts
|
|
43675
|
+
function createMachineStopCommandListener(onStopRequested) {
|
|
43676
|
+
return (command) => {
|
|
43677
|
+
if (command.type !== "machine:stop")
|
|
43678
|
+
return;
|
|
43679
|
+
onStopRequested?.();
|
|
43680
|
+
return WS_CONTROL_COMMAND_CONSUMED;
|
|
43681
|
+
};
|
|
43682
|
+
}
|
|
43683
|
+
|
|
43468
43684
|
// src/daemon/messageReminderScheduler.ts
|
|
43469
43685
|
function reminderKey(agentId, channel2) {
|
|
43470
43686
|
return `${agentId}\x00${channel2}`;
|
|
@@ -43559,7 +43775,7 @@ class MessageReminderScheduler {
|
|
|
43559
43775
|
}
|
|
43560
43776
|
|
|
43561
43777
|
// src/manager/agentDriverHost.ts
|
|
43562
|
-
import { randomUUID as
|
|
43778
|
+
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
43563
43779
|
import { homedir as homedir13 } from "node:os";
|
|
43564
43780
|
import { join as join17 } from "node:path";
|
|
43565
43781
|
|
|
@@ -43715,7 +43931,7 @@ function createDaemonAgentDriverHost(ctx, onRawLine) {
|
|
|
43715
43931
|
onRawLine?.(event.text);
|
|
43716
43932
|
},
|
|
43717
43933
|
now: () => Date.now(),
|
|
43718
|
-
createId: () =>
|
|
43934
|
+
createId: () => randomUUID9()
|
|
43719
43935
|
};
|
|
43720
43936
|
}
|
|
43721
43937
|
|
|
@@ -43794,7 +44010,7 @@ class DaemonSelfSleepScheduler {
|
|
|
43794
44010
|
// src/telemetry/dailyTokenUsage.ts
|
|
43795
44011
|
import { chmod, mkdir, open as open3, readFile as readFile3, rename, rm } from "node:fs/promises";
|
|
43796
44012
|
import { dirname as dirname6, join as join18 } from "node:path";
|
|
43797
|
-
import { randomUUID as
|
|
44013
|
+
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
43798
44014
|
var TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
43799
44015
|
var TOKEN_USAGE_RECOVERY_DAYS = 2;
|
|
43800
44016
|
var TOKEN_USAGE_RETENTION_DAYS = TOKEN_USAGE_WINDOW_DAYS + TOKEN_USAGE_RECOVERY_DAYS;
|
|
@@ -44043,7 +44259,7 @@ class DailyTokenUsageStore {
|
|
|
44043
44259
|
async persist() {
|
|
44044
44260
|
const directory = dirname6(this.filePath);
|
|
44045
44261
|
await mkdir(directory, { recursive: true, mode: 448 });
|
|
44046
|
-
const temporary = `${this.filePath}.${
|
|
44262
|
+
const temporary = `${this.filePath}.${randomUUID10()}.tmp`;
|
|
44047
44263
|
try {
|
|
44048
44264
|
const file2 = await open3(temporary, "wx", 384);
|
|
44049
44265
|
try {
|
|
@@ -44778,6 +44994,7 @@ async function createDaemon(opts) {
|
|
|
44778
44994
|
manager,
|
|
44779
44995
|
channel: channel2,
|
|
44780
44996
|
runtimeReport: opts.runtimeReport,
|
|
44997
|
+
supportsMachineStop: typeof opts.onStopRequested === "function",
|
|
44781
44998
|
hostname: opts.hostname,
|
|
44782
44999
|
platform: opts.platform,
|
|
44783
45000
|
arch: opts.arch,
|
|
@@ -44820,6 +45037,7 @@ async function createDaemon(opts) {
|
|
|
44820
45037
|
channel2.sendReady?.(router.buildReady());
|
|
44821
45038
|
};
|
|
44822
45039
|
channel2.onCommand(createSelfUpdateCommandListener(opts.handleSelfUpdate));
|
|
45040
|
+
channel2.onCommand(createMachineStopCommandListener(opts.onStopRequested));
|
|
44823
45041
|
channel2.onCommand(createDiagnosticsCommandListener({
|
|
44824
45042
|
handleDiagnosticCommand: opts.handleDiagnosticCommand,
|
|
44825
45043
|
reportDiagnosticFailure: opts.reportDiagnosticFailure
|
|
@@ -46684,8 +46902,8 @@ async function runPreparedDaemon(prepared, opts) {
|
|
|
46684
46902
|
machineKey: prepared.machineKey
|
|
46685
46903
|
});
|
|
46686
46904
|
const keepAlive = setInterval(() => {}, 24 * 60 * 60 * 1000);
|
|
46687
|
-
const reportDiagnosticFailure = async (
|
|
46688
|
-
await diagnosticTransport.fail(
|
|
46905
|
+
const reportDiagnosticFailure = async (failure3) => {
|
|
46906
|
+
await diagnosticTransport.fail(failure3.reportId, failure3.failureCode);
|
|
46689
46907
|
};
|
|
46690
46908
|
const handleDiagnosticCommand = async (command) => {
|
|
46691
46909
|
try {
|
|
@@ -46791,6 +47009,9 @@ async function runPreparedDaemon(prepared, opts) {
|
|
|
46791
47009
|
daemonVersion: prepared.daemonVersion,
|
|
46792
47010
|
logger: log2,
|
|
46793
47011
|
handleSelfUpdate,
|
|
47012
|
+
onStopRequested: () => {
|
|
47013
|
+
shutdown(0);
|
|
47014
|
+
},
|
|
46794
47015
|
handleDiagnosticCommand,
|
|
46795
47016
|
reportDiagnosticFailure,
|
|
46796
47017
|
onDiagnosticSources: ({ fsmTraceSource, statusFilePath }) => {
|
|
@@ -48019,6 +48240,8 @@ function printEnvelope(env) {
|
|
|
48019
48240
|
out.code = env.code;
|
|
48020
48241
|
if (env.hint !== undefined && env.hint !== null)
|
|
48021
48242
|
out.hint = env.hint;
|
|
48243
|
+
if (env.platformDetails)
|
|
48244
|
+
Object.assign(out, env.platformDetails);
|
|
48022
48245
|
process.stdout.write(JSON.stringify(out) + `
|
|
48023
48246
|
`);
|
|
48024
48247
|
}
|
|
@@ -48204,7 +48427,7 @@ ${MESSAGE_SEND_STDIN_POLICY}`);
|
|
|
48204
48427
|
}
|
|
48205
48428
|
replyToSeq = n;
|
|
48206
48429
|
}
|
|
48207
|
-
const nonce =
|
|
48430
|
+
const nonce = randomUUID13();
|
|
48208
48431
|
let res;
|
|
48209
48432
|
try {
|
|
48210
48433
|
res = await sendWithRetry(api2, {
|
|
@@ -48595,6 +48818,7 @@ function buildProgram(stdin) {
|
|
|
48595
48818
|
writeOut: () => {},
|
|
48596
48819
|
writeErr: () => {}
|
|
48597
48820
|
}).option("--agent <id>", "agent identity (or ALOOK_AGENT_ID env)");
|
|
48821
|
+
registerPlatformCommands(program, getApi, printEnvelope);
|
|
48598
48822
|
const message2 = program.command("message").description("message operations").exitOverride();
|
|
48599
48823
|
message2.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
48600
48824
|
message2.command("send").description("send a message to a channel, DM, or thread").option("--target <ref>", "destination (path-style ref, e.g. /demo-workspace#1234/general)").requiredOption("--stdin", "read the required UTF-8 message body from non-TTY stdin (max 1 KiB)").option("-a, --attachment <id>", "attach an uploaded file by id (repeatable — order = message order)", (v, prev = []) => [...prev, v], []).option("--force", "bypass duplicate detection only; channel alignment and other send checks still apply").option("--reply <seq>", 'reply to a message by its seq in --target (e.g. "#37" or 37)').requiredOption("--remind-after <0|Nm|Nh>", "required idle follow-up: 0 disables; 1m..24h arms/resets one same-scope timer; a newer message or daemon restart cancels it").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
@@ -48830,7 +49054,8 @@ async function main(argv = process.argv.slice(2), io = {}) {
|
|
|
48830
49054
|
printEnvelope({
|
|
48831
49055
|
error: err.message,
|
|
48832
49056
|
code: err.code,
|
|
48833
|
-
hint: err.hint
|
|
49057
|
+
hint: err.hint,
|
|
49058
|
+
platformDetails: err.platformDetails
|
|
48834
49059
|
});
|
|
48835
49060
|
}
|
|
48836
49061
|
if (argv[0] === "daemon" && (argv[1] === "resume" || argv[1] === "replace")) {
|