@topolo/cli 0.8.4 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +80 -7
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { platform as platform2 } from "os";
|
|
|
9
9
|
import { createInterface } from "readline/promises";
|
|
10
10
|
import { stdin as input } from "process";
|
|
11
11
|
|
|
12
|
-
// node_modules/@topolo/sdk/dist/index.js
|
|
12
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.4/node_modules/@topolo/sdk/dist/index.js
|
|
13
13
|
function applyAuthHeaders(headers, credential) {
|
|
14
14
|
if (credential.kind === "api_key") {
|
|
15
15
|
headers.set("X-Api-Key", credential.apiKey);
|
|
@@ -1984,6 +1984,7 @@ function mergeSignals(a, b) {
|
|
|
1984
1984
|
function compactActionCatalogEntry(action) {
|
|
1985
1985
|
const required = Array.isArray(action.inputSchema["required"]) ? action.inputSchema["required"].filter((value) => typeof value === "string") : [];
|
|
1986
1986
|
const examples = action.agentContract?.examples ?? [];
|
|
1987
|
+
const example = compactExample(examples[0]?.input);
|
|
1987
1988
|
return {
|
|
1988
1989
|
actionId: action.actionId,
|
|
1989
1990
|
title: action.title,
|
|
@@ -1995,13 +1996,83 @@ function compactActionCatalogEntry(action) {
|
|
|
1995
1996
|
requiredPermission: action.requiredPermission,
|
|
1996
1997
|
requiredInput: required,
|
|
1997
1998
|
resourceType: action.agentContract?.resource?.kind ?? null,
|
|
1998
|
-
exampleInput:
|
|
1999
|
+
exampleInput: example.value,
|
|
2000
|
+
exampleInputAvailable: example.available,
|
|
1999
2001
|
docsUrl: action.agentContract?.docsUrl ?? null
|
|
2000
2002
|
};
|
|
2001
2003
|
}
|
|
2004
|
+
function compactExample(input2) {
|
|
2005
|
+
if (!input2) return { value: null, available: false };
|
|
2006
|
+
const serialized = JSON.stringify(input2);
|
|
2007
|
+
if (serialized.length > 512) return { value: null, available: true };
|
|
2008
|
+
return { value: input2, available: true };
|
|
2009
|
+
}
|
|
2002
2010
|
function compactActionValidation(actionId, validation) {
|
|
2003
2011
|
return { actionId, valid: validation.valid, errors: validation.errors };
|
|
2004
2012
|
}
|
|
2013
|
+
var ACTION_RESULT_MAX_DEPTH = 3;
|
|
2014
|
+
var ACTION_RESULT_MAX_KEYS = 12;
|
|
2015
|
+
var ACTION_RESULT_MAX_ORDINARY_KEYS = 5;
|
|
2016
|
+
var ACTION_RESULT_MAX_ITEMS = 3;
|
|
2017
|
+
var ACTION_RESULT_MAX_SCALARS = 60;
|
|
2018
|
+
var ACTION_RESULT_MAX_STRING = 256;
|
|
2019
|
+
function resultKeyPriority(key) {
|
|
2020
|
+
if (/^(id|requestId|status|state|url|slug|name|title|version)$/i.test(key)) return 0;
|
|
2021
|
+
if (/(Id|Ids|Url|Uri|Status|State|Count|Total|Version|CreatedAt|UpdatedAt)$/i.test(key)) return 1;
|
|
2022
|
+
return 2;
|
|
2023
|
+
}
|
|
2024
|
+
function compactResultValue(value, depth, budget) {
|
|
2025
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") {
|
|
2026
|
+
budget.scalars += 1;
|
|
2027
|
+
return value;
|
|
2028
|
+
}
|
|
2029
|
+
if (typeof value === "string") {
|
|
2030
|
+
budget.scalars += 1;
|
|
2031
|
+
if (value.length <= ACTION_RESULT_MAX_STRING) return value;
|
|
2032
|
+
return `${value.slice(0, ACTION_RESULT_MAX_STRING)}\u2026 (${value.length} chars)`;
|
|
2033
|
+
}
|
|
2034
|
+
if (depth >= ACTION_RESULT_MAX_DEPTH || budget.scalars >= ACTION_RESULT_MAX_SCALARS) {
|
|
2035
|
+
return Array.isArray(value) ? { count: value.length, omitted: true } : { omitted: true };
|
|
2036
|
+
}
|
|
2037
|
+
if (Array.isArray(value)) {
|
|
2038
|
+
const items = value.slice(0, ACTION_RESULT_MAX_ITEMS).map((item) => compactResultValue(item, depth + 1, budget));
|
|
2039
|
+
return value.length > ACTION_RESULT_MAX_ITEMS ? { count: value.length, items, omittedItems: value.length - ACTION_RESULT_MAX_ITEMS } : items;
|
|
2040
|
+
}
|
|
2041
|
+
if (typeof value === "object") {
|
|
2042
|
+
const record = value;
|
|
2043
|
+
const allKeys = Object.keys(record);
|
|
2044
|
+
const ranked = allKeys.sort((left, right) => resultKeyPriority(left) - resultKeyPriority(right));
|
|
2045
|
+
const prioritized = ranked.filter((key) => resultKeyPriority(key) < 2);
|
|
2046
|
+
const ordinary = ranked.filter((key) => resultKeyPriority(key) === 2);
|
|
2047
|
+
const ordinaryLimit = depth === 0 ? ACTION_RESULT_MAX_ORDINARY_KEYS : prioritized.length ? 1 : ACTION_RESULT_MAX_ORDINARY_KEYS;
|
|
2048
|
+
const keys = [
|
|
2049
|
+
...prioritized,
|
|
2050
|
+
...ordinary.slice(0, ordinaryLimit)
|
|
2051
|
+
].slice(0, ACTION_RESULT_MAX_KEYS);
|
|
2052
|
+
const compact = Object.fromEntries(keys.map((key) => [key, compactResultValue(record[key], depth + 1, budget)]));
|
|
2053
|
+
if (allKeys.length > keys.length) compact["_omittedKeys"] = allKeys.length - keys.length;
|
|
2054
|
+
return compact;
|
|
2055
|
+
}
|
|
2056
|
+
budget.scalars += 1;
|
|
2057
|
+
return String(value);
|
|
2058
|
+
}
|
|
2059
|
+
function compactActionResult(actionId, result) {
|
|
2060
|
+
let normalized = result;
|
|
2061
|
+
if (typeof result === "string") {
|
|
2062
|
+
try {
|
|
2063
|
+
normalized = JSON.parse(result);
|
|
2064
|
+
} catch {
|
|
2065
|
+
normalized = result;
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
return { actionId, result: compactResultValue(normalized, 0, { scalars: 0 }) };
|
|
2069
|
+
}
|
|
2070
|
+
function preferExactActionMatches(actions, query) {
|
|
2071
|
+
const expected = query?.trim().toLowerCase();
|
|
2072
|
+
if (!expected) return actions;
|
|
2073
|
+
const exact = actions.filter((action) => [action.actionId, action.name, action.toolName].some((candidate) => candidate?.trim().toLowerCase() === expected));
|
|
2074
|
+
return exact.length ? exact : actions;
|
|
2075
|
+
}
|
|
2005
2076
|
function compactActionPlan(plan) {
|
|
2006
2077
|
return {
|
|
2007
2078
|
actionId: plan.action.actionId,
|
|
@@ -2287,7 +2358,7 @@ function createTopolo(options) {
|
|
|
2287
2358
|
};
|
|
2288
2359
|
}
|
|
2289
2360
|
|
|
2290
|
-
// node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2361
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.4/node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2291
2362
|
import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
|
|
2292
2363
|
import { existsSync } from "fs";
|
|
2293
2364
|
import { homedir, platform } from "os";
|
|
@@ -3543,8 +3614,9 @@ function registerActionsCommand(program2) {
|
|
|
3543
3614
|
cursor: opts.cursor,
|
|
3544
3615
|
limit: parsePageSize(opts.limit)
|
|
3545
3616
|
});
|
|
3546
|
-
const
|
|
3547
|
-
|
|
3617
|
+
const actions2 = preferExactActionMatches(result.actions, opts.query);
|
|
3618
|
+
const output = opts.detail ? { ...result, actions: actions2 } : { actions: actions2.map(compactActionCatalogEntry), page: result.page };
|
|
3619
|
+
emit(output, mode, () => formatActionRows(actions2, result.page.nextCursor));
|
|
3548
3620
|
} catch (err) {
|
|
3549
3621
|
fail(err, mode);
|
|
3550
3622
|
}
|
|
@@ -3562,7 +3634,7 @@ function registerActionsCommand(program2) {
|
|
|
3562
3634
|
fail(err, mode);
|
|
3563
3635
|
}
|
|
3564
3636
|
});
|
|
3565
|
-
actions.command("call <action>").description("Call a permission-scoped Topolo action").option("-d, --data <json-or-@file>", "JSON action input or @path to a JSON file", "{}").option("--resource-type <type>", "App-local resource alias, such as workspace").option("--resource-id <id>", "Resource id for the selected resource type").option("--confirm", "Acknowledge a mutating action").option("--json", "Output JSON").option("--no-json", "Output human-readable text").action(async (action, opts, command) => {
|
|
3637
|
+
actions.command("call <action>").description("Call a permission-scoped Topolo action").option("-d, --data <json-or-@file>", "JSON action input or @path to a JSON file", "{}").option("--resource-type <type>", "App-local resource alias, such as workspace").option("--resource-id <id>", "Resource id for the selected resource type").option("--confirm", "Acknowledge a mutating action").option("--detail", "Return the complete action response instead of a bounded agent projection").option("--json", "Output JSON").option("--no-json", "Output human-readable text").action(async (action, opts, command) => {
|
|
3566
3638
|
const mode = resolveOutputMode(opts.json ?? command.parent?.opts().json);
|
|
3567
3639
|
try {
|
|
3568
3640
|
const topolo = await buildClient();
|
|
@@ -3575,7 +3647,8 @@ function registerActionsCommand(program2) {
|
|
|
3575
3647
|
confirm: opts.confirm === true,
|
|
3576
3648
|
...resource ? { resource } : {}
|
|
3577
3649
|
});
|
|
3578
|
-
|
|
3650
|
+
const output = detailRequested(opts.detail, command) ? result : compactActionResult(action, result);
|
|
3651
|
+
emit(output, mode, () => JSON.stringify(output, null, 2));
|
|
3579
3652
|
} catch (err) {
|
|
3580
3653
|
fail(err, mode);
|
|
3581
3654
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/cli",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"topoloPublishedVersion": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
|
+
"topoloPublishedVersion": "0.8.6",
|
|
5
5
|
"description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Topolo",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
28
|
-
"@topolo/mcp": "0.11.
|
|
29
|
-
"@topolo/sdk": "0.11.
|
|
28
|
+
"@topolo/mcp": "0.11.4",
|
|
29
|
+
"@topolo/sdk": "0.11.4",
|
|
30
30
|
"commander": "^12.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|