@usenaive-sdk/cli 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +32 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -39216,6 +39216,21 @@ var ExecResultSchema = external_exports.object({
|
|
|
39216
39216
|
truncated: external_exports.boolean().optional()
|
|
39217
39217
|
});
|
|
39218
39218
|
var DirectorySchema = external_exports.object({ entries: external_exports.array(FileEntrySchema2) });
|
|
39219
|
+
async function* untilExit(path, frames2) {
|
|
39220
|
+
let exited = false;
|
|
39221
|
+
for await (const frame of frames2) {
|
|
39222
|
+
if ("exit" in frame) exited = true;
|
|
39223
|
+
yield frame;
|
|
39224
|
+
}
|
|
39225
|
+
if (!exited) {
|
|
39226
|
+
throw new ApiError(502, {
|
|
39227
|
+
type: "api_error",
|
|
39228
|
+
code: "internal_error",
|
|
39229
|
+
message: `POST ${path} ended without an exit frame; the command may have run \u2014 check GET \u2026/commands before re-running it`,
|
|
39230
|
+
request_id: ""
|
|
39231
|
+
});
|
|
39232
|
+
}
|
|
39233
|
+
}
|
|
39219
39234
|
var workspace = (config2) => ({
|
|
39220
39235
|
/** The name, and nothing else (§41.5). */
|
|
39221
39236
|
update: (id, body2) => request(config2, ComputerSchema2, { method: "PATCH", path: `/v1/computers/${encodeURIComponent(id)}`, body: body2 }),
|
|
@@ -39225,11 +39240,14 @@ var workspace = (config2) => ({
|
|
|
39225
39240
|
* The same run as `exec`, frame by frame (§41.2): `{stdout}`/`{stderr}` as they arrive, then one
|
|
39226
39241
|
* `{exit}` naming the `computer_command` row it was recorded as. One connection, no resume.
|
|
39227
39242
|
*/
|
|
39228
|
-
execStream: (id, command, opts = {}) =>
|
|
39229
|
-
|
|
39230
|
-
|
|
39231
|
-
|
|
39232
|
-
|
|
39243
|
+
execStream: (id, command, opts = {}) => {
|
|
39244
|
+
const body2 = { command, ...opts.timeoutMs === void 0 ? {} : { timeout_ms: opts.timeoutMs } };
|
|
39245
|
+
return untilExit(`/v1/computers/${encodeURIComponent(id)}/exec/stream`, streamFrames(config2, ExecStreamFrameSchema2, {
|
|
39246
|
+
method: "POST",
|
|
39247
|
+
path: `/v1/computers/${encodeURIComponent(id)}/exec/stream`,
|
|
39248
|
+
body: body2
|
|
39249
|
+
}));
|
|
39250
|
+
},
|
|
39233
39251
|
/** What has been run on the box, newest first (§41.3). */
|
|
39234
39252
|
commands: (id, query2 = {}) => request(config2, page(ComputerCommandSchema2), {
|
|
39235
39253
|
method: "GET",
|
|
@@ -51875,7 +51893,7 @@ var ALIASES = {
|
|
|
51875
51893
|
};
|
|
51876
51894
|
|
|
51877
51895
|
// src/cli.ts
|
|
51878
|
-
var VERSION = true ? "1.0.
|
|
51896
|
+
var VERSION = true ? "1.0.3" : "0.0.0-dev";
|
|
51879
51897
|
var GLOBAL_FLAGS_HELP = "global flags: --json (default) --human --profile <name> --api-key <key> --org <org_id> --api-base-url <url>";
|
|
51880
51898
|
function usage() {
|
|
51881
51899
|
const groups = [...Object.keys(GROUPS), ...Object.keys(ALIASES)].sort().join(", ");
|
|
@@ -51949,9 +51967,13 @@ function clients(deps2, baseUrl) {
|
|
|
51949
51967
|
const fetch = namingHost(deps2.fetch, baseUrl);
|
|
51950
51968
|
return (apiKey) => createClient({ baseUrl, apiKey, fetch, idempotencyKey: deps2.idempotencyKey });
|
|
51951
51969
|
}
|
|
51970
|
+
function argvKeyWarning(flag) {
|
|
51971
|
+
return `warning: ${flag} leaves the key in shell history and, under npx, in ~/.npm/_logs; pipe it on stdin (read -rs KEY && printf '%s\\n' "$KEY" | naive login) or set NAIVE_API_KEY`;
|
|
51972
|
+
}
|
|
51952
51973
|
async function run(argv, deps2) {
|
|
51953
51974
|
const parsed = parseLine(argv);
|
|
51954
51975
|
const first = parsed.words[0] ?? "";
|
|
51976
|
+
let argvKey;
|
|
51955
51977
|
try {
|
|
51956
51978
|
if (parsed.args(2).bool("version")) {
|
|
51957
51979
|
deps2.io.out(`naive ${VERSION} (api ${API_VERSION})`);
|
|
@@ -51972,6 +51994,8 @@ async function run(argv, deps2) {
|
|
|
51972
51994
|
const args = parsed.args(sub2 ? 3 : alias ? 1 : 2);
|
|
51973
51995
|
rejectUnknownFlags(args.names(), group, command);
|
|
51974
51996
|
const config2 = resolveConfig(args, deps2.env, deps2.readConfig, { login: group === "auth" && command === "login" });
|
|
51997
|
+
const claimKey = group === "naive" && command === "claim" && args.str("key") !== void 0;
|
|
51998
|
+
argvKey = args.str("api-key") !== void 0 ? "--api-key" : claimKey ? "--key" : void 0;
|
|
51975
51999
|
if (config2.apiKey === "" && group !== "auth" && group !== "naive") throw new UsageError(NO_API_KEY);
|
|
51976
52000
|
const withApiKey = clients(deps2, config2.baseUrl);
|
|
51977
52001
|
const human2 = args.bool("human");
|
|
@@ -51988,6 +52012,8 @@ async function run(argv, deps2) {
|
|
|
51988
52012
|
} catch (cause) {
|
|
51989
52013
|
deps2.io.err(describeError(cause));
|
|
51990
52014
|
return exitForError(cause);
|
|
52015
|
+
} finally {
|
|
52016
|
+
if (argvKey !== void 0) deps2.io.err(argvKeyWarning(argvKey));
|
|
51991
52017
|
}
|
|
51992
52018
|
}
|
|
51993
52019
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usenaive-sdk/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Naive Managed Agents command line — create agents, run sessions, watch events, see cost.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"esbuild": "0.28.2",
|
|
28
28
|
"yaml": "^2.9.0",
|
|
29
29
|
"@vetta/core": "0.0.0",
|
|
30
|
-
"@usenaive-sdk/managed-agents": "0.12.
|
|
30
|
+
"@usenaive-sdk/managed-agents": "0.12.3",
|
|
31
31
|
"@usenaive-sdk/blueprints": "0.18.0"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|