TypeScript quickstart
A source-correct, no-network first success in TypeScript.
Start with an operation that needs no model, network, identity seed, or wallet. This verifies the actual TypeScript message API before adding a provider or tools.
Prerequisites
The package manifest requires Node.js 20 or later. Node.js 24 is used for these docs. Packages expose ES modules and declaration files from their build output.
Use a source checkout
The paths below assume the Forge checkout is beside your application. Adjust the local path to your workspace. Registry publication is not inferred from the package name.
cd forge/forge-ts
npm install
npm run buildFirst success
Save this in your application's entry point after resolving @forge-sdk/core.
import { Role, createTextMessage, getTextContent } from '@forge-sdk/core';
const message = createTextMessage(Role.User, 'Hello, Forge');
if (getTextContent(message) !== 'Hello, Forge') {
throw new Error('Unexpected message content');
}
console.log(getTextContent(message));Expected output: Hello, Forge. This checks message construction and text extraction only; it does not call an LLM.
Add an agent
AgentConfig is an interface, not a class. Pass { name, model } to new ToolLoopAgent. Call await agent.initialize() before run(), read output.finalText, and terminate the instance when finished. agentDid is optional. The default approval handler is AutoApprove; select an explicit policy before exposing tools with side effects.
Verify the source
The example uses declarations from the message declarations. Package metadata comes from forge-ts/package.json.