W3-d 邮件、待办汇总、分享链接的界面

- 设置 → 通知:渠道多一种格式「邮件」,邮件服务没启用时不列;个人邮件渠道不填地址,写「发到账号邮箱 …」(账号没有邮箱照实写
  发不出去),全局、应用的填收件地址;投递记录里邮件成功写「已交给邮件服务器」、悬停说明退信不追踪;新增「邮件服务」一节
  (管理员改、搭建者只看:口令留空不改、可清除,发测试邮件要先保存)和「每天的待办汇总」的发送时间
- 设置 → 偏好设置的「应用」一节:「允许建分享链接」开关(缺省关,写明关掉时已有的一并打不开)
- 应用编辑 → 岗位与授权:分享链接的管理(选页面、始终最新 / 固定这一期、有效期 1–90 天、允许嵌入;链接只显示这一次;
  列出状态、到期、打开次数,撤销先确认);开关关着时不给新建,已有的照列能撤销;个人应用写明不能分享
- /s 分享页:不进外壳(App 在 /s 上整个跳过认人、取目录、心跳、读主题,请求层在 /s 上也不送去登录页),key 从 # 后面读、
  放进请求头;同一个 ViewRenderer 渲染、操作全禁用;印章常显(「数据的来历」逐个列视图的印章);点数字说明出处在下载的
  报告里;页脚「只读 · 由 X 于 … 分享 · … 到期」;撤销、到期、关了开关、链接不完整按服务端的话写明;没允许嵌入的分享在别的
  页面的 iframe 里不显示内容、给「在新窗口打开」
