hiwork-core 0.0.37 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +34 -114
- package/lib/identity-context.js +50 -0
- package/lib/index.js +81 -36
- package/lib/types/client/menu-preferences.d.ts +4 -3
- package/lib/types/client/styles.d.ts +5 -4
- package/lib/types/client/user-badge.d.ts +7 -2
- package/lib/types/identity-context.d.ts +54 -0
- package/lib/types/index.d.ts +10 -3
- package/lib/types/provision-session.d.ts +2 -0
- package/package.json +26 -25
package/lib/client.js
CHANGED
|
@@ -1065,108 +1065,6 @@ function pickSettingsSectionButton(buttons, labels) {
|
|
|
1065
1065
|
}
|
|
1066
1066
|
return void 0;
|
|
1067
1067
|
}
|
|
1068
|
-
var cancelPendingNavigation;
|
|
1069
|
-
function isVisibleSubtree(el) {
|
|
1070
|
-
if (el === null) return false;
|
|
1071
|
-
const style = getComputedStyle(el);
|
|
1072
|
-
if (style.display === "none" || style.visibility === "hidden") return false;
|
|
1073
|
-
return el.parentElement === null || isVisibleSubtree(el.parentElement);
|
|
1074
|
-
}
|
|
1075
|
-
function openSettingsSection(root, label, onMissing) {
|
|
1076
|
-
const labels = typeof label === "string" ? [label] : label;
|
|
1077
|
-
if (cancelPendingNavigation !== void 0 && document.querySelector('[role="dialog"]') !== null) {
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
const trigger = root?.querySelector('[aria-haspopup="dialog"]');
|
|
1081
|
-
if (trigger === null || trigger === void 0) {
|
|
1082
|
-
onMissing?.();
|
|
1083
|
-
return;
|
|
1084
|
-
}
|
|
1085
|
-
cancelPendingNavigation?.();
|
|
1086
|
-
let frame;
|
|
1087
|
-
let finished = false;
|
|
1088
|
-
let sawPanel = false;
|
|
1089
|
-
let reopenTimer;
|
|
1090
|
-
let watchdog;
|
|
1091
|
-
let lastSignature = "";
|
|
1092
|
-
const IDLE_MS = 1500;
|
|
1093
|
-
const finishFailure = () => {
|
|
1094
|
-
cleanup();
|
|
1095
|
-
console.warn(`[hiwork-core] \u672A\u627E\u5230\u8BBE\u7F6E\u5206\u533A\uFF1A${labels.join(" / ")}`);
|
|
1096
|
-
onMissing?.();
|
|
1097
|
-
};
|
|
1098
|
-
const armWatchdog = () => {
|
|
1099
|
-
window.clearTimeout(watchdog);
|
|
1100
|
-
watchdog = window.setTimeout(() => {
|
|
1101
|
-
if (finished) return;
|
|
1102
|
-
if (select()) return;
|
|
1103
|
-
finishFailure();
|
|
1104
|
-
}, IDLE_MS);
|
|
1105
|
-
};
|
|
1106
|
-
const observer = new MutationObserver(() => {
|
|
1107
|
-
schedule();
|
|
1108
|
-
});
|
|
1109
|
-
const cleanup = () => {
|
|
1110
|
-
if (finished) return;
|
|
1111
|
-
finished = true;
|
|
1112
|
-
observer.disconnect();
|
|
1113
|
-
window.clearTimeout(watchdog);
|
|
1114
|
-
window.clearTimeout(reopenTimer);
|
|
1115
|
-
if (frame !== void 0) window.cancelAnimationFrame(frame);
|
|
1116
|
-
if (cancelPendingNavigation === cleanup) cancelPendingNavigation = void 0;
|
|
1117
|
-
};
|
|
1118
|
-
const select = () => {
|
|
1119
|
-
if (finished) return false;
|
|
1120
|
-
const panels = Array.from(document.querySelectorAll('[role="dialog"]')).filter((panel) => isVisibleSubtree(panel));
|
|
1121
|
-
const buttons = panels.flatMap((panel) => Array.from(panel.querySelectorAll("nav button")));
|
|
1122
|
-
const target = panels.length === 0 ? void 0 : pickSettingsSectionButton(buttons, labels);
|
|
1123
|
-
const targetActive = target !== void 0 && (target.className.includes("active") || target.getAttribute("aria-current") === "true");
|
|
1124
|
-
const signature = `${panels.length}:${targetActive ? 1 : 0}`;
|
|
1125
|
-
if (signature !== lastSignature) {
|
|
1126
|
-
lastSignature = signature;
|
|
1127
|
-
armWatchdog();
|
|
1128
|
-
}
|
|
1129
|
-
if (panels.length === 0) {
|
|
1130
|
-
if (sawPanel) {
|
|
1131
|
-
sawPanel = false;
|
|
1132
|
-
reopenTimer = window.setTimeout(() => {
|
|
1133
|
-
reopenTimer = void 0;
|
|
1134
|
-
if (finished || sawPanel) return;
|
|
1135
|
-
if (typeof document === "undefined" || document.querySelector('[role="dialog"]') !== null) return;
|
|
1136
|
-
trigger.click();
|
|
1137
|
-
}, 300);
|
|
1138
|
-
return false;
|
|
1139
|
-
}
|
|
1140
|
-
trigger.click();
|
|
1141
|
-
return false;
|
|
1142
|
-
}
|
|
1143
|
-
sawPanel = true;
|
|
1144
|
-
if (target === void 0) return false;
|
|
1145
|
-
if (targetActive) {
|
|
1146
|
-
cleanup();
|
|
1147
|
-
return true;
|
|
1148
|
-
}
|
|
1149
|
-
target.click();
|
|
1150
|
-
return false;
|
|
1151
|
-
};
|
|
1152
|
-
const schedule = () => {
|
|
1153
|
-
if (finished || frame !== void 0) return;
|
|
1154
|
-
frame = window.requestAnimationFrame(() => {
|
|
1155
|
-
frame = void 0;
|
|
1156
|
-
select();
|
|
1157
|
-
});
|
|
1158
|
-
};
|
|
1159
|
-
armWatchdog();
|
|
1160
|
-
observer.observe(document.body, {
|
|
1161
|
-
childList: true,
|
|
1162
|
-
subtree: true,
|
|
1163
|
-
// 壳把激活态应用到导航钮是纯属性变更(class/aria-current),必须监听才能复核收敛
|
|
1164
|
-
attributes: true,
|
|
1165
|
-
attributeFilter: ["class", "aria-current", "aria-expanded"]
|
|
1166
|
-
});
|
|
1167
|
-
cancelPendingNavigation = cleanup;
|
|
1168
|
-
schedule();
|
|
1169
|
-
}
|
|
1170
1068
|
|
|
1171
1069
|
// src/client/user-badge.tsx
|
|
1172
1070
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
@@ -1388,11 +1286,27 @@ function LogoutIcon() {
|
|
|
1388
1286
|
}
|
|
1389
1287
|
);
|
|
1390
1288
|
}
|
|
1391
|
-
function openGatewaySettings() {
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1289
|
+
function openGatewaySettings(openSettings) {
|
|
1290
|
+
openSettings();
|
|
1291
|
+
selectSettingsSection([AI_ROUTER_SECTION_LABEL]);
|
|
1292
|
+
}
|
|
1293
|
+
function selectSettingsSection(labels) {
|
|
1294
|
+
const started = Date.now();
|
|
1295
|
+
const tick = () => {
|
|
1296
|
+
const dialog = document.querySelector('[role="dialog"]');
|
|
1297
|
+
if (dialog !== null) {
|
|
1298
|
+
const button = pickSettingsSectionButton(
|
|
1299
|
+
Array.from(dialog.querySelectorAll("button")),
|
|
1300
|
+
labels
|
|
1301
|
+
);
|
|
1302
|
+
if (button !== void 0) {
|
|
1303
|
+
button.click();
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
if (Date.now() - started < 3e3) window.setTimeout(tick, 120);
|
|
1308
|
+
};
|
|
1309
|
+
tick();
|
|
1396
1310
|
}
|
|
1397
1311
|
function LogoutConfirm(props) {
|
|
1398
1312
|
const { onCancel } = props;
|
|
@@ -1500,7 +1414,9 @@ function UserBadge(props) {
|
|
|
1500
1414
|
style: railRowStyle,
|
|
1501
1415
|
title: displayName,
|
|
1502
1416
|
"aria-label": "\u6253\u5F00\u8BBE\u7F6E",
|
|
1503
|
-
onClick:
|
|
1417
|
+
onClick: () => {
|
|
1418
|
+
openGatewaySettings(props.openSettings);
|
|
1419
|
+
},
|
|
1504
1420
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: avatarStyle(24), children: initial })
|
|
1505
1421
|
}
|
|
1506
1422
|
),
|
|
@@ -1517,7 +1433,9 @@ function UserBadge(props) {
|
|
|
1517
1433
|
style: profileButtonStyle,
|
|
1518
1434
|
title: "\u6253\u5F00\u8BBE\u7F6E",
|
|
1519
1435
|
"aria-label": `\u6253\u5F00\u8BBE\u7F6E\uFF08${displayName}\uFF09`,
|
|
1520
|
-
onClick:
|
|
1436
|
+
onClick: () => {
|
|
1437
|
+
openGatewaySettings(props.openSettings);
|
|
1438
|
+
},
|
|
1521
1439
|
children: [
|
|
1522
1440
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: avatarStyle(24), children: initial }),
|
|
1523
1441
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: nameTextStyle, children: displayName })
|
|
@@ -1532,7 +1450,9 @@ function UserBadge(props) {
|
|
|
1532
1450
|
style: iconButtonStyle,
|
|
1533
1451
|
title: "\u8BBE\u7F6E",
|
|
1534
1452
|
"aria-label": "\u8BBE\u7F6E",
|
|
1535
|
-
onClick:
|
|
1453
|
+
onClick: () => {
|
|
1454
|
+
openGatewaySettings(props.openSettings);
|
|
1455
|
+
},
|
|
1536
1456
|
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives.IconSettingsOutlineMedium, { size: 16 })
|
|
1537
1457
|
}
|
|
1538
1458
|
),
|
|
@@ -3301,7 +3221,7 @@ function createFeatureRegistry() {
|
|
|
3301
3221
|
|
|
3302
3222
|
// src/client/menu-preferences.ts
|
|
3303
3223
|
var HIWORK_MENU_NS = "hiwork-menu";
|
|
3304
|
-
var DEFAULT_SIDEBAR_LIMIT =
|
|
3224
|
+
var DEFAULT_SIDEBAR_LIMIT = 6;
|
|
3305
3225
|
var MORE_MENU_ITEM_ID = "__hiwork_more__";
|
|
3306
3226
|
var MORE_MENU_LABEL = "\u66F4\u591A";
|
|
3307
3227
|
var MENU_SECTION_LABEL = "\u4FA7\u680F\u83DC\u5355";
|
|
@@ -7232,9 +7152,9 @@ function apply(ctx) {
|
|
|
7232
7152
|
priority: -1,
|
|
7233
7153
|
inject: () => ({ appVersion })
|
|
7234
7154
|
}, BrandName));
|
|
7235
|
-
ctx.slots.inject("
|
|
7236
|
-
name: "
|
|
7237
|
-
|
|
7155
|
+
ctx.slots.inject("settings.launcher", () => ctx.slots.register({
|
|
7156
|
+
name: "settings.launcher",
|
|
7157
|
+
priority: -1,
|
|
7238
7158
|
inject: () => ({ ...controller.inject(), pluginUpdates })
|
|
7239
7159
|
}, UserBadge));
|
|
7240
7160
|
ctx.effect(() => mountLoginGate(form, storeCredential), "hiwork-core: login gate");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** runtime context 贡献名(DSH 侧 snapshot 按名归并,改动即破坏对齐面)。 */
|
|
2
|
+
export const IDENTITY_CONTEXT_NAME = 'hiwork:identity';
|
|
3
|
+
/** 排在 sandbox:policy(110) / approval:policy(115) 之前——身份是最外层的环境事实。 */
|
|
4
|
+
export const IDENTITY_CONTEXT_ORDER = 105;
|
|
5
|
+
/** 模块内文案常量:安全限定语逐字来自 spec §3.2,不导出(测试硬编码全文钉文案)。 */
|
|
6
|
+
const CAVEAT = '该身份用于个性化与按人表述;涉及数据权限的操作必须走受管工具/连接器完成,不得把此文本当作凭证。';
|
|
7
|
+
/** 裁掉两侧空白;非字符串或空白串一律视同缺省(与 identity.ts 的 textOrUndefined 同口径)。 */
|
|
8
|
+
function textOrUndefined(value) {
|
|
9
|
+
if (typeof value !== 'string')
|
|
10
|
+
return undefined;
|
|
11
|
+
const text = value.trim();
|
|
12
|
+
return text === '' ? undefined : text;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 渲染身份上下文一行:已登录输出 `HiWork 登录身份:姓名(工号 工号)。<限定语>`,
|
|
16
|
+
* displayName 缺省回退 `工号 <工号>`;**未登录(username 缺省 / 空白 / 非字符串)或
|
|
17
|
+
* state 缺失一律空串**——半份身份(只有 displayName)也不输出,姓名不得单独泄漏。
|
|
18
|
+
*/
|
|
19
|
+
export function renderIdentityContextText(state) {
|
|
20
|
+
const username = textOrUndefined(state?.username);
|
|
21
|
+
if (username === undefined)
|
|
22
|
+
return '';
|
|
23
|
+
const displayName = textOrUndefined(state?.displayName);
|
|
24
|
+
const who = displayName === undefined ? `工号 ${username}` : `${displayName}(工号 ${username})`;
|
|
25
|
+
return `HiWork 登录身份:${who}。${CAVEAT}`;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 注册身份 runtime context 贡献;返回 disposer(交给 `ctx.effect` 管理生命周期)。
|
|
29
|
+
* 读失败收敛为空串并记一笔,绝不向组装层抛——身份上下文缺席只应意味着「未登录」。
|
|
30
|
+
*/
|
|
31
|
+
export function registerIdentityContext(systemPrompt, deps) {
|
|
32
|
+
const dispose = systemPrompt.context({
|
|
33
|
+
name: IDENTITY_CONTEXT_NAME,
|
|
34
|
+
order: IDENTITY_CONTEXT_ORDER,
|
|
35
|
+
text: () => {
|
|
36
|
+
try {
|
|
37
|
+
// enabled 的判断也在 try 内:真实接线里 enabled 与 current 读同一个命名空间,
|
|
38
|
+
// 任一侧抛异常都收敛为空串(身份上下文缺席只应意味着「未登录」)。
|
|
39
|
+
if (!deps.enabled())
|
|
40
|
+
return '';
|
|
41
|
+
return renderIdentityContextText(deps.current());
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
deps.log?.(`hiwork-core: 登录身份上下文读取失败(${error instanceof Error ? error.name : typeof error})`);
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return typeof dispose === 'function' ? dispose : () => { };
|
|
50
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -8267,7 +8267,7 @@ defineMethod("transform", [
|
|
|
8267
8267
|
], ({ inner }, isInner) => inner.toString(isInner));
|
|
8268
8268
|
|
|
8269
8269
|
// src/version.ts
|
|
8270
|
-
var PKG_VERSION = false ? "dev" : "0.0.
|
|
8270
|
+
var PKG_VERSION = false ? "dev" : "0.0.38";
|
|
8271
8271
|
|
|
8272
8272
|
// src/browser-login.ts
|
|
8273
8273
|
import { createHash, randomBytes, randomUUID } from "node:crypto";
|
|
@@ -12490,7 +12490,7 @@ var Service = class Service2 {
|
|
|
12490
12490
|
}
|
|
12491
12491
|
};
|
|
12492
12492
|
|
|
12493
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-scope@0.
|
|
12493
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-scope@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4_@deepseek-ai+dsh-invariants_8ef32aa4891a716d53102df556bb759f/node_modules/@deepseek-ai/dsh-scope/lib/index.js
|
|
12494
12494
|
var NamedEntries = class {
|
|
12495
12495
|
duplicateError;
|
|
12496
12496
|
data = /* @__PURE__ */ new Map();
|
|
@@ -12706,10 +12706,10 @@ function scopeTarget(base, key) {
|
|
|
12706
12706
|
return carrier;
|
|
12707
12707
|
}
|
|
12708
12708
|
|
|
12709
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-llm@0.
|
|
12709
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-llm@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-llm/lib/index.js
|
|
12710
12710
|
import { createRequire } from "node:module";
|
|
12711
12711
|
|
|
12712
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-typert-protocol@0.
|
|
12712
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-typert-protocol@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-typert-protocol/lib/index.js
|
|
12713
12713
|
var RemoteError = class extends Error {
|
|
12714
12714
|
code;
|
|
12715
12715
|
details;
|
|
@@ -12834,7 +12834,7 @@ function validateName(subject, value) {
|
|
|
12834
12834
|
if (!isTypertRemoteSegment(value)) throw new TypeError(`typert-protocol: ${subject} must contain only RPC endpoint segment characters`);
|
|
12835
12835
|
}
|
|
12836
12836
|
|
|
12837
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-util-values@0.
|
|
12837
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-util-values@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-util-values/lib/index.js
|
|
12838
12838
|
function assertNever(value, context) {
|
|
12839
12839
|
const rendered = JSON.stringify(value) ?? String(value);
|
|
12840
12840
|
throw new Error(`unreachable variant${context ? ` in ${context}` : ""}: ${rendered}`);
|
|
@@ -12843,7 +12843,7 @@ function hasIntrinsicConstructor(prototype, name2) {
|
|
|
12843
12843
|
const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
|
|
12844
12844
|
if (typeof constructor !== "function") return false;
|
|
12845
12845
|
try {
|
|
12846
|
-
return constructor.name === name2 && constructor.prototype === prototype && Function.prototype.toString.call(constructor) ===
|
|
12846
|
+
return constructor.name === name2 && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === Function.prototype.toString.call(name2 === "Array" ? Array : Object);
|
|
12847
12847
|
} catch {
|
|
12848
12848
|
return false;
|
|
12849
12849
|
}
|
|
@@ -13015,7 +13015,7 @@ function deepFreeze(value) {
|
|
|
13015
13015
|
return value;
|
|
13016
13016
|
}
|
|
13017
13017
|
|
|
13018
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-util-crypto@0.
|
|
13018
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-util-crypto@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-util-crypto/lib/index.js
|
|
13019
13019
|
function randomUUID2() {
|
|
13020
13020
|
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(16));
|
|
13021
13021
|
const hex = Array.from(bytes, (byte, index) => {
|
|
@@ -13024,15 +13024,15 @@ function randomUUID2() {
|
|
|
13024
13024
|
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
13025
13025
|
}
|
|
13026
13026
|
|
|
13027
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-brand@0.
|
|
13027
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-brand@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-brand/lib/index.js
|
|
13028
13028
|
function brandString(value) {
|
|
13029
13029
|
return value;
|
|
13030
13030
|
}
|
|
13031
13031
|
|
|
13032
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-timeout@0.
|
|
13032
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-timeout@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-timeout/lib/index.js
|
|
13033
13033
|
var MAX_TIMER_DELAY_MS = 2147483647;
|
|
13034
13034
|
|
|
13035
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-llm@0.
|
|
13035
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-llm@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-llm/lib/index.js
|
|
13036
13036
|
function freezeMessage(message) {
|
|
13037
13037
|
return deepFreeze(structuredClone(message));
|
|
13038
13038
|
}
|
|
@@ -14075,7 +14075,7 @@ function adapterFailureChunk(error, signal) {
|
|
|
14075
14075
|
};
|
|
14076
14076
|
}
|
|
14077
14077
|
|
|
14078
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-sandbox@0.
|
|
14078
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-sandbox@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4_@deepseek-ai+dsh-llm@0.2._910788faa6d5e8808178f15deb98d164/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js
|
|
14079
14079
|
var WIDER_MODES = {
|
|
14080
14080
|
"read-only": ["workspace-write", "danger-full-access"],
|
|
14081
14081
|
"workspace-write": ["danger-full-access"]
|
|
@@ -14117,7 +14117,7 @@ async function approveEscalation(request, approval) {
|
|
|
14117
14117
|
}
|
|
14118
14118
|
}
|
|
14119
14119
|
|
|
14120
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-tools@0.
|
|
14120
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-tools@0.2.0-rc.1_44958e8f826516598aa7d335d84aa068/node_modules/@deepseek-ai/dsh-tools/lib/index.js
|
|
14121
14121
|
var JsonSchemaError = class extends HarnessError {
|
|
14122
14122
|
/** Individual schema violations in walk order. */
|
|
14123
14123
|
violations;
|
|
@@ -19132,6 +19132,42 @@ function provideIdentity(ctx, deps) {
|
|
|
19132
19132
|
};
|
|
19133
19133
|
}
|
|
19134
19134
|
|
|
19135
|
+
// src/identity-context.ts
|
|
19136
|
+
var IDENTITY_CONTEXT_NAME = "hiwork:identity";
|
|
19137
|
+
var IDENTITY_CONTEXT_ORDER = 105;
|
|
19138
|
+
var CAVEAT = "\u8BE5\u8EAB\u4EFD\u7528\u4E8E\u4E2A\u6027\u5316\u4E0E\u6309\u4EBA\u8868\u8FF0\uFF1B\u6D89\u53CA\u6570\u636E\u6743\u9650\u7684\u64CD\u4F5C\u5FC5\u987B\u8D70\u53D7\u7BA1\u5DE5\u5177/\u8FDE\u63A5\u5668\u5B8C\u6210\uFF0C\u4E0D\u5F97\u628A\u6B64\u6587\u672C\u5F53\u4F5C\u51ED\u8BC1\u3002";
|
|
19139
|
+
function textOrUndefined6(value) {
|
|
19140
|
+
if (typeof value !== "string") return void 0;
|
|
19141
|
+
const text = value.trim();
|
|
19142
|
+
return text === "" ? void 0 : text;
|
|
19143
|
+
}
|
|
19144
|
+
function renderIdentityContextText(state) {
|
|
19145
|
+
const username = textOrUndefined6(state?.username);
|
|
19146
|
+
if (username === void 0) return "";
|
|
19147
|
+
const displayName = textOrUndefined6(state?.displayName);
|
|
19148
|
+
const who = displayName === void 0 ? `\u5DE5\u53F7 ${username}` : `${displayName}\uFF08\u5DE5\u53F7 ${username}\uFF09`;
|
|
19149
|
+
return `HiWork \u767B\u5F55\u8EAB\u4EFD\uFF1A${who}\u3002${CAVEAT}`;
|
|
19150
|
+
}
|
|
19151
|
+
function registerIdentityContext(systemPrompt, deps) {
|
|
19152
|
+
const dispose = systemPrompt.context({
|
|
19153
|
+
name: IDENTITY_CONTEXT_NAME,
|
|
19154
|
+
order: IDENTITY_CONTEXT_ORDER,
|
|
19155
|
+
text: () => {
|
|
19156
|
+
try {
|
|
19157
|
+
if (!deps.enabled()) return "";
|
|
19158
|
+
return renderIdentityContextText(deps.current());
|
|
19159
|
+
} catch (error) {
|
|
19160
|
+
deps.log?.(
|
|
19161
|
+
`hiwork-core: \u767B\u5F55\u8EAB\u4EFD\u4E0A\u4E0B\u6587\u8BFB\u53D6\u5931\u8D25\uFF08${error instanceof Error ? error.name : typeof error}\uFF09`
|
|
19162
|
+
);
|
|
19163
|
+
return "";
|
|
19164
|
+
}
|
|
19165
|
+
}
|
|
19166
|
+
});
|
|
19167
|
+
return typeof dispose === "function" ? dispose : () => {
|
|
19168
|
+
};
|
|
19169
|
+
}
|
|
19170
|
+
|
|
19135
19171
|
// src/knowledge-config.ts
|
|
19136
19172
|
var HIWORK_KNOWLEDGE_SERVICE = "hiworkKnowledge";
|
|
19137
19173
|
var ME_KNOWLEDGE_CONFIG_PATH = "/api/me/knowledge-config";
|
|
@@ -19158,22 +19194,22 @@ function messageFor(reason) {
|
|
|
19158
19194
|
function failure12(reason, message) {
|
|
19159
19195
|
return { ok: false, reason, message: message ?? messageFor(reason) };
|
|
19160
19196
|
}
|
|
19161
|
-
function
|
|
19197
|
+
function textOrUndefined7(value) {
|
|
19162
19198
|
if (typeof value !== "string") return void 0;
|
|
19163
19199
|
const text = value.trim();
|
|
19164
19200
|
return text === "" ? void 0 : text;
|
|
19165
19201
|
}
|
|
19166
19202
|
function projectKnowledgeConfig(body) {
|
|
19167
|
-
const baseUrl =
|
|
19168
|
-
const apiKey =
|
|
19203
|
+
const baseUrl = textOrUndefined7(body["base_url"] ?? body["baseUrl"]);
|
|
19204
|
+
const apiKey = textOrUndefined7(body["api_key"] ?? body["apiKey"]);
|
|
19169
19205
|
if (baseUrl === void 0 || apiKey === void 0) return void 0;
|
|
19170
19206
|
return {
|
|
19171
19207
|
ok: true,
|
|
19172
19208
|
baseUrl,
|
|
19173
19209
|
apiKey,
|
|
19174
|
-
agentId:
|
|
19175
|
-
chatModelId:
|
|
19176
|
-
tenantId:
|
|
19210
|
+
agentId: textOrUndefined7(body["agent_id"] ?? body["agentId"]) ?? "",
|
|
19211
|
+
chatModelId: textOrUndefined7(body["chat_model_id"] ?? body["chatModelId"]) ?? "",
|
|
19212
|
+
tenantId: textOrUndefined7(body["tenant_id"] ?? body["tenantId"]) ?? "",
|
|
19177
19213
|
knowledgeBases: projectKnowledgeBases(body["knowledge_bases"] ?? body["knowledgeBases"])
|
|
19178
19214
|
};
|
|
19179
19215
|
}
|
|
@@ -19184,10 +19220,10 @@ function projectKnowledgeBases(value) {
|
|
|
19184
19220
|
for (const item of value) {
|
|
19185
19221
|
if (item === null || typeof item !== "object") continue;
|
|
19186
19222
|
const record = item;
|
|
19187
|
-
const id =
|
|
19223
|
+
const id = textOrUndefined7(record["id"]);
|
|
19188
19224
|
if (id === void 0 || seen.has(id)) continue;
|
|
19189
19225
|
seen.add(id);
|
|
19190
|
-
bases.push({ id, name:
|
|
19226
|
+
bases.push({ id, name: textOrUndefined7(record["name"]) ?? "" });
|
|
19191
19227
|
}
|
|
19192
19228
|
return bases.length === 0 ? EMPTY_KNOWLEDGE_BASES : bases;
|
|
19193
19229
|
}
|
|
@@ -19243,8 +19279,8 @@ var KnowledgeConfigProvider = class {
|
|
|
19243
19279
|
const raw = await gateway.getMyKnowledgeToken(sessionCookie);
|
|
19244
19280
|
const envelope = raw;
|
|
19245
19281
|
const body = envelope?.["data"] && typeof envelope["data"] === "object" ? envelope["data"] : envelope;
|
|
19246
|
-
const token =
|
|
19247
|
-
const audience =
|
|
19282
|
+
const token = textOrUndefined7(body?.["token"] ?? body?.["knowledge_token"]);
|
|
19283
|
+
const audience = textOrUndefined7(body?.["audience"] ?? body?.["aud"]);
|
|
19248
19284
|
const ids = body?.["knowledge_base_ids"] ?? body?.["knowledgeBaseIds"];
|
|
19249
19285
|
if (!token || audience !== "hiwork-knowledge" || !Array.isArray(ids) || !ids.every((id) => typeof id === "string")) {
|
|
19250
19286
|
this.deps.log?.("hiwork-core: \u7F51\u5173\u8FD4\u56DE\u7684 knowledge-token \u5F62\u72B6\u65E0\u6548");
|
|
@@ -19255,8 +19291,8 @@ var KnowledgeConfigProvider = class {
|
|
|
19255
19291
|
const knowledgeBases = Array.isArray(rawBases) ? rawBases.flatMap((item) => {
|
|
19256
19292
|
if (item === null || typeof item !== "object") return [];
|
|
19257
19293
|
const obj = item;
|
|
19258
|
-
const id =
|
|
19259
|
-
return id ? [{ id, name:
|
|
19294
|
+
const id = textOrUndefined7(obj["id"]);
|
|
19295
|
+
return id ? [{ id, name: textOrUndefined7(obj["name"]) ?? "" }] : [];
|
|
19260
19296
|
}).filter((item) => knowledgeBaseIds.includes(item.id)) : [];
|
|
19261
19297
|
const view = { ok: true, token, audience, knowledgeBaseIds, knowledgeBases };
|
|
19262
19298
|
this.tokenCached = { sessionCookie, view, at: this.now() };
|
|
@@ -19374,7 +19410,7 @@ function messageFor2(reason) {
|
|
|
19374
19410
|
function failure13(reason, message) {
|
|
19375
19411
|
return { ok: false, reason, message: message ?? messageFor2(reason) };
|
|
19376
19412
|
}
|
|
19377
|
-
function
|
|
19413
|
+
function textOrUndefined8(value) {
|
|
19378
19414
|
if (typeof value !== "string") return void 0;
|
|
19379
19415
|
const text = value.trim();
|
|
19380
19416
|
return text === "" ? void 0 : text;
|
|
@@ -19383,15 +19419,15 @@ function teamIdsOf(value) {
|
|
|
19383
19419
|
if (!Array.isArray(value)) return [];
|
|
19384
19420
|
const ids = [];
|
|
19385
19421
|
for (const item of value) {
|
|
19386
|
-
const text =
|
|
19422
|
+
const text = textOrUndefined8(item);
|
|
19387
19423
|
if (text !== void 0) ids.push(text);
|
|
19388
19424
|
}
|
|
19389
19425
|
return ids;
|
|
19390
19426
|
}
|
|
19391
19427
|
function projectMemoryConfig(body) {
|
|
19392
|
-
const panelUrl =
|
|
19393
|
-
const serviceId =
|
|
19394
|
-
const apiKey =
|
|
19428
|
+
const panelUrl = textOrUndefined8(body["panel_url"] ?? body["panelUrl"]);
|
|
19429
|
+
const serviceId = textOrUndefined8(body["service_id"] ?? body["serviceId"]);
|
|
19430
|
+
const apiKey = textOrUndefined8(body["api_key"] ?? body["apiKey"] ?? body["userKey"]);
|
|
19395
19431
|
if (panelUrl === void 0 || serviceId === void 0 || apiKey === void 0) return void 0;
|
|
19396
19432
|
return {
|
|
19397
19433
|
ok: true,
|
|
@@ -19658,7 +19694,7 @@ function provideOfficeRelay(ctx, deps) {
|
|
|
19658
19694
|
};
|
|
19659
19695
|
}
|
|
19660
19696
|
|
|
19661
|
-
// node_modules/.pnpm/@deepseek-ai+dsh-web@0.
|
|
19697
|
+
// node_modules/.pnpm/@deepseek-ai+dsh-web@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4_@deepseek-ai+dsh-llm@0.2.0-rc.1_@deepseek-ai+cordis@4.0.4_/node_modules/@deepseek-ai/dsh-web/lib/index.js
|
|
19662
19698
|
var WebError = class extends HarnessError {
|
|
19663
19699
|
};
|
|
19664
19700
|
var WebRuntime = class extends Service {
|
|
@@ -19836,7 +19872,7 @@ function httpOutcomeToError(status, code) {
|
|
|
19836
19872
|
if (status === 502 || code === "SEARCH_UPSTREAM_ERROR") return new WebError("\u641C\u7D22\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", HIWORK_SEARCH_UPSTREAM);
|
|
19837
19873
|
return new WebError("\u8054\u7F51\u641C\u7D22\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5", "WEB_PROVIDER_ERROR");
|
|
19838
19874
|
}
|
|
19839
|
-
function
|
|
19875
|
+
function textOrUndefined9(value) {
|
|
19840
19876
|
if (typeof value !== "string") return void 0;
|
|
19841
19877
|
const text = value.trim();
|
|
19842
19878
|
return text === "" ? void 0 : text;
|
|
@@ -19848,11 +19884,11 @@ function projectWebSearch(body) {
|
|
|
19848
19884
|
for (const item of raw) {
|
|
19849
19885
|
if (item === null || typeof item !== "object") continue;
|
|
19850
19886
|
const record = item;
|
|
19851
|
-
const url =
|
|
19887
|
+
const url = textOrUndefined9(record["url"]);
|
|
19852
19888
|
if (url === void 0) continue;
|
|
19853
|
-
const title =
|
|
19854
|
-
const snippet =
|
|
19855
|
-
const publishedAt =
|
|
19889
|
+
const title = textOrUndefined9(record["title"]);
|
|
19890
|
+
const snippet = textOrUndefined9(record["snippet"]) ?? textOrUndefined9(record["content"]);
|
|
19891
|
+
const publishedAt = textOrUndefined9(record["published_at"]);
|
|
19856
19892
|
sources.push({
|
|
19857
19893
|
url,
|
|
19858
19894
|
...title !== void 0 ? { title } : {},
|
|
@@ -19916,7 +19952,7 @@ function registerManagedSearchProvider(web, deps) {
|
|
|
19916
19952
|
|
|
19917
19953
|
// src/index.ts
|
|
19918
19954
|
var name = "hiwork-core";
|
|
19919
|
-
var inject = ["settings", "credentials", "workspaceRegistry", "connection", "web", "agents"];
|
|
19955
|
+
var inject = ["settings", "credentials", "workspaceRegistry", "connection", "web", "agents", "systemPrompt"];
|
|
19920
19956
|
var NS = "ai-router";
|
|
19921
19957
|
var PI_AI_NS = "llm-pi-ai";
|
|
19922
19958
|
var MenuConfig = Schema.object({
|
|
@@ -19928,6 +19964,8 @@ var MenuConfig = Schema.object({
|
|
|
19928
19964
|
var lastErrorSchema = Schema.object({ code: Schema.string().required(), message: Schema.string().required() }).default(void 0);
|
|
19929
19965
|
var Config = Schema.object({
|
|
19930
19966
|
baseURL: Schema.string(),
|
|
19967
|
+
// 非 volatile:与 baseURL 同类的组合层固定配置(不进用户表单),出问题经 bundle patch 关闭。
|
|
19968
|
+
identityContext: Schema.boolean().default(true),
|
|
19931
19969
|
keyId: Schema.string().volatile(),
|
|
19932
19970
|
username: Schema.string().volatile(),
|
|
19933
19971
|
displayName: Schema.string().volatile(),
|
|
@@ -20599,6 +20637,13 @@ function apply(ctx, config) {
|
|
|
20599
20637
|
ctx.logger.warn(message);
|
|
20600
20638
|
}
|
|
20601
20639
|
}), "hiwork-core: identity service");
|
|
20640
|
+
ctx.effect(() => registerIdentityContext(ctx.systemPrompt, {
|
|
20641
|
+
current: () => current(),
|
|
20642
|
+
enabled: () => current().identityContext !== false,
|
|
20643
|
+
log: (message) => {
|
|
20644
|
+
ctx.logger.warn(message);
|
|
20645
|
+
}
|
|
20646
|
+
}), "hiwork-core: identity runtime context");
|
|
20602
20647
|
ctx.effect(() => provideMemoryConfig(ctx, {
|
|
20603
20648
|
resolveSession: async () => (await ports.credentials.resolve(SESSION_REF))?.value,
|
|
20604
20649
|
gateway: () => {
|
|
@@ -15,10 +15,11 @@ export declare const HIWORK_MENU_NS = "hiwork-menu";
|
|
|
15
15
|
/**
|
|
16
16
|
* 未自定义时侧栏直显的条数上限(不含原生的「新会话」)。
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* 当前第一方入口恰为 6 个(五个业务 feature + 官方「插件」代理项 order 70)——上限取 6,
|
|
19
|
+
* 全量直显、「更多」行为空不渲染;第 7 个及以后的未标记入口仍走「更多」(「以后再装插件
|
|
20
|
+
* 也不会把侧栏顶高」的机制不变)。改这个数要同步 menu-preferences.spec 的硬编码用例。
|
|
20
21
|
*/
|
|
21
|
-
export declare const DEFAULT_SIDEBAR_LIMIT =
|
|
22
|
+
export declare const DEFAULT_SIDEBAR_LIMIT = 6;
|
|
22
23
|
/** 菜单里「更多」那一行的固定 id(与 feature id 同域,但永不来自注册表)。 */
|
|
23
24
|
export declare const MORE_MENU_ITEM_ID = "__hiwork_more__";
|
|
24
25
|
/** 「更多」这一行的文案(hiwork-core 未注册 locale 命名空间,沿用硬编码中文)。 */
|
|
@@ -76,11 +76,12 @@ export declare const frameCss: string;
|
|
|
76
76
|
/**
|
|
77
77
|
* 隐藏宿主动作入口:
|
|
78
78
|
* - 会话头部右上角「Session 日志」导出入口(产品要求不暴露会话日志导出);
|
|
79
|
-
* -
|
|
79
|
+
* - 侧栏底部官方「设置」触发钮:0.2 起用户徽章注册进 `settings.launcher` 单席槽位
|
|
80
|
+
* (priority -1 抢占官方 ui-settings-account 的账户触发行),**官方触发钮不再渲染**
|
|
81
|
+
* (单席槽位按优先级只出一席),这条 CSS 是 0.1.x 运行树上的兜底——徽章当时挂在
|
|
82
|
+
* sidebar.footer.action、官方触发钮仍在。两代部署并存无害。
|
|
80
83
|
* 注意官方设置弹窗面板 portal 在 settingsArea 容器内部渲染,只能隐藏触发钮
|
|
81
|
-
* 本身(settingsArea 整区 display:none
|
|
82
|
-
* 供 openSettingsSection 程序化点击(display:none 不影响 .click() 派发,
|
|
83
|
-
* dsh-ui 同款做法),弹窗照常打开。
|
|
84
|
+
* 本身(settingsArea 整区 display:none 会连弹窗一起藏掉)。
|
|
84
85
|
* 均按 CSS module 语义后缀命中(hash 前缀无关)。display:none 同时移出无障碍树与
|
|
85
86
|
* Tab 焦点链。后续要隐藏其他宿主入口,规则追加到这里。
|
|
86
87
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { InjectFace
|
|
1
|
+
import type { InjectFace } from '@deepseek-ai/dsh-client-ui-slots';
|
|
2
2
|
import { type AiRouterCardFace } from './controller.ts';
|
|
3
3
|
import { type PluginUpdatesStore } from './plugin-updates.ts';
|
|
4
4
|
/**
|
|
@@ -19,6 +19,11 @@ import { type PluginUpdatesStore } from './plugin-updates.ts';
|
|
|
19
19
|
export interface PluginUpdatesFace {
|
|
20
20
|
pluginUpdates: PluginUpdatesStore;
|
|
21
21
|
}
|
|
22
|
-
export type UserBadgeProps =
|
|
22
|
+
export type UserBadgeProps = InjectFace<AiRouterCardFace & PluginUpdatesFace> & {
|
|
23
|
+
/** `settings.launcher` 槽位的渲染参数(ui-settings-general 的 SettingsRoot 下发)。 */
|
|
24
|
+
readonly wide: boolean | undefined;
|
|
25
|
+
/** 打开设置弹窗(壳拥有 open 状态);分区直达由 selectSettingsSection 补齐。 */
|
|
26
|
+
readonly openSettings: () => void;
|
|
27
|
+
};
|
|
23
28
|
/** 底部账号信息行(宽栏 / 折叠栏共用;插件更新提示卡片也由它渲染,见下)。 */
|
|
24
29
|
export declare function UserBadge(props: UserBadgeProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 登录身份的 runtime context 贡献(`hiwork:identity`):把「当前登录人是谁」送进
|
|
3
|
+
* AI 上下文,供 skill / 会话按人表述与个性化使用(spec
|
|
4
|
+
* `docs/superpowers/specs/2026-10-09-identity-runtime-context-design.md`)。
|
|
5
|
+
*
|
|
6
|
+
* 设计要点(与 `src/identity.ts` 同构):
|
|
7
|
+
* - **cordis-free 纯模块**:注册走结构化的 {@link SystemPromptPort} 窄端口,调用方
|
|
8
|
+
* (index.ts)传真实 `ctx.systemPrompt`;单测直接伪造。真实 PromptContext.text
|
|
9
|
+
* 接受 `(AssembleContext) => string`,本模块的 `() => string` 结构兼容(忽略入参);
|
|
10
|
+
* - **空串 = 不贡献**(DSH 原生语义):未登录、bundle 层关闭(`identityContext: false`)、
|
|
11
|
+
* 读失败一律返回空串——零暴露,且绝不向组装层抛异常;
|
|
12
|
+
* - **每次组装现读**:text 是每次求值的 provider,登录 / 登出 / 换号在下一步即时反映,
|
|
13
|
+
* 不缓存旧身份;
|
|
14
|
+
* - **身份文本不是凭证**:上下文里的身份只作展示 / 个性化 / 按人表述用,鉴权一律在
|
|
15
|
+
* 通道层(loopback RPC 带网关会话、MCP 断言→mint)。文案末尾那句限定语是对模型的
|
|
16
|
+
* 引导,不是防线;
|
|
17
|
+
* - **字段最小化**:只用 `username`(工号)与 `displayName`(姓名),归一化口径与
|
|
18
|
+
* identity.ts 的 textOrUndefined 一致(裁空白、空白串视同缺省)。keys / subject /
|
|
19
|
+
* 团队一律不进上下文。
|
|
20
|
+
*/
|
|
21
|
+
import type { IdentityState } from './identity.ts';
|
|
22
|
+
/** runtime context 贡献名(DSH 侧 snapshot 按名归并,改动即破坏对齐面)。 */
|
|
23
|
+
export declare const IDENTITY_CONTEXT_NAME = "hiwork:identity";
|
|
24
|
+
/** 排在 sandbox:policy(110) / approval:policy(115) 之前——身份是最外层的环境事实。 */
|
|
25
|
+
export declare const IDENTITY_CONTEXT_ORDER = 105;
|
|
26
|
+
/**
|
|
27
|
+
* 渲染身份上下文一行:已登录输出 `HiWork 登录身份:姓名(工号 工号)。<限定语>`,
|
|
28
|
+
* displayName 缺省回退 `工号 <工号>`;**未登录(username 缺省 / 空白 / 非字符串)或
|
|
29
|
+
* state 缺失一律空串**——半份身份(只有 displayName)也不输出,姓名不得单独泄漏。
|
|
30
|
+
*/
|
|
31
|
+
export declare function renderIdentityContextText(state: IdentityState | undefined): string;
|
|
32
|
+
/** `ctx.systemPrompt.context` 的最小端口(结构兼容 DSH 的 SystemPrompt,便于单测伪造)。 */
|
|
33
|
+
export interface SystemPromptPort {
|
|
34
|
+
/** 注册一条 runtime context 贡献;返回注销函数(或任何可注销值,见 registerIdentityContext)。 */
|
|
35
|
+
context(contribution: {
|
|
36
|
+
name: string;
|
|
37
|
+
order: number;
|
|
38
|
+
text: () => string;
|
|
39
|
+
}): unknown;
|
|
40
|
+
}
|
|
41
|
+
/** 注册侧依赖:登录态现读 + bundle 层开关 + 日志出口。 */
|
|
42
|
+
export interface IdentityContextDeps {
|
|
43
|
+
/** 读一次当前登录态(与 hiworkIdentity 同一数据源;每次组装都会调用)。 */
|
|
44
|
+
current(): IdentityState;
|
|
45
|
+
/** bundle 层固定开关(缺省开);关闭时贡献空文本。 */
|
|
46
|
+
enabled(): boolean;
|
|
47
|
+
/** Host 日志出口(只记错误类型,不记身份字段)。 */
|
|
48
|
+
log?(message: string): void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 注册身份 runtime context 贡献;返回 disposer(交给 `ctx.effect` 管理生命周期)。
|
|
52
|
+
* 读失败收敛为空串并记一笔,绝不向组装层抛——身份上下文缺席只应意味着「未登录」。
|
|
53
|
+
*/
|
|
54
|
+
export declare function registerIdentityContext(systemPrompt: SystemPromptPort, deps: IdentityContextDeps): () => void;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -19,7 +19,8 @@ export declare const name = "hiwork-core";
|
|
|
19
19
|
* (`ctx.web.registerSearchProvider`,见 `src/web-search.ts`;dsh-base 基座先于本
|
|
20
20
|
* 插件挂载 dsh-web);`agents` 是根 Agent 注册表——`image_generate` 工具要挂在根 Agent
|
|
21
21
|
* 上(`ctx.agents.roots()` / `agent/created`,见 `src/tools.ts`;与 knowledge 的
|
|
22
|
-
* `inject`
|
|
22
|
+
* `inject` 同源);`systemPrompt` 承载登录身份的 runtime context 贡献
|
|
23
|
+
* (`hiwork:identity`,见 `src/identity-context.ts`);其余三项是既有登录 / 供给依赖。
|
|
23
24
|
*/
|
|
24
25
|
export declare const inject: string[];
|
|
25
26
|
/** 侧栏菜单偏好的解析值(client 侧 `MenuPreferences` 的同一份形状)。 */
|
|
@@ -44,6 +45,11 @@ export declare const MenuConfig: z<MenuConfigValue>;
|
|
|
44
45
|
/** 插件配置 + 运行时状态字段(全部可选;写操作按此 schema 校验)。 */
|
|
45
46
|
export interface Config {
|
|
46
47
|
baseURL?: string;
|
|
48
|
+
/**
|
|
49
|
+
* 身份上下文开关(bundle 层固定配置,缺省开):把当前登录人(工号 + 姓名)以
|
|
50
|
+
* runtime context 贡献暴露进 AI 上下文;关闭时贡献空文本(零暴露)。
|
|
51
|
+
*/
|
|
52
|
+
identityContext?: boolean;
|
|
47
53
|
keyId?: string;
|
|
48
54
|
username?: string;
|
|
49
55
|
displayName?: string;
|
|
@@ -114,12 +120,13 @@ export declare const Config: z<Config>;
|
|
|
114
120
|
/**
|
|
115
121
|
* apply 收到的运行时 config:volatile 字段是稳定引用(schemastery 解析期包装,值为
|
|
116
122
|
* undefined 时引用依然存在),随 profile 变更被框架原地更新——持有引用、每次现取,
|
|
117
|
-
* 绝不缓存 `.get()` 的结果。baseURL 仍是普通组合层配置。
|
|
123
|
+
* 绝不缓存 `.get()` 的结果。baseURL 与 identityContext 仍是普通组合层配置。
|
|
118
124
|
*/
|
|
119
125
|
export type RuntimeConfig = {
|
|
120
126
|
baseURL?: string;
|
|
127
|
+
identityContext?: boolean;
|
|
121
128
|
} & {
|
|
122
|
-
[K in Exclude<keyof Config, 'baseURL'>]?: Volatile<Config[K]>;
|
|
129
|
+
[K in Exclude<keyof Config, 'baseURL' | 'identityContext'>]?: Volatile<Config[K]>;
|
|
123
130
|
};
|
|
124
131
|
/**
|
|
125
132
|
* settings.mutate 的路径操作(rc.2 的 dsh-settings 不再导出 `SettingsPathOp` 类型,
|
|
@@ -37,6 +37,8 @@ export interface AiRouterStatePort {
|
|
|
37
37
|
/** ai-router 命名空间解析后的值(相关字段)。 */
|
|
38
38
|
export interface AiRouterNamespaceValue {
|
|
39
39
|
baseURL?: string;
|
|
40
|
+
/** 身份上下文开关(bundle 层固定配置,缺省开);关闭时 `hiwork:identity` 贡献空文本。 */
|
|
41
|
+
identityContext?: boolean;
|
|
40
42
|
keyId?: string;
|
|
41
43
|
username?: string;
|
|
42
44
|
/** 登录账号的显示名(网关 LDAP displayName,如中文名);缺省时 UI 回退 username。 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hiwork-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.38",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "HiWork 企业统一登录与模型自动供给插件(ai-router 网关登录,Web 表单,无 CLI 认证)",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -42,33 +42,34 @@
|
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@deepseek-ai/cordis": "~4.0.4",
|
|
45
|
-
"@deepseek-ai/dsh-client-ui-layout": ">=0.1.0-rc.5 <0.2.0"
|
|
45
|
+
"@deepseek-ai/dsh-client-ui-layout": ">=0.1.0-rc.5 <0.2.0 || >=0.2.0-rc.1 <0.3.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@deepseek-ai/cordis": "4.0.4",
|
|
49
49
|
"@deepseek-ai/cordis-plugin-loader": "1.0.5",
|
|
50
|
-
"@deepseek-ai/dsh-agent-default-model": "0.
|
|
51
|
-
"@deepseek-ai/dsh-api-remotes": "0.
|
|
52
|
-
"@deepseek-ai/dsh-app-boot": "0.
|
|
53
|
-
"@deepseek-ai/dsh-attachment": "0.
|
|
54
|
-
"@deepseek-ai/dsh-client-store": "0.
|
|
55
|
-
"@deepseek-ai/dsh-client-ui-chat": "0.
|
|
56
|
-
"@deepseek-ai/dsh-client-ui-conversation": "0.
|
|
57
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.
|
|
58
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.
|
|
59
|
-
"@deepseek-ai/dsh-client-ui-session": "0.
|
|
60
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.
|
|
61
|
-
"@deepseek-ai/dsh-client-ui-sidebar": "0.
|
|
62
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.
|
|
63
|
-
"@deepseek-ai/dsh-config-editor": "0.
|
|
64
|
-
"@deepseek-ai/dsh-credentials": "0.
|
|
65
|
-
"@deepseek-ai/dsh-credentials-local": "0.
|
|
66
|
-
"@deepseek-ai/dsh-llm": "0.
|
|
67
|
-
"@deepseek-ai/dsh-llm-pi-ai": "0.
|
|
68
|
-
"@deepseek-ai/dsh-settings": "0.
|
|
69
|
-
"@deepseek-ai/dsh-
|
|
70
|
-
"@deepseek-ai/dsh-
|
|
71
|
-
"@deepseek-ai/dsh-
|
|
50
|
+
"@deepseek-ai/dsh-agent-default-model": "0.2.0-rc.1",
|
|
51
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.0-rc.1",
|
|
52
|
+
"@deepseek-ai/dsh-app-boot": "0.2.0-rc.1",
|
|
53
|
+
"@deepseek-ai/dsh-attachment": "0.2.0-rc.1",
|
|
54
|
+
"@deepseek-ai/dsh-client-store": "0.2.0-rc.1",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-chat": "0.2.0-rc.1",
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.0-rc.1",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.1",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.1",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-session": "0.2.0-rc.1",
|
|
60
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.1",
|
|
61
|
+
"@deepseek-ai/dsh-client-ui-sidebar": "0.2.0-rc.1",
|
|
62
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.1",
|
|
63
|
+
"@deepseek-ai/dsh-config-editor": "0.2.0-rc.1",
|
|
64
|
+
"@deepseek-ai/dsh-credentials": "0.2.0-rc.1",
|
|
65
|
+
"@deepseek-ai/dsh-credentials-local": "0.2.0-rc.1",
|
|
66
|
+
"@deepseek-ai/dsh-llm": "0.2.0-rc.1",
|
|
67
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.1",
|
|
68
|
+
"@deepseek-ai/dsh-settings": "0.2.0-rc.1",
|
|
69
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1",
|
|
70
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.1",
|
|
71
|
+
"@deepseek-ai/dsh-web": "0.2.0-rc.1",
|
|
72
|
+
"@deepseek-ai/dsh-workspace": "0.2.0-rc.1",
|
|
72
73
|
"@deepseek-ai/schemastery": "3.18.4",
|
|
73
74
|
"@types/node": "^22",
|
|
74
75
|
"@types/react": "^18",
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"typescript": "^5",
|
|
82
83
|
"vitest": "^3",
|
|
83
84
|
"yaml": "^2.8.1",
|
|
84
|
-
"@deepseek-ai/dsh-client-ui-layout": "0.
|
|
85
|
+
"@deepseek-ai/dsh-client-ui-layout": "0.2.0-rc.1"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
87
88
|
"typecheck": "tsc --noEmit",
|