@trusty-squire/mcp 0.1.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/LICENSE +21 -0
- package/README.md +83 -0
- package/dist/api-client.d.ts +130 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +156 -0
- package/dist/api-client.js.map +1 -0
- package/dist/install/agents.d.ts +16 -0
- package/dist/install/agents.d.ts.map +1 -0
- package/dist/install/agents.js +171 -0
- package/dist/install/agents.js.map +1 -0
- package/dist/install/cli.d.ts +24 -0
- package/dist/install/cli.d.ts.map +1 -0
- package/dist/install/cli.js +277 -0
- package/dist/install/cli.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +100 -0
- package/dist/server.js.map +1 -0
- package/dist/session.d.ts +25 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +112 -0
- package/dist/session.js.map +1 -0
- package/dist/tools/cancel.d.ts +12 -0
- package/dist/tools/cancel.d.ts.map +1 -0
- package/dist/tools/cancel.js +34 -0
- package/dist/tools/cancel.js.map +1 -0
- package/dist/tools/get-credential.d.ts +15 -0
- package/dist/tools/get-credential.d.ts.map +1 -0
- package/dist/tools/get-credential.js +44 -0
- package/dist/tools/get-credential.js.map +1 -0
- package/dist/tools/get-usage.d.ts +6 -0
- package/dist/tools/get-usage.d.ts.map +1 -0
- package/dist/tools/get-usage.js +24 -0
- package/dist/tools/get-usage.js.map +1 -0
- package/dist/tools/index.d.ts +23 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +48 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/list-services.d.ts +15 -0
- package/dist/tools/list-services.d.ts.map +1 -0
- package/dist/tools/list-services.js +55 -0
- package/dist/tools/list-services.js.map +1 -0
- package/dist/tools/list-subscriptions.d.ts +6 -0
- package/dist/tools/list-subscriptions.d.ts.map +1 -0
- package/dist/tools/list-subscriptions.js +25 -0
- package/dist/tools/list-subscriptions.js.map +1 -0
- package/dist/tools/provision-any.d.ts +120 -0
- package/dist/tools/provision-any.d.ts.map +1 -0
- package/dist/tools/provision-any.js +243 -0
- package/dist/tools/provision-any.js.map +1 -0
- package/dist/tools/provision.d.ts +30 -0
- package/dist/tools/provision.d.ts.map +1 -0
- package/dist/tools/provision.js +108 -0
- package/dist/tools/provision.js.map +1 -0
- package/dist/tools/rotate-credential.d.ts +12 -0
- package/dist/tools/rotate-credential.d.ts.map +1 -0
- package/dist/tools/rotate-credential.js +43 -0
- package/dist/tools/rotate-credential.js.map +1 -0
- package/dist/tools/wait-for-approval.d.ts +28 -0
- package/dist/tools/wait-for-approval.d.ts.map +1 -0
- package/dist/tools/wait-for-approval.js +82 -0
- package/dist/tools/wait-for-approval.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Trusty Squire
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# mcp
|
|
2
|
+
|
|
3
|
+
Local MCP server vibe coding agents (Claude Code, Cursor, Goose, Cline, Continue) install. Thin relay translating MCP tool calls into HTTP calls against the Trusty Squire API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx @trusty-squire/mcp install
|
|
9
|
+
# or specify a target explicitly:
|
|
10
|
+
npx @trusty-squire/mcp install --target=claude-code
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The CLI:
|
|
14
|
+
1. Detects installed coding agents (when `--target` is omitted).
|
|
15
|
+
2. Generates a one-time pairing token via `POST /v1/mcp/pair/initiate`.
|
|
16
|
+
3. Opens your browser to `https://app.trustysquire.ai/pair?token=…`.
|
|
17
|
+
4. Polls the API. Once you complete the browser flow with a passkey, the CLI receives the agent session token.
|
|
18
|
+
5. Saves the session to your OS keychain (or a `0600` file fallback when keytar isn't available).
|
|
19
|
+
6. Writes the MCP server config into the target agent's config file. Existing entries are preserved.
|
|
20
|
+
|
|
21
|
+
After install, restart your coding agent to pick up the eight squire tools.
|
|
22
|
+
|
|
23
|
+
## Tools
|
|
24
|
+
|
|
25
|
+
| Tool | Purpose |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `provision` | Sign up for a SaaS service on the user's behalf, returning working credentials |
|
|
28
|
+
| `wait_for_approval` | Poll a run until it leaves PENDING_APPROVAL or times out |
|
|
29
|
+
| `get_credential` | Retrieve a vault-stored credential (audit-logged) |
|
|
30
|
+
| `list_services` | Browse the adapter directory by category or query |
|
|
31
|
+
| `list_subscriptions` | List the user's active subscriptions |
|
|
32
|
+
| `cancel` | Cancel a subscription (v0 stub — flow selector lands later) |
|
|
33
|
+
| `get_usage` | Report monthly + daily spending vs the user's mandate budget |
|
|
34
|
+
| `rotate_credential` | Rotate a credential (v0 stub — same reason as cancel) |
|
|
35
|
+
|
|
36
|
+
Every tool's description is hand-tuned to drive agent behavior — the assistant reads them and decides when to call, so the wording matters more than the JSON schema.
|
|
37
|
+
|
|
38
|
+
## Logout
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npx @trusty-squire/mcp logout
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Clears the local session. The browser-side AgentSession row remains revocable via the PWA's settings page.
|
|
45
|
+
|
|
46
|
+
## Agent config locations
|
|
47
|
+
|
|
48
|
+
| Agent | File |
|
|
49
|
+
|---|---|
|
|
50
|
+
| Claude Code | `~/.claude/mcp.json` |
|
|
51
|
+
| Cursor | `~/.cursor/mcp.json` (or `.cursor/mcp.json` for project-scoped) |
|
|
52
|
+
| Goose | `$XDG_CONFIG_HOME/goose/profiles.yaml` (default `~/.config/goose/profiles.yaml`) |
|
|
53
|
+
| Cline | `~/.cline/mcp_config.json` |
|
|
54
|
+
| Continue | `~/.continue/config.yaml` |
|
|
55
|
+
|
|
56
|
+
Each writer is idempotent: rerunning `install` won't duplicate entries.
|
|
57
|
+
|
|
58
|
+
## Session storage
|
|
59
|
+
|
|
60
|
+
By default the CLI saves the session to the OS keychain via [keytar](https://github.com/atom/node-keytar). When keytar isn't available — minimal Linux containers without `libsecret-1-dev`, CI machines — the CLI silently falls back to a file at `$XDG_CONFIG_HOME/trusty-squire/session.json` (default `~/.config/trusty-squire/session.json`), permissions `0600`.
|
|
61
|
+
|
|
62
|
+
## Environment variables
|
|
63
|
+
|
|
64
|
+
| Var | Default | Purpose |
|
|
65
|
+
|---|---|---|
|
|
66
|
+
| `TRUSTY_SQUIRE_API_BASE` | `https://api.trustysquire.ai` | API gateway URL |
|
|
67
|
+
| `ADAPTER_REGISTRY_URL` | `https://registry.trustysquire.ai` | Adapter registry (read by `list_services`) |
|
|
68
|
+
| `TRUSTY_SQUIRE_AGENT_IDENTITY` | `unknown` | Self-reported agent identity in audit headers |
|
|
69
|
+
|
|
70
|
+
For local dev against your own API at `localhost:3000`:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
TRUSTY_SQUIRE_API_BASE=http://localhost:3000 \
|
|
74
|
+
ADAPTER_REGISTRY_URL=http://localhost:3001 \
|
|
75
|
+
npx @trusty-squire/mcp install --target=claude-code --api-base=http://localhost:3000
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## What this server does NOT do
|
|
79
|
+
|
|
80
|
+
- Fork the coding agent. We write configs only.
|
|
81
|
+
- Implement OAuth. One-time pairing is the entire flow.
|
|
82
|
+
- Bundle the API runtime. Separate apps for separate processes.
|
|
83
|
+
- Implement tier-2 fallbacks. The API drives execution.
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
export declare class MissingSessionError extends Error {
|
|
2
|
+
constructor();
|
|
3
|
+
}
|
|
4
|
+
export declare class ApiCallError extends Error {
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly code: string;
|
|
7
|
+
readonly body?: unknown | undefined;
|
|
8
|
+
constructor(status: number, code: string, message: string, body?: unknown | undefined);
|
|
9
|
+
}
|
|
10
|
+
export interface ApiClientConfig {
|
|
11
|
+
apiBaseUrl: string;
|
|
12
|
+
registryBaseUrl: string;
|
|
13
|
+
agentSessionToken: string;
|
|
14
|
+
fetch?: typeof fetch;
|
|
15
|
+
agentIdentity?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ProvisionInput {
|
|
18
|
+
service: string;
|
|
19
|
+
plan: string;
|
|
20
|
+
project_name: string;
|
|
21
|
+
category: string;
|
|
22
|
+
cost_cents: number;
|
|
23
|
+
recurrence: "one_time" | "monthly" | "yearly" | "none";
|
|
24
|
+
idempotency_key?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface RunSummary {
|
|
27
|
+
id: string;
|
|
28
|
+
state: string;
|
|
29
|
+
service: string;
|
|
30
|
+
plan: string;
|
|
31
|
+
project_name: string;
|
|
32
|
+
subscription_id: string | null;
|
|
33
|
+
failure_reason: string | null;
|
|
34
|
+
created_at: string;
|
|
35
|
+
completed_at: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface CreateRunResponse {
|
|
38
|
+
run: {
|
|
39
|
+
id: string;
|
|
40
|
+
state: string;
|
|
41
|
+
};
|
|
42
|
+
decision: "silent" | "needs_approval" | "reject";
|
|
43
|
+
approval_url?: string;
|
|
44
|
+
reasons?: string[];
|
|
45
|
+
required_confidence?: "low" | "medium" | "high";
|
|
46
|
+
}
|
|
47
|
+
export interface CredentialResponse {
|
|
48
|
+
value: string;
|
|
49
|
+
reference: string;
|
|
50
|
+
retrieved_at: string;
|
|
51
|
+
}
|
|
52
|
+
export interface DirectoryEntry {
|
|
53
|
+
service: string;
|
|
54
|
+
latest_version: string;
|
|
55
|
+
display_name: string;
|
|
56
|
+
category: string;
|
|
57
|
+
homepage: string;
|
|
58
|
+
description: string | null;
|
|
59
|
+
}
|
|
60
|
+
export interface UsageResponse {
|
|
61
|
+
monthly: {
|
|
62
|
+
spent_cents: number;
|
|
63
|
+
budget_cents: number;
|
|
64
|
+
remaining_cents: number;
|
|
65
|
+
};
|
|
66
|
+
daily: {
|
|
67
|
+
spent_cents: number;
|
|
68
|
+
silent_max_cents: number;
|
|
69
|
+
};
|
|
70
|
+
mandate_id: string;
|
|
71
|
+
}
|
|
72
|
+
export declare class ApiClient {
|
|
73
|
+
private readonly config;
|
|
74
|
+
private readonly fetchImpl;
|
|
75
|
+
constructor(config: ApiClientConfig);
|
|
76
|
+
createRun(input: ProvisionInput): Promise<CreateRunResponse>;
|
|
77
|
+
getRun(runId: string): Promise<RunSummary>;
|
|
78
|
+
getCredential(reference: string, purpose: string): Promise<CredentialResponse>;
|
|
79
|
+
listSubscriptions(): Promise<{
|
|
80
|
+
subscriptions: unknown[];
|
|
81
|
+
}>;
|
|
82
|
+
cancelSubscription(id: string): Promise<unknown>;
|
|
83
|
+
getUsage(): Promise<UsageResponse>;
|
|
84
|
+
listServices(category?: string): Promise<{
|
|
85
|
+
adapters: DirectoryEntry[];
|
|
86
|
+
}>;
|
|
87
|
+
private headers;
|
|
88
|
+
private get;
|
|
89
|
+
private post;
|
|
90
|
+
private handleResponse;
|
|
91
|
+
}
|
|
92
|
+
export interface PairInitiateResponse {
|
|
93
|
+
pair_token: string;
|
|
94
|
+
pair_url: string;
|
|
95
|
+
expires_at: string;
|
|
96
|
+
}
|
|
97
|
+
export declare function pairInitiate(apiBaseUrl: string, agentIdentity: string, machineToken?: string | null, fetchImpl?: typeof fetch): Promise<PairInitiateResponse>;
|
|
98
|
+
export interface PairStatusResponse {
|
|
99
|
+
status: "pending" | "claimed" | "expired";
|
|
100
|
+
agent_session_token?: string;
|
|
101
|
+
account_id?: string;
|
|
102
|
+
}
|
|
103
|
+
export declare function pairPoll(apiBaseUrl: string, token: string, fetchImpl?: typeof fetch): Promise<PairStatusResponse>;
|
|
104
|
+
export interface MachineInstallResponse {
|
|
105
|
+
machine_token: string;
|
|
106
|
+
quota_limit: number;
|
|
107
|
+
quota_used: number;
|
|
108
|
+
tier: "anonymous" | "paired";
|
|
109
|
+
message?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface InstallAsnPayload {
|
|
112
|
+
ip: string;
|
|
113
|
+
asn: string | null;
|
|
114
|
+
org: string | null;
|
|
115
|
+
country: string | null;
|
|
116
|
+
class: "residential" | "datacenter" | "unknown";
|
|
117
|
+
}
|
|
118
|
+
export declare function issueMachineToken(apiBaseUrl: string, fetchImpl?: typeof fetch, asn?: InstallAsnPayload): Promise<MachineInstallResponse>;
|
|
119
|
+
export interface MachineStatusResponse {
|
|
120
|
+
tier: "anonymous" | "paired";
|
|
121
|
+
quota_limit: number;
|
|
122
|
+
quota_used: number;
|
|
123
|
+
quota_remaining: number;
|
|
124
|
+
over_quota: boolean;
|
|
125
|
+
paired_account_id: string | null;
|
|
126
|
+
created_at: string;
|
|
127
|
+
last_used_at: string | null;
|
|
128
|
+
}
|
|
129
|
+
export declare function getMachineStatus(apiBaseUrl: string, machineToken: string, fetchImpl?: typeof fetch): Promise<MachineStatusResponse>;
|
|
130
|
+
//# sourceMappingURL=api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAMA,qBAAa,mBAAoB,SAAQ,KAAK;;CAO7C;AAED,qBAAa,YAAa,SAAQ,KAAK;aAEnB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;aAEZ,IAAI,CAAC,EAAE,OAAO;gBAHd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,OAAO,YAAA;CAKjC;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;IAErB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,M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Aa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;CACjD;AAED,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,SAAS,GAAE,OAAO,KAAa,EAC/B,GAAG,CAAC,EAAE,iBAAiB,GACtB,OAAO,CAAC,sBAAsB,CAAC,CASjC;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,WAAW,GAAG,QAAQ,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,SAAS,GAAE,OAAO,KAAa,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CAMhC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// HTTP client wrapping calls to apps/api + apps/registry-api.
|
|
2
|
+
//
|
|
3
|
+
// All methods return parsed JSON or throw a typed error. The client
|
|
4
|
+
// is the only thing the MCP tools touch — tests inject a mock to
|
|
5
|
+
// keep their behaviour deterministic without spinning up HTTP.
|
|
6
|
+
export class MissingSessionError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("No active Trusty Squire session. Run `npx @trusty-squire/mcp install --target=<agent>` to pair this machine.");
|
|
9
|
+
this.name = "MissingSessionError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class ApiCallError extends Error {
|
|
13
|
+
status;
|
|
14
|
+
code;
|
|
15
|
+
body;
|
|
16
|
+
constructor(status, code, message, body) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.status = status;
|
|
19
|
+
this.code = code;
|
|
20
|
+
this.body = body;
|
|
21
|
+
this.name = "ApiCallError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class ApiClient {
|
|
25
|
+
config;
|
|
26
|
+
fetchImpl;
|
|
27
|
+
constructor(config) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.fetchImpl = config.fetch ?? fetch;
|
|
30
|
+
}
|
|
31
|
+
// ── Runs / provision / approvals ───────────────────────────
|
|
32
|
+
async createRun(input) {
|
|
33
|
+
return this.post("/v1/runs", input);
|
|
34
|
+
}
|
|
35
|
+
async getRun(runId) {
|
|
36
|
+
return this.get(`/v1/runs/${encodeURIComponent(runId)}`);
|
|
37
|
+
}
|
|
38
|
+
// ── Credentials ───────────────────────────────────────────
|
|
39
|
+
async getCredential(reference, purpose) {
|
|
40
|
+
return this.get(`/v1/credentials/${encodeURIComponent(reference)}?purpose=${encodeURIComponent(purpose)}`);
|
|
41
|
+
}
|
|
42
|
+
// ── Subscriptions ─────────────────────────────────────────
|
|
43
|
+
async listSubscriptions() {
|
|
44
|
+
return this.get("/v1/subscriptions");
|
|
45
|
+
}
|
|
46
|
+
async cancelSubscription(id) {
|
|
47
|
+
const res = await this.fetchImpl(`${this.config.apiBaseUrl}/v1/subscriptions/${encodeURIComponent(id)}`, { method: "DELETE", headers: this.headers() });
|
|
48
|
+
return this.handleResponse(res, "DELETE", `/v1/subscriptions/${id}`);
|
|
49
|
+
}
|
|
50
|
+
// ── Usage ─────────────────────────────────────────────────
|
|
51
|
+
async getUsage() {
|
|
52
|
+
return this.get("/v1/usage");
|
|
53
|
+
}
|
|
54
|
+
// ── Service directory ─────────────────────────────────────
|
|
55
|
+
async listServices(category) {
|
|
56
|
+
const url = category !== undefined
|
|
57
|
+
? `${this.config.registryBaseUrl}/adapters?category=${encodeURIComponent(category)}`
|
|
58
|
+
: `${this.config.registryBaseUrl}/adapters`;
|
|
59
|
+
const res = await this.fetchImpl(url, { method: "GET" });
|
|
60
|
+
return (await this.handleResponse(res, "GET", url));
|
|
61
|
+
}
|
|
62
|
+
// ── Internal HTTP helpers ─────────────────────────────────
|
|
63
|
+
headers() {
|
|
64
|
+
const h = {
|
|
65
|
+
Authorization: `Bearer ${this.config.agentSessionToken}`,
|
|
66
|
+
Accept: "application/json",
|
|
67
|
+
"Content-Type": "application/json",
|
|
68
|
+
};
|
|
69
|
+
if (this.config.agentIdentity !== undefined) {
|
|
70
|
+
h["X-Squire-Agent-Identity"] = this.config.agentIdentity;
|
|
71
|
+
}
|
|
72
|
+
return h;
|
|
73
|
+
}
|
|
74
|
+
async get(path) {
|
|
75
|
+
const res = await this.fetchImpl(`${this.config.apiBaseUrl}${path}`, {
|
|
76
|
+
method: "GET",
|
|
77
|
+
headers: this.headers(),
|
|
78
|
+
});
|
|
79
|
+
return (await this.handleResponse(res, "GET", path));
|
|
80
|
+
}
|
|
81
|
+
async post(path, body) {
|
|
82
|
+
const res = await this.fetchImpl(`${this.config.apiBaseUrl}${path}`, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers: this.headers(),
|
|
85
|
+
body: JSON.stringify(body),
|
|
86
|
+
});
|
|
87
|
+
return (await this.handleResponse(res, "POST", path));
|
|
88
|
+
}
|
|
89
|
+
async handleResponse(res, method, path) {
|
|
90
|
+
const body = await safeJson(res);
|
|
91
|
+
if (!res.ok) {
|
|
92
|
+
const code = isErrorBody(body) ? body.error : `http_${res.status}`;
|
|
93
|
+
throw new ApiCallError(res.status, code, `${method} ${path} → ${res.status} ${code}`, body);
|
|
94
|
+
}
|
|
95
|
+
return body;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function safeJson(res) {
|
|
99
|
+
try {
|
|
100
|
+
return await res.json();
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function isErrorBody(b) {
|
|
107
|
+
return (b !== null &&
|
|
108
|
+
typeof b === "object" &&
|
|
109
|
+
"error" in b &&
|
|
110
|
+
typeof b.error === "string");
|
|
111
|
+
}
|
|
112
|
+
export async function pairInitiate(apiBaseUrl, agentIdentity,
|
|
113
|
+
// Optional Tier-0 machine token. When supplied the eventual claim
|
|
114
|
+
// links it to the new account so quota stops applying.
|
|
115
|
+
machineToken = null, fetchImpl = fetch) {
|
|
116
|
+
const res = await fetchImpl(`${apiBaseUrl}/v1/mcp/pair/initiate`, {
|
|
117
|
+
method: "POST",
|
|
118
|
+
headers: { "Content-Type": "application/json" },
|
|
119
|
+
body: JSON.stringify({
|
|
120
|
+
agent_identity: agentIdentity,
|
|
121
|
+
...(machineToken !== null ? { machine_token: machineToken } : {}),
|
|
122
|
+
}),
|
|
123
|
+
});
|
|
124
|
+
if (!res.ok)
|
|
125
|
+
throw new ApiCallError(res.status, "pair_initiate_failed", "pairing failed");
|
|
126
|
+
return (await res.json());
|
|
127
|
+
}
|
|
128
|
+
export async function pairPoll(apiBaseUrl, token, fetchImpl = fetch) {
|
|
129
|
+
const res = await fetchImpl(`${apiBaseUrl}/v1/mcp/pair/${encodeURIComponent(token)}/status`);
|
|
130
|
+
// 200 + status === 'pending' | 'claimed'; 410 → expired (return shape rather than throw).
|
|
131
|
+
if (res.status === 410)
|
|
132
|
+
return { status: "expired" };
|
|
133
|
+
if (!res.ok)
|
|
134
|
+
throw new ApiCallError(res.status, "pair_poll_failed", "pairing poll failed");
|
|
135
|
+
return (await res.json());
|
|
136
|
+
}
|
|
137
|
+
export async function issueMachineToken(apiBaseUrl, fetchImpl = fetch, asn) {
|
|
138
|
+
const init = { method: "POST" };
|
|
139
|
+
if (asn !== undefined) {
|
|
140
|
+
init.headers = { "content-type": "application/json" };
|
|
141
|
+
init.body = JSON.stringify({ asn });
|
|
142
|
+
}
|
|
143
|
+
const res = await fetchImpl(`${apiBaseUrl}/v1/install`, init);
|
|
144
|
+
if (!res.ok)
|
|
145
|
+
throw new ApiCallError(res.status, "install_failed", "machine install failed");
|
|
146
|
+
return (await res.json());
|
|
147
|
+
}
|
|
148
|
+
export async function getMachineStatus(apiBaseUrl, machineToken, fetchImpl = fetch) {
|
|
149
|
+
const res = await fetchImpl(`${apiBaseUrl}/v1/install/status`, {
|
|
150
|
+
headers: { "x-machine-token": machineToken },
|
|
151
|
+
});
|
|
152
|
+
if (!res.ok)
|
|
153
|
+
throw new ApiCallError(res.status, "status_failed", "machine status failed");
|
|
154
|
+
return (await res.json());
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-client.js","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,oEAAoE;AACpE,iEAAiE;AACjE,+DAA+D;AAE/D,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC5C;QACE,KAAK,CACH,8GAA8G,CAC/G,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEnB;IACA;IAEA;IAJlB,YACkB,MAAc,EACd,IAAY,EAC5B,OAAe,EACC,IAAc;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QALC,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAEZ,SAAI,GAAJ,IAAI,CAAU;QAG9B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF;AA8D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B,EAClB,YAA0B,KAAK,EAC/B,GAAuB;IAEvB,MAAM,IAAI,GAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC7C,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;QACtD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,UAAU,aAAa,EAAE,IAAI,CAAC,CAAC;IAC9D,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,wBAAwB,CAAC,CAAC;IAC5F,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA2B,CAAC;AACtD,CAAC;AAaD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAAkB,EAClB,YAAoB,EACpB,YAA0B,KAAK;IAE/B,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,UAAU,oBAAoB,EAAE;QAC7D,OAAO,EAAE,EAAE,iBAAiB,EAAE,YAAY,EAAE;KAC7C,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,IAAI,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,eAAe,EAAE,uBAAuB,CAAC,CAAC;IAC1F,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA0B,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type AgentTarget = "claude-code" | "cursor" | "goose" | "cline" | "continue";
|
|
2
|
+
export interface AgentDefinition {
|
|
3
|
+
target: AgentTarget;
|
|
4
|
+
display_name: string;
|
|
5
|
+
config_path: () => string;
|
|
6
|
+
detect: () => Promise<boolean>;
|
|
7
|
+
writeConfig: (input: WriteConfigInput) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export interface WriteConfigInput {
|
|
10
|
+
command: string;
|
|
11
|
+
args: string[];
|
|
12
|
+
env: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export declare const AGENTS: Record<AgentTarget, AgentDefinition>;
|
|
15
|
+
export declare function detectInstalledAgents(): Promise<AgentDefinition[]>;
|
|
16
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/install/agents.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,QAAQ,GACR,OAAO,GACP,OAAO,GACP,UAAU,CAAC;AAEf,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,WAAW,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,MAAM,CAAC;IAI1B,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAG/B,WAAW,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B;AAwJD,eAAO,MAAM,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,eAAe,CAMvD,CAAC;AAEF,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC,CAMxE"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Agent registry: each entry knows where its MCP config file lives,
|
|
2
|
+
// how to merge a `squire` server entry into the existing config, and
|
|
3
|
+
// how to detect whether the user has the agent installed.
|
|
4
|
+
import { promises as fs } from "node:fs";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { stringify as yamlStringify, parse as yamlParse } from "yaml";
|
|
8
|
+
// Tests override $HOME to isolate the file system. Node's os.homedir()
|
|
9
|
+
// reads from getpwuid_r and ignores $HOME, so we honor HOME first
|
|
10
|
+
// (matching the convention every shell uses).
|
|
11
|
+
function home() {
|
|
12
|
+
return process.env.HOME ?? os.homedir();
|
|
13
|
+
}
|
|
14
|
+
const SERVER_KEY = "squire";
|
|
15
|
+
// ── Helpers shared across JSON-format agents ─────────────────
|
|
16
|
+
async function readJsonIfExists(filePath) {
|
|
17
|
+
try {
|
|
18
|
+
const raw = await fs.readFile(filePath, "utf8");
|
|
19
|
+
const parsed = JSON.parse(raw);
|
|
20
|
+
return parsed !== null && typeof parsed === "object"
|
|
21
|
+
? parsed
|
|
22
|
+
: {};
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
if (err.code === "ENOENT")
|
|
26
|
+
return {};
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function writeJson(filePath, data) {
|
|
31
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
32
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2) + "\n", { mode: 0o600 });
|
|
33
|
+
}
|
|
34
|
+
// Merge a `squire` entry into the standard mcpServers map without
|
|
35
|
+
// clobbering other entries the user has added.
|
|
36
|
+
async function mergeMcpServersJson(filePath, input) {
|
|
37
|
+
const existing = await readJsonIfExists(filePath);
|
|
38
|
+
const servers = existing.mcpServers !== undefined && typeof existing.mcpServers === "object"
|
|
39
|
+
? existing.mcpServers
|
|
40
|
+
: {};
|
|
41
|
+
servers[SERVER_KEY] = {
|
|
42
|
+
command: input.command,
|
|
43
|
+
args: input.args,
|
|
44
|
+
env: input.env,
|
|
45
|
+
};
|
|
46
|
+
existing.mcpServers = servers;
|
|
47
|
+
await writeJson(filePath, existing);
|
|
48
|
+
}
|
|
49
|
+
// ── claude-code ──────────────────────────────────────────────
|
|
50
|
+
const claudeCode = {
|
|
51
|
+
target: "claude-code",
|
|
52
|
+
display_name: "Claude Code",
|
|
53
|
+
config_path: () => path.join(home(), ".claude", "mcp.json"),
|
|
54
|
+
detect: async () => exists(path.join(home(), ".claude")),
|
|
55
|
+
writeConfig: async (input) => mergeMcpServersJson(claudeCode.config_path(), input),
|
|
56
|
+
};
|
|
57
|
+
// ── cursor ──────────────────────────────────────────────────
|
|
58
|
+
const cursor = {
|
|
59
|
+
target: "cursor",
|
|
60
|
+
display_name: "Cursor",
|
|
61
|
+
config_path: () => path.join(home(), ".cursor", "mcp.json"),
|
|
62
|
+
detect: async () => exists(path.join(home(), ".cursor")),
|
|
63
|
+
writeConfig: async (input) => mergeMcpServersJson(cursor.config_path(), input),
|
|
64
|
+
};
|
|
65
|
+
// ── goose ───────────────────────────────────────────────────
|
|
66
|
+
//
|
|
67
|
+
// goose uses YAML with an `extensions` key. Spec listed `profiles.yaml`
|
|
68
|
+
// but recent goose versions use `~/.config/goose/profiles.yaml`. We
|
|
69
|
+
// merge into the same key shape (`extensions.squire`) so existing
|
|
70
|
+
// custom extensions are preserved.
|
|
71
|
+
const goose = {
|
|
72
|
+
target: "goose",
|
|
73
|
+
display_name: "Goose",
|
|
74
|
+
config_path: () => path.join(process.env.XDG_CONFIG_HOME ?? path.join(home(), ".config"), "goose", "profiles.yaml"),
|
|
75
|
+
detect: async () => exists(goose.config_path()),
|
|
76
|
+
writeConfig: async (input) => {
|
|
77
|
+
const filePath = goose.config_path();
|
|
78
|
+
let data = {};
|
|
79
|
+
try {
|
|
80
|
+
const raw = await fs.readFile(filePath, "utf8");
|
|
81
|
+
const parsed = yamlParse(raw);
|
|
82
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
83
|
+
data = parsed;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
if (err.code !== "ENOENT")
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
const extensions = data.extensions !== undefined && typeof data.extensions === "object"
|
|
91
|
+
? data.extensions
|
|
92
|
+
: {};
|
|
93
|
+
extensions[SERVER_KEY] = {
|
|
94
|
+
type: "stdio",
|
|
95
|
+
cmd: input.command,
|
|
96
|
+
args: input.args,
|
|
97
|
+
envs: input.env,
|
|
98
|
+
};
|
|
99
|
+
data.extensions = extensions;
|
|
100
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
101
|
+
await fs.writeFile(filePath, yamlStringify(data), { mode: 0o600 });
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
// ── cline ───────────────────────────────────────────────────
|
|
105
|
+
const cline = {
|
|
106
|
+
target: "cline",
|
|
107
|
+
display_name: "Cline",
|
|
108
|
+
config_path: () => path.join(home(), ".cline", "mcp_config.json"),
|
|
109
|
+
detect: async () => exists(path.join(home(), ".cline")),
|
|
110
|
+
writeConfig: async (input) => mergeMcpServersJson(cline.config_path(), input),
|
|
111
|
+
};
|
|
112
|
+
// ── continue ────────────────────────────────────────────────
|
|
113
|
+
const continueAgent = {
|
|
114
|
+
target: "continue",
|
|
115
|
+
display_name: "Continue",
|
|
116
|
+
config_path: () => path.join(home(), ".continue", "config.yaml"),
|
|
117
|
+
detect: async () => exists(path.join(home(), ".continue")),
|
|
118
|
+
writeConfig: async (input) => {
|
|
119
|
+
const filePath = continueAgent.config_path();
|
|
120
|
+
let data = {};
|
|
121
|
+
try {
|
|
122
|
+
const raw = await fs.readFile(filePath, "utf8");
|
|
123
|
+
const parsed = yamlParse(raw);
|
|
124
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
125
|
+
data = parsed;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
if (err.code !== "ENOENT")
|
|
130
|
+
throw err;
|
|
131
|
+
}
|
|
132
|
+
const mcpServers = data.mcpServers !== undefined && Array.isArray(data.mcpServers)
|
|
133
|
+
? data.mcpServers
|
|
134
|
+
: [];
|
|
135
|
+
const filtered = mcpServers.filter((s) => s.name !== SERVER_KEY);
|
|
136
|
+
filtered.push({
|
|
137
|
+
name: SERVER_KEY,
|
|
138
|
+
command: input.command,
|
|
139
|
+
args: input.args,
|
|
140
|
+
env: input.env,
|
|
141
|
+
});
|
|
142
|
+
data.mcpServers = filtered;
|
|
143
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
144
|
+
await fs.writeFile(filePath, yamlStringify(data), { mode: 0o600 });
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
export const AGENTS = {
|
|
148
|
+
"claude-code": claudeCode,
|
|
149
|
+
cursor,
|
|
150
|
+
goose,
|
|
151
|
+
cline,
|
|
152
|
+
continue: continueAgent,
|
|
153
|
+
};
|
|
154
|
+
export async function detectInstalledAgents() {
|
|
155
|
+
const out = [];
|
|
156
|
+
for (const agent of Object.values(AGENTS)) {
|
|
157
|
+
if (await agent.detect())
|
|
158
|
+
out.push(agent);
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
async function exists(p) {
|
|
163
|
+
try {
|
|
164
|
+
await fs.access(p);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/install/agents.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,qEAAqE;AACrE,0DAA0D;AAE1D,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAEtE,uEAAuE;AACvE,kEAAkE;AAClE,8CAA8C;A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AM,GAAyC;IAC1D,aAAa,EAAE,UAAU;IACzB,MAAM;IACN,KAAK;IACL,KAAK;IACL,QAAQ,EAAE,aAAa;CACxB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,GAAG,GAAsB,EAAE,CAAC;IAClC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,IAAI,MAAM,KAAK,CAAC,MAAM,EAAE;YAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,CAAS;IAC7B,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { type AgentTarget } from "./agents.js";
|
|
3
|
+
import { type AsnInfo } from "@trusty-squire/universal-bot";
|
|
4
|
+
type Argv = {
|
|
5
|
+
command: string;
|
|
6
|
+
target?: AgentTarget;
|
|
7
|
+
apiBase: string;
|
|
8
|
+
withPair: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare function parseArgs(argv: string[]): Argv;
|
|
11
|
+
declare function install(args: Argv): Promise<void>;
|
|
12
|
+
declare function pair(args: Argv): Promise<void>;
|
|
13
|
+
declare function logout(): Promise<void>;
|
|
14
|
+
interface ClaimResult {
|
|
15
|
+
token: string;
|
|
16
|
+
account_id: string;
|
|
17
|
+
}
|
|
18
|
+
declare function pollForClaim(apiBase: string, pairToken: string, intervalMsOrOpts?: number | {
|
|
19
|
+
intervalMs?: number;
|
|
20
|
+
timeoutMs?: number;
|
|
21
|
+
}, timeoutMsArg?: number): Promise<ClaimResult | null>;
|
|
22
|
+
declare function printAsnWarning(asn: AsnInfo): void;
|
|
23
|
+
export { install, pair, logout, parseArgs, pollForClaim, printAsnWarning };
|
|
24
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/install/cli.ts"],"names":[],"mappings":";AAsBA,OAAO,EAAiC,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAIvE,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,iBAAS,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAmBvC;AA4BD,iBAAe,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CA+EhD;AAED,iBAAe,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAc7C;AAyDD,iBAAe,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAIrC;AAiBD,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,iBAAe,YAAY,CACzB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,gBAAgB,GAAE,MAAM,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,EAC3E,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAoB7B;AAKD,iBAAS,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAyB3C;AASD,OAAO,EAAE,OAAO,EAAE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