@agentvault/agentvault 0.14.1 → 0.14.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/channel.d.ts.map +1 -1
- package/dist/cli.js +368 -5
- package/dist/cli.js.map +4 -4
- package/dist/create-agent.d.ts +28 -0
- package/dist/create-agent.d.ts.map +1 -0
- package/dist/gateway-send.d.ts +27 -0
- package/dist/gateway-send.d.ts.map +1 -1
- package/dist/http-handlers.d.ts +4 -0
- package/dist/http-handlers.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +76 -1
- package/dist/index.js.map +2 -2
- package/dist/openclaw-entry.d.ts.map +1 -1
- package/dist/openclaw-entry.js +39 -0
- package/dist/openclaw-entry.js.map +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentVault "create" command — spin up a brand new OpenClaw peer agent.
|
|
3
|
+
*
|
|
4
|
+
* Ports the logic from ~/.openclaw/workspace/scripts/create-agent.sh into
|
|
5
|
+
* TypeScript, eliminating the jq dependency.
|
|
6
|
+
*
|
|
7
|
+
* Usage: npx @agentvault/agentvault create <name> --token=av_tok_...
|
|
8
|
+
*/
|
|
9
|
+
export interface CreateAgentOptions {
|
|
10
|
+
name: string;
|
|
11
|
+
token: string;
|
|
12
|
+
port?: number;
|
|
13
|
+
apiUrl: string;
|
|
14
|
+
force?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Resolve the OpenClaw home directory (~/.openclaw) */
|
|
17
|
+
export declare function openclawHome(): string;
|
|
18
|
+
/** Parse openclaw.json and return its contents. */
|
|
19
|
+
export declare function readOpenClawConfig(home: string): any;
|
|
20
|
+
/**
|
|
21
|
+
* Scan all accounts in openclaw.json for httpPort values and return next free port.
|
|
22
|
+
* Minimum port is `startPort` (default 18790).
|
|
23
|
+
*/
|
|
24
|
+
export declare function findNextPort(config: any, startPort?: number): number;
|
|
25
|
+
/** Generate workspace template files for a new agent. */
|
|
26
|
+
export declare function generateWorkspaceFiles(name: string): Record<string, string>;
|
|
27
|
+
export declare function runCreateCommand(options: CreateAgentOptions): Promise<void>;
|
|
28
|
+
//# sourceMappingURL=create-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-agent.d.ts","sourceRoot":"","sources":["../src/create-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAID,wDAAwD;AACxD,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,mDAAmD;AACnD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAIpD;AAUD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,SAAS,SAAQ,GAAG,MAAM,CAwBnE;AAgBD,yDAAyD;AACzD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA8C3E;AAID,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6KjF"}
|
package/dist/gateway-send.d.ts
CHANGED
|
@@ -29,6 +29,33 @@ export interface GatewayStatusResult {
|
|
|
29
29
|
* Never throws — returns `{ ok: false, error }` on failure.
|
|
30
30
|
*/
|
|
31
31
|
export declare function sendToOwner(text: string, options?: GatewaySendOptions): Promise<GatewaySendResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Send a decision request to the agent's owner via the gateway HTTP server.
|
|
34
|
+
* Never throws — returns `{ ok: false, error }` on failure.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sendDecisionToOwner(request: {
|
|
37
|
+
title: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
options: Array<{
|
|
40
|
+
option_id: string;
|
|
41
|
+
label: string;
|
|
42
|
+
risk_level?: string;
|
|
43
|
+
is_default?: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
context_refs?: Array<{
|
|
46
|
+
type: string;
|
|
47
|
+
uri: string;
|
|
48
|
+
label: string;
|
|
49
|
+
}>;
|
|
50
|
+
deadline?: string;
|
|
51
|
+
auto_action?: {
|
|
52
|
+
option_id: string;
|
|
53
|
+
trigger: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
};
|
|
56
|
+
}, options?: GatewaySendOptions): Promise<GatewaySendResult & {
|
|
57
|
+
decision_id?: string;
|
|
58
|
+
}>;
|
|
32
59
|
/**
|
|
33
60
|
* Check gateway health / status.
|
|
34
61
|
* Never throws — returns `{ ok: false, error }` on failure.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway-send.d.ts","sourceRoot":"","sources":["../src/gateway-send.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA4BD;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,IAAI,E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EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5E,EACD,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,iBAAiB,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CA8BvD;AAED;;;GAGG;AACH,wBAAsB,YAAY,CAChC,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,mBAAmB,CAAC,CAoB9B"}
|
package/dist/http-handlers.d.ts
CHANGED
|
@@ -21,6 +21,10 @@ export declare function handleSendRequest(parsed: Record<string, unknown>, chann
|
|
|
21
21
|
* Handle POST /action — send an action confirmation.
|
|
22
22
|
*/
|
|
23
23
|
export declare function handleActionRequest(parsed: Record<string, unknown>, channel: SecureChannel): Promise<HandlerResult>;
|
|
24
|
+
/**
|
|
25
|
+
* Handle POST /decision — send a decision request to the owner.
|
|
26
|
+
*/
|
|
27
|
+
export declare function handleDecisionRequest(parsed: Record<string, unknown>, channel: SecureChannel): Promise<HandlerResult>;
|
|
24
28
|
/**
|
|
25
29
|
* Handle GET /status — return channel health info.
|
|
26
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-handlers.d.ts","sourceRoot":"","sources":["../src/http-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC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
|
@@ -3,11 +3,11 @@ export type { SecureChannelConfig, ChannelState, MessageMetadata, AttachmentData
|
|
|
3
3
|
export { listAccountIds, resolveAccount } from "./account-config.js";
|
|
4
4
|
export type { ResolvedAccount } from "./account-config.js";
|
|
5
5
|
export { agentVaultPlugin, setOcRuntime, getActiveChannel } from "./openclaw-plugin.js";
|
|
6
|
-
export { sendToOwner, checkGateway } from "./gateway-send.js";
|
|
6
|
+
export { sendToOwner, sendDecisionToOwner, checkGateway } from "./gateway-send.js";
|
|
7
7
|
export type { GatewaySendOptions, GatewaySendResult, GatewayStatusResult, } from "./gateway-send.js";
|
|
8
8
|
export { requestHeartbeatNow, onAgentEvent, onSessionTranscriptUpdate } from "./openclaw-compat.js";
|
|
9
9
|
export { isUsingManagedRoutes } from "./openclaw-entry.js";
|
|
10
|
-
export { handleSendRequest, handleActionRequest, handleStatusRequest } from "./http-handlers.js";
|
|
10
|
+
export { handleSendRequest, handleActionRequest, handleDecisionRequest, handleStatusRequest } from "./http-handlers.js";
|
|
11
11
|
export type { HandlerResult } from "./http-handlers.js";
|
|
12
12
|
export type { OpenClawPluginApi, PluginRuntime, ChannelGatewayContext, ChannelOutboundPayloadContext, ReplyPayload, MessageSentEvent, SessionStartEvent, SessionEndEvent, AgentEventPayload, TranscriptUpdatePayload, } from "./openclaw-types.js";
|
|
13
13
|
export declare const VERSION = "0.14.1";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EACV,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,YAAY,EACZ,WAAW,EACX,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,WAAW,EACX,QAAQ,EACR,cAAc,E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qBAAqB,CAAC;AAG3D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACxH,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,qBAAqB,EACrB,6BAA6B,EAC7B,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,OAAO,WAAW,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -45880,6 +45880,7 @@ var init_openclaw_compat = __esm({
|
|
|
45880
45880
|
var http_handlers_exports = {};
|
|
45881
45881
|
__export(http_handlers_exports, {
|
|
45882
45882
|
handleActionRequest: () => handleActionRequest,
|
|
45883
|
+
handleDecisionRequest: () => handleDecisionRequest,
|
|
45883
45884
|
handleSendRequest: () => handleSendRequest,
|
|
45884
45885
|
handleStatusRequest: () => handleStatusRequest
|
|
45885
45886
|
});
|
|
@@ -45933,6 +45934,34 @@ async function handleActionRequest(parsed, channel) {
|
|
|
45933
45934
|
return { status: 500, body: { ok: false, error: String(err) } };
|
|
45934
45935
|
}
|
|
45935
45936
|
}
|
|
45937
|
+
async function handleDecisionRequest(parsed, channel) {
|
|
45938
|
+
const title = parsed.title;
|
|
45939
|
+
if (!title || typeof title !== "string") {
|
|
45940
|
+
return { status: 400, body: { ok: false, error: "Missing 'title' field" } };
|
|
45941
|
+
}
|
|
45942
|
+
const options = parsed.options;
|
|
45943
|
+
if (!Array.isArray(options) || options.length < 2) {
|
|
45944
|
+
return { status: 400, body: { ok: false, error: "'options' must be an array with at least 2 items" } };
|
|
45945
|
+
}
|
|
45946
|
+
for (const opt of options) {
|
|
45947
|
+
if (!opt || typeof opt !== "object" || !opt.option_id || !opt.label) {
|
|
45948
|
+
return { status: 400, body: { ok: false, error: "Each option must have 'option_id' and 'label'" } };
|
|
45949
|
+
}
|
|
45950
|
+
}
|
|
45951
|
+
try {
|
|
45952
|
+
const decision_id = await channel.sendDecisionRequest({
|
|
45953
|
+
title,
|
|
45954
|
+
description: parsed.description,
|
|
45955
|
+
options,
|
|
45956
|
+
context_refs: parsed.context_refs,
|
|
45957
|
+
deadline: parsed.deadline,
|
|
45958
|
+
auto_action: parsed.auto_action
|
|
45959
|
+
});
|
|
45960
|
+
return { status: 200, body: { ok: true, decision_id } };
|
|
45961
|
+
} catch (err) {
|
|
45962
|
+
return { status: 500, body: { ok: false, error: String(err) } };
|
|
45963
|
+
}
|
|
45964
|
+
}
|
|
45936
45965
|
function handleStatusRequest(channel) {
|
|
45937
45966
|
return {
|
|
45938
45967
|
status: 200,
|
|
@@ -46737,6 +46766,22 @@ var init_channel = __esm({
|
|
|
46737
46766
|
res.end(JSON.stringify({ ok: false, error: String(err) }));
|
|
46738
46767
|
}
|
|
46739
46768
|
});
|
|
46769
|
+
} else if (req.method === "POST" && req.url === "/decision") {
|
|
46770
|
+
let body = "";
|
|
46771
|
+
req.on("data", (chunk) => {
|
|
46772
|
+
body += chunk.toString();
|
|
46773
|
+
});
|
|
46774
|
+
req.on("end", async () => {
|
|
46775
|
+
try {
|
|
46776
|
+
const parsed = JSON.parse(body);
|
|
46777
|
+
const result = await handlers.handleDecisionRequest(parsed, this);
|
|
46778
|
+
res.writeHead(result.status, { "Content-Type": "application/json" });
|
|
46779
|
+
res.end(JSON.stringify(result.body));
|
|
46780
|
+
} catch (err) {
|
|
46781
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
46782
|
+
res.end(JSON.stringify({ ok: false, error: String(err) }));
|
|
46783
|
+
}
|
|
46784
|
+
});
|
|
46740
46785
|
} else if (req.method === "POST" && req.url === "/action") {
|
|
46741
46786
|
let body = "";
|
|
46742
46787
|
req.on("data", (chunk) => {
|
|
@@ -46759,7 +46804,7 @@ var init_channel = __esm({
|
|
|
46759
46804
|
res.end(JSON.stringify(result.body));
|
|
46760
46805
|
} else {
|
|
46761
46806
|
res.writeHead(404, { "Content-Type": "application/json" });
|
|
46762
|
-
res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /action, or GET /status" }));
|
|
46807
|
+
res.end(JSON.stringify({ ok: false, error: "Not found. Use POST /send, POST /decision, POST /action, or GET /status" }));
|
|
46763
46808
|
}
|
|
46764
46809
|
});
|
|
46765
46810
|
this._httpServer.listen(port, "127.0.0.1", () => {
|
|
@@ -49029,6 +49074,34 @@ async function sendToOwner(text, options) {
|
|
|
49029
49074
|
return { ok: false, error: friendlyError(err) };
|
|
49030
49075
|
}
|
|
49031
49076
|
}
|
|
49077
|
+
async function sendDecisionToOwner(request, options) {
|
|
49078
|
+
if (!request.title || typeof request.title !== "string") {
|
|
49079
|
+
return { ok: false, error: "Decision title must be a non-empty string" };
|
|
49080
|
+
}
|
|
49081
|
+
if (!Array.isArray(request.options) || request.options.length < 2) {
|
|
49082
|
+
return { ok: false, error: "Decision must have at least 2 options" };
|
|
49083
|
+
}
|
|
49084
|
+
requestHeartbeatNow({ reason: "proactive-decision" }).catch(() => {
|
|
49085
|
+
});
|
|
49086
|
+
try {
|
|
49087
|
+
const base = resolveBaseUrl(options);
|
|
49088
|
+
const path = process.env.OPENCLAW_GATEWAY_URL ? "/agentvault/decision" : "/decision";
|
|
49089
|
+
const res = await fetch(`${base}${path}`, {
|
|
49090
|
+
method: "POST",
|
|
49091
|
+
headers: { "Content-Type": "application/json" },
|
|
49092
|
+
body: JSON.stringify(request),
|
|
49093
|
+
signal: options?.signal
|
|
49094
|
+
});
|
|
49095
|
+
if (!res.ok) {
|
|
49096
|
+
const body = await res.text().catch(() => "");
|
|
49097
|
+
return { ok: false, error: `HTTP ${res.status}${body ? `: ${body}` : ""}` };
|
|
49098
|
+
}
|
|
49099
|
+
const data = await res.json();
|
|
49100
|
+
return { ok: true, decision_id: data.decision_id };
|
|
49101
|
+
} catch (err) {
|
|
49102
|
+
return { ok: false, error: friendlyError(err) };
|
|
49103
|
+
}
|
|
49104
|
+
}
|
|
49032
49105
|
async function checkGateway(options) {
|
|
49033
49106
|
try {
|
|
49034
49107
|
const base = resolveBaseUrl(options);
|
|
@@ -49100,6 +49173,7 @@ export {
|
|
|
49100
49173
|
checkGateway,
|
|
49101
49174
|
getActiveChannel,
|
|
49102
49175
|
handleActionRequest,
|
|
49176
|
+
handleDecisionRequest,
|
|
49103
49177
|
handleSendRequest,
|
|
49104
49178
|
handleStatusRequest,
|
|
49105
49179
|
isUsingManagedRoutes,
|
|
@@ -49108,6 +49182,7 @@ export {
|
|
|
49108
49182
|
onSessionTranscriptUpdate,
|
|
49109
49183
|
requestHeartbeatNow,
|
|
49110
49184
|
resolveAccount,
|
|
49185
|
+
sendDecisionToOwner,
|
|
49111
49186
|
sendToOwner,
|
|
49112
49187
|
setOcRuntime
|
|
49113
49188
|
};
|