@vapi-network/cli 0.7.0 → 0.9.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/README.md +3 -0
- package/dist/agent.d.ts +23 -2
- package/dist/cli.d.ts +28 -2
- package/dist/cli.js +30757 -12253
- package/dist/cli.js.map +3 -3
- package/dist/cloud-backup.d.ts +7 -0
- package/dist/docs.d.ts +2 -0
- package/dist/headless.d.ts +37 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30756 -12252
- package/dist/index.js.map +3 -3
- package/dist/runtime-local.d.ts +40 -0
- package/dist/runtime-railway.d.ts +198 -0
- package/dist/swarm.d.ts +2 -0
- package/dist/task.d.ts +36 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
|
+
import { type Runtime, type RuntimeKind } from "@vapi-network/mcp";
|
|
3
|
+
import { type CliDependencies } from "./cli.js";
|
|
4
|
+
import { type RailwayRuntimeOptions } from "./runtime-railway.js";
|
|
5
|
+
type Spawn = (command: string, args: readonly string[], options: {
|
|
6
|
+
detached: true;
|
|
7
|
+
stdio: ["ignore", number, number];
|
|
8
|
+
env: NodeJS.ProcessEnv;
|
|
9
|
+
windowsHide: true;
|
|
10
|
+
}) => Pick<ChildProcess, "pid" | "unref">;
|
|
11
|
+
export type LocalRuntimeOptions = {
|
|
12
|
+
home: string;
|
|
13
|
+
entry?: string;
|
|
14
|
+
execPath?: string;
|
|
15
|
+
env?: NodeJS.ProcessEnv;
|
|
16
|
+
spawn?: Spawn;
|
|
17
|
+
kill?: (pid: number, signal: NodeJS.Signals | 0) => void;
|
|
18
|
+
/** Full command line of a live process, or undefined when there is none. */
|
|
19
|
+
processCommand?: (pid: number) => string | undefined;
|
|
20
|
+
openLog?: (path: string) => number;
|
|
21
|
+
closeFd?: (fd: number) => void;
|
|
22
|
+
readFile?: (path: string, encoding: "utf8") => Promise<string>;
|
|
23
|
+
now?: () => Date;
|
|
24
|
+
};
|
|
25
|
+
export declare function createLocalRuntime(options: LocalRuntimeOptions): Runtime;
|
|
26
|
+
/** What one start asks of a remote runtime. Status, list and stop need none of it. */
|
|
27
|
+
export type RuntimeRequest = {
|
|
28
|
+
checkpoint?: string;
|
|
29
|
+
allowRemoteKey?: boolean;
|
|
30
|
+
keepSandbox?: boolean;
|
|
31
|
+
/** The member accounts the owner confirmed; a railway start refuses any other. */
|
|
32
|
+
confirmedMembers?: readonly string[];
|
|
33
|
+
};
|
|
34
|
+
export type RuntimeOptions = LocalRuntimeOptions & {
|
|
35
|
+
railway?: Omit<RailwayRuntimeOptions, "home">;
|
|
36
|
+
};
|
|
37
|
+
export declare function runtimeForKind(kind: RuntimeKind, options: RuntimeOptions): Runtime;
|
|
38
|
+
export declare function resolveRuntime(kind: RuntimeKind, home: string, dependencies: CliDependencies, request?: RuntimeRequest): Runtime;
|
|
39
|
+
export declare function parseRuntimeKind(value: string | undefined): RuntimeKind;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { WalletStore, type AgentProfile, type SecretStore, type SwarmBalanceReader, type SwarmFile, type SwarmMember, type VapiConfig } from "@vapi-network/core";
|
|
2
|
+
import { type Runtime, type RuntimeMember, type RuntimeRun } from "@vapi-network/mcp";
|
|
3
|
+
/**
|
|
4
|
+
* The experimental `railway` runtime: one swarm member runs `vapi agent run
|
|
5
|
+
* --bundle-env` inside a Railway sandbox booted from a checkpoint that has the
|
|
6
|
+
* vAPI CLI preinstalled.
|
|
7
|
+
*
|
|
8
|
+
* Only that member's own private key and its own link credentials leave this
|
|
9
|
+
* machine, inside a member bundle passed through `--env-file`. Never the
|
|
10
|
+
* recovery phrase, never the treasury, never another account. vAPI never reads
|
|
11
|
+
* or stores Railway tokens: the `railway` CLI uses whatever it is logged into
|
|
12
|
+
* (or `RAILWAY_API_TOKEN`).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Every `railway` invocation this adapter makes, in one place so flags are
|
|
16
|
+
* easy to correct. Measured against Railway CLI 5.30.1; `--json` on `create`
|
|
17
|
+
* is assumed. `create` may return while the sandbox is still booting, so the
|
|
18
|
+
* adapter runs `readyCommand` until it succeeds before the detached run.
|
|
19
|
+
*/
|
|
20
|
+
export declare const RAILWAY_CLI: {
|
|
21
|
+
readonly binary: "railway";
|
|
22
|
+
readonly create: (options: {
|
|
23
|
+
checkpoint: string;
|
|
24
|
+
envFile: string;
|
|
25
|
+
idleTimeoutMinutes: number;
|
|
26
|
+
}) => string[];
|
|
27
|
+
readonly exec: (id: string, command: readonly string[], detach: boolean) => string[];
|
|
28
|
+
readonly destroy: (id: string) => string[];
|
|
29
|
+
readonly readyCommand: readonly ["true"];
|
|
30
|
+
readonly resultPath: "/tmp/vapi-result.json";
|
|
31
|
+
readonly bundleVariable: "VAPI_MEMBER_BUNDLE";
|
|
32
|
+
};
|
|
33
|
+
/** The largest target a member running on Railway may hold: 1.00 USDC. */
|
|
34
|
+
export declare const REMOTE_MAX_TARGET_ATOMIC = 1000000n;
|
|
35
|
+
/** The largest effective ceiling a member running on Railway may hold: 2.00 USDC. */
|
|
36
|
+
export declare const REMOTE_MAX_CEILING_ATOMIC = 2000000n;
|
|
37
|
+
export declare const DEFAULT_RAILWAY_IDLE_TIMEOUT_MINUTES = 30;
|
|
38
|
+
/** How often the adapter asks a new sandbox whether it runs yet: 20 × 1.5 s, about 30 s. */
|
|
39
|
+
export declare const DEFAULT_RAILWAY_READY_ATTEMPTS = 20;
|
|
40
|
+
export declare const DEFAULT_RAILWAY_READY_INTERVAL_MS = 1500;
|
|
41
|
+
/** How long a SIGINT/SIGTERM during `start` waits for the sandbox destroy before re-raising. */
|
|
42
|
+
export declare const DEFAULT_RAILWAY_SIGNAL_DESTROY_TIMEOUT_MS = 5000;
|
|
43
|
+
/** A checkpoint name: 1-64 characters, a letter or digit first, so it never reads as an option. */
|
|
44
|
+
export declare const RAILWAY_CHECKPOINT_PATTERN: RegExp;
|
|
45
|
+
export declare const RAILWAY_CHECKPOINT_RULE = "1-64 letters, digits, '.', '_' or '-', starting with a letter or digit";
|
|
46
|
+
export type RailwayExecResult = {
|
|
47
|
+
code: number | null;
|
|
48
|
+
stdout: string;
|
|
49
|
+
stderr: string;
|
|
50
|
+
};
|
|
51
|
+
export type RailwayExec = (file: string, args: readonly string[]) => Promise<RailwayExecResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Runs one process with stdin closed and this process's environment, so the
|
|
54
|
+
* `railway` CLI authenticates however it is set up here. It rejects only when
|
|
55
|
+
* the binary cannot be started at all.
|
|
56
|
+
*/
|
|
57
|
+
export declare const defaultRailwayExec: RailwayExec;
|
|
58
|
+
/** Reads the sandbox id from `railway sandbox create --json` output. Never echoes the output. */
|
|
59
|
+
export declare function parseSandboxId(stdout: string): string;
|
|
60
|
+
export type RemoteKeyRefusalCode = "not_in_swarm" | "swarm_treasury" | "not_a_member" | "lead_mode" | "target_too_high" | "ceiling_too_high" | "ceiling_disabled" | "remote_key_not_allowed" | "agent_marker" | "balance_too_high" | "balance_on_other_network" | "balance_unreadable" | "authorization_unresolved" | "no_daily_allowance" | "unsafe_config" | "unsupported_network" | "member_not_confirmed";
|
|
61
|
+
/** A member that may not run on a remote sandbox. The message says how to fix it. */
|
|
62
|
+
export declare class RemoteKeyRefusedError extends Error {
|
|
63
|
+
readonly code: RemoteKeyRefusalCode;
|
|
64
|
+
readonly name = "RemoteKeyRefusedError";
|
|
65
|
+
constructor(code: RemoteKeyRefusalCode, message: string);
|
|
66
|
+
}
|
|
67
|
+
export type RemoteSafeMember = {
|
|
68
|
+
swarm: SwarmFile;
|
|
69
|
+
swarmMember: SwarmMember;
|
|
70
|
+
/** The configured ceiling; never null for a remote-safe member. */
|
|
71
|
+
ceilingAtomic: bigint;
|
|
72
|
+
effectiveCeilingAtomic: bigint;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Refuses, before any key is read, every member whose key may not leave this
|
|
76
|
+
* machine: accounts outside a swarm, a swarm treasury, non-members, lead runs,
|
|
77
|
+
* a target above 1.00 USDC, an effective ceiling above 2.00 USDC or disabled,
|
|
78
|
+
* and any run without an explicit `allowRemoteKey`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function assertRemoteSafeMember(args: {
|
|
81
|
+
home: string;
|
|
82
|
+
member: RuntimeMember;
|
|
83
|
+
mode: RuntimeRun["mode"];
|
|
84
|
+
store: Pick<WalletStore, "ceilingCaps" | "ceilingSweepPending">;
|
|
85
|
+
allowRemoteKey?: boolean;
|
|
86
|
+
readSwarm?: (home: string, name: string) => Promise<SwarmFile>;
|
|
87
|
+
}): Promise<RemoteSafeMember>;
|
|
88
|
+
export type RailwayRuntimeFs = {
|
|
89
|
+
mkdtemp: (prefix: string) => Promise<string>;
|
|
90
|
+
writeFile: (path: string, data: string, options: {
|
|
91
|
+
encoding: "utf8";
|
|
92
|
+
mode: number;
|
|
93
|
+
flag: "wx";
|
|
94
|
+
}) => Promise<void>;
|
|
95
|
+
rm: (path: string, options: {
|
|
96
|
+
recursive: true;
|
|
97
|
+
force: true;
|
|
98
|
+
}) => Promise<void>;
|
|
99
|
+
stat: (path: string) => Promise<{
|
|
100
|
+
mode: number;
|
|
101
|
+
}>;
|
|
102
|
+
};
|
|
103
|
+
export type RailwayRuntimeOptions = {
|
|
104
|
+
home: string;
|
|
105
|
+
store?: WalletStore | (() => Promise<WalletStore>);
|
|
106
|
+
vaultKey?: () => Promise<{
|
|
107
|
+
path: string;
|
|
108
|
+
key: Uint8Array;
|
|
109
|
+
}>;
|
|
110
|
+
secrets?: SecretStore;
|
|
111
|
+
checkpoint?: string;
|
|
112
|
+
idleTimeoutMinutes?: number;
|
|
113
|
+
allowRemoteKey?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* The member accounts the owner confirmed for this run. `start` refuses any
|
|
116
|
+
* other member, and every member when the set is missing.
|
|
117
|
+
*/
|
|
118
|
+
confirmedMembers?: readonly string[];
|
|
119
|
+
keepSandbox?: boolean;
|
|
120
|
+
exec?: RailwayExec;
|
|
121
|
+
fs?: Partial<RailwayRuntimeFs>;
|
|
122
|
+
/** Parent directory of the temporary env-file directory. Defaults to `os.tmpdir()`. */
|
|
123
|
+
tmpdir?: string;
|
|
124
|
+
readProfile?: (name: string) => Promise<AgentProfile>;
|
|
125
|
+
readSwarm?: (home: string, name: string) => Promise<SwarmFile>;
|
|
126
|
+
/** The owner's local config. Only network ids, USDC and discovery URLs reach a bundle. */
|
|
127
|
+
config?: () => Promise<VapiConfig>;
|
|
128
|
+
/**
|
|
129
|
+
* Reads a member's live USDC balance before its key is exported. Defaults to
|
|
130
|
+
* an RPC read on the swarm network through the owner's local config.
|
|
131
|
+
*/
|
|
132
|
+
balanceReader?: SwarmBalanceReader;
|
|
133
|
+
/** The fetch the default balance reader uses. */
|
|
134
|
+
fetchImpl?: typeof fetch;
|
|
135
|
+
now?: () => Date;
|
|
136
|
+
tty?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* An environment checked for `VAPI_NO_SECRETS` and the agent markers, which
|
|
139
|
+
* refuse a key export exactly as they refuse `vapi export-key`. `process.env`
|
|
140
|
+
* is always checked as well, so an injected clean environment cannot lift a
|
|
141
|
+
* marker this process runs under.
|
|
142
|
+
*/
|
|
143
|
+
env?: NodeJS.ProcessEnv;
|
|
144
|
+
/** Readiness probes after `sandbox create`. Defaults to {@link DEFAULT_RAILWAY_READY_ATTEMPTS}. */
|
|
145
|
+
readyAttempts?: number;
|
|
146
|
+
readyIntervalMs?: number;
|
|
147
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* How long a SIGINT/SIGTERM during `start` waits for `sandbox destroy`
|
|
150
|
+
* before it re-raises. Defaults to {@link DEFAULT_RAILWAY_SIGNAL_DESTROY_TIMEOUT_MS}.
|
|
151
|
+
*/
|
|
152
|
+
signalDestroyTimeoutMs?: number;
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* What this machine knows about a run's sandbox, at `<home>/runs/<runId>.railway.json`
|
|
156
|
+
* (0600). Written before `sandbox create`, so a sandbox holding a member key is
|
|
157
|
+
* never untracked: `creating` (no id yet, or create failed unclearly), `running`,
|
|
158
|
+
* `orphaned` (a destroy failed or was interrupted) or `kept` (finished with
|
|
159
|
+
* keepSandbox). No key, bundle or credential is ever in it.
|
|
160
|
+
*/
|
|
161
|
+
export type RailwaySidecar = {
|
|
162
|
+
v: 1;
|
|
163
|
+
runId: string;
|
|
164
|
+
account: string;
|
|
165
|
+
swarm: string;
|
|
166
|
+
state: "creating" | "running" | "orphaned" | "kept";
|
|
167
|
+
sandboxId?: string;
|
|
168
|
+
checkpoint: string;
|
|
169
|
+
keepSandbox: boolean;
|
|
170
|
+
};
|
|
171
|
+
export declare function railwaySidecarPath(home: string, runId: string): string;
|
|
172
|
+
export declare function createRailwayRuntime(options: RailwayRuntimeOptions): Runtime;
|
|
173
|
+
/**
|
|
174
|
+
* Every sidecar in `<home>/runs/`, including the 0.6 pre-release shape (read
|
|
175
|
+
* as `running`). Unreadable or invalid files are skipped.
|
|
176
|
+
*/
|
|
177
|
+
export declare function listRailwaySidecars(home: string): Promise<RailwaySidecar[]>;
|
|
178
|
+
/**
|
|
179
|
+
* Destroys the sandbox a sidecar names and deletes the sidecar. Without a
|
|
180
|
+
* sandbox id, or when the destroy fails, the sidecar stays (`orphaned` after a
|
|
181
|
+
* failed destroy) and `error` tells the owner the exact `railway` command.
|
|
182
|
+
*/
|
|
183
|
+
export declare function destroyRailwaySidecar(home: string, runId: string, options?: {
|
|
184
|
+
exec?: RailwayExec;
|
|
185
|
+
}): Promise<{
|
|
186
|
+
runId: string;
|
|
187
|
+
sandboxId?: string;
|
|
188
|
+
destroyed: boolean;
|
|
189
|
+
error?: string;
|
|
190
|
+
}>;
|
|
191
|
+
export declare function assertRemoteBalance(args: Parameters<SwarmBalanceReader>[0] & {
|
|
192
|
+
swarm: string;
|
|
193
|
+
readBalance: SwarmBalanceReader;
|
|
194
|
+
}): Promise<void>;
|
|
195
|
+
/** The default balance reader: an RPC read through the owner's local network config. */
|
|
196
|
+
export declare function ownerBalanceReader(config: VapiConfig, fetchImpl: typeof fetch | undefined): SwarmBalanceReader;
|
|
197
|
+
/** Why a key export was refused in an agent or locked-down environment. */
|
|
198
|
+
export declare function agentMarkerRefusal(marker: string): RemoteKeyRefusedError;
|
package/dist/swarm.d.ts
ADDED
package/dist/task.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type TasksChain, type TasksClient, type TasksClientOptions, type PendingTransactions, type UploadFileInput } from "@vapi-network/core/tasks";
|
|
2
|
+
import { parseArguments, type CliDependencies, type CliIo, type WalletTarget } from "./cli.js";
|
|
3
|
+
export type TasksCommandDependencies = {
|
|
4
|
+
client?: TasksClient | ((options: TasksClientOptions) => TasksClient);
|
|
5
|
+
chain?: TasksChain;
|
|
6
|
+
sleep?: (milliseconds: number) => Promise<void>;
|
|
7
|
+
randomUUID?: () => string;
|
|
8
|
+
};
|
|
9
|
+
export declare const TASK_HELP = "Usage:\n vapi task search [--open] [--min <usd>] [--tab trending|new|closing|paid] [--limit <n>] [--json]\n vapi task show <id> [--account <name>] [--json]\n vapi task post --title <text> --brief <file|-> --amount <usd> --deadline <duration|ISO> [--intake proposals|submissions] [--max-awards <k>] [--webhook <https-url>] [--account <name>] [--json]\n vapi task propose <id> --price <usd> --duration <duration> --note <text> [--account <name>] [--json]\n vapi task submit <id> --proof <https-url> [--proof <https-url>...] [--file <path>...] [--account <name>] [--json]\n vapi task award <id> <proposalId> [--account <name>] [--json]\n vapi task sign <id> [--yes] [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task fund <id> [--yes] [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task deliver <id> --files <path...> --note <text> [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task release <id> [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task refund <id> [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task dispute <id> --evidence-hash <0x + 64 hex> [--yes] [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task counter-evidence <id> --evidence-hash <0x + 64 hex> [--yes] [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task resolve-unmatched <id> [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task message <id> <text> [--account <name>] [--json]\n vapi task thread <id> [--after <cursor>] [--account <name>] [--json]\n vapi task watch <id> [--until <state>] [--auto-release] [--timeout 7d] [--interval 5s] [--counterparty <0x\u2026>] [--account <name>] [--json]\n vapi task status <id> [--account <name>] [--json]\n\nDurations: 5s, 10m, 48h, 7d, or an ISO-8601 timestamp. Posting and proposal terms require at least 10 minutes.\nDispute accepts a precomputed evidence hash only; evidence-file hashing is still undecided upstream.\nWatch requires an interval of at least 1s and a positive timeout. Auto-release uses the acting wallet's agent profile, or defaults, and releases only amounts strictly below the threshold.\nPosting a task moves no money. Task reads require tasks:read and writes require tasks:write; write access includes reads.\nThe thread cursor is the previous page's nextBeforeSeq; --after reads older messages using beforeSeq.\nEvery command accepts --json. Watch and a partially completed sign may write more than one JSON value. Human diagnostics go to stderr.\n\nExit codes:\n 0 ok\n 1 error, including invalid usage, unavailable routes and chain failures\n 2 policy refusal only (JSON ok:false with reason policy.perTask or policy.perDay)\n 3 approval needed in non-interactive mode\n\nFund, deliver, release, refund, dispute, counter-evidence, resolve-unmatched and watch auto-release sign with the local vault wallet. The CLI waits for two confirmations and records pending transactions for recovery. It never retries a chain mutation automatically.";
|
|
10
|
+
type Parsed = ReturnType<typeof parseArguments>;
|
|
11
|
+
type TaskRoute = keyof TasksClient;
|
|
12
|
+
export declare class TaskCommandError extends Error {
|
|
13
|
+
readonly code: string;
|
|
14
|
+
readonly manifestHash?: `0x${string}` | undefined;
|
|
15
|
+
constructor(code: string, message: string, manifestHash?: `0x${string}` | undefined);
|
|
16
|
+
}
|
|
17
|
+
/** Relative milliseconds; timestamps are measured from the supplied clock. */
|
|
18
|
+
export declare function parseTaskDuration(text: string, now: Date): number;
|
|
19
|
+
export type TaskContext = {
|
|
20
|
+
client: TasksClient;
|
|
21
|
+
chain: TasksChain;
|
|
22
|
+
pending?: PendingTransactions;
|
|
23
|
+
baseUrl: string;
|
|
24
|
+
target?: WalletTarget;
|
|
25
|
+
token?: string;
|
|
26
|
+
randomUUID: () => string;
|
|
27
|
+
sleep: (milliseconds: number) => Promise<void>;
|
|
28
|
+
signInHint: string;
|
|
29
|
+
};
|
|
30
|
+
/** Reuses wallet selection, registry configuration and device-link credentials. */
|
|
31
|
+
export declare function taskContext(parsed: Parsed, io: CliIo, dependencies: CliDependencies, publicOnly?: boolean): Promise<TaskContext>;
|
|
32
|
+
export declare function taskRequest<T>(verb: string, route: TaskRoute, operation: () => Promise<T>): Promise<T>;
|
|
33
|
+
export declare function taskOutput(io: CliIo, json: boolean, context: TaskContext, verb: string, value: object, lines: string[]): void;
|
|
34
|
+
export declare function taskCommand(argv: string[], json: boolean, io: CliIo, dependencies: CliDependencies): Promise<number | undefined>;
|
|
35
|
+
export declare function readTaskFile(path: string): Promise<UploadFileInput>;
|
|
36
|
+
export {};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.
|
|
1
|
+
export declare const CLI_VERSION = "0.9.0";
|