Files
rea/src/contracts/toolContractHelpers.ts
T
morluto 104b1a35b4 fix(contracts): refuse empty address and procedure selectors in the contracts (#10753)
* fix(contracts): refuse empty address and procedure selectors in the contracts

* refactor(cli): project decompile from its contract with --file-offset as an alternative selector (#10756)

* refactor(cli): project search from its contracts with --kind choosing the operation (#10761)

* refactor(cli): project search from its contracts with --kind choosing the operation

* fix(cli): check operation choices' option rules and bind errors to the selected contract

* test(cli): group operation-choice checks in their own block

* refactor(cli): project decompile-all from its contract onto a native session target (#10778)

* refactor(cli): project decompile-all from its contract onto a native session target

* refactor(cli): project native Mach-O, Swift and native UI commands from their contracts

* fix(cli): read search, decompile-all and native utility contracts from their groups so startup stays lazy

* test(cli): drop the empty-selector admission mismatches the contracts now refuse
2026-11-15 22:03:37 +08:00

40 lines
1.1 KiB
TypeScript

import { z } from "zod";
import { jsonValueSchema } from "../domain/jsonValue.js";
import { TOOL_EXAMPLE_OVERRIDES } from "./toolContractExamples.js";
import type { ToolExample } from "./toolContractTypes.js";
export const document = z
.string()
.optional()
.describe(
"The active target's provider document name; use open_binary to switch targets",
);
// A selector names one object, so an empty address or procedure is refused
// at admission rather than reaching a provider.
export const address = z
.string()
.min(1)
.describe(
"A provider-normalized address; default memory uses 0x-prefixed hexadecimal",
);
export const optionalAddress = address.optional();
export const procedure = z
.string()
.min(1)
.describe("The procedure name or address");
const exampleInputSchema = z.record(z.string(), jsonValueSchema);
export const examplesFor = (
name: string,
inputSchema: z.ZodObject,
): readonly ToolExample[] => {
const parsed = inputSchema.parse(TOOL_EXAMPLE_OVERRIDES[name] ?? {});
return [
{
title: `Example ${name.replaceAll("_", " ")} request`,
input: exampleInputSchema.parse(parsed),
},
];
};