@axiom-lattice/protocols 7.5.0 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axiom-lattice/protocols",
3
- "version": "7.5.0",
3
+ "version": "7.7.0",
4
4
  "description": "Unified protocol type definitions for Axiom Lattice framework",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -122,7 +122,7 @@ export interface OpenAuditAppendInput {
122
122
  domain: string;
123
123
  action: string;
124
124
  args: unknown;
125
- status: "ok" | "error";
125
+ status: "ok" | "error" | "cancelled";
126
126
  errorCode?: string;
127
127
  durationMs: number;
128
128
  }
@@ -135,8 +135,10 @@ export interface OpenAuditRecord extends OpenAuditAppendInput {
135
135
  export interface OpenAuditQuery {
136
136
  tenantId: string;
137
137
  credentialId?: string;
138
+ projectId?: string;
138
139
  domain?: string;
139
- status?: "ok" | "error";
140
+ action?: string;
141
+ status?: "ok" | "error" | "cancelled";
140
142
  /** ISO timestamps; inclusive from / exclusive to. */
141
143
  from?: string;
142
144
  to?: string;
@@ -146,6 +148,8 @@ export interface OpenAuditQuery {
146
148
 
147
149
  export interface OpenAuditStore {
148
150
  append(record: OpenAuditAppendInput): Promise<void>;
151
+ /** Tenant-scoped detail lookup. */
152
+ get(tenantId: string, id: string): Promise<OpenAuditRecord | null>;
149
153
  /** Tenant-scoped, newest-first. */
150
154
  query(params: OpenAuditQuery): Promise<OpenAuditRecord[]>;
151
155
  }
@@ -49,21 +49,22 @@ export const AUTH_FONT_FAMILIES: Record<
49
49
  system: {
50
50
  labelKey: "platformAdmin.settings.branding.font.system",
51
51
  stack:
52
- 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
52
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", sans-serif',
53
53
  },
54
54
  inter: {
55
55
  labelKey: "platformAdmin.settings.branding.font.inter",
56
56
  stack:
57
- 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
57
+ 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", sans-serif',
58
58
  },
59
59
  serif: {
60
60
  labelKey: "platformAdmin.settings.branding.font.serif",
61
- stack: 'Georgia, "Times New Roman", Times, serif',
61
+ stack:
62
+ 'Georgia, "Times New Roman", Times, "Songti SC", SimSun, "Noto Serif SC", "Source Han Serif SC", serif',
62
63
  },
63
64
  mono: {
64
65
  labelKey: "platformAdmin.settings.branding.font.mono",
65
66
  stack:
66
- '"SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace',
67
+ '"SFMono-Regular", Consolas, "Liberation Mono", Menlo, "Noto Sans Mono CJK SC", "Sarasa Mono SC", "PingFang SC", "Microsoft YaHei", monospace',
67
68
  },
68
69
  };
69
70
 
@@ -1342,6 +1343,18 @@ export interface AuthBrandingCase {
1342
1343
  * Complete first-party examples built from the platform logo and repo-hosted
1343
1344
  * SVG assets. The case stays structured; no HTML is stored or injected.
1344
1345
  */
1346
+ /**
1347
+ * Canonical host namespace for assets referenced by auth branding presets.
1348
+ * Hosts expose this directory (for example via nginx) and may override the
1349
+ * individual URLs with absolute or CDN URLs.
1350
+ */
1351
+ export const AUTH_BRANDING_ASSET_BASE = "/public";
1352
+
1353
+ /** Resolve an auth branding preset asset under the canonical public namespace. */
1354
+ export function authBrandingAsset(path: string): string {
1355
+ return `${AUTH_BRANDING_ASSET_BASE}/${path.replace(/^\/+/, "")}`;
1356
+ }
1357
+
1345
1358
  export const AUTH_BRANDING_CASES = {
1346
1359
  "editorial-launch": {
1347
1360
  id: "editorial-launch",
@@ -1351,15 +1364,15 @@ export const AUTH_BRANDING_CASES = {
1351
1364
  presetId: "editorial-centered",
1352
1365
  branding: {
1353
1366
  brandName: "AlphaFina",
1354
- logoUrl: "/logo.png",
1367
+ logoUrl: authBrandingAsset("logo.png"),
1355
1368
  loginTitle: "A quieter way to sign in",
1356
1369
  loginSubtitle: "One account for every workspace.",
1357
1370
  footerNote: "SOC 2 ready · SSO · Audit logs",
1358
1371
  panelEyebrow: "Crafted for thoughtful teams",
1359
- panelTrustLogo1: "/cases/trust-northstar.svg",
1360
- panelTrustLogo2: "/cases/trust-acme.svg",
1361
- panelTrustLogo3: "/cases/trust-vertex.svg",
1362
- panelTrustLogo4: "/cases/trust-lumen.svg",
1372
+ panelTrustLogo1: authBrandingAsset("presets/trust-northstar.svg"),
1373
+ panelTrustLogo2: authBrandingAsset("presets/trust-acme.svg"),
1374
+ panelTrustLogo3: authBrandingAsset("presets/trust-vertex.svg"),
1375
+ panelTrustLogo4: authBrandingAsset("presets/trust-lumen.svg"),
1363
1376
  },
1364
1377
  },
1365
1378
  "product-showcase": {
@@ -1370,7 +1383,7 @@ export const AUTH_BRANDING_CASES = {
1370
1383
  presetId: "product",
1371
1384
  branding: {
1372
1385
  brandName: "AlphaFina",
1373
- logoUrl: "/logo.png",
1386
+ logoUrl: authBrandingAsset("logo.png"),
1374
1387
  loginLayout: "split-showcase",
1375
1388
  panelPosition: "right",
1376
1389
  panelContentAlign: "center",
@@ -1382,12 +1395,12 @@ export const AUTH_BRANDING_CASES = {
1382
1395
  panelPoint1: "Live run visibility",
1383
1396
  panelPoint2: "Audit-ready activity",
1384
1397
  panelPoint3: "One shared context",
1385
- panelProductImageUrl: "/cases/product-dashboard.svg",
1398
+ panelProductImageUrl: authBrandingAsset("presets/product-dashboard.svg"),
1386
1399
  panelProductImageAlt: "AlphaFina workspace dashboard",
1387
- panelTrustLogo1: "/cases/trust-northstar.svg",
1388
- panelTrustLogo2: "/cases/trust-acme.svg",
1389
- panelTrustLogo3: "/cases/trust-vertex.svg",
1390
- panelTrustLogo4: "/cases/trust-lumen.svg",
1400
+ panelTrustLogo1: authBrandingAsset("presets/trust-northstar.svg"),
1401
+ panelTrustLogo2: authBrandingAsset("presets/trust-acme.svg"),
1402
+ panelTrustLogo3: authBrandingAsset("presets/trust-vertex.svg"),
1403
+ panelTrustLogo4: authBrandingAsset("presets/trust-lumen.svg"),
1391
1404
  imageFit: "cover",
1392
1405
  imagePosition: "top",
1393
1406
  imageTreatment: "none",
@@ -1408,7 +1421,7 @@ export const AUTH_BRANDING_CASES = {
1408
1421
  presetId: "narrative",
1409
1422
  branding: {
1410
1423
  brandName: "AlphaFina",
1411
- logoUrl: "/logo.png",
1424
+ logoUrl: authBrandingAsset("logo.png"),
1412
1425
  loginLayout: "split-story",
1413
1426
  panelEyebrow: "Trusted by modern teams",
1414
1427
  panelTitle: "Build with confidence",
@@ -1427,10 +1440,10 @@ export const AUTH_BRANDING_CASES = {
1427
1440
  "The calmest, most reliable launch experience we have shipped.",
1428
1441
  panelQuoteAuthor: "Maya Chen",
1429
1442
  panelQuoteRole: "VP Engineering, Northstar",
1430
- panelTrustLogo1: "/cases/trust-northstar.svg",
1431
- panelTrustLogo2: "/cases/trust-acme.svg",
1432
- panelTrustLogo3: "/cases/trust-vertex.svg",
1433
- panelTrustLogo4: "/cases/trust-lumen.svg",
1443
+ panelTrustLogo1: authBrandingAsset("presets/trust-northstar.svg"),
1444
+ panelTrustLogo2: authBrandingAsset("presets/trust-acme.svg"),
1445
+ panelTrustLogo3: authBrandingAsset("presets/trust-vertex.svg"),
1446
+ panelTrustLogo4: authBrandingAsset("presets/trust-lumen.svg"),
1434
1447
  },
1435
1448
  },
1436
1449
  "aurora-launch": {
@@ -1441,9 +1454,9 @@ export const AUTH_BRANDING_CASES = {
1441
1454
  presetId: "aurora",
1442
1455
  branding: {
1443
1456
  brandName: "AlphaFina",
1444
- logoUrl: "/logo.png",
1457
+ logoUrl: authBrandingAsset("logo.png"),
1445
1458
  loginLayout: "full-bleed",
1446
- backgroundImageUrl: "/cases/aurora-bg.svg",
1459
+ backgroundImageUrl: authBrandingAsset("presets/aurora-bg.svg"),
1447
1460
  backgroundOverlayColor: "#000000",
1448
1461
  backgroundOverlayOpacity: 35,
1449
1462
  imageFit: "cover",
@@ -1464,10 +1477,10 @@ export const AUTH_BRANDING_CASES = {
1464
1477
  presetId: "cinematic",
1465
1478
  branding: {
1466
1479
  brandName: "AlphaFina",
1467
- logoUrl: "/logo.png",
1480
+ logoUrl: authBrandingAsset("logo.png"),
1468
1481
  loginLayout: "full-bleed",
1469
- backgroundVideoUrl: "/cases/14471967_3840_2160_30fps.mp4",
1470
- backgroundImageUrl: "/cases/aurora-bg.svg",
1482
+ backgroundVideoUrl: authBrandingAsset("presets/14471967_3840_2160_30fps.mp4"),
1483
+ backgroundImageUrl: authBrandingAsset("presets/aurora-bg.svg"),
1471
1484
  backgroundOverlayColor: "#000000",
1472
1485
  backgroundOverlayOpacity: 65,
1473
1486
  imageFit: "cover",
@@ -1487,10 +1500,10 @@ export const AUTH_BRANDING_CASES = {
1487
1500
  presetId: "aurora",
1488
1501
  branding: {
1489
1502
  brandName: "AlphaFina",
1490
- logoUrl: "/logo.png",
1503
+ logoUrl: authBrandingAsset("logo.png"),
1491
1504
  loginLayout: "full-bleed",
1492
- backgroundVideoUrl: "/cases/15404923_1920_1080_60fps.mp4",
1493
- backgroundImageUrl: "/cases/aurora-bg.svg",
1505
+ backgroundVideoUrl: authBrandingAsset("presets/15404923_1920_1080_60fps.mp4"),
1506
+ backgroundImageUrl: authBrandingAsset("presets/aurora-bg.svg"),
1494
1507
  backgroundOverlayColor: "#000000",
1495
1508
  backgroundOverlayOpacity: 30,
1496
1509
  imageFit: "cover",
@@ -206,7 +206,7 @@ export const PLATFORM_SETTINGS_DEFAULTS = {
206
206
  /** Branding used when neither the platform default nor a domain overrides it. */
207
207
  export const DEFAULT_PLATFORM_BRANDING: PlatformBranding = {
208
208
  brandName: "AlphaFina",
209
- logoUrl: "/logo.png",
209
+ logoUrl: "/public/logo.png",
210
210
  primaryColor: "#5b50c6",
211
211
  backgroundColor: "#ffffff",
212
212
  loginLayout: DEFAULT_LOGIN_LAYOUT,
@@ -147,4 +147,103 @@ export interface ThreadStore {
147
147
  * @returns Expired threads ordered by `expiresAt` ascending.
148
148
  */
149
149
  listExpiredThreads(now: Date, limit: number): Promise<Thread[]>;
150
+
151
+ /**
152
+ * List persisted threads for one tenant, newest first.
153
+ *
154
+ * @param tenantId Tenant scope.
155
+ * @param query Optional kind/assistant/time filters and pagination.
156
+ * @returns Matching safe records and the unpaginated total.
157
+ */
158
+ listThreadsByTenant(
159
+ tenantId: string,
160
+ query?: ThreadMonitorQuery
161
+ ): Promise<{ records: ThreadMonitorRecord[]; total: number }>;
162
+ }
163
+
164
+ /** Derived monitor kind for a persisted thread. */
165
+ export type ThreadMonitorKind =
166
+ | "conversation"
167
+ | "room_presence"
168
+ | "task_execution"
169
+ | "open_api"
170
+ | "web_app"
171
+ | "cron"
172
+ | "channel";
173
+
174
+ /** Filters accepted by a tenant-wide thread list. */
175
+ export interface ThreadMonitorQuery {
176
+ limit?: number;
177
+ offset?: number;
178
+ kind?: ThreadMonitorKind;
179
+ assistantId?: string;
180
+ createdAfter?: string;
181
+ }
182
+
183
+ /** Safe thread projection returned by the tenant monitor. */
184
+ export interface ThreadMonitorRecord {
185
+ id: string;
186
+ tenantId: string;
187
+ assistantId: string;
188
+ kind: ThreadMonitorKind;
189
+ workspaceId?: string;
190
+ projectId?: string;
191
+ roomId?: string;
192
+ taskId?: string;
193
+ createdAt: Date;
194
+ updatedAt: Date;
195
+ expiresAt?: Date;
196
+ }
197
+
198
+ /**
199
+ * Derive the monitor kind from metadata already written by the owning flows.
200
+ *
201
+ * No stored `kind` column exists; unknown or missing metadata is
202
+ * `conversation`.
203
+ */
204
+ export function classifyThreadMetadata(
205
+ metadata: Record<string, unknown> | undefined
206
+ ): ThreadMonitorKind {
207
+ if (!metadata) return "conversation";
208
+ if (metadata.source === "project_task" && metadata.kind === "task_execution") {
209
+ return "task_execution";
210
+ }
211
+ if (metadata.source === "project_room" && metadata.kind === "room_presence") {
212
+ return "room_presence";
213
+ }
214
+ if (metadata.source === "open_api") return "open_api";
215
+ if (metadata.source === "web_app") return "web_app";
216
+ if (typeof metadata.cronId === "string" && metadata.cronId.length > 0) {
217
+ return "cron";
218
+ }
219
+ if (typeof metadata.channel === "string" && metadata.channel.length > 0) {
220
+ return "channel";
221
+ }
222
+ return "conversation";
223
+ }
224
+
225
+ /** Project a stored thread into the safe monitor shape. */
226
+ export function toThreadMonitorRecord(thread: Thread): ThreadMonitorRecord {
227
+ const metadata = thread.metadata ?? {};
228
+ const readString = (key: string): string | undefined => {
229
+ const value = metadata[key];
230
+ return typeof value === "string" && value.length > 0 ? value : undefined;
231
+ };
232
+ const workspaceId = readString("workspaceId");
233
+ const projectId = readString("projectId");
234
+ const roomId = readString("roomId");
235
+ const taskId = readString("taskId");
236
+ return {
237
+ id: thread.id,
238
+ tenantId: thread.tenantId,
239
+ assistantId: thread.assistantId,
240
+ kind: classifyThreadMetadata(metadata),
241
+ ...(workspaceId ? { workspaceId } : {}),
242
+ ...(projectId ? { projectId } : {}),
243
+ ...(roomId ? { roomId } : {}),
244
+ ...(taskId ? { taskId } : {}),
245
+ createdAt: thread.createdAt,
246
+ updatedAt: thread.updatedAt,
247
+ ...(thread.expiresAt ? { expiresAt: thread.expiresAt } : {}),
248
+ };
150
249
  }
@@ -76,6 +76,14 @@ describe("PlatformBrandingFields", () => {
76
76
  }
77
77
  });
78
78
 
79
+ it("includes CJK fallbacks in the sans font stack", () => {
80
+ const stack = AUTH_FONT_FAMILIES.system.stack;
81
+ expect(stack).toContain('"PingFang SC"');
82
+ expect(stack).toContain('"Hiragino Sans GB"');
83
+ expect(stack).toContain('"Microsoft YaHei"');
84
+ expect(stack).toContain('"Noto Sans SC"');
85
+ });
86
+
79
87
  it("keeps presets visually distinct beyond color", () => {
80
88
  const axes = [
81
89
  "loginLayout",
@@ -0,0 +1,60 @@
1
+ import {
2
+ classifyThreadMetadata,
3
+ toThreadMonitorRecord,
4
+ type Thread,
5
+ } from "../ThreadStoreProtocol";
6
+
7
+ function thread(metadata?: Record<string, unknown>): Thread {
8
+ return {
9
+ id: "thread-1",
10
+ tenantId: "tenant-1",
11
+ assistantId: "agent-1",
12
+ metadata,
13
+ createdAt: new Date("2026-01-01T00:00:00.000Z"),
14
+ updatedAt: new Date("2026-01-02T00:00:00.000Z"),
15
+ };
16
+ }
17
+
18
+ describe("thread monitor classification", () => {
19
+ it.each([
20
+ [{ source: "project_task", kind: "task_execution" }, "task_execution"],
21
+ [{ source: "project_room", kind: "room_presence" }, "room_presence"],
22
+ [{ source: "open_api" }, "open_api"],
23
+ [{ source: "web_app" }, "web_app"],
24
+ [{ cronId: "cron-1" }, "cron"],
25
+ [{ channel: "lark" }, "channel"],
26
+ [{}, "conversation"],
27
+ [undefined, "conversation"],
28
+ ])("classifies %j as %s", (metadata, expected) => {
29
+ expect(classifyThreadMetadata(metadata as never)).toBe(expected);
30
+ });
31
+
32
+ it("projects only explicit monitor fields", () => {
33
+ const record = toThreadMonitorRecord(
34
+ thread({
35
+ source: "project_task",
36
+ kind: "task_execution",
37
+ workspaceId: "ws-1",
38
+ projectId: "p-1",
39
+ roomId: "room-1",
40
+ taskId: "task-1",
41
+ secret: "do-not-leak",
42
+ }),
43
+ );
44
+
45
+ expect(record).toEqual({
46
+ id: "thread-1",
47
+ tenantId: "tenant-1",
48
+ assistantId: "agent-1",
49
+ kind: "task_execution",
50
+ workspaceId: "ws-1",
51
+ projectId: "p-1",
52
+ roomId: "room-1",
53
+ taskId: "task-1",
54
+ createdAt: new Date("2026-01-01T00:00:00.000Z"),
55
+ updatedAt: new Date("2026-01-02T00:00:00.000Z"),
56
+ });
57
+ expect(record).not.toHaveProperty("metadata");
58
+ expect(record).not.toHaveProperty("secret");
59
+ });
60
+ });