@alook/cli 0.0.159 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +928 -269
- package/dist/session-runner.js +815 -153
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -40,6 +40,50 @@ function fillPool(bytes) {
|
|
|
40
40
|
}
|
|
41
41
|
poolOffset += bytes;
|
|
42
42
|
}
|
|
43
|
+
function random(bytes) {
|
|
44
|
+
fillPool(bytes |= 0);
|
|
45
|
+
return pool.subarray(poolOffset - bytes, poolOffset);
|
|
46
|
+
}
|
|
47
|
+
function customRandom(alphabet, defaultSize, getRandom) {
|
|
48
|
+
let safeByteCutoff = 256 - 256 % alphabet.length;
|
|
49
|
+
if (safeByteCutoff === 256) {
|
|
50
|
+
let mask = alphabet.length - 1;
|
|
51
|
+
return (size = defaultSize) => {
|
|
52
|
+
if (!size)
|
|
53
|
+
return "";
|
|
54
|
+
let id = "";
|
|
55
|
+
while (true) {
|
|
56
|
+
let bytes = getRandom(size);
|
|
57
|
+
let i = size;
|
|
58
|
+
while (i--) {
|
|
59
|
+
id += alphabet[bytes[i] & mask];
|
|
60
|
+
if (id.length >= size)
|
|
61
|
+
return id;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
let step = Math.ceil(1.6 * 256 * defaultSize / safeByteCutoff);
|
|
67
|
+
return (size = defaultSize) => {
|
|
68
|
+
if (!size)
|
|
69
|
+
return "";
|
|
70
|
+
let id = "";
|
|
71
|
+
while (true) {
|
|
72
|
+
let bytes = getRandom(step);
|
|
73
|
+
let i = step;
|
|
74
|
+
while (i--) {
|
|
75
|
+
if (bytes[i] < safeByteCutoff) {
|
|
76
|
+
id += alphabet[bytes[i] % alphabet.length];
|
|
77
|
+
if (id.length >= size)
|
|
78
|
+
return id;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function customAlphabet(alphabet, size = 21) {
|
|
85
|
+
return customRandom(alphabet, size, random);
|
|
86
|
+
}
|
|
43
87
|
function nanoid3(size = 21) {
|
|
44
88
|
fillPool(size |= 0);
|
|
45
89
|
let id = "";
|
|
@@ -11694,7 +11738,7 @@ function finalize(ctx, schema) {
|
|
|
11694
11738
|
result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
11695
11739
|
} else if (ctx.target === "draft-04") {
|
|
11696
11740
|
result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
11697
|
-
} else if (ctx.target === "openapi-3.0") {}
|
|
11741
|
+
} else if (ctx.target === "openapi-3.0") {} else {}
|
|
11698
11742
|
if (ctx.external?.uri) {
|
|
11699
11743
|
const id = ctx.external.registry.get(schema)?.id;
|
|
11700
11744
|
if (!id)
|
|
@@ -11938,7 +11982,7 @@ var literalProcessor = (schema, ctx, json, _params) => {
|
|
|
11938
11982
|
if (val === undefined) {
|
|
11939
11983
|
if (ctx.unrepresentable === "throw") {
|
|
11940
11984
|
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
11941
|
-
}
|
|
11985
|
+
} else {}
|
|
11942
11986
|
} else if (typeof val === "bigint") {
|
|
11943
11987
|
if (ctx.unrepresentable === "throw") {
|
|
11944
11988
|
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
@@ -14506,6 +14550,13 @@ function date4(params) {
|
|
|
14506
14550
|
|
|
14507
14551
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
14508
14552
|
config(en_default());
|
|
14553
|
+
// ../shared/src/utils/slug.ts
|
|
14554
|
+
init_nanoid();
|
|
14555
|
+
var slugId = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz");
|
|
14556
|
+
function sanitizeSlug(input) {
|
|
14557
|
+
return input.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60).replace(/-+$/g, "");
|
|
14558
|
+
}
|
|
14559
|
+
|
|
14509
14560
|
// ../shared/src/lib/community-name.ts
|
|
14510
14561
|
var FORBIDDEN_NAME_CHARS = /[#@\x00-\x1f\x7f-\x9f]/;
|
|
14511
14562
|
function validateCommunityName(name) {
|
|
@@ -14933,11 +14984,11 @@ var UpdateMemberRequestSchema = exports_external.object({
|
|
|
14933
14984
|
});
|
|
14934
14985
|
var CreateWorkspaceRequestSchema = exports_external.object({
|
|
14935
14986
|
name: exports_external.string().min(1, "name is required"),
|
|
14936
|
-
slug: exports_external.string().optional().default("")
|
|
14987
|
+
slug: exports_external.string().optional().default("").transform(sanitizeSlug)
|
|
14937
14988
|
});
|
|
14938
14989
|
var UpdateWorkspaceRequestSchema = exports_external.object({
|
|
14939
14990
|
name: exports_external.string().min(1, "name is required").max(100).trim().optional(),
|
|
14940
|
-
slug: exports_external.string().min(1, "slug is required").
|
|
14991
|
+
slug: exports_external.string().min(1, "slug is required").trim().toLowerCase().transform(sanitizeSlug).optional()
|
|
14941
14992
|
});
|
|
14942
14993
|
var DeleteWorkspaceRequestSchema = exports_external.object({
|
|
14943
14994
|
confirm_name: exports_external.string().min(1, "confirm_name is required")
|
|
@@ -15073,6 +15124,7 @@ var SessionErrorFrameSchema = exports_external.object({
|
|
|
15073
15124
|
type: exports_external.literal("session.error"),
|
|
15074
15125
|
code: exports_external.enum(["runtime_not_available"]),
|
|
15075
15126
|
agentId: exports_external.string().optional(),
|
|
15127
|
+
launchId: exports_external.string().optional(),
|
|
15076
15128
|
payload: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
15077
15129
|
});
|
|
15078
15130
|
var AgentActivityMessageSchema = exports_external.object({
|
|
@@ -15083,12 +15135,25 @@ var AgentActivityMessageSchema = exports_external.object({
|
|
|
15083
15135
|
var AgentTypingMessageSchema = exports_external.object({
|
|
15084
15136
|
type: exports_external.literal("agent_typing"),
|
|
15085
15137
|
agentId: exports_external.string(),
|
|
15086
|
-
|
|
15138
|
+
channelId: exports_external.string().min(1)
|
|
15087
15139
|
});
|
|
15088
15140
|
var AgentTypingStopMessageSchema = exports_external.object({
|
|
15089
15141
|
type: exports_external.literal("agent_typing_stop"),
|
|
15090
15142
|
agentId: exports_external.string(),
|
|
15091
|
-
|
|
15143
|
+
channelId: exports_external.string().min(1)
|
|
15144
|
+
});
|
|
15145
|
+
var AgentSessionMessageSchema = exports_external.object({
|
|
15146
|
+
type: exports_external.literal("agent_session"),
|
|
15147
|
+
agentId: exports_external.string().min(1),
|
|
15148
|
+
sessionId: exports_external.string().min(1),
|
|
15149
|
+
launchId: exports_external.string().min(1)
|
|
15150
|
+
});
|
|
15151
|
+
var AgentWakeAckMessageSchema = exports_external.object({
|
|
15152
|
+
type: exports_external.literal("agent_wake_ack"),
|
|
15153
|
+
agentId: exports_external.string().min(1),
|
|
15154
|
+
launchId: exports_external.string().min(1),
|
|
15155
|
+
status: exports_external.enum(["ok", "error"]),
|
|
15156
|
+
error: exports_external.object({ code: exports_external.string().optional(), message: exports_external.string().optional() }).optional()
|
|
15092
15157
|
});
|
|
15093
15158
|
var CommunityPairTokenResponseSchema = exports_external.object({
|
|
15094
15159
|
tokenId: exports_external.string(),
|
|
@@ -15125,13 +15190,16 @@ var CommunityBotCreateRequestSchema = exports_external.object({
|
|
|
15125
15190
|
description: exports_external.string().max(COMMUNITY_BOT_DESCRIPTION_MAX).optional(),
|
|
15126
15191
|
machineId: exports_external.string().min(1),
|
|
15127
15192
|
runtime: exports_external.string().min(1),
|
|
15128
|
-
image: BotImageUrlSchema.optional()
|
|
15193
|
+
image: BotImageUrlSchema.optional(),
|
|
15194
|
+
model: exports_external.string().trim().min(1).max(100).nullable().optional()
|
|
15129
15195
|
});
|
|
15130
15196
|
var CommunityBotPatchRequestSchema = exports_external.object({
|
|
15131
15197
|
name: exports_external.string().trim().min(COMMUNITY_BOT_NAME_MIN).max(COMMUNITY_BOT_NAME_MAX).refine(isMentionSafeName, { message: MENTION_SAFE_NAME_MSG }).optional(),
|
|
15132
15198
|
description: exports_external.string().max(COMMUNITY_BOT_DESCRIPTION_MAX).optional(),
|
|
15133
|
-
image: BotImageUrlSchema.nullable().optional()
|
|
15134
|
-
|
|
15199
|
+
image: BotImageUrlSchema.nullable().optional(),
|
|
15200
|
+
model: exports_external.string().trim().min(1).max(100).nullable().optional(),
|
|
15201
|
+
runtime: exports_external.string().trim().min(1).max(COMMUNITY_RUNTIME_ID_MAX).optional()
|
|
15202
|
+
}).refine((v) => v.name !== undefined || v.description !== undefined || v.image !== undefined || v.runtime !== undefined || ("model" in v), {
|
|
15135
15203
|
message: "at least one field must be provided"
|
|
15136
15204
|
});
|
|
15137
15205
|
var CommunityBotAddToServerRequestSchema = exports_external.object({
|
|
@@ -15148,7 +15216,9 @@ var CommunityAgentSendRequestSchema = exports_external.object({
|
|
|
15148
15216
|
channel: exports_external.string().min(1),
|
|
15149
15217
|
content: CommunityAgentMessageContentSchema,
|
|
15150
15218
|
attachments: exports_external.array(exports_external.string().min(1)).max(MAX_ATTACHMENTS_PER_MESSAGE).default([]),
|
|
15151
|
-
seenUpToSeq: CommunityAgentSeqSchema.optional()
|
|
15219
|
+
seenUpToSeq: CommunityAgentSeqSchema.optional(),
|
|
15220
|
+
replyToSeq: CommunityAgentPositiveSeqSchema.optional(),
|
|
15221
|
+
nonce: exports_external.string().min(1).max(128).optional()
|
|
15152
15222
|
}).refine((d) => d.content.text.trim().length > 0 || d.attachments.length > 0, { message: "message must have text or attachments" });
|
|
15153
15223
|
var CommunityAgentAttachmentUploadResponseSchema = exports_external.object({
|
|
15154
15224
|
id: exports_external.string(),
|
|
@@ -15179,8 +15249,17 @@ var CommunityAgentResolveRequestSchema = exports_external.object({
|
|
|
15179
15249
|
var CommunityAgentListChannelsRequestSchema = exports_external.object({
|
|
15180
15250
|
server: exports_external.string().min(1).optional()
|
|
15181
15251
|
});
|
|
15252
|
+
var CommunityAgentCreatePostRequestSchema = exports_external.object({
|
|
15253
|
+
forum: exports_external.string().min(1),
|
|
15254
|
+
title: exports_external.string().min(1),
|
|
15255
|
+
content: CommunityAgentMessageContentSchema,
|
|
15256
|
+
attachments: exports_external.array(exports_external.string().min(1)).max(MAX_ATTACHMENTS_PER_MESSAGE).default([]),
|
|
15257
|
+
nonce: exports_external.string().min(1).max(128).optional()
|
|
15258
|
+
}).refine((d) => d.content.text.trim().length > 0 || d.attachments.length > 0, { message: "post must have text or attachments" });
|
|
15182
15259
|
var CommunityAgentListMembersRequestSchema = exports_external.object({
|
|
15183
|
-
server: exports_external.string().min(1)
|
|
15260
|
+
server: exports_external.string().min(1),
|
|
15261
|
+
limit: exports_external.number().int().positive().optional(),
|
|
15262
|
+
cursor: exports_external.string().min(1).optional()
|
|
15184
15263
|
});
|
|
15185
15264
|
var CommunityAgentChannelMemberRequestSchema = exports_external.object({
|
|
15186
15265
|
channel: exports_external.string().min(1),
|
|
@@ -15189,11 +15268,18 @@ var CommunityAgentChannelMemberRequestSchema = exports_external.object({
|
|
|
15189
15268
|
var CommunityAgentJoinServerRequestSchema = exports_external.object({
|
|
15190
15269
|
invite: exports_external.string().min(1)
|
|
15191
15270
|
});
|
|
15271
|
+
var CommunityAgentNapRequestSchema = exports_external.object({
|
|
15272
|
+
handoff: exports_external.string().trim().min(1)
|
|
15273
|
+
});
|
|
15192
15274
|
var CommunityAgentReactAddRequestSchema = exports_external.object({
|
|
15193
15275
|
channel: exports_external.string().min(1),
|
|
15194
15276
|
seq: CommunityAgentPositiveSeqSchema,
|
|
15195
15277
|
emoji: exports_external.string().min(1)
|
|
15196
15278
|
});
|
|
15279
|
+
var CommunityAgentFriendRequestSchema = exports_external.object({
|
|
15280
|
+
username: exports_external.string().min(1)
|
|
15281
|
+
});
|
|
15282
|
+
var CommunityAgentListFriendsSchema = exports_external.object({});
|
|
15197
15283
|
var AuditLogCliInvocationPayloadSchema = exports_external.object({
|
|
15198
15284
|
subcommand: exports_external.string().min(1)
|
|
15199
15285
|
});
|
|
@@ -15214,20 +15300,47 @@ var AuditLogWakeTriggerPayloadSchema = exports_external.object({
|
|
|
15214
15300
|
senderHandle: exports_external.string().min(1),
|
|
15215
15301
|
reason: exports_external.enum(["unread", "mention"])
|
|
15216
15302
|
});
|
|
15217
|
-
var AuditLogSessionResetPayloadSchema = exports_external.object({
|
|
15303
|
+
var AuditLogSessionResetPayloadSchema = exports_external.object({
|
|
15304
|
+
trigger: exports_external.enum(["single", "reset_all"])
|
|
15305
|
+
});
|
|
15306
|
+
var AuditLogNapPayloadSchema = exports_external.object({
|
|
15307
|
+
trigger: exports_external.literal("nap")
|
|
15308
|
+
});
|
|
15309
|
+
var AuditLogModelChangedPayloadSchema = exports_external.object({
|
|
15310
|
+
from: exports_external.string().nullable(),
|
|
15311
|
+
to: exports_external.string().nullable()
|
|
15312
|
+
});
|
|
15313
|
+
var AuditLogProviderChangedPayloadSchema = exports_external.object({
|
|
15314
|
+
from: exports_external.string().min(1),
|
|
15315
|
+
to: exports_external.string().min(1)
|
|
15316
|
+
});
|
|
15317
|
+
var AuditLogErrorPayloadSchema = exports_external.object({
|
|
15318
|
+
scope: exports_external.enum(["spawn", "runtime", "exit", "handshake_timeout", "model_switch", "reset"]),
|
|
15319
|
+
code: exports_external.string().min(1).max(120),
|
|
15320
|
+
message: exports_external.string().max(2048),
|
|
15321
|
+
model: exports_external.string().nullable()
|
|
15322
|
+
});
|
|
15218
15323
|
var BotAuditEventSchema = exports_external.discriminatedUnion("kind", [
|
|
15219
15324
|
exports_external.object({ kind: exports_external.literal("cli_invocation"), payload: AuditLogCliInvocationPayloadSchema }),
|
|
15220
15325
|
exports_external.object({ kind: exports_external.literal("tool_call"), payload: AuditLogToolCallPayloadSchema }),
|
|
15221
15326
|
exports_external.object({ kind: exports_external.literal("thinking"), payload: AuditLogThinkingPayloadSchema }),
|
|
15222
15327
|
exports_external.object({ kind: exports_external.literal("wake_trigger"), payload: AuditLogWakeTriggerPayloadSchema }),
|
|
15223
|
-
exports_external.object({ kind: exports_external.literal("session_reset"), payload: AuditLogSessionResetPayloadSchema })
|
|
15328
|
+
exports_external.object({ kind: exports_external.literal("session_reset"), payload: AuditLogSessionResetPayloadSchema }),
|
|
15329
|
+
exports_external.object({ kind: exports_external.literal("nap"), payload: AuditLogNapPayloadSchema }),
|
|
15330
|
+
exports_external.object({ kind: exports_external.literal("model_changed"), payload: AuditLogModelChangedPayloadSchema }),
|
|
15331
|
+
exports_external.object({ kind: exports_external.literal("provider_changed"), payload: AuditLogProviderChangedPayloadSchema }),
|
|
15332
|
+
exports_external.object({ kind: exports_external.literal("error"), payload: AuditLogErrorPayloadSchema })
|
|
15224
15333
|
]);
|
|
15225
15334
|
var BotAuditEventKindSchema = exports_external.enum([
|
|
15226
15335
|
"cli_invocation",
|
|
15227
15336
|
"tool_call",
|
|
15228
15337
|
"thinking",
|
|
15229
15338
|
"wake_trigger",
|
|
15230
|
-
"session_reset"
|
|
15339
|
+
"session_reset",
|
|
15340
|
+
"nap",
|
|
15341
|
+
"model_changed",
|
|
15342
|
+
"provider_changed",
|
|
15343
|
+
"error"
|
|
15231
15344
|
]);
|
|
15232
15345
|
var HostBotAuditEventFrameSchema = exports_external.object({
|
|
15233
15346
|
type: exports_external.literal("bot_audit_event"),
|
|
@@ -15236,7 +15349,71 @@ var HostBotAuditEventFrameSchema = exports_external.object({
|
|
|
15236
15349
|
launchId: exports_external.string().nullable().optional(),
|
|
15237
15350
|
event: BotAuditEventSchema
|
|
15238
15351
|
});
|
|
15239
|
-
//
|
|
15352
|
+
// ../shared/src/community-cli-contract.ts
|
|
15353
|
+
var HostCommandSchema = exports_external.discriminatedUnion("type", [
|
|
15354
|
+
exports_external.object({
|
|
15355
|
+
type: exports_external.literal("agent:wake"),
|
|
15356
|
+
agentId: exports_external.string().min(1),
|
|
15357
|
+
config: exports_external.unknown(),
|
|
15358
|
+
sessionId: exports_external.string().optional(),
|
|
15359
|
+
launchId: exports_external.string().min(1),
|
|
15360
|
+
unreadNotice: exports_external.unknown()
|
|
15361
|
+
}),
|
|
15362
|
+
exports_external.object({
|
|
15363
|
+
type: exports_external.literal("agent:stop"),
|
|
15364
|
+
agentId: exports_external.string().min(1)
|
|
15365
|
+
}),
|
|
15366
|
+
exports_external.object({
|
|
15367
|
+
type: exports_external.literal("agent:reset"),
|
|
15368
|
+
agentId: exports_external.string().min(1),
|
|
15369
|
+
config: exports_external.unknown(),
|
|
15370
|
+
launchId: exports_external.string().min(1)
|
|
15371
|
+
}),
|
|
15372
|
+
exports_external.object({
|
|
15373
|
+
type: exports_external.literal("agent:nap"),
|
|
15374
|
+
agentId: exports_external.string().min(1),
|
|
15375
|
+
config: exports_external.unknown(),
|
|
15376
|
+
launchId: exports_external.string().min(1),
|
|
15377
|
+
handoff: exports_external.string().min(1)
|
|
15378
|
+
}),
|
|
15379
|
+
exports_external.object({
|
|
15380
|
+
type: exports_external.literal("agent:model_switch"),
|
|
15381
|
+
agentId: exports_external.string().min(1),
|
|
15382
|
+
config: exports_external.unknown(),
|
|
15383
|
+
launchId: exports_external.string().min(1)
|
|
15384
|
+
}),
|
|
15385
|
+
exports_external.object({
|
|
15386
|
+
type: exports_external.literal("machine:reset_all"),
|
|
15387
|
+
resets: exports_external.array(exports_external.object({
|
|
15388
|
+
agentId: exports_external.string().min(1),
|
|
15389
|
+
config: exports_external.unknown(),
|
|
15390
|
+
launchId: exports_external.string().min(1)
|
|
15391
|
+
}))
|
|
15392
|
+
}),
|
|
15393
|
+
exports_external.object({
|
|
15394
|
+
type: exports_external.literal("bot:added"),
|
|
15395
|
+
botId: exports_external.string().min(1),
|
|
15396
|
+
name: exports_external.string().optional(),
|
|
15397
|
+
discriminator: exports_external.string().optional(),
|
|
15398
|
+
description: exports_external.string().optional(),
|
|
15399
|
+
ownerName: exports_external.string().optional(),
|
|
15400
|
+
ownerDiscriminator: exports_external.string().optional()
|
|
15401
|
+
}),
|
|
15402
|
+
exports_external.object({
|
|
15403
|
+
type: exports_external.literal("bot:updated"),
|
|
15404
|
+
botId: exports_external.string().min(1),
|
|
15405
|
+
name: exports_external.string().optional(),
|
|
15406
|
+
discriminator: exports_external.string().optional(),
|
|
15407
|
+
description: exports_external.string().optional(),
|
|
15408
|
+
ownerName: exports_external.string().optional(),
|
|
15409
|
+
ownerDiscriminator: exports_external.string().optional()
|
|
15410
|
+
}),
|
|
15411
|
+
exports_external.object({
|
|
15412
|
+
type: exports_external.literal("bot:removed"),
|
|
15413
|
+
botId: exports_external.string().min(1)
|
|
15414
|
+
})
|
|
15415
|
+
]);
|
|
15416
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/entity.js
|
|
15240
15417
|
var entityKind = Symbol.for("drizzle:entityKind");
|
|
15241
15418
|
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
15242
15419
|
function is(value, type) {
|
|
@@ -15261,7 +15438,7 @@ function is(value, type) {
|
|
|
15261
15438
|
return false;
|
|
15262
15439
|
}
|
|
15263
15440
|
|
|
15264
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15441
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/column.js
|
|
15265
15442
|
class Column {
|
|
15266
15443
|
constructor(table, config2) {
|
|
15267
15444
|
this.table = table;
|
|
@@ -15311,7 +15488,7 @@ class Column {
|
|
|
15311
15488
|
}
|
|
15312
15489
|
}
|
|
15313
15490
|
|
|
15314
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15491
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/column-builder.js
|
|
15315
15492
|
class ColumnBuilder {
|
|
15316
15493
|
static [entityKind] = "ColumnBuilder";
|
|
15317
15494
|
config;
|
|
@@ -15367,20 +15544,20 @@ class ColumnBuilder {
|
|
|
15367
15544
|
}
|
|
15368
15545
|
}
|
|
15369
15546
|
|
|
15370
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15547
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/table.utils.js
|
|
15371
15548
|
var TableName = Symbol.for("drizzle:Name");
|
|
15372
15549
|
|
|
15373
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15550
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/tracing-utils.js
|
|
15374
15551
|
function iife(fn, ...args) {
|
|
15375
15552
|
return fn(...args);
|
|
15376
15553
|
}
|
|
15377
15554
|
|
|
15378
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15555
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/pg-core/unique-constraint.js
|
|
15379
15556
|
function uniqueKeyName(table, columns) {
|
|
15380
15557
|
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
15381
15558
|
}
|
|
15382
15559
|
|
|
15383
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15560
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/pg-core/columns/common.js
|
|
15384
15561
|
class PgColumn extends Column {
|
|
15385
15562
|
constructor(table, config2) {
|
|
15386
15563
|
if (!config2.uniqueName) {
|
|
@@ -15429,7 +15606,7 @@ class ExtraConfigColumn extends PgColumn {
|
|
|
15429
15606
|
}
|
|
15430
15607
|
}
|
|
15431
15608
|
|
|
15432
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15609
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/pg-core/columns/enum.js
|
|
15433
15610
|
class PgEnumObjectColumn extends PgColumn {
|
|
15434
15611
|
static [entityKind] = "PgEnumObjectColumn";
|
|
15435
15612
|
enum;
|
|
@@ -15459,7 +15636,7 @@ class PgEnumColumn extends PgColumn {
|
|
|
15459
15636
|
}
|
|
15460
15637
|
}
|
|
15461
15638
|
|
|
15462
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15639
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/subquery.js
|
|
15463
15640
|
class Subquery {
|
|
15464
15641
|
static [entityKind] = "Subquery";
|
|
15465
15642
|
constructor(sql, fields, alias, isWith = false, usedTables = []) {
|
|
@@ -15474,10 +15651,10 @@ class Subquery {
|
|
|
15474
15651
|
}
|
|
15475
15652
|
}
|
|
15476
15653
|
|
|
15477
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15654
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/version.js
|
|
15478
15655
|
var version2 = "0.45.2";
|
|
15479
15656
|
|
|
15480
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15657
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/tracing.js
|
|
15481
15658
|
var otel;
|
|
15482
15659
|
var rawTracer;
|
|
15483
15660
|
var tracer = {
|
|
@@ -15504,10 +15681,10 @@ var tracer = {
|
|
|
15504
15681
|
}
|
|
15505
15682
|
};
|
|
15506
15683
|
|
|
15507
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15684
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/view-common.js
|
|
15508
15685
|
var ViewBaseConfig = Symbol.for("drizzle:ViewBaseConfig");
|
|
15509
15686
|
|
|
15510
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15687
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/table.js
|
|
15511
15688
|
var Schema = Symbol.for("drizzle:Schema");
|
|
15512
15689
|
var Columns = Symbol.for("drizzle:Columns");
|
|
15513
15690
|
var ExtraConfigColumns = Symbol.for("drizzle:ExtraConfigColumns");
|
|
@@ -15545,7 +15722,7 @@ class Table {
|
|
|
15545
15722
|
}
|
|
15546
15723
|
}
|
|
15547
15724
|
|
|
15548
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
15725
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sql/sql.js
|
|
15549
15726
|
function isSQLWrapper(value) {
|
|
15550
15727
|
return value !== null && value !== undefined && typeof value.getSQL === "function";
|
|
15551
15728
|
}
|
|
@@ -15905,7 +16082,7 @@ Subquery.prototype.getSQL = function() {
|
|
|
15905
16082
|
return new SQL([this]);
|
|
15906
16083
|
};
|
|
15907
16084
|
|
|
15908
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16085
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/utils.js
|
|
15909
16086
|
function getColumnNameAndConfig(a, b) {
|
|
15910
16087
|
return {
|
|
15911
16088
|
name: typeof a === "string" && a.length > 0 ? a : "",
|
|
@@ -15918,7 +16095,6 @@ var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder;
|
|
|
15918
16095
|
var exports_community_schema = {};
|
|
15919
16096
|
__export(exports_community_schema, {
|
|
15920
16097
|
communityUserProfile: () => communityUserProfile,
|
|
15921
|
-
communityThreadParticipant: () => communityThreadParticipant,
|
|
15922
16098
|
communityServerMember: () => communityServerMember,
|
|
15923
16099
|
communityServerInvite: () => communityServerInvite,
|
|
15924
16100
|
communityServerFolderItem: () => communityServerFolderItem,
|
|
@@ -15928,21 +16104,23 @@ __export(exports_community_schema, {
|
|
|
15928
16104
|
communityReaction: () => communityReaction,
|
|
15929
16105
|
communityPin: () => communityPin,
|
|
15930
16106
|
communityNotificationSetting: () => communityNotificationSetting,
|
|
16107
|
+
communityMessageTag: () => communityMessageTag,
|
|
15931
16108
|
communityMessageSeq: () => communityMessageSeq,
|
|
16109
|
+
communityMessageMark: () => communityMessageMark,
|
|
15932
16110
|
communityMessage: () => communityMessage,
|
|
15933
16111
|
communityMention: () => communityMention,
|
|
15934
16112
|
communityFriendship: () => communityFriendship,
|
|
15935
|
-
communityDmConversation: () => communityDmConversation,
|
|
15936
16113
|
communityChannelMember: () => communityChannelMember,
|
|
15937
16114
|
communityChannel: () => communityChannel,
|
|
15938
16115
|
communityCategory: () => communityCategory,
|
|
16116
|
+
communityBotDailyActivity: () => communityBotDailyActivity,
|
|
15939
16117
|
communityBotApprovalRequest: () => communityBotApprovalRequest,
|
|
15940
16118
|
communityBotActivityEvent: () => communityBotActivityEvent,
|
|
15941
16119
|
communityAuditLog: () => communityAuditLog,
|
|
15942
16120
|
communityAttachment: () => communityAttachment
|
|
15943
16121
|
});
|
|
15944
16122
|
|
|
15945
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16123
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
|
|
15946
16124
|
class ForeignKeyBuilder {
|
|
15947
16125
|
static [entityKind] = "SQLiteForeignKeyBuilder";
|
|
15948
16126
|
reference;
|
|
@@ -16010,7 +16188,7 @@ function foreignKey(config2) {
|
|
|
16010
16188
|
return new ForeignKeyBuilder(mappedConfig);
|
|
16011
16189
|
}
|
|
16012
16190
|
|
|
16013
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16191
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/unique-constraint.js
|
|
16014
16192
|
function uniqueKeyName2(table, columns) {
|
|
16015
16193
|
return `${table[TableName]}_${columns.join("_")}_unique`;
|
|
16016
16194
|
}
|
|
@@ -16055,7 +16233,7 @@ class UniqueConstraint {
|
|
|
16055
16233
|
}
|
|
16056
16234
|
}
|
|
16057
16235
|
|
|
16058
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16236
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/columns/common.js
|
|
16059
16237
|
class SQLiteColumnBuilder extends ColumnBuilder {
|
|
16060
16238
|
static [entityKind] = "SQLiteColumnBuilder";
|
|
16061
16239
|
foreignKeyConfigs = [];
|
|
@@ -16106,7 +16284,7 @@ class SQLiteColumn extends Column {
|
|
|
16106
16284
|
static [entityKind] = "SQLiteColumn";
|
|
16107
16285
|
}
|
|
16108
16286
|
|
|
16109
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16287
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/columns/blob.js
|
|
16110
16288
|
class SQLiteBigIntBuilder extends SQLiteColumnBuilder {
|
|
16111
16289
|
static [entityKind] = "SQLiteBigIntBuilder";
|
|
16112
16290
|
constructor(name) {
|
|
@@ -16194,7 +16372,7 @@ function blob(a, b) {
|
|
|
16194
16372
|
return new SQLiteBlobBufferBuilder(name);
|
|
16195
16373
|
}
|
|
16196
16374
|
|
|
16197
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16375
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/columns/custom.js
|
|
16198
16376
|
class SQLiteCustomColumnBuilder extends SQLiteColumnBuilder {
|
|
16199
16377
|
static [entityKind] = "SQLiteCustomColumnBuilder";
|
|
16200
16378
|
constructor(name, fieldConfig, customTypeParams) {
|
|
@@ -16235,7 +16413,7 @@ function customType(customTypeParams) {
|
|
|
16235
16413
|
};
|
|
16236
16414
|
}
|
|
16237
16415
|
|
|
16238
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16416
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/columns/integer.js
|
|
16239
16417
|
class SQLiteBaseIntegerBuilder extends SQLiteColumnBuilder {
|
|
16240
16418
|
static [entityKind] = "SQLiteBaseIntegerBuilder";
|
|
16241
16419
|
constructor(name, dataType, columnType) {
|
|
@@ -16337,7 +16515,7 @@ function integer2(a, b) {
|
|
|
16337
16515
|
return new SQLiteIntegerBuilder(name);
|
|
16338
16516
|
}
|
|
16339
16517
|
|
|
16340
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16518
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
|
|
16341
16519
|
class SQLiteNumericBuilder extends SQLiteColumnBuilder {
|
|
16342
16520
|
static [entityKind] = "SQLiteNumericBuilder";
|
|
16343
16521
|
constructor(name) {
|
|
@@ -16407,7 +16585,7 @@ function numeric(a, b) {
|
|
|
16407
16585
|
return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
|
|
16408
16586
|
}
|
|
16409
16587
|
|
|
16410
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16588
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/columns/real.js
|
|
16411
16589
|
class SQLiteRealBuilder extends SQLiteColumnBuilder {
|
|
16412
16590
|
static [entityKind] = "SQLiteRealBuilder";
|
|
16413
16591
|
constructor(name) {
|
|
@@ -16428,7 +16606,7 @@ function real(name) {
|
|
|
16428
16606
|
return new SQLiteRealBuilder(name ?? "");
|
|
16429
16607
|
}
|
|
16430
16608
|
|
|
16431
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16609
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/columns/text.js
|
|
16432
16610
|
class SQLiteTextBuilder extends SQLiteColumnBuilder {
|
|
16433
16611
|
static [entityKind] = "SQLiteTextBuilder";
|
|
16434
16612
|
constructor(name, config2) {
|
|
@@ -16483,7 +16661,7 @@ function text(a, b = {}) {
|
|
|
16483
16661
|
return new SQLiteTextBuilder(name, config2);
|
|
16484
16662
|
}
|
|
16485
16663
|
|
|
16486
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16664
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/columns/all.js
|
|
16487
16665
|
function getSQLiteColumnBuilders() {
|
|
16488
16666
|
return {
|
|
16489
16667
|
blob,
|
|
@@ -16495,7 +16673,7 @@ function getSQLiteColumnBuilders() {
|
|
|
16495
16673
|
};
|
|
16496
16674
|
}
|
|
16497
16675
|
|
|
16498
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16676
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/table.js
|
|
16499
16677
|
var InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
|
16500
16678
|
|
|
16501
16679
|
class SQLiteTable extends Table {
|
|
@@ -16529,7 +16707,7 @@ var sqliteTable = (name, columns, extraConfig) => {
|
|
|
16529
16707
|
return sqliteTableBase(name, columns, extraConfig);
|
|
16530
16708
|
};
|
|
16531
16709
|
|
|
16532
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16710
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/indexes.js
|
|
16533
16711
|
class IndexBuilderOn {
|
|
16534
16712
|
constructor(name, unique2) {
|
|
16535
16713
|
this.name = name;
|
|
@@ -16575,7 +16753,7 @@ function uniqueIndex(name) {
|
|
|
16575
16753
|
return new IndexBuilderOn(name, true);
|
|
16576
16754
|
}
|
|
16577
16755
|
|
|
16578
|
-
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@
|
|
16756
|
+
// ../../node_modules/.pnpm/drizzle-orm@0.45.2_@cloudflare+workers-types@4.20260702.1_@opentelemetry+api@1.9.1_@typ_5aa9492b131e5fac58fa98e88e5c0ad3/node_modules/drizzle-orm/sqlite-core/primary-keys.js
|
|
16579
16757
|
function primaryKey(...config2) {
|
|
16580
16758
|
if (config2[0].columns) {
|
|
16581
16759
|
return new PrimaryKeyBuilder(config2[0].columns, config2[0].name);
|
|
@@ -16663,7 +16841,8 @@ var user = sqliteTable("user", {
|
|
|
16663
16841
|
isBot: integer2("isBot", { mode: "boolean" }).notNull().default(false),
|
|
16664
16842
|
ownerUserId: text("ownerUserId").references(() => user.id, { onDelete: "no action" }),
|
|
16665
16843
|
deletedAt: text("deletedAt"),
|
|
16666
|
-
discriminator: text("discriminator").notNull().default("0000")
|
|
16844
|
+
discriminator: text("discriminator").notNull().default("0000"),
|
|
16845
|
+
lastRefreshContextAt: text("lastRefreshContextAt")
|
|
16667
16846
|
}, (t) => [index("idx_user_ownerUserId_isBot").on(t.ownerUserId, t.isBot)]);
|
|
16668
16847
|
var session = sqliteTable("session", {
|
|
16669
16848
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
@@ -17205,11 +17384,14 @@ var inboxUnread = sqliteTable("inbox_unread", {
|
|
|
17205
17384
|
var communityServer = sqliteTable("community_server", {
|
|
17206
17385
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17207
17386
|
name: text("name").notNull(),
|
|
17387
|
+
discriminator: text("discriminator").notNull().default("0000"),
|
|
17208
17388
|
description: text("description").default(""),
|
|
17209
17389
|
icon: text("icon"),
|
|
17210
17390
|
ownerId: text("owner_id").notNull().references(() => user.id, { onDelete: "restrict" }),
|
|
17211
17391
|
createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17212
|
-
})
|
|
17392
|
+
}, (t) => [
|
|
17393
|
+
uniqueIndex("idx_community_server_name_discriminator").on(t.name, t.discriminator)
|
|
17394
|
+
]);
|
|
17213
17395
|
var communityCategory = sqliteTable("community_category", {
|
|
17214
17396
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17215
17397
|
serverId: text("server_id").notNull().references(() => communityServer.id, { onDelete: "cascade" }),
|
|
@@ -17220,15 +17402,16 @@ var communityCategory = sqliteTable("community_category", {
|
|
|
17220
17402
|
}, (t) => [unique("uq_category_server_name").on(t.serverId, t.name)]);
|
|
17221
17403
|
var communityChannel = sqliteTable("community_channel", {
|
|
17222
17404
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17223
|
-
serverId: text("server_id").
|
|
17405
|
+
serverId: text("server_id").references(() => communityServer.id, {
|
|
17406
|
+
onDelete: "cascade"
|
|
17407
|
+
}),
|
|
17224
17408
|
categoryId: text("category_id").references(() => communityCategory.id, {
|
|
17225
17409
|
onDelete: "set null"
|
|
17226
17410
|
}),
|
|
17227
|
-
name: text("name")
|
|
17411
|
+
name: text("name"),
|
|
17228
17412
|
type: text("type").notNull().default("text"),
|
|
17229
17413
|
topic: text("topic").default(""),
|
|
17230
17414
|
position: integer2("position").default(0),
|
|
17231
|
-
forumTags: text("forum_tags"),
|
|
17232
17415
|
parentChannelId: text("parent_channel_id").references(() => communityChannel.id, {
|
|
17233
17416
|
onDelete: "cascade"
|
|
17234
17417
|
}),
|
|
@@ -17241,39 +17424,21 @@ var communityChannel = sqliteTable("community_channel", {
|
|
|
17241
17424
|
}, (t) => [
|
|
17242
17425
|
index("idx_channel_server_position").on(t.serverId, t.position),
|
|
17243
17426
|
index("idx_channel_server_last_message").on(t.serverId, t.lastMessageAt),
|
|
17244
|
-
index("idx_channel_parent").on(t.parentChannelId)
|
|
17427
|
+
index("idx_channel_parent").on(t.parentChannelId),
|
|
17428
|
+
uniqueIndex("idx_channel_server_name").on(t.serverId, t.name).where(sql`parent_channel_id IS NULL`)
|
|
17245
17429
|
]);
|
|
17246
17430
|
var communityChannelMember = sqliteTable("community_channel_member", {
|
|
17247
17431
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17248
17432
|
channelId: text("channel_id").notNull().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
17249
17433
|
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
17434
|
+
relation: text("relation").notNull().default("access"),
|
|
17435
|
+
source: text("source").notNull().default("added"),
|
|
17250
17436
|
addedBy: text("added_by").references(() => user.id, { onDelete: "set null" }),
|
|
17251
17437
|
addedAt: text("added_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17252
17438
|
}, (t) => [
|
|
17253
|
-
unique("uq_channel_member").on(t.channelId, t.userId),
|
|
17439
|
+
unique("uq_channel_member").on(t.channelId, t.userId, t.relation),
|
|
17254
17440
|
index("idx_channel_member_user").on(t.userId)
|
|
17255
17441
|
]);
|
|
17256
|
-
var communityThreadParticipant = sqliteTable("community_thread_participant", {
|
|
17257
|
-
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17258
|
-
threadChannelId: text("thread_channel_id").notNull().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
17259
|
-
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
17260
|
-
source: text("source").notNull().default("mention"),
|
|
17261
|
-
addedAt: text("added_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17262
|
-
}, (t) => [
|
|
17263
|
-
unique("uq_thread_participant").on(t.threadChannelId, t.userId),
|
|
17264
|
-
index("idx_thread_participant_user").on(t.userId)
|
|
17265
|
-
]);
|
|
17266
|
-
var communityDmConversation = sqliteTable("community_dm_conversation", {
|
|
17267
|
-
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17268
|
-
user1Id: text("user1_id").references(() => user.id, { onDelete: "set null" }),
|
|
17269
|
-
user2Id: text("user2_id").references(() => user.id, { onDelete: "set null" }),
|
|
17270
|
-
lastMessageAt: text("last_message_at"),
|
|
17271
|
-
createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17272
|
-
}, (t) => [
|
|
17273
|
-
unique("uq_dm_conversation_users").on(t.user1Id, t.user2Id),
|
|
17274
|
-
index("idx_dm_conversation_user1_last_message").on(t.user1Id, t.lastMessageAt),
|
|
17275
|
-
index("idx_dm_conversation_user2_last_message").on(t.user2Id, t.lastMessageAt)
|
|
17276
|
-
]);
|
|
17277
17442
|
var communityMessage = sqliteTable("community_message", {
|
|
17278
17443
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17279
17444
|
authorId: text("author_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
@@ -17282,20 +17447,19 @@ var communityMessage = sqliteTable("community_message", {
|
|
|
17282
17447
|
mentionType: text("mention_type"),
|
|
17283
17448
|
replyToId: text("reply_to_id"),
|
|
17284
17449
|
embeds: text("embeds"),
|
|
17285
|
-
flags: integer2("flags").default(0),
|
|
17286
17450
|
createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString()),
|
|
17287
|
-
channelId: text("channel_id").references(() => communityChannel.id, {
|
|
17451
|
+
channelId: text("channel_id").notNull().references(() => communityChannel.id, {
|
|
17288
17452
|
onDelete: "cascade"
|
|
17289
17453
|
}),
|
|
17290
|
-
|
|
17291
|
-
|
|
17454
|
+
seq: integer2("seq").notNull().default(0),
|
|
17455
|
+
friendshipId: text("friendship_id").references(() => communityFriendship.id, { onDelete: "set null" }),
|
|
17456
|
+
clientNonce: text("client_nonce")
|
|
17292
17457
|
}, (t) => [
|
|
17293
17458
|
index("idx_message_channel_created").on(t.channelId, t.createdAt),
|
|
17294
|
-
index("idx_message_channel_mention_created").on(t.channelId, t.mentionType, t.createdAt)
|
|
17295
|
-
index("idx_message_dm_created").on(t.dmConversationId, t.createdAt)
|
|
17459
|
+
index("idx_message_channel_mention_created").on(t.channelId, t.mentionType, t.createdAt)
|
|
17296
17460
|
]);
|
|
17297
17461
|
var communityMessageSeq = sqliteTable("community_message_seq", {
|
|
17298
|
-
|
|
17462
|
+
channelId: text("channel_id").primaryKey().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
17299
17463
|
nextSeq: integer2("next_seq").notNull()
|
|
17300
17464
|
});
|
|
17301
17465
|
var communityServerMember = sqliteTable("community_server_member", {
|
|
@@ -17303,13 +17467,13 @@ var communityServerMember = sqliteTable("community_server_member", {
|
|
|
17303
17467
|
serverId: text("server_id").notNull().references(() => communityServer.id, { onDelete: "cascade" }),
|
|
17304
17468
|
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
17305
17469
|
role: text("role").default("member"),
|
|
17306
|
-
nickname: text("nickname"),
|
|
17307
17470
|
railOrder: integer2("rail_order").default(0),
|
|
17308
17471
|
joinedAt: text("joined_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17309
17472
|
}, (t) => [
|
|
17310
17473
|
unique("uq_server_member_server_user").on(t.serverId, t.userId),
|
|
17311
17474
|
index("idx_server_member_user").on(t.userId),
|
|
17312
|
-
index("idx_server_member_user_rail_order").on(t.userId, t.railOrder)
|
|
17475
|
+
index("idx_server_member_user_rail_order").on(t.userId, t.railOrder),
|
|
17476
|
+
index("idx_server_member_server_joined").on(t.serverId, t.joinedAt)
|
|
17313
17477
|
]);
|
|
17314
17478
|
var communityServerFolder = sqliteTable("community_server_folder", {
|
|
17315
17479
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
@@ -17334,27 +17498,27 @@ var communityServerInvite = sqliteTable("community_server_invite", {
|
|
|
17334
17498
|
uses: integer2("uses").default(0),
|
|
17335
17499
|
expiresAt: text("expires_at"),
|
|
17336
17500
|
createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17337
|
-
});
|
|
17501
|
+
}, (t) => [index("idx_server_invite_server").on(t.serverId)]);
|
|
17338
17502
|
var communityFriendship = sqliteTable("community_friendship", {
|
|
17339
17503
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17340
17504
|
requesterId: text("requester_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
17341
17505
|
addresseeId: text("addressee_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
17342
17506
|
status: text("status").notNull().default("pending"),
|
|
17507
|
+
needsOwnerApproval: text("needs_owner_approval").references(() => user.id),
|
|
17343
17508
|
blockerId: text("blocker_id"),
|
|
17344
17509
|
createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString()),
|
|
17345
|
-
updatedAt: text("updated_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17510
|
+
updatedAt: text("updated_at").notNull().$defaultFn(() => new Date().toISOString()),
|
|
17511
|
+
resolvedAt: text("resolved_at")
|
|
17346
17512
|
}, (t) => [
|
|
17347
|
-
unique("uq_friendship_requester_addressee").on(t.requesterId, t.addresseeId),
|
|
17348
17513
|
index("idx_friendship_addressee_status").on(t.addresseeId, t.status),
|
|
17349
17514
|
index("idx_friendship_requester_status").on(t.requesterId, t.status)
|
|
17350
17515
|
]);
|
|
17351
17516
|
var communityReadState = sqliteTable("community_read_state", {
|
|
17352
17517
|
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17353
17518
|
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
17354
|
-
channelId: text("channel_id").references(() => communityChannel.id, {
|
|
17519
|
+
channelId: text("channel_id").notNull().references(() => communityChannel.id, {
|
|
17355
17520
|
onDelete: "cascade"
|
|
17356
17521
|
}),
|
|
17357
|
-
dmConversationId: text("dm_conversation_id").references(() => communityDmConversation.id, { onDelete: "cascade" }),
|
|
17358
17522
|
lastReadAt: text("last_read_at").notNull(),
|
|
17359
17523
|
lastReadMessageId: text("last_read_message_id"),
|
|
17360
17524
|
lastReadSeq: integer2("last_read_seq").notNull().default(0)
|
|
@@ -17375,7 +17539,6 @@ var communityAttachment = sqliteTable("community_attachment", {
|
|
|
17375
17539
|
onDelete: "cascade"
|
|
17376
17540
|
}),
|
|
17377
17541
|
uploaderId: text("uploader_id").notNull(),
|
|
17378
|
-
kind: text("kind").notNull(),
|
|
17379
17542
|
targetId: text("target_id").notNull(),
|
|
17380
17543
|
r2Key: text("r2_key").notNull(),
|
|
17381
17544
|
filename: text("filename").notNull(),
|
|
@@ -17467,6 +17630,30 @@ var communityBotActivityEvent = sqliteTable("community_bot_activity_event", {
|
|
|
17467
17630
|
}, (t) => [
|
|
17468
17631
|
index("idx_bot_activity_event_bot_created").on(t.botId, t.createdAt, t.id)
|
|
17469
17632
|
]);
|
|
17633
|
+
var communityBotDailyActivity = sqliteTable("community_bot_daily_activity", {
|
|
17634
|
+
botId: text("bot_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
17635
|
+
day: text("day").notNull(),
|
|
17636
|
+
handledCount: integer2("handled_count").notNull().default(0),
|
|
17637
|
+
sentCount: integer2("sent_count").notNull().default(0)
|
|
17638
|
+
}, (t) => [primaryKey({ columns: [t.botId, t.day] })]);
|
|
17639
|
+
var communityMessageMark = sqliteTable("community_message_mark", {
|
|
17640
|
+
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17641
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
17642
|
+
channelId: text("channel_id").notNull().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
17643
|
+
messageId: text("message_id").notNull().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
17644
|
+
createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17645
|
+
}, (t) => [
|
|
17646
|
+
unique("uq_mark_user_message").on(t.userId, t.messageId),
|
|
17647
|
+
index("idx_mark_user_created").on(t.userId, t.createdAt)
|
|
17648
|
+
]);
|
|
17649
|
+
var communityMessageTag = sqliteTable("community_message_tag", {
|
|
17650
|
+
id: text("id").primaryKey().$defaultFn(() => nanoid3()),
|
|
17651
|
+
messageId: text("message_id").notNull().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
17652
|
+
tag: text("tag").notNull()
|
|
17653
|
+
}, (t) => [
|
|
17654
|
+
unique("uq_message_tag").on(t.messageId, t.tag),
|
|
17655
|
+
index("idx_message_tag_tag").on(t.tag, t.messageId)
|
|
17656
|
+
]);
|
|
17470
17657
|
|
|
17471
17658
|
// ../shared/src/logger.ts
|
|
17472
17659
|
var LEVELS = {
|
|
@@ -17548,6 +17735,14 @@ function createLogger(opts) {
|
|
|
17548
17735
|
return new Logger(opts);
|
|
17549
17736
|
}
|
|
17550
17737
|
|
|
17738
|
+
// ../shared/src/db/queries/_chunk.ts
|
|
17739
|
+
var D1_MAX_BIND_PARAMS = 100;
|
|
17740
|
+
function maxRowsPerInsert(paramsPerRow) {
|
|
17741
|
+
if (paramsPerRow < 1)
|
|
17742
|
+
throw new Error("paramsPerRow must be >= 1");
|
|
17743
|
+
return Math.floor(D1_MAX_BIND_PARAMS / paramsPerRow);
|
|
17744
|
+
}
|
|
17745
|
+
|
|
17551
17746
|
// ../shared/src/db/queries/community/message.ts
|
|
17552
17747
|
var log = createLogger({ service: "community-queries" });
|
|
17553
17748
|
var listedMessageProjection = {
|
|
@@ -17558,10 +17753,11 @@ var listedMessageProjection = {
|
|
|
17558
17753
|
mentionType: communityMessage.mentionType,
|
|
17559
17754
|
replyToId: communityMessage.replyToId,
|
|
17560
17755
|
embeds: communityMessage.embeds,
|
|
17561
|
-
|
|
17756
|
+
seq: communityMessage.seq,
|
|
17562
17757
|
createdAt: communityMessage.createdAt,
|
|
17563
17758
|
channelId: communityMessage.channelId,
|
|
17564
|
-
|
|
17759
|
+
friendshipId: communityMessage.friendshipId,
|
|
17760
|
+
clientNonce: communityMessage.clientNonce,
|
|
17565
17761
|
authorName: user.name,
|
|
17566
17762
|
authorEmail: user.email,
|
|
17567
17763
|
authorImage: user.image
|
|
@@ -17626,6 +17822,7 @@ var communityBotBinding = sqliteTable("community_bot_binding", {
|
|
|
17626
17822
|
userId: text("user_id").primaryKey().references(() => user.id, { onDelete: "cascade" }),
|
|
17627
17823
|
machineId: text("machine_id").notNull().references(() => communityMachine.id, { onDelete: "restrict" }),
|
|
17628
17824
|
runtime: text("runtime").notNull(),
|
|
17825
|
+
modelName: text("model_name"),
|
|
17629
17826
|
createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString())
|
|
17630
17827
|
}, (t) => [index("idx_community_bot_binding_machine").on(t.machineId)]);
|
|
17631
17828
|
var communityAgentRunnerKey = sqliteTable("community_agent_runner_key", {
|
|
@@ -17660,7 +17857,6 @@ var internalUserColumns = {
|
|
|
17660
17857
|
};
|
|
17661
17858
|
|
|
17662
17859
|
// ../shared/src/db/queries/community/channel.ts
|
|
17663
|
-
var log2 = createLogger({ service: "community-queries" });
|
|
17664
17860
|
var CHANNEL_COLUMNS = {
|
|
17665
17861
|
id: communityChannel.id,
|
|
17666
17862
|
serverId: communityChannel.serverId,
|
|
@@ -17669,7 +17865,6 @@ var CHANNEL_COLUMNS = {
|
|
|
17669
17865
|
type: communityChannel.type,
|
|
17670
17866
|
topic: communityChannel.topic,
|
|
17671
17867
|
position: communityChannel.position,
|
|
17672
|
-
forumTags: communityChannel.forumTags,
|
|
17673
17868
|
parentChannelId: communityChannel.parentChannelId,
|
|
17674
17869
|
creatorId: communityChannel.creatorId,
|
|
17675
17870
|
messageCount: communityChannel.messageCount,
|
|
@@ -17679,6 +17874,16 @@ var CHANNEL_COLUMNS = {
|
|
|
17679
17874
|
createdAt: communityChannel.createdAt
|
|
17680
17875
|
};
|
|
17681
17876
|
|
|
17877
|
+
// ../shared/src/db/queries/community/thread.ts
|
|
17878
|
+
var NOTIFY_CONFLICT_TARGET = [
|
|
17879
|
+
communityChannelMember.channelId,
|
|
17880
|
+
communityChannelMember.userId,
|
|
17881
|
+
communityChannelMember.relation
|
|
17882
|
+
];
|
|
17883
|
+
|
|
17884
|
+
// ../shared/src/db/resilience.ts
|
|
17885
|
+
var defaultLogger = createLogger({ service: "d1-resilience" });
|
|
17886
|
+
|
|
17682
17887
|
// ../shared/src/db/queries/community/agent-inbox.ts
|
|
17683
17888
|
var AGENT_MESSAGE_COLUMNS = {
|
|
17684
17889
|
id: communityMessage.id,
|
|
@@ -17686,9 +17891,13 @@ var AGENT_MESSAGE_COLUMNS = {
|
|
|
17686
17891
|
content: communityMessage.content,
|
|
17687
17892
|
createdAt: communityMessage.createdAt,
|
|
17688
17893
|
channelId: communityMessage.channelId,
|
|
17689
|
-
|
|
17690
|
-
|
|
17894
|
+
seq: communityMessage.seq,
|
|
17895
|
+
replyToId: communityMessage.replyToId
|
|
17691
17896
|
};
|
|
17897
|
+
var channelJoinBaselineGuard = sql`${communityMessage.createdAt} > COALESCE(${communityChannelMember.addedAt}, ${communityServerMember.joinedAt}, '')`;
|
|
17898
|
+
|
|
17899
|
+
// ../shared/src/db/queries/community/mention.ts
|
|
17900
|
+
var MENTION_INSERT_MAX_ROWS = maxRowsPerInsert(5);
|
|
17692
17901
|
// ../shared/src/community/bot-activity-presets.ts
|
|
17693
17902
|
var BOT_ACTIVITY_PRESETS = {
|
|
17694
17903
|
idle: { emoji: "\uD83D\uDCA4", text: "Idle" },
|
|
@@ -17703,9 +17912,467 @@ var RUNNING_PRESETS = [
|
|
|
17703
17912
|
{ emoji: "\uD83D\uDE80", text: "On it" },
|
|
17704
17913
|
{ emoji: "\uD83D\uDD25", text: "In the zone" }
|
|
17705
17914
|
];
|
|
17706
|
-
|
|
17707
|
-
|
|
17708
|
-
|
|
17915
|
+
var BOT_ACTIVITY_STATUS_PAIRS = [
|
|
17916
|
+
BOT_ACTIVITY_PRESETS.idle,
|
|
17917
|
+
BOT_ACTIVITY_PRESETS.starting,
|
|
17918
|
+
BOT_ACTIVITY_PRESETS.stopping,
|
|
17919
|
+
...RUNNING_PRESETS
|
|
17920
|
+
];
|
|
17921
|
+
// ../shared/src/community-ws-events.ts
|
|
17922
|
+
var string4 = exports_external.string();
|
|
17923
|
+
var nullableString = string4.nullable();
|
|
17924
|
+
var channelTypeSchema = exports_external.enum(["text", "forum"]);
|
|
17925
|
+
var mentionTypeSchema = exports_external.literal("everyone");
|
|
17926
|
+
var friendApprovalProfileSchema = exports_external.strictObject({
|
|
17927
|
+
id: string4,
|
|
17928
|
+
name: string4,
|
|
17929
|
+
discriminator: string4,
|
|
17930
|
+
image: nullableString
|
|
17931
|
+
});
|
|
17932
|
+
var FriendApprovalPayloadSchema = exports_external.strictObject({
|
|
17933
|
+
friendshipId: string4,
|
|
17934
|
+
status: exports_external.enum(["pending", "approved", "denied", "superseded", "cancelled"]),
|
|
17935
|
+
waitingOn: exports_external.enum(["you", "other-owner", "addressee"]).nullable(),
|
|
17936
|
+
otherProfile: friendApprovalProfileSchema,
|
|
17937
|
+
botProfile: friendApprovalProfileSchema,
|
|
17938
|
+
waitingOnProfile: friendApprovalProfileSchema.nullable().optional()
|
|
17939
|
+
});
|
|
17940
|
+
var messageAttachmentSchema = exports_external.strictObject({
|
|
17941
|
+
id: string4,
|
|
17942
|
+
filename: string4,
|
|
17943
|
+
url: string4,
|
|
17944
|
+
contentType: string4.optional(),
|
|
17945
|
+
size: exports_external.number().optional(),
|
|
17946
|
+
width: exports_external.number().nullable().optional(),
|
|
17947
|
+
height: exports_external.number().nullable().optional()
|
|
17948
|
+
});
|
|
17949
|
+
var messageSchema = exports_external.strictObject({
|
|
17950
|
+
id: string4,
|
|
17951
|
+
seq: exports_external.number(),
|
|
17952
|
+
authorId: string4,
|
|
17953
|
+
authorName: string4,
|
|
17954
|
+
authorAvatar: string4.optional(),
|
|
17955
|
+
content: string4,
|
|
17956
|
+
type: exports_external.enum(["chat", "system"]),
|
|
17957
|
+
systemKind: exports_external.literal("thread").optional(),
|
|
17958
|
+
mentionType: mentionTypeSchema.nullable().optional(),
|
|
17959
|
+
replyToId: nullableString.optional(),
|
|
17960
|
+
replyTo: exports_external.strictObject({
|
|
17961
|
+
id: string4,
|
|
17962
|
+
authorName: string4,
|
|
17963
|
+
text: string4,
|
|
17964
|
+
deleted: exports_external.boolean().optional()
|
|
17965
|
+
}).optional(),
|
|
17966
|
+
embeds: exports_external.array(exports_external.unknown()).optional(),
|
|
17967
|
+
attachments: exports_external.array(messageAttachmentSchema).optional(),
|
|
17968
|
+
createdAt: string4,
|
|
17969
|
+
clientNonce: string4.optional(),
|
|
17970
|
+
approval: FriendApprovalPayloadSchema.optional()
|
|
17971
|
+
});
|
|
17972
|
+
var communityMessageCreateSchema = exports_external.strictObject({
|
|
17973
|
+
type: exports_external.literal("community:message.create"),
|
|
17974
|
+
channelId: string4,
|
|
17975
|
+
serverId: string4.optional(),
|
|
17976
|
+
parentChannelId: string4.optional(),
|
|
17977
|
+
message: messageSchema
|
|
17978
|
+
});
|
|
17979
|
+
var communityMessageUpdatedSchema = exports_external.strictObject({
|
|
17980
|
+
type: exports_external.literal("community:message.updated"),
|
|
17981
|
+
channelId: string4,
|
|
17982
|
+
messageId: string4,
|
|
17983
|
+
approval: FriendApprovalPayloadSchema
|
|
17984
|
+
});
|
|
17985
|
+
var communityMessageEditedSchema = exports_external.strictObject({
|
|
17986
|
+
type: exports_external.literal("community:message.edited"),
|
|
17987
|
+
channelId: string4,
|
|
17988
|
+
messageId: string4,
|
|
17989
|
+
content: string4,
|
|
17990
|
+
parentChannelId: string4.optional(),
|
|
17991
|
+
serverId: string4.optional()
|
|
17992
|
+
}).refine((event) => event.parentChannelId === undefined || event.serverId !== undefined);
|
|
17993
|
+
var communityReactionAddSchema = exports_external.strictObject({
|
|
17994
|
+
type: exports_external.literal("community:reaction.add"),
|
|
17995
|
+
channelId: string4,
|
|
17996
|
+
messageId: string4,
|
|
17997
|
+
userId: string4,
|
|
17998
|
+
emoji: string4
|
|
17999
|
+
});
|
|
18000
|
+
var communityReactionRemoveSchema = exports_external.strictObject({
|
|
18001
|
+
type: exports_external.literal("community:reaction.remove"),
|
|
18002
|
+
channelId: string4,
|
|
18003
|
+
messageId: string4,
|
|
18004
|
+
userId: string4,
|
|
18005
|
+
emoji: string4
|
|
18006
|
+
});
|
|
18007
|
+
var communityPinAddSchema = exports_external.strictObject({
|
|
18008
|
+
type: exports_external.literal("community:pin.add"),
|
|
18009
|
+
channelId: string4,
|
|
18010
|
+
messageId: string4
|
|
18011
|
+
});
|
|
18012
|
+
var communityPinRemoveSchema = exports_external.strictObject({
|
|
18013
|
+
type: exports_external.literal("community:pin.remove"),
|
|
18014
|
+
channelId: string4,
|
|
18015
|
+
messageId: string4
|
|
18016
|
+
});
|
|
18017
|
+
var typingFields = {
|
|
18018
|
+
channelId: string4,
|
|
18019
|
+
userId: string4,
|
|
18020
|
+
name: string4.optional(),
|
|
18021
|
+
discriminator: string4.optional()
|
|
18022
|
+
};
|
|
18023
|
+
var communityTypingStartSchema = exports_external.strictObject({
|
|
18024
|
+
type: exports_external.literal("community:typing.start"),
|
|
18025
|
+
...typingFields
|
|
18026
|
+
});
|
|
18027
|
+
var communityTypingStopSchema = exports_external.strictObject({
|
|
18028
|
+
type: exports_external.literal("community:typing.stop"),
|
|
18029
|
+
...typingFields
|
|
18030
|
+
});
|
|
18031
|
+
var communityChildChannelCreateSchema = exports_external.strictObject({
|
|
18032
|
+
type: exports_external.literal("community:channel.child_create"),
|
|
18033
|
+
parentChannelId: string4,
|
|
18034
|
+
channel: exports_external.strictObject({
|
|
18035
|
+
id: string4,
|
|
18036
|
+
name: string4,
|
|
18037
|
+
type: exports_external.literal("thread"),
|
|
18038
|
+
creatorId: string4.optional(),
|
|
18039
|
+
createdAt: string4
|
|
18040
|
+
}),
|
|
18041
|
+
parentMessageId: string4.optional()
|
|
18042
|
+
});
|
|
18043
|
+
var communityChildChannelUpdateSchema = exports_external.strictObject({
|
|
18044
|
+
type: exports_external.literal("community:channel.child_update"),
|
|
18045
|
+
parentChannelId: string4,
|
|
18046
|
+
channelId: string4,
|
|
18047
|
+
changes: exports_external.strictObject({
|
|
18048
|
+
name: string4.optional(),
|
|
18049
|
+
archived: exports_external.boolean().optional(),
|
|
18050
|
+
tags: exports_external.array(string4).nullable().optional(),
|
|
18051
|
+
lastMessageAt: string4.optional(),
|
|
18052
|
+
messageCount: exports_external.number().optional()
|
|
18053
|
+
})
|
|
18054
|
+
});
|
|
18055
|
+
var communityServerUpdateSchema = exports_external.strictObject({
|
|
18056
|
+
type: exports_external.literal("community:server.update"),
|
|
18057
|
+
serverId: string4,
|
|
18058
|
+
changes: exports_external.strictObject({
|
|
18059
|
+
name: string4.optional(),
|
|
18060
|
+
description: string4.optional(),
|
|
18061
|
+
icon: nullableString.optional()
|
|
18062
|
+
})
|
|
18063
|
+
});
|
|
18064
|
+
var communityServerDeleteSchema = exports_external.strictObject({
|
|
18065
|
+
type: exports_external.literal("community:server.delete"),
|
|
18066
|
+
serverId: string4
|
|
18067
|
+
});
|
|
18068
|
+
var communityChannelCreateSchema = exports_external.strictObject({
|
|
18069
|
+
type: exports_external.literal("community:channel.create"),
|
|
18070
|
+
serverId: string4,
|
|
18071
|
+
channel: exports_external.strictObject({
|
|
18072
|
+
id: string4,
|
|
18073
|
+
name: string4,
|
|
18074
|
+
type: channelTypeSchema,
|
|
18075
|
+
categoryId: nullableString.optional(),
|
|
18076
|
+
topic: string4.optional(),
|
|
18077
|
+
position: exports_external.number(),
|
|
18078
|
+
createdAt: string4
|
|
18079
|
+
})
|
|
18080
|
+
});
|
|
18081
|
+
var communityChannelUpdateSchema = exports_external.strictObject({
|
|
18082
|
+
type: exports_external.literal("community:channel.update"),
|
|
18083
|
+
serverId: string4,
|
|
18084
|
+
channelId: string4,
|
|
18085
|
+
changes: exports_external.strictObject({
|
|
18086
|
+
name: string4.optional(),
|
|
18087
|
+
topic: string4.optional(),
|
|
18088
|
+
categoryId: nullableString.optional(),
|
|
18089
|
+
type: channelTypeSchema.optional()
|
|
18090
|
+
})
|
|
18091
|
+
});
|
|
18092
|
+
var communityChannelDeleteSchema = exports_external.strictObject({
|
|
18093
|
+
type: exports_external.literal("community:channel.delete"),
|
|
18094
|
+
serverId: string4,
|
|
18095
|
+
channelId: string4,
|
|
18096
|
+
parentChannelId: nullableString.optional()
|
|
18097
|
+
});
|
|
18098
|
+
var positionedIdSchema = exports_external.strictObject({ id: string4, position: exports_external.number() });
|
|
18099
|
+
var communityChannelReorderSchema = exports_external.strictObject({
|
|
18100
|
+
type: exports_external.literal("community:channel.reorder"),
|
|
18101
|
+
serverId: string4,
|
|
18102
|
+
channels: exports_external.array(positionedIdSchema)
|
|
18103
|
+
});
|
|
18104
|
+
var communityChannelMemberAddSchema = exports_external.strictObject({
|
|
18105
|
+
type: exports_external.literal("community:channel.member_add"),
|
|
18106
|
+
serverId: string4,
|
|
18107
|
+
channelId: string4,
|
|
18108
|
+
userId: string4
|
|
18109
|
+
});
|
|
18110
|
+
var communityChannelMemberRemoveSchema = exports_external.strictObject({
|
|
18111
|
+
type: exports_external.literal("community:channel.member_remove"),
|
|
18112
|
+
serverId: string4,
|
|
18113
|
+
channelId: string4,
|
|
18114
|
+
userId: string4
|
|
18115
|
+
});
|
|
18116
|
+
var communityCategoryCreateSchema = exports_external.strictObject({
|
|
18117
|
+
type: exports_external.literal("community:category.create"),
|
|
18118
|
+
serverId: string4,
|
|
18119
|
+
category: exports_external.strictObject({
|
|
18120
|
+
id: string4,
|
|
18121
|
+
name: string4,
|
|
18122
|
+
position: exports_external.number(),
|
|
18123
|
+
private: exports_external.boolean()
|
|
18124
|
+
})
|
|
18125
|
+
});
|
|
18126
|
+
var communityCategoryUpdateSchema = exports_external.strictObject({
|
|
18127
|
+
type: exports_external.literal("community:category.update"),
|
|
18128
|
+
serverId: string4,
|
|
18129
|
+
categoryId: string4,
|
|
18130
|
+
changes: exports_external.strictObject({
|
|
18131
|
+
name: string4.optional(),
|
|
18132
|
+
position: exports_external.number().optional(),
|
|
18133
|
+
private: exports_external.boolean().optional()
|
|
18134
|
+
})
|
|
18135
|
+
});
|
|
18136
|
+
var communityCategoryDeleteSchema = exports_external.strictObject({
|
|
18137
|
+
type: exports_external.literal("community:category.delete"),
|
|
18138
|
+
serverId: string4,
|
|
18139
|
+
categoryId: string4
|
|
18140
|
+
});
|
|
18141
|
+
var communityCategoryReorderSchema = exports_external.strictObject({
|
|
18142
|
+
type: exports_external.literal("community:category.reorder"),
|
|
18143
|
+
serverId: string4,
|
|
18144
|
+
categories: exports_external.array(positionedIdSchema)
|
|
18145
|
+
});
|
|
18146
|
+
var communityMemberJoinSchema = exports_external.strictObject({
|
|
18147
|
+
type: exports_external.literal("community:member.join"),
|
|
18148
|
+
serverId: string4,
|
|
18149
|
+
member: exports_external.strictObject({
|
|
18150
|
+
id: string4,
|
|
18151
|
+
userId: string4,
|
|
18152
|
+
name: string4,
|
|
18153
|
+
discriminator: string4,
|
|
18154
|
+
avatar: string4.optional(),
|
|
18155
|
+
role: string4,
|
|
18156
|
+
joinedAt: string4
|
|
18157
|
+
})
|
|
18158
|
+
});
|
|
18159
|
+
var communityMemberLeaveSchema = exports_external.strictObject({
|
|
18160
|
+
type: exports_external.literal("community:member.leave"),
|
|
18161
|
+
serverId: string4,
|
|
18162
|
+
userId: string4
|
|
18163
|
+
});
|
|
18164
|
+
var communityMemberUpdateSchema = exports_external.strictObject({
|
|
18165
|
+
type: exports_external.literal("community:member.update"),
|
|
18166
|
+
serverId: string4,
|
|
18167
|
+
memberId: string4,
|
|
18168
|
+
userId: string4.optional(),
|
|
18169
|
+
changes: exports_external.strictObject({
|
|
18170
|
+
role: string4.optional(),
|
|
18171
|
+
nickname: nullableString.optional()
|
|
18172
|
+
})
|
|
18173
|
+
});
|
|
18174
|
+
var communityFriendRequestSchema = exports_external.strictObject({
|
|
18175
|
+
type: exports_external.literal("community:friend.request"),
|
|
18176
|
+
friendship: exports_external.strictObject({
|
|
18177
|
+
id: string4,
|
|
18178
|
+
requesterId: string4,
|
|
18179
|
+
addresseeId: string4,
|
|
18180
|
+
status: exports_external.literal("pending"),
|
|
18181
|
+
createdAt: string4
|
|
18182
|
+
})
|
|
18183
|
+
});
|
|
18184
|
+
var friendshipIdFields = { friendshipId: string4 };
|
|
18185
|
+
var communityFriendAcceptSchema = exports_external.strictObject({
|
|
18186
|
+
type: exports_external.literal("community:friend.accept"),
|
|
18187
|
+
...friendshipIdFields
|
|
18188
|
+
});
|
|
18189
|
+
var communityFriendRejectSchema = exports_external.strictObject({
|
|
18190
|
+
type: exports_external.literal("community:friend.reject"),
|
|
18191
|
+
...friendshipIdFields
|
|
18192
|
+
});
|
|
18193
|
+
var communityFriendRemoveSchema = exports_external.strictObject({
|
|
18194
|
+
type: exports_external.literal("community:friend.remove"),
|
|
18195
|
+
...friendshipIdFields
|
|
18196
|
+
});
|
|
18197
|
+
var communityFriendBlockSchema = exports_external.strictObject({
|
|
18198
|
+
type: exports_external.literal("community:friend.block"),
|
|
18199
|
+
userId: string4
|
|
18200
|
+
});
|
|
18201
|
+
var communityInviteCreateSchema = exports_external.strictObject({
|
|
18202
|
+
type: exports_external.literal("community:invite.create"),
|
|
18203
|
+
serverId: string4,
|
|
18204
|
+
invite: exports_external.strictObject({
|
|
18205
|
+
id: string4,
|
|
18206
|
+
token: string4,
|
|
18207
|
+
maxUses: exports_external.number().nullable().optional(),
|
|
18208
|
+
uses: exports_external.number().nullable().optional(),
|
|
18209
|
+
expiresAt: nullableString.optional(),
|
|
18210
|
+
createdAt: string4
|
|
18211
|
+
})
|
|
18212
|
+
});
|
|
18213
|
+
var communityMentionCreateSchema = exports_external.strictObject({
|
|
18214
|
+
type: exports_external.literal("community:mention.create"),
|
|
18215
|
+
userId: string4,
|
|
18216
|
+
messageId: string4,
|
|
18217
|
+
channelId: string4.optional(),
|
|
18218
|
+
authorName: string4
|
|
18219
|
+
});
|
|
18220
|
+
var communityUnreadBumpSchema = exports_external.strictObject({
|
|
18221
|
+
type: exports_external.literal("community:unread.bump"),
|
|
18222
|
+
userId: string4,
|
|
18223
|
+
channelId: string4,
|
|
18224
|
+
serverId: string4.optional(),
|
|
18225
|
+
railChannelId: string4.optional(),
|
|
18226
|
+
isMention: exports_external.boolean().optional()
|
|
18227
|
+
});
|
|
18228
|
+
var communityPresenceUpdateSchema = exports_external.strictObject({
|
|
18229
|
+
type: exports_external.literal("community:presence.update"),
|
|
18230
|
+
userId: string4,
|
|
18231
|
+
online: exports_external.boolean()
|
|
18232
|
+
});
|
|
18233
|
+
var communityStatusUpdateSchema = exports_external.strictObject({
|
|
18234
|
+
type: exports_external.literal("community:status.update"),
|
|
18235
|
+
userId: string4,
|
|
18236
|
+
statusEmoji: nullableString,
|
|
18237
|
+
statusText: nullableString
|
|
18238
|
+
});
|
|
18239
|
+
var machineRuntimeSchema = CommunityMachineRuntimeSchema.strict();
|
|
18240
|
+
var CommunityMachineSummarySchema2 = exports_external.strictObject({
|
|
18241
|
+
id: string4,
|
|
18242
|
+
hostname: string4,
|
|
18243
|
+
displayName: string4,
|
|
18244
|
+
platform: string4,
|
|
18245
|
+
arch: string4,
|
|
18246
|
+
osRelease: string4,
|
|
18247
|
+
daemonVersion: string4,
|
|
18248
|
+
lastSeenAt: nullableString,
|
|
18249
|
+
status: exports_external.enum(["online", "offline"]),
|
|
18250
|
+
availableRuntimes: exports_external.array(machineRuntimeSchema),
|
|
18251
|
+
lastRuntimeError: exports_external.strictObject({
|
|
18252
|
+
requested: string4,
|
|
18253
|
+
available: exports_external.array(string4),
|
|
18254
|
+
at: string4
|
|
18255
|
+
}).optional(),
|
|
18256
|
+
createdAt: string4,
|
|
18257
|
+
updatedAt: string4
|
|
18258
|
+
});
|
|
18259
|
+
var communityMachineCreatedSchema = exports_external.strictObject({
|
|
18260
|
+
type: exports_external.literal("community:machine.created"),
|
|
18261
|
+
machine: CommunityMachineSummarySchema2,
|
|
18262
|
+
tokenId: string4
|
|
18263
|
+
});
|
|
18264
|
+
var communityMachineStatusSchema = exports_external.strictObject({
|
|
18265
|
+
type: exports_external.literal("community:machine.status"),
|
|
18266
|
+
machineId: string4,
|
|
18267
|
+
status: exports_external.enum(["online", "offline"]),
|
|
18268
|
+
lastSeenAt: string4
|
|
18269
|
+
});
|
|
18270
|
+
var communityMachineUpdatedSchema = exports_external.strictObject({
|
|
18271
|
+
type: exports_external.literal("community:machine.updated"),
|
|
18272
|
+
machine: CommunityMachineSummarySchema2
|
|
18273
|
+
});
|
|
18274
|
+
var communityMachineRemovedSchema = exports_external.strictObject({
|
|
18275
|
+
type: exports_external.literal("community:machine.removed"),
|
|
18276
|
+
machineId: string4
|
|
18277
|
+
});
|
|
18278
|
+
var communityBotAuditEventSchema = exports_external.strictObject({
|
|
18279
|
+
type: exports_external.literal("community:bot.audit_event"),
|
|
18280
|
+
botId: string4,
|
|
18281
|
+
id: string4,
|
|
18282
|
+
kind: exports_external.enum(["cli_invocation", "tool_call", "thinking", "wake_trigger", "session_reset", "nap", "model_changed", "provider_changed", "error"]),
|
|
18283
|
+
payload: exports_external.unknown(),
|
|
18284
|
+
sessionId: nullableString.optional(),
|
|
18285
|
+
launchId: nullableString.optional(),
|
|
18286
|
+
createdAt: string4
|
|
18287
|
+
}).refine((event) => Object.prototype.hasOwnProperty.call(event, "payload"));
|
|
18288
|
+
var CommunityWsEventDiscriminatedSchema = exports_external.discriminatedUnion("type", [
|
|
18289
|
+
communityMessageCreateSchema,
|
|
18290
|
+
communityMessageUpdatedSchema,
|
|
18291
|
+
communityMessageEditedSchema,
|
|
18292
|
+
communityReactionAddSchema,
|
|
18293
|
+
communityReactionRemoveSchema,
|
|
18294
|
+
communityPinAddSchema,
|
|
18295
|
+
communityPinRemoveSchema,
|
|
18296
|
+
communityTypingStartSchema,
|
|
18297
|
+
communityTypingStopSchema,
|
|
18298
|
+
communityChildChannelCreateSchema,
|
|
18299
|
+
communityChildChannelUpdateSchema,
|
|
18300
|
+
communityServerUpdateSchema,
|
|
18301
|
+
communityServerDeleteSchema,
|
|
18302
|
+
communityChannelCreateSchema,
|
|
18303
|
+
communityChannelUpdateSchema,
|
|
18304
|
+
communityChannelDeleteSchema,
|
|
18305
|
+
communityChannelReorderSchema,
|
|
18306
|
+
communityChannelMemberAddSchema,
|
|
18307
|
+
communityChannelMemberRemoveSchema,
|
|
18308
|
+
communityCategoryCreateSchema,
|
|
18309
|
+
communityCategoryUpdateSchema,
|
|
18310
|
+
communityCategoryDeleteSchema,
|
|
18311
|
+
communityCategoryReorderSchema,
|
|
18312
|
+
communityMemberJoinSchema,
|
|
18313
|
+
communityMemberLeaveSchema,
|
|
18314
|
+
communityMemberUpdateSchema,
|
|
18315
|
+
communityFriendRequestSchema,
|
|
18316
|
+
communityFriendAcceptSchema,
|
|
18317
|
+
communityFriendRejectSchema,
|
|
18318
|
+
communityFriendRemoveSchema,
|
|
18319
|
+
communityFriendBlockSchema,
|
|
18320
|
+
communityInviteCreateSchema,
|
|
18321
|
+
communityMentionCreateSchema,
|
|
18322
|
+
communityUnreadBumpSchema,
|
|
18323
|
+
communityPresenceUpdateSchema,
|
|
18324
|
+
communityStatusUpdateSchema,
|
|
18325
|
+
communityMachineCreatedSchema,
|
|
18326
|
+
communityMachineStatusSchema,
|
|
18327
|
+
communityMachineUpdatedSchema,
|
|
18328
|
+
communityMachineRemovedSchema,
|
|
18329
|
+
communityBotAuditEventSchema
|
|
18330
|
+
]);
|
|
18331
|
+
var CommunityWsEventSchema = CommunityWsEventDiscriminatedSchema.transform((event) => event);
|
|
18332
|
+
var WS_EVENTS = {
|
|
18333
|
+
MESSAGE_CREATE: "community:message.create",
|
|
18334
|
+
MESSAGE_UPDATED: "community:message.updated",
|
|
18335
|
+
MESSAGE_EDITED: "community:message.edited",
|
|
18336
|
+
REACTION_ADD: "community:reaction.add",
|
|
18337
|
+
REACTION_REMOVE: "community:reaction.remove",
|
|
18338
|
+
PIN_ADD: "community:pin.add",
|
|
18339
|
+
PIN_REMOVE: "community:pin.remove",
|
|
18340
|
+
TYPING_START: "community:typing.start",
|
|
18341
|
+
TYPING_STOP: "community:typing.stop",
|
|
18342
|
+
CHILD_CHANNEL_CREATE: "community:channel.child_create",
|
|
18343
|
+
CHILD_CHANNEL_UPDATE: "community:channel.child_update",
|
|
18344
|
+
SERVER_UPDATE: "community:server.update",
|
|
18345
|
+
SERVER_DELETE: "community:server.delete",
|
|
18346
|
+
CHANNEL_CREATE: "community:channel.create",
|
|
18347
|
+
CHANNEL_UPDATE: "community:channel.update",
|
|
18348
|
+
CHANNEL_DELETE: "community:channel.delete",
|
|
18349
|
+
CHANNEL_REORDER: "community:channel.reorder",
|
|
18350
|
+
CHANNEL_MEMBER_ADD: "community:channel.member_add",
|
|
18351
|
+
CHANNEL_MEMBER_REMOVE: "community:channel.member_remove",
|
|
18352
|
+
CATEGORY_CREATE: "community:category.create",
|
|
18353
|
+
CATEGORY_UPDATE: "community:category.update",
|
|
18354
|
+
CATEGORY_DELETE: "community:category.delete",
|
|
18355
|
+
CATEGORY_REORDER: "community:category.reorder",
|
|
18356
|
+
MEMBER_JOIN: "community:member.join",
|
|
18357
|
+
MEMBER_LEAVE: "community:member.leave",
|
|
18358
|
+
MEMBER_UPDATE: "community:member.update",
|
|
18359
|
+
FRIEND_REQUEST: "community:friend.request",
|
|
18360
|
+
FRIEND_ACCEPT: "community:friend.accept",
|
|
18361
|
+
FRIEND_REJECT: "community:friend.reject",
|
|
18362
|
+
FRIEND_REMOVE: "community:friend.remove",
|
|
18363
|
+
FRIEND_BLOCK: "community:friend.block",
|
|
18364
|
+
INVITE_CREATE: "community:invite.create",
|
|
18365
|
+
MENTION_CREATE: "community:mention.create",
|
|
18366
|
+
UNREAD_BUMP: "community:unread.bump",
|
|
18367
|
+
PRESENCE_UPDATE: "community:presence.update",
|
|
18368
|
+
STATUS_UPDATE: "community:status.update",
|
|
18369
|
+
MACHINE_CREATED: "community:machine.created",
|
|
18370
|
+
MACHINE_STATUS: "community:machine.status",
|
|
18371
|
+
MACHINE_UPDATED: "community:machine.updated",
|
|
18372
|
+
MACHINE_REMOVED: "community:machine.removed",
|
|
18373
|
+
BOT_AUDIT_EVENT: "community:bot.audit_event"
|
|
18374
|
+
};
|
|
18375
|
+
var COMMUNITY_EVENT_TYPES = new Set(Object.values(WS_EVENTS));
|
|
17709
18376
|
// ../shared/src/db/index.ts
|
|
17710
18377
|
var allSchema = { ...exports_schema, ...exports_community_schema, ...exports_community_machine_schema };
|
|
17711
18378
|
// ../shared/src/db/queries/task.ts
|
|
@@ -17735,13 +18402,8 @@ function toAlookAddress(h) {
|
|
|
17735
18402
|
}
|
|
17736
18403
|
// ../shared/src/db/queries/community/search.ts
|
|
17737
18404
|
var FTS_KEYWORDS = new Set(["and", "or", "not", "near"]);
|
|
17738
|
-
// ../shared/src/db/queries/community/
|
|
17739
|
-
var
|
|
17740
|
-
BOT_ACTIVITY_PRESETS.idle,
|
|
17741
|
-
BOT_ACTIVITY_PRESETS.starting,
|
|
17742
|
-
BOT_ACTIVITY_PRESETS.stopping,
|
|
17743
|
-
...RUNNING_PRESETS
|
|
17744
|
-
];
|
|
18405
|
+
// ../shared/src/db/queries/community/server-folder.ts
|
|
18406
|
+
var FOLDER_ITEM_INSERT_MAX_ROWS = maxRowsPerInsert(3);
|
|
17745
18407
|
// ../shared/src/semver.ts
|
|
17746
18408
|
function semverGte(a, b) {
|
|
17747
18409
|
const pa = a.split(".").map(Number);
|
|
@@ -18157,10 +18819,10 @@ class Logger2 {
|
|
|
18157
18819
|
function createLogger2(opts) {
|
|
18158
18820
|
return new Logger2(opts);
|
|
18159
18821
|
}
|
|
18160
|
-
var
|
|
18822
|
+
var log2 = createLogger2();
|
|
18161
18823
|
|
|
18162
18824
|
// daemon/pidfile.ts
|
|
18163
|
-
var
|
|
18825
|
+
var log3 = createLogger2({ module: "pidfile" });
|
|
18164
18826
|
function isProcessAlive(pid) {
|
|
18165
18827
|
try {
|
|
18166
18828
|
process.kill(pid, 0);
|
|
@@ -18184,7 +18846,7 @@ function acquireDaemonPid(profile) {
|
|
|
18184
18846
|
const content = readFileSync3(pidPath, "utf-8").trim();
|
|
18185
18847
|
const existingPid = parseInt(content, 10);
|
|
18186
18848
|
if (!isNaN(existingPid) && isProcessAlive(existingPid)) {
|
|
18187
|
-
|
|
18849
|
+
log3.error(`Another daemon is already running (PID ${existingPid}). ` + `Remove ${pidPath} if this is stale.`);
|
|
18188
18850
|
return false;
|
|
18189
18851
|
}
|
|
18190
18852
|
} catch {}
|
|
@@ -18362,7 +19024,7 @@ import { createInterface } from "readline";
|
|
|
18362
19024
|
|
|
18363
19025
|
// daemon/kill-tree.ts
|
|
18364
19026
|
import { execSync } from "child_process";
|
|
18365
|
-
var
|
|
19027
|
+
var log4 = createLogger2({ module: "kill-tree" });
|
|
18366
19028
|
function killGraceMs() {
|
|
18367
19029
|
return Number(process.env.ALOOK_KILL_GRACE_MS) || 2000;
|
|
18368
19030
|
}
|
|
@@ -18408,7 +19070,7 @@ async function killProcessTree(pid, opts) {
|
|
|
18408
19070
|
await new Promise((r) => setTimeout(r, POLL_MS));
|
|
18409
19071
|
}
|
|
18410
19072
|
if (isAlive(pid)) {
|
|
18411
|
-
|
|
19073
|
+
log4.warn(`pid=${pid} survived SIGTERM after ${graceMs}ms — escalating to SIGKILL`);
|
|
18412
19074
|
signalTree(pid, "SIGKILL");
|
|
18413
19075
|
}
|
|
18414
19076
|
}
|
|
@@ -18663,8 +19325,8 @@ class ClaudeBackend {
|
|
|
18663
19325
|
};
|
|
18664
19326
|
const resultPromise = new Promise((resolve) => {
|
|
18665
19327
|
const stderrChunks = [];
|
|
18666
|
-
proc.stderr?.on("data", (
|
|
18667
|
-
stderrChunks.push(
|
|
19328
|
+
proc.stderr?.on("data", (chunk2) => {
|
|
19329
|
+
stderrChunks.push(chunk2.toString());
|
|
18668
19330
|
});
|
|
18669
19331
|
const rl = createInterface({ input: proc.stdout });
|
|
18670
19332
|
if (useStdinPrompt) {
|
|
@@ -19474,8 +20136,8 @@ class CodexBackend {
|
|
|
19474
20136
|
};
|
|
19475
20137
|
const resultPromise = new Promise((resolve) => {
|
|
19476
20138
|
const stderrChunks = [];
|
|
19477
|
-
proc.stderr?.on("data", (
|
|
19478
|
-
stderrChunks.push(
|
|
20139
|
+
proc.stderr?.on("data", (chunk2) => {
|
|
20140
|
+
stderrChunks.push(chunk2.toString());
|
|
19479
20141
|
});
|
|
19480
20142
|
const rl = createInterface2({ input: proc.stdout });
|
|
19481
20143
|
rl.on("line", (line) => {
|
|
@@ -19871,8 +20533,8 @@ class OpenCodeBackend {
|
|
|
19871
20533
|
};
|
|
19872
20534
|
const resultPromise = new Promise((resolve) => {
|
|
19873
20535
|
const stderrChunks = [];
|
|
19874
|
-
proc.stderr?.on("data", (
|
|
19875
|
-
stderrChunks.push(
|
|
20536
|
+
proc.stderr?.on("data", (chunk2) => {
|
|
20537
|
+
stderrChunks.push(chunk2.toString());
|
|
19876
20538
|
});
|
|
19877
20539
|
const rl = createInterface3({ input: proc.stdout });
|
|
19878
20540
|
rl.on("line", (line) => {
|
|
@@ -20615,7 +21277,7 @@ function releaseLock(lockPath) {
|
|
|
20615
21277
|
}
|
|
20616
21278
|
|
|
20617
21279
|
// daemon/execenv/timeline.ts
|
|
20618
|
-
var
|
|
21280
|
+
var log5 = createLogger2({ module: "timeline" });
|
|
20619
21281
|
function readJsonl(filePath) {
|
|
20620
21282
|
let content;
|
|
20621
21283
|
try {
|
|
@@ -20684,7 +21346,7 @@ async function initEntryAsync(timelineDir, entry) {
|
|
|
20684
21346
|
acquired = acquireLock(lockPath);
|
|
20685
21347
|
}
|
|
20686
21348
|
if (!acquired) {
|
|
20687
|
-
|
|
21349
|
+
log5.debug(`Timeline initEntry: could not acquire lock for ${filename}`);
|
|
20688
21350
|
return;
|
|
20689
21351
|
}
|
|
20690
21352
|
try {
|
|
@@ -20694,7 +21356,7 @@ async function initEntryAsync(timelineDir, entry) {
|
|
|
20694
21356
|
releaseLock(lockPath);
|
|
20695
21357
|
}
|
|
20696
21358
|
} catch (err) {
|
|
20697
|
-
|
|
21359
|
+
log5.debug("Timeline initEntry failed", err);
|
|
20698
21360
|
}
|
|
20699
21361
|
}
|
|
20700
21362
|
function updateEntry(timelineDir, taskId, updater) {
|
|
@@ -20704,7 +21366,7 @@ function updateEntry(timelineDir, taskId, updater) {
|
|
|
20704
21366
|
try {
|
|
20705
21367
|
const acquired = acquireLock(lockPath);
|
|
20706
21368
|
if (!acquired) {
|
|
20707
|
-
|
|
21369
|
+
log5.debug(`Timeline updateEntry: lock held for ${filename}, skipping`);
|
|
20708
21370
|
continue;
|
|
20709
21371
|
}
|
|
20710
21372
|
try {
|
|
@@ -20737,10 +21399,10 @@ function updateEntry(timelineDir, taskId, updater) {
|
|
|
20737
21399
|
releaseLock(lockPath);
|
|
20738
21400
|
}
|
|
20739
21401
|
} catch (err) {
|
|
20740
|
-
|
|
21402
|
+
log5.debug(`Timeline updateEntry failed for ${filename}`, err);
|
|
20741
21403
|
}
|
|
20742
21404
|
}
|
|
20743
|
-
|
|
21405
|
+
log5.debug(`Timeline updateEntry: task_id ${taskId} not found in last 7 days`);
|
|
20744
21406
|
}
|
|
20745
21407
|
function createTimelineEntry(taskId, prompt, type, sessionId, pid, provider, contextKey, detailedLog) {
|
|
20746
21408
|
return {
|
|
@@ -20809,7 +21471,7 @@ function findSupersedablePredecessor(timelineDir, contextKey, provider, warmupGr
|
|
|
20809
21471
|
// daemon/execenv/steering.ts
|
|
20810
21472
|
import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync5, readFileSync as readFileSync6, unlinkSync as unlinkSync3, readdirSync, statSync as statSync2 } from "fs";
|
|
20811
21473
|
import { join as join8 } from "path";
|
|
20812
|
-
var
|
|
21474
|
+
var log6 = createLogger2({ module: "steering" });
|
|
20813
21475
|
var INTENT_DIR_NAME = ".kill_intents";
|
|
20814
21476
|
var STEERING_LOCK_DIR = ".steering_locks";
|
|
20815
21477
|
var INTENT_STALE_MS = 10 * 60 * 1000;
|
|
@@ -20863,7 +21525,7 @@ function cleanupStaleIntents(baseDir) {
|
|
|
20863
21525
|
const stat = statSync2(filePath);
|
|
20864
21526
|
if (now - stat.mtimeMs > INTENT_STALE_MS) {
|
|
20865
21527
|
unlinkSync3(filePath);
|
|
20866
|
-
|
|
21528
|
+
log6.debug(`Cleaned up stale kill intent for task ${intent.targetTaskId}`);
|
|
20867
21529
|
}
|
|
20868
21530
|
} catch {}
|
|
20869
21531
|
}
|
|
@@ -20883,7 +21545,7 @@ function releaseSteeringLock(baseDir, contextKey) {
|
|
|
20883
21545
|
// daemon/steering/mailbox.ts
|
|
20884
21546
|
import { mkdirSync as mkdirSync6, writeFileSync as writeFileSync6, readFileSync as readFileSync7, renameSync as renameSync2, readdirSync as readdirSync2, unlinkSync as unlinkSync4, rmSync, existsSync as existsSync2, watch } from "fs";
|
|
20885
21547
|
import { join as join9 } from "path";
|
|
20886
|
-
var
|
|
21548
|
+
var log7 = createLogger2({ module: "mailbox" });
|
|
20887
21549
|
function inboxDir(baseDir, contextKey) {
|
|
20888
21550
|
const safeKey = contextKey.replace(/[^a-zA-Z0-9_:-]/g, "_");
|
|
20889
21551
|
return join9(baseDir, ".steering", safeKey, "inbox");
|
|
@@ -21013,7 +21675,7 @@ function watchInbox(baseDir, contextKey, onMessage) {
|
|
|
21013
21675
|
scan();
|
|
21014
21676
|
});
|
|
21015
21677
|
} catch {
|
|
21016
|
-
|
|
21678
|
+
log7.debug("fs.watch failed, relying on polling only");
|
|
21017
21679
|
}
|
|
21018
21680
|
const pollTimer = setInterval(scan, 200);
|
|
21019
21681
|
return {
|
|
@@ -21661,7 +22323,7 @@ function buildMergedPrompt(tasks, attachmentsMap) {
|
|
|
21661
22323
|
}
|
|
21662
22324
|
|
|
21663
22325
|
// daemon/session-runner.ts
|
|
21664
|
-
var
|
|
22326
|
+
var log8 = createLogger2({ module: "session-runner" });
|
|
21665
22327
|
var ATTACHMENTS_BASE = tempDir("alook-attachments");
|
|
21666
22328
|
async function writeMarkerFile(workspacesRoot, marker) {
|
|
21667
22329
|
const dir = path.join(workspacesRoot, ".pending_completions");
|
|
@@ -21709,20 +22371,20 @@ async function reportToServer(fn, markerData, workspacesRoot) {
|
|
|
21709
22371
|
} catch (e) {
|
|
21710
22372
|
lastErr = e;
|
|
21711
22373
|
if (isClientError(e)) {
|
|
21712
|
-
|
|
22374
|
+
log8.info(`server report for task ${markerData.taskId}: task already in terminal state (${e})`);
|
|
21713
22375
|
return;
|
|
21714
22376
|
}
|
|
21715
22377
|
if (attempt < RETRY_DELAYS.length && isRetryableError(e)) {
|
|
21716
|
-
|
|
22378
|
+
log8.debug(`server report attempt ${attempt + 1} failed for task ${markerData.taskId}, retrying in ${RETRY_DELAYS[attempt]}ms`);
|
|
21717
22379
|
await new Promise((r) => setTimeout(r, RETRY_DELAYS[attempt]));
|
|
21718
22380
|
}
|
|
21719
22381
|
}
|
|
21720
22382
|
}
|
|
21721
|
-
|
|
22383
|
+
log8.warn(`server report failed for task ${markerData.taskId} after retries, writing marker: ${lastErr}`);
|
|
21722
22384
|
try {
|
|
21723
22385
|
await writeMarkerFile(workspacesRoot, markerData);
|
|
21724
22386
|
} catch (writeErr) {
|
|
21725
|
-
|
|
22387
|
+
log8.error(`marker write also failed for task ${markerData.taskId}: ${writeErr}`);
|
|
21726
22388
|
}
|
|
21727
22389
|
}
|
|
21728
22390
|
function sanitizeFilename(name) {
|
|
@@ -21753,7 +22415,7 @@ async function downloadAttachments(client, token, workspaceId, taskId, attachmen
|
|
|
21753
22415
|
}
|
|
21754
22416
|
async function runSession(input) {
|
|
21755
22417
|
const { task, provider, cliPath, model, serverURL, token, workspacesRoot, agentTimeout, messageInactivityTimeout } = input;
|
|
21756
|
-
|
|
22418
|
+
log8.info(`starting (task=${task.id}, type=${task.type}, agent=${task.agentId}, provider=${provider}, model=${model || "default"})`);
|
|
21757
22419
|
const client = new DaemonClient(serverURL);
|
|
21758
22420
|
const backend = createBackend(provider, cliPath);
|
|
21759
22421
|
const agentBaseDir = path.join(workspacesRoot, task.workspaceId, task.agentId, "workdir");
|
|
@@ -21776,7 +22438,7 @@ async function runSession(input) {
|
|
|
21776
22438
|
try {
|
|
21777
22439
|
await client.reportMessages(token, task.id, batch);
|
|
21778
22440
|
} catch (e) {
|
|
21779
|
-
|
|
22441
|
+
log8.debug("message report failed", e);
|
|
21780
22442
|
}
|
|
21781
22443
|
};
|
|
21782
22444
|
let mailboxWatcher = null;
|
|
@@ -21785,13 +22447,13 @@ async function runSession(input) {
|
|
|
21785
22447
|
if (killed)
|
|
21786
22448
|
return;
|
|
21787
22449
|
killed = true;
|
|
21788
|
-
|
|
22450
|
+
log8.info(`killed by signal (messages=${seq}, tools=${toolCount})`);
|
|
21789
22451
|
if (mailboxWatcher)
|
|
21790
22452
|
mailboxWatcher.stop();
|
|
21791
22453
|
if (stalledRecoveryTimer)
|
|
21792
22454
|
clearInterval(stalledRecoveryTimer);
|
|
21793
22455
|
if (agentPid !== undefined) {
|
|
21794
|
-
|
|
22456
|
+
log8.info(`killing inner agent group (pid=${agentPid})`);
|
|
21795
22457
|
await killProcessTree(agentPid);
|
|
21796
22458
|
}
|
|
21797
22459
|
if (flushTimer)
|
|
@@ -21834,14 +22496,14 @@ async function runSession(input) {
|
|
|
21834
22496
|
const attachmentIds = task.context?.attachment_ids ?? [];
|
|
21835
22497
|
let attachments;
|
|
21836
22498
|
if (attachmentIds.length > 0) {
|
|
21837
|
-
|
|
22499
|
+
log8.info(`downloading ${attachmentIds.length} attachment(s)`);
|
|
21838
22500
|
try {
|
|
21839
22501
|
attachments = await downloadAttachments(client, token, task.workspaceId, task.id, attachmentIds);
|
|
21840
|
-
|
|
22502
|
+
log8.info(`attachments ready (${attachments.length} file(s))`);
|
|
21841
22503
|
} catch (e) {
|
|
21842
22504
|
await cleanupAttachments(task.id);
|
|
21843
22505
|
const errMsg = `failed to download attachments: ${e}`;
|
|
21844
|
-
|
|
22506
|
+
log8.error(errMsg);
|
|
21845
22507
|
updateEntry(timelineDir, task.id, (entry) => {
|
|
21846
22508
|
entry.pid = null;
|
|
21847
22509
|
entry.status = "failed";
|
|
@@ -21858,7 +22520,7 @@ async function runSession(input) {
|
|
|
21858
22520
|
const prompt = input.promptOverride ?? buildPrompt(task, attachments);
|
|
21859
22521
|
const resumeSessionId = task.contextKey ? findResumableSessionByContextKey(timelineDir, task.contextKey, provider) ?? undefined : undefined;
|
|
21860
22522
|
if (resumeSessionId) {
|
|
21861
|
-
|
|
22523
|
+
log8.info(`resuming session ${resumeSessionId} (context_key: ${task.contextKey})`);
|
|
21862
22524
|
}
|
|
21863
22525
|
const session2 = backend.execute(prompt, {
|
|
21864
22526
|
cwd: workDir,
|
|
@@ -21871,14 +22533,14 @@ async function runSession(input) {
|
|
|
21871
22533
|
agentPid = session2.pid;
|
|
21872
22534
|
if (killed) {
|
|
21873
22535
|
if (agentPid !== undefined) {
|
|
21874
|
-
|
|
22536
|
+
log8.info(`kill landed during spawn — reaping inner agent group (pid=${agentPid})`);
|
|
21875
22537
|
await killProcessTree(agentPid);
|
|
21876
22538
|
}
|
|
21877
22539
|
process.exit(1);
|
|
21878
22540
|
}
|
|
21879
22541
|
const earlySessionId = await session2.sessionId;
|
|
21880
|
-
|
|
21881
|
-
|
|
22542
|
+
log8.info(`agent started (pid=${agentPid ?? "unknown"}, session=${earlySessionId})`);
|
|
22543
|
+
log8.info(JSON.stringify({ role: "user", type: "text", content: prompt }));
|
|
21882
22544
|
updateEntry(timelineDir, task.id, (entry) => {
|
|
21883
22545
|
entry.session_id = earlySessionId || null;
|
|
21884
22546
|
if (earlySessionId)
|
|
@@ -21910,7 +22572,7 @@ async function runSession(input) {
|
|
|
21910
22572
|
apmState = recentResult.nextState;
|
|
21911
22573
|
if (event.kind === "error") {
|
|
21912
22574
|
const classified = classifyRuntimeError(event.message);
|
|
21913
|
-
|
|
22575
|
+
log8.info(`steering: error classified as ${classified.errorClass}: ${scrubDiagnosticText(event.message)}`);
|
|
21914
22576
|
const errResult = reduceApmGatedError(apmState, { disableToolBoundaryFlush: true });
|
|
21915
22577
|
apmState = errResult.nextState;
|
|
21916
22578
|
}
|
|
@@ -22018,7 +22680,7 @@ async function runSession(input) {
|
|
|
22018
22680
|
for (const msg of apmState.pendingMessages) {
|
|
22019
22681
|
const sendResult = session2.send(msg, eff.stdinMode);
|
|
22020
22682
|
if (!sendResult.ok) {
|
|
22021
|
-
|
|
22683
|
+
log8.warn("steering: send failed during turn_end flush", { reason: sendResult.reason });
|
|
22022
22684
|
allSent = false;
|
|
22023
22685
|
break;
|
|
22024
22686
|
}
|
|
@@ -22039,7 +22701,7 @@ async function runSession(input) {
|
|
|
22039
22701
|
if (flushedOk || apmState.pendingMessages.length === 0) {
|
|
22040
22702
|
for (const steeredId of pendingSteeredTasks) {
|
|
22041
22703
|
client.completeTask(token, steeredId, { output: "" }).catch((e) => {
|
|
22042
|
-
|
|
22704
|
+
log8.debug(`steering: failed to complete steered task ${steeredId}`, e);
|
|
22043
22705
|
});
|
|
22044
22706
|
}
|
|
22045
22707
|
pendingSteeredTasks.clear();
|
|
@@ -22050,11 +22712,11 @@ async function runSession(input) {
|
|
|
22050
22712
|
}
|
|
22051
22713
|
}
|
|
22052
22714
|
} catch (err) {
|
|
22053
|
-
|
|
22715
|
+
log8.warn("steering: consumeParsedEvents error", { err: err instanceof Error ? err.message : String(err) });
|
|
22054
22716
|
}
|
|
22055
22717
|
};
|
|
22056
22718
|
consumeParsedEvents().catch((err) => {
|
|
22057
|
-
|
|
22719
|
+
log8.error("steering: consumeParsedEvents unhandled error", { err: err instanceof Error ? err.message : String(err) });
|
|
22058
22720
|
});
|
|
22059
22721
|
}
|
|
22060
22722
|
stalledRecoveryTimer = setInterval(() => {
|
|
@@ -22066,7 +22728,7 @@ async function runSession(input) {
|
|
|
22066
22728
|
});
|
|
22067
22729
|
apmState = startupResult.nextState;
|
|
22068
22730
|
if (startupResult.shouldTerminate) {
|
|
22069
|
-
|
|
22731
|
+
log8.warn("steering: startup timeout — no progress events received, killing agent");
|
|
22070
22732
|
if (agentPid !== undefined)
|
|
22071
22733
|
killProcessTree(agentPid);
|
|
22072
22734
|
return;
|
|
@@ -22087,7 +22749,7 @@ async function runSession(input) {
|
|
|
22087
22749
|
});
|
|
22088
22750
|
apmState = stalledResult.nextState;
|
|
22089
22751
|
if (stalledResult.shouldTerminate) {
|
|
22090
|
-
|
|
22752
|
+
log8.warn(`steering: stalled recovery — agent stale for ${(staleForMs / 1000).toFixed(1)}s with ${apmState.pendingMessages.length} pending messages, killing`);
|
|
22091
22753
|
if (agentPid !== undefined)
|
|
22092
22754
|
killProcessTree(agentPid);
|
|
22093
22755
|
}
|
|
@@ -22147,7 +22809,7 @@ async function runSession(input) {
|
|
|
22147
22809
|
if (delivered && message2.taskId) {
|
|
22148
22810
|
pendingSteeredTasks.add(message2.taskId);
|
|
22149
22811
|
client.startTask(token, message2.taskId).catch((e) => {
|
|
22150
|
-
|
|
22812
|
+
log8.debug(`steering: failed to start steered task ${message2.taskId}`, e);
|
|
22151
22813
|
});
|
|
22152
22814
|
}
|
|
22153
22815
|
cleanupInboxFile(agentBaseDir, task.contextKey, seq2);
|
|
@@ -22168,7 +22830,7 @@ async function runSession(input) {
|
|
|
22168
22830
|
]) : next);
|
|
22169
22831
|
if (raceResult === "timeout") {
|
|
22170
22832
|
inactivityTimedOut = true;
|
|
22171
|
-
|
|
22833
|
+
log8.warn(`message inactivity timeout (${INACTIVITY_TIMEOUT_MS / 1000}s) — killing agent`);
|
|
22172
22834
|
if (session2.pid !== undefined) {
|
|
22173
22835
|
await killProcessTree(session2.pid);
|
|
22174
22836
|
}
|
|
@@ -22183,9 +22845,9 @@ async function runSession(input) {
|
|
|
22183
22845
|
if (msg.type === "tool-use")
|
|
22184
22846
|
toolCount++;
|
|
22185
22847
|
if (msg.type === "tool-result" && msg.output && msg.output.length > 500) {
|
|
22186
|
-
|
|
22848
|
+
log8.info(JSON.stringify({ role: "assistant", ...msg, output: msg.output.slice(0, 500) + `... (${msg.output.length} chars)` }));
|
|
22187
22849
|
} else {
|
|
22188
|
-
|
|
22850
|
+
log8.info(JSON.stringify({ role: "assistant", ...msg }));
|
|
22189
22851
|
}
|
|
22190
22852
|
if (msg.type === "status" || msg.type === "log")
|
|
22191
22853
|
continue;
|
|
@@ -22253,18 +22915,18 @@ async function runSession(input) {
|
|
|
22253
22915
|
body.session_id = result.sessionId;
|
|
22254
22916
|
await reportToServer(() => client.completeTask(token, task.id, body), { taskId: task.id, type: "complete", payload: body, token, serverURL, createdAt: new Date().toISOString() }, workspacesRoot);
|
|
22255
22917
|
const dur = (result.durationMs / 1000).toFixed(1);
|
|
22256
|
-
|
|
22918
|
+
log8.info(`completed (duration=${dur}s, messages=${seq}, tools=${toolCount})`);
|
|
22257
22919
|
} else {
|
|
22258
22920
|
const errorMsg = result.error || "agent exited unexpectedly";
|
|
22259
22921
|
await reportToServer(() => client.failTask(token, task.id, errorMsg), { taskId: task.id, type: "fail", payload: { error: errorMsg }, token, serverURL, createdAt: new Date().toISOString() }, workspacesRoot);
|
|
22260
22922
|
const dur = (result.durationMs / 1000).toFixed(1);
|
|
22261
|
-
|
|
22923
|
+
log8.info(`failed (duration=${dur}s, messages=${seq}, tools=${toolCount}) — ${result.error}`);
|
|
22262
22924
|
}
|
|
22263
22925
|
}
|
|
22264
22926
|
async function main() {
|
|
22265
22927
|
const encoded = process.argv[2];
|
|
22266
22928
|
if (!encoded) {
|
|
22267
|
-
|
|
22929
|
+
log8.error("session-runner: missing base64-encoded input argument");
|
|
22268
22930
|
process.exit(1);
|
|
22269
22931
|
}
|
|
22270
22932
|
let input;
|
|
@@ -22272,14 +22934,14 @@ async function main() {
|
|
|
22272
22934
|
const json2 = Buffer.from(encoded, "base64").toString("utf-8");
|
|
22273
22935
|
input = JSON.parse(json2);
|
|
22274
22936
|
} catch (e) {
|
|
22275
|
-
|
|
22937
|
+
log8.error("session-runner: failed to parse input", e);
|
|
22276
22938
|
process.exit(1);
|
|
22277
22939
|
}
|
|
22278
22940
|
const client = new DaemonClient(input.serverURL);
|
|
22279
22941
|
try {
|
|
22280
22942
|
await runSession(input);
|
|
22281
22943
|
} catch (e) {
|
|
22282
|
-
|
|
22944
|
+
log8.error(`session-runner: unhandled error for task ${input.task.id}`, e);
|
|
22283
22945
|
await cleanupAttachments(input.task.id);
|
|
22284
22946
|
const timelineDir = path.join(input.workspacesRoot, input.task.workspaceId, input.task.agentId, "workdir", ".context_timeline").replace(/\\/g, "/");
|
|
22285
22947
|
updateEntry(timelineDir, input.task.id, (entry) => {
|
|
@@ -22298,7 +22960,7 @@ if (isDirectExecution) {
|
|
|
22298
22960
|
}
|
|
22299
22961
|
|
|
22300
22962
|
// daemon/ws-client.ts
|
|
22301
|
-
var
|
|
22963
|
+
var log9 = createLogger2({ module: "ws-client" });
|
|
22302
22964
|
var WS_RECONNECT_INIT = 1000;
|
|
22303
22965
|
var WS_RECONNECT_MAX = 30000;
|
|
22304
22966
|
var WS_PING_INTERVAL = 25000;
|
|
@@ -22335,11 +22997,11 @@ class DaemonWsClient {
|
|
|
22335
22997
|
return;
|
|
22336
22998
|
this.cleanup();
|
|
22337
22999
|
const wsUrl = this.getUrl();
|
|
22338
|
-
|
|
23000
|
+
log9.info("connecting", { url: wsUrl });
|
|
22339
23001
|
try {
|
|
22340
23002
|
this.ws = new WebSocket(wsUrl);
|
|
22341
23003
|
} catch (err) {
|
|
22342
|
-
|
|
23004
|
+
log9.warn("ws creation failed", { err: String(err) });
|
|
22343
23005
|
this.scheduleReconnect();
|
|
22344
23006
|
return;
|
|
22345
23007
|
}
|
|
@@ -22361,36 +23023,36 @@ class DaemonWsClient {
|
|
|
22361
23023
|
try {
|
|
22362
23024
|
const msg = JSON.parse(str);
|
|
22363
23025
|
if (msg.type === "auth.ok") {
|
|
22364
|
-
|
|
23026
|
+
log9.info("authenticated");
|
|
22365
23027
|
this.connected = true;
|
|
22366
23028
|
this.opts.onConnected();
|
|
22367
23029
|
return;
|
|
22368
23030
|
}
|
|
22369
23031
|
if (msg.type === "error" && msg.code === "AUTH_REJECTED") {
|
|
22370
|
-
|
|
23032
|
+
log9.warn("machine token rejected by server (AUTH_REJECTED)", { reason: msg.reason });
|
|
22371
23033
|
this.opts.onAuthRejected?.(msg.reason);
|
|
22372
23034
|
return;
|
|
22373
23035
|
}
|
|
22374
23036
|
const parsed = DaemonPushMessageSchema.safeParse(msg);
|
|
22375
23037
|
if (!parsed.success) {
|
|
22376
|
-
|
|
23038
|
+
log9.warn("invalid push message", { err: parsed.error.message });
|
|
22377
23039
|
return;
|
|
22378
23040
|
}
|
|
22379
23041
|
this.opts.onMessage(parsed.data);
|
|
22380
23042
|
} catch (err) {
|
|
22381
|
-
|
|
23043
|
+
log9.debug("message parse error", { err: String(err) });
|
|
22382
23044
|
}
|
|
22383
23045
|
});
|
|
22384
23046
|
this.ws.addEventListener("error", (event) => {
|
|
22385
23047
|
const err = event;
|
|
22386
|
-
|
|
23048
|
+
log9.warn("ws error", { err: String(err?.message ?? err?.error ?? "unknown") });
|
|
22387
23049
|
});
|
|
22388
23050
|
this.ws.addEventListener("close", (event) => {
|
|
22389
23051
|
const { code, reason } = event;
|
|
22390
23052
|
const wasConnected = this.connected;
|
|
22391
23053
|
this.connected = false;
|
|
22392
23054
|
this.stopHeartbeat();
|
|
22393
|
-
|
|
23055
|
+
log9.info("ws closed", { code, reason, wasConnected });
|
|
22394
23056
|
if (wasConnected) {
|
|
22395
23057
|
this.opts.onDisconnected();
|
|
22396
23058
|
}
|
|
@@ -22423,7 +23085,7 @@ class DaemonWsClient {
|
|
|
22423
23085
|
const delay = Math.min(this.reconnectDelay, WS_RECONNECT_MAX);
|
|
22424
23086
|
this.reconnectDelay = Math.min(delay * 2, WS_RECONNECT_MAX);
|
|
22425
23087
|
const jitter = Math.random() * 500;
|
|
22426
|
-
|
|
23088
|
+
log9.info("reconnecting", { delayMs: Math.round(delay + jitter) });
|
|
22427
23089
|
this.reconnectTimer = setTimeout(() => {
|
|
22428
23090
|
this.reconnectTimer = null;
|
|
22429
23091
|
this.connect();
|
|
@@ -22437,7 +23099,7 @@ class DaemonWsClient {
|
|
|
22437
23099
|
}, WS_PING_INTERVAL);
|
|
22438
23100
|
this.livenessInterval = setInterval(() => {
|
|
22439
23101
|
if (Date.now() - this.lastMessageAt > WS_LIVENESS_TIMEOUT) {
|
|
22440
|
-
|
|
23102
|
+
log9.warn("liveness timeout, closing");
|
|
22441
23103
|
this.ws?.close();
|
|
22442
23104
|
}
|
|
22443
23105
|
}, 5000);
|
|
@@ -22485,7 +23147,7 @@ function runNpmUpdate(targetVersion) {
|
|
|
22485
23147
|
}
|
|
22486
23148
|
|
|
22487
23149
|
// daemon/update-handler.ts
|
|
22488
|
-
var
|
|
23150
|
+
var log10 = createLogger2({ module: "updater" });
|
|
22489
23151
|
var updating = false;
|
|
22490
23152
|
var retryCount = 0;
|
|
22491
23153
|
var MAX_RETRIES = 3;
|
|
@@ -22515,29 +23177,29 @@ async function handleCliUpdate(version3, onSuccess, profile) {
|
|
|
22515
23177
|
if (retryCount >= MAX_RETRIES)
|
|
22516
23178
|
return;
|
|
22517
23179
|
if (process.env.ALOOK_CMD_PREFIX) {
|
|
22518
|
-
|
|
23180
|
+
log10.info(`Skipping auto-update in app mode — user should run: npx @alook/app@latest update`);
|
|
22519
23181
|
return;
|
|
22520
23182
|
}
|
|
22521
23183
|
const marker = readUpdateMarker(profile);
|
|
22522
23184
|
if (marker === version3) {
|
|
22523
|
-
|
|
23185
|
+
log10.info(`Skipping update to v${version3} — already attempted (marker exists)`);
|
|
22524
23186
|
return;
|
|
22525
23187
|
}
|
|
22526
23188
|
updating = true;
|
|
22527
23189
|
try {
|
|
22528
|
-
|
|
23190
|
+
log10.info(`Updating CLI to v${version3}...`);
|
|
22529
23191
|
const result = await runNpmUpdate(version3);
|
|
22530
23192
|
if (result.success) {
|
|
22531
23193
|
writeUpdateMarker(version3, profile);
|
|
22532
|
-
|
|
23194
|
+
log10.info(`CLI updated to v${version3} — restarting`);
|
|
22533
23195
|
onSuccess();
|
|
22534
23196
|
} else {
|
|
22535
23197
|
retryCount++;
|
|
22536
|
-
|
|
23198
|
+
log10.error(`CLI update failed (attempt ${retryCount}/${MAX_RETRIES}): ${result.output}`);
|
|
22537
23199
|
}
|
|
22538
23200
|
} catch (e) {
|
|
22539
23201
|
retryCount++;
|
|
22540
|
-
|
|
23202
|
+
log10.error(`CLI update error (attempt ${retryCount}/${MAX_RETRIES})`, e);
|
|
22541
23203
|
} finally {
|
|
22542
23204
|
updating = false;
|
|
22543
23205
|
}
|
|
@@ -22646,7 +23308,7 @@ import { existsSync as existsSync3, mkdirSync as mkdirSync8, readFileSync as rea
|
|
|
22646
23308
|
import { join as join11, basename } from "path";
|
|
22647
23309
|
import { homedir as homedir2 } from "os";
|
|
22648
23310
|
import { createHash as createHash2 } from "crypto";
|
|
22649
|
-
var
|
|
23311
|
+
var log11 = createLogger2({ module: "skill-scanner" });
|
|
22650
23312
|
function getCacheDir() {
|
|
22651
23313
|
return join11(configDir(), "skills");
|
|
22652
23314
|
}
|
|
@@ -22942,7 +23604,7 @@ function runScan() {
|
|
|
22942
23604
|
const prevHash = readCacheHash(globalCachePath(scannerConfig.daemonId, runtime));
|
|
22943
23605
|
if (prevHash !== hash2) {
|
|
22944
23606
|
const skillItems = skills.map((s) => ({ name: s.name, description: s.description }));
|
|
22945
|
-
|
|
23607
|
+
log11.debug(`Syncing global ${runtime} — ${skills.length} skills`);
|
|
22946
23608
|
const daemonId = scannerConfig.daemonId;
|
|
22947
23609
|
const syncPromises = scannerConfig.workspaces.map((ws) => clientRef.syncSkills(ws.token, {
|
|
22948
23610
|
scope: "global",
|
|
@@ -22956,11 +23618,11 @@ function runScan() {
|
|
|
22956
23618
|
if (isClientError2(e)) {
|
|
22957
23619
|
writeCacheFile(globalCachePath(daemonId, runtime), hash2, skills);
|
|
22958
23620
|
}
|
|
22959
|
-
|
|
23621
|
+
log11.debug("Global skill sync failed", e);
|
|
22960
23622
|
});
|
|
22961
23623
|
}
|
|
22962
23624
|
} catch (e) {
|
|
22963
|
-
|
|
23625
|
+
log11.debug(`Global scan error for ${runtime}`, e);
|
|
22964
23626
|
}
|
|
22965
23627
|
}
|
|
22966
23628
|
const targets = discoverTargets();
|
|
@@ -22973,7 +23635,7 @@ function runScan() {
|
|
|
22973
23635
|
const prevHash = readCacheHash(agentCachePath(target.agentId, target.runtime));
|
|
22974
23636
|
if (prevHash !== hash2) {
|
|
22975
23637
|
const skillItems = skills.map((s) => ({ name: s.name, description: s.description }));
|
|
22976
|
-
|
|
23638
|
+
log11.debug(`Syncing ${target.agentId}:${target.runtime} — ${skills.length} agent skills`);
|
|
22977
23639
|
clientRef.syncSkills(target.token, {
|
|
22978
23640
|
scope: "agent",
|
|
22979
23641
|
agent_id: target.agentId,
|
|
@@ -22985,11 +23647,11 @@ function runScan() {
|
|
|
22985
23647
|
if (isClientError2(e)) {
|
|
22986
23648
|
writeCacheFile(agentCachePath(target.agentId, target.runtime), hash2, skills);
|
|
22987
23649
|
}
|
|
22988
|
-
|
|
23650
|
+
log11.debug("Agent skill sync failed", e);
|
|
22989
23651
|
});
|
|
22990
23652
|
}
|
|
22991
23653
|
} catch (e) {
|
|
22992
|
-
|
|
23654
|
+
log11.debug(`Agent scan error for ${target.agentId}:${target.runtime}`, e);
|
|
22993
23655
|
}
|
|
22994
23656
|
}
|
|
22995
23657
|
}
|
|
@@ -23045,7 +23707,7 @@ import { readdir as readdir2, readFile as readFile2, unlink, stat as fsStat } fr
|
|
|
23045
23707
|
import { execSync as execSync4, spawn as spawn5 } from "child_process";
|
|
23046
23708
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
23047
23709
|
import { dirname as dirname3, join as join12 } from "path";
|
|
23048
|
-
var
|
|
23710
|
+
var log12 = createLogger2({ module: "daemon" });
|
|
23049
23711
|
var _dir = dirname3(fileURLToPath2(import.meta.url));
|
|
23050
23712
|
var sessionRunnerPath = existsSync4(join12(_dir, "session-runner.js")) ? join12(_dir, "session-runner.js") : join12(_dir, "session-runner.ts");
|
|
23051
23713
|
var meetingRunnerPath = existsSync4(join12(_dir, "meeting-runner.js")) ? join12(_dir, "meeting-runner.js") : join12(_dir, "meeting-runner.ts");
|
|
@@ -23153,14 +23815,14 @@ async function reconcilePendingCompletions(workspacesRoot) {
|
|
|
23153
23815
|
try {
|
|
23154
23816
|
parsed = JSON.parse(raw);
|
|
23155
23817
|
} catch {
|
|
23156
|
-
|
|
23818
|
+
log12.warn(`reconcile: malformed marker ${name}, deleting`);
|
|
23157
23819
|
try {
|
|
23158
23820
|
await unlink(filePath);
|
|
23159
23821
|
} catch {}
|
|
23160
23822
|
continue;
|
|
23161
23823
|
}
|
|
23162
23824
|
if (!isValidMarker(parsed)) {
|
|
23163
|
-
|
|
23825
|
+
log12.warn(`reconcile: invalid marker structure ${name}, deleting`);
|
|
23164
23826
|
try {
|
|
23165
23827
|
await unlink(filePath);
|
|
23166
23828
|
} catch {}
|
|
@@ -23169,7 +23831,7 @@ async function reconcilePendingCompletions(workspacesRoot) {
|
|
|
23169
23831
|
const marker = parsed;
|
|
23170
23832
|
const age = Date.now() - new Date(marker.createdAt).getTime();
|
|
23171
23833
|
if (age > MARKER_STALE_MS) {
|
|
23172
|
-
|
|
23834
|
+
log12.warn(`reconcile: stale marker ${name} (${Math.round(age / 3600000)}h old), deleting`);
|
|
23173
23835
|
try {
|
|
23174
23836
|
await unlink(filePath);
|
|
23175
23837
|
} catch {}
|
|
@@ -23185,7 +23847,7 @@ async function reconcilePendingCompletions(workspacesRoot) {
|
|
|
23185
23847
|
try {
|
|
23186
23848
|
await unlink(filePath);
|
|
23187
23849
|
} catch (delErr) {
|
|
23188
|
-
|
|
23850
|
+
log12.warn(`reconcile: delivered marker ${name} but failed to delete: ${delErr}`);
|
|
23189
23851
|
}
|
|
23190
23852
|
} catch (deliverErr) {
|
|
23191
23853
|
if (isClientError3(deliverErr)) {
|
|
@@ -23193,11 +23855,11 @@ async function reconcilePendingCompletions(workspacesRoot) {
|
|
|
23193
23855
|
await unlink(filePath);
|
|
23194
23856
|
} catch {}
|
|
23195
23857
|
} else {
|
|
23196
|
-
|
|
23858
|
+
log12.debug(`reconcile: delivery failed for ${name}, will retry next cycle`);
|
|
23197
23859
|
}
|
|
23198
23860
|
}
|
|
23199
23861
|
} catch (e) {
|
|
23200
|
-
|
|
23862
|
+
log12.debug(`reconcile: error processing ${name}`, e);
|
|
23201
23863
|
}
|
|
23202
23864
|
}
|
|
23203
23865
|
}
|
|
@@ -23208,7 +23870,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23208
23870
|
}
|
|
23209
23871
|
process.once("exit", () => releaseDaemonPid(profile));
|
|
23210
23872
|
const bailOnUnexpected = (label, err) => {
|
|
23211
|
-
|
|
23873
|
+
log12.error(`${label} — shutting down`, err);
|
|
23212
23874
|
releaseDaemonPid(profile);
|
|
23213
23875
|
process.exit(1);
|
|
23214
23876
|
};
|
|
@@ -23221,20 +23883,20 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23221
23883
|
if (marker) {
|
|
23222
23884
|
clearUpdateMarker(profile);
|
|
23223
23885
|
if (marker === config2.cliVersion) {
|
|
23224
|
-
|
|
23886
|
+
log12.info(`Cleared update marker — now running v${config2.cliVersion}`);
|
|
23225
23887
|
} else {
|
|
23226
|
-
|
|
23888
|
+
log12.info(`Cleared stale update marker (was v${marker}, running v${config2.cliVersion}) — update will be retried`);
|
|
23227
23889
|
}
|
|
23228
23890
|
}
|
|
23229
23891
|
const cliConfig = loadCLIConfigForProfile(profile);
|
|
23230
23892
|
const workspaces = activeWorkspaces(cliConfig.watched_workspaces);
|
|
23231
23893
|
if (workspaces.length === 0) {
|
|
23232
|
-
|
|
23894
|
+
log12.info("No workspaces configured — daemon starting in standby mode. Register a workspace to begin.");
|
|
23233
23895
|
}
|
|
23234
23896
|
if (workspaces.length > 0) {
|
|
23235
23897
|
const hasPerWorkspaceTokens = workspaces.every((ws) => !!ws.token);
|
|
23236
23898
|
if (!hasPerWorkspaceTokens) {
|
|
23237
|
-
|
|
23899
|
+
log12.error(`Config uses old format. Run '${cmdPrefix()} register --token <token>' for each workspace to upgrade.`);
|
|
23238
23900
|
process.exit(1);
|
|
23239
23901
|
return;
|
|
23240
23902
|
}
|
|
@@ -23255,11 +23917,11 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23255
23917
|
}
|
|
23256
23918
|
}
|
|
23257
23919
|
if (providers.length === 0) {
|
|
23258
|
-
|
|
23920
|
+
log12.error("No agent CLI tools found on PATH.");
|
|
23259
23921
|
process.exit(1);
|
|
23260
23922
|
return;
|
|
23261
23923
|
}
|
|
23262
|
-
|
|
23924
|
+
log12.info(`Detected providers: ${providers.map((p) => `${p.type}@${p.version}`).join(", ")}`);
|
|
23263
23925
|
const workspaceStates = [];
|
|
23264
23926
|
const runtimeIndex = new Map;
|
|
23265
23927
|
let hadWorkspaces = workspaces.length > 0;
|
|
@@ -23269,7 +23931,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23269
23931
|
type: p.type,
|
|
23270
23932
|
version: p.version
|
|
23271
23933
|
}));
|
|
23272
|
-
|
|
23934
|
+
log12.info(`Registering workspace ${ws.id} (${ws.name ?? "unnamed"}) with ${runtimes.length} runtime(s)...`);
|
|
23273
23935
|
let resp;
|
|
23274
23936
|
try {
|
|
23275
23937
|
resp = await client.register(ws.token, {
|
|
@@ -23282,13 +23944,13 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23282
23944
|
});
|
|
23283
23945
|
} catch (e) {
|
|
23284
23946
|
if (e instanceof Error && e.message.startsWith("HTTP 401")) {
|
|
23285
|
-
|
|
23947
|
+
log12.warn(`Workspace ${ws.id} token invalid — skipping (run '${cmdPrefix()} register --token <token>' to fix)`);
|
|
23286
23948
|
} else {
|
|
23287
|
-
|
|
23949
|
+
log12.error(`Failed to register workspace ${ws.id}, skipping`, e);
|
|
23288
23950
|
}
|
|
23289
23951
|
continue;
|
|
23290
23952
|
}
|
|
23291
|
-
|
|
23953
|
+
log12.info(`Workspace ${ws.id} registered — ${resp.runtimes.length} runtime(s)`);
|
|
23292
23954
|
const runtimeIds = resp.runtimes.map((r) => r.id);
|
|
23293
23955
|
workspaceStates.push({ workspaceId: ws.id, token: ws.token, runtimeIds });
|
|
23294
23956
|
for (let i = 0;i < runtimeIds.length; i++) {
|
|
@@ -23300,13 +23962,13 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23300
23962
|
}
|
|
23301
23963
|
}
|
|
23302
23964
|
if (workspaceStates.length === 0 && hadWorkspaces) {
|
|
23303
|
-
|
|
23965
|
+
log12.error("No workspaces registered successfully.");
|
|
23304
23966
|
process.exit(1);
|
|
23305
23967
|
return;
|
|
23306
23968
|
}
|
|
23307
23969
|
const allRuntimeIds = workspaceStates.flatMap((ws) => ws.runtimeIds);
|
|
23308
23970
|
health.setRuntimeCount(allRuntimeIds.length);
|
|
23309
|
-
|
|
23971
|
+
log12.info(`Daemon started — ${allRuntimeIds.length} runtime(s) across ${workspaceStates.length} workspace(s)`);
|
|
23310
23972
|
const activeTasks = new Set;
|
|
23311
23973
|
const pendingSteer = new Map;
|
|
23312
23974
|
const knownAgentIds = new Set(workspaces.flatMap((ws) => ws.agent_ids ?? []));
|
|
@@ -23344,7 +24006,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23344
24006
|
saveCLIConfigForProfile(profile, cfg);
|
|
23345
24007
|
}
|
|
23346
24008
|
} catch {}
|
|
23347
|
-
|
|
24009
|
+
log12.info(`Workspace ${workspaceId} removed from polling — ${reason}`);
|
|
23348
24010
|
}
|
|
23349
24011
|
const pollCycle = async () => {
|
|
23350
24012
|
let remaining = config2.maxConcurrentTasks - activeTasks.size;
|
|
@@ -23371,7 +24033,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23371
24033
|
handleCliUpdate(pending_update.version, () => requestRestart(), profile);
|
|
23372
24034
|
}
|
|
23373
24035
|
if (pending_rescan) {
|
|
23374
|
-
|
|
24036
|
+
log12.info("Rescan requested — restarting daemon to re-detect runtimes");
|
|
23375
24037
|
for (const [id, reason] of toRemove) {
|
|
23376
24038
|
markWorkspaceDeleted(id, reason);
|
|
23377
24039
|
}
|
|
@@ -23384,13 +24046,13 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23384
24046
|
activeTasks.add(task.id);
|
|
23385
24047
|
remaining--;
|
|
23386
24048
|
handleTask(client, config2, runtimeIndex, task, ws.token, activeTasks, pendingSteer).catch((e) => {
|
|
23387
|
-
|
|
24049
|
+
log12.error("Task error", e);
|
|
23388
24050
|
activeTasks.delete(task.id);
|
|
23389
24051
|
});
|
|
23390
24052
|
}
|
|
23391
24053
|
if (file_requests) {
|
|
23392
24054
|
for (const req of file_requests) {
|
|
23393
|
-
handleFileRequest(client, config2, ws.workspaceId, req, ws.token).catch((e) =>
|
|
24055
|
+
handleFileRequest(client, config2, ws.workspaceId, req, ws.token).catch((e) => log12.debug("File request error", e));
|
|
23394
24056
|
}
|
|
23395
24057
|
}
|
|
23396
24058
|
if (meetings) {
|
|
@@ -23418,11 +24080,11 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23418
24080
|
if (n >= WS_AUTH_401_THRESHOLD) {
|
|
23419
24081
|
toRemove.set(ws.workspaceId, `poll 401 x${n}`);
|
|
23420
24082
|
} else {
|
|
23421
|
-
|
|
24083
|
+
log12.warn(`Workspace ${ws.workspaceId} poll 401 (${n}/${WS_AUTH_401_THRESHOLD}) — will retry`);
|
|
23422
24084
|
}
|
|
23423
24085
|
} else {
|
|
23424
24086
|
consecutive401.delete(ws.workspaceId);
|
|
23425
|
-
|
|
24087
|
+
log12.debug("Poll error", e);
|
|
23426
24088
|
}
|
|
23427
24089
|
}
|
|
23428
24090
|
}
|
|
@@ -23435,7 +24097,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23435
24097
|
rebuildWsClient();
|
|
23436
24098
|
}
|
|
23437
24099
|
if (workspaceStates.length === 0 && hadWorkspaces) {
|
|
23438
|
-
|
|
24100
|
+
log12.info("All workspaces evicted — shutting down");
|
|
23439
24101
|
shutdown();
|
|
23440
24102
|
}
|
|
23441
24103
|
};
|
|
@@ -23443,7 +24105,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23443
24105
|
const heartbeatPing = () => {
|
|
23444
24106
|
for (const ws of workspaceStates) {
|
|
23445
24107
|
client.heartbeat(ws.token, config2.daemonId).catch((e) => {
|
|
23446
|
-
|
|
24108
|
+
log12.debug("heartbeat failed", { workspaceId: ws.workspaceId, err: String(e) });
|
|
23447
24109
|
});
|
|
23448
24110
|
}
|
|
23449
24111
|
};
|
|
@@ -23468,7 +24130,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23468
24130
|
syncAgentId(task.agentId, ws.workspaceId);
|
|
23469
24131
|
activeTasks.add(task.id);
|
|
23470
24132
|
handleTask(client, config2, runtimeIndex, task, ws.token, activeTasks, pendingSteer).catch((e) => {
|
|
23471
|
-
|
|
24133
|
+
log12.error("WS task error", e);
|
|
23472
24134
|
activeTasks.delete(task.id);
|
|
23473
24135
|
});
|
|
23474
24136
|
}
|
|
@@ -23477,7 +24139,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23477
24139
|
const ws = wsMap.get(msg.workspaceId);
|
|
23478
24140
|
if (ws) {
|
|
23479
24141
|
for (const req of msg.requests) {
|
|
23480
|
-
handleFileRequest(client, config2, ws.workspaceId, req, ws.token).catch((e) =>
|
|
24142
|
+
handleFileRequest(client, config2, ws.workspaceId, req, ws.token).catch((e) => log12.debug("WS file request error", e));
|
|
23481
24143
|
}
|
|
23482
24144
|
}
|
|
23483
24145
|
break;
|
|
@@ -23509,7 +24171,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23509
24171
|
if (wasWsToken)
|
|
23510
24172
|
rebuildWsClient();
|
|
23511
24173
|
if (workspaceStates.length === 0 && hadWorkspaces) {
|
|
23512
|
-
|
|
24174
|
+
log12.info("All workspaces removed — shutting down");
|
|
23513
24175
|
shutdown();
|
|
23514
24176
|
}
|
|
23515
24177
|
break;
|
|
@@ -23520,7 +24182,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23520
24182
|
}
|
|
23521
24183
|
break;
|
|
23522
24184
|
case "daemon.rescan":
|
|
23523
|
-
|
|
24185
|
+
log12.info("WS rescan requested — restarting daemon");
|
|
23524
24186
|
requestRestart();
|
|
23525
24187
|
break;
|
|
23526
24188
|
case "daemon.kill": {
|
|
@@ -23548,7 +24210,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23548
24210
|
});
|
|
23549
24211
|
activeTasks.add(killTask.id);
|
|
23550
24212
|
handleTask(client, config2, runtimeIndex, killTask, ws.token, activeTasks, pendingSteer).catch((e) => {
|
|
23551
|
-
|
|
24213
|
+
log12.error("WS kill task error", e);
|
|
23552
24214
|
activeTasks.delete(killTask.id);
|
|
23553
24215
|
});
|
|
23554
24216
|
}
|
|
@@ -23561,11 +24223,11 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23561
24223
|
const wsCallbacks = {
|
|
23562
24224
|
onMessage: handleWsPush,
|
|
23563
24225
|
onConnected: () => {
|
|
23564
|
-
|
|
24226
|
+
log12.info("WS connected — switching to low-frequency poll");
|
|
23565
24227
|
updatePollInterval(config2.wsPollInterval);
|
|
23566
24228
|
},
|
|
23567
24229
|
onDisconnected: () => {
|
|
23568
|
-
|
|
24230
|
+
log12.info("WS disconnected — reverting to high-frequency poll");
|
|
23569
24231
|
updatePollInterval(config2.pollInterval);
|
|
23570
24232
|
},
|
|
23571
24233
|
onAuthRejected: (reason) => {
|
|
@@ -23585,18 +24247,18 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23585
24247
|
let confirmedDead = false;
|
|
23586
24248
|
try {
|
|
23587
24249
|
await client.poll(token, config2.daemonId, 0, config2.cliVersion);
|
|
23588
|
-
|
|
24250
|
+
log12.info(`Workspace ${workspaceId} WS auth rejection not confirmed by poll — keeping (likely transient)`);
|
|
23589
24251
|
} catch (e) {
|
|
23590
24252
|
if (e instanceof Error && e.message.startsWith("HTTP 401")) {
|
|
23591
24253
|
confirmedDead = true;
|
|
23592
24254
|
markWorkspaceDeleted(workspaceId, `WS auth rejected${reason ? ` (${reason})` : ""} — confirmed by poll 401`);
|
|
23593
24255
|
} else {
|
|
23594
|
-
|
|
24256
|
+
log12.debug("Confirm-poll error (transient) — keeping workspace", e);
|
|
23595
24257
|
}
|
|
23596
24258
|
}
|
|
23597
24259
|
rebuildWsClient();
|
|
23598
24260
|
if (confirmedDead && workspaceStates.length === 0 && hadWorkspaces) {
|
|
23599
|
-
|
|
24261
|
+
log12.info("All workspaces removed — shutting down");
|
|
23600
24262
|
shutdown();
|
|
23601
24263
|
}
|
|
23602
24264
|
}
|
|
@@ -23621,13 +24283,13 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23621
24283
|
const sweepTick = async () => {
|
|
23622
24284
|
for (const ws of workspaceStates) {
|
|
23623
24285
|
client.sweep(ws.token, config2.daemonId).catch((e) => {
|
|
23624
|
-
|
|
24286
|
+
log12.debug("sweep ping failed", { workspaceId: ws.workspaceId, err: String(e) });
|
|
23625
24287
|
});
|
|
23626
24288
|
}
|
|
23627
24289
|
try {
|
|
23628
24290
|
await reconcilePendingCompletions(config2.workspacesRoot);
|
|
23629
24291
|
} catch (e) {
|
|
23630
|
-
|
|
24292
|
+
log12.debug("reconciliation error", e);
|
|
23631
24293
|
}
|
|
23632
24294
|
};
|
|
23633
24295
|
const sweepTimer = setInterval(sweepTick, config2.sweepInterval);
|
|
@@ -23651,7 +24313,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23651
24313
|
if (shuttingDown)
|
|
23652
24314
|
return;
|
|
23653
24315
|
shuttingDown = true;
|
|
23654
|
-
|
|
24316
|
+
log12.info(restartRequested ? "Restarting..." : "Shutting down...");
|
|
23655
24317
|
clearInterval(pollTimer);
|
|
23656
24318
|
clearInterval(heartbeatTimer);
|
|
23657
24319
|
clearInterval(sweepTimer);
|
|
@@ -23679,7 +24341,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23679
24341
|
mkdirSync9(dirname3(logPath), { recursive: true, mode: 448 });
|
|
23680
24342
|
logFd = openSync(logPath, "a", 384);
|
|
23681
24343
|
} catch (e) {
|
|
23682
|
-
|
|
24344
|
+
log12.error(`Failed to open daemon log file ${logPath}`, e);
|
|
23683
24345
|
}
|
|
23684
24346
|
const child = spawn5(process.execPath, args, {
|
|
23685
24347
|
detached: true,
|
|
@@ -23689,7 +24351,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23689
24351
|
child.unref();
|
|
23690
24352
|
if (logFd != null)
|
|
23691
24353
|
closeSync(logFd);
|
|
23692
|
-
|
|
24354
|
+
log12.info(`Spawned new daemon (pid=${child.pid}), logs: ${logPath}`);
|
|
23693
24355
|
}
|
|
23694
24356
|
clearTimeout(timeout);
|
|
23695
24357
|
process.exit(0);
|
|
@@ -23700,7 +24362,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23700
24362
|
process.on("SIGHUP", async () => {
|
|
23701
24363
|
if (shuttingDown)
|
|
23702
24364
|
return;
|
|
23703
|
-
|
|
24365
|
+
log12.info("SIGHUP received — reloading config...");
|
|
23704
24366
|
try {
|
|
23705
24367
|
const freshConfig = loadCLIConfigForProfile(profile);
|
|
23706
24368
|
const freshWorkspaces = activeWorkspaces(freshConfig.watched_workspaces);
|
|
@@ -23708,7 +24370,7 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23708
24370
|
const newWorkspaces = freshWorkspaces.filter((ws) => ws.token && !existingIds.has(ws.id));
|
|
23709
24371
|
for (const ws of newWorkspaces) {
|
|
23710
24372
|
const runtimes = providers.map((p) => ({ type: p.type, version: p.version }));
|
|
23711
|
-
|
|
24373
|
+
log12.info(`Registering new workspace ${ws.id} (${ws.name ?? "unnamed"})...`);
|
|
23712
24374
|
try {
|
|
23713
24375
|
const resp = await client.register(ws.token, {
|
|
23714
24376
|
workspace_id: ws.id,
|
|
@@ -23727,9 +24389,9 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23727
24389
|
provider: providers[i].type
|
|
23728
24390
|
});
|
|
23729
24391
|
}
|
|
23730
|
-
|
|
24392
|
+
log12.info(`Workspace ${ws.id} added — ${runtimeIds.length} runtime(s)`);
|
|
23731
24393
|
} catch (e) {
|
|
23732
|
-
|
|
24394
|
+
log12.error(`Failed to register new workspace ${ws.id}`, e);
|
|
23733
24395
|
}
|
|
23734
24396
|
}
|
|
23735
24397
|
if (newWorkspaces.length > 0) {
|
|
@@ -23737,14 +24399,14 @@ async function startDaemon(profile, serverUrl) {
|
|
|
23737
24399
|
health.setRuntimeCount(workspaceStates.reduce((sum, w) => sum + w.runtimeIds.length, 0));
|
|
23738
24400
|
if (!wsClient && workspaceStates.length > 0) {
|
|
23739
24401
|
rebuildWsClient();
|
|
23740
|
-
|
|
24402
|
+
log12.info("WS push client initialized after SIGHUP reload");
|
|
23741
24403
|
}
|
|
23742
|
-
|
|
24404
|
+
log12.info(`Reload complete — now polling ${workspaceStates.length} workspace(s)`);
|
|
23743
24405
|
} else {
|
|
23744
|
-
|
|
24406
|
+
log12.info("Reload complete — no new workspaces found");
|
|
23745
24407
|
}
|
|
23746
24408
|
} catch (e) {
|
|
23747
|
-
|
|
24409
|
+
log12.error("Failed to reload config", e);
|
|
23748
24410
|
}
|
|
23749
24411
|
});
|
|
23750
24412
|
await pollCycle();
|
|
@@ -23759,7 +24421,7 @@ function spawnSessionRunner(input) {
|
|
|
23759
24421
|
try {
|
|
23760
24422
|
fd = openSync(logFilePath, "a");
|
|
23761
24423
|
} catch (e) {
|
|
23762
|
-
|
|
24424
|
+
log12.error(`Failed to open log file ${logFilePath}`, e);
|
|
23763
24425
|
}
|
|
23764
24426
|
const child = spawn5(process.execPath, [sessionRunnerPath, encoded], {
|
|
23765
24427
|
detached: true,
|
|
@@ -23779,7 +24441,7 @@ function spawnMeetingRunner(input) {
|
|
|
23779
24441
|
try {
|
|
23780
24442
|
fd = openSync(logFilePath, "a");
|
|
23781
24443
|
} catch (e) {
|
|
23782
|
-
|
|
24444
|
+
log12.error(`Failed to open meeting log file ${logFilePath}`, e);
|
|
23783
24445
|
}
|
|
23784
24446
|
const child = spawn5(process.execPath, [meetingRunnerPath, encoded], {
|
|
23785
24447
|
detached: true,
|
|
@@ -23788,7 +24450,7 @@ function spawnMeetingRunner(input) {
|
|
|
23788
24450
|
child.unref();
|
|
23789
24451
|
if (fd != null)
|
|
23790
24452
|
closeSync(fd);
|
|
23791
|
-
|
|
24453
|
+
log12.info(`Spawned meeting runner for ${input.meetingId} (pid=${child.pid})`);
|
|
23792
24454
|
return child;
|
|
23793
24455
|
}
|
|
23794
24456
|
async function handleFileRequest(client, config2, workspaceId, req, token) {
|
|
@@ -23830,7 +24492,7 @@ async function killAndVerify(pid) {
|
|
|
23830
24492
|
await new Promise((r) => setTimeout(r, 100));
|
|
23831
24493
|
}
|
|
23832
24494
|
if (isAlive(pid)) {
|
|
23833
|
-
|
|
24495
|
+
log12.warn(`session-runner pid=${pid} survived SIGTERM after ${verifyMs}ms — escalating to SIGKILL`);
|
|
23834
24496
|
try {
|
|
23835
24497
|
process.kill(pid, "SIGKILL");
|
|
23836
24498
|
} catch {}
|
|
@@ -23838,7 +24500,7 @@ async function killAndVerify(pid) {
|
|
|
23838
24500
|
return true;
|
|
23839
24501
|
}
|
|
23840
24502
|
async function handleTask(client, config2, runtimeIndex, task, token, activeTasks, pendingSteer) {
|
|
23841
|
-
|
|
24503
|
+
log12.info(`Task ${task.id} claimed agent=${task.agentId}`);
|
|
23842
24504
|
if (task.type === TASK_TYPES.KILL_TASK) {
|
|
23843
24505
|
const targetTaskId = task.context?.target_task_id;
|
|
23844
24506
|
if (!targetTaskId) {
|
|
@@ -23868,17 +24530,17 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
23868
24530
|
const delivered = await killAndVerify(pid);
|
|
23869
24531
|
if (delivered) {
|
|
23870
24532
|
await client.failTask(token, task.id, "killed");
|
|
23871
|
-
|
|
24533
|
+
log12.info(`Kill task ${task.id}: terminated pid=${pid} for target=${targetTaskId}`);
|
|
23872
24534
|
} else {
|
|
23873
24535
|
await client.failTask(token, task.id, "target process already exited");
|
|
23874
|
-
|
|
24536
|
+
log12.info(`Kill task ${task.id}: target pid=${pid} already exited`);
|
|
23875
24537
|
}
|
|
23876
24538
|
} catch (e) {
|
|
23877
24539
|
await client.failTask(token, task.id, `kill failed: ${e}`);
|
|
23878
24540
|
}
|
|
23879
24541
|
} else {
|
|
23880
24542
|
await client.failTask(token, task.id, "target not found in timeline");
|
|
23881
|
-
|
|
24543
|
+
log12.info(`Kill task ${task.id}: target ${targetTaskId} not found in timeline`);
|
|
23882
24544
|
}
|
|
23883
24545
|
activeTasks.delete(task.id);
|
|
23884
24546
|
return;
|
|
@@ -23920,7 +24582,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
23920
24582
|
}
|
|
23921
24583
|
existing.tasks.push(task);
|
|
23922
24584
|
existing.attachments.set(task.id, myAttachments);
|
|
23923
|
-
|
|
24585
|
+
log12.info(`Steering: ${task.id} merged into pending entry (lock contention) for context_key=${ctxKey} (${existing.tasks.length} tasks)`);
|
|
23924
24586
|
existing.wake();
|
|
23925
24587
|
try {
|
|
23926
24588
|
await client.supersedeTask(token, task.id);
|
|
@@ -23934,7 +24596,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
23934
24596
|
await new Promise((r) => setTimeout(r, MERGE_POLL_MS));
|
|
23935
24597
|
}
|
|
23936
24598
|
if (!lockAcquired) {
|
|
23937
|
-
|
|
24599
|
+
log12.warn(`Steering lock contention for context_key=${ctxKey}, proceeding without steering`);
|
|
23938
24600
|
}
|
|
23939
24601
|
}
|
|
23940
24602
|
if (lockAcquired) {
|
|
@@ -23949,7 +24611,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
23949
24611
|
try {
|
|
23950
24612
|
myAttachments = await downloadAttachments(client, token, task.workspaceId, task.id, attachmentIds);
|
|
23951
24613
|
} catch (e) {
|
|
23952
|
-
|
|
24614
|
+
log12.warn(`Steering: failed to download attachments for ${task.id}`, e);
|
|
23953
24615
|
}
|
|
23954
24616
|
}
|
|
23955
24617
|
let ownerWake;
|
|
@@ -23965,7 +24627,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
23965
24627
|
pendingSteer.set(ctxKey, entry);
|
|
23966
24628
|
let predecessor = "entry" in result ? result.entry : null;
|
|
23967
24629
|
if (!predecessor) {
|
|
23968
|
-
|
|
24630
|
+
log12.info(`Steering: predecessor ${result.pending.task_id} warming up; ${task.id} waiting`);
|
|
23969
24631
|
const POLL_MS2 = 200;
|
|
23970
24632
|
const MAX_WAIT_MS = steerWarmupGraceMs();
|
|
23971
24633
|
const waitStart = Date.now();
|
|
@@ -23976,7 +24638,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
23976
24638
|
continue;
|
|
23977
24639
|
const r = findSupersedablePredecessor(timelineDir, ctxKey, provider, steerWarmupGraceMs(), Date.now());
|
|
23978
24640
|
if (!r) {
|
|
23979
|
-
|
|
24641
|
+
log12.info(`Steering: predecessor vanished; ${task.id} proceeding`);
|
|
23980
24642
|
break;
|
|
23981
24643
|
}
|
|
23982
24644
|
if ("entry" in r) {
|
|
@@ -23997,7 +24659,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
23997
24659
|
const backendInst = createBackend(provider, "");
|
|
23998
24660
|
const isPersistent = backendInst.lifecycle?.kind === "persistent";
|
|
23999
24661
|
if (config2.enableSteering && isPersistent && predecessor.pid != null) {
|
|
24000
|
-
|
|
24662
|
+
log12.info(`Steering: task ${task.id} steering into predecessor ${predecessor.task_id} via mailbox (context_key=${ctxKey})`);
|
|
24001
24663
|
try {
|
|
24002
24664
|
ensureMailboxDirs(agentBaseDir, ctxKey);
|
|
24003
24665
|
const attachmentIds2 = task.context?.attachment_ids ?? [];
|
|
@@ -24007,7 +24669,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24007
24669
|
const downloaded = await downloadAttachments(client, token, task.workspaceId, task.id, attachmentIds2);
|
|
24008
24670
|
steerAttachments = downloaded.map((a) => ({ localPath: a.path, filename: a.filename, contentType: a.content_type }));
|
|
24009
24671
|
} catch (e) {
|
|
24010
|
-
|
|
24672
|
+
log12.warn(`Steering mailbox: failed to download attachments for ${task.id}`, e);
|
|
24011
24673
|
}
|
|
24012
24674
|
}
|
|
24013
24675
|
const seq = writeSteerMessage(agentBaseDir, ctxKey, {
|
|
@@ -24018,7 +24680,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24018
24680
|
});
|
|
24019
24681
|
const ackResult = await waitForAck(agentBaseDir, ctxKey, seq);
|
|
24020
24682
|
if (ackResult.acked) {
|
|
24021
|
-
|
|
24683
|
+
log12.info(`Steering: task ${task.id} steered into predecessor ${predecessor.task_id} (acked)`);
|
|
24022
24684
|
try {
|
|
24023
24685
|
await client.startTask(token, task.id);
|
|
24024
24686
|
} catch {}
|
|
@@ -24026,19 +24688,19 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24026
24688
|
activeTasks.delete(task.id);
|
|
24027
24689
|
return;
|
|
24028
24690
|
}
|
|
24029
|
-
|
|
24691
|
+
log12.info(`Steering: mailbox delivery failed for ${task.id} (${ackResult.nackReason}), falling back to kill-and-respawn`);
|
|
24030
24692
|
} catch (e) {
|
|
24031
|
-
|
|
24693
|
+
log12.warn(`Steering: mailbox error for ${task.id}, falling back to kill-and-respawn`, e);
|
|
24032
24694
|
}
|
|
24033
24695
|
}
|
|
24034
|
-
|
|
24696
|
+
log12.info(`Steering: task ${task.id} supersedes predecessor ${predecessor.task_id} (context_key=${ctxKey})`);
|
|
24035
24697
|
if (predecessor.pid != null) {
|
|
24036
24698
|
writeKillIntent(agentBaseDir, { reason: "superseded", targetTaskId: predecessor.task_id, expectedPid: predecessor.pid, successorTaskId: task.id });
|
|
24037
24699
|
try {
|
|
24038
24700
|
const delivered = await killAndVerify(predecessor.pid);
|
|
24039
|
-
|
|
24701
|
+
log12.info(delivered ? `Steering: terminated predecessor pid=${predecessor.pid}` : `Steering: predecessor pid=${predecessor.pid} already exited`);
|
|
24040
24702
|
} catch (e) {
|
|
24041
|
-
|
|
24703
|
+
log12.warn(`Steering: kill failed for pid=${predecessor.pid}`, e);
|
|
24042
24704
|
}
|
|
24043
24705
|
const killWaitStart = Date.now();
|
|
24044
24706
|
while (Date.now() - killWaitStart < 15000) {
|
|
@@ -24054,7 +24716,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24054
24716
|
const finalEntry = pendingSteer.get(ctxKey);
|
|
24055
24717
|
if (finalEntry && finalEntry.tasks.length > 1) {
|
|
24056
24718
|
promptOverride = buildMergedPrompt(finalEntry.tasks, finalEntry.attachments);
|
|
24057
|
-
|
|
24719
|
+
log12.info(`Steering: merged ${finalEntry.tasks.length} tasks for context_key=${ctxKey}`);
|
|
24058
24720
|
} else if (finalEntry && finalEntry.tasks.length === 1) {
|
|
24059
24721
|
const att = finalEntry.attachments.get(task.id);
|
|
24060
24722
|
if (att && att.length > 0) {
|
|
@@ -24069,7 +24731,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24069
24731
|
try {
|
|
24070
24732
|
myAttachments = await downloadAttachments(client, token, task.workspaceId, task.id, attachmentIds);
|
|
24071
24733
|
} catch (e) {
|
|
24072
|
-
|
|
24734
|
+
log12.warn(`Steering: failed to download attachments for ${task.id}`, e);
|
|
24073
24735
|
}
|
|
24074
24736
|
}
|
|
24075
24737
|
for (const prev of existing.tasks) {
|
|
@@ -24081,7 +24743,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24081
24743
|
}
|
|
24082
24744
|
existing.tasks.push(task);
|
|
24083
24745
|
existing.attachments.set(task.id, myAttachments);
|
|
24084
|
-
|
|
24746
|
+
log12.info(`Steering: ${task.id} merged into pending entry for context_key=${ctxKey} (${existing.tasks.length} tasks)`);
|
|
24085
24747
|
existing.wake();
|
|
24086
24748
|
try {
|
|
24087
24749
|
await client.supersedeTask(token, task.id);
|
|
@@ -24128,14 +24790,14 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24128
24790
|
const agentBaseDir = join12(config2.workspacesRoot, task.workspaceId, task.agentId, "workdir");
|
|
24129
24791
|
const killIntent = readKillIntent(agentBaseDir, task.id);
|
|
24130
24792
|
if (killIntent) {
|
|
24131
|
-
|
|
24793
|
+
log12.info(`Task ${task.id} exited (${killIntent.reason}) — expected, skipping failTask`);
|
|
24132
24794
|
clearKillIntent(agentBaseDir, task.id);
|
|
24133
24795
|
return;
|
|
24134
24796
|
}
|
|
24135
24797
|
const errorMsg = code === null ? "killed by signal" : `session-runner exited with code ${code}`;
|
|
24136
24798
|
try {
|
|
24137
24799
|
await client.failTask(token, task.id, errorMsg);
|
|
24138
|
-
|
|
24800
|
+
log12.warn(`session-runner crashed (${errorMsg}, task ${task.id})`);
|
|
24139
24801
|
const timelineDir = join12(agentBaseDir, ".context_timeline");
|
|
24140
24802
|
updateEntry(timelineDir, task.id, (entry) => {
|
|
24141
24803
|
entry.pid = null;
|
|
@@ -24144,10 +24806,10 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24144
24806
|
});
|
|
24145
24807
|
} catch (e) {
|
|
24146
24808
|
if (isClientError3(e)) {
|
|
24147
|
-
|
|
24809
|
+
log12.info(`Task ${task.id} exited (already terminal) — session-runner handled cleanup`);
|
|
24148
24810
|
return;
|
|
24149
24811
|
}
|
|
24150
|
-
|
|
24812
|
+
log12.error(`Failed to report crash for task ${task.id}`, e);
|
|
24151
24813
|
try {
|
|
24152
24814
|
await writeMarkerFile(config2.workspacesRoot, {
|
|
24153
24815
|
taskId: task.id,
|
|
@@ -24161,7 +24823,7 @@ async function handleTask(client, config2, runtimeIndex, task, token, activeTask
|
|
|
24161
24823
|
}
|
|
24162
24824
|
}
|
|
24163
24825
|
});
|
|
24164
|
-
|
|
24826
|
+
log12.info(`Task ${task.id} dispatched to session-runner (pid=${child.pid})`);
|
|
24165
24827
|
}
|
|
24166
24828
|
|
|
24167
24829
|
// lib/runtimes.ts
|
|
@@ -24901,7 +25563,7 @@ function gatherContextEnvVars() {
|
|
|
24901
25563
|
}
|
|
24902
25564
|
|
|
24903
25565
|
// commands/email.ts
|
|
24904
|
-
var
|
|
25566
|
+
var log13 = createLogger2({ module: "email" });
|
|
24905
25567
|
var VALID_STATUSES = ["unread", "read", "archived", "sent"];
|
|
24906
25568
|
var VALID_FOLDERS = ["inbox", "sent", "untrust"];
|
|
24907
25569
|
var EMAIL_BASE = tempDir("alook-emails");
|
|
@@ -24988,7 +25650,7 @@ function emailCommand() {
|
|
|
24988
25650
|
} catch (err) {
|
|
24989
25651
|
const msg = err instanceof Error ? err.message : String(err);
|
|
24990
25652
|
if (msg.includes("404")) {
|
|
24991
|
-
|
|
25653
|
+
log13.warn(`email body not available for ${email3.id}, skipping`);
|
|
24992
25654
|
continue;
|
|
24993
25655
|
}
|
|
24994
25656
|
throw err;
|
|
@@ -25082,7 +25744,7 @@ function emailCommand() {
|
|
|
25082
25744
|
references = [parentEmail.references, parentEmail.message_id].filter(Boolean).join(" ").trim() || undefined;
|
|
25083
25745
|
}
|
|
25084
25746
|
} catch {
|
|
25085
|
-
|
|
25747
|
+
log13.warn(`could not fetch parent email ${opts.inReplyTo}, sending without threading`);
|
|
25086
25748
|
}
|
|
25087
25749
|
}
|
|
25088
25750
|
const ctx = gatherContextEnvVars();
|
|
@@ -25854,9 +26516,6 @@ function syncCommand() {
|
|
|
25854
26516
|
// commands/workspace.ts
|
|
25855
26517
|
import { Command as Command13 } from "commander";
|
|
25856
26518
|
import { readFileSync as readFileSync15 } from "fs";
|
|
25857
|
-
function slugify3(name) {
|
|
25858
|
-
return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 60);
|
|
25859
|
-
}
|
|
25860
26519
|
function sleep4(ms) {
|
|
25861
26520
|
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
25862
26521
|
}
|
|
@@ -25878,7 +26537,7 @@ async function resolveWorkspaceId(client, configName) {
|
|
|
25878
26537
|
}
|
|
25879
26538
|
const wsName = configName || "Personal";
|
|
25880
26539
|
try {
|
|
25881
|
-
const newWs = await client.postJSON("/api/workspaces", { name: wsName, slug:
|
|
26540
|
+
const newWs = await client.postJSON("/api/workspaces", { name: wsName, slug: sanitizeSlug(wsName) });
|
|
25882
26541
|
console.log(`Created workspace: ${newWs.name} (${newWs.id})`);
|
|
25883
26542
|
return { workspaceId: newWs.id, created: true };
|
|
25884
26543
|
} catch (err) {
|
|
@@ -26000,7 +26659,7 @@ Workspace initialized: ${res.studio.name || res.workspace.name}`);
|
|
|
26000
26659
|
if (agents.length > 0) {
|
|
26001
26660
|
console.log("Current workspace has existing agents. Creating a new workspace...");
|
|
26002
26661
|
const wsName = opts.name || config2.name || "New Workspace";
|
|
26003
|
-
const newWs = await targetClient.postJSON("/api/workspaces", { name: wsName, slug:
|
|
26662
|
+
const newWs = await targetClient.postJSON("/api/workspaces", { name: wsName, slug: sanitizeSlug(wsName) });
|
|
26004
26663
|
targetWorkspaceId = newWs.id;
|
|
26005
26664
|
targetClient = new APIClient(serverUrl, token, targetWorkspaceId);
|
|
26006
26665
|
console.log(`Created workspace: ${newWs.name} (${newWs.id})`);
|