@alook/daemon 0.1.60 → 0.1.62
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/README.md +42 -0
- package/dist/cli/index.js +1069 -634
- package/dist/index.js +652 -452
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -54704,6 +54704,122 @@ function bigint3(params) {
|
|
|
54704
54704
|
function date4(params) {
|
|
54705
54705
|
return _coercedDate(ZodDate, params);
|
|
54706
54706
|
}
|
|
54707
|
+
// ../shared/src/constants/community.ts
|
|
54708
|
+
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
54709
|
+
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
54710
|
+
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
54711
|
+
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
54712
|
+
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
54713
|
+
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
54714
|
+
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
54715
|
+
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
54716
|
+
var ALLOWED_ICON_MIME_TYPES = [
|
|
54717
|
+
"image/png",
|
|
54718
|
+
"image/jpeg",
|
|
54719
|
+
"image/webp",
|
|
54720
|
+
"image/gif"
|
|
54721
|
+
];
|
|
54722
|
+
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
54723
|
+
var PARTICIPANT_SOURCE = {
|
|
54724
|
+
MENTION: "mention",
|
|
54725
|
+
SPOKE: "spoke",
|
|
54726
|
+
ADDED: "added"
|
|
54727
|
+
};
|
|
54728
|
+
|
|
54729
|
+
// ../shared/src/lib/discriminator.ts
|
|
54730
|
+
function parseNameAndTag(q) {
|
|
54731
|
+
const m = /^(.+)#(\d{4,})$/.exec(q);
|
|
54732
|
+
if (!m)
|
|
54733
|
+
return null;
|
|
54734
|
+
const name = m[1].trim();
|
|
54735
|
+
const discriminator = m[2];
|
|
54736
|
+
if (!name)
|
|
54737
|
+
return null;
|
|
54738
|
+
return { name, discriminator };
|
|
54739
|
+
}
|
|
54740
|
+
function formatHandle(name, discriminator) {
|
|
54741
|
+
return `${name}#${discriminator}`;
|
|
54742
|
+
}
|
|
54743
|
+
|
|
54744
|
+
// ../shared/src/pii-contract.ts
|
|
54745
|
+
var PII_CAPABILITY = "pii-v1";
|
|
54746
|
+
var PII_MAX_PLUGINS = 32;
|
|
54747
|
+
var PII_SOURCE_MAX_BYTES = 16 * 1024;
|
|
54748
|
+
var PII_TEXT_MAX_BYTES = 1024;
|
|
54749
|
+
var PII_REQUEST_MAX_BYTES = 8 * 1024;
|
|
54750
|
+
var PiiPreviewTextSchema = exports_external.string().max(PII_TEXT_MAX_BYTES).refine((text2) => new TextEncoder().encode(text2).byteLength <= PII_TEXT_MAX_BYTES).refine((text2) => text2.trim().length > 0);
|
|
54751
|
+
var PiiPluginSchema = exports_external.strictObject({
|
|
54752
|
+
id: exports_external.string().min(1).max(128),
|
|
54753
|
+
name: exports_external.string().trim().min(1).max(80),
|
|
54754
|
+
description: exports_external.string().trim().min(1).max(256),
|
|
54755
|
+
enabled: exports_external.boolean()
|
|
54756
|
+
});
|
|
54757
|
+
var PiiSnapshotSchema = exports_external.strictObject({
|
|
54758
|
+
revision: exports_external.number().int().nonnegative(),
|
|
54759
|
+
plugins: exports_external.array(PiiPluginSchema).max(PII_MAX_PLUGINS)
|
|
54760
|
+
});
|
|
54761
|
+
var pluginId = exports_external.string().min(1).max(128);
|
|
54762
|
+
var expectedRevision = exports_external.number().int().nonnegative();
|
|
54763
|
+
var PiiOperationSchema = exports_external.discriminatedUnion("action", [
|
|
54764
|
+
exports_external.strictObject({ action: exports_external.literal("list") }),
|
|
54765
|
+
exports_external.strictObject({ action: exports_external.literal("setEnabled"), pluginId, enabled: exports_external.boolean(), expectedRevision }),
|
|
54766
|
+
exports_external.strictObject({ action: exports_external.literal("remove"), pluginId, expectedRevision }),
|
|
54767
|
+
exports_external.strictObject({ action: exports_external.literal("preview"), text: PiiPreviewTextSchema, expectedRevision })
|
|
54768
|
+
]);
|
|
54769
|
+
var PiiRequestSchema = exports_external.strictObject({
|
|
54770
|
+
requestId: exports_external.string().min(1).max(128),
|
|
54771
|
+
operation: PiiOperationSchema
|
|
54772
|
+
});
|
|
54773
|
+
var PiiCommandSchema = PiiRequestSchema.extend({
|
|
54774
|
+
type: exports_external.literal("pii:manage"),
|
|
54775
|
+
botId: exports_external.string().min(1).max(128)
|
|
54776
|
+
});
|
|
54777
|
+
var PiiErrorCodeSchema = exports_external.enum([
|
|
54778
|
+
"PII_CONFLICT",
|
|
54779
|
+
"PII_UNAVAILABLE",
|
|
54780
|
+
"PII_PLUGIN_NOT_FOUND",
|
|
54781
|
+
"PII_BOT_NOT_FOUND",
|
|
54782
|
+
"PII_PLUGIN_FAILED",
|
|
54783
|
+
"PII_PLUGIN_TIMEOUT",
|
|
54784
|
+
"PII_INVALID_RESULT",
|
|
54785
|
+
"PII_OUTPUT_TOO_LARGE",
|
|
54786
|
+
"PII_INVALID_SOURCE",
|
|
54787
|
+
"PII_CONFIG_UNAVAILABLE",
|
|
54788
|
+
"PII_SOURCE_TOO_LARGE",
|
|
54789
|
+
"PII_INVALID_REQUEST"
|
|
54790
|
+
]);
|
|
54791
|
+
var PiiResultSchema = exports_external.discriminatedUnion("status", [
|
|
54792
|
+
exports_external.strictObject({ status: exports_external.literal("complete"), snapshot: PiiSnapshotSchema, output: PiiPreviewTextSchema.optional(), triggeredFilters: exports_external.array(PiiPluginSchema.pick({ id: true, name: true })).max(PII_MAX_PLUGINS).optional() }),
|
|
54793
|
+
exports_external.strictObject({
|
|
54794
|
+
status: exports_external.literal("error"),
|
|
54795
|
+
code: PiiErrorCodeSchema,
|
|
54796
|
+
pluginId: pluginId.optional(),
|
|
54797
|
+
snapshot: PiiSnapshotSchema.optional()
|
|
54798
|
+
})
|
|
54799
|
+
]);
|
|
54800
|
+
var PiiResultFrameSchema = exports_external.strictObject({
|
|
54801
|
+
type: exports_external.literal("pii_result"),
|
|
54802
|
+
botId: exports_external.string().min(1).max(128),
|
|
54803
|
+
requestId: exports_external.string().min(1).max(128),
|
|
54804
|
+
result: PiiResultSchema
|
|
54805
|
+
});
|
|
54806
|
+
var PiiLocalRequestSchema = exports_external.discriminatedUnion("action", [
|
|
54807
|
+
exports_external.strictObject({ action: exports_external.literal("list") }),
|
|
54808
|
+
exports_external.strictObject({
|
|
54809
|
+
action: exports_external.literal("add"),
|
|
54810
|
+
name: PiiPluginSchema.shape.name,
|
|
54811
|
+
description: PiiPluginSchema.shape.description,
|
|
54812
|
+
source: exports_external.string().min(1).max(PII_SOURCE_MAX_BYTES)
|
|
54813
|
+
})
|
|
54814
|
+
]);
|
|
54815
|
+
|
|
54816
|
+
// ../shared/src/utils/community-roles.ts
|
|
54817
|
+
var ROLES = {
|
|
54818
|
+
OWNER: "owner",
|
|
54819
|
+
ADMIN: "admin",
|
|
54820
|
+
MEMBER: "member"
|
|
54821
|
+
};
|
|
54822
|
+
|
|
54707
54823
|
// ../shared/src/db/community-machine-schema.ts
|
|
54708
54824
|
var exports_community_machine_schema = {};
|
|
54709
54825
|
__export(exports_community_machine_schema, {
|
|
@@ -57190,25 +57306,6 @@ var OwnerDiagnosticReportSchema = exports_external.discriminatedUnion("status",
|
|
|
57190
57306
|
objectExpired: exports_external.literal(false)
|
|
57191
57307
|
}).strict()
|
|
57192
57308
|
]);
|
|
57193
|
-
// ../shared/src/community-contract.ts
|
|
57194
|
-
var COMMUNITY_RESOURCE_CONTRACT_VERSION = 3;
|
|
57195
|
-
|
|
57196
|
-
// ../shared/src/community-friend-approval.ts
|
|
57197
|
-
var profile = exports_external.strictObject({
|
|
57198
|
-
id: exports_external.string(),
|
|
57199
|
-
name: exports_external.string(),
|
|
57200
|
-
discriminator: exports_external.string(),
|
|
57201
|
-
image: exports_external.string().nullable(),
|
|
57202
|
-
avatarVersion: exports_external.number().int().nonnegative()
|
|
57203
|
-
});
|
|
57204
|
-
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
57205
|
-
friendshipId: exports_external.string(),
|
|
57206
|
-
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
57207
|
-
waitingOn: exports_external.enum(["you", "other-owner", "addressee"]).nullable(),
|
|
57208
|
-
otherProfile: profile,
|
|
57209
|
-
botProfile: profile,
|
|
57210
|
-
waitingOnProfile: profile.nullable().optional()
|
|
57211
|
-
});
|
|
57212
57309
|
|
|
57213
57310
|
// ../shared/src/runtime-models-contract.ts
|
|
57214
57311
|
var RUNTIME_MODEL_DISCOVERY_CAPABILITY = "runtime-model-discovery-v1";
|
|
@@ -57225,100 +57322,6 @@ var RuntimeModelDiscoveryErrorSchema = exports_external.strictObject({
|
|
|
57225
57322
|
message: exports_external.string().min(1).max(256)
|
|
57226
57323
|
});
|
|
57227
57324
|
|
|
57228
|
-
// ../shared/src/utils/slug.ts
|
|
57229
|
-
init_nanoid();
|
|
57230
|
-
var slugId = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz");
|
|
57231
|
-
function sanitizeSlug(input2) {
|
|
57232
|
-
return input2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
|
|
57233
|
-
}
|
|
57234
|
-
|
|
57235
|
-
// ../shared/src/pii-contract.ts
|
|
57236
|
-
var PII_CAPABILITY = "pii-v1";
|
|
57237
|
-
var PII_MAX_PLUGINS = 32;
|
|
57238
|
-
var PII_SOURCE_MAX_BYTES = 16 * 1024;
|
|
57239
|
-
var PII_TEXT_MAX_BYTES = 1024;
|
|
57240
|
-
var PII_REQUEST_MAX_BYTES = 8 * 1024;
|
|
57241
|
-
var PiiPreviewTextSchema = exports_external.string().max(PII_TEXT_MAX_BYTES).refine((text3) => new TextEncoder().encode(text3).byteLength <= PII_TEXT_MAX_BYTES).refine((text3) => text3.trim().length > 0);
|
|
57242
|
-
var PiiPluginSchema = exports_external.strictObject({
|
|
57243
|
-
id: exports_external.string().min(1).max(128),
|
|
57244
|
-
name: exports_external.string().trim().min(1).max(80),
|
|
57245
|
-
description: exports_external.string().trim().min(1).max(256),
|
|
57246
|
-
enabled: exports_external.boolean()
|
|
57247
|
-
});
|
|
57248
|
-
var PiiSnapshotSchema = exports_external.strictObject({
|
|
57249
|
-
revision: exports_external.number().int().nonnegative(),
|
|
57250
|
-
plugins: exports_external.array(PiiPluginSchema).max(PII_MAX_PLUGINS)
|
|
57251
|
-
});
|
|
57252
|
-
var pluginId = exports_external.string().min(1).max(128);
|
|
57253
|
-
var expectedRevision = exports_external.number().int().nonnegative();
|
|
57254
|
-
var PiiOperationSchema = exports_external.discriminatedUnion("action", [
|
|
57255
|
-
exports_external.strictObject({ action: exports_external.literal("list") }),
|
|
57256
|
-
exports_external.strictObject({ action: exports_external.literal("setEnabled"), pluginId, enabled: exports_external.boolean(), expectedRevision }),
|
|
57257
|
-
exports_external.strictObject({ action: exports_external.literal("remove"), pluginId, expectedRevision }),
|
|
57258
|
-
exports_external.strictObject({ action: exports_external.literal("preview"), text: PiiPreviewTextSchema, expectedRevision })
|
|
57259
|
-
]);
|
|
57260
|
-
var PiiRequestSchema = exports_external.strictObject({
|
|
57261
|
-
requestId: exports_external.string().min(1).max(128),
|
|
57262
|
-
operation: PiiOperationSchema
|
|
57263
|
-
});
|
|
57264
|
-
var PiiCommandSchema = PiiRequestSchema.extend({
|
|
57265
|
-
type: exports_external.literal("pii:manage"),
|
|
57266
|
-
botId: exports_external.string().min(1).max(128)
|
|
57267
|
-
});
|
|
57268
|
-
var PiiErrorCodeSchema = exports_external.enum([
|
|
57269
|
-
"PII_CONFLICT",
|
|
57270
|
-
"PII_UNAVAILABLE",
|
|
57271
|
-
"PII_PLUGIN_NOT_FOUND",
|
|
57272
|
-
"PII_BOT_NOT_FOUND",
|
|
57273
|
-
"PII_PLUGIN_FAILED",
|
|
57274
|
-
"PII_PLUGIN_TIMEOUT",
|
|
57275
|
-
"PII_INVALID_RESULT",
|
|
57276
|
-
"PII_OUTPUT_TOO_LARGE",
|
|
57277
|
-
"PII_INVALID_SOURCE",
|
|
57278
|
-
"PII_CONFIG_UNAVAILABLE",
|
|
57279
|
-
"PII_SOURCE_TOO_LARGE",
|
|
57280
|
-
"PII_INVALID_REQUEST"
|
|
57281
|
-
]);
|
|
57282
|
-
var PiiResultSchema = exports_external.discriminatedUnion("status", [
|
|
57283
|
-
exports_external.strictObject({ status: exports_external.literal("complete"), snapshot: PiiSnapshotSchema, output: PiiPreviewTextSchema.optional(), triggeredFilters: exports_external.array(PiiPluginSchema.pick({ id: true, name: true })).max(PII_MAX_PLUGINS).optional() }),
|
|
57284
|
-
exports_external.strictObject({
|
|
57285
|
-
status: exports_external.literal("error"),
|
|
57286
|
-
code: PiiErrorCodeSchema,
|
|
57287
|
-
pluginId: pluginId.optional(),
|
|
57288
|
-
snapshot: PiiSnapshotSchema.optional()
|
|
57289
|
-
})
|
|
57290
|
-
]);
|
|
57291
|
-
var PiiResultFrameSchema = exports_external.strictObject({
|
|
57292
|
-
type: exports_external.literal("pii_result"),
|
|
57293
|
-
botId: exports_external.string().min(1).max(128),
|
|
57294
|
-
requestId: exports_external.string().min(1).max(128),
|
|
57295
|
-
result: PiiResultSchema
|
|
57296
|
-
});
|
|
57297
|
-
var PiiLocalRequestSchema = exports_external.discriminatedUnion("action", [
|
|
57298
|
-
exports_external.strictObject({ action: exports_external.literal("list") }),
|
|
57299
|
-
exports_external.strictObject({
|
|
57300
|
-
action: exports_external.literal("add"),
|
|
57301
|
-
name: PiiPluginSchema.shape.name,
|
|
57302
|
-
description: PiiPluginSchema.shape.description,
|
|
57303
|
-
source: exports_external.string().min(1).max(PII_SOURCE_MAX_BYTES)
|
|
57304
|
-
})
|
|
57305
|
-
]);
|
|
57306
|
-
|
|
57307
|
-
// ../shared/src/lib/discriminator.ts
|
|
57308
|
-
function parseNameAndTag(q) {
|
|
57309
|
-
const m = /^(.+)#(\d{4,})$/.exec(q);
|
|
57310
|
-
if (!m)
|
|
57311
|
-
return null;
|
|
57312
|
-
const name = m[1].trim();
|
|
57313
|
-
const discriminator = m[2];
|
|
57314
|
-
if (!name)
|
|
57315
|
-
return null;
|
|
57316
|
-
return { name, discriminator };
|
|
57317
|
-
}
|
|
57318
|
-
function formatHandle(name, discriminator) {
|
|
57319
|
-
return `${name}#${discriminator}`;
|
|
57320
|
-
}
|
|
57321
|
-
|
|
57322
57325
|
// ../shared/src/community-cli-contract.ts
|
|
57323
57326
|
var AGENT_EVENT_PROMPT_MAX_LENGTH = 32768;
|
|
57324
57327
|
var DM_SERVER = ".dm";
|
|
@@ -57494,6 +57497,91 @@ var HostCommandSchema = exports_external.discriminatedUnion("type", [
|
|
|
57494
57497
|
DiagnosticCollectCommandSchema
|
|
57495
57498
|
]);
|
|
57496
57499
|
|
|
57500
|
+
// ../shared/src/automation.ts
|
|
57501
|
+
var AUTOMATION_WRITE_PERMISSIONS = ["bot.create", "server.create", "server.invite", "message.send"];
|
|
57502
|
+
var AUTOMATION_READ_PERMISSIONS = ["machine.read", "friend.read", "server.read"];
|
|
57503
|
+
var AutomationPermissionSchema = exports_external.enum([...AUTOMATION_WRITE_PERMISSIONS, ...AUTOMATION_READ_PERMISSIONS]);
|
|
57504
|
+
var AutomationExpirySchema = exports_external.enum(["1h", "24h", "7d", "30d", "forever"]);
|
|
57505
|
+
var AutomationPermissionPolicySchema = exports_external.strictObject({
|
|
57506
|
+
permission: AutomationPermissionSchema,
|
|
57507
|
+
limit: exports_external.number().int().positive(),
|
|
57508
|
+
period: exports_external.enum(["hour", "day"])
|
|
57509
|
+
}).refine((value) => value.limit <= (value.period === "hour" ? 64 : 1536), {
|
|
57510
|
+
message: "Limit cannot exceed 64/hour or 1536/day",
|
|
57511
|
+
path: ["limit"]
|
|
57512
|
+
});
|
|
57513
|
+
var permissions = exports_external.array(AutomationPermissionPolicySchema).min(1).max(AutomationPermissionSchema.options.length).refine((values) => new Set(values.map((value) => value.permission)).size === values.length, "Duplicate permission");
|
|
57514
|
+
var AutomationAccessCodeCreateSchema = exports_external.strictObject({
|
|
57515
|
+
name: exports_external.string().trim().min(1).max(100),
|
|
57516
|
+
expiresIn: AutomationExpirySchema.default("24h"),
|
|
57517
|
+
permissions
|
|
57518
|
+
});
|
|
57519
|
+
var AutomationAccessCodeUpdateSchema = exports_external.strictObject({
|
|
57520
|
+
name: exports_external.string().trim().min(1).max(100).optional(),
|
|
57521
|
+
expiresIn: AutomationExpirySchema.optional(),
|
|
57522
|
+
permissions: permissions.optional()
|
|
57523
|
+
}).refine((value) => Object.keys(value).length > 0, "Provide at least one change");
|
|
57524
|
+
var AutomationMessageSendSchema = exports_external.strictObject({
|
|
57525
|
+
target: exports_external.string().min(1).max(1024).refine((value) => {
|
|
57526
|
+
try {
|
|
57527
|
+
parseRef(value);
|
|
57528
|
+
return true;
|
|
57529
|
+
} catch {
|
|
57530
|
+
return false;
|
|
57531
|
+
}
|
|
57532
|
+
}, "Use a channel or DM ref"),
|
|
57533
|
+
as: exports_external.string().max(128).refine((value) => value === "me" || value.startsWith("@") && Boolean(parseNameAndTag(value.slice(1))), "Use me or @name#NNNN"),
|
|
57534
|
+
content: exports_external.string().max(MAX_MESSAGE_CONTENT_LENGTH).refine((value) => value.trim().length > 0, "Message content is required"),
|
|
57535
|
+
nonce: exports_external.string().min(1).max(128)
|
|
57536
|
+
});
|
|
57537
|
+
var AutomationMessageSentSchema = exports_external.object({
|
|
57538
|
+
state: exports_external.literal("sent"),
|
|
57539
|
+
seq: exports_external.string().regex(/^#[1-9]\d*$/),
|
|
57540
|
+
deduped: exports_external.boolean(),
|
|
57541
|
+
threadId: exports_external.string().optional()
|
|
57542
|
+
});
|
|
57543
|
+
// ../shared/src/community-profile-resource.ts
|
|
57544
|
+
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
57545
|
+
id: exports_external.string().min(1),
|
|
57546
|
+
name: exports_external.string(),
|
|
57547
|
+
discriminator: exports_external.string().min(1),
|
|
57548
|
+
avatar: exports_external.string().nullable(),
|
|
57549
|
+
avatarVersion: exports_external.number().int().nonnegative(),
|
|
57550
|
+
aboutMe: exports_external.string().optional(),
|
|
57551
|
+
bannerColor: exports_external.string().nullable().optional(),
|
|
57552
|
+
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
57553
|
+
ownerUserId: exports_external.string().min(1).nullable().optional(),
|
|
57554
|
+
ownerHandle: exports_external.string().nullable().optional(),
|
|
57555
|
+
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
57556
|
+
ownedByViewer: exports_external.boolean().optional(),
|
|
57557
|
+
statusEmoji: exports_external.string().nullable().optional(),
|
|
57558
|
+
statusText: exports_external.string().nullable().optional()
|
|
57559
|
+
});
|
|
57560
|
+
// ../shared/src/business-schema-version.ts
|
|
57561
|
+
var BUSINESS_SCHEMA_VERSION = 7;
|
|
57562
|
+
|
|
57563
|
+
// ../shared/src/community-contract.ts
|
|
57564
|
+
var COMMUNITY_RESOURCE_CONTRACT_VERSION = BUSINESS_SCHEMA_VERSION;
|
|
57565
|
+
|
|
57566
|
+
// ../shared/src/community-friend-approval.ts
|
|
57567
|
+
var identity = CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatarVersion: true });
|
|
57568
|
+
var profile = identity.extend({ image: CommunityResourceProfileSchema.shape.avatar });
|
|
57569
|
+
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
57570
|
+
friendshipId: exports_external.string(),
|
|
57571
|
+
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
57572
|
+
waitingOn: exports_external.enum(["you", "other-owner", "addressee"]).nullable(),
|
|
57573
|
+
otherProfile: profile,
|
|
57574
|
+
botProfile: profile,
|
|
57575
|
+
waitingOnProfile: profile.nullable().optional()
|
|
57576
|
+
});
|
|
57577
|
+
|
|
57578
|
+
// ../shared/src/utils/slug.ts
|
|
57579
|
+
init_nanoid();
|
|
57580
|
+
var slugId = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz");
|
|
57581
|
+
function sanitizeSlug(input2) {
|
|
57582
|
+
return input2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
|
|
57583
|
+
}
|
|
57584
|
+
|
|
57497
57585
|
// ../shared/src/provider-telemetry.ts
|
|
57498
57586
|
var DAILY_TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
57499
57587
|
var safeToken = exports_external.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
@@ -57561,11 +57649,11 @@ var AvailableQuotaObservationSchema = exports_external.object({
|
|
|
57561
57649
|
}).strict().superRefine((value, ctx) => {
|
|
57562
57650
|
const identities = new Set;
|
|
57563
57651
|
for (const [index2, limit] of value.limits.entries()) {
|
|
57564
|
-
const
|
|
57565
|
-
if (identities.has(
|
|
57652
|
+
const identity2 = quotaIdentity(limit);
|
|
57653
|
+
if (identities.has(identity2)) {
|
|
57566
57654
|
ctx.addIssue({ code: "custom", message: "duplicate quota bucket identity", path: ["limits", index2] });
|
|
57567
57655
|
}
|
|
57568
|
-
identities.add(
|
|
57656
|
+
identities.add(identity2);
|
|
57569
57657
|
}
|
|
57570
57658
|
});
|
|
57571
57659
|
var ProviderQuotaObservationSchema = exports_external.union([
|
|
@@ -57582,23 +57670,6 @@ var ProviderQuotaSnapshotSchema = exports_external.object({
|
|
|
57582
57670
|
observation: ProviderQuotaObservationSchema
|
|
57583
57671
|
}).strict();
|
|
57584
57672
|
|
|
57585
|
-
// ../shared/src/constants/community.ts
|
|
57586
|
-
var MAX_FOLDER_NAME_LENGTH = 100;
|
|
57587
|
-
var MAX_PROFILE_NAME_LENGTH = 100;
|
|
57588
|
-
var MAX_PROFILE_ABOUT_LENGTH = 1000;
|
|
57589
|
-
var MAX_MESSAGE_CONTENT_LENGTH = 4000;
|
|
57590
|
-
var MAX_ATTACHMENTS_PER_MESSAGE = 10;
|
|
57591
|
-
var MAX_ATTACHMENT_SIZE_BYTES = 25 * 1024 * 1024;
|
|
57592
|
-
var MAX_ATTACHMENT_THUMBNAIL_SIZE_BYTES = 256 * 1024;
|
|
57593
|
-
var MAX_SERVER_ICON_SIZE_BYTES = 5 * 1024 * 1024;
|
|
57594
|
-
var ALLOWED_ICON_MIME_TYPES = [
|
|
57595
|
-
"image/png",
|
|
57596
|
-
"image/jpeg",
|
|
57597
|
-
"image/webp",
|
|
57598
|
-
"image/gif"
|
|
57599
|
-
];
|
|
57600
|
-
var MAX_ICON_SOURCE_FILE_SIZE_BYTES = 15 * 1024 * 1024;
|
|
57601
|
-
|
|
57602
57673
|
// ../shared/src/lib/community-name.ts
|
|
57603
57674
|
var FORBIDDEN_NAME_CHARS = /[#@\x00-\x1f\x7f-\x9f]/;
|
|
57604
57675
|
function validateCommunityName(name) {
|
|
@@ -57724,15 +57795,6 @@ var PollResponseSchema = exports_external.object({
|
|
|
57724
57795
|
file_requests: exports_external.array(FileRequestItemSchema).optional(),
|
|
57725
57796
|
meetings: exports_external.array(PollMeetingItemSchema).optional()
|
|
57726
57797
|
});
|
|
57727
|
-
var DaemonPushMessageSchema = exports_external.discriminatedUnion("type", [
|
|
57728
|
-
exports_external.object({ type: exports_external.literal("daemon.tasks"), tasks: exports_external.array(TaskApiSchema) }),
|
|
57729
|
-
exports_external.object({ type: exports_external.literal("daemon.file_requests"), workspaceId: exports_external.string(), requests: exports_external.array(FileRequestItemSchema) }),
|
|
57730
|
-
exports_external.object({ type: exports_external.literal("daemon.meetings"), meetings: exports_external.array(PollMeetingItemSchema) }),
|
|
57731
|
-
exports_external.object({ type: exports_external.literal("daemon.evict"), workspaceId: exports_external.string() }),
|
|
57732
|
-
exports_external.object({ type: exports_external.literal("daemon.update"), version: exports_external.string() }),
|
|
57733
|
-
exports_external.object({ type: exports_external.literal("daemon.rescan") }),
|
|
57734
|
-
exports_external.object({ type: exports_external.literal("daemon.kill"), workspaceId: exports_external.string(), agentId: exports_external.string().min(1), taskId: exports_external.string(), targetTaskId: exports_external.string() })
|
|
57735
|
-
]);
|
|
57736
57798
|
var RegisterResponseSchema = exports_external.object({
|
|
57737
57799
|
runtimes: exports_external.array(exports_external.object({ id: exports_external.string() }))
|
|
57738
57800
|
});
|
|
@@ -57928,10 +57990,6 @@ var CreateMessageRequestSchema = exports_external.object({
|
|
|
57928
57990
|
content: exports_external.string().min(1, "content is required"),
|
|
57929
57991
|
metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
57930
57992
|
});
|
|
57931
|
-
var AgentDmRequestSchema = exports_external.object({
|
|
57932
|
-
content: exports_external.string().min(1, "content is required"),
|
|
57933
|
-
task_id: exports_external.string().min(1).optional()
|
|
57934
|
-
});
|
|
57935
57993
|
var EmailAttachmentSchema = exports_external.object({
|
|
57936
57994
|
key: exports_external.string().min(1),
|
|
57937
57995
|
filename: exports_external.string().min(1),
|
|
@@ -58559,13 +58617,12 @@ var BotCreationSubmitSchema = exports_external.strictObject({
|
|
|
58559
58617
|
requestId: exports_external.string().min(1).max(128),
|
|
58560
58618
|
bots: exports_external.array(BotCreationProposalSchema).min(1).max(BOT_CREATION_MAX_ITEMS)
|
|
58561
58619
|
});
|
|
58562
|
-
var BotCreationIdentitySchema =
|
|
58563
|
-
id:
|
|
58564
|
-
name:
|
|
58565
|
-
discriminator:
|
|
58566
|
-
|
|
58567
|
-
|
|
58568
|
-
});
|
|
58620
|
+
var BotCreationIdentitySchema = CommunityResourceProfileSchema.pick({
|
|
58621
|
+
id: true,
|
|
58622
|
+
name: true,
|
|
58623
|
+
discriminator: true,
|
|
58624
|
+
avatarVersion: true
|
|
58625
|
+
}).extend({ image: CommunityResourceProfileSchema.shape.avatar });
|
|
58569
58626
|
var BotCreationItemSchema = BotCreationProposalSchema.extend({
|
|
58570
58627
|
itemId: exports_external.string(),
|
|
58571
58628
|
description: exports_external.string(),
|
|
@@ -58588,7 +58645,26 @@ var BotCreationDecisionSchema = exports_external.strictObject({ decision: export
|
|
|
58588
58645
|
// ../shared/src/community-resources.ts
|
|
58589
58646
|
var id = exports_external.string().min(1);
|
|
58590
58647
|
var nullableId = id.nullable();
|
|
58591
|
-
var
|
|
58648
|
+
var storedArchivedSchema = exports_external.union([exports_external.boolean(), exports_external.literal(0), exports_external.literal(1)]).transform((value) => value === true || value === 1);
|
|
58649
|
+
var CommunityServerResourceSchema = exports_external.strictObject({
|
|
58650
|
+
id: exports_external.string().min(1),
|
|
58651
|
+
position: exports_external.number().int().nonnegative(),
|
|
58652
|
+
name: exports_external.string(),
|
|
58653
|
+
discriminator: exports_external.string(),
|
|
58654
|
+
description: exports_external.string(),
|
|
58655
|
+
ownerId: exports_external.string(),
|
|
58656
|
+
icon: exports_external.string().nullable(),
|
|
58657
|
+
official: exports_external.boolean(),
|
|
58658
|
+
isOwner: exports_external.boolean()
|
|
58659
|
+
});
|
|
58660
|
+
var CommunityCategoryResourceSchema = exports_external.strictObject({
|
|
58661
|
+
id: exports_external.string().min(1),
|
|
58662
|
+
serverId: exports_external.string().min(1),
|
|
58663
|
+
name: exports_external.string(),
|
|
58664
|
+
position: exports_external.number(),
|
|
58665
|
+
private: exports_external.boolean(),
|
|
58666
|
+
creatorId: exports_external.string().nullable()
|
|
58667
|
+
});
|
|
58592
58668
|
var CommunityChannelResourceSchema = exports_external.strictObject({
|
|
58593
58669
|
id,
|
|
58594
58670
|
type: exports_external.enum(["text", "forum", "thread", "dm"]),
|
|
@@ -58616,31 +58692,13 @@ var CommunityChannelIdentitySchema = CommunityChannelResourceSchema.pick({
|
|
|
58616
58692
|
archived: true,
|
|
58617
58693
|
lastMessageAt: true,
|
|
58618
58694
|
createdAt: true
|
|
58619
|
-
}).
|
|
58620
|
-
var legacyChannelIdentitySchema = CommunityChannelIdentitySchema.extend({
|
|
58621
|
-
archived: legacyArchivedSchema,
|
|
58622
|
-
parentChannelId: nullableId.default(null),
|
|
58623
|
-
parentMessageId: nullableId.default(null),
|
|
58624
|
-
creatorId: nullableId.default(null),
|
|
58625
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null)
|
|
58626
|
-
});
|
|
58695
|
+
}).strip();
|
|
58627
58696
|
var CommunityAccessDecisionSchema = exports_external.strictObject({
|
|
58628
58697
|
channelId: id,
|
|
58629
58698
|
canRead: exports_external.boolean(),
|
|
58630
58699
|
canSend: exports_external.boolean(),
|
|
58631
58700
|
canCreateDiscussion: exports_external.boolean()
|
|
58632
58701
|
});
|
|
58633
|
-
var CommunityLegacyMessageAttachmentSchema = exports_external.strictObject({
|
|
58634
|
-
kind: exports_external.enum(["image", "file"]),
|
|
58635
|
-
name: exports_external.string(),
|
|
58636
|
-
url: exports_external.string(),
|
|
58637
|
-
thumbnailUrl: exports_external.string().optional(),
|
|
58638
|
-
contentType: exports_external.string().optional(),
|
|
58639
|
-
size: exports_external.string().optional(),
|
|
58640
|
-
sizeBytes: exports_external.number().nonnegative().optional(),
|
|
58641
|
-
width: exports_external.number().nonnegative().optional(),
|
|
58642
|
-
height: exports_external.number().nonnegative().optional()
|
|
58643
|
-
});
|
|
58644
58702
|
var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
58645
58703
|
id,
|
|
58646
58704
|
name: exports_external.string(),
|
|
@@ -58651,23 +58709,6 @@ var CommunityMessageAttachmentSchema = exports_external.strictObject({
|
|
|
58651
58709
|
width: exports_external.number().int().nonnegative().nullable(),
|
|
58652
58710
|
height: exports_external.number().int().nonnegative().nullable()
|
|
58653
58711
|
});
|
|
58654
|
-
var CommunityMessagePreviewAttachmentSchema = CommunityMessageAttachmentSchema.partial().required({ name: true, url: true });
|
|
58655
|
-
var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
58656
|
-
id,
|
|
58657
|
-
name: exports_external.string(),
|
|
58658
|
-
discriminator: exports_external.string().min(1).nullable(),
|
|
58659
|
-
avatar: exports_external.string().nullable(),
|
|
58660
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
58661
|
-
aboutMe: exports_external.string().optional(),
|
|
58662
|
-
bannerColor: exports_external.string().nullable().optional(),
|
|
58663
|
-
kind: exports_external.enum(["human", "bot"]).optional(),
|
|
58664
|
-
ownerUserId: nullableId.optional(),
|
|
58665
|
-
ownerHandle: exports_external.string().nullable().optional(),
|
|
58666
|
-
mutualServers: exports_external.number().int().nonnegative().optional(),
|
|
58667
|
-
ownedByViewer: exports_external.boolean().optional(),
|
|
58668
|
-
statusEmoji: exports_external.string().nullable().optional(),
|
|
58669
|
-
statusText: exports_external.string().nullable().optional()
|
|
58670
|
-
});
|
|
58671
58712
|
var CommunityMessageThreadParticipantSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatar: true, avatarVersion: true });
|
|
58672
58713
|
var messageThreadSchema = exports_external.strictObject({
|
|
58673
58714
|
id,
|
|
@@ -58679,14 +58720,6 @@ var messageThreadSchema = exports_external.strictObject({
|
|
|
58679
58720
|
participants: exports_external.array(CommunityMessageThreadParticipantSchema).optional(),
|
|
58680
58721
|
participantCount: exports_external.number().int().nonnegative().optional()
|
|
58681
58722
|
});
|
|
58682
|
-
var legacyMessageThreadSchema = messageThreadSchema.extend({
|
|
58683
|
-
name: exports_external.string(),
|
|
58684
|
-
lastReplyAt: exports_external.string().optional(),
|
|
58685
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.extend({ avatar: exports_external.string() })).optional()
|
|
58686
|
-
});
|
|
58687
|
-
var messageThreadPreviewSchema = messageThreadSchema.partial().required({ id: true }).extend({
|
|
58688
|
-
participants: exports_external.array(CommunityMessageThreadParticipantSchema.partial().required({ id: true })).optional()
|
|
58689
|
-
});
|
|
58690
58723
|
var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
58691
58724
|
id,
|
|
58692
58725
|
channelId: id,
|
|
@@ -58709,7 +58742,7 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
58709
58742
|
authorName: exports_external.string(),
|
|
58710
58743
|
text: exports_external.string(),
|
|
58711
58744
|
deleted: exports_external.boolean().optional()
|
|
58712
|
-
}).optional(),
|
|
58745
|
+
}).refine((reply) => reply.deleted === true || reply.authorId !== undefined, { message: "Live reply author identity missing" }).optional(),
|
|
58713
58746
|
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
58714
58747
|
reactions: exports_external.array(exports_external.strictObject({
|
|
58715
58748
|
emoji: exports_external.string(),
|
|
@@ -58721,21 +58754,37 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
58721
58754
|
approval: FriendApprovalPayloadSchema.optional(),
|
|
58722
58755
|
botCreation: BotCreationPayloadSchema.optional()
|
|
58723
58756
|
});
|
|
58724
|
-
|
|
58725
|
-
|
|
58726
|
-
|
|
58727
|
-
|
|
58757
|
+
function communityMessageProfileIds(messages) {
|
|
58758
|
+
return [...new Set(messages.flatMap((message2) => [message2.authorId, ...message2.replyTo?.authorId && message2.replyTo.deleted !== true ? [message2.replyTo.authorId] : []]))];
|
|
58759
|
+
}
|
|
58760
|
+
var CommunityMessageResourcesSchema = exports_external.strictObject({
|
|
58761
|
+
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
58762
|
+
profiles: exports_external.array(CommunityResourceProfileSchema)
|
|
58763
|
+
}).superRefine((resources, ctx) => {
|
|
58764
|
+
const ids = new Set(resources.profiles.map((profile2) => profile2.id));
|
|
58765
|
+
if (ids.size !== resources.profiles.length || communityMessageProfileIds(resources.messages).some((id2) => !ids.has(id2))) {
|
|
58766
|
+
ctx.addIssue({ code: "custom", path: ["profiles"], message: "Message profile missing or duplicated in resource graph" });
|
|
58767
|
+
}
|
|
58768
|
+
});
|
|
58728
58769
|
var CommunityReadStateResourceSchema = exports_external.strictObject({
|
|
58729
58770
|
channelId: id,
|
|
58730
58771
|
lastReadMessageId: nullableId,
|
|
58731
58772
|
lastReadAt: exports_external.string().nullable(),
|
|
58732
58773
|
lastReadSeq: exports_external.number().int().nonnegative()
|
|
58733
58774
|
});
|
|
58734
|
-
var
|
|
58775
|
+
var CommunityServerMembershipResourceSchema = exports_external.strictObject({
|
|
58776
|
+
serverId: id,
|
|
58777
|
+
userId: id,
|
|
58778
|
+
memberId: id,
|
|
58779
|
+
role: exports_external.string()
|
|
58780
|
+
});
|
|
58781
|
+
var CommunityChannelMembershipResourceSchema = exports_external.strictObject({
|
|
58735
58782
|
channelId: id,
|
|
58736
58783
|
userId: id,
|
|
58737
58784
|
relation: exports_external.enum(["access", "notify"]),
|
|
58738
|
-
source: exports_external.
|
|
58785
|
+
source: exports_external.enum([...Object.values(PARTICIPANT_SOURCE), "explicit", "inherited", "admin", "access-decision"])
|
|
58786
|
+
});
|
|
58787
|
+
var CommunityMemberRelationSchema = CommunityChannelMembershipResourceSchema.extend({
|
|
58739
58788
|
isCreator: exports_external.boolean(),
|
|
58740
58789
|
role: exports_external.string().nullable(),
|
|
58741
58790
|
memberId: nullableId
|
|
@@ -58748,14 +58797,25 @@ var CommunityPageSchema = exports_external.strictObject({
|
|
|
58748
58797
|
latestSeq: exports_external.number().int().nonnegative()
|
|
58749
58798
|
});
|
|
58750
58799
|
var envelope = { contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), channelId: id };
|
|
58800
|
+
var CommunityResourceBundleSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
58801
|
+
viewerId: id,
|
|
58802
|
+
servers: exports_external.array(CommunityServerResourceSchema),
|
|
58803
|
+
serverMemberships: exports_external.array(CommunityServerMembershipResourceSchema),
|
|
58804
|
+
channels: exports_external.array(CommunityChannelResourceSchema),
|
|
58805
|
+
memberships: exports_external.array(CommunityChannelMembershipResourceSchema)
|
|
58806
|
+
}).superRefine((bundle, ctx) => {
|
|
58807
|
+
const channels = new Set(bundle.channels.map((row) => row.id));
|
|
58808
|
+
const servers = new Set(bundle.servers.map((row) => row.id));
|
|
58809
|
+
if (channels.size !== bundle.channels.length || servers.size !== bundle.servers.length || new Set(bundle.messages.map((row) => row.id)).size !== bundle.messages.length || new Set(bundle.profiles.map((row) => row.id)).size !== bundle.profiles.length || new Set(bundle.memberships.map((row) => `${row.channelId}:${row.userId}:${row.relation}`)).size !== bundle.memberships.length || new Set(bundle.serverMemberships.map((row) => `${row.serverId}:${row.userId}`)).size !== bundle.serverMemberships.length || bundle.messages.some((row) => !channels.has(row.channelId)) || bundle.servers.some((row) => !bundle.serverMemberships.some((member2) => member2.serverId === row.id && member2.userId === bundle.viewerId)) || bundle.channels.some((row) => !bundle.memberships.some((member2) => member2.channelId === row.id && member2.userId === bundle.viewerId && member2.relation === "access")) || bundle.channels.some((row) => row.serverId !== null && !servers.has(row.serverId) || row.parentChannelId !== null && !channels.has(row.parentChannelId)) || bundle.memberships.some((row) => row.userId !== bundle.viewerId || !channels.has(row.channelId)) || bundle.serverMemberships.some((row) => row.userId !== bundle.viewerId || !servers.has(row.serverId)))
|
|
58810
|
+
ctx.addIssue({ code: "custom", message: "Resource bundle scope mismatch" });
|
|
58811
|
+
});
|
|
58751
58812
|
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
58752
|
-
var CommunityMessagesReadSchema =
|
|
58813
|
+
var CommunityMessagesReadSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
58753
58814
|
...envelope,
|
|
58754
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
58755
58815
|
page: CommunityPageSchema,
|
|
58756
58816
|
surfaceReceipt: exports_external.strictObject({ channelId: id, surfaceKind: exports_external.enum(["channel", "forum", "thread", "dm"]) })
|
|
58757
58817
|
});
|
|
58758
|
-
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.
|
|
58818
|
+
var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.safeExtend({
|
|
58759
58819
|
viewerId: id,
|
|
58760
58820
|
peer: CommunityResourceProfileSchema.nullable(),
|
|
58761
58821
|
channel: CommunityChannelResourceSchema,
|
|
@@ -58770,6 +58830,12 @@ var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
|
58770
58830
|
anchorMessageId: nullableId
|
|
58771
58831
|
})
|
|
58772
58832
|
}).superRefine((entry, ctx) => {
|
|
58833
|
+
if (entry.opener) {
|
|
58834
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [...entry.messages, entry.opener], profiles: entry.profiles });
|
|
58835
|
+
if (!graph.success)
|
|
58836
|
+
for (const issue3 of graph.error.issues)
|
|
58837
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
58838
|
+
}
|
|
58773
58839
|
for (const [path13, channelId] of [
|
|
58774
58840
|
[["channel", "id"], entry.channel.id],
|
|
58775
58841
|
[["access", "channelId"], entry.access.channelId],
|
|
@@ -58807,72 +58873,37 @@ var CommunityConversationEntryReadSchema = CommunityMessagesReadSchema.extend({
|
|
|
58807
58873
|
if (entry.selection.reason === "read_pointer_missing" && entry.readState.lastReadMessageId === null)
|
|
58808
58874
|
ctx.addIssue({ code: "custom", path: ["selection", "reason"], message: "Conversation entry missing read pointer" });
|
|
58809
58875
|
});
|
|
58810
|
-
var
|
|
58876
|
+
var CommunityMessageReadSchema = exports_external.strictObject({
|
|
58877
|
+
...envelope,
|
|
58811
58878
|
message: CommunityMessageResourceSchema,
|
|
58812
|
-
|
|
58813
|
-
|
|
58879
|
+
profiles: CommunityMessageResourcesSchema.shape.profiles
|
|
58880
|
+
}).superRefine((read, ctx) => {
|
|
58881
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [read.message], profiles: read.profiles });
|
|
58882
|
+
if (!graph.success)
|
|
58883
|
+
for (const issue3 of graph.error.issues)
|
|
58884
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
58814
58885
|
});
|
|
58815
|
-
var
|
|
58886
|
+
var CommunityMessagePostedSchema = CommunityMessageReadSchema.safeExtend({ deduped: exports_external.boolean(), threadId: id.optional() });
|
|
58816
58887
|
var CommunityMembersReadSchema = exports_external.strictObject({ ...envelope, relation: exports_external.enum(["access", "notify"]), members: exports_external.array(CommunityMemberRelationSchema), profiles: exports_external.array(CommunityResourceProfileSchema) });
|
|
58817
58888
|
var CommunityThreadsReadSchema = exports_external.strictObject({
|
|
58818
58889
|
...envelope,
|
|
58819
58890
|
channel: CommunityChannelResourceSchema,
|
|
58820
58891
|
threads: exports_external.array(CommunityChannelResourceSchema),
|
|
58821
|
-
included:
|
|
58822
|
-
messages: exports_external.array(CommunityMessageResourceSchema),
|
|
58892
|
+
included: CommunityMessageResourcesSchema.safeExtend({
|
|
58823
58893
|
members: exports_external.array(CommunityMemberRelationSchema),
|
|
58824
|
-
profiles: exports_external.array(CommunityResourceProfileSchema),
|
|
58825
58894
|
tags: exports_external.array(exports_external.strictObject({ messageId: id, tag: exports_external.string() })),
|
|
58826
58895
|
participantCounts: exports_external.array(exports_external.strictObject({ channelId: id, count: exports_external.number().int().nonnegative() }))
|
|
58827
58896
|
}),
|
|
58828
58897
|
page: exports_external.strictObject({ nextCursor: exports_external.string().nullable(), hasMore: exports_external.boolean() })
|
|
58829
58898
|
});
|
|
58830
58899
|
var CommunityReadAdvanceSchema = exports_external.strictObject({ ...envelope, changed: exports_external.boolean(), targetSeq: exports_external.number().int().nonnegative(), revision: exports_external.number().int().nonnegative() });
|
|
58900
|
+
var CommunityInviteJoinTargetSchema = exports_external.object({ serverId: CommunityServerResourceSchema.shape.id }).strip();
|
|
58831
58901
|
var CommunityReadErrorSchema = exports_external.strictObject({ contractVersion: exports_external.literal(COMMUNITY_RESOURCE_CONTRACT_VERSION), error: exports_external.strictObject({
|
|
58832
58902
|
code: exports_external.enum(["invalid_input", "invalid_reply_target", "unauthenticated", "not_found", "not_allowed", "blocked", "idempotency_conflict", "rate_limited", "temporarily_unavailable"]),
|
|
58833
58903
|
message: exports_external.string(),
|
|
58834
|
-
retryable: exports_external.boolean()
|
|
58904
|
+
retryable: exports_external.boolean(),
|
|
58905
|
+
details: exports_external.array(exports_external.string()).optional()
|
|
58835
58906
|
}) });
|
|
58836
|
-
var legacyProfileSchema = CommunityResourceProfileSchema.pick({
|
|
58837
|
-
id: true,
|
|
58838
|
-
name: true,
|
|
58839
|
-
avatar: true,
|
|
58840
|
-
avatarVersion: true
|
|
58841
|
-
}).extend({ discriminator: exports_external.string().nullable(), statusEmoji: exports_external.string().nullable(), statusText: exports_external.string() });
|
|
58842
|
-
var CommunityLegacyMessageResourceSchema = CommunityMessageResourceSchema.extend({ authorAvatar: exports_external.string().optional(), attachments: exports_external.array(CommunityLegacyMessageAttachmentSchema), thread: legacyMessageThreadSchema.optional() });
|
|
58843
|
-
var legacyEnvelope = { contractVersion: exports_external.literal(2), channelId: id };
|
|
58844
|
-
var legacyReadSchemas = {
|
|
58845
|
-
channel: CommunityChannelReadSchema.extend(legacyEnvelope),
|
|
58846
|
-
messages: CommunityMessagesReadSchema.extend({ ...legacyEnvelope, messages: exports_external.array(CommunityLegacyMessageResourceSchema) }),
|
|
58847
|
-
members: CommunityMembersReadSchema.extend({ ...legacyEnvelope, profiles: exports_external.array(legacyProfileSchema) }),
|
|
58848
|
-
threads: CommunityThreadsReadSchema.extend({ ...legacyEnvelope, included: CommunityThreadsReadSchema.shape.included.extend({
|
|
58849
|
-
messages: exports_external.array(CommunityLegacyMessageResourceSchema),
|
|
58850
|
-
profiles: exports_external.array(legacyProfileSchema)
|
|
58851
|
-
}) }),
|
|
58852
|
-
readAdvance: CommunityReadAdvanceSchema.extend(legacyEnvelope),
|
|
58853
|
-
error: CommunityReadErrorSchema.extend({ contractVersion: exports_external.literal(2) })
|
|
58854
|
-
};
|
|
58855
|
-
var legacyChannelResourcePreviewSchema = CommunityChannelResourceSchema.partial().strip().extend({
|
|
58856
|
-
archived: legacyArchivedSchema.optional()
|
|
58857
|
-
});
|
|
58858
|
-
var legacyChannelResourceSchema = CommunityChannelResourceSchema.strip().extend({
|
|
58859
|
-
topic: CommunityChannelResourceSchema.shape.topic.nullish().transform((value) => value ?? ""),
|
|
58860
|
-
position: CommunityChannelResourceSchema.shape.position.nullish().transform((value) => value ?? 0),
|
|
58861
|
-
messageCount: CommunityChannelResourceSchema.shape.messageCount.nullish().transform((value) => value ?? 0),
|
|
58862
|
-
categoryId: nullableId.default(null),
|
|
58863
|
-
parentChannelId: nullableId.default(null),
|
|
58864
|
-
parentMessageId: nullableId.default(null),
|
|
58865
|
-
creatorId: nullableId.default(null),
|
|
58866
|
-
lastMessageAt: CommunityChannelResourceSchema.shape.lastMessageAt.default(null),
|
|
58867
|
-
archived: legacyArchivedSchema
|
|
58868
|
-
});
|
|
58869
|
-
var legacyMessageResourceSchema = CommunityLegacyMessageResourceSchema.strip().extend({
|
|
58870
|
-
channelId: id.optional(),
|
|
58871
|
-
replyToId: nullableId.optional(),
|
|
58872
|
-
clientNonce: CommunityMessageResourceSchema.shape.clientNonce.default(null),
|
|
58873
|
-
attachments: CommunityLegacyMessageResourceSchema.shape.attachments.default([]),
|
|
58874
|
-
embeds: CommunityMessageResourceSchema.shape.embeds.nullable().transform((value) => value ?? undefined)
|
|
58875
|
-
});
|
|
58876
58907
|
|
|
58877
58908
|
// ../shared/src/community-attention.ts
|
|
58878
58909
|
var id2 = exports_external.string().min(1);
|
|
@@ -58927,11 +58958,7 @@ var AttentionItemSchema = exports_external.strictObject({
|
|
|
58927
58958
|
ctx.addIssue({ code: "custom", message: "mention or reply cannot carry forum presentation refs" });
|
|
58928
58959
|
}
|
|
58929
58960
|
});
|
|
58930
|
-
var AttentionIncludedServerSchema =
|
|
58931
|
-
id: id2,
|
|
58932
|
-
name: exports_external.string(),
|
|
58933
|
-
discriminator: exports_external.string()
|
|
58934
|
-
});
|
|
58961
|
+
var AttentionIncludedServerSchema = CommunityServerResourceSchema.pick({ id: true, name: true, discriminator: true });
|
|
58935
58962
|
var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
58936
58963
|
id: true,
|
|
58937
58964
|
serverId: true,
|
|
@@ -58952,20 +58979,17 @@ var AttentionIncludedChannelSchema = CommunityChannelResourceSchema.pick({
|
|
|
58952
58979
|
var AttentionIncludedDmSchema = exports_external.strictObject({
|
|
58953
58980
|
id: id2,
|
|
58954
58981
|
userId: id2,
|
|
58955
|
-
name:
|
|
58956
|
-
discriminator: exports_external.string(),
|
|
58957
|
-
avatar: exports_external.string(),
|
|
58958
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
58982
|
+
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
58959
58983
|
lastMessageAt: exports_external.string(),
|
|
58960
58984
|
lastUnreadSeq: exports_external.number().int().nonnegative()
|
|
58961
58985
|
});
|
|
58962
58986
|
var AttentionIncludedProfileSchema = exports_external.strictObject({
|
|
58963
58987
|
userId: CommunityResourceProfileSchema.shape.id,
|
|
58964
58988
|
...CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).shape,
|
|
58965
|
-
discriminator:
|
|
58966
|
-
avatar:
|
|
58989
|
+
discriminator: CommunityResourceProfileSchema.shape.discriminator,
|
|
58990
|
+
avatar: CommunityResourceProfileSchema.shape.avatar
|
|
58967
58991
|
});
|
|
58968
|
-
var AttentionIncludedMessageSchema =
|
|
58992
|
+
var AttentionIncludedMessageSchema = CommunityMessageResourceSchema.pick({
|
|
58969
58993
|
id: true,
|
|
58970
58994
|
channelId: true,
|
|
58971
58995
|
type: true,
|
|
@@ -58974,7 +58998,7 @@ var AttentionIncludedMessageSchema = CommunityMessagePreviewSchema.pick({
|
|
|
58974
58998
|
seq: true,
|
|
58975
58999
|
createdAt: true,
|
|
58976
59000
|
content: true
|
|
58977
|
-
}).
|
|
59001
|
+
}).partial({ authorId: true });
|
|
58978
59002
|
var AttentionIncludedSchema = exports_external.strictObject({
|
|
58979
59003
|
servers: exports_external.array(AttentionIncludedServerSchema),
|
|
58980
59004
|
channels: exports_external.array(AttentionIncludedChannelSchema),
|
|
@@ -58982,13 +59006,19 @@ var AttentionIncludedSchema = exports_external.strictObject({
|
|
|
58982
59006
|
profiles: exports_external.array(AttentionIncludedProfileSchema),
|
|
58983
59007
|
messages: exports_external.array(AttentionIncludedMessageSchema)
|
|
58984
59008
|
});
|
|
58985
|
-
var
|
|
59009
|
+
var AccountAttentionProjectionSchema = exports_external.strictObject({
|
|
58986
59010
|
scopes: exports_external.array(AttentionScopeSchema),
|
|
58987
59011
|
items: exports_external.array(AttentionItemSchema),
|
|
58988
59012
|
limit: exports_external.number().int().positive(),
|
|
58989
59013
|
truncated: exports_external.boolean(),
|
|
58990
59014
|
included: AttentionIncludedSchema
|
|
59015
|
+
});
|
|
59016
|
+
var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
59017
|
+
resources: CommunityResourceBundleSchema
|
|
58991
59018
|
}).superRefine((snapshot, ctx) => {
|
|
59019
|
+
const resources = snapshot.resources;
|
|
59020
|
+
if (snapshot.included.servers.some((summary) => !resources.servers.some((row) => row.id === summary.id)) || [...snapshot.included.channels, ...snapshot.included.dms].some((summary) => !resources.channels.some((row) => row.id === summary.id)) || snapshot.included.profiles.some((summary) => !resources.profiles.some((row) => row.id === summary.userId)) || snapshot.included.messages.some((summary) => !resources.messages.some((row) => row.id === summary.id && row.channelId === summary.channelId)) || resources.memberships.some((row) => row.userId !== resources.viewerId || row.relation !== "access" || !resources.channels.some((channel2) => channel2.id === row.channelId)) || resources.serverMemberships.some((row) => row.userId !== resources.viewerId || !resources.servers.some((server) => server.id === row.serverId)))
|
|
59021
|
+
ctx.addIssue({ code: "custom", message: "Attention resource closure mismatch" });
|
|
58992
59022
|
const scopeIds = new Set;
|
|
58993
59023
|
for (const scope of snapshot.scopes) {
|
|
58994
59024
|
if (scopeIds.has(scope.scopeId)) {
|
|
@@ -59783,52 +59813,85 @@ var AGENT_UNREAD_CHANNEL_CHUNK_SIZE = maxInParams(13);
|
|
|
59783
59813
|
|
|
59784
59814
|
// ../shared/src/db/queries/community/mention.ts
|
|
59785
59815
|
var MENTION_INSERT_MAX_ROWS = maxRowsPerInsert(5);
|
|
59816
|
+
// ../shared/src/community-cache.ts
|
|
59817
|
+
var nullableString = exports_external.string().nullable();
|
|
59818
|
+
var optionalNullableString = nullableString.optional();
|
|
59819
|
+
var serverSchema = CommunityServerResourceSchema;
|
|
59820
|
+
var categorySchema = CommunityCategoryResourceSchema.extend({ pending: exports_external.boolean() });
|
|
59821
|
+
var channelLocalSchema = exports_external.strictObject({
|
|
59822
|
+
muted: exports_external.boolean(),
|
|
59823
|
+
tags: exports_external.array(exports_external.string()),
|
|
59824
|
+
pending: exports_external.boolean(),
|
|
59825
|
+
openerSeq: exports_external.number().int().nonnegative().optional(),
|
|
59826
|
+
openerUnread: exports_external.boolean().optional(),
|
|
59827
|
+
preview: exports_external.string().optional(),
|
|
59828
|
+
firstMessageId: exports_external.string().min(1).nullable().optional(),
|
|
59829
|
+
participantCount: exports_external.number().int().nonnegative().optional()
|
|
59830
|
+
});
|
|
59831
|
+
var channelSchema = CommunityChannelResourceSchema.extend(channelLocalSchema.shape);
|
|
59832
|
+
var serverMembershipSchema = CommunityServerMembershipResourceSchema.extend({
|
|
59833
|
+
id: exports_external.string().min(1),
|
|
59834
|
+
nickname: optionalNullableString,
|
|
59835
|
+
joinedAt: exports_external.string().optional(),
|
|
59836
|
+
viewer: exports_external.boolean()
|
|
59837
|
+
});
|
|
59838
|
+
var channelMembershipSchema = CommunityChannelMembershipResourceSchema.extend({ id: exports_external.string().min(1) });
|
|
59839
|
+
var readStateSchema = CommunityReadStateResourceSchema.extend({ observedRevision: exports_external.number().int().nonnegative().optional() });
|
|
59840
|
+
var friendshipSchema = exports_external.strictObject({
|
|
59841
|
+
id: exports_external.string().min(1),
|
|
59842
|
+
userId: exports_external.string().min(1),
|
|
59843
|
+
kind: exports_external.enum(["accepted", "incoming", "outgoing", "blocked"]),
|
|
59844
|
+
sub: exports_external.string().optional(),
|
|
59845
|
+
needsOwnerApproval: optionalNullableString
|
|
59846
|
+
});
|
|
59847
|
+
var readStateClockSchema = exports_external.strictObject({
|
|
59848
|
+
id: exports_external.literal("account"),
|
|
59849
|
+
revision: exports_external.number().int().nonnegative()
|
|
59850
|
+
});
|
|
59851
|
+
var folderSchema = exports_external.strictObject({
|
|
59852
|
+
id: exports_external.string().min(1),
|
|
59853
|
+
name: exports_external.string()
|
|
59854
|
+
});
|
|
59855
|
+
var serverRailSchema = exports_external.strictObject({
|
|
59856
|
+
id: exports_external.literal("account"),
|
|
59857
|
+
entries: exports_external.array(serverRailEntrySchema)
|
|
59858
|
+
});
|
|
59859
|
+
var folderItemSchema = exports_external.strictObject({
|
|
59860
|
+
id: exports_external.string().min(1),
|
|
59861
|
+
folderId: exports_external.string().min(1),
|
|
59862
|
+
serverId: exports_external.string().min(1),
|
|
59863
|
+
position: exports_external.number()
|
|
59864
|
+
});
|
|
59865
|
+
var notificationSettingSchema = exports_external.strictObject({
|
|
59866
|
+
id: exports_external.string().min(1),
|
|
59867
|
+
serverId: optionalNullableString,
|
|
59868
|
+
channelId: optionalNullableString,
|
|
59869
|
+
level: exports_external.string()
|
|
59870
|
+
}).superRefine((row, ctx) => {
|
|
59871
|
+
if (Boolean(row.serverId) === Boolean(row.channelId)) {
|
|
59872
|
+
ctx.addIssue({
|
|
59873
|
+
code: "custom",
|
|
59874
|
+
message: "notification setting requires exactly one target"
|
|
59875
|
+
});
|
|
59876
|
+
}
|
|
59877
|
+
});
|
|
59878
|
+
|
|
59786
59879
|
// ../shared/src/community-ws-events.ts
|
|
59787
59880
|
var string4 = exports_external.string();
|
|
59788
|
-
var
|
|
59881
|
+
var nullableString2 = string4.nullable();
|
|
59789
59882
|
var channelTypeSchema = CommunityChannelResourceSchema.shape.type.extract(["text", "forum"]);
|
|
59790
|
-
var
|
|
59791
|
-
id: string4,
|
|
59792
|
-
filename: string4,
|
|
59793
|
-
url: string4,
|
|
59794
|
-
thumbnailUrl: string4.optional(),
|
|
59795
|
-
contentType: string4.optional(),
|
|
59796
|
-
size: exports_external.number().optional(),
|
|
59797
|
-
width: exports_external.number().nullable().optional(),
|
|
59798
|
-
height: exports_external.number().nullable().optional()
|
|
59799
|
-
});
|
|
59800
|
-
var messageSchema = CommunityMessageResourceSchema.pick({
|
|
59801
|
-
content: true,
|
|
59802
|
-
type: true,
|
|
59803
|
-
systemKind: true,
|
|
59804
|
-
authorAvatar: true,
|
|
59805
|
-
authorAvatarVersion: true,
|
|
59806
|
-
mentionType: true,
|
|
59807
|
-
embeds: true,
|
|
59808
|
-
createdAt: true,
|
|
59809
|
-
approval: true,
|
|
59810
|
-
botCreation: true
|
|
59811
|
-
}).extend({
|
|
59812
|
-
id: string4,
|
|
59813
|
-
seq: exports_external.number(),
|
|
59814
|
-
authorId: string4,
|
|
59815
|
-
authorName: string4,
|
|
59816
|
-
authorAvatar: string4.optional(),
|
|
59817
|
-
authorAvatarVersion: CommunityMessageResourceSchema.shape.authorAvatarVersion.unwrap(),
|
|
59818
|
-
replyToId: nullableString.optional(),
|
|
59819
|
-
replyTo: CommunityMessageResourceSchema.shape.replyTo.unwrap().extend({
|
|
59820
|
-
id: string4,
|
|
59821
|
-
authorId: string4.optional()
|
|
59822
|
-
}).optional(),
|
|
59823
|
-
attachments: exports_external.array(messageAttachmentSchema).optional(),
|
|
59824
|
-
clientNonce: string4.optional()
|
|
59825
|
-
});
|
|
59826
|
-
var CommunityLegacyMessageCreateSchema = exports_external.strictObject({
|
|
59883
|
+
var communityMessageCreateSchema = exports_external.strictObject({
|
|
59827
59884
|
type: exports_external.literal("community:message.create"),
|
|
59828
59885
|
channelId: string4,
|
|
59829
59886
|
serverId: string4.optional(),
|
|
59830
59887
|
parentChannelId: string4.optional(),
|
|
59831
|
-
message:
|
|
59888
|
+
message: CommunityMessageResourceSchema.required({ authorName: true, authorAvatarVersion: true }),
|
|
59889
|
+
profiles: CommunityMessageResourcesSchema.shape.profiles
|
|
59890
|
+
}).refine((event) => event.message.channelId === event.channelId).superRefine((event, ctx) => {
|
|
59891
|
+
const graph = CommunityMessageResourcesSchema.safeParse({ messages: [event.message], profiles: event.profiles });
|
|
59892
|
+
if (!graph.success)
|
|
59893
|
+
for (const issue3 of graph.error.issues)
|
|
59894
|
+
ctx.addIssue({ code: "custom", path: issue3.path, message: issue3.message });
|
|
59832
59895
|
});
|
|
59833
59896
|
var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
59834
59897
|
type: exports_external.literal("community:message.updated"),
|
|
@@ -59837,14 +59900,6 @@ var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
|
59837
59900
|
approval: FriendApprovalPayloadSchema.optional(),
|
|
59838
59901
|
botCreation: BotCreationPayloadSchema.optional()
|
|
59839
59902
|
}).refine((event) => event.approval !== undefined || event.botCreation !== undefined);
|
|
59840
|
-
var communityMessageEditedSchema = exports_external.strictObject({
|
|
59841
|
-
type: exports_external.literal("community:message.edited"),
|
|
59842
|
-
channelId: string4,
|
|
59843
|
-
messageId: string4,
|
|
59844
|
-
content: string4,
|
|
59845
|
-
parentChannelId: string4.optional(),
|
|
59846
|
-
serverId: string4.optional()
|
|
59847
|
-
}).refine((event) => event.parentChannelId === undefined || event.serverId !== undefined);
|
|
59848
59903
|
var communityReactionAddSchema = exports_external.strictObject({
|
|
59849
59904
|
type: exports_external.literal("community:reaction.add"),
|
|
59850
59905
|
channelId: string4,
|
|
@@ -59886,35 +59941,19 @@ var communityTypingStopSchema = exports_external.strictObject({
|
|
|
59886
59941
|
var communityChildChannelCreateSchema = exports_external.strictObject({
|
|
59887
59942
|
type: exports_external.literal("community:channel.child_create"),
|
|
59888
59943
|
parentChannelId: string4,
|
|
59889
|
-
channel: exports_external.
|
|
59890
|
-
id: string4,
|
|
59891
|
-
name: string4,
|
|
59892
|
-
type: exports_external.literal("thread"),
|
|
59893
|
-
creatorId: string4.optional(),
|
|
59894
|
-
createdAt: string4
|
|
59895
|
-
}),
|
|
59944
|
+
channel: CommunityChannelResourceSchema.extend({ type: exports_external.literal("thread") }),
|
|
59896
59945
|
parentMessageId: string4.optional()
|
|
59897
|
-
});
|
|
59946
|
+
}).refine((event) => event.channel.parentChannelId === event.parentChannelId && (event.parentMessageId === undefined || event.parentMessageId === event.channel.parentMessageId));
|
|
59898
59947
|
var communityChildChannelUpdateSchema = exports_external.strictObject({
|
|
59899
59948
|
type: exports_external.literal("community:channel.child_update"),
|
|
59900
59949
|
parentChannelId: string4,
|
|
59901
59950
|
channelId: string4,
|
|
59902
|
-
changes: exports_external.
|
|
59903
|
-
name: string4.optional(),
|
|
59904
|
-
archived: exports_external.boolean().optional(),
|
|
59905
|
-
tags: exports_external.array(string4).nullable().optional(),
|
|
59906
|
-
lastMessageAt: string4.optional(),
|
|
59907
|
-
messageCount: exports_external.number().optional()
|
|
59908
|
-
})
|
|
59951
|
+
changes: CommunityChannelResourceSchema.pick({ name: true, archived: true, lastMessageAt: true, messageCount: true }).partial().extend({ tags: exports_external.array(string4).nullable().optional() })
|
|
59909
59952
|
});
|
|
59910
59953
|
var communityServerUpdateSchema = exports_external.strictObject({
|
|
59911
59954
|
type: exports_external.literal("community:server.update"),
|
|
59912
59955
|
serverId: string4,
|
|
59913
|
-
changes:
|
|
59914
|
-
name: string4.optional(),
|
|
59915
|
-
description: string4.optional(),
|
|
59916
|
-
icon: nullableString.optional()
|
|
59917
|
-
})
|
|
59956
|
+
changes: serverSchema.pick({ name: true, description: true, icon: true }).partial()
|
|
59918
59957
|
});
|
|
59919
59958
|
var communityServerRailChangedSchema = exports_external.strictObject({
|
|
59920
59959
|
type: exports_external.literal("community:server_rail.changed")
|
|
@@ -59926,32 +59965,19 @@ var communityServerDeleteSchema = exports_external.strictObject({
|
|
|
59926
59965
|
var communityChannelCreateSchema = exports_external.strictObject({
|
|
59927
59966
|
type: exports_external.literal("community:channel.create"),
|
|
59928
59967
|
serverId: string4,
|
|
59929
|
-
channel:
|
|
59930
|
-
|
|
59931
|
-
name: string4,
|
|
59932
|
-
type: channelTypeSchema,
|
|
59933
|
-
categoryId: nullableString.optional(),
|
|
59934
|
-
topic: string4.optional(),
|
|
59935
|
-
position: exports_external.number(),
|
|
59936
|
-
createdAt: string4
|
|
59937
|
-
})
|
|
59938
|
-
});
|
|
59968
|
+
channel: CommunityChannelResourceSchema.extend({ type: channelTypeSchema })
|
|
59969
|
+
}).refine((event) => event.channel.serverId === event.serverId);
|
|
59939
59970
|
var communityChannelUpdateSchema = exports_external.strictObject({
|
|
59940
59971
|
type: exports_external.literal("community:channel.update"),
|
|
59941
59972
|
serverId: string4,
|
|
59942
59973
|
channelId: string4,
|
|
59943
|
-
changes:
|
|
59944
|
-
name: string4.optional(),
|
|
59945
|
-
topic: string4.optional(),
|
|
59946
|
-
categoryId: nullableString.optional(),
|
|
59947
|
-
type: channelTypeSchema.optional()
|
|
59948
|
-
})
|
|
59974
|
+
changes: CommunityChannelResourceSchema.pick({ name: true, topic: true, categoryId: true, type: true }).partial().extend({ type: channelTypeSchema.optional() })
|
|
59949
59975
|
});
|
|
59950
59976
|
var communityChannelDeleteSchema = exports_external.strictObject({
|
|
59951
59977
|
type: exports_external.literal("community:channel.delete"),
|
|
59952
59978
|
serverId: string4,
|
|
59953
59979
|
channelId: string4,
|
|
59954
|
-
parentChannelId:
|
|
59980
|
+
parentChannelId: nullableString2.optional(),
|
|
59955
59981
|
parentMessageId: string4.optional()
|
|
59956
59982
|
}).refine((event) => event.parentMessageId === undefined || typeof event.parentChannelId === "string" && event.parentChannelId.length > 0, { message: "parentMessageId requires parentChannelId" });
|
|
59957
59983
|
var positionedIdSchema = exports_external.strictObject({ id: string4, position: exports_external.number() });
|
|
@@ -59960,18 +59986,6 @@ var communityChannelReorderSchema = exports_external.strictObject({
|
|
|
59960
59986
|
serverId: string4,
|
|
59961
59987
|
channels: exports_external.array(positionedIdSchema)
|
|
59962
59988
|
});
|
|
59963
|
-
var communityChannelMemberAddSchema = exports_external.strictObject({
|
|
59964
|
-
type: exports_external.literal("community:channel.member_add"),
|
|
59965
|
-
serverId: string4,
|
|
59966
|
-
channelId: string4,
|
|
59967
|
-
userId: string4
|
|
59968
|
-
});
|
|
59969
|
-
var communityChannelMemberRemoveSchema = exports_external.strictObject({
|
|
59970
|
-
type: exports_external.literal("community:channel.member_remove"),
|
|
59971
|
-
serverId: string4,
|
|
59972
|
-
channelId: string4,
|
|
59973
|
-
userId: string4
|
|
59974
|
-
});
|
|
59975
59989
|
var communityChannelMembershipChangeSchema = exports_external.strictObject({
|
|
59976
59990
|
type: exports_external.literal("community:channel.membership.change"),
|
|
59977
59991
|
channelId: string4,
|
|
@@ -59983,12 +59997,7 @@ var communityChannelMembershipChangeSchema = exports_external.strictObject({
|
|
|
59983
59997
|
var communityCategoryCreateSchema = exports_external.strictObject({
|
|
59984
59998
|
type: exports_external.literal("community:category.create"),
|
|
59985
59999
|
serverId: string4,
|
|
59986
|
-
category:
|
|
59987
|
-
id: string4,
|
|
59988
|
-
name: string4,
|
|
59989
|
-
position: exports_external.number(),
|
|
59990
|
-
private: exports_external.boolean()
|
|
59991
|
-
})
|
|
60000
|
+
category: CommunityCategoryResourceSchema
|
|
59992
60001
|
});
|
|
59993
60002
|
var communityCategoryUpdateSchema = exports_external.strictObject({
|
|
59994
60003
|
type: exports_external.literal("community:category.update"),
|
|
@@ -60013,13 +60022,9 @@ var communityCategoryReorderSchema = exports_external.strictObject({
|
|
|
60013
60022
|
var communityMemberJoinSchema = exports_external.strictObject({
|
|
60014
60023
|
type: exports_external.literal("community:member.join"),
|
|
60015
60024
|
serverId: string4,
|
|
60016
|
-
member:
|
|
60025
|
+
member: CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true }).extend({
|
|
60017
60026
|
id: string4,
|
|
60018
60027
|
userId: string4,
|
|
60019
|
-
name: string4,
|
|
60020
|
-
discriminator: string4,
|
|
60021
|
-
avatar: string4.optional(),
|
|
60022
|
-
avatarVersion: exports_external.number().int().nonnegative(),
|
|
60023
60028
|
role: string4,
|
|
60024
60029
|
joinedAt: string4
|
|
60025
60030
|
})
|
|
@@ -60036,7 +60041,7 @@ var communityMemberUpdateSchema = exports_external.strictObject({
|
|
|
60036
60041
|
userId: string4.optional(),
|
|
60037
60042
|
changes: exports_external.strictObject({
|
|
60038
60043
|
role: string4.optional(),
|
|
60039
|
-
nickname:
|
|
60044
|
+
nickname: nullableString2.optional()
|
|
60040
60045
|
})
|
|
60041
60046
|
});
|
|
60042
60047
|
var communityFriendRequestSchema = exports_external.strictObject({
|
|
@@ -60067,7 +60072,7 @@ var communityFriendBlockSchema = exports_external.strictObject({
|
|
|
60067
60072
|
userId: string4,
|
|
60068
60073
|
blockedByViewer: exports_external.boolean().optional()
|
|
60069
60074
|
});
|
|
60070
|
-
var
|
|
60075
|
+
var CommunityInviteCreateSchema = exports_external.strictObject({
|
|
60071
60076
|
type: exports_external.literal("community:invite.create"),
|
|
60072
60077
|
serverId: string4,
|
|
60073
60078
|
invite: exports_external.strictObject({
|
|
@@ -60075,7 +60080,7 @@ var communityInviteCreateSchema = exports_external.strictObject({
|
|
|
60075
60080
|
token: string4,
|
|
60076
60081
|
maxUses: exports_external.number().nullable().optional(),
|
|
60077
60082
|
uses: exports_external.number().nullable().optional(),
|
|
60078
|
-
expiresAt:
|
|
60083
|
+
expiresAt: nullableString2.optional(),
|
|
60079
60084
|
createdAt: string4
|
|
60080
60085
|
})
|
|
60081
60086
|
});
|
|
@@ -60120,24 +60125,17 @@ var communityPresenceUpdateSchema = exports_external.strictObject({
|
|
|
60120
60125
|
var communityStatusUpdateSchema = exports_external.strictObject({
|
|
60121
60126
|
type: exports_external.literal("community:status.update"),
|
|
60122
60127
|
userId: string4,
|
|
60123
|
-
statusEmoji:
|
|
60124
|
-
statusText:
|
|
60128
|
+
statusEmoji: nullableString2,
|
|
60129
|
+
statusText: nullableString2
|
|
60125
60130
|
});
|
|
60126
|
-
var communityIdentityUpdateSchema =
|
|
60131
|
+
var communityIdentityUpdateSchema = CommunityResourceProfileSchema.pick({ avatar: true, avatarVersion: true }).extend({
|
|
60127
60132
|
type: exports_external.literal("community:identity.update"),
|
|
60128
60133
|
userId: string4,
|
|
60129
|
-
|
|
60130
|
-
avatarVersion: exports_external.number().int().positive()
|
|
60134
|
+
avatarVersion: CommunityResourceProfileSchema.shape.avatarVersion.refine((version3) => version3 > 0)
|
|
60131
60135
|
});
|
|
60132
|
-
var communityProfileUpdateSchema =
|
|
60136
|
+
var communityProfileUpdateSchema = CommunityResourceProfileSchema.pick({ name: true, discriminator: true, aboutMe: true, bannerColor: true, kind: true, ownerUserId: true }).required().extend({
|
|
60133
60137
|
type: exports_external.literal("community:profile.update"),
|
|
60134
|
-
userId: string4
|
|
60135
|
-
name: string4,
|
|
60136
|
-
discriminator: string4,
|
|
60137
|
-
aboutMe: string4,
|
|
60138
|
-
bannerColor: nullableString,
|
|
60139
|
-
kind: exports_external.enum(["human", "bot"]),
|
|
60140
|
-
ownerUserId: nullableString
|
|
60138
|
+
userId: string4
|
|
60141
60139
|
});
|
|
60142
60140
|
var communityMachineCreatedSchema = exports_external.strictObject({
|
|
60143
60141
|
type: exports_external.literal("community:machine.created"),
|
|
@@ -60164,8 +60162,8 @@ var communityBotAuditEventSchema = exports_external.strictObject({
|
|
|
60164
60162
|
id: string4,
|
|
60165
60163
|
kind: exports_external.enum(["cli_invocation", "tool_call", "thinking", "text", "turn_interrupt", "wake_trigger", "session_reset", "nap", "model_changed", "provider_changed", "error"]),
|
|
60166
60164
|
payload: exports_external.unknown(),
|
|
60167
|
-
sessionId:
|
|
60168
|
-
launchId:
|
|
60165
|
+
sessionId: nullableString2.optional(),
|
|
60166
|
+
launchId: nullableString2.optional(),
|
|
60169
60167
|
createdAt: string4
|
|
60170
60168
|
}).refine((event) => Object.prototype.hasOwnProperty.call(event, "payload"));
|
|
60171
60169
|
var communityRuntimeModelsSchema = exports_external.strictObject({
|
|
@@ -60185,7 +60183,6 @@ var communityBotPiiSchema = exports_external.strictObject({
|
|
|
60185
60183
|
var commonCommunityEventSchemas = [
|
|
60186
60184
|
communityBotPiiSchema,
|
|
60187
60185
|
communityMessageUpdatedSchema,
|
|
60188
|
-
communityMessageEditedSchema,
|
|
60189
60186
|
communityReactionAddSchema,
|
|
60190
60187
|
communityReactionRemoveSchema,
|
|
60191
60188
|
communityPinAddSchema,
|
|
@@ -60197,8 +60194,6 @@ var commonCommunityEventSchemas = [
|
|
|
60197
60194
|
communityServerDeleteSchema,
|
|
60198
60195
|
communityChannelDeleteSchema,
|
|
60199
60196
|
communityChannelReorderSchema,
|
|
60200
|
-
communityChannelMemberAddSchema,
|
|
60201
|
-
communityChannelMemberRemoveSchema,
|
|
60202
60197
|
communityChannelMembershipChangeSchema,
|
|
60203
60198
|
communityCategoryCreateSchema,
|
|
60204
60199
|
communityCategoryUpdateSchema,
|
|
@@ -60212,7 +60207,7 @@ var commonCommunityEventSchemas = [
|
|
|
60212
60207
|
communityFriendRejectSchema,
|
|
60213
60208
|
communityFriendRemoveSchema,
|
|
60214
60209
|
communityFriendBlockSchema,
|
|
60215
|
-
|
|
60210
|
+
CommunityInviteCreateSchema,
|
|
60216
60211
|
communityMentionCreateSchema,
|
|
60217
60212
|
communityUnreadBumpSchema,
|
|
60218
60213
|
communityReadStateAdvancedSchema,
|
|
@@ -60226,9 +60221,9 @@ var commonCommunityEventSchemas = [
|
|
|
60226
60221
|
communityMachineRemovedSchema,
|
|
60227
60222
|
communityBotAuditEventSchema
|
|
60228
60223
|
];
|
|
60229
|
-
var
|
|
60224
|
+
var CommunityWsEventSchema = exports_external.discriminatedUnion("type", [
|
|
60230
60225
|
...commonCommunityEventSchemas,
|
|
60231
|
-
|
|
60226
|
+
communityMessageCreateSchema,
|
|
60232
60227
|
communityChildChannelCreateSchema,
|
|
60233
60228
|
communityChannelCreateSchema,
|
|
60234
60229
|
communityChildChannelUpdateSchema,
|
|
@@ -60236,22 +60231,9 @@ var CommunityWsEventDiscriminatedSchema = exports_external.discriminatedUnion("t
|
|
|
60236
60231
|
communityIdentityUpdateSchema,
|
|
60237
60232
|
communityProfileUpdateSchema
|
|
60238
60233
|
]);
|
|
60239
|
-
var CommunityResourceWsEventDiscriminatedSchema = exports_external.discriminatedUnion("type", [
|
|
60240
|
-
...commonCommunityEventSchemas,
|
|
60241
|
-
CommunityLegacyMessageCreateSchema.extend({ message: CommunityMessageResourceSchema.required({ authorName: true, authorAvatarVersion: true }) }).refine((event) => event.message.channelId === event.channelId),
|
|
60242
|
-
communityChildChannelCreateSchema.extend({ channel: CommunityChannelResourceSchema.extend({ type: exports_external.literal("thread") }) }).refine((event) => event.channel.parentChannelId === event.parentChannelId && (event.parentMessageId === undefined || event.parentMessageId === event.channel.parentMessageId)),
|
|
60243
|
-
communityChannelCreateSchema.extend({ channel: CommunityChannelResourceSchema.extend({ type: channelTypeSchema }) }).refine((event) => event.channel.serverId === event.serverId),
|
|
60244
|
-
communityChildChannelUpdateSchema.extend({ changes: CommunityChannelResourceSchema.pick({ name: true, archived: true, lastMessageAt: true, messageCount: true }).partial().extend({ tags: exports_external.array(string4).nullable().optional() }) }),
|
|
60245
|
-
communityChannelUpdateSchema.extend({ changes: CommunityChannelResourceSchema.pick({ name: true, topic: true, categoryId: true, type: true }).partial().extend({ type: channelTypeSchema.optional() }) }),
|
|
60246
|
-
communityIdentityUpdateSchema.extend({ avatar: CommunityResourceProfileSchema.shape.avatar, avatarVersion: CommunityResourceProfileSchema.shape.avatarVersion.refine((version3) => version3 > 0) }),
|
|
60247
|
-
CommunityResourceProfileSchema.pick({ name: true, discriminator: true, aboutMe: true, bannerColor: true, kind: true, ownerUserId: true }).required().extend({ type: exports_external.literal("community:profile.update"), userId: string4 })
|
|
60248
|
-
]);
|
|
60249
|
-
var CommunityWsEventSchema = CommunityWsEventDiscriminatedSchema.transform((event) => event);
|
|
60250
|
-
var CommunityResourceWsEventSchema = CommunityResourceWsEventDiscriminatedSchema.transform((event) => event);
|
|
60251
60234
|
var WS_EVENTS = {
|
|
60252
60235
|
MESSAGE_CREATE: "community:message.create",
|
|
60253
60236
|
MESSAGE_UPDATED: "community:message.updated",
|
|
60254
|
-
MESSAGE_EDITED: "community:message.edited",
|
|
60255
60237
|
REACTION_ADD: "community:reaction.add",
|
|
60256
60238
|
REACTION_REMOVE: "community:reaction.remove",
|
|
60257
60239
|
PIN_ADD: "community:pin.add",
|
|
@@ -60267,8 +60249,6 @@ var WS_EVENTS = {
|
|
|
60267
60249
|
CHANNEL_UPDATE: "community:channel.update",
|
|
60268
60250
|
CHANNEL_DELETE: "community:channel.delete",
|
|
60269
60251
|
CHANNEL_REORDER: "community:channel.reorder",
|
|
60270
|
-
CHANNEL_MEMBER_ADD: "community:channel.member_add",
|
|
60271
|
-
CHANNEL_MEMBER_REMOVE: "community:channel.member_remove",
|
|
60272
60252
|
CHANNEL_MEMBERSHIP_CHANGE: "community:channel.membership.change",
|
|
60273
60253
|
CATEGORY_CREATE: "community:category.create",
|
|
60274
60254
|
CATEGORY_UPDATE: "community:category.update",
|
|
@@ -60328,20 +60308,14 @@ var MESSAGE_DELIVERY_MAX_USERS = 1000;
|
|
|
60328
60308
|
var MESSAGE_DELIVERY_MAX_EVENTS_PER_USER = 5;
|
|
60329
60309
|
var target = exports_external.string().refine(isValidCommunityUserTarget);
|
|
60330
60310
|
var targetList = exports_external.array(target).max(MESSAGE_DELIVERY_MAX_USERS);
|
|
60331
|
-
var memberAddedSchema = exports_external.strictObject({
|
|
60332
|
-
userId: target,
|
|
60333
|
-
serverId: exports_external.string().min(1),
|
|
60334
|
-
channelId: exports_external.string().min(1)
|
|
60335
|
-
});
|
|
60336
60311
|
var batchShape = exports_external.strictObject({
|
|
60337
|
-
communityContract: exports_external.literal(
|
|
60312
|
+
communityContract: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
60338
60313
|
messageId: exports_external.string().min(1),
|
|
60339
60314
|
messageEvent: exports_external.unknown(),
|
|
60340
60315
|
contentUserIds: targetList,
|
|
60341
60316
|
unreadPlainUserIds: targetList,
|
|
60342
60317
|
unreadMentionUserIds: targetList,
|
|
60343
60318
|
mentionUserIds: targetList,
|
|
60344
|
-
memberAdded: memberAddedSchema.optional(),
|
|
60345
60319
|
joinedParticipantUserIds: targetList.optional(),
|
|
60346
60320
|
rosterRefreshUserId: target.optional(),
|
|
60347
60321
|
parentProjection: exports_external.unknown().optional(),
|
|
@@ -60469,12 +60443,36 @@ var communityBotCreationRequest = sqliteTable("community_bot_creation_request",
|
|
|
60469
60443
|
resolvedAt: text2("resolved_at")
|
|
60470
60444
|
}, (t) => [index("idx_bot_creation_requester").on(t.requesterId, t.createdAt), index("idx_bot_creation_owner").on(t.ownerId, t.createdAt)]);
|
|
60471
60445
|
|
|
60446
|
+
// ../shared/src/db/automation-schema.ts
|
|
60447
|
+
var exports_automation_schema = {};
|
|
60448
|
+
__export(exports_automation_schema, {
|
|
60449
|
+
automationAccessPermission: () => automationAccessPermission,
|
|
60450
|
+
automationAccessCode: () => automationAccessCode
|
|
60451
|
+
});
|
|
60452
|
+
var automationAccessCode = sqliteTable("automation_access_code", {
|
|
60453
|
+
id: text2("id").primaryKey(),
|
|
60454
|
+
ownerId: text2("owner_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
60455
|
+
name: text2("name").notNull(),
|
|
60456
|
+
secretHash: text2("secret_hash").notNull().unique(),
|
|
60457
|
+
expiresAt: text2("expires_at"),
|
|
60458
|
+
createdAt: text2("created_at").notNull()
|
|
60459
|
+
}, (table) => [index("idx_automation_code_owner").on(table.ownerId)]);
|
|
60460
|
+
var automationAccessPermission = sqliteTable("automation_access_permission", {
|
|
60461
|
+
codeId: text2("code_id").notNull().references(() => automationAccessCode.id, { onDelete: "cascade" }),
|
|
60462
|
+
permission: text2("permission").$type().notNull(),
|
|
60463
|
+
limit: integer2("request_limit").notNull(),
|
|
60464
|
+
period: text2("period", { enum: ["hour", "day"] }).notNull()
|
|
60465
|
+
}, (table) => [primaryKey({ columns: [table.codeId, table.permission] })]);
|
|
60466
|
+
|
|
60472
60467
|
// ../shared/src/db/index.ts
|
|
60473
|
-
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 };
|
|
60468
|
+
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, ...exports_automation_schema };
|
|
60474
60469
|
// ../shared/src/db/queries/native-oauth.ts
|
|
60475
60470
|
var ATTEMPT_TTL_MS = 10 * 60 * 1000;
|
|
60476
60471
|
var HANDOFF_TTL_MS = 2 * 60 * 1000;
|
|
60477
60472
|
var RETENTION_MS = 24 * 60 * 60 * 1000;
|
|
60473
|
+
|
|
60474
|
+
// ../shared/src/db/queries/automation.ts
|
|
60475
|
+
var publicFields = { id: automationAccessCode.id, name: automationAccessCode.name, createdAt: automationAccessCode.createdAt, expiresAt: automationAccessCode.expiresAt };
|
|
60478
60476
|
// ../shared/src/db/queries/task.ts
|
|
60479
60477
|
var DEFAULT_STALE_SECONDS = Number(process.env.ALOOK_STALE_DISPATCH_TIMEOUT_S) || 20;
|
|
60480
60478
|
var DEFAULT_STALE_RUNNING_SECONDS = Number(process.env.ALOOK_STALE_RUNNING_TIMEOUT_S) || 3600;
|
|
@@ -60600,6 +60598,199 @@ var channelReorderRequestSchema = exports_external.strictObject({
|
|
|
60600
60598
|
channelIds: exports_external.array(exports_external.string().min(1)).min(1).refine((ids) => new Set(ids).size === ids.length, "channelIds must be unique"),
|
|
60601
60599
|
move: exports_external.strictObject({ channelId: exports_external.string().min(1), categoryId: exports_external.string().min(1).nullable() }).optional()
|
|
60602
60600
|
}).refine((request) => !request.move || request.channelIds.includes(request.move.channelId), "moved channel must be included in channelIds");
|
|
60601
|
+
// ../shared/src/task-payload-cache.ts
|
|
60602
|
+
var TaskEmailAddressCacheSchema = exports_external.array(exports_external.strictObject({
|
|
60603
|
+
workspaceId: exports_external.string().min(1),
|
|
60604
|
+
agentId: exports_external.string().min(1),
|
|
60605
|
+
emailAddress: exports_external.string()
|
|
60606
|
+
}));
|
|
60607
|
+
var TaskMemberInstructionCacheSchema = exports_external.strictObject({
|
|
60608
|
+
workspaceId: exports_external.string().min(1),
|
|
60609
|
+
userId: exports_external.string().min(1),
|
|
60610
|
+
globalInstruction: exports_external.string()
|
|
60611
|
+
}).nullable();
|
|
60612
|
+
var TaskUserIdentityCacheSchema = CommunityResourceProfileSchema.pick({ id: true, name: true }).extend({ email: exports_external.string() }).nullable();
|
|
60613
|
+
// ../shared/src/community-forum-sidebar.ts
|
|
60614
|
+
var timestamp = exports_external.string().refine((value) => Number.isFinite(Date.parse(value)));
|
|
60615
|
+
var CommunityForumSidebarChannelSummarySchema = CommunityChannelResourceSchema.pick({
|
|
60616
|
+
id: true,
|
|
60617
|
+
name: true,
|
|
60618
|
+
serverId: true,
|
|
60619
|
+
parentChannelId: true,
|
|
60620
|
+
parentMessageId: true
|
|
60621
|
+
}).extend({
|
|
60622
|
+
serverId: CommunityChannelResourceSchema.shape.serverId.unwrap(),
|
|
60623
|
+
parentChannelId: CommunityChannelResourceSchema.shape.parentChannelId.unwrap(),
|
|
60624
|
+
parentMessageId: CommunityChannelResourceSchema.shape.parentMessageId.unwrap(),
|
|
60625
|
+
activityAt: timestamp,
|
|
60626
|
+
expiresAt: timestamp,
|
|
60627
|
+
unread: exports_external.boolean()
|
|
60628
|
+
});
|
|
60629
|
+
var CommunityForumSidebarEnvelopeSchema = exports_external.strictObject({
|
|
60630
|
+
schemaVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
60631
|
+
serverId: exports_external.string().min(1),
|
|
60632
|
+
channels: exports_external.array(CommunityForumSidebarChannelSummarySchema),
|
|
60633
|
+
canonicalChannels: exports_external.array(CommunityForumSidebarChannelSummarySchema),
|
|
60634
|
+
retainedChannel: CommunityForumSidebarChannelSummarySchema.nullable(),
|
|
60635
|
+
retainedDisposition: exports_external.enum(["eligible", "opener-archived", "genuine-negative"]).nullable(),
|
|
60636
|
+
resources: CommunityResourceBundleSchema,
|
|
60637
|
+
serverNow: timestamp
|
|
60638
|
+
}).superRefine((data, ctx) => {
|
|
60639
|
+
const selected = [...data.canonicalChannels, ...data.retainedChannel ? [data.retainedChannel] : []];
|
|
60640
|
+
if (data.resources.servers.some((row) => row.id !== data.serverId) || data.resources.channels.some((row) => row.serverId !== data.serverId) || new Set(data.channels.map((row) => row.id)).size !== data.channels.length || new Set(data.canonicalChannels.map((row) => row.id)).size !== data.canonicalChannels.length || data.canonicalChannels.some((row) => data.canonicalChannels.filter((other) => other.parentChannelId === row.parentChannelId).length > 5) || data.channels.some((row) => !selected.some((other) => other.id === row.id)) || data.retainedDisposition === "eligible" !== (data.retainedChannel !== null) || selected.some((row) => !data.resources.channels.some((channel2) => channel2.id === row.id && channel2.type === "thread" && channel2.serverId === row.serverId && channel2.parentChannelId === row.parentChannelId && channel2.parentMessageId === row.parentMessageId) || !data.resources.messages.some((message2) => message2.id === row.parentMessageId && message2.channelId === row.parentChannelId) || !data.resources.memberships.some((member2) => member2.channelId === row.id && member2.userId === data.resources.viewerId && member2.relation === "notify"))) {
|
|
60641
|
+
ctx.addIssue({ code: "custom", message: "Forum sidebar resource closure mismatch" });
|
|
60642
|
+
}
|
|
60643
|
+
});
|
|
60644
|
+
// ../shared/src/community-machine-resources.ts
|
|
60645
|
+
var CommunityMachineIdentityCacheSchema = CommunityMachineSummarySchema.pick({
|
|
60646
|
+
id: true,
|
|
60647
|
+
hostname: true,
|
|
60648
|
+
displayName: true,
|
|
60649
|
+
platform: true,
|
|
60650
|
+
arch: true,
|
|
60651
|
+
osRelease: true,
|
|
60652
|
+
daemonVersion: true,
|
|
60653
|
+
createdAt: true,
|
|
60654
|
+
updatedAt: true
|
|
60655
|
+
});
|
|
60656
|
+
var CommunityMachineListReadSchema = exports_external.strictObject({ machines: exports_external.array(CommunityMachineSummarySchema), complete: exports_external.literal(true) });
|
|
60657
|
+
// ../shared/src/community-friends.ts
|
|
60658
|
+
var CommunityAcceptedFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true, sub: true });
|
|
60659
|
+
var CommunityBlockedFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true });
|
|
60660
|
+
var CommunityPendingFriendDescriptorSchema = friendshipSchema.pick({ id: true, userId: true, needsOwnerApproval: true }).extend({
|
|
60661
|
+
kind: friendshipSchema.shape.kind.extract(["incoming", "outgoing"])
|
|
60662
|
+
});
|
|
60663
|
+
var envelope2 = { contractVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION) };
|
|
60664
|
+
var fresh = { ...envelope2, resources: CommunityResourceBundleSchema, stale: exports_external.literal(false).optional() };
|
|
60665
|
+
var stale = { ...envelope2, stale: exports_external.literal(true) };
|
|
60666
|
+
function checkProfiles(rows, resources, ctx) {
|
|
60667
|
+
if (rows.some((row) => !resources.profiles.some((profile2) => profile2.id === row.userId))) {
|
|
60668
|
+
ctx.addIssue({ code: "custom", message: "Friend profile resource missing" });
|
|
60669
|
+
}
|
|
60670
|
+
}
|
|
60671
|
+
var CommunityAcceptedFriendsReadSchema = exports_external.union([
|
|
60672
|
+
exports_external.strictObject({ ...fresh, friends: exports_external.array(CommunityAcceptedFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.friends, value.resources, ctx)),
|
|
60673
|
+
exports_external.strictObject({ ...stale, friends: exports_external.array(CommunityAcceptedFriendDescriptorSchema).length(0) })
|
|
60674
|
+
]);
|
|
60675
|
+
var CommunityBlockedFriendsReadSchema = exports_external.union([
|
|
60676
|
+
exports_external.strictObject({ ...fresh, blocked: exports_external.array(CommunityBlockedFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.blocked, value.resources, ctx)),
|
|
60677
|
+
exports_external.strictObject({ ...stale, blocked: exports_external.array(CommunityBlockedFriendDescriptorSchema).length(0) })
|
|
60678
|
+
]);
|
|
60679
|
+
var CommunityPendingFriendsReadSchema = exports_external.union([
|
|
60680
|
+
exports_external.strictObject({ ...fresh, pending: exports_external.array(CommunityPendingFriendDescriptorSchema) }).superRefine((value, ctx) => checkProfiles(value.pending, value.resources, ctx)),
|
|
60681
|
+
exports_external.strictObject({ ...stale, pending: exports_external.array(CommunityPendingFriendDescriptorSchema).length(0) })
|
|
60682
|
+
]);
|
|
60683
|
+
// ../shared/src/community-invites.ts
|
|
60684
|
+
var CommunityInviteListItemSchema = CommunityInviteCreateSchema.shape.invite.required({ maxUses: true, uses: true, expiresAt: true }).extend({
|
|
60685
|
+
uses: CommunityInviteCreateSchema.shape.invite.shape.uses.unwrap().unwrap().int().nonnegative(),
|
|
60686
|
+
creatorId: CommunityResourceProfileSchema.shape.id.nullable()
|
|
60687
|
+
});
|
|
60688
|
+
var CommunityInvitesReadSchema = exports_external.strictObject({
|
|
60689
|
+
contractVersion: exports_external.literal(BUSINESS_SCHEMA_VERSION),
|
|
60690
|
+
serverId: CommunityServerResourceSchema.shape.id,
|
|
60691
|
+
invites: exports_external.array(CommunityInviteListItemSchema),
|
|
60692
|
+
resources: CommunityResourceBundleSchema
|
|
60693
|
+
}).superRefine((value, ctx) => {
|
|
60694
|
+
if (new Set(value.invites.map((row) => row.id)).size !== value.invites.length)
|
|
60695
|
+
ctx.addIssue({ code: "custom", message: "Duplicate invite descriptor" });
|
|
60696
|
+
if (!value.resources.servers.some((row) => row.id === value.serverId) || value.resources.servers.some((row) => row.id !== value.serverId))
|
|
60697
|
+
ctx.addIssue({ code: "custom", message: "Invite server resource mismatch" });
|
|
60698
|
+
if (value.invites.some((row) => row.creatorId !== null && !value.resources.profiles.some((profile2) => profile2.id === row.creatorId)))
|
|
60699
|
+
ctx.addIssue({ code: "custom", message: "Invite creator profile resource missing" });
|
|
60700
|
+
});
|
|
60701
|
+
// ../shared/src/community-dms.ts
|
|
60702
|
+
var CommunityDmReadItemSchema = exports_external.strictObject({
|
|
60703
|
+
id: CommunityChannelResourceSchema.shape.id,
|
|
60704
|
+
userId: CommunityResourceProfileSchema.shape.id,
|
|
60705
|
+
channel: CommunityChannelResourceSchema,
|
|
60706
|
+
profile: CommunityResourceProfileSchema,
|
|
60707
|
+
memberships: exports_external.array(CommunityMemberRelationSchema).length(2),
|
|
60708
|
+
preview: exports_external.string(),
|
|
60709
|
+
activityAt: CommunityChannelResourceSchema.shape.createdAt,
|
|
60710
|
+
unread: exports_external.boolean(),
|
|
60711
|
+
lastUnreadSeq: CommunityMessageResourceSchema.shape.seq.optional()
|
|
60712
|
+
}).superRefine((dm, ctx) => {
|
|
60713
|
+
const users = new Set(dm.memberships.map((row) => row.userId));
|
|
60714
|
+
if (dm.channel.id !== dm.id || dm.channel.type !== "dm" || dm.channel.serverId !== null || dm.channel.categoryId !== null || dm.channel.parentChannelId !== null || dm.channel.parentMessageId !== null || dm.profile.id !== dm.userId || users.size !== 2 || !users.has(dm.userId) || dm.memberships.some((row) => row.channelId !== dm.id || row.relation !== "access") || dm.unread !== (dm.lastUnreadSeq !== undefined)) {
|
|
60715
|
+
ctx.addIssue({ code: "custom", message: "DM resource scope mismatch" });
|
|
60716
|
+
}
|
|
60717
|
+
});
|
|
60718
|
+
var CommunityDmsReadSchema = exports_external.strictObject({ conversations: exports_external.array(CommunityDmReadItemSchema) }).superRefine((value, ctx) => {
|
|
60719
|
+
if (new Set(value.conversations.map((row) => row.id)).size !== value.conversations.length) {
|
|
60720
|
+
ctx.addIssue({ code: "custom", message: "Duplicate DM resource identity" });
|
|
60721
|
+
}
|
|
60722
|
+
});
|
|
60723
|
+
// ../shared/src/community-profile-reads.ts
|
|
60724
|
+
var CommunitySelfProfileReadSchema = CommunityResourceProfileSchema.pick({
|
|
60725
|
+
id: true,
|
|
60726
|
+
name: true,
|
|
60727
|
+
discriminator: true,
|
|
60728
|
+
avatar: true,
|
|
60729
|
+
avatarVersion: true,
|
|
60730
|
+
aboutMe: true,
|
|
60731
|
+
bannerColor: true,
|
|
60732
|
+
statusEmoji: true,
|
|
60733
|
+
statusText: true
|
|
60734
|
+
}).required();
|
|
60735
|
+
var card = CommunitySelfProfileReadSchema.omit({ avatar: true }).extend({
|
|
60736
|
+
image: CommunityResourceProfileSchema.shape.avatar,
|
|
60737
|
+
mutualServers: CommunityResourceProfileSchema.shape.mutualServers.unwrap()
|
|
60738
|
+
});
|
|
60739
|
+
var CommunityUserCardReadSchema = exports_external.discriminatedUnion("kind", [
|
|
60740
|
+
card.extend({ kind: exports_external.literal("human") }),
|
|
60741
|
+
card.extend({ kind: exports_external.literal("bot"), ownerProfile: exports_external.strictObject({ id: CommunityResourceProfileSchema.shape.id, handle: CommunityResourceProfileSchema.shape.ownerHandle.unwrap().unwrap() }), ownedByViewer: CommunityResourceProfileSchema.shape.ownedByViewer.unwrap() })
|
|
60742
|
+
]);
|
|
60743
|
+
var CommunityServerMemberReadSchema = CommunityResourceProfileSchema.pick({ name: true, discriminator: true, avatar: true, avatarVersion: true, statusEmoji: true, statusText: true }).required().extend({
|
|
60744
|
+
id: CommunityServerMembershipResourceSchema.shape.memberId,
|
|
60745
|
+
userId: CommunityResourceProfileSchema.shape.id,
|
|
60746
|
+
role: exports_external.enum(ROLES),
|
|
60747
|
+
status: exports_external.enum(["online", "offline"]),
|
|
60748
|
+
sub: exports_external.string(),
|
|
60749
|
+
isBot: exports_external.literal(true).optional(),
|
|
60750
|
+
ownerUserId: CommunityResourceProfileSchema.shape.id.optional()
|
|
60751
|
+
}).superRefine((row, ctx) => {
|
|
60752
|
+
if (row.isBot === true !== (row.ownerUserId !== undefined))
|
|
60753
|
+
ctx.addIssue({ code: "custom", message: "Member owner metadata mismatch" });
|
|
60754
|
+
});
|
|
60755
|
+
var page = exports_external.strictObject({
|
|
60756
|
+
viewerId: CommunityResourceProfileSchema.shape.id,
|
|
60757
|
+
serverId: CommunityServerMembershipResourceSchema.shape.serverId,
|
|
60758
|
+
members: exports_external.array(CommunityServerMemberReadSchema),
|
|
60759
|
+
hasMore: exports_external.boolean(),
|
|
60760
|
+
cursor: exports_external.string().min(1).optional(),
|
|
60761
|
+
limit: exports_external.number().int().positive()
|
|
60762
|
+
});
|
|
60763
|
+
var validatePage = (value, ctx) => {
|
|
60764
|
+
if (value.hasMore && !value.cursor || new Set(value.members.map((row) => row.id)).size !== value.members.length || new Set(value.members.map((row) => row.userId)).size !== value.members.length || value.members.length > value.limit || value.members.some((row) => row.ownerUserId !== undefined && row.ownerUserId !== value.viewerId))
|
|
60765
|
+
ctx.addIssue({ code: "custom", message: "Member page scope mismatch" });
|
|
60766
|
+
};
|
|
60767
|
+
var CommunityServerMembersReadSchema = page.extend({ total: exports_external.number().int().nonnegative() }).superRefine(validatePage);
|
|
60768
|
+
var CommunityServerMemberSearchReadSchema = page.superRefine(validatePage);
|
|
60769
|
+
var CommunityUserSearchReadSchema = exports_external.strictObject({ users: exports_external.array(CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatarVersion: true }).extend({ image: CommunityResourceProfileSchema.shape.avatar })) });
|
|
60770
|
+
var CommunityReactionActorProfileSchema = CommunityResourceProfileSchema.pick({ id: true, name: true, discriminator: true, avatar: true, avatarVersion: true });
|
|
60771
|
+
var CommunityReactionDetailsReadSchema = exports_external.strictObject({
|
|
60772
|
+
messageId: CommunityResourceProfileSchema.shape.id,
|
|
60773
|
+
scope: exports_external.discriminatedUnion("kind", [
|
|
60774
|
+
exports_external.strictObject({ kind: exports_external.literal("server"), serverId: CommunityServerMembershipResourceSchema.shape.serverId, channelId: CommunityResourceProfileSchema.shape.id }),
|
|
60775
|
+
exports_external.strictObject({ kind: exports_external.literal("dm"), channelId: CommunityResourceProfileSchema.shape.id })
|
|
60776
|
+
]),
|
|
60777
|
+
actors: exports_external.array(exports_external.strictObject({ userId: CommunityResourceProfileSchema.shape.id, profile: CommunityReactionActorProfileSchema.nullable() }))
|
|
60778
|
+
}).superRefine((value, ctx) => {
|
|
60779
|
+
if (new Set(value.actors.map((row) => row.userId)).size !== value.actors.length || value.actors.some((row) => row.profile && row.profile.id !== row.userId))
|
|
60780
|
+
ctx.addIssue({ code: "custom", message: "Reaction actor identity mismatch" });
|
|
60781
|
+
});
|
|
60782
|
+
var CommunityBotProfileSummarySchema = CommunityResourceProfileSchema.pick({ id: true, name: true, avatarVersion: true }).extend({
|
|
60783
|
+
image: CommunityResourceProfileSchema.shape.avatar,
|
|
60784
|
+
discriminator: CommunityResourceProfileSchema.shape.discriminator.optional(),
|
|
60785
|
+
description: CommunityResourceProfileSchema.shape.aboutMe,
|
|
60786
|
+
presence: exports_external.enum(["online", "offline"]).optional()
|
|
60787
|
+
}).strip();
|
|
60788
|
+
var CommunityBotsProfileReadSchema = exports_external.object({
|
|
60789
|
+
bots: exports_external.array(CommunityBotProfileSummarySchema.required({ discriminator: true, description: true, presence: true }).extend({ ownerUserId: CommunityResourceProfileSchema.shape.id }))
|
|
60790
|
+
}).strip().superRefine((value, ctx) => {
|
|
60791
|
+
if (new Set(value.bots.map((row) => row.id)).size !== value.bots.length)
|
|
60792
|
+
ctx.addIssue({ code: "custom", message: "Duplicate bot catalogue identity" });
|
|
60793
|
+
});
|
|
60603
60794
|
// src/manager/memoryMaintenancePrompt.ts
|
|
60604
60795
|
var MEMORY_MAINTENANCE_PROMPT = `The daemon is preparing to reset this idle session. First, clean up your memory so the next session does not inherit incorrect or outdated notes.
|
|
60605
60796
|
|
|
@@ -60607,10 +60798,11 @@ var MEMORY_MAINTENANCE_PROMPT = `The daemon is preparing to reset this idle sess
|
|
|
60607
60798
|
2. Facts: Verify claims, especially work progress, against the latest original records. Search the context timeline and task discussions through their latest outcomes. Correct outdated or unsupported claims; keep uncertainty explicit.
|
|
60608
60799
|
3. Learn: Use .context_timeline to find channels and threads you recently participated in. Read the full history of each recent discussion, from the initial request through the work, intermediate corrections, and any final decisions. Understand the sequence of events and why the user corrected the approach before learning first principles. Proactively record the user's guidance on communication, collaboration, and how to do work. Distill it into first principles: the underlying goals, reasons, and constraints that make the guidance reusable. Preserve its scope and source links; distinguish explicit user instructions from your own inferences. Update or remove superseded notes.
|
|
60609
60800
|
4. Durability: Keep only lasting facts, preferences, and reusable lessons or procedures. Remove task status, milestones, temporary plans, and diaries; extract a reusable lesson only when useful. Keep memory.md brief with links; put procedures, scope, and reasons in experiences. Reason from first principles: distill specific events into underlying causes, constraints, and reusable principles. Omit incidental dates and details; retain context only when it changes the principle’s validity or scope.
|
|
60801
|
+
5. Follow up: After completing the memory review and any needed edits, run \`$ALOOK_CLI message mark list\` and check each unfinished item's latest discussion. In the item's original channel, thread, or DM, send the relevant person a brief reminder of the remaining work and the next action needed. Skip items that are already complete or cancelled. Do not wait for replies.
|
|
60610
60802
|
|
|
60611
|
-
Edit only your own memory files. This review is internal maintenance; perform it silently. Do not proactively send the owner, users, or channels progress updates, completion notices, or details about your memory state. Communicate task-relevant results, questions, and blockers normally. If nothing needs a user-facing response, send no message.
|
|
60803
|
+
Edit only your own memory files. This review is internal maintenance; perform it silently. Do not proactively send the owner, users, or channels progress updates, completion notices, or details about your memory state. The task reminders in step 5 are separate from memory-maintenance updates. Communicate task-relevant results, questions, and blockers normally. If nothing needs a user-facing response, send no message.
|
|
60612
60804
|
|
|
60613
|
-
If new work arrives, handle it first and defer nap. Otherwise, after completing the review
|
|
60805
|
+
If new work arrives, handle it first and defer nap. Otherwise, after completing the review, any needed edits, and the task reminders, your final action is to run the following command without --handoff. Do not finish with only a written reply. This instruction authorizes that nap:
|
|
60614
60806
|
|
|
60615
60807
|
$ALOOK_CLI nap`;
|
|
60616
60808
|
// src/runtimeConfig.ts
|
|
@@ -60635,7 +60827,7 @@ var MESSAGE_SEND_STDIN_POLICY = [
|
|
|
60635
60827
|
" - a short list or table for several exact items, mappings, or comparisons;",
|
|
60636
60828
|
" - pseudocode for logic, a shallow tree for hierarchy or ownership, Mermaid for sequence or " + "flow, and `diff` for what changed.",
|
|
60637
60829
|
"- Keep each visual next to the short text it supports. Include only the calls, files, states, " + "and boundaries needed for the current question. Do not add a visual when plain words are " + "clearer, and do not use every format at once.",
|
|
60638
|
-
"- The message body is limited to 1 KiB. Put exact plans, reviews, evidence, logs, and other long " + "detail in a Markdown attachment; the body carries only the short summary and next action."
|
|
60830
|
+
"- The message body is limited to 1 KiB. Put exact plans, reviews, evidence, logs, and other long " + "detail in a Markdown attachment; put HTML pages for inline display (charts, diagrams, or interface " + "mockups) in an HTML attachment and reference them in the body using the required inline HTML format; " + "the body carries only the short summary and next action."
|
|
60639
60831
|
].join(`
|
|
60640
60832
|
`);
|
|
60641
60833
|
function identitySection(config2) {
|
|
@@ -60710,7 +60902,7 @@ function cliCommandsSection() {
|
|
|
60710
60902
|
"",
|
|
60711
60903
|
`1. \`${CLI} platform machine --list\` — list your owner's machines.`,
|
|
60712
60904
|
`2. \`${CLI} platform machine --backends --id <machine-id>\` — read the selected online machine's backends.`,
|
|
60713
|
-
`3. \`${CLI} platform machine --models --id <machine-id> --backend <backend-id> [--model <full-model-id>] [--refresh]\` — read
|
|
60905
|
+
`3. \`${CLI} platform machine --models --id <machine-id> --backend <backend-id> [--model <full-model-id>] [--refresh]\` — read models and model-specific effort options using a five-minute server cache. A cache miss or expiry fetches fresh models and waits for the result; \`--refresh\` bypasses the cache. Failures do not return an old list. Do not poll.`,
|
|
60714
60906
|
`4. \`${CLI} platform bot --list\` — list your owner's bots.`,
|
|
60715
60907
|
`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.`,
|
|
60716
60908
|
"",
|
|
@@ -60762,6 +60954,7 @@ function messagingSection() {
|
|
|
60762
60954
|
"",
|
|
60763
60955
|
`- Send body: use \`${CLI} message send --target <ref> --remind-after T --stdin\` with the ` + "quoted-heredoc form under *Message formatting*.",
|
|
60764
60956
|
`- Long detail: upload it with \`${CLI} message attachment upload --file <path>.md\`; ` + "add the returned id as `--attachment <id>` on the short stdin send.",
|
|
60957
|
+
`- Inline HTML: upload a self-contained UTF-8 \`<path>.html\` file with \`${CLI} message attachment upload --file <path>.html\`. ` + "Inline CSS and JavaScript in the file; do not depend on local paths on the sender's computer. " + "Include the returned ID with `--attachment <id>` when sending. Put `[alook-html-preview](attachment-id)` " + "in its own paragraph at the intended position in the message, with a blank line before and after; " + "do not put the marker in a code block. " + "Use the Alook theme CSS variables injected by the host on `:root`: " + "`--background`, `--foreground`, `--card`, `--card-foreground`, `--popover`, `--popover-foreground`, " + "`--primary`, `--primary-foreground`, `--secondary`, `--secondary-foreground`, `--muted`, `--muted-foreground`, " + "`--accent`, `--accent-foreground`, `--border`, `--input`, `--ring`, `--destructive`, `--warning`, " + "`--radius`, `--font-sans`, and `--font-mono`. Use their values directly with `var(...)`; " + "do not hardcode page theme colors to one light or dark scheme. " + "Do not add background colors to `html`, `body`, or the outermost element. Do not add an outer card, " + "border, banner title, or side padding. This rule takes priority over other page-background authoring rules. " + "An internal box that needs a background uses a theme variable, 16px padding, and `var(--radius)` corners. " + "Adapt to the available width and different screen sizes; do not hardcode a desktop page width. " + "Give charts fixed pixel heights. Let content set the page height. Do not use `vh`, `dvh`, `svh`, or `lvh`, " + "and do not set `height:100%` on `html` or `body`. The current preview validator rejects those viewport units; " + "percentage heights on the document roots can cause a measurement loop. " + "Alook measures the frame height automatically in CSS pixels, currently 80–2000px inline. " + "Sending a message requires no height parameter. Keep the original HTML within the current 2 MiB preview limit.",
|
|
60765
60958
|
"- Reuse files: to forward an attachment or send the same file again, pass its existing ID with `--attachment <id>`. " + "Do not download and upload it again. Reuse works across channels, DMs, and threads while you can still read the file. " + "Upload only a new or changed file.",
|
|
60766
60959
|
`- Cite a specific message: add \`--reply "#37"\` — \`--reply\` takes the \`#N\` seq ` + "(within `--target`) of the message you're answering.",
|
|
60767
60960
|
"",
|
|
@@ -63142,23 +63335,23 @@ class AgentRouter {
|
|
|
63142
63335
|
const reply = this.opts.channel.reportRuntimeModels;
|
|
63143
63336
|
if (!reply)
|
|
63144
63337
|
return;
|
|
63145
|
-
const
|
|
63338
|
+
const identity2 = { type: "runtime_models", requestId: cmd.requestId, runtimeId: cmd.runtimeId };
|
|
63146
63339
|
try {
|
|
63147
63340
|
const current = this.runtimes.get(cmd.runtimeId);
|
|
63148
63341
|
if (!current)
|
|
63149
63342
|
throw new UnknownRuntimeError(cmd.runtimeId, [...this.runtimes.keys()]);
|
|
63150
63343
|
const probe = await this.discoverRuntimeModels(cmd.runtimeId);
|
|
63151
63344
|
if (!probe) {
|
|
63152
|
-
reply.call(this.opts.channel, { ...
|
|
63345
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: "model_discovery_timeout", message: "Model discovery timed out; retry the request" } });
|
|
63153
63346
|
return;
|
|
63154
63347
|
}
|
|
63155
63348
|
if (probe.status !== "healthy") {
|
|
63156
|
-
reply.call(this.opts.channel, { ...
|
|
63349
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: probe.error.code, message: probe.error.message } });
|
|
63157
63350
|
return;
|
|
63158
63351
|
}
|
|
63159
|
-
reply.call(this.opts.channel, { ...
|
|
63352
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "complete", runtimeReport: [...this.runtimes.values()] } });
|
|
63160
63353
|
} catch {
|
|
63161
|
-
reply.call(this.opts.channel, { ...
|
|
63354
|
+
reply.call(this.opts.channel, { ...identity2, result: { status: "error", code: "model_discovery_failed", message: "Could not discover models for this runtime" } });
|
|
63162
63355
|
}
|
|
63163
63356
|
return;
|
|
63164
63357
|
}
|
|
@@ -63972,7 +64165,8 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
63972
64165
|
}
|
|
63973
64166
|
};
|
|
63974
64167
|
const server = http.createServer(async (req, res) => {
|
|
63975
|
-
const
|
|
64168
|
+
const requestUrl = new URL2(req.url ?? "/", "http://placeholder");
|
|
64169
|
+
const pathname = requestUrl.pathname;
|
|
63976
64170
|
if (pathname === LOCAL_PII_PATH && (req.method === "GET" || req.method === "POST")) {
|
|
63977
64171
|
const localVerdict = broker.check(req.headers["authorization"], req.method === "GET" ? "read" : "send");
|
|
63978
64172
|
if (!localVerdict.ok) {
|
|
@@ -64205,7 +64399,8 @@ async function startCredentialProxy(broker, options = {}) {
|
|
|
64205
64399
|
res.writeHead(502, { "content-type": "application/json" });
|
|
64206
64400
|
res.end(JSON.stringify({ error: `upstream error: ${err.message}`, code: "upstream_error" }));
|
|
64207
64401
|
});
|
|
64208
|
-
const
|
|
64402
|
+
const waitingForModels = req.method === "POST" && /^\/api\/community\/machines\/[^/]+\/discover-models$/.test(pathname) && requestUrl.searchParams.get("wait") === "1";
|
|
64403
|
+
const upstreamTimeoutMs = options.upstreamTimeoutMs ?? (waitingForModels ? 55000 : DEFAULT_UPSTREAM_TIMEOUT_MS);
|
|
64209
64404
|
upstreamReq.setTimeout(upstreamTimeoutMs, () => {
|
|
64210
64405
|
upstreamReq.destroy();
|
|
64211
64406
|
upstreamRes?.destroy();
|
|
@@ -68314,6 +68509,11 @@ function readHostGitIdentity() {
|
|
|
68314
68509
|
return value;
|
|
68315
68510
|
}
|
|
68316
68511
|
|
|
68512
|
+
// src/npmEnvironment.ts
|
|
68513
|
+
function withoutNpmExecPackage(env) {
|
|
68514
|
+
return Object.fromEntries(Object.entries(env).filter(([key]) => key.toLowerCase() !== "npm_config_package"));
|
|
68515
|
+
}
|
|
68516
|
+
|
|
68317
68517
|
// src/manager/agentDriverHost.ts
|
|
68318
68518
|
function runtimeEnvironment(ctx) {
|
|
68319
68519
|
const runtime = ctx.config.runtimeContext;
|
|
@@ -68372,7 +68572,7 @@ function createDaemonAgentDriverHost(ctx, onRawLine) {
|
|
|
68372
68572
|
const resource = {
|
|
68373
68573
|
executablePath: ctx.agentCliPath,
|
|
68374
68574
|
environmentLayers: {
|
|
68375
|
-
base:
|
|
68575
|
+
base: withoutNpmExecPackage(process.env),
|
|
68376
68576
|
hostStatic: {},
|
|
68377
68577
|
identityProtected: buildGitIdentityEnv({
|
|
68378
68578
|
agentName: ctx.config.agentName,
|
|
@@ -68414,7 +68614,7 @@ function createDaemonAgentDriverHost(ctx, onRawLine) {
|
|
|
68414
68614
|
}
|
|
68415
68615
|
|
|
68416
68616
|
// src/daemon/daemonSelfSleep.ts
|
|
68417
|
-
var DAEMON_SELF_SLEEP_TIMEOUT_MS =
|
|
68617
|
+
var DAEMON_SELF_SLEEP_TIMEOUT_MS = 7 * 24 * 60 * 60 * 1000;
|
|
68418
68618
|
var systemClock = {
|
|
68419
68619
|
setTimer: (callback, delayMs) => setTimeout(callback, delayMs),
|
|
68420
68620
|
clearTimer: (timer) => clearTimeout(timer)
|
|
@@ -68555,13 +68755,13 @@ class DailyTokenUsageStore {
|
|
|
68555
68755
|
dayKeyInTimeZone(0, timeZone);
|
|
68556
68756
|
return timeZone;
|
|
68557
68757
|
}
|
|
68558
|
-
record(botId, delta,
|
|
68758
|
+
record(botId, delta, identity2) {
|
|
68559
68759
|
return this.enqueue(async () => {
|
|
68560
|
-
if (
|
|
68561
|
-
if (!
|
|
68760
|
+
if (identity2) {
|
|
68761
|
+
if (!identity2.source || identity2.source.length > 256 || !Number.isSafeInteger(identity2.index) || identity2.index < 0 || !Number.isFinite(Date.parse(identity2.occurredAt)))
|
|
68562
68762
|
throw new Error("Invalid token usage identity");
|
|
68563
|
-
if (!this.pending.some((sample) => sample.botId === botId && sample.identity.source ===
|
|
68564
|
-
this.pending.push({ botId, delta, identity });
|
|
68763
|
+
if (!this.pending.some((sample) => sample.botId === botId && sample.identity.source === identity2.source && sample.identity.index === identity2.index))
|
|
68764
|
+
this.pending.push({ botId, delta, identity: identity2 });
|
|
68565
68765
|
await this.load();
|
|
68566
68766
|
await this.flushPending();
|
|
68567
68767
|
} else {
|
|
@@ -68594,13 +68794,13 @@ class DailyTokenUsageStore {
|
|
|
68594
68794
|
throw error62;
|
|
68595
68795
|
}
|
|
68596
68796
|
}
|
|
68597
|
-
apply(botId, delta,
|
|
68797
|
+
apply(botId, delta, identity2) {
|
|
68598
68798
|
const at = this.now();
|
|
68599
68799
|
const timeZone = this.timeZone;
|
|
68600
|
-
const day = dayKeyInTimeZone(
|
|
68601
|
-
if (
|
|
68800
|
+
const day = dayKeyInTimeZone(identity2 ? new Date(identity2.occurredAt) : at, timeZone);
|
|
68801
|
+
if (identity2 && day < oldestRetainedDay(at, timeZone))
|
|
68602
68802
|
return;
|
|
68603
|
-
if (
|
|
68803
|
+
if (identity2 && this.data.sources?.[botId]?.[identity2.source]?.ranges.some(([start, end]) => identity2.index >= start && identity2.index <= end))
|
|
68604
68804
|
return;
|
|
68605
68805
|
this.prune(at, timeZone);
|
|
68606
68806
|
const snapshots = this.data.bots[botId] ?? [];
|
|
@@ -68615,11 +68815,11 @@ class DailyTokenUsageStore {
|
|
|
68615
68815
|
snapshots.push(next);
|
|
68616
68816
|
snapshots.sort((a, b) => a.day.localeCompare(b.day));
|
|
68617
68817
|
this.data.bots[botId] = snapshots;
|
|
68618
|
-
if (
|
|
68818
|
+
if (identity2) {
|
|
68619
68819
|
this.data.sources ??= {};
|
|
68620
68820
|
this.data.sources[botId] ??= {};
|
|
68621
|
-
const saved = this.data.sources[botId][
|
|
68622
|
-
const ranges = [...saved?.ranges ?? [], [
|
|
68821
|
+
const saved = this.data.sources[botId][identity2.source];
|
|
68822
|
+
const ranges = [...saved?.ranges ?? [], [identity2.index, identity2.index]].sort((a, b) => a[0] - b[0]);
|
|
68623
68823
|
const merged = [];
|
|
68624
68824
|
for (const range of ranges) {
|
|
68625
68825
|
const last = merged.at(-1);
|
|
@@ -68628,7 +68828,7 @@ class DailyTokenUsageStore {
|
|
|
68628
68828
|
else
|
|
68629
68829
|
merged.push([range[0], range[1]]);
|
|
68630
68830
|
}
|
|
68631
|
-
this.data.sources[botId][
|
|
68831
|
+
this.data.sources[botId][identity2.source] = { ranges: merged, day: saved && saved.day > day ? saved.day : day };
|
|
68632
68832
|
}
|
|
68633
68833
|
}
|
|
68634
68834
|
snapshots(botId) {
|
|
@@ -69423,10 +69623,10 @@ async function createDaemon(opts) {
|
|
|
69423
69623
|
tokenUsageAvailability.set(agentId, { backendId, status });
|
|
69424
69624
|
reportTelemetryForIdleAgent(agentId);
|
|
69425
69625
|
},
|
|
69426
|
-
onTokenUsage: ({ agentId, usage, identity }) => {
|
|
69626
|
+
onTokenUsage: ({ agentId, usage, identity: identity2 }) => {
|
|
69427
69627
|
if (usageSealed)
|
|
69428
69628
|
return;
|
|
69429
|
-
trackTelemetry(dailyTokenUsage2.record(agentId, usage,
|
|
69629
|
+
trackTelemetry(dailyTokenUsage2.record(agentId, usage, identity2).then(() => reportTelemetryForIdleAgent(agentId)).catch(() => {
|
|
69430
69630
|
log2.warn("daily token usage persistence failed", { agentId });
|
|
69431
69631
|
}));
|
|
69432
69632
|
},
|