@xgjktech/xg-openclaw-shared 0.2.1 → 0.2.2
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plan-types.d.ts +5 -2
- package/dist/plan-types.d.ts.map +1 -1
- package/dist/plan-types.js +8 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { Plan, Task, Step, TaskStatus, StepStatus, PlanOrigin } from "./plan-types.js";
|
|
2
|
-
export { assertPlanInvariants, PlanInvariantError } from "./plan-types.js";
|
|
2
|
+
export { assertPlanInvariants, isPlanCancelled, PlanInvariantError } from "./plan-types.js";
|
|
3
3
|
export type { PlanStore, PlanSummary } from "./plan-store.js";
|
|
4
4
|
export { SqlitePlanStore, openPlanStoreReadonly, resolvePlanDbPath, PlanStoreError } from "./plan-store.js";
|
|
5
5
|
export type { PlanEventPayload, PlanEventSummary } from "./plan-events.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE5F,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5G,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// 桶文件:xg-shared 的唯一公开面。两插件(本插件 + IM 插件)均只从此入口 import。
|
|
2
|
-
export { assertPlanInvariants, PlanInvariantError } from "./plan-types.js";
|
|
2
|
+
export { assertPlanInvariants, isPlanCancelled, PlanInvariantError } from "./plan-types.js";
|
|
3
3
|
export { SqlitePlanStore, openPlanStoreReadonly, resolvePlanDbPath, PlanStoreError } from "./plan-store.js";
|
|
4
4
|
export { planEventStream, isPlanEventPayload } from "./plan-events.js";
|
package/dist/plan-types.d.ts
CHANGED
|
@@ -34,17 +34,20 @@ export interface Plan {
|
|
|
34
34
|
updatedAt: string;
|
|
35
35
|
tasks: Task[];
|
|
36
36
|
origin?: PlanOrigin;
|
|
37
|
+
status?: "active" | "cancelled";
|
|
38
|
+
cancelledAt?: string;
|
|
37
39
|
}
|
|
38
40
|
export declare class PlanInvariantError extends Error {
|
|
39
41
|
constructor(message: string);
|
|
40
42
|
}
|
|
43
|
+
export declare function isPlanCancelled(plan: Plan): boolean;
|
|
41
44
|
/**
|
|
42
45
|
* 校验 Plan 是否满足全部领域不变量,违反则抛出 PlanInvariantError。
|
|
43
46
|
* 写入方落库前调用;共享函数签名保持稳定,供旧消费者继续复用。
|
|
44
47
|
*
|
|
45
48
|
* 仅校验持久化文档的基础形状:planId / goal 非空、tasks 至少一项,
|
|
46
|
-
* task.status / step.status 取值在枚举内。执行纪律由工具
|
|
47
|
-
*
|
|
49
|
+
* plan.status / task.status / step.status 取值在枚举内。执行纪律由工具
|
|
50
|
+
* description 引导,不在共享层阻断草稿计划落库。
|
|
48
51
|
*/
|
|
49
52
|
export declare function assertPlanInvariants(plan: Plan): void;
|
|
50
53
|
//# sourceMappingURL=plan-types.d.ts.map
|
package/dist/plan-types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-types.d.ts","sourceRoot":"","sources":["../src/plan-types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,SAAS,CAAC;AAC7E,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC;AAUjE,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,IAAI;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,MAAM,CAAC,EAAE,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":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CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAiCrD"}
|
package/dist/plan-types.js
CHANGED
|
@@ -18,13 +18,16 @@ function isTaskStatus(value) {
|
|
|
18
18
|
function isStepStatus(value) {
|
|
19
19
|
return STEP_STATUSES.includes(value);
|
|
20
20
|
}
|
|
21
|
+
export function isPlanCancelled(plan) {
|
|
22
|
+
return plan.status === "cancelled";
|
|
23
|
+
}
|
|
21
24
|
/**
|
|
22
25
|
* 校验 Plan 是否满足全部领域不变量,违反则抛出 PlanInvariantError。
|
|
23
26
|
* 写入方落库前调用;共享函数签名保持稳定,供旧消费者继续复用。
|
|
24
27
|
*
|
|
25
28
|
* 仅校验持久化文档的基础形状:planId / goal 非空、tasks 至少一项,
|
|
26
|
-
* task.status / step.status 取值在枚举内。执行纪律由工具
|
|
27
|
-
*
|
|
29
|
+
* plan.status / task.status / step.status 取值在枚举内。执行纪律由工具
|
|
30
|
+
* description 引导,不在共享层阻断草稿计划落库。
|
|
28
31
|
*/
|
|
29
32
|
export function assertPlanInvariants(plan) {
|
|
30
33
|
if (plan.planId.trim() === "") {
|
|
@@ -36,6 +39,9 @@ export function assertPlanInvariants(plan) {
|
|
|
36
39
|
if (plan.tasks.length === 0) {
|
|
37
40
|
throw new PlanInvariantError("tasks 至少一项");
|
|
38
41
|
}
|
|
42
|
+
if (plan.status !== undefined && plan.status !== "active" && plan.status !== "cancelled") {
|
|
43
|
+
throw new PlanInvariantError(`status 取值非法: ${plan.status}`);
|
|
44
|
+
}
|
|
39
45
|
plan.tasks.forEach((task, taskIndex) => {
|
|
40
46
|
if (!isTaskStatus(task.status)) {
|
|
41
47
|
throw new PlanInvariantError(`tasks[${taskIndex}].status 取值非法: ${task.status}`);
|