@engini/cli 0.10.1 → 0.12.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 +14 -2
- package/dist/cli.js +400 -2
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# @engini/cli
|
|
2
2
|
|
|
3
3
|
Machine-first command line for the [Engini](https://engini.io) Public API — run tools
|
|
4
|
-
across your connected apps from the terminal or an agent. The `engini` binary is
|
|
5
|
-
|
|
4
|
+
across your connected apps from the terminal or an agent. The `engini` binary is
|
|
5
|
+
the CLI (an earlier parallel Python implementation, `engini[cli]`, was retired
|
|
6
|
+
once this one reached full parity).
|
|
6
7
|
|
|
7
8
|
## Install
|
|
8
9
|
|
|
@@ -29,12 +30,23 @@ engini tools result <handle> --select items.email # drill into a large result
|
|
|
29
30
|
engini login | logout | whoami # auth
|
|
30
31
|
engini tools list | get | call | result # discover, execute & drill into results
|
|
31
32
|
engini applications list | get # browse connector apps
|
|
33
|
+
engini toolsets list | get | create | update | delete # scope an agent's tools/connections/workflows
|
|
32
34
|
engini connect [<app>] # create a connection (interactive / agent-resumable)
|
|
33
35
|
engini connections list | get # inspect connections
|
|
34
36
|
engini connections create | delete | check | refresh | objects | select-objects # primitives
|
|
35
37
|
engini connections sign-in-url | oauth-complete # OAuth2 start / finish primitives
|
|
36
38
|
```
|
|
37
39
|
|
|
40
|
+
`toolsets create`/`update` take either `--from-file <path|@path|->` (the whole
|
|
41
|
+
request body as JSON, matching `tools call --args`) or repeatable
|
|
42
|
+
`--connection <id>[:slug,slug]` / `--application <slug>[:slug,slug]` /
|
|
43
|
+
`--workflow <guid>` flags — the two forms are mutually exclusive. `update` is a
|
|
44
|
+
`PATCH` that **replaces** each member wholesale (an omitted member is left
|
|
45
|
+
unchanged; a supplied one replaces the whole set — it never merges), so
|
|
46
|
+
`--dry-run` fetches the current toolset and previews the diff (current vs
|
|
47
|
+
resulting, plus explicit added/removed lists) rather than just echoing the
|
|
48
|
+
outgoing request.
|
|
49
|
+
|
|
38
50
|
Run `engini <command> --help` for details and examples on any command.
|
|
39
51
|
|
|
40
52
|
`connect <app>` discovers the app's authentication methods, collects credentials
|
package/dist/cli.js
CHANGED
|
@@ -135,6 +135,10 @@ function fail(code, message, hint2) {
|
|
|
135
135
|
}
|
|
136
136
|
throw new CliError(code);
|
|
137
137
|
}
|
|
138
|
+
function mapCommanderExitCode(exitCode) {
|
|
139
|
+
const code = exitCode ?? 1;
|
|
140
|
+
return code === 0 ? 0 /* OK */ : 2 /* USAGE */;
|
|
141
|
+
}
|
|
138
142
|
function maskSecret(value) {
|
|
139
143
|
return value.length > 8 ? `${value.slice(0, 4)}\u2026${value.slice(-4)}` : "****";
|
|
140
144
|
}
|
|
@@ -1166,6 +1170,17 @@ CONNECTIONS
|
|
|
1166
1170
|
connections select-objects <id> --object <id> Choose which objects to sync (async).
|
|
1167
1171
|
connections delete <id> [--force] Remove a connection.
|
|
1168
1172
|
|
|
1173
|
+
TOOLSETS
|
|
1174
|
+
toolsets list List your toolsets.
|
|
1175
|
+
toolsets get <id> Show full detail for one toolset.
|
|
1176
|
+
toolsets create --name <n> [--connection <id>[:slugs]] [--application <slug>[:slugs]] [--workflow <guid>] | --from-file <path|@path|->
|
|
1177
|
+
Create a toolset scoping specific connections/apps and workflows.
|
|
1178
|
+
toolsets update <id> [--name <n>] [--connection ...] [--application ...] [--workflow ...] | --from-file <path|@path|->
|
|
1179
|
+
Replace name/connections/workflows \u2014 each flag replaces the whole
|
|
1180
|
+
set for that member (never merges); omit a member to leave it
|
|
1181
|
+
unchanged. --dry-run previews the diff before you commit to it.
|
|
1182
|
+
toolsets delete <id> [--force] Remove a toolset.
|
|
1183
|
+
|
|
1169
1184
|
OUTPUT & EXIT CODES
|
|
1170
1185
|
Output adapts to context: human-readable on a TTY, compact JSON when piped, pretty
|
|
1171
1186
|
JSON with --json. Universal flags on every command:
|
|
@@ -1919,6 +1934,388 @@ function registerTools(program) {
|
|
|
1919
1934
|
registerToolsResult(tools);
|
|
1920
1935
|
}
|
|
1921
1936
|
|
|
1937
|
+
// src/toolsets/shared.ts
|
|
1938
|
+
import { readFileSync as readFileSync4 } from "fs";
|
|
1939
|
+
function collect2(value, previous = []) {
|
|
1940
|
+
return [...previous, value];
|
|
1941
|
+
}
|
|
1942
|
+
function parseToolsetId(value) {
|
|
1943
|
+
if (!value) fail(2 /* USAGE */, "Missing required argument 'toolset_id'.");
|
|
1944
|
+
return value;
|
|
1945
|
+
}
|
|
1946
|
+
function splitSlugs(spec) {
|
|
1947
|
+
const colon = spec.indexOf(":");
|
|
1948
|
+
if (colon < 0) return [spec, void 0];
|
|
1949
|
+
const head = spec.slice(0, colon);
|
|
1950
|
+
const slugs = spec.slice(colon + 1).split(",").map((s) => s.trim()).filter(Boolean);
|
|
1951
|
+
return [head, slugs.length > 0 ? slugs : void 0];
|
|
1952
|
+
}
|
|
1953
|
+
function parseConnectionFlags(specs) {
|
|
1954
|
+
return (specs ?? []).map((spec) => {
|
|
1955
|
+
const [idPart, toolSlugs] = splitSlugs(spec);
|
|
1956
|
+
if (!/^\d+$/.test(idPart)) {
|
|
1957
|
+
fail(2 /* USAGE */, `--connection must be <id> or <id>:slug,slug, got '${spec}'.`);
|
|
1958
|
+
}
|
|
1959
|
+
return { connectionId: Number(idPart), toolSlugs };
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
function parseApplicationFlags(specs) {
|
|
1963
|
+
return (specs ?? []).map((spec) => {
|
|
1964
|
+
const [applicationSlug, toolSlugs] = splitSlugs(spec);
|
|
1965
|
+
if (!applicationSlug) {
|
|
1966
|
+
fail(2 /* USAGE */, `--application must be <slug> or <slug>:tool,tool, got '${spec}'.`);
|
|
1967
|
+
}
|
|
1968
|
+
return { applicationSlug, toolSlugs };
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
function hasConnectionFlags(opts) {
|
|
1972
|
+
return Boolean(opts.connection?.length) || Boolean(opts.application?.length);
|
|
1973
|
+
}
|
|
1974
|
+
function connectionsFromFlags(opts) {
|
|
1975
|
+
return [...parseConnectionFlags(opts.connection), ...parseApplicationFlags(opts.application)];
|
|
1976
|
+
}
|
|
1977
|
+
function connectionsFromFlagsOrUndefined(opts) {
|
|
1978
|
+
return hasConnectionFlags(opts) ? connectionsFromFlags(opts) : void 0;
|
|
1979
|
+
}
|
|
1980
|
+
function workflowsFromFlagsOrUndefined(specs) {
|
|
1981
|
+
return specs && specs.length > 0 ? specs : void 0;
|
|
1982
|
+
}
|
|
1983
|
+
function loadFromFile(spec) {
|
|
1984
|
+
let text;
|
|
1985
|
+
if (spec === "-") {
|
|
1986
|
+
text = readFileSync4(0, "utf8");
|
|
1987
|
+
} else if (spec.startsWith("@")) {
|
|
1988
|
+
try {
|
|
1989
|
+
text = readFileSync4(spec.slice(1), "utf8");
|
|
1990
|
+
} catch (err) {
|
|
1991
|
+
return fail(2 /* USAGE */, `Cannot read ${spec.slice(1)}: ${err.message}`);
|
|
1992
|
+
}
|
|
1993
|
+
} else {
|
|
1994
|
+
text = spec;
|
|
1995
|
+
}
|
|
1996
|
+
let data;
|
|
1997
|
+
try {
|
|
1998
|
+
data = JSON.parse(text);
|
|
1999
|
+
} catch (err) {
|
|
2000
|
+
return fail(2 /* USAGE */, `--from-file is not valid JSON: ${err.message}`);
|
|
2001
|
+
}
|
|
2002
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) {
|
|
2003
|
+
return fail(2 /* USAGE */, "--from-file must be a JSON object.");
|
|
2004
|
+
}
|
|
2005
|
+
return data;
|
|
2006
|
+
}
|
|
2007
|
+
var CONNECTION_ENTRY_ALIASES = {
|
|
2008
|
+
connection_id: "connectionId",
|
|
2009
|
+
application_slug: "applicationSlug",
|
|
2010
|
+
tool_slugs: "toolSlugs"
|
|
2011
|
+
};
|
|
2012
|
+
var REQUEST_KEYS = /* @__PURE__ */ new Set(["connectionId", "applicationSlug", "toolSlugs"]);
|
|
2013
|
+
function parseFromFileConnections(raw) {
|
|
2014
|
+
return raw.map((item) => {
|
|
2015
|
+
if (item === null || typeof item !== "object" || Array.isArray(item)) {
|
|
2016
|
+
fail(2 /* USAGE */, "--from-file 'connections' entries must be JSON objects.");
|
|
2017
|
+
}
|
|
2018
|
+
const normalized = {};
|
|
2019
|
+
for (const [key, value] of Object.entries(item)) {
|
|
2020
|
+
const aliased = CONNECTION_ENTRY_ALIASES[key] ?? key;
|
|
2021
|
+
if (!REQUEST_KEYS.has(aliased)) continue;
|
|
2022
|
+
normalized[aliased] = value;
|
|
2023
|
+
}
|
|
2024
|
+
return normalized;
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
function rejectFromFileCombo(fromFile, opts) {
|
|
2028
|
+
if (!fromFile) return;
|
|
2029
|
+
const combined = opts.name !== void 0 || Boolean(opts.connection?.length) || Boolean(opts.application?.length) || Boolean(opts.workflow?.length);
|
|
2030
|
+
if (combined) {
|
|
2031
|
+
fail(
|
|
2032
|
+
2 /* USAGE */,
|
|
2033
|
+
"--from-file cannot be combined with --name/--connection/--application/--workflow."
|
|
2034
|
+
);
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
function summarizeConnection(c) {
|
|
2038
|
+
return {
|
|
2039
|
+
connection_id: c.connectionId,
|
|
2040
|
+
application_slug: c.applicationSlug,
|
|
2041
|
+
application_name: clean(c.applicationName),
|
|
2042
|
+
tool_slugs: c.toolSlugs
|
|
2043
|
+
};
|
|
2044
|
+
}
|
|
2045
|
+
function summarizeToolset(t) {
|
|
2046
|
+
return {
|
|
2047
|
+
toolset_id: t.toolsetId,
|
|
2048
|
+
name: t.name,
|
|
2049
|
+
connections: t.connections.map(summarizeConnection),
|
|
2050
|
+
workflows: t.workflows,
|
|
2051
|
+
created_date: t.createdDate
|
|
2052
|
+
};
|
|
2053
|
+
}
|
|
2054
|
+
function summarizeConnectionRequest(c) {
|
|
2055
|
+
return {
|
|
2056
|
+
connection_id: c.connectionId ?? null,
|
|
2057
|
+
application_slug: c.applicationSlug ?? null,
|
|
2058
|
+
tool_slugs: c.toolSlugs ?? []
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
function connectionKey(c) {
|
|
2062
|
+
return c.connectionId != null ? `id:${c.connectionId}` : `app:${c.applicationSlug}`;
|
|
2063
|
+
}
|
|
2064
|
+
function scopeKey(c) {
|
|
2065
|
+
const slugs = c.toolSlugs ?? [];
|
|
2066
|
+
return slugs.length === 0 ? "*" : [...slugs].sort().join(",");
|
|
2067
|
+
}
|
|
2068
|
+
function diffConnections(current, next) {
|
|
2069
|
+
const currentKeys = new Set(current.map((c) => connectionKey(c)));
|
|
2070
|
+
const nextByKey = new Map(next.map((c) => [connectionKey(c), c]));
|
|
2071
|
+
const nextKeys = new Set(nextByKey.keys());
|
|
2072
|
+
const changed = current.filter((c) => nextKeys.has(connectionKey(c))).filter((c) => scopeKey(c) !== scopeKey(nextByKey.get(connectionKey(c)))).map((c) => {
|
|
2073
|
+
const nextEntry = nextByKey.get(connectionKey(c));
|
|
2074
|
+
return {
|
|
2075
|
+
connection_id: c.connectionId,
|
|
2076
|
+
application_slug: c.applicationSlug,
|
|
2077
|
+
from: summarizeConnection(c),
|
|
2078
|
+
// A bare `--connection <id>` next-side entry carries no
|
|
2079
|
+
// `applicationSlug` (it's resolved server-side from the id), but it's
|
|
2080
|
+
// still the *same* connection as `c` - falling back to `c`'s known
|
|
2081
|
+
// slug avoids a `to.application_slug: null` sitting next to a `from`
|
|
2082
|
+
// that shows the real slug, which reads as "the slug is being
|
|
2083
|
+
// cleared" when nothing about the app binding actually changed.
|
|
2084
|
+
to: {
|
|
2085
|
+
...summarizeConnectionRequest(nextEntry),
|
|
2086
|
+
application_slug: nextEntry.applicationSlug ?? c.applicationSlug
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2089
|
+
});
|
|
2090
|
+
return {
|
|
2091
|
+
current: current.map(summarizeConnection),
|
|
2092
|
+
resulting: next.map(summarizeConnectionRequest),
|
|
2093
|
+
added: next.filter((c) => !currentKeys.has(connectionKey(c))).map(summarizeConnectionRequest),
|
|
2094
|
+
removed: current.filter((c) => !nextKeys.has(connectionKey(c))).map(summarizeConnection),
|
|
2095
|
+
changed
|
|
2096
|
+
};
|
|
2097
|
+
}
|
|
2098
|
+
function diffWorkflows(current, next) {
|
|
2099
|
+
const currentSet = new Set(current);
|
|
2100
|
+
const nextSet = new Set(next);
|
|
2101
|
+
return {
|
|
2102
|
+
current,
|
|
2103
|
+
resulting: next,
|
|
2104
|
+
added: next.filter((id) => !currentSet.has(id)),
|
|
2105
|
+
removed: current.filter((id) => !nextSet.has(id))
|
|
2106
|
+
};
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
// src/toolsets/create.ts
|
|
2110
|
+
function buildRequestBody(opts) {
|
|
2111
|
+
rejectFromFileCombo(opts.fromFile, opts);
|
|
2112
|
+
if (opts.fromFile) {
|
|
2113
|
+
const raw = loadFromFile(opts.fromFile);
|
|
2114
|
+
if (typeof raw.name !== "string" || !raw.name) {
|
|
2115
|
+
fail(2 /* USAGE */, "--from-file body must have a non-empty string 'name'.");
|
|
2116
|
+
}
|
|
2117
|
+
if (!Array.isArray(raw.connections)) {
|
|
2118
|
+
fail(2 /* USAGE */, "--from-file body must have a 'connections' array.");
|
|
2119
|
+
}
|
|
2120
|
+
return {
|
|
2121
|
+
name: raw.name,
|
|
2122
|
+
connections: parseFromFileConnections(raw.connections),
|
|
2123
|
+
workflows: Array.isArray(raw.workflows) ? raw.workflows : void 0
|
|
2124
|
+
};
|
|
2125
|
+
}
|
|
2126
|
+
if (!opts.name) fail(2 /* USAGE */, "Missing required option '--name'.");
|
|
2127
|
+
return {
|
|
2128
|
+
name: opts.name,
|
|
2129
|
+
connections: connectionsFromFlags(opts),
|
|
2130
|
+
workflows: workflowsFromFlagsOrUndefined(opts.workflow)
|
|
2131
|
+
};
|
|
2132
|
+
}
|
|
2133
|
+
async function createBody2(opts) {
|
|
2134
|
+
const body = buildRequestBody(opts);
|
|
2135
|
+
if (dryRun()) {
|
|
2136
|
+
printOutput({
|
|
2137
|
+
would_create: {
|
|
2138
|
+
name: body.name,
|
|
2139
|
+
connections: body.connections.map(summarizeConnectionRequest),
|
|
2140
|
+
workflows: body.workflows ?? []
|
|
2141
|
+
}
|
|
2142
|
+
});
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
const toolset = await apiErrors(async () => {
|
|
2146
|
+
const client = buildClient();
|
|
2147
|
+
return client.toolsets.create(body);
|
|
2148
|
+
});
|
|
2149
|
+
printOutput(summarizeToolset(toolset));
|
|
2150
|
+
}
|
|
2151
|
+
function registerToolsetsCreate(toolsets) {
|
|
2152
|
+
const cmd = toolsets.command("create").description("Create a toolset scoping specific connections/apps and workflows.").option("--from-file <path>", "Whole request body: JSON object, @file.json, or - for stdin").option("--name <name>", "Display name for the toolset").option(
|
|
2153
|
+
"--connection <id[:slug,slug]>",
|
|
2154
|
+
"Include a connection (repeatable); bare id = all its tools",
|
|
2155
|
+
collect2
|
|
2156
|
+
).option(
|
|
2157
|
+
"--application <slug[:slug,slug]>",
|
|
2158
|
+
"Include an application's default connection (repeatable)",
|
|
2159
|
+
collect2
|
|
2160
|
+
).option("--workflow <guid>", "Include a workflow (repeatable)", collect2);
|
|
2161
|
+
cmd.addHelpText(
|
|
2162
|
+
"after",
|
|
2163
|
+
"\nExamples:\n engini toolsets create --name Sales --connection 3 --application slack:send_message\n engini toolsets create --from-file toolset.json\n engini toolsets create --name Sales --connection 3 --dry-run"
|
|
2164
|
+
);
|
|
2165
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2166
|
+
cmd.action(async (opts, command) => {
|
|
2167
|
+
await runCommand(command, opts, true, () => createBody2(opts));
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
|
|
2171
|
+
// src/toolsets/delete.ts
|
|
2172
|
+
async function deleteBody2(toolsetId, opts) {
|
|
2173
|
+
const id = parseToolsetId(toolsetId);
|
|
2174
|
+
if (dryRun()) {
|
|
2175
|
+
printOutput({ would_delete: id });
|
|
2176
|
+
return;
|
|
2177
|
+
}
|
|
2178
|
+
await confirmOrFail(`Delete toolset ${id}?`, { force: Boolean(opts.force) });
|
|
2179
|
+
await apiErrors(async () => {
|
|
2180
|
+
const client = buildClient();
|
|
2181
|
+
return client.toolsets.delete(id);
|
|
2182
|
+
});
|
|
2183
|
+
printOutput({ deleted: id });
|
|
2184
|
+
}
|
|
2185
|
+
function registerToolsetsDelete(toolsets) {
|
|
2186
|
+
const cmd = toolsets.command("delete").description("Remove a toolset.").argument("[toolset_id]", "Toolset id").option("--force", "Delete without confirming");
|
|
2187
|
+
cmd.addHelpText("after", "\nExamples:\n engini toolsets delete <toolset_id> --force");
|
|
2188
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2189
|
+
cmd.action(async (id, opts, command) => {
|
|
2190
|
+
await runCommand(command, opts, true, () => deleteBody2(id, opts));
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2193
|
+
|
|
2194
|
+
// src/toolsets/get.ts
|
|
2195
|
+
async function getBody4(toolsetId) {
|
|
2196
|
+
const id = parseToolsetId(toolsetId);
|
|
2197
|
+
const toolset = await apiErrors(async () => {
|
|
2198
|
+
const client = buildClient();
|
|
2199
|
+
return client.toolsets.get(id);
|
|
2200
|
+
});
|
|
2201
|
+
printOutput({
|
|
2202
|
+
...summarizeToolset(toolset),
|
|
2203
|
+
updated_date: clean(toolset.updatedDate),
|
|
2204
|
+
created_by_account_user_id: clean(toolset.createdByAccountUserId),
|
|
2205
|
+
updated_by_account_user_id: clean(toolset.updatedByAccountUserId)
|
|
2206
|
+
});
|
|
2207
|
+
}
|
|
2208
|
+
function registerToolsetsGet(toolsets) {
|
|
2209
|
+
const cmd = toolsets.command("get").description("Show full detail for one toolset.").argument("[toolset_id]", "Toolset id");
|
|
2210
|
+
cmd.addHelpText("after", "\nExamples:\n engini toolsets get <toolset_id> --json");
|
|
2211
|
+
addUniversalOptions(cmd);
|
|
2212
|
+
cmd.action(async (id, opts, command) => {
|
|
2213
|
+
await runCommand(command, opts, false, () => getBody4(id));
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
// src/toolsets/list.ts
|
|
2218
|
+
async function listBody4() {
|
|
2219
|
+
const toolsets = await apiErrors(async () => {
|
|
2220
|
+
const client = buildClient();
|
|
2221
|
+
return client.toolsets.list();
|
|
2222
|
+
});
|
|
2223
|
+
printOutput(toolsets.map(summarizeToolset));
|
|
2224
|
+
}
|
|
2225
|
+
function registerToolsetsList(toolsets) {
|
|
2226
|
+
const cmd = toolsets.command("list").description("List your toolsets.");
|
|
2227
|
+
cmd.addHelpText(
|
|
2228
|
+
"after",
|
|
2229
|
+
"\nExamples:\n engini toolsets list --json\n engini toolsets list | jq -r '.[].toolset_id'"
|
|
2230
|
+
);
|
|
2231
|
+
addUniversalOptions(cmd);
|
|
2232
|
+
cmd.action(async (opts, command) => {
|
|
2233
|
+
await runCommand(command, opts, false, () => listBody4());
|
|
2234
|
+
});
|
|
2235
|
+
}
|
|
2236
|
+
|
|
2237
|
+
// src/toolsets/update.ts
|
|
2238
|
+
function buildRequestBody2(opts) {
|
|
2239
|
+
rejectFromFileCombo(opts.fromFile, opts);
|
|
2240
|
+
if (opts.fromFile) {
|
|
2241
|
+
const raw = loadFromFile(opts.fromFile);
|
|
2242
|
+
return {
|
|
2243
|
+
name: typeof raw.name === "string" ? raw.name : void 0,
|
|
2244
|
+
connections: Array.isArray(raw.connections) ? parseFromFileConnections(raw.connections) : void 0,
|
|
2245
|
+
workflows: Array.isArray(raw.workflows) ? raw.workflows : void 0
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
return {
|
|
2249
|
+
name: opts.name,
|
|
2250
|
+
connections: connectionsFromFlagsOrUndefined(opts),
|
|
2251
|
+
workflows: workflowsFromFlagsOrUndefined(opts.workflow)
|
|
2252
|
+
};
|
|
2253
|
+
}
|
|
2254
|
+
async function previewDryRun(toolsetId, body) {
|
|
2255
|
+
const current = await apiErrors(async () => {
|
|
2256
|
+
const client = buildClient();
|
|
2257
|
+
return client.toolsets.get(toolsetId);
|
|
2258
|
+
});
|
|
2259
|
+
printOutput({
|
|
2260
|
+
would_update: {
|
|
2261
|
+
toolset_id: toolsetId,
|
|
2262
|
+
name: body.name === void 0 ? null : { from: current.name, to: body.name },
|
|
2263
|
+
connections: body.connections === void 0 ? null : diffConnections(current.connections, body.connections),
|
|
2264
|
+
workflows: body.workflows === void 0 ? null : diffWorkflows(current.workflows, body.workflows)
|
|
2265
|
+
}
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
async function updateBody(toolsetId, opts) {
|
|
2269
|
+
const id = parseToolsetId(toolsetId);
|
|
2270
|
+
const body = buildRequestBody2(opts);
|
|
2271
|
+
if (body.name === void 0 && body.connections === void 0 && body.workflows === void 0) {
|
|
2272
|
+
fail(
|
|
2273
|
+
2 /* USAGE */,
|
|
2274
|
+
"Nothing to update \u2014 pass --name/--connection/--application/--workflow or --from-file."
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2277
|
+
if (dryRun()) {
|
|
2278
|
+
await previewDryRun(id, body);
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
const toolset = await apiErrors(async () => {
|
|
2282
|
+
const client = buildClient();
|
|
2283
|
+
return client.toolsets.update(id, body);
|
|
2284
|
+
});
|
|
2285
|
+
printOutput(summarizeToolset(toolset));
|
|
2286
|
+
}
|
|
2287
|
+
function registerToolsetsUpdate(toolsets) {
|
|
2288
|
+
const cmd = toolsets.command("update").description(
|
|
2289
|
+
"Replace a toolset's name/connections/workflows. --connection/--application/--workflow replace the entire existing set for that member; they do not merge. Omit a member to leave it unchanged."
|
|
2290
|
+
).argument("[toolset_id]", "Toolset id").option("--from-file <path>", "Whole request body: JSON object, @file.json, or - for stdin").option("--name <name>", "New display name").option(
|
|
2291
|
+
"--connection <id[:slug,slug]>",
|
|
2292
|
+
"Replacement connection (repeatable); bare id = all its tools",
|
|
2293
|
+
collect2
|
|
2294
|
+
).option(
|
|
2295
|
+
"--application <slug[:slug,slug]>",
|
|
2296
|
+
"Replacement application default connection (repeatable)",
|
|
2297
|
+
collect2
|
|
2298
|
+
).option("--workflow <guid>", "Replacement workflow (repeatable)", collect2);
|
|
2299
|
+
cmd.addHelpText(
|
|
2300
|
+
"after",
|
|
2301
|
+
"\nExamples:\n engini toolsets update <id> --name 'Sales v2'\n engini toolsets update <id> --connection 3 --dry-run # preview dropped bindings\n engini toolsets update <id> --from-file toolset.json"
|
|
2302
|
+
);
|
|
2303
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2304
|
+
cmd.action(async (id, opts, command) => {
|
|
2305
|
+
await runCommand(command, opts, true, () => updateBody(id, opts));
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
// src/toolsets/index.ts
|
|
2310
|
+
function registerToolsets(program) {
|
|
2311
|
+
const toolsets = program.command("toolsets").description("List, inspect, create, update, and remove toolsets.");
|
|
2312
|
+
registerToolsetsList(toolsets);
|
|
2313
|
+
registerToolsetsGet(toolsets);
|
|
2314
|
+
registerToolsetsCreate(toolsets);
|
|
2315
|
+
registerToolsetsUpdate(toolsets);
|
|
2316
|
+
registerToolsetsDelete(toolsets);
|
|
2317
|
+
}
|
|
2318
|
+
|
|
1922
2319
|
// src/whoami.ts
|
|
1923
2320
|
function summary4(me) {
|
|
1924
2321
|
return {
|
|
@@ -1946,7 +2343,7 @@ function registerWhoami(program) {
|
|
|
1946
2343
|
}
|
|
1947
2344
|
|
|
1948
2345
|
// src/version.ts
|
|
1949
|
-
var VERSION = true ? "0.
|
|
2346
|
+
var VERSION = true ? "0.12.0" : "0.0.0";
|
|
1950
2347
|
|
|
1951
2348
|
// src/main.ts
|
|
1952
2349
|
function buildProgram() {
|
|
@@ -1959,6 +2356,7 @@ function buildProgram() {
|
|
|
1959
2356
|
registerTools(program);
|
|
1960
2357
|
registerApplications(program);
|
|
1961
2358
|
registerConnections(program);
|
|
2359
|
+
registerToolsets(program);
|
|
1962
2360
|
installHelp(program);
|
|
1963
2361
|
return program;
|
|
1964
2362
|
}
|
|
@@ -1982,7 +2380,7 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
1982
2380
|
process.exit(err.code);
|
|
1983
2381
|
}
|
|
1984
2382
|
if (err && typeof err === "object" && "exitCode" in err) {
|
|
1985
|
-
process.exit(err.exitCode
|
|
2383
|
+
process.exit(mapCommanderExitCode(err.exitCode));
|
|
1986
2384
|
}
|
|
1987
2385
|
console.error(err instanceof Error ? err.message : String(err));
|
|
1988
2386
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@engini/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Engini CLI — machine-first command line over the Engini Public API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist"
|
|
12
12
|
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
},
|
|
13
16
|
"repository": {
|
|
14
17
|
"type": "git",
|
|
15
18
|
"url": "https://github.com/engini/engini-sdk",
|
|
@@ -21,7 +24,7 @@
|
|
|
21
24
|
"test": "vitest run"
|
|
22
25
|
},
|
|
23
26
|
"dependencies": {
|
|
24
|
-
"@engini/sdk": "^0.
|
|
27
|
+
"@engini/sdk": "^0.12.0",
|
|
25
28
|
"commander": "^12.1.0",
|
|
26
29
|
"smol-toml": "^1.3.0"
|
|
27
30
|
},
|