Skip to content

Commit 75630fe

Browse files
cramforcepranaygp
andauthored
Type check all the docs and READMEs (#715)
* Type check all the docs and READMEs * mdx DCO Remediation Commit for Malte Ubl <[email protected]> I, Malte Ubl <[email protected]>, hereby add my Signed-off-by to this commit: f61880c Signed-off-by: Malte Ubl <[email protected]> * mdx2 DCO Remediation Commit for Malte Ubl <[email protected]> I, Malte Ubl <[email protected]>, hereby add my Signed-off-by to this commit: 98dd484 Signed-off-by: Malte Ubl <[email protected]> * remove temp AI scripts and fix one docs issue * Fix code review issue * add empty changeset --------- Signed-off-by: Malte Ubl <[email protected]> Co-authored-by: Pranay Prakash <[email protected]>
1 parent a531a74 commit 75630fe

35 files changed

+1808
-15
lines changed

.changeset/bitter-guests-flow.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Docs Typecheck
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "!*"
9+
pull_request:
10+
11+
concurrency:
12+
# Unique group for this workflow and branch
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
docs-typecheck:
18+
name: Documentation Code Samples
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 5
21+
env:
22+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
23+
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
24+
steps:
25+
- name: Checkout Repo
26+
uses: actions/checkout@v4
27+
28+
- name: Setup pnpm
29+
uses: pnpm/action-setup@v3
30+
with:
31+
version: 10.14.0
32+
33+
- name: Setup Node.js 22.x
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 22.x
37+
cache: "pnpm"
38+
39+
- name: Install Dependencies
40+
run: pnpm install --frozen-lockfile
41+
42+
- name: Build packages
43+
run: pnpm build
44+
45+
- name: Type-check documentation code samples
46+
run: pnpm test:docs

docs/content/docs/ai/human-in-the-loop.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const bookingApprovalHook = defineHook({
7171

7272
Create a tool that creates a hook instance using the tool call ID as the token. The UI will use this ID to submit the approval.
7373

74+
{/* @skip-typecheck: incomplete code sample */}
7475
```typescript title="workflows/chat/steps/tools.ts" lineNumbers
7576
import { z } from "zod";
7677

@@ -236,6 +237,7 @@ export function BookingApproval({ toolCallId, input, output }: BookingApprovalPr
236237

237238
Use the component we just created to render the tool call and approval controls in your chat interface:
238239

240+
{/* @skip-typecheck: incomplete code sample */}
239241
```typescript title="app/page.tsx" lineNumbers
240242
// ... existing imports ...
241243
import { BookingApproval } from "@/components/booking-approval";

docs/content/docs/ai/index.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ OPENAI_API_KEY=...
7878

7979
Then modify your API endpoint to use the OpenAI provider:
8080

81+
{/* @skip-typecheck: incomplete code sample */}
8182
```typescript title="app/api/chat/route.ts" lineNumbers
8283
// ...
8384
import { openai } from "@workflow/ai/openai"; // [!code highlight]
@@ -240,6 +241,7 @@ export default withWorkflow(nextConfig);
240241
241242
Move the agent logic into a separate function, which will serve as our workflow definition.
242243
244+
{/* @skip-typecheck: Shows two mutually exclusive model options */}
243245
```typescript title="workflows/chat/workflow.ts" lineNumbers
244246
import { DurableAgent } from "@workflow/ai/agent"; // [!code highlight]
245247
import { getWritable } from "workflow"; // [!code highlight]
@@ -313,6 +315,7 @@ Key changes:
313315
314316
Mark all tool definitions with `"use step"` to make them durable. This enables automatic retries and observability for each tool call:
315317
318+
{/* @skip-typecheck: incomplete code sample */}
316319
```typescript title="workflows/chat/steps/tools.ts​" lineNumbers
317320
// ...
318321

docs/content/docs/ai/resumable-streams.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Let's add stream resumption to our Flight Booking Agent that we build in the [Bu
2020

2121
Modify your chat endpoint to include the workflow run ID in a response header. The Run ID uniquely identifies the run's stream, so it allows the client to know which stream to reconnect to.
2222

23+
{/* @skip-typecheck: incomplete code sample */}
2324
```typescript title="app/api/chat/route.ts" lineNumbers
2425
// ... imports ...
2526

docs/content/docs/ai/sleep-and-delays.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const flightBookingTools = {
6363

6464
To round it off, extend the UI to display the tool call status. This can be done either by displaying the tool call information directly, or by emitting custom data parts to the stream (see [Streaming Updates from Tools](/docs/ai/streaming-updates-from-tools) for more details). In this case, since there aren't any fine-grained progress updates to show, we'll just display the tool call information directly:
6565

66+
{/* @skip-typecheck: incomplete code sample */}
6667
```typescript title="app/page.tsx" lineNumbers
6768
export default function ChatPage() {
6869

@@ -194,6 +195,8 @@ export async function pollForResult(jobId: string) {
194195
async function checkJobStatus(jobId: string) {
195196
"use step";
196197
// Check job status...
198+
const response = await fetch(`/api/jobs/${jobId}`);
199+
return response.json();
197200
}
198201
```
199202

docs/content/docs/ai/streaming-updates-from-tools.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ The `type` field must be a string starting with `data-` followed by your custom
3838

3939
Use [`getWritable()`](/docs/api-reference/workflow/get-writable) inside a step function to get a handle to the stream. This is the same stream that the LLM and other tools calls are writing to, so we can inject out own data packets directly.
4040

41+
{/* @skip-typecheck: incomplete code sample */}
4142
```typescript title="workflows/chat/steps/tools.ts" lineNumbers
4243
import { getWritable } from "workflow"; // [!code highlight]
4344
import type { UIMessageChunk } from "ai";
@@ -88,6 +89,7 @@ Key points:
8889

8990
Update your chat component to detect and render the custom data parts. Data parts are stored in the message's `parts` array alongside text and tool invocation parts:
9091

92+
{/* @skip-typecheck: incomplete code sample */}
9193
```typescript title="app/page.tsx" lineNumbers
9294
{message.parts.map((part, partIndex) => {
9395
// Render text parts

docs/content/docs/api-reference/workflow/get-writable.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,13 @@ async function streamTextStep(
274274
}
275275

276276
reader.releaseLock();
277-
278-
// Close the stream
279-
writer.close();
280277
writer.releaseLock();
278+
279+
// Return the result for the workflow to use
280+
return {
281+
messages: await result.response.then((r) => r.messages),
282+
finishReason: await result.finishReason,
283+
};
281284
}
282285

283286
async function endStream(writable: WritableStream<UIMessageChunk>) {

docs/content/docs/deploying/world/local-world.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The queue automatically detects your development server's port and adjusts the q
4747

4848
The local world provides a simple authentication implementation since no authentication is required or enforced in local development.
4949

50+
{/* @skip-typecheck: incomplete code sample */}
5051
```typescript
5152
getAuthHeaders(): Promise<Record<string, string>> {
5253
return Promise.resolve({});
@@ -67,6 +68,7 @@ export WORKFLOW_LOCAL_DATA_DIR=./custom-workflow-data
6768

6869
**Programmatically:**
6970

71+
{/* @skip-typecheck: incomplete code sample */}
7072
```typescript
7173
import { createLocalWorld } from "@workflow/world-local";
7274

@@ -79,6 +81,7 @@ By default, the local world **automatically detects** which port your applicatio
7981

8082
**Auto-detection example** (recommended):
8183

84+
{/* @skip-typecheck: incomplete code sample */}
8285
```typescript
8386
import { createLocalWorld } from "@workflow/world-local";
8487

@@ -92,6 +95,7 @@ If auto-detection fails, the world will fall back to the `PORT` environment vari
9295

9396
You can override the auto-detected port by specifying it explicitly:
9497

98+
{/* @skip-typecheck: incomplete code sample */}
9599
```typescript
96100
import { createLocalWorld } from "@workflow/world-local";
97101

@@ -116,6 +120,7 @@ export WORKFLOW_LOCAL_BASE_URL=https://local.example.com:3000
116120

117121
**Programmatically:**
118122

123+
{/* @skip-typecheck: incomplete code sample */}
119124
```typescript
120125
import { createLocalWorld } from "@workflow/world-local";
121126

@@ -207,6 +212,7 @@ For production deployments, use the [Vercel World](/docs/deploying/world/vercel-
207212

208213
Creates a local world instance:
209214

215+
{/* @skip-typecheck: incomplete code sample */}
210216
```typescript
211217
function createLocalWorld(
212218
args?: Partial<{
@@ -230,6 +236,7 @@ function createLocalWorld(
230236

231237
**Examples:**
232238

239+
{/* @skip-typecheck: incomplete code sample */}
233240
```typescript
234241
import { createLocalWorld } from "@workflow/world-local";
235242

docs/content/docs/deploying/world/vercel-world.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ The Vercel world implements security best practices:
135135

136136
Creates a Vercel world instance:
137137

138+
{/* @skip-typecheck: incomplete code sample */}
138139
```typescript
139140
function createVercelWorld(
140141
config?: APIConfig
@@ -156,6 +157,7 @@ function createVercelWorld(
156157

157158
**Example:**
158159

160+
{/* @skip-typecheck: incomplete code sample */}
159161
```typescript
160162
import { createVercelWorld } from "@workflow/world-vercel";
161163

0 commit comments

Comments
 (0)