@xgjktech/xg-openclaw-harness-tools 0.4.9 → 0.4.10

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA+BA,QAAA,MAAM,WAAW,kEA6Df,CAAC;AAaH,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiDA,QAAA,MAAM,WAAW,kEAkEf,CAAC;AAeH,eAAe,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { Type } from "typebox";
1
2
  import { defineToolPlugin } from "openclaw/plugin-sdk/tool-plugin";
2
3
  import { isSubagentSessionKey } from "openclaw/plugin-sdk/routing";
3
4
  import { resolvePlanDbPath, SqlitePlanStore, SqliteActionStore } from "@xgjktech/xg-openclaw-shared";
@@ -7,6 +8,18 @@ import { ACTION_DISPATCH_DESCRIPTION, ActionDispatchParams, buildActionDispatchT
7
8
  import { toPlanOrigin } from "./plan-origin.js";
8
9
  import { buildPlanPromptInjection } from "./plan-prompt.js";
9
10
  const PLUGIN_ID = "xg-harness-tools";
11
+ // 计划功能总开关:默认 false(关闭 xg_plan_write / xg_plan_view 及主动建计划 prompt 注入)。
12
+ // 代码与测试保留,部署时在插件配置里设 { "enablePlan": true } 即可重新启用。
13
+ const PluginConfigSchema = Type.Object({
14
+ enablePlan: Type.Optional(Type.Boolean({
15
+ default: false,
16
+ description: "启用 xg 计划工具(xg_plan_write / xg_plan_view)与主动建计划 prompt 注入。默认 false。",
17
+ })),
18
+ });
19
+ /** 计划功能是否启用:仅显式 true 才开启,缺省/其他值一律视为关闭。 */
20
+ function isPlanEnabled(pluginConfig) {
21
+ return pluginConfig?.enablePlan === true;
22
+ }
10
23
  // 临时诊断日志:确认 subagent 会话的 sessionKey 是否到达 hook/tool factory 且判定正确。确认后删除。
11
24
  function logPlanGate(api, tag, sessionKey) {
12
25
  api.runtime?.logging
@@ -20,6 +33,7 @@ const pluginEntry = defineToolPlugin({
20
33
  id: PLUGIN_ID,
21
34
  name: "XG Harness Tools",
22
35
  description: "企业工具插件:计划管理与通用动作分发(plan_write / plan_view / action_dispatch)",
36
+ configSchema: PluginConfigSchema,
23
37
  tools: (tool) => {
24
38
  let planStore;
25
39
  let actionStore;
@@ -44,9 +58,12 @@ const pluginEntry = defineToolPlugin({
44
58
  description: PLAN_WRITE_DESCRIPTION,
45
59
  parameters: PlanWriteParams,
46
60
  optional: true,
47
- factory: ({ api, toolContext }) => {
48
- // 计划只允许主 agent 维护;subagent 会话不注册计划工具,杜绝其建计划。
61
+ factory: ({ api, config, toolContext }) => {
62
+ // 计划功能默认关闭;仅显式 enablePlan:true 时注册。
49
63
  logPlanGate(api, "plan_write_factory", toolContext.sessionKey);
64
+ if (!config.enablePlan)
65
+ return null;
66
+ // 计划只允许主 agent 维护;subagent 会话不注册计划工具,杜绝其建计划。
50
67
  if (isSubagentSessionKey(toolContext.sessionKey))
51
68
  return null;
52
69
  return buildPlanWriteTool(getPlanStore(api), toPlanOrigin(toolContext));
@@ -58,8 +75,11 @@ const pluginEntry = defineToolPlugin({
58
75
  description: PLAN_VIEW_DESCRIPTION,
59
76
  parameters: PlanViewParams,
60
77
  optional: true,
61
- factory: ({ api, toolContext }) => {
78
+ factory: ({ api, config, toolContext }) => {
79
+ // 计划功能默认关闭;仅显式 enablePlan:true 时注册。
62
80
  logPlanGate(api, "plan_view_factory", toolContext.sessionKey);
81
+ if (!config.enablePlan)
82
+ return null;
63
83
  if (isSubagentSessionKey(toolContext.sessionKey))
64
84
  return null;
65
85
  return buildPlanViewTool({ store: getPlanStore(api), origin: toPlanOrigin(toolContext) });
@@ -81,6 +101,9 @@ const pluginEntry = defineToolPlugin({
81
101
  const baseRegister = pluginEntry.register;
82
102
  pluginEntry.register = (api) => {
83
103
  baseRegister(api);
104
+ // 计划功能默认关闭时,不注入主动建计划纪律。
105
+ if (!isPlanEnabled(api.pluginConfig))
106
+ return;
84
107
  api.on("before_prompt_build", (event, ctx) => {
85
108
  logPlanGate(api, "hook", ctx.sessionKey);
86
109
  return buildPlanPromptInjection(event, ctx);
@@ -6,7 +6,13 @@
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": true,
9
- "properties": {}
9
+ "properties": {
10
+ "enablePlan": {
11
+ "type": "boolean",
12
+ "default": false,
13
+ "description": "启用 xg 计划工具(xg_plan_write / xg_plan_view)与主动建计划 prompt 注入。默认 false。"
14
+ }
15
+ }
10
16
  },
11
17
  "contracts": {
12
18
  "tools": ["xg_plan_write", "xg_plan_view", "xg_action_dispatch"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xgjktech/xg-openclaw-harness-tools",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "企业工具插件:plan_write / plan_view / action_dispatch(OpenClaw 第三方工具插件)",
5
5
  "license": "MIT",
6
6
  "type": "module",