@engini/cli 0.26.0 → 0.28.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 +3 -1
- package/dist/cli.js +62 -54
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ npx @engini/cli --help
|
|
|
19
19
|
engini login --api-key eng_… # or bare `engini login` to paste it interactively
|
|
20
20
|
engini applications list --available # discover connector apps
|
|
21
21
|
engini tools list --application monday # discover tools
|
|
22
|
+
engini tools get monday_create_item --connection 3 # schema as connection 3 sees it
|
|
23
|
+
engini opa list --updated-after 2026-10-01T00:00:00Z # on-prem agents changed at or after
|
|
22
24
|
engini tools call monday_create_item --args '{}' --connection 3
|
|
23
25
|
engini tools call gmail_send_mail --args '{}' --file attachmentsarray=@report.pdf # attach a file
|
|
24
26
|
engini tools result <handle> --select items.email # drill into a large result
|
|
@@ -100,7 +102,7 @@ engini connect monday --auth 0 --field ApiKey=<key> # creates → checks → r
|
|
|
100
102
|
engini connect outlook --json # → {need:"oauth", sign_in_url, state, state_expires_in_seconds, resume:"engini connect outlook --auth 0 --oauth-state <state>"}
|
|
101
103
|
# show sign_in_url to the user - they must sign in within state_expires_in_seconds of
|
|
102
104
|
# minting; past that the server has purged the state and the resume below fails fast, not hangs:
|
|
103
|
-
engini connect outlook --auth 0 --oauth-state <state> # polls
|
|
105
|
+
engini connect outlook --auth 0 --oauth-state <state> # polls sign-in status → creates → checks → refreshes
|
|
104
106
|
|
|
105
107
|
# re-authenticate an EXISTING OAuth2 connection in place — same sign-in flow,
|
|
106
108
|
# but --oauth-state alone (no --field/--name/--metadata) is a valid edit and
|
package/dist/cli.js
CHANGED
|
@@ -450,7 +450,7 @@ function saveConfig(config, path = configPath()) {
|
|
|
450
450
|
}
|
|
451
451
|
|
|
452
452
|
// src/version.ts
|
|
453
|
-
var VERSION = true ? "0.
|
|
453
|
+
var VERSION = true ? "0.28.0" : "0.0.0";
|
|
454
454
|
|
|
455
455
|
// src/http.ts
|
|
456
456
|
var USER_AGENT_PREFIX = `engini-cli/${VERSION}`;
|
|
@@ -642,8 +642,6 @@ async function safeTrigger(action, what) {
|
|
|
642
642
|
throw err;
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
|
-
var OAUTH_DONE = /* @__PURE__ */ new Set(["completed", "complete", "success", "succeeded"]);
|
|
646
|
-
var OAUTH_FAILED = /* @__PURE__ */ new Set(["failed", "error", "cancelled", "canceled", "denied"]);
|
|
647
645
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
648
646
|
var OAUTH_STATE_TTL_SECONDS = 300;
|
|
649
647
|
function collect(value, previous = []) {
|
|
@@ -695,24 +693,31 @@ async function pollRefresh(client, connectionId, opts) {
|
|
|
695
693
|
}
|
|
696
694
|
return "completed";
|
|
697
695
|
}
|
|
698
|
-
async function
|
|
696
|
+
async function pollSignInStatus(client, state, opts) {
|
|
699
697
|
progress(
|
|
700
698
|
`Waiting for you to finish signing in (up to ${Math.round(opts.timeout)}s, Ctrl-C to abort)\u2026`
|
|
701
699
|
);
|
|
702
700
|
const deadline = Date.now() + opts.timeout * 1e3;
|
|
703
701
|
for (; ; ) {
|
|
704
|
-
const resp = await client.connections.
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
702
|
+
const resp = await client.connections.getSignInStatus(state);
|
|
703
|
+
switch (resp.status) {
|
|
704
|
+
case "signed_in":
|
|
705
|
+
return resp;
|
|
706
|
+
case "expired":
|
|
707
|
+
fail(
|
|
708
|
+
4 /* NOT_FOUND */,
|
|
709
|
+
`OAuth sign-in state not found - it may have expired (states are purged ${OAUTH_STATE_TTL_SECONDS} seconds after they're minted) or never existed.`,
|
|
710
|
+
"Start over: `engini connect <app>` mints a fresh sign_in_url + state."
|
|
711
|
+
);
|
|
712
|
+
break;
|
|
713
|
+
case "failed":
|
|
714
|
+
case "cancelled":
|
|
715
|
+
fail(
|
|
716
|
+
1 /* GENERIC */,
|
|
717
|
+
`OAuth sign-in ${resp.status}.`,
|
|
718
|
+
"Start over: `engini connect <app>` mints a fresh sign_in_url + state."
|
|
719
|
+
);
|
|
720
|
+
break;
|
|
716
721
|
}
|
|
717
722
|
if (Date.now() >= deadline) {
|
|
718
723
|
fail(124 /* TIMEOUT */, "OAuth sign-in did not complete in time.");
|
|
@@ -720,14 +725,6 @@ async function pollAccessToken(client, state, opts) {
|
|
|
720
725
|
await sleep(opts.interval * 1e3);
|
|
721
726
|
}
|
|
722
727
|
}
|
|
723
|
-
function oauthFields(token) {
|
|
724
|
-
const fields = {};
|
|
725
|
-
for (const [key, value] of Object.entries(token.connectionData ?? {})) {
|
|
726
|
-
if (value === null || value === void 0 || value === "") continue;
|
|
727
|
-
fields[key] = typeof value === "string" ? value : JSON.stringify(value);
|
|
728
|
-
}
|
|
729
|
-
return fields;
|
|
730
|
-
}
|
|
731
728
|
|
|
732
729
|
// src/connect.ts
|
|
733
730
|
var PLACEHOLDER = "<value>";
|
|
@@ -887,7 +884,7 @@ async function chooseAuth(methods, auth, application, provider) {
|
|
|
887
884
|
resume: `engini connect ${application} --auth <id>${providerResumeFlag(provider)}`
|
|
888
885
|
});
|
|
889
886
|
}
|
|
890
|
-
async function collectFields(method, application, provided, oauthState, fieldOptions, provider) {
|
|
887
|
+
async function collectFields(method, application, provided, oauthState, fieldOptions, provider, derived) {
|
|
891
888
|
async function readSecretField(label) {
|
|
892
889
|
const { value, truncated } = await promptHidden(label);
|
|
893
890
|
if (truncated) {
|
|
@@ -922,12 +919,14 @@ async function collectFields(method, application, provided, oauthState, fieldOpt
|
|
|
922
919
|
);
|
|
923
920
|
}
|
|
924
921
|
}
|
|
922
|
+
for (const k of derived ?? []) delete provided[k];
|
|
923
|
+
const isSatisfied = (name) => name in provided || (derived?.has(name) ?? false);
|
|
925
924
|
const required = schema.filter((f) => f.isRequired);
|
|
926
|
-
const missing = required.filter((f) => !(f.fieldName
|
|
925
|
+
const missing = required.filter((f) => !isSatisfied(f.fieldName));
|
|
927
926
|
if (missing.length === 0) return provided;
|
|
928
927
|
if (isInteractive()) {
|
|
929
928
|
for (const f of schema) {
|
|
930
|
-
if (f.fieldName
|
|
929
|
+
if (isSatisfied(f.fieldName)) continue;
|
|
931
930
|
const label = fieldLabel(f);
|
|
932
931
|
const options = fieldOptions?.[f.fieldName];
|
|
933
932
|
const value = options && Object.keys(options).length > 0 ? await promptFieldOption(label, options, f.isRequired, resumeHint) : f.isPassword ? await readSecretField(label) : await promptText(label, clean(f.defaultValue) ?? "");
|
|
@@ -1006,10 +1005,9 @@ async function resolveObjects(objs, connectionId, application) {
|
|
|
1006
1005
|
async function oauthFieldsFor(client, application, method, oauthState, field, timing, provider) {
|
|
1007
1006
|
const cliFields = parseFields(field);
|
|
1008
1007
|
if (oauthState) {
|
|
1009
|
-
const
|
|
1010
|
-
const merged = { ...cliFields, ...oauthFields(token) };
|
|
1008
|
+
const status = await pollSignInStatus(client, oauthState, timing);
|
|
1011
1009
|
return {
|
|
1012
|
-
fields: await collectFields(method, application,
|
|
1010
|
+
fields: await collectFields(method, application, cliFields, oauthState, status.fieldOptions, provider, new Set(status.derivedFields)),
|
|
1013
1011
|
state: oauthState
|
|
1014
1012
|
};
|
|
1015
1013
|
}
|
|
@@ -1020,10 +1018,9 @@ async function oauthFieldsFor(client, application, method, oauthState, field, ti
|
|
|
1020
1018
|
if (isTty() && timing.wait) {
|
|
1021
1019
|
openBrowser(resp.signInUrl);
|
|
1022
1020
|
progress(`Opened ${resp.signInUrl} \u2014 complete the sign-in in your browser.`);
|
|
1023
|
-
const
|
|
1024
|
-
const merged = { ...cliFields, ...oauthFields(token) };
|
|
1021
|
+
const status = await pollSignInStatus(client, resp.state, timing);
|
|
1025
1022
|
return {
|
|
1026
|
-
fields: await collectFields(method, application,
|
|
1023
|
+
fields: await collectFields(method, application, cliFields, resp.state, status.fieldOptions, provider, new Set(status.derivedFields)),
|
|
1027
1024
|
state: resp.state
|
|
1028
1025
|
};
|
|
1029
1026
|
}
|
|
@@ -1096,7 +1093,7 @@ function methodSummary(m) {
|
|
|
1096
1093
|
// to have discovered them from. Each field's `options` therefore comes back `null` in
|
|
1097
1094
|
// this `need: "auth"` payload specifically because it's not knowable yet, not because
|
|
1098
1095
|
// the field has none - that's a distinct case (`{}`, once a sign-in has run - see
|
|
1099
|
-
// `fieldSummary` and the `
|
|
1096
|
+
// `fieldSummary` and the `SignInStatusResponse.fieldOptions` doc in @engini/sdk). Worth
|
|
1100
1097
|
// calling out explicitly wherever step 5 documents this payload, since the two look the
|
|
1101
1098
|
// same on the wire (both fall out here as `options: null`) but mean different things.
|
|
1102
1099
|
fields: m.connectionFields.map((f) => fieldSummary(f))
|
|
@@ -1829,12 +1826,12 @@ async function oauthCompleteBody(application, opts) {
|
|
|
1829
1826
|
}
|
|
1830
1827
|
const conn = await apiErrors(async () => {
|
|
1831
1828
|
const client = buildClient();
|
|
1832
|
-
|
|
1829
|
+
await pollSignInStatus(client, opts.state, {
|
|
1833
1830
|
timeout: Number(opts.timeout ?? 300),
|
|
1834
1831
|
interval: Number(opts.pollInterval ?? 2)
|
|
1835
1832
|
});
|
|
1836
1833
|
progress(`Creating connection '${name}'\u2026`);
|
|
1837
|
-
return client.connections.create(application, name, auth,
|
|
1834
|
+
return client.connections.create(application, name, auth, {}, {
|
|
1838
1835
|
oauthState: opts.state
|
|
1839
1836
|
});
|
|
1840
1837
|
});
|
|
@@ -2121,7 +2118,7 @@ function registerConnections(program) {
|
|
|
2121
2118
|
// src/help.ts
|
|
2122
2119
|
import { Help } from "commander";
|
|
2123
2120
|
var REPO_URL = "https://github.com/engini/engini-sdk";
|
|
2124
|
-
var KEYS_URL = "https://app.engini.io/
|
|
2121
|
+
var KEYS_URL = "https://app.engini.io/api-keys";
|
|
2125
2122
|
var EXIT_LABELS = {
|
|
2126
2123
|
[0 /* OK */]: "success",
|
|
2127
2124
|
[1 /* GENERIC */]: "general error",
|
|
@@ -2150,8 +2147,9 @@ USAGE
|
|
|
2150
2147
|
CORE COMMANDS
|
|
2151
2148
|
tools list [--application <slug>] [--toolset <id>] [--limit <n>]
|
|
2152
2149
|
Discover available tools (one concise summary per tool).
|
|
2153
|
-
tools get <tool_id>
|
|
2154
|
-
Full input/output schema + capability flags for one tool
|
|
2150
|
+
tools get <tool_id> [--connection <id>]
|
|
2151
|
+
Full input/output schema + capability flags for one tool
|
|
2152
|
+
(--connection: the schema as that connection sees it).
|
|
2155
2153
|
tools call <tool_id> --args <json|@file|-> [--file <field=@path>] [--connection <id>] [--raw] [--llm <vendor>] [--inline]
|
|
2156
2154
|
Execute a tool against a connection. Attach files with --file (repeat for a
|
|
2157
2155
|
list). Validate first with --dry-run. A large result spills to a local
|
|
@@ -2267,7 +2265,8 @@ MCP SERVERS
|
|
|
2267
2265
|
ON-PREMISE AGENTS
|
|
2268
2266
|
The Engini component a customer installs behind their firewall to reach SQL Server,
|
|
2269
2267
|
Oracle, Priority ERP and file shares. Not connections: connections list never shows them.
|
|
2270
|
-
opa list [--status <s>] [--name <substr>]
|
|
2268
|
+
opa list [--status <s>] [--name <substr>] [--updated-after <iso>]
|
|
2269
|
+
List the account's on-premise agents.
|
|
2271
2270
|
opa get <id> Status, version, last heartbeat, settings.
|
|
2272
2271
|
opa create --name <n> [...] Register an agent. PRINTS ITS TOKEN.
|
|
2273
2272
|
opa update <id> [...] Change name/description/settings (merges).
|
|
@@ -2431,7 +2430,7 @@ function installHelp(program) {
|
|
|
2431
2430
|
|
|
2432
2431
|
// src/login.ts
|
|
2433
2432
|
function keysUrl(config) {
|
|
2434
|
-
return `${config.identity_url.replace(/\/+$/, "")}/
|
|
2433
|
+
return `${config.identity_url.replace(/\/+$/, "")}/api-keys`;
|
|
2435
2434
|
}
|
|
2436
2435
|
var MAX_KEY_ATTEMPTS = 3;
|
|
2437
2436
|
function charCount(key) {
|
|
@@ -3320,7 +3319,7 @@ function registerOpaGet(opa) {
|
|
|
3320
3319
|
// src/opa/list.ts
|
|
3321
3320
|
async function listBody7(opts) {
|
|
3322
3321
|
const agents = await apiErrors(
|
|
3323
|
-
async () => buildClient().opa.list({ status: opts.status, name: opts.name })
|
|
3322
|
+
async () => buildClient().opa.list({ status: opts.status, name: opts.name, updatedAfter: opts.updatedAfter })
|
|
3324
3323
|
);
|
|
3325
3324
|
printOutput(agents.map(summarizeAgent));
|
|
3326
3325
|
}
|
|
@@ -3328,10 +3327,10 @@ function registerOpaList(opa) {
|
|
|
3328
3327
|
const cmd = opa.command("list").description("List the account's on-premise agents.").option(
|
|
3329
3328
|
"--status <status>",
|
|
3330
3329
|
"Filter: WaitingForConnection | Online | Offline | Disabled (case-insensitive)"
|
|
3331
|
-
).option("--name <substring>", "Filter by name substring");
|
|
3330
|
+
).option("--name <substring>", "Filter by name substring").option("--updated-after <datetime>", "Only agents changed at or after this ISO 8601 datetime; include Z or an offset (no zone is read as server time)");
|
|
3332
3331
|
cmd.addHelpText(
|
|
3333
3332
|
"after",
|
|
3334
|
-
"\nExamples:\n engini opa list\n engini opa list --status offline --json"
|
|
3333
|
+
"\nExamples:\n engini opa list\n engini opa list --status offline --json\n engini opa list --updated-after 2026-10-01T00:00:00Z"
|
|
3335
3334
|
);
|
|
3336
3335
|
addUniversalOptions(cmd);
|
|
3337
3336
|
cmd.action(async (opts, command) => {
|
|
@@ -3948,21 +3947,27 @@ function detail3(schema) {
|
|
|
3948
3947
|
max_sorts: clean(schema.maxSorts)
|
|
3949
3948
|
};
|
|
3950
3949
|
}
|
|
3951
|
-
async function getBody7(toolId) {
|
|
3950
|
+
async function getBody7(toolId, connection) {
|
|
3952
3951
|
if (!toolId) {
|
|
3953
3952
|
fail(2 /* USAGE */, "Missing required argument 'tool_id'.");
|
|
3954
3953
|
}
|
|
3954
|
+
const connectionId = parseConnection(connection);
|
|
3955
3955
|
const schema = await apiErrors(async () => {
|
|
3956
3956
|
const client = buildClient();
|
|
3957
|
-
return client.tools.getOne(toolId);
|
|
3957
|
+
return client.tools.getOne(toolId, void 0, connectionId);
|
|
3958
3958
|
});
|
|
3959
3959
|
printOutput(detail3(schema));
|
|
3960
3960
|
}
|
|
3961
3961
|
function registerToolsGet(tools) {
|
|
3962
|
-
const cmd = tools.command("get").description("Show full canonical detail for one tool.").argument("[tool_id]", "Tool slug");
|
|
3962
|
+
const cmd = tools.command("get").description("Show full canonical detail for one tool.").argument("[tool_id]", "Tool slug").option("--connection <id>", "Show the schema as this connection sees it");
|
|
3963
3963
|
addUniversalOptions(cmd);
|
|
3964
3964
|
cmd.action(async (toolId, opts, command) => {
|
|
3965
|
-
await runCommand(
|
|
3965
|
+
await runCommand(
|
|
3966
|
+
command,
|
|
3967
|
+
opts,
|
|
3968
|
+
false,
|
|
3969
|
+
() => getBody7(toolId, opts.connection)
|
|
3970
|
+
);
|
|
3966
3971
|
});
|
|
3967
3972
|
}
|
|
3968
3973
|
|
|
@@ -4538,13 +4543,12 @@ function connectionRef(raw) {
|
|
|
4538
4543
|
if (raw === void 0) return {};
|
|
4539
4544
|
return /^\d+$/.test(raw) ? { connectionId: Number(raw) } : { connectionName: raw };
|
|
4540
4545
|
}
|
|
4541
|
-
async function
|
|
4546
|
+
async function accountDefaultDestination() {
|
|
4542
4547
|
try {
|
|
4543
4548
|
await buildClient().triggers.destination.get();
|
|
4544
|
-
return
|
|
4549
|
+
return "set";
|
|
4545
4550
|
} catch (err) {
|
|
4546
|
-
|
|
4547
|
-
throw err;
|
|
4551
|
+
return err instanceof EnginiNotFoundError2 ? "none" : "unknown";
|
|
4548
4552
|
}
|
|
4549
4553
|
}
|
|
4550
4554
|
async function createBody5(triggerSlug, opts) {
|
|
@@ -4593,11 +4597,15 @@ async function createBody5(triggerSlug, opts) {
|
|
|
4593
4597
|
}
|
|
4594
4598
|
});
|
|
4595
4599
|
if (opts.destination === void 0) {
|
|
4596
|
-
const
|
|
4597
|
-
if (
|
|
4600
|
+
const defaultDestination = await accountDefaultDestination();
|
|
4601
|
+
if (defaultDestination === "none") {
|
|
4598
4602
|
progress(
|
|
4599
4603
|
"No destination is set for this trigger and the account has no default \u2014 events will accrue but nothing will be delivered. Set one with `engini triggers destinations set <url>`."
|
|
4600
4604
|
);
|
|
4605
|
+
} else if (defaultDestination === "unknown") {
|
|
4606
|
+
progress(
|
|
4607
|
+
"Trigger created, but this key could not check the account's default destination \u2014 events are delivered only if one is set."
|
|
4608
|
+
);
|
|
4601
4609
|
}
|
|
4602
4610
|
}
|
|
4603
4611
|
printOutput({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@engini/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Engini CLI — machine-first command line over the Engini Public API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test": "vitest run"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@engini/sdk": "^0.
|
|
29
|
+
"@engini/sdk": "^0.28.0",
|
|
30
30
|
"commander": "^12.1.0",
|
|
31
31
|
"smol-toml": "^1.3.0"
|
|
32
32
|
},
|