scrollport 0.1.0 → 0.2.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 +17 -3
- package/dist/args.d.ts +13 -2
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +77 -9
- package/dist/args.js.map +1 -1
- package/dist/cli.js +46 -11
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +10 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +12 -0
- package/dist/client.js.map +1 -0
- package/dist/commands/catalog.d.ts +11 -0
- package/dist/commands/catalog.d.ts.map +1 -0
- package/dist/commands/catalog.js +81 -0
- package/dist/commands/catalog.js.map +1 -0
- package/dist/commands/key.d.ts +4 -0
- package/dist/commands/key.d.ts.map +1 -0
- package/dist/commands/key.js +13 -0
- package/dist/commands/key.js.map +1 -0
- package/dist/commands/run.d.ts +25 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +161 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/commands/setup.d.ts +10 -0
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +45 -3
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/wallet.d.ts +10 -0
- package/dist/commands/wallet.d.ts.map +1 -0
- package/dist/commands/wallet.js +37 -0
- package/dist/commands/wallet.js.map +1 -0
- package/dist/device-client.d.ts +18 -0
- package/dist/device-client.d.ts.map +1 -1
- package/dist/device-client.js +19 -0
- package/dist/device-client.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/http.js +1 -1
- package/dist/output.d.ts +4 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +1 -1
- package/dist/output.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,10 +27,16 @@ touches your shell history.
|
|
|
27
27
|
| `scrollport setup` | device flow: get a key and store it |
|
|
28
28
|
| `scrollport status` | is there a key, and does the API still accept it? |
|
|
29
29
|
| `scrollport logout` | remove the key stored on this machine |
|
|
30
|
+
| `scrollport discover <query>` | find live catalog tools for a job |
|
|
31
|
+
| `scrollport inspect <tool-id>` | read one tool's schema, worked example and teaching errors |
|
|
32
|
+
| `scrollport run <tool-id> --input '<json>'\|@file [--confirm]` | submit input and poll the persisted run to a terminal result |
|
|
33
|
+
| `scrollport wallet` | read available funds and human-controlled spend limits |
|
|
30
34
|
| `scrollport help` / `version` | |
|
|
31
35
|
|
|
32
|
-
The
|
|
33
|
-
|
|
36
|
+
The CLI is a thin client over the API's permanent four control tools. The API
|
|
37
|
+
remains the authority for pricing, lifecycle, wallet holds and human approval.
|
|
38
|
+
When a run needs approval, the CLI prints the approval URL. `--confirm` only
|
|
39
|
+
waits for a human decision; it cannot approve or alter a spend limit.
|
|
34
40
|
|
|
35
41
|
## Flags
|
|
36
42
|
|
|
@@ -41,6 +47,8 @@ are **not in this release**.
|
|
|
41
47
|
| `--force` | `setup`: provision a new key even if one already works |
|
|
42
48
|
| `--no-browser` | `setup`: print the link, open nothing |
|
|
43
49
|
| `--offline` | `status`: report what is on disk, skip the API check |
|
|
50
|
+
| `--input <json>\|@file` | `run`: JSON literal or a local JSON file prefixed with `@` |
|
|
51
|
+
| `--confirm` | `run`: keep polling after printing a human approval URL |
|
|
44
52
|
|
|
45
53
|
## Environment
|
|
46
54
|
|
|
@@ -84,6 +92,12 @@ Fields present per command:
|
|
|
84
92
|
`verified` (`null` when unchecked), and `permissions_warning` when the file is
|
|
85
93
|
readable beyond its owner.
|
|
86
94
|
- `logout` — `removed`, `credentials_path`, `env_key_still_set`.
|
|
95
|
+
- `discover` — `query`, `discovery` (the API's typed capability/tool result).
|
|
96
|
+
- `inspect` — `tool_id`, `tool` (the API's full inspection response).
|
|
97
|
+
- `run` — `run_id`, `estimate`, `run`. A completed failed run returns JSON with
|
|
98
|
+
`ok: false` and exit code `1`; API refusal errors retain their own teaching
|
|
99
|
+
error and exit code.
|
|
100
|
+
- `wallet` — `wallet` (the API's current wallet response).
|
|
87
101
|
|
|
88
102
|
**The API key itself is never emitted**, in either mode. Masked only. A key in
|
|
89
103
|
stdout is a key in a log, a CI artifact and a screen recording.
|
|
@@ -140,7 +154,7 @@ assumes a file.
|
|
|
140
154
|
```
|
|
141
155
|
pnpm --filter scrollport build
|
|
142
156
|
pnpm --filter scrollport test # hermetic: no server, no database
|
|
143
|
-
node packages/cli/dist/cli.js
|
|
157
|
+
node packages/cli/dist/cli.js discover "research company funding" --api-url http://localhost:8787
|
|
144
158
|
```
|
|
145
159
|
|
|
146
160
|
The tests stub `fetch` and point `SCROLLPORT_HOME` at a temp directory. They
|
package/dist/args.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare const COMMANDS: readonly ["setup", "status", "logout", "help", "version"];
|
|
1
|
+
export declare const COMMANDS: readonly ["setup", "status", "logout", "discover", "inspect", "run", "wallet", "help", "version"];
|
|
2
2
|
export type Command = (typeof COMMANDS)[number];
|
|
3
|
-
export declare const USAGE = "scrollport \u2014 provision an agent's key against one prepaid wallet.\n\nUsage:\n scrollport setup connect this machine (device flow, two clicks)\n scrollport status is there a key, and does it still work?\n scrollport logout forget the key stored on this machine\n scrollport help | version\n\nOptions:\n --json machine-readable output: one JSON object on stdout,\n progress on stderr. Stable \u2014 see README.md.\n --api-url <url> API origin (default https://api.scrollport.com,\n or $SCROLLPORT_API_URL)\n --force setup: provision a new key even if one already works\n --no-browser setup: print the link, do not open a browser\n --offline status: report what is on disk, skip the API check\n -h, --help this text\n -v, --version print the version\n\nEnvironment:\n SCROLLPORT_API_KEY a key to use instead of the stored one (read, never\n written \u2014 this is the CI path)\n SCROLLPORT_API_URL default for --api-url\n SCROLLPORT_HOME config directory (default ~/.scrollport)\n SCROLLPORT_NO_BROWSER set to anything to never open a browser\n\nExit codes:\n 0 ok \u00B7 1 error \u00B7 2 usage \u00B7 3 approval denied \u00B7 4 code expired\n 5 API unreachable \u00B7 6 no usable key (run `scrollport setup`) \u00B7 130 interrupted\n
|
|
3
|
+
export declare const USAGE = "scrollport \u2014 provision an agent's key against one prepaid wallet.\n\nUsage:\n scrollport setup connect this machine (device flow, two clicks)\n scrollport setup --invite <code>\n redeem an agent invite: no browser, no approval \u2014\n the human already decided when they created it\n scrollport status is there a key, and does it still work?\n scrollport logout forget the key stored on this machine\n scrollport discover <query> find live catalog tools for a job\n scrollport inspect <tool-id>\n read one tool's input contract and worked example\n scrollport run <tool-id> --input '<json>'|@file [--confirm]\n start a tool, then poll it to a terminal result\n scrollport run --resume <run-id> [--confirm]\n resume polling an existing run; starts nothing\n scrollport wallet read the current wallet and spend limits\n scrollport help | version\n\nOptions:\n --json machine-readable output: one JSON object on stdout,\n progress on stderr. Stable \u2014 see README.md.\n --api-url <url> API origin (default https://api.scrollport.com,\n or $SCROLLPORT_API_URL)\n --force setup: provision a new key even if one already works\n --no-browser setup: print the link, do not open a browser\n --invite <code> setup: redeem an invite instead of the device flow.\n One call, no browser. The same endpoint an agent with\n no shell can POST directly \u2014 see README.md.\n --offline status: report what is on disk, skip the API check\n --input <json>|@file run: JSON input, or a path to a JSON file prefixed\n with @. Input is read locally and sent only to the API.\n --confirm run: after an approval URL is returned, wait while a\n human makes the decision. It never approves for them.\n --resume <run-id> run: poll an existing run instead of starting one\n -h, --help this text\n -v, --version print the version\n\nEnvironment:\n SCROLLPORT_API_KEY a key to use instead of the stored one (read, never\n written \u2014 this is the CI path)\n SCROLLPORT_API_URL default for --api-url\n SCROLLPORT_HOME config directory (default ~/.scrollport)\n SCROLLPORT_NO_BROWSER set to anything to never open a browser\n\nExit codes:\n 0 ok \u00B7 1 error \u00B7 2 usage \u00B7 3 approval denied \u00B7 4 code expired\n 5 API unreachable \u00B7 6 no usable key (run `scrollport setup`) \u00B7 130 interrupted\n";
|
|
4
4
|
/** The published version, read from our own package.json at run time. */
|
|
5
5
|
export declare function version(): string;
|
|
6
6
|
export interface ParsedArgs {
|
|
@@ -10,6 +10,17 @@ export interface ParsedArgs {
|
|
|
10
10
|
force: boolean;
|
|
11
11
|
noBrowser: boolean;
|
|
12
12
|
offline: boolean;
|
|
13
|
+
/** An invite code, when `setup` should redeem one instead of the device flow. */
|
|
14
|
+
invite: string | undefined;
|
|
15
|
+
/** discover's natural-language query. */
|
|
16
|
+
query: string | undefined;
|
|
17
|
+
/** inspect/run's public tool id. */
|
|
18
|
+
toolId: string | undefined;
|
|
19
|
+
/** run's JSON literal or @file reference. */
|
|
20
|
+
input: string | undefined;
|
|
21
|
+
/** Keep polling an approval-gated run; never bypasses the human decision. */
|
|
22
|
+
confirm: boolean;
|
|
23
|
+
resume: string | undefined;
|
|
13
24
|
}
|
|
14
25
|
export type Env = Record<string, string | undefined>;
|
|
15
26
|
/**
|
package/dist/args.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"args.d.ts","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,QAAQ,mGAUX,CAAC;AACX,MAAM,MAAM,OAAO,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhD,eAAO,MAAM,KAAK,0wFAgDjB,CAAC;AAEF,yEAAyE;AACzE,wBAAgB,OAAO,IAAI,MAAM,CAQhC;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,iFAAiF;IACjF,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,yCAAyC;IACzC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,oCAAoC;IACpC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,6CAA6C;IAC7C,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,GAAiB,GAAG,UAAU,CA8FnF"}
|
package/dist/args.js
CHANGED
|
@@ -9,13 +9,34 @@ import { readFileSync } from "node:fs";
|
|
|
9
9
|
import { parseArgs } from "node:util";
|
|
10
10
|
import { CliError, EXIT_USAGE } from "./errors.js";
|
|
11
11
|
import { DEFAULT_API_URL } from "./http.js";
|
|
12
|
-
export const COMMANDS = [
|
|
12
|
+
export const COMMANDS = [
|
|
13
|
+
"setup",
|
|
14
|
+
"status",
|
|
15
|
+
"logout",
|
|
16
|
+
"discover",
|
|
17
|
+
"inspect",
|
|
18
|
+
"run",
|
|
19
|
+
"wallet",
|
|
20
|
+
"help",
|
|
21
|
+
"version",
|
|
22
|
+
];
|
|
13
23
|
export const USAGE = `scrollport — provision an agent's key against one prepaid wallet.
|
|
14
24
|
|
|
15
25
|
Usage:
|
|
16
26
|
scrollport setup connect this machine (device flow, two clicks)
|
|
27
|
+
scrollport setup --invite <code>
|
|
28
|
+
redeem an agent invite: no browser, no approval —
|
|
29
|
+
the human already decided when they created it
|
|
17
30
|
scrollport status is there a key, and does it still work?
|
|
18
31
|
scrollport logout forget the key stored on this machine
|
|
32
|
+
scrollport discover <query> find live catalog tools for a job
|
|
33
|
+
scrollport inspect <tool-id>
|
|
34
|
+
read one tool's input contract and worked example
|
|
35
|
+
scrollport run <tool-id> --input '<json>'|@file [--confirm]
|
|
36
|
+
start a tool, then poll it to a terminal result
|
|
37
|
+
scrollport run --resume <run-id> [--confirm]
|
|
38
|
+
resume polling an existing run; starts nothing
|
|
39
|
+
scrollport wallet read the current wallet and spend limits
|
|
19
40
|
scrollport help | version
|
|
20
41
|
|
|
21
42
|
Options:
|
|
@@ -25,7 +46,15 @@ Options:
|
|
|
25
46
|
or $SCROLLPORT_API_URL)
|
|
26
47
|
--force setup: provision a new key even if one already works
|
|
27
48
|
--no-browser setup: print the link, do not open a browser
|
|
49
|
+
--invite <code> setup: redeem an invite instead of the device flow.
|
|
50
|
+
One call, no browser. The same endpoint an agent with
|
|
51
|
+
no shell can POST directly — see README.md.
|
|
28
52
|
--offline status: report what is on disk, skip the API check
|
|
53
|
+
--input <json>|@file run: JSON input, or a path to a JSON file prefixed
|
|
54
|
+
with @. Input is read locally and sent only to the API.
|
|
55
|
+
--confirm run: after an approval URL is returned, wait while a
|
|
56
|
+
human makes the decision. It never approves for them.
|
|
57
|
+
--resume <run-id> run: poll an existing run instead of starting one
|
|
29
58
|
-h, --help this text
|
|
30
59
|
-v, --version print the version
|
|
31
60
|
|
|
@@ -39,8 +68,6 @@ Environment:
|
|
|
39
68
|
Exit codes:
|
|
40
69
|
0 ok · 1 error · 2 usage · 3 approval denied · 4 code expired
|
|
41
70
|
5 API unreachable · 6 no usable key (run \`scrollport setup\`) · 130 interrupted
|
|
42
|
-
|
|
43
|
-
Capability commands (discover, inspect, run, wallet) are not in this release.
|
|
44
71
|
`;
|
|
45
72
|
/** The published version, read from our own package.json at run time. */
|
|
46
73
|
export function version() {
|
|
@@ -70,7 +97,11 @@ export function parseCommandLine(argv, env = process.env) {
|
|
|
70
97
|
"api-url": { type: "string" },
|
|
71
98
|
force: { type: "boolean", default: false },
|
|
72
99
|
"no-browser": { type: "boolean", default: false },
|
|
100
|
+
invite: { type: "string" },
|
|
73
101
|
offline: { type: "boolean", default: false },
|
|
102
|
+
input: { type: "string" },
|
|
103
|
+
confirm: { type: "boolean", default: false },
|
|
104
|
+
resume: { type: "string" },
|
|
74
105
|
help: { type: "boolean", short: "h", default: false },
|
|
75
106
|
version: { type: "boolean", short: "v", default: false },
|
|
76
107
|
},
|
|
@@ -102,12 +133,37 @@ export function parseCommandLine(argv, env = process.env) {
|
|
|
102
133
|
});
|
|
103
134
|
}
|
|
104
135
|
}
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
136
|
+
const positionalsAfterCommand = positionals.slice(1);
|
|
137
|
+
let query;
|
|
138
|
+
let toolId;
|
|
139
|
+
if (command === "discover") {
|
|
140
|
+
query = positionalsAfterCommand.join(" ").trim() || undefined;
|
|
141
|
+
if (!query)
|
|
142
|
+
throw usage("`discover` needs a query.", "scrollport discover \"research company funding\"");
|
|
143
|
+
}
|
|
144
|
+
else if (command === "inspect" || command === "run") {
|
|
145
|
+
const resume = typeof values.resume === "string" ? values.resume : undefined;
|
|
146
|
+
if (command === "run" && resume) {
|
|
147
|
+
if (positionalsAfterCommand.length)
|
|
148
|
+
throw usage("`run --resume` takes no tool id.", "scrollport run --resume <run-id>");
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
if (positionalsAfterCommand.length !== 1) {
|
|
152
|
+
throw usage(`\`${command}\` needs exactly one tool id.`, command === "run" ? "scrollport run web-search --input '{\"query\":\"example\"}'" : "scrollport inspect web-search");
|
|
153
|
+
}
|
|
154
|
+
toolId = positionalsAfterCommand[0];
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else if (positionalsAfterCommand.length > 0) {
|
|
158
|
+
throw usage(`\`${command}\` takes no arguments (got: ${positionalsAfterCommand.join(" ")}).`, `scrollport ${command}`);
|
|
159
|
+
}
|
|
160
|
+
const input = typeof values.input === "string" ? values.input : undefined;
|
|
161
|
+
const resume = typeof values.resume === "string" ? values.resume : undefined;
|
|
162
|
+
if (command === "run" && !input && !resume) {
|
|
163
|
+
throw usage("`run` needs --input with JSON or @file.", "scrollport run web-search --input '{\"query\":\"example\"}'");
|
|
164
|
+
}
|
|
165
|
+
if (command !== "run" && (input !== undefined || values.confirm === true || resume !== undefined)) {
|
|
166
|
+
throw usage("--input and --confirm are only valid with `run`.", "scrollport run web-search --input '{\"query\":\"example\"}'");
|
|
111
167
|
}
|
|
112
168
|
const apiUrl = values["api-url"] ?? env["SCROLLPORT_API_URL"];
|
|
113
169
|
return {
|
|
@@ -116,7 +172,19 @@ export function parseCommandLine(argv, env = process.env) {
|
|
|
116
172
|
...(apiUrl === undefined ? { apiUrl: undefined } : { apiUrl }),
|
|
117
173
|
force: values.force === true,
|
|
118
174
|
noBrowser: values["no-browser"] === true,
|
|
175
|
+
invite: typeof values.invite === "string" ? values.invite : undefined,
|
|
119
176
|
offline: values.offline === true,
|
|
177
|
+
query,
|
|
178
|
+
toolId,
|
|
179
|
+
input,
|
|
180
|
+
confirm: values.confirm === true,
|
|
181
|
+
resume,
|
|
120
182
|
};
|
|
121
183
|
}
|
|
184
|
+
function usage(message, example) {
|
|
185
|
+
return new CliError("usage", message, {
|
|
186
|
+
hint: `example: ${example}`,
|
|
187
|
+
exitCode: EXIT_USAGE,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
122
190
|
//# sourceMappingURL=args.js.map
|
package/dist/args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../src/args.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,O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AE,MAAM,CAAC,KAAK,KAAK,IAAI;QAC5B,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,KAAK,IAAI;QACxC,MAAM,EAAE,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;QACrE,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI;QAChC,KAAK;QACL,MAAM;QACN,KAAK;QACL,OAAO,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI;QAChC,MAAM;KACP,CAAC;AACJ,CAAC;AAED,SAAS,KAAK,CAAC,OAAe,EAAE,OAAe;IAC7C,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE;QACpC,IAAI,EAAE,YAAY,OAAO,EAAE;QAC3B,QAAQ,EAAE,UAAU;KACrB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -7,17 +7,18 @@
|
|
|
7
7
|
* let an exception reach the user as a raw stack trace unless it really is a bug
|
|
8
8
|
* of ours.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* `wallet`) are not here yet, and `--help` says so rather than implying a
|
|
13
|
-
* surface that does not exist.
|
|
10
|
+
* The API owns all money, lifecycle and approval decisions. The CLI is only a
|
|
11
|
+
* credentialed transport and presentation layer over those same four tools.
|
|
14
12
|
*/
|
|
15
13
|
import { parseCommandLine, USAGE, version } from "./args.js";
|
|
16
14
|
import { runLogout } from "./commands/logout.js";
|
|
15
|
+
import { runDiscover, runInspect } from "./commands/catalog.js";
|
|
16
|
+
import { runRun } from "./commands/run.js";
|
|
17
17
|
import { runSetup } from "./commands/setup.js";
|
|
18
18
|
import { runStatus } from "./commands/status.js";
|
|
19
|
+
import { runWallet } from "./commands/wallet.js";
|
|
20
|
+
import { makeClient } from "./client.js";
|
|
19
21
|
import { CliError, EXIT_ERROR, EXIT_INTERRUPTED, EXIT_OK, isCliError } from "./errors.js";
|
|
20
|
-
import { ApiClient, DEFAULT_API_URL, normalizeApiUrl } from "./http.js";
|
|
21
22
|
import { createReporter } from "./output.js";
|
|
22
23
|
const sleep = (ms) => new Promise((resolve) => {
|
|
23
24
|
setTimeout(resolve, ms);
|
|
@@ -51,15 +52,42 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
51
52
|
case "setup": {
|
|
52
53
|
const client = makeClient(args.apiUrl);
|
|
53
54
|
installInterruptHandler(reporter, "setup");
|
|
54
|
-
const result = await runSetup({ client, reporter, env: process.env, sleep, now: () => Date.now() }, { force: args.force, noBrowser: args.noBrowser });
|
|
55
|
+
const result = await runSetup({ client, reporter, env: process.env, sleep, now: () => Date.now() }, { force: args.force, noBrowser: args.noBrowser, invite: args.invite });
|
|
55
56
|
reporter.finish("setup", result);
|
|
56
|
-
return EXIT_OK;
|
|
57
|
+
return result.exitCode ?? EXIT_OK;
|
|
57
58
|
}
|
|
58
59
|
case "status": {
|
|
59
60
|
const client = makeClient(args.apiUrl);
|
|
60
61
|
const result = await runStatus({ client, reporter, env: process.env }, { offline: args.offline });
|
|
61
62
|
reporter.finish("status", result);
|
|
62
|
-
return EXIT_OK;
|
|
63
|
+
return result.exitCode ?? EXIT_OK;
|
|
64
|
+
}
|
|
65
|
+
case "discover": {
|
|
66
|
+
const result = await runDiscover({ client: makeClient(args.apiUrl), env: process.env }, args.query);
|
|
67
|
+
reporter.finish("discover", result);
|
|
68
|
+
return result.exitCode ?? EXIT_OK;
|
|
69
|
+
}
|
|
70
|
+
case "inspect": {
|
|
71
|
+
const result = await runInspect({ client: makeClient(args.apiUrl), env: process.env }, args.toolId);
|
|
72
|
+
reporter.finish("inspect", result);
|
|
73
|
+
return result.exitCode ?? EXIT_OK;
|
|
74
|
+
}
|
|
75
|
+
case "run": {
|
|
76
|
+
const result = await runRun({
|
|
77
|
+
client: makeClient(args.apiUrl),
|
|
78
|
+
env: process.env,
|
|
79
|
+
reporter,
|
|
80
|
+
sleep,
|
|
81
|
+
now: () => Date.now(),
|
|
82
|
+
onInterrupt: (runId) => installRunInterruptHandler(reporter, runId),
|
|
83
|
+
}, { ...(args.resume ? { resume: args.resume } : { toolId: args.toolId, input: args.input }), confirm: args.confirm });
|
|
84
|
+
reporter.finish("run", result);
|
|
85
|
+
return result.exitCode ?? EXIT_OK;
|
|
86
|
+
}
|
|
87
|
+
case "wallet": {
|
|
88
|
+
const result = await runWallet({ client: makeClient(args.apiUrl), env: process.env });
|
|
89
|
+
reporter.finish("wallet", result);
|
|
90
|
+
return result.exitCode ?? EXIT_OK;
|
|
63
91
|
}
|
|
64
92
|
}
|
|
65
93
|
}
|
|
@@ -67,9 +95,6 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
67
95
|
return report(reporter, args.command, err);
|
|
68
96
|
}
|
|
69
97
|
}
|
|
70
|
-
function makeClient(apiUrl) {
|
|
71
|
-
return new ApiClient(normalizeApiUrl(apiUrl ?? DEFAULT_API_URL));
|
|
72
|
-
}
|
|
73
98
|
/**
|
|
74
99
|
* Render a failure and pick its exit code. Anything that is not a CliError is a
|
|
75
100
|
* bug in this CLI, and gets a stack trace — being noisier about our own faults
|
|
@@ -101,6 +126,16 @@ function installInterruptHandler(reporter, command) {
|
|
|
101
126
|
finish(EXIT_INTERRUPTED);
|
|
102
127
|
});
|
|
103
128
|
}
|
|
129
|
+
/** A submitted run has a durable id; Ctrl-C must never invite a duplicate POST. */
|
|
130
|
+
function installRunInterruptHandler(reporter, runId) {
|
|
131
|
+
process.on("SIGINT", () => {
|
|
132
|
+
reporter.fail("run", new CliError("interrupted", `Stopped waiting for run ${runId}.`, {
|
|
133
|
+
hint: `The submitted run may still be executing. Resume it with \`scrollport run --resume ${runId}\`; do not submit it again.`,
|
|
134
|
+
exitCode: EXIT_INTERRUPTED,
|
|
135
|
+
}));
|
|
136
|
+
finish(EXIT_INTERRUPTED);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
104
139
|
/**
|
|
105
140
|
* Exit once stdout has drained.
|
|
106
141
|
*
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAmB,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAiB,MAAM,aAAa,CAAC;AAE5D,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE,CAC1C,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;IACtB,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC;AAEL,KAAK,UAAU,IAAI,CAAC,OAAiB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,8EAA8E;IAC9E,+EAA+E;IAC/E,yEAAyE;IACzE,8EAA8E;IAC9E,8CAA8C;IAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAE1C,IAAI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EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACxB,QAAQ,CAAC,IAAI,CACX,KAAK,EACL,IAAI,QAAQ,CAAC,aAAa,EAAE,2BAA2B,KAAK,GAAG,EAAE;YAC/D,IAAI,EAAE,sFAAsF,KAAK,6BAA6B;YAC9H,QAAQ,EAAE,gBAAgB;SAC3B,CAAC,CACH,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IACxB,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,cAAc,KAAK,CAAC,EAAE,CAAC;QACxE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO;IACT,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Resolve an API client without ever putting a stored key or origin on stdout. */
|
|
2
|
+
import { type Env } from "./credentials.js";
|
|
3
|
+
import { ApiClient } from "./http.js";
|
|
4
|
+
/**
|
|
5
|
+
* An explicit flag/environment origin wins. Otherwise a file-backed key stays
|
|
6
|
+
* coupled to the origin it was minted against, which is essential for local
|
|
7
|
+
* and staging setups and is deliberately not a server-side policy decision.
|
|
8
|
+
*/
|
|
9
|
+
export declare function makeClient(apiUrl: string | undefined, env?: Env): ApiClient;
|
|
10
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAoC,MAAM,WAAW,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,GAAE,GAAiB,GAAG,SAAS,CAExF"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Resolve an API client without ever putting a stored key or origin on stdout. */
|
|
2
|
+
import { resolveApiKey } from "./credentials.js";
|
|
3
|
+
import { ApiClient, DEFAULT_API_URL, normalizeApiUrl } from "./http.js";
|
|
4
|
+
/**
|
|
5
|
+
* An explicit flag/environment origin wins. Otherwise a file-backed key stays
|
|
6
|
+
* coupled to the origin it was minted against, which is essential for local
|
|
7
|
+
* and staging setups and is deliberately not a server-side policy decision.
|
|
8
|
+
*/
|
|
9
|
+
export function makeClient(apiUrl, env = process.env) {
|
|
10
|
+
return new ApiClient(normalizeApiUrl(apiUrl ?? resolveApiKey(env)?.apiUrl ?? DEFAULT_API_URL));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,OAAO,EAAE,aAAa,EAAY,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAExE;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAC,MAA0B,EAAE,MAAW,OAAO,CAAC,GAAG;IAC3E,OAAO,IAAI,SAAS,CAAC,eAAe,CAAC,MAAM,IAAI,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,eAAe,CAAC,CAAC,CAAC;AACjG,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Thin CLI wrappers for the API's discover and inspect control tools. */
|
|
2
|
+
import type { Env } from "../credentials.js";
|
|
3
|
+
import type { ApiClient } from "../http.js";
|
|
4
|
+
import type { CommandResult } from "../output.js";
|
|
5
|
+
export interface CatalogDeps {
|
|
6
|
+
client: ApiClient;
|
|
7
|
+
env: Env;
|
|
8
|
+
}
|
|
9
|
+
export declare function runDiscover(deps: CatalogDeps, query: string): Promise<CommandResult>;
|
|
10
|
+
export declare function runInspect(deps: CatalogDeps, toolId: string): Promise<CommandResult>;
|
|
11
|
+
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/commands/catalog.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,GAAG,CAAC;CACV;AAED,wBAAsB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAoB1F;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAyB1F"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { requireApiKey } from "./key.js";
|
|
2
|
+
export async function runDiscover(deps, query) {
|
|
3
|
+
const key = requireApiKey(deps.env);
|
|
4
|
+
const discovery = await deps.client.request("GET", `/tools/search?q=${encodeURIComponent(query)}`, { apiKey: key.apiKey });
|
|
5
|
+
const tools = Array.isArray(discovery["tools"]) ? discovery["tools"] : [];
|
|
6
|
+
const capabilityTools = Array.isArray(discovery["capabilities"])
|
|
7
|
+
? discovery["capabilities"].flatMap((capability) => {
|
|
8
|
+
if (typeof capability !== "object" || capability === null)
|
|
9
|
+
return [];
|
|
10
|
+
const nested = capability["tools"];
|
|
11
|
+
return Array.isArray(nested) ? nested : [];
|
|
12
|
+
})
|
|
13
|
+
: [];
|
|
14
|
+
const shownTools = tools.length ? tools : capabilityTools;
|
|
15
|
+
const human = [`Found ${shownTools.length} live tool${shownTools.length === 1 ? "" : "s"} for: ${query}`];
|
|
16
|
+
for (const tool of shownTools)
|
|
17
|
+
human.push(formatTool(tool));
|
|
18
|
+
if (!shownTools.length)
|
|
19
|
+
human.push("Try a broader job description; only published, live tools are returned.");
|
|
20
|
+
return { json: { query, discovery }, human };
|
|
21
|
+
}
|
|
22
|
+
export async function runInspect(deps, toolId) {
|
|
23
|
+
const key = requireApiKey(deps.env);
|
|
24
|
+
const tool = await deps.client.request("GET", `/tools/${encodeURIComponent(toolId)}`, { apiKey: key.apiKey });
|
|
25
|
+
const name = stringField(tool, "name") ?? toolId;
|
|
26
|
+
const summary = stringField(tool, "summary");
|
|
27
|
+
return {
|
|
28
|
+
json: { tool_id: toolId, tool },
|
|
29
|
+
human: [
|
|
30
|
+
name,
|
|
31
|
+
...(summary ? [summary] : []),
|
|
32
|
+
"",
|
|
33
|
+
"Input contract:",
|
|
34
|
+
pretty(tool["input_schema"]),
|
|
35
|
+
"",
|
|
36
|
+
"Worked example:",
|
|
37
|
+
pretty(tool["worked_example"]),
|
|
38
|
+
"",
|
|
39
|
+
"Common errors:",
|
|
40
|
+
pretty(tool["common_errors"]),
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function formatTool(value) {
|
|
45
|
+
if (typeof value !== "object" || value === null)
|
|
46
|
+
return `- ${pretty(value)}`;
|
|
47
|
+
const tool = value;
|
|
48
|
+
const id = stringField(tool, "tool_id") ?? stringField(tool, "public_slug") ?? stringField(tool, "id") ?? "unknown";
|
|
49
|
+
const name = stringField(tool, "name") ?? id;
|
|
50
|
+
const price = stringField(tool, "price");
|
|
51
|
+
const unit = stringField(tool, "price_unit");
|
|
52
|
+
return `- ${id} — ${name}${price ? ` (${formatUnitPrice(price)}${unit ? ` / ${unit}` : ""})` : ""}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Keep the public CLI's human rate display identical to shared `formatPrice`.
|
|
56
|
+
* `@scrollport/shared` is deliberately private, so the separately published
|
|
57
|
+
* CLI cannot import it at runtime; this string-only copy keeps API decimals
|
|
58
|
+
* out of float math while JSON mode retains the exact original value.
|
|
59
|
+
*/
|
|
60
|
+
function formatUnitPrice(value) {
|
|
61
|
+
const source = value.trim();
|
|
62
|
+
const match = /^([+-]?)(\d+)(?:\.(\d+))?$/.exec(source);
|
|
63
|
+
if (!match)
|
|
64
|
+
return `$${value}`;
|
|
65
|
+
const negative = match[1] === "-";
|
|
66
|
+
const fraction = match[3] ?? "";
|
|
67
|
+
let scaled = BigInt(match[2]) * 10000n + BigInt(fraction.slice(0, 4).padEnd(4, "0") || "0");
|
|
68
|
+
if (fraction.length > 4 && fraction[4] >= "5")
|
|
69
|
+
scaled += 1n;
|
|
70
|
+
const whole = scaled / 10000n;
|
|
71
|
+
const decimals = String(scaled % 10000n).padStart(4, "0");
|
|
72
|
+
const sign = negative && scaled !== 0n ? "-" : "";
|
|
73
|
+
return `${sign}$${whole}.${decimals}`;
|
|
74
|
+
}
|
|
75
|
+
function stringField(value, key) {
|
|
76
|
+
return typeof value[key] === "string" ? value[key] : undefined;
|
|
77
|
+
}
|
|
78
|
+
function pretty(value) {
|
|
79
|
+
return JSON.stringify(value ?? null, null, 2);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/commands/catalog.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,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AM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC;IAC9F,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAE,IAAI,GAAG;QAAE,MAAM,IAAI,EAAE,CAAC;IAC7D,MAAM,KAAK,GAAG,MAAM,GAAG,MAAO,CAAC;IAC/B,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,MAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,QAAQ,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,QAAQ,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,WAAW,CAAC,KAA8B,EAAE,GAAW;IAC9D,OAAO,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,IAAI,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../src/commands/key.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,EAAkC,KAAK,GAAG,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG/F,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,WAAW,CAOnD"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Resolve the one credential every agent-facing control command needs. */
|
|
2
|
+
import { credentialsPath, resolveApiKey } from "../credentials.js";
|
|
3
|
+
import { CliError, EXIT_UNAUTHENTICATED } from "../errors.js";
|
|
4
|
+
export function requireApiKey(env) {
|
|
5
|
+
const resolved = resolveApiKey(env);
|
|
6
|
+
if (resolved)
|
|
7
|
+
return resolved;
|
|
8
|
+
throw new CliError("not_authenticated", `No scrollport key on this machine (looked in ${credentialsPath(env)}).`, {
|
|
9
|
+
hint: "Run `scrollport setup` — it takes two clicks and provisions one.",
|
|
10
|
+
exitCode: EXIT_UNAUTHENTICATED,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.js","sourceRoot":"","sources":["../../src/commands/key.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,OAAO,EAAE,eAAe,EAAE,aAAa,EAA8B,MAAM,mBAAmB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,UAAU,aAAa,CAAC,GAAQ;IACpC,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAC9B,MAAM,IAAI,QAAQ,CAAC,mBAAmB,EAAE,gDAAgD,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE;QAChH,IAAI,EAAE,kEAAkE;QACxE,QAAQ,EAAE,oBAAoB;KAC/B,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Env } from "../credentials.js";
|
|
2
|
+
import { ApiClient } from "../http.js";
|
|
3
|
+
import type { CommandResult, Reporter } from "../output.js";
|
|
4
|
+
export interface RunDeps {
|
|
5
|
+
client: ApiClient;
|
|
6
|
+
env: Env;
|
|
7
|
+
reporter: Reporter;
|
|
8
|
+
sleep: (ms: number) => Promise<void>;
|
|
9
|
+
now: () => number;
|
|
10
|
+
/** Register recovery guidance only once a submitted run has a durable id. */
|
|
11
|
+
onInterrupt?: (runId: string) => void;
|
|
12
|
+
}
|
|
13
|
+
export type RunOptions = ({
|
|
14
|
+
toolId: string;
|
|
15
|
+
input: string;
|
|
16
|
+
} | {
|
|
17
|
+
resume: string;
|
|
18
|
+
}) & {
|
|
19
|
+
/** Poll a confirmation-gated run while a human opens its approval URL. */
|
|
20
|
+
confirm: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare function runRun(deps: RunDeps, opts: RunOptions): Promise<CommandResult>;
|
|
23
|
+
/** Parse only local JSON; tool schemas remain the API's responsibility. */
|
|
24
|
+
export declare function readInput(raw: string): unknown;
|
|
25
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAA+B,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAiB5D,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,6EAA6E;IAC7E,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,MAAM,UAAU,GAAG,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG;IAClF,0EAA0E;IAC1E,OAAO,EAAE,OAAO,CAAC;CAClB,CAAA;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CA0CpF;AAED,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAW9C"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client for the API's asynchronous run control tool.
|
|
3
|
+
*
|
|
4
|
+
* The API owns estimates, holds, lifecycle validation and human confirmation.
|
|
5
|
+
* This command only submits input, follows the persisted run id, and renders
|
|
6
|
+
* the result. In particular, --confirm waits for a person; it never decides.
|
|
7
|
+
*/
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
9
|
+
import { CliError, EXIT_DENIED, EXIT_ERROR, EXIT_EXPIRED, EXIT_USAGE } from "../errors.js";
|
|
10
|
+
import { ApiClient, isTeachingError, toCliError } from "../http.js";
|
|
11
|
+
import { requireApiKey } from "./key.js";
|
|
12
|
+
const POLL_INTERVAL_MS = 1_000;
|
|
13
|
+
const POLL_TIMEOUT_MS = 10 * 60 * 1_000;
|
|
14
|
+
export async function runRun(deps, opts) {
|
|
15
|
+
const key = requireApiKey(deps.env);
|
|
16
|
+
if ("resume" in opts)
|
|
17
|
+
return await waitForRun(deps, opts.resume, "unknown");
|
|
18
|
+
const input = readInput(opts.input);
|
|
19
|
+
const response = await deps.client.send("POST", "/runs", {
|
|
20
|
+
apiKey: key.apiKey,
|
|
21
|
+
body: { tool_id: opts.toolId, input },
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
const approval = confirmation(response.body);
|
|
25
|
+
if (!approval)
|
|
26
|
+
throw toCliError(response);
|
|
27
|
+
deps.reporter.progress(`Approval required: ${approval.approvalUrl}`);
|
|
28
|
+
deps.reporter.progress("A signed-in human must decide. This CLI cannot approve a spend gate.");
|
|
29
|
+
if (!opts.confirm) {
|
|
30
|
+
return {
|
|
31
|
+
json: {
|
|
32
|
+
run_id: approval.runId,
|
|
33
|
+
status: "awaiting_approval",
|
|
34
|
+
estimate: approval.estimate,
|
|
35
|
+
approval_url: approval.approvalUrl,
|
|
36
|
+
expires_in: approval.expiresIn,
|
|
37
|
+
},
|
|
38
|
+
human: [
|
|
39
|
+
`Run ${approval.runId} is awaiting human approval (estimate: $${approval.estimate}).`,
|
|
40
|
+
`Approval URL: ${approval.approvalUrl}`,
|
|
41
|
+
`After a human decides, resume this exact run: scrollport run --resume ${approval.runId}`,
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return await waitForRun(deps, approval.runId, approval.estimate);
|
|
46
|
+
}
|
|
47
|
+
const accepted = record(response.body);
|
|
48
|
+
const runId = typeof accepted?.["run_id"] === "string" ? accepted["run_id"] : null;
|
|
49
|
+
const estimate = typeof accepted?.["estimate"] === "string" ? accepted["estimate"] : null;
|
|
50
|
+
if (!runId || !estimate) {
|
|
51
|
+
throw new CliError("unexpected_response", "The API accepted a run but returned no run_id or estimate.", {
|
|
52
|
+
hint: "Retry only after checking the API run history; an accepted run may already be in progress.",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return await waitForRun(deps, runId, estimate);
|
|
56
|
+
}
|
|
57
|
+
/** Parse only local JSON; tool schemas remain the API's responsibility. */
|
|
58
|
+
export function readInput(raw) {
|
|
59
|
+
const source = raw.startsWith("@") ? readInputFile(raw.slice(1)) : raw;
|
|
60
|
+
try {
|
|
61
|
+
return JSON.parse(source);
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
throw new CliError("invalid_input_json", "--input must be valid JSON.", {
|
|
65
|
+
hint: "example: --input '{\"query\":\"recent company funding\"}' or --input @input.json",
|
|
66
|
+
exitCode: EXIT_USAGE,
|
|
67
|
+
cause,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function readInputFile(path) {
|
|
72
|
+
if (!path) {
|
|
73
|
+
throw new CliError("input_file_missing", "`@` needs a JSON file path.", {
|
|
74
|
+
hint: "example: --input @input.json",
|
|
75
|
+
exitCode: EXIT_USAGE,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
return readFileSync(path, "utf8");
|
|
80
|
+
}
|
|
81
|
+
catch (cause) {
|
|
82
|
+
throw new CliError("input_file_unreadable", `Could not read input file ${path}.`, {
|
|
83
|
+
hint: "Pass a readable JSON file after @, or pass JSON directly with --input '{...}'.",
|
|
84
|
+
exitCode: EXIT_USAGE,
|
|
85
|
+
cause,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function waitForRun(deps, runId, estimate) {
|
|
90
|
+
const key = requireApiKey(deps.env);
|
|
91
|
+
deps.onInterrupt?.(runId);
|
|
92
|
+
const deadline = deps.now() + POLL_TIMEOUT_MS;
|
|
93
|
+
let polls = 0;
|
|
94
|
+
deps.reporter.progress(`Run ${runId} accepted (estimate: $${estimate}); waiting for completion…`);
|
|
95
|
+
while (true) {
|
|
96
|
+
const run = await deps.client.request("GET", `/runs/${encodeURIComponent(runId)}`, {
|
|
97
|
+
apiKey: key.apiKey,
|
|
98
|
+
});
|
|
99
|
+
if (run.status === "succeeded" || run.status === "failed")
|
|
100
|
+
return completed(runId, estimate, run);
|
|
101
|
+
if (deps.now() >= deadline) {
|
|
102
|
+
throw new CliError("run_poll_timeout", `Run ${runId} did not finish within 10 minutes.`, {
|
|
103
|
+
hint: `Poll GET /v1/runs/${runId} with the same agent credential before starting another run.`,
|
|
104
|
+
exitCode: EXIT_ERROR,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
polls += 1;
|
|
108
|
+
if (polls % 15 === 0)
|
|
109
|
+
deps.reporter.progress(`Run ${runId} is still ${run.status}; polling again…`);
|
|
110
|
+
await deps.sleep(POLL_INTERVAL_MS);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function completed(runId, estimate, run) {
|
|
114
|
+
const success = run.status === "succeeded";
|
|
115
|
+
const approvalOutcome = approvalExitCode(run.error);
|
|
116
|
+
const shownEstimate = estimate === "unknown" ? run.cost_estimated : estimate;
|
|
117
|
+
const cost = success ? (run.cost_final ?? shownEstimate) : "0";
|
|
118
|
+
return {
|
|
119
|
+
ok: success,
|
|
120
|
+
...(success ? {} : { exitCode: approvalOutcome ?? EXIT_ERROR }),
|
|
121
|
+
json: { run_id: runId, estimate: shownEstimate, run },
|
|
122
|
+
human: [
|
|
123
|
+
`Run ${runId} ${success ? "succeeded" : "failed"}.`,
|
|
124
|
+
`Estimated: $${shownEstimate} · Charged: $${cost}${success ? "" : " (hold released)"}`,
|
|
125
|
+
...(run.result === undefined ? [] : ["", "Result:", pretty(run.result)]),
|
|
126
|
+
...(run.artifacts === undefined ? [] : ["", "Artifacts:", pretty(run.artifacts)]),
|
|
127
|
+
...(run.error === undefined ? [] : ["", "Error:", pretty(run.error)]),
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function approvalExitCode(value) {
|
|
132
|
+
if (typeof value !== "object" || value === null)
|
|
133
|
+
return null;
|
|
134
|
+
const error = value["error"];
|
|
135
|
+
if (error === "approval_denied")
|
|
136
|
+
return EXIT_DENIED;
|
|
137
|
+
if (error === "approval_expired")
|
|
138
|
+
return EXIT_EXPIRED;
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
function confirmation(value) {
|
|
142
|
+
if (!isTeachingError(value) || value.error !== "confirmation_required")
|
|
143
|
+
return null;
|
|
144
|
+
const body = value;
|
|
145
|
+
if (typeof body["run_id"] !== "string" || typeof body["approval_url"] !== "string" || typeof body["estimate"] !== "string") {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
runId: body["run_id"],
|
|
150
|
+
approvalUrl: body["approval_url"],
|
|
151
|
+
estimate: body["estimate"],
|
|
152
|
+
expiresIn: typeof body["expires_in"] === "number" ? body["expires_in"] : 0,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function record(value) {
|
|
156
|
+
return typeof value === "object" && value !== null ? value : null;
|
|
157
|
+
}
|
|
158
|
+
function pretty(value) {
|
|
159
|
+
return JSON.stringify(value, null, 2);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC;AA4BxC,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,IAAa,EAAE,IAAgB;IAC1D,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,QAAQ,IAAI,IAAI;QAAE,OAAO,MAAM,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC5E,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE;QACvD,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE;KACtC,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACj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I,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/F,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -13,6 +13,16 @@ export interface SetupOptions {
|
|
|
13
13
|
force: boolean;
|
|
14
14
|
/** `--no-browser`: print the link, open nothing. */
|
|
15
15
|
noBrowser: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* `--invite <code>`: redeem an invite instead of running the device flow.
|
|
18
|
+
*
|
|
19
|
+
* There is no browser and no polling on this path, because there is nothing
|
|
20
|
+
* to approve — the human already decided, naming the agent and capping its
|
|
21
|
+
* scopes, when they created the invite. This is a thin wrapper over
|
|
22
|
+
* `POST /v1/auth/invite/redeem`, which an agent with no shell can call
|
|
23
|
+
* directly; the CLI's only added value here is writing the 0600 file.
|
|
24
|
+
*/
|
|
25
|
+
invite?: string | undefined;
|
|
16
26
|
}
|
|
17
27
|
export declare function runSetup(deps: SetupDeps, opts: SetupOptions): Promise<CommandResult>;
|
|
18
28
|
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAqBA,OAAO,EAKL,KAAK,GAAG,EACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAqBA,OAAO,EAKL,KAAK,GAAG,EACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAO5D,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,GAAG,EAAE,GAAG,CAAC;IACT,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,GAAG,EAAE,MAAM,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,KAAK,EAAE,OAAO,CAAC;IACf,oDAAoD;IACpD,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAsE1F"}
|
package/dist/commands/setup.js
CHANGED
|
@@ -17,11 +17,12 @@
|
|
|
17
17
|
* confusable characters — see device-flow.ts on the API side.)
|
|
18
18
|
*/
|
|
19
19
|
import { awaitAuthorization } from "../device-flow.js";
|
|
20
|
-
import { pollDeviceToken, startDeviceAuthorization } from "../device-client.js";
|
|
20
|
+
import { AGENT_SCOPES, pollDeviceToken, startDeviceAuthorization } from "../device-client.js";
|
|
21
21
|
import { assertSafeUrl, openInBrowser, shouldOpenBrowser } from "../browser.js";
|
|
22
22
|
import { credentialsPath, maskKey, resolveApiKey, saveCredentials, } from "../credentials.js";
|
|
23
23
|
import { CliError, EXIT_ERROR } from "../errors.js";
|
|
24
24
|
import { verifyKey } from "../verify.js";
|
|
25
|
+
import { version } from "../args.js";
|
|
25
26
|
/** How often to reassure a waiting human. Every 5s poll would be noise. */
|
|
26
27
|
const PROGRESS_EVERY_MS = 30_000;
|
|
27
28
|
export async function runSetup(deps, opts) {
|
|
@@ -58,8 +59,39 @@ export async function runSetup(deps, opts) {
|
|
|
58
59
|
reporter.progress(" Provisioning a new one.");
|
|
59
60
|
}
|
|
60
61
|
}
|
|
62
|
+
// ── invite path: no browser, no polling, nothing to approve ──────────────
|
|
63
|
+
// An invite replaces the device flow rather than seeding it. The human
|
|
64
|
+
// already decided — naming this agent and capping its scopes — when they
|
|
65
|
+
// created the invite, so there is no consent step left to run. This is a thin
|
|
66
|
+
// wrapper over POST /v1/auth/invite/redeem; an agent with no shell calls that
|
|
67
|
+
// endpoint directly and skips the CLI entirely.
|
|
68
|
+
let granted;
|
|
69
|
+
if (opts.invite) {
|
|
70
|
+
reporter.progress("Redeeming invite…");
|
|
71
|
+
const redeemed = await client.request("POST", "/auth/invite/redeem", {
|
|
72
|
+
body: {
|
|
73
|
+
code: opts.invite,
|
|
74
|
+
// What this agent claims to be. Display-only provenance, never
|
|
75
|
+
// authorising — the name and scopes come from the invite.
|
|
76
|
+
client_name: `scrollport-cli/${version()}`,
|
|
77
|
+
method: "cli",
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
granted = { apiKey: redeemed.api_key, accountId: redeemed.account_id };
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
granted = await runDeviceFlow(deps, opts, reporter);
|
|
84
|
+
}
|
|
85
|
+
return finishSetup(deps, opts, granted);
|
|
86
|
+
}
|
|
87
|
+
/** The original two-click flow, unchanged, moved behind one call. */
|
|
88
|
+
async function runDeviceFlow(deps, opts, reporter) {
|
|
89
|
+
const { client, env } = deps;
|
|
61
90
|
// ── 1. Ask for a code ────────────────────────────────────────────────────
|
|
62
|
-
|
|
91
|
+
// Scopes are named explicitly: an empty list leaves the consent screen with
|
|
92
|
+
// no scope row at all, and `/start` sends this same four for the direct HTTP
|
|
93
|
+
// route. Both paths must ask for the same thing.
|
|
94
|
+
const auth = await startDeviceAuthorization(client, { scopes: AGENT_SCOPES });
|
|
63
95
|
const verificationUrl = assertSafeUrl(auth.verification_uri_complete);
|
|
64
96
|
const minutes = Math.max(1, Math.round(auth.expires_in / 60));
|
|
65
97
|
reporter.progress("");
|
|
@@ -99,12 +131,22 @@ export async function runSetup(deps, opts) {
|
|
|
99
131
|
lastProgressAt = deps.now();
|
|
100
132
|
}
|
|
101
133
|
};
|
|
102
|
-
|
|
134
|
+
return awaitAuthorization(auth, {
|
|
103
135
|
poll: (deviceCode) => pollDeviceToken(client, deviceCode),
|
|
104
136
|
sleep: deps.sleep,
|
|
105
137
|
now: deps.now,
|
|
106
138
|
onWait,
|
|
107
139
|
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Store, verify, report — shared by both paths.
|
|
143
|
+
*
|
|
144
|
+
* Split out when `--invite` landed: the two paths differ only in how the key is
|
|
145
|
+
* obtained, and everything after that (write it to disk before anything else
|
|
146
|
+
* can fail, prove it works, warn about the env var shadowing it) is identical.
|
|
147
|
+
*/
|
|
148
|
+
async function finishSetup(deps, _opts, granted) {
|
|
149
|
+
const { client, env } = deps;
|
|
108
150
|
// ── 3. Store it before anything else can fail ────────────────────────────
|
|
109
151
|
// The key is minted exactly once (the server's grant is spent). If we lose it
|
|
110
152
|
// now it is gone for good, so it goes to disk before we do anything clever.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,kBAAkB,EAAkB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/commands/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,kBAAkB,EAAkB,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO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,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE;YAClE,KAAK,EAAE;gBACL,4BAA4B,QAAQ,KAAK,IAAI,CAAC,cAAc,IAAI;gBAChE,YAAY,OAAO,CAAC,SAAS,EAAE;gBAC/B,yGAAyG;gBACzG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;aACpC;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,aAAa,EAAE;QACjE,KAAK,EAAE;YACL,4BAA4B,QAAQ,KAAK,IAAI,CAAC,cAAc,IAAI;YAChE,YAAY,OAAO,CAAC,SAAS,EAAE;YAC/B,oBAAoB,MAAM,CAAC,OAAO,mBAAmB;YACrD,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACpC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,OAAe;IACtC,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QACtC,MAAM,IAAI,GAAG,OAAO,GAAG,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;IACjD,CAAC;IACD,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Read-only wallet control tool. Limits remain human-only API operations. */
|
|
2
|
+
import type { Env } from "../credentials.js";
|
|
3
|
+
import type { ApiClient } from "../http.js";
|
|
4
|
+
import type { CommandResult } from "../output.js";
|
|
5
|
+
export interface WalletDeps {
|
|
6
|
+
client: ApiClient;
|
|
7
|
+
env: Env;
|
|
8
|
+
}
|
|
9
|
+
export declare function runWallet(deps: WalletDeps): Promise<CommandResult>;
|
|
10
|
+
//# sourceMappingURL=wallet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/commands/wallet.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAGlD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,GAAG,CAAC;CACV;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAcxE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { requireApiKey } from "./key.js";
|
|
2
|
+
export async function runWallet(deps) {
|
|
3
|
+
const key = requireApiKey(deps.env);
|
|
4
|
+
const wallet = await deps.client.request("GET", "/wallet", { apiKey: key.apiKey });
|
|
5
|
+
return {
|
|
6
|
+
json: { wallet },
|
|
7
|
+
human: [
|
|
8
|
+
`Workspace: ${text(wallet, "workspace_name") ?? "unknown"}`,
|
|
9
|
+
`Available: ${formatBalance(text(wallet, "available") ?? "0")}`,
|
|
10
|
+
`Balance: ${formatBalance(text(wallet, "balance") ?? "0")} · Held: ${formatBalance(text(wallet, "held") ?? "0")}`,
|
|
11
|
+
`Per-run confirmation: ${moneyOrNone(wallet["confirm_threshold"])}`,
|
|
12
|
+
`Daily limit: ${moneyOrNone(wallet["daily_spend_limit"])} · remaining: ${wallet["daily_remaining"] === null ? "No limit" : formatBalance(String(wallet["daily_remaining"] ?? "0"))}`,
|
|
13
|
+
`Daily reset: ${text(wallet, "daily_resets_at") ?? "unknown"}`,
|
|
14
|
+
],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function text(value, key) {
|
|
18
|
+
return typeof value[key] === "string" ? value[key] : undefined;
|
|
19
|
+
}
|
|
20
|
+
function moneyOrNone(value) {
|
|
21
|
+
return typeof value === "string" ? `$${value.replace(/\.0+$/, "")}` : "No limit";
|
|
22
|
+
}
|
|
23
|
+
/** Account aggregates display at 2dp, floored, without introducing float math. */
|
|
24
|
+
function formatBalance(value) {
|
|
25
|
+
const negative = value.trim().startsWith("-");
|
|
26
|
+
const [wholeRaw, fractionRaw = ""] = value.trim().replace(/^[+-]/, "").split(".");
|
|
27
|
+
const whole = wholeRaw || "0";
|
|
28
|
+
const fraction = `${fractionRaw}00`.slice(0, 2);
|
|
29
|
+
const hasRemainder = /[1-9]/.test(fractionRaw.slice(2));
|
|
30
|
+
if (!negative)
|
|
31
|
+
return `$${whole}.${fraction}`;
|
|
32
|
+
if (!hasRemainder)
|
|
33
|
+
return `-$${whole}.${fraction}`;
|
|
34
|
+
const cents = BigInt(whole) * 100n + BigInt(fraction || "0") + 1n;
|
|
35
|
+
return `-$${cents / 100n}.${String(cents % 100n).padStart(2, "0")}`;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=wallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet.js","sourceRoot":"","sources":["../../src/commands/wallet.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAOzC,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAgB;IAC9C,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAA0B,KAAK,EAAE,SAAS,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAA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E,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC9C,MAAM,CAAC,QAAQ,EAAE,WAAW,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClF,MAAM,KAAK,GAAG,QAAQ,IAAI,GAAG,CAAC;IAC9B,MAAM,QAAQ,GAAG,GAAG,WAAW,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,KAAK,IAAI,QAAQ,EAAE,CAAC;IAC9C,IAAI,CAAC,YAAY;QAAE,OAAO,KAAK,KAAK,IAAI,QAAQ,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;IAClE,OAAO,KAAK,KAAK,GAAG,IAAI,IAAI,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AACtE,CAAC"}
|
package/dist/device-client.d.ts
CHANGED
|
@@ -2,6 +2,24 @@ import type { ApiClient } from "./http.js";
|
|
|
2
2
|
import type { DeviceAuthorizationStart, PollOutcome } from "./device-flow.js";
|
|
3
3
|
/** Shown on the consent screen so the human can see what they are approving. */
|
|
4
4
|
export declare const CLIENT_NAME = "scrollport CLI";
|
|
5
|
+
/**
|
|
6
|
+
* What a user agent is granted: all four, always.
|
|
7
|
+
*
|
|
8
|
+
* Asked for explicitly rather than left to the server's default, for two
|
|
9
|
+
* reasons. The consent screen renders the scope row only when the list is
|
|
10
|
+
* non-empty (`apps/web/app/device/page.tsx`), so omitting them shows the human
|
|
11
|
+
* *nothing* about what they are approving — and the anti-phishing property of
|
|
12
|
+
* this flow is that the human can see what they are agreeing to. And `/start`
|
|
13
|
+
* tells an agent calling the HTTP endpoint directly to send exactly this list;
|
|
14
|
+
* the two routes have to produce the same grant, or "run the CLI if you can" is
|
|
15
|
+
* a quiet downgrade.
|
|
16
|
+
*
|
|
17
|
+
* A narrower set is not useful: an agent without `wallet` cannot answer "can I
|
|
18
|
+
* afford this?", which is the question it asks most. #169 makes the same four a
|
|
19
|
+
* server-side ceiling, at which point this becomes belt-and-braces rather than
|
|
20
|
+
* the only thing holding the grant together.
|
|
21
|
+
*/
|
|
22
|
+
export declare const AGENT_SCOPES: string[];
|
|
5
23
|
/**
|
|
6
24
|
* `POST /v1/auth/device`. Returns both plaintext codes — the only time they
|
|
7
25
|
* exist. The device code is a credential and is never displayed; the user code
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-client.d.ts","sourceRoot":"","sources":["../src/device-client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9E,gFAAgF;AAChF,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,SAAS,EACjB,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GACpD,OAAO,CAAC,wBAAwB,CAAC,
|
|
1
|
+
{"version":3,"file":"device-client.d.ts","sourceRoot":"","sources":["../src/device-client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9E,gFAAgF;AAChF,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,UAA2C,CAAC;AAErE;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,SAAS,EACjB,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GACpD,OAAO,CAAC,wBAAwB,CAAC,CAWnC;AAED;;;;;;;;GAQG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,CAAC,CAkDtB"}
|
package/dist/device-client.js
CHANGED
|
@@ -2,6 +2,24 @@ import { isTeachingError, toCliError } from "./http.js";
|
|
|
2
2
|
import { isCliError } from "./errors.js";
|
|
3
3
|
/** Shown on the consent screen so the human can see what they are approving. */
|
|
4
4
|
export const CLIENT_NAME = "scrollport CLI";
|
|
5
|
+
/**
|
|
6
|
+
* What a user agent is granted: all four, always.
|
|
7
|
+
*
|
|
8
|
+
* Asked for explicitly rather than left to the server's default, for two
|
|
9
|
+
* reasons. The consent screen renders the scope row only when the list is
|
|
10
|
+
* non-empty (`apps/web/app/device/page.tsx`), so omitting them shows the human
|
|
11
|
+
* *nothing* about what they are approving — and the anti-phishing property of
|
|
12
|
+
* this flow is that the human can see what they are agreeing to. And `/start`
|
|
13
|
+
* tells an agent calling the HTTP endpoint directly to send exactly this list;
|
|
14
|
+
* the two routes have to produce the same grant, or "run the CLI if you can" is
|
|
15
|
+
* a quiet downgrade.
|
|
16
|
+
*
|
|
17
|
+
* A narrower set is not useful: an agent without `wallet` cannot answer "can I
|
|
18
|
+
* afford this?", which is the question it asks most. #169 makes the same four a
|
|
19
|
+
* server-side ceiling, at which point this becomes belt-and-braces rather than
|
|
20
|
+
* the only thing holding the grant together.
|
|
21
|
+
*/
|
|
22
|
+
export const AGENT_SCOPES = ["discover", "inspect", "run", "wallet"];
|
|
5
23
|
/**
|
|
6
24
|
* `POST /v1/auth/device`. Returns both plaintext codes — the only time they
|
|
7
25
|
* exist. The device code is a credential and is never displayed; the user code
|
|
@@ -13,6 +31,7 @@ export async function startDeviceAuthorization(client, opts = {}) {
|
|
|
13
31
|
const body = await client.request("POST", "/auth/device", {
|
|
14
32
|
body: {
|
|
15
33
|
client_name: opts.clientName ?? CLIENT_NAME,
|
|
34
|
+
access_method: "cli",
|
|
16
35
|
...(opts.scopes ? { scopes: opts.scopes } : {}),
|
|
17
36
|
},
|
|
18
37
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-client.js","sourceRoot":"","sources":["../src/device-client.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,gFAAgF;AAChF,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,MAAiB,EACjB,OAAmD,EAAE;IAErD,8EAA8E;IAC9E,yEAAyE;IACzE,MAAM,IAAI,GAAuB,MAAM,MAAM,CAAC,OAAO,CAAqB,MAAM,EAAE,cAAc,EAAE;QAChG,IAAI,EAAE;YACJ,WAAW,EAAE,IAAI,CAAC,UAAU,IAAI,WAAW;YAC3C,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD;KACF,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAiB,EACjB,UAAkB;IAElB,IAAI,GAAG,CAAC;IACR,IAAI,CAAC;QACH,G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IAED,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,YAAY,CAAC,IAAa;IACjC,MAAM,KAAK,GAAI,IAAgC,CAAC,UAAU,CAAC,CAAC;IAC5D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5E,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* regex a message. Every code below is documented in README.md and must stay
|
|
7
7
|
* stable.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* ONBOARDING.md > Invariant 5 applies to the terminal exactly as it applies to the
|
|
10
10
|
* API: `{ error, message, hint }`, where the hint carries the corrected command
|
|
11
11
|
* wherever one exists. A CLI that prints "Error: request failed" has taught the
|
|
12
12
|
* user nothing and cost them a support round-trip.
|
package/dist/errors.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* regex a message. Every code below is documented in README.md and must stay
|
|
7
7
|
* stable.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* ONBOARDING.md > Invariant 5 applies to the terminal exactly as it applies to the
|
|
10
10
|
* API: `{ error, message, hint }`, where the hint carries the corrected command
|
|
11
11
|
* wherever one exists. A CLI that prints "Error: request failed" has taught the
|
|
12
12
|
* user nothing and cost them a support round-trip.
|
package/dist/http.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export declare class ApiClient {
|
|
|
69
69
|
export declare function isTeachingError(body: unknown): body is TeachingError;
|
|
70
70
|
/**
|
|
71
71
|
* Turn a failed response into a CliError, preserving the API's message and hint
|
|
72
|
-
* verbatim. The server already wrote a teaching error (
|
|
72
|
+
* verbatim. The server already wrote a teaching error (ONBOARDING.md > Invariant 5);
|
|
73
73
|
* rewording it here would only lose information.
|
|
74
74
|
*/
|
|
75
75
|
export declare function toCliError(res: ApiResponse): CliError;
|
package/dist/http.js
CHANGED
|
@@ -136,7 +136,7 @@ export function isTeachingError(body) {
|
|
|
136
136
|
}
|
|
137
137
|
/**
|
|
138
138
|
* Turn a failed response into a CliError, preserving the API's message and hint
|
|
139
|
-
* verbatim. The server already wrote a teaching error (
|
|
139
|
+
* verbatim. The server already wrote a teaching error (ONBOARDING.md > Invariant 5);
|
|
140
140
|
* rewording it here would only lose information.
|
|
141
141
|
*/
|
|
142
142
|
export function toCliError(res) {
|
package/dist/output.d.ts
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
import type { CliError } from "./errors.js";
|
|
10
10
|
/** What a command hands back: one machine object, and the lines a human reads. */
|
|
11
11
|
export interface CommandResult {
|
|
12
|
+
/** False only when the API completed a requested run unsuccessfully. */
|
|
13
|
+
ok?: boolean;
|
|
14
|
+
/** A completed remote run can be a command failure without being a CLI crash. */
|
|
15
|
+
exitCode?: number;
|
|
12
16
|
/** Merged into the `--json` envelope. Must contain no secrets. */
|
|
13
17
|
json: Record<string, unknown>;
|
|
14
18
|
/** stdout lines for a human. Empty is legal. */
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,kFAAkF;AAClF,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,gDAAgD;IAChD,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,uEAAuE;IACvE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,gEAAgE;IAChE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA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EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,eAAe,GAAG,QAAQ,CA0B9D"}
|
package/dist/output.js
CHANGED
|
@@ -7,7 +7,7 @@ export function createReporter(opts) {
|
|
|
7
7
|
},
|
|
8
8
|
finish(command, result) {
|
|
9
9
|
if (opts.json) {
|
|
10
|
-
out(`${JSON.stringify({ ok: true, command, ...result.json })}\n`);
|
|
10
|
+
out(`${JSON.stringify({ ok: result.ok ?? true, command, ...result.json })}\n`);
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
for (const line of result.human)
|
package/dist/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAqCA,MAAM,UAAU,cAAc,CAAC,IAAqB;IAClD,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5E,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5E,OAAO;QACL,QAAQ,CAAC,IAAI;YACX,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QACnB,CAAC;QAED,MAAM,CAAC,OAAO,EAAE,MAAM;YACpB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC;gBAC/E,OAAO;YACT,CAAC;YACD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK;gBAAE,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,QAAQ;YACpB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;gBACzE,OAAO;YACT,CAAC;YACD,GAAG,CAAC,YAAY,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;YACtC,IAAI,QAAQ,CAAC,IAAI;gBAAE,GAAG,CAAC,UAAU,QAAQ,CAAC,IAAI,IAAI,CAAC,CAAC;QACtD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scrollport",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "scrollport CLI \u2014 provision an agent's key against one prepaid wallet.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"build": "tsc -b",
|
|
22
22
|
"typecheck": "tsc --noEmit",
|
|
23
23
|
"test": "vitest run",
|
|
24
|
-
"lint": "
|
|
24
|
+
"lint": "eslint . --max-warnings=0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@scrollport/shared": "workspace:*",
|