hostctl 0.1.55 → 0.1.57
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/bin/hostctl.js +147 -7
- package/dist/bin/hostctl.js.map +1 -1
- package/dist/index.js +147 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/hostctl.js
CHANGED
|
@@ -3981,7 +3981,7 @@ var ParamMap = class _ParamMap {
|
|
|
3981
3981
|
import * as z from "zod";
|
|
3982
3982
|
|
|
3983
3983
|
// src/version.ts
|
|
3984
|
-
var version = "0.1.
|
|
3984
|
+
var version = "0.1.57";
|
|
3985
3985
|
|
|
3986
3986
|
// src/app.ts
|
|
3987
3987
|
import { retryUntilDefined } from "ts-retry";
|
|
@@ -33906,8 +33906,8 @@ function renderTaskRows(rows, {
|
|
|
33906
33906
|
name: r.name,
|
|
33907
33907
|
description: r.description,
|
|
33908
33908
|
module: r.module,
|
|
33909
|
-
inputSchema:
|
|
33910
|
-
outputSchema:
|
|
33909
|
+
inputSchema: schemaToDescriptor(r.inputSchema),
|
|
33910
|
+
outputSchema: schemaToDescriptor(r.outputSchema),
|
|
33911
33911
|
schemaSource: r.schemaSource
|
|
33912
33912
|
}));
|
|
33913
33913
|
console.log(JSON.stringify(sanitized, null, 2));
|
|
@@ -33948,9 +33948,12 @@ function summarizeType(val) {
|
|
|
33948
33948
|
case "optional":
|
|
33949
33949
|
case "ZodNullable":
|
|
33950
33950
|
case "nullable":
|
|
33951
|
+
case "ZodDefault":
|
|
33952
|
+
case "default":
|
|
33951
33953
|
return summarizeType(def.innerType || def.type);
|
|
33952
33954
|
case "ZodEffects":
|
|
33953
|
-
|
|
33955
|
+
case "pipe":
|
|
33956
|
+
return summarizeType(def.schema || def.in);
|
|
33954
33957
|
case "ZodString":
|
|
33955
33958
|
case "string":
|
|
33956
33959
|
return { type: "string", desc };
|
|
@@ -33973,8 +33976,11 @@ function summarizeType(val) {
|
|
|
33973
33976
|
return types.length ? { type: types.join(" | "), desc } : {};
|
|
33974
33977
|
}
|
|
33975
33978
|
case "ZodLiteral":
|
|
33976
|
-
case "literal":
|
|
33977
|
-
|
|
33979
|
+
case "literal": {
|
|
33980
|
+
const values3 = Array.isArray(def?.values) ? def.values : def?.value !== void 0 ? [def.value] : [];
|
|
33981
|
+
const value = values3.length ? values3[0] : void 0;
|
|
33982
|
+
return { type: value !== void 0 ? JSON.stringify(value) : void 0, desc };
|
|
33983
|
+
}
|
|
33978
33984
|
case "ZodObject":
|
|
33979
33985
|
case "object":
|
|
33980
33986
|
return { type: "object", desc };
|
|
@@ -33982,6 +33988,140 @@ function summarizeType(val) {
|
|
|
33982
33988
|
return { type: String(tn).replace(/^Zod/, "").toLowerCase(), desc };
|
|
33983
33989
|
}
|
|
33984
33990
|
}
|
|
33991
|
+
function schemaToDescriptor(schema) {
|
|
33992
|
+
if (!schema) return null;
|
|
33993
|
+
const { schema: base, nullable } = unwrapSchema(schema);
|
|
33994
|
+
const def = base?._def ?? base?.def;
|
|
33995
|
+
const typeName = def?.typeName || def?.type;
|
|
33996
|
+
const description = def?.description || base?.description;
|
|
33997
|
+
let descriptor = {};
|
|
33998
|
+
switch (typeName) {
|
|
33999
|
+
case "ZodString":
|
|
34000
|
+
case "string":
|
|
34001
|
+
descriptor.type = "string";
|
|
34002
|
+
break;
|
|
34003
|
+
case "ZodNumber":
|
|
34004
|
+
case "number":
|
|
34005
|
+
descriptor.type = "number";
|
|
34006
|
+
break;
|
|
34007
|
+
case "ZodBoolean":
|
|
34008
|
+
case "boolean":
|
|
34009
|
+
descriptor.type = "boolean";
|
|
34010
|
+
break;
|
|
34011
|
+
case "ZodArray":
|
|
34012
|
+
case "array": {
|
|
34013
|
+
const inner = def?.element ?? def?.type;
|
|
34014
|
+
descriptor.type = "array";
|
|
34015
|
+
descriptor.items = schemaToDescriptor(inner);
|
|
34016
|
+
break;
|
|
34017
|
+
}
|
|
34018
|
+
case "ZodObject":
|
|
34019
|
+
case "object": {
|
|
34020
|
+
const shapeSource = def?.shape || def?.shape_;
|
|
34021
|
+
const shape = shapeSource && typeof shapeSource === "function" ? shapeSource.call(def) : shapeSource;
|
|
34022
|
+
const properties = {};
|
|
34023
|
+
const required = [];
|
|
34024
|
+
if (shape && typeof shape === "object") {
|
|
34025
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
34026
|
+
const { schema: fieldSchema, optional, nullable: fieldNullable } = unwrapSchema(value);
|
|
34027
|
+
const fieldDescriptor = schemaToDescriptor(fieldSchema) ?? {};
|
|
34028
|
+
if (fieldNullable) {
|
|
34029
|
+
fieldDescriptor.nullable = true;
|
|
34030
|
+
}
|
|
34031
|
+
properties[key] = fieldDescriptor;
|
|
34032
|
+
if (!optional) {
|
|
34033
|
+
required.push(key);
|
|
34034
|
+
}
|
|
34035
|
+
}
|
|
34036
|
+
}
|
|
34037
|
+
descriptor.type = "object";
|
|
34038
|
+
descriptor.properties = properties;
|
|
34039
|
+
descriptor.required = required.length ? required : void 0;
|
|
34040
|
+
break;
|
|
34041
|
+
}
|
|
34042
|
+
case "ZodUnion":
|
|
34043
|
+
case "union": {
|
|
34044
|
+
const options = def?.options ?? [];
|
|
34045
|
+
descriptor.anyOf = options.map((option) => schemaToDescriptor(option)).filter(Boolean);
|
|
34046
|
+
break;
|
|
34047
|
+
}
|
|
34048
|
+
case "ZodLiteral":
|
|
34049
|
+
case "literal": {
|
|
34050
|
+
const values3 = Array.isArray(def?.values) ? def.values : def?.value !== void 0 ? [def.value] : [];
|
|
34051
|
+
const sample = values3.length ? values3[0] : void 0;
|
|
34052
|
+
descriptor.type = sample === null ? "null" : typeof sample;
|
|
34053
|
+
descriptor.enum = values3;
|
|
34054
|
+
break;
|
|
34055
|
+
}
|
|
34056
|
+
case "ZodEnum":
|
|
34057
|
+
case "enum":
|
|
34058
|
+
const enumValues = Array.isArray(def?.values) ? def.values : Object.values(def?.entries ?? {});
|
|
34059
|
+
descriptor.enum = enumValues;
|
|
34060
|
+
if (enumValues.length) {
|
|
34061
|
+
const hasNumber = enumValues.some((value) => typeof value === "number");
|
|
34062
|
+
const hasString = enumValues.some((value) => typeof value === "string");
|
|
34063
|
+
descriptor.type = hasNumber && !hasString ? "number" : "string";
|
|
34064
|
+
} else {
|
|
34065
|
+
descriptor.type = "string";
|
|
34066
|
+
}
|
|
34067
|
+
break;
|
|
34068
|
+
case "ZodNativeEnum":
|
|
34069
|
+
case "nativeenum": {
|
|
34070
|
+
const values3 = Array.isArray(def?.values) ? def.values : Object.values(def?.entries ?? def?.values ?? {});
|
|
34071
|
+
descriptor.type = values3.every((value) => typeof value === "number") ? "number" : "string";
|
|
34072
|
+
descriptor.enum = values3;
|
|
34073
|
+
break;
|
|
34074
|
+
}
|
|
34075
|
+
default:
|
|
34076
|
+
descriptor.type = typeName ? String(typeName).replace(/^Zod/, "").toLowerCase() : "unknown";
|
|
34077
|
+
break;
|
|
34078
|
+
}
|
|
34079
|
+
if (description) {
|
|
34080
|
+
descriptor.description = description;
|
|
34081
|
+
}
|
|
34082
|
+
if (nullable) {
|
|
34083
|
+
descriptor.nullable = true;
|
|
34084
|
+
}
|
|
34085
|
+
return descriptor;
|
|
34086
|
+
}
|
|
34087
|
+
function unwrapSchema(schema) {
|
|
34088
|
+
let current = schema;
|
|
34089
|
+
let optional = false;
|
|
34090
|
+
let nullable = false;
|
|
34091
|
+
while (current) {
|
|
34092
|
+
const def = current?._def ?? current?.def;
|
|
34093
|
+
const typeName = def?.typeName || def?.type;
|
|
34094
|
+
if (typeName === "ZodOptional" || typeName === "optional") {
|
|
34095
|
+
optional = true;
|
|
34096
|
+
current = def?.innerType ?? def?.type;
|
|
34097
|
+
continue;
|
|
34098
|
+
}
|
|
34099
|
+
if (typeName === "ZodNullable" || typeName === "nullable") {
|
|
34100
|
+
nullable = true;
|
|
34101
|
+
current = def?.innerType ?? def?.type;
|
|
34102
|
+
continue;
|
|
34103
|
+
}
|
|
34104
|
+
if (typeName === "ZodDefault" || typeName === "default") {
|
|
34105
|
+
optional = true;
|
|
34106
|
+
current = def?.innerType ?? def?.type;
|
|
34107
|
+
continue;
|
|
34108
|
+
}
|
|
34109
|
+
if (typeName === "ZodEffects" || typeName === "effects") {
|
|
34110
|
+
current = def?.schema;
|
|
34111
|
+
continue;
|
|
34112
|
+
}
|
|
34113
|
+
if (typeName === "pipe") {
|
|
34114
|
+
current = def?.in ?? def?.schema;
|
|
34115
|
+
continue;
|
|
34116
|
+
}
|
|
34117
|
+
if (typeName === "transform") {
|
|
34118
|
+
current = def?.schema ?? def?.in;
|
|
34119
|
+
continue;
|
|
34120
|
+
}
|
|
34121
|
+
break;
|
|
34122
|
+
}
|
|
34123
|
+
return { schema: current, optional, nullable };
|
|
34124
|
+
}
|
|
33985
34125
|
function formatSchemaLines(schema) {
|
|
33986
34126
|
if (!schema) return ["none"];
|
|
33987
34127
|
const def = schema._def ?? schema.def;
|
|
@@ -33994,7 +34134,7 @@ function formatSchemaLines(schema) {
|
|
|
33994
34134
|
const tn = anyVal?._def?.typeName || anyVal?.def?.type;
|
|
33995
34135
|
const typeString = summary2.type || (tn ? String(tn).replace(/^Zod/, "").toLowerCase() : void 0);
|
|
33996
34136
|
const desc = summary2.desc;
|
|
33997
|
-
const optional =
|
|
34137
|
+
const optional = ["ZodOptional", "optional", "ZodNullable", "nullable", "ZodDefault", "default"].includes(tn);
|
|
33998
34138
|
const typePart = typeString ? `: ${typeString}` : "";
|
|
33999
34139
|
const descPart = desc ? ` - ${desc}` : "";
|
|
34000
34140
|
return `- ${key}${optional ? "?" : ""}${typePart}${descPart}`;
|