tencent-claw-shield 0.1.0-beta.9 → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  import type { ShieldApprovalCategory, ShieldFailMode, ShieldSeverity, ShieldStage, ShieldSurface } from "../types";
2
2
  /** 统一钩子名称枚举:对应 Agent 生命周期中的各个检测点 */
3
- export type ShieldCanonicalHookName = "message_received" | "before_llm_request" | "before_tool_call" | "message_sending" | "before_message_write" | "tool_result_persist";
3
+ export type ShieldCanonicalHookName = "message_received" | "before_prompt_build" | "before_llm_request" | "before_tool_call" | "message_sending" | "before_message_write" | "tool_result_persist";
4
4
  /**
5
5
  * 兼容别名:历史代码使用 ShieldHookName,等价于统一钩子名
6
6
  * 后续建议优先使用 ShieldCanonicalHookName
@@ -32,12 +32,21 @@ export type HookEnvelopeBase = {
32
32
  /** 入口钩子信封:用户消息到达时触发 */
33
33
  export type IngressEnvelope = HookEnvelopeBase & {
34
34
  canonicalHook: "message_received";
35
- hostHookName: "message_received" | "before_prompt_build";
35
+ hostHookName: "message_received";
36
36
  surface: "ingress";
37
37
  payload: {
38
38
  message: unknown;
39
39
  };
40
40
  };
41
+ /** 提示词构建前钩子信封:构建 LLM prompt 前触发,可修改 prompt */
42
+ export type PromptBuildEnvelope = HookEnvelopeBase & {
43
+ canonicalHook: "before_prompt_build";
44
+ hostHookName: "before_prompt_build";
45
+ surface: "prompt_build";
46
+ payload: {
47
+ message: unknown;
48
+ };
49
+ };
41
50
  /** LLM 请求钩子信封:向大模型发送请求前触发 */
42
51
  export type LlmRequestEnvelope = HookEnvelopeBase & {
43
52
  canonicalHook: "before_llm_request";
@@ -84,7 +93,7 @@ export type PersistEnvelope = HookEnvelopeBase & {
84
93
  };
85
94
  };
86
95
  /** 钩子信封联合类型:所有钩子信封的联合 */
87
- export type HookEnvelope = IngressEnvelope | LlmRequestEnvelope | ToolCallEnvelope | EgressEnvelope | PersistEnvelope;
96
+ export type HookEnvelope = IngressEnvelope | PromptBuildEnvelope | LlmRequestEnvelope | ToolCallEnvelope | EgressEnvelope | PersistEnvelope;
88
97
  /** 原因代码:标识安全问题的分类 */
89
98
  export type ReasonCode = "prompt_injection" | "retrieval_poisoning" | "sensitive_action" | "egress_exfiltration" | "mcp_allowlist_violation" | "model_governance_violation" | "approval_required" | "unknown";
90
99
  /** 标准化的检测发现:将各种来源的发现统一为标准格式 */