@topolo/cli 0.8.4 → 0.8.5
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 +72 -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.3/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,75 @@ 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 = 4;
|
|
2014
|
+
var ACTION_RESULT_MAX_KEYS = 16;
|
|
2015
|
+
var ACTION_RESULT_MAX_ITEMS = 5;
|
|
2016
|
+
var ACTION_RESULT_MAX_SCALARS = 120;
|
|
2017
|
+
var ACTION_RESULT_MAX_STRING = 512;
|
|
2018
|
+
function resultKeyPriority(key) {
|
|
2019
|
+
if (/^(id|requestId|status|state|url|slug|name|title|version)$/i.test(key)) return 0;
|
|
2020
|
+
if (/(Id|Ids|Url|Uri|Status|State|Count|Total|Version|CreatedAt|UpdatedAt)$/i.test(key)) return 1;
|
|
2021
|
+
return 2;
|
|
2022
|
+
}
|
|
2023
|
+
function compactResultValue(value, depth, budget) {
|
|
2024
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") {
|
|
2025
|
+
budget.scalars += 1;
|
|
2026
|
+
return value;
|
|
2027
|
+
}
|
|
2028
|
+
if (typeof value === "string") {
|
|
2029
|
+
budget.scalars += 1;
|
|
2030
|
+
if (value.length <= ACTION_RESULT_MAX_STRING) return value;
|
|
2031
|
+
return `${value.slice(0, ACTION_RESULT_MAX_STRING)}\u2026 (${value.length} chars)`;
|
|
2032
|
+
}
|
|
2033
|
+
if (depth >= ACTION_RESULT_MAX_DEPTH || budget.scalars >= ACTION_RESULT_MAX_SCALARS) {
|
|
2034
|
+
return Array.isArray(value) ? { count: value.length, omitted: true } : { omitted: true };
|
|
2035
|
+
}
|
|
2036
|
+
if (Array.isArray(value)) {
|
|
2037
|
+
const items = value.slice(0, ACTION_RESULT_MAX_ITEMS).map((item) => compactResultValue(item, depth + 1, budget));
|
|
2038
|
+
return value.length > ACTION_RESULT_MAX_ITEMS ? { count: value.length, items, omittedItems: value.length - ACTION_RESULT_MAX_ITEMS } : items;
|
|
2039
|
+
}
|
|
2040
|
+
if (typeof value === "object") {
|
|
2041
|
+
const record = value;
|
|
2042
|
+
const allKeys = Object.keys(record);
|
|
2043
|
+
const keys = allKeys.sort((left, right) => resultKeyPriority(left) - resultKeyPriority(right)).slice(0, ACTION_RESULT_MAX_KEYS);
|
|
2044
|
+
const compact = Object.fromEntries(keys.map((key) => [key, compactResultValue(record[key], depth + 1, budget)]));
|
|
2045
|
+
if (allKeys.length > keys.length) compact["_omittedKeys"] = allKeys.length - keys.length;
|
|
2046
|
+
return compact;
|
|
2047
|
+
}
|
|
2048
|
+
budget.scalars += 1;
|
|
2049
|
+
return String(value);
|
|
2050
|
+
}
|
|
2051
|
+
function compactActionResult(actionId, result) {
|
|
2052
|
+
let normalized = result;
|
|
2053
|
+
if (typeof result === "string") {
|
|
2054
|
+
try {
|
|
2055
|
+
normalized = JSON.parse(result);
|
|
2056
|
+
} catch {
|
|
2057
|
+
normalized = result;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
return { actionId, result: compactResultValue(normalized, 0, { scalars: 0 }) };
|
|
2061
|
+
}
|
|
2062
|
+
function preferExactActionMatches(actions, query) {
|
|
2063
|
+
const expected = query?.trim().toLowerCase();
|
|
2064
|
+
if (!expected) return actions;
|
|
2065
|
+
const exact = actions.filter((action) => [action.actionId, action.name, action.toolName].some((candidate) => candidate?.trim().toLowerCase() === expected));
|
|
2066
|
+
return exact.length ? exact : actions;
|
|
2067
|
+
}
|
|
2005
2068
|
function compactActionPlan(plan) {
|
|
2006
2069
|
return {
|
|
2007
2070
|
actionId: plan.action.actionId,
|
|
@@ -2287,7 +2350,7 @@ function createTopolo(options) {
|
|
|
2287
2350
|
};
|
|
2288
2351
|
}
|
|
2289
2352
|
|
|
2290
|
-
// node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2353
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.3/node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2291
2354
|
import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
|
|
2292
2355
|
import { existsSync } from "fs";
|
|
2293
2356
|
import { homedir, platform } from "os";
|
|
@@ -3543,8 +3606,9 @@ function registerActionsCommand(program2) {
|
|
|
3543
3606
|
cursor: opts.cursor,
|
|
3544
3607
|
limit: parsePageSize(opts.limit)
|
|
3545
3608
|
});
|
|
3546
|
-
const
|
|
3547
|
-
|
|
3609
|
+
const actions2 = preferExactActionMatches(result.actions, opts.query);
|
|
3610
|
+
const output = opts.detail ? { ...result, actions: actions2 } : { actions: actions2.map(compactActionCatalogEntry), page: result.page };
|
|
3611
|
+
emit(output, mode, () => formatActionRows(actions2, result.page.nextCursor));
|
|
3548
3612
|
} catch (err) {
|
|
3549
3613
|
fail(err, mode);
|
|
3550
3614
|
}
|
|
@@ -3562,7 +3626,7 @@ function registerActionsCommand(program2) {
|
|
|
3562
3626
|
fail(err, mode);
|
|
3563
3627
|
}
|
|
3564
3628
|
});
|
|
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) => {
|
|
3629
|
+
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
3630
|
const mode = resolveOutputMode(opts.json ?? command.parent?.opts().json);
|
|
3567
3631
|
try {
|
|
3568
3632
|
const topolo = await buildClient();
|
|
@@ -3575,7 +3639,8 @@ function registerActionsCommand(program2) {
|
|
|
3575
3639
|
confirm: opts.confirm === true,
|
|
3576
3640
|
...resource ? { resource } : {}
|
|
3577
3641
|
});
|
|
3578
|
-
|
|
3642
|
+
const output = detailRequested(opts.detail, command) ? result : compactActionResult(action, result);
|
|
3643
|
+
emit(output, mode, () => JSON.stringify(output, null, 2));
|
|
3579
3644
|
} catch (err) {
|
|
3580
3645
|
fail(err, mode);
|
|
3581
3646
|
}
|
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.5",
|
|
4
|
+
"topoloPublishedVersion": "0.8.5",
|
|
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.3",
|
|
29
|
+
"@topolo/sdk": "0.11.3",
|
|
30
30
|
"commander": "^12.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|