| @@ -76,11 +76,7 @@ export async function invokeTool(ctx: ActionCtx, task: TaskRecord, call: ToolCal · 75 unmodified lines |
| 76 | 76 | ); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | | − const payload = (input && typeof input === "object" && !Array.isArray(input)) |
| 80 | | − ? (input as Record<string, unknown>) |
| 81 | | − : (typeof input === "string") |
| 82 | | − ? ({ query: input } satisfies Record<string, unknown>) |
| 83 | | − : {}; |
| 79 | + const payload = input && typeof input === "object" ? (input as Record<string, unknown>) : {}; |
| 84 | 80 | const isAllowed = (path: string, approval: ToolDefinition["approval"]) => |
| 85 | 81 | getDecisionForContext( |
| 86 | 82 | { path, approval, description: "", run: async () => null } as ToolDefinition, |
| @@ -88,22 +84,9 @@ export async function invokeTool(ctx: ActionCtx, task: TaskRecord, call: ToolCal · 1 unmodified line |
| 88 | 84 | typedPolicies, |
| 89 | 85 | ) !== "deny"; |
| 90 | 86 | |
| 91 | | − const formatSignature = (inputHint: string | undefined, outputHint: string | undefined) => { |
| 92 | | − const args = (inputHint && inputHint.trim().length > 0) ? inputHint.trim() : "{}"; |
| 93 | | − const out = (outputHint && outputHint.trim().length > 0) ? outputHint.trim() : "unknown"; |
| 94 | | − return `(input: ${args}): Promise<${out}>`; |
| 95 | | − }; |
| 96 | | − |
| 97 | | − const buildExampleCall = (path: string, previewKeys?: string[]) => { |
| 98 | | − const keys = Array.isArray(previewKeys) ? previewKeys : []; |
| 99 | | − if (keys.length === 0) { |
| 100 | | − return `await tools.${path}({});`; |
| 101 | | − } |
| 102 | | − const snippet = keys |
| 103 | | − .slice(0, 5) |
| 104 | | − .map((key) => `${key}: ...`) |
| 105 | | − .join(", "); |
| 106 | | − return `await tools.${path}({ ${snippet} });`; |
| 87 | + const normalizeHint = (value: unknown, fallback: string) => { |
| 88 | + const str = typeof value === "string" ? value.trim() : ""; |
| 89 | + return str.length > 0 ? str : fallback; |
| 107 | 90 | }; |
| 108 | 91 | |
| 109 | 92 | if (toolPath === "catalog.namespaces") { |
| @@ -145,19 +128,12 @@ export async function invokeTool(ctx: ActionCtx, task: TaskRecord, call: ToolCal · 35 unmodified lines |
| 145 | 128 | const preferredPath = entry.preferredPath ?? entry.path; |
| 146 | 129 | return { |
| 147 | 130 | path: preferredPath, |
| 148 | | − aliases: entry.aliases ?? [], |
| 149 | 131 | source: entry.source, |
| 150 | 132 | approval: entry.approval, |
| 151 | 133 | description: entry.description, |
| 152 | | − signatureInfo: { |
| 153 | | − input: entry.displayInput, |
| 154 | | − output: entry.displayOutput, |
| 155 | | − requiredKeys: entry.requiredInputKeys ?? [], |
| 156 | | − previewKeys: entry.previewInputKeys ?? [], |
| 157 | | − }, |
| 158 | | − signatureText: formatSignature(entry.displayInput, entry.displayOutput), |
| 159 | | − canonicalSignature: formatSignature(entry.displayInput, entry.displayOutput), |
| 160 | | − exampleCall: buildExampleCall(preferredPath, entry.previewInputKeys), |
| 134 | + input: normalizeHint(entry.displayInput, "{}"), |
| 135 | + output: normalizeHint(entry.displayOutput, "unknown"), |
| 136 | + requiredKeys: entry.requiredInputKeys ?? [], |
| 161 | 137 | }; |
| 162 | 138 | }); |
| 163 | 139 | |
| @@ -184,19 +160,12 @@ export async function invokeTool(ctx: ActionCtx, task: TaskRecord, call: ToolCal · 20 unmodified lines |
| 184 | 160 | const description = compact ? String(entry.description ?? "").split("\n")[0] : entry.description; |
| 185 | 161 | return { |
| 186 | 162 | path: preferredPath, |
| 187 | | − aliases: entry.aliases ?? [], |
| 188 | 163 | source: entry.source, |
| 189 | 164 | approval: entry.approval, |
| 190 | 165 | description, |
| 191 | | − signature: formatSignature(entry.displayInput, entry.displayOutput), |
| 192 | | − canonicalSignature: formatSignature(entry.displayInput, entry.displayOutput), |
| 193 | | − signatureInfo: { |
| 194 | | − input: entry.displayInput, |
| 195 | | − output: entry.displayOutput, |
| 196 | | − requiredKeys: entry.requiredInputKeys ?? [], |
| 197 | | − previewKeys: entry.previewInputKeys ?? [], |
| 198 | | − }, |
| 199 | | − exampleCall: buildExampleCall(preferredPath, entry.previewInputKeys), |
| 166 | + input: normalizeHint(entry.displayInput, "{}"), |
| 167 | + output: normalizeHint(entry.displayOutput, "unknown"), |
| 168 | + requiredKeys: entry.requiredInputKeys ?? [], |
| 200 | 169 | }; |
| 201 | 170 | }); |
| 202 | 171 | |