bailinghub 0.4.0 → 0.5.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.
Files changed (141) hide show
  1. package/.gitignore +5 -0
  2. package/README.en.md +5 -2
  3. package/README.md +5 -2
  4. package/SECURITY.md +11 -0
  5. package/docker-compose.images.yml +2 -2
  6. package/docs/AGENT_AUTH_API.en.md +175 -0
  7. package/docs/AGENT_AUTH_API.md +190 -0
  8. package/docs/AGENT_CLIENT_QUICKSTART.en.md +212 -0
  9. package/docs/AGENT_CLIENT_QUICKSTART.md +206 -0
  10. package/docs/AGENT_CLIENT_RUNTIME_API.en.md +157 -0
  11. package/docs/AGENT_CLIENT_RUNTIME_API.md +107 -0
  12. package/docs/CHANGELOG.en.md +13 -0
  13. package/docs/CHANGELOG.md +13 -0
  14. package/docs/INDEPENDENT_VALIDATION.en.md +4 -4
  15. package/docs/INDEPENDENT_VALIDATION.md +4 -4
  16. package/docs/README.en.md +8 -2
  17. package/docs/README.md +8 -2
  18. package/docs/RELEASE_NOTES_v0.5.0.en.md +41 -0
  19. package/docs/RELEASE_NOTES_v0.5.0.md +41 -0
  20. package/package.json +3 -2
  21. package/schemas/config/client.schema.json +7 -0
  22. package/schemas/config/common.schema.json +30 -0
  23. package/schemas/config/route.schema.json +11 -0
  24. package/scripts/check-doc-links.mjs +1 -1
  25. package/scripts/check-image-tags.sh +1 -1
  26. package/scripts/check-release-consistency.test.mjs +5 -5
  27. package/scripts/e2e-console.mjs +144 -0
  28. package/scripts/export-oss.mjs +5 -12
  29. package/scripts/install.sh +1 -1
  30. package/scripts/public-content-denylist.mjs +82 -0
  31. package/scripts/public-content-denylist.test.mjs +53 -0
  32. package/scripts/publish-images.sh +1 -1
  33. package/scripts/release-audit.mjs +8 -13
  34. package/scripts/sdk-runtime-test.mjs +171 -7
  35. package/scripts/security-scan.mjs +8 -5
  36. package/scripts/validate-examples.mjs +3 -1
  37. package/scripts/verify-github-repo.mjs +7 -12
  38. package/scripts/verify-oss-export.mjs +6 -12
  39. package/sdk/php/README.md +27 -1
  40. package/sdk/php/src/AgentAuth.php +78 -0
  41. package/sdk/php/src/HubClient.php +3 -0
  42. package/sdk/php7/README.md +32 -2
  43. package/sdk/php7/src/AgentAuth.php +77 -0
  44. package/sdk/php7/src/HubClient.php +3 -0
  45. package/sql/055_agent_auth.sql +72 -0
  46. package/sql/056_agent_client_runtime.sql +60 -0
  47. package/src/adapters/channels/wecom-api.ts +1 -1
  48. package/src/app/agent-client-runtime.test.ts +221 -0
  49. package/src/app/agent-client-runtime.ts +408 -0
  50. package/src/app/agent-tool-invocations.test.ts +462 -0
  51. package/src/app/agent-tool-invocations.ts +795 -0
  52. package/src/app/agent-tool-job.test.ts +62 -0
  53. package/src/app/agent-tool-job.ts +41 -0
  54. package/src/app/auth.ts +2 -1
  55. package/src/app/kernel.ts +2 -0
  56. package/src/app/runtime-context.ts +8 -0
  57. package/src/app/tool-approvals.ts +5 -1
  58. package/src/app/tool-assembly.ts +19 -1
  59. package/src/app/tool-context.ts +2 -1
  60. package/src/core/config/config-codec.ts +2 -1
  61. package/src/core/config/config-models.test.ts +10 -0
  62. package/src/core/config/config-models.ts +21 -0
  63. package/src/core/config/config-schema.test.ts +6 -0
  64. package/src/core/config/route-config.test.ts +15 -0
  65. package/src/core/config/route-config.ts +36 -0
  66. package/src/core/config/tools-config.test.ts +58 -1
  67. package/src/core/config/tools-config.ts +84 -0
  68. package/src/core/contracts/tools.ts +162 -29
  69. package/src/core/contracts/types.ts +36 -0
  70. package/src/core/runtime/agent-client-trace.test.ts +154 -0
  71. package/src/core/runtime/agent-client-trace.ts +288 -0
  72. package/src/core/runtime/launch-runtime.ts +13 -0
  73. package/src/core/runtime/trace-runtime.test.ts +18 -1
  74. package/src/core/runtime/trace-runtime.ts +28 -3
  75. package/src/core/state/state-codec.ts +2 -0
  76. package/src/infrastructure/config/config-agent-auth-repository.test.ts +147 -0
  77. package/src/infrastructure/config/config-agent-auth-repository.ts +356 -0
  78. package/src/infrastructure/config/config-agent-client-runtime-repository.ts +253 -0
  79. package/src/infrastructure/config/config-approval-ledger.test.ts +32 -0
  80. package/src/infrastructure/config/config-approval-ledger.ts +16 -0
  81. package/src/infrastructure/config/config-client-repository.ts +3 -3
  82. package/src/infrastructure/config/config-conversation-ledger.test.ts +69 -0
  83. package/src/infrastructure/config/config-conversation-ledger.ts +8 -7
  84. package/src/infrastructure/config/config-observability-ledger.test.ts +50 -0
  85. package/src/infrastructure/config/config-observability-ledger.ts +65 -10
  86. package/src/infrastructure/config/config-route-repository.ts +4 -3
  87. package/src/infrastructure/config/configstore.ts +14 -3
  88. package/src/infrastructure/state/state-mysql.ts +2 -2
  89. package/src/kernel-api/v1/contracts.ts +8 -0
  90. package/src/routes/admin-runtime.test.ts +214 -0
  91. package/src/routes/admin-runtime.ts +82 -2
  92. package/src/routes/agent-api.test.ts +379 -0
  93. package/src/routes/agent-api.ts +251 -0
  94. package/src/routes/agent-auth.test.ts +276 -0
  95. package/src/routes/agent-auth.ts +395 -0
  96. package/src/routes/approvals.ts +4 -1
  97. package/src/routes/critical-routes.test.ts +235 -1
  98. package/src/routes/private-default.ts +2 -1
  99. package/src/routes/private.ts +16 -1
  100. package/src/routes/run.ts +79 -13
  101. package/web/connect/bailing-connect-php.tgz +0 -0
  102. package/web/connect/bailing-connect-php7.tgz +0 -0
  103. package/web/console/assets/{Accounts-DuUY2UJU.js → Accounts-D4RRm5D1.js} +1 -1
  104. package/web/console/assets/{Approvals-B11mo1dy.js → Approvals-CsTTKb8o.js} +1 -1
  105. package/web/console/assets/{Audit-CQwJRIJT.js → Audit-BzvZ7JZw.js} +1 -1
  106. package/web/console/assets/{BrandLockup-BIF-h1pi.js → BrandLockup-CYcA93wh.js} +1 -1
  107. package/web/console/assets/{Channels-BIploUT-.js → Channels-DRQZggqM.js} +1 -1
  108. package/web/console/assets/{ChatEntries-Cpg_WV-o.js → ChatEntries-BUB7BWKU.js} +1 -1
  109. package/web/console/assets/Clients-CQ_MonGL.css +1 -0
  110. package/web/console/assets/Clients-HhCyrxfz.js +3 -0
  111. package/web/console/assets/{Cost-BF52tfU2.js → Cost-BZgFf1yM.js} +1 -1
  112. package/web/console/assets/{Credentials-SwfmQAv6.js → Credentials-BTe2Q07j.js} +1 -1
  113. package/web/console/assets/{Diagnostics-CJfbI_8p.js → Diagnostics-WL-buYli.js} +1 -1
  114. package/web/console/assets/{Executors-CzlZlznA.js → Executors-CGZ-7Xmp.js} +1 -1
  115. package/web/console/assets/{Kb-CVX22U4k.js → Kb-VVw8oGsT.js} +1 -1
  116. package/web/console/assets/{Login-PoUVsBI-.js → Login-rwvmBBPl.js} +1 -1
  117. package/web/console/assets/{Projects-DYlbjLQy.js → Projects-CexaCEY1.js} +1 -1
  118. package/web/console/assets/Routes-B9ZHbQAp.js +124 -0
  119. package/web/console/assets/Routes-BbkFpi6Y.css +1 -0
  120. package/web/console/assets/Runs-4zDD9VOC.css +1 -0
  121. package/web/console/assets/Runs-BzFNPTwD.js +3 -0
  122. package/web/console/assets/{Setup-xiPXit_b.js → Setup-Djh5yadQ.js} +1 -1
  123. package/web/console/assets/{Shell-DNiWZOYB.js → Shell-kn763smL.js} +1 -1
  124. package/web/console/assets/{StorageBuckets-Bjsc3pLd.js → StorageBuckets-CQBR41W1.js} +1 -1
  125. package/web/console/assets/{SystemSettings-CcKF2lJ9.js → SystemSettings-DgnopekD.js} +1 -1
  126. package/web/console/assets/{SystemStatus-Oj1xjxJn.js → SystemStatus-Bj8-kPt2.js} +1 -1
  127. package/web/console/assets/{Targets-y1KllVXT.js → Targets-BAfCt_nH.js} +1 -1
  128. package/web/console/assets/{Tools-DoEP_y9x.js → Tools-xjd0NZdE.js} +1 -1
  129. package/web/console/assets/{index-CxPIS6G7.js → index-DfJA7iJS.js} +2 -2
  130. package/web/console/assets/{request-CBLNpLth.js → request-DkNPOweH.js} +1 -1
  131. package/web/console/assets/{schema-DzwLpuOy.js → schema-CgPWAu1_.js} +1 -1
  132. package/web/console/index.html +1 -1
  133. package/web-admin/src/pages/Clients.vue +11 -3
  134. package/web-admin/src/pages/Routes.vue +282 -16
  135. package/web-admin/src/pages/Runs.vue +159 -38
  136. package/web/console/assets/Clients--D7NQJKk.css +0 -1
  137. package/web/console/assets/Clients-DS29eUi2.js +0 -3
  138. package/web/console/assets/Routes-DSEvGujN.js +0 -124
  139. package/web/console/assets/Routes-DWGQN5Pv.css +0 -1
  140. package/web/console/assets/Runs-B-TsYZEt.js +0 -3
  141. package/web/console/assets/Runs-CUtSsPW-.css +0 -1
@@ -1,7 +1,7 @@
1
1
  // OSS 默认私有 HTTP 分发:这里才绑定 app/runtime 单组织单例和默认业务 handler。
2
2
  // 自定义部署应 import private.ts 的 handlePrivateHttpFor(deps) 并传入自己的 deps。
3
3
  import type { IncomingMessage, ServerResponse } from 'node:http';
4
- import { cfg, cfgStore, kbService, store, targetRegistry, toolIndex } from '../app/runtime';
4
+ import { cfg, cfgStore, isPaused, kbService, store, targetRegistry, toolIndex } from '../app/runtime';
5
5
  import { handleAdminApi } from './admin-default';
6
6
  import { handleApprovalDecision } from './approvals-default';
7
7
  import { handleExecutorClaim, handleExecutorHeartbeat, handleExecutorResult } from './executor-default';
