@xgjktech/xg-openclaw-harness-tools 0.4.5 → 0.4.7
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":"plan-write-tool.d.ts","sourceRoot":"","sources":["../src/plan-write-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,SAAS,EAGf,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"plan-write-tool.d.ts","sourceRoot":"","sources":["../src/plan-write-tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAIL,KAAK,UAAU,EACf,KAAK,SAAS,EAGf,MAAM,8BAA8B,CAAC;AAkCtC,eAAO,MAAM,eAAe;;;;;;;;;EAwB3B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE9D,eAAO,MAAM,sBAAsB,QA4BvB,CAAC;AA0Eb,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,YAAY,CA2HtF"}
|
package/dist/plan-write-tool.js
CHANGED
|
@@ -18,6 +18,9 @@ const TaskInput = Type.Object({
|
|
|
18
18
|
], { default: "pending" })),
|
|
19
19
|
note: Type.Optional(Type.String({ maxLength: 1000, description: "备注;blocked 时写明原因" })),
|
|
20
20
|
}, { additionalProperties: false });
|
|
21
|
+
function normalizeOptionalString(value) {
|
|
22
|
+
return value === undefined || value.trim() === "" ? undefined : value;
|
|
23
|
+
}
|
|
21
24
|
export const PlanWriteParams = Type.Object({
|
|
22
25
|
planId: Type.Optional(Type.String({ maxLength: 128, description: "留空=新建;填写=整张覆盖该计划" })),
|
|
23
26
|
goal: Type.Optional(Type.String({
|
|
@@ -124,9 +127,10 @@ export function buildPlanWriteTool(store, origin) {
|
|
|
124
127
|
parameters: PlanWriteParams,
|
|
125
128
|
async execute(_toolCallId, rawParams) {
|
|
126
129
|
const params = rawParams;
|
|
130
|
+
const planIdParam = normalizeOptionalString(params.planId);
|
|
127
131
|
try {
|
|
128
132
|
if (params.cancel === true) {
|
|
129
|
-
if (
|
|
133
|
+
if (planIdParam === undefined ||
|
|
130
134
|
params.goal !== undefined ||
|
|
131
135
|
params.tasks !== undefined) {
|
|
132
136
|
const result = {
|
|
@@ -135,7 +139,7 @@ export function buildPlanWriteTool(store, origin) {
|
|
|
135
139
|
};
|
|
136
140
|
return toolJsonResult(result);
|
|
137
141
|
}
|
|
138
|
-
const existing = store.get(
|
|
142
|
+
const existing = store.get(planIdParam);
|
|
139
143
|
if (existing === undefined || !planInScope(existing, scope)) {
|
|
140
144
|
const result = {
|
|
141
145
|
ok: false,
|
|
@@ -177,8 +181,8 @@ export function buildPlanWriteTool(store, origin) {
|
|
|
177
181
|
return toolJsonResult(result);
|
|
178
182
|
}
|
|
179
183
|
let existing;
|
|
180
|
-
if (
|
|
181
|
-
existing = store.get(
|
|
184
|
+
if (planIdParam !== undefined) {
|
|
185
|
+
existing = store.get(planIdParam);
|
|
182
186
|
if (existing === undefined || !planInScope(existing, scope)) {
|
|
183
187
|
const result = {
|
|
184
188
|
ok: false,
|
|
@@ -188,12 +192,12 @@ export function buildPlanWriteTool(store, origin) {
|
|
|
188
192
|
}
|
|
189
193
|
}
|
|
190
194
|
let warnings;
|
|
191
|
-
if (
|
|
195
|
+
if (planIdParam === undefined && scope !== undefined) {
|
|
192
196
|
const warning = unfinishedPlanWarning(store.listPlansByOrigin(scope), Date.now());
|
|
193
197
|
if (warning !== undefined)
|
|
194
198
|
warnings = [warning];
|
|
195
199
|
}
|
|
196
|
-
const planId =
|
|
200
|
+
const planId = planIdParam ?? randomUUID();
|
|
197
201
|
const plan = buildPlan(params.goal, params.tasks, existing, planId, origin, new Date().toISOString());
|
|
198
202
|
assertPlanInvariants(plan);
|
|
199
203
|
store.set(plan);
|