Documentation
¶
Overview ¶
Package tsrender produces the TypeScript .d.ts blocks that Airlock embeds into the agent system prompt: typed signatures for registered tools, and per-server `declare const mcp_{slug}: {...}` namespaces for MCP tools.
The package is split out from agentsdk's main API surface so builders (agentsdk consumers) don't see these types in their import autocomplete or godoc — agentsdk's main package stays focused on the builder API (RegisterTool, MCPHandle, etc.). The rendering here is shared between agentsdk's tests and the airlock module's prompt template; both import this package directly.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderMCPNamespace ¶
func RenderMCPNamespace(slug string, tools []MCPToolRender) string
RenderMCPNamespace emits a typed `declare const mcp_{slug}: { ... };` block describing each discovered MCP tool as a method on the namespace object. Mirrors the JS binding shape installed by agentsdk's vm.go so the LLM's call site and the runtime stay in lockstep.
declare const mcp_github: {
/** Search for GitHub repositories. */
search_repos(args: { query: string }): unknown;
...
};
func RenderToolDecls ¶
func RenderToolDecls(tools []ToolRender) string
RenderToolDecls emits a TypeScript .d.ts-style block describing each tool. Output is suitable for direct inclusion in an LLM prompt.
Types ¶
type MCPToolRender ¶
type MCPToolRender struct {
Name string
Description string
InputSchema json.RawMessage
}
MCPToolRender carries the bits Airlock has cached about an MCP tool. Only the input shape is typed — MCP doesn't define an output schema, so the rendered return type is always `unknown` (caller does runtime parsing).
type ToolRender ¶
type ToolRender struct {
Name string
Description string
InputSchema json.RawMessage
OutputSchema json.RawMessage
InputExamples []json.RawMessage
}
ToolRender is the data RenderToolDecls consumes. Airlock builds this from the hydrated DB/sync payload; the agent assembles it from the registered-tool schemas in tests. Both paths go through the same renderer so the LLM sees one format.