@@ -16,6 +16,7 @@ export function defaultPrivateHttpDeps(): PrivateHttpDeps {
16
16
  cfg,
17
17
  configStore: cfgStore,
18
18
  stateStore: store,
19
+ isPaused,
19
20
  kbService,
20
21
  toolIndex,
21
22
  targetRegistry,
@@ -12,10 +12,13 @@ import type { KbService } from '../services/kb';
12
12
  import type { ToolIndexService } from '../services/tools-index';
13
13
  import type { TargetRegistry } from '../core/targets/registry';
14
14
  import type { KernelHostAdminSessionV1, KernelIdentityProviderV1 } from '../kernel-api/v1/contracts';
15
+ import { handleAgentAuthHttpFor } from './agent-auth';
16
+ import { handleAgentApiHttpFor } from './agent-api';
15
17
 
16
18
  export interface PrivateHttpDeps extends AuthRuntimeDeps {
17
19
  cfg: AppConfig;
18
20
  stateStore: RuntimeStateStore;
21
+ isPaused: () => boolean;
19
22
  kbService: KbService | null;
20
23
  toolIndex: ToolIndexService | null;
21
24
  handleAdminApi(method: string, path: string, req: IncomingMessage, res: ServerResponse, principal: Principal): Promise<boolean>;
@@ -109,6 +112,17 @@ export async function handlePrivateHttpFor(deps: PrivateHttpDeps, req: IncomingM
109
112
  const mApprovalDecision = method === 'POST' ? path.match(/^\/approvals\/(\d+)\/decision$/) : null;
110
113
  if (mApprovalDecision) { await deps.handleApprovalDecision(req, res, Number(mApprovalDecision[1]), url); return; }
111
114
 
115
+ // 本地 Agent 的网页授权与独立 API 使用专用 bearer,不复用旧 /run Client Token 入口。
116
+ if (await handleAgentAuthHttpFor({ configStore: deps.configStore }, req, res, url)) return;
117
+ if (await handleAgentApiHttpFor({
118
+ configStore: deps.configStore,
119
+ stateStore: deps.stateStore,
120
+ isPaused: deps.isPaused,
121
+ handleRun: deps.handleRun,
122
+ toolProxyDeps: toolProxyDeps(deps),
123
+ kbService: deps.kbService,
124
+ }, req, res, url)) return;
125
+
112
126
  if (method === 'POST' && path === '/admin/login') {
113
127
  if (deps.identityProvider?.handleLogin) await deps.identityProvider.handleLogin(req, res);
114
128
  else if (deps.identityProvider) send(res, 404, { error: 'local login disabled by host' });
@@ -202,7 +216,8 @@ export async function handlePrivateHttpFor(deps: PrivateHttpDeps, req: IncomingM
202
216
  if (method === 'GET' && path.startsWith('/jobs/')) {
203
217
  const job = await deps.stateStore.getJob(path.slice('/jobs/'.length));
204
218
  // 接入方只能看自己触发的 job(job_id 是 uuid 不可猜,这里是第二道闸)。
205
- if (!job || (!isAdmin && job.client_app_id !== principal.client.app_id)) { send(res, 404, { error: 'not found' }); return; }
219
+ // Agent 任务还必须由原 Agent Session 经专用 API 读取,同 app 的 Client Token 也不能越权。
220
+ if (!job || (!isAdmin && (job.client_app_id !== principal.client.app_id || !!job.agent_session_id))) { send(res, 404, { error: 'not found' }); return; }
206
221
  send(res, 200, job);
207
222
  return;
208
223
  }
package/src/routes/run.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // 业务触发入口:POST /run — 接入方/admin 带 token 触发,解析路由/会话/项目后交 engine.launchJob。
2
2
  import type { IncomingMessage, ServerResponse } from 'node:http';
3
- import { randomUUID } from 'node:crypto';
3
+ import { createHash, randomUUID } from 'node:crypto';
4
4
  import { readBody, send } from '../app/http';
5
5
  import type { EngineRuntime } from '../app/engine';
6
6
  import { type Principal, clientAllowsRoute, rateLimitedFor } from '../app/auth';
@@ -23,6 +23,34 @@ interface RuntimeContextInput {
23
23
 
24
24
  const CLIENT_ROUTE_PATTERN = /^[a-z0-9][a-z0-9_-]{1,63}$/;
25
25
  const CLIENT_RUN_FIELDS = new Set(['request_id', 'route', 'input', 'metadata', 'callback_url']);
26
+ const AGENT_RUN_FIELDS = new Set(['request_id', 'route', 'input', 'metadata']);
27
+ const AGENT_RESERVED_METADATA_FIELDS = new Set([
28
+ 'principal', 'subject', 'operator', 'principal_id', 'user_id', 'uid', 'operator_id',
29
+ 'visitor_uid', 'operator_uid', 'tenant', 'tenant_id', 'org_id', 'workspace_id',
30
+ 'roles', 'role', 'audience', 'principal_type', 'user_type', 'client_app_id', 'source',
31
+ 'session_id', 'on_behalf_of', 'agent_session_id', 'agent_client_app_id', 'agent_device_label',
32
+ ]);
33
+
34
+ function agentAllowsRoute(principal: Extract<Principal, { kind: 'agent' }>, routeKey: string): boolean {
35
+ return principal.session.allowed_routes.includes('*') || principal.session.allowed_routes.includes(routeKey);
36
+ }
37
+
38
+ function agentUserMetadata(value: Record<string, unknown>): Record<string, unknown> {
39
+ return Object.fromEntries(Object.entries(value).filter(([key]) => !AGENT_RESERVED_METADATA_FIELDS.has(key)));
40
+ }
41
+
42
+ function agentSubjectScope(principal: Extract<Principal, { kind: 'agent' }>): string {
43
+ // Agent 与旧 Client /run 使用不同命名空间;scope 只由业务后端批准的主体派生,
44
+ // 不读取用户 metadata。client_app_id + NUL + on_behalf_of 共同入摘要,
45
+ // 避免不同 Client 恰好采用相同不透明主体值时共用历史。
46
+ const subjectHash = createHash('sha256')
47
+ .update('bailinghub.agent-subject.v1\0', 'utf8')
48
+ .update(principal.session.client_app_id, 'utf8')
49
+ .update('\0', 'utf8')
50
+ .update(principal.session.on_behalf_of, 'utf8')
51
+ .digest('hex');
52
+ return `agent-subject:${subjectHash}`;
53
+ }
26
54
 
27
55
  function isRecord(value: unknown): value is Record<string, unknown> {
28
56
  return typeof value === 'object' && value !== null && !Array.isArray(value);
@@ -73,25 +101,42 @@ export async function handleRunFor(deps: RunApiDeps, req: IncomingMessage, res:
73
101
  const ctx = await deps.runtimeContextFor({ source: 'run', requestId: body.request_id, principal });
74
102
  const { state: store, config: cfgStore } = deps.runtimeStoresFor(ctx);
75
103
  const engine = deps.engineForContext(ctx);
76
- const metadata = (body.metadata as Record<string, unknown>) ?? {};
104
+ const suppliedMetadata = (body.metadata as Record<string, unknown>) ?? {};
105
+ const agent = principal.kind === 'agent' ? principal : null;
106
+ // Agent 身份字段只从服务端会话注入;同名用户 metadata 永远被覆盖。
107
+ const metadata: Record<string, unknown> = agent
108
+ ? {
109
+ ...agentUserMetadata(suppliedMetadata),
110
+ principal: { ...agent.session.principal },
111
+ on_behalf_of: agent.session.on_behalf_of,
112
+ visitor_uid: agent.session.on_behalf_of,
113
+ operator_uid: agent.session.on_behalf_of,
114
+ agent_session_id: agent.session.session_id,
115
+ agent_client_app_id: agent.session.client_app_id,
116
+ agent_device_label: agent.session.device_label,
117
+ }
118
+ : suppliedMetadata;
77
119
 
78
120
  // 接入方策略闸门:只能走 route(不许自带 project/profile 绕过路由配置)+ 路由白名单 + 限速
79
- const client = principal.kind === 'client' ? principal.client : null;
121
+ const client = principal.kind === 'client' || principal.kind === 'agent' ? principal.client : null;
80
122
  if (client) {
81
123
  if (typeof body.route !== 'string' || !CLIENT_ROUTE_PATTERN.test(body.route)) {
82
124
  send(res, 400, { error: '接入方 route 必须匹配 ^[a-z0-9][a-z0-9_-]{1,63}$' });
83
125
  return;
84
126
  }
85
127
  if (body.project || body.profile) { send(res, 403, { error: '接入方不可覆盖 project/profile(由路由配置决定)' }); return; }
86
- const unknownFields = Object.keys(rawBody).filter((key) => !CLIENT_RUN_FIELDS.has(key));
128
+ const allowedFields = agent ? AGENT_RUN_FIELDS : CLIENT_RUN_FIELDS;
129
+ const unknownFields = Object.keys(rawBody).filter((key) => !allowedFields.has(key));
87
130
  if (unknownFields.length > 0) {
88
- send(res, 400, { error: `接入方请求包含公开 Client API 未声明字段: ${unknownFields.join(', ')}` });
131
+ send(res, 400, { error: `${agent ? 'Agent' : '接入方'}请求包含未声明字段: ${unknownFields.join(', ')}` });
89
132
  return;
90
133
  }
91
134
  if (body.route !== 'auto' && !clientAllowsRoute(client, body.route)) { send(res, 403, { error: `接入方 ${client.app_id} 无权调用路由 ${body.route}` }); return; }
135
+ if (agent && body.route !== 'auto' && !agentAllowsRoute(agent, body.route)) { send(res, 403, { error: `Agent 会话无权调用路由 ${body.route}` }); return; }
92
136
  if (await rateLimitedFor(cfgStore, client)) { send(res, 429, { error: `超出限速(${client.rate_limit_per_min}/分钟),请稍后重试同 request_id` }); return; }
93
137
  }
94
- const actor = resolvePrincipal({ metadata, clientAppId: client?.app_id ?? null, channel: client?.app_id ?? 'admin' });
138
+ const requestChannel = agent?.session.principal.channel ?? (client?.app_id ?? 'admin');
139
+ const actor = resolvePrincipal({ metadata, clientAppId: client?.app_id ?? null, channel: requestChannel });
95
140
 
96
141
  let route: Route | null = null;
97
142
  let resolvedRouteKey = body.route ?? null;
@@ -99,7 +144,7 @@ export async function handleRunFor(deps: RunApiDeps, req: IncomingMessage, res:
99
144
  let target = 'llm';
100
145
  let project = body.project;
101
146
  let profileName = body.profile;
102
- let callbackUrl = body.callback_url;
147
+ let callbackUrl = agent ? undefined : body.callback_url;
103
148
  let session: SessionTarget;
104
149
  let threadScope = ''; // 对话线索 scope(与会话 scope 同语义)
105
150
 
@@ -112,7 +157,7 @@ export async function handleRunFor(deps: RunApiDeps, req: IncomingMessage, res:
112
157
  metadata,
113
158
  client,
114
159
  principal: actor,
115
- channel: client?.app_id ?? 'admin',
160
+ channel: requestChannel,
116
161
  });
117
162
  routeDecision = {
118
163
  mode: 'auto',
@@ -132,13 +177,20 @@ export async function handleRunFor(deps: RunApiDeps, req: IncomingMessage, res:
132
177
  if (!route) { send(res, 400, { error: `未知 route: ${body.route}` }); return; }
133
178
  if (!route.enabled) { send(res, 400, { error: `route 已停用: ${body.route}` }); return; }
134
179
  if (client && !clientAllowsRoute(client, route.route_key)) { send(res, 403, { error: `接入方 ${client.app_id} 无权调用路由 ${route.route_key}` }); return; }
180
+ if (agent && !agentAllowsRoute(agent, route.route_key)) { send(res, 403, { error: `Agent 会话无权调用路由 ${route.route_key}` }); return; }
135
181
  const audience = audienceAllows(route.audience, actor);
136
182
  if (!audience.ok) { send(res, 403, { error: `主体无权进入路由 ${route.route_key}`, reason: audience.reason }); return; }
137
183
  target = route.target;
138
184
  project = route.project;
139
185
  profileName = body.profile ?? route.profile;
140
- callbackUrl = body.callback_url ?? route.default_callback_url;
141
- const s = await cfgStore.conversations.resolveSession(route, metadata);
186
+ callbackUrl = agent ? undefined : (body.callback_url ?? route.default_callback_url);
187
+ if (agent && (route.session_policy === 'fixed' || route.session_policy === 'passthrough')) {
188
+ send(res, 403, { error: `Agent API 不允许 session_policy=${route.session_policy};请使用 new 或 per_key` });
189
+ return;
190
+ }
191
+ const s = agent && route.session_policy === 'per_key'
192
+ ? await cfgStore.conversations.sessionForScope(route.route_key, agentSubjectScope(agent))
193
+ : await cfgStore.conversations.resolveSession(route, metadata);
142
194
  session = { sessionId: s.sessionId, isContinue: s.isContinue };
143
195
  threadScope = s.scopeKey || `req:${body.request_id}`; // new 策略每单自成线索
144
196
  } else {
@@ -158,7 +210,12 @@ export async function handleRunFor(deps: RunApiDeps, req: IncomingMessage, res:
158
210
  // 幂等(接入方只能撞自己的 request_id,防跨方碰撞/探测)
159
211
  const existing = await store.findByRequestId(body.request_id);
160
212
  if (existing) {
161
- if (client && existing.client_app_id !== client.app_id) {
213
+ const existingAgentSessionId = existing.agent_session_id ?? '';
214
+ if (agent && (existing.client_app_id !== client?.app_id || existingAgentSessionId !== agent.session.session_id)) {
215
+ send(res, 409, { error: 'request_id 与其他 Agent 会话冲突,请换用带本会话前缀的 request_id' });
216
+ return;
217
+ }
218
+ if (!agent && client && (existing.client_app_id !== client.app_id || !!existingAgentSessionId)) {
162
219
  send(res, 409, { error: 'request_id 与其他接入方冲突,请换用带自身前缀的 request_id' });
163
220
  return;
164
221
  }
@@ -178,9 +235,18 @@ export async function handleRunFor(deps: RunApiDeps, req: IncomingMessage, res:
178
235
  requestId: body.request_id, fullInput: body.input,
179
236
  route, routeKey: resolvedRouteKey,
180
237
  target, project: project ?? null, projectPath,
181
- profileName, permission: route?.permission, source: client ? client.app_id : (body.source ?? 'unknown'),
238
+ profileName, permission: route?.permission, source: agent ? `agent:${client!.app_id}` : (client ? client.app_id : (body.source ?? 'unknown')),
182
239
  clientAppId: client?.app_id, metadata: jobMetadata, callbackUrl,
183
- session, threadScope, principalId, channel: client?.app_id ?? 'admin',
240
+ session, threadScope, principalId, channel: agent ? `agent:${client!.app_id}` : (client?.app_id ?? 'admin'),
241
+ ...(agent ? {
242
+ agentAttribution: {
243
+ agentSessionId: agent.session.session_id,
244
+ clientAppId: agent.session.client_app_id,
245
+ subjectId: agent.session.principal.id,
246
+ ...(agent.session.principal.tenant ? { businessTenantRef: agent.session.principal.tenant } : {}),
247
+ onBehalfOf: agent.session.on_behalf_of,
248
+ },
249
+ } : {}),
184
250
  });
185
251
  if (client && cfgStore) void cfgStore.clients.touch(client.app_id).catch(() => { /* 观测字段,失败不影响主流程 */ });
186
252
 
Binary file
@@ -1,3 +1,3 @@
1
- import{aj as K,E as V}from"./vendor-element-D7WRzHhy.js";import{a as C}from"./request-CBLNpLth.js";import{f as W,c as X}from"./util-SiQC2MJh.js";import{u as Y}from"./index-CxPIS6G7.js";import{H as c}from"./HelpTip-CT07o3kB.js";import{d as Z,z as h,c as L,S as n,J as t,R as O,r as _,ai as i,o as b,e as o,Q as r,P as s,u as ee,I as E,O as $,a3 as le,q as te}from"./vendor-vue-B2uhHUfE.js";import{_ as ne}from"./_plugin-vue_export-helper-DlAUqK2U.js";const ae={class:"head"},oe={class:"account-main"},se={class:"account-stack"},de={class:"muted"},ie={class:"account-stack"},ue={class:"muted"},re=Z({__name:"Accounts",setup(me){const y={admin:"全能",kb_editor:"知识库维护",viewer:"只读任务"},N=Y(),x=_([]),T=_(["admin","kb_editor","viewer"]),u=_(!1),m=_(!1),w=_(!1),d=te({username:"",display_name:"",role:"kb_editor",password:"",enabled:!0});async function g(){var e;const a=await C("/admin/api/admins");x.value=a.list,(e=a.roles)!=null&&e.length&&(T.value=a.roles)}function S(a){return a==="admin"?"admin":a==="kb_editor"?"kb_editor":a==="viewer"?"viewer":a}function M(a){return a?`最近登录 ${W(a)}`:"从未登录"}function j(){m.value=!1,Object.assign(d,{username:"",display_name:"",role:"kb_editor",password:"",enabled:!0}),u.value=!0}function q(a){m.value=!0,Object.assign(d,{username:a.username,display_name:a.display_name||"",role:a.role,password:"",enabled:!!a.enabled}),u.value=!0}async function D(){w.value=!0;try{const a=await C("/admin/api/admins",{method:"POST",body:JSON.stringify(d)});u.value=!1,await g(),a.generated_password?(await K.alert(`账号 ${a.username} 的初始密码(只显示这一次,请立即发给使用人):
1
+ import{aj as K,E as V}from"./vendor-element-D7WRzHhy.js";import{a as C}from"./request-DkNPOweH.js";import{f as W,c as X}from"./util-SiQC2MJh.js";import{u as Y}from"./index-DfJA7iJS.js";import{H as c}from"./HelpTip-CT07o3kB.js";import{d as Z,z as h,c as L,S as n,J as t,R as O,r as _,ai as i,o as b,e as o,Q as r,P as s,u as ee,I as E,O as $,a3 as le,q as te}from"./vendor-vue-B2uhHUfE.js";import{_ as ne}from"./_plugin-vue_export-helper-DlAUqK2U.js";const ae={class:"head"},oe={class:"account-main"},se={class:"account-stack"},de={class:"muted"},ie={class:"account-stack"},ue={class:"muted"},re=Z({__name:"Accounts",setup(me){const y={admin:"全能",kb_editor:"知识库维护",viewer:"只读任务"},N=Y(),x=_([]),T=_(["admin","kb_editor","viewer"]),u=_(!1),m=_(!1),w=_(!1),d=te({username:"",display_name:"",role:"kb_editor",password:"",enabled:!0});async function g(){var e;const a=await C("/admin/api/admins");x.value=a.list,(e=a.roles)!=null&&e.length&&(T.value=a.roles)}function S(a){return a==="admin"?"admin":a==="kb_editor"?"kb_editor":a==="viewer"?"viewer":a}function M(a){return a?`最近登录 ${W(a)}`:"从未登录"}function j(){m.value=!1,Object.assign(d,{username:"",display_name:"",role:"kb_editor",password:"",enabled:!0}),u.value=!0}function q(a){m.value=!0,Object.assign(d,{username:a.username,display_name:a.display_name||"",role:a.role,password:"",enabled:!!a.enabled}),u.value=!0}async function D(){w.value=!0;try{const a=await C("/admin/api/admins",{method:"POST",body:JSON.stringify(d)});u.value=!1,await g(),a.generated_password?(await K.alert(`账号 ${a.username} 的初始密码(只显示这一次,请立即发给使用人):
2
2
 
3
3
  ${a.generated_password}`,"账号已创建",{confirmButtonText:"复制密码"}).catch(()=>{}),await X(a.generated_password,"密码已复制")):V.success("已保存")}catch(a){V.error(a.message)}finally{w.value=!1}}async function I(a){try{await C("/admin/api/admins/"+encodeURIComponent(a),{method:"DELETE"}),await g()}catch(e){V.error(e.message)}}return h(g),(a,e)=>{const p=i("el-button"),v=i("el-table-column"),U=i("el-tag"),R=i("el-popconfirm"),z=i("el-table"),A=i("el-card"),k=i("el-input"),f=i("el-form-item"),H=i("el-option"),J=i("el-select"),P=i("el-switch"),F=i("el-form"),Q=i("el-drawer");return b(),L(O,null,[n(A,{shadow:"never"},{header:t(()=>[o("div",ae,[e[9]||(e[9]=o("b",null,"后台账号",-1)),e[10]||(e[10]=s()),n(c,{title:"后台账号 / 角色"},{default:t(()=>[...e[7]||(e[7]=[o("p",null,"后台账号只用于维护中枢控制台,不等同于业务系统用户,也不参与聊天/工具调用的业务身份。",-1),o("p",null,[s("角色决定可见板块与管理权限:"),o("code",null,"admin"),s(" 管全局配置,"),o("code",null,"kb_editor"),s(" 维护知识库,"),o("code",null,"viewer"),s(" 查看运行记录。")],-1)])]),_:1}),n(p,{type:"primary",style:{"margin-left":"auto"},onClick:j},{default:t(()=>[...e[8]||(e[8]=[s("新建账号",-1)])]),_:1})])]),default:t(()=>[n(z,{data:x.value},{default:t(()=>[n(v,{label:"账号","min-width":"240","show-overflow-tooltip":""},{default:t(({row:l})=>[o("div",oe,[o("b",null,r(l.display_name||l.username),1),o("code",null,r(l.username),1)])]),_:1}),n(v,{label:"角色权限","min-width":"220"},{default:t(({row:l})=>[o("div",se,[n(U,{type:l.role==="admin"?"warning":"info",effect:"plain"},{default:t(()=>[s(r(S(l.role)),1)]),_:2},1032,["type"]),o("span",de,r(y[l.role]||"自定义角色"),1)])]),_:1}),n(v,{label:"登录状态","min-width":"190"},{default:t(({row:l})=>[o("div",ie,[n(U,{type:l.enabled?"success":"info",effect:"plain"},{default:t(()=>[s(r(l.enabled?"启用":"停用"),1)]),_:2},1032,["type"]),o("span",ue,r(M(l.last_login_at)),1)])]),_:1}),n(v,{"min-width":"80",align:"right"},{default:t(({row:l})=>{var B;return[n(p,{link:"",type:"primary",onClick:G=>q(l)},{default:t(()=>[...e[11]||(e[11]=[s("编辑",-1)])]),_:1},8,["onClick"]),l.username!==((B=ee(N).me)==null?void 0:B.username)?(b(),E(R,{key:0,title:"删除该账号?其登录会话立即失效。",width:"240",onConfirm:G=>I(l.username)},{reference:t(()=>[n(p,{link:"",type:"danger"},{default:t(()=>[...e[12]||(e[12]=[s("删",-1)])]),_:1})]),_:1},8,["onConfirm"])):$("",!0)]}),_:1})]),_:1},8,["data"])]),_:1}),n(Q,{modelValue:u.value,"onUpdate:modelValue":e[6]||(e[6]=l=>u.value=l),title:m.value?"编辑账号":"新建账号",size:"420px"},{footer:t(()=>[n(p,{onClick:e[5]||(e[5]=l=>u.value=!1)},{default:t(()=>[...e[22]||(e[22]=[s("取消",-1)])]),_:1}),n(p,{type:"primary",loading:w.value,onClick:D},{default:t(()=>[...e[23]||(e[23]=[s("保存",-1)])]),_:1},8,["loading"])]),default:t(()=>[n(F,{"label-position":"top"},{default:t(()=>[n(f,null,{label:t(()=>[...e[13]||(e[13]=[s("用户名 ",-1),o("span",{class:"field-required"},"必填",-1)])]),default:t(()=>[n(k,{modelValue:d.username,"onUpdate:modelValue":e[0]||(e[0]=l=>d.username=l),disabled:m.value,placeholder:"如 ops-admin",class:"mono"},null,8,["modelValue","disabled"])]),_:1}),n(f,{label:"显示名(可选)"},{default:t(()=>[n(k,{modelValue:d.display_name,"onUpdate:modelValue":e[1]||(e[1]=l=>d.display_name=l)},null,8,["modelValue"])]),_:1}),n(f,null,{label:t(()=>[e[15]||(e[15]=s("角色 ",-1)),e[16]||(e[16]=o("span",{class:"field-required"},"必填",-1)),e[17]||(e[17]=s()),n(c,{title:"角色"},{default:t(()=>[...e[14]||(e[14]=[o("p",null,[o("b",null,"admin"),s(":管理全局配置与账号;"),o("b",null,"kb_editor"),s(":维护知识库;"),o("b",null,"viewer"),s(":只读查看运行记录。")],-1)])]),_:1})]),default:t(()=>[n(J,{modelValue:d.role,"onUpdate:modelValue":e[2]||(e[2]=l=>d.role=l),style:{width:"100%"}},{default:t(()=>[(b(!0),L(O,null,le(T.value,l=>(b(),E(H,{key:l,value:l,label:l+(y[l]?"("+y[l]+")":"")},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1}),n(f,null,{label:t(()=>[e[19]||(e[19]=s("密码 ",-1)),n(c,{title:"密码"},{default:t(()=>[...e[18]||(e[18]=[o("p",null,"新建时留空会自动生成,并只显示一次。编辑时留空表示不修改;填写后该账号其他登录会话会立即下线。",-1)])]),_:1})]),default:t(()=>[n(k,{modelValue:d.password,"onUpdate:modelValue":e[3]||(e[3]=l=>d.password=l),type:"password","show-password":"",autocomplete:"new-password",placeholder:"至少 8 位"},null,8,["modelValue"])]),_:1}),m.value?(b(),E(f,{key:0},{label:t(()=>[e[21]||(e[21]=s("启用 ",-1)),n(c,{title:"启用状态"},{default:t(()=>[...e[20]||(e[20]=[o("p",null,"停用账号会立即使其登录会话失效。",-1)])]),_:1})]),default:t(()=>[n(P,{modelValue:d.enabled,"onUpdate:modelValue":e[4]||(e[4]=l=>d.enabled=l)},null,8,["modelValue"])]),_:1})):$("",!0)]),_:1})]),_:1},8,["modelValue","title"])],64)}}}),we=ne(re,[["__scopeId","data-v-f7ba53c9"]]);export{we as default};
@@ -1 +1 @@
1
- import{d as R,z as U,V as q,I as v,J as s,ai as i,r as N,o as u,S as a,e as o,Q as l,c as m,R as x,O as S,u as z,P as d,aC as F}from"./vendor-vue-B2uhHUfE.js";import{E as J}from"./vendor-element-D7WRzHhy.js";import{a as O}from"./request-CBLNpLth.js";import{o as Q}from"./docs-DPUOCa7R.js";import{f as T}from"./util-SiQC2MJh.js";import{H as G}from"./HelpTip-CT07o3kB.js";import{_ as K}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-CxPIS6G7.js";const W={class:"head"},X={class:"intent"},Y={class:"block"},Z={class:"block"},w={class:"intent-main"},ee={class:"muted"},te={class:"muted ellipsis"},ne={class:"intent-stack"},se={class:"muted mono"},oe={class:"muted"},ae={class:"intent-stack"},le={class:"muted"},ie={class:"intent-stack"},de={key:0,class:"muted ellipsis"},re={key:1,class:"muted"},ue=R({__name:"Approvals",setup(pe){const $=F(),f=N([]),c=N("pending");let y=0;async function _(){f.value=await O("/admin/api/tool-approvals?status="+c.value)}async function g(n,t){try{const r=await O(`/admin/api/tool-approvals/${n}/${t}`,{method:"POST"});J.success(t==="approve"?r.rerun?"已批准,任务已自动重跑":"已批准(任务在途,运行中会执行该调用)":"已拒绝"),await _()}catch(r){J.error(r.message)}}function B(n){$.push("/runs?job="+n)}function I(){Q("/docs/approvals")}function b(n,t){return n==="risk_high"?"高风险":n==="confirm_required"?"强制确认":n==="confirm_when"?"条件确认":t==="high"?"高风险":"需确认"}function j(n){return n==="high"?"高风险":n==="medium"?"中风险":n||"需确认"}function D(n){return n.status==="pending"?"待决策":n.status==="approved"?n.used_at?"已批准 · 已执行":"已批准 · 待执行":"已拒绝"}function E(n){return n.status==="pending"?"warning":n.status==="approved"?"success":"info"}function L(n){try{return JSON.stringify(JSON.parse(n),null,2)}catch{return n}}return U(()=>{_(),y=window.setInterval(()=>void _(),3e4)}),q(()=>window.clearInterval(y)),(n,t)=>{const r=i("el-button"),k=i("el-radio-button"),A=i("el-radio-group"),H=i("el-empty"),p=i("el-table-column"),h=i("el-tag"),C=i("el-popconfirm"),M=i("el-table"),P=i("el-card");return u(),v(P,{shadow:"never"},{header:s(()=>[o("div",W,[t[5]||(t[5]=o("b",null,"审批意图",-1)),t[6]||(t[6]=d()),a(G,{title:"审批意图是什么"},{default:s(()=>[...t[1]||(t[1]=[o("p",null,"高风险或命中参数级确认规则的工具调用会先冻结成审批意图。中枢锁定调用快照,批准后任务自动重跑并只执行被批准的那次调用。",-1),o("p",null,"如果路由配置了业务侧审批承接,这里仍可追溯中枢侧意图与最终决策;实际审批人和审批页面由业务系统决定。",-1)])]),_:1}),a(r,{style:{"margin-left":"auto"},onClick:I},{default:s(()=>[...t[2]||(t[2]=[d("开发文档",-1)])]),_:1}),a(A,{modelValue:c.value,"onUpdate:modelValue":t[0]||(t[0]=e=>c.value=e),size:"small",onChange:_},{default:s(()=>[a(k,{value:"pending"},{default:s(()=>[...t[3]||(t[3]=[d("待审批",-1)])]),_:1}),a(k,{value:"all"},{default:s(()=>[...t[4]||(t[4]=[d("全部",-1)])]),_:1})]),_:1},8,["modelValue"])])]),default:s(()=>[f.value.length?(u(),v(M,{key:1,data:f.value,"row-key":"id"},{default:s(()=>[a(p,{type:"expand"},{default:s(({row:e})=>[o("div",X,[t[8]||(t[8]=o("div",{class:"td-sec"},"参数快照",-1)),o("pre",Y,l(L(e.args_json||"{}")),1),e.intent?(u(),m(x,{key:0},[t[7]||(t[7]=o("div",{class:"td-sec"},"审批意图完整快照",-1)),o("pre",Z,l(JSON.stringify(e.intent,null,2)),1)],64)):S("",!0)])]),_:1}),a(p,{label:"审批意图","min-width":"320","show-overflow-tooltip":""},{default:s(({row:e})=>[o("div",w,[o("span",ee,"#"+l(e.id)+" · "+l(z(T)(e.created_at)),1),o("b",null,l(e.summary||e.reason||e.tool),1),o("span",te,l(e.reason||b(e.policy,e.risk)),1),o("code",null,l(e.provider)+" · "+l(e.tool),1)])]),_:1}),a(p,{label:"调用上下文","min-width":"260","show-overflow-tooltip":""},{default:s(({row:e})=>[o("div",ne,[o("code",null,l(e.method)+" "+l(e.path),1),o("span",se,l(e.scope),1),o("span",oe,"主体 "+l(e.on_behalf_of||"无主体"),1),a(r,{link:"",type:"primary",size:"small",onClick:V=>B(e.job_id)},{default:s(()=>[...t[9]||(t[9]=[d("看任务",-1)])]),_:1},8,["onClick"])])]),_:1}),a(p,{label:"治理规则",width:"150"},{default:s(({row:e})=>[o("div",ae,[a(h,{size:"small",effect:"plain",type:e.risk==="high"?"danger":"warning"},{default:s(()=>[d(l(j(e.risk)),1)]),_:2},1032,["type"]),o("span",le,l(b(e.policy,e.risk)),1)])]),_:1}),a(p,{label:"决策状态",width:"170"},{default:s(({row:e})=>[o("div",ie,[a(h,{size:"small",type:E(e),effect:"plain"},{default:s(()=>[d(l(D(e)),1)]),_:2},1032,["type"]),e.decided_by?(u(),m("span",de,l(e.decided_by)+" · "+l(z(T)(e.decided_at)),1)):(u(),m("span",re,"等待业务侧或控制台兜底决策"))])]),_:1}),a(p,{width:"178",align:"right"},{default:s(({row:e})=>[e.status==="pending"?(u(),m(x,{key:0},[a(C,{title:"批准该意图?任务将自动重跑并执行这次已冻结的调用快照。",width:"260",onConfirm:V=>g(e.id,"approve")},{reference:s(()=>[a(r,{link:"",type:"success"},{default:s(()=>[...t[10]||(t[10]=[d("兜底批准",-1)])]),_:1})]),_:1},8,["onConfirm"]),a(C,{title:"拒绝该意图?任务保持原结论,不会重跑。",width:"260",onConfirm:V=>g(e.id,"deny")},{reference:s(()=>[a(r,{link:"",type:"danger"},{default:s(()=>[...t[11]||(t[11]=[d("兜底拒绝",-1)])]),_:1})]),_:1},8,["onConfirm"])],64)):S("",!0)]),_:1})]),_:1},8,["data"])):(u(),v(H,{key:0,description:c.value==="pending"?"没有待审批的调用":"还没有审批记录"},null,8,["description"]))]),_:1})}}}),ke=K(ue,[["__scopeId","data-v-03845cb0"]]);export{ke as default};
1
+ import{d as R,z as U,V as q,I as v,J as s,ai as i,r as N,o as u,S as a,e as o,Q as l,c as m,R as x,O as S,u as z,P as d,aC as F}from"./vendor-vue-B2uhHUfE.js";import{E as J}from"./vendor-element-D7WRzHhy.js";import{a as O}from"./request-DkNPOweH.js";import{o as Q}from"./docs-DPUOCa7R.js";import{f as T}from"./util-SiQC2MJh.js";import{H as G}from"./HelpTip-CT07o3kB.js";import{_ as K}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-DfJA7iJS.js";const W={class:"head"},X={class:"intent"},Y={class:"block"},Z={class:"block"},w={class:"intent-main"},ee={class:"muted"},te={class:"muted ellipsis"},ne={class:"intent-stack"},se={class:"muted mono"},oe={class:"muted"},ae={class:"intent-stack"},le={class:"muted"},ie={class:"intent-stack"},de={key:0,class:"muted ellipsis"},re={key:1,class:"muted"},ue=R({__name:"Approvals",setup(pe){const $=F(),f=N([]),c=N("pending");let y=0;async function _(){f.value=await O("/admin/api/tool-approvals?status="+c.value)}async function g(n,t){try{const r=await O(`/admin/api/tool-approvals/${n}/${t}`,{method:"POST"});J.success(t==="approve"?r.rerun?"已批准,任务已自动重跑":"已批准(任务在途,运行中会执行该调用)":"已拒绝"),await _()}catch(r){J.error(r.message)}}function B(n){$.push("/runs?job="+n)}function I(){Q("/docs/approvals")}function b(n,t){return n==="risk_high"?"高风险":n==="confirm_required"?"强制确认":n==="confirm_when"?"条件确认":t==="high"?"高风险":"需确认"}function j(n){return n==="high"?"高风险":n==="medium"?"中风险":n||"需确认"}function D(n){return n.status==="pending"?"待决策":n.status==="approved"?n.used_at?"已批准 · 已执行":"已批准 · 待执行":"已拒绝"}function E(n){return n.status==="pending"?"warning":n.status==="approved"?"success":"info"}function L(n){try{return JSON.stringify(JSON.parse(n),null,2)}catch{return n}}return U(()=>{_(),y=window.setInterval(()=>void _(),3e4)}),q(()=>window.clearInterval(y)),(n,t)=>{const r=i("el-button"),k=i("el-radio-button"),A=i("el-radio-group"),H=i("el-empty"),p=i("el-table-column"),h=i("el-tag"),C=i("el-popconfirm"),M=i("el-table"),P=i("el-card");return u(),v(P,{shadow:"never"},{header:s(()=>[o("div",W,[t[5]||(t[5]=o("b",null,"审批意图",-1)),t[6]||(t[6]=d()),a(G,{title:"审批意图是什么"},{default:s(()=>[...t[1]||(t[1]=[o("p",null,"高风险或命中参数级确认规则的工具调用会先冻结成审批意图。中枢锁定调用快照,批准后任务自动重跑并只执行被批准的那次调用。",-1),o("p",null,"如果路由配置了业务侧审批承接,这里仍可追溯中枢侧意图与最终决策;实际审批人和审批页面由业务系统决定。",-1)])]),_:1}),a(r,{style:{"margin-left":"auto"},onClick:I},{default:s(()=>[...t[2]||(t[2]=[d("开发文档",-1)])]),_:1}),a(A,{modelValue:c.value,"onUpdate:modelValue":t[0]||(t[0]=e=>c.value=e),size:"small",onChange:_},{default:s(()=>[a(k,{value:"pending"},{default:s(()=>[...t[3]||(t[3]=[d("待审批",-1)])]),_:1}),a(k,{value:"all"},{default:s(()=>[...t[4]||(t[4]=[d("全部",-1)])]),_:1})]),_:1},8,["modelValue"])])]),default:s(()=>[f.value.length?(u(),v(M,{key:1,data:f.value,"row-key":"id"},{default:s(()=>[a(p,{type:"expand"},{default:s(({row:e})=>[o("div",X,[t[8]||(t[8]=o("div",{class:"td-sec"},"参数快照",-1)),o("pre",Y,l(L(e.args_json||"{}")),1),e.intent?(u(),m(x,{key:0},[t[7]||(t[7]=o("div",{class:"td-sec"},"审批意图完整快照",-1)),o("pre",Z,l(JSON.stringify(e.intent,null,2)),1)],64)):S("",!0)])]),_:1}),a(p,{label:"审批意图","min-width":"320","show-overflow-tooltip":""},{default:s(({row:e})=>[o("div",w,[o("span",ee,"#"+l(e.id)+" · "+l(z(T)(e.created_at)),1),o("b",null,l(e.summary||e.reason||e.tool),1),o("span",te,l(e.reason||b(e.policy,e.risk)),1),o("code",null,l(e.provider)+" · "+l(e.tool),1)])]),_:1}),a(p,{label:"调用上下文","min-width":"260","show-overflow-tooltip":""},{default:s(({row:e})=>[o("div",ne,[o("code",null,l(e.method)+" "+l(e.path),1),o("span",se,l(e.scope),1),o("span",oe,"主体 "+l(e.on_behalf_of||"无主体"),1),a(r,{link:"",type:"primary",size:"small",onClick:V=>B(e.job_id)},{default:s(()=>[...t[9]||(t[9]=[d("看任务",-1)])]),_:1},8,["onClick"])])]),_:1}),a(p,{label:"治理规则",width:"150"},{default:s(({row:e})=>[o("div",ae,[a(h,{size:"small",effect:"plain",type:e.risk==="high"?"danger":"warning"},{default:s(()=>[d(l(j(e.risk)),1)]),_:2},1032,["type"]),o("span",le,l(b(e.policy,e.risk)),1)])]),_:1}),a(p,{label:"决策状态",width:"170"},{default:s(({row:e})=>[o("div",ie,[a(h,{size:"small",type:E(e),effect:"plain"},{default:s(()=>[d(l(D(e)),1)]),_:2},1032,["type"]),e.decided_by?(u(),m("span",de,l(e.decided_by)+" · "+l(z(T)(e.decided_at)),1)):(u(),m("span",re,"等待业务侧或控制台兜底决策"))])]),_:1}),a(p,{width:"178",align:"right"},{default:s(({row:e})=>[e.status==="pending"?(u(),m(x,{key:0},[a(C,{title:"批准该意图?任务将自动重跑并执行这次已冻结的调用快照。",width:"260",onConfirm:V=>g(e.id,"approve")},{reference:s(()=>[a(r,{link:"",type:"success"},{default:s(()=>[...t[10]||(t[10]=[d("兜底批准",-1)])]),_:1})]),_:1},8,["onConfirm"]),a(C,{title:"拒绝该意图?任务保持原结论,不会重跑。",width:"260",onConfirm:V=>g(e.id,"deny")},{reference:s(()=>[a(r,{link:"",type:"danger"},{default:s(()=>[...t[11]||(t[11]=[d("兜底拒绝",-1)])]),_:1})]),_:1},8,["onConfirm"])],64)):S("",!0)]),_:1})]),_:1},8,["data"])):(u(),v(H,{key:0,description:c.value==="pending"?"没有待审批的调用":"还没有审批记录"},null,8,["description"]))]),_:1})}}}),ke=K(ue,[["__scopeId","data-v-03845cb0"]]);export{ke as default};
@@ -1 +1 @@
1
- import{a as h}from"./request-CBLNpLth.js";import{f as B}from"./util-SiQC2MJh.js";import{H as N}from"./HelpTip-CT07o3kB.js";import{d as P,z as S,I as g,J as a,ai as i,r as d,o as u,K as V,S as n,e as o,Q as c,u as A,P as p,c as $,O as H,as as I}from"./vendor-vue-B2uhHUfE.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-CxPIS6G7.js";import"./vendor-element-D7WRzHhy.js";const O={class:"head"},j={class:"audit-main"},z={class:"muted"},G={class:"audit-stack"},J={class:"muted mono"},K={key:2,class:"loadmore"},f=100,Q=P({__name:"Audit",setup(U){const s=d([]),r=d(!1),m=d(!1),_=d(!1);function k(e){return String(e||"").replace(/^\/admin\/api\//,"").replace(/^routes/,"触发路由").replace(/^clients/,"接入方").replace(/^credentials/,"模型凭证").replace(/^tool-providers/,"工具源").replace(/^targets/,"调度目标").replace(/^executor-tokens/,"执行器令牌").replace(/^storage-buckets/,"对象存储").replace(/^admins/,"后台账号").replace(/^kb/,"知识库")}function w(e){return e==="DELETE"?"删除":e==="POST"?"保存":e==="PUT"?"更新":e||"变更"}async function b(){r.value=!0;try{const e=await h(`/admin/api/config-audit?limit=${f}&offset=0`);s.value=e,m.value=e.length===f}finally{r.value=!1}}async function E(){_.value=!0;try{const e=await h(`/admin/api/config-audit?limit=${f}&offset=${s.value.length}`);s.value=s.value.concat(e),m.value=e.length===f}finally{_.value=!1}}return S(b),(e,t)=>{const y=i("el-button"),T=i("el-empty"),v=i("el-table-column"),x=i("el-tag"),C=i("el-table"),D=i("el-card"),L=I("loading");return u(),g(D,{shadow:"never"},{header:a(()=>[o("div",O,[t[2]||(t[2]=o("b",null,"变更审计",-1)),t[3]||(t[3]=p()),n(N,{title:"变更审计是什么"},{default:a(()=>[...t[0]||(t[0]=[o("p",null,"记录控制台配置被谁修改、何时修改、作用到哪个配置对象。用于追溯路由、凭证、接入方、账号、知识库、目标等配置变更。",-1),o("p",null,"这是配置审计,不是任务执行 trace;任务执行过程请到「任务」查看。",-1)])]),_:1}),n(y,{style:{"margin-left":"auto"},loading:r.value,onClick:b},{default:a(()=>[...t[1]||(t[1]=[p("刷新",-1)])]),_:1},8,["loading"])])]),default:a(()=>[!s.value.length&&!r.value?(u(),g(T,{key:0,description:"暂无配置变更记录"})):V((u(),g(C,{key:1,data:s.value},{default:a(()=>[n(v,{label:"变更事件","min-width":"260","show-overflow-tooltip":""},{default:a(({row:l})=>[o("div",j,[o("b",null,c(l.by||"未知操作人"),1),o("span",z,c(A(B)(l.ts,!0)),1)])]),_:1}),n(v,{label:"配置对象","min-width":"360","show-overflow-tooltip":""},{default:a(({row:l})=>[o("div",G,[o("code",null,c(k(l.path)),1),o("span",J,c(l.path),1)])]),_:1}),n(v,{label:"动作",width:"110",align:"center"},{default:a(({row:l})=>[n(x,{type:l.method==="DELETE"?"danger":"success",effect:"plain"},{default:a(()=>[p(c(w(l.method)),1)]),_:2},1032,["type"])]),_:1})]),_:1},8,["data"])),[[L,r.value]]),m.value?(u(),$("div",K,[n(y,{loading:_.value,onClick:E},{default:a(()=>[...t[4]||(t[4]=[p("加载更多",-1)])]),_:1},8,["loading"])])):H("",!0)]),_:1})}}}),ee=M(Q,[["__scopeId","data-v-a240b46d"]]);export{ee as default};
1
+ import{a as h}from"./request-DkNPOweH.js";import{f as B}from"./util-SiQC2MJh.js";import{H as N}from"./HelpTip-CT07o3kB.js";import{d as P,z as S,I as g,J as a,ai as i,r as d,o as u,K as V,S as n,e as o,Q as c,u as A,P as p,c as $,O as H,as as I}from"./vendor-vue-B2uhHUfE.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-DfJA7iJS.js";import"./vendor-element-D7WRzHhy.js";const O={class:"head"},j={class:"audit-main"},z={class:"muted"},G={class:"audit-stack"},J={class:"muted mono"},K={key:2,class:"loadmore"},f=100,Q=P({__name:"Audit",setup(U){const s=d([]),r=d(!1),m=d(!1),_=d(!1);function k(e){return String(e||"").replace(/^\/admin\/api\//,"").replace(/^routes/,"触发路由").replace(/^clients/,"接入方").replace(/^credentials/,"模型凭证").replace(/^tool-providers/,"工具源").replace(/^targets/,"调度目标").replace(/^executor-tokens/,"执行器令牌").replace(/^storage-buckets/,"对象存储").replace(/^admins/,"后台账号").replace(/^kb/,"知识库")}function w(e){return e==="DELETE"?"删除":e==="POST"?"保存":e==="PUT"?"更新":e||"变更"}async function b(){r.value=!0;try{const e=await h(`/admin/api/config-audit?limit=${f}&offset=0`);s.value=e,m.value=e.length===f}finally{r.value=!1}}async function E(){_.value=!0;try{const e=await h(`/admin/api/config-audit?limit=${f}&offset=${s.value.length}`);s.value=s.value.concat(e),m.value=e.length===f}finally{_.value=!1}}return S(b),(e,t)=>{const y=i("el-button"),T=i("el-empty"),v=i("el-table-column"),x=i("el-tag"),C=i("el-table"),D=i("el-card"),L=I("loading");return u(),g(D,{shadow:"never"},{header:a(()=>[o("div",O,[t[2]||(t[2]=o("b",null,"变更审计",-1)),t[3]||(t[3]=p()),n(N,{title:"变更审计是什么"},{default:a(()=>[...t[0]||(t[0]=[o("p",null,"记录控制台配置被谁修改、何时修改、作用到哪个配置对象。用于追溯路由、凭证、接入方、账号、知识库、目标等配置变更。",-1),o("p",null,"这是配置审计,不是任务执行 trace;任务执行过程请到「任务」查看。",-1)])]),_:1}),n(y,{style:{"margin-left":"auto"},loading:r.value,onClick:b},{default:a(()=>[...t[1]||(t[1]=[p("刷新",-1)])]),_:1},8,["loading"])])]),default:a(()=>[!s.value.length&&!r.value?(u(),g(T,{key:0,description:"暂无配置变更记录"})):V((u(),g(C,{key:1,data:s.value},{default:a(()=>[n(v,{label:"变更事件","min-width":"260","show-overflow-tooltip":""},{default:a(({row:l})=>[o("div",j,[o("b",null,c(l.by||"未知操作人"),1),o("span",z,c(A(B)(l.ts,!0)),1)])]),_:1}),n(v,{label:"配置对象","min-width":"360","show-overflow-tooltip":""},{default:a(({row:l})=>[o("div",G,[o("code",null,c(k(l.path)),1),o("span",J,c(l.path),1)])]),_:1}),n(v,{label:"动作",width:"110",align:"center"},{default:a(({row:l})=>[n(x,{type:l.method==="DELETE"?"danger":"success",effect:"plain"},{default:a(()=>[p(c(w(l.method)),1)]),_:2},1032,["type"])]),_:1})]),_:1},8,["data"])),[[L,r.value]]),m.value?(u(),$("div",K,[n(y,{loading:_.value,onClick:E},{default:a(()=>[...t[4]||(t[4]=[p("加载更多",-1)])]),_:1},8,["loading"])])):H("",!0)]),_:1})}}}),ee=M(Q,[["__scopeId","data-v-a240b46d"]]);export{ee as default};
@@ -1 +1 @@
1
- import{i as H,a as t}from"./index-CxPIS6G7.js";import{d as e,u as Q,o as V,c as s,aD as r}from"./vendor-vue-B2uhHUfE.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";const o=["src","alt"],n={key:1,class:"brand-lockup-svg",viewBox:"0 0 144 58",role:"img","aria-label":"百灵中枢 BailingHub"},l=e({__name:"BrandLockup",setup(Z){return(c,a)=>Q(H).logo_url?(V(),s("img",{key:0,class:"brand-lockup-image",src:Q(t)(Q(H).logo_url),alt:Q(H).site_name},null,8,o)):(V(),s("svg",n,[...a[0]||(a[0]=[r('<g transform="translate(0 -3) scale(0.2416667)" data-v-efbff744><path class="brand-lockup-svg__mark-main" fill-rule="evenodd" d="M42 44h34v152H54l-12-12zM76 44h58v34H76zM76 103h22v34H76zM76 162h58v34H76zM150 44h22l12 12v8h-34zM150 86h34v110h-34z" data-v-efbff744></path><path class="brand-lockup-svg__mark-accent" fill-rule="evenodd" d="M116 103h68v34h-68zM76 162h58v34H76z" data-v-efbff744></path></g><path class="brand-lockup-svg__main" transform="translate(0 1)" d="M59.197 7.553H77.824V10.535H59.197ZM63.397 17.486H73.897V20.237H63.397ZM63.481 22.442H73.603V25.256H63.481ZM66.715 8.645 70.474 9.401Q70.222 10.304 69.96 11.186Q69.697 12.068 69.466 12.845Q69.235 13.622 69.004 14.231L66.085 13.496Q66.232 12.803 66.368 11.963Q66.505 11.123 66.6 10.262Q66.694 9.401 66.715 8.645ZM61.129 12.509H76.081V26.474H72.805V15.323H64.237V26.474H61.129Z M87.925 15.911H91.159Q91.012 17.507 90.739 18.893Q90.466 20.279 89.868 21.476Q89.269 22.673 88.177 23.649Q87.085 24.626 85.342 25.392Q83.599 26.159 80.995 26.684Q80.806 26.075 80.344 25.298Q79.882 24.521 79.42 24.038Q81.73 23.639 83.242 23.082Q84.754 22.526 85.647 21.791Q86.539 21.056 86.99 20.163Q87.442 19.271 87.631 18.21Q87.82 17.15 87.925 15.911ZM82.948 16.541 85.573 17.507Q85.195 18.746 84.618 19.985Q84.04 21.224 83.179 22.085L80.638 20.552Q81.436 19.817 82.024 18.746Q82.612 17.675 82.948 16.541ZM95.401 16.415 98.047 17.927Q97.396 18.998 96.714 20.069Q96.031 21.14 95.443 21.917L93.175 20.531Q93.553 20.006 93.963 19.303Q94.372 18.599 94.761 17.843Q95.149 17.087 95.401 16.415ZM90.781 17.192Q91.306 19.145 92.335 20.499Q93.364 21.854 95.118 22.62Q96.871 23.387 99.58 23.639Q99.286 23.954 98.95 24.447Q98.614 24.941 98.32 25.466Q98.026 25.991 97.837 26.432Q95.611 26.075 94.025 25.382Q92.44 24.689 91.358 23.597Q90.277 22.505 89.542 20.993Q88.807 19.481 88.282 17.486ZM82.108 10.304H96.115V12.362H82.108ZM81.184 7.07H97.354V15.533H81.184V12.845H94.435V9.758H81.184Z M101.743 10.136H119.341V21.056H116.128V13.139H104.809V21.161H101.743ZM103.318 17.066H117.892V20.069H103.318ZM108.841 6.545H112.075V26.495H108.841Z M121.714 10.388H129.001V13.202H121.714ZM124.276 6.545H127.027V26.495H124.276ZM124.255 12.551 125.83 13.202Q125.62 14.525 125.305 15.9Q124.99 17.276 124.591 18.588Q124.192 19.901 123.709 21.035Q123.226 22.169 122.68 22.988Q122.554 22.547 122.312 21.98Q122.071 21.413 121.798 20.846Q121.525 20.279 121.273 19.859Q121.777 19.229 122.239 18.358Q122.701 17.486 123.089 16.499Q123.478 15.512 123.772 14.493Q124.066 13.475 124.255 12.551ZM126.922 13.664Q127.111 13.874 127.468 14.409Q127.825 14.945 128.234 15.585Q128.644 16.226 128.99 16.772Q129.337 17.318 129.463 17.549L127.72 19.565Q127.552 19.061 127.29 18.41Q127.027 17.759 126.722 17.066Q126.418 16.373 126.124 15.764Q125.83 15.155 125.599 14.714ZM141.118 7.574V10.325H132.403V23.051H141.454V25.781H129.442V7.574ZM132.235 12.614 134.482 11.144Q135.343 12.236 136.277 13.496Q137.212 14.756 138.115 16.026Q139.018 17.297 139.753 18.494Q140.488 19.691 140.95 20.699L138.409 22.484Q138.01 21.497 137.317 20.268Q136.624 19.04 135.774 17.717Q134.923 16.394 134.01 15.081Q133.096 13.769 132.235 12.614ZM137.947 10.913 140.761 11.669Q140.026 13.769 139.018 15.817Q138.01 17.864 136.844 19.649Q135.679 21.434 134.44 22.757Q134.209 22.484 133.789 22.085Q133.369 21.686 132.939 21.308Q132.508 20.93 132.172 20.699Q133.39 19.565 134.471 18Q135.553 16.436 136.445 14.619Q137.338 12.803 137.947 10.913Z" data-v-efbff744></path><path class="brand-lockup-svg__sub" transform="translate(-1 0)" d="M60.891 43.8V35.77H63.3Q64.455 35.77 65.126 36.32Q65.797 36.87 65.797 37.838Q65.797 38.377 65.555 38.778Q65.313 39.18 64.895 39.4Q64.477 39.62 63.938 39.62V39.543Q64.532 39.532 64.988 39.763Q65.445 39.994 65.709 40.445Q65.973 40.896 65.973 41.523Q65.973 42.216 65.665 42.733Q65.357 43.25 64.791 43.525Q64.224 43.8 63.443 43.8ZM62.134 42.711H63.355Q63.971 42.711 64.334 42.381Q64.697 42.051 64.697 41.468Q64.697 40.874 64.334 40.516Q63.971 40.159 63.355 40.159H62.134ZM62.134 39.103H63.289Q63.861 39.103 64.186 38.8Q64.51 38.498 64.51 37.981Q64.51 37.453 64.186 37.156Q63.861 36.859 63.3 36.859H62.134Z M68.029 43.8 70.064 35.77H71.736L73.771 43.8H72.473L72 41.809H69.8L69.338 43.8ZM70.031 40.753H71.758L71.252 38.52Q71.12 37.948 71.026 37.497Q70.933 37.046 70.9 36.87Q70.867 37.046 70.779 37.492Q70.691 37.937 70.559 38.509Z M76.234 43.8V42.667H77.851V36.903H76.234V35.77H80.766V36.903H79.149V42.667H80.766V43.8Z M83.966 43.8V35.77H85.253V42.612H88.707V43.8Z M91.434 43.8V42.667H93.051V36.903H91.434V35.77H95.966V36.903H94.349V42.667H95.966V43.8Z M98.847 43.8V35.77H100.431L102.719 42.348Q102.697 42.018 102.658 41.561Q102.62 41.105 102.598 40.615Q102.576 40.126 102.576 39.741V35.77H103.753V43.8H102.169L99.892 37.222Q99.925 37.519 99.952 37.959Q99.98 38.399 100.002 38.867Q100.024 39.334 100.024 39.73V43.8Z M108.944 43.91Q108.185 43.91 107.618 43.624Q107.052 43.338 106.744 42.804Q106.436 42.271 106.436 41.556V38.014Q106.436 37.288 106.744 36.76Q107.052 36.232 107.618 35.946Q108.185 35.66 108.944 35.66Q109.714 35.66 110.269 35.951Q110.825 36.243 111.133 36.765Q111.441 37.288 111.441 38.014H110.165Q110.165 37.42 109.846 37.106Q109.527 36.793 108.944 36.793Q108.361 36.793 108.036 37.106Q107.712 37.42 107.712 38.014V41.556Q107.712 42.139 108.036 42.463Q108.361 42.788 108.944 42.788Q109.527 42.788 109.846 42.463Q110.165 42.139 110.165 41.545V40.698H108.724V39.576H111.441V41.556Q111.441 42.271 111.133 42.799Q110.825 43.327 110.269 43.618Q109.714 43.91 108.944 43.91Z M121.691 43.8V35.77H122.978V39.048H125.222V35.77H126.509V43.8H125.222V40.236H122.978V43.8Z M131.7 43.91Q130.534 43.91 129.89 43.272Q129.247 42.634 129.247 41.534V35.77H130.523V41.523Q130.523 42.117 130.82 42.453Q131.117 42.788 131.7 42.788Q132.272 42.788 132.574 42.453Q132.877 42.117 132.877 41.523V35.77H134.153V41.534Q134.153 42.634 133.515 43.272Q132.877 43.91 131.7 43.91Z M136.891 43.8V35.77H139.3Q140.455 35.77 141.126 36.32Q141.797 36.87 141.797 37.838Q141.797 38.377 141.555 38.778Q141.313 39.18 140.895 39.4Q140.477 39.62 139.938 39.62V39.543Q140.532 39.532 140.988 39.763Q141.445 39.994 141.709 40.445Q141.973 40.896 141.973 41.523Q141.973 42.216 141.665 42.733Q141.357 43.25 140.79 43.525Q140.224 43.8 139.443 43.8ZM138.134 42.711H139.355Q139.971 42.711 140.334 42.381Q140.697 42.051 140.697 41.468Q140.697 40.874 140.334 40.516Q139.971 40.159 139.355 40.159H138.134ZM138.134 39.103H139.289Q139.861 39.103 140.185 38.8Q140.51 38.498 140.51 37.981Q140.51 37.453 140.185 37.156Q139.861 36.859 139.3 36.859H138.134Z" data-v-efbff744></path>',3)])]))}}),_=M(l,[["__scopeId","data-v-efbff744"]]);export{_ as B};
1
+ import{i as H,a as t}from"./index-DfJA7iJS.js";import{d as e,u as Q,o as V,c as s,aD as r}from"./vendor-vue-B2uhHUfE.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";const o=["src","alt"],n={key:1,class:"brand-lockup-svg",viewBox:"0 0 144 58",role:"img","aria-label":"百灵中枢 BailingHub"},l=e({__name:"BrandLockup",setup(Z){return(c,a)=>Q(H).logo_url?(V(),s("img",{key:0,class:"brand-lockup-image",src:Q(t)(Q(H).logo_url),alt:Q(H).site_name},null,8,o)):(V(),s("svg",n,[...a[0]||(a[0]=[r('<g transform="translate(0 -3) scale(0.2416667)" data-v-efbff744><path class="brand-lockup-svg__mark-main" fill-rule="evenodd" d="M42 44h34v152H54l-12-12zM76 44h58v34H76zM76 103h22v34H76zM76 162h58v34H76zM150 44h22l12 12v8h-34zM150 86h34v110h-34z" data-v-efbff744></path><path class="brand-lockup-svg__mark-accent" fill-rule="evenodd" d="M116 103h68v34h-68zM76 162h58v34H76z" data-v-efbff744></path></g><path class="brand-lockup-svg__main" transform="translate(0 1)" d="M59.197 7.553H77.824V10.535H59.197ZM63.397 17.486H73.897V20.237H63.397ZM63.481 22.442H73.603V25.256H63.481ZM66.715 8.645 70.474 9.401Q70.222 10.304 69.96 11.186Q69.697 12.068 69.466 12.845Q69.235 13.622 69.004 14.231L66.085 13.496Q66.232 12.803 66.368 11.963Q66.505 11.123 66.6 10.262Q66.694 9.401 66.715 8.645ZM61.129 12.509H76.081V26.474H72.805V15.323H64.237V26.474H61.129Z M87.925 15.911H91.159Q91.012 17.507 90.739 18.893Q90.466 20.279 89.868 21.476Q89.269 22.673 88.177 23.649Q87.085 24.626 85.342 25.392Q83.599 26.159 80.995 26.684Q80.806 26.075 80.344 25.298Q79.882 24.521 79.42 24.038Q81.73 23.639 83.242 23.082Q84.754 22.526 85.647 21.791Q86.539 21.056 86.99 20.163Q87.442 19.271 87.631 18.21Q87.82 17.15 87.925 15.911ZM82.948 16.541 85.573 17.507Q85.195 18.746 84.618 19.985Q84.04 21.224 83.179 22.085L80.638 20.552Q81.436 19.817 82.024 18.746Q82.612 17.675 82.948 16.541ZM95.401 16.415 98.047 17.927Q97.396 18.998 96.714 20.069Q96.031 21.14 95.443 21.917L93.175 20.531Q93.553 20.006 93.963 19.303Q94.372 18.599 94.761 17.843Q95.149 17.087 95.401 16.415ZM90.781 17.192Q91.306 19.145 92.335 20.499Q93.364 21.854 95.118 22.62Q96.871 23.387 99.58 23.639Q99.286 23.954 98.95 24.447Q98.614 24.941 98.32 25.466Q98.026 25.991 97.837 26.432Q95.611 26.075 94.025 25.382Q92.44 24.689 91.358 23.597Q90.277 22.505 89.542 20.993Q88.807 19.481 88.282 17.486ZM82.108 10.304H96.115V12.362H82.108ZM81.184 7.07H97.354V15.533H81.184V12.845H94.435V9.758H81.184Z M101.743 10.136H119.341V21.056H116.128V13.139H104.809V21.161H101.743ZM103.318 17.066H117.892V20.069H103.318ZM108.841 6.545H112.075V26.495H108.841Z M121.714 10.388H129.001V13.202H121.714ZM124.276 6.545H127.027V26.495H124.276ZM124.255 12.551 125.83 13.202Q125.62 14.525 125.305 15.9Q124.99 17.276 124.591 18.588Q124.192 19.901 123.709 21.035Q123.226 22.169 122.68 22.988Q122.554 22.547 122.312 21.98Q122.071 21.413 121.798 20.846Q121.525 20.279 121.273 19.859Q121.777 19.229 122.239 18.358Q122.701 17.486 123.089 16.499Q123.478 15.512 123.772 14.493Q124.066 13.475 124.255 12.551ZM126.922 13.664Q127.111 13.874 127.468 14.409Q127.825 14.945 128.234 15.585Q128.644 16.226 128.99 16.772Q129.337 17.318 129.463 17.549L127.72 19.565Q127.552 19.061 127.29 18.41Q127.027 17.759 126.722 17.066Q126.418 16.373 126.124 15.764Q125.83 15.155 125.599 14.714ZM141.118 7.574V10.325H132.403V23.051H141.454V25.781H129.442V7.574ZM132.235 12.614 134.482 11.144Q135.343 12.236 136.277 13.496Q137.212 14.756 138.115 16.026Q139.018 17.297 139.753 18.494Q140.488 19.691 140.95 20.699L138.409 22.484Q138.01 21.497 137.317 20.268Q136.624 19.04 135.774 17.717Q134.923 16.394 134.01 15.081Q133.096 13.769 132.235 12.614ZM137.947 10.913 140.761 11.669Q140.026 13.769 139.018 15.817Q138.01 17.864 136.844 19.649Q135.679 21.434 134.44 22.757Q134.209 22.484 133.789 22.085Q133.369 21.686 132.939 21.308Q132.508 20.93 132.172 20.699Q133.39 19.565 134.471 18Q135.553 16.436 136.445 14.619Q137.338 12.803 137.947 10.913Z" data-v-efbff744></path><path class="brand-lockup-svg__sub" transform="translate(-1 0)" d="M60.891 43.8V35.77H63.3Q64.455 35.77 65.126 36.32Q65.797 36.87 65.797 37.838Q65.797 38.377 65.555 38.778Q65.313 39.18 64.895 39.4Q64.477 39.62 63.938 39.62V39.543Q64.532 39.532 64.988 39.763Q65.445 39.994 65.709 40.445Q65.973 40.896 65.973 41.523Q65.973 42.216 65.665 42.733Q65.357 43.25 64.791 43.525Q64.224 43.8 63.443 43.8ZM62.134 42.711H63.355Q63.971 42.711 64.334 42.381Q64.697 42.051 64.697 41.468Q64.697 40.874 64.334 40.516Q63.971 40.159 63.355 40.159H62.134ZM62.134 39.103H63.289Q63.861 39.103 64.186 38.8Q64.51 38.498 64.51 37.981Q64.51 37.453 64.186 37.156Q63.861 36.859 63.3 36.859H62.134Z M68.029 43.8 70.064 35.77H71.736L73.771 43.8H72.473L72 41.809H69.8L69.338 43.8ZM70.031 40.753H71.758L71.252 38.52Q71.12 37.948 71.026 37.497Q70.933 37.046 70.9 36.87Q70.867 37.046 70.779 37.492Q70.691 37.937 70.559 38.509Z M76.234 43.8V42.667H77.851V36.903H76.234V35.77H80.766V36.903H79.149V42.667H80.766V43.8Z M83.966 43.8V35.77H85.253V42.612H88.707V43.8Z M91.434 43.8V42.667H93.051V36.903H91.434V35.77H95.966V36.903H94.349V42.667H95.966V43.8Z M98.847 43.8V35.77H100.431L102.719 42.348Q102.697 42.018 102.658 41.561Q102.62 41.105 102.598 40.615Q102.576 40.126 102.576 39.741V35.77H103.753V43.8H102.169L99.892 37.222Q99.925 37.519 99.952 37.959Q99.98 38.399 100.002 38.867Q100.024 39.334 100.024 39.73V43.8Z M108.944 43.91Q108.185 43.91 107.618 43.624Q107.052 43.338 106.744 42.804Q106.436 42.271 106.436 41.556V38.014Q106.436 37.288 106.744 36.76Q107.052 36.232 107.618 35.946Q108.185 35.66 108.944 35.66Q109.714 35.66 110.269 35.951Q110.825 36.243 111.133 36.765Q111.441 37.288 111.441 38.014H110.165Q110.165 37.42 109.846 37.106Q109.527 36.793 108.944 36.793Q108.361 36.793 108.036 37.106Q107.712 37.42 107.712 38.014V41.556Q107.712 42.139 108.036 42.463Q108.361 42.788 108.944 42.788Q109.527 42.788 109.846 42.463Q110.165 42.139 110.165 41.545V40.698H108.724V39.576H111.441V41.556Q111.441 42.271 111.133 42.799Q110.825 43.327 110.269 43.618Q109.714 43.91 108.944 43.91Z M121.691 43.8V35.77H122.978V39.048H125.222V35.77H126.509V43.8H125.222V40.236H122.978V43.8Z M131.7 43.91Q130.534 43.91 129.89 43.272Q129.247 42.634 129.247 41.534V35.77H130.523V41.523Q130.523 42.117 130.82 42.453Q131.117 42.788 131.7 42.788Q132.272 42.788 132.574 42.453Q132.877 42.117 132.877 41.523V35.77H134.153V41.534Q134.153 42.634 133.515 43.272Q132.877 43.91 131.7 43.91Z M136.891 43.8V35.77H139.3Q140.455 35.77 141.126 36.32Q141.797 36.87 141.797 37.838Q141.797 38.377 141.555 38.778Q141.313 39.18 140.895 39.4Q140.477 39.62 139.938 39.62V39.543Q140.532 39.532 140.988 39.763Q141.445 39.994 141.709 40.445Q141.973 40.896 141.973 41.523Q141.973 42.216 141.665 42.733Q141.357 43.25 140.79 43.525Q140.224 43.8 139.443 43.8ZM138.134 42.711H139.355Q139.971 42.711 140.334 42.381Q140.697 42.051 140.697 41.468Q140.697 40.874 140.334 40.516Q139.971 40.159 139.355 40.159H138.134ZM138.134 39.103H139.289Q139.861 39.103 140.185 38.8Q140.51 38.498 140.51 37.981Q140.51 37.453 140.185 37.156Q139.861 36.859 139.3 36.859H138.134Z" data-v-efbff744></path>',3)])]))}}),_=M(l,[["__scopeId","data-v-efbff744"]]);export{_ as B};
@@ -1,4 +1,4 @@
1
- import{E as P}from"./vendor-element-D7WRzHhy.js";import{a as x}from"./request-CBLNpLth.js";import{o as ze}from"./docs-DPUOCa7R.js";import{c as z}from"./util-SiQC2MJh.js";import{u as Be,b as B}from"./index-CxPIS6G7.js";import{H as y}from"./HelpTip-CT07o3kB.js";import{u as Le,s as Ke,a as Je,b as Me}from"./schema-DzwLpuOy.js";import{d as Fe,z as Xe,c as g,S as a,J as t,R as D,r as b,ai as f,o as r,I as $,P as o,e as l,Q as i,O as T,u as N,a3 as L,q as Ee,m as K}from"./vendor-vue-B2uhHUfE.js";import{_ as Ge}from"./_plugin-vue_export-helper-DlAUqK2U.js";const Qe={class:"head"},We={class:"channel-main"},Ye={class:"tagline"},Ze={key:0,class:"muted ellipsis"},el={class:"channel-stack"},ll={class:"tagline"},tl={class:"muted"},nl={class:"callback-line"},al={class:"mono muted"},ol={class:"channel-stack"},sl={class:"tagline"},il={key:0,class:"muted"},dl={class:"head"},ul={class:"channel-main"},rl={key:0,class:"muted ellipsis"},pl={class:"channel-stack"},ml={class:"tagline"},fl={class:"mono muted"},cl={class:"channel-stack"},vl={class:"muted"},yl={key:0,class:"field-required"},bl={key:0,class:"field-required"},_l={key:0,class:"field-required"},kl={class:"code-context"},gl={class:"code-context-main"},$l={key:1,class:"muted"},Vl={key:0,class:"channel-code-summary"},Cl={class:"mono"},Tl={class:"mono"},xl={class:"snippet-card"},wl={class:"snippet-head"},Ul={class:"snippet-code"},hl={class:"snippet-card"},Pl={class:"snippet-head"},Sl={class:"snippet-code"},El={class:"snippet-card"},Al={class:"snippet-head"},Ol={class:"snippet-code"},Il={class:"snippet-card"},jl={class:"snippet-head"},ql={class:"snippet-code"},Rl={class:"code-notices compact",style:{"margin-top":"12px"}},Dl={class:"code-notice info"},Nl=Fe({__name:"Channels",setup(Hl){const G={wecom:"企业微信",feishu:"飞书"},Q=Be(),J=Le("channel"),O=b([]),W=b([]),Y=b(!1),_=b(null),k=b(""),C=b("<接入方token>"),Z=b("curl"),ee=b([]),de=b([]),I=b(!1),j=b(!1),le=b(!1),M=b("basic"),ue={name:"",kind:"wecom",route_key:"",corpid:"",token:"",aes_key:"",agentid:"",secret:"",reply_wait_ms:4e3,bucket:"",description:"",enabled:!0},u=Ee({...ue});function m(s,e){return Ke(J.schema.value,s,e)}function V(s,e=""){return Je(J.schema.value,s,e)}function te(s){return Me(J.required.value,s)}function re(s,e="wecom"){const d=e==="wecom"?"wecom":e;return`${B()}/${d}/${s}`}function pe(s){return re(s.name,s.kind)}function me(s){const e=ee.value.find(d=>d.route_key===s);return(e==null?void 0:e.name)||s||"-"}function F(s){const e=s.config||{};return!!(e.corpid&&e.agentid&&(e.secret||e.secret_masked||e.has_secret))}function Ae(s){const e=Array.isArray(s)?s.map(d=>String(d)).filter(Boolean):[];return e.length?e.length<=3?e.join("、"):`${e.slice(0,3).join("、")} 等 ${e.length} 人`:"-"}async function ne(){O.value=await x("/admin/api/channels")}function fe(){j.value=!1,M.value="basic",Object.assign(u,ue),I.value=!0}function Oe(s){j.value=!0,M.value="basic";const e=s.config||{};Object.assign(u,{name:s.name,kind:s.kind,route_key:s.route_key,corpid:e.corpid||"",token:"",aes_key:"",agentid:e.agentid||"",secret:"",reply_wait_ms:Number(e.reply_wait_ms)||4e3,bucket:e.bucket||"",description:s.description||"",enabled:!!s.enabled}),I.value=!0}async function Ie(){le.value=!0;try{const s={name:u.name,kind:u.kind,route_key:u.route_key,description:u.description,enabled:u.enabled,config:{corpid:u.corpid,token:u.token,aes_key:u.aes_key,agentid:u.agentid,secret:u.secret,reply_wait_ms:u.reply_wait_ms,bucket:u.bucket}};await x("/admin/api/channels",{method:"POST",body:JSON.stringify(s)}),P.success("已保存(密钥不再回显完整值)"),I.value=!1,await ne()}catch(s){P.error(s.message)}finally{le.value=!1}}async function je(s){try{await x("/admin/api/channels/"+encodeURIComponent(s),{method:"DELETE"}),await ne()}catch(e){P.error(e.message)}}const ce={executor_offline:"执行器离线",queue_backlog:"任务积压",error_burst:"任务失败激增",spec_change:"工具源 spec 变更",spec_refresh_fail:"工具源 spec 刷新失败",authz_probe:"工具源鉴权探针告警"},ae=b([]),q=b(!1),X=b(!1),oe=b(!1),ve={id:0,event_prefix:"",channel:"",recipients:[],cooldown_min:60,description:"",enabled:!0},c=Ee({...ve});async function se(){try{ae.value=await x("/admin/api/alert-rules")}catch{}}function ye(){X.value=!1,Object.assign(c,ve,{recipients:[]}),q.value=!0}function qe(s){X.value=!0,Object.assign(c,{id:s.id,event_prefix:s.event_prefix||"",channel:s.channel,recipients:[...s.recipients||[]],cooldown_min:s.cooldown_min||60,description:s.description||"",enabled:!!s.enabled}),q.value=!0}async function Re(){if(!c.channel){P.error("请选择渠道");return}if(!c.recipients.length){P.error("至少填一个收件人");return}oe.value=!0;try{await x("/admin/api/alert-rules",{method:"POST",body:JSON.stringify({...c,id:c.id||void 0})}),P.success("已保存"),q.value=!1,await se()}catch(s){P.error(s.message)}finally{oe.value=!1}}async function De(s){try{await x("/admin/api/alert-rules/"+s,{method:"DELETE"}),await se()}catch(e){P.error(e.message)}}const H=K(()=>W.value.filter(s=>{var e;return(s.allowed_channels||[]).includes("*")||(s.allowed_channels||[]).includes((e=_.value)==null?void 0:e.name)}));async function Ne(s){var d;_.value=s,Z.value="curl",C.value="<接入方token>";const e=W.value.filter(S=>(S.allowed_channels||[]).includes("*")||(S.allowed_channels||[]).includes(s.name));k.value=((d=e[0])==null?void 0:d.app_id)||"",Y.value=!0,k.value&&await be()}async function be(){if(!k.value){C.value="<接入方token>";return}try{const s=await x("/admin/api/clients/"+encodeURIComponent(k.value)+"/token");C.value=s.token}catch{C.value="<接入方token>"}}const _e=K(()=>{const s=_.value;if(!s)return"";const e=B(),d="bailing_send_"+String(s.name).replace(/[^a-z0-9]+/gi,"_"),S=k.value?k.value+"_":"";return`/**
1
+ import{E as P}from"./vendor-element-D7WRzHhy.js";import{a as x}from"./request-DkNPOweH.js";import{o as ze}from"./docs-DPUOCa7R.js";import{c as z}from"./util-SiQC2MJh.js";import{u as Be,b as B}from"./index-DfJA7iJS.js";import{H as y}from"./HelpTip-CT07o3kB.js";import{u as Le,s as Ke,a as Je,b as Me}from"./schema-CgPWAu1_.js";import{d as Fe,z as Xe,c as g,S as a,J as t,R as D,r as b,ai as f,o as r,I as $,P as o,e as l,Q as i,O as T,u as N,a3 as L,q as Ee,m as K}from"./vendor-vue-B2uhHUfE.js";import{_ as Ge}from"./_plugin-vue_export-helper-DlAUqK2U.js";const Qe={class:"head"},We={class:"channel-main"},Ye={class:"tagline"},Ze={key:0,class:"muted ellipsis"},el={class:"channel-stack"},ll={class:"tagline"},tl={class:"muted"},nl={class:"callback-line"},al={class:"mono muted"},ol={class:"channel-stack"},sl={class:"tagline"},il={key:0,class:"muted"},dl={class:"head"},ul={class:"channel-main"},rl={key:0,class:"muted ellipsis"},pl={class:"channel-stack"},ml={class:"tagline"},fl={class:"mono muted"},cl={class:"channel-stack"},vl={class:"muted"},yl={key:0,class:"field-required"},bl={key:0,class:"field-required"},_l={key:0,class:"field-required"},kl={class:"code-context"},gl={class:"code-context-main"},$l={key:1,class:"muted"},Vl={key:0,class:"channel-code-summary"},Cl={class:"mono"},Tl={class:"mono"},xl={class:"snippet-card"},wl={class:"snippet-head"},Ul={class:"snippet-code"},hl={class:"snippet-card"},Pl={class:"snippet-head"},Sl={class:"snippet-code"},El={class:"snippet-card"},Al={class:"snippet-head"},Ol={class:"snippet-code"},Il={class:"snippet-card"},jl={class:"snippet-head"},ql={class:"snippet-code"},Rl={class:"code-notices compact",style:{"margin-top":"12px"}},Dl={class:"code-notice info"},Nl=Fe({__name:"Channels",setup(Hl){const G={wecom:"企业微信",feishu:"飞书"},Q=Be(),J=Le("channel"),O=b([]),W=b([]),Y=b(!1),_=b(null),k=b(""),C=b("<接入方token>"),Z=b("curl"),ee=b([]),de=b([]),I=b(!1),j=b(!1),le=b(!1),M=b("basic"),ue={name:"",kind:"wecom",route_key:"",corpid:"",token:"",aes_key:"",agentid:"",secret:"",reply_wait_ms:4e3,bucket:"",description:"",enabled:!0},u=Ee({...ue});function m(s,e){return Ke(J.schema.value,s,e)}function V(s,e=""){return Je(J.schema.value,s,e)}function te(s){return Me(J.required.value,s)}function re(s,e="wecom"){const d=e==="wecom"?"wecom":e;return`${B()}/${d}/${s}`}function pe(s){return re(s.name,s.kind)}function me(s){const e=ee.value.find(d=>d.route_key===s);return(e==null?void 0:e.name)||s||"-"}function F(s){const e=s.config||{};return!!(e.corpid&&e.agentid&&(e.secret||e.secret_masked||e.has_secret))}function Ae(s){const e=Array.isArray(s)?s.map(d=>String(d)).filter(Boolean):[];return e.length?e.length<=3?e.join("、"):`${e.slice(0,3).join("、")} 等 ${e.length} 人`:"-"}async function ne(){O.value=await x("/admin/api/channels")}function fe(){j.value=!1,M.value="basic",Object.assign(u,ue),I.value=!0}function Oe(s){j.value=!0,M.value="basic";const e=s.config||{};Object.assign(u,{name:s.name,kind:s.kind,route_key:s.route_key,corpid:e.corpid||"",token:"",aes_key:"",agentid:e.agentid||"",secret:"",reply_wait_ms:Number(e.reply_wait_ms)||4e3,bucket:e.bucket||"",description:s.description||"",enabled:!!s.enabled}),I.value=!0}async function Ie(){le.value=!0;try{const s={name:u.name,kind:u.kind,route_key:u.route_key,description:u.description,enabled:u.enabled,config:{corpid:u.corpid,token:u.token,aes_key:u.aes_key,agentid:u.agentid,secret:u.secret,reply_wait_ms:u.reply_wait_ms,bucket:u.bucket}};await x("/admin/api/channels",{method:"POST",body:JSON.stringify(s)}),P.success("已保存(密钥不再回显完整值)"),I.value=!1,await ne()}catch(s){P.error(s.message)}finally{le.value=!1}}async function je(s){try{await x("/admin/api/channels/"+encodeURIComponent(s),{method:"DELETE"}),await ne()}catch(e){P.error(e.message)}}const ce={executor_offline:"执行器离线",queue_backlog:"任务积压",error_burst:"任务失败激增",spec_change:"工具源 spec 变更",spec_refresh_fail:"工具源 spec 刷新失败",authz_probe:"工具源鉴权探针告警"},ae=b([]),q=b(!1),X=b(!1),oe=b(!1),ve={id:0,event_prefix:"",channel:"",recipients:[],cooldown_min:60,description:"",enabled:!0},c=Ee({...ve});async function se(){try{ae.value=await x("/admin/api/alert-rules")}catch{}}function ye(){X.value=!1,Object.assign(c,ve,{recipients:[]}),q.value=!0}function qe(s){X.value=!0,Object.assign(c,{id:s.id,event_prefix:s.event_prefix||"",channel:s.channel,recipients:[...s.recipients||[]],cooldown_min:s.cooldown_min||60,description:s.description||"",enabled:!!s.enabled}),q.value=!0}async function Re(){if(!c.channel){P.error("请选择渠道");return}if(!c.recipients.length){P.error("至少填一个收件人");return}oe.value=!0;try{await x("/admin/api/alert-rules",{method:"POST",body:JSON.stringify({...c,id:c.id||void 0})}),P.success("已保存"),q.value=!1,await se()}catch(s){P.error(s.message)}finally{oe.value=!1}}async function De(s){try{await x("/admin/api/alert-rules/"+s,{method:"DELETE"}),await se()}catch(e){P.error(e.message)}}const H=K(()=>W.value.filter(s=>{var e;return(s.allowed_channels||[]).includes("*")||(s.allowed_channels||[]).includes((e=_.value)==null?void 0:e.name)}));async function Ne(s){var d;_.value=s,Z.value="curl",C.value="<接入方token>";const e=W.value.filter(S=>(S.allowed_channels||[]).includes("*")||(S.allowed_channels||[]).includes(s.name));k.value=((d=e[0])==null?void 0:d.app_id)||"",Y.value=!0,k.value&&await be()}async function be(){if(!k.value){C.value="<接入方token>";return}try{const s=await x("/admin/api/clients/"+encodeURIComponent(k.value)+"/token");C.value=s.token}catch{C.value="<接入方token>"}}const _e=K(()=>{const s=_.value;if(!s)return"";const e=B(),d="bailing_send_"+String(s.name).replace(/[^a-z0-9]+/gi,"_"),S=k.value?k.value+"_":"";return`/**
2
2
  * 百灵中枢 · 经「${s.name}」渠道主动给某用户推一条消息(文字 / 图片 / 附件)
3
3
  * 会作为「回复方」记进该用户在本渠道的会话历史;用户随后追问,大脑接得上。
4
4
  * 用法:
@@ -1,4 +1,4 @@
1
- import{E as w}from"./vendor-element-D7WRzHhy.js";import{a as x}from"./request-CBLNpLth.js";import{o as lt}from"./docs-DPUOCa7R.js";import{f as nt}from"./util-SiQC2MJh.js";import{b as ot}from"./index-CxPIS6G7.js";import{H as c}from"./HelpTip-CT07o3kB.js";import{d as at,z as it,c as C,S as n,J as o,R as S,r as b,ai as p,o as _,e as l,P as i,I as v,Q as s,O as P,a3 as K,u as Oe,q as je,m as I}from"./vendor-vue-B2uhHUfE.js";import{_ as dt}from"./_plugin-vue_export-helper-DlAUqK2U.js";const st={class:"head"},ut={class:"entry-main"},rt={key:0,class:"muted ellipsis"},pt={class:"entry-stack"},mt={class:"muted"},_t={class:"muted"},ft={class:"entry-stack"},yt={class:"tagline"},bt={class:"tagline"},gt={class:"protection-stack"},vt={class:"muted"},kt={class:"table-actions"},ct={class:"state-copy"},Vt={class:"row"},wt={class:"state-copy"},xt={class:"state-copy"},$t={class:"position-config"},Ut={class:"row"},Ct={class:"row offset-row"},Ot={class:"code-notices compact"},jt={key:0,class:"code-notice info"},It={key:0,class:"embed-entry-summary"},Tt={class:"mono"},Nt={class:"mono"},At={class:"snippet-card"},Et={class:"snippet-head"},Pt={class:"snippet-code compact"},Rt={class:"snippet-card"},Lt={class:"snippet-head"},St={class:"snippet-code compact"},zt={class:"snippet-card"},Bt={class:"snippet-head"},Dt={class:"snippet-code"},Ft={class:"snippet-card"},Ht={class:"snippet-head"},Jt={class:"snippet-code"},Kt={class:"snippet-notes"},qt={class:"muted"},Gt={class:"row2"},Mt={class:"row2"},Qt={class:"mono"},Xt={class:"muted mono"},Wt=at({__name:"ChatEntries",setup(Yt){const z=b([]),q=b([]),se=b([]),ue=b([]),T=b(!1),B=b(!1),G=b(!1),D=b("basic"),re={title_align:"center",width:400,height:600,position:"right",offset_x:24,offset_y:24,avatar:"",launcher_icon:"",default_open:!1,resizable:!1,ai_notice:!0,powered_by_visible:!0,powered_by_text:""},d=je({entry_key:"",name:"",route_key:"",origins_text:"",ticket_client:"",bucket:"",title:"",greeting:"",color:"#3fb950",...re,rate_limit_per_min:20,description:"",enabled:!0}),M=b("");function pe(a){return q.value.find(e=>e.route_key===a)}function me(a){const e=pe(a);return e?e.name||e.route_key:"未找到路由"}function Ie(a){const e=pe(a);return e!=null&&e.target?`→ ${e.target}`:""}function Te(a,e){const u=Array.isArray(a)?a.map(k=>String(k)).filter(Boolean):[];return u.length?u.includes("*")?[e]:u.length<=2?u:[...u.slice(0,2),`+${u.length-2}`]:[]}function Ne(a){const e=Array.isArray(a.allowed_origins)?a.allowed_origins.filter(Boolean):[];return e.length?e.length===1?e[0]:`${e.length} 个站点`:"不限 Origin"}const Q=b(!1),_e=b(null),X=b([]);function Ae(a){return a==="up"?"有用":a==="down"?"没用":"反馈"}function Ee(a){return a==="up"?"success":a==="down"?"danger":"info"}const W=b(!1),R=b(null),Y=b([]),Z=b(!1),f=je({id:0,url_pattern:"",page_key:"",page_name:"",description:"",priority:0,enabled:!0}),h=b(!1),m=b(null),ee=b("script"),L=b("node"),O=ot(),fe=I(()=>{var a;return`<script src="${O}/widget.js" data-entry="${(a=m.value)==null?void 0:a.entry_key}" async><\/script>`}),ye=I(()=>{var a;return`${O}/widget/demo/${(a=m.value)==null?void 0:a.entry_key}`}),be=I(()=>{var a;return[`curl -X POST '${O}/chat/${(a=m.value)==null?void 0:a.entry_key}' \\`," -H 'content-type: application/json' \\",` -d '{"message":"你好","visitor_id":"demo-visitor-01","wait_ms":8000,"ticket":"<可选:登录身份票据,签法见下方票据生成>"}'`,"# 带 ticket = 登录身份(验签失败回 401,不会静默降级为匿名);不带 = 匿名访客","# 可选 thread_id(字母数字_-,≤32 字符):同一身份下按它切分平行会话——开新会话=换新值,续旧会话=复用;不带=该身份单线程续聊","# 返回 {done,reply,job_id,visitor_id,references?,attachments?};done=false 时轮询 GET /chat/<入口>/result/<job_id>?wait=8000","# reply=markdown 回复;attachments=解析好的富内容数组(图片/文件),无 md 渲染器的端按 type 渲染(详见官网 /docs#routes)","# 注意:聊天任务归属本入口,不能用接入方 token 走 GET /jobs/<id> 查(那是 API 触发任务的取法),结果只走上面的 result 端点",'# 审批类操作(如删除):首跑回"已提交审批",业务侧或控制台兜底批准后任务重跑,最终结果经路由「送达 webhook」回调业务后端',"# 载荷、签名和重试规范见官网 /docs/api;同 job_id 的 result 端点也会更新,可作轮询兜底",'# 评价:POST /chat/<入口>/rate/<job_id> 体 {"rating":"up|down|note","visitor_id":"<同上>","comment":"可选;rating=note 时必填"}',"# 小程序/服务端调用不带浏览器 Origin 头:站点 Origin 白名单不拦(它只防别家网页盗嵌)"].join(`
1
+ import{E as w}from"./vendor-element-D7WRzHhy.js";import{a as x}from"./request-DkNPOweH.js";import{o as lt}from"./docs-DPUOCa7R.js";import{f as nt}from"./util-SiQC2MJh.js";import{b as ot}from"./index-DfJA7iJS.js";import{H as c}from"./HelpTip-CT07o3kB.js";import{d as at,z as it,c as C,S as n,J as o,R as S,r as b,ai as p,o as _,e as l,P as i,I as v,Q as s,O as P,a3 as K,u as Oe,q as je,m as I}from"./vendor-vue-B2uhHUfE.js";import{_ as dt}from"./_plugin-vue_export-helper-DlAUqK2U.js";const st={class:"head"},ut={class:"entry-main"},rt={key:0,class:"muted ellipsis"},pt={class:"entry-stack"},mt={class:"muted"},_t={class:"muted"},ft={class:"entry-stack"},yt={class:"tagline"},bt={class:"tagline"},gt={class:"protection-stack"},vt={class:"muted"},kt={class:"table-actions"},ct={class:"state-copy"},Vt={class:"row"},wt={class:"state-copy"},xt={class:"state-copy"},$t={class:"position-config"},Ut={class:"row"},Ct={class:"row offset-row"},Ot={class:"code-notices compact"},jt={key:0,class:"code-notice info"},It={key:0,class:"embed-entry-summary"},Tt={class:"mono"},Nt={class:"mono"},At={class:"snippet-card"},Et={class:"snippet-head"},Pt={class:"snippet-code compact"},Rt={class:"snippet-card"},Lt={class:"snippet-head"},St={class:"snippet-code compact"},zt={class:"snippet-card"},Bt={class:"snippet-head"},Dt={class:"snippet-code"},Ft={class:"snippet-card"},Ht={class:"snippet-head"},Jt={class:"snippet-code"},Kt={class:"snippet-notes"},qt={class:"muted"},Gt={class:"row2"},Mt={class:"row2"},Qt={class:"mono"},Xt={class:"muted mono"},Wt=at({__name:"ChatEntries",setup(Yt){const z=b([]),q=b([]),se=b([]),ue=b([]),T=b(!1),B=b(!1),G=b(!1),D=b("basic"),re={title_align:"center",width:400,height:600,position:"right",offset_x:24,offset_y:24,avatar:"",launcher_icon:"",default_open:!1,resizable:!1,ai_notice:!0,powered_by_visible:!0,powered_by_text:""},d=je({entry_key:"",name:"",route_key:"",origins_text:"",ticket_client:"",bucket:"",title:"",greeting:"",color:"#3fb950",...re,rate_limit_per_min:20,description:"",enabled:!0}),M=b("");function pe(a){return q.value.find(e=>e.route_key===a)}function me(a){const e=pe(a);return e?e.name||e.route_key:"未找到路由"}function Ie(a){const e=pe(a);return e!=null&&e.target?`→ ${e.target}`:""}function Te(a,e){const u=Array.isArray(a)?a.map(k=>String(k)).filter(Boolean):[];return u.length?u.includes("*")?[e]:u.length<=2?u:[...u.slice(0,2),`+${u.length-2}`]:[]}function Ne(a){const e=Array.isArray(a.allowed_origins)?a.allowed_origins.filter(Boolean):[];return e.length?e.length===1?e[0]:`${e.length} 个站点`:"不限 Origin"}const Q=b(!1),_e=b(null),X=b([]);function Ae(a){return a==="up"?"有用":a==="down"?"没用":"反馈"}function Ee(a){return a==="up"?"success":a==="down"?"danger":"info"}const W=b(!1),R=b(null),Y=b([]),Z=b(!1),f=je({id:0,url_pattern:"",page_key:"",page_name:"",description:"",priority:0,enabled:!0}),h=b(!1),m=b(null),ee=b("script"),L=b("node"),O=ot(),fe=I(()=>{var a;return`<script src="${O}/widget.js" data-entry="${(a=m.value)==null?void 0:a.entry_key}" async><\/script>`}),ye=I(()=>{var a;return`${O}/widget/demo/${(a=m.value)==null?void 0:a.entry_key}`}),be=I(()=>{var a;return[`curl -X POST '${O}/chat/${(a=m.value)==null?void 0:a.entry_key}' \\`," -H 'content-type: application/json' \\",` -d '{"message":"你好","visitor_id":"demo-visitor-01","wait_ms":8000,"ticket":"<可选:登录身份票据,签法见下方票据生成>"}'`,"# 带 ticket = 登录身份(验签失败回 401,不会静默降级为匿名);不带 = 匿名访客","# 可选 thread_id(字母数字_-,≤32 字符):同一身份下按它切分平行会话——开新会话=换新值,续旧会话=复用;不带=该身份单线程续聊","# 返回 {done,reply,job_id,visitor_id,references?,attachments?};done=false 时轮询 GET /chat/<入口>/result/<job_id>?wait=8000","# reply=markdown 回复;attachments=解析好的富内容数组(图片/文件),无 md 渲染器的端按 type 渲染(详见官网 /docs#routes)","# 注意:聊天任务归属本入口,不能用接入方 token 走 GET /jobs/<id> 查(那是 API 触发任务的取法),结果只走上面的 result 端点",'# 审批类操作(如删除):首跑回"已提交审批",业务侧或控制台兜底批准后任务重跑,最终结果经路由「送达 webhook」回调业务后端',"# 载荷、签名和重试规范见官网 /docs/api;同 job_id 的 result 端点也会更新,可作轮询兜底",'# 评价:POST /chat/<入口>/rate/<job_id> 体 {"rating":"up|down|note","visitor_id":"<同上>","comment":"可选;rating=note 时必填"}',"# 小程序/服务端调用不带浏览器 Origin 头:站点 Origin 白名单不拦(它只防别家网页盗嵌)"].join(`
2
2
  `)}),Pe=I(()=>{var a,e;return[`// 用接入方「${(a=m.value)==null?void 0:a.ticket_client}」的 token 签发(1 小时有效,按需调整)`,'// uid 是中枢原样回传的「操作主体」串:多租户务必把租户编进去(如 "{$tenantId}:{$uid}"),别只签裸 uid——','// 否则接第二个租户时 uid 跨租户撞车,中枢无处补救(详见官网 /docs#security)。单租户也建议直接用 "1:1"。',"$subject = $tenantId . ':' . $当前登录用户ID; // 单租户可只写 (string)$当前登录用户ID","$payload = rtrim(strtr(base64_encode(json_encode(['uid' => $subject, 'exp' => time() + 3600])), '+/', '-_'), '=');","$ticket = 'v1.' . $payload . '.' . hash_hmac('sha256', $payload, $接入方token);","// 页面输出(登录用户才输出 data-ticket;游客不输出即匿名聊):",`<script src="${O}/widget.js" data-entry="${(e=m.value)==null?void 0:e.entry_key}" data-ticket="<?= $ticket ?>" async><\/script>`].join(`
3
3
  `)}),Re=I(()=>{var a,e;return[`// 用接入方「${(a=m.value)==null?void 0:a.ticket_client}」的 token 签发(1 小时有效,按需调整)`,"// uid 是中枢原样回传的「操作主体」串:多租户务必把租户编进去,如 tenantId + ':' + userId。","import { createHmac } from 'node:crypto';","","const clientToken = process.env.BAILING_CLIENT_TOKEN || '<接入方token>';","const subject = tenantId + ':' + userId;","const body = JSON.stringify({ uid: subject, exp: Math.floor(Date.now() / 1000) + 3600 });","const payload = Buffer.from(body)"," .toString('base64')"," .replace(/\\+/g, '-')"," .replace(/\\//g, '_')"," .replace(/=+$/, '');","const signature = createHmac('sha256', clientToken).update(payload).digest('hex');","const ticket = 'v1.' + payload + '.' + signature;","","// 页面输出(登录用户才输出 data-ticket;游客不输出即匿名聊):",`<script src="${O}/widget.js" data-entry="${(e=m.value)==null?void 0:e.entry_key}" data-ticket="\${ticket}" async><\/script>`].join(`
4
4
  `)}),Le=I(()=>{var a,e;return[`# 用接入方「${(a=m.value)==null?void 0:a.ticket_client}」的 token 签发(1 小时有效,按需调整)`,'# uid 是中枢原样回传的「操作主体」串:多租户务必把租户编进去,如 f"{tenant_id}:{user_id}"。',"import base64","import hashlib","import hmac","import json","import os","import time","",'client_token = os.getenv("BAILING_CLIENT_TOKEN", "<接入方token>")','subject = f"{tenant_id}:{user_id}"','body = json.dumps({"uid": subject, "exp": int(time.time()) + 3600}, ensure_ascii=False, separators=(",", ":")).encode("utf-8")','payload = base64.urlsafe_b64encode(body).decode("utf-8").rstrip("=")','signature = hmac.new(client_token.encode("utf-8"), payload.encode("utf-8"), hashlib.sha256).hexdigest()','ticket = f"v1.{payload}.{signature}"',"","# 页面输出(登录用户才输出 data-ticket;游客不输出即匿名聊):",`# <script src="${O}/widget.js" data-entry="${(e=m.value)==null?void 0:e.entry_key}" data-ticket="{ticket}" async><\\/script>`].join(`
@@ -0,0 +1 @@
1
+ .head[data-v-4d900ece]{display:flex;align-items:center;gap:10px}.muted[data-v-4d900ece]{color:var(--el-text-color-secondary);font-size:12px}.mono[data-v-4d900ece]{font-family:var(--bz-mono);font-size:12px}.client-main[data-v-4d900ece],.client-stack[data-v-4d900ece],.protection-stack[data-v-4d900ece]{display:grid;gap:4px;min-width:0}.client-main b[data-v-4d900ece]{min-width:0;overflow:hidden;color:var(--el-text-color-primary);font-size:13px;font-weight:650;text-overflow:ellipsis;white-space:nowrap}.client-main code[data-v-4d900ece]{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.client-token[data-v-4d900ece],.tagline[data-v-4d900ece],.protection-stack>div[data-v-4d900ece]{display:flex;align-items:center;flex-wrap:wrap;gap:5px;min-width:0}.inline-row[data-v-4d900ece]{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.hint[data-v-4d900ece]{margin-top:4px;width:100%}
@@ -0,0 +1,3 @@
1
+ import{E as O,aj as fe}from"./vendor-element-D7WRzHhy.js";import{a as V}from"./request-DkNPOweH.js";import{f as ce,c as J}from"./util-SiQC2MJh.js";import{u as be}from"./index-DfJA7iJS.js";import{H as g}from"./HelpTip-CT07o3kB.js";import{u as ke,s as ye,a as ge,b as ve}from"./schema-CgPWAu1_.js";import{d as we,z as he,c as k,S as a,J as l,R as C,r as z,ai as m,o as u,I as v,P as o,e as n,Q as s,u as X,O as T,a3 as N,q as Y}from"./vendor-vue-B2uhHUfE.js";import{_ as Ve}from"./_plugin-vue_export-helper-DlAUqK2U.js";const Te={class:"head"},Ce={class:"client-main"},ze={class:"client-token"},Se={class:"mono muted"},Ue={class:"client-stack"},Oe={class:"tagline"},Ne={class:"tagline"},Pe={key:1,class:"muted"},Ae={class:"tagline"},xe={key:1,class:"muted"},Be={class:"protection-stack"},Ee={class:"muted"},je={class:"muted"},De={key:0,class:"field-required"},$e={key:0,class:"field-required"},qe={key:0,class:"field-required"},He={class:"inline-row"},Ie=we({__name:"Clients",setup(Re){const j=be(),P=ke("client"),D=z([]),K=z([]),L=z([]),$=z({}),S=z(!1),U=z(!1),q=z(!1),r=Y({app_id:"",name:"",agent_authorize_url:"",allowed_routes:[],allowed_channels:[],rate_limit_per_min:60,description:"",enabled:!0}),_=Y({enabled:!1,window:"day",hard_cost_usd:void 0,hard_tokens:void 0});let A={};function p(i,e){return ye(P.schema.value,i,e)}function w(i,e=""){return ge(P.schema.value,i,e)}function H(i){return ve(P.required.value,i)}function Z(i){var e,d,f;return((e=i.budget)==null?void 0:e.enabled)!==!1&&(((d=i.budget)==null?void 0:d.hard_cost_usd)||((f=i.budget)==null?void 0:f.hard_tokens))}function I(i,e){const d=Array.isArray(i)?i.map(f=>String(f)).filter(Boolean):[];return d.length?d.includes("*")?[e]:d.length<=3?d:[...d.slice(0,3),`+${d.length-3}`]:[]}async function x(){D.value=await V("/admin/api/clients")}function ee(i,e){const d={},f={};if(!i||typeof i!="object"||Array.isArray(i))return[d,f];for(const[c,h]of Object.entries(i))e.includes(c)?d[c]=h:f[c]=h;return[d,f]}function le(){Object.assign(_,{enabled:!1,window:"day",hard_cost_usd:void 0,hard_tokens:void 0}),A={}}function te(i){const[e,d]=ee(i,["enabled","window","window_hours","hard_cost_usd","hard_tokens","soft_cost_usd","soft_tokens"]),f=Number(e.window_hours)===1?"hour":Number(e.window_hours)===720?"month":"day",c=["hour","day","month"].includes(String(e.window))?String(e.window):f;Object.assign(_,{enabled:!!i&&e.enabled!==!1,window:c,hard_cost_usd:e.hard_cost_usd==null?void 0:Number(e.hard_cost_usd),hard_tokens:e.hard_tokens==null?void 0:Number(e.hard_tokens)}),A=d}function ne(){if(!_.enabled)return;const i=Number(_.hard_cost_usd),e=Number(_.hard_tokens);if(!(!(i>0)&&!(e>0)&&!Object.keys(A).length))return{enabled:!0,window:_.window,...i>0?{hard_cost_usd:i}:{},...e>0?{hard_tokens:Math.round(e)}:{},...A}}function F(){U.value=!1,Object.assign(r,{app_id:"",name:"",agent_authorize_url:"",allowed_routes:[],allowed_channels:[],rate_limit_per_min:60,description:"",enabled:!0}),le(),S.value=!0}function ae(i){U.value=!0,Object.assign(r,{app_id:i.app_id,name:i.name,agent_authorize_url:i.agent_authorize_url||"",allowed_routes:[...i.allowed_routes||[]],allowed_channels:[...i.allowed_channels||[]],rate_limit_per_min:i.rate_limit_per_min??60,description:i.description||"",enabled:!!i.enabled}),te(i.budget),S.value=!0}async function oe(){if(!r.allowed_routes.length){O.error("至少选一个路由(或 *)");return}q.value=!0;try{const i=await V("/admin/api/clients",{method:"POST",body:JSON.stringify({...r,budget:ne()})});S.value=!1,await x(),U.value?O.success("已保存"):(await fe.alert(`接入方 ${i.app_id} 的 token(业务侧 Authorization 用):
2
+
3
+ ${i.token}`,"接入方已创建",{confirmButtonText:"复制 token"}).catch(()=>{}),await J(i.token,"token 已复制"))}catch(i){O.error(i.message)}finally{q.value=!1}}async function ie(i){try{const e=await V("/admin/api/clients",{method:"POST",body:JSON.stringify({...i,rotate_token:!0})});await x(),await J(e.token,"新 token 已复制,请同步给业务侧")}catch(e){O.error(e.message)}}async function de(i){try{await V("/admin/api/clients/"+encodeURIComponent(i),{method:"DELETE"}),await x()}catch(e){O.error(e.message)}}async function se(i){try{const e=await V("/admin/api/clients/"+encodeURIComponent(i)+"/token");await J(e.token,"完整 token 已复制")}catch(e){O.error(e.message)}}return he(async()=>{var i;if(await Promise.all([P.load().catch(()=>{}),x()]),j.can("channels:read"))try{L.value=(await V("/admin/api/channels")).map(e=>e.name)}catch{}if(j.can("routes:read")){try{K.value=(await V("/admin/api/routes")).map(e=>e.route_key)}catch{}try{const e={};for(const d of await V("/admin/api/chat-entries"))d.ticket_client&&(e[i=d.ticket_client]||(e[i]=[])).push(d.entry_key);$.value=e}catch{}}}),(i,e)=>{const d=m("el-button"),f=m("el-empty"),c=m("el-table-column"),h=m("el-tag"),G=m("el-popconfirm"),ue=m("el-table"),re=m("el-card"),B=m("el-input"),y=m("el-form-item"),E=m("el-option"),Q=m("el-select"),R=m("el-input-number"),W=m("el-switch"),M=m("el-radio-button"),pe=m("el-radio-group"),me=m("el-form"),_e=m("el-drawer");return u(),k(C,null,[a(re,{shadow:"never"},{header:l(()=>[n("div",Te,[e[16]||(e[16]=n("b",null,"接入方",-1)),e[17]||(e[17]=o()),a(g,{title:"接入方是干什么的"},{default:l(()=>[...e[14]||(e[14]=[n("p",null,[o("业务系统「"),n("b",null,"带 token 主动调中枢 API"),o("」的一把可吊销钥匙,管三条主动调用链路:① "),n("code",null,"POST /run"),o(" 发任务;② "),n("code",null,"GET /jobs/:id"),o(" 查结果;③ "),n("code",null,"POST /send"),o(" 经渠道主动推消息给某用户(会作为「回复方」记进该用户在该渠道的会话历史,用户追问时大脑读得到)。控制:能不能调(token)、能调哪些路由(可调路由白名单)、能往哪些渠道推(可推渠道白名单)、调多频(限速)。")],-1),n("p",null,[n("b",null,"聊天入口(网页/小程序组件)不走接入方"),o("——那是公开面(Origin 白名单 + 限速),不带 token。接入方在聊天里只有一个间接角色:「票据签发方」,业务后端用它的 token 给登录用户签身份票据(见右侧「聊天入口票据」列)。")],-1),n("p",null,[n("b",null,"开始对接:"),o("可直接到「触发路由」页点该路由的「调用代码」按钮,生成可粘贴的 HTTP / Node.js / Python / PHP 高频示例;Java、Go、.NET 与任意语言接入见官网 SDK 文档。")],-1)])]),_:1}),a(d,{type:"primary",style:{"margin-left":"auto"},onClick:F},{default:l(()=>[...e[15]||(e[15]=[o("新建接入方",-1)])]),_:1})])]),default:l(()=>[D.value.length?(u(),v(ue,{key:1,data:D.value},{default:l(()=>[a(c,{label:"接入方","min-width":"250","show-overflow-tooltip":""},{default:l(({row:t})=>[n("div",Ce,[n("b",null,s(t.name||t.app_id),1),n("code",null,s(t.app_id),1),n("div",ze,[n("span",Se,s(t.token),1),X(j).can("clients:write")?(u(),v(d,{key:0,link:"",type:"primary",onClick:b=>se(t.app_id)},{default:l(()=>[...e[19]||(e[19]=[o("复制完整",-1)])]),_:1},8,["onClick"])):T("",!0)])])]),_:1}),a(c,{label:"授权边界","min-width":"280"},{default:l(({row:t})=>[n("div",Ue,[n("div",Oe,[e[20]||(e[20]=n("span",{class:"muted"},"可调",-1)),(u(!0),k(C,null,N(I(t.allowed_routes,"全部路由"),b=>(u(),v(h,{key:b,size:"small",effect:"plain",type:"info"},{default:l(()=>[o(s(b),1)]),_:2},1024))),128))]),n("div",Ne,[e[21]||(e[21]=n("span",{class:"muted"},"可推",-1)),(t.allowed_channels||[]).length?(u(!0),k(C,{key:0},N(I(t.allowed_channels,"全部渠道"),b=>(u(),v(h,{key:b,size:"small",effect:"plain",type:"warning"},{default:l(()=>[o(s(b),1)]),_:2},1024))),128)):(u(),k("span",Pe,"不允许主动推送"))])])]),_:1}),a(c,{label:"聊天票据","min-width":"190"},{default:l(({row:t})=>[n("div",Ae,[($.value[t.app_id]||[]).length?(u(!0),k(C,{key:0},N(I($.value[t.app_id],"全部入口"),b=>(u(),v(h,{key:b,size:"small",effect:"plain",type:"success"},{default:l(()=>[o(s(b),1)]),_:2},1024))),128)):(u(),k("span",xe,"未作为票据签发方"))])]),_:1}),a(c,{label:"保护",width:"180"},{default:l(({row:t})=>[n("div",Be,[n("div",null,[a(h,{size:"small",effect:"plain",type:t.enabled?"success":"info"},{default:l(()=>[o(s(t.enabled?"已启用":"已停用"),1)]),_:2},1032,["type"]),t.agent_authorize_url?(u(),v(h,{key:0,size:"small",effect:"plain",type:"primary"},{default:l(()=>[...e[22]||(e[22]=[o("Agent 登录",-1)])]),_:1})):T("",!0),Z(t)?(u(),v(h,{key:1,size:"small",effect:"plain",type:"danger"},{default:l(()=>[...e[23]||(e[23]=[o("预算闸",-1)])]),_:1})):T("",!0)]),n("span",Ee,"限速 "+s(t.rate_limit_per_min?t.rate_limit_per_min+"/分":"不限"),1)])]),_:1}),a(c,{width:"136"},{header:l(()=>[e[25]||(e[25]=o("最近调用 ",-1)),a(g,{title:"最近调用怎么算"},{default:l(()=>[...e[24]||(e[24]=[n("p",null,[o("最近一次该接入方"),n("b",null,"凭证被实际使用"),o(":① 业务后端带 token 调 "),n("code",null,"/run"),o(" / "),n("code",null,"/jobs/:id"),o(";② 它作为聊天入口票据签发方,由已登录业务用户携带后端签发的身份票据来验签。")],-1),n("p",null,[n("b",null,"聊天入口的匿名流量不算"),o("(公开面、不带 token)——所以小程序匿名聊天再多这里也不动,属正常;真正验过业务身份票据后才会显示活跃。")],-1)])]),_:1})]),default:l(({row:t})=>[n("span",je,s(X(ce)(t.last_used_at)),1)]),_:1}),a(c,{width:"146",align:"right"},{default:l(({row:t})=>[a(d,{link:"",type:"primary",onClick:b=>ae(t)},{default:l(()=>[...e[26]||(e[26]=[o("编辑",-1)])]),_:1},8,["onClick"]),a(G,{title:"换钥?旧 token 立即作废,业务侧需同步更新。",width:"240",onConfirm:b=>ie(t)},{reference:l(()=>[a(d,{link:"",type:"warning"},{default:l(()=>[...e[27]||(e[27]=[o("换钥",-1)])]),_:1})]),_:1},8,["onConfirm"]),a(G,{title:"删除该接入方?其 token 立即失效。",width:"220",onConfirm:b=>de(t.app_id)},{reference:l(()=>[a(d,{link:"",type:"danger"},{default:l(()=>[...e[28]||(e[28]=[o("删",-1)])]),_:1})]),_:1},8,["onConfirm"])]),_:1})]),_:1},8,["data"])):(u(),v(f,{key:0,description:"还没有接入方:业务系统接入前先在这里发一把钥匙"},{default:l(()=>[a(d,{type:"primary",onClick:F},{default:l(()=>[...e[18]||(e[18]=[o("发第一把",-1)])]),_:1})]),_:1}))]),_:1}),a(_e,{modelValue:S.value,"onUpdate:modelValue":e[13]||(e[13]=t=>S.value=t),title:U.value?"编辑接入方":"新建接入方",size:"440px"},{footer:l(()=>[a(d,{onClick:e[12]||(e[12]=t=>S.value=!1)},{default:l(()=>[...e[44]||(e[44]=[o("取消",-1)])]),_:1}),a(d,{type:"primary",loading:q.value,onClick:oe},{default:l(()=>[...e[45]||(e[45]=[o("保存",-1)])]),_:1},8,["loading"])]),default:l(()=>[a(me,{"label-position":"top"},{default:l(()=>[a(y,null,{label:l(()=>[o(s(p("app_id","AppID"))+" ",1),H("app_id")?(u(),k("span",De,"*")):T("",!0),e[29]||(e[29]=o()),a(g,{title:p("app_id","AppID")},{default:l(()=>[n("p",null,s(w("app_id","接入方的稳定标识。")),1)]),_:1},8,["title"])]),default:l(()=>[a(B,{modelValue:r.app_id,"onUpdate:modelValue":e[0]||(e[0]=t=>r.app_id=t),disabled:U.value,placeholder:"留空自动生成,如 business-api",class:"mono"},null,8,["modelValue","disabled"])]),_:1}),a(y,null,{label:l(()=>[o(s(p("name","名称"))+" ",1),H("name")?(u(),k("span",$e,"*")):T("",!0),e[30]||(e[30]=o()),a(g,{title:p("name","名称")},{default:l(()=>[n("p",null,s(w("name","后台展示的人类可读名称。")),1)]),_:1},8,["title"])]),default:l(()=>[a(B,{modelValue:r.name,"onUpdate:modelValue":e[1]||(e[1]=t=>r.name=t),placeholder:"如 业务系统"},null,8,["modelValue"])]),_:1}),a(y,null,{label:l(()=>[o(s(p("agent_authorize_url","Agent 授权页"))+" ",1),a(g,{title:p("agent_authorize_url","Agent 授权页")},{default:l(()=>[n("p",null,s(w("agent_authorize_url","本地 Agent 发起登录时打开的业务系统网页。")),1),e[31]||(e[31]=n("p",null,[o("留空表示不开放 Agent 登录。生产必须使用 HTTPS;本机联调可使用带端口的 "),n("code",null,"127.0.0.1"),o(" / "),n("code",null,"::1"),o(" HTTP URL。")],-1))]),_:1},8,["title"])]),default:l(()=>[a(B,{modelValue:r.agent_authorize_url,"onUpdate:modelValue":e[2]||(e[2]=t=>r.agent_authorize_url=t),placeholder:"https://business.example.com/agent-authorize",class:"mono"},null,8,["modelValue"])]),_:1}),a(y,null,{label:l(()=>[o(s(p("allowed_routes","可调路由"))+" ",1),H("allowed_routes")?(u(),k("span",qe,"*")):T("",!0),e[33]||(e[33]=o()),a(g,{title:p("allowed_routes","可调路由")},{default:l(()=>[n("p",null,s(w("allowed_routes","该接入方可触发哪些 route。")),1),e[32]||(e[32]=n("p",null,[n("code",null,"*"),o(" 表示全部路由,适合本地开发或完全受信的内部系统,生产环境慎用。")],-1))]),_:1},8,["title"])]),default:l(()=>[a(Q,{modelValue:r.allowed_routes,"onUpdate:modelValue":e[3]||(e[3]=t=>r.allowed_routes=t),multiple:"",filterable:"","allow-create":"","default-first-option":"",style:{width:"100%"},placeholder:"选择或输入场景标识"},{default:l(()=>[a(E,{value:"*",label:"*(全部路由)"}),(u(!0),k(C,null,N(K.value,t=>(u(),v(E,{key:t,value:t,label:t},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1}),a(y,null,{label:l(()=>[o(s(p("allowed_channels","可推渠道白名单"))+" ",1),a(g,{title:p("allowed_channels","可推渠道白名单")},{default:l(()=>[n("p",null,s(w("allowed_channels","该接入方调 POST /send 主动推消息时,只能推这里授权的渠道。")),1),e[34]||(e[34]=n("p",null,"推送会作为「回复方」消息记进收件人在该渠道的会话历史,所以用户后续在该渠道追问时,大脑接得上上下文。",-1))]),_:1},8,["title"])]),default:l(()=>[a(Q,{modelValue:r.allowed_channels,"onUpdate:modelValue":e[4]||(e[4]=t=>r.allowed_channels=t),multiple:"",filterable:"","default-first-option":"",style:{width:"100%"},placeholder:"留空=不允许主动推;或选渠道 / *"},{default:l(()=>[a(E,{value:"*",label:"*(全部渠道)"}),(u(!0),k(C,null,N(L.value,t=>(u(),v(E,{key:t,value:t,label:t},null,8,["value","label"]))),128))]),_:1},8,["modelValue"])]),_:1}),a(y,null,{label:l(()=>[o(s(p("rate_limit_per_min","限速"))+" ",1),a(g,{title:p("rate_limit_per_min","限速")},{default:l(()=>[n("p",null,s(w("rate_limit_per_min","该接入方每分钟最多调用多少次。0 表示不限。")),1),e[35]||(e[35]=n("p",null,[n("code",null,"/run"),o(" 和 "),n("code",null,"/send"),o(" 共用同一限速桶。")],-1))]),_:1},8,["title"])]),default:l(()=>[a(R,{modelValue:r.rate_limit_per_min,"onUpdate:modelValue":e[5]||(e[5]=t=>r.rate_limit_per_min=t),min:0,max:6e3},null,8,["modelValue"])]),_:1}),a(y,null,{label:l(()=>[o(s(p("budget","成本预算闸"))+" ",1),a(g,{title:p("budget","成本预算闸")},{default:l(()=>[n("p",null,s(w("budget","按接入方维度限制模型成本或 token 用量。")),1),e[36]||(e[36]=n("p",null,[o("按该接入方在指定窗口内的历史用量做入口硬限。达到成本或 token 上限后,该接入方的新 "),n("code",null,"/run"),o(" 任务会直接记为 "),n("code",null,"rejected"),o(",不会再进入模型、执行器或工具链路。")],-1)),e[37]||(e[37]=n("p",null,"这是调用方级预算;触发路由页还可以配置场景级预算。两边任一命中都会拒绝。",-1))]),_:1},8,["title"])]),default:l(()=>[a(W,{modelValue:_.enabled,"onUpdate:modelValue":e[6]||(e[6]=t=>_.enabled=t)},null,8,["modelValue"])]),_:1}),_.enabled?(u(),k(C,{key:0},[a(y,{label:"预算窗口"},{default:l(()=>[a(pe,{modelValue:_.window,"onUpdate:modelValue":e[7]||(e[7]=t=>_.window=t)},{default:l(()=>[a(M,{value:"hour"},{default:l(()=>[...e[38]||(e[38]=[o("每小时",-1)])]),_:1}),a(M,{value:"day"},{default:l(()=>[...e[39]||(e[39]=[o("每天",-1)])]),_:1}),a(M,{value:"month"},{default:l(()=>[...e[40]||(e[40]=[o("每月",-1)])]),_:1})]),_:1},8,["modelValue"])]),_:1}),a(y,{label:"硬限"},{default:l(()=>[n("div",He,[e[41]||(e[41]=n("span",{class:"muted"},"成本 USD",-1)),a(R,{modelValue:_.hard_cost_usd,"onUpdate:modelValue":e[8]||(e[8]=t=>_.hard_cost_usd=t),min:0,step:.1,precision:4},null,8,["modelValue"]),e[42]||(e[42]=n("span",{class:"muted"},"Token",-1)),a(R,{modelValue:_.hard_tokens,"onUpdate:modelValue":e[9]||(e[9]=t=>_.hard_tokens=t),min:0,step:1e3},null,8,["modelValue"])]),e[43]||(e[43]=n("div",{class:"muted hint"},"两个都为空等于不设硬限;任一达到上限即拒绝新任务。",-1))]),_:1})],64)):T("",!0),a(y,null,{label:l(()=>[o(s(p("description","说明"))+" ",1),a(g,{title:p("description","说明")},{default:l(()=>[n("p",null,s(w("description","给后台管理员看的补充备注。")),1)]),_:1},8,["title"])]),default:l(()=>[a(B,{modelValue:r.description,"onUpdate:modelValue":e[10]||(e[10]=t=>r.description=t)},null,8,["modelValue"])]),_:1}),U.value?(u(),v(y,{key:1},{label:l(()=>[o(s(p("enabled","启用"))+" ",1),a(g,{title:p("enabled","启用")},{default:l(()=>[n("p",null,s(w("enabled","关闭后该接入方 token 不再允许调用。")),1)]),_:1},8,["title"])]),default:l(()=>[a(W,{modelValue:r.enabled,"onUpdate:modelValue":e[11]||(e[11]=t=>r.enabled=t)},null,8,["modelValue"])]),_:1})):T("",!0)]),_:1})]),_:1},8,["modelValue","title"])],64)}}}),Xe=Ve(Ie,[["__scopeId","data-v-4d900ece"]]);export{Xe as default};
@@ -1 +1 @@
1
- import{d as U,z as q,I as b,J as n,ai as _,r as V,o as r,K as G,c as x,e as l,Q as a,S as u,P as d,L as O,R as X,a3 as Y,_ as B,m as i,as as Z,aC as ll}from"./vendor-vue-B2uhHUfE.js";import{a as el}from"./request-CBLNpLth.js";import{H as tl}from"./HelpTip-CT07o3kB.js";import{_ as sl}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-CxPIS6G7.js";import"./vendor-element-D7WRzHhy.js";const al={class:"head"},ol={class:"actions"},nl={class:"cost-page"},ul={class:"overview"},il={class:"metric primary"},dl={class:"metric"},rl={class:"metric"},cl={class:"metric"},vl={class:"notice-actions"},pl={class:"section"},_l={key:1,class:"trend"},ml={class:"mono day"},bl={class:"bar-track"},fl={class:"mono cost"},yl={class:"muted jobs"},gl={class:"breakdown"},hl={class:"section panel"},kl={class:"share"},wl={class:"section panel"},jl={class:"share"},xl=U({__name:"Cost",setup(Cl){const J=ll(),p=V(null),f=V(30),g=V(!1),o=i(()=>{var t;return((t=p.value)==null?void 0:t.total)??{jobs:0,cost_usd:0,tokens:0}}),h=i(()=>o.value.cost_usd>0),P=i(()=>o.value.jobs?o.value.cost_usd/o.value.jobs:0),S=i(()=>o.value.jobs?o.value.tokens/o.value.jobs:0),A=i(()=>{var t;return o.value.cost_usd/Math.max(1,((t=p.value)==null?void 0:t.days)??f.value)}),C=i(()=>{var t;return[...((t=p.value)==null?void 0:t.by_day)??[]].sort((e,y)=>e.day.localeCompare(y.day))}),$=i(()=>{var t;return(((t=p.value)==null?void 0:t.by_target)??[]).slice(0,10)}),z=i(()=>{var t;return(((t=p.value)==null?void 0:t.by_route)??[]).slice(0,10)}),M=i(()=>Math.max(0,...C.value.map(t=>t.cost_usd))),k=i(()=>$.value[0]),w=i(()=>z.value[0]),H=i(()=>{var t,e;return o.value.jobs?h.value?`主要消耗来自 ${((t=w.value)==null?void 0:t.route)||((e=k.value)==null?void 0:e.target)||"当前窗口任务"}`:"已有任务,但没有模型成本记录":"该窗口内还没有任务"}),L=i(()=>{if(!o.value.jobs)return"业务系统触发路由后,这里会开始展示成本趋势和消耗归因。";if(!h.value)return"通常是执行器目标、业务工具调用,或模型没有回报 usage。可以先用任务页查看运行链路是否正常。";const t=[];return w.value&&t.push(`路由「${w.value.route}」消耗 ${c(w.value.cost_usd)}`),k.value&&t.push(`目标「${k.value.target}」消耗 ${c(k.value.cost_usd)}`),t.join(",")+"。"});async function N(){g.value=!0;try{p.value=await el("/admin/api/cost?days="+f.value)}finally{g.value=!1}}function c(t){const e=Number(t)||0;return e===0?"$0":"$"+e.toFixed(e>=1?2:4)}function m(t){return new Intl.NumberFormat("zh-CN",{maximumFractionDigits:0}).format(Number(t)||0)}function W(t){return M.value?Math.max(4,Math.round(t/M.value*100))+"%":"0%"}function F(t){return o.value.cost_usd?Math.max(3,Math.round(t/o.value.cost_usd*100))+"%":"0%"}function I(t){J.push(t)}return q(N),(t,e)=>{const y=_("el-option"),E=_("el-select"),D=_("el-button"),R=_("el-empty"),v=_("el-table-column"),T=_("el-table"),K=_("el-card"),Q=Z("loading");return r(),b(K,{shadow:"never"},{header:n(()=>[l("div",al,[l("div",null,[e[4]||(e[4]=l("b",null,"成本观测",-1)),u(tl,{title:"成本观测看什么"},{default:n(()=>[...e[3]||(e[3]=[l("p",null,[d("这里按任务回报的 "),l("code",null,"usage"),d(" 聚合模型成本和 token,用来判断最近一段时间是否有异常消耗。")],-1),l("p",null,"本页只读,不拦截调用。真正的硬限在「接入方」和「触发路由」的成本预算闸里配置。",-1),l("p",null,[d("执行器、业务工具或未回报 "),l("code",null,"usage"),d(" 的目标不会产生 "),l("code",null,"cost_usd"),d(",这属于正常情况。")],-1)])]),_:1})]),l("div",ol,[u(E,{modelValue:f.value,"onUpdate:modelValue":e[0]||(e[0]=j=>f.value=j),size:"small",style:{width:"110px"},onChange:N},{default:n(()=>[u(y,{value:7,label:"近 7 天"}),u(y,{value:30,label:"近 30 天"}),u(y,{value:90,label:"近 90 天"})]),_:1},8,["modelValue"]),u(D,{size:"small",loading:g.value,onClick:N},{default:n(()=>[...e[5]||(e[5]=[d("刷新",-1)])]),_:1},8,["loading"])])])]),default:n(()=>{var j;return[G((r(),x("div",nl,[l("section",ul,[l("div",il,[e[6]||(e[6]=l("span",null,"总花费",-1)),l("b",null,a(c(o.value.cost_usd)),1),l("em",null,a(((j=p.value)==null?void 0:j.days)??f.value)+" 天窗口",1)]),l("div",dl,[e[7]||(e[7]=l("span",null,"任务数",-1)),l("b",null,a(m(o.value.jobs)),1),l("em",null,a(o.value.jobs?`单任务 ${c(P.value)}`:"暂无任务"),1)]),l("div",rl,[e[8]||(e[8]=l("span",null,"Token",-1)),l("b",null,a(m(o.value.tokens)),1),l("em",null,a(o.value.tokens?`单任务 ${m(S.value)}`:"未记录 token"),1)]),l("div",cl,[e[9]||(e[9]=l("span",null,"日均花费",-1)),l("b",null,a(c(A.value)),1),l("em",null,a(h.value?`最高日 ${c(M.value)}`:"无成本峰值"),1)])]),l("section",{class:O(["notice",{empty:!h.value}])},[l("div",null,[l("b",null,a(H.value),1),l("p",null,a(L.value),1)]),l("div",vl,[u(D,{size:"small",onClick:e[1]||(e[1]=s=>I("/clients"))},{default:n(()=>[...e[10]||(e[10]=[d("接入方预算",-1)])]),_:1}),u(D,{size:"small",onClick:e[2]||(e[2]=s=>I("/routes"))},{default:n(()=>[...e[11]||(e[11]=[d("路由预算",-1)])]),_:1})])],2),l("section",pl,[e[12]||(e[12]=l("div",{class:"section-head"},[l("div",null,[l("b",null,"按天趋势"),l("span",null,"用来判断是否有突增、持续增长或某天集中消耗。")])],-1)),C.value.length?(r(),x("div",_l,[(r(!0),x(X,null,Y(C.value,s=>(r(),x("div",{key:s.day,class:"day-row"},[l("span",ml,a(s.day),1),l("div",bl,[l("div",{class:"bar",style:B({width:W(s.cost_usd)})},null,4)]),l("span",fl,a(c(s.cost_usd)),1),l("span",yl,a(m(s.jobs))+" 任务",1)]))),128))])):(r(),b(R,{key:0,description:"该窗口内没有任务记录"}))]),l("section",gl,[l("div",hl,[e[13]||(e[13]=l("div",{class:"section-head"},[l("div",null,[l("b",null,"调度目标消耗"),l("span",null,"定位是哪个模型或执行目标产生费用。")])],-1)),$.value.length?(r(),b(T,{key:1,data:$.value,size:"small","empty-text":"无数据"},{default:n(()=>[u(v,{prop:"target",label:"调度目标","min-width":"150","show-overflow-tooltip":""},{default:n(({row:s})=>[l("code",null,a(s.target),1)]),_:1}),u(v,{label:"占比",width:"110"},{default:n(({row:s})=>[l("div",kl,[l("span",{style:B({width:F(s.cost_usd)})},null,4)])]),_:1}),u(v,{prop:"jobs",label:"任务",width:"76",align:"right"},{default:n(({row:s})=>[d(a(m(s.jobs)),1)]),_:1}),u(v,{label:"花费",width:"104",align:"right"},{default:n(({row:s})=>[d(a(c(s.cost_usd)),1)]),_:1})]),_:1},8,["data"])):(r(),b(R,{key:0,description:"还没有目标成本数据"}))]),l("div",wl,[e[14]||(e[14]=l("div",{class:"section-head"},[l("div",null,[l("b",null,"触发路由消耗"),l("span",null,"定位是哪个业务场景产生费用。")])],-1)),z.value.length?(r(),b(T,{key:1,data:z.value,size:"small","empty-text":"无数据"},{default:n(()=>[u(v,{prop:"route",label:"触发路由","min-width":"150","show-overflow-tooltip":""}),u(v,{label:"占比",width:"110"},{default:n(({row:s})=>[l("div",jl,[l("span",{style:B({width:F(s.cost_usd)})},null,4)])]),_:1}),u(v,{prop:"jobs",label:"任务",width:"76",align:"right"},{default:n(({row:s})=>[d(a(m(s.jobs)),1)]),_:1}),u(v,{label:"花费",width:"104",align:"right"},{default:n(({row:s})=>[d(a(c(s.cost_usd)),1)]),_:1})]),_:1},8,["data"])):(r(),b(R,{key:0,description:"还没有路由成本数据"}))])]),e[15]||(e[15]=l("section",{class:"section guide"},[l("div",null,[l("b",null,"成本治理边界"),l("p",null,"观测页负责看趋势和归因;预算闸负责拦截新任务;模型侧账单仍以模型服务商账单为准。")]),l("div",{class:"guide-grid"},[l("div",null,[l("span",null,"接入方预算"),l("p",null,"限制某个业务系统整体消耗,适合按调用方控成本。")]),l("div",null,[l("span",null,"路由预算"),l("p",null,"限制某个 AI 场景消耗,适合按业务场景控成本。")]),l("div",null,[l("span",null,"未记录 usage"),l("p",null,"执行器或目标未上报 usage 时,只能统计任务数,不会计入美元成本。")])])],-1))])),[[Q,g.value]])]}),_:1})}}}),Vl=sl(xl,[["__scopeId","data-v-1b1c6790"]]);export{Vl as default};
1
+ import{d as U,z as q,I as b,J as n,ai as _,r as V,o as r,K as G,c as x,e as l,Q as a,S as u,P as d,L as O,R as X,a3 as Y,_ as B,m as i,as as Z,aC as ll}from"./vendor-vue-B2uhHUfE.js";import{a as el}from"./request-DkNPOweH.js";import{H as tl}from"./HelpTip-CT07o3kB.js";import{_ as sl}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-DfJA7iJS.js";import"./vendor-element-D7WRzHhy.js";const al={class:"head"},ol={class:"actions"},nl={class:"cost-page"},ul={class:"overview"},il={class:"metric primary"},dl={class:"metric"},rl={class:"metric"},cl={class:"metric"},vl={class:"notice-actions"},pl={class:"section"},_l={key:1,class:"trend"},ml={class:"mono day"},bl={class:"bar-track"},fl={class:"mono cost"},yl={class:"muted jobs"},gl={class:"breakdown"},hl={class:"section panel"},kl={class:"share"},wl={class:"section panel"},jl={class:"share"},xl=U({__name:"Cost",setup(Cl){const J=ll(),p=V(null),f=V(30),g=V(!1),o=i(()=>{var t;return((t=p.value)==null?void 0:t.total)??{jobs:0,cost_usd:0,tokens:0}}),h=i(()=>o.value.cost_usd>0),P=i(()=>o.value.jobs?o.value.cost_usd/o.value.jobs:0),S=i(()=>o.value.jobs?o.value.tokens/o.value.jobs:0),A=i(()=>{var t;return o.value.cost_usd/Math.max(1,((t=p.value)==null?void 0:t.days)??f.value)}),C=i(()=>{var t;return[...((t=p.value)==null?void 0:t.by_day)??[]].sort((e,y)=>e.day.localeCompare(y.day))}),$=i(()=>{var t;return(((t=p.value)==null?void 0:t.by_target)??[]).slice(0,10)}),z=i(()=>{var t;return(((t=p.value)==null?void 0:t.by_route)??[]).slice(0,10)}),M=i(()=>Math.max(0,...C.value.map(t=>t.cost_usd))),k=i(()=>$.value[0]),w=i(()=>z.value[0]),H=i(()=>{var t,e;return o.value.jobs?h.value?`主要消耗来自 ${((t=w.value)==null?void 0:t.route)||((e=k.value)==null?void 0:e.target)||"当前窗口任务"}`:"已有任务,但没有模型成本记录":"该窗口内还没有任务"}),L=i(()=>{if(!o.value.jobs)return"业务系统触发路由后,这里会开始展示成本趋势和消耗归因。";if(!h.value)return"通常是执行器目标、业务工具调用,或模型没有回报 usage。可以先用任务页查看运行链路是否正常。";const t=[];return w.value&&t.push(`路由「${w.value.route}」消耗 ${c(w.value.cost_usd)}`),k.value&&t.push(`目标「${k.value.target}」消耗 ${c(k.value.cost_usd)}`),t.join(",")+"。"});async function N(){g.value=!0;try{p.value=await el("/admin/api/cost?days="+f.value)}finally{g.value=!1}}function c(t){const e=Number(t)||0;return e===0?"$0":"$"+e.toFixed(e>=1?2:4)}function m(t){return new Intl.NumberFormat("zh-CN",{maximumFractionDigits:0}).format(Number(t)||0)}function W(t){return M.value?Math.max(4,Math.round(t/M.value*100))+"%":"0%"}function F(t){return o.value.cost_usd?Math.max(3,Math.round(t/o.value.cost_usd*100))+"%":"0%"}function I(t){J.push(t)}return q(N),(t,e)=>{const y=_("el-option"),E=_("el-select"),D=_("el-button"),R=_("el-empty"),v=_("el-table-column"),T=_("el-table"),K=_("el-card"),Q=Z("loading");return r(),b(K,{shadow:"never"},{header:n(()=>[l("div",al,[l("div",null,[e[4]||(e[4]=l("b",null,"成本观测",-1)),u(tl,{title:"成本观测看什么"},{default:n(()=>[...e[3]||(e[3]=[l("p",null,[d("这里按任务回报的 "),l("code",null,"usage"),d(" 聚合模型成本和 token,用来判断最近一段时间是否有异常消耗。")],-1),l("p",null,"本页只读,不拦截调用。真正的硬限在「接入方」和「触发路由」的成本预算闸里配置。",-1),l("p",null,[d("执行器、业务工具或未回报 "),l("code",null,"usage"),d(" 的目标不会产生 "),l("code",null,"cost_usd"),d(",这属于正常情况。")],-1)])]),_:1})]),l("div",ol,[u(E,{modelValue:f.value,"onUpdate:modelValue":e[0]||(e[0]=j=>f.value=j),size:"small",style:{width:"110px"},onChange:N},{default:n(()=>[u(y,{value:7,label:"近 7 天"}),u(y,{value:30,label:"近 30 天"}),u(y,{value:90,label:"近 90 天"})]),_:1},8,["modelValue"]),u(D,{size:"small",loading:g.value,onClick:N},{default:n(()=>[...e[5]||(e[5]=[d("刷新",-1)])]),_:1},8,["loading"])])])]),default:n(()=>{var j;return[G((r(),x("div",nl,[l("section",ul,[l("div",il,[e[6]||(e[6]=l("span",null,"总花费",-1)),l("b",null,a(c(o.value.cost_usd)),1),l("em",null,a(((j=p.value)==null?void 0:j.days)??f.value)+" 天窗口",1)]),l("div",dl,[e[7]||(e[7]=l("span",null,"任务数",-1)),l("b",null,a(m(o.value.jobs)),1),l("em",null,a(o.value.jobs?`单任务 ${c(P.value)}`:"暂无任务"),1)]),l("div",rl,[e[8]||(e[8]=l("span",null,"Token",-1)),l("b",null,a(m(o.value.tokens)),1),l("em",null,a(o.value.tokens?`单任务 ${m(S.value)}`:"未记录 token"),1)]),l("div",cl,[e[9]||(e[9]=l("span",null,"日均花费",-1)),l("b",null,a(c(A.value)),1),l("em",null,a(h.value?`最高日 ${c(M.value)}`:"无成本峰值"),1)])]),l("section",{class:O(["notice",{empty:!h.value}])},[l("div",null,[l("b",null,a(H.value),1),l("p",null,a(L.value),1)]),l("div",vl,[u(D,{size:"small",onClick:e[1]||(e[1]=s=>I("/clients"))},{default:n(()=>[...e[10]||(e[10]=[d("接入方预算",-1)])]),_:1}),u(D,{size:"small",onClick:e[2]||(e[2]=s=>I("/routes"))},{default:n(()=>[...e[11]||(e[11]=[d("路由预算",-1)])]),_:1})])],2),l("section",pl,[e[12]||(e[12]=l("div",{class:"section-head"},[l("div",null,[l("b",null,"按天趋势"),l("span",null,"用来判断是否有突增、持续增长或某天集中消耗。")])],-1)),C.value.length?(r(),x("div",_l,[(r(!0),x(X,null,Y(C.value,s=>(r(),x("div",{key:s.day,class:"day-row"},[l("span",ml,a(s.day),1),l("div",bl,[l("div",{class:"bar",style:B({width:W(s.cost_usd)})},null,4)]),l("span",fl,a(c(s.cost_usd)),1),l("span",yl,a(m(s.jobs))+" 任务",1)]))),128))])):(r(),b(R,{key:0,description:"该窗口内没有任务记录"}))]),l("section",gl,[l("div",hl,[e[13]||(e[13]=l("div",{class:"section-head"},[l("div",null,[l("b",null,"调度目标消耗"),l("span",null,"定位是哪个模型或执行目标产生费用。")])],-1)),$.value.length?(r(),b(T,{key:1,data:$.value,size:"small","empty-text":"无数据"},{default:n(()=>[u(v,{prop:"target",label:"调度目标","min-width":"150","show-overflow-tooltip":""},{default:n(({row:s})=>[l("code",null,a(s.target),1)]),_:1}),u(v,{label:"占比",width:"110"},{default:n(({row:s})=>[l("div",kl,[l("span",{style:B({width:F(s.cost_usd)})},null,4)])]),_:1}),u(v,{prop:"jobs",label:"任务",width:"76",align:"right"},{default:n(({row:s})=>[d(a(m(s.jobs)),1)]),_:1}),u(v,{label:"花费",width:"104",align:"right"},{default:n(({row:s})=>[d(a(c(s.cost_usd)),1)]),_:1})]),_:1},8,["data"])):(r(),b(R,{key:0,description:"还没有目标成本数据"}))]),l("div",wl,[e[14]||(e[14]=l("div",{class:"section-head"},[l("div",null,[l("b",null,"触发路由消耗"),l("span",null,"定位是哪个业务场景产生费用。")])],-1)),z.value.length?(r(),b(T,{key:1,data:z.value,size:"small","empty-text":"无数据"},{default:n(()=>[u(v,{prop:"route",label:"触发路由","min-width":"150","show-overflow-tooltip":""}),u(v,{label:"占比",width:"110"},{default:n(({row:s})=>[l("div",jl,[l("span",{style:B({width:F(s.cost_usd)})},null,4)])]),_:1}),u(v,{prop:"jobs",label:"任务",width:"76",align:"right"},{default:n(({row:s})=>[d(a(m(s.jobs)),1)]),_:1}),u(v,{label:"花费",width:"104",align:"right"},{default:n(({row:s})=>[d(a(c(s.cost_usd)),1)]),_:1})]),_:1},8,["data"])):(r(),b(R,{key:0,description:"还没有路由成本数据"}))])]),e[15]||(e[15]=l("section",{class:"section guide"},[l("div",null,[l("b",null,"成本治理边界"),l("p",null,"观测页负责看趋势和归因;预算闸负责拦截新任务;模型侧账单仍以模型服务商账单为准。")]),l("div",{class:"guide-grid"},[l("div",null,[l("span",null,"接入方预算"),l("p",null,"限制某个业务系统整体消耗,适合按调用方控成本。")]),l("div",null,[l("span",null,"路由预算"),l("p",null,"限制某个 AI 场景消耗,适合按业务场景控成本。")]),l("div",null,[l("span",null,"未记录 usage"),l("p",null,"执行器或目标未上报 usage 时,只能统计任务数,不会计入美元成本。")])])],-1))])),[[Q,g.value]])]}),_:1})}}}),Vl=sl(xl,[["__scopeId","data-v-1b1c6790"]]);export{Vl as default};