@agentvault/agentvault 0.19.58 → 0.19.60
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/_cp.d.ts +10 -0
- package/dist/_cp.d.ts.map +1 -0
- package/dist/account-config.d.ts +20 -0
- package/dist/account-config.d.ts.map +1 -0
- package/dist/channel.d.ts +391 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +1218 -473
- package/dist/cli.js.map +3 -3
- package/dist/create-agent.d.ts +28 -0
- package/dist/create-agent.d.ts.map +1 -0
- package/dist/credential-store.d.ts +62 -0
- package/dist/credential-store.d.ts.map +1 -0
- package/dist/crypto-helpers.d.ts +2 -0
- package/dist/crypto-helpers.d.ts.map +1 -0
- package/dist/doctor.d.ts +41 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/fetch-interceptor.d.ts +32 -0
- package/dist/fetch-interceptor.d.ts.map +1 -0
- package/dist/gateway-send.d.ts +98 -0
- package/dist/gateway-send.d.ts.map +1 -0
- package/dist/http-handlers.d.ts +53 -0
- package/dist/http-handlers.d.ts.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1156 -473
- package/dist/index.js.map +3 -3
- package/dist/mcp-handlers.d.ts +26 -0
- package/dist/mcp-handlers.d.ts.map +1 -0
- package/dist/mcp-proxy-helpers.d.ts +9 -0
- package/dist/mcp-proxy-helpers.d.ts.map +1 -0
- package/dist/mcp-server.d.ts +91 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mls-state.d.ts +16 -0
- package/dist/mls-state.d.ts.map +1 -0
- package/dist/openclaw-compat.d.ts +33 -0
- package/dist/openclaw-compat.d.ts.map +1 -0
- package/dist/openclaw-entry.d.ts +32 -0
- package/dist/openclaw-entry.d.ts.map +1 -0
- package/dist/openclaw-plugin.d.ts +102 -0
- package/dist/openclaw-plugin.d.ts.map +1 -0
- package/dist/openclaw-types.d.ts +186 -0
- package/dist/openclaw-types.d.ts.map +1 -0
- package/dist/policy-enforcer.d.ts +78 -0
- package/dist/policy-enforcer.d.ts.map +1 -0
- package/dist/setup.d.ts +27 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/skill-invoker.d.ts +30 -0
- package/dist/skill-invoker.d.ts.map +1 -0
- package/dist/skill-manifest.d.ts +30 -0
- package/dist/skill-manifest.d.ts.map +1 -0
- package/dist/skill-telemetry.d.ts +36 -0
- package/dist/skill-telemetry.d.ts.map +1 -0
- package/dist/skills-publish.d.ts +8 -0
- package/dist/skills-publish.d.ts.map +1 -0
- package/dist/state.d.ts +32 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/transport.d.ts +24 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/types.d.ts +421 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/workspace-handlers.d.ts +62 -0
- package/dist/workspace-handlers.d.ts.map +1 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP HTTP request handlers — routes /mcp requests to AgentVaultMcpServer.
|
|
3
|
+
*
|
|
4
|
+
* Supports both self-managed HTTP and OpenClaw managed routes.
|
|
5
|
+
*/
|
|
6
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
7
|
+
import type { AgentVaultMcpServer } from "./mcp-server.js";
|
|
8
|
+
/**
|
|
9
|
+
* Create an HTTP request handler for MCP routes.
|
|
10
|
+
*
|
|
11
|
+
* Routes:
|
|
12
|
+
* POST /mcp — MCP Streamable HTTP messages
|
|
13
|
+
* GET /mcp — MCP SSE stream (for server-initiated messages)
|
|
14
|
+
* DELETE /mcp — Close MCP session
|
|
15
|
+
*
|
|
16
|
+
* All other paths are passed through to the next handler.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createMcpHandler(mcpServer: AgentVaultMcpServer | null, basePath?: string): (req: IncomingMessage, res: ServerResponse, next?: () => void) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Build a status object with MCP info for the /status endpoint.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getMcpStatus(mcpServer: AgentVaultMcpServer | null): {
|
|
23
|
+
mcp_enabled: boolean;
|
|
24
|
+
mcp_skills_count: number;
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=mcp-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-handlers.d.ts","sourceRoot":"","sources":["../src/mcp-handlers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,mBAAmB,GAAG,IAAI,EACrC,QAAQ,GAAE,MAAe,GACxB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CA0BxE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,mBAAmB,GAAG,IAAI,GACpC;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE,CAQpD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentVaultMcpServer } from "./mcp-server.js";
|
|
2
|
+
/**
|
|
3
|
+
* Forward a JSON-RPC payload to the MCP server by creating synthetic
|
|
4
|
+
* HTTP request/response objects that the Streamable HTTP transport expects.
|
|
5
|
+
*
|
|
6
|
+
* Returns the MCP server's JSON-RPC response.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMcpProxyRequest(mcpServer: AgentVaultMcpServer, payload: unknown): Promise<unknown>;
|
|
9
|
+
//# sourceMappingURL=mcp-proxy-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-proxy-helpers.d.ts","sourceRoot":"","sources":["../src/mcp-proxy-helpers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,OAAO,CAAC,CAqDlB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
export interface SkillDefinition {
|
|
3
|
+
name: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
/** JSON Schema for the tool input (not Zod — raw JSON Schema object). */
|
|
7
|
+
inputSchema?: Record<string, unknown>;
|
|
8
|
+
/** Freeform instructions that are surfaced as an MCP prompt. */
|
|
9
|
+
instructions?: string;
|
|
10
|
+
/** SLA definition blob attached to the skill registry resource. */
|
|
11
|
+
slaDefinition?: Record<string, unknown>;
|
|
12
|
+
/** Tags for categorisation. */
|
|
13
|
+
tags?: string[];
|
|
14
|
+
/** Tools/capabilities explicitly allowed for this skill. */
|
|
15
|
+
toolsAllowed?: string[];
|
|
16
|
+
/** Tools/capabilities explicitly denied for this skill. */
|
|
17
|
+
toolsDenied?: string[];
|
|
18
|
+
/** JSON Schema for skill output validation. */
|
|
19
|
+
outputSchema?: Record<string, unknown>;
|
|
20
|
+
/** Model routing strategy: "auto" | "round-robin" | "least-latency". */
|
|
21
|
+
modelRouting?: string;
|
|
22
|
+
/** Allowed LLM models for this skill. */
|
|
23
|
+
allowedModels?: string[];
|
|
24
|
+
/** Default LLM model for this skill. */
|
|
25
|
+
defaultModel?: string;
|
|
26
|
+
/** AgentVault certification tier: "verified" | "certified" | "enterprise". */
|
|
27
|
+
certificationTier?: string;
|
|
28
|
+
/** Integrity configuration (algorithm, hashChain). */
|
|
29
|
+
integrity?: Record<string, unknown>;
|
|
30
|
+
/** Required policy presets (e.g., ["network: agentvault"]). */
|
|
31
|
+
requiredPolicies?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface McpServerOpts {
|
|
34
|
+
agentName: string;
|
|
35
|
+
apiUrl: string;
|
|
36
|
+
apiKey?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Called when an MCP client invokes a registered skill tool.
|
|
39
|
+
* Receives skill name, args, and the full skill definition (including instructions).
|
|
40
|
+
* Return value is serialised as JSON and sent back as tool output.
|
|
41
|
+
*/
|
|
42
|
+
onInvoke?: (skillName: string, args: Record<string, unknown>, skill: SkillDefinition) => Promise<unknown>;
|
|
43
|
+
}
|
|
44
|
+
export declare class AgentVaultMcpServer {
|
|
45
|
+
private server;
|
|
46
|
+
private skills;
|
|
47
|
+
private opts;
|
|
48
|
+
private initialized;
|
|
49
|
+
constructor(opts: McpServerOpts);
|
|
50
|
+
/**
|
|
51
|
+
* Register a skill that will be exposed as an MCP tool.
|
|
52
|
+
* Must be called *before* `initialize()`.
|
|
53
|
+
*/
|
|
54
|
+
registerSkill(skill: SkillDefinition): void;
|
|
55
|
+
/**
|
|
56
|
+
* Register all skills as MCP tools / resources / prompts.
|
|
57
|
+
* Called lazily on first request if not called explicitly.
|
|
58
|
+
*/
|
|
59
|
+
initialize(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Handle an incoming HTTP request to the /mcp endpoint.
|
|
62
|
+
*
|
|
63
|
+
* Supports the Streamable HTTP transport protocol:
|
|
64
|
+
* - POST for JSON-RPC messages
|
|
65
|
+
* - GET for SSE notification stream
|
|
66
|
+
* - DELETE for session close
|
|
67
|
+
*
|
|
68
|
+
* Each request gets a fresh stateless transport; after the response is
|
|
69
|
+
* flushed the transport + underlying protocol connection are torn down
|
|
70
|
+
* so the single McpServer instance is ready for the next caller.
|
|
71
|
+
*
|
|
72
|
+
* Local requests from 127.0.0.1/::1 bypass SPT validation (owner access).
|
|
73
|
+
*/
|
|
74
|
+
handleRequest(req: IncomingMessage, res: ServerResponse): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Register a single skill as an MCP tool.
|
|
77
|
+
*
|
|
78
|
+
* The MCP SDK's `tool()` overloads that accept a schema expect Zod types.
|
|
79
|
+
* Since our skill definitions use raw JSON Schema we register without
|
|
80
|
+
* schema validation (name + description + handler) and let the handler
|
|
81
|
+
* receive the raw args object.
|
|
82
|
+
*/
|
|
83
|
+
private registerToolForSkill;
|
|
84
|
+
/**
|
|
85
|
+
* Validate a Service Provider Token against the AgentVault backend.
|
|
86
|
+
*/
|
|
87
|
+
private validateSpt;
|
|
88
|
+
get skillCount(): number;
|
|
89
|
+
get isInitialized(): boolean;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAMjE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,gEAAgE;IAChE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAIhB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,2DAA2D;IAC3D,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,YAAY,CA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I,aAAa,IAAI,OAAO,CAE3B;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Save MLS group state to a per-group file.
|
|
3
|
+
* State is an opaque serialized string from MLSGroupManager.exportState().
|
|
4
|
+
*/
|
|
5
|
+
export declare function saveMlsState(dataDir: string, groupId: string, state: string): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Load MLS group state from a per-group file.
|
|
8
|
+
* Returns null if the file doesn't exist (first join or after re-join cleanup).
|
|
9
|
+
*/
|
|
10
|
+
export declare function loadMlsState(dataDir: string, groupId: string): Promise<string | null>;
|
|
11
|
+
/**
|
|
12
|
+
* Delete MLS group state file.
|
|
13
|
+
* Used when re-joining a group (old state is invalid after re-join).
|
|
14
|
+
*/
|
|
15
|
+
export declare function deleteMlsState(dataDir: string, groupId: string): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=mls-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mls-state.d.ts","sourceRoot":"","sources":["../src/mls-state.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOxB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw SDK compatibility layer — dynamic import wrappers with caching.
|
|
3
|
+
*
|
|
4
|
+
* Each wrapper attempts to import a deep SDK module at runtime. If the import
|
|
5
|
+
* fails (older gateway, missing SDK), the function returns a no-op result.
|
|
6
|
+
* Results are cached after the first attempt.
|
|
7
|
+
*
|
|
8
|
+
* IMPORTANT: All imports are guarded by try/catch — the plugin degrades
|
|
9
|
+
* gracefully on older OpenClaw versions.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentEventPayload, TranscriptUpdatePayload } from "./openclaw-types.js";
|
|
12
|
+
/**
|
|
13
|
+
* Request an immediate heartbeat wake from the OpenClaw gateway.
|
|
14
|
+
* Returns true if the heartbeat API was available and called, false otherwise.
|
|
15
|
+
* Never throws.
|
|
16
|
+
*/
|
|
17
|
+
export declare function requestHeartbeatNow(opts?: {
|
|
18
|
+
reason?: string;
|
|
19
|
+
}): Promise<boolean>;
|
|
20
|
+
type AgentEventCallback = (event: AgentEventPayload) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Subscribe to agent-level events (tool_use, reasoning_complete, error, etc.).
|
|
23
|
+
* Returns an unsubscribe function, or a no-op if the API is unavailable.
|
|
24
|
+
*/
|
|
25
|
+
export declare function onAgentEvent(callback: AgentEventCallback): Promise<() => void>;
|
|
26
|
+
type TranscriptCallback = (update: TranscriptUpdatePayload) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Subscribe to session transcript updates for behavioral analysis.
|
|
29
|
+
* Returns an unsubscribe function, or a no-op if the API is unavailable.
|
|
30
|
+
*/
|
|
31
|
+
export declare function onSessionTranscriptUpdate(callback: TranscriptCallback): Promise<() => void>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=openclaw-compat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw-compat.d.ts","sourceRoot":"","sources":["../src/openclaw-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAQtF;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAmBtF;AAMD,KAAK,kBAAkB,GAAG,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAG7D;;;GAGG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAkBpF;AAMD,KAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAC;AAGpE;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAkBjG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw channel plugin entry point.
|
|
3
|
+
*
|
|
4
|
+
* Intentionally thin — no heavy imports (libsodium etc.) at module load time.
|
|
5
|
+
* SecureChannel is dynamically imported inside gateway.startAccount (already async)
|
|
6
|
+
* so libsodium's top-level await never runs during plugin registration.
|
|
7
|
+
*
|
|
8
|
+
* Loaded by OpenClaw via the `openclaw.extensions` field in package.json.
|
|
9
|
+
*/
|
|
10
|
+
import type { OpenClawPluginApi } from "./openclaw-types.js";
|
|
11
|
+
/** Whether OpenClaw managed HTTP routes are active (vs self-managed server). */
|
|
12
|
+
export declare let isUsingManagedRoutes: boolean;
|
|
13
|
+
/** Extract @mention names from plaintext. Returns lowercased names. */
|
|
14
|
+
declare function _parseMentions(text: string): string[];
|
|
15
|
+
/** Determine whether this agent should process a room message based on @mentions and sender type.
|
|
16
|
+
*
|
|
17
|
+
* Loop prevention is handled by the rate limiter (_roomCanReply: 4 replies/60s
|
|
18
|
+
* with 2min cooldown), so we no longer gate on senderIsAgent. All messages
|
|
19
|
+
* are processed unless they @mention a *different* agent specifically.
|
|
20
|
+
*/
|
|
21
|
+
declare function _shouldProcessRoomMessage(plaintext: string, agentName: string, accountId: string, _senderIsAgent?: boolean): boolean;
|
|
22
|
+
/** Strip the matching @mention prefix from plaintext so the agent sees clean text. */
|
|
23
|
+
declare function _stripMentions(text: string, agentName: string, accountId: string): string;
|
|
24
|
+
export { _parseMentions, _shouldProcessRoomMessage, _stripMentions };
|
|
25
|
+
declare const _default: {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
description: string;
|
|
29
|
+
register(api: OpenClawPluginApi): void;
|
|
30
|
+
};
|
|
31
|
+
export default _default;
|
|
32
|
+
//# sourceMappingURL=openclaw-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw-entry.d.ts","sourceRoot":"","sources":["../src/openclaw-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,OAAO,KAAK,EACV,iBAAiB,EASlB,MAAM,qBAAqB,CAAC;AA4D7B,gFAAgF;AAChF,eAAO,IAAI,oBAAoB,SAAQ,CAAC;AA+CxC,uEAAuE;AACvE,iBAAS,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAS9C;AAED;;;;;GAKG;AACH,iBAAS,yBAAyB,CAChC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,cAAc,CAAC,EAAE,OAAO,GACvB,OAAO,CAgBT;AAED,sFAAsF;AACtF,iBAAS,cAAc,CACrB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAiBR;AAokCD,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,cAAc,EAAE,CAAC;;;;;kBAQrD,iBAAiB;;AAJjC,wBA+WE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentVault OpenClaw Channel Plugin
|
|
3
|
+
*
|
|
4
|
+
* Registers AgentVault as a first-class OpenClaw messaging channel.
|
|
5
|
+
* Messages from the AgentVault UI are decrypted and routed into the
|
|
6
|
+
* OpenClaw agent loop; agent replies are encrypted and sent back.
|
|
7
|
+
*
|
|
8
|
+
* Installation (one-time):
|
|
9
|
+
* npx @agentvault/agentvault setup --token=av_tok_...
|
|
10
|
+
*
|
|
11
|
+
* After setup, restart OpenClaw — no further configuration needed.
|
|
12
|
+
*/
|
|
13
|
+
import { SecureChannel } from "./channel.js";
|
|
14
|
+
import { listAccountIds, resolveAccount, type ResolvedAccount } from "./account-config.js";
|
|
15
|
+
import type { PluginRuntime, ChannelGatewayContext, ChannelOutboundPayloadContext } from "./openclaw-types.js";
|
|
16
|
+
export declare function setOcRuntime(runtime: PluginRuntime): void;
|
|
17
|
+
export declare function getActiveChannel(accountId?: string): SecureChannel | undefined;
|
|
18
|
+
export declare const agentVaultPlugin: {
|
|
19
|
+
id: string;
|
|
20
|
+
meta: {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
selectionLabel: string;
|
|
24
|
+
docsPath: string;
|
|
25
|
+
blurb: string;
|
|
26
|
+
aliases: string[];
|
|
27
|
+
};
|
|
28
|
+
capabilities: {
|
|
29
|
+
chatTypes: string[];
|
|
30
|
+
};
|
|
31
|
+
config: {
|
|
32
|
+
listAccountIds: typeof listAccountIds;
|
|
33
|
+
resolveAccount: typeof resolveAccount;
|
|
34
|
+
};
|
|
35
|
+
gateway: {
|
|
36
|
+
/** Health probe for `openclaw channels status --probe` */
|
|
37
|
+
probe: (ctx: any) => Promise<{
|
|
38
|
+
ok: boolean;
|
|
39
|
+
status: string;
|
|
40
|
+
error: string;
|
|
41
|
+
deviceId?: undefined;
|
|
42
|
+
sessions?: undefined;
|
|
43
|
+
} | {
|
|
44
|
+
ok: boolean;
|
|
45
|
+
status: import("./types.js").ChannelState;
|
|
46
|
+
deviceId: string | undefined;
|
|
47
|
+
sessions: number;
|
|
48
|
+
error?: undefined;
|
|
49
|
+
}>;
|
|
50
|
+
/** Status for `openclaw health --json` per-channel summary */
|
|
51
|
+
status: (ctx: any) => {
|
|
52
|
+
connected: boolean;
|
|
53
|
+
status: string;
|
|
54
|
+
deviceId?: undefined;
|
|
55
|
+
sessions?: undefined;
|
|
56
|
+
encrypted?: undefined;
|
|
57
|
+
} | {
|
|
58
|
+
connected: boolean;
|
|
59
|
+
status: import("./types.js").ChannelState;
|
|
60
|
+
deviceId: string | undefined;
|
|
61
|
+
sessions: number;
|
|
62
|
+
encrypted: boolean;
|
|
63
|
+
};
|
|
64
|
+
startAccount: (ctx: ChannelGatewayContext<ResolvedAccount>) => Promise<{
|
|
65
|
+
stop: () => Promise<void>;
|
|
66
|
+
}>;
|
|
67
|
+
};
|
|
68
|
+
outbound: {
|
|
69
|
+
deliveryMode: "direct";
|
|
70
|
+
targets: {
|
|
71
|
+
id: string;
|
|
72
|
+
label: string;
|
|
73
|
+
accountId: string;
|
|
74
|
+
}[];
|
|
75
|
+
sendText: ({ text, accountId, targetId, }: {
|
|
76
|
+
text: string;
|
|
77
|
+
accountId?: string;
|
|
78
|
+
targetId?: string;
|
|
79
|
+
}) => Promise<{
|
|
80
|
+
ok: boolean;
|
|
81
|
+
error?: string;
|
|
82
|
+
}>;
|
|
83
|
+
sendMedia: ({ text, mediaUrl, accountId, }: {
|
|
84
|
+
to: string;
|
|
85
|
+
text?: string;
|
|
86
|
+
mediaUrl: string;
|
|
87
|
+
accountId?: string;
|
|
88
|
+
}) => Promise<{
|
|
89
|
+
ok: boolean;
|
|
90
|
+
error?: string;
|
|
91
|
+
}>;
|
|
92
|
+
/** Rich payload delivery — OpenClaw v2026.3.2+ */
|
|
93
|
+
sendPayload: (ctx: ChannelOutboundPayloadContext) => Promise<{
|
|
94
|
+
ok: boolean;
|
|
95
|
+
error: string;
|
|
96
|
+
} | {
|
|
97
|
+
ok: boolean;
|
|
98
|
+
error?: undefined;
|
|
99
|
+
}>;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=openclaw-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw-plugin.d.ts","sourceRoot":"","sources":["../src/openclaw-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAI3F,OAAO,KAAK,EACV,aAAa,EACb,qBAAqB,EACrB,6BAA6B,EAC9B,MAAM,qBAAqB,CAAC;AAS7B,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAEzD;AAED,wBAAgB,gBAAgB,CAAC,SAAS,SAAY,GAAG,aAAa,GAAG,SAAS,CAEjF;AAMD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;QAkBzB,0DAA0D;qBACvC,GAAG;;;;;;;;;;;;;QAatB,8DAA8D;sBAChD,GAAG;;;;;;;;;;;;;4BAaS,qBAAqB,CAAC,eAAe,CAAC;;;;;;;;;;;mDA0F7D;YACD,IAAI,EAAE,MAAM,CAAC;YACb,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,KAAG,OAAO,CAAC;YAAE,EAAE,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;oDAkBzC;YACD,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,CAAC,EAAE,MAAM,CAAC;SACpB,KAAG,OAAO,CAAC;YAAE,EAAE,EAAE,OAAO,CAAC;YAAC,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QAe5C,kDAAkD;2BACzB,6BAA6B;;;;;;;;CA8BzD,CAAC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenClaw SDK type re-exports with inline fallback declarations.
|
|
3
|
+
*
|
|
4
|
+
* If `openclaw` is installed, we re-export the actual SDK types for full
|
|
5
|
+
* type-safety. Otherwise, we declare compatible fallback types so the
|
|
6
|
+
* plugin compiles standalone (e.g., during npm publish or in older envs).
|
|
7
|
+
*
|
|
8
|
+
* IMPORTANT: All runtime usage of OpenClaw APIs must still use feature
|
|
9
|
+
* detection (typeof checks, try/catch dynamic imports) — these types
|
|
10
|
+
* are purely for compile-time correctness.
|
|
11
|
+
*/
|
|
12
|
+
/** OpenClaw plugin API passed to register(). */
|
|
13
|
+
export interface OpenClawPluginApi {
|
|
14
|
+
runtime: PluginRuntime;
|
|
15
|
+
registerChannel(opts: {
|
|
16
|
+
plugin: unknown;
|
|
17
|
+
}): void;
|
|
18
|
+
registerTool?(opts: unknown, flags?: {
|
|
19
|
+
optional?: boolean;
|
|
20
|
+
}): void;
|
|
21
|
+
registerCommand?(opts: unknown): void;
|
|
22
|
+
registerHttpRoute?(opts: HttpRouteRegistration): void;
|
|
23
|
+
on?(event: string, handler: (...args: any[]) => void | Promise<void>): void;
|
|
24
|
+
}
|
|
25
|
+
/** OpenClaw runtime object — exposes channel, error, and other subsystems. */
|
|
26
|
+
export interface PluginRuntime {
|
|
27
|
+
channel: {
|
|
28
|
+
routing: {
|
|
29
|
+
resolveAgentRoute(opts: unknown): {
|
|
30
|
+
agentId: string;
|
|
31
|
+
sessionKey: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
session: {
|
|
35
|
+
resolveStorePath(store: unknown, opts: {
|
|
36
|
+
agentId: string;
|
|
37
|
+
}): string;
|
|
38
|
+
readSessionUpdatedAt(opts: {
|
|
39
|
+
storePath: string;
|
|
40
|
+
sessionKey: string;
|
|
41
|
+
}): number | undefined;
|
|
42
|
+
recordInboundSession(opts: unknown): Promise<void>;
|
|
43
|
+
};
|
|
44
|
+
reply: {
|
|
45
|
+
resolveEnvelopeFormatOptions(cfg: unknown): unknown;
|
|
46
|
+
formatAgentEnvelope(opts: unknown): string;
|
|
47
|
+
finalizeInboundContext(payload: Record<string, unknown>): Record<string, unknown>;
|
|
48
|
+
dispatchReplyWithBufferedBlockDispatcher(opts: unknown): Promise<void>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
error?(...args: unknown[]): void;
|
|
52
|
+
}
|
|
53
|
+
/** Context passed to gateway.startAccount(). */
|
|
54
|
+
export interface ChannelGatewayContext<TAccount = ResolvedAccountBase> {
|
|
55
|
+
account: TAccount;
|
|
56
|
+
cfg: unknown;
|
|
57
|
+
log?: {
|
|
58
|
+
info(msg: string): void;
|
|
59
|
+
warn?(msg: string): void;
|
|
60
|
+
error?(msg: string): void;
|
|
61
|
+
} | ((msg: string) => void);
|
|
62
|
+
abortSignal?: AbortSignal;
|
|
63
|
+
}
|
|
64
|
+
/** Minimal resolved account shape from OpenClaw config resolution. */
|
|
65
|
+
export interface ResolvedAccountBase {
|
|
66
|
+
accountId: string;
|
|
67
|
+
configured: boolean;
|
|
68
|
+
dataDir: string;
|
|
69
|
+
apiUrl: string;
|
|
70
|
+
agentName: string;
|
|
71
|
+
httpPort: number;
|
|
72
|
+
}
|
|
73
|
+
/** Context passed to outbound.sendPayload(). */
|
|
74
|
+
export interface ChannelOutboundPayloadContext {
|
|
75
|
+
payload: ReplyPayload;
|
|
76
|
+
sessionKey: string;
|
|
77
|
+
accountId?: string;
|
|
78
|
+
targetId?: string;
|
|
79
|
+
}
|
|
80
|
+
/** Structured reply payload from OpenClaw v2026.3.2+. */
|
|
81
|
+
export interface ReplyPayload {
|
|
82
|
+
text?: string;
|
|
83
|
+
mediaUrls?: string[];
|
|
84
|
+
isReasoning?: boolean;
|
|
85
|
+
suggestedActions?: SuggestedAction[];
|
|
86
|
+
metadata?: Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
/** Suggested action attached to a reply payload. */
|
|
89
|
+
export interface SuggestedAction {
|
|
90
|
+
label: string;
|
|
91
|
+
action: string;
|
|
92
|
+
payload?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
/** Registration options for registerHttpRoute(). */
|
|
95
|
+
export interface HttpRouteRegistration {
|
|
96
|
+
path: string;
|
|
97
|
+
method?: "GET" | "POST" | "PUT" | "DELETE";
|
|
98
|
+
handler: (req: HttpRouteRequest) => Promise<HttpRouteResponse> | HttpRouteResponse;
|
|
99
|
+
}
|
|
100
|
+
/** Simplified request object from OpenClaw managed HTTP routes. */
|
|
101
|
+
export interface HttpRouteRequest {
|
|
102
|
+
method: string;
|
|
103
|
+
path: string;
|
|
104
|
+
headers: Record<string, string>;
|
|
105
|
+
body?: unknown;
|
|
106
|
+
remoteAddress?: string;
|
|
107
|
+
}
|
|
108
|
+
/** Response object for OpenClaw managed HTTP routes. */
|
|
109
|
+
export interface HttpRouteResponse {
|
|
110
|
+
status: number;
|
|
111
|
+
headers?: Record<string, string>;
|
|
112
|
+
body: unknown;
|
|
113
|
+
}
|
|
114
|
+
/** Hook event for message_sent. */
|
|
115
|
+
export interface MessageSentEvent {
|
|
116
|
+
messageId: string;
|
|
117
|
+
channelId: string;
|
|
118
|
+
sessionKey: string;
|
|
119
|
+
timestamp: number;
|
|
120
|
+
deliveryStatus: "delivered" | "failed" | "pending";
|
|
121
|
+
}
|
|
122
|
+
/** Hook event for session_start. */
|
|
123
|
+
export interface SessionStartEvent {
|
|
124
|
+
sessionKey: string;
|
|
125
|
+
agentId: string;
|
|
126
|
+
timestamp: number;
|
|
127
|
+
}
|
|
128
|
+
/** Hook event for session_end. */
|
|
129
|
+
export interface SessionEndEvent {
|
|
130
|
+
sessionKey: string;
|
|
131
|
+
agentId: string;
|
|
132
|
+
timestamp: number;
|
|
133
|
+
reason?: string;
|
|
134
|
+
}
|
|
135
|
+
/** Agent event payload from openclaw/dist/plugin-sdk/infra/agent-events.js. */
|
|
136
|
+
export interface AgentEventPayload {
|
|
137
|
+
type: string;
|
|
138
|
+
agentId: string;
|
|
139
|
+
timestamp: number;
|
|
140
|
+
data?: Record<string, unknown>;
|
|
141
|
+
}
|
|
142
|
+
/** Transcript update payload from openclaw/dist/plugin-sdk/sessions/transcript-events.js. */
|
|
143
|
+
export interface TranscriptUpdatePayload {
|
|
144
|
+
sessionKey: string;
|
|
145
|
+
delta: string;
|
|
146
|
+
timestamp: number;
|
|
147
|
+
role?: "assistant" | "user" | "system";
|
|
148
|
+
}
|
|
149
|
+
/** Hook event for before_tool_call (OpenClaw v2026.3.28+). */
|
|
150
|
+
export interface BeforeToolCallEvent {
|
|
151
|
+
toolName: string;
|
|
152
|
+
args: Record<string, unknown>;
|
|
153
|
+
agentId: string;
|
|
154
|
+
sessionKey: string;
|
|
155
|
+
}
|
|
156
|
+
/** Result returned from before_tool_call hook. */
|
|
157
|
+
export interface BeforeToolCallResult {
|
|
158
|
+
/** If true, pause execution and ask owner for approval */
|
|
159
|
+
requireApproval?: boolean;
|
|
160
|
+
/** Reason shown in the approval overlay */
|
|
161
|
+
approvalReason?: string;
|
|
162
|
+
/** If true, block the tool call entirely */
|
|
163
|
+
blocked?: boolean;
|
|
164
|
+
/** Reason for blocking */
|
|
165
|
+
blockedReason?: string;
|
|
166
|
+
}
|
|
167
|
+
/** Hook event for before_dispatch (OpenClaw v2026.3.28+). */
|
|
168
|
+
export interface BeforeDispatchEvent {
|
|
169
|
+
channelId: string;
|
|
170
|
+
agentId: string;
|
|
171
|
+
sessionKey: string;
|
|
172
|
+
inbound: {
|
|
173
|
+
text: string;
|
|
174
|
+
sender?: string;
|
|
175
|
+
metadata?: Record<string, unknown>;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/** Hook handler map type. */
|
|
179
|
+
export type PluginHookHandlerMap = {
|
|
180
|
+
message_sent?: (event: MessageSentEvent) => void | Promise<void>;
|
|
181
|
+
session_start?: (event: SessionStartEvent) => void | Promise<void>;
|
|
182
|
+
session_end?: (event: SessionEndEvent) => void | Promise<void>;
|
|
183
|
+
before_tool_call?: (event: BeforeToolCallEvent) => BeforeToolCallResult | Promise<BeforeToolCallResult>;
|
|
184
|
+
before_dispatch?: (event: BeforeDispatchEvent) => void | Promise<void>;
|
|
185
|
+
};
|
|
186
|
+
//# sourceMappingURL=openclaw-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw-types.d.ts","sourceRoot":"","sources":["../src/openclaw-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AASH,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,aAAa,CAAC;IACvB,eAAe,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD,YAAY,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACnE,eAAe,CAAC,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACtC,iBAAiB,CAAC,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACtD,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC7E;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE;QACP,OAAO,EAAE;YAAE,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG;gBAAE,OAAO,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE,CAAA;SAAE,CAAC;QACvF,OAAO,EAAE;YACP,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE;gBAAE,OAAO,EAAE,MAAM,CAAA;aAAE,GAAG,MAAM,CAAC;YACpE,oBAAoB,CAAC,IAAI,EAAE;gBAAE,SAAS,EAAE,MAAM,CAAC;gBAAC,UAAU,EAAE,MAAM,CAAA;aAAE,GAAG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AA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0BAA0B;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,6DAA6D;AAC7D,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACpC,CAAC;CACH;AAED,6BAA6B;AAC7B,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/D,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACxG,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy Enforcer — validates skill invocations against the 5-stage policy pipeline.
|
|
3
|
+
*
|
|
4
|
+
* Pipeline stages:
|
|
5
|
+
* 1. Parse — extract action intent from request
|
|
6
|
+
* 2. Validate — schema validation of policy rules
|
|
7
|
+
* 3. Enforce — apply tool, model, and rate policies
|
|
8
|
+
* 4. Log — emit av.policy.evaluate telemetry span
|
|
9
|
+
* 5. Report — aggregate policy metrics
|
|
10
|
+
*
|
|
11
|
+
* Integration points:
|
|
12
|
+
* - AgentVaultMcpServer wraps tool handlers with enforce()
|
|
13
|
+
* - Channel.deliver() checks before forwarding sensitive messages
|
|
14
|
+
* - agentvault_check_policy MCP tool calls evaluate()
|
|
15
|
+
*/
|
|
16
|
+
import type { SkillDefinition } from "./mcp-server.js";
|
|
17
|
+
import { type TelemetrySpan } from "@agentvault/crypto";
|
|
18
|
+
export interface PolicyContext {
|
|
19
|
+
skillName: string;
|
|
20
|
+
toolName?: string;
|
|
21
|
+
model?: string;
|
|
22
|
+
args?: Record<string, unknown>;
|
|
23
|
+
agentId?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface PolicyResult {
|
|
26
|
+
allowed: boolean;
|
|
27
|
+
violations: PolicyViolation[];
|
|
28
|
+
stage: "parse" | "validate" | "enforce" | "log" | "report";
|
|
29
|
+
}
|
|
30
|
+
export interface PolicyViolation {
|
|
31
|
+
ruleId: string;
|
|
32
|
+
scope: "tool" | "model" | "rate" | "network" | "custom";
|
|
33
|
+
action: "block" | "warn" | "log";
|
|
34
|
+
type: string;
|
|
35
|
+
message: string;
|
|
36
|
+
details?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface PolicyMetrics {
|
|
39
|
+
totalEvaluations: number;
|
|
40
|
+
totalBlocks: number;
|
|
41
|
+
totalWarnings: number;
|
|
42
|
+
bySkill: Record<string, {
|
|
43
|
+
evaluations: number;
|
|
44
|
+
blocks: number;
|
|
45
|
+
}>;
|
|
46
|
+
byRule: Record<string, number>;
|
|
47
|
+
}
|
|
48
|
+
export declare class PolicyEnforcer {
|
|
49
|
+
private skills;
|
|
50
|
+
private metrics;
|
|
51
|
+
private spanBuffer;
|
|
52
|
+
/**
|
|
53
|
+
* Register a skill definition for policy evaluation.
|
|
54
|
+
*/
|
|
55
|
+
registerSkill(skill: SkillDefinition): void;
|
|
56
|
+
/**
|
|
57
|
+
* Full 5-stage policy pipeline evaluation.
|
|
58
|
+
*/
|
|
59
|
+
evaluate(ctx: PolicyContext): PolicyResult;
|
|
60
|
+
/**
|
|
61
|
+
* Wrap an MCP tool handler with policy enforcement.
|
|
62
|
+
* Returns a function that checks policy before calling the original handler.
|
|
63
|
+
*/
|
|
64
|
+
wrapHandler(skillName: string, handler: (args: Record<string, unknown>) => Promise<unknown>): (args: Record<string, unknown>) => Promise<unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* Get accumulated policy metrics.
|
|
67
|
+
*/
|
|
68
|
+
getMetrics(): PolicyMetrics;
|
|
69
|
+
/**
|
|
70
|
+
* Drain buffered telemetry spans.
|
|
71
|
+
*/
|
|
72
|
+
drainSpans(): TelemetrySpan[];
|
|
73
|
+
/**
|
|
74
|
+
* Reset all metrics (for testing).
|
|
75
|
+
*/
|
|
76
|
+
resetMetrics(): void;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=policy-enforcer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-enforcer.d.ts","sourceRoot":"","sources":["../src/policy-enforcer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAM5B,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,eAAe,EAAE,CAAC;I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;OAEG;IACH,UAAU,IAAI,aAAa,EAAE;IAM7B;;OAEG;IACH,YAAY,IAAI,IAAI;CASrB"}
|
package/dist/setup.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentVault one-time setup command.
|
|
3
|
+
*
|
|
4
|
+
* Runs enrollment + waits for owner approval + persists state,
|
|
5
|
+
* then auto-registers the agentvault channel in openclaw config.
|
|
6
|
+
*
|
|
7
|
+
* Usage: npx @agentvault/agentvault setup --token=av_tok_...
|
|
8
|
+
*/
|
|
9
|
+
export declare function runSetupCommand(options: {
|
|
10
|
+
token: string;
|
|
11
|
+
name: string;
|
|
12
|
+
apiUrl: string;
|
|
13
|
+
dataDir: string;
|
|
14
|
+
accountId?: string;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* Install/update the plugin in OpenClaw's extensions directory.
|
|
19
|
+
* Returns true if the plugin is installed (or was already up-to-date).
|
|
20
|
+
*/
|
|
21
|
+
export declare function installPlugin(env: NodeJS.ProcessEnv): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Configure pm2 to manage the OpenClaw gateway process.
|
|
24
|
+
* Returns true if pm2 was configured (or already configured).
|
|
25
|
+
*/
|
|
26
|
+
export declare function configurePm2(env: NodeJS.ProcessEnv): boolean;
|
|
27
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0ShB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAqC7D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CA4D5D"}
|