@things-factory/ai-assistant 10.1.271 → 10.1.272
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/client/components/assistant-chat.ts +18 -6
- package/client/components/assistant-dock.ts +15 -1
- package/client/components/proposal-request.test.ts +12 -1
- package/client/utils/addressed-draft.test.ts +31 -0
- package/client/utils/assistant-ask.ts +7 -0
- package/client/utils/assistant-request-context.ts +10 -0
- package/dist-client/components/assistant-chat.d.ts +6 -0
- package/dist-client/components/assistant-chat.js +23 -6
- package/dist-client/components/assistant-chat.js.map +1 -1
- package/dist-client/components/assistant-dock.js +15 -0
- package/dist-client/components/assistant-dock.js.map +1 -1
- package/dist-client/components/proposal-request.test.js +11 -1
- package/dist-client/components/proposal-request.test.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-client/utils/addressed-draft.test.d.ts +1 -0
- package/dist-client/utils/addressed-draft.test.js +27 -0
- package/dist-client/utils/addressed-draft.test.js.map +1 -0
- package/dist-client/utils/assistant-ask.d.ts +10 -0
- package/dist-client/utils/assistant-ask.js.map +1 -1
- package/dist-client/utils/assistant-request-context.d.ts +12 -0
- package/dist-client/utils/assistant-request-context.js +11 -0
- package/dist-client/utils/assistant-request-context.js.map +1 -1
- package/dist-server/service/assistant-chat-resolver.js +4 -1
- package/dist-server/service/assistant-chat-resolver.js.map +1 -1
- package/dist-server/service/assistant-mode/index.d.ts +1 -0
- package/dist-server/service/assistant-mode/index.js +4 -1
- package/dist-server/service/assistant-mode/index.js.map +1 -1
- package/dist-server/service/assistant-mode/turn-lines.d.ts +12 -0
- package/dist-server/service/assistant-mode/turn-lines.js +38 -0
- package/dist-server/service/assistant-mode/turn-lines.js.map +1 -0
- package/dist-server/service/chat-message/index.d.ts +1 -0
- package/dist-server/service/chat-message/index.js +3 -1
- package/dist-server/service/chat-message/index.js.map +1 -1
- package/dist-server/service/chat-message/room-turn.d.ts +31 -0
- package/dist-server/service/chat-message/room-turn.js +30 -0
- package/dist-server/service/chat-message/room-turn.js.map +1 -0
- package/dist-server/service/chat-session-participant/mention-invite.d.ts +2 -0
- package/dist-server/service/chat-session-participant/mention-invite.js +5 -0
- package/dist-server/service/chat-session-participant/mention-invite.js.map +1 -1
- package/dist-server/service/chat-session-resolver.d.ts +5 -0
- package/dist-server/service/chat-session-resolver.js +55 -2
- package/dist-server/service/chat-session-resolver.js.map +1 -1
- package/dist-server/service/data-entry/entry-apply.d.ts +2 -0
- package/dist-server/service/data-entry/entry-apply.js +1 -1
- package/dist-server/service/data-entry/entry-apply.js.map +1 -1
- package/dist-server/service/data-entry/entry-resolver.js +2 -1
- package/dist-server/service/data-entry/entry-resolver.js.map +1 -1
- package/dist-server/service/data-entry/entry-target.d.ts +7 -2
- package/dist-server/service/data-entry/entry-target.js.map +1 -1
- package/dist-server/service/people/index.d.ts +2 -0
- package/dist-server/service/people/index.js +9 -1
- package/dist-server/service/people/index.js.map +1 -1
- package/dist-server/service/people/person-subject.d.ts +34 -0
- package/dist-server/service/people/person-subject.js +89 -0
- package/dist-server/service/people/person-subject.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/server/service/assistant-chat-resolver.ts +4 -1
- package/server/service/assistant-mode/index.ts +1 -0
- package/server/service/assistant-mode/open-subject-door.test.ts +7 -2
- package/server/service/assistant-mode/turn-lines.ts +43 -0
- package/server/service/chat-message/index.ts +1 -0
- package/server/service/chat-message/room-turn.ts +42 -0
- package/server/service/chat-session-participant/mention-invite.ts +5 -0
- package/server/service/chat-session-resolver.ts +49 -2
- package/server/service/data-entry/entry-apply.ts +3 -1
- package/server/service/data-entry/entry-resolver.ts +2 -1
- package/server/service/data-entry/entry-target.ts +5 -2
- package/server/service/people/index.ts +2 -0
- package/server/service/people/person-subject.test.ts +163 -0
- package/server/service/people/person-subject.ts +88 -0
- package/test/assistant-request-context.test.ts +1 -1
- package/test/open-doors.test.ts +3 -1
- package/translations/en.json +2 -0
- package/translations/es.json +2 -0
- package/translations/ja.json +2 -0
- package/translations/ko.json +2 -0
- package/translations/ms.json +2 -0
- package/translations/zh.json +2 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onRoomTurn = onRoomTurn;
|
|
4
|
+
exports.tellRoomTurn = tellRoomTurn;
|
|
5
|
+
/*
|
|
6
|
+
* A person spoke to the people of a conversation - told to the modules that wait for it. worklist closes a question it
|
|
7
|
+
* handed to that person once they answer in the conversation it came from (ADR-0200 decision 3).
|
|
8
|
+
*
|
|
9
|
+
* Only the door that stores words to the room tells (`sendRoomMessage`): what the person asks the assistant - polish
|
|
10
|
+
* my draft - is not their answer.
|
|
11
|
+
*/
|
|
12
|
+
const env_1 = require("@things-factory/env");
|
|
13
|
+
const listeners = new Set();
|
|
14
|
+
/** A module waits for people's words in conversations. Answers the way to stop. */
|
|
15
|
+
function onRoomTurn(listener) {
|
|
16
|
+
listeners.add(listener);
|
|
17
|
+
return () => listeners.delete(listener);
|
|
18
|
+
}
|
|
19
|
+
/** Every listener hears the turn; one that fails is logged and does not stop the person's words. */
|
|
20
|
+
async function tellRoomTurn(turn) {
|
|
21
|
+
for (const listener of listeners) {
|
|
22
|
+
try {
|
|
23
|
+
await listener(turn);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
env_1.logger.error(`[ai-assistant/room-turn] a listener failed for session ${turn.session.id}: ${error?.message ?? error}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=room-turn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-turn.js","sourceRoot":"","sources":["../../../server/service/chat-message/room-turn.ts"],"names":[],"mappings":";;AA2BA,gCAGC;AAGD,oCAQC;AAzCD;;;;;;GAMG;AACH,6CAA4C;AAiB5C,MAAM,SAAS,GAAG,IAAI,GAAG,EAAY,CAAA;AAErC,mFAAmF;AACnF,SAAgB,UAAU,CAAC,QAAkB;IAC3C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACvB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AACzC,CAAC;AAED,oGAAoG;AAC7F,KAAK,UAAU,YAAY,CAAC,IAAc;IAC/C,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,YAAM,CAAC,KAAK,CAAC,0DAA0D,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,KAAK,EAAE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAA;QACvH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/*\n * A person spoke to the people of a conversation - told to the modules that wait for it. worklist closes a question it\n * handed to that person once they answer in the conversation it came from (ADR-0200 decision 3).\n *\n * Only the door that stores words to the room tells (`sendRoomMessage`): what the person asks the assistant - polish\n * my draft - is not their answer.\n */\nimport { logger } from '@things-factory/env'\n\nexport interface RoomTurn {\n domain: { id: string }\n /** Who spoke. */\n user: { id: string; name?: string; email?: string }\n session: { id: string; anchorType?: string | null; anchorId?: string | null }\n /** The message as stored. */\n message: { id: string; content: string }\n /** The request's transaction - a listener writes in it, so the turn and what it closed stand or fall together. */\n tx?: any\n /** The request's translator. */\n t?: (key: string, options?: any) => string\n}\n\ntype Listener = (turn: RoomTurn) => void | Promise<void>\n\nconst listeners = new Set<Listener>()\n\n/** A module waits for people's words in conversations. Answers the way to stop. */\nexport function onRoomTurn(listener: Listener): () => void {\n listeners.add(listener)\n return () => listeners.delete(listener)\n}\n\n/** Every listener hears the turn; one that fails is logged and does not stop the person's words. */\nexport async function tellRoomTurn(turn: RoomTurn): Promise<void> {\n for (const listener of listeners) {\n try {\n await listener(turn)\n } catch (error: any) {\n logger.error(`[ai-assistant/room-turn] a listener failed for session ${turn.session.id}: ${error?.message ?? error}`)\n }\n }\n}\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** The text as a person reads it - `@Admin{userId:UUID}` is `@Admin`. Kept where a turn's words are stored as an answer. */
|
|
2
|
+
export declare function withoutMentionIds(text: string): string;
|
|
1
3
|
/** 본문에서 `@user{userId:UUID}` 마커의 userId 를 뽑는다 — 첫 등장 순, 중복 제거. */
|
|
2
4
|
export declare function extractMentionUserIds(text: string | null | undefined): string[];
|
|
3
5
|
/** 멘션된 사람 중 **아직 참여자가 아니고 자기 자신도 아닌** 새 사람만. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withoutMentionIds = withoutMentionIds;
|
|
3
4
|
exports.extractMentionUserIds = extractMentionUserIds;
|
|
4
5
|
exports.newParticipantUserIds = newParticipantUserIds;
|
|
5
6
|
exports.inviteMentionedUsers = inviteMentionedUsers;
|
|
@@ -34,6 +35,10 @@ exports.seatWriter = seatWriter;
|
|
|
34
35
|
* under the same rule - two ways in, one seat.
|
|
35
36
|
*/
|
|
36
37
|
const session_visibility_js_1 = require("../chat-session/session-visibility.js");
|
|
38
|
+
/** The text as a person reads it - `@Admin{userId:UUID}` is `@Admin`. Kept where a turn's words are stored as an answer. */
|
|
39
|
+
function withoutMentionIds(text) {
|
|
40
|
+
return text.replace(/\{userId:[^}\s]+\}/g, '');
|
|
41
|
+
}
|
|
37
42
|
/** 본문에서 `@user{userId:UUID}` 마커의 userId 를 뽑는다 — 첫 등장 순, 중복 제거. */
|
|
38
43
|
function extractMentionUserIds(text) {
|
|
39
44
|
if (!text)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mention-invite.js","sourceRoot":"","sources":["../../../server/service/chat-session-participant/mention-invite.ts"],"names":[],"mappings":";;AA8BA,sDAcC;A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IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAA;IACjH,MAAM,eAAe,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACtD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,iIAAiI;AACjI,KAAK,UAAU,eAAe,CAAC,IAAS,EAAE,QAAe,EAAE,KAA2F,EAAE,MAAc;IACpK,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAA;IAC5G,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAS,CAAC,CAAA;IACjG,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,CAAC,IAAI,CAAC;YACd,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAS;YACrC,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,SAAS,EAAS;YACvC,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAS;YAC3B,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO,EAAE,KAAK,CAAC,OAAO;SAChB,CAAC,CAAA;IACX,CAAC;AACH,CAAC","sourcesContent":["/*\n * Mentioning someone tells them (ADR-0071 decision 1, as amended by ADR-0073).\n *\n * The machinery existed in the board product only: `@name` in a board chat added a participant and\n * sent them an invite, and the same `@name` in a twin deliberation added nobody. The person typing\n * it had every reason to believe they had called a colleague in.\n *\n * ── What a mention is now ─────────────────────────────────────────────────────\n * A conversation in the domain is open: anyone may walk in, with nothing to approve and nobody to\n * ask (ADR-0073 decision 2). So a mention grants nothing — it points. It seats the named person so\n * the conversation reaches their list, and it tells them their name came up. Somebody who was never\n * mentioned can read the same room by opening it.\n *\n * Two rules survive the amendment:\n * ① only a door that stores **a person's turn** mentions — never the model, a tool, or the\n * assistant's own answer. What the assistant writes must not seat people.\n * ② whoever is named joins as a member and is told.\n *\n * What went: the inviter's own role (there is nothing to hand out), the refusal verdicts, and the\n * notice shown before sending. A private conversation is the one place a mention cannot seat\n * someone — there the named person is told and stays outside until an owner opens it.\n *\n * ── A group (2026-10-24, ADR-0073 decision 3) ──────────────────────────────────\n * In a group the seat is the key, so who seats is asked again: the owner's mention seats, a member's\n * tells (`maySeat`). The invite door (`inviteToAISession`) seats through the same `seatParticipants`\n * under the same rule - two ways in, one seat.\n */\nimport { isOpenRoom, maySeat } from '../chat-session/session-visibility.js'\n\n/** 본문에서 `@user{userId:UUID}` 마커의 userId 를 뽑는다 — 첫 등장 순, 중복 제거. */\nexport function extractMentionUserIds(text: string | null | undefined): string[] {\n if (!text) return []\n const re = /\\{userId:([^}\\s]+)\\}/g\n const seen = new Set<string>()\n const out: string[] = []\n let m: RegExpExecArray | null\n while ((m = re.exec(text)) !== null) {\n const id = m[1]\n if (!seen.has(id)) {\n seen.add(id)\n out.push(id)\n }\n }\n return out\n}\n\n/** 멘션된 사람 중 **아직 참여자가 아니고 자기 자신도 아닌** 새 사람만. */\nexport function newParticipantUserIds(\n mentioned: ReadonlyArray<string>,\n existing: ReadonlyArray<string>,\n selfUserId?: string | null\n): string[] {\n const have = new Set(existing)\n if (selfUserId) have.add(selfUserId)\n const out: string[] = []\n const seen = new Set<string>()\n for (const id of mentioned) {\n if (!id || have.has(id) || seen.has(id)) continue\n seen.add(id)\n out.push(id)\n }\n return out\n}\n\nexport interface MentionInviteResult {\n /** 이번에 새로 앉은 사람들. 알림은 이들에게 간다. */\n invited: string[]\n /** 앉힐 수 없는 방이거나 부른 사람에게 그 자리가 없어 앉히지 못한 사람들 — 이름은 불렸고 방에는 못 들어온다. */\n notSeated?: string[]\n}\n\nexport interface MentionInviteInput {\n /** 저장된 **사람의 말**. 어시스턴트의 답이나 도구 결과를 여기에 넘기지 않는다(조건 ①). */\n content: string\n sessionId: string\n domainId: string\n inviter: { id?: string } | undefined | null\n /** 참여자 저장소 — 시험이 가짜를 넣는다. */\n participants: any\n /** 이 대화의 공개 범위(ADR-0073). 그룹은 owner 의 멘션만, 비공개는 아무의 멘션도 앉히지 않는다. */\n visibility?: string | null\n}\n\n/** 멘션된 사람을 참여자로 앉힌다 — 앉힐 수 있는 방이고 부른 사람에게 그 자리가 있을 때만(`maySeat`). */\nexport async function inviteMentionedUsers(input: MentionInviteInput): Promise<MentionInviteResult> {\n const mentioned = extractMentionUserIds(input.content)\n if (mentioned.length === 0) return { invited: [] }\n return seatParticipants({ ...input, userIds: mentioned })\n}\n\nexport interface SeatInput {\n sessionId: string\n domainId: string\n inviter: { id?: string } | undefined | null\n /** 앉힐 사람들. 이미 앉은 사람과 부른 사람 자신은 빠진다. */\n userIds: ReadonlyArray<string>\n participants: any\n visibility?: string | null\n}\n\n/**\n * 사람을 앉힌다 — 멘션과 초대 단추가 함께 쓰는 한 곳.\n *\n * 규칙은 `maySeat` 한 줄이다: 공개 방은 누구나, 그룹은 owner 만, 비공개는 아무도. 앉히지 못하면\n * 아무것도 쓰지 않고 그 사람들을 `notSeated` 로 돌려준다 — 화면이 그대로 말한다.\n * 나갔던 사람(soft delete)은 되살린다 — 다시 부른 것이지 새 사람이 아니다.\n */\nexport async function seatParticipants(input: SeatInput): Promise<MentionInviteResult> {\n const repo = input.participants\n const existing = await repo.find({\n where: { session: { id: input.sessionId } as any, domain: { id: input.domainId } as any },\n withDeleted: true\n })\n\n /* A hide-only `viewer` row is not a seat - the person is brought in over it, as a member. */\n const seated = existing.filter((row: any) => !row.deletedAt && row.role !== 'viewer')\n const activeIds = seated.map((row: any) => row.userId).filter(Boolean)\n const fresh = newParticipantUserIds(input.userIds, activeIds, input.inviter?.id)\n if (fresh.length === 0) return { invited: [] }\n\n /*\n * 공개 방에서 앉히는 일은 아무것도 주지 않지만(누구나 들어온다), 그룹과 비공개에서는 그것이 곧 접근을\n * 주는 일이다. 그룹에서는 owner 가 주고, 비공개에서는 아무도 주지 않는다 — 이름이 불렸다는 것만 남는다.\n */\n const inviterRole = seated.find((row: any) => row.userId === input.inviter?.id)?.role\n if (!maySeat(input.visibility, inviterRole)) return { invited: [], notSeated: fresh }\n\n for (const userId of fresh) await writeMemberSeat(repo, existing, input, userId)\n\n return { invited: fresh }\n}\n\n/**\n * The seats a person's turn gives - what every door that stores a person's words calls.\n *\n * The writer first: in an open room anyone may walk in and speak, and until 2026-10-24 speaking seated nobody. A\n * conversation four people wrote in showed two in its roster - the one who started it and the one who was\n * mentioned - and the other two had no presence, no unread badge and no activity notice. In a group or private\n * room the writer is seated already (the write gate let them in by their seat). Then the people mentioned.\n */\nexport async function seatTurn(input: MentionInviteInput): Promise<MentionInviteResult> {\n await seatWriter(input)\n return inviteMentionedUsers(input)\n}\n\n/** Seat the person who spoke, in an open room only - there the seat grants nothing, it records who took part. */\nexport async function seatWriter(input: Omit<SeatInput, 'userIds'>): Promise<boolean> {\n const writerId = input.inviter?.id\n if (!writerId || !isOpenRoom(input.visibility)) return false\n const repo = input.participants\n const existing = await repo.find({\n where: { session: { id: input.sessionId } as any, domain: { id: input.domainId } as any },\n withDeleted: true\n })\n if (existing.some((row: any) => row.userId === writerId && !row.deletedAt && row.role !== 'viewer')) return false\n await writeMemberSeat(repo, existing, input, writerId)\n return true\n}\n\n/** One member seat: someone who left (soft delete) or only hid it (`viewer`) is brought back on that row, never a second one. */\nasync function writeMemberSeat(repo: any, existing: any[], input: { sessionId: string; domainId: string; inviter: { id?: string } | undefined | null }, userId: string) {\n const prior = existing.find((row: any) => row.userId === userId && (row.deletedAt || row.role === 'viewer'))\n if (prior) {\n await repo.update(prior.id, { deletedAt: null, role: 'member', updater: input.inviter } as any)\n } else {\n await repo.save({\n domain: { id: input.domainId } as any,\n session: { id: input.sessionId } as any,\n user: { id: userId } as any,\n role: 'member',\n creator: input.inviter,\n updater: input.inviter\n } as any)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mention-invite.js","sourceRoot":"","sources":["../../../server/service/chat-session-participant/mention-invite.ts"],"names":[],"mappings":";;AA8BA,8CAEC;AAGD,sDAcC;AAGD,sDAeC;AAsBD,oDAIC;AAmBD,4CAuBC;AAUD,4BAGC;AAGD,gCAWC;AAlKD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,iFAA2E;AAE3E,4HAA4H;AAC5H,SAAgB,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAA;AAChD,CAAC;AAED,kEAAkE;AAClE,SAAgB,qBAAqB,CAAC,IAA+B;IACnE,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAA;IACpB,MAAM,EAAE,GAAG,uBAAuB,CAAA;IAClC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,MAAM,GAAG,GAAa,EAAE,CAAA;IACxB,IAAI,CAAyB,CAAA;IAC7B,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACpC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACf,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;YACZ,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACd,CAAC;IACH,CAAC;IACD,OAAO,GA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QAAQ,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAS,CAAC,CAAA;IACjG,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,CAAC,IAAI,CAAC;YACd,MAAM,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,QAAQ,EAAS;YACrC,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,SAAS,EAAS;YACvC,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAS;YAC3B,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,OAAO,EAAE,KAAK,CAAC,OAAO;SAChB,CAAC,CAAA;IACX,CAAC;AACH,CAAC","sourcesContent":["/*\n * Mentioning someone tells them (ADR-0071 decision 1, as amended by ADR-0073).\n *\n * The machinery existed in the board product only: `@name` in a board chat added a participant and\n * sent them an invite, and the same `@name` in a twin deliberation added nobody. The person typing\n * it had every reason to believe they had called a colleague in.\n *\n * ── What a mention is now ─────────────────────────────────────────────────────\n * A conversation in the domain is open: anyone may walk in, with nothing to approve and nobody to\n * ask (ADR-0073 decision 2). So a mention grants nothing — it points. It seats the named person so\n * the conversation reaches their list, and it tells them their name came up. Somebody who was never\n * mentioned can read the same room by opening it.\n *\n * Two rules survive the amendment:\n * ① only a door that stores **a person's turn** mentions — never the model, a tool, or the\n * assistant's own answer. What the assistant writes must not seat people.\n * ② whoever is named joins as a member and is told.\n *\n * What went: the inviter's own role (there is nothing to hand out), the refusal verdicts, and the\n * notice shown before sending. A private conversation is the one place a mention cannot seat\n * someone — there the named person is told and stays outside until an owner opens it.\n *\n * ── A group (2026-10-24, ADR-0073 decision 3) ──────────────────────────────────\n * In a group the seat is the key, so who seats is asked again: the owner's mention seats, a member's\n * tells (`maySeat`). The invite door (`inviteToAISession`) seats through the same `seatParticipants`\n * under the same rule - two ways in, one seat.\n */\nimport { isOpenRoom, maySeat } from '../chat-session/session-visibility.js'\n\n/** The text as a person reads it - `@Admin{userId:UUID}` is `@Admin`. Kept where a turn's words are stored as an answer. */\nexport function withoutMentionIds(text: string): string {\n return text.replace(/\\{userId:[^}\\s]+\\}/g, '')\n}\n\n/** 본문에서 `@user{userId:UUID}` 마커의 userId 를 뽑는다 — 첫 등장 순, 중복 제거. */\nexport function extractMentionUserIds(text: string | null | undefined): string[] {\n if (!text) return []\n const re = /\\{userId:([^}\\s]+)\\}/g\n const seen = new Set<string>()\n const out: string[] = []\n let m: RegExpExecArray | null\n while ((m = re.exec(text)) !== null) {\n const id = m[1]\n if (!seen.has(id)) {\n seen.add(id)\n out.push(id)\n }\n }\n return out\n}\n\n/** 멘션된 사람 중 **아직 참여자가 아니고 자기 자신도 아닌** 새 사람만. */\nexport function newParticipantUserIds(\n mentioned: ReadonlyArray<string>,\n existing: ReadonlyArray<string>,\n selfUserId?: string | null\n): string[] {\n const have = new Set(existing)\n if (selfUserId) have.add(selfUserId)\n const out: string[] = []\n const seen = new Set<string>()\n for (const id of mentioned) {\n if (!id || have.has(id) || seen.has(id)) continue\n seen.add(id)\n out.push(id)\n }\n return out\n}\n\nexport interface MentionInviteResult {\n /** 이번에 새로 앉은 사람들. 알림은 이들에게 간다. */\n invited: string[]\n /** 앉힐 수 없는 방이거나 부른 사람에게 그 자리가 없어 앉히지 못한 사람들 — 이름은 불렸고 방에는 못 들어온다. */\n notSeated?: string[]\n}\n\nexport interface MentionInviteInput {\n /** 저장된 **사람의 말**. 어시스턴트의 답이나 도구 결과를 여기에 넘기지 않는다(조건 ①). */\n content: string\n sessionId: string\n domainId: string\n inviter: { id?: string } | undefined | null\n /** 참여자 저장소 — 시험이 가짜를 넣는다. */\n participants: any\n /** 이 대화의 공개 범위(ADR-0073). 그룹은 owner 의 멘션만, 비공개는 아무의 멘션도 앉히지 않는다. */\n visibility?: string | null\n}\n\n/** 멘션된 사람을 참여자로 앉힌다 — 앉힐 수 있는 방이고 부른 사람에게 그 자리가 있을 때만(`maySeat`). */\nexport async function inviteMentionedUsers(input: MentionInviteInput): Promise<MentionInviteResult> {\n const mentioned = extractMentionUserIds(input.content)\n if (mentioned.length === 0) return { invited: [] }\n return seatParticipants({ ...input, userIds: mentioned })\n}\n\nexport interface SeatInput {\n sessionId: string\n domainId: string\n inviter: { id?: string } | undefined | null\n /** 앉힐 사람들. 이미 앉은 사람과 부른 사람 자신은 빠진다. */\n userIds: ReadonlyArray<string>\n participants: any\n visibility?: string | null\n}\n\n/**\n * 사람을 앉힌다 — 멘션과 초대 단추가 함께 쓰는 한 곳.\n *\n * 규칙은 `maySeat` 한 줄이다: 공개 방은 누구나, 그룹은 owner 만, 비공개는 아무도. 앉히지 못하면\n * 아무것도 쓰지 않고 그 사람들을 `notSeated` 로 돌려준다 — 화면이 그대로 말한다.\n * 나갔던 사람(soft delete)은 되살린다 — 다시 부른 것이지 새 사람이 아니다.\n */\nexport async function seatParticipants(input: SeatInput): Promise<MentionInviteResult> {\n const repo = input.participants\n const existing = await repo.find({\n where: { session: { id: input.sessionId } as any, domain: { id: input.domainId } as any },\n withDeleted: true\n })\n\n /* A hide-only `viewer` row is not a seat - the person is brought in over it, as a member. */\n const seated = existing.filter((row: any) => !row.deletedAt && row.role !== 'viewer')\n const activeIds = seated.map((row: any) => row.userId).filter(Boolean)\n const fresh = newParticipantUserIds(input.userIds, activeIds, input.inviter?.id)\n if (fresh.length === 0) return { invited: [] }\n\n /*\n * 공개 방에서 앉히는 일은 아무것도 주지 않지만(누구나 들어온다), 그룹과 비공개에서는 그것이 곧 접근을\n * 주는 일이다. 그룹에서는 owner 가 주고, 비공개에서는 아무도 주지 않는다 — 이름이 불렸다는 것만 남는다.\n */\n const inviterRole = seated.find((row: any) => row.userId === input.inviter?.id)?.role\n if (!maySeat(input.visibility, inviterRole)) return { invited: [], notSeated: fresh }\n\n for (const userId of fresh) await writeMemberSeat(repo, existing, input, userId)\n\n return { invited: fresh }\n}\n\n/**\n * The seats a person's turn gives - what every door that stores a person's words calls.\n *\n * The writer first: in an open room anyone may walk in and speak, and until 2026-10-24 speaking seated nobody. A\n * conversation four people wrote in showed two in its roster - the one who started it and the one who was\n * mentioned - and the other two had no presence, no unread badge and no activity notice. In a group or private\n * room the writer is seated already (the write gate let them in by their seat). Then the people mentioned.\n */\nexport async function seatTurn(input: MentionInviteInput): Promise<MentionInviteResult> {\n await seatWriter(input)\n return inviteMentionedUsers(input)\n}\n\n/** Seat the person who spoke, in an open room only - there the seat grants nothing, it records who took part. */\nexport async function seatWriter(input: Omit<SeatInput, 'userIds'>): Promise<boolean> {\n const writerId = input.inviter?.id\n if (!writerId || !isOpenRoom(input.visibility)) return false\n const repo = input.participants\n const existing = await repo.find({\n where: { session: { id: input.sessionId } as any, domain: { id: input.domainId } as any },\n withDeleted: true\n })\n if (existing.some((row: any) => row.userId === writerId && !row.deletedAt && row.role !== 'viewer')) return false\n await writeMemberSeat(repo, existing, input, writerId)\n return true\n}\n\n/** One member seat: someone who left (soft delete) or only hid it (`viewer`) is brought back on that row, never a second one. */\nasync function writeMemberSeat(repo: any, existing: any[], input: { sessionId: string; domainId: string; inviter: { id?: string } | undefined | null }, userId: string) {\n const prior = existing.find((row: any) => row.userId === userId && (row.deletedAt || row.role === 'viewer'))\n if (prior) {\n await repo.update(prior.id, { deletedAt: null, role: 'member', updater: input.inviter } as any)\n } else {\n await repo.save({\n domain: { id: input.domainId } as any,\n session: { id: input.sessionId } as any,\n user: { id: userId } as any,\n role: 'member',\n creator: input.inviter,\n updater: input.inviter\n } as any)\n }\n}\n"]}
|
|
@@ -152,6 +152,11 @@ export declare class ChatSessionResolver {
|
|
|
152
152
|
* rule (`maySeat`). The invite button and the line under a mention read it; the doors decide again.
|
|
153
153
|
*/
|
|
154
154
|
mayInviteToAISession(sessionId: string, context: ResolverContext): Promise<boolean>;
|
|
155
|
+
/**
|
|
156
|
+
* The person this conversation is about, who always reads it (ADR-0200) - the screen offers no way to send them out,
|
|
157
|
+
* and keeps no copy of the rule. The doors refuse again.
|
|
158
|
+
*/
|
|
159
|
+
keptInAISession(sessionId: string, context: ResolverContext): Promise<string | null>;
|
|
155
160
|
touchPresence(sessionId: string, context: ResolverContext): Promise<boolean>;
|
|
156
161
|
chatMessages(sessionId: string, limit: number, offset: number, context: ResolverContext): Promise<ChatMessage[]>;
|
|
157
162
|
startAISession(anchorType: string, anchorId: string, context: ResolverContext): Promise<ChatSession>;
|
|
@@ -23,6 +23,8 @@ const room_message_js_1 = require("./chat-message/room-message.js");
|
|
|
23
23
|
const reader_gate_js_1 = require("./chat-message/reader-gate.js");
|
|
24
24
|
const request_translator_js_1 = require("./request-translator.js");
|
|
25
25
|
const session_visibility_js_1 = require("./chat-session/session-visibility.js");
|
|
26
|
+
const person_subject_js_1 = require("./people/person-subject.js");
|
|
27
|
+
const room_turn_js_1 = require("./chat-message/room-turn.js");
|
|
26
28
|
const mention_invite_js_1 = require("./chat-session-participant/mention-invite.js");
|
|
27
29
|
const chat_typing_js_1 = require("./chat-message/chat-typing.js");
|
|
28
30
|
const invite_notification_js_1 = require("./chat-session-participant/invite-notification.js");
|
|
@@ -241,6 +243,29 @@ function attachmentRefusalMessage(refusal, context) {
|
|
|
241
243
|
return t('ai-assistant.text.too-many-attachments', { max: refusal.maxFiles, defaultValue: 'at most {max} files can be sent at once.' });
|
|
242
244
|
}
|
|
243
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* A conversation about someone seats them as it is made - they read whatever is asked of their records (ADR-0200).
|
|
248
|
+
* Their seat is a member's, given by the one who started it, as an invite gives it.
|
|
249
|
+
*/
|
|
250
|
+
async function seatPersonOf(session, starter, tx) {
|
|
251
|
+
const seat = (0, person_subject_js_1.personSeatOf)(session.anchorType, session.anchorId, starter);
|
|
252
|
+
if (!seat)
|
|
253
|
+
return;
|
|
254
|
+
await (0, shell_1.getRepository)(chat_session_participant_js_1.ChatSessionParticipant, tx).save({
|
|
255
|
+
domain: session.domain,
|
|
256
|
+
session: { id: session.id },
|
|
257
|
+
user: { id: seat.userId },
|
|
258
|
+
role: 'member',
|
|
259
|
+
creator: starter,
|
|
260
|
+
updater: starter
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/** A conversation about someone stays a group they sit in - said in the asker's words when a change would undo that. */
|
|
264
|
+
function refusePersonRoom(session, change, context) {
|
|
265
|
+
const refusal = session && (0, person_subject_js_1.personRoomRefusal)({ ...session, creatorId: session.creatorId }, change);
|
|
266
|
+
if (refusal)
|
|
267
|
+
throw new Error((0, request_translator_js_1.requestTranslator)(context)(`ai-assistant.text.${refusal}`, { defaultValue: person_subject_js_1.PERSON_ROOM_REFUSALS[refusal] }));
|
|
268
|
+
}
|
|
244
269
|
let ChatSessionResolver = class ChatSessionResolver {
|
|
245
270
|
async chatSession(id, context) {
|
|
246
271
|
const { domain, user } = context.state;
|
|
@@ -529,6 +554,7 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
529
554
|
return false;
|
|
530
555
|
if (session.visibility === visibility)
|
|
531
556
|
return true;
|
|
557
|
+
refusePersonRoom(session, { visibility }, context);
|
|
532
558
|
/*
|
|
533
559
|
* Private is the owner's alone (ADR-0073 decision 3). The members leave with the change - a private room
|
|
534
560
|
* with people still seated in it would be a group under another name. Bringing them back is inviting
|
|
@@ -602,6 +628,7 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
602
628
|
const theirs = seats.find(seat => seat.userId === userId && seat.role === 'member');
|
|
603
629
|
if (!theirs)
|
|
604
630
|
return false;
|
|
631
|
+
refusePersonRoom(await (0, shell_1.getRepository)(chat_session_js_1.ChatSession).findOneBy({ id: sessionId, domain: { id: domain.id } }), { removing: userId }, context);
|
|
605
632
|
return await this._leave(sessionId, theirs, context);
|
|
606
633
|
}
|
|
607
634
|
/**
|
|
@@ -620,6 +647,7 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
620
647
|
}
|
|
621
648
|
if (mine?.role !== 'member')
|
|
622
649
|
return false;
|
|
650
|
+
refusePersonRoom(await (0, shell_1.getRepository)(chat_session_js_1.ChatSession).findOneBy({ id: sessionId, domain: { id: domain.id } }), { removing: user.id }, context);
|
|
623
651
|
return await this._leave(sessionId, mine, context);
|
|
624
652
|
}
|
|
625
653
|
async _leave(sessionId, seat, context) {
|
|
@@ -734,6 +762,16 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
734
762
|
});
|
|
735
763
|
return (0, session_visibility_js_1.maySeat)(session.visibility, seat?.role);
|
|
736
764
|
}
|
|
765
|
+
/**
|
|
766
|
+
* The person this conversation is about, who always reads it (ADR-0200) - the screen offers no way to send them out,
|
|
767
|
+
* and keeps no copy of the rule. The doors refuse again.
|
|
768
|
+
*/
|
|
769
|
+
async keptInAISession(sessionId, context) {
|
|
770
|
+
const { domain } = context.state;
|
|
771
|
+
const session = await (0, shell_1.getRepository)(chat_session_js_1.ChatSession).findOneBy({ id: sessionId, domain: { id: domain.id } });
|
|
772
|
+
const personId = session && (0, person_subject_js_1.personOfAnchor)(session.anchorType, session.anchorId);
|
|
773
|
+
return personId && (0, person_subject_js_1.personRoomRefusal)(session, { removing: personId }) ? personId : null;
|
|
774
|
+
}
|
|
737
775
|
async touchPresence(sessionId, context) {
|
|
738
776
|
const { domain, user } = context.state;
|
|
739
777
|
const repo = (0, shell_1.getRepository)(chat_session_participant_js_1.ChatSessionParticipant);
|
|
@@ -787,7 +825,7 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
787
825
|
domain,
|
|
788
826
|
...(0, session_anchor_js_1.anchorColumns)(anchorType, anchorId),
|
|
789
827
|
/* 새 대화는 비공개로 태어난다 — 공개는 owner 가 고른다(ADR-0073 결정 2, 2026-09-30 고침). */
|
|
790
|
-
visibility: (0, session_visibility_js_1.initialVisibility)({ anchorType }),
|
|
828
|
+
visibility: (0, person_subject_js_1.personSeatOf)(anchorType, anchorId, user)?.visibility ?? (0, session_visibility_js_1.initialVisibility)({ anchorType }),
|
|
791
829
|
creator: user,
|
|
792
830
|
updater: user
|
|
793
831
|
});
|
|
@@ -800,6 +838,7 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
800
838
|
creator: user,
|
|
801
839
|
updater: user
|
|
802
840
|
});
|
|
841
|
+
await seatPersonOf(session, user, tx);
|
|
803
842
|
return session;
|
|
804
843
|
}
|
|
805
844
|
async createAISession(anchorType, anchorId, name, context) {
|
|
@@ -810,7 +849,7 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
810
849
|
const session = await repo.save({
|
|
811
850
|
domain,
|
|
812
851
|
...(0, session_anchor_js_1.anchorColumns)(anchorType, anchorId),
|
|
813
|
-
visibility: (0, session_visibility_js_1.initialVisibility)({ anchorType }),
|
|
852
|
+
visibility: (0, person_subject_js_1.personSeatOf)(anchorType, anchorId, user)?.visibility ?? (0, session_visibility_js_1.initialVisibility)({ anchorType }),
|
|
814
853
|
creator: user,
|
|
815
854
|
updater: user,
|
|
816
855
|
name: finalName
|
|
@@ -824,6 +863,7 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
824
863
|
creator: user,
|
|
825
864
|
updater: user
|
|
826
865
|
});
|
|
866
|
+
await seatPersonOf(session, user, tx);
|
|
827
867
|
return session;
|
|
828
868
|
}
|
|
829
869
|
async renameChatSession(sessionId, name, context) {
|
|
@@ -965,6 +1005,7 @@ let ChatSessionResolver = class ChatSessionResolver {
|
|
|
965
1005
|
visibility: session.visibility
|
|
966
1006
|
});
|
|
967
1007
|
await notifyInvited(context, invite.invited, user, session.name);
|
|
1008
|
+
await (0, room_turn_js_1.tellRoomTurn)({ domain, user, session: session, message: saved, tx, t: (0, request_translator_js_1.requestTranslator)(context) });
|
|
968
1009
|
/* 사람의 말이다 — 목록의 최근 활동과 다른 참여자의 안 읽음이 이것으로 움직인다. */
|
|
969
1010
|
try {
|
|
970
1011
|
await (0, shell_1.getRepository)(chat_session_js_1.ChatSession, tx).update(session.id, (0, session_inbox_js_1.activityPatch)(body));
|
|
@@ -1377,6 +1418,18 @@ tslib_1.__decorate([
|
|
|
1377
1418
|
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
1378
1419
|
tslib_1.__metadata("design:returntype", Promise)
|
|
1379
1420
|
], ChatSessionResolver.prototype, "mayInviteToAISession", null);
|
|
1421
|
+
tslib_1.__decorate([
|
|
1422
|
+
(0, type_graphql_1.Query)(() => String, {
|
|
1423
|
+
nullable: true,
|
|
1424
|
+
description: 'The user this conversation is about, who cannot be sent out of it - none for any other conversation. A hint for the screen; the doors decide again.'
|
|
1425
|
+
}),
|
|
1426
|
+
(0, type_graphql_1.Directive)('@privilege(category: "ai-assistant", privilege: "query", domainOwnerGranted: true)'),
|
|
1427
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('sessionId')),
|
|
1428
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
1429
|
+
tslib_1.__metadata("design:type", Function),
|
|
1430
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
1431
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
1432
|
+
], ChatSessionResolver.prototype, "keptInAISession", null);
|
|
1380
1433
|
tslib_1.__decorate([
|
|
1381
1434
|
(0, type_graphql_1.Mutation)(() => Boolean, {
|
|
1382
1435
|
description: 'Presence heartbeat — bump current user\'s lastSeenAt in the session (online indicator).'
|