@dg-kit/safety 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/contracts.d.ts +44 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +9 -0
- package/dist/contracts.js.map +1 -0
- package/dist/default-policies.d.ts +36 -0
- package/dist/default-policies.d.ts.map +1 -0
- package/dist/default-policies.js +333 -0
- package/dist/default-policies.js.map +1 -0
- package/dist/device-command-queue.d.ts +60 -0
- package/dist/device-command-queue.d.ts.map +1 -0
- package/dist/device-command-queue.js +105 -0
- package/dist/device-command-queue.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/lifecycle-guard.d.ts +30 -0
- package/dist/lifecycle-guard.d.ts.map +1 -0
- package/dist/lifecycle-guard.js +59 -0
- package/dist/lifecycle-guard.js.map +1 -0
- package/dist/policy-engine.d.ts +45 -0
- package/dist/policy-engine.d.ts.map +1 -0
- package/dist/policy-engine.js +31 -0
- package/dist/policy-engine.js.map +1 -0
- package/dist/safety-acceptance.d.ts +27 -0
- package/dist/safety-acceptance.d.ts.map +1 -0
- package/dist/safety-acceptance.js +64 -0
- package/dist/safety-acceptance.js.map +1 -0
- package/dist/safety-bus.d.ts +156 -0
- package/dist/safety-bus.d.ts.map +1 -0
- package/dist/safety-bus.js +169 -0
- package/dist/safety-bus.js.map +1 -0
- package/dist/safety-notice-content.d.ts +37 -0
- package/dist/safety-notice-content.d.ts.map +1 -0
- package/dist/safety-notice-content.js +72 -0
- package/dist/safety-notice-content.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety-bus.js","sourceRoot":"","sources":["../src/safety-bus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAkFH,MAAM,QAAQ,GAAG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**
|
|
2
|
+
* Body text of the pre-use safety acknowledgement.
|
|
3
|
+
*
|
|
4
|
+
* Lives in kit/safety rather than the UI layer because it is part of the
|
|
5
|
+
* safety chain: it is the product's risk disclosure to the user, and whoever
|
|
6
|
+
* audits that will look in this package first. The UI layer only decides how
|
|
7
|
+
* to display it.
|
|
8
|
+
*
|
|
9
|
+
* Before the merge, Agent and Chat each carried a copy; seven of the nine
|
|
10
|
+
* items were byte-identical and the other two had already silently diverged —
|
|
11
|
+
* Agent's "do not use / use with caution" section had "or consult a
|
|
12
|
+
* professional first", Chat's did not. That is exactly what "safety logic
|
|
13
|
+
* must never have a second independently-evolving copy" is meant to prevent:
|
|
14
|
+
* nobody remembers to update both.
|
|
15
|
+
*
|
|
16
|
+
* Think before editing this copy: these sentences exist to keep people from
|
|
17
|
+
* getting hurt; they are not marketing text.
|
|
18
|
+
*/
|
|
19
|
+
export interface SafetyNoticeSection {
|
|
20
|
+
title: string;
|
|
21
|
+
items: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
export declare const SAFETY_NOTICE_SECTIONS: readonly SafetyNoticeSection[];
|
|
24
|
+
export interface SafetyCallout {
|
|
25
|
+
title: string;
|
|
26
|
+
body: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The single most important callout at the top. Risk sources differ per
|
|
30
|
+
* module, hence the per-module keys — but the body lives here once; modules
|
|
31
|
+
* are not allowed to write their own.
|
|
32
|
+
*/
|
|
33
|
+
export declare const SAFETY_CALLOUTS: Record<string, SafetyCallout>;
|
|
34
|
+
export declare const DEFAULT_SAFETY_CALLOUT: SafetyCallout;
|
|
35
|
+
/** Forced reading time in seconds. The button is unclickable until it elapses. */
|
|
36
|
+
export declare const SAFETY_NOTICE_COUNTDOWN_SECONDS = 10;
|
|
37
|
+
//# sourceMappingURL=safety-notice-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety-notice-content.d.ts","sourceRoot":"","sources":["../src/safety-notice-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED,eAAO,MAAM,sBAAsB,EAAE,SAAS,mBAAmB,EA2BvD,CAAC;AAEX,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAazD,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,aAGpC,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,+BAA+B,KAAK,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Body text of the pre-use safety acknowledgement.
|
|
3
|
+
*
|
|
4
|
+
* Lives in kit/safety rather than the UI layer because it is part of the
|
|
5
|
+
* safety chain: it is the product's risk disclosure to the user, and whoever
|
|
6
|
+
* audits that will look in this package first. The UI layer only decides how
|
|
7
|
+
* to display it.
|
|
8
|
+
*
|
|
9
|
+
* Before the merge, Agent and Chat each carried a copy; seven of the nine
|
|
10
|
+
* items were byte-identical and the other two had already silently diverged —
|
|
11
|
+
* Agent's "do not use / use with caution" section had "or consult a
|
|
12
|
+
* professional first", Chat's did not. That is exactly what "safety logic
|
|
13
|
+
* must never have a second independently-evolving copy" is meant to prevent:
|
|
14
|
+
* nobody remembers to update both.
|
|
15
|
+
*
|
|
16
|
+
* Think before editing this copy: these sentences exist to keep people from
|
|
17
|
+
* getting hurt; they are not marketing text.
|
|
18
|
+
*/
|
|
19
|
+
export const SAFETY_NOTICE_SECTIONS = [
|
|
20
|
+
{
|
|
21
|
+
title: '开始前确认',
|
|
22
|
+
items: [
|
|
23
|
+
'本项目会驱动设备输出波形,浏览器、蓝牙、网络与桥接链路都可能出现异常或延迟。',
|
|
24
|
+
'使用时请保持清醒,并确保你可以随时通过物理方式断开设备或停止输出。',
|
|
25
|
+
'本项目不是医疗产品,也不能替代专业判断或风险评估。',
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: '禁用与慎用',
|
|
30
|
+
items: [
|
|
31
|
+
// When merging the two copies, keep the more complete sentence: Chat's
|
|
32
|
+
// version was missing the "or consult a professional first" escape.
|
|
33
|
+
'心脏起搏器、心血管疾病、癫痫、孕期或任何不确定身体状况时,请不要使用,或先咨询专业人士。',
|
|
34
|
+
'禁止将电极放在胸口、头部、颈部、破损皮肤、炎症区域或任何异常敏感部位。',
|
|
35
|
+
'独处、睡眠、洗澡、饮酒后、驾驶中或操作机械时,禁止使用。',
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
title: '使用中要求',
|
|
40
|
+
items: [
|
|
41
|
+
'首次使用或更换部位时,请从最低强度开始,逐步确认体感与安全边界。',
|
|
42
|
+
'输出期间不要移动电极,不要频繁切换贴片位置,也不要让导电部件短接。',
|
|
43
|
+
'若出现刺痛、灼热、头晕、心悸或任何不适,请立刻停止并断开设备。',
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* The single most important callout at the top. Risk sources differ per
|
|
49
|
+
* module, hence the per-module keys — but the body lives here once; modules
|
|
50
|
+
* are not allowed to write their own.
|
|
51
|
+
*/
|
|
52
|
+
export const SAFETY_CALLOUTS = {
|
|
53
|
+
agent: {
|
|
54
|
+
title: 'AI 不是安全控制器。',
|
|
55
|
+
body: '模型可能误判,浏览器、蓝牙或桥接链路也可能卡顿、重试、断连或产生非预期行为。请始终把“立刻停止输出”和“立刻断开设备”放在最高优先级。',
|
|
56
|
+
},
|
|
57
|
+
chat: {
|
|
58
|
+
title: '远程控制具有不确定性。',
|
|
59
|
+
body: '房间里的其他人、浏览器、蓝牙或网络链路都可能产生非预期行为。请始终把“立刻停止输出”和“立刻断开设备”放在最高优先级。',
|
|
60
|
+
},
|
|
61
|
+
voice: {
|
|
62
|
+
title: '语音识别会出错。',
|
|
63
|
+
body: '模型可能听错或误判,网络链路也可能卡顿、断连。请始终把“立刻停止输出”和“立刻断开设备”放在最高优先级。',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
export const DEFAULT_SAFETY_CALLOUT = {
|
|
67
|
+
title: '设备输出具有不确定性。',
|
|
68
|
+
body: '浏览器、蓝牙或网络链路可能卡顿、断连或产生非预期行为。请始终把“立刻停止输出”和“立刻断开设备”放在最高优先级。',
|
|
69
|
+
};
|
|
70
|
+
/** Forced reading time in seconds. The button is unclickable until it elapses. */
|
|
71
|
+
export const SAFETY_NOTICE_COUNTDOWN_SECONDS = 10;
|
|
72
|
+
//# sourceMappingURL=safety-notice-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safety-notice-content.js","sourceRoot":"","sources":["../src/safety-notice-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAOH,MAAM,CAAC,MAAM,sBAAsB,GAAmC;IACpE;QACE,KAAK,EAAE,OAAO;QACd,KAAK,EAAE;YACL,wCAAwC;YACxC,mCAAmC;YACnC,2BAA2B;SAC5B;KACF;IACD;QACE,KAAK,EAAE,OAAO;QACd,KAAK,EAAE;YACL,uEAAuE;YACvE,oEAAoE;YACpE,8CAA8C;YAC9C,qCAAqC;YACrC,8BAA8B;SAC/B;KACF;IACD;QACE,KAAK,EAAE,OAAO;QACd,KAAK,EAAE;YACL,kCAAkC;YAClC,mCAAmC;YACnC,iCAAiC;SAClC;KACF;CACO,CAAC;AAOX;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAkC;IAC5D,KAAK,EAAE;QACL,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,qEAAqE;KAC5E;IACD,IAAI,EAAE;QACJ,KAAK,EAAE,aAAa;QACpB,IAAI,EAAE,6DAA6D;KACpE;IACD,KAAK,EAAE;QACL,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,sDAAsD;KAC7D;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAkB;IACnD,KAAK,EAAE,aAAa;IACpB,IAAI,EAAE,0DAA0D;CACjE,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dg-kit/safety",
|
|
3
|
+
"version": "1.14.0",
|
|
4
|
+
"description": "DG-Lab 设备安全链:策略引擎、默认上限策略、串行命令队列",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "0xNullAI",
|
|
7
|
+
"homepage": "https://github.com/0xNullAI/0xNuller/tree/main/packages/kit/safety",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/0xNullAI/0xNuller.git",
|
|
27
|
+
"directory": "packages/kit/safety"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsc -p tsconfig.json",
|
|
31
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
32
|
+
"prepublishOnly": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@dg-kit/core": "1.14.0",
|
|
36
|
+
"@dg-kit/protocol": "1.14.0"
|
|
37
|
+
}
|
|
38
|
+
}
|