@songsid/agend 2.4.0-beta.10 → 2.4.0-beta.12
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/accounts-view.d.ts +29 -0
- package/dist/accounts-view.js +2 -14
- package/dist/accounts-view.js.map +1 -1
- package/dist/agent-endpoint.d.ts +1 -0
- package/dist/agent-endpoint.js +4 -2
- package/dist/agent-endpoint.js.map +1 -1
- package/dist/auth-api.d.ts +2 -0
- package/dist/auth-api.js +29 -2
- package/dist/auth-api.js.map +1 -1
- package/dist/backend/claude-code.js +35 -9
- package/dist/backend/claude-code.js.map +1 -1
- package/dist/backend/codex-precaution.d.ts +7 -0
- package/dist/backend/codex-precaution.js +102 -0
- package/dist/backend/codex-precaution.js.map +1 -0
- package/dist/backend/codex.d.ts +1 -0
- package/dist/backend/codex.js +18 -0
- package/dist/backend/codex.js.map +1 -1
- package/dist/backend/grok.js +21 -6
- package/dist/backend/grok.js.map +1 -1
- package/dist/backend/types.d.ts +9 -1
- package/dist/backend/types.js.map +1 -1
- package/dist/build-provenance.json +1 -1
- package/dist/channel/mcp-server.js +1 -1
- package/dist/channel/mcp-server.js.map +1 -1
- package/dist/channel/mcp-tools.js +3 -1
- package/dist/channel/mcp-tools.js.map +1 -1
- package/dist/claude-install-kind.d.ts +19 -0
- package/dist/claude-install-kind.js +54 -0
- package/dist/claude-install-kind.js.map +1 -0
- package/dist/cli-audited.js +3 -3
- package/dist/cli-audited.js.map +1 -1
- package/dist/daemon.d.ts +5 -0
- package/dist/daemon.js +22 -4
- package/dist/daemon.js.map +1 -1
- package/dist/event-log.d.ts +12 -0
- package/dist/event-log.js +40 -0
- package/dist/event-log.js.map +1 -1
- package/dist/fleet-manager.d.ts +122 -2
- package/dist/fleet-manager.js +482 -27
- package/dist/fleet-manager.js.map +1 -1
- package/dist/general-knowledge/skills/hub/SKILL.md +38 -6
- package/dist/general-knowledge/skills/web-dashboard/SKILL.md +16 -1
- package/dist/hub/admin-dashboard.js +3 -3
- package/dist/hub/admin-dashboard.js.map +1 -1
- package/dist/hub/agent-catalog-model.d.ts +276 -0
- package/dist/hub/agent-catalog-model.js +49 -0
- package/dist/hub/agent-catalog-model.js.map +1 -0
- package/dist/hub/agent-catalog.d.ts +137 -0
- package/dist/hub/agent-catalog.js +118 -0
- package/dist/hub/agent-catalog.js.map +1 -0
- package/dist/hub/agent-intro-model.d.ts +38 -0
- package/dist/hub/agent-intro-model.js +14 -0
- package/dist/hub/agent-intro-model.js.map +1 -0
- package/dist/hub/agent-intro-tool.d.ts +35 -0
- package/dist/hub/agent-intro-tool.js +83 -0
- package/dist/hub/agent-intro-tool.js.map +1 -0
- package/dist/hub/agent-intro.d.ts +31 -0
- package/dist/hub/agent-intro.js +51 -0
- package/dist/hub/agent-intro.js.map +1 -0
- package/dist/hub/catalog.d.ts +4 -2
- package/dist/hub/catalog.js +19 -3
- package/dist/hub/catalog.js.map +1 -1
- package/dist/hub/client.d.ts +3 -0
- package/dist/hub/client.js +47 -1
- package/dist/hub/client.js.map +1 -1
- package/dist/hub/compose/member.d.ts +19 -5
- package/dist/hub/compose/member.js +94 -13
- package/dist/hub/compose/member.js.map +1 -1
- package/dist/hub/compose/server.d.ts +5 -0
- package/dist/hub/compose/server.js +6 -1
- package/dist/hub/compose/server.js.map +1 -1
- package/dist/hub/execution/service.d.ts +1 -1
- package/dist/hub/execution/service.js +1 -0
- package/dist/hub/execution/service.js.map +1 -1
- package/dist/hub/http/compose.d.ts +3 -0
- package/dist/hub/http/compose.js +122 -15
- package/dist/hub/http/compose.js.map +1 -1
- package/dist/hub/http/schema.js +15 -0
- package/dist/hub/http/schema.js.map +1 -1
- package/dist/hub/mcp/tools.js +2 -1
- package/dist/hub/mcp/tools.js.map +1 -1
- package/dist/hub/member/agent-catalog.d.ts +28 -0
- package/dist/hub/member/agent-catalog.js +80 -0
- package/dist/hub/member/agent-catalog.js.map +1 -0
- package/dist/hub/member/agent-intro.d.ts +28 -0
- package/dist/hub/member/agent-intro.js +66 -0
- package/dist/hub/member/agent-intro.js.map +1 -0
- package/dist/hub/member/exposure-api.d.ts +3 -3
- package/dist/hub/member/exposure-api.js +4 -4
- package/dist/hub/member/exposure-api.js.map +1 -1
- package/dist/hub/member/exposures.d.ts +12 -4
- package/dist/hub/member/exposures.js +27 -13
- package/dist/hub/member/exposures.js.map +1 -1
- package/dist/hub/member/room-ask.d.ts +14 -1
- package/dist/hub/member/room-ask.js +76 -10
- package/dist/hub/member/room-ask.js.map +1 -1
- package/dist/hub/member/room-context-budget.d.ts +5 -0
- package/dist/hub/member/room-context-budget.js +34 -0
- package/dist/hub/member/room-context-budget.js.map +1 -0
- package/dist/hub/member/room-notification.d.ts +1 -1
- package/dist/hub/member/room-post.d.ts +6 -3
- package/dist/hub/member/room-post.js +9 -3
- package/dist/hub/member/room-post.js.map +1 -1
- package/dist/hub/member/sharing-journal.d.ts +252 -0
- package/dist/hub/member/sharing-journal.js +212 -0
- package/dist/hub/member/sharing-journal.js.map +1 -0
- package/dist/hub/member/sharing-link.d.ts +25 -0
- package/dist/hub/member/sharing-link.js +68 -0
- package/dist/hub/member/sharing-link.js.map +1 -0
- package/dist/hub/member/sharing-result.d.ts +6 -0
- package/dist/hub/member/sharing-result.js +46 -0
- package/dist/hub/member/sharing-result.js.map +1 -0
- package/dist/hub/member/sharing.d.ts +37 -0
- package/dist/hub/member/sharing.js +181 -0
- package/dist/hub/member/sharing.js.map +1 -0
- package/dist/hub/personal/owner-host.d.ts +6 -0
- package/dist/hub/personal/owner-host.js +4 -2
- package/dist/hub/personal/owner-host.js.map +1 -1
- package/dist/hub/protocol.d.ts +398 -4
- package/dist/hub/protocol.js +13 -5
- package/dist/hub/protocol.js.map +1 -1
- package/dist/hub/room-answer-status-model.d.ts +3 -0
- package/dist/hub/room-answer-status-model.js +4 -0
- package/dist/hub/room-answer-status-model.js.map +1 -0
- package/dist/hub/room-brief-model.d.ts +30 -0
- package/dist/hub/room-brief-model.js +37 -0
- package/dist/hub/room-brief-model.js.map +1 -0
- package/dist/hub/room-context-model.d.ts +2 -0
- package/dist/hub/room-context-model.js +2 -2
- package/dist/hub/room-context-model.js.map +1 -1
- package/dist/hub/room-members-model.d.ts +63 -0
- package/dist/hub/room-members-model.js +7 -0
- package/dist/hub/room-members-model.js.map +1 -0
- package/dist/hub/rooms/agents.d.ts +1 -0
- package/dist/hub/rooms/agents.js +62 -11
- package/dist/hub/rooms/agents.js.map +1 -1
- package/dist/hub/rooms/brief.d.ts +18 -0
- package/dist/hub/rooms/brief.js +39 -0
- package/dist/hub/rooms/brief.js.map +1 -0
- package/dist/hub/rooms/direct-view.d.ts +5 -1
- package/dist/hub/rooms/direct-view.js +2 -2
- package/dist/hub/rooms/direct-view.js.map +1 -1
- package/dist/hub/rooms/members-page.d.ts +33 -0
- package/dist/hub/rooms/members-page.js +37 -0
- package/dist/hub/rooms/members-page.js.map +1 -0
- package/dist/hub/rooms/purpose.d.ts +7 -0
- package/dist/hub/rooms/purpose.js +14 -0
- package/dist/hub/rooms/purpose.js.map +1 -0
- package/dist/hub/rooms/service.d.ts +43 -0
- package/dist/hub/rooms/service.js +80 -22
- package/dist/hub/rooms/service.js.map +1 -1
- package/dist/hub/rooms/types.d.ts +6 -1
- package/dist/hub/rooms.d.ts +1 -0
- package/dist/hub/rooms.js +9 -4
- package/dist/hub/rooms.js.map +1 -1
- package/dist/hub/runtime.d.ts +1 -1
- package/dist/hub/server.js +49 -1
- package/dist/hub/server.js.map +1 -1
- package/dist/hub/sharing-previous-access.d.ts +22 -0
- package/dist/hub/sharing-previous-access.js +93 -0
- package/dist/hub/sharing-previous-access.js.map +1 -0
- package/dist/hub/sharing-requests.d.ts +171 -0
- package/dist/hub/sharing-requests.js +311 -0
- package/dist/hub/sharing-requests.js.map +1 -0
- package/dist/hub/sharing-retention.d.ts +47 -0
- package/dist/hub/sharing-retention.js +83 -0
- package/dist/hub/sharing-retention.js.map +1 -0
- package/dist/hub/sharing-withdrawal.d.ts +14 -0
- package/dist/hub/sharing-withdrawal.js +28 -0
- package/dist/hub/sharing-withdrawal.js.map +1 -0
- package/dist/hub/types.d.ts +13 -5
- package/dist/hub-page-sharing-settings.d.ts +6 -0
- package/dist/hub-page-sharing-settings.js +19 -0
- package/dist/hub-page-sharing-settings.js.map +1 -0
- package/dist/hub-room-reply-warning.d.ts +2 -0
- package/dist/hub-room-reply-warning.js +16 -0
- package/dist/hub-room-reply-warning.js.map +1 -0
- package/dist/hub-sharing-notice.d.ts +43 -0
- package/dist/hub-sharing-notice.js +34 -0
- package/dist/hub-sharing-notice.js.map +1 -0
- package/dist/instance-lifecycle.d.ts +15 -0
- package/dist/instance-lifecycle.js +36 -1
- package/dist/instance-lifecycle.js.map +1 -1
- package/dist/locale.js +78 -0
- package/dist/locale.js.map +1 -1
- package/dist/login-controller.d.ts +26 -0
- package/dist/login-controller.js +72 -2
- package/dist/login-controller.js.map +1 -1
- package/dist/login-flows.js +1 -1
- package/dist/login-flows.js.map +1 -1
- package/dist/native-mcp.js +1 -1
- package/dist/native-mcp.js.map +1 -1
- package/dist/needs-you-hub.js +1 -1
- package/dist/needs-you-hub.js.map +1 -1
- package/dist/needs-you.d.ts +8 -1
- package/dist/needs-you.js +6 -0
- package/dist/needs-you.js.map +1 -1
- package/dist/office-share-page.js +1 -1
- package/dist/office-share-page.js.map +1 -1
- package/dist/outbound-handlers.d.ts +2 -1
- package/dist/outbound-handlers.js +17 -4
- package/dist/outbound-handlers.js.map +1 -1
- package/dist/outbound-schemas.d.ts +10 -0
- package/dist/outbound-schemas.js +3 -1
- package/dist/outbound-schemas.js.map +1 -1
- package/dist/public-web-gateway.js +9 -3
- package/dist/public-web-gateway.js.map +1 -1
- package/dist/remote-card-answer.d.ts +1 -1
- package/dist/remote-card-answer.js +8 -1
- package/dist/remote-card-answer.js.map +1 -1
- package/dist/remote-card-prompt.js +1 -1
- package/dist/remote-card-prompt.js.map +1 -1
- package/dist/restart-progress.d.ts +6 -0
- package/dist/restart-progress.js +5 -0
- package/dist/restart-progress.js.map +1 -1
- package/dist/settings-api.d.ts +1 -0
- package/dist/settings-api.js +84 -10
- package/dist/settings-api.js.map +1 -1
- package/dist/settings-baseline.d.ts +3 -0
- package/dist/settings-baseline.js +2 -2
- package/dist/settings-baseline.js.map +1 -1
- package/dist/settings-change.js +1 -0
- package/dist/settings-change.js.map +1 -1
- package/dist/settings-effect.d.ts +3 -0
- package/dist/settings-effect.js +33 -2
- package/dist/settings-effect.js.map +1 -1
- package/dist/tool-permissions.js +3 -3
- package/dist/tool-permissions.js.map +1 -1
- package/dist/ui/chat-quote.js +3 -261
- package/dist/ui/fleet-office-card.js +8 -4
- package/dist/ui/fleet-office-pack.d.ts +1 -0
- package/dist/ui/fleet-office-pack.js +6 -2
- package/dist/ui/fleet-office-play.js +84 -0
- package/dist/ui/fleet-office-store.js +23 -0
- package/dist/ui/fleet-office-zones.js +5 -1
- package/dist/ui/fleet-office.js +78 -8
- package/dist/ui/host-install.js +77 -3
- package/dist/ui/hub-agent-intro.js +35 -0
- package/dist/ui/hub-attachments.js +81 -3
- package/dist/ui/hub-chat-strings.js +4 -4
- package/dist/ui/hub-client.js +16 -1
- package/dist/ui/hub-grant-picker.js +25 -11
- package/dist/ui/hub-group-strings.js +3 -3
- package/dist/ui/hub-intro-notice.js +16 -0
- package/dist/ui/hub-my-agents-model.js +42 -0
- package/dist/ui/hub-my-agents-strings.js +18 -0
- package/dist/ui/hub-my-agents.js +144 -0
- package/dist/ui/hub-owner-strings.js +5 -5
- package/dist/ui/hub-personal-agent.js +5 -4
- package/dist/ui/hub-room-composer.js +37 -6
- package/dist/ui/hub-room-list.js +4 -3
- package/dist/ui/hub-room-members.js +5 -2
- package/dist/ui/hub-room-new.js +8 -5
- package/dist/ui/hub-room-purpose.js +19 -0
- package/dist/ui/hub-room-search.js +1 -1
- package/dist/ui/hub-room-settings.js +9 -0
- package/dist/ui/hub-room-strings.js +6 -4
- package/dist/ui/hub-room-thread.js +70 -17
- package/dist/ui/hub-strings.js +5 -5
- package/dist/ui/hub-welcome.js +6 -6
- package/dist/ui/notice-hub-sharing.js +81 -0
- package/dist/ui/panel-chat.js +19 -5
- package/dist/ui/panel-hub.js +77 -29
- package/dist/ui/panel-notices.js +2 -1
- package/dist/ui/settings-hub-connection.js +2 -2
- package/dist/ui/settings-hub-page-sharing.js +52 -0
- package/dist/ui/settings-hub.js +4 -2
- package/dist/ui/settings-registry.js +1 -0
- package/dist/ui/shared/app-i18n.js +2 -2
- package/dist/ui/shared/app-shell.js +14 -2
- package/dist/ui/shared/app-store.js +6 -2
- package/dist/ui/shared/app.js +3 -1
- package/dist/ui/shared/chat-msg-actions.js +3 -1
- package/dist/ui/shared/chat-quote.js +261 -0
- package/dist/ui/shared/hub-chat.css +31 -0
- package/dist/ui/shared/hub-my-agents.css +35 -0
- package/dist/ui/shared/hub-rooms-u2.css +5 -0
- package/dist/ui/shared/module-warm.d.ts +3 -0
- package/dist/ui/shared/module-warm.js +39 -0
- package/dist/web-api.d.ts +21 -5
- package/dist/web-api.js +138 -7
- package/dist/web-api.js.map +1 -1
- package/dist/web-asset-version.d.ts +65 -0
- package/dist/web-asset-version.js +259 -0
- package/dist/web-asset-version.js.map +1 -0
- package/dist/web-host-guard.js +3 -1
- package/dist/web-host-guard.js.map +1 -1
- package/dist/web-host-install.d.ts +30 -3
- package/dist/web-host-install.js +50 -4
- package/dist/web-host-install.js.map +1 -1
- package/dist/web-notices.d.ts +17 -0
- package/dist/web-notices.js +47 -6
- package/dist/web-notices.js.map +1 -1
- package/dist/web-terminal.d.ts +5 -0
- package/dist/web-terminal.js +11 -0
- package/dist/web-terminal.js.map +1 -1
- package/launcher/agend-install.cjs +48 -7
- package/package.json +1 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { HUB_ROOM_MEMBERS_CAPABILITY } from "../room-members-model.js";
|
|
2
|
+
import { pageRoomMembers } from "./members-page.js";
|
|
3
|
+
import { normalizeRoomPurpose } from "./purpose.js";
|
|
4
|
+
import { agentIntro } from "../agent-intro.js";
|
|
1
5
|
import { countChainStop } from "../admin-dashboard.js";
|
|
2
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
7
|
import { z } from "zod";
|
|
@@ -23,7 +27,8 @@ import { HUB_ROOM_MENTION_FEEDBACK_CAPABILITY } from "../room-mention-feedback-m
|
|
|
23
27
|
import { personalMentionRefusals, recordPersonalMentionRefusals } from "../personal/refusals.js";
|
|
24
28
|
const label = plain(120).transform(s => s.trim()).refine(s => s.length > 0 && !/[\u0000-\u001f\u007f]/.test(s));
|
|
25
29
|
const personId = z.string().max(128).refine(s => /^[a-z][a-z0-9_-]{0,63}\/[a-f0-9-]{36}$/.test(s));
|
|
26
|
-
const
|
|
30
|
+
const purpose = z.string().transform(normalizeRoomPurpose);
|
|
31
|
+
const createSchema = z.strictObject({ name: label, purpose: purpose.default(""), people: z.array(personId).max(100).default([]), teams: z.array(uuid).max(100).default([]),
|
|
27
32
|
groups: z.array(uuid).max(100).default([]), agents: z.array(uuid).max(64).default([]), assistant: z.boolean().default(false) });
|
|
28
33
|
// M-3125: a post carries up to 10 of the poster's own pending uploads in this room; with files the text may be empty.
|
|
29
34
|
const postSchema = z.strictObject({ text: plain(64 * 1024), mentions: z.array(z.string().max(128)).max(100).default([]),
|
|
@@ -74,7 +79,7 @@ export function validRoomEmoji(s) {
|
|
|
74
79
|
return false;
|
|
75
80
|
return [...new Intl.Segmenter("en", { granularity: "grapheme" }).segment(s)].length === 1;
|
|
76
81
|
}
|
|
77
|
-
const patchSchema = z.strictObject({ name: label.optional(), allMention: z.boolean().optional(), historyForNew: z.enum(["since-join", "all"]).optional(), archived: z.boolean().optional(), assistant: z.boolean().optional() });
|
|
82
|
+
const patchSchema = z.strictObject({ name: label.optional(), purpose: purpose.optional(), allMention: z.boolean().optional(), historyForNew: z.enum(["since-join", "all"]).optional(), archived: z.boolean().optional(), assistant: z.boolean().optional() });
|
|
78
83
|
export class HubRoomRefusal extends Error {
|
|
79
84
|
status;
|
|
80
85
|
code;
|
|
@@ -214,8 +219,13 @@ export class HubGroupRooms {
|
|
|
214
219
|
}
|
|
215
220
|
maximum(db, id) { return db.prepare("SELECT COALESCE(MAX(sequence),0) AS n FROM hub_room_posts WHERE room_id=?").get(id).n; }
|
|
216
221
|
projection(row) {
|
|
217
|
-
|
|
222
|
+
let system = row.author_kind === "system" && ["room-created", "member-joined", "admin-joined", "poll-closed", "app-rate-limited"].includes(row.author_id)
|
|
218
223
|
? { kind: row.author_id, name: row.author_name } : undefined;
|
|
224
|
+
if (row.author_kind === "system" && row.author_id === "purpose-changed") {
|
|
225
|
+
const event = this.core.atomic(db => db.prepare("SELECT purpose FROM hub_room_purpose_events WHERE post_id=?").get(row.id));
|
|
226
|
+
if (event)
|
|
227
|
+
system = { kind: "purpose-changed", name: row.author_name, purpose: event.purpose };
|
|
228
|
+
}
|
|
219
229
|
// Agent rows retain their owner-at-message in author_subject; a later exposure transfer must not relabel history.
|
|
220
230
|
const agent = row.author_kind === "agent" ? this.core.atomic(db => {
|
|
221
231
|
const e = readExposure(db, row.author_id);
|
|
@@ -237,8 +247,10 @@ export class HubGroupRooms {
|
|
|
237
247
|
WHERE p.id=? AND p.room_id=? AND p.author_kind='person' AND NOT EXISTS
|
|
238
248
|
(SELECT 1 FROM hub_room_agent_operations op WHERE op.post_id=p.id AND op.member_id=p.author_id)`)
|
|
239
249
|
.get(row.answer_to, row.room_id) : undefined;
|
|
250
|
+
const stopped = row.delivery_id && row.stage === "not-answered" ? db.prepare("SELECT 1 FROM hub_room_deliveries WHERE id=? AND reason_code='owner-stopped-sharing'").get(row.delivery_id) : null;
|
|
251
|
+
const missing = row.delivery_id && row.stage === "not-answered" ? db.prepare("SELECT 1 FROM hub_room_deliveries WHERE id=? AND reason_code='finished-without-answer'").get(row.delivery_id) : null;
|
|
240
252
|
const reactions = this.reactions(db, row.id), buttons = row.author_kind === "agent" ? this.buttons.view(db, row.id, id => this.memberName(db, id)) : undefined;
|
|
241
|
-
return { ...(ask ? { ask } : {}), ...(asker ? { askedBy: asker.id } : {}), ...(this.assistant.warning(db, row.id) ? { warning: "assistant-unavailable" } : {}), ...(reactions.length ? { reactions } : {}), ...(buttons ? { buttons } : {}) };
|
|
253
|
+
return { ...(missing ? { reasonCode: "finished-without-answer" } : {}), ...(stopped ? { reasonCode: "owner-stopped-sharing" } : {}), ...(ask ? { ask } : {}), ...(asker ? { askedBy: asker.id } : {}), ...(this.assistant.warning(db, row.id) ? { warning: "assistant-unavailable" } : {}), ...(reactions.length ? { reactions } : {}), ...(buttons ? { buttons } : {}) };
|
|
242
254
|
}) };
|
|
243
255
|
}
|
|
244
256
|
/** M-3127: a post's reactions, each emoji in the order it first appeared, its members in the order they reacted. */
|
|
@@ -297,13 +309,9 @@ export class HubGroupRooms {
|
|
|
297
309
|
this.core.audit(tx, { requestId: source.id, actor: { kind: "person", person: personFromString(source.author_subject) }, action: "room.agent-mention-stopped", result: "completed", roomId: source.room_id, messageId: row.id, contentRef: row.content_ref });
|
|
298
310
|
}
|
|
299
311
|
/** Both answers and proactive posts use this transaction, once, before any external delivery. */
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const source = db.prepare("SELECT * FROM hub_room_members WHERE room_id=? AND kind='agent' AND subject=? AND owner_at_join=?").get(post.room_id, sourceId, post.author_subject);
|
|
304
|
-
if (!source)
|
|
305
|
-
return;
|
|
306
|
-
const members = db.prepare("SELECT * FROM hub_room_members WHERE room_id=?").all(post.room_id).flatMap(m => {
|
|
312
|
+
/** The room's members by the names an @ can use: people (and their login), and agents whose owner still publishes them. */
|
|
313
|
+
mentionMembers(db, roomId) {
|
|
314
|
+
return db.prepare("SELECT * FROM hub_room_members WHERE room_id=?").all(roomId).flatMap(m => {
|
|
307
315
|
if (m.kind === "person") {
|
|
308
316
|
const p = db.prepare("SELECT login_label FROM hub_people WHERE person=? UNION ALL SELECT login_label FROM hub_room_people WHERE person=? LIMIT 1").get(m.subject, m.subject);
|
|
309
317
|
return [{ ...m, name: this.name(db, m.subject), login: p?.login_label }];
|
|
@@ -311,6 +319,14 @@ export class HubGroupRooms {
|
|
|
311
319
|
const e = m.kind === "agent" ? readExposure(db, m.subject) : undefined;
|
|
312
320
|
return e && e.owner === m.owner_at_join ? [{ ...m, name: e.display_name }] : [];
|
|
313
321
|
});
|
|
322
|
+
}
|
|
323
|
+
agentMentions(db, tx, post) {
|
|
324
|
+
const operation = db.prepare("SELECT exposure_id,receipt_id FROM hub_room_agent_operations WHERE post_id=?").get(post.id);
|
|
325
|
+
const sourceId = operation?.exposure_id ?? post.author_id, onBehalf = !!operation?.receipt_id;
|
|
326
|
+
const source = db.prepare("SELECT * FROM hub_room_members WHERE room_id=? AND kind='agent' AND subject=? AND owner_at_join=?").get(post.room_id, sourceId, post.author_subject);
|
|
327
|
+
if (!source)
|
|
328
|
+
return;
|
|
329
|
+
const members = this.mentionMembers(db, post.room_id);
|
|
314
330
|
const resolved = resolveRoomMentions(this.core.deps.content.get(post.content_ref)?.question ?? "", members, onBehalf ? "" : sourceId), accepted = [], refusedPersonal = [];
|
|
315
331
|
if (resolved.all && !onBehalf)
|
|
316
332
|
this.stop(db, tx, post, "all");
|
|
@@ -394,13 +410,34 @@ export class HubGroupRooms {
|
|
|
394
410
|
this.agentReadBuckets.set(owner, { at: b?.at ?? at, count: (b?.count ?? 0) + 1 });
|
|
395
411
|
}
|
|
396
412
|
async agentMembers(input, link) {
|
|
397
|
-
const body = validated(roomMembersSchema, input)
|
|
413
|
+
const body = validated(roomMembersSchema, input);
|
|
414
|
+
if (body.v2 && !link.features.has(HUB_ROOM_MEMBERS_CAPABILITY))
|
|
415
|
+
throw new HubProtocolError("incompatible");
|
|
416
|
+
const { source, fence } = await this.agentSource(body.exposureId, link);
|
|
398
417
|
this.agentRead(source.owner);
|
|
399
418
|
return this.core.atomic(db => {
|
|
400
419
|
const rows = db.prepare(`SELECT r.id,r.name FROM hub_room_members m JOIN hub_group_rooms r ON r.id=m.room_id WHERE m.kind='agent' AND m.subject=? AND m.owner_at_join=? AND r.archived=0 AND r.assistant_for IS NULL AND (r.id=? OR r.name=?) ORDER BY r.id LIMIT 201`).all(source.id, source.owner, body.room, body.room);
|
|
401
420
|
const room = rows.find(r => r.id === body.room) ?? (rows.length === 1 ? rows[0] : undefined);
|
|
402
|
-
if (!room)
|
|
403
|
-
|
|
421
|
+
if (!room) {
|
|
422
|
+
const choices = rows.slice(0, 200);
|
|
423
|
+
if (body.v2)
|
|
424
|
+
while (Buffer.byteLength(JSON.stringify({ ok: false, code: "ambiguous-room", rooms: choices })) > 8192)
|
|
425
|
+
choices.pop();
|
|
426
|
+
return rows.length ? { ok: false, code: "ambiguous-room", rooms: choices } : { ok: false, code: "not-found" };
|
|
427
|
+
}
|
|
428
|
+
if (body.v2) {
|
|
429
|
+
const roomRow = this.room(db, room.id);
|
|
430
|
+
const roster = db.prepare("SELECT * FROM hub_room_members WHERE room_id=? ORDER BY kind,id").all(room.id).map(m => {
|
|
431
|
+
if (m.kind === "assistant")
|
|
432
|
+
return { id: "assistant", kind: "assistant", name: "Hub assistant", presence: this.assistant.presence(room.id), intro: "Hub assistant. Answers from this room's chat.", mentionable: false };
|
|
433
|
+
if (m.kind === "agent") {
|
|
434
|
+
const e = readExposure(db, m.subject);
|
|
435
|
+
return { id: m.subject, kind: m.kind, name: e?.display_name ?? m.subject, presence: this.agents.presence(m.subject).presence, owner: { name: this.name(db, m.owner_at_join ?? "") }, intro: agentIntro(db, m.subject).intro };
|
|
436
|
+
}
|
|
437
|
+
return { id: m.id, kind: m.kind, name: this.name(db, m.subject), presence: db.prepare("SELECT 1 FROM hub_sessions WHERE person=? AND state='active' AND expires_at>?").get(m.subject, this.core.now()) ? "online" : "offline" };
|
|
438
|
+
});
|
|
439
|
+
return pageRoomMembers(room.id, roomRow.purpose, roster, body, JSON.stringify([source.id, source.owner]));
|
|
440
|
+
}
|
|
404
441
|
const members = db.prepare("SELECT * FROM hub_room_members WHERE room_id=? ORDER BY kind,id LIMIT 201").all(room.id).map(m => {
|
|
405
442
|
if (m.kind === "assistant")
|
|
406
443
|
return { id: "assistant", kind: m.kind, name: "Hub assistant", presence: this.assistant.presence(room.id) };
|
|
@@ -516,6 +553,13 @@ export class HubGroupRooms {
|
|
|
516
553
|
VALUES(@id,@room_id,@sequence,@author_kind,@author_id,@author_subject,@author_name,@content_ref,@digest,@mentions,@reply_to,@idempotency_key,@created_at)`).run(row);
|
|
517
554
|
return row;
|
|
518
555
|
}
|
|
556
|
+
recordPurpose(db, tx, id, me, purpose, requestId) {
|
|
557
|
+
const name = this.name(db, me), text = purpose ? `${name} set the purpose: ${purpose}` : `${name} cleared the purpose.`;
|
|
558
|
+
const post = this.insert(db, tx, id, { kind: "system", id: "purpose-changed", subject: me, name }, text);
|
|
559
|
+
db.prepare("INSERT INTO hub_room_purpose_events VALUES(?,?)").run(post.id, purpose);
|
|
560
|
+
this.core.audit(tx, { requestId, actor: { kind: "person", person: personFromString(me) }, action: "room.purpose-changed", result: "completed", roomId: id, messageId: post.id, contentRef: post.content_ref });
|
|
561
|
+
return post;
|
|
562
|
+
}
|
|
519
563
|
summary(db, room, member) {
|
|
520
564
|
const counts = db.prepare("SELECT kind,COUNT(*) AS n FROM hub_room_members WHERE room_id=? GROUP BY kind").all(room.id);
|
|
521
565
|
const floor = member.joined_sequence;
|
|
@@ -527,7 +571,7 @@ export class HubGroupRooms {
|
|
|
527
571
|
const online = db.prepare(`SELECT COUNT(*) AS n FROM hub_room_members m WHERE m.room_id=? AND m.kind='person' AND EXISTS
|
|
528
572
|
(SELECT 1 FROM hub_sessions s WHERE s.person=m.subject AND s.state='active' AND s.expires_at>?)`).get(room.id, this.core.now()).n;
|
|
529
573
|
const projected = last ? this.projection(last) : undefined;
|
|
530
|
-
const summary = { id: room.id, kind: "group", name: room.name, people: counts.find(c => c.kind === "person")?.n ?? 0,
|
|
574
|
+
const summary = { id: room.id, kind: "group", name: room.name, purpose: room.purpose ?? "", people: counts.find(c => c.kind === "person")?.n ?? 0,
|
|
531
575
|
agents: counts.find(c => c.kind === "agent")?.n ?? 0, online, unread, lastAt: last?.created_at ?? room.created_at,
|
|
532
576
|
lastText: projected?.text.slice(0, 240) ?? "", ...(projected?.system ? { lastSystem: projected.system } : {}), lastAuthor: last?.author_name ?? "", mentioned, archived: room.archived === 1 };
|
|
533
577
|
return room.assistant_for ? { ...summary, kind: "direct", assistant: true, presence: this.assistant.presence(room.id) } : summary;
|
|
@@ -572,7 +616,7 @@ export class HubGroupRooms {
|
|
|
572
616
|
...view.askable.map(({ exposure: e, ownerName }) => ({ kind: "agent", id: e.id, name: e.displayName, mine: false, owner: { name: ownerName } }))]
|
|
573
617
|
.filter(e => e.name.toLowerCase().startsWith(q.trim().toLowerCase())).slice(0, 20);
|
|
574
618
|
this.fence(ctx).assertCurrent();
|
|
575
|
-
return hits;
|
|
619
|
+
return this.core.atomic(db => hits.map(row => ({ ...row, ...agentIntro(db, row.id) })), this.fence(ctx));
|
|
576
620
|
}
|
|
577
621
|
if (q.trim().length >= 2 && (kind === "group" && this.core.deps.directory.searchPolicyGroups || kind === "person" && this.core.deps.directory.searchGrantPeople)) {
|
|
578
622
|
return this.directory.search(ctx, me, q.trim(), kind, () => this.core.atomic(db => {
|
|
@@ -662,7 +706,7 @@ export class HubGroupRooms {
|
|
|
662
706
|
throw new HubRoomRefusal(403, "denied");
|
|
663
707
|
rememberRoomPeople(db, selectedPeople, this.core.now());
|
|
664
708
|
const id = randomUUID();
|
|
665
|
-
db.prepare("INSERT INTO hub_group_rooms(id,name,created_by,created_at) VALUES(
|
|
709
|
+
db.prepare("INSERT INTO hub_group_rooms(id,name,purpose,created_by,created_at) VALUES(?,?,?,?,?)").run(id, body.name, body.purpose, me, this.core.now());
|
|
666
710
|
for (const person of people)
|
|
667
711
|
db.prepare("INSERT INTO hub_room_members(id,room_id,kind,subject,role,joined_sequence) VALUES(?,?,'person',?,?,0)").run(randomUUID(), id, person, person === me ? "manager" : "member");
|
|
668
712
|
this.insert(db, tx, id, { kind: "system", id: "room-created", subject: me, name: this.name(db, me) }, `${this.name(db, me)} created this room.`);
|
|
@@ -670,6 +714,8 @@ export class HubGroupRooms {
|
|
|
670
714
|
this.addAgentMember(db, tx, id, agent, me);
|
|
671
715
|
if (body.assistant)
|
|
672
716
|
this.addAssistant(db, id);
|
|
717
|
+
if (body.purpose)
|
|
718
|
+
this.recordPurpose(db, tx, id, me, body.purpose, ctx.requestId);
|
|
673
719
|
this.core.audit(tx, { requestId: ctx.requestId, actor: { kind: "person", person: personFromString(me) }, action: "room.created", result: "completed", roomId: id });
|
|
674
720
|
return this.summary(db, this.room(db, id), this.member(db, id, me));
|
|
675
721
|
}, { assertCurrent: () => { this.fence(ctx).assertCurrent(); for (const permit of permits)
|
|
@@ -701,7 +747,7 @@ export class HubGroupRooms {
|
|
|
701
747
|
return { id: "assistant", kind: m.kind, name: "Hub assistant", role: m.role, presence: this.assistant.presence(id) };
|
|
702
748
|
if (m.kind === "agent") {
|
|
703
749
|
const e = readExposure(db, m.subject);
|
|
704
|
-
return { id: m.subject, kind: m.kind, name: e?.display_name ?? m.subject, role: m.role,
|
|
750
|
+
return { id: m.subject, kind: m.kind, name: e?.display_name ?? m.subject, ...agentIntro(db, m.subject), role: m.role,
|
|
705
751
|
...(e ? { agentKind: e.source_kind === "personal" ? "personal" : "fleet" } : {}),
|
|
706
752
|
...(e?.answer_only === 1 ? { answerOnly: true } : {}), owner: { name: this.name(db, m.owner_at_join ?? "") }, ...this.agents.presence(m.subject), canAsk: canAsk.has(m.subject) };
|
|
707
753
|
}
|
|
@@ -719,7 +765,7 @@ export class HubGroupRooms {
|
|
|
719
765
|
}
|
|
720
766
|
async patch(ctx, id, input) {
|
|
721
767
|
const body = validated(patchSchema, input), me = await this.who(ctx);
|
|
722
|
-
this.core.atomic((db, tx) => {
|
|
768
|
+
const purposePost = this.core.atomic((db, tx) => {
|
|
723
769
|
this.member(db, id, me, true);
|
|
724
770
|
const row = this.room(db, id);
|
|
725
771
|
if (row.assistant_for)
|
|
@@ -728,13 +774,17 @@ export class HubGroupRooms {
|
|
|
728
774
|
this.addAssistant(db, id);
|
|
729
775
|
else if (body.assistant === false)
|
|
730
776
|
db.prepare("DELETE FROM hub_room_members WHERE room_id=? AND kind='assistant'").run(id);
|
|
731
|
-
db.prepare("UPDATE hub_group_rooms SET name=?,all_mention=?,history_for_new=?,archived=? WHERE id=?")
|
|
732
|
-
.run(body.name ?? row.name, body.allMention === undefined ? row.all_mention : Number(body.allMention), body.historyForNew ?? row.history_for_new, body.archived === undefined ? row.archived : Number(body.archived), id);
|
|
777
|
+
db.prepare("UPDATE hub_group_rooms SET name=?,purpose=?,all_mention=?,history_for_new=?,archived=? WHERE id=?")
|
|
778
|
+
.run(body.name ?? row.name, body.purpose ?? row.purpose, body.allMention === undefined ? row.all_mention : Number(body.allMention), body.historyForNew ?? row.history_for_new, body.archived === undefined ? row.archived : Number(body.archived), id);
|
|
779
|
+
const changed = body.purpose !== undefined && body.purpose !== row.purpose ? this.recordPurpose(db, tx, id, me, body.purpose, ctx.requestId) : null;
|
|
733
780
|
this.core.audit(tx, { requestId: ctx.requestId, actor: { kind: "person", person: personFromString(me) }, action: "room.updated", result: "completed", roomId: id });
|
|
781
|
+
return changed;
|
|
734
782
|
}, this.fence(ctx));
|
|
735
783
|
if (body.archived || body.assistant === false)
|
|
736
784
|
this.assistant.forget(id);
|
|
737
785
|
this.agents.sweep(id);
|
|
786
|
+
if (purposePost)
|
|
787
|
+
this.emit({ type: "message.added", roomId: id, data: { roomId: id, message: this.projection(purposePost) }, sequence: purposePost.sequence });
|
|
738
788
|
this.emit({ type: "room.changed", roomId: id, data: { roomId: id } });
|
|
739
789
|
return this.detail(ctx, id);
|
|
740
790
|
}
|
|
@@ -903,7 +953,15 @@ export class HubGroupRooms {
|
|
|
903
953
|
if (body.replyTo && !db.prepare("SELECT 1 FROM hub_room_posts WHERE id=? AND room_id=? AND sequence>=?").get(body.replyTo, id, member.joined_sequence))
|
|
904
954
|
throw new HubRoomRefusal(404, "not-found");
|
|
905
955
|
const refs = files.length ? this.store().pending(db, id, me, files) : [];
|
|
906
|
-
|
|
956
|
+
// M-3298: an "@Name" a person types reminds that person (the room list's @, their page's ping). The Hub alone says who:
|
|
957
|
+
// the people the text names, resolved as an agent post's are (agentMentions) — not oneself; an ambiguous name, code and
|
|
958
|
+
// email addresses are no one (mentions.ts). Of what the page sent only what routes is kept (@all, the assistant, the
|
|
959
|
+
// room's agents): a person id in it is never taken on trust (#4132 review F1: a page's pick of one of two same-named
|
|
960
|
+
// people, or a crafted id the text does not name, would remind someone the text did not).
|
|
961
|
+
const agentIds = new Set(db.prepare("SELECT subject FROM hub_room_members WHERE room_id=? AND kind='agent'").all(id).map(m => m.subject));
|
|
962
|
+
const routed = body.mentions.filter(m => m === "all" || m === "assistant" || agentIds.has(m));
|
|
963
|
+
const people = resolveRoomMentions(body.text, this.mentionMembers(db, id), "").people.filter(p => p !== member.id);
|
|
964
|
+
const post = this.insert(db, tx, id, { kind: "person", id: member.id, subject: me, name: this.name(db, me) }, body.text, [...new Set([...routed, ...people])], body.idempotencyKey, digest, body.replyTo ?? null);
|
|
907
965
|
if (ctx.application)
|
|
908
966
|
db.prepare("INSERT INTO hub_mcp_room_posts VALUES(?,?,?)").run(post.id, ctx.application.id, ctx.application.name);
|
|
909
967
|
if (refs.length)
|