@engini/cli 0.6.0 → 0.7.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 +32 -1
- package/dist/cli.js +358 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,13 +20,14 @@ engini applications list --available # discover connector apps
|
|
|
20
20
|
engini tools list --application monday # discover tools
|
|
21
21
|
engini tools call monday_create_item --args '{}' --connection 3
|
|
22
22
|
engini tools call gmail_send_mail --args '{}' --file attachmentsarray=@report.pdf # attach a file
|
|
23
|
+
engini tools result <handle> --select items.email # drill into a large result
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
## Commands
|
|
26
27
|
|
|
27
28
|
```
|
|
28
29
|
engini login | logout | whoami # auth
|
|
29
|
-
engini tools list | get | call
|
|
30
|
+
engini tools list | get | call | result # discover, execute & drill into results
|
|
30
31
|
engini applications list | get # browse connector apps
|
|
31
32
|
engini connections list | get # inspect connections
|
|
32
33
|
engini connect # open the connections page in your browser
|
|
@@ -47,6 +48,36 @@ with `--json`. Every command also accepts:
|
|
|
47
48
|
Exit codes are a stable contract: `0` success · `1` general error · `2` usage error ·
|
|
48
49
|
`3` authentication error · `4` not found · `5` validation error · `124` timeout.
|
|
49
50
|
|
|
51
|
+
## Large results (token economy)
|
|
52
|
+
|
|
53
|
+
Tool outputs can be huge — an agent shouldn't pay tokens for data it hasn't asked
|
|
54
|
+
for. When a `tools call` result exceeds `--max-bytes` (default `4096`), it is
|
|
55
|
+
spilled to a local sandbox and the command prints a compact envelope instead:
|
|
56
|
+
|
|
57
|
+
```jsonc
|
|
58
|
+
{ "handle": "h42", "history_id": 42, "data_size": 84211,
|
|
59
|
+
"shape": { "type": "object", "keys": { "items": "array", "total": "number" } },
|
|
60
|
+
"preview": { "id": 1, "email": "a@x.io" },
|
|
61
|
+
"hint": "Full result stored. Pull data with: engini tools result h42 …" }
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Then drill in with `tools result <handle>`, paying only for what you pull:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
engini tools result h42 --select items.email # dot-path (maps over a list)
|
|
68
|
+
engini tools result h42 --fields id,name # project keys per item
|
|
69
|
+
engini tools result h42 --select items --offset 20 --limit 10 # page a list
|
|
70
|
+
engini tools result h42 --full # the whole payload
|
|
71
|
+
engini tools result --list # known handles
|
|
72
|
+
engini tools result --clear # wipe the sandbox
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
`--inline` (or `--max-bytes 0`) forces the full result inline; `--raw` / `--llm`
|
|
76
|
+
emit the full output as before and bypass the sandbox. Stored results live under
|
|
77
|
+
`$XDG_CACHE_HOME/engini/results/` (`%APPDATA%` on Windows) and are auto-pruned to
|
|
78
|
+
the most-recent 20, dropping anything older than 24h — so a handle is short-lived;
|
|
79
|
+
drill in during the same session.
|
|
80
|
+
|
|
50
81
|
## Configuration
|
|
51
82
|
|
|
52
83
|
Credentials and host config live in `$XDG_CONFIG_HOME/engini/config.toml`
|
package/dist/cli.js
CHANGED
|
@@ -107,17 +107,17 @@ function printOutput(obj) {
|
|
|
107
107
|
pretty(obj);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function fail(code, message,
|
|
110
|
+
function fail(code, message, hint2) {
|
|
111
111
|
if (isTty()) {
|
|
112
112
|
console.error(`Error: ${message}`);
|
|
113
|
-
if (
|
|
113
|
+
if (hint2) console.error(`Hint: ${hint2}`);
|
|
114
114
|
} else {
|
|
115
115
|
const payload = {
|
|
116
116
|
error: ERROR_NAMES[code] ?? "Error",
|
|
117
117
|
message,
|
|
118
118
|
exit_code: code
|
|
119
119
|
};
|
|
120
|
-
if (
|
|
120
|
+
if (hint2) payload.hint = hint2;
|
|
121
121
|
console.error(JSON.stringify(payload));
|
|
122
122
|
}
|
|
123
123
|
throw new CliError(code);
|
|
@@ -503,9 +503,13 @@ CORE COMMANDS
|
|
|
503
503
|
Discover available tools (one concise summary per tool).
|
|
504
504
|
tools get <tool_id>
|
|
505
505
|
Full input/output schema + capability flags for one tool.
|
|
506
|
-
tools call <tool_id> --args <json|@file|-> [--file <field=@path>] [--connection <id>] [--raw] [--llm <vendor>]
|
|
506
|
+
tools call <tool_id> --args <json|@file|-> [--file <field=@path>] [--connection <id>] [--raw] [--llm <vendor>] [--inline]
|
|
507
507
|
Execute a tool against a connection. Attach files with --file (repeat for a
|
|
508
|
-
list). Validate first with --dry-run.
|
|
508
|
+
list). Validate first with --dry-run. A large result spills to a local
|
|
509
|
+
handle (use --inline / --max-bytes <n> to control this).
|
|
510
|
+
tools result <handle> [--select <path>] [--fields <a,b>] [--offset <n>] [--limit <m>] [--full] [--list] [--clear]
|
|
511
|
+
Drill into a stored tools call result: extract a dot-path, project fields,
|
|
512
|
+
or page a list \u2014 paying tokens only for what you pull.
|
|
509
513
|
applications list [--search <q>] [--available] [--limit <n>]
|
|
510
514
|
Browse connector apps (slug, categories, tool counts).
|
|
511
515
|
applications get <slug>
|
|
@@ -564,6 +568,11 @@ EXAMPLES
|
|
|
564
568
|
# Provider-shaped result for an agent loop
|
|
565
569
|
engini tools call monday_create_item --args '{}' --llm openai --tool-call-id call_1
|
|
566
570
|
|
|
571
|
+
# Large result -> handle; drill in without paying for the whole payload
|
|
572
|
+
engini tools call list_rows --args '{}' # prints {handle, shape, preview, \u2026}
|
|
573
|
+
engini tools result <handle> --select items.email
|
|
574
|
+
engini tools result <handle> --fields id,name --offset 20 --limit 10
|
|
575
|
+
|
|
567
576
|
# Machine-readable arg schema (for agents)
|
|
568
577
|
engini tools call --schema
|
|
569
578
|
|
|
@@ -589,7 +598,15 @@ var EXAMPLES = {
|
|
|
589
598
|
engini tools call monday_create_item --args @item.json --connection 3
|
|
590
599
|
echo '{"name":"x"}' | engini tools call monday_create_item --args -
|
|
591
600
|
engini tools call gmail_send_mail --args '{}' --file attachmentsarray=@report.pdf
|
|
592
|
-
engini tools call monday_create_item --args '{}' --llm openai --tool-call-id call_1
|
|
601
|
+
engini tools call monday_create_item --args '{}' --llm openai --tool-call-id call_1
|
|
602
|
+
engini tools call list_rows --args '{}' # large result -> handle; then: engini tools result <handle>`,
|
|
603
|
+
"tools result": `Examples:
|
|
604
|
+
engini tools result h42 # shape + preview
|
|
605
|
+
engini tools result h42 --select items.email # one dot-path (maps over a list)
|
|
606
|
+
engini tools result h42 --fields id,name # project keys per item
|
|
607
|
+
engini tools result h42 --select items --offset 20 --limit 10
|
|
608
|
+
engini tools result --list # known handles
|
|
609
|
+
engini tools result --clear # wipe the sandbox`,
|
|
593
610
|
"applications list": `Examples:
|
|
594
611
|
engini applications list --available --limit 10
|
|
595
612
|
engini applications list --search crm --json
|
|
@@ -617,6 +634,7 @@ function installHelp(program) {
|
|
|
617
634
|
addExamples(sub("list"), EXAMPLES["tools list"]);
|
|
618
635
|
addExamples(sub("get"), EXAMPLES["tools get"]);
|
|
619
636
|
addExamples(sub("call"), EXAMPLES["tools call"]);
|
|
637
|
+
addExamples(sub("result"), EXAMPLES["tools result"]);
|
|
620
638
|
}
|
|
621
639
|
const applications = find("applications");
|
|
622
640
|
if (applications) {
|
|
@@ -699,19 +717,254 @@ function registerLogout(program) {
|
|
|
699
717
|
}
|
|
700
718
|
|
|
701
719
|
// src/tools/call.ts
|
|
702
|
-
import { readFileSync as
|
|
720
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
703
721
|
import {
|
|
704
722
|
AnthropicProvider,
|
|
705
723
|
File,
|
|
706
724
|
OpenAIProvider
|
|
707
725
|
} from "@engini/sdk";
|
|
726
|
+
|
|
727
|
+
// src/results.ts
|
|
728
|
+
import { randomBytes } from "crypto";
|
|
729
|
+
import {
|
|
730
|
+
existsSync as existsSync2,
|
|
731
|
+
mkdirSync as mkdirSync2,
|
|
732
|
+
readFileSync as readFileSync2,
|
|
733
|
+
readdirSync,
|
|
734
|
+
rmSync,
|
|
735
|
+
statSync,
|
|
736
|
+
writeFileSync as writeFileSync2
|
|
737
|
+
} from "fs";
|
|
738
|
+
import { homedir as homedir2 } from "os";
|
|
739
|
+
import { join as join2 } from "path";
|
|
740
|
+
var MAX_RESULTS = 20;
|
|
741
|
+
var TTL_SECONDS = 24 * 60 * 60;
|
|
742
|
+
var PREVIEW_BYTES = 512;
|
|
743
|
+
function cacheDir() {
|
|
744
|
+
const base = process.platform === "win32" ? process.env.APPDATA ?? homedir2() : process.env.XDG_CACHE_HOME ?? join2(homedir2(), ".cache");
|
|
745
|
+
return join2(base, "engini", "results");
|
|
746
|
+
}
|
|
747
|
+
function serialize(value) {
|
|
748
|
+
return JSON.stringify(value ?? null);
|
|
749
|
+
}
|
|
750
|
+
function byteLength(value) {
|
|
751
|
+
return Buffer.byteLength(serialize(value), "utf8");
|
|
752
|
+
}
|
|
753
|
+
function jsonFiles(dir) {
|
|
754
|
+
if (!existsSync2(dir)) return [];
|
|
755
|
+
return readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
756
|
+
}
|
|
757
|
+
function storeResult(output, historyId) {
|
|
758
|
+
const handle = historyId !== null ? `h${historyId}` : `r${randomBytes(6).toString("hex")}`;
|
|
759
|
+
const dir = cacheDir();
|
|
760
|
+
mkdirSync2(dir, { recursive: true, mode: 448 });
|
|
761
|
+
const dataSize = byteLength(output);
|
|
762
|
+
const payload = {
|
|
763
|
+
output: output ?? null,
|
|
764
|
+
history_id: historyId,
|
|
765
|
+
data_size: dataSize,
|
|
766
|
+
created: Math.floor(Date.now() / 1e3)
|
|
767
|
+
};
|
|
768
|
+
writeFileSync2(join2(dir, `${handle}.json`), JSON.stringify(payload), { mode: 384 });
|
|
769
|
+
prune();
|
|
770
|
+
return { handle, dataSize };
|
|
771
|
+
}
|
|
772
|
+
function loadResult(handle) {
|
|
773
|
+
const path = join2(cacheDir(), `${handle}.json`);
|
|
774
|
+
if (!existsSync2(path)) return null;
|
|
775
|
+
try {
|
|
776
|
+
const data = JSON.parse(readFileSync2(path, "utf8"));
|
|
777
|
+
return data && typeof data === "object" ? data : null;
|
|
778
|
+
} catch {
|
|
779
|
+
return null;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
function listResults() {
|
|
783
|
+
const dir = cacheDir();
|
|
784
|
+
const now = Date.now();
|
|
785
|
+
const rows = [];
|
|
786
|
+
for (const name of jsonFiles(dir)) {
|
|
787
|
+
const handle = name.slice(0, -".json".length);
|
|
788
|
+
let mtimeMs;
|
|
789
|
+
try {
|
|
790
|
+
mtimeMs = statSync(join2(dir, name)).mtimeMs;
|
|
791
|
+
} catch {
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
const data = loadResult(handle);
|
|
795
|
+
rows.push({
|
|
796
|
+
mtime: mtimeMs,
|
|
797
|
+
row: {
|
|
798
|
+
handle,
|
|
799
|
+
history_id: data?.history_id ?? null,
|
|
800
|
+
data_size: data?.data_size ?? null,
|
|
801
|
+
age_seconds: Math.floor((now - mtimeMs) / 1e3)
|
|
802
|
+
}
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
rows.sort((a, b) => b.mtime - a.mtime);
|
|
806
|
+
return rows.map((r) => r.row);
|
|
807
|
+
}
|
|
808
|
+
function clearResults() {
|
|
809
|
+
const dir = cacheDir();
|
|
810
|
+
let count = 0;
|
|
811
|
+
for (const name of jsonFiles(dir)) {
|
|
812
|
+
rmSync(join2(dir, name), { force: true });
|
|
813
|
+
count += 1;
|
|
814
|
+
}
|
|
815
|
+
return count;
|
|
816
|
+
}
|
|
817
|
+
function prune() {
|
|
818
|
+
const dir = cacheDir();
|
|
819
|
+
if (!existsSync2(dir)) return;
|
|
820
|
+
const now = Date.now();
|
|
821
|
+
const entries = [];
|
|
822
|
+
for (const name of jsonFiles(dir)) {
|
|
823
|
+
const path = join2(dir, name);
|
|
824
|
+
try {
|
|
825
|
+
entries.push({ path, mtime: statSync(path).mtimeMs });
|
|
826
|
+
} catch {
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
entries.sort((a, b) => b.mtime - a.mtime);
|
|
830
|
+
const survivors = [];
|
|
831
|
+
for (const { path, mtime } of entries) {
|
|
832
|
+
if (now - mtime > TTL_SECONDS * 1e3) rmSync(path, { force: true });
|
|
833
|
+
else survivors.push(path);
|
|
834
|
+
}
|
|
835
|
+
for (const path of survivors.slice(MAX_RESULTS)) rmSync(path, { force: true });
|
|
836
|
+
}
|
|
837
|
+
function typeName(value) {
|
|
838
|
+
if (value === null || value === void 0) return "null";
|
|
839
|
+
if (Array.isArray(value)) return "array";
|
|
840
|
+
switch (typeof value) {
|
|
841
|
+
case "boolean":
|
|
842
|
+
return "boolean";
|
|
843
|
+
case "number":
|
|
844
|
+
return "number";
|
|
845
|
+
case "string":
|
|
846
|
+
return "string";
|
|
847
|
+
case "object":
|
|
848
|
+
return "object";
|
|
849
|
+
default:
|
|
850
|
+
return "string";
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
function inferShape(value) {
|
|
854
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
855
|
+
const keys = {};
|
|
856
|
+
for (const [k, v] of Object.entries(value)) keys[k] = typeName(v);
|
|
857
|
+
return { type: "object", keys };
|
|
858
|
+
}
|
|
859
|
+
if (Array.isArray(value)) {
|
|
860
|
+
const shape = { type: "array", length: value.length };
|
|
861
|
+
if (value.length > 0) {
|
|
862
|
+
const first = typeName(value[0]);
|
|
863
|
+
const homogeneous = value.every((item) => typeName(item) === first);
|
|
864
|
+
shape.item_shape = homogeneous ? inferShape(value[0]) : "mixed";
|
|
865
|
+
}
|
|
866
|
+
return shape;
|
|
867
|
+
}
|
|
868
|
+
return typeName(value);
|
|
869
|
+
}
|
|
870
|
+
function makePreview(value) {
|
|
871
|
+
const candidate = Array.isArray(value) ? value.length > 0 ? value[0] : null : value;
|
|
872
|
+
if (byteLength(candidate) <= PREVIEW_BYTES) return candidate ?? null;
|
|
873
|
+
if (typeof candidate === "string") return `${candidate.slice(0, PREVIEW_BYTES)}\u2026`;
|
|
874
|
+
return { _truncated: true, _note: "preview omitted; use --select/--fields" };
|
|
875
|
+
}
|
|
876
|
+
function hint(handle) {
|
|
877
|
+
return `Full result stored. Pull data with: engini tools result ${handle} --select <path> | --fields a,b | --offset N --limit M`;
|
|
878
|
+
}
|
|
879
|
+
function buildEnvelope(handle, historyId, dataSize, output) {
|
|
880
|
+
return {
|
|
881
|
+
handle,
|
|
882
|
+
history_id: historyId,
|
|
883
|
+
data_size: dataSize,
|
|
884
|
+
shape: inferShape(output),
|
|
885
|
+
preview: makePreview(output),
|
|
886
|
+
hint: hint(handle)
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
function parsePath(path) {
|
|
890
|
+
const atoms = [];
|
|
891
|
+
let token = "";
|
|
892
|
+
let i = 0;
|
|
893
|
+
while (i < path.length) {
|
|
894
|
+
const ch = path[i];
|
|
895
|
+
if (ch === ".") {
|
|
896
|
+
if (token) {
|
|
897
|
+
atoms.push({ kind: "key", value: token });
|
|
898
|
+
token = "";
|
|
899
|
+
}
|
|
900
|
+
i += 1;
|
|
901
|
+
} else if (ch === "[") {
|
|
902
|
+
if (token) {
|
|
903
|
+
atoms.push({ kind: "key", value: token });
|
|
904
|
+
token = "";
|
|
905
|
+
}
|
|
906
|
+
const j = path.indexOf("]", i);
|
|
907
|
+
if (j === -1) break;
|
|
908
|
+
const digits = path.slice(i + 1, j);
|
|
909
|
+
if (/^\d+$/.test(digits)) atoms.push({ kind: "index", value: Number(digits) });
|
|
910
|
+
i = j + 1;
|
|
911
|
+
} else {
|
|
912
|
+
token += ch;
|
|
913
|
+
i += 1;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
if (token) atoms.push({ kind: "key", value: token });
|
|
917
|
+
return atoms;
|
|
918
|
+
}
|
|
919
|
+
function step(cur, atom) {
|
|
920
|
+
if (atom.kind === "index") {
|
|
921
|
+
if (Array.isArray(cur) && atom.value >= 0 && atom.value < cur.length) return cur[atom.value];
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
if (Array.isArray(cur)) return cur.map((item) => step(item, atom));
|
|
925
|
+
if (cur !== null && typeof cur === "object") {
|
|
926
|
+
const value = cur[atom.value];
|
|
927
|
+
return value === void 0 ? null : value;
|
|
928
|
+
}
|
|
929
|
+
return null;
|
|
930
|
+
}
|
|
931
|
+
function selectPath(value, path) {
|
|
932
|
+
let cur = value;
|
|
933
|
+
for (const atom of parsePath(path)) {
|
|
934
|
+
cur = step(cur, atom);
|
|
935
|
+
if (cur === null) return null;
|
|
936
|
+
}
|
|
937
|
+
return cur;
|
|
938
|
+
}
|
|
939
|
+
function pick(obj, fields) {
|
|
940
|
+
const out = {};
|
|
941
|
+
for (const k of fields) if (k in obj) out[k] = obj[k];
|
|
942
|
+
return out;
|
|
943
|
+
}
|
|
944
|
+
function projectFields(value, fields) {
|
|
945
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
946
|
+
return pick(value, fields);
|
|
947
|
+
}
|
|
948
|
+
if (Array.isArray(value)) {
|
|
949
|
+
return value.map(
|
|
950
|
+
(item) => item !== null && typeof item === "object" && !Array.isArray(item) ? pick(item, fields) : null
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
return null;
|
|
954
|
+
}
|
|
955
|
+
function paginate(value, offset, limit) {
|
|
956
|
+
const sliced = value.slice(offset);
|
|
957
|
+
return limit !== null ? sliced.slice(0, limit) : sliced;
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// src/tools/call.ts
|
|
708
961
|
function loadArgs(spec) {
|
|
709
962
|
let text;
|
|
710
963
|
if (spec === "-") {
|
|
711
|
-
text =
|
|
964
|
+
text = readFileSync3(0, "utf8");
|
|
712
965
|
} else if (spec.startsWith("@")) {
|
|
713
966
|
try {
|
|
714
|
-
text =
|
|
967
|
+
text = readFileSync3(spec.slice(1), "utf8");
|
|
715
968
|
} catch (err) {
|
|
716
969
|
return fail(2 /* USAGE */, `Cannot read ${spec.slice(1)}: ${err.message}`);
|
|
717
970
|
}
|
|
@@ -788,8 +1041,15 @@ function renderResult(result, opts) {
|
|
|
788
1041
|
const call = { id: opts.toolCallId ?? opts.toolId, name: opts.toolId, arguments: {} };
|
|
789
1042
|
return provider.formatToolResult(call, { output: result.output });
|
|
790
1043
|
}
|
|
1044
|
+
const output = result.output;
|
|
1045
|
+
const size = Buffer.byteLength(serialize(output), "utf8");
|
|
1046
|
+
const historyId = result.historyId ?? null;
|
|
1047
|
+
if (!opts.inline && opts.maxBytes > 0 && size > opts.maxBytes) {
|
|
1048
|
+
const stored = storeResult(output, historyId);
|
|
1049
|
+
return buildEnvelope(stored.handle, historyId, stored.dataSize, output);
|
|
1050
|
+
}
|
|
791
1051
|
return {
|
|
792
|
-
output
|
|
1052
|
+
output,
|
|
793
1053
|
history_id: result.historyId,
|
|
794
1054
|
execution_info: result.executionInfo
|
|
795
1055
|
};
|
|
@@ -801,8 +1061,18 @@ async function callBody(toolId, opts) {
|
|
|
801
1061
|
if (opts.args === void 0) {
|
|
802
1062
|
fail(2 /* USAGE */, "Missing required option --args.");
|
|
803
1063
|
}
|
|
804
|
-
|
|
805
|
-
|
|
1064
|
+
const modes = [
|
|
1065
|
+
["--raw", Boolean(opts.raw)],
|
|
1066
|
+
["--llm", Boolean(opts.llm)],
|
|
1067
|
+
["--inline", Boolean(opts.inline)]
|
|
1068
|
+
];
|
|
1069
|
+
const explicit = modes.filter(([, on]) => on).map(([name]) => name);
|
|
1070
|
+
if (explicit.length > 1) {
|
|
1071
|
+
fail(2 /* USAGE */, `Pass only one of ${explicit.join(", ")}.`);
|
|
1072
|
+
}
|
|
1073
|
+
const maxBytes = opts.maxBytes === void 0 ? 4096 : Number(opts.maxBytes);
|
|
1074
|
+
if (!Number.isFinite(maxBytes) || maxBytes < 0) {
|
|
1075
|
+
fail(2 /* USAGE */, "--max-bytes must be a non-negative integer.");
|
|
806
1076
|
}
|
|
807
1077
|
const args = loadArgs(opts.args);
|
|
808
1078
|
Object.assign(args, loadFiles(opts.file));
|
|
@@ -830,7 +1100,9 @@ async function callBody(toolId, opts) {
|
|
|
830
1100
|
raw: opts.raw,
|
|
831
1101
|
llm: opts.llm,
|
|
832
1102
|
toolId,
|
|
833
|
-
toolCallId: opts.toolCallId
|
|
1103
|
+
toolCallId: opts.toolCallId,
|
|
1104
|
+
maxBytes,
|
|
1105
|
+
inline: opts.inline
|
|
834
1106
|
})
|
|
835
1107
|
);
|
|
836
1108
|
}
|
|
@@ -839,7 +1111,7 @@ function registerToolsCall(tools) {
|
|
|
839
1111
|
"--file <spec>",
|
|
840
1112
|
"Attach a file: field=@path (repeat the same field for a list of files)",
|
|
841
1113
|
collectFile
|
|
842
|
-
).option("--connection <id>", "Connection id to run against").option("--toolset <id>", "Toolset id to resolve the connection").option("--raw", "Emit the tool output verbatim (no envelope)").option("--llm <vendor>", "Provider-shaped result: openai|anthropic").option("--tool-call-id <id>", "Correlation id for --llm output");
|
|
1114
|
+
).option("--connection <id>", "Connection id to run against").option("--toolset <id>", "Toolset id to resolve the connection").option("--raw", "Emit the tool output verbatim (no envelope)").option("--llm <vendor>", "Provider-shaped result: openai|anthropic").option("--tool-call-id <id>", "Correlation id for --llm output").option("--max-bytes <n>", "Spill default-mode results larger than N bytes (0 = never)").option("--inline", "Force the full inline result, bypassing the sandbox");
|
|
843
1115
|
addUniversalOptions(cmd, { mutating: true });
|
|
844
1116
|
cmd.action(async (toolId, opts, command) => {
|
|
845
1117
|
await runCommand(command, opts, true, () => callBody(toolId, opts));
|
|
@@ -930,12 +1202,83 @@ function registerToolsList(tools) {
|
|
|
930
1202
|
});
|
|
931
1203
|
}
|
|
932
1204
|
|
|
1205
|
+
// src/tools/result.ts
|
|
1206
|
+
function collectSelect(value, previous = []) {
|
|
1207
|
+
return [...previous, value];
|
|
1208
|
+
}
|
|
1209
|
+
function resultBody(handle, opts) {
|
|
1210
|
+
if (opts.list) {
|
|
1211
|
+
printOutput(listResults());
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
if (opts.clear) {
|
|
1215
|
+
printOutput({ cleared: clearResults() });
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
if (!handle) {
|
|
1219
|
+
fail(2 /* USAGE */, "Missing required argument 'handle'.", "Pass a handle, or use --list.");
|
|
1220
|
+
}
|
|
1221
|
+
const stored = loadResult(handle);
|
|
1222
|
+
if (stored === null) {
|
|
1223
|
+
fail(
|
|
1224
|
+
4 /* NOT_FOUND */,
|
|
1225
|
+
`No stored result for handle '${handle}'.`,
|
|
1226
|
+
"It may have expired or been pruned; re-run the tool."
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
const output = stored.output;
|
|
1230
|
+
if (opts.full) {
|
|
1231
|
+
printOutput(output);
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
const offset = opts.offset === void 0 ? 0 : Number(opts.offset);
|
|
1235
|
+
const limit = opts.limit === void 0 ? null : Number(opts.limit);
|
|
1236
|
+
const select = opts.select ?? [];
|
|
1237
|
+
const paging = offset !== 0 || limit !== null;
|
|
1238
|
+
if (select.length === 0 && opts.fields === void 0 && !paging) {
|
|
1239
|
+
printOutput(buildEnvelope(handle, stored.history_id ?? null, stored.data_size ?? null, output));
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
let value = output;
|
|
1243
|
+
if (select.length === 1) {
|
|
1244
|
+
value = selectPath(value, select[0]);
|
|
1245
|
+
} else if (select.length > 1) {
|
|
1246
|
+
const out = {};
|
|
1247
|
+
for (const path of select) out[path] = selectPath(output, path);
|
|
1248
|
+
value = out;
|
|
1249
|
+
}
|
|
1250
|
+
if (opts.fields !== void 0) {
|
|
1251
|
+
const keys = opts.fields.split(",").map((f) => f.trim()).filter(Boolean);
|
|
1252
|
+
value = projectFields(value, keys);
|
|
1253
|
+
}
|
|
1254
|
+
if (paging) {
|
|
1255
|
+
if (!Array.isArray(value)) {
|
|
1256
|
+
fail(2 /* USAGE */, "--offset/--limit require a list value.", "Use --select to reach a list first.");
|
|
1257
|
+
}
|
|
1258
|
+
value = paginate(value, offset, limit);
|
|
1259
|
+
}
|
|
1260
|
+
printOutput(value);
|
|
1261
|
+
}
|
|
1262
|
+
function registerToolsResult(tools) {
|
|
1263
|
+
const cmd = tools.command("result").description("Drill into a sandboxed tools call result.").argument("[handle]", "Result handle from a prior tools call").option("--select <path>", "Dot-path to extract, e.g. items.email (repeatable)", collectSelect).option("--fields <keys>", "Comma-separated keys to project from object(s)").option("--offset <n>", "Skip N items of a list value").option("--limit <m>", "Return at most M list items").option("--full", "Emit the entire stored payload").option("--list", "List stored result handles").option("--clear", "Delete all stored results");
|
|
1264
|
+
addUniversalOptions(cmd);
|
|
1265
|
+
cmd.action(async (handle, opts, command) => {
|
|
1266
|
+
await runCommand(
|
|
1267
|
+
command,
|
|
1268
|
+
opts,
|
|
1269
|
+
false,
|
|
1270
|
+
() => resultBody(handle, opts)
|
|
1271
|
+
);
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
|
|
933
1275
|
// src/tools/index.ts
|
|
934
1276
|
function registerTools(program) {
|
|
935
1277
|
const tools = program.command("tools").description("Discover and execute tools.");
|
|
936
1278
|
registerToolsList(tools);
|
|
937
1279
|
registerToolsGet(tools);
|
|
938
1280
|
registerToolsCall(tools);
|
|
1281
|
+
registerToolsResult(tools);
|
|
939
1282
|
}
|
|
940
1283
|
|
|
941
1284
|
// src/whoami.ts
|
|
@@ -965,7 +1308,7 @@ function registerWhoami(program) {
|
|
|
965
1308
|
}
|
|
966
1309
|
|
|
967
1310
|
// src/version.ts
|
|
968
|
-
var VERSION = true ? "0.
|
|
1311
|
+
var VERSION = true ? "0.7.0" : "0.0.0";
|
|
969
1312
|
|
|
970
1313
|
// src/main.ts
|
|
971
1314
|
function buildProgram() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@engini/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Engini CLI — machine-first command line over the Engini Public API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"test": "vitest run"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@engini/sdk": "^0.
|
|
24
|
+
"@engini/sdk": "^0.7.0",
|
|
25
25
|
"commander": "^12.1.0",
|
|
26
26
|
"smol-toml": "^1.3.0"
|
|
27
27
|
},
|