- ViewRenderer 加 onEvidence:点数字交给调用方(分享页),不开在线证据面板
- check-copy 加「快照链接」一条(总方案 X10:写「分享链接」),带自检
This commit is contained in:
ThearchyHelios
2026-10-16 16:44:06 +08:00
parent f759c5c82d
commit f887cdc30a
16 changed files with 936 additions and 51 deletions
+12 -2
View File
@@ -6,10 +6,11 @@
*/
import type {
AppBindings, AppDetail, AppGrant, AppHookRow, AppList, HookReceipts, AppSpec, AppSummary, AppVersionRow, BackfillPlan, BackfillResult,
ComponentCatalog, Disposition, InstanceRow, LintIssue, PublishResult, ViewModel,
ComponentCatalog, Disposition, InstanceRow, LintIssue, PublishResult, ViewModel, ViewShareCreated, ViewShareList,
ViewShareRow,
} from '../typesApp'
import type { ConversationDetail, EvidenceSegmentDetail } from '../types'
import { del, get, patch, post, put, qs, type RequestOptions } from './http'
import { del, get, patch, post, put, qs, request, type RequestOptions } from './http'
const at = (id: string) => `/apps/${encodeURIComponent(id)}`
const hookAt = (id: string, name: string) => `${at(id)}/hooks/${encodeURIComponent(name)}`
@@ -74,6 +75,15 @@ export const apps = {
deleteHook: (id: string, name: string) => del(hookAt(id, name)),
/** 钩子最近收到的请求(manage):状态、原因、发起的实例或解决的待办,加近 1 小时验签失败几次(04 细案 A6) */
hookReceipts: (id: string, name: string) => get<HookReceipts>(`${hookAt(id, name)}/receipts`),
/**
* 分享链接(manage,服务端 api/shares.py):列、建、撤销。建要管理员开了「允许建分享链接」,到期必填(最长 max_days 天);
* key 只在建的这一次交回
*/
shares: (id: string) => get<ViewShareList>(`${at(id)}/shares`),
createShare: (id: string, body: { page_id: string; mode: 'latest' | 'fixed'; expires_at: string; embed_allowed: boolean }) =>
post<ViewShareCreated>(`${at(id)}/shares`, body),
revokeShare: (id: string, shareId: string) =>
request<ViewShareRow>(`${at(id)}/shares/${encodeURIComponent(shareId)}`, { method: 'DELETE' }),
/**
* 应用编辑器里助手的对话(D-e,manage):取这个应用的那段对话,没有就建(kind=app、归属这个应用)。带着历史轮次;
* 老服务端只回对话本身时由调用方再按 id 取一次
+5 -3
View File
@@ -5,7 +5,7 @@
import type { CatalogReviewAction, CatalogSource, CatalogStatus } from '../types'
import type {
CapabilityEffect, CapabilityReviewOutcome, CapabilityReviewRow, CapabilityRow, EndpointRow, NotifyChannelRow,
NotifyEventRow,
NotifyEventRow, NotifyMailState,
} from '../typesApp'
import { del, get, patch, post, put, qs, type RequestOptions } from './http'
@@ -122,8 +122,10 @@ export const endpoints = {
}
export const notify = {
channels: () => get<{ items: NotifyChannelRow[] }>('/notify/channels'),
createChannel: (body: { name: string; scope: string; owner_id?: string | null; format: string; url: string;
/** mail:邮件服务启没启用、本人的账号邮箱(老服务端不给) */
channels: () => get<{ items: NotifyChannelRow[]; mail?: NotifyMailState }>('/notify/channels'),
/** 邮件渠道:个人的不带 url(只发到账号邮箱),全局、应用的 url 是收件地址(逗号或换行分隔,最多 20 个) */
createChannel: (body: { name: string; scope: string; owner_id?: string | null; format: string; url?: string;
secret?: string | null; events: string[] }) => post<NotifyChannelRow>('/notify/channels', body),
updateChannel: (id: string, body: Record<string, any>) => patch<NotifyChannelRow>(`/notify/channels/${encodeURIComponent(id)}`, body),
removeChannel: (id: string) => del(`/notify/channels/${encodeURIComponent(id)}`),
+2
View File
@@ -689,6 +689,8 @@ export const api = {
/** 今天(本地日期)结论句裁判花了多少:设置页放在每日上限旁边。只读,计数只有裁判自己记 */
judgeSpend: () => get<{ date?: string; usd?: number; calls?: number; unpriced_calls?: number
daily_max_usd?: number | null }>('/settings/judge/spend'),
/** 按存着的邮件服务设置发一封测试邮件,发到管理员自己的账号邮箱(管理员;关登录、没有邮箱时 422) */
mailTest: () => post<{ ok: boolean; message: string }>('/settings/mail/test'),
},
// ---- 工具 ----
+2 -1
View File
@@ -104,7 +104,8 @@ export function actorHeader(): Record<string, string> {
function toLogin(path?: string) {
if (typeof window === 'undefined' || path === '/auth/login' || path === '/auth/me') return
const { pathname, search } = window.location
if (pathname === '/login') return
// 分享页(/s)上没有登录这回事:不送去登录页
if (pathname === '/login' || pathname === '/s') return
const back = `${pathname}${search}`
window.location.assign(back && back !== '/' ? `/login?next=${encodeURIComponent(back)}` : '/login')
}
+42
View File
@@ -0,0 +1,42 @@
/**
* 分享页(/s)的两个接口:GET /api/shares/page、GET /api/shares/report.html(服务端 api/shares.py,04 细案 C2)。
*
* 分享 key 在链接的 # 后面(/s#<key>),打开页面时不发给服务器;这里读出来放进请求头 X-AgentLab-Share,服务端只认请求头。
* 不经 http.request:那条路会带署名头、把 401 当成「会话没了」整页跳去登录页——分享页上没有登录这回事,也不该在外壳的连接
* 状态里报来报去。报错照样翻成 ApiError({detail, code}),页面按 code 写「链接已撤销 / 已到期」。
*
* 只从 ./http、./bundle 导入(同 reportExport.ts,避免和 client.ts 循环导入)。
*/
import type { SharePayload } from '../typesApp'
import { ApiError, BASE, NETWORK_MESSAGE, codeOf, describeDetail } from './http'
import { dispositionName } from './bundle'
export const SHARE_HEADER = 'X-AgentLab-Share'
async function call(path: string, key: string): Promise<Response> {
let res: Response
try {
res = await fetch(BASE + path, { headers: { [SHARE_HEADER]: key }, credentials: 'omit', referrerPolicy: 'no-referrer' })
} catch (e: any) {
throw new ApiError(0, NETWORK_MESSAGE, { kind: 'network', raw: `${e?.name ?? 'Error'}: ${e?.message ?? e}` })
}
if (res.ok) return res
const text = await res.text().catch(() => '')
let body: any = null
try { body = JSON.parse(text) } catch { /* 不是 JSON(代理回的页面) */ }
const detail = body?.detail
throw new ApiError(res.status, detail ? describeDetail(detail, path) : `请求失败(HTTP ${res.status})`,
{ detail, code: codeOf(body), body, raw: `${res.status} ${text.slice(0, 500)}` })
}
export const shares = {
/** 分享页的视图模型、页脚、能下载报告的运行 */
page: async (key: string): Promise<SharePayload> => (await call('/shares/page', key)).json(),
/** 下载报告(附件):只认这条分享解析出来的运行;文件名取服务端给的,没给是 null */
report: async (key: string, runId: string, reportNode?: string): Promise<{ blob: Blob; name: string | null }> => {
const q = new URLSearchParams({ run: runId })
if (reportNode) q.set('report', reportNode)
const res = await call(`/shares/report.html?${q.toString()}`, key)
return { blob: await res.blob(), name: dispositionName(res.headers.get('Content-Disposition')) }
},
}