@xpr-agents/openclaw 0.2.15 → 0.3.0
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/cli-session.d.ts +60 -0
- package/dist/cli-session.d.ts.map +1 -0
- package/dist/cli-session.js +89 -0
- package/dist/cli-session.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -3
- package/dist/index.js.map +1 -1
- package/dist/proton-cli.d.ts +73 -0
- package/dist/proton-cli.d.ts.map +1 -0
- package/dist/proton-cli.js +221 -0
- package/dist/proton-cli.js.map +1 -0
- package/dist/session.d.ts +18 -6
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +20 -22
- package/dist/session.js.map +1 -1
- package/dist/tools/a2a.d.ts.map +1 -1
- package/dist/tools/a2a.js +24 -2
- package/dist/tools/a2a.js.map +1 -1
- package/dist/tools/agent.js +6 -6
- package/dist/tools/agent.js.map +1 -1
- package/dist/tools/escrow.js +14 -14
- package/dist/tools/escrow.js.map +1 -1
- package/dist/tools/feedback.js +3 -3
- package/dist/tools/feedback.js.map +1 -1
- package/dist/tools/validation.js +4 -4
- package/dist/tools/validation.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI-backed session factories.
|
|
3
|
+
*
|
|
4
|
+
* Provides two shapes from the same underlying proton CLI wrapper:
|
|
5
|
+
*
|
|
6
|
+
* 1. createCliSession() → ProtonSession (SDK shape)
|
|
7
|
+
* Used by openclaw/src/session.ts and downstream tools/registries.
|
|
8
|
+
* Preserves the SDK's public ProtonSession interface — no changes to
|
|
9
|
+
* sdk/src/types.ts, no breaking changes for SDK consumers.
|
|
10
|
+
*
|
|
11
|
+
* 2. createCliApi() → eosjs-Api lookalike + auth metadata
|
|
12
|
+
* Used by skill files (defi, nft, lending, governance, xmd) that
|
|
13
|
+
* previously called `await session.api.transact({actions}, options)`.
|
|
14
|
+
* The .transact() signature matches eosjs so handler bodies need no
|
|
15
|
+
* changes — only the session factory swaps.
|
|
16
|
+
*
|
|
17
|
+
* Both shapes route every signed action through `proton transaction:push`.
|
|
18
|
+
* Neither holds, reads, or transmits private key material.
|
|
19
|
+
*/
|
|
20
|
+
import { JsonRpc } from '@proton/js';
|
|
21
|
+
import type { ProtonSession, TransactArgs, TransactionResult } from '@xpr-agents/sdk';
|
|
22
|
+
export interface CliSessionOptions {
|
|
23
|
+
account: string;
|
|
24
|
+
permission?: string;
|
|
25
|
+
rpcEndpoint?: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a ProtonSession (SDK shape) backed by the proton CLI.
|
|
29
|
+
* No private key required — the CLI signs internally via its keychain.
|
|
30
|
+
*/
|
|
31
|
+
export declare function createCliSession(opts: CliSessionOptions): {
|
|
32
|
+
rpc: JsonRpc;
|
|
33
|
+
session: ProtonSession;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Lightweight Api lookalike returned by createCliApi(). Matches the subset
|
|
37
|
+
* of eosjs Api that the 5 signing skills use.
|
|
38
|
+
*/
|
|
39
|
+
export interface CliApi {
|
|
40
|
+
transact(tx: {
|
|
41
|
+
actions: TransactArgs['actions'];
|
|
42
|
+
}, options?: {
|
|
43
|
+
blocksBehind?: number;
|
|
44
|
+
expireSeconds?: number;
|
|
45
|
+
}): Promise<TransactionResult>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create an eosjs-Api lookalike backed by the proton CLI.
|
|
49
|
+
* Drop-in replacement for the `api` returned by skill `getSession()`
|
|
50
|
+
* functions that used to construct `new Api({ rpc, signatureProvider })`.
|
|
51
|
+
*
|
|
52
|
+
* The blocksBehind/expireSeconds options are accepted but ignored —
|
|
53
|
+
* proton CLI manages tx headers internally. Skill code remains unchanged.
|
|
54
|
+
*/
|
|
55
|
+
export declare function createCliApi(opts: CliSessionOptions): {
|
|
56
|
+
api: CliApi;
|
|
57
|
+
account: string;
|
|
58
|
+
permission: string;
|
|
59
|
+
};
|
|
60
|
+
//# sourceMappingURL=cli-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-session.d.ts","sourceRoot":"","sources":["../src/cli-session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKtF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA6BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG;IACzD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,aAAa,CAAC;CACxB,CAkBA;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,CACN,EAAE,EAAE;QAAE,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAA;KAAE,EACxC,OAAO,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,GAC1D,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAYA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI-backed session factories.
|
|
4
|
+
*
|
|
5
|
+
* Provides two shapes from the same underlying proton CLI wrapper:
|
|
6
|
+
*
|
|
7
|
+
* 1. createCliSession() → ProtonSession (SDK shape)
|
|
8
|
+
* Used by openclaw/src/session.ts and downstream tools/registries.
|
|
9
|
+
* Preserves the SDK's public ProtonSession interface — no changes to
|
|
10
|
+
* sdk/src/types.ts, no breaking changes for SDK consumers.
|
|
11
|
+
*
|
|
12
|
+
* 2. createCliApi() → eosjs-Api lookalike + auth metadata
|
|
13
|
+
* Used by skill files (defi, nft, lending, governance, xmd) that
|
|
14
|
+
* previously called `await session.api.transact({actions}, options)`.
|
|
15
|
+
* The .transact() signature matches eosjs so handler bodies need no
|
|
16
|
+
* changes — only the session factory swaps.
|
|
17
|
+
*
|
|
18
|
+
* Both shapes route every signed action through `proton transaction:push`.
|
|
19
|
+
* Neither holds, reads, or transmits private key material.
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.createCliSession = createCliSession;
|
|
23
|
+
exports.createCliApi = createCliApi;
|
|
24
|
+
const js_1 = require("@proton/js");
|
|
25
|
+
const proton_cli_1 = require("./proton-cli");
|
|
26
|
+
const DEFAULT_PERMISSION = 'active';
|
|
27
|
+
/**
|
|
28
|
+
* Result of CLI signing, normalised to the SDK's TransactionResult shape.
|
|
29
|
+
* `processed` is best-effort: proton CLI returns the full Hyperion-style
|
|
30
|
+
* trace, but we only surface block_num and block_time for SDK compatibility.
|
|
31
|
+
*/
|
|
32
|
+
function normaliseResult(result) {
|
|
33
|
+
const processed = result.processed;
|
|
34
|
+
return {
|
|
35
|
+
transaction_id: result.transaction_id,
|
|
36
|
+
processed: {
|
|
37
|
+
block_num: processed?.block_num ?? processed?.receipt?.block_num ?? 0,
|
|
38
|
+
block_time: processed?.block_time ?? '',
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function toCliActions(actions) {
|
|
43
|
+
return actions.map((a) => ({
|
|
44
|
+
account: a.account,
|
|
45
|
+
name: a.name,
|
|
46
|
+
authorization: a.authorization,
|
|
47
|
+
data: a.data,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a ProtonSession (SDK shape) backed by the proton CLI.
|
|
52
|
+
* No private key required — the CLI signs internally via its keychain.
|
|
53
|
+
*/
|
|
54
|
+
function createCliSession(opts) {
|
|
55
|
+
const account = opts.account;
|
|
56
|
+
const permission = opts.permission ?? DEFAULT_PERMISSION;
|
|
57
|
+
const rpcEndpoint = opts.rpcEndpoint ?? 'https://proton.greymass.com';
|
|
58
|
+
const rpc = new js_1.JsonRpc(rpcEndpoint);
|
|
59
|
+
const session = {
|
|
60
|
+
auth: { actor: account, permission },
|
|
61
|
+
link: {
|
|
62
|
+
transact: async (args) => {
|
|
63
|
+
const result = await (0, proton_cli_1.execTransactionPush)({ actions: toCliActions(args.actions) });
|
|
64
|
+
return normaliseResult(result);
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
return { rpc, session };
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create an eosjs-Api lookalike backed by the proton CLI.
|
|
72
|
+
* Drop-in replacement for the `api` returned by skill `getSession()`
|
|
73
|
+
* functions that used to construct `new Api({ rpc, signatureProvider })`.
|
|
74
|
+
*
|
|
75
|
+
* The blocksBehind/expireSeconds options are accepted but ignored —
|
|
76
|
+
* proton CLI manages tx headers internally. Skill code remains unchanged.
|
|
77
|
+
*/
|
|
78
|
+
function createCliApi(opts) {
|
|
79
|
+
const account = opts.account;
|
|
80
|
+
const permission = opts.permission ?? DEFAULT_PERMISSION;
|
|
81
|
+
const api = {
|
|
82
|
+
transact: async (tx, _options) => {
|
|
83
|
+
const result = await (0, proton_cli_1.execTransactionPush)({ actions: toCliActions(tx.actions) });
|
|
84
|
+
return normaliseResult(result);
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
return { api, account, permission };
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=cli-session.js.map
|
|
@@ -0,0 +1 @@
|
|
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AAkB,EAA8B,EAAE;gBACjE,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAmB,EAAC,EAAE,OAAO,EAAE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBAClF,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC;SACF;KACF,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC1B,CAAC;AAaD;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,IAAuB;IAKlD,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC7B,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,kBAAkB,CAAC;IAEzD,MAAM,GAAG,GAAW;QAClB,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE;YAC/B,MAAM,MAAM,GAAG,MAAM,IAAA,gCAAmB,EAAC,EAAE,OAAO,EAAE,YAAY,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAChF,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;KACF,CAAC;IAEF,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;AACtC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
import type { PluginApi } from './types';
|
|
14
14
|
export type { SkillManifest, SkillApi, LoadedSkill } from './skill-types';
|
|
15
15
|
export type { ToolDefinition, PluginApi } from './types';
|
|
16
|
+
export { createCliSession, createCliApi } from './cli-session';
|
|
17
|
+
export type { CliSessionOptions, CliApi } from './cli-session';
|
|
18
|
+
export { execAction, execTransactionPush, getTableRows, checkProtonCli, checkKeychainPopulated, ProtonCliError, } from './proton-cli';
|
|
19
|
+
export type { CliErrorCode, CliAction, CliTransactionResult, TableQueryOpts } from './proton-cli';
|
|
16
20
|
/**
|
|
17
21
|
* OpenClaw plugin API shape (real runtime API).
|
|
18
22
|
* Plugins receive this from the OpenClaw gateway.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,OAAO,KAAK,EAAE,SAAS,EAAgC,MAAM,SAAS,CAAC;AAGvE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1E,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,OAAO,KAAK,EAAE,SAAS,EAAgC,MAAM,SAAS,CAAC;AAGvE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1E,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAIzD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAElG;;;GAGG;AACH,UAAU,iBAAiB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,IAAI,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,OAAO,CAAC;QACpB,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;YAChE,OAAO,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC,CAAC;SACjD,CAAC,CAAC;KACJ,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AA0BD,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CA8DpF"}
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* - 15 Shellbook tools (posts, comments, voting, subshells, search, profiles)
|
|
13
13
|
*/
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ProtonCliError = exports.checkKeychainPopulated = exports.checkProtonCli = exports.getTableRows = exports.execTransactionPush = exports.execAction = exports.createCliApi = exports.createCliSession = void 0;
|
|
15
16
|
exports.default = xprAgentsPlugin;
|
|
16
17
|
const session_1 = require("./session");
|
|
17
18
|
const agent_1 = require("./tools/agent");
|
|
@@ -21,6 +22,18 @@ const escrow_1 = require("./tools/escrow");
|
|
|
21
22
|
const indexer_1 = require("./tools/indexer");
|
|
22
23
|
const a2a_1 = require("./tools/a2a");
|
|
23
24
|
const shellbook_1 = require("./tools/shellbook");
|
|
25
|
+
// Re-export CLI session factories. Used by skill packages to obtain a
|
|
26
|
+
// signing session backed by the proton CLI (no private key in process).
|
|
27
|
+
var cli_session_1 = require("./cli-session");
|
|
28
|
+
Object.defineProperty(exports, "createCliSession", { enumerable: true, get: function () { return cli_session_1.createCliSession; } });
|
|
29
|
+
Object.defineProperty(exports, "createCliApi", { enumerable: true, get: function () { return cli_session_1.createCliApi; } });
|
|
30
|
+
var proton_cli_1 = require("./proton-cli");
|
|
31
|
+
Object.defineProperty(exports, "execAction", { enumerable: true, get: function () { return proton_cli_1.execAction; } });
|
|
32
|
+
Object.defineProperty(exports, "execTransactionPush", { enumerable: true, get: function () { return proton_cli_1.execTransactionPush; } });
|
|
33
|
+
Object.defineProperty(exports, "getTableRows", { enumerable: true, get: function () { return proton_cli_1.getTableRows; } });
|
|
34
|
+
Object.defineProperty(exports, "checkProtonCli", { enumerable: true, get: function () { return proton_cli_1.checkProtonCli; } });
|
|
35
|
+
Object.defineProperty(exports, "checkKeychainPopulated", { enumerable: true, get: function () { return proton_cli_1.checkKeychainPopulated; } });
|
|
36
|
+
Object.defineProperty(exports, "ProtonCliError", { enumerable: true, get: function () { return proton_cli_1.ProtonCliError; } });
|
|
24
37
|
/**
|
|
25
38
|
* Create an adapter that bridges the real OpenClaw API to our internal PluginApi.
|
|
26
39
|
* This lets all 57 tool registrations work unchanged.
|
|
@@ -54,7 +67,10 @@ function xprAgentsPlugin(realApi) {
|
|
|
54
67
|
const network = rawConfig.network || 'mainnet';
|
|
55
68
|
const defaultRpc = network === 'mainnet' ? 'https://proton.eosusa.io' : 'https://tn1.protonnz.com';
|
|
56
69
|
const rpcEndpoint = rawConfig.rpcEndpoint || process.env.XPR_RPC_ENDPOINT || defaultRpc;
|
|
57
|
-
|
|
70
|
+
// Signing is enabled when XPR_ACCOUNT is set. The proton CLI handles the
|
|
71
|
+
// private key — the agent process never sees it. Verifying CLI presence
|
|
72
|
+
// is the entry-point's job (starter/agent/src/index.ts), not the plugin's.
|
|
73
|
+
const hasCredentials = !!process.env.XPR_ACCOUNT;
|
|
58
74
|
// Create RPC connection and optional session
|
|
59
75
|
let rpc;
|
|
60
76
|
let session;
|
|
@@ -72,7 +88,7 @@ function xprAgentsPlugin(realApi) {
|
|
|
72
88
|
session,
|
|
73
89
|
network: rawConfig.network || 'mainnet',
|
|
74
90
|
rpcEndpoint,
|
|
75
|
-
indexerUrl: rawConfig.indexerUrl || '
|
|
91
|
+
indexerUrl: rawConfig.indexerUrl || process.env.INDEXER_URL || 'https://indexer.xpragents.com',
|
|
76
92
|
contracts: {
|
|
77
93
|
agentcore: contractsRaw.agentcore || 'agentcore',
|
|
78
94
|
agentfeed: contractsRaw.agentfeed || 'agentfeed',
|
|
@@ -91,7 +107,7 @@ function xprAgentsPlugin(realApi) {
|
|
|
91
107
|
(0, a2a_1.registerA2ATools)(api, config);
|
|
92
108
|
(0, shellbook_1.registerShellbookTools)(api);
|
|
93
109
|
if (!hasCredentials) {
|
|
94
|
-
console.log('[xpr-agents] Read-only mode:
|
|
110
|
+
console.log('[xpr-agents] Read-only mode: XPR_ACCOUNT not set. Write tools will fail.');
|
|
95
111
|
}
|
|
96
112
|
console.log(`[xpr-agents] Plugin loaded: ${config.network} (${rpcEndpoint})`);
|
|
97
113
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AA0EH,kCA8DC;AAtID,uCAA6D;AAC7D,yCAAmD;AACnD,+CAAyD;AACzD,mDAA6D;AAC7D,2CAAqD;AACrD,6CAAuD;AACvD,qCAA+C;AAC/C,iDAA2D;AAO3D,sEAAsE;AACtE,wEAAwE;AACxE,6CAA+D;AAAtD,+GAAA,gBAAgB,OAAA;AAAE,2GAAA,YAAY,OAAA;AAEvC,2CAOsB;AANpB,wGAAA,UAAU,OAAA;AACV,iHAAA,mBAAmB,OAAA;AACnB,0GAAA,YAAY,OAAA;AACZ,4GAAA,cAAc,OAAA;AACd,oHAAA,sBAAsB,OAAA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AAG,EAAE,MAAM,CAAC,CAAC;IACnC,IAAA,oCAAuB,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACrC,IAAA,4BAAmB,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACjC,IAAA,8BAAoB,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAClC,IAAA,sBAAgB,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAA,kCAAsB,EAAC,GAAG,CAAC,CAAC;IAE5B,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,0EAA0E,CAAC,CAAC;IAC1F,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,+BAA+B,MAAM,CAAC,OAAO,KAAK,WAAW,GAAG,CAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proton CLI wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Shells out to the `proton` CLI for all transaction signing. The agent
|
|
5
|
+
* process never touches private keys — they live exclusively in the CLI's
|
|
6
|
+
* encrypted keychain.
|
|
7
|
+
*
|
|
8
|
+
* Used by:
|
|
9
|
+
* - openclaw/src/session.ts (createCliSession factory)
|
|
10
|
+
* - openclaw/src/cli-session.ts (createCliApi factory)
|
|
11
|
+
* - openclaw/starter/agent/skills/* (via @xpr-agents/openclaw)
|
|
12
|
+
*/
|
|
13
|
+
export type CliErrorCode = 'network' | 'auth' | 'serialization' | 'reverted' | 'unknown';
|
|
14
|
+
export declare class ProtonCliError extends Error {
|
|
15
|
+
readonly code: CliErrorCode;
|
|
16
|
+
readonly stderr: string;
|
|
17
|
+
constructor(message: string, code: CliErrorCode, stderr: string);
|
|
18
|
+
}
|
|
19
|
+
export interface CliAction {
|
|
20
|
+
account: string;
|
|
21
|
+
name: string;
|
|
22
|
+
authorization: Array<{
|
|
23
|
+
actor: string;
|
|
24
|
+
permission: string;
|
|
25
|
+
}>;
|
|
26
|
+
data: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export interface CliTransactionResult {
|
|
29
|
+
transaction_id: string;
|
|
30
|
+
processed?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface TableQueryOpts {
|
|
33
|
+
limit?: number;
|
|
34
|
+
lower_bound?: string;
|
|
35
|
+
upper_bound?: string;
|
|
36
|
+
reverse?: boolean;
|
|
37
|
+
index_position?: number;
|
|
38
|
+
key_type?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Sign and submit a single action via `proton action`.
|
|
42
|
+
*
|
|
43
|
+
* @param contract - Contract account (e.g. 'agentescrow')
|
|
44
|
+
* @param action - Action name (e.g. 'createjob')
|
|
45
|
+
* @param data - Positional args matching the contract's action ABI
|
|
46
|
+
* @param authorization - "account@permission" string (e.g. "alice@active")
|
|
47
|
+
*/
|
|
48
|
+
export declare function execAction(contract: string, action: string, data: unknown[], authorization: string): Promise<CliTransactionResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Sign and submit a multi-action atomic transaction via `proton transaction:push`.
|
|
51
|
+
*
|
|
52
|
+
* NOTE: do NOT use the bare `proton transaction` command — it does not
|
|
53
|
+
* JSON.parse its argument (bug in @proton/cli). Use `transaction:push` exclusively.
|
|
54
|
+
*/
|
|
55
|
+
export declare function execTransactionPush(tx: {
|
|
56
|
+
actions: CliAction[];
|
|
57
|
+
}): Promise<CliTransactionResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Read-only table query via `proton table`. No signing required.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getTableRows(code: string, table: string, scope?: string, opts?: TableQueryOpts): Promise<unknown>;
|
|
62
|
+
/**
|
|
63
|
+
* Verify the proton CLI is installed and on PATH. Used by startup checks.
|
|
64
|
+
*/
|
|
65
|
+
export declare function checkProtonCli(): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Verify the proton CLI keychain has at least one key registered.
|
|
68
|
+
* Soft check — this doesn't verify any specific account, just that
|
|
69
|
+
* a keychain exists. The CLI itself will fail with auth code if the
|
|
70
|
+
* specific account's key is missing.
|
|
71
|
+
*/
|
|
72
|
+
export declare function checkKeychainPopulated(): Promise<boolean>;
|
|
73
|
+
//# sourceMappingURL=proton-cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proton-cli.d.ts","sourceRoot":"","sources":["../src/proton-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAUH,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,eAAe,GAAG,UAAU,GAAG,SAAS,CAAC;AAEzF,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM;CAMhE;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA+FD;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EAAE,EACf,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,oBAAoB,CAAC,CAe/B;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,EAAE,EAAE;IAAE,OAAO,EAAE,SAAS,EAAE,CAAA;CAAE,GAC3B,OAAO,CAAC,oBAAoB,CAAC,CAoB/B;AAED;;GAEG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,OAAO,CAAC,CAelB;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAOvD;AAED;;;;;GAKG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO/D"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Proton CLI wrapper.
|
|
4
|
+
*
|
|
5
|
+
* Shells out to the `proton` CLI for all transaction signing. The agent
|
|
6
|
+
* process never touches private keys — they live exclusively in the CLI's
|
|
7
|
+
* encrypted keychain.
|
|
8
|
+
*
|
|
9
|
+
* Used by:
|
|
10
|
+
* - openclaw/src/session.ts (createCliSession factory)
|
|
11
|
+
* - openclaw/src/cli-session.ts (createCliApi factory)
|
|
12
|
+
* - openclaw/starter/agent/skills/* (via @xpr-agents/openclaw)
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ProtonCliError = void 0;
|
|
16
|
+
exports.execAction = execAction;
|
|
17
|
+
exports.execTransactionPush = execTransactionPush;
|
|
18
|
+
exports.getTableRows = getTableRows;
|
|
19
|
+
exports.checkProtonCli = checkProtonCli;
|
|
20
|
+
exports.checkKeychainPopulated = checkKeychainPopulated;
|
|
21
|
+
const child_process_1 = require("child_process");
|
|
22
|
+
const util_1 = require("util");
|
|
23
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
24
|
+
const CLI_TIMEOUT_MS = 30000;
|
|
25
|
+
const MAX_BUFFER = 10 * 1024 * 1024; // 10MB
|
|
26
|
+
class ProtonCliError extends Error {
|
|
27
|
+
constructor(message, code, stderr) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.name = 'ProtonCliError';
|
|
30
|
+
this.code = code;
|
|
31
|
+
this.stderr = stderr;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ProtonCliError = ProtonCliError;
|
|
35
|
+
/**
|
|
36
|
+
* Categorise an error from the CLI by stderr signature.
|
|
37
|
+
* Default to 'unknown' — pattern set is intentionally narrow.
|
|
38
|
+
*/
|
|
39
|
+
function classifyError(stderr) {
|
|
40
|
+
if (/ECONNREFUSED|ETIMEDOUT|ENOTFOUND|fetch failed|getaddrinfo|ENETUNREACH/i.test(stderr)) {
|
|
41
|
+
return 'network';
|
|
42
|
+
}
|
|
43
|
+
if (/no key found|key is not unlocked|account .* not found|signature_provider/i.test(stderr)) {
|
|
44
|
+
return 'auth';
|
|
45
|
+
}
|
|
46
|
+
if (/unable to unpack|invalid type|cannot serialize|unknown action|unknown_action_exception/i.test(stderr)) {
|
|
47
|
+
return 'serialization';
|
|
48
|
+
}
|
|
49
|
+
if (/assertion failure|eosio_assert|action_validate_exception/i.test(stderr)) {
|
|
50
|
+
return 'reverted';
|
|
51
|
+
}
|
|
52
|
+
return 'unknown';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Remove anything that looks like action data payload from stderr before logging.
|
|
56
|
+
* Action data may contain memos, addresses, or other potentially sensitive info.
|
|
57
|
+
*/
|
|
58
|
+
function scrubStderr(stderr) {
|
|
59
|
+
if (!stderr)
|
|
60
|
+
return '';
|
|
61
|
+
return stderr
|
|
62
|
+
// Strip "data": { ... } blocks (single-line and multi-line)
|
|
63
|
+
.replace(/"data"\s*:\s*\{[^}]*\}/gs, '"data":[scrubbed]')
|
|
64
|
+
// Strip hex_data blocks
|
|
65
|
+
.replace(/"hex_data"\s*:\s*"[^"]*"/g, '"hex_data":"[scrubbed]"');
|
|
66
|
+
}
|
|
67
|
+
function logStart(contract, action, auth) {
|
|
68
|
+
console.error(`[proton-cli] action ${contract}::${action} auth=${auth}`);
|
|
69
|
+
}
|
|
70
|
+
function logSuccess(txid, ms) {
|
|
71
|
+
console.error(`[proton-cli] tx ${txid} ok in ${ms}ms`);
|
|
72
|
+
}
|
|
73
|
+
function logFailure(code, scrubbed) {
|
|
74
|
+
// Cap stderr in logs to avoid flooding
|
|
75
|
+
const snippet = scrubbed.length > 500 ? scrubbed.slice(0, 500) + '...' : scrubbed;
|
|
76
|
+
console.error(`[proton-cli] tx FAILED: ${code} ${snippet}`);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Parse the transaction ID from proton CLI stdout.
|
|
80
|
+
* Output is JSON containing a transaction_id (or trx_id) field.
|
|
81
|
+
*/
|
|
82
|
+
function parseTxId(stdout) {
|
|
83
|
+
const txMatch = stdout.match(/"transaction_id"\s*:\s*"([0-9a-f]+)"/);
|
|
84
|
+
if (txMatch)
|
|
85
|
+
return txMatch[1];
|
|
86
|
+
const trxMatch = stdout.match(/"trx_id"\s*:\s*"([0-9a-f]+)"/);
|
|
87
|
+
return trxMatch ? trxMatch[1] : null;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Try to parse the full processed result block from stdout. Best-effort.
|
|
91
|
+
*/
|
|
92
|
+
function tryParseProcessed(stdout) {
|
|
93
|
+
try {
|
|
94
|
+
const parsed = JSON.parse(stdout);
|
|
95
|
+
if (parsed && typeof parsed === 'object' && 'processed' in parsed) {
|
|
96
|
+
return parsed.processed;
|
|
97
|
+
}
|
|
98
|
+
return parsed;
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Run the proton CLI with the given arguments. Always uses execFile (no shell).
|
|
106
|
+
*/
|
|
107
|
+
async function runProton(args) {
|
|
108
|
+
try {
|
|
109
|
+
const result = await execFileAsync('proton', args, {
|
|
110
|
+
timeout: CLI_TIMEOUT_MS,
|
|
111
|
+
maxBuffer: MAX_BUFFER,
|
|
112
|
+
});
|
|
113
|
+
return { stdout: result.stdout };
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
const e = err;
|
|
117
|
+
const stderrRaw = (e.stderr || '') + (e.message || '');
|
|
118
|
+
const scrubbed = scrubStderr(stderrRaw);
|
|
119
|
+
const code = classifyError(stderrRaw);
|
|
120
|
+
logFailure(code, scrubbed);
|
|
121
|
+
throw new ProtonCliError(`proton CLI failed: ${code}`, code, scrubbed);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Sign and submit a single action via `proton action`.
|
|
126
|
+
*
|
|
127
|
+
* @param contract - Contract account (e.g. 'agentescrow')
|
|
128
|
+
* @param action - Action name (e.g. 'createjob')
|
|
129
|
+
* @param data - Positional args matching the contract's action ABI
|
|
130
|
+
* @param authorization - "account@permission" string (e.g. "alice@active")
|
|
131
|
+
*/
|
|
132
|
+
async function execAction(contract, action, data, authorization) {
|
|
133
|
+
logStart(contract, action, authorization);
|
|
134
|
+
const start = Date.now();
|
|
135
|
+
const dataJson = JSON.stringify(data);
|
|
136
|
+
const { stdout } = await runProton(['action', contract, action, dataJson, authorization]);
|
|
137
|
+
const txid = parseTxId(stdout);
|
|
138
|
+
if (!txid) {
|
|
139
|
+
throw new ProtonCliError('proton CLI returned success but no transaction ID could be parsed', 'unknown', stdout);
|
|
140
|
+
}
|
|
141
|
+
logSuccess(txid, Date.now() - start);
|
|
142
|
+
return { transaction_id: txid, processed: tryParseProcessed(stdout) };
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Sign and submit a multi-action atomic transaction via `proton transaction:push`.
|
|
146
|
+
*
|
|
147
|
+
* NOTE: do NOT use the bare `proton transaction` command — it does not
|
|
148
|
+
* JSON.parse its argument (bug in @proton/cli). Use `transaction:push` exclusively.
|
|
149
|
+
*/
|
|
150
|
+
async function execTransactionPush(tx) {
|
|
151
|
+
if (!tx.actions || tx.actions.length === 0) {
|
|
152
|
+
throw new ProtonCliError('execTransactionPush: empty actions array', 'unknown', '');
|
|
153
|
+
}
|
|
154
|
+
const first = tx.actions[0];
|
|
155
|
+
const auth = first.authorization[0];
|
|
156
|
+
logStart(first.account, first.name, `${auth.actor}@${auth.permission}`);
|
|
157
|
+
const start = Date.now();
|
|
158
|
+
const txJson = JSON.stringify(tx);
|
|
159
|
+
const { stdout } = await runProton(['transaction:push', txJson]);
|
|
160
|
+
const txid = parseTxId(stdout);
|
|
161
|
+
if (!txid) {
|
|
162
|
+
throw new ProtonCliError('proton CLI returned success but no transaction ID could be parsed', 'unknown', stdout);
|
|
163
|
+
}
|
|
164
|
+
logSuccess(txid, Date.now() - start);
|
|
165
|
+
return { transaction_id: txid, processed: tryParseProcessed(stdout) };
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Read-only table query via `proton table`. No signing required.
|
|
169
|
+
*/
|
|
170
|
+
async function getTableRows(code, table, scope, opts) {
|
|
171
|
+
const args = ['table', code, table];
|
|
172
|
+
if (scope)
|
|
173
|
+
args.push(scope);
|
|
174
|
+
if (opts?.limit !== undefined)
|
|
175
|
+
args.push('-c', String(opts.limit));
|
|
176
|
+
if (opts?.lower_bound !== undefined)
|
|
177
|
+
args.push('-l', opts.lower_bound);
|
|
178
|
+
if (opts?.upper_bound !== undefined)
|
|
179
|
+
args.push('-u', opts.upper_bound);
|
|
180
|
+
if (opts?.reverse)
|
|
181
|
+
args.push('-r');
|
|
182
|
+
if (opts?.index_position !== undefined)
|
|
183
|
+
args.push('-i', String(opts.index_position));
|
|
184
|
+
if (opts?.key_type !== undefined)
|
|
185
|
+
args.push('-k', opts.key_type);
|
|
186
|
+
const { stdout } = await runProton(args);
|
|
187
|
+
try {
|
|
188
|
+
return JSON.parse(stdout);
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
throw new ProtonCliError('proton table returned invalid JSON', 'unknown', stdout);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Verify the proton CLI is installed and on PATH. Used by startup checks.
|
|
196
|
+
*/
|
|
197
|
+
async function checkProtonCli() {
|
|
198
|
+
try {
|
|
199
|
+
await execFileAsync('proton', ['--version'], { timeout: 5000 });
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Verify the proton CLI keychain has at least one key registered.
|
|
208
|
+
* Soft check — this doesn't verify any specific account, just that
|
|
209
|
+
* a keychain exists. The CLI itself will fail with auth code if the
|
|
210
|
+
* specific account's key is missing.
|
|
211
|
+
*/
|
|
212
|
+
async function checkKeychainPopulated() {
|
|
213
|
+
try {
|
|
214
|
+
const { stdout } = await execFileAsync('proton', ['key:list'], { timeout: 5000 });
|
|
215
|
+
return stdout.includes('publicKey');
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=proton-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proton-cli.js","sourceRoot":"","sources":["../src/proton-cli.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAkJH,gCAoBC;AAQD,kDAsBC;AAKD,oCAoBC;AAKD,wCAOC;AAQD,wDAOC;AAtPD,iDAAyC;AACzC,+BAAiC;AAEjC,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,wBAAQ,CAAC,CAAC;AAE1C,MAAM,cAAc,GAAG,KAAM,CAAC;AAC9B,MAAM,UAAU,GA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CAAC;QACH,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,sBAAsB;IAC1C,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAClF,OAAO,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/session.d.ts
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side ProtonSession factory.
|
|
3
|
+
*
|
|
4
|
+
* This module previously held a JsSignatureProvider that loaded
|
|
5
|
+
* XPR_PRIVATE_KEY into the agent process. After the 2026-04-24 charliebot
|
|
6
|
+
* incident — where a hardcoded private key was leaked to a public repo —
|
|
7
|
+
* all signing was moved to the proton CLI's encrypted keychain.
|
|
8
|
+
*
|
|
9
|
+
* This file is now a thin wrapper around createCliSession.
|
|
10
|
+
*
|
|
11
|
+
* Required env: XPR_ACCOUNT
|
|
12
|
+
* Optional env: XPR_PERMISSION (defaults to 'active'), XPR_RPC_ENDPOINT
|
|
13
|
+
*
|
|
14
|
+
* The agent process MUST NOT read XPR_PRIVATE_KEY. The legacy entry-point
|
|
15
|
+
* check in starter/agent/src/index.ts refuses to start if it is set.
|
|
16
|
+
*/
|
|
1
17
|
import { JsonRpc } from '@proton/js';
|
|
2
18
|
import type { ProtonSession } from '@xpr-agents/sdk';
|
|
3
19
|
export interface SessionConfig {
|
|
4
20
|
rpcEndpoint: string;
|
|
5
|
-
privateKey?: string;
|
|
6
21
|
account?: string;
|
|
7
22
|
permission?: string;
|
|
8
23
|
}
|
|
9
24
|
/**
|
|
10
|
-
* Create a server-side ProtonSession
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* Required env vars: XPR_PRIVATE_KEY, XPR_ACCOUNT
|
|
14
|
-
* Optional: XPR_PERMISSION (defaults to 'active')
|
|
25
|
+
* Create a server-side ProtonSession backed by the proton CLI.
|
|
26
|
+
* No private key required — the CLI signs internally via its keychain.
|
|
15
27
|
*/
|
|
16
28
|
export declare function createSession(config: SessionConfig): {
|
|
17
29
|
rpc: JsonRpc;
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,GAAG;IAAE,GAAG,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,aAAa,CAAA;CAAE,CAS7F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAE9D"}
|