@coffeexdev/openclaw-sentinel 0.4.2 → 0.4.3
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/tool.d.ts +2 -2
- package/dist/tool.js +5 -3
- package/dist/toolSchema.d.ts +45 -1
- package/dist/toolSchema.js +31 -13
- package/package.json +1 -1
package/dist/tool.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AnyAgentTool } from "openclaw/plugin-sdk";
|
|
2
2
|
import type { Static } from "@sinclair/typebox";
|
|
3
3
|
import { WatcherManager } from "./watcherManager.js";
|
|
4
|
-
import {
|
|
5
|
-
export type SentinelToolParams = Static<typeof
|
|
4
|
+
import { SentinelToolValidationSchema } from "./toolSchema.js";
|
|
5
|
+
export type SentinelToolParams = Static<typeof SentinelToolValidationSchema>;
|
|
6
6
|
type SentinelToolContext = {
|
|
7
7
|
messageChannel?: string;
|
|
8
8
|
requesterSenderId?: string;
|
package/dist/tool.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsonResult } from "openclaw/plugin-sdk";
|
|
2
2
|
import { Value } from "@sinclair/typebox/value";
|
|
3
|
-
import { SentinelToolSchema } from "./toolSchema.js";
|
|
3
|
+
import { SentinelToolSchema, SentinelToolValidationSchema } from "./toolSchema.js";
|
|
4
4
|
import { TemplateValueSchema } from "./templateValueSchema.js";
|
|
5
5
|
function validateParams(params) {
|
|
6
6
|
const candidate = (params ?? {});
|
|
7
|
-
if (!Value.Check(
|
|
8
|
-
const first = [
|
|
7
|
+
if (!Value.Check(SentinelToolValidationSchema, [TemplateValueSchema], candidate)) {
|
|
8
|
+
const first = [
|
|
9
|
+
...Value.Errors(SentinelToolValidationSchema, [TemplateValueSchema], candidate),
|
|
10
|
+
][0];
|
|
9
11
|
const where = first?.path || "(root)";
|
|
10
12
|
const why = first?.message || "Invalid parameters";
|
|
11
13
|
throw new Error(`Invalid sentinel_control parameters at ${where}: ${why}`);
|
package/dist/toolSchema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const SentinelToolValidationSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
|
|
2
2
|
action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"create">, import("@sinclair/typebox").TLiteral<"add">]>;
|
|
3
3
|
watcher: import("@sinclair/typebox").TObject<{
|
|
4
4
|
id: import("@sinclair/typebox").TString;
|
|
@@ -46,3 +46,47 @@ export declare const SentinelToolSchema: import("@sinclair/typebox").TUnion<[imp
|
|
|
46
46
|
}>, import("@sinclair/typebox").TObject<{
|
|
47
47
|
action: import("@sinclair/typebox").TLiteral<"list">;
|
|
48
48
|
}>]>;
|
|
49
|
+
export declare const SentinelToolSchema: import("@sinclair/typebox").TObject<{
|
|
50
|
+
action: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"create">, import("@sinclair/typebox").TLiteral<"add">]>, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"enable">, import("@sinclair/typebox").TLiteral<"disable">, import("@sinclair/typebox").TLiteral<"remove">, import("@sinclair/typebox").TLiteral<"delete">, import("@sinclair/typebox").TLiteral<"status">, import("@sinclair/typebox").TLiteral<"get">]>, import("@sinclair/typebox").TLiteral<"list">]>;
|
|
51
|
+
watcher: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
|
|
52
|
+
id: import("@sinclair/typebox").TString;
|
|
53
|
+
skillId: import("@sinclair/typebox").TString;
|
|
54
|
+
enabled: import("@sinclair/typebox").TBoolean;
|
|
55
|
+
strategy: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"http-poll">, import("@sinclair/typebox").TLiteral<"websocket">, import("@sinclair/typebox").TLiteral<"sse">, import("@sinclair/typebox").TLiteral<"http-long-poll">]>;
|
|
56
|
+
endpoint: import("@sinclair/typebox").TString;
|
|
57
|
+
method: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"GET">, import("@sinclair/typebox").TLiteral<"POST">]>>;
|
|
58
|
+
headers: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>>;
|
|
59
|
+
body: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
60
|
+
intervalMs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
61
|
+
timeoutMs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
|
62
|
+
match: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"all">, import("@sinclair/typebox").TLiteral<"any">]>;
|
|
63
|
+
conditions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
64
|
+
path: import("@sinclair/typebox").TString;
|
|
65
|
+
op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"eq">, import("@sinclair/typebox").TLiteral<"neq">, import("@sinclair/typebox").TLiteral<"gt">, import("@sinclair/typebox").TLiteral<"gte">, import("@sinclair/typebox").TLiteral<"lt">, import("@sinclair/typebox").TLiteral<"lte">, import("@sinclair/typebox").TLiteral<"exists">, import("@sinclair/typebox").TLiteral<"absent">, import("@sinclair/typebox").TLiteral<"contains">, import("@sinclair/typebox").TLiteral<"matches">, import("@sinclair/typebox").TLiteral<"changed">]>;
|
|
66
|
+
value: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
|
|
67
|
+
}>>;
|
|
68
|
+
fire: import("@sinclair/typebox").TObject<{
|
|
69
|
+
webhookPath: import("@sinclair/typebox").TString;
|
|
70
|
+
eventName: import("@sinclair/typebox").TString;
|
|
71
|
+
payloadTemplate: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TRef<any>>;
|
|
72
|
+
intent: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
73
|
+
contextTemplate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TRef<any>>>;
|
|
74
|
+
priority: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"low">, import("@sinclair/typebox").TLiteral<"normal">, import("@sinclair/typebox").TLiteral<"high">, import("@sinclair/typebox").TLiteral<"critical">]>>;
|
|
75
|
+
deadlineTemplate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
76
|
+
dedupeKeyTemplate: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
77
|
+
}>;
|
|
78
|
+
retry: import("@sinclair/typebox").TObject<{
|
|
79
|
+
maxRetries: import("@sinclair/typebox").TNumber;
|
|
80
|
+
baseMs: import("@sinclair/typebox").TNumber;
|
|
81
|
+
maxMs: import("@sinclair/typebox").TNumber;
|
|
82
|
+
}>;
|
|
83
|
+
fireOnce: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
|
|
84
|
+
deliveryTargets: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
|
|
85
|
+
channel: import("@sinclair/typebox").TString;
|
|
86
|
+
to: import("@sinclair/typebox").TString;
|
|
87
|
+
accountId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
88
|
+
}>>>;
|
|
89
|
+
metadata: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>>;
|
|
90
|
+
}>>;
|
|
91
|
+
id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
|
92
|
+
}>;
|
package/dist/toolSchema.js
CHANGED
|
@@ -80,27 +80,45 @@ const WatcherSchema = Type.Object({
|
|
|
80
80
|
})),
|
|
81
81
|
metadata: Type.Optional(Type.Record(Type.String(), Type.String(), { description: "Arbitrary key-value metadata" })),
|
|
82
82
|
}, { description: "Full watcher definition" });
|
|
83
|
+
const CreateActionNameSchema = Type.Union([Type.Literal("create"), Type.Literal("add")], {
|
|
84
|
+
description: "Create action (alias: add)",
|
|
85
|
+
});
|
|
86
|
+
const IdActionNameSchema = Type.Union([
|
|
87
|
+
Type.Literal("enable"),
|
|
88
|
+
Type.Literal("disable"),
|
|
89
|
+
Type.Literal("remove"),
|
|
90
|
+
Type.Literal("delete"),
|
|
91
|
+
Type.Literal("status"),
|
|
92
|
+
Type.Literal("get"),
|
|
93
|
+
], { description: "ID-targeting action aliases: delete/remove and get/status" });
|
|
94
|
+
const ListActionNameSchema = Type.Literal("list", { description: "List all watchers" });
|
|
95
|
+
const AnyActionNameSchema = Type.Union([
|
|
96
|
+
CreateActionNameSchema,
|
|
97
|
+
IdActionNameSchema,
|
|
98
|
+
ListActionNameSchema,
|
|
99
|
+
]);
|
|
83
100
|
const CreateActionSchema = Type.Object({
|
|
84
|
-
action:
|
|
85
|
-
description: "Create action (alias: add)",
|
|
86
|
-
}),
|
|
101
|
+
action: CreateActionNameSchema,
|
|
87
102
|
watcher: WatcherSchema,
|
|
88
103
|
}, { additionalProperties: false });
|
|
89
104
|
const IdActionSchema = Type.Object({
|
|
90
|
-
action:
|
|
91
|
-
Type.Literal("enable"),
|
|
92
|
-
Type.Literal("disable"),
|
|
93
|
-
Type.Literal("remove"),
|
|
94
|
-
Type.Literal("delete"),
|
|
95
|
-
Type.Literal("status"),
|
|
96
|
-
Type.Literal("get"),
|
|
97
|
-
], { description: "ID-targeting action aliases: delete/remove and get/status" }),
|
|
105
|
+
action: IdActionNameSchema,
|
|
98
106
|
id: Type.String({ description: "Watcher ID for action target" }),
|
|
99
107
|
}, { additionalProperties: false });
|
|
100
108
|
const ListActionSchema = Type.Object({
|
|
101
|
-
action:
|
|
109
|
+
action: ListActionNameSchema,
|
|
102
110
|
}, { additionalProperties: false });
|
|
103
|
-
export const
|
|
111
|
+
export const SentinelToolValidationSchema = Type.Union([CreateActionSchema, IdActionSchema, ListActionSchema], {
|
|
112
|
+
$defs: {
|
|
113
|
+
templateValue: TemplateValueSchema,
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
export const SentinelToolSchema = Type.Object({
|
|
117
|
+
action: AnyActionNameSchema,
|
|
118
|
+
watcher: Type.Optional(WatcherSchema),
|
|
119
|
+
id: Type.Optional(Type.String({ description: "Watcher ID for action target" })),
|
|
120
|
+
}, {
|
|
121
|
+
additionalProperties: false,
|
|
104
122
|
$defs: {
|
|
105
123
|
templateValue: TemplateValueSchema,
|
|
106
124
|
},
|