@alook/daemon 0.1.70 → 0.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +375 -59
- package/dist/index.js +269 -11
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -43079,7 +43079,7 @@ var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
|
43079
43079
|
statusText: exports_external.string().nullable().optional()
|
|
43080
43080
|
});
|
|
43081
43081
|
// ../shared/src/business-schema-version.ts
|
|
43082
|
-
var BUSINESS_SCHEMA_VERSION =
|
|
43082
|
+
var BUSINESS_SCHEMA_VERSION = 11;
|
|
43083
43083
|
|
|
43084
43084
|
// ../shared/src/community-contract.ts
|
|
43085
43085
|
var COMMUNITY_RESOURCE_CONTRACT_VERSION = BUSINESS_SCHEMA_VERSION;
|
|
@@ -43115,6 +43115,134 @@ var AgentModelReportSchema = exports_external.object({
|
|
|
43115
43115
|
observedAt: exports_external.string().datetime({ offset: true })
|
|
43116
43116
|
});
|
|
43117
43117
|
|
|
43118
|
+
// ../shared/src/community-decision-card.ts
|
|
43119
|
+
var DECISION_CARD_EMBED_KIND = "decision_card";
|
|
43120
|
+
var DECISION_CARD_EMBED_VERSION = 1;
|
|
43121
|
+
var DECISION_CARD_MAX_BYTES = 8 * 1024;
|
|
43122
|
+
var DECISION_CARD_MAX_MENTIONS = 20;
|
|
43123
|
+
var DECISION_CARD_MIN_QUESTIONS = 1;
|
|
43124
|
+
var DECISION_CARD_MAX_QUESTIONS = 4;
|
|
43125
|
+
var DECISION_CARD_MIN_OPTIONS = 2;
|
|
43126
|
+
var DECISION_CARD_MAX_OPTIONS = 6;
|
|
43127
|
+
var DECISION_CARD_ID_MAX_LENGTH = 40;
|
|
43128
|
+
var DECISION_CARD_SUMMARY_MAX_LENGTH = 240;
|
|
43129
|
+
var DECISION_CARD_HEADER_MAX_LENGTH = 24;
|
|
43130
|
+
var DECISION_CARD_QUESTION_MAX_LENGTH = 300;
|
|
43131
|
+
var DECISION_CARD_OPTION_LABEL_MAX_LENGTH = 120;
|
|
43132
|
+
var DECISION_CARD_OPTION_DESC_MAX_LENGTH = 240;
|
|
43133
|
+
var DECISION_CARD_OTHER_TEXT_MAX_LENGTH = 500;
|
|
43134
|
+
function decisionCardUtf8Bytes(value) {
|
|
43135
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
43136
|
+
}
|
|
43137
|
+
var idFieldSchema = exports_external.string().trim().min(1).max(DECISION_CARD_ID_MAX_LENGTH).regex(/^[a-zA-Z0-9_-]+$/, "id must contain only letters, digits, hyphens, or underscores");
|
|
43138
|
+
var optionalTrimmedText = (max) => exports_external.string().trim().max(max).transform((value) => value.length > 0 ? value : undefined).optional();
|
|
43139
|
+
var requiredSummarySchema = exports_external.string().trim().min(1, "summary is required").max(DECISION_CARD_SUMMARY_MAX_LENGTH);
|
|
43140
|
+
var DecisionCardOptionInputSchema = exports_external.strictObject({
|
|
43141
|
+
id: idFieldSchema.optional(),
|
|
43142
|
+
label: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH),
|
|
43143
|
+
description: optionalTrimmedText(DECISION_CARD_OPTION_DESC_MAX_LENGTH),
|
|
43144
|
+
recommended: exports_external.boolean().optional()
|
|
43145
|
+
});
|
|
43146
|
+
var DecisionCardQuestionInputSchema = exports_external.strictObject({
|
|
43147
|
+
id: idFieldSchema.optional(),
|
|
43148
|
+
header: optionalTrimmedText(DECISION_CARD_HEADER_MAX_LENGTH),
|
|
43149
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
43150
|
+
multiSelect: exports_external.boolean().optional(),
|
|
43151
|
+
allowOther: exports_external.boolean().optional(),
|
|
43152
|
+
options: exports_external.array(DecisionCardOptionInputSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
43153
|
+
});
|
|
43154
|
+
function hasDuplicateIds(ids) {
|
|
43155
|
+
return new Set(ids).size !== ids.length;
|
|
43156
|
+
}
|
|
43157
|
+
var mentionHandleSchema = exports_external.string().trim().min(1).max(128).refine((value) => parseNameAndTag(value.startsWith("@") ? value.slice(1) : value) !== null, { message: 'mention must be a handle like "@alice#0001"' });
|
|
43158
|
+
var DecisionCardInputSchema = exports_external.strictObject({
|
|
43159
|
+
mentions: exports_external.array(mentionHandleSchema).max(DECISION_CARD_MAX_MENTIONS).optional(),
|
|
43160
|
+
summary: requiredSummarySchema,
|
|
43161
|
+
questions: exports_external.array(DecisionCardQuestionInputSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
43162
|
+
}).superRefine((value, ctx) => {
|
|
43163
|
+
const qIds = value.questions.map((q, index) => q.id ?? `q${index + 1}`);
|
|
43164
|
+
if (hasDuplicateIds(qIds)) {
|
|
43165
|
+
ctx.addIssue({
|
|
43166
|
+
code: "custom",
|
|
43167
|
+
path: ["questions"],
|
|
43168
|
+
message: "question ids must be unique"
|
|
43169
|
+
});
|
|
43170
|
+
}
|
|
43171
|
+
value.questions.forEach((q, qIndex) => {
|
|
43172
|
+
const optIds = q.options.map((opt, oIndex) => opt.id ?? `o${oIndex + 1}`);
|
|
43173
|
+
if (hasDuplicateIds(optIds)) {
|
|
43174
|
+
ctx.addIssue({
|
|
43175
|
+
code: "custom",
|
|
43176
|
+
path: ["questions", qIndex, "options"],
|
|
43177
|
+
message: "option ids must be unique within a question"
|
|
43178
|
+
});
|
|
43179
|
+
}
|
|
43180
|
+
});
|
|
43181
|
+
if (decisionCardUtf8Bytes(value) > DECISION_CARD_MAX_BYTES) {
|
|
43182
|
+
ctx.addIssue({
|
|
43183
|
+
code: "custom",
|
|
43184
|
+
path: [],
|
|
43185
|
+
message: `decision card exceeds ${DECISION_CARD_MAX_BYTES} bytes`
|
|
43186
|
+
});
|
|
43187
|
+
}
|
|
43188
|
+
});
|
|
43189
|
+
var DecisionCardCliOptionSchema = exports_external.union([
|
|
43190
|
+
exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH).transform((label) => ({ label })),
|
|
43191
|
+
DecisionCardOptionInputSchema
|
|
43192
|
+
]);
|
|
43193
|
+
var DecisionCardCliInputSchema = exports_external.strictObject({
|
|
43194
|
+
mentions: exports_external.array(mentionHandleSchema).max(DECISION_CARD_MAX_MENTIONS).optional(),
|
|
43195
|
+
summary: requiredSummarySchema,
|
|
43196
|
+
questions: exports_external.array(exports_external.strictObject({
|
|
43197
|
+
id: idFieldSchema.optional(),
|
|
43198
|
+
header: optionalTrimmedText(DECISION_CARD_HEADER_MAX_LENGTH),
|
|
43199
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
43200
|
+
multiSelect: exports_external.boolean().optional(),
|
|
43201
|
+
allowOther: exports_external.boolean().optional(),
|
|
43202
|
+
options: exports_external.array(DecisionCardCliOptionSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
43203
|
+
})).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
43204
|
+
});
|
|
43205
|
+
function parseDecisionCardCliInput(raw) {
|
|
43206
|
+
const pre = DecisionCardCliInputSchema.safeParse(raw);
|
|
43207
|
+
if (!pre.success)
|
|
43208
|
+
return pre;
|
|
43209
|
+
return DecisionCardInputSchema.safeParse(pre.data);
|
|
43210
|
+
}
|
|
43211
|
+
var DecisionCardAssigneeSchema = exports_external.strictObject({
|
|
43212
|
+
userId: exports_external.string().min(1),
|
|
43213
|
+
handle: exports_external.string().min(1)
|
|
43214
|
+
});
|
|
43215
|
+
var DecisionCardNormalizedOptionSchema = exports_external.strictObject({
|
|
43216
|
+
id: idFieldSchema,
|
|
43217
|
+
label: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH),
|
|
43218
|
+
description: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_DESC_MAX_LENGTH).optional(),
|
|
43219
|
+
recommended: exports_external.boolean().optional()
|
|
43220
|
+
});
|
|
43221
|
+
var DecisionCardNormalizedQuestionSchema = exports_external.strictObject({
|
|
43222
|
+
id: idFieldSchema,
|
|
43223
|
+
header: exports_external.string().trim().min(1).max(DECISION_CARD_HEADER_MAX_LENGTH).optional(),
|
|
43224
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
43225
|
+
multiSelect: exports_external.boolean(),
|
|
43226
|
+
allowOther: exports_external.boolean(),
|
|
43227
|
+
options: exports_external.array(DecisionCardNormalizedOptionSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
43228
|
+
});
|
|
43229
|
+
var DecisionCardEmbedSchema = exports_external.strictObject({
|
|
43230
|
+
kind: exports_external.literal(DECISION_CARD_EMBED_KIND),
|
|
43231
|
+
version: exports_external.literal(DECISION_CARD_EMBED_VERSION),
|
|
43232
|
+
summary: exports_external.string().trim().min(1).max(DECISION_CARD_SUMMARY_MAX_LENGTH).optional(),
|
|
43233
|
+
assignees: exports_external.array(DecisionCardAssigneeSchema).max(DECISION_CARD_MAX_MENTIONS),
|
|
43234
|
+
questions: exports_external.array(DecisionCardNormalizedQuestionSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS),
|
|
43235
|
+
respondedUserIds: exports_external.array(exports_external.string().min(1)).optional()
|
|
43236
|
+
});
|
|
43237
|
+
var DecisionCardAnswerItemSchema = exports_external.strictObject({
|
|
43238
|
+
questionId: idFieldSchema,
|
|
43239
|
+
selectedOptionIds: exports_external.array(idFieldSchema).max(DECISION_CARD_MAX_OPTIONS).optional(),
|
|
43240
|
+
otherText: exports_external.string().trim().max(DECISION_CARD_OTHER_TEXT_MAX_LENGTH).optional()
|
|
43241
|
+
});
|
|
43242
|
+
var DecisionCardAnswerInputSchema = exports_external.strictObject({
|
|
43243
|
+
answers: exports_external.array(DecisionCardAnswerItemSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
43244
|
+
});
|
|
43245
|
+
|
|
43118
43246
|
// ../shared/src/provider-telemetry.ts
|
|
43119
43247
|
var DAILY_TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
43120
43248
|
var PROVIDER_QUOTA_BACKENDS = ["claude", "codex", "codex-app", "codex-cli", "grok", "antigravity", "cursor", "cursor-sdk", "copilot", "qoder", "agy"];
|
|
@@ -43539,12 +43667,38 @@ var CommunityAgentCursorSchema = exports_external.object({
|
|
|
43539
43667
|
var CommunityAgentSendRequestSchema = exports_external.object({
|
|
43540
43668
|
channel: exports_external.string().min(1),
|
|
43541
43669
|
content: CommunityAgentMessageContentSchema,
|
|
43670
|
+
question: DecisionCardInputSchema.optional(),
|
|
43542
43671
|
attachments: exports_external.array(exports_external.string().min(1)).max(MAX_ATTACHMENTS_PER_MESSAGE).default([]),
|
|
43543
43672
|
seenUpToSeq: CommunityAgentSeqSchema.optional(),
|
|
43544
43673
|
replyToSeq: CommunityAgentPositiveSeqSchema.optional(),
|
|
43545
43674
|
force: exports_external.boolean().optional(),
|
|
43546
43675
|
nonce: exports_external.string().min(1).max(128).optional()
|
|
43547
|
-
}).
|
|
43676
|
+
}).superRefine((d, ctx) => {
|
|
43677
|
+
if (d.question !== undefined) {
|
|
43678
|
+
if (d.attachments.length > 0) {
|
|
43679
|
+
ctx.addIssue({
|
|
43680
|
+
code: "custom",
|
|
43681
|
+
path: ["attachments"],
|
|
43682
|
+
message: "decision card messages cannot include attachments"
|
|
43683
|
+
});
|
|
43684
|
+
}
|
|
43685
|
+
if (d.content.text.trim().length > 0) {
|
|
43686
|
+
ctx.addIssue({
|
|
43687
|
+
code: "custom",
|
|
43688
|
+
path: ["content", "text"],
|
|
43689
|
+
message: "decision card messages must omit content.text"
|
|
43690
|
+
});
|
|
43691
|
+
}
|
|
43692
|
+
return;
|
|
43693
|
+
}
|
|
43694
|
+
if (d.content.text.trim().length === 0 && d.attachments.length === 0) {
|
|
43695
|
+
ctx.addIssue({
|
|
43696
|
+
code: "custom",
|
|
43697
|
+
path: [],
|
|
43698
|
+
message: "message must have text or attachments"
|
|
43699
|
+
});
|
|
43700
|
+
}
|
|
43701
|
+
});
|
|
43548
43702
|
var CommunityAgentAttachmentUploadResponseSchema = exports_external.object({
|
|
43549
43703
|
id: exports_external.string(),
|
|
43550
43704
|
filename: exports_external.string(),
|
|
@@ -43838,7 +43992,7 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
43838
43992
|
seq: exports_external.number().int().nonnegative(),
|
|
43839
43993
|
authorId: id,
|
|
43840
43994
|
createdAt: exports_external.string(),
|
|
43841
|
-
type: exports_external.enum(["chat", "system"]),
|
|
43995
|
+
type: exports_external.enum(["chat", "system", "question"]),
|
|
43842
43996
|
content: exports_external.string(),
|
|
43843
43997
|
replyToId: nullableId,
|
|
43844
43998
|
clientNonce: exports_external.string().nullable(),
|
|
@@ -43931,11 +44085,18 @@ var CommunityResourceBundleSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
|
43931
44085
|
servers: exports_external.array(CommunityServerResourceSchema),
|
|
43932
44086
|
serverMemberships: exports_external.array(CommunityServerMembershipResourceSchema),
|
|
43933
44087
|
channels: exports_external.array(CommunityChannelResourceSchema),
|
|
43934
|
-
memberships: exports_external.array(CommunityChannelMembershipResourceSchema)
|
|
44088
|
+
memberships: exports_external.array(CommunityChannelMembershipResourceSchema),
|
|
44089
|
+
categories: exports_external.array(CommunityCategoryResourceSchema).optional(),
|
|
44090
|
+
dmPeers: exports_external.array(exports_external.strictObject({ channelId: id, userId: id })).optional()
|
|
43935
44091
|
}).superRefine((bundle, ctx) => {
|
|
43936
44092
|
const channels = new Set(bundle.channels.map((row) => row.id));
|
|
43937
44093
|
const servers = new Set(bundle.servers.map((row) => row.id));
|
|
43938
|
-
|
|
44094
|
+
const categories = bundle.categories ?? [];
|
|
44095
|
+
const dmPeers = bundle.dmPeers ?? [];
|
|
44096
|
+
const dmChannels = new Set(bundle.channels.filter((row) => row.type === "dm").map((row) => row.id));
|
|
44097
|
+
const profiles = new Set(bundle.profiles.map((row) => row.id));
|
|
44098
|
+
const readableCategories = new Map(bundle.channels.flatMap((row) => row.categoryId ? [[row.categoryId, row.serverId]] : []));
|
|
44099
|
+
if (channels.size !== bundle.channels.length || servers.size !== bundle.servers.length || new Set(categories.map((row) => row.id)).size !== categories.length || categories.some((row) => readableCategories.get(row.id) !== row.serverId) || new Set(dmPeers.map((row) => row.channelId)).size !== dmPeers.length || dmPeers.some((row) => !dmChannels.has(row.channelId) || row.userId === bundle.viewerId || !profiles.has(row.userId)) || new Set(bundle.messages.map((row) => row.id)).size !== bundle.messages.length || profiles.size !== bundle.profiles.length || new Set(bundle.memberships.map((row) => `${row.channelId}:${row.userId}:${row.relation}`)).size !== bundle.memberships.length || new Set(bundle.serverMemberships.map((row) => `${row.serverId}:${row.userId}`)).size !== bundle.serverMemberships.length || bundle.messages.some((row) => !channels.has(row.channelId)) || bundle.servers.some((row) => !bundle.serverMemberships.some((member) => member.serverId === row.id && member.userId === bundle.viewerId)) || bundle.channels.some((row) => !bundle.memberships.some((member) => member.channelId === row.id && member.userId === bundle.viewerId && member.relation === "access")) || bundle.channels.some((row) => row.serverId !== null && !servers.has(row.serverId) || row.parentChannelId !== null && !channels.has(row.parentChannelId)) || bundle.memberships.some((row) => row.userId !== bundle.viewerId || !channels.has(row.channelId)) || bundle.serverMemberships.some((row) => row.userId !== bundle.viewerId || !servers.has(row.serverId)))
|
|
43939
44100
|
ctx.addIssue({ code: "custom", message: "Resource bundle scope mismatch" });
|
|
43940
44101
|
});
|
|
43941
44102
|
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
@@ -44058,7 +44219,7 @@ var AttentionScopeSchema = exports_external.strictObject({
|
|
|
44058
44219
|
});
|
|
44059
44220
|
var AttentionItemSchema = exports_external.strictObject({
|
|
44060
44221
|
id: id2,
|
|
44061
|
-
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post"]),
|
|
44222
|
+
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post", "question"]),
|
|
44062
44223
|
sourceId: id2,
|
|
44063
44224
|
scopeId: id2.nullable().optional(),
|
|
44064
44225
|
messageId: id2.nullable().optional(),
|
|
@@ -44093,7 +44254,7 @@ var AttentionItemSchema = exports_external.strictObject({
|
|
|
44093
44254
|
ctx.addIssue({ code: "custom", message: "message attention requires an actor" });
|
|
44094
44255
|
}
|
|
44095
44256
|
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
44096
|
-
ctx.addIssue({ code: "custom", message: "
|
|
44257
|
+
ctx.addIssue({ code: "custom", message: "message attention cannot carry forum presentation refs" });
|
|
44097
44258
|
}
|
|
44098
44259
|
});
|
|
44099
44260
|
var AttentionIncludedServerSchema = CommunityServerResourceSchema.pick({ id: true, name: true, discriminator: true });
|
|
@@ -44149,6 +44310,7 @@ var AccountAttentionProjectionSchema = exports_external.strictObject({
|
|
|
44149
44310
|
items: exports_external.array(AttentionItemSchema),
|
|
44150
44311
|
limit: exports_external.number().int().positive(),
|
|
44151
44312
|
truncated: exports_external.boolean(),
|
|
44313
|
+
todosTruncated: exports_external.boolean().optional(),
|
|
44152
44314
|
included: AttentionIncludedSchema
|
|
44153
44315
|
});
|
|
44154
44316
|
var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
@@ -44211,7 +44373,7 @@ var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
|
44211
44373
|
ctx.addIssue({ code: "custom", message: `duplicate attention item: ${item.id}` });
|
|
44212
44374
|
}
|
|
44213
44375
|
itemIds.add(item.id);
|
|
44214
|
-
if (item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
44376
|
+
if (item.kind !== "question" && item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
44215
44377
|
ctx.addIssue({ code: "custom", message: `attention item references missing scope: ${item.scopeId}` });
|
|
44216
44378
|
}
|
|
44217
44379
|
if (item.kind === "friend_request") {
|
|
@@ -44220,6 +44382,16 @@ var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
|
44220
44382
|
}
|
|
44221
44383
|
continue;
|
|
44222
44384
|
}
|
|
44385
|
+
if (item.kind === "question") {
|
|
44386
|
+
const message2 = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
44387
|
+
const channel = item.scopeId ? channelById.get(item.scopeId) : undefined;
|
|
44388
|
+
const dm = item.scopeId ? dmById.get(item.scopeId) : undefined;
|
|
44389
|
+
const ownerValid = Boolean(channel && serverById.has(channel.serverId) || dm && profileById.has(dm.userId));
|
|
44390
|
+
if (!item.scopeId || !message2 || message2.channelId !== item.scopeId || !item.actorUserId || !profileById.has(item.actorUserId) || !ownerValid) {
|
|
44391
|
+
ctx.addIssue({ code: "custom", message: `question attention references incomplete owners: ${item.id}` });
|
|
44392
|
+
}
|
|
44393
|
+
continue;
|
|
44394
|
+
}
|
|
44223
44395
|
const scope = item.scopeId ? snapshot.scopes.find((candidate) => candidate.scopeId === item.scopeId) : undefined;
|
|
44224
44396
|
const message = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
44225
44397
|
if (!scope || !message) {
|
|
@@ -45098,6 +45270,9 @@ function and(...unfilteredConditions) {
|
|
|
45098
45270
|
new StringChunk(")")
|
|
45099
45271
|
]);
|
|
45100
45272
|
}
|
|
45273
|
+
function isNull(value) {
|
|
45274
|
+
return sql`${value} is null`;
|
|
45275
|
+
}
|
|
45101
45276
|
function isNotNull(value) {
|
|
45102
45277
|
return sql`${value} is not null`;
|
|
45103
45278
|
}
|
|
@@ -45120,6 +45295,7 @@ __export(exports_community_schema, {
|
|
|
45120
45295
|
communityReadStateRevision: () => communityReadStateRevision,
|
|
45121
45296
|
communityReadState: () => communityReadState,
|
|
45122
45297
|
communityReaction: () => communityReaction,
|
|
45298
|
+
communityQuestionTodo: () => communityQuestionTodo,
|
|
45123
45299
|
communityPushDevice: () => communityPushDevice,
|
|
45124
45300
|
communityPin: () => communityPin,
|
|
45125
45301
|
communityNotificationSetting: () => communityNotificationSetting,
|
|
@@ -46087,7 +46263,20 @@ var communityMessage = sqliteTable("community_message", {
|
|
|
46087
46263
|
}, (t) => [
|
|
46088
46264
|
index("idx_community_message_author_id_lookup").on(t.authorId),
|
|
46089
46265
|
index("idx_message_channel_created").on(t.channelId, t.createdAt),
|
|
46090
|
-
index("idx_message_channel_mention_created").on(t.channelId, t.mentionType, t.createdAt)
|
|
46266
|
+
index("idx_message_channel_mention_created").on(t.channelId, t.mentionType, t.createdAt),
|
|
46267
|
+
index("idx_community_message_channel_reply_author").on(t.channelId, t.replyToId, t.authorId).where(sql`${t.replyToId} IS NOT NULL`)
|
|
46268
|
+
]);
|
|
46269
|
+
var communityQuestionTodo = sqliteTable("community_question_todo", {
|
|
46270
|
+
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
46271
|
+
messageId: text("message_id").notNull().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
46272
|
+
channelId: text("channel_id").notNull().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
46273
|
+
createdAt: text("created_at").notNull().$defaultFn(() => new Date().toISOString()),
|
|
46274
|
+
dismissedAt: text("dismissed_at")
|
|
46275
|
+
}, (t) => [
|
|
46276
|
+
primaryKey({ columns: [t.userId, t.messageId] }),
|
|
46277
|
+
index("idx_community_question_todo_user_active").on(t.userId, desc(t.createdAt), desc(t.messageId)).where(isNull(t.dismissedAt)),
|
|
46278
|
+
index("idx_community_question_todo_message_id_lookup").on(t.messageId),
|
|
46279
|
+
index("idx_community_question_todo_channel_id_lookup").on(t.channelId)
|
|
46091
46280
|
]);
|
|
46092
46281
|
var communityMessageSeq = sqliteTable("community_message_seq", {
|
|
46093
46282
|
channelId: text("channel_id").primaryKey().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
@@ -46754,7 +46943,9 @@ var AGENT_MESSAGE_COLUMNS = {
|
|
|
46754
46943
|
createdAt: communityMessage.createdAt,
|
|
46755
46944
|
channelId: communityMessage.channelId,
|
|
46756
46945
|
seq: communityMessage.seq,
|
|
46757
|
-
replyToId: communityMessage.replyToId
|
|
46946
|
+
replyToId: communityMessage.replyToId,
|
|
46947
|
+
type: communityMessage.type,
|
|
46948
|
+
embeds: communityMessage.embeds
|
|
46758
46949
|
};
|
|
46759
46950
|
var channelJoinBaselineGuard = sql`${communityMessage.createdAt} > COALESCE(${communityChannelMember.addedAt}, ${communityServerMember.joinedAt}, '')`;
|
|
46760
46951
|
var AGENT_UNREAD_CHANNEL_CHUNK_SIZE = maxInParams(13);
|
|
@@ -47002,6 +47193,7 @@ var communityInboxChangedSchema = exports_external.strictObject({
|
|
|
47002
47193
|
"read_all",
|
|
47003
47194
|
"mention_read_all",
|
|
47004
47195
|
"mention_dismiss",
|
|
47196
|
+
"todo_dismiss",
|
|
47005
47197
|
"notification_policy"
|
|
47006
47198
|
])
|
|
47007
47199
|
});
|
|
@@ -80238,12 +80430,75 @@ async function handleLocalPii(request, response, botId, pii) {
|
|
|
80238
80430
|
writePiiError(response, error62);
|
|
80239
80431
|
}
|
|
80240
80432
|
}
|
|
80433
|
+
async function filterQuestionPii(rawQuestion, botId, pii) {
|
|
80434
|
+
const parsed = DecisionCardInputSchema.safeParse(rawQuestion);
|
|
80435
|
+
if (!parsed.success)
|
|
80436
|
+
throw new PiiError("PII_INVALID_REQUEST");
|
|
80437
|
+
const triggeredById = new Map;
|
|
80438
|
+
const runField = async (value) => {
|
|
80439
|
+
const result2 = await pii.filterWithResult(botId, value);
|
|
80440
|
+
for (const filter of result2.triggeredFilters) {
|
|
80441
|
+
if (!triggeredById.has(filter.id))
|
|
80442
|
+
triggeredById.set(filter.id, filter);
|
|
80443
|
+
}
|
|
80444
|
+
return result2.text;
|
|
80445
|
+
};
|
|
80446
|
+
const source = parsed.data;
|
|
80447
|
+
const summary = await runField(source.summary);
|
|
80448
|
+
const questions = [];
|
|
80449
|
+
for (const question of source.questions) {
|
|
80450
|
+
const header = question.header !== undefined ? await runField(question.header) : undefined;
|
|
80451
|
+
const prompt = await runField(question.question);
|
|
80452
|
+
const options = [];
|
|
80453
|
+
for (const option of question.options) {
|
|
80454
|
+
const label2 = await runField(option.label);
|
|
80455
|
+
const description = option.description !== undefined ? await runField(option.description) : undefined;
|
|
80456
|
+
options.push({
|
|
80457
|
+
...option.id !== undefined ? { id: option.id } : {},
|
|
80458
|
+
label: label2,
|
|
80459
|
+
...description !== undefined ? { description } : {},
|
|
80460
|
+
...option.recommended !== undefined ? { recommended: option.recommended } : {}
|
|
80461
|
+
});
|
|
80462
|
+
}
|
|
80463
|
+
questions.push({
|
|
80464
|
+
...question.id !== undefined ? { id: question.id } : {},
|
|
80465
|
+
...header !== undefined ? { header } : {},
|
|
80466
|
+
question: prompt,
|
|
80467
|
+
...question.multiSelect !== undefined ? { multiSelect: question.multiSelect } : {},
|
|
80468
|
+
...question.allowOther !== undefined ? { allowOther: question.allowOther } : {},
|
|
80469
|
+
options
|
|
80470
|
+
});
|
|
80471
|
+
}
|
|
80472
|
+
const filtered = {
|
|
80473
|
+
...source.mentions !== undefined ? { mentions: source.mentions } : {},
|
|
80474
|
+
summary,
|
|
80475
|
+
questions
|
|
80476
|
+
};
|
|
80477
|
+
if (decisionCardUtf8Bytes(filtered) > DECISION_CARD_MAX_BYTES) {
|
|
80478
|
+
throw new PiiError("PII_OUTPUT_TOO_LARGE");
|
|
80479
|
+
}
|
|
80480
|
+
const validated = DecisionCardInputSchema.safeParse(filtered);
|
|
80481
|
+
if (!validated.success)
|
|
80482
|
+
throw new PiiError("PII_INVALID_RESULT");
|
|
80483
|
+
return { question: validated.data, triggeredFilters: [...triggeredById.values()] };
|
|
80484
|
+
}
|
|
80241
80485
|
async function filterPiiRequest(request, botId, pii) {
|
|
80242
80486
|
const body = await readJson2(request);
|
|
80243
80487
|
const content3 = body.content;
|
|
80244
80488
|
if (!content3 || typeof content3 !== "object" || Array.isArray(content3) || content3.text !== undefined && typeof content3.text !== "string") {
|
|
80245
80489
|
throw new PiiError("PII_INVALID_REQUEST");
|
|
80246
80490
|
}
|
|
80491
|
+
if (body.question !== undefined) {
|
|
80492
|
+
if ((content3.text ?? "").trim().length > 0) {
|
|
80493
|
+
throw new PiiError("PII_INVALID_REQUEST");
|
|
80494
|
+
}
|
|
80495
|
+
const filteredQuestion = await filterQuestionPii(body.question, botId, pii);
|
|
80496
|
+
body.content = { ...content3, text: "" };
|
|
80497
|
+
body.question = filteredQuestion.question;
|
|
80498
|
+
if (!CommunityAgentSendRequestSchema.safeParse(body).success)
|
|
80499
|
+
throw new PiiError("PII_INVALID_RESULT");
|
|
80500
|
+
return { body: Buffer.from(JSON.stringify(body)), triggeredFilters: filteredQuestion.triggeredFilters };
|
|
80501
|
+
}
|
|
80247
80502
|
const { text: text8, triggeredFilters } = await pii.filterWithResult(botId, content3.text ?? "");
|
|
80248
80503
|
if (Buffer.byteLength(text8, "utf8") > PII_TEXT_MAX_BYTES)
|
|
80249
80504
|
throw new PiiError("PII_OUTPUT_TOO_LARGE");
|
|
@@ -81622,6 +81877,15 @@ function messagingSection() {
|
|
|
81622
81877
|
"ALOOK_MESSAGE_7F3C",
|
|
81623
81878
|
"```",
|
|
81624
81879
|
"",
|
|
81880
|
+
"#### Ask for a decision",
|
|
81881
|
+
"",
|
|
81882
|
+
`Alook users cannot see native question prompts. When you need someone to choose from options, use \`${CLI} message send --ask\` with JSON on stdin (max 8 KiB).`,
|
|
81883
|
+
"Include a required non-empty `summary` (1–240 chars). Recommend at least one option per question to help the user decide. Use `recommended: true`. Use `mentions` to name respondents, and short `header` values for multi-question tabs. Answers arrive in your inbox as replies to the original question.",
|
|
81884
|
+
"",
|
|
81885
|
+
"```json",
|
|
81886
|
+
`{"mentions":["@alice#0001"],"summary":"Confirm today's release","questions":[{"question":"Ship today?","options":[{"label":"Ship","recommended":true},"Wait"]}]}`,
|
|
81887
|
+
"```",
|
|
81888
|
+
"",
|
|
81625
81889
|
"#### Pulled messages",
|
|
81626
81890
|
"",
|
|
81627
81891
|
"```json",
|
|
@@ -81691,7 +81955,7 @@ function cliCommandsSection() {
|
|
|
81691
81955
|
"### Messaging",
|
|
81692
81956
|
"",
|
|
81693
81957
|
`1. \`${CLI} inbox pull\` — fetch unread messages and advance their read waterlines.`,
|
|
81694
|
-
`2. \`${CLI} message send --target <ref> --remind-after <0|Nm|Nh> --stdin\` —
|
|
81958
|
+
`2. \`${CLI} message send --target <ref> --remind-after <0|Nm|Nh> [--ask] --stdin\` — Send to a ` + `channel, DM, or thread. ` + `For plain messages, pass up to 1 KiB of UTF-8 text through stdin and use \`--attachment <id>\` for files (repeatable, order matters). ` + `\`--remind-after\` accepts \`0\` or a whole-number duration from \`1m\` to \`24h\`.`,
|
|
81695
81959
|
`3. \`${CLI} message attachment upload --file <path>\` — upload a local file and get a reusable attachment ID. Supports Markdown and inline HTML; see Communication for formatting.`,
|
|
81696
81960
|
`4. \`${CLI} message attachment download --id <id> [--out <path>]\` — download an attachment you can read, including your own unsent uploads.`,
|
|
81697
81961
|
`5. \`${CLI} message property set --target <full-message-ref> --json <json>\` — add a supported property value to a message.`,
|
|
@@ -90678,8 +90942,18 @@ async function readLiteralInput(args) {
|
|
|
90678
90942
|
throw new CliError(`${command}: input exceeds ${args.maxBytes} UTF-8 bytes`);
|
|
90679
90943
|
chunks.push(bytes);
|
|
90680
90944
|
}
|
|
90681
|
-
|
|
90945
|
+
const raw = Buffer.concat(chunks);
|
|
90946
|
+
if (args.strictUtf8) {
|
|
90947
|
+
try {
|
|
90948
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(raw);
|
|
90949
|
+
} catch {
|
|
90950
|
+
throw new CliError(`${command}: --stdin must be valid UTF-8 JSON`);
|
|
90951
|
+
}
|
|
90952
|
+
}
|
|
90953
|
+
return raw.toString("utf8");
|
|
90682
90954
|
} catch (err) {
|
|
90955
|
+
if (err instanceof CliError)
|
|
90956
|
+
throw err;
|
|
90683
90957
|
throw new CliError(`${command}: cannot read stdin: ${err.message}`);
|
|
90684
90958
|
}
|
|
90685
90959
|
}
|
|
@@ -90736,55 +91010,21 @@ function contentTypeFromFilename(filename) {
|
|
|
90736
91010
|
async function sendWithRetry(api2, req) {
|
|
90737
91011
|
return withTransientMutationRetry(() => api2.send(req));
|
|
90738
91012
|
}
|
|
90739
|
-
|
|
90740
|
-
|
|
90741
|
-
|
|
90742
|
-
const
|
|
90743
|
-
const
|
|
90744
|
-
const
|
|
90745
|
-
if (!
|
|
90746
|
-
throw new CliError(
|
|
90747
|
-
parseRef(channel);
|
|
90748
|
-
const literalText = await readLiteralInput({
|
|
90749
|
-
command: "message send",
|
|
90750
|
-
stdinSelected: opts.stdin === true,
|
|
90751
|
-
stdin
|
|
90752
|
-
});
|
|
90753
|
-
const text8 = stripMalformedAlookHeredocTail(literalText ?? "");
|
|
90754
|
-
const textBytes = Buffer.byteLength(text8, "utf8");
|
|
90755
|
-
if (textBytes > CLIENT_MAX_MESSAGE_BODY_BYTES) {
|
|
90756
|
-
throw new CliError(`message send: --stdin body is ${textBytes} bytes; max ${CLIENT_MAX_MESSAGE_BODY_BYTES}. Rewrite it before retrying.
|
|
90757
|
-
|
|
90758
|
-
${MESSAGE_SEND_STDIN_POLICY}`);
|
|
90759
|
-
}
|
|
90760
|
-
const attachmentIds = Array.isArray(opts.attachment) ? opts.attachment : [];
|
|
90761
|
-
const hasText = text8.trim().length > 0;
|
|
90762
|
-
if (!hasText && attachmentIds.length === 0) {
|
|
90763
|
-
throw new CliError("message send: --stdin must contain text unless --attachment <id> is present");
|
|
90764
|
-
}
|
|
90765
|
-
let replyToSeq;
|
|
90766
|
-
const replyFlag = opts.reply;
|
|
90767
|
-
if (replyFlag !== undefined && replyFlag !== "") {
|
|
90768
|
-
const raw = String(replyFlag).trim();
|
|
90769
|
-
const stripped = raw.startsWith("#") ? raw.slice(1) : raw;
|
|
90770
|
-
const n = Number(stripped);
|
|
90771
|
-
if (!/^\d+$/.test(stripped) || !Number.isInteger(n) || n < 1) {
|
|
90772
|
-
throw new CliError('message send: --reply must be a message seq like "#37"');
|
|
90773
|
-
}
|
|
90774
|
-
replyToSeq = n;
|
|
91013
|
+
function parseReplySeqOption(command, replyFlag) {
|
|
91014
|
+
if (replyFlag === undefined || replyFlag === "")
|
|
91015
|
+
return;
|
|
91016
|
+
const raw = String(replyFlag).trim();
|
|
91017
|
+
const stripped = raw.startsWith("#") ? raw.slice(1) : raw;
|
|
91018
|
+
const n = Number(stripped);
|
|
91019
|
+
if (!/^\d+$/.test(stripped) || !Number.isInteger(n) || n < 1) {
|
|
91020
|
+
throw new CliError(`${command}: --reply must be a message seq like "#37"`);
|
|
90775
91021
|
}
|
|
90776
|
-
|
|
91022
|
+
return n;
|
|
91023
|
+
}
|
|
91024
|
+
async function dispatchSendAndArmReminder(api2, channel, remindAfterMs, req) {
|
|
90777
91025
|
let res;
|
|
90778
91026
|
try {
|
|
90779
|
-
res = await sendWithRetry(api2,
|
|
90780
|
-
agentId: agent,
|
|
90781
|
-
channel,
|
|
90782
|
-
content: { text: text8 ?? "" },
|
|
90783
|
-
attachments: attachmentIds.length > 0 ? attachmentIds : undefined,
|
|
90784
|
-
replyToSeq,
|
|
90785
|
-
nonce,
|
|
90786
|
-
...opts.force === true ? { force: true } : {}
|
|
90787
|
-
});
|
|
91027
|
+
res = await sendWithRetry(api2, req);
|
|
90788
91028
|
} catch (err) {
|
|
90789
91029
|
if (err instanceof Error && "code" in err && err.code === "duplicate_message") {
|
|
90790
91030
|
err.hint = "If this message really needs to be sent, retry with --force. This only bypasses duplicate detection; channel alignment is still required.";
|
|
@@ -90812,6 +91052,82 @@ ${MESSAGE_SEND_STDIN_POLICY}`);
|
|
|
90812
91052
|
return { sent, ...pii, reminder: { armed: false, reason: "local reminder request failed" } };
|
|
90813
91053
|
}
|
|
90814
91054
|
}
|
|
91055
|
+
async function cmdMessageSend(opts, stdin) {
|
|
91056
|
+
const remindAfterFlag = opts.remindAfter;
|
|
91057
|
+
const remindAfterMs = parseRemindAfter(remindAfterFlag);
|
|
91058
|
+
const api2 = getApi();
|
|
91059
|
+
const agent = agentId(opts);
|
|
91060
|
+
const channel = opts.target;
|
|
91061
|
+
if (!channel)
|
|
91062
|
+
throw new CliError("message send: --target <ref> is required (e.g. /demo-workspace#1234/general)");
|
|
91063
|
+
parseRef(channel);
|
|
91064
|
+
const attachmentIds = Array.isArray(opts.attachment) ? opts.attachment : [];
|
|
91065
|
+
const replyToSeq = parseReplySeqOption("message send", opts.reply);
|
|
91066
|
+
if (opts.ask === true) {
|
|
91067
|
+
if (attachmentIds.length > 0) {
|
|
91068
|
+
throw new CliError("message send --ask: cannot combine --ask with --attachment");
|
|
91069
|
+
}
|
|
91070
|
+
const rawBody = await readLiteralInput({
|
|
91071
|
+
command: "message send --ask",
|
|
91072
|
+
stdinSelected: opts.stdin === true,
|
|
91073
|
+
stdin,
|
|
91074
|
+
maxBytes: DECISION_CARD_MAX_BYTES,
|
|
91075
|
+
strictUtf8: true
|
|
91076
|
+
});
|
|
91077
|
+
const cleaned = stripMalformedAlookHeredocTail(rawBody ?? "").trim();
|
|
91078
|
+
if (!cleaned) {
|
|
91079
|
+
throw new CliError("message send --ask: --stdin must contain a JSON decision card payload");
|
|
91080
|
+
}
|
|
91081
|
+
let parsedJson;
|
|
91082
|
+
try {
|
|
91083
|
+
parsedJson = JSON.parse(cleaned);
|
|
91084
|
+
} catch {
|
|
91085
|
+
throw new CliError("message send --ask: --stdin must be valid UTF-8 JSON");
|
|
91086
|
+
}
|
|
91087
|
+
const validated = parseDecisionCardCliInput(parsedJson);
|
|
91088
|
+
if (!validated.success) {
|
|
91089
|
+
const issue2 = validated.error.issues[0];
|
|
91090
|
+
const path24 = issue2?.path?.length ? `${issue2.path.join(".")}: ` : "";
|
|
91091
|
+
throw new CliError(`message send --ask: invalid decision card payload (${path24}${issue2?.message ?? "invalid schema"})`);
|
|
91092
|
+
}
|
|
91093
|
+
const nonce2 = randomUUID20();
|
|
91094
|
+
return dispatchSendAndArmReminder(api2, channel, remindAfterMs, {
|
|
91095
|
+
agentId: agent,
|
|
91096
|
+
channel,
|
|
91097
|
+
content: { text: "" },
|
|
91098
|
+
question: validated.data,
|
|
91099
|
+
replyToSeq,
|
|
91100
|
+
nonce: nonce2,
|
|
91101
|
+
...opts.force === true ? { force: true } : {}
|
|
91102
|
+
});
|
|
91103
|
+
}
|
|
91104
|
+
const literalText = await readLiteralInput({
|
|
91105
|
+
command: "message send",
|
|
91106
|
+
stdinSelected: opts.stdin === true,
|
|
91107
|
+
stdin
|
|
91108
|
+
});
|
|
91109
|
+
const text8 = stripMalformedAlookHeredocTail(literalText ?? "");
|
|
91110
|
+
const textBytes = Buffer.byteLength(text8, "utf8");
|
|
91111
|
+
if (textBytes > CLIENT_MAX_MESSAGE_BODY_BYTES) {
|
|
91112
|
+
throw new CliError(`message send: --stdin body is ${textBytes} bytes; max ${CLIENT_MAX_MESSAGE_BODY_BYTES}. Rewrite it before retrying.
|
|
91113
|
+
|
|
91114
|
+
${MESSAGE_SEND_STDIN_POLICY}`);
|
|
91115
|
+
}
|
|
91116
|
+
const hasText = text8.trim().length > 0;
|
|
91117
|
+
if (!hasText && attachmentIds.length === 0) {
|
|
91118
|
+
throw new CliError("message send: --stdin must contain text unless --attachment <id> is present");
|
|
91119
|
+
}
|
|
91120
|
+
const nonce = randomUUID20();
|
|
91121
|
+
return dispatchSendAndArmReminder(api2, channel, remindAfterMs, {
|
|
91122
|
+
agentId: agent,
|
|
91123
|
+
channel,
|
|
91124
|
+
content: { text: text8 ?? "" },
|
|
91125
|
+
attachments: attachmentIds.length > 0 ? attachmentIds : undefined,
|
|
91126
|
+
replyToSeq,
|
|
91127
|
+
nonce,
|
|
91128
|
+
...opts.force === true ? { force: true } : {}
|
|
91129
|
+
});
|
|
91130
|
+
}
|
|
90815
91131
|
function parseMessagePropertyJson(command, raw) {
|
|
90816
91132
|
if (typeof raw !== "string")
|
|
90817
91133
|
throw new CliError(`${command}: --json <json> is required`);
|
|
@@ -91170,7 +91486,7 @@ function buildProgram(stdin) {
|
|
|
91170
91486
|
registerPiiCommands(program, printEnvelope);
|
|
91171
91487
|
const message = program.command("message").description("message operations").exitOverride();
|
|
91172
91488
|
message.configureOutput({ writeOut: () => {}, writeErr: () => {} });
|
|
91173
|
-
message.command("send").description("send a message to a channel, DM, or thread").option("--target <ref>", "destination (path-style ref, e.g. /demo-workspace#1234/general)").requiredOption("--stdin", "read the required UTF-8 message body from non-TTY stdin (max 1 KiB)").option("-a, --attachment <id>", "attach an uploaded file by id (repeatable — order = message order)", (v, prev = []) => [...prev, v], []).option("--force", "bypass duplicate detection only; channel alignment and other send checks still apply").option("--reply <seq>", 'reply to a message by its seq in --target (e.g. "#37" or 37)').requiredOption("--remind-after <0|Nm|Nh>", "required idle follow-up: 0 disables; 1m..24h arms/resets one same-scope timer; a newer message or daemon restart cancels it").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
91489
|
+
message.command("send").description("send a message to a channel, DM, or thread").option("--target <ref>", "destination (path-style ref, e.g. /demo-workspace#1234/general)").requiredOption("--stdin", "read the required UTF-8 message body from non-TTY stdin (max 1 KiB, or 8 KiB JSON with --ask)").option("--ask", "send a structured decision card from UTF-8 JSON on --stdin with required summary and questions (text channel, thread, or DM)").option("-a, --attachment <id>", "attach an uploaded file by id (repeatable — order = message order)", (v, prev = []) => [...prev, v], []).option("--force", "bypass duplicate detection only; channel alignment and other send checks still apply").option("--reply <seq>", 'reply to a message by its seq in --target (e.g. "#37" or 37)').requiredOption("--remind-after <0|Nm|Nh>", "required idle follow-up: 0 disables; 1m..24h arms/resets one same-scope timer; a newer message or daemon restart cancels it").exitOverride().configureOutput({ writeOut: () => {}, writeErr: () => {} }).action(async function() {
|
|
91174
91490
|
const localOpts = this.opts();
|
|
91175
91491
|
const globalOpts = program.opts();
|
|
91176
91492
|
const result2 = await cmdMessageSend({ ...globalOpts, ...localOpts }, stdin);
|
package/dist/index.js
CHANGED
|
@@ -59061,7 +59061,7 @@ var CommunityResourceProfileSchema = exports_external.strictObject({
|
|
|
59061
59061
|
statusText: exports_external.string().nullable().optional()
|
|
59062
59062
|
});
|
|
59063
59063
|
// ../shared/src/business-schema-version.ts
|
|
59064
|
-
var BUSINESS_SCHEMA_VERSION =
|
|
59064
|
+
var BUSINESS_SCHEMA_VERSION = 11;
|
|
59065
59065
|
|
|
59066
59066
|
// ../shared/src/community-contract.ts
|
|
59067
59067
|
var COMMUNITY_RESOURCE_CONTRACT_VERSION = BUSINESS_SCHEMA_VERSION;
|
|
@@ -59097,6 +59097,128 @@ var AgentModelReportSchema = exports_external.object({
|
|
|
59097
59097
|
observedAt: exports_external.string().datetime({ offset: true })
|
|
59098
59098
|
});
|
|
59099
59099
|
|
|
59100
|
+
// ../shared/src/community-decision-card.ts
|
|
59101
|
+
var DECISION_CARD_EMBED_KIND = "decision_card";
|
|
59102
|
+
var DECISION_CARD_EMBED_VERSION = 1;
|
|
59103
|
+
var DECISION_CARD_MAX_BYTES = 8 * 1024;
|
|
59104
|
+
var DECISION_CARD_MAX_MENTIONS = 20;
|
|
59105
|
+
var DECISION_CARD_MIN_QUESTIONS = 1;
|
|
59106
|
+
var DECISION_CARD_MAX_QUESTIONS = 4;
|
|
59107
|
+
var DECISION_CARD_MIN_OPTIONS = 2;
|
|
59108
|
+
var DECISION_CARD_MAX_OPTIONS = 6;
|
|
59109
|
+
var DECISION_CARD_ID_MAX_LENGTH = 40;
|
|
59110
|
+
var DECISION_CARD_SUMMARY_MAX_LENGTH = 240;
|
|
59111
|
+
var DECISION_CARD_HEADER_MAX_LENGTH = 24;
|
|
59112
|
+
var DECISION_CARD_QUESTION_MAX_LENGTH = 300;
|
|
59113
|
+
var DECISION_CARD_OPTION_LABEL_MAX_LENGTH = 120;
|
|
59114
|
+
var DECISION_CARD_OPTION_DESC_MAX_LENGTH = 240;
|
|
59115
|
+
var DECISION_CARD_OTHER_TEXT_MAX_LENGTH = 500;
|
|
59116
|
+
function decisionCardUtf8Bytes(value) {
|
|
59117
|
+
return new TextEncoder().encode(JSON.stringify(value)).byteLength;
|
|
59118
|
+
}
|
|
59119
|
+
var idFieldSchema = exports_external.string().trim().min(1).max(DECISION_CARD_ID_MAX_LENGTH).regex(/^[a-zA-Z0-9_-]+$/, "id must contain only letters, digits, hyphens, or underscores");
|
|
59120
|
+
var optionalTrimmedText = (max) => exports_external.string().trim().max(max).transform((value) => value.length > 0 ? value : undefined).optional();
|
|
59121
|
+
var requiredSummarySchema = exports_external.string().trim().min(1, "summary is required").max(DECISION_CARD_SUMMARY_MAX_LENGTH);
|
|
59122
|
+
var DecisionCardOptionInputSchema = exports_external.strictObject({
|
|
59123
|
+
id: idFieldSchema.optional(),
|
|
59124
|
+
label: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH),
|
|
59125
|
+
description: optionalTrimmedText(DECISION_CARD_OPTION_DESC_MAX_LENGTH),
|
|
59126
|
+
recommended: exports_external.boolean().optional()
|
|
59127
|
+
});
|
|
59128
|
+
var DecisionCardQuestionInputSchema = exports_external.strictObject({
|
|
59129
|
+
id: idFieldSchema.optional(),
|
|
59130
|
+
header: optionalTrimmedText(DECISION_CARD_HEADER_MAX_LENGTH),
|
|
59131
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
59132
|
+
multiSelect: exports_external.boolean().optional(),
|
|
59133
|
+
allowOther: exports_external.boolean().optional(),
|
|
59134
|
+
options: exports_external.array(DecisionCardOptionInputSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
59135
|
+
});
|
|
59136
|
+
function hasDuplicateIds(ids) {
|
|
59137
|
+
return new Set(ids).size !== ids.length;
|
|
59138
|
+
}
|
|
59139
|
+
var mentionHandleSchema = exports_external.string().trim().min(1).max(128).refine((value) => parseNameAndTag(value.startsWith("@") ? value.slice(1) : value) !== null, { message: 'mention must be a handle like "@alice#0001"' });
|
|
59140
|
+
var DecisionCardInputSchema = exports_external.strictObject({
|
|
59141
|
+
mentions: exports_external.array(mentionHandleSchema).max(DECISION_CARD_MAX_MENTIONS).optional(),
|
|
59142
|
+
summary: requiredSummarySchema,
|
|
59143
|
+
questions: exports_external.array(DecisionCardQuestionInputSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
59144
|
+
}).superRefine((value, ctx) => {
|
|
59145
|
+
const qIds = value.questions.map((q, index) => q.id ?? `q${index + 1}`);
|
|
59146
|
+
if (hasDuplicateIds(qIds)) {
|
|
59147
|
+
ctx.addIssue({
|
|
59148
|
+
code: "custom",
|
|
59149
|
+
path: ["questions"],
|
|
59150
|
+
message: "question ids must be unique"
|
|
59151
|
+
});
|
|
59152
|
+
}
|
|
59153
|
+
value.questions.forEach((q, qIndex) => {
|
|
59154
|
+
const optIds = q.options.map((opt, oIndex) => opt.id ?? `o${oIndex + 1}`);
|
|
59155
|
+
if (hasDuplicateIds(optIds)) {
|
|
59156
|
+
ctx.addIssue({
|
|
59157
|
+
code: "custom",
|
|
59158
|
+
path: ["questions", qIndex, "options"],
|
|
59159
|
+
message: "option ids must be unique within a question"
|
|
59160
|
+
});
|
|
59161
|
+
}
|
|
59162
|
+
});
|
|
59163
|
+
if (decisionCardUtf8Bytes(value) > DECISION_CARD_MAX_BYTES) {
|
|
59164
|
+
ctx.addIssue({
|
|
59165
|
+
code: "custom",
|
|
59166
|
+
path: [],
|
|
59167
|
+
message: `decision card exceeds ${DECISION_CARD_MAX_BYTES} bytes`
|
|
59168
|
+
});
|
|
59169
|
+
}
|
|
59170
|
+
});
|
|
59171
|
+
var DecisionCardCliOptionSchema = exports_external.union([
|
|
59172
|
+
exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH).transform((label2) => ({ label: label2 })),
|
|
59173
|
+
DecisionCardOptionInputSchema
|
|
59174
|
+
]);
|
|
59175
|
+
var DecisionCardCliInputSchema = exports_external.strictObject({
|
|
59176
|
+
mentions: exports_external.array(mentionHandleSchema).max(DECISION_CARD_MAX_MENTIONS).optional(),
|
|
59177
|
+
summary: requiredSummarySchema,
|
|
59178
|
+
questions: exports_external.array(exports_external.strictObject({
|
|
59179
|
+
id: idFieldSchema.optional(),
|
|
59180
|
+
header: optionalTrimmedText(DECISION_CARD_HEADER_MAX_LENGTH),
|
|
59181
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
59182
|
+
multiSelect: exports_external.boolean().optional(),
|
|
59183
|
+
allowOther: exports_external.boolean().optional(),
|
|
59184
|
+
options: exports_external.array(DecisionCardCliOptionSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
59185
|
+
})).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
59186
|
+
});
|
|
59187
|
+
var DecisionCardAssigneeSchema = exports_external.strictObject({
|
|
59188
|
+
userId: exports_external.string().min(1),
|
|
59189
|
+
handle: exports_external.string().min(1)
|
|
59190
|
+
});
|
|
59191
|
+
var DecisionCardNormalizedOptionSchema = exports_external.strictObject({
|
|
59192
|
+
id: idFieldSchema,
|
|
59193
|
+
label: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_LABEL_MAX_LENGTH),
|
|
59194
|
+
description: exports_external.string().trim().min(1).max(DECISION_CARD_OPTION_DESC_MAX_LENGTH).optional(),
|
|
59195
|
+
recommended: exports_external.boolean().optional()
|
|
59196
|
+
});
|
|
59197
|
+
var DecisionCardNormalizedQuestionSchema = exports_external.strictObject({
|
|
59198
|
+
id: idFieldSchema,
|
|
59199
|
+
header: exports_external.string().trim().min(1).max(DECISION_CARD_HEADER_MAX_LENGTH).optional(),
|
|
59200
|
+
question: exports_external.string().trim().min(1).max(DECISION_CARD_QUESTION_MAX_LENGTH),
|
|
59201
|
+
multiSelect: exports_external.boolean(),
|
|
59202
|
+
allowOther: exports_external.boolean(),
|
|
59203
|
+
options: exports_external.array(DecisionCardNormalizedOptionSchema).min(DECISION_CARD_MIN_OPTIONS).max(DECISION_CARD_MAX_OPTIONS)
|
|
59204
|
+
});
|
|
59205
|
+
var DecisionCardEmbedSchema = exports_external.strictObject({
|
|
59206
|
+
kind: exports_external.literal(DECISION_CARD_EMBED_KIND),
|
|
59207
|
+
version: exports_external.literal(DECISION_CARD_EMBED_VERSION),
|
|
59208
|
+
summary: exports_external.string().trim().min(1).max(DECISION_CARD_SUMMARY_MAX_LENGTH).optional(),
|
|
59209
|
+
assignees: exports_external.array(DecisionCardAssigneeSchema).max(DECISION_CARD_MAX_MENTIONS),
|
|
59210
|
+
questions: exports_external.array(DecisionCardNormalizedQuestionSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS),
|
|
59211
|
+
respondedUserIds: exports_external.array(exports_external.string().min(1)).optional()
|
|
59212
|
+
});
|
|
59213
|
+
var DecisionCardAnswerItemSchema = exports_external.strictObject({
|
|
59214
|
+
questionId: idFieldSchema,
|
|
59215
|
+
selectedOptionIds: exports_external.array(idFieldSchema).max(DECISION_CARD_MAX_OPTIONS).optional(),
|
|
59216
|
+
otherText: exports_external.string().trim().max(DECISION_CARD_OTHER_TEXT_MAX_LENGTH).optional()
|
|
59217
|
+
});
|
|
59218
|
+
var DecisionCardAnswerInputSchema = exports_external.strictObject({
|
|
59219
|
+
answers: exports_external.array(DecisionCardAnswerItemSchema).min(DECISION_CARD_MIN_QUESTIONS).max(DECISION_CARD_MAX_QUESTIONS)
|
|
59220
|
+
});
|
|
59221
|
+
|
|
59100
59222
|
// ../shared/src/provider-telemetry.ts
|
|
59101
59223
|
var DAILY_TOKEN_USAGE_WINDOW_DAYS = 30;
|
|
59102
59224
|
var PROVIDER_QUOTA_BACKENDS = ["claude", "codex", "codex-app", "codex-cli", "grok", "antigravity", "cursor", "cursor-sdk", "copilot", "qoder", "agy"];
|
|
@@ -59521,12 +59643,38 @@ var CommunityAgentCursorSchema = exports_external.object({
|
|
|
59521
59643
|
var CommunityAgentSendRequestSchema = exports_external.object({
|
|
59522
59644
|
channel: exports_external.string().min(1),
|
|
59523
59645
|
content: CommunityAgentMessageContentSchema,
|
|
59646
|
+
question: DecisionCardInputSchema.optional(),
|
|
59524
59647
|
attachments: exports_external.array(exports_external.string().min(1)).max(MAX_ATTACHMENTS_PER_MESSAGE).default([]),
|
|
59525
59648
|
seenUpToSeq: CommunityAgentSeqSchema.optional(),
|
|
59526
59649
|
replyToSeq: CommunityAgentPositiveSeqSchema.optional(),
|
|
59527
59650
|
force: exports_external.boolean().optional(),
|
|
59528
59651
|
nonce: exports_external.string().min(1).max(128).optional()
|
|
59529
|
-
}).
|
|
59652
|
+
}).superRefine((d, ctx) => {
|
|
59653
|
+
if (d.question !== undefined) {
|
|
59654
|
+
if (d.attachments.length > 0) {
|
|
59655
|
+
ctx.addIssue({
|
|
59656
|
+
code: "custom",
|
|
59657
|
+
path: ["attachments"],
|
|
59658
|
+
message: "decision card messages cannot include attachments"
|
|
59659
|
+
});
|
|
59660
|
+
}
|
|
59661
|
+
if (d.content.text.trim().length > 0) {
|
|
59662
|
+
ctx.addIssue({
|
|
59663
|
+
code: "custom",
|
|
59664
|
+
path: ["content", "text"],
|
|
59665
|
+
message: "decision card messages must omit content.text"
|
|
59666
|
+
});
|
|
59667
|
+
}
|
|
59668
|
+
return;
|
|
59669
|
+
}
|
|
59670
|
+
if (d.content.text.trim().length === 0 && d.attachments.length === 0) {
|
|
59671
|
+
ctx.addIssue({
|
|
59672
|
+
code: "custom",
|
|
59673
|
+
path: [],
|
|
59674
|
+
message: "message must have text or attachments"
|
|
59675
|
+
});
|
|
59676
|
+
}
|
|
59677
|
+
});
|
|
59530
59678
|
var CommunityAgentAttachmentUploadResponseSchema = exports_external.object({
|
|
59531
59679
|
id: exports_external.string(),
|
|
59532
59680
|
filename: exports_external.string(),
|
|
@@ -59819,7 +59967,7 @@ var CommunityMessageResourceSchema = exports_external.strictObject({
|
|
|
59819
59967
|
seq: exports_external.number().int().nonnegative(),
|
|
59820
59968
|
authorId: id2,
|
|
59821
59969
|
createdAt: exports_external.string(),
|
|
59822
|
-
type: exports_external.enum(["chat", "system"]),
|
|
59970
|
+
type: exports_external.enum(["chat", "system", "question"]),
|
|
59823
59971
|
content: exports_external.string(),
|
|
59824
59972
|
replyToId: nullableId,
|
|
59825
59973
|
clientNonce: exports_external.string().nullable(),
|
|
@@ -59912,11 +60060,18 @@ var CommunityResourceBundleSchema = CommunityMessageResourcesSchema.safeExtend({
|
|
|
59912
60060
|
servers: exports_external.array(CommunityServerResourceSchema),
|
|
59913
60061
|
serverMemberships: exports_external.array(CommunityServerMembershipResourceSchema),
|
|
59914
60062
|
channels: exports_external.array(CommunityChannelResourceSchema),
|
|
59915
|
-
memberships: exports_external.array(CommunityChannelMembershipResourceSchema)
|
|
60063
|
+
memberships: exports_external.array(CommunityChannelMembershipResourceSchema),
|
|
60064
|
+
categories: exports_external.array(CommunityCategoryResourceSchema).optional(),
|
|
60065
|
+
dmPeers: exports_external.array(exports_external.strictObject({ channelId: id2, userId: id2 })).optional()
|
|
59916
60066
|
}).superRefine((bundle, ctx) => {
|
|
59917
60067
|
const channels = new Set(bundle.channels.map((row) => row.id));
|
|
59918
60068
|
const servers = new Set(bundle.servers.map((row) => row.id));
|
|
59919
|
-
|
|
60069
|
+
const categories = bundle.categories ?? [];
|
|
60070
|
+
const dmPeers = bundle.dmPeers ?? [];
|
|
60071
|
+
const dmChannels = new Set(bundle.channels.filter((row) => row.type === "dm").map((row) => row.id));
|
|
60072
|
+
const profiles = new Set(bundle.profiles.map((row) => row.id));
|
|
60073
|
+
const readableCategories = new Map(bundle.channels.flatMap((row) => row.categoryId ? [[row.categoryId, row.serverId]] : []));
|
|
60074
|
+
if (channels.size !== bundle.channels.length || servers.size !== bundle.servers.length || new Set(categories.map((row) => row.id)).size !== categories.length || categories.some((row) => readableCategories.get(row.id) !== row.serverId) || new Set(dmPeers.map((row) => row.channelId)).size !== dmPeers.length || dmPeers.some((row) => !dmChannels.has(row.channelId) || row.userId === bundle.viewerId || !profiles.has(row.userId)) || new Set(bundle.messages.map((row) => row.id)).size !== bundle.messages.length || profiles.size !== bundle.profiles.length || new Set(bundle.memberships.map((row) => `${row.channelId}:${row.userId}:${row.relation}`)).size !== bundle.memberships.length || new Set(bundle.serverMemberships.map((row) => `${row.serverId}:${row.userId}`)).size !== bundle.serverMemberships.length || bundle.messages.some((row) => !channels.has(row.channelId)) || bundle.servers.some((row) => !bundle.serverMemberships.some((member) => member.serverId === row.id && member.userId === bundle.viewerId)) || bundle.channels.some((row) => !bundle.memberships.some((member) => member.channelId === row.id && member.userId === bundle.viewerId && member.relation === "access")) || bundle.channels.some((row) => row.serverId !== null && !servers.has(row.serverId) || row.parentChannelId !== null && !channels.has(row.parentChannelId)) || bundle.memberships.some((row) => row.userId !== bundle.viewerId || !channels.has(row.channelId)) || bundle.serverMemberships.some((row) => row.userId !== bundle.viewerId || !servers.has(row.serverId)))
|
|
59920
60075
|
ctx.addIssue({ code: "custom", message: "Resource bundle scope mismatch" });
|
|
59921
60076
|
});
|
|
59922
60077
|
var CommunityChannelReadSchema = exports_external.strictObject({ ...envelope, channel: CommunityChannelResourceSchema, access: CommunityAccessDecisionSchema });
|
|
@@ -60039,7 +60194,7 @@ var AttentionScopeSchema = exports_external.strictObject({
|
|
|
60039
60194
|
});
|
|
60040
60195
|
var AttentionItemSchema = exports_external.strictObject({
|
|
60041
60196
|
id: id3,
|
|
60042
|
-
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post"]),
|
|
60197
|
+
kind: exports_external.enum(["mention", "reply", "friend_request", "forum_post", "question"]),
|
|
60043
60198
|
sourceId: id3,
|
|
60044
60199
|
scopeId: id3.nullable().optional(),
|
|
60045
60200
|
messageId: id3.nullable().optional(),
|
|
@@ -60074,7 +60229,7 @@ var AttentionItemSchema = exports_external.strictObject({
|
|
|
60074
60229
|
ctx.addIssue({ code: "custom", message: "message attention requires an actor" });
|
|
60075
60230
|
}
|
|
60076
60231
|
if (item.childChannelId || item.openerSeq !== undefined || item.readTarget) {
|
|
60077
|
-
ctx.addIssue({ code: "custom", message: "
|
|
60232
|
+
ctx.addIssue({ code: "custom", message: "message attention cannot carry forum presentation refs" });
|
|
60078
60233
|
}
|
|
60079
60234
|
});
|
|
60080
60235
|
var AttentionIncludedServerSchema = CommunityServerResourceSchema.pick({ id: true, name: true, discriminator: true });
|
|
@@ -60130,6 +60285,7 @@ var AccountAttentionProjectionSchema = exports_external.strictObject({
|
|
|
60130
60285
|
items: exports_external.array(AttentionItemSchema),
|
|
60131
60286
|
limit: exports_external.number().int().positive(),
|
|
60132
60287
|
truncated: exports_external.boolean(),
|
|
60288
|
+
todosTruncated: exports_external.boolean().optional(),
|
|
60133
60289
|
included: AttentionIncludedSchema
|
|
60134
60290
|
});
|
|
60135
60291
|
var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
@@ -60192,7 +60348,7 @@ var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
|
60192
60348
|
ctx.addIssue({ code: "custom", message: `duplicate attention item: ${item.id}` });
|
|
60193
60349
|
}
|
|
60194
60350
|
itemIds.add(item.id);
|
|
60195
|
-
if (item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
60351
|
+
if (item.kind !== "question" && item.scopeId && !scopeIds.has(item.scopeId)) {
|
|
60196
60352
|
ctx.addIssue({ code: "custom", message: `attention item references missing scope: ${item.scopeId}` });
|
|
60197
60353
|
}
|
|
60198
60354
|
if (item.kind === "friend_request") {
|
|
@@ -60201,6 +60357,16 @@ var AccountAttentionSnapshotSchema = AccountAttentionProjectionSchema.extend({
|
|
|
60201
60357
|
}
|
|
60202
60358
|
continue;
|
|
60203
60359
|
}
|
|
60360
|
+
if (item.kind === "question") {
|
|
60361
|
+
const message2 = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
60362
|
+
const channel = item.scopeId ? channelById.get(item.scopeId) : undefined;
|
|
60363
|
+
const dm = item.scopeId ? dmById.get(item.scopeId) : undefined;
|
|
60364
|
+
const ownerValid = Boolean(channel && serverById.has(channel.serverId) || dm && profileById.has(dm.userId));
|
|
60365
|
+
if (!item.scopeId || !message2 || message2.channelId !== item.scopeId || !item.actorUserId || !profileById.has(item.actorUserId) || !ownerValid) {
|
|
60366
|
+
ctx.addIssue({ code: "custom", message: `question attention references incomplete owners: ${item.id}` });
|
|
60367
|
+
}
|
|
60368
|
+
continue;
|
|
60369
|
+
}
|
|
60204
60370
|
const scope = item.scopeId ? snapshot.scopes.find((candidate) => candidate.scopeId === item.scopeId) : undefined;
|
|
60205
60371
|
const message = item.messageId ? messageById.get(item.messageId) : undefined;
|
|
60206
60372
|
if (!scope || !message) {
|
|
@@ -61079,6 +61245,9 @@ function and(...unfilteredConditions) {
|
|
|
61079
61245
|
new StringChunk(")")
|
|
61080
61246
|
]);
|
|
61081
61247
|
}
|
|
61248
|
+
function isNull(value) {
|
|
61249
|
+
return sql`${value} is null`;
|
|
61250
|
+
}
|
|
61082
61251
|
function isNotNull(value) {
|
|
61083
61252
|
return sql`${value} is not null`;
|
|
61084
61253
|
}
|
|
@@ -61101,6 +61270,7 @@ __export(exports_community_schema, {
|
|
|
61101
61270
|
communityReadStateRevision: () => communityReadStateRevision,
|
|
61102
61271
|
communityReadState: () => communityReadState,
|
|
61103
61272
|
communityReaction: () => communityReaction,
|
|
61273
|
+
communityQuestionTodo: () => communityQuestionTodo,
|
|
61104
61274
|
communityPushDevice: () => communityPushDevice,
|
|
61105
61275
|
communityPin: () => communityPin,
|
|
61106
61276
|
communityNotificationSetting: () => communityNotificationSetting,
|
|
@@ -62068,7 +62238,20 @@ var communityMessage = sqliteTable("community_message", {
|
|
|
62068
62238
|
}, (t) => [
|
|
62069
62239
|
index("idx_community_message_author_id_lookup").on(t.authorId),
|
|
62070
62240
|
index("idx_message_channel_created").on(t.channelId, t.createdAt),
|
|
62071
|
-
index("idx_message_channel_mention_created").on(t.channelId, t.mentionType, t.createdAt)
|
|
62241
|
+
index("idx_message_channel_mention_created").on(t.channelId, t.mentionType, t.createdAt),
|
|
62242
|
+
index("idx_community_message_channel_reply_author").on(t.channelId, t.replyToId, t.authorId).where(sql`${t.replyToId} IS NOT NULL`)
|
|
62243
|
+
]);
|
|
62244
|
+
var communityQuestionTodo = sqliteTable("community_question_todo", {
|
|
62245
|
+
userId: text2("user_id").notNull().references(() => user.id, { onDelete: "cascade" }),
|
|
62246
|
+
messageId: text2("message_id").notNull().references(() => communityMessage.id, { onDelete: "cascade" }),
|
|
62247
|
+
channelId: text2("channel_id").notNull().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
62248
|
+
createdAt: text2("created_at").notNull().$defaultFn(() => new Date().toISOString()),
|
|
62249
|
+
dismissedAt: text2("dismissed_at")
|
|
62250
|
+
}, (t) => [
|
|
62251
|
+
primaryKey({ columns: [t.userId, t.messageId] }),
|
|
62252
|
+
index("idx_community_question_todo_user_active").on(t.userId, desc(t.createdAt), desc(t.messageId)).where(isNull(t.dismissedAt)),
|
|
62253
|
+
index("idx_community_question_todo_message_id_lookup").on(t.messageId),
|
|
62254
|
+
index("idx_community_question_todo_channel_id_lookup").on(t.channelId)
|
|
62072
62255
|
]);
|
|
62073
62256
|
var communityMessageSeq = sqliteTable("community_message_seq", {
|
|
62074
62257
|
channelId: text2("channel_id").primaryKey().references(() => communityChannel.id, { onDelete: "cascade" }),
|
|
@@ -62735,7 +62918,9 @@ var AGENT_MESSAGE_COLUMNS = {
|
|
|
62735
62918
|
createdAt: communityMessage.createdAt,
|
|
62736
62919
|
channelId: communityMessage.channelId,
|
|
62737
62920
|
seq: communityMessage.seq,
|
|
62738
|
-
replyToId: communityMessage.replyToId
|
|
62921
|
+
replyToId: communityMessage.replyToId,
|
|
62922
|
+
type: communityMessage.type,
|
|
62923
|
+
embeds: communityMessage.embeds
|
|
62739
62924
|
};
|
|
62740
62925
|
var channelJoinBaselineGuard = sql`${communityMessage.createdAt} > COALESCE(${communityChannelMember.addedAt}, ${communityServerMember.joinedAt}, '')`;
|
|
62741
62926
|
var AGENT_UNREAD_CHANNEL_CHUNK_SIZE = maxInParams(13);
|
|
@@ -62983,6 +63168,7 @@ var communityInboxChangedSchema = exports_external.strictObject({
|
|
|
62983
63168
|
"read_all",
|
|
62984
63169
|
"mention_read_all",
|
|
62985
63170
|
"mention_dismiss",
|
|
63171
|
+
"todo_dismiss",
|
|
62986
63172
|
"notification_policy"
|
|
62987
63173
|
])
|
|
62988
63174
|
});
|
|
@@ -77855,6 +78041,15 @@ function messagingSection() {
|
|
|
77855
78041
|
"ALOOK_MESSAGE_7F3C",
|
|
77856
78042
|
"```",
|
|
77857
78043
|
"",
|
|
78044
|
+
"#### Ask for a decision",
|
|
78045
|
+
"",
|
|
78046
|
+
`Alook users cannot see native question prompts. When you need someone to choose from options, use \`${CLI} message send --ask\` with JSON on stdin (max 8 KiB).`,
|
|
78047
|
+
"Include a required non-empty `summary` (1–240 chars). Recommend at least one option per question to help the user decide. Use `recommended: true`. Use `mentions` to name respondents, and short `header` values for multi-question tabs. Answers arrive in your inbox as replies to the original question.",
|
|
78048
|
+
"",
|
|
78049
|
+
"```json",
|
|
78050
|
+
`{"mentions":["@alice#0001"],"summary":"Confirm today's release","questions":[{"question":"Ship today?","options":[{"label":"Ship","recommended":true},"Wait"]}]}`,
|
|
78051
|
+
"```",
|
|
78052
|
+
"",
|
|
77858
78053
|
"#### Pulled messages",
|
|
77859
78054
|
"",
|
|
77860
78055
|
"```json",
|
|
@@ -77924,7 +78119,7 @@ function cliCommandsSection() {
|
|
|
77924
78119
|
"### Messaging",
|
|
77925
78120
|
"",
|
|
77926
78121
|
`1. \`${CLI} inbox pull\` — fetch unread messages and advance their read waterlines.`,
|
|
77927
|
-
`2. \`${CLI} message send --target <ref> --remind-after <0|Nm|Nh> --stdin\` —
|
|
78122
|
+
`2. \`${CLI} message send --target <ref> --remind-after <0|Nm|Nh> [--ask] --stdin\` — Send to a ` + `channel, DM, or thread. ` + `For plain messages, pass up to 1 KiB of UTF-8 text through stdin and use \`--attachment <id>\` for files (repeatable, order matters). ` + `\`--remind-after\` accepts \`0\` or a whole-number duration from \`1m\` to \`24h\`.`,
|
|
77928
78123
|
`3. \`${CLI} message attachment upload --file <path>\` — upload a local file and get a reusable attachment ID. Supports Markdown and inline HTML; see Communication for formatting.`,
|
|
77929
78124
|
`4. \`${CLI} message attachment download --id <id> [--out <path>]\` — download an attachment you can read, including your own unsent uploads.`,
|
|
77930
78125
|
`5. \`${CLI} message property set --target <full-message-ref> --json <json>\` — add a supported property value to a message.`,
|
|
@@ -81059,12 +81254,75 @@ async function handleLocalPii(request, response, botId, pii) {
|
|
|
81059
81254
|
writePiiError(response, error62);
|
|
81060
81255
|
}
|
|
81061
81256
|
}
|
|
81257
|
+
async function filterQuestionPii(rawQuestion, botId, pii) {
|
|
81258
|
+
const parsed = DecisionCardInputSchema.safeParse(rawQuestion);
|
|
81259
|
+
if (!parsed.success)
|
|
81260
|
+
throw new PiiError("PII_INVALID_REQUEST");
|
|
81261
|
+
const triggeredById = new Map;
|
|
81262
|
+
const runField = async (value) => {
|
|
81263
|
+
const result2 = await pii.filterWithResult(botId, value);
|
|
81264
|
+
for (const filter of result2.triggeredFilters) {
|
|
81265
|
+
if (!triggeredById.has(filter.id))
|
|
81266
|
+
triggeredById.set(filter.id, filter);
|
|
81267
|
+
}
|
|
81268
|
+
return result2.text;
|
|
81269
|
+
};
|
|
81270
|
+
const source = parsed.data;
|
|
81271
|
+
const summary = await runField(source.summary);
|
|
81272
|
+
const questions = [];
|
|
81273
|
+
for (const question of source.questions) {
|
|
81274
|
+
const header = question.header !== undefined ? await runField(question.header) : undefined;
|
|
81275
|
+
const prompt = await runField(question.question);
|
|
81276
|
+
const options = [];
|
|
81277
|
+
for (const option of question.options) {
|
|
81278
|
+
const label2 = await runField(option.label);
|
|
81279
|
+
const description = option.description !== undefined ? await runField(option.description) : undefined;
|
|
81280
|
+
options.push({
|
|
81281
|
+
...option.id !== undefined ? { id: option.id } : {},
|
|
81282
|
+
label: label2,
|
|
81283
|
+
...description !== undefined ? { description } : {},
|
|
81284
|
+
...option.recommended !== undefined ? { recommended: option.recommended } : {}
|
|
81285
|
+
});
|
|
81286
|
+
}
|
|
81287
|
+
questions.push({
|
|
81288
|
+
...question.id !== undefined ? { id: question.id } : {},
|
|
81289
|
+
...header !== undefined ? { header } : {},
|
|
81290
|
+
question: prompt,
|
|
81291
|
+
...question.multiSelect !== undefined ? { multiSelect: question.multiSelect } : {},
|
|
81292
|
+
...question.allowOther !== undefined ? { allowOther: question.allowOther } : {},
|
|
81293
|
+
options
|
|
81294
|
+
});
|
|
81295
|
+
}
|
|
81296
|
+
const filtered = {
|
|
81297
|
+
...source.mentions !== undefined ? { mentions: source.mentions } : {},
|
|
81298
|
+
summary,
|
|
81299
|
+
questions
|
|
81300
|
+
};
|
|
81301
|
+
if (decisionCardUtf8Bytes(filtered) > DECISION_CARD_MAX_BYTES) {
|
|
81302
|
+
throw new PiiError("PII_OUTPUT_TOO_LARGE");
|
|
81303
|
+
}
|
|
81304
|
+
const validated = DecisionCardInputSchema.safeParse(filtered);
|
|
81305
|
+
if (!validated.success)
|
|
81306
|
+
throw new PiiError("PII_INVALID_RESULT");
|
|
81307
|
+
return { question: validated.data, triggeredFilters: [...triggeredById.values()] };
|
|
81308
|
+
}
|
|
81062
81309
|
async function filterPiiRequest(request, botId, pii) {
|
|
81063
81310
|
const body = await readJson2(request);
|
|
81064
81311
|
const content3 = body.content;
|
|
81065
81312
|
if (!content3 || typeof content3 !== "object" || Array.isArray(content3) || content3.text !== undefined && typeof content3.text !== "string") {
|
|
81066
81313
|
throw new PiiError("PII_INVALID_REQUEST");
|
|
81067
81314
|
}
|
|
81315
|
+
if (body.question !== undefined) {
|
|
81316
|
+
if ((content3.text ?? "").trim().length > 0) {
|
|
81317
|
+
throw new PiiError("PII_INVALID_REQUEST");
|
|
81318
|
+
}
|
|
81319
|
+
const filteredQuestion = await filterQuestionPii(body.question, botId, pii);
|
|
81320
|
+
body.content = { ...content3, text: "" };
|
|
81321
|
+
body.question = filteredQuestion.question;
|
|
81322
|
+
if (!CommunityAgentSendRequestSchema.safeParse(body).success)
|
|
81323
|
+
throw new PiiError("PII_INVALID_RESULT");
|
|
81324
|
+
return { body: Buffer.from(JSON.stringify(body)), triggeredFilters: filteredQuestion.triggeredFilters };
|
|
81325
|
+
}
|
|
81068
81326
|
const { text: text8, triggeredFilters } = await pii.filterWithResult(botId, content3.text ?? "");
|
|
81069
81327
|
if (Buffer.byteLength(text8, "utf8") > PII_TEXT_MAX_BYTES)
|
|
81070
81328
|
throw new PiiError("PII_OUTPUT_TOO_LARGE");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alook/daemon",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.71",
|
|
4
4
|
"description": "Alook agent daemon — host-side runtime backend, process manager, credential proxy, and control plane.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/alookai/alook#readme",
|