import { generateText, tool } from "@stacknet/sdk";
import { z } from "zod";
const result = await generateText({
model: geoff("magma"),
prompt: "Find all critical vulnerabilities in our infrastructure and create tickets for them",
tools: {
scanInfrastructure: tool({
description: "Run a security scan against cloud infrastructure and return findings",
inputSchema: z.object({
target: z.enum(["aws", "gcp", "azure", "all"]).describe("Cloud provider to scan"),
severity: z.enum(["critical", "high", "medium", "all"]).describe("Minimum severity level"),
}),
execute: async ({ target, severity }) => {
const findings = await securityScanner.scan({ provider: target, minSeverity: severity });
return findings; // [{ id, title, severity, resource, remediation }]
},
}),
createTicket: tool({
description: "Create a ticket in the issue tracker for a security finding",
inputSchema: z.object({
title: z.string(),
description: z.string(),
priority: z.enum(["p0", "p1", "p2"]),
assignee: z.string().optional(),
}),
execute: async ({ title, description, priority, assignee }) => {
const ticket = await issueTracker.create({ title, description, priority, assignee });
return { ticketId: ticket.id, url: ticket.url };
},
}),
notifyTeam: tool({
description: "Send a Slack notification to the security team channel",
inputSchema: z.object({
channel: z.string().describe("Slack channel name"),
message: z.string(),
}),
execute: async ({ channel, message }) => {
await slack.postMessage({ channel, text: message });
return { sent: true, channel };
},
}),
},
maxSteps: 10, // Allow multi-step tool use
});
console.log(result.text); // Summary of what was done
console.log(result.toolCalls); // All tool invocations
console.log(result.toolResults); // Results from each tool