@w6w/cli 0.9.15 → 0.9.23
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 +29 -14
- package/dist/bin/w6w.js +4 -0
- package/dist/bin/w6w.js.map +1 -1
- package/dist/mod.d.ts +20 -2
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +25 -13
- package/dist/mod.js.map +1 -1
- package/dist/src/args.d.ts +8 -1
- package/dist/src/args.d.ts.map +1 -1
- package/dist/src/args.js +15 -3
- package/dist/src/args.js.map +1 -1
- package/dist/src/client.d.ts +51 -4
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +83 -30
- package/dist/src/client.js.map +1 -1
- package/dist/src/commands/agents-studio.d.ts +24 -0
- package/dist/src/commands/agents-studio.d.ts.map +1 -0
- package/dist/src/commands/agents-studio.js +431 -0
- package/dist/src/commands/agents-studio.js.map +1 -0
- package/dist/src/commands/assets.d.ts +47 -0
- package/dist/src/commands/assets.d.ts.map +1 -0
- package/dist/src/commands/assets.js +412 -0
- package/dist/src/commands/assets.js.map +1 -0
- package/dist/src/commands/auth.d.ts +24 -0
- package/dist/src/commands/auth.d.ts.map +1 -0
- package/dist/src/commands/auth.js +112 -0
- package/dist/src/commands/auth.js.map +1 -0
- package/dist/src/commands/config.d.ts +21 -0
- package/dist/src/commands/config.d.ts.map +1 -0
- package/dist/src/commands/config.js +73 -0
- package/dist/src/commands/config.js.map +1 -0
- package/dist/src/commands/connections.d.ts +1 -1
- package/dist/src/commands/connections.d.ts.map +1 -1
- package/dist/src/commands/connections.js +27 -2
- package/dist/src/commands/connections.js.map +1 -1
- package/dist/src/commands/index.d.ts +6 -0
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +18 -0
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/ls.d.ts +21 -0
- package/dist/src/commands/ls.d.ts.map +1 -0
- package/dist/src/commands/ls.js +53 -0
- package/dist/src/commands/ls.js.map +1 -0
- package/dist/src/commands/models.d.ts +16 -0
- package/dist/src/commands/models.d.ts.map +1 -0
- package/dist/src/commands/models.js +126 -0
- package/dist/src/commands/models.js.map +1 -0
- package/dist/src/commands/vars.d.ts.map +1 -1
- package/dist/src/commands/vars.js +2 -2
- package/dist/src/commands/vars.js.map +1 -1
- package/dist/src/config-store.d.ts +86 -0
- package/dist/src/config-store.d.ts.map +1 -0
- package/dist/src/config-store.js +129 -0
- package/dist/src/config-store.js.map +1 -0
- package/dist/src/help.generated.d.ts.map +1 -1
- package/dist/src/help.generated.js +2723 -105
- package/dist/src/help.generated.js.map +1 -1
- package/dist/src/store-fs.d.ts +34 -0
- package/dist/src/store-fs.d.ts.map +1 -0
- package/dist/src/store-fs.js +151 -0
- package/dist/src/store-fs.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w auth login | logout | status` — the stored API token.
|
|
3
|
+
*
|
|
4
|
+
* Declared in `endpoints.json` `cli.commands[]` (CLI-only: no API operation sits
|
|
5
|
+
* behind them) and routed like any other group. None of them touches the
|
|
6
|
+
* network, and none ever prints a token.
|
|
7
|
+
*
|
|
8
|
+
* The token is **bound to the base URL it is saved for**. All three commands
|
|
9
|
+
* resolve that URL through the one resolver in `src/client.ts`
|
|
10
|
+
* ({@linkcode resolveSettings}), the same code a real command uses, so
|
|
11
|
+
* `auth status` reports exactly what the next command will do.
|
|
12
|
+
*
|
|
13
|
+
* `login` takes the token as a positional (`w6w auth login <token>`) or from
|
|
14
|
+
* standard input (`w6w auth login -`, or no argument with piped input). The
|
|
15
|
+
* stdin form is the safer one: a positional lands in shell history and in the
|
|
16
|
+
* process list. `login` never stores the global `--token` or `W6W_TOKEN` — they
|
|
17
|
+
* are overrides, not credentials to save.
|
|
18
|
+
*
|
|
19
|
+
* @module
|
|
20
|
+
*/
|
|
21
|
+
import { ConfigError } from "@w6w/sdk";
|
|
22
|
+
import { ENV_TOKEN, isUnsendable, resolveSettings } from "../client.js";
|
|
23
|
+
import { serializeConfig } from "../config-store.js";
|
|
24
|
+
import { noExtraArguments, usageError } from "./shared.js";
|
|
25
|
+
/** The base URL these commands act on: flag > env > stored > default, never the token sources. */
|
|
26
|
+
function resolveBase(context) {
|
|
27
|
+
const { globals } = context.invocation;
|
|
28
|
+
return resolveSettings({ ...globals, token: undefined }, (name) => (name === ENV_TOKEN ? undefined : context.env(name)), context.stored);
|
|
29
|
+
}
|
|
30
|
+
/** `"****"` plus the last four characters of a long-enough token, else just `"****"`. */
|
|
31
|
+
function mask(token) {
|
|
32
|
+
return token.length >= 12 ? `****${token.slice(-4)}` : "****";
|
|
33
|
+
}
|
|
34
|
+
function requirePath(context) {
|
|
35
|
+
const path = context.store.path;
|
|
36
|
+
if (path === undefined) {
|
|
37
|
+
throw new ConfigError("w6w cannot tell where to keep its config: neither XDG_CONFIG_HOME (an absolute path) " +
|
|
38
|
+
"nor HOME is set. Nothing was saved.");
|
|
39
|
+
}
|
|
40
|
+
return path;
|
|
41
|
+
}
|
|
42
|
+
const login = async (context) => {
|
|
43
|
+
noExtraArguments(context, 1);
|
|
44
|
+
const positional = context.invocation.positionals[0];
|
|
45
|
+
let token;
|
|
46
|
+
if (positional === "-" || (positional === undefined && !context.stdin.isTerminal())) {
|
|
47
|
+
// One trailing newline is the shell's, not the token's.
|
|
48
|
+
token = (await context.stdin.read()).replace(/\r?\n$/, "");
|
|
49
|
+
}
|
|
50
|
+
else if (positional === undefined) {
|
|
51
|
+
throw usageError(context, "`auth login` needs a token. Pass it as an argument, or pipe it in: " +
|
|
52
|
+
"`printf '%s' \"$TOKEN\" | w6w auth login -`.");
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
token = positional;
|
|
56
|
+
}
|
|
57
|
+
if (token.trim().length === 0) {
|
|
58
|
+
throw usageError(context, "The token is empty; nothing was saved.");
|
|
59
|
+
}
|
|
60
|
+
if (isUnsendable(token)) {
|
|
61
|
+
throw usageError(context, "The token contains a character that cannot be sent in an HTTP header " +
|
|
62
|
+
"(a control character); nothing was saved.");
|
|
63
|
+
}
|
|
64
|
+
const { baseUrl } = resolveBase(context);
|
|
65
|
+
const path = requirePath(context);
|
|
66
|
+
const next = {
|
|
67
|
+
version: 1,
|
|
68
|
+
baseUrl,
|
|
69
|
+
hosts: { ...context.stored.hosts, [baseUrl]: { token } },
|
|
70
|
+
};
|
|
71
|
+
await context.store.write(serializeConfig(next));
|
|
72
|
+
context.out.emit({ baseUrl, configPath: path }, () => `Saved the API token for ${baseUrl} in ${path}.`);
|
|
73
|
+
};
|
|
74
|
+
const logout = async (context) => {
|
|
75
|
+
noExtraArguments(context, 0);
|
|
76
|
+
const { baseUrl } = resolveBase(context);
|
|
77
|
+
const had = Object.hasOwn(context.stored.hosts, baseUrl);
|
|
78
|
+
if (had) {
|
|
79
|
+
requirePath(context);
|
|
80
|
+
const hosts = { ...context.stored.hosts };
|
|
81
|
+
delete hosts[baseUrl];
|
|
82
|
+
await context.store.write(serializeConfig({ version: 1, baseUrl: context.stored.baseUrl, hosts }));
|
|
83
|
+
}
|
|
84
|
+
context.out.emit({ baseUrl, removed: had }, () => had
|
|
85
|
+
? `Removed the stored API token for ${baseUrl}.`
|
|
86
|
+
: `No stored API token for ${baseUrl}; nothing to remove.`);
|
|
87
|
+
};
|
|
88
|
+
const status = (context) => {
|
|
89
|
+
noExtraArguments(context, 0);
|
|
90
|
+
const settings = resolveSettings(context.invocation.globals, context.env, context.stored);
|
|
91
|
+
const payload = {
|
|
92
|
+
baseUrl: settings.baseUrl,
|
|
93
|
+
baseUrlSource: settings.baseUrlSource,
|
|
94
|
+
tokenSource: settings.tokenSource ?? null,
|
|
95
|
+
tokenMasked: settings.token === undefined ? null : mask(settings.token),
|
|
96
|
+
configPath: context.store.path ?? null,
|
|
97
|
+
};
|
|
98
|
+
context.out.emit(payload, (styles) => [
|
|
99
|
+
`${styles.bold("base URL")} ${payload.baseUrl} (${payload.baseUrlSource})`,
|
|
100
|
+
`${styles.bold("token")} ${payload.tokenSource === null
|
|
101
|
+
? "none — run `w6w auth login`"
|
|
102
|
+
: `${payload.tokenMasked} (${payload.tokenSource})`}`,
|
|
103
|
+
`${styles.bold("config")} ${payload.configPath ?? "(no config directory)"}`,
|
|
104
|
+
].join("\n"));
|
|
105
|
+
};
|
|
106
|
+
/** The three `w6w auth` commands. */
|
|
107
|
+
export const AUTH_COMMANDS = {
|
|
108
|
+
"auth login": login,
|
|
109
|
+
"auth logout": logout,
|
|
110
|
+
"auth status": status,
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/commands/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,eAAe,EAAqB,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE3D,kGAAkG;AAClG,SAAS,WAAW,CAAC,OAAuB;IAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IACvC,OAAO,eAAe,CACpB,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAChC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,EAC9D,OAAO,CAAC,MAAM,CACf,CAAC;AACJ,CAAC;AAED,yFAAyF;AACzF,SAAS,IAAI,CAAC,KAAa;IACzB,OAAO,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,O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AO,OAAO,CAAC,UAAU,IAAI,uBAAuB,EAAE;KAC/E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,qCAAqC;AACrC,MAAM,CAAC,MAAM,aAAa,GAAoB;IAC5C,YAAY,EAAE,KAAK;IACnB,aAAa,EAAE,MAAM;IACrB,aAAa,EAAE,MAAM;CACtB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w config get-base-url | set-base-url <url>` — the stored API base URL.
|
|
3
|
+
*
|
|
4
|
+
* Declared in `endpoints.json` `cli.commands[]` (CLI-only: no API operation sits
|
|
5
|
+
* behind them). Neither touches the network, and neither ever prints a token.
|
|
6
|
+
*
|
|
7
|
+
* Both resolve the URL through the one resolver in `src/client.ts`
|
|
8
|
+
* ({@linkcode resolveSettings}), so `get-base-url` reports exactly what the next
|
|
9
|
+
* command will use, and `set-base-url` stores exactly the canonical form that
|
|
10
|
+
* resolver produces (and that `hosts` is keyed by).
|
|
11
|
+
*
|
|
12
|
+
* `set-base-url` rewrites only `baseUrl`. It never copies, moves or re-keys a
|
|
13
|
+
* token: a token saved for host A is never sent to host B, so after switching
|
|
14
|
+
* hosts the new one needs its own `w6w auth login`.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import type { CommandRegistry } from "../../mod.ts";
|
|
19
|
+
/** The two `w6w config` commands. */
|
|
20
|
+
export declare const CONFIG_COMMANDS: CommandRegistry;
|
|
21
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/commands/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AAkEpE,qCAAqC;AACrC,eAAO,MAAM,eAAe,EAAE,eAG7B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w config get-base-url | set-base-url <url>` — the stored API base URL.
|
|
3
|
+
*
|
|
4
|
+
* Declared in `endpoints.json` `cli.commands[]` (CLI-only: no API operation sits
|
|
5
|
+
* behind them). Neither touches the network, and neither ever prints a token.
|
|
6
|
+
*
|
|
7
|
+
* Both resolve the URL through the one resolver in `src/client.ts`
|
|
8
|
+
* ({@linkcode resolveSettings}), so `get-base-url` reports exactly what the next
|
|
9
|
+
* command will use, and `set-base-url` stores exactly the canonical form that
|
|
10
|
+
* resolver produces (and that `hosts` is keyed by).
|
|
11
|
+
*
|
|
12
|
+
* `set-base-url` rewrites only `baseUrl`. It never copies, moves or re-keys a
|
|
13
|
+
* token: a token saved for host A is never sent to host B, so after switching
|
|
14
|
+
* hosts the new one needs its own `w6w auth login`.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import { joinBaseUrl } from "@w6w/sdk";
|
|
19
|
+
import { ENV_BASE_URL, ENV_TOKEN, envValue, resolveSettings } from "../client.js";
|
|
20
|
+
import { serializeConfig } from "../config-store.js";
|
|
21
|
+
import { argument, noExtraArguments } from "./shared.js";
|
|
22
|
+
const getBaseUrl = (context) => {
|
|
23
|
+
noExtraArguments(context, 0);
|
|
24
|
+
// The token sources are irrelevant here; hide them so a bad token never blocks a read.
|
|
25
|
+
const settings = resolveSettings({ ...context.invocation.globals, token: undefined }, (name) => (name === ENV_TOKEN ? undefined : context.env(name)), context.stored);
|
|
26
|
+
const configBaseUrl = context.stored.baseUrl.trim().length > 0
|
|
27
|
+
? context.stored.baseUrl
|
|
28
|
+
: undefined;
|
|
29
|
+
const payload = {
|
|
30
|
+
baseUrl: settings.baseUrl,
|
|
31
|
+
baseUrlSource: settings.baseUrlSource,
|
|
32
|
+
...(configBaseUrl === undefined ? {} : { configBaseUrl }),
|
|
33
|
+
configPath: context.store.path ?? null,
|
|
34
|
+
};
|
|
35
|
+
context.out.emit(payload, () => `${payload.baseUrl} (${payload.baseUrlSource})`);
|
|
36
|
+
};
|
|
37
|
+
const setBaseUrl = async (context) => {
|
|
38
|
+
const raw = argument(context, 0, "a base URL, like `https://api.example.com`");
|
|
39
|
+
noExtraArguments(context, 1);
|
|
40
|
+
// Validate and canonicalise with the one resolver: the positional stands in for the flag.
|
|
41
|
+
const { baseUrl } = resolveSettings({
|
|
42
|
+
...context.invocation.globals,
|
|
43
|
+
baseUrl: raw,
|
|
44
|
+
token: undefined,
|
|
45
|
+
});
|
|
46
|
+
const path = context.store.path;
|
|
47
|
+
if (path === undefined) {
|
|
48
|
+
throw new Error("w6w cannot tell where to keep its config: neither XDG_CONFIG_HOME (an absolute path) " +
|
|
49
|
+
"nor HOME is set. Nothing was saved.");
|
|
50
|
+
}
|
|
51
|
+
await context.store.write(serializeConfig({ version: 1, baseUrl, hosts: context.stored.hosts }));
|
|
52
|
+
context.out.emit({ baseUrl, configPath: path }, () => `Saved ${baseUrl} as the base URL in ${path}.`);
|
|
53
|
+
const fromEnv = envValue(context.env, ENV_BASE_URL);
|
|
54
|
+
if (fromEnv !== undefined) {
|
|
55
|
+
let envCanonical;
|
|
56
|
+
try {
|
|
57
|
+
envCanonical = joinBaseUrl(fromEnv.trim());
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
envCanonical = fromEnv;
|
|
61
|
+
}
|
|
62
|
+
if (envCanonical !== baseUrl) {
|
|
63
|
+
// stderr, so `--json` stdout stays one parseable document.
|
|
64
|
+
context.out.error(`${ENV_BASE_URL} is set to ${fromEnv} and still takes precedence over the saved base URL.`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/** The two `w6w config` commands. */
|
|
69
|
+
export const CONFIG_COMMANDS = {
|
|
70
|
+
"config get-base-url": getBaseUrl,
|
|
71
|
+
"config set-base-url": setBaseUrl,
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0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;QAC7C,CAAC;QAAC,MAAM,CAAC;YACP,YAAY,GAAG,OAAO,CAAC;QACzB,CAAC;QACD,IAAI,YAAY,KAAK,OAAO,EAAE,CAAC;YAC7B,2DAA2D;YAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CACf,GAAG,YAAY,cAAc,OAAO,sDAAsD,CAC3F,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAEF,qCAAqC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAoB;IAC9C,qBAAqB,EAAE,UAAU;IACjC,qBAAqB,EAAE,UAAU;CAClC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `w6w connections list | get | delete` — find a connection, read one, remove one.
|
|
2
|
+
* `w6w connections list | get | delete [--force]` — find a connection, read one, remove one.
|
|
3
3
|
*
|
|
4
4
|
* `list` exists so a caller can find a `conn_…` id to pass to `w6w run`; it has
|
|
5
5
|
* no filters and no pagination. `get` and `delete` address one by that id.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../../src/commands/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../../src/commands/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AAsEpE,eAAO,MAAM,mBAAmB,EAAE,eAIjC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `w6w connections list | get | delete` — find a connection, read one, remove one.
|
|
2
|
+
* `w6w connections list | get | delete [--force]` — find a connection, read one, remove one.
|
|
3
3
|
*
|
|
4
4
|
* `list` exists so a caller can find a `conn_…` id to pass to `w6w run`; it has
|
|
5
5
|
* no filters and no pagination. `get` and `delete` address one by that id.
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*
|
|
13
13
|
* @module
|
|
14
14
|
*/
|
|
15
|
+
import { ApiError } from "@w6w/sdk";
|
|
15
16
|
import { argument, noExtraArguments, table } from "./shared.js";
|
|
16
17
|
/** One connection, as a table row. */
|
|
17
18
|
function row(connection) {
|
|
@@ -38,10 +39,34 @@ const get = async (context) => {
|
|
|
38
39
|
JSON.stringify(connection, null, 2),
|
|
39
40
|
].join("\n"));
|
|
40
41
|
};
|
|
42
|
+
/** One dependent callable from a `connection_in_use` body, as `<kind> <displayName> (<id>)`. */
|
|
43
|
+
function dependentLines(raw) {
|
|
44
|
+
const callables = raw
|
|
45
|
+
?.error?.dependents?.callables;
|
|
46
|
+
if (!Array.isArray(callables))
|
|
47
|
+
return [];
|
|
48
|
+
return callables.map((c) => `${c.kind} ${c.displayName} (${c.id})`);
|
|
49
|
+
}
|
|
41
50
|
const remove = async (context) => {
|
|
42
51
|
const id = argument(context, 0, "a connection id (see: `w6w connections list`)");
|
|
43
52
|
noExtraArguments(context, 1);
|
|
44
|
-
|
|
53
|
+
const force = context.invocation.options.force === true;
|
|
54
|
+
try {
|
|
55
|
+
await context.client().connections.delete(id, { force });
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
if (err instanceof ApiError && err.status === 409 && err.code === "connection_in_use") {
|
|
59
|
+
const lines = dependentLines(err.raw);
|
|
60
|
+
if (lines.length > 0) {
|
|
61
|
+
context.out.error([
|
|
62
|
+
`Connection ${id} is in use by:`,
|
|
63
|
+
...lines.map((line) => ` ${line}`),
|
|
64
|
+
"Re-run with --force to delete it anyway (the callables above are disabled, not edited).",
|
|
65
|
+
].join("\n"));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
45
70
|
// `null`: the SDK unwraps a delete to nothing; `--json` must not invent a body.
|
|
46
71
|
context.out.emit(null, (styles) => styles.dim(`Deleted ${id}.`));
|
|
47
72
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/commands/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/commands/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhE,sCAAsC;AACtC,SAAS,GAAG,CAAC,UAA6B;IACxC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;AACrF,CAAC;AAED,6EAA6E;AAC7E,SAAS,UAAU,CAAC,WAAgC,EAAE,MAAc;IAClE,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnE,OAAO,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,IAAI,GAAmB,KAAK,EAAE,OAAO,EAAE,EAAE;IAC7C,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC7B,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAC9D,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;AAC7E,CAAC,CA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AAK,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC;IACxD,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACtF,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACtC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CACf;oBACE,cAAc,EAAE,gBAAgB;oBAChC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;oBACnC,yFAAyF;iBAC1F,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;YACJ,CAAC;QACH,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;IACD,gFAAgF;IAChF,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAoB;IAClD,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,GAAG;IACtB,oBAAoB,EAAE,MAAM;CAC7B,CAAC"}
|
|
@@ -29,6 +29,12 @@ export { APP_COMMANDS } from "./apps.ts";
|
|
|
29
29
|
export { DASHBOARD_COMMANDS } from "./dashboard.ts";
|
|
30
30
|
export { PROJECT_COMMANDS } from "./projects.ts";
|
|
31
31
|
export { RELIABILITY_COMMANDS } from "./reliability.ts";
|
|
32
|
+
export { AUTH_COMMANDS } from "./auth.ts";
|
|
33
|
+
export { CONFIG_COMMANDS } from "./config.ts";
|
|
34
|
+
export { LS_COMMANDS } from "./ls.ts";
|
|
35
|
+
export { MODEL_COMMANDS } from "./models.ts";
|
|
36
|
+
export { ASSET_COMMANDS } from "./assets.ts";
|
|
37
|
+
export { AGENT_STUDIO_COMMANDS } from "./agents-studio.ts";
|
|
32
38
|
/** Every wired command, keyed by canonical command path. */
|
|
33
39
|
export declare const COMMANDS: CommandRegistry;
|
|
34
40
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAqBpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,4DAA4D;AAC5D,eAAO,MAAM,QAAQ,EAAE,eAoBtB,CAAC"}
|
|
@@ -28,6 +28,12 @@ import { APP_COMMANDS } from "./apps.js";
|
|
|
28
28
|
import { DASHBOARD_COMMANDS } from "./dashboard.js";
|
|
29
29
|
import { PROJECT_COMMANDS } from "./projects.js";
|
|
30
30
|
import { RELIABILITY_COMMANDS } from "./reliability.js";
|
|
31
|
+
import { AUTH_COMMANDS } from "./auth.js";
|
|
32
|
+
import { CONFIG_COMMANDS } from "./config.js";
|
|
33
|
+
import { LS_COMMANDS } from "./ls.js";
|
|
34
|
+
import { MODEL_COMMANDS } from "./models.js";
|
|
35
|
+
import { ASSET_COMMANDS } from "./assets.js";
|
|
36
|
+
import { AGENT_STUDIO_COMMANDS } from "./agents-studio.js";
|
|
31
37
|
export { DOCUMENT_COMMANDS } from "./documents.js";
|
|
32
38
|
export { VAR_COMMANDS } from "./vars.js";
|
|
33
39
|
export { ME_COMMANDS } from "./me.js";
|
|
@@ -41,9 +47,18 @@ export { APP_COMMANDS } from "./apps.js";
|
|
|
41
47
|
export { DASHBOARD_COMMANDS } from "./dashboard.js";
|
|
42
48
|
export { PROJECT_COMMANDS } from "./projects.js";
|
|
43
49
|
export { RELIABILITY_COMMANDS } from "./reliability.js";
|
|
50
|
+
export { AUTH_COMMANDS } from "./auth.js";
|
|
51
|
+
export { CONFIG_COMMANDS } from "./config.js";
|
|
52
|
+
export { LS_COMMANDS } from "./ls.js";
|
|
53
|
+
export { MODEL_COMMANDS } from "./models.js";
|
|
54
|
+
export { ASSET_COMMANDS } from "./assets.js";
|
|
55
|
+
export { AGENT_STUDIO_COMMANDS } from "./agents-studio.js";
|
|
44
56
|
/** Every wired command, keyed by canonical command path. */
|
|
45
57
|
export const COMMANDS = {
|
|
46
58
|
...DOCUMENT_COMMANDS,
|
|
59
|
+
...MODEL_COMMANDS,
|
|
60
|
+
...ASSET_COMMANDS,
|
|
61
|
+
...AGENT_STUDIO_COMMANDS,
|
|
47
62
|
...VAR_COMMANDS,
|
|
48
63
|
...ME_COMMANDS,
|
|
49
64
|
...CONNECTION_COMMANDS,
|
|
@@ -56,5 +71,8 @@ export const COMMANDS = {
|
|
|
56
71
|
...DASHBOARD_COMMANDS,
|
|
57
72
|
...PROJECT_COMMANDS,
|
|
58
73
|
...RELIABILITY_COMMANDS,
|
|
74
|
+
...AUTH_COMMANDS,
|
|
75
|
+
...CONFIG_COMMANDS,
|
|
76
|
+
...LS_COMMANDS,
|
|
59
77
|
};
|
|
60
78
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,M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C,GAAG,iBAAiB;IACpB,GAAG,cAAc;IACjB,GAAG,cAAc;IACjB,GAAG,qBAAqB;IACxB,GAAG,YAAY;IACf,GAAG,WAAW;IACd,GAAG,mBAAmB;IACtB,GAAG,iBAAiB;IACpB,GAAG,iBAAiB;IACpB,GAAG,kBAAkB;IACrB,GAAG,YAAY;IACf,GAAG,aAAa;IAChB,GAAG,YAAY;IACf,GAAG,kBAAkB;IACrB,GAAG,gBAAgB;IACnB,GAAG,oBAAoB;IACvB,GAAG,aAAa;IAChB,GAAG,eAAe;IAClB,GAAG,WAAW;CACf,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w ls <integrations|workflows|functions|endpoints>` — one root verb to list a kind.
|
|
3
|
+
*
|
|
4
|
+
* A pure re-dispatch: `workflows`, `functions` and `integrations` run the very
|
|
5
|
+
* handlers behind `workflows list`, `functions list` and `connections list`, so
|
|
6
|
+
* the request, the output and the exit code are the delegate's, byte for byte.
|
|
7
|
+
* `endpoints` lists through the SDK's **unstable** `console.endpoints` namespace
|
|
8
|
+
* (not part of the stable contract) and says so in its human output.
|
|
9
|
+
*
|
|
10
|
+
* This root `ls` is distinct from the in-group `ls` alias for `list`
|
|
11
|
+
* (`w6w documents ls`); `w6w run ls` still treats `ls` as a positional.
|
|
12
|
+
*
|
|
13
|
+
* It imports the three delegate registries directly, never the aggregated
|
|
14
|
+
* `COMMANDS` — that would be an import cycle through `index.ts`.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import type { CommandRegistry } from "../../mod.ts";
|
|
19
|
+
/** The root `ls` command. */
|
|
20
|
+
export declare const LS_COMMANDS: CommandRegistry;
|
|
21
|
+
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../../src/commands/ls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AA8CpE,6BAA6B;AAC7B,eAAO,MAAM,WAAW,EAAE,eAA8B,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w ls <integrations|workflows|functions|endpoints>` — one root verb to list a kind.
|
|
3
|
+
*
|
|
4
|
+
* A pure re-dispatch: `workflows`, `functions` and `integrations` run the very
|
|
5
|
+
* handlers behind `workflows list`, `functions list` and `connections list`, so
|
|
6
|
+
* the request, the output and the exit code are the delegate's, byte for byte.
|
|
7
|
+
* `endpoints` lists through the SDK's **unstable** `console.endpoints` namespace
|
|
8
|
+
* (not part of the stable contract) and says so in its human output.
|
|
9
|
+
*
|
|
10
|
+
* This root `ls` is distinct from the in-group `ls` alias for `list`
|
|
11
|
+
* (`w6w documents ls`); `w6w run ls` still treats `ls` as a positional.
|
|
12
|
+
*
|
|
13
|
+
* It imports the three delegate registries directly, never the aggregated
|
|
14
|
+
* `COMMANDS` — that would be an import cycle through `index.ts`.
|
|
15
|
+
*
|
|
16
|
+
* @module
|
|
17
|
+
*/
|
|
18
|
+
import { CONNECTION_COMMANDS } from "./connections.js";
|
|
19
|
+
import { FUNCTION_COMMANDS } from "./functions.js";
|
|
20
|
+
import { WORKFLOW_COMMANDS } from "./workflows.js";
|
|
21
|
+
import { table, usageError } from "./shared.js";
|
|
22
|
+
const KINDS = ["integrations", "workflows", "functions", "endpoints"];
|
|
23
|
+
const DELEGATES = {
|
|
24
|
+
workflows: WORKFLOW_COMMANDS["workflows list"],
|
|
25
|
+
functions: FUNCTION_COMMANDS["functions list"],
|
|
26
|
+
integrations: CONNECTION_COMMANDS["connections list"],
|
|
27
|
+
};
|
|
28
|
+
const ls = async (context) => {
|
|
29
|
+
const [kind, ...rest] = context.invocation.positionals;
|
|
30
|
+
if (kind === undefined || !KINDS.includes(kind)) {
|
|
31
|
+
throw usageError(context, (kind === undefined ? "`w6w ls` needs a kind to list." : `Unknown kind \`${kind}\`.`) +
|
|
32
|
+
` Kinds: ${KINDS.join(", ")}.`);
|
|
33
|
+
}
|
|
34
|
+
const delegateContext = {
|
|
35
|
+
...context,
|
|
36
|
+
invocation: { ...context.invocation, positionals: rest },
|
|
37
|
+
};
|
|
38
|
+
const delegate = DELEGATES[kind];
|
|
39
|
+
if (delegate !== undefined)
|
|
40
|
+
return await delegate(delegateContext);
|
|
41
|
+
// endpoints — unstable console namespace.
|
|
42
|
+
if (rest.length > 0) {
|
|
43
|
+
throw usageError(context, `\`w6w ls endpoints\` takes no arguments, and got \`${rest[0]}\`.`);
|
|
44
|
+
}
|
|
45
|
+
const endpoints = await context.client().console.endpoints.list();
|
|
46
|
+
context.out.emit(endpoints, (styles) => [
|
|
47
|
+
styles.dim("Endpoints (unstable: listed through the console API, which may change)"),
|
|
48
|
+
endpoints.length === 0 ? styles.dim("No endpoints.") : table(["ID", "KEY", "STATUS", "NAME"], endpoints.map((e) => [e.id, e.key, e.status, e.displayName]), styles),
|
|
49
|
+
].join("\n"));
|
|
50
|
+
};
|
|
51
|
+
/** The root `ls` command. */
|
|
52
|
+
export const LS_COMMANDS = { "ls": ls };
|
|
53
|
+
//# sourceMappingURL=ls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ls.js","sourceRoot":"","sources":["../../../src/commands/ls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,KAAK,GAAG,CAAC,cAAc,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAU,CAAC;AAE/E,MAAM,SAAS,GAAmC;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CAAC,GAAG,CAAC,wEAAwE,CAAC;QACpF,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAC1D,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,EAC/B,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,EAC5D,MAAM,CACP;KACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;AAEF,6BAA6B;AAC7B,MAAM,CAAC,MAAM,WAAW,GAAoB,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w models …`, `w6w model-routes …` and `w6w model-usage` — the model
|
|
3
|
+
* registry at the command line.
|
|
4
|
+
*
|
|
5
|
+
* Six commands, **one SDK call each**. `model-routes complete` prints the flat
|
|
6
|
+
* gateway envelope exactly as the server sent it (`invocationId`, `status`,
|
|
7
|
+
* `key`, …): there is no unwrap to `output`, because the envelope is the
|
|
8
|
+
* result. `--project` is optional everywhere; an absent flag sends no
|
|
9
|
+
* `?project=` and the server resolves the account's default project.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import type { CommandRegistry } from "../../mod.ts";
|
|
14
|
+
/** The six model commands, keyed by canonical command path. */
|
|
15
|
+
export declare const MODEL_COMMANDS: CommandRegistry;
|
|
16
|
+
//# sourceMappingURL=models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../src/commands/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAkC,eAAe,EAAE,MAAM,cAAc,CAAC;AAyHpF,+DAA+D;AAC/D,eAAO,MAAM,cAAc,EAAE,eAO5B,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `w6w models …`, `w6w model-routes …` and `w6w model-usage` — the model
|
|
3
|
+
* registry at the command line.
|
|
4
|
+
*
|
|
5
|
+
* Six commands, **one SDK call each**. `model-routes complete` prints the flat
|
|
6
|
+
* gateway envelope exactly as the server sent it (`invocationId`, `status`,
|
|
7
|
+
* `key`, …): there is no unwrap to `output`, because the envelope is the
|
|
8
|
+
* result. `--project` is optional everywhere; an absent flag sends no
|
|
9
|
+
* `?project=` and the server resolves the account's default project.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
import { argument, noExtraArguments, requiredFlag, table, textFlag, usageError } from "./shared.js";
|
|
14
|
+
/** The project scope for one call: the `--project` flag, or nothing at all. */
|
|
15
|
+
function scope(context) {
|
|
16
|
+
const project = textFlag(context, "project");
|
|
17
|
+
return project === undefined ? {} : { project };
|
|
18
|
+
}
|
|
19
|
+
/** A positive-integer flag, or `undefined` when absent. */
|
|
20
|
+
function count(context, name) {
|
|
21
|
+
const text = textFlag(context, name);
|
|
22
|
+
if (text === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
if (!/^[0-9]+$/.test(text) || Number(text) < 1) {
|
|
25
|
+
throw usageError(context, `\`--${name}\` must be a positive integer.`);
|
|
26
|
+
}
|
|
27
|
+
return Number(text);
|
|
28
|
+
}
|
|
29
|
+
function text(value) {
|
|
30
|
+
return typeof value === "string"
|
|
31
|
+
? value
|
|
32
|
+
: value === undefined || value === null
|
|
33
|
+
? "-"
|
|
34
|
+
: String(value);
|
|
35
|
+
}
|
|
36
|
+
const listModels = async (context) => {
|
|
37
|
+
noExtraArguments(context, 0);
|
|
38
|
+
const page = await context.client().models.list({
|
|
39
|
+
provider: textFlag(context, "provider"),
|
|
40
|
+
status: textFlag(context, "status"),
|
|
41
|
+
limit: count(context, "limit"),
|
|
42
|
+
cursor: textFlag(context, "cursor"),
|
|
43
|
+
});
|
|
44
|
+
context.out.emit(page, (styles) => {
|
|
45
|
+
if (page.models.length === 0)
|
|
46
|
+
return styles.dim("No models.");
|
|
47
|
+
const rows = page.models.map((m) => [m.id, text(m.provider), text(m.status)]);
|
|
48
|
+
const body = table(["ID", "PROVIDER", "STATUS"], rows, styles);
|
|
49
|
+
return page.nextCursor ? `${body}\n${styles.dim(`next: --cursor ${page.nextCursor}`)}` : body;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const getModel = async (context) => {
|
|
53
|
+
const id = argument(context, 0, "a model id (see: `w6w models ls`)");
|
|
54
|
+
noExtraArguments(context, 1);
|
|
55
|
+
const model = await context.client().models.get(id);
|
|
56
|
+
context.out.emit(model, () => JSON.stringify(model, null, 2));
|
|
57
|
+
};
|
|
58
|
+
const listRoutes = async (context) => {
|
|
59
|
+
noExtraArguments(context, 0);
|
|
60
|
+
const routes = await context.client().modelRoutes.list(scope(context));
|
|
61
|
+
context.out.emit(routes, (styles) => {
|
|
62
|
+
if (routes.length === 0)
|
|
63
|
+
return styles.dim("No model routes.");
|
|
64
|
+
return table(["NAME", "STATUS"], routes.map((r) => [r.name, text(r.status)]), styles);
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
const getRoute = async (context) => {
|
|
68
|
+
const name = argument(context, 0, "a route name (see: `w6w model-routes list`)");
|
|
69
|
+
noExtraArguments(context, 1);
|
|
70
|
+
const route = await context.client().modelRoutes.get(name, scope(context));
|
|
71
|
+
context.out.emit(route, () => JSON.stringify(route, null, 2));
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* `w6w model-routes complete <name> --input <json>` — the flat envelope, as-is.
|
|
75
|
+
* `--dialect` and `--response` are the **server's** enums; they are passed
|
|
76
|
+
* through untouched so a value the server starts accepting is not refused here.
|
|
77
|
+
* `--dialect` is `bridge|openai|anthropic|ollama`; the envelope carries `usageSummary`.
|
|
78
|
+
*/
|
|
79
|
+
const complete = async (context) => {
|
|
80
|
+
const name = argument(context, 0, "a route name (see: `w6w model-routes list`)");
|
|
81
|
+
noExtraArguments(context, 1);
|
|
82
|
+
const raw = requiredFlag(context, "input", "--input <json>");
|
|
83
|
+
let input;
|
|
84
|
+
try {
|
|
85
|
+
input = JSON.parse(raw);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
throw usageError(context, "`--input` must be valid JSON.");
|
|
89
|
+
}
|
|
90
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
91
|
+
throw usageError(context, "`--input` must be a JSON object.");
|
|
92
|
+
}
|
|
93
|
+
const envelope = await context.client().modelRoutes.complete(name, input, {
|
|
94
|
+
...scope(context),
|
|
95
|
+
// deno-lint-ignore no-explicit-any
|
|
96
|
+
dialect: textFlag(context, "dialect"),
|
|
97
|
+
// deno-lint-ignore no-explicit-any
|
|
98
|
+
response: textFlag(context, "response"),
|
|
99
|
+
});
|
|
100
|
+
context.out.emit(envelope, () => JSON.stringify(envelope, null, 2));
|
|
101
|
+
};
|
|
102
|
+
const usage = async (context) => {
|
|
103
|
+
noExtraArguments(context, 0);
|
|
104
|
+
const report = await context.client().modelUsage.query({
|
|
105
|
+
...scope(context),
|
|
106
|
+
// deno-lint-ignore no-explicit-any
|
|
107
|
+
groupBy: textFlag(context, "groupBy"),
|
|
108
|
+
from: textFlag(context, "from"),
|
|
109
|
+
to: textFlag(context, "to"),
|
|
110
|
+
route: textFlag(context, "route"),
|
|
111
|
+
model: textFlag(context, "model"),
|
|
112
|
+
limit: count(context, "limit"),
|
|
113
|
+
cursor: textFlag(context, "cursor"),
|
|
114
|
+
});
|
|
115
|
+
context.out.emit(report, () => JSON.stringify(report, null, 2));
|
|
116
|
+
};
|
|
117
|
+
/** The six model commands, keyed by canonical command path. */
|
|
118
|
+
export const MODEL_COMMANDS = {
|
|
119
|
+
"models list": listModels,
|
|
120
|
+
"models get": getModel,
|
|
121
|
+
"model-routes list": listRoutes,
|
|
122
|
+
"model-routes get": getRoute,
|
|
123
|
+
"model-routes complete": complete,
|
|
124
|
+
"model-usage": usage,
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/commands/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEpG,+EAA+E;AAC/E,SAAS,KAAK,CAAC,OAAuB;IACpC,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC7C,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC;AAClD,CAAC;AAED,2DAA2D;AAC3D,SAAS,KAAK,CAAC,OAAuB,EAAE,IAAY;IAClD,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACrC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,IAAI,gCAAgC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ;QAC9B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YACvC,CAAC,CAAC,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kBAAkB,EAAE,QAAQ;IAC5B,uBAAuB,EAAE,QAAQ;IACjC,aAAa,EAAE,KAAK;CACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vars.d.ts","sourceRoot":"","sources":["../../../src/commands/vars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAkC,eAAe,EAAE,MAAM,cAAc,CAAC;AAoDpF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAO3E;
|
|
1
|
+
{"version":3,"file":"vars.d.ts","sourceRoot":"","sources":["../../../src/commands/vars.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAkC,eAAe,EAAE,MAAM,cAAc,CAAC;AAoDpF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAO3E;AA0HD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,eAO1B,CAAC"}
|