@stellar-agent-services/provider-kit 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +508 -2
- package/dist/approve/assets/index-BazIJAI2.css +1 -0
- package/dist/approve/assets/index-CL28cSJy.js +420 -0
- package/dist/approve/favicon.svg +1 -0
- package/dist/approve/index.html +18 -0
- package/dist/cli/approval-view.d.ts +80 -0
- package/dist/cli/approval-view.d.ts.map +1 -0
- package/dist/cli/approval-view.js +5 -0
- package/dist/cli/approval-view.js.map +1 -0
- package/dist/cli/approval.d.ts +132 -0
- package/dist/cli/approval.d.ts.map +1 -0
- package/dist/cli/approval.js +542 -0
- package/dist/cli/approval.js.map +1 -0
- package/dist/cli/check.d.ts +3 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +137 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/dev-account.d.ts +28 -0
- package/dist/cli/dev-account.d.ts.map +1 -0
- package/dist/cli/dev-account.js +62 -0
- package/dist/cli/dev-account.js.map +1 -0
- package/dist/cli/dev.d.ts +27 -0
- package/dist/cli/dev.d.ts.map +1 -0
- package/dist/cli/dev.js +226 -0
- package/dist/cli/dev.js.map +1 -0
- package/dist/cli/discovery.d.ts +20 -0
- package/dist/cli/discovery.d.ts.map +1 -0
- package/dist/cli/discovery.js +202 -0
- package/dist/cli/discovery.js.map +1 -0
- package/dist/cli/env-file.d.ts +16 -0
- package/dist/cli/env-file.d.ts.map +1 -0
- package/dist/cli/env-file.js +77 -0
- package/dist/cli/env-file.js.map +1 -0
- package/dist/cli/fly.d.ts +28 -0
- package/dist/cli/fly.d.ts.map +1 -0
- package/dist/cli/fly.js +92 -0
- package/dist/cli/fly.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +11 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +170 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/cli/launch.d.ts +21 -0
- package/dist/cli/launch.d.ts.map +1 -0
- package/dist/cli/launch.js +627 -0
- package/dist/cli/launch.js.map +1 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +158 -0
- package/dist/cli/main.js.map +1 -0
- package/dist/cli/owner-chain.d.ts +88 -0
- package/dist/cli/owner-chain.d.ts.map +1 -0
- package/dist/cli/owner-chain.js +284 -0
- package/dist/cli/owner-chain.js.map +1 -0
- package/dist/cli/owner-steps.d.ts +33 -0
- package/dist/cli/owner-steps.d.ts.map +1 -0
- package/dist/cli/owner-steps.js +121 -0
- package/dist/cli/owner-steps.js.map +1 -0
- package/dist/cli/processes.d.ts +47 -0
- package/dist/cli/processes.d.ts.map +1 -0
- package/dist/cli/processes.js +129 -0
- package/dist/cli/processes.js.map +1 -0
- package/dist/cli/reconcile.d.ts +3 -0
- package/dist/cli/reconcile.d.ts.map +1 -0
- package/dist/cli/reconcile.js +76 -0
- package/dist/cli/reconcile.js.map +1 -0
- package/dist/cli/register.d.ts +9 -0
- package/dist/cli/register.d.ts.map +1 -0
- package/dist/cli/register.js +209 -0
- package/dist/cli/register.js.map +1 -0
- package/dist/cli/request-validation.d.ts +5 -0
- package/dist/cli/request-validation.d.ts.map +1 -0
- package/dist/cli/request-validation.js +144 -0
- package/dist/cli/request-validation.js.map +1 -0
- package/dist/cli/serve.d.ts +25 -0
- package/dist/cli/serve.d.ts.map +1 -0
- package/dist/cli/serve.js +73 -0
- package/dist/cli/serve.js.map +1 -0
- package/dist/cli/shared.d.ts +142 -0
- package/dist/cli/shared.d.ts.map +1 -0
- package/dist/cli/shared.js +110 -0
- package/dist/cli/shared.js.map +1 -0
- package/dist/cli/status.d.ts +32 -0
- package/dist/cli/status.d.ts.map +1 -0
- package/dist/cli/status.js +248 -0
- package/dist/cli/status.js.map +1 -0
- package/dist/cli/target.d.ts +14 -0
- package/dist/cli/target.d.ts.map +1 -0
- package/dist/cli/target.js +43 -0
- package/dist/cli/target.js.map +1 -0
- package/dist/cli/trustline.d.ts +3 -0
- package/dist/cli/trustline.d.ts.map +1 -0
- package/dist/cli/trustline.js +114 -0
- package/dist/cli/trustline.js.map +1 -0
- package/dist/cli/try.d.ts +54 -0
- package/dist/cli/try.d.ts.map +1 -0
- package/dist/cli/try.js +450 -0
- package/dist/cli/try.js.map +1 -0
- package/dist/cli/tunnel.d.ts +13 -0
- package/dist/cli/tunnel.d.ts.map +1 -0
- package/dist/cli/tunnel.js +43 -0
- package/dist/cli/tunnel.js.map +1 -0
- package/dist/cli/validators.d.ts +6 -0
- package/dist/cli/validators.d.ts.map +1 -0
- package/dist/cli/validators.js +14 -0
- package/dist/cli/validators.js.map +1 -0
- package/dist/define-service.d.ts +71 -0
- package/dist/define-service.d.ts.map +1 -0
- package/dist/define-service.js +86 -0
- package/dist/define-service.js.map +1 -0
- package/dist/gateway/config.d.ts +88 -0
- package/dist/gateway/config.d.ts.map +1 -0
- package/dist/gateway/config.js +201 -0
- package/dist/gateway/config.js.map +1 -0
- package/dist/gateway/openapi.d.ts +69 -0
- package/dist/gateway/openapi.d.ts.map +1 -0
- package/dist/gateway/openapi.js +677 -0
- package/dist/gateway/openapi.js.map +1 -0
- package/dist/gateway/upstream.d.ts +15 -0
- package/dist/gateway/upstream.d.ts.map +1 -0
- package/dist/gateway/upstream.js +95 -0
- package/dist/gateway/upstream.js.map +1 -0
- package/dist/http/bounded.d.ts +3 -0
- package/dist/http/bounded.d.ts.map +1 -0
- package/dist/http/bounded.js +23 -0
- package/dist/http/bounded.js.map +1 -0
- package/dist/http/node-server.d.ts +15 -0
- package/dist/http/node-server.d.ts.map +1 -0
- package/dist/http/node-server.js +120 -0
- package/dist/http/node-server.js.map +1 -0
- package/dist/http/rate-limit.d.ts +11 -0
- package/dist/http/rate-limit.d.ts.map +1 -0
- package/dist/http/rate-limit.js +35 -0
- package/dist/http/rate-limit.js.map +1 -0
- package/dist/http/router.d.ts +29 -0
- package/dist/http/router.d.ts.map +1 -0
- package/dist/http/router.js +329 -0
- package/dist/http/router.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/memory-store.d.ts +3 -0
- package/dist/jobs/memory-store.d.ts.map +1 -0
- package/dist/jobs/memory-store.js +121 -0
- package/dist/jobs/memory-store.js.map +1 -0
- package/dist/jobs/reconcile.d.ts +22 -0
- package/dist/jobs/reconcile.d.ts.map +1 -0
- package/dist/jobs/reconcile.js +82 -0
- package/dist/jobs/reconcile.js.map +1 -0
- package/dist/jobs/recovery.d.ts +19 -0
- package/dist/jobs/recovery.d.ts.map +1 -0
- package/dist/jobs/recovery.js +65 -0
- package/dist/jobs/recovery.js.map +1 -0
- package/dist/jobs/runner.d.ts +38 -0
- package/dist/jobs/runner.d.ts.map +1 -0
- package/dist/jobs/runner.js +194 -0
- package/dist/jobs/runner.js.map +1 -0
- package/dist/jobs/scheduler.d.ts +66 -0
- package/dist/jobs/scheduler.d.ts.map +1 -0
- package/dist/jobs/scheduler.js +197 -0
- package/dist/jobs/scheduler.js.map +1 -0
- package/dist/jobs/sqlite-store.d.ts +8 -0
- package/dist/jobs/sqlite-store.d.ts.map +1 -0
- package/dist/jobs/sqlite-store.js +231 -0
- package/dist/jobs/sqlite-store.js.map +1 -0
- package/dist/jobs/store.d.ts +118 -0
- package/dist/jobs/store.d.ts.map +1 -0
- package/dist/jobs/store.js +36 -0
- package/dist/jobs/store.js.map +1 -0
- package/dist/manifest.d.ts +11 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +99 -0
- package/dist/manifest.js.map +1 -0
- package/dist/payments/chain.d.ts +23 -0
- package/dist/payments/chain.d.ts.map +1 -0
- package/dist/payments/chain.js +108 -0
- package/dist/payments/chain.js.map +1 -0
- package/dist/payments/facilitator.d.ts +44 -0
- package/dist/payments/facilitator.d.ts.map +1 -0
- package/dist/payments/facilitator.js +125 -0
- package/dist/payments/facilitator.js.map +1 -0
- package/dist/payments/onchain.d.ts +36 -0
- package/dist/payments/onchain.d.ts.map +1 -0
- package/dist/payments/onchain.js +191 -0
- package/dist/payments/onchain.js.map +1 -0
- package/dist/payments/payload-checks.d.ts +22 -0
- package/dist/payments/payload-checks.d.ts.map +1 -0
- package/dist/payments/payload-checks.js +113 -0
- package/dist/payments/payload-checks.js.map +1 -0
- package/dist/payments/settlement.d.ts +22 -0
- package/dist/payments/settlement.d.ts.map +1 -0
- package/dist/payments/settlement.js +65 -0
- package/dist/payments/settlement.js.map +1 -0
- package/dist/payments/x402-server.d.ts +8 -0
- package/dist/payments/x402-server.d.ts.map +1 -0
- package/dist/payments/x402-server.js +74 -0
- package/dist/payments/x402-server.js.map +1 -0
- package/dist/provider.d.ts +63 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +177 -0
- package/dist/provider.js.map +1 -0
- package/dist/registration.d.ts +86 -0
- package/dist/registration.d.ts.map +1 -0
- package/dist/registration.js +162 -0
- package/dist/registration.js.map +1 -0
- package/dist/testing.d.ts +13 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +48 -0
- package/dist/testing.js.map +1 -0
- package/dist/validation-request.d.ts +36 -0
- package/dist/validation-request.d.ts.map +1 -0
- package/dist/validation-request.js +101 -0
- package/dist/validation-request.js.map +1 -0
- package/package.json +55 -4
- package/schemas/gateway-config.schema.json +140 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { parseArgs } from "node:util";
|
|
2
|
+
import type { StellarNetwork } from "@stellar-agent-services/protocol";
|
|
3
|
+
import { type RegistryReader } from "../registration.js";
|
|
4
|
+
import { type ApprovalOutcome, type ApprovalPlan } from "./approval.js";
|
|
5
|
+
import { type OwnerChain } from "./owner-chain.js";
|
|
6
|
+
export declare const OPTIONS: {
|
|
7
|
+
readonly config: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly short: "c";
|
|
10
|
+
};
|
|
11
|
+
readonly manifest: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
};
|
|
14
|
+
readonly port: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly short: "p";
|
|
17
|
+
};
|
|
18
|
+
readonly dev: {
|
|
19
|
+
readonly type: "boolean";
|
|
20
|
+
};
|
|
21
|
+
readonly "no-workers": {
|
|
22
|
+
readonly type: "boolean";
|
|
23
|
+
};
|
|
24
|
+
readonly "no-open": {
|
|
25
|
+
readonly type: "boolean";
|
|
26
|
+
};
|
|
27
|
+
readonly out: {
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly short: "o";
|
|
30
|
+
};
|
|
31
|
+
readonly upstream: {
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
};
|
|
34
|
+
readonly openapi: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
};
|
|
37
|
+
readonly source: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
};
|
|
40
|
+
readonly "agent-uri": {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
};
|
|
43
|
+
readonly validator: {
|
|
44
|
+
readonly type: "string";
|
|
45
|
+
};
|
|
46
|
+
readonly network: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
};
|
|
49
|
+
readonly store: {
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
};
|
|
52
|
+
readonly rpc: {
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
};
|
|
55
|
+
readonly "dry-run": {
|
|
56
|
+
readonly type: "boolean";
|
|
57
|
+
};
|
|
58
|
+
readonly yes: {
|
|
59
|
+
readonly type: "boolean";
|
|
60
|
+
readonly short: "y";
|
|
61
|
+
};
|
|
62
|
+
readonly help: {
|
|
63
|
+
readonly type: "boolean";
|
|
64
|
+
readonly short: "h";
|
|
65
|
+
};
|
|
66
|
+
readonly "env-file": {
|
|
67
|
+
readonly type: "string";
|
|
68
|
+
};
|
|
69
|
+
readonly with: {
|
|
70
|
+
readonly type: "string";
|
|
71
|
+
};
|
|
72
|
+
readonly tunnel: {
|
|
73
|
+
readonly type: "boolean";
|
|
74
|
+
};
|
|
75
|
+
readonly start: {
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
};
|
|
78
|
+
readonly url: {
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
};
|
|
81
|
+
readonly deploy: {
|
|
82
|
+
readonly type: "boolean";
|
|
83
|
+
};
|
|
84
|
+
readonly "no-deploy": {
|
|
85
|
+
readonly type: "boolean";
|
|
86
|
+
};
|
|
87
|
+
readonly "no-wait": {
|
|
88
|
+
readonly type: "boolean";
|
|
89
|
+
};
|
|
90
|
+
readonly "no-validation": {
|
|
91
|
+
readonly type: "boolean";
|
|
92
|
+
};
|
|
93
|
+
readonly validate: {
|
|
94
|
+
readonly type: "boolean";
|
|
95
|
+
};
|
|
96
|
+
readonly json: {
|
|
97
|
+
readonly type: "boolean";
|
|
98
|
+
};
|
|
99
|
+
readonly fix: {
|
|
100
|
+
readonly type: "boolean";
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export type CliFlags = ReturnType<typeof parseArgs<{
|
|
104
|
+
options: typeof OPTIONS;
|
|
105
|
+
allowPositionals: true;
|
|
106
|
+
}>>["values"];
|
|
107
|
+
/** The gateway config a command reads when --config doesn't name one: the one `provider-kit init` writes. */
|
|
108
|
+
export declare const DEFAULT_CONFIG = "provider.config.json";
|
|
109
|
+
/**
|
|
110
|
+
* How to run a step in this project: its npm script when ./package.json has one (`npm create stellar-service` writes
|
|
111
|
+
* them), else the provider-kit command.
|
|
112
|
+
*/
|
|
113
|
+
export declare function nextCommand(step: "dev" | "try" | "check" | "launch" | "status" | "deploy", fallback?: string): string;
|
|
114
|
+
/** A mistake in how the CLI was called: printed with the usage text, exit code 2. */
|
|
115
|
+
export declare class UsageError extends Error {
|
|
116
|
+
name: string;
|
|
117
|
+
}
|
|
118
|
+
/** Runs the Stellar CLI (https://developers.stellar.org/docs/tools/cli) and returns its standard output. */
|
|
119
|
+
export type StellarCli = (args: string[]) => Promise<string>;
|
|
120
|
+
/** The installed Stellar CLI, or undefined when it is not installed. */
|
|
121
|
+
export declare function findStellarCli(): Promise<StellarCli | undefined>;
|
|
122
|
+
/**
|
|
123
|
+
* Provider text on one terminal line: no control characters or direction overrides, which could rewrite what the
|
|
124
|
+
* terminal shows, and at most `max` characters.
|
|
125
|
+
*/
|
|
126
|
+
export declare function plain(text: string, max?: number): string;
|
|
127
|
+
/** Quotes an argument for copying into a shell. A $(...) placeholder stays a command substitution. */
|
|
128
|
+
export declare function quote(arg: string): string;
|
|
129
|
+
/** Where the owner commands (trustline, register, request-validation) reach the outside world. Tests replace it. */
|
|
130
|
+
export interface OwnerIo {
|
|
131
|
+
/** The Stellar CLI, or undefined when it is not installed: for --source. */
|
|
132
|
+
stellar(): Promise<StellarCli | undefined>;
|
|
133
|
+
registry(network: StellarNetwork, rpcUrl?: string): RegistryReader;
|
|
134
|
+
chain(network: StellarNetwork, rpcUrl?: string): OwnerChain;
|
|
135
|
+
/** Has the developer approve `plan` in their wallet: the local approval page. */
|
|
136
|
+
approve(plan: ApprovalPlan, chain: OwnerChain): Promise<ApprovalOutcome>;
|
|
137
|
+
now(): Date;
|
|
138
|
+
}
|
|
139
|
+
export declare function ownerIo(flags: CliFlags): OwnerIo;
|
|
140
|
+
/** --network as a network id: testnet or mainnet, also written pubnet, stellar:testnet or stellar:pubnet. */
|
|
141
|
+
export declare function parseNetwork(value: string): StellarNetwork;
|
|
142
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/cli/shared.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,C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E,OAAO,IAAI,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;IACnE,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5D,iFAAiF;IACjF,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IACzE,GAAG,IAAI,IAAI,CAAC;CACb;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAUhD;AAED,6GAA6G;AAC7G,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAI1D"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// What every CLI command shares: the flags, the usage error, and the two ways the owner's transactions are
|
|
2
|
+
// signed: in the owner's own wallet on a local approval page (cli/approval.ts), or with --source by the
|
|
3
|
+
// Stellar CLI, with a key from its keychain.
|
|
4
|
+
import { execFile } from "node:child_process";
|
|
5
|
+
import { readFileSync } from "node:fs";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
import { rpcRegistry } from "../registration.js";
|
|
8
|
+
import { approveInBrowser } from "./approval.js";
|
|
9
|
+
import { rpcOwnerChain } from "./owner-chain.js";
|
|
10
|
+
export const OPTIONS = {
|
|
11
|
+
config: { type: "string", short: "c" },
|
|
12
|
+
manifest: { type: "string" },
|
|
13
|
+
port: { type: "string", short: "p" },
|
|
14
|
+
dev: { type: "boolean" },
|
|
15
|
+
"no-workers": { type: "boolean" },
|
|
16
|
+
"no-open": { type: "boolean" },
|
|
17
|
+
out: { type: "string", short: "o" },
|
|
18
|
+
upstream: { type: "string" },
|
|
19
|
+
openapi: { type: "string" },
|
|
20
|
+
source: { type: "string" },
|
|
21
|
+
"agent-uri": { type: "string" },
|
|
22
|
+
validator: { type: "string" },
|
|
23
|
+
network: { type: "string" },
|
|
24
|
+
store: { type: "string" },
|
|
25
|
+
rpc: { type: "string" },
|
|
26
|
+
"dry-run": { type: "boolean" },
|
|
27
|
+
yes: { type: "boolean", short: "y" },
|
|
28
|
+
help: { type: "boolean", short: "h" },
|
|
29
|
+
// dev, launch, status and try
|
|
30
|
+
"env-file": { type: "string" },
|
|
31
|
+
with: { type: "string" },
|
|
32
|
+
tunnel: { type: "boolean" },
|
|
33
|
+
start: { type: "string" },
|
|
34
|
+
url: { type: "string" },
|
|
35
|
+
deploy: { type: "boolean" },
|
|
36
|
+
"no-deploy": { type: "boolean" },
|
|
37
|
+
"no-wait": { type: "boolean" },
|
|
38
|
+
"no-validation": { type: "boolean" },
|
|
39
|
+
validate: { type: "boolean" },
|
|
40
|
+
// check and status
|
|
41
|
+
json: { type: "boolean" },
|
|
42
|
+
fix: { type: "boolean" },
|
|
43
|
+
};
|
|
44
|
+
/** The gateway config a command reads when --config doesn't name one: the one `provider-kit init` writes. */
|
|
45
|
+
export const DEFAULT_CONFIG = "provider.config.json";
|
|
46
|
+
/**
|
|
47
|
+
* How to run a step in this project: its npm script when ./package.json has one (`npm create stellar-service` writes
|
|
48
|
+
* them), else the provider-kit command.
|
|
49
|
+
*/
|
|
50
|
+
export function nextCommand(step, fallback = `provider-kit ${step}`) {
|
|
51
|
+
try {
|
|
52
|
+
const scripts = JSON.parse(readFileSync("package.json", "utf8")).scripts;
|
|
53
|
+
if (typeof scripts?.[step] === "string")
|
|
54
|
+
return `npm run ${step}`;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// No package.json here, or not one to read.
|
|
58
|
+
}
|
|
59
|
+
return fallback;
|
|
60
|
+
}
|
|
61
|
+
/** A mistake in how the CLI was called: printed with the usage text, exit code 2. */
|
|
62
|
+
export class UsageError extends Error {
|
|
63
|
+
name = "UsageError";
|
|
64
|
+
}
|
|
65
|
+
const run = promisify(execFile);
|
|
66
|
+
/** The installed Stellar CLI, or undefined when it is not installed. */
|
|
67
|
+
export async function findStellarCli() {
|
|
68
|
+
try {
|
|
69
|
+
await run("stellar", ["--version"], { timeout: 10_000 });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
return async (args) => (await run("stellar", args, { timeout: 120_000, maxBuffer: 1024 * 1024 })).stdout;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Provider text on one terminal line: no control characters or direction overrides, which could rewrite what the
|
|
78
|
+
* terminal shows, and at most `max` characters.
|
|
79
|
+
*/
|
|
80
|
+
export function plain(text, max = 80) {
|
|
81
|
+
const line = text.replace(/[\u0000-\u001f\u007f-\u009f--]+/g, " ").trim();
|
|
82
|
+
return line.length > max ? `${line.slice(0, max - 1)}…` : line;
|
|
83
|
+
}
|
|
84
|
+
/** Quotes an argument for copying into a shell. A $(...) placeholder stays a command substitution. */
|
|
85
|
+
export function quote(arg) {
|
|
86
|
+
if (arg.startsWith("$("))
|
|
87
|
+
return `"${arg}"`;
|
|
88
|
+
return /^[\w@%+=:,./-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", "'\\''")}'`;
|
|
89
|
+
}
|
|
90
|
+
export function ownerIo(flags) {
|
|
91
|
+
const port = flags.port === undefined ? undefined : Number(flags.port);
|
|
92
|
+
if (port !== undefined && !(Number.isInteger(port) && port > 0 && port < 65536))
|
|
93
|
+
throw new UsageError("--port must be a port number");
|
|
94
|
+
return {
|
|
95
|
+
stellar: findStellarCli,
|
|
96
|
+
registry: rpcRegistry,
|
|
97
|
+
chain: rpcOwnerChain,
|
|
98
|
+
approve: (plan, chain) => approveInBrowser(plan, chain, { open: !flags["no-open"], ...(port === undefined ? {} : { port }) }),
|
|
99
|
+
now: () => new Date(),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/** --network as a network id: testnet or mainnet, also written pubnet, stellar:testnet or stellar:pubnet. */
|
|
103
|
+
export function parseNetwork(value) {
|
|
104
|
+
if (["testnet", "stellar:testnet"].includes(value))
|
|
105
|
+
return "stellar:testnet";
|
|
106
|
+
if (["mainnet", "pubnet", "public", "stellar:pubnet"].includes(value))
|
|
107
|
+
return "stellar:pubnet";
|
|
108
|
+
throw new UsageError(`--network must be testnet or mainnet, not "${value}"`);
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/cli/shared.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,wGAAwG;AACxG,6CAA6C;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,WAAW,EAAuB,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAA2C,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAmB,MAAM,kBAAkB,CAAC;AAElE,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;IACtC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC5B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;IACpC,GAAG,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IACxB,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;IAC9B,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE;IACnC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC5B,OAAO,EAAE,EAAE,IAAI,E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;IACxC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAC;IAC7E,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,gBAAgB,CAAC;IAC/F,MAAM,IAAI,UAAU,CAAC,8CAA8C,KAAK,GAAG,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type StellarNetwork } from "@stellar-agent-services/protocol";
|
|
2
|
+
import { type RegistryReader } from "../registration.js";
|
|
3
|
+
import { type OwnerChain } from "./owner-chain.js";
|
|
4
|
+
import { type CliFlags } from "./shared.js";
|
|
5
|
+
export type StageId = "local" | "payTo" | "paid" | "registered" | "live" | "verified";
|
|
6
|
+
export interface Stage {
|
|
7
|
+
id: StageId;
|
|
8
|
+
/** true: done; false: not yet; null: can't tell from here. */
|
|
9
|
+
ok: boolean | null;
|
|
10
|
+
detail: string;
|
|
11
|
+
}
|
|
12
|
+
export interface Status {
|
|
13
|
+
network: StellarNetwork;
|
|
14
|
+
stages: Stage[];
|
|
15
|
+
next: {
|
|
16
|
+
command?: string;
|
|
17
|
+
why: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Where `status` reaches the outside world. Tests replace it. */
|
|
21
|
+
export interface StatusIo {
|
|
22
|
+
log(line: string): void;
|
|
23
|
+
fetch: typeof fetch;
|
|
24
|
+
chain(network: StellarNetwork, rpcUrl?: string): OwnerChain;
|
|
25
|
+
registry(network: StellarNetwork, rpcUrl?: string): RegistryReader;
|
|
26
|
+
env: NodeJS.ProcessEnv;
|
|
27
|
+
}
|
|
28
|
+
export declare function statusIo(): StatusIo;
|
|
29
|
+
export declare function status(flags: CliFlags, io?: StatusIo): Promise<number>;
|
|
30
|
+
/** Every stage, read from this computer, the chain and the public address. */
|
|
31
|
+
export declare function findStatus(flags: CliFlags, io: StatusIo): Promise<Status>;
|
|
32
|
+
//# sourceMappingURL=status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/cli/status.ts"],"names":[],"mappings":"AAcA,OAAO,EAA0F,KAAK,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAG/J,OAAO,EAA+D,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAItH,OAAO,EAA4C,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAAkD,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5F,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC;AAEtF,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,8DAA8D;IAC9D,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACrB,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,IAAI,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC;AAED,kEAAkE;AAClE,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,KAAK,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5D,QAAQ,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;IACnE,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB;AAED,wBAAgB,QAAQ,IAAI,QAAQ,CAQnC;AAKD,wBAAsB,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,GAAE,QAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAaxF;AAED,8EAA8E;AAC9E,wBAAsB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAiH/E"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// provider-kit status: where a provider stands, from this computer to verified, and the one command to run next
|
|
2
|
+
// (docs/provider-setup-guide.md). --json prints the same for scripts and coding agents.
|
|
3
|
+
//
|
|
4
|
+
// local the provider on this computer answers, with a manifest that passes the standard
|
|
5
|
+
// payTo PAY_TO: a throwaway testnet account (provider-kit dev made it) or yours, with a USDC trustline [P2]
|
|
6
|
+
// paid payTo holds USDC: a paid call reached it
|
|
7
|
+
// registered the agent (AGENT_ID) exists, its registration lists the public manifest and its wallet is payTo [I1]–[I3]
|
|
8
|
+
// live the public manifest answers, naming the agent [I2]
|
|
9
|
+
// verified a verifier answered a validation request for the agent (docs/verification.md)
|
|
10
|
+
// The public manifest comes from --url, fly.toml or an https:// PUBLIC_ORIGIN, else from the registration itself.
|
|
11
|
+
// It only reads: no key, no payment, no transaction.
|
|
12
|
+
import { existsSync } from "node:fs";
|
|
13
|
+
import { readFile } from "node:fs/promises";
|
|
14
|
+
import { DEFAULT_MANIFEST_PATH, HORIZON_URL, USDC_ISSUER, VALIDATION_TAG } from "@stellar-agent-services/protocol";
|
|
15
|
+
import { DEFAULT_PORT, gatewayManifestUrl } from "../gateway/config.js";
|
|
16
|
+
import { checkManifest } from "../manifest.js";
|
|
17
|
+
import { inspectRegistration, REGISTRATION_SERVICE_NAME, rpcRegistry } from "../registration.js";
|
|
18
|
+
import { payToKind } from "./dev-account.js";
|
|
19
|
+
import { ENV_FILE, loadEnvFile } from "./env-file.js";
|
|
20
|
+
import { FLY_TOML, flyApp } from "./fly.js";
|
|
21
|
+
import { networkName, rpcOwnerChain, shortAddress } from "./owner-chain.js";
|
|
22
|
+
import { DEFAULT_CONFIG, nextCommand, plain, UsageError } from "./shared.js";
|
|
23
|
+
export function statusIo() {
|
|
24
|
+
return {
|
|
25
|
+
log: (line) => console.log(line),
|
|
26
|
+
fetch: (input, init) => fetch(input, init),
|
|
27
|
+
chain: rpcOwnerChain,
|
|
28
|
+
registry: rpcRegistry,
|
|
29
|
+
env: process.env,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const MARK = { true: "✓", false: "✗", null: "·" };
|
|
33
|
+
const TIMEOUT_MS = 8000;
|
|
34
|
+
export async function status(flags, io = statusIo()) {
|
|
35
|
+
const envFile = flags["env-file"] ?? ENV_FILE;
|
|
36
|
+
if (flags["env-file"] !== undefined && !existsSync(envFile))
|
|
37
|
+
throw new UsageError(`${envFile} doesn't exist`);
|
|
38
|
+
await loadEnvFile(envFile, io.env);
|
|
39
|
+
const result = await findStatus(flags, io);
|
|
40
|
+
if (flags.json) {
|
|
41
|
+
io.log(JSON.stringify(result, null, 2));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
io.log(`Status on ${networkName(result.network)}`);
|
|
45
|
+
for (const stage of result.stages)
|
|
46
|
+
io.log(` ${MARK[String(stage.ok)]} ${stage.id.padEnd(10)} ${stage.detail}`);
|
|
47
|
+
io.log(`\nNext: ${result.next.command === undefined ? result.next.why : `${result.next.command} ${result.next.why}`}`);
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
/** Every stage, read from this computer, the chain and the public address. */
|
|
52
|
+
export async function findStatus(flags, io) {
|
|
53
|
+
const config = flags.config ?? (existsSync(DEFAULT_CONFIG) ? DEFAULT_CONFIG : undefined);
|
|
54
|
+
const configFile = config === undefined ? undefined : await readConfig(config);
|
|
55
|
+
// local
|
|
56
|
+
const localUrl = flags.manifest ?? (await localManifestUrl(config, io.env));
|
|
57
|
+
const local = await readManifest(io.fetch, localUrl);
|
|
58
|
+
const localProblems = local.manifest === undefined ? [] : checkManifest(local.manifest, localUrl, true);
|
|
59
|
+
const stages = [
|
|
60
|
+
local.manifest === undefined
|
|
61
|
+
? { id: "local", ok: false, detail: `nothing serves ${localUrl}: ${local.problem}` }
|
|
62
|
+
: localProblems.length > 0
|
|
63
|
+
? { id: "local", ok: false, detail: `${localUrl} fails the standard: [${localProblems[0].rule}] ${localProblems[0].message}` }
|
|
64
|
+
: { id: "local", ok: true, detail: `${plain(local.manifest.provider.name, 60)} runs at ${localUrl}` },
|
|
65
|
+
];
|
|
66
|
+
const network = local.manifest?.payment.accepts[0].network ?? configFile?.network ?? (io.env["STELLAR_NETWORK"] === "stellar:pubnet" ? "stellar:pubnet" : "stellar:testnet");
|
|
67
|
+
const chain = io.chain(network, flags.rpc);
|
|
68
|
+
const registry = io.registry(network, flags.rpc);
|
|
69
|
+
// payTo and paid
|
|
70
|
+
const kind = payToKind(io.env);
|
|
71
|
+
const payTo = kind === "unset" ? local.manifest?.payment.accepts[0].payTo : io.env["PAY_TO"];
|
|
72
|
+
let paidUsdc;
|
|
73
|
+
if (payTo === undefined) {
|
|
74
|
+
stages.push({
|
|
75
|
+
id: "payTo",
|
|
76
|
+
ok: false,
|
|
77
|
+
detail: network === "stellar:testnet" ? "PAY_TO is empty: provider-kit dev makes a throwaway testnet account, launch connects your wallet" : "PAY_TO is empty: launch connects your wallet",
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const what = kind === "throwaway" ? "a throwaway testnet account (test payments only)" : "your account";
|
|
82
|
+
try {
|
|
83
|
+
const account = payTo.startsWith("C") ? { exists: true, usdcTrustline: true } : await chain.account(payTo);
|
|
84
|
+
stages.push(!account.exists
|
|
85
|
+
? { id: "payTo", ok: false, detail: `${shortAddress(payTo)} doesn't exist on ${networkName(network)}` }
|
|
86
|
+
: !account.usdcTrustline
|
|
87
|
+
? { id: "payTo", ok: false, detail: `${shortAddress(payTo)}, ${what}, has no USDC trustline [P2]` }
|
|
88
|
+
: { id: "payTo", ok: true, detail: `${shortAddress(payTo)}, ${what}, can receive USDC` });
|
|
89
|
+
paidUsdc = account.exists ? await usdcBalance(io.fetch, network, payTo) : undefined;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
stages.push({ id: "payTo", ok: null, detail: `the chain can't be read: ${error.message}` });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
stages.push(paidUsdc === undefined
|
|
96
|
+
? { id: "paid", ok: null, detail: "payTo's USDC balance can't be read" }
|
|
97
|
+
: Number(paidUsdc) > 0
|
|
98
|
+
? { id: "paid", ok: true, detail: `payTo holds ${paidUsdc} USDC: paid calls reached it` }
|
|
99
|
+
: { id: "paid", ok: false, detail: "payTo holds no USDC yet: no paid call has reached it" });
|
|
100
|
+
// registered, live, verified
|
|
101
|
+
const agentText = io.env["AGENT_ID"] !== undefined && io.env["AGENT_ID"] !== "" ? io.env["AGENT_ID"] : configFile?.agentId;
|
|
102
|
+
const agentId = agentText === undefined ? undefined : Number(agentText);
|
|
103
|
+
const fly = await flyApp(FLY_TOML);
|
|
104
|
+
const origin = flags.url ?? fly?.origin ?? (io.env["PUBLIC_ORIGIN"]?.startsWith("https://") ? io.env["PUBLIC_ORIGIN"] : undefined);
|
|
105
|
+
let publicUrl = origin === undefined ? undefined : new URL(DEFAULT_MANIFEST_PATH, new URL(origin).origin).toString();
|
|
106
|
+
let registered = false;
|
|
107
|
+
if (agentId === undefined || !Number.isInteger(agentId)) {
|
|
108
|
+
stages.push({ id: "registered", ok: false, detail: "no AGENT_ID: not registered in Stellar 8004 yet" });
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
try {
|
|
112
|
+
// Read once for the manifest URL the registration names, when nothing here says where the service lives.
|
|
113
|
+
const probe = await inspectRegistration(pretend(network, agentId, payTo ?? ""), publicUrl ?? "", { registry, fetch: io.fetch });
|
|
114
|
+
publicUrl ??= listedManifest(probe.file);
|
|
115
|
+
const { findings } = publicUrl === undefined ? probe : await inspectRegistration(pretend(network, agentId, payTo ?? ""), publicUrl, { registry, fetch: io.fetch });
|
|
116
|
+
const failed = findings.filter((finding) => !finding.ok);
|
|
117
|
+
registered = failed.length === 0;
|
|
118
|
+
stages.push(registered ? { id: "registered", ok: true, detail: `agent ${agentId}: its registration lists ${publicUrl}, its wallet is payTo` } : { id: "registered", ok: false, detail: `agent ${agentId}: [${failed[0].rule}] ${failed[0].message}` });
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
stages.push({ id: "registered", ok: null, detail: `the identity registry can't be read: ${error.message}` });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
let live = false;
|
|
125
|
+
if (publicUrl === undefined) {
|
|
126
|
+
stages.push({ id: "live", ok: false, detail: "no public address yet: launch takes one from --url, fly.toml or PUBLIC_ORIGIN" });
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
const served = await readManifest(io.fetch, publicUrl);
|
|
130
|
+
if (served.manifest === undefined) {
|
|
131
|
+
stages.push({ id: "live", ok: false, detail: `${publicUrl}: ${served.problem}` });
|
|
132
|
+
}
|
|
133
|
+
else if (agentId !== undefined && served.manifest.provider.agentId !== agentId) {
|
|
134
|
+
stages.push({ id: "live", ok: false, detail: `${publicUrl} answers, but names ${served.manifest.provider.agentId === undefined ? "no agent" : `agent ${served.manifest.provider.agentId}`}, not ${agentId}: deploy again [I2]` });
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
live = true;
|
|
138
|
+
stages.push({ id: "live", ok: true, detail: `${publicUrl} answers` });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
let verified = false;
|
|
142
|
+
let requested;
|
|
143
|
+
if (agentId === undefined || !Number.isInteger(agentId)) {
|
|
144
|
+
stages.push({ id: "verified", ok: false, detail: "not registered, so there is nothing to verify yet" });
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
try {
|
|
148
|
+
const records = (await registry.agentValidations(agentId)).filter((record) => record.tag === VALIDATION_TAG || !record.hasResponse);
|
|
149
|
+
const answered = records.filter((record) => record.hasResponse).at(-1);
|
|
150
|
+
requested = records.at(-1)?.validator;
|
|
151
|
+
if (answered !== undefined) {
|
|
152
|
+
verified = true;
|
|
153
|
+
stages.push({ id: "verified", ok: true, detail: `${shortAddress(answered.validator)} answered with ${answered.response} of 100` });
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
stages.push({ id: "verified", ok: false, detail: requested === undefined ? "no validation requested" : `requested from ${shortAddress(requested)}, no answer yet` });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
stages.push({ id: "verified", ok: null, detail: `the Validation Registry can't be read: ${error.message}` });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return { network, stages, next: whatNext({ network, local: local.manifest !== undefined, paid: Number(paidUsdc ?? 0) > 0, kind, registered, live, verified, requested, fly: fly !== undefined }) };
|
|
164
|
+
}
|
|
165
|
+
function whatNext(state) {
|
|
166
|
+
const launch = { command: nextCommand("launch"), why: "connects your wallet, registers the service and deploys it" };
|
|
167
|
+
if (state.registered && state.live && state.verified)
|
|
168
|
+
return { why: "Nothing: agents can find it, pay it and check its verification." };
|
|
169
|
+
if (state.registered && state.live) {
|
|
170
|
+
return state.requested === undefined
|
|
171
|
+
? { command: `${nextCommand("launch")} --validator <G...>`, why: "asks a verifier to check it" }
|
|
172
|
+
: { why: `Waiting for the verifier ${shortAddress(state.requested)} to answer: it checks the service and answers on chain.` };
|
|
173
|
+
}
|
|
174
|
+
if (state.registered)
|
|
175
|
+
return { command: state.fly ? nextCommand("deploy", "fly deploy --ha=false") : "deploy it", why: "serves the manifest with the agent id at the public address" };
|
|
176
|
+
// Testnet has test money and throwaway accounts: run it and pay it before launching. Mainnet has neither.
|
|
177
|
+
if (state.network !== "stellar:testnet")
|
|
178
|
+
return launch;
|
|
179
|
+
if (!state.local)
|
|
180
|
+
return { command: nextCommand("dev"), why: "runs it on this computer, with no wallet needed" };
|
|
181
|
+
if (!state.paid && state.kind !== "yours")
|
|
182
|
+
return { command: nextCommand("try"), why: "pays for one call with test money" };
|
|
183
|
+
return launch;
|
|
184
|
+
}
|
|
185
|
+
/** The fields of a manifest inspectRegistration() reads, for a provider known by its agent id and payTo. */
|
|
186
|
+
function pretend(network, agentId, payTo) {
|
|
187
|
+
return { provider: { name: "", agentId }, payment: { accepts: [{ network, payTo }] } };
|
|
188
|
+
}
|
|
189
|
+
/** The manifest URL a registration file lists [I1]. */
|
|
190
|
+
function listedManifest(file) {
|
|
191
|
+
const services = Array.isArray(file?.["services"]) ? file["services"] : [];
|
|
192
|
+
const endpoint = services.find((service) => service.name === REGISTRATION_SERVICE_NAME)?.endpoint;
|
|
193
|
+
return typeof endpoint === "string" && endpoint.startsWith("https://") ? endpoint : undefined;
|
|
194
|
+
}
|
|
195
|
+
async function readConfig(path) {
|
|
196
|
+
try {
|
|
197
|
+
const file = JSON.parse(await readFile(path, "utf8"));
|
|
198
|
+
const network = file.network === "stellar:testnet" || file.network === "stellar:pubnet" ? file.network : undefined;
|
|
199
|
+
const agentId = typeof file.provider?.agentId === "number" ? String(file.provider.agentId) : undefined;
|
|
200
|
+
return { ...(network === undefined ? {} : { network }), ...(agentId === undefined ? {} : { agentId }) };
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return undefined;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/** The local provider's manifest URL: the gateway config's, when it is on this computer, else the default port. */
|
|
207
|
+
async function localManifestUrl(config, env) {
|
|
208
|
+
if (config !== undefined) {
|
|
209
|
+
try {
|
|
210
|
+
const url = await gatewayManifestUrl(config, env);
|
|
211
|
+
if (/^http:\/\/(localhost|127\.0\.0\.1)[:/]/.test(url))
|
|
212
|
+
return url;
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
// A config whose baseUrl isn't set here: the default port, below.
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return new URL(DEFAULT_MANIFEST_PATH, `http://localhost:${env["PORT"] ?? DEFAULT_PORT}`).toString();
|
|
219
|
+
}
|
|
220
|
+
async function readManifest(fetcher, url) {
|
|
221
|
+
try {
|
|
222
|
+
const response = await fetcher(url, { redirect: "manual", headers: { Accept: "application/json" }, signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
223
|
+
if (response.status !== 200) {
|
|
224
|
+
await response.body?.cancel();
|
|
225
|
+
return { problem: `it answered ${response.status}` };
|
|
226
|
+
}
|
|
227
|
+
return { manifest: (await response.json()) };
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
return { problem: error instanceof TypeError ? "nothing answers" : error.message };
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** payTo's USDC balance from Horizon, such as "0.0300000", or undefined when it can't be read. */
|
|
234
|
+
async function usdcBalance(fetcher, network, payTo) {
|
|
235
|
+
if (payTo.startsWith("C"))
|
|
236
|
+
return undefined;
|
|
237
|
+
try {
|
|
238
|
+
const response = await fetcher(`${HORIZON_URL[network]}/accounts/${payTo}`, { signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
239
|
+
if (!response.ok)
|
|
240
|
+
return undefined;
|
|
241
|
+
const account = (await response.json());
|
|
242
|
+
return account.balances.find((balance) => balance.asset_code === "USDC" && balance.asset_issuer === USDC_ISSUER[network])?.balance ?? "0";
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
return undefined;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../src/cli/status.ts"],"names":[],"mappings":"AAAA,gHAAgH;AAChH,wFAAwF;AACxF,EAAE;AACF,gGAAgG;AAChG,oHAAoH;AACpH,yDAAyD;AACzD,0HAA0H;AAC1H,mEAAmE;AACnE,8FAA8F;AAC9F,kHAAkH;AAClH,qDAAqD;AAEr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,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACzH,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,OAAO,SAAS,CAAC;QACnC,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAoF,CAAC;QAC3H,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,KAAK,MAAM,IAAI,OAAO,CAAC,YAAY,KAAK,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,OAAO,IAAI,GAAG,CAAC;IAC5I,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type ProviderManifest } from "@stellar-agent-services/protocol";
|
|
2
|
+
import type { Facilitator } from "../payments/facilitator.js";
|
|
3
|
+
import { type CliFlags } from "./shared.js";
|
|
4
|
+
export type Target = {
|
|
5
|
+
manifest: ProviderManifest;
|
|
6
|
+
manifestUrl: string;
|
|
7
|
+
facilitator?: Facilitator;
|
|
8
|
+
source: string;
|
|
9
|
+
} | {
|
|
10
|
+
problems: string[];
|
|
11
|
+
source: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function loadTarget(flags: CliFlags): Promise<Target>;
|
|
14
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../src/cli/target.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAG7F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,MAAM,GACd;IAAE,QAAQ,EAAE,gBAAgB,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC9F;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C,wBAAsB,UAAU,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BjE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// The provider a CLI command looks at: built from a gateway config (--config), or fetched from a
|
|
2
|
+
// running provider of any kind, library, gateway or native (--manifest).
|
|
3
|
+
import { MANIFEST_MAX_BYTES } from "@stellar-agent-services/protocol";
|
|
4
|
+
import { loadGatewayConfig } from "../gateway/config.js";
|
|
5
|
+
import { checkManifest } from "../manifest.js";
|
|
6
|
+
import { createProvider } from "../provider.js";
|
|
7
|
+
import { UsageError } from "./shared.js";
|
|
8
|
+
export async function loadTarget(flags) {
|
|
9
|
+
if ((flags.config === undefined) === (flags.manifest === undefined))
|
|
10
|
+
throw new UsageError("pass --config <file> or --manifest <url>");
|
|
11
|
+
if (flags.config !== undefined) {
|
|
12
|
+
const source = flags.config;
|
|
13
|
+
const { config } = await loadGatewayConfig(source, { openStore: false, overrides: flags.dev ? { dev: true } : {} });
|
|
14
|
+
try {
|
|
15
|
+
const provider = createProvider(config);
|
|
16
|
+
await provider.close();
|
|
17
|
+
const facilitator = typeof config.facilitator === "string" ? undefined : config.facilitator;
|
|
18
|
+
return { manifest: provider.manifest, manifestUrl: provider.manifestUrl, source, ...(facilitator === undefined ? {} : { facilitator }) };
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return { problems: [error.message], source };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const url = flags.manifest;
|
|
25
|
+
const response = await fetch(url, { redirect: "manual", headers: { Accept: "application/json" }, signal: AbortSignal.timeout(15_000) });
|
|
26
|
+
if (response.status !== 200)
|
|
27
|
+
return { problems: [`[M1] the manifest answered ${response.status}; redirects are not followed [M3]`], source: url };
|
|
28
|
+
const text = await response.text();
|
|
29
|
+
if (Buffer.byteLength(text) > MANIFEST_MAX_BYTES)
|
|
30
|
+
return { problems: ["[M3] the manifest is larger than 256 KiB"], source: url };
|
|
31
|
+
let manifest;
|
|
32
|
+
try {
|
|
33
|
+
manifest = JSON.parse(text);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { problems: ["the manifest is not valid JSON"], source: url };
|
|
37
|
+
}
|
|
38
|
+
const violations = checkManifest(manifest, url, flags.dev ?? false);
|
|
39
|
+
if (violations.length > 0)
|
|
40
|
+
return { problems: violations.map((violation) => `[${violation.rule}] ${violation.pointer || "/"}: ${violation.message}`), source: url };
|
|
41
|
+
return { manifest, manifestUrl: url, source: url };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=target.js.map